Prev: 28510 Up: Map Next: 28647
28561: Move location to print and terrain interaction cursor down two character rows with y-wrap
Instructions from 28609 onwards can only be executed if, after moving down two character blocks, the next location to draw to is beneath the (two-character deep) floor, on the same character row as the "SPELLBOUND" text in the bottom window which shows either the copyright message if Magic Knight doesn't hold the Mirror, or Magic Knight's strength and inventory if he does.
Used by the routine at 28344.
Input
HL Points to terrain interaction table data for bottom-right character block of 2-by-2 brickwork block just drawn
28561 LD HL,(36488) Load HL with display file address to draw character
28564 LD A,L Clear all but least significant five bits (i.e. x-coordinate)...
28565 AND 31 ...
28567 LD L,A ...
28568 LD H,0 ...
28570 PUSH HL Store HL (x-coordinate to draw character)
28571 CALL 37719 Move virtual text cursor to beginning of character row two rows below current position
28574 LD HL,(36488) Load HL with display file address to draw character (as just updated)
28577 POP DE Restore DE (new location to draw character, previously in HL)
28578 ADD HL,DE Add x-coordinate as offset to updated location to draw character
28579 LD (36488),HL Store the new location (now two characters below position upon entering this routine)
28582 LD HL,(23481) Update current terrain interaction table cursor position onwards by 64 characters (i.e. down two rows)...
28585 LD BC,64 ...
28588 ADD HL,BC ...
28589 LD (23481),HL ...
28592 LD HL,(36488) Load HL with new display file address to draw character
28595 LD A,H If memory location to draw character is not in the bottom third of the display...
28596 AND 248 ...
28598 CP 80 ...
28600 JR NZ,28645 ...then return
28602 LD A,L If memory location to draw character is not in the fifth character row (any of the 8 pixel rows)...
28603 AND 224 ...(which is the row two rows beneath the floor level, in line with "SPELLBOUND" text in bottom window)...
28605 CP 128 ...
28607 JR NZ,28645 ...then return
28609 LD A,64 Load 64 into MSB of display file address to print character, wrapping from bottom of display back up to top...
28611 LD (36489),A ...
28614 LD A,(36488) Increase LSB by two characters (moving right by two characters upon bottom-to-top wrap)...
28617 INC A ...
28618 INC A ...
28619 AND 31 Cap value to maximum of 31 to ensure that new position is in top character row of display (i.e. y-coordinate = 0)...
28621 LD (36488),A ...and store
28624 LD BC,24539 Point BC at terrain interaction table
28627 XOR A Set A to zero (and clear carry flag)
28628 LD HL,(23481) Load HL with terrain interaction table cursor
28631 SBC HL,BC Load HL with position of terrain interaction table cursor relative (i.e. offset) to beginning of the table
28633 LD A,L Advance cursor x-coordinate offset by two character blocks...
28634 INC A ...
28635 INC A ...
28636 AND 31 ...and cap value to maximum of 31 to ensure that new position is in top character row of display (i.e. y-coordinate = 0)...
28638 LD L,A Place new x-coordinate in HL along with y-coordinate of zero...
28639 LD H,0 ...
28641 ADD HL,BC Add this new offset to start of terrain interaction data
28642 LD (23481),HL Store the updated terrain interaction table cursor
28645 EXX Switch registers
28646 RET Return
Prev: 28510 Up: Map Next: 28647