Routines |
Prev: 56457 | Up: Map | Next: 56612 |
Used by the routine at 56309.
|
||||||||||||||||
This routine incorporates slightly tweaked versions of the:
The opposite routine (graphic partially obscured by right-hand screen border) is at 56457.
|
||||||||||||||||
56533 | LD A,(HL) | Get graphics byte | ||||||||||||||
56534 | INC HL | ...and move graphic address pointer along, ready for next one | ||||||||||||||
56535 | CP 0 | Byte empty? | ||||||||||||||
56537 | JR Z,56577 | ...If so, skip this byte, don't bother shifting or drawing | ||||||||||||||
56539 | 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
|
||||||||||||||||
56540 | LD H,A | H contains the unshifted graphic byte | ||||||||||||||
56541 | LD L,0 | Clear L register ready to receive shifted bits | ||||||||||||||
56543 | LD A,B | Temp store for the 'shift counter' (containing number of right-shifts needed) | ||||||||||||||
56544 | CP 0 | Any more shifts needed? | ||||||||||||||
56546 | JR Z,56555 | ...If not, skip out of the shift loop | ||||||||||||||
56548 | RR H | Rotate byte in H register into L register | ||||||||||||||
56550 | RR L | |||||||||||||||
56552 | DJNZ 56548 | Repeat for number of shifts needed (counter) | ||||||||||||||
56554 | LD B,A | Reset the shift counter (from A register) | ||||||||||||||
56555 | 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 | ||||||||||||||
56556 | LD A,(60111) | Check draw/erase flag | ||||||||||||||
56559 | CP 1 | 0 = Erase, 1 = Draw | ||||||||||||||
56561 | JR Z,56570 | If flag = 1, jump to DRAW routine. Otherwise ERASE (next routine) | ||||||||||||||
ERASE SCREEN BYTE
|
||||||||||||||||
56563 | LD A,E | Don't need to erase the first graphic byte (stored in D register) as it's on the screen border, instead get the second byte (stored in E) | ||||||||||||||
56564 | INC HL | Move display address pointer right one character square to character column 2, just inside the left border | ||||||||||||||
56565 | CPL | Invert the graphics byte | ||||||||||||||
56566 | AND (HL) | AND with screen byte (i.e. keeps existing screen byte, clears sprite byte) | ||||||||||||||
56567 | LD (HL),A | ...and put back on screen. | ||||||||||||||
56568 | JR 56574 | |||||||||||||||
DRAW SCREEN BYTE
|
||||||||||||||||
56570 | LD A,E | Don't need to draw the first graphic byte (stored in D register) as it's on the screen border, instead get the second byte (stored in E) | ||||||||||||||
56571 | INC HL | Move display address pointer right one character square | ||||||||||||||
56572 | OR (HL) | OR with existing screen byte, preserve any background graphics | ||||||||||||||
56573 | LD (HL),A | ...and put back on screen. | ||||||||||||||
Graphic byte now drawn/erased
|
||||||||||||||||
56574 | DEC HL | Move back left one character space/screen display address | ||||||||||||||
56575 | EX DE,HL | |||||||||||||||
56576 | POP HL | HL now back to the graphic display address pointer, DE contains the screen display address | ||||||||||||||
Recalculate screen address after drawing/erasing the graphic byte (also jump in to here from 56537 if byte to draw is empty)
|
||||||||||||||||
56577 | LD A,D | Get high byte of screen address | ||||||||||||||
56578 | INC A | ...and increment (move down 1 pixel row) | ||||||||||||||
56579 | AND 7 | Are we crossing into a new character row (8th pixel row)? | ||||||||||||||
56581 | JR Z,56586 | |||||||||||||||
56583 | INC D | If not, increment screen display address pointer (move down 1 pixel row) | ||||||||||||||
56584 | JR 56600 | |||||||||||||||
56586 | LD A,D | Otherwise, adjust high byte to the correct screen address | ||||||||||||||
56587 | AND 248 | Reset the low 3 bits (pixel row number) to zero | ||||||||||||||
56589 | LD D,A | |||||||||||||||
56590 | LD A,E | Get the low byte of the screen address | ||||||||||||||
56591 | ADD A,32 | Increment column by 32 to move down to next screen row | ||||||||||||||
56593 | LD E,A | |||||||||||||||
56594 | JR NC,56600 | Crossing a 1/3 screen boundary? ...If not, skip next 3 instructions | ||||||||||||||
56596 | LD A,D | ...If so, adjust high byte of screen address accordingly | ||||||||||||||
56597 | ADD A,8 | |||||||||||||||
56599 | 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
|
||||||||||||||||
56600 | LD A,D | |||||||||||||||
56601 | CP 80 | Are we into the last 3rd of the screen? | ||||||||||||||
56603 | DEC C | (Decrement number of tile bytes to draw) | ||||||||||||||
56604 | JP NC,56442 | Jump to 56442 if into last 3rd of screen (out of bounds) | ||||||||||||||
56607 | JR NZ,56533 | If bytes left to draw in the tile - continue to draw next tile byte | ||||||||||||||
56609 | JP 56446 |
Prev: 56457 | Up: Map | Next: 56612 |