Routines |
Prev: 56216 | Up: Map | Next: 56385 |
Used by the routine at 56216.
|
||||||||||||||
This routine calculates the screen display address position to draw the graphic at, and checks if it's encroaching on the left or right border of the screen
|
||||||||||||||
56309 | LD A,1 | This is the flag indicating whether (any part of the graphic) is visible on-screen (0 = not visible, 1 = visible) | ||||||||||||
56311 | LD (60117),A | It's set here to visible (1) as part of the item is visible. | ||||||||||||
This calculates the LOW BYTE of the screen display address
|
||||||||||||||
56314 | LD A,E | Horizontal pixel position, from left of screen display | ||||||||||||
56315 | RRA | Divide by 8 to get the screen (character) column | ||||||||||||
56316 | RRA | |||||||||||||
56317 | RRA | |||||||||||||
56318 | AND 31 | Filter out unnecessary bits (5-7) that may have been affected by the RRA instructions, just keeping bits 0-4 (values 0-31) | ||||||||||||
56320 | LD E,A | Store in E register | ||||||||||||
56321 | LD A,D | Get the calculated vertical (Y) pixel position - these need to go into bits 5-7 of the byte currently stored in E | ||||||||||||
56322 | RLA | Character row is currently indicated by bits 3-5 so shift them left twice to bits 5-7 | ||||||||||||
56323 | RLA | |||||||||||||
56324 | AND 224 | Get those top three bits (filter out any others)... | ||||||||||||
56326 | ADD A,E | ...and combine them with bits 0-4 which hold the column number, to form the screen display address low byte | ||||||||||||
56327 | LD E,A | Store back in E register | ||||||||||||
This routine calculates the HIGH BYTE of the screen address
|
||||||||||||||
56328 | LD A,D | Vertical pixel position, from top of screen display | ||||||||||||
56329 | RRA | Divide by 8 to get screen (character) row | ||||||||||||
56330 | RRA | |||||||||||||
56331 | RRA | |||||||||||||
56332 | AND 24 | Bits 3 (8) and 4 (16) include the screen display address high byte character row (0-24) | ||||||||||||
56334 | ADD A,64 | Set bit 6 (always set for screen addresses) | ||||||||||||
56336 | ADD A,C | C contains the pixel row number in the character line (0-7). Add this to the high byte of the address | ||||||||||||
56337 | LD D,A | Put the calculated screen address high byte into the D register | ||||||||||||
56338 | LD A,(60113) | Number of bytes in the graphic tile to draw | ||||||||||||
56341 | LD C,A | Store in C as a counter (checked later at 56432) | ||||||||||||
Check if we're in the decorative screen border. Tiles are drawn (character) column by column, so we only need to check for the inner border (columns 1 & 30), not the outer ones (columns 0 & 31).
Mirrored graphic tiles have 'reversed' offsets so they tend to be drawn right-to-left, so we need to check both left and right columns.
|
||||||||||||||
56342 | LD A,E | Retrieve the screen display low byte from the E register | ||||||||||||
56343 | AND 31 | Bits 0-4 (values 0-31) give us the screen vertical (character) column | ||||||||||||
56345 | CP 1 | Check if we're into the left border (column 1) | ||||||||||||
56347 | JP Z,56533 | |||||||||||||
56350 | CP 29 | Check if we're into the right border (column 29) | ||||||||||||
56352 | JP Z,56457 | |||||||||||||
Start of tile graphic draw/erase loop - jump back here from 56435
Shifts graphic so that shifted graphics byte contained in 2 bytes, H & L, ready to draw on screen
|
||||||||||||||
56355 | LD A,(HL) | Get graphics byte | ||||||||||||
56356 | INC HL | ...And move graphic address pointer along, ready for next one | ||||||||||||
56357 | CP 0 | Byte empty? | ||||||||||||
56359 | JR Z,56406 | ...If so, skip this byte, don't bother shifting or drawing | ||||||||||||
56361 | PUSH HL | Store address pointer | ||||||||||||
Shifts graphic so that the right-shifted graphics byte is contained in 2 bytes, H and L, ready to draw on screen
|
||||||||||||||
56362 | LD H,A | H contains the unshifted graphic byte | ||||||||||||
56363 | LD L,0 | Clear L register ready to receive shifted bits | ||||||||||||
56365 | LD A,B | Temp store for the 'shift counter' (containing number of right-shifts needed) | ||||||||||||
56366 | CP 0 | Any more shifts needed? | ||||||||||||
56368 | JR Z,56377 | ...If not, skip out of the shift loop | ||||||||||||
56370 | RR H | Rotate byte in H register into L register | ||||||||||||
56372 | RR L | |||||||||||||
56374 | DJNZ 56370 | Repeat for number of shifts (counter) | ||||||||||||
56376 | LD B,A | Reset the shift counter (from A register) | ||||||||||||
56377 | EX DE,HL | Swap registers so that D & E contain the byte values to draw, and HL contains the screen display address to draw at | ||||||||||||
56378 | LD A,(60111) | Check draw/erase flag | ||||||||||||
56381 | CP 1 | 0 = Erase, 1 = Draw | ||||||||||||
56383 | JR Z,56396 | If flag = 1, jump to DRAW routine. Otherwise ERASE (next routine) |
Prev: 56216 | Up: Map | Next: 56385 |