Prev: A9A0 Up: Map Next: A9E4
A9AD: Plot tile
This plots an exterior tile then advances DE' to the next column.
Input
A Tile index
DE' Pointer into the 24x17x8 screen buffer ("window_buf")
HL' Pointer into the 7x5 supertile indices buffer ("map_buf") (used to select the correct tile group)
plot_tile A9AD EXX Unbank input registers
A9AE EX AF,AF' Bank the tile index
A9AF LD A,(HL) Fetch a supertile index from map_buf
Now map the tile index and supertile index into a tile pointer:
Supertiles 44 and lower use tiles 0..249 (249 tile span)
Supertiles 45..138 and 204..218 use tiles 145..400 (255 tile span)
Supertiles 139..203 use tiles 365..570 (205 tile span)
A9B0 LD BC,$8590 Point BC at exterior_tiles[0]
A9B3 CP $2D If supertile index <= 44 jump to plot_tile_chosen
A9B5 JR C,plot_tile_chosen
A9B7 LD BC,$8A18 Point BC at exterior_tiles[145]
A9BA CP $8B If supertile index <= 138 or >= 204 jump to plot_tile_chosen
A9BC JR C,plot_tile_chosen
A9BE CP $CC
A9C0 JR NC,plot_tile_chosen
A9C2 LD BC,$90F8 Point BC at exterior_tiles[365]
plot_tile_chosen A9C5 PUSH HL Preserve the supertile pointer
A9C6 EX AF,AF' Unbank the tile index
A9C7 LD L,A Point HL at BC[tile index]
A9C8 LD H,$00
A9CA ADD HL,HL
A9CB ADD HL,HL
A9CC ADD HL,HL
A9CD ADD HL,BC
A9CE PUSH DE Preserve the screen buffer pointer
A9CF EX DE,HL Transpose
A9D0 LD BC,$0018 Set the screen buffer stride to 24
A9D3 LD A,$08 Set eight iterations
Start loop
plot_tile_loop A9D5 EX AF,AF' Preserve the loop counter
A9D6 LD A,(DE) Copy a byte of tile
A9D7 LD (HL),A
A9D8 ADD HL,BC Advance the destination pointer to the next row
A9D9 INC E Advance the source pointer
A9DA EX AF,AF' Restore the loop counter
A9DB DEC A ...loop
A9DC JP NZ,plot_tile_loop
A9DF POP DE Restore the screen buffer pointer
A9E0 INC DE Advance the screen buffer pointer
A9E1 POP HL Restore the supertile pointer
A9E2 EXX Re-bank input registers
A9E3 RET Return
Prev: A9A0 Up: Map Next: A9E4