Prev: B951 Up: Map Next: B9AC
B952: Draw Room
Used by the routines at 813B, Demo_Start, AC06, ED2A and EDF7.
DrawRoom B952 LD A,$B8 Write B8 to Data_Platform_9.
B954 LD ($AF88),A
B957 CALL Clear_PlayArea Call Clear_PlayArea.
Get the current room ID and double it. This is stored in DE as an offset.
B95A LD A,(IY+$0F) E=(*IY+0F)*02.
B95D ADD A,A
B95E LD E,A
B95F LD D,$00 D=00.
B961 LD HL,$CDB5 HL=Table_RoomData+DE.
B964 ADD HL,DE
Fetch the room data location from the lookup table.
B965 LD E,(HL) E=*HL.
B966 INC HL Increment HL by one.
B967 LD D,(HL) D=*HL.
B968 EX DE,HL Exchange the DE and HL registers.
Fetch a room data pair and store it in DE. Note, this is not a memory address.
DrawRoom_Loop B969 LD D,(HL) D=*HL.
B96A INC HL Increment HL by one.
B96B LD E,(HL) E=*HL.
B96C INC HL Increment HL by one.
Drop bit 7 of D and test for the control characters.
B96D LD A,D A=D.
B96E AND %01111111 Keep only bits 0-6.
Are we done?
B970 CP $7F If the result is 7F jump to DrawRoom_Finish.
B972 JR Z,DrawRoom_Finish
Some parts of rooms are dynamic (depending on if a task is completed or not), check if this should be actioned.
B974 CP $7E If the result is not 7E jump to DrawRoom_ProcessData.
B976 JR NZ,DrawRoom_ProcessData
Fetch the task ID.
B978 LD A,E A=E.
B979 CALL Handler_TaskCompleted Call Handler_TaskCompleted.
B97C JR NZ,DrawRoom_Loop If the task is not complete, jump to DrawRoom_Loop.
Move onto the next room data pair.
B97E INC HL Increment HL by two.
B97F INC HL
B980 JR DrawRoom_Loop Jump to DrawRoom_Loop.
Pull out the screen co-ordinates and graphics address.
DrawRoom_ProcessData B982 PUSH HL Stash the room data pointer held by HL on the stack.
B983 LD B,A B=A.
Grab the second byte from the room data pair, this contains both the x and y cursor position commands.
Y is essentially C=bits 3-7 of the second byte of the room data, shifted to bits 0-4. This is assigned to E at B995 below.
B984 LD A,E A=E.
B985 AND %11111000 Keep only bits 3-7.
B987 RRA Rotate A right three times.
B988 RRA
B989 RRA
B98A LD C,A C=A.
Todo.
B98B RL D Rotate D left once.
B98D RL E Rotate E left once.
B98F LD A,E A=E.
B990 AND %00001111 Keep only bits 0-3.
B992 ADD A,$05 D=A+05.
B994 LD D,A
B995 LD E,C E=C.
The offset below for the graphic ID is created using the first byte with bit 7 from B96D and B983.
B996 LD L,B L=B.
B997 LD H,$00 H=00.
B999 ADD HL,HL HL*=02.
B99A LD BC,$BD86 HL+=Table_GraphicData.
B99D ADD HL,BC
Fetch the graphics control data from the lookup table.
B99E LD A,(HL) A=*HL.
B99F INC HL Increment HL by one.
B9A0 LD H,(HL) H=*HL.
B9A1 LD L,A L=A.
B9A2 CALL Controller_Tile Call Controller_Tile.
B9A5 POP HL Restore the room data pointer held by HL from the stack.
B9A6 JR DrawRoom_Loop Jump to DrawRoom_Loop.
Finish by blitting the shadow buffer to the screen and return to the calling routine.
DrawRoom_Finish B9A8 CALL $B9AC Call B9AC.
B9AB RET Return.
Prev: B951 Up: Map Next: B9AC