; The CHR ROM is in in non-standard compressed format.
; A standard CHR ROM slot is a 16-byte, 4 bpp bitmap.
; Here, we store two 8x8, 2 bpp bitmaps in the same slot
; to represent a 8x16 ASCII font. This allows us to fit
; the entire ASCII font into 1520 bytes for extreme
; compression, which can be padding to 2048 KiB pages, and
; be repeated n times in the CHR ROM. This allows a fail-safe
; ROM monitor to always show characters even with wrong mapper
; settings.
;
; When we draw a character to the screen, we set two 8x8
; vertical in the nametable in the vertical direction, both
; bytes are set with the same CHR ROM index. The attribute
; table is used to force the PPU to display two distinct
; bitmaps for the whole font.
;
; At the top of a font, the attribute table select palette 0
; which makes the second bitplane invisible, at the bottom of
; a font, the attribute table uses palette 1 which makes the
; first bitplane invisible.
;
; Due to the limited granularity of the attribute table,
; two blank lines must appear between each line of text.
ldx #VAL_PPU_MASK_RENDER_OFF
stx REG_PPU_MASK
ppu_set_address $23C0
ppu_fill_attribute_table \
1 << BIT_PPU_ATTR_BOTTOM_LEFT | \
1 << BIT_PPU_ATTR_BOTTOM_RIGHT | \
0 << BIT_PPU_ATTR_TOP_LEFT | \
0 << BIT_PPU_ATTR_TOP_RIGHT
; Palette #0, this "truth table" masks bitplane 1's data,
; because color 0b10 (index 2) is set to black.
ppu_set_palette 0, 0, $1F
ppu_set_palette 0, 1, $30
ppu_set_palette 0, 2, $1F
ppu_set_palette 0, 3, $30
; Palette #1, this "truth table" masks bitplane 1's data,
; because color 0b01 (index 1) is set to black.
ppu_set_palette 1, 0, $1F
ppu_set_palette 1, 1, $1F
ppu_set_palette 1, 2, $30
ppu_set_palette 1, 3, $30