Prev: 51606 Up: Map Next: 51830
51647: 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 51812. A non-zero return means the script step succeeded.
ProcessDisplayRecord 51647 PUSH HL Point IY at the display record and call CheckObjectVisibility to check whether the object is visible.
51648 POP IY
51650 CALL CheckObjectVisibility
51653 JR NC,ProcessDisplayRecord_TestHandler Go to ProcessDisplayRecord_TestHandler if CheckObjectVisibility finds the object is not visible.
Bit 5 of the record flags is clear?
51655 LD A,(IY+0) Jump to ProcessDisplayRecord_TestHandler if bit 5 of the record flags is clear.
51658 AND 32
51660 JR Z,ProcessDisplayRecord_TestHandler
51662 LD HL,52155 Point HL at the failure step at 52155.
ProcessDisplayRecord_Fail 51665 XOR A Clear A.
51666 RET Return.
Test the character field, the graphics field and the handler bit.
ProcessDisplayRecord_TestHandler 51667 CALL TestLowBitsOfCharacter Go to ProcessDisplayRecord_Fail if the character test on this record fails.
51670 JR Z,ProcessDisplayRecord_Fail
51672 CALL TestLowBitsOfGraphics Go to ProcessDisplayRecord_Fail if the graphics test on this record fails.
51675 JR Z,ProcessDisplayRecord_Fail
51677 BIT 6,(IY+0) Skip ahead to ProcessDisplayRecord_TestParser unless bit 6 of the record flags is set.
51681 JR Z,ProcessDisplayRecord_TestParser
51683 LD L,(IY+2) Read the handler word at bytes 2/3 of the record and save IY.
51686 LD H,(IY+3)
51689 PUSH IY
51691 CALL 52020 Run the handler via 52020.
51694 POP IY Restore IY from the stack.
51696 JR Z,ProcessDisplayRecord_Fail Go to ProcessDisplayRecord_Fail if the handler returns zero.
ProcessDisplayRecord_TestParser 51698 LD A,(40971) Jump to ProcessDisplayRecord_StoreCount if the parser flag at 40971 is set.
51701 AND A
51702 JR NZ,ProcessDisplayRecord_StoreCount
51704 OR %00000001 Reset the zero flag.
51706 RET Return.
Take the high nibble of the record's value byte (1) as the count and store it at CharacterScriptCycles.
ProcessDisplayRecord_StoreCount 51707 PUSH IY Save the record pointer and read the value byte (1).
51709 LD A,(IY+1)
51712 RRCA Shift that byte down by four bits.
51713 RRCA
51714 RRCA
51715 RRCA
51716 AND 15 Keep the high nibble.
51718 LD L,A Use that nibble as the low byte of the count.
51719 LD H,0 Clear the high byte.
51721 LD (40991),HL Store the count at CharacterScriptCycles.
ProcessDisplayRecord_ComputeLength 51724 POP HL Restore the record address from the stack.
51725 LD DE,2 Step over the two-byte header.
51728 ADD HL,DE
51729 BIT 6,(IY+0) Skip ahead to ProcessDisplayRecord_TestFiveExtraBytes unless bit 6 of the record flags is set.
51733 JR Z,ProcessDisplayRecord_TestFiveExtraBytes
51735 ADD HL,DE Step over the handler word.
ProcessDisplayRecord_TestFiveExtraBytes 51736 LD DE,5 Skip ahead to ProcessDisplayRecord_SaveAttributes unless bit 4 of the record flags is set.
51739 BIT 4,(IY+0)
51743 JR Z,ProcessDisplayRecord_SaveAttributes
51745 ADD HL,DE Step over the five extra bytes.
ProcessDisplayRecord_SaveAttributes 51746 LD A,(40970) Read the character attribute and store it in the workspace byte at 50321.
51749 LD (50321),A
51752 LD IX,(40979) Point IX at the current object.
51756 LD A,(IX+15) Read the object's attribute and store it in the workspace byte at 50322, then save the address after the record.
51759 LD (50322),A
51762 PUSH HL
51763 PUSH IY Save the record, store 1 in the parser flag at 40972, and call ReadSavedCharacter.
51765 LD A,1
51767 LD (40972),A
51770 CALL ReadSavedCharacter
51773 POP IY Restore the pointers from the stack.
51775 POP HL
51776 BIT 7,(IY+0) And skip ahead to ProcessDisplayRecord_FillLocationLow unless bit 7 of the record flags is set.
51780 JR Z,ProcessDisplayRecord_FillLocationLow
51782 SCF Set the carry.
51783 RET Return with HL pointing past the record, so the script resumes there.
Fill a location byte that is still 255 from the room parameters.
ProcessDisplayRecord_FillLocationLow 51784 LD A,(40919) Go to ProcessDisplayRecord_FillLocationHigh unless the low byte of LocationValue is 255.
51787 INC A
51788 JR NZ,ProcessDisplayRecord_FillLocationHigh
51790 LD A,(41012) Copy the room display parameter into LocationValue.
51793 LD (40919),A
ProcessDisplayRecord_FillLocationHigh 51796 LD A,(40920) Go to ProcessDisplayRecord_RunFollowingCode unless the high byte of LocationValue is 255.
51799 INC A
51800 JR NZ,ProcessDisplayRecord_RunFollowingCode
51802 LD A,(41013) Copy the room graphics parameter into the high byte of LocationValue.
51805 LD (40920),A
ProcessDisplayRecord_RunFollowingCode 51808 XOR A Clear the flag at 51886 and run the code that follows the record (at HL) via RunDisplayRecordCode.
51809 LD (51886),A
51812 CALL RunDisplayRecordCode
51815 PUSH AF Call ReadCharacterTimetable, saving result and the pointer.
51816 PUSH HL
51817 CALL ReadCharacterTimetable
51820 LD A,(51886) Call CheckCharacterDisguise if the room flag at 51886 is clear.
51823 AND A
51824 CALL Z,CheckCharacterDisguise
51827 POP HL Restore the pointer from the stack.
51828 POP AF Restore AF from the stack.
51829 RET Return.
Prev: 51606 Up: Map Next: 51830