Prev: 27750 Up: Map Next: 27934
27762: Move Magic Knight into room A, draw room, objects and characters and initialise room-specific data
Used by the routines at 26997 and 32252.
Input
A (entry at 27762 only) Index of room to move Magic Knight into
27762 LD (23701),A Update Magic Knight's current room to be room index passed to this routine in A
This entry point is used by the routines at 27136, 28323, 28506, 28554, 31688, 32252, 32895 and 55814.
27765 LD A,(25020) Load Magic Knight's current strength into A...
27768 OR A ...and if not zero...
27769 JR NZ,27813 ...then skip ahead to 27813
27771 LD A,14 If Magic Knight is carrying the McTablet Food (14)...
27773 CALL 33645 ...
27776 JR Z,27784 ...then skip ahead to 27784
27778 LD HL,44643 Point HL at "YOU DIED OF EXHAUSTION" text
27781 JP NZ,55685 If Magic Knight is not carrying the McTablet Food then jump to "game over" window routine and return to control selection menu
27784 LD HL,45899 Point HL at "YOU HAD TO EAT SOME OF YOUR OWN MCTABLETS..." text
27787 LD DE,37195 Adjust height of window 13 to accommodate text...
27790 CALL 33774 ...
27793 PUSH HL Store HL (pointer to start of actual text)
27794 LD A,13 Draw window 13...
27796 CALL 34990 ...
27799 POP HL Restore HL (pointer to start of actual text)
27800 CALL 34762 Print text at HL
27803 LD A,100 Set Magic Knight's current strength to 100...
27805 LD (25020),A ...
27808 CALL 55138 Display "PRESS FIRE TO CONTINUE" window and wait for fire to be pressed
27811 JR 27817 Skip ahead to 27817
27813 DEC A Decrease Magic Knight's current strength by one...
27814 LD (25020),A ...
27817 CALL 27703 Draw top in-game window
27820 LD A,(23701) Load A with Magic Knight's current room
27823 AND 3 Clear all but the lowest two bits to leave a value 0-3...
27825 ADD A,68 ...add this to 68...
27827 LD (37102),A ...and set the border attribute of window 1 to this value
27830 LD A,(23701) Load A with Magic Knight's current room...
27833 INC A ...increase by one...
27834 AND 3 ...clear all but the lowest two bits to leave a value 0-3...
27836 ADD A,68 ...add this to 68...
27838 LD (37214),A ...and set the border attribute of window 15 to this value
27841 LD HL,24064 Load character rows 0-5 in terrain interaction table with 254...
27844 LD DE,24065 ...i.e. prevent Magic Knight jumping above ceilings...
27847 LD BC,192 ...
27850 LD (HL),254 ...
27852 LDIR ...
27854 LD BC,544 Load character rows 6-22 in terrain interaction table with 0...
27857 LD (HL),0 ...i.e. allow Magic Knight to pass through freely...
27859 LDIR ...
27861 LD BC,31 Load character row 23 in terrain interaction table with 254...
27864 LD (HL),254 ...i.e. prevent Magic Knight falling through floors...
27866 LDIR ...
27868 LD A,(23701) Load A with Magic Knight's current room
27871 LD HL,50143 Point HL at start of table of room layout data pointers
27874 CALL 55730 Load address of layout data for Magic Knight's current room into HL
27877 PUSH HL Store HL (pointer to room layout data for Magic Knight's current room)
27878 CALL 35627 Clear display file below 7th character row (play area)
27881 XOR A Store 0 (black INK, black PAPER) at 23695...
27882 LD (23695),A ...
27885 LD H,A Copy this attribute into both bytes of HL...
27886 LD L,A ...
27887 CALL 28716 ...wait for interrupt then flood 7th - 23rd rows of attribute file with this attribute
27890 POP HL Restore HL (pointer to room layout data for Magic Knight's current room)
27891 LD (27987),HL Store address of start of room layout data by modifying instruction at 27985
This entry point is used by the routines at 27934, 28730, 28753, 28766 and 28785.
27894 LD A,(HL) Read byte of room layout data
27895 OR A If byte is a zero (i.e. marker for end of layout data)...
27896 JP Z,27951 ...then draw floor, paint attributes / terrain interaction data, draw Magic Knight, characters and objects then return
27899 CP 251 If byte is less than 251...
27901 JP C,27934 ...then skip ahead to 27934 (read layout parameters and draw graphic in place, then jump back to 27894)
27904 CP 255 If byte is 255 (print run of UDG)...
27906 JP Z,28730 ...then jump to 28730 (read start coordinates, repeat count and UDG code, print run of UDGs, then jump back to 27894)
27909 CP 254 If byte is 254 (print a single UDG)...
27911 JP Z,28753 ...then jump to 28753 (read coordinates and UDG code, print the UDG, then jump back to 27894)
27914 CP 253 If byte is 253 (draw a line)...
27916 JP Z,28766 ...then jump to 28766 (draw a line, then jump back to 27894)
27919 CP 252 If byte is 252 (draw a horizontal line)...
27921 JP Z,28785 ...then jump to 28785 (draw a horizontal line, then jump back to 27894)
27924 CP 251 If byte is not 251 (used to draw walls)...
27926 JR NZ,27934 ...then skip ahead to 27934 (read layout parameters and draw graphic in place, then jump back to 27894)
27928 LD BC,6 Advance HL by six bytes to next entry in room layout data...
27931 ADD HL,BC ...
27932 JR 27894 Loop back to 27894 for next byte of room layout data
Prev: 27750 Up: Map Next: 27934