![]() |
Routines |
Prev: 6100 | Up: Map |
|
||||||||||||
610B | LD A,E | A=skool x-coordinate (0-95) | ||||||||||
610C | AND $60 | Now H is 0x80 if 0<=E<32; 0x88 if 32<=E<64; or 0x90 if 64<=E<96 | ||||||||||
610E | RRCA | |||||||||||
610F | INC A | |||||||||||
6110 | RRCA | |||||||||||
6111 | LD H,A | |||||||||||
6112 | LD A,(DE) | A=skool UDG reference for the character square at (E,D) | ||||||||||
6113 | PUSH DE | |||||||||||
6114 | LD L,A | HL=base address of the UDG bytes for the character square at (E,D) | ||||||||||
6115 | LD BC,$0800 | B=8, C=0 | ||||||||||
6118 | LD DE,$7F01 | Copy the 8 bytes of the skool UDG into the back buffer at 7F01 | ||||||||||
611B | LD A,(HL) | |||||||||||
611C | LD (DE),A | |||||||||||
611D | INC H | |||||||||||
611E | INC E | |||||||||||
611F | DJNZ $611B | |||||||||||
6121 | NOP | |||||||||||
6122 | POP DE | Restore the skool coordinates to DE | ||||||||||
6123 | LD B,$15 | There are 21 characters to consider | ||||||||||
6125 | LD H,$98 | 0x98=little boy no. 1 | ||||||||||
Now we enter a loop that checks which part (if any) of each character's sprite appears at the skool coordinates in DE.
|
||||||||||||
6127 | LD L,$62 | Byte 0x62 of the character's buffer holds his x-coordinate | ||||||||||
6129 | LD A,E | A=skool x-coordinate (0-95) | ||||||||||
612A | SUB (HL) | Subtract the character's x-coordinate | ||||||||||
612B | DEC HL | Byte 0x61 of the character's buffer holds his y-coordinate | ||||||||||
612C | JR C,$615E | Jump if no part of the character's sprite appears at this x-coordinate | ||||||||||
612E | CP $03 | |||||||||||
6130 | JR NC,$615E | |||||||||||
6132 | ADD A,A | Now C is 0, 4 or 8, corresponding to the column (left, middle or right) of the character's sprite that aligns with x-coordinate E | ||||||||||
6133 | ADD A,A | |||||||||||
6134 | LD C,A | |||||||||||
6135 | LD A,D | A=skool y-coordinate (152-172) | ||||||||||
6136 | SUB (HL) | Subtract the character's y-coordinate | ||||||||||
6137 | JR C,$615E | Jump if no part of the character's sprite appears at this y-coordinate | ||||||||||
6139 | CP $04 | |||||||||||
613B | JR NC,$615E | |||||||||||
613D | ADD A,C | A=0x00-0x0B, corresponding to the sprite tile that appears at (E,D) | ||||||||||
613E | EXX | |||||||||||
613F | ADD A,$AD | |||||||||||
6141 | LD H,A | H'=0xAD-0xB8 | ||||||||||
6142 | EXX | |||||||||||
6143 | LD L,$60 | Pick up the character's animatory state in A | ||||||||||
6145 | LD A,(HL) | |||||||||||
6146 | EXX | |||||||||||
6147 | LD L,A | L'=character's animatory state | ||||||||||
6148 | LD A,(HL) | A=sprite tile UDG reference | ||||||||||
6149 | AND A | Is it the blank UDG? | ||||||||||
614A | JR Z,$615D | Jump if so | ||||||||||
614C | CALL $6D0A | Get the base address of the sprite tile UDG bytes in HL' | ||||||||||
The following inner loop superimposes the sprite tile onto the tile built up so far in the back buffer at 7F01 (which was originally populated with the relevant skool UDG).
|
||||||||||||
614F | LD B,$08 | There are 8 bytes in the UDG | ||||||||||
6151 | LD DE,$7F01 | |||||||||||
6154 | LD A,(DE) | A=back buffer UDG byte | ||||||||||
6155 | OR (HL) | OR in the sprite tile UDG byte | ||||||||||
6156 | INC H | |||||||||||
6157 | AND (HL) | AND in the sprite tile UDG mask | ||||||||||
6158 | INC H | |||||||||||
6159 | LD (DE),A | |||||||||||
615A | INC E | |||||||||||
615B | DJNZ $6154 | Jump back until the UDG is done | ||||||||||
615D | EXX | |||||||||||
615E | INC H | Next character | ||||||||||
615F | DJNZ $6127 | Jump back to consider the next character | ||||||||||
The display tile (consisting of the skool UDG with all relevant sprite tiles superimposed) has been built. Figure out where in the display file it should be printed.
|
||||||||||||
6161 | LD HL,$7F00 | 7F00 holds the leftmost column of the skool on-screen (0-64) | ||||||||||
6164 | LD A,D | A=skool y-coordinate (152-172) | ||||||||||
6165 | AND $07 | Set C to the LSB of the display file address corresponding to the screen coordinates (0,D-152) | ||||||||||
6167 | RRCA | |||||||||||
6168 | RRCA | |||||||||||
6169 | RRCA | |||||||||||
616A | LD C,A | |||||||||||
616B | LD A,E | A=screen x-coordinate (0-31) | ||||||||||
616C | SUB (HL) | |||||||||||
616D | ADD A,C | Set L to the LSB of the display file address corresponding to the skool coordinates (E,D) | ||||||||||
616E | LD L,A | |||||||||||
616F | LD A,D | A=screen y-coordinate (0-20) | ||||||||||
6170 | SUB $98 | |||||||||||
6172 | AND $18 | Set H to the MSB of the display file address corresponding to the skool coordinates (E,D) | ||||||||||
6174 | ADD A,$40 | |||||||||||
6176 | LD H,A | |||||||||||
Having computed the appropriate display file address in HL, copy the tile from the back buffer to the screen.
|
||||||||||||
6177 | LD B,$08 | Copy the tile to the screen | ||||||||||
6179 | LD DE,$7F01 | |||||||||||
617C | LD A,(DE) | |||||||||||
617D | LD (HL),A | |||||||||||
617E | INC H | |||||||||||
617F | INC E | |||||||||||
6180 | DJNZ $617C | |||||||||||
6182 | RET |
Prev: 6100 | Up: Map |