Routines |
Prev: 53150 | Up: Map | Next: 53278 |
53185 | LD DE,24037 | Point DE at table of background attribute data | ||
53188 | LD A,(25157) | Load A with Magic Knight's current y-coordinate (pixels) | ||
53191 | AND 248 | Clear lowest three bits to round down to nearest multiple of 8 | ||
53193 | LD L,A | Load this value into HL... | ||
53194 | LD H,0 | ... | ||
53196 | ADD HL,HL | Multiply by four to obtain 32 × y-coordinate (characters)... | ||
53197 | ADD HL,HL | ... | ||
53198 | LD A,(25156) | Load A with Magic Knight's current x-coordinate (pixels) | ||
53201 | RRCA | Divide this by eight, rounding down to nearest integer... | ||
53202 | RRCA | ...to convert from pixels to characters... | ||
53203 | RRCA | ... | ||
53204 | AND 31 | ... | ||
53206 | LD C,A | Load x-coordinate (characters) into BC... | ||
53207 | LD B,0 | ... | ||
53209 | ADD HL,BC | Add x-coordinate to 32 × y-coordinate in HL | ||
53210 | PUSH HL | Store HL (32 × y-coordinate in characters) | ||
53211 | LD BC,22528 | Add this to start address of attribute file... | ||
53214 | ADD HL,BC | ...so that HL points to required byte in attribute file | ||
53215 | EX (SP),HL | Put attribute file address on top of stack and load HL with 32 × y-coordinate | ||
53216 | LD BC,24064 | Point BC at start of terrain interaction data table... | ||
53219 | ADD HL,BC | ...and add 32 × y-coordinate as offset in HL | ||
53220 | EX (SP),HL | Restore attribute file address to HL... | ||
53221 | POP IX | ...and load IX with terrain interaction address | ||
53223 | LD A,(25162) | Load C with Magic Knight's attribute... | ||
53226 | LD C,A | ... | ||
53227 | LD B,4 | Load B with 4 as Magic Knight is four characters tall | ||
53229 | PUSH BC | Store BC (B = remaining number of character rows) | ||
53230 | LD A,(HL) | Copy byte from attribute file... | ||
53231 | LD (DE),A | ...into table of background attribute data | ||
53232 | BIT 5,(IX+0) | If preserve-attribute terrain interaction flag is set for this character... | ||
53236 | JP NZ,53240 | ...then skip ahead to 53240 | ||
53239 | LD (HL),C | Set current attribute file byte to match Magic Knight's attribute | ||
53240 | INC HL | Advance current position in attribute file | ||
53241 | INC DE | Advance current position in table of background attribute data | ||
53242 | LD A,(HL) | Copy byte from attribute file... | ||
53243 | LD (DE),A | ...into table of background attribute data | ||
53244 | BIT 5,(IX+1) | If preserve-attribute terrain interaction flag is set for this character... | ||
53248 | JP NZ,53252 | ...then skip ahead to 53252 | ||
53251 | LD (HL),C | Set current attribute file byte to match Magic Knight's attribute | ||
53252 | INC HL | Advance current position in attribute file | ||
53253 | INC DE | Advance current position in table of background attribute data | ||
53254 | LD A,(HL) | Copy byte from attribute file... | ||
53255 | LD (DE),A | ...into table of background attribute data | ||
53256 | BIT 5,(IX+2) | If preserve-attribute terrain interaction flag is set for this character... | ||
53260 | JP NZ,53264 | ...then skip ahead to 53264 | ||
53263 | LD (HL),C | Set current attribute file byte to match Magic Knight's attribute | ||
53264 | INC DE | Advance current position in table of background attribute data | ||
53265 | LD BC,30 | Advance current position in attribute file by 30 bytes... | ||
53268 | ADD HL,BC | ...i.e. down one character and left two characters | ||
53269 | LD BC,32 | Advance current position in terrain interaction data table by 32 bytes... | ||
53272 | ADD IX,BC | ...i.e. down one character | ||
53274 | POP BC | Restore BC (B = remaining number of character rows) | ||
53275 | DJNZ 53229 | If character rows remain then loop back to 53229 | ||
53277 | RET | Return |
Prev: 53150 | Up: Map | Next: 53278 |