Prev: C290 Up: Map Next: C2F8
C2C2: Calculate horizontal/vertical room co-ordinates for each room section/components
Used by the routine at C20F.
back/side room connectors
The byte at EB7D acts as an incrementing counter which is compared with room size (first byte in the room data sets at 61A9). This works out which bit of the room is being dealt with (left, back or right).
The routine then identifies the vertical and horizontal positions for each consecutive scenery components.
C2C2 LD A,($EB7D) Get counter byte, starting at 1
C2C5 INC A Increment and then re-store
C2C6 LD ($EB7D),A
C2C9 LD C,A
C2CA LD A,($EB7C) First room data byte from room data set at 61A9 - indicates room size
C2CD SUB C Subtract (check against) the counter
C2CE JR C,$C2F8 If counter is greater than the room data byte, the side and back wall joints have been calculated. Skip to C2F8 to deal with the corner/vertical wall connectors
C2D0 CP $02 Check which section we're dealing with
C2D2 JR NC,$C2DE
Room-size-minus-counter = 1 or 0. This means we're dealing with the RIGHT side of the room.
C2D4 LD A,($EB79) Increase vertical (Y) position by 16 pixels
C2D7 ADD A,$10 Each side wall part is 16 pixels tall (e.g. the right side wall section, so add 16 pixels from the current position
C2D9 LD ($EB79),A Store adjusted vertical graphic position
C2DC JR $C2ED
Room size is 2 or more than the counter, so we're dealing with the scenery either on the left wall or the back wall scenery.
C2DE LD A,($EB7D) Get the counter byte
C2E1 CP $04 >=4?
C2E3 JR NC,$C2ED If so, we're dealing with the BACK WALL section - no need to adjust the vertical co-ordinate as it's all along the same level
Neither of the above checks were met, so we're dealing with the LEFT side of the room.
C2E5 LD A,($EB79) Vertical (Y) position
C2E8 SUB $10 Each side wall part is 16 pixels tall (e.g. the left side wall section, so subtract 16 pixels from the current position as they're drawn sequentially from left to right
C2EA LD ($EB79),A ...and re-store
Wall/floor sections (e.g. the connectors at 9DC8) are 4 characters (32 pixels) wide.
Calculate the horizontal (X) position - this is easy as every room section is 32 pixels wide.
C2ED LD A,($EB78)
C2F0 ADD A,$08 Increase horizontal position by 8 half-character squares (32 pixels)
C2F2 LD ($EB78),A
C2F5 JP $C1E0 Return to the next item to set up
Prev: C290 Up: Map Next: C2F8