Prev: 38829 Up: Map Next: 39014
38841: Move Magic Knight into room A, draw room, objects and characters and initialise room-specific data
Used by the routines at 38024, 40406, 40437 and 40546.
Input
A Index of room to move Magic Knight into
38841 LD (23702),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 38205, 39714 and 64878.
38844 LD A,(24768) Load Magic Knight's current strength into A...
38847 OR A ...and if not zero...
38848 JR NZ,38865 ...then skip ahead to 38865
38850 LD A,16 If Magic Knight is wearing the Brass Ankh...
38852 CALL 45505 ...
38855 JR Z,38863 ...then skip ahead to 38863
This entry point is used by the routines at 40153 and 40201.
38857 LD HL,51071 Point HL at "YOU DIED OF EXHAUSTION" text
38860 JP 64582 Jump to "game over" window routine and return to control selection menu
38863 LD A,61 Set Magic Knight's current strength to 60...
38865 DEC A ...
38866 LD (24768),A ...
38869 CALL 38780 Draw top in-game window
38872 LD A,71 Load A with 71 (white INK, black PAPER, BRIGHT)...
38874 LD (23695),A ...and store this value at 23693 and 23695...
38877 LD (23693),A ...
38880 LD A,32 Load 32 into "frame number" property of...
38882 LD (46756),A ...axe 1...
38885 LD (46764),A ...axe 2...
38888 LD (46772),A ...axe 3...
38891 LD (46780),A ...and axe 4...
38894 CALL 46784 Draw axe(s) to screen if Magic Knight is in an axe room
38897 LD A,(23702) Load A with Magic Knight's current room
38900 AND 3 Clear all but the lowest two bits to leave a value 0-3...
38902 ADD A,68 ...add this to 68...
38904 LD (49047),A ...and set the border attribute of window 1 to this value
38907 LD HL,23808 Load character rows 0-4 in terrain interaction table with 254...
38910 LD DE,23809 ...i.e. prevent Magic Knight jumping above ceilings...
38913 LD BC,160 ...
38916 LD (HL),254 ...
38918 LDIR ...
38920 LD BC,576 Load character rows 5-22 in terrain interaction table with 0...
38923 LD (HL),0 ...i.e. allow Magic Knight to pass through freely...
38925 LDIR ...
38927 LD BC,31 Load character row 23 in terrain interaction table with 254...
38930 LD (HL),254 ...i.e. prevent Magic Knight falling through floors...
38932 LDIR ...
38934 LD HL,22688 Starting at the beginning of the sixth character row (y=5)...
38937 LD DE,22689 ...fill the attribute file to the end with...
38940 LD BC,607 ...white INK, black PAPER, BRIGHT...
38943 LD (HL),71 ...
38945 LDIR ...
38947 LD HL,23368 Set all entries in table of glowing attribute file addresses to zero...
38950 LD DE,23369 ...
38953 LD BC,29 ...
38956 LD (HL),0 ...
38958 LDIR ...
38960 LD A,(23702) Load A with Magic Knight's current room
38963 LD HL,58841 Point HL at start of table of room layout data pointers
38966 CALL 64627 Load address of layout data for Magic Knight's current room into HL
38969 PUSH HL Store HL (pointer to room layout data for Magic Knight's current room)
38970 CALL 47833 Clear lower two thirds, and lower three character rows of upper third of display file
38973 POP HL Restore HL (pointer to room layout data for Magic Knight's current room)
38974 LD (39065),HL Store address of start of room layout data by modifying instruction at 39063
This entry point is used by the routines at 39014, 39036 and 39047.
38977 LD A,(HL) Read byte of room layout data
38978 OR A If byte is a zero (i.e. marker for end of layout data)...
38979 JP Z,39047 ...then draw floor, paint attributes / terrain interaction data, draw Magic Knight, characters and objects then return
38982 CP 126 If byte is 126 (i.e. vertical block drawing)...
38984 JP Z,39036 ...then skip ahead to 39036 (skip over block drawing data to start of next instruction)
38987 CP 127 If byte is 127 (i.e. horizontal block drawing)...
38989 JP Z,39036 ...then skip ahead to 39036 (skip over block drawing data to start of next instruction)
38992 BIT 7,A If bit 7 (draw-layout-data-fragment flag) is set...
38994 JP NZ,39014 ...then jump to 39014 (start drawing layout data fragment)
38997 INC HL Advance HL by three bytes to x- and y-coordinates...
38998 INC HL ...
38999 INC HL ...
39000 LD E,(HL) Load x- and y-coordinates (characters) for graphic into DE...
39001 INC HL ...
39002 LD D,(HL) ...
39003 INC HL Advance HL to mirror options...
39004 LD C,(HL) ...and load into C
39005 INC HL Advance HL to next byte (start of next entry) in room layout data
39006 PUSH HL Store HL (current position in room layout data)
39007 EX DE,HL Swap DE (now current position in room layout data) and HL (x- and y-coordinates of graphic to draw)
39008 CALL 40664 Read graphic definition from room layout data and draw
39011 POP HL Restore HL (current position in room layout data)
39012 JR 38977 Loop back to 38977 for next byte of room layout data
Prev: 38829 Up: Map Next: 39014