← 98FE Step a display-file pointer down one character row Map 995C → Clear the tile map to empty
990B: Render the tile map to the screen
Renders every tile-map cell into the back buffer, then copies the back buffer to the display file.
render_tilemap 990B LD HL,tilemap Start at the tile map.
990E LD BC,TILEMAP_SIZE Process every cell.
render_tilemap_0 9911 PUSH BC Each cell: hold the counter and the map pointer across the glyph copy.
9912 PUSH HL
9913 LD A,(HL) Read the tile value.
9914 LD L,A
9915 LD H,$00 Point DE at the tile's bitmap in the tile set, 8 bytes per tile.
9917 ADD HL,HL
9918 ADD HL,HL
9919 ADD HL,HL
991A LD DE,TILEGFX_BASE
991D ADD HL,DE
991E EX DE,HL
991F POP HL
9920 PUSH HL
9921 LD A,H Build the back-buffer destination from the cell's screen-third (high bits).
9922 AND $03
9924 RLCA
9925 RLCA
9926 RLCA
9927 ADD A,BACKBUF_BASE/$100
9929 LD H,A
992A LD A,(DE) Copy the 8 glyph rows into the back buffer (INC H steps down pixel rows).
992B LD (HL),A
992C INC H
992D INC DE
992E LD A,(DE)
992F LD (HL),A
9930 INC H
9931 INC DE
9932 LD A,(DE)
9933 LD (HL),A
9934 INC H
9935 INC DE
9936 LD A,(DE)
9937 LD (HL),A
9938 INC H
9939 INC DE
993A LD A,(DE)
993B LD (HL),A
993C INC H
993D INC DE
993E LD A,(DE)
993F LD (HL),A
9940 INC H
9941 INC DE
9942 LD A,(DE)
9943 LD (HL),A
9944 INC H
9945 INC DE
9946 LD A,(DE)
9947 LD (HL),A
9948 POP HL
9949 INC HL
994A POP BC
994B DEC BC
994C LD A,B
994D OR C
994E JR NZ,render_tilemap_0
9950 LD HL,BACKBUF_BASE Finally copy the whole back buffer to the display file.
9953 LD DE,SCREEN_BASE
9956 LD BC,SCREEN_SIZE
9959 LDIR
995B RET
← 98FE Step a display-file pointer down one character row Map 995C → Clear the tile map to empty
Fork me on GitHub