Prev: 55653 Up: Map Next: 55843
55665: Continue Bad Tempered Thing Dialogue
Used by the routine at Update_Bad_Tempered_Thing_Dialogue.
Continuation of Update_Bad_Tempered_Thing_Dialogue after the dialogue table at Data_BadTemperedThingDialogue.
Continue_Bad_Tempered_Thing_Dialogue 55665 LD A,(29358) Load A with the current task index (CurrentTaskIndex).
55668 OR A Is A zero? If not, jump to Update_Bad_Tempered_Thing_Dialogue_IndexTable.
55669 JR NZ,Update_Bad_Tempered_Thing_Dialogue_IndexTable
55671 LD HL,55245 Point HL at Bad Tempered Thing dialogue bytes (55245).
55674 SET 0,(HL) Mark this Bad Tempered Thing aside as already shown (bit 0 of 55245).
55676 LD HL,55910 Point HL at Messaging: Task Menu Options (Messaging_WhatNext).
55679 LD A,6 Load A with 6.
55681 JR Update_Bad_Tempered_Thing_Dialogue_Hit Jump to Update_Bad_Tempered_Thing_Dialogue_Hit to pick a random dialogue variant.
Index the per-task dialogue table at Data_BadTemperedThingDialogue by the current task.
Update_Bad_Tempered_Thing_Dialogue_IndexTable 55683 ADD A,A Double A.
55684 LD E,A Copy A into E for later use.
55685 LD D,0 Clear D (high byte of a pointer/offset).
55687 LD HL,55653 Point HL at the dialogue table (Data_BadTemperedThingDialogue).
55690 ADD HL,DE Add the offset in DE to the pointer in HL.
55691 LD E,(HL) Fetch the dialogue pointer into DE.
55692 INC HL
55693 LD D,(HL)
55694 EX DE,HL Swap the destination and source pointers in DE/HL.
Skip join markers (&) and walk B fragments to the gated line.
Update_Bad_Tempered_Thing_Dialogue_SkipJoinMarkers 55695 CALL Advance_DialogueCharacter Call Advance_DialogueCharacter to advance Dialogue Character.
55698 CP 38 Is A equal to 38? If so, jump to Update_Bad_Tempered_Thing_Dialogue_SkipJoinMarkers.
55700 JR Z,Update_Bad_Tempered_Thing_Dialogue_SkipJoinMarkers
55702 DJNZ Update_Bad_Tempered_Thing_Dialogue_SkipJoinMarkers Decrease the loop counter in B and jump to Update_Bad_Tempered_Thing_Dialogue_SkipJoinMarkers if more iterations remain.
If the gate byte is non-zero, decrement it and fall back to a random aside; else start Part A.
Update_Bad_Tempered_Thing_Dialogue_GateByteOrAside 55704 LD A,(HL) Fetch the byte at HL.
55705 OR A Is A zero? If so, jump to Update_Bad_Tempered_Thing_Dialogue_PartA.
55706 JR Z,Update_Bad_Tempered_Thing_Dialogue_PartA
55708 DEC (HL) Decrease the counter/flag byte at HL.
55709 CALL Advance_DialogueCharacter Call Advance_DialogueCharacter to advance Dialogue Character.
55712 CP 38 Is A equal to 38? If so, jump to Update_Bad_Tempered_Thing_Dialogue_GateByteOrAside.
55714 JR Z,Update_Bad_Tempered_Thing_Dialogue_GateByteOrAside
55716 LD HL,55245 Point HL at Bad Tempered Thing dialogue bytes (55245).
55719 SET 0,(HL) Set bit 0 of 55245 (aside-already-shown).
55721 LD HL,56604 Point HL at 56604.
55724 LD A,4 Load A with 4.
Pick a random aside variant and skip that many fragments before printing.
Update_Bad_Tempered_Thing_Dialogue_Hit 55726 CALL PseudoRandom Call PseudoRandom to pick a pseudo-random value.
55729 INC A Turn the random roll into a 1-based skip count.
55730 LD B,A Copy A into B for later use.
Consume the remaining skip count via Advance_DialogueCharacter, then enter the print setup at Update_Bad_Tempered_Thing_Dialogue_PartB.
Update_Bad_Tempered_Thing_Dialogue_Exit 55731 CALL Advance_DialogueCharacter Call Advance_DialogueCharacter to advance Dialogue Character.
55734 DJNZ Update_Bad_Tempered_Thing_Dialogue_Exit Decrease the loop counter in B and jump to Update_Bad_Tempered_Thing_Dialogue_Exit if more iterations remain.
55736 JR Update_Bad_Tempered_Thing_Dialogue_PartB Jump to Update_Bad_Tempered_Thing_Dialogue_PartB to continue Bad Tempered Thing dialogue.
Seed a fresh random gate byte (1..3) when the previous gate hit zero.
Update_Bad_Tempered_Thing_Dialogue_PartA 55738 LD A,3 Load A with 3.
55740 CALL PseudoRandom Call PseudoRandom to pick a pseudo-random value.
55743 INC A Turn the random roll into a 1-based gate value.
55744 LD (HL),A Set the byte at HL.
55745 INC HL Advance past the freshly written gate byte.
This entry point is used by the routine at Update_Bad_Tempered_Thing_Dialogue.
Stash the dialogue string pointer and begin measuring the fragment length.
Update_Bad_Tempered_Thing_Dialogue_PartB 55746 PUSH HL Stash HL on the stack.
55747 LD E,0 Load E with 0.
Count characters until a fragment ([) or join (&) marker.
Update_Bad_Tempered_Thing_Dialogue_PartC 55749 LD A,(HL) Fetch the byte at HL.
55750 CP 91 Is A equal to 91? If so, jump to Update_Bad_Tempered_Thing_Dialogue_PartD.
55752 JR Z,Update_Bad_Tempered_Thing_Dialogue_PartD
55754 CP 38 Is A equal to 38? If so, jump to Update_Bad_Tempered_Thing_Dialogue_PartD.
55756 JR Z,Update_Bad_Tempered_Thing_Dialogue_PartD
55758 INC E Advance the low byte of the pointer/offset in DE.
55759 INC HL Advance through the dialogue fragment.
55760 JR Update_Bad_Tempered_Thing_Dialogue_PartC Jump to Update_Bad_Tempered_Thing_Dialogue_PartC to fetch the next dialogue byte.
Compute left padding so the line centres within the 23-character dialogue strip.
Update_Bad_Tempered_Thing_Dialogue_PartD 55762 LD A,23 Load A with 23.
55764 SUB E Subtract E from A.
55765 JR NC,Update_Bad_Tempered_Thing_Dialogue_PartE If no borrow/miss was signaled, jump to Update_Bad_Tempered_Thing_Dialogue_PartE.
55767 XOR A Clear A to 0.
Halve that padding, restore the string pointer into IX, and aim HL at 23233 (attribute buffer).
Update_Bad_Tempered_Thing_Dialogue_PartE 55768 SRL A Shift the flag/value in A right one bit.
55770 POP IX Pop the dialogue string pointer into IX.
55772 LD HL,23233 Load HL with 23233 (attribute buffer).
55775 LD E,A Copy A into E for later use.
55776 LD D,0 Clear D (high byte of a pointer/offset).
55778 ADD HL,DE Add the offset in DE to the pointer in HL.
Draw each dialogue character via Draw_DialogueCharacter, saving the cursor in 55246 / 55248.
Update_Bad_Tempered_Thing_Dialogue_PartF 55779 LD E,(IX+0) Load E with the next dialogue character code from *(IX).
55782 LD D,0 Clear D (high byte of a pointer/offset).
55784 CALL Draw_DialogueCharacter Call Draw_DialogueCharacter to draw Dialogue Character.
55787 INC IX Advance the dialogue source pointer by one character.
55789 INC HL Advance the attribute-file destination by one column.
55790 LD (55246),IX Store IX in 55246.
55794 LD (55248),HL Store HL in 55248.
55797 LD A,(IX+0) Fetch the next dialogue byte from *(IX).
55800 CP 91 Is A equal to 91? If so, jump to Update_Bad_Tempered_Thing_Dialogue_PartG.
55802 JR Z,Update_Bad_Tempered_Thing_Dialogue_PartG
55804 CP 38 Is A equal to 38? If not, return.
55806 RET NZ
End of line: clear the aside-shown bit, restore Berk's layout, and arm the 254 cooldown.
Update_Bad_Tempered_Thing_Dialogue_PartG 55807 LD HL,55245 Point HL at Bad Tempered Thing dialogue bytes (55245).
55810 RES 0,(HL) Clear bit 0 of 55245 (aside-already-shown).
55812 LD HL,40094 Point HL at GraphicLayout_Boney.
55815 LD (36595),HL Write that layout pointer to Boney's graphic-layout field (Pointer_BoneyGraphicLayout).
55818 LD A,(29383) Load A with the Bad Tempered Thing state (BadTemperedThingState).
55821 OR A Is A zero? If so, return.
55822 RET Z
55823 LD A,254 Load A with 254.
55825 LD (29383),A Set the Bad Tempered Thing state (BadTemperedThingState).
55828 LD A,47 Load A with 47.
55830 LD (55250),A Set the Bad Tempered Thing dialogue state (55250).
55833 RET Return.
This entry point is used by the routine at Update_Bad_Tempered_Thing_Dialogue.
Resume a mid-line print from the saved 55246 / 55248 cursors.
Update_Bad_Tempered_Thing_Dialogue_PartH 55834 LD IX,(55246) Load IX from 55246.
55838 LD HL,(55248) Load HL from 55248.
55841 JR Update_Bad_Tempered_Thing_Dialogue_PartF Jump to Update_Bad_Tempered_Thing_Dialogue_PartF to reload the entity type for dialogue.
Prev: 55653 Up: Map Next: 55843