Prev: C7D0 Up: Map Next: C837
C7EA: Copy current room item data set into working buffer
Used by the routine at D325.
Input
HL Address pointer to room data sets at 7C00 that contain the scenery, object and creature data in the current room
Get a room data set at 7C00 and copy it into the working buffer at EB43, ready to deal with:
C7EA LD A,(HL) Check for end-of-data byte
C7EB CP $FF
C7ED JP Z,$D331 If found, skip out of routine
C7F0 LD BC,$0010 Prep counter to copy 16 bytes
C7F3 CP $00 If the first byte is zero...
C7F5 JR NZ,$C7FA
C7F7 ADD HL,BC ...then this room item is no longer present, so skip to the next data bank of 16 bytes
C7F8 JR $C7EA ...and keep checking the data banks
Copy room item data from data bank into working data buffer at EB43
C7FA LD DE,$EB43 Copy data from 16 byte data bank at 7C00 to EB43
C7FD LDIR
C7FF LD ($EABC),HL Store address pointer, now at the start of the next 16 byte data set
C802 LD A,($EB4E) Item properties byte
C805 AND %11111011 Reset bit 2 of this data byte - to indicate this particular room item doesn't needs erasing prior to drawing
C807 LD ($EB4E),A ...and restore
C80A LD HL,($EB51) Get graphic address pointer to this item's graphics, in the address pointer table at 97C3
C80D LD ($EACD),HL ...and store.
Calculate and store this item's horizontal room co-ordinates. Horizontal half-character (4-pixel) position is converted to pixel position and stored at EAD3.
The carry bit is used in the calculation to store (at EAD4) a flag indicating where the item is in the room, and is set to 0 (visible part of screen), 1 (right of the visible screen) or 255 (left of the visible screen).
C810 LD HL,($EB47) H = Graphic horizontal position within current room, in half character (4 pixel) steps (H = EB48, L = EB47). L contains an overflow from this.
C813 ADD HL,HL x 2
C814 SBC A,A If carry set, set A to 255, otherwise 0
C815 ADD HL,HL x 4 to complete conversion of horizontal position from half-characters to pixels
C816 RLA If carry set, rotate carry bit into A register
C817 LD ($EAD4),A ...and store as the high byte, e.g. 0 = in room viewport, 1 = to the right of the viewport, 255 = to the left of the viewport
C81A LD A,H Get horizontal screen pixel position
C81B LD ($EAD3),A ...and store.
The next instructions check bit 4 of the Graphic properties byte (this bit is unused).
C81E LD A,($EB4F) This is the pre-graphics data byte (Graphic properties)
C821 AND $10 Check if bit 4 set (16)
C823 JR Z,$C837 If it's NOT set, jump to C837
None of the graphics has bit 4 (16) set, so these instructions aren't run (which add an offset to the graphic address pointer):
C825 LD HL,($EB51) ---
C828 ADD HL,DE ---
C829 ADD HL,DE ---
C82A LD ($EB51),HL ---
C82D LD A,($EB4E) ---
C830 OR $04 ---
C832 LD ($EB4E),A ---
C835 JR $C841 ---
Prev: C7D0 Up: Map Next: C837