Prev: 49808 Up: Map Next: 49912
49858: Calculate horizontal/vertical room co-ordinates for each room section/components
Used by the routine at 49679.
back/side room connectors
The byte at 60285 acts as an incrementing counter which is compared with room size (first byte in the room data sets at 25001). 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.
49858 LD A,(60285) Get counter byte, starting at 1
49861 INC A Increment and then re-store
49862 LD (60285),A
49865 LD C,A
49866 LD A,(60284) First room data byte from room data set at 25001 - indicates room size
49869 SUB C Subtract (check against) the counter
49870 JR C,49912 If counter is greater than the room data byte, the side and back wall joints have been calculated. Skip to 49912 to deal with the corner/vertical wall connectors
49872 CP 2 Check which section we're dealing with
49874 JR NC,49886
Room-size-minus-counter = 1 or 0. This means we're dealing with the RIGHT side of the room.
49876 LD A,(60281) Increase vertical (Y) position by 16 pixels
49879 ADD A,16 Each side wall part is 16 pixels tall (e.g. the right side wall section, so add 16 pixels from the current position
49881 LD (60281),A Store adjusted vertical graphic position
49884 JR 49901
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.
49886 LD A,(60285) Get the counter byte
49889 CP 4 >=4?
49891 JR NC,49901 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.
49893 LD A,(60281) Vertical (Y) position
49896 SUB 16 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
49898 LD (60281),A ...and re-store
Wall/floor sections (e.g. the connectors at 40392) are 4 characters (32 pixels) wide.
Calculate the horizontal (X) position - this is easy as every room section is 32 pixels wide.
49901 LD A,(60280)
49904 ADD A,8 Increase horizontal position by 8 half-character squares (32 pixels)
49906 LD (60280),A
49909 JP 49632 Return to the next item to set up
Prev: 49808 Up: Map Next: 49912