Prev: 47441 Up: Map Next: 47532
47442: Draw Room
Used by the routines at 33083, Demo_Start, 44038, 60714 and 60919.
DrawRoom 47442 LD A,184 Write 184 to Data_Platform_9.
47444 LD (44936),A
47447 CALL Clear_PlayArea Call Clear_PlayArea.
Get the current room ID and double it. This is stored in DE as an offset.
47450 LD A,(IY+15) E=(*IY+15)*2.
47453 ADD A,A
47454 LD E,A
47455 LD D,0 D=0.
47457 LD HL,52661 HL=Table_RoomData+DE.
47460 ADD HL,DE
Fetch the room data location from the lookup table.
47461 LD E,(HL) E=*HL.
47462 INC HL Increment HL by one.
47463 LD D,(HL) D=*HL.
47464 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 47465 LD D,(HL) D=*HL.
47466 INC HL Increment HL by one.
47467 LD E,(HL) E=*HL.
47468 INC HL Increment HL by one.
Drop bit 7 of D and test for the control characters.
47469 LD A,D A=D.
47470 AND %01111111 Keep only bits 0-6.
Are we done?
47472 CP 127 If the result is 127 jump to DrawRoom_Finish.
47474 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.
47476 CP 126 If the result is not 126 jump to DrawRoom_ProcessData.
47478 JR NZ,DrawRoom_ProcessData
Fetch the task ID.
47480 LD A,E A=E.
47481 CALL Handler_TaskCompleted Call Handler_TaskCompleted.
47484 JR NZ,DrawRoom_Loop If the task is not complete, jump to DrawRoom_Loop.
Move onto the next room data pair.
47486 INC HL Increment HL by two.
47487 INC HL
47488 JR DrawRoom_Loop Jump to DrawRoom_Loop.
Pull out the screen co-ordinates and graphics address.
DrawRoom_ProcessData 47490 PUSH HL Stash the room data pointer held by HL on the stack.
47491 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 47509 below.
47492 LD A,E A=E.
47493 AND %11111000 Keep only bits 3-7.
47495 RRA Rotate A right three times.
47496 RRA
47497 RRA
47498 LD C,A C=A.
Todo.
47499 RL D Rotate D left once.
47501 RL E Rotate E left once.
47503 LD A,E A=E.
47504 AND %00001111 Keep only bits 0-3.
47506 ADD A,5 D=A+5.
47508 LD D,A
47509 LD E,C E=C.
The offset below for the graphic ID is created using the first byte with bit 7 from 47469 and 47491.
47510 LD L,B L=B.
47511 LD H,0 H=0.
47513 ADD HL,HL HL*=2.
47514 LD BC,48518 HL+=Table_GraphicData.
47517 ADD HL,BC
Fetch the graphics control data from the lookup table.
47518 LD A,(HL) A=*HL.
47519 INC HL Increment HL by one.
47520 LD H,(HL) H=*HL.
47521 LD L,A L=A.
47522 CALL Controller_Tile Call Controller_Tile.
47525 POP HL Restore the room data pointer held by HL from the stack.
47526 JR DrawRoom_Loop Jump to DrawRoom_Loop.
Finish by blitting the shadow buffer to the screen and return to the calling routine.
DrawRoom_Finish 47528 CALL 47532 Call 47532.
47531 RET Return.
Prev: 47441 Up: Map Next: 47532