Routines |
Prev: 56439 | Up: Map | Next: 56533 |
Used by the routine at 56309.
|
||||||||||||||||
The graphics byte is pixel-shifted into two screen bytes, but the second byte is now in the right border area.
This routine incorporates slightly tweaked versions of the:
The opposite routine (graphic partially obscured by left-hand screen border) is at 56533.
|
||||||||||||||||
56457 | LD A,(HL) | Get graphics byte | ||||||||||||||
56458 | INC HL | ...and move graphic address pointer along, ready for next one | ||||||||||||||
56459 | CP 0 | Byte empty? | ||||||||||||||
56461 | JR Z,56498 | ...If so, skip this byte, don't bother shifting or drawing | ||||||||||||||
56463 | 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:
|
||||||||||||||||
56464 | LD H,A | H contains the unshifted graphic byte | ||||||||||||||
56465 | LD L,0 | Clear L register ready to receive shifted bits | ||||||||||||||
56467 | LD A,B | Temp store for the 'shift counter' (containing number of right-shifts needed) | ||||||||||||||
56468 | CP 0 | Any more shifts needed? | ||||||||||||||
56470 | JR Z,56479 | ...If not, skip out of the shift loop | ||||||||||||||
56472 | RR H | Rotate byte in H register into L register | ||||||||||||||
56474 | RR L | |||||||||||||||
56476 | DJNZ 56472 | Repeat for number of shifts needed (counter) | ||||||||||||||
56478 | LD B,A | Reset the shift counter (from A register) | ||||||||||||||
56479 | 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 | ||||||||||||||
56480 | LD A,(60111) | Check draw/erase flag | ||||||||||||||
56483 | CP 1 | 0 = Erase, 1 = Draw | ||||||||||||||
56485 | JR Z,56493 | If flag = 1, jump to DRAW routine. Otherwise ERASE (next routine) | ||||||||||||||
ERASE SCREEN BYTE
Don't need to erase the second graphic byte (stored in E register) as it's on the screen border.
|
||||||||||||||||
56487 | LD A,D | Get first graphic byte | ||||||||||||||
56488 | CPL | Invert it | ||||||||||||||
56489 | AND (HL) | AND with screen byte (i.e. keeps existing screen byte, clears sprite byte) | ||||||||||||||
56490 | LD (HL),A | ...and put back on screen. | ||||||||||||||
56491 | JR 56496 | |||||||||||||||
DRAW SCREEN BYTE
No need to draw the second graphic byte (stored in E register) as it's on the screen border.
|
||||||||||||||||
56493 | LD A,D | Get first graphic byte | ||||||||||||||
56494 | OR (HL) | OR with existing screen byte, preserve any background graphics | ||||||||||||||
56495 | LD (HL),A | ...and draw back on screen. | ||||||||||||||
56496 | EX DE,HL | |||||||||||||||
56497 | POP HL | HL now back to the graphic display address pointer, DE contains the screen display address | ||||||||||||||
Recalculate screen address 1 pixel line down after drawing/erasing the graphic byte (also jump in to here from 56461 if byte empty)
|
||||||||||||||||
56498 | LD A,D | Get high byte of screen address | ||||||||||||||
56499 | INC A | ...and increment (move down 1 pixel row) | ||||||||||||||
56500 | AND 7 | Are we crossing into a new character row (8th pixel row)? | ||||||||||||||
56502 | JR Z,56507 | |||||||||||||||
56504 | INC D | If not, increment screen display address pointer (move down 1 pixel row) | ||||||||||||||
56505 | JR 56521 | |||||||||||||||
56507 | LD A,D | Otherwise, adjust high byte to the correct screen address | ||||||||||||||
56508 | AND 248 | Reset the low 3 bits (pixel row number) to zero | ||||||||||||||
56510 | LD D,A | |||||||||||||||
56511 | LD A,E | Get the low byte of the screen address | ||||||||||||||
56512 | ADD A,32 | Increment column by 32 to move down to next screen row | ||||||||||||||
56514 | LD E,A | |||||||||||||||
56515 | JR NC,56521 | Crossing a 1/3 screen boundary? ...If not, skip next 3 instructions | ||||||||||||||
56517 | LD A,D | ...If so, adjust high byte of screen address accordingly | ||||||||||||||
56518 | ADD A,8 | |||||||||||||||
56520 | LD D,A | Store correct screen address high byte back in D register | ||||||||||||||
Check if encroaching out of bounds into bottom third of screen, where the scroll status panel is
|
||||||||||||||||
56521 | LD A,D | |||||||||||||||
56522 | CP 80 | Are we into the last 3rd of the screen? | ||||||||||||||
56524 | DEC C | (Decrement number of tile bytes to draw) | ||||||||||||||
56525 | JP NC,56442 | Jump to 56442 if into last 3rd of screen (out of bounds) | ||||||||||||||
56528 | JR NZ,56457 | If bytes left to draw in the tile - continue to draw next tile byte | ||||||||||||||
56530 | JP 56446 |
Prev: 56439 | Up: Map | Next: 56533 |