Prev: 27809 Up: Map Next: 28064
27865: Move Magic Knight into room A, initialise room-specific data and draw room
Used by the routines at 26906, 27168 and 29514.
Input
A Room index
27865 LD (65529),A Update Magic Knight's current room to be room index passed to this routine in A
27868 LD A,(25315) Decrease Magic Knight's current strength by one...
27871 DEC A ...
27872 LD (25315),A ...
27875 OR A Set zero flag if strength is zero
27876 LD HL,43960 Point HL to "YOU DIED OF EXHAUSTION" text...
27879 JP Z,35101 ...and if strength is zero, jump to "game over" window routine and exit
27882 LD A,32 Load 32 into "frame number" property of...
27884 LD (36187),A ...odd ball 1...
27887 LD (36195),A ...odd ball 2...
27890 LD (36203),A ...odd ball 3...
27893 LD (36211),A ...and odd ball 4
27896 CALL 30101 Indent "SPELLBOUND" text in bottom window to indicate Magic Knight's current floor
27899 LD A,(65529) Flag Magic Knight's current room as visited for scoring purposes...
27902 LD E,A ...
27903 LD D,0 ...
27905 LD HL,23412 ...
27908 ADD HL,DE ...
27909 LD (HL),1 ...
27911 LD A,7 Set stored border colour to 7 (black)...
27913 LD (23624),A ...
27916 XOR A Set A to zero
27917 OUT (254),A Set border to black and reset speaker state
27919 LD A,224 Set current terrain interaction parameter to impassable-horizontally, impassable-vertically and preserve-attribute...
27921 LD (23483),A ...
27924 LD A,71 Store 71 (white INK, black PAPER, BRIGHT) at 23695...
27926 LD (23695),A ...
27929 LD A,(23467) Load game progress flags, part 2 into A
27932 RRCA Set A to 2 if Armouris Photonicus has been cast, else set A to zero...
27933 AND 2 ...
27935 ADD A,69 ...add A to 69 (attribute value for cyan INK, black PAPER, BRIGHT, i.e. Magic Knight's initial attribute)
27937 LD (25393),A Load this value into Magic Knight's current attribute slot
27940 XOR A Set brickwork-drawing-direction flag to zero (horizontal mode for floor and ceiling)...
27941 LD (23476),A ...
27944 LD HL,24539 Point HL at start of terrain interaction data...
27947 LD DE,24540 ...and set 640 bytes from there onwards to 0, clearing data...
27950 LD BC,639 ...
27953 LD (HL),A ...
27954 LDIR ...
27956 LD HL,23383 Clear table of glowing attribute file addresses...
27959 LD DE,23384 ...
27962 LD BC,19 ...
27965 LD (HL),A ...
27966 LDIR ...
27968 LD (25389),A Set Magic Knight's current frame to erase to zero (frame 0 is blank graphic data) so Magic Knight is drawn but not erased
27971 LD (25390),A Set Magic Knight's frame number to zero
27974 LD HL,16384 Set "display file address to print character to" to beginning of display file...
27977 LD (36488),HL ...
27980 LD HL,22528 Point attribute cursor to beginning of attribute file...
27983 LD (23487),HL ...
27986 LD HL,24539 Set terrain interaction table cursor to point to start of terrain interaction table...
27989 LD (23481),HL ...
27992 LD A,(65529) Load Magic Knight's current room into A...
27995 ADD A,A ...and double the value (as room entries are 2 bytes wide)
27996 LD D,0 Load into DE...
27998 LD E,A ...
27999 LD HL,51913 ...and add to position of start of table of room data addresses...
28002 ADD HL,DE ...into HL
28003 LD A,(HL) Read address of room data for this room into HL...
28004 INC HL ...
28005 LD H,(HL) ...
28006 LD L,A ...
Room data is read here
28007 LD A,(HL) Load byte from room data into A
28008 OR A If data is a zero...
28009 JP Z,28092 ...then draw bottom in-game window + room name and animate entry (puff of smoke) of a character if required and return
28012 CP 160 If data is less than 160...
28014 JP C,28038 ...then skip ahead to 28038
28017 PUSH HL Store HL (pointer to current position in current room data)
28018 SUB 230 Subtract 230 from current data
28020 ADD A,A Double the remaining value...
28021 LD E,A ...and load into DE...
28022 LD D,0 ...
28024 LD HL,30170 Point HL at table of addresses of room feature drawing routines
28027 ADD HL,DE Add doubled index value as offset to pointer to table of room feature drawing routine addresses
28028 LD A,(HL) Load room feature drawing address into HL...
28029 INC HL ...
28030 LD H,(HL) ...
28031 LD L,A ...
28032 PUSH HL Transfer room feature drawing address into IX...
28033 POP IX ...
28035 POP HL Restore HL (pointer to current position in current room data)
28036 JP (IX) Jump to room feature drawing routine address
Data is less than 160
28038 LD B,A Copy byte of room data into B (repeat counter for drawing brickwork / architecture)
28039 INC HL Advance pointer to current room data by one byte
28040 LD A,(HL) Load next byte of room data into A...
28041 LD C,A ...and copy into C
28042 OR A If this value is zero...
28043 JR Z,28050 ...then skip ahead to 28050
28045 INC HL Advance HL by one byte
28046 LD A,(HL) Store data at 23695...
28047 LD (23695),A ...
28050 LD A,C Copy C into A
28051 CALL 28344 Draw a 2-by-2 block of brickwork, depending upon brickwork drawing mode, with architecture style A
28054 DJNZ 28050 Loop back to draw next block of brickwork if counter is not zero
This entry point is used by the routines at 28064, 29396 and 29414.
28056 XOR A Set brickwork drawing mode to two rows...
28057 LD (23469),A ...
This entry point is used by the routines at 28651, 28659, 28667, 28675, 28683, 28747, 28841, 28882, 28960, 29032, 29089, 29150, 29184, 29205, 29225, 29291, 29356 and 29375.
28060 INC HL Advance room data pointer by one byte...
28061 JP 28007 ...and repeat routine for this new data
Prev: 27809 Up: Map Next: 28064