Prev: BBDD Up: Map Next: BC67
BBF7: Draw Room
Used by the routines at GameComplete, HandlerGameMenu, NewHighScore and BBDD.
Input
HL The Room Data memory address (e.g. Room_Special_MainMenu, Room_00)
The room data is held as:
Byte Type
01 Room Graphic Data Address
02
03 X Position
04 Y Position
And is terminated when 0000 is reached.
Fetch the room data graphic address.
DrawRoom BBF7 LD E,(HL) DE=room data graphic address.
BBF8 INC HL
BBF9 LD D,(HL)
BBFA LD A,E Return if the terminator is found.
BBFB OR D
BBFC RET Z
Fetch the X/ Y position data.
BBFD INC HL Increment HL by one.
BBFE LD C,(HL) BC=X/ Y position data.
BBFF INC HL
BC00 LD B,(HL)
BC01 INC HL Increment HL by one, ready for the next loop.
BC02 PUSH HL Stash HL (room graphic data pointer) on the stack.
BC03 LD H,B HL=BC.
BC04 LD L,C
BC05 CALL DrawRoom_Process Call DrawRoom_Process.
BC08 POP HL Restore HL from the stack (room graphic data pointer).
BC09 JR DrawRoom Jump back to DrawRoom.
At the point of processing; HL contains X/ Y position data, DE contains the room data graphic address (and BC is throwaway).
DrawRoom_Process BC0B PUSH HL Stash HL (X/ Y position) on the stack.
BC0C CALL ScreenAddress Call ScreenAddress.
BC0F LD A,(DE) C=room graphic width byte.
BC10 LD C,A
BC11 INC DE Increment DE by one.
BC12 LD A,(DE) B=room graphic height byte.
BC13 LD B,A
BC14 INC DE Increment DE by one.
DrawRoom_Row_Loop BC15 PUSH BC Stash BC on the stack.
DrawRoom_Write_Row BC16 LD A,(DE) A=fetch a byte of graphics data.
BC17 CPL Invert the bits.
BC18 LD (HL),A Write the graphic data to HL (screen buffer).
BC19 INC L Move onto the next screen location.
BC1A INC DE Increment DE by one.
BC1B DJNZ DrawRoom_Write_Row Decrease the width counter by one and loop back to DrawRoom_Write_Row until counter is zero.
BC1D POP BC Restore BC from the stack.
BC1E LD A,L L=L-B.
BC1F SUB B
BC20 LD L,A
BC21 CALL ScreenPos1PixelBelow Call ScreenPos1PixelBelow.
BC24 DEC C Decrease the height counter by one and loop back to DrawRoom_Row_Loop until counter is zero.
BC25 JR NZ,DrawRoom_Row_Loop
BC27 POP HL Restore HL from the stack.
BC28 CALL AttributeAddress Call AttributeAddress.
BC2B LD A,(DE)
BC2C INC DE
BC2D LD C,A
BC2E LD A,(DE)
BC2F INC DE
BC30 LD B,A
BC31 LD A,($96B2) If 96B2 is not zero, jump to DrawRoom_2.
BC34 AND A
BC35 JR NZ,DrawRoom_2
DrawRoom_0 BC37 PUSH BC
BC38 PUSH HL
DrawRoom_1 BC39 LD A,(DE)
BC3A INC DE
BC3B LD (HL),A
BC3C INC L
BC3D DJNZ DrawRoom_1
BC3F POP HL
BC40 LD BC,$0020 BC=0020.
BC43 ADD HL,BC
BC44 POP BC
BC45 DEC C
BC46 JR NZ,DrawRoom_0
BC48 RET Return.
DrawRoom_2 BC49 PUSH BC Stash BC on the stack.
BC4A XOR A Write 00 to 96B2.
BC4B LD ($96B2),A
DrawRoom_3 BC4E ADD A,C
BC4F DJNZ DrawRoom_3
BC51 LD C,A
BC52 LD B,$00
BC54 EX DE,HL
BC55 ADD HL,BC
BC56 EX DE,HL
BC57 POP BC
BC58 JR DrawRoom_0
BC5A LD HL,$0000 HL=0000.
BC5D LD B,$08 B=08.
DrawRoom_4 BC5F ADD HL,HL
BC60 RLCA
BC61 JR NC,DrawRoom_5
BC63 ADD HL,DE
DrawRoom_5 BC64 DJNZ DrawRoom_4
BC66 RET Return.
Prev: BBDD Up: Map Next: BC67