Prev: C996 Up: Map Next: CA76
C9BF: Process Display Record
Used by the routine at ProcessObjectDisplayEntry.
HL points at a display record (flags, value, optional handler word, optional five extra bytes). Checks the record against the current object, character and graphics, runs its handler if bit 6 is set, and then either returns the address after the record (bit 7 set) or runs the code that follows it via CA64. A non-zero return means the script step succeeded.
ProcessDisplayRecord C9BF PUSH HL Point IY at the display record and call CheckObjectVisibility to check whether the object is visible.
C9C0 POP IY
C9C2 CALL CheckObjectVisibility
C9C5 JR NC,ProcessDisplayRecord_TestHandler Go to ProcessDisplayRecord_TestHandler if CheckObjectVisibility finds the object is not visible.
Bit 5 of the record flags is clear?
C9C7 LD A,(IY+$00) Jump to ProcessDisplayRecord_TestHandler if bit 5 of the record flags is clear.
C9CA AND $20
C9CC JR Z,ProcessDisplayRecord_TestHandler
C9CE LD HL,$CBBB Point HL at the failure step at CBBB.
ProcessDisplayRecord_Fail C9D1 XOR A Clear A.
C9D2 RET Return.
Test the character field, the graphics field and the handler bit.
ProcessDisplayRecord_TestHandler C9D3 CALL TestLowBitsOfCharacter Go to ProcessDisplayRecord_Fail if the character test on this record fails.
C9D6 JR Z,ProcessDisplayRecord_Fail
C9D8 CALL TestLowBitsOfGraphics Go to ProcessDisplayRecord_Fail if the graphics test on this record fails.
C9DB JR Z,ProcessDisplayRecord_Fail
C9DD BIT 6,(IY+$00) Skip ahead to ProcessDisplayRecord_TestParser unless bit 6 of the record flags is set.
C9E1 JR Z,ProcessDisplayRecord_TestParser
C9E3 LD L,(IY+$02) Read the handler word at bytes 02/03 of the record and save IY.
C9E6 LD H,(IY+$03)
C9E9 PUSH IY
C9EB CALL $CB34 Run the handler via CB34.
C9EE POP IY Restore IY from the stack.
C9F0 JR Z,ProcessDisplayRecord_Fail Go to ProcessDisplayRecord_Fail if the handler returns zero.
ProcessDisplayRecord_TestParser C9F2 LD A,($A00B) Jump to ProcessDisplayRecord_StoreCount if the parser flag at A00B is set.
C9F5 AND A
C9F6 JR NZ,ProcessDisplayRecord_StoreCount
C9F8 OR %00000001 Reset the zero flag.
C9FA RET Return.
Take the high nibble of the record's value byte (01) as the count and store it at CharacterScriptCycles.
ProcessDisplayRecord_StoreCount C9FB PUSH IY Save the record pointer and read the value byte (01).
C9FD LD A,(IY+$01)
CA00 RRCA Shift that byte down by four bits.
CA01 RRCA
CA02 RRCA
CA03 RRCA
CA04 AND $0F Keep the high nibble.
CA06 LD L,A Use that nibble as the low byte of the count.
CA07 LD H,$00 Clear the high byte.
CA09 LD ($A01F),HL Store the count at CharacterScriptCycles.
ProcessDisplayRecord_ComputeLength CA0C POP HL Restore the record address from the stack.
CA0D LD DE,$0002 Step over the two-byte header.
CA10 ADD HL,DE
CA11 BIT 6,(IY+$00) Skip ahead to ProcessDisplayRecord_TestFiveExtraBytes unless bit 6 of the record flags is set.
CA15 JR Z,ProcessDisplayRecord_TestFiveExtraBytes
CA17 ADD HL,DE Step over the handler word.
ProcessDisplayRecord_TestFiveExtraBytes CA18 LD DE,$0005 Skip ahead to ProcessDisplayRecord_SaveAttributes unless bit 4 of the record flags is set.
CA1B BIT 4,(IY+$00)
CA1F JR Z,ProcessDisplayRecord_SaveAttributes
CA21 ADD HL,DE Step over the five extra bytes.
ProcessDisplayRecord_SaveAttributes CA22 LD A,($A00A) Read the character attribute and store it in the workspace byte at C491.
CA25 LD ($C491),A
CA28 LD IX,($A013) Point IX at the current object.
CA2C LD A,(IX+$0F) Read the object's attribute and store it in the workspace byte at C492, then save the address after the record.
CA2F LD ($C492),A
CA32 PUSH HL
CA33 PUSH IY Save the record, store 01 in the parser flag at A00C, and call ReadSavedCharacter.
CA35 LD A,$01
CA37 LD ($A00C),A
CA3A CALL ReadSavedCharacter
CA3D POP IY Restore the pointers from the stack.
CA3F POP HL
CA40 BIT 7,(IY+$00) And skip ahead to ProcessDisplayRecord_FillLocationLow unless bit 7 of the record flags is set.
CA44 JR Z,ProcessDisplayRecord_FillLocationLow
CA46 SCF Set the carry.
CA47 RET Return with HL pointing past the record, so the script resumes there.
Fill a location byte that is still FF from the room parameters.
ProcessDisplayRecord_FillLocationLow CA48 LD A,($9FD7) Go to ProcessDisplayRecord_FillLocationHigh unless the low byte of LocationValue is FF.
CA4B INC A
CA4C JR NZ,ProcessDisplayRecord_FillLocationHigh
CA4E LD A,($A034) Copy the room display parameter into LocationValue.
CA51 LD ($9FD7),A
ProcessDisplayRecord_FillLocationHigh CA54 LD A,($9FD8) Go to ProcessDisplayRecord_RunFollowingCode unless the high byte of LocationValue is FF.
CA57 INC A
CA58 JR NZ,ProcessDisplayRecord_RunFollowingCode
CA5A LD A,($A035) Copy the room graphics parameter into the high byte of LocationValue.
CA5D LD ($9FD8),A
ProcessDisplayRecord_RunFollowingCode CA60 XOR A Clear the flag at CAAE and run the code that follows the record (at HL) via RunDisplayRecordCode.
CA61 LD ($CAAE),A
CA64 CALL RunDisplayRecordCode
CA67 PUSH AF Call ReadCharacterTimetable, saving result and the pointer.
CA68 PUSH HL
CA69 CALL ReadCharacterTimetable
CA6C LD A,($CAAE) Call CheckCharacterDisguise if the room flag at CAAE is clear.
CA6F AND A
CA70 CALL Z,CheckCharacterDisguise
CA73 POP HL Restore the pointer from the stack.
CA74 POP AF Restore AF from the stack.
CA75 RET Return.
Prev: C996 Up: Map Next: CA76