From 381f61a0c1f64512e8facba55ff09a0245a08333 Mon Sep 17 00:00:00 2001 From: "Matthew D. Steele" Date: Tue, 26 Mar 2024 16:50:44 -0400 Subject: [PATCH] Implement simpler conditional branches for dialog --- src/dialog.asm | 37 +++++++++++------ src/dialog.inc | 27 +++++++++++-- src/rooms/city_building2.asm | 56 +++++++------------------- src/rooms/city_building6.asm | 11 +----- src/rooms/city_outskirts.asm | 15 +++---- src/rooms/core_boss.asm | 72 +++++++++------------------------- src/rooms/core_south.asm | 11 +----- src/rooms/factory_east.asm | 11 +----- src/rooms/factory_elevator.asm | 13 +----- src/rooms/factory_vault.asm | 12 +----- src/rooms/garden_east.asm | 24 ++---------- src/rooms/mermaid_hut1.asm | 6 +-- src/rooms/mermaid_hut2.asm | 11 +----- src/rooms/mermaid_hut3.asm | 11 +----- src/rooms/mermaid_hut4.asm | 25 ++++-------- src/rooms/mermaid_spring.asm | 56 +++++++++----------------- src/rooms/mermaid_village.asm | 18 ++------- src/rooms/prison_upper.asm | 46 ++++++---------------- src/rooms/temple_entry.asm | 41 ++++--------------- 19 files changed, 150 insertions(+), 353 deletions(-) diff --git a/src/dialog.asm b/src/dialog.asm index 622baa85..0e2d1267 100644 --- a/src/dialog.asm +++ b/src/dialog.asm @@ -24,6 +24,7 @@ .INCLUDE "device.inc" .INCLUDE "devices/dialog.inc" .INCLUDE "dialog.inc" +.INCLUDE "flag.inc" .INCLUDE "hud.inc" .INCLUDE "joypad.inc" .INCLUDE "macros.inc" @@ -69,8 +70,7 @@ .IMPORT DataA_Dialog_MermaidHut4Florist_sDialog .IMPORT DataA_Dialog_MermaidHut5Marie_sDialog .IMPORT DataA_Dialog_MermaidHut5Nora_sDialog -.IMPORT DataA_Dialog_MermaidSpringAlex1_sDialog -.IMPORT DataA_Dialog_MermaidSpringAlex2_sDialog +.IMPORT DataA_Dialog_MermaidSpringAlex_sDialog .IMPORT DataA_Dialog_MermaidSpringSign_sDialog .IMPORT DataA_Dialog_MermaidVillageAlex_sDialog .IMPORT DataA_Dialog_MermaidVillageBruno_sDialog @@ -146,6 +146,7 @@ .IMPORT Func_AllocOneObject .IMPORT Func_BufferPpuTransfer .IMPORT Func_ClearRestOfOamAndProcessFrame +.IMPORT Func_IsFlagSet .IMPORT Func_SetFlag .IMPORT Func_TryPushAvatarHorz .IMPORT Func_Window_GetRowPpuAddr @@ -264,7 +265,6 @@ Zp_DialogTextCol_u8: .res 1 ;;; dialog question, and is set to false ($00) whenever the player chooses ;;; "no". Dynamic dialog functions can read this variable to react to the ;;; player's choice. -.EXPORTZP Zp_DialogAnsweredYes_bool Zp_DialogAnsweredYes_bool: .res 1 ;;; A pointer to the next sDialog entry to execute. @@ -474,8 +474,7 @@ _Finish: d_entry t, MermaidHut4Florist, DataA_Dialog_MermaidHut4Florist_sDialog d_entry t, MermaidHut5Marie, DataA_Dialog_MermaidHut5Marie_sDialog d_entry t, MermaidHut5Nora, DataA_Dialog_MermaidHut5Nora_sDialog - d_entry t, MermaidSpringAlex1, DataA_Dialog_MermaidSpringAlex1_sDialog - d_entry t, MermaidSpringAlex2, DataA_Dialog_MermaidSpringAlex2_sDialog + d_entry t, MermaidSpringAlex, DataA_Dialog_MermaidSpringAlex_sDialog d_entry t, MermaidSpringSign, DataA_Dialog_MermaidSpringSign_sDialog d_entry t, MermaidVillageAlex, DataA_Dialog_MermaidVillageAlex_sDialog d_entry t, MermaidVillageBruno, DataA_Dialog_MermaidVillageBruno_sDialog @@ -788,7 +787,7 @@ _ReadPortraitByte: cmp #ePortrait::NUM_VALUES blt _SetPortrait _DialogFunction: - tax ; entry kind (kDialogEntryCall or kDialogEntryFunc) + tax ; entry kind (kDialogEntryBranch/Call/Func/Goto) lda (Zp_Next_sDialog_ptr), y sta T0 iny @@ -799,18 +798,34 @@ _DialogFunction: beq @entryGoto cpx #kDialogEntryFunc beq @entryFunc - @entryCall: - jsr _UpdateDialogPointer - jsr _CallT1T0 - jmp _ReadPortraitByte + cpx #kDialogEntryCall + beq @entryCall + @entryBranch: + lda (Zp_Next_sDialog_ptr), y + tax ; eFlag value to branch on + iny + jsr _UpdateDialogPointer ; preserves X and T0+ + txa ; eFlag value to branch on + .assert eFlag::None = 0, error + bne @checkFlag + bit Zp_DialogAnsweredYes_bool + bmi @entryGoto + bpl _ReadPortraitByte ; unconditional + @checkFlag: + jsr Func_IsFlagSet ; preserves T0+, returns Z + beq _ReadPortraitByte @entryGoto: ldya T1T0 - bmi @setNext ; unconditional (enforced by dlg_Goto macro) + bmi @setNext ; unconditional (enforced by dlg_Goto/dlg_If* macros) @entryFunc: jsr _CallT1T0 ; returns YA @setNext: stya Zp_Next_sDialog_ptr jmp _ReadPortraitByte + @entryCall: + jsr _UpdateDialogPointer ; preserves T0+ + jsr _CallT1T0 + jmp _ReadPortraitByte _CallT1T0: jmp (T1T0) _StartCutscene: diff --git a/src/dialog.inc b/src/dialog.inc index 90dc0cab..d6232ee7 100644 --- a/src/dialog.inc +++ b/src/dialog.inc @@ -64,7 +64,8 @@ ;;; Special constants used in place of an ePortrait value for doing dialog ;;; control flow. -.ASSERT $fa >= ePortrait::NUM_VALUES, error +.ASSERT $f9 >= ePortrait::NUM_VALUES, error +kDialogEntryBranch = $f9 ; conditionally jumps to a sDialog, else continues kDialogEntryCall = $fa ; calls a function, then continues the sDialog kDialogEntryFunc = $fb ; calls a function that returns next sDialog in YA kDialogEntryGoto = $fc ; jumps to the specified sDialog @@ -112,8 +113,7 @@ kDialogEntryCutscene = $ff ; ends the dialog and starts a new cutscene MermaidHut4Florist MermaidHut5Marie MermaidHut5Nora - MermaidSpringAlex1 - MermaidSpringAlex2 + MermaidSpringAlex MermaidSpringSign MermaidVillageAlex MermaidVillageBruno @@ -209,6 +209,25 @@ kDialogTextYesNo = $ff .addr LABEL .ENDMACRO +;;; Expands to a sDialog entry that jumps to another sDialog entry if the +;;; specified flag is set, and otherwise continues to the next entry. +.MACRO dlg_IfSet FLAG, LABEL + .assert LABEL >= $8000, error + .byte kDialogEntryBranch + .addr LABEL + .byte eFlag::FLAG +.ENDMACRO + +;;; Expands to a sDialog entry that jumps to another sDialog entry if the +;;; player answered "YES" to the previous YES/NO dialog question, and otherwise +;;; continues to the next entry. +.MACRO dlg_IfYes LABEL + .assert LABEL >= $8000, error + .byte kDialogEntryBranch + .addr LABEL + .byte 0 +.ENDMACRO + ;;; Expands to a sDialog entry that calls a dynamic dialog function. .MACRO dlg_Func LABEL .assert LABEL >= $8000, error @@ -226,7 +245,7 @@ kDialogTextYesNo = $ff ;;; Expands to a sDialog entry that adds a quest marker before continuing. .MACRO dlg_Quest FLAG .byte kDialogEntryQuest - .byte FLAG + .byte eFlag::FLAG .ENDMACRO ;;; Expands to a sDialog entry indicating the end of the dialog. diff --git a/src/rooms/city_building2.asm b/src/rooms/city_building2.asm index a896110f..efa1fb45 100644 --- a/src/rooms/city_building2.asm +++ b/src/rooms/city_building2.asm @@ -30,7 +30,6 @@ .IMPORT DataA_Room_Building_sTileset .IMPORT Data_Empty_sActor_arr -.IMPORT Data_Empty_sDialog .IMPORT FuncA_Objects_Draw1x1Shape .IMPORT FuncA_Objects_MoveShapeLeftByA .IMPORT FuncA_Objects_SetShapePosToPlatformTopLeft @@ -39,7 +38,6 @@ .IMPORT Func_SetFlag .IMPORT Ppu_ChrObjCity .IMPORT Sram_ProgressFlags_arr -.IMPORTZP Zp_DialogAnsweredYes_bool .IMPORTZP Zp_FrameCounter_u8 .IMPORTZP Zp_RoomState @@ -204,53 +202,27 @@ _Devices_sDevice_arr: .EXPORT DataA_Dialog_CityBuilding2Screen_sDialog .PROC DataA_Dialog_CityBuilding2Screen_sDialog - dlg_Func _InitialFunc -_InitialFunc: - ;; If the eastern door in CityCenter has already been unlocked, display a - ;; message to that effect. - flag_bit Sram_ProgressFlags_arr, eFlag::CityCenterDoorUnlocked - beq @doorStillLocked - ;; For safety, connect the key generator (even though you shouldn't - ;; normally be able to unlock the door without connecting the key generator - ;; first). - ldx #eFlag::CityCenterKeygenConnected ; param: flag - jsr Func_SetFlag - ldya #_Unlocked_sDialog - rts - @doorStillLocked: - ;; Otherwise, if the key generator has already been connected to the - ;; western semaphore, display a message to that effect. - flag_bit Sram_ProgressFlags_arr, eFlag::CityCenterKeygenConnected - beq @notYetConnected - ldya #_AlreadyConnected_sDialog - rts - ;; Otherwise, prompt the player to connect the key generator. - @notYetConnected: - ldya #_Unconnected_sDialog - rts -_Unconnected_sDialog: + dlg_IfSet CityCenterDoorUnlocked, _Unlocked_sDialog dlg_Text Screen, DataA_Text0_CityBuilding2Screen_Locked_u8_arr + dlg_IfSet CityCenterKeygenConnected, _Connected_sDialog +_Unconnected_sDialog: dlg_Text Screen, DataA_Text0_CityBuilding2Screen_Question_u8_arr - dlg_Func _QuestionFunc -_QuestionFunc: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #Data_Empty_sDialog - rts - @yes: - ldx #eFlag::CityCenterKeygenConnected ; param: flag - jsr Func_SetFlag - ldya #_NowConnected_sDialog - rts -_AlreadyConnected_sDialog: - dlg_Text Screen, DataA_Text0_CityBuilding2Screen_Locked_u8_arr -_NowConnected_sDialog: + dlg_IfYes _Connected_sDialog + dlg_Done +_Connected_sDialog: + dlg_Call _ConnectKeygen dlg_Text Screen, DataA_Text0_CityBuilding2Screen_Connected_u8_arr dlg_Done _Unlocked_sDialog: + ;; For safety, connect the key generator (even though you shouldn't + ;; normally be able to unlock the door without connecting the key generator + ;; first). + dlg_Call _ConnectKeygen dlg_Text Screen, DataA_Text0_CityBuilding2Screen_Unlocked_u8_arr dlg_Done +_ConnectKeygen: + ldx #eFlag::CityCenterKeygenConnected ; param: flag + jmp Func_SetFlag .ENDPROC ;;;=========================================================================;;; diff --git a/src/rooms/city_building6.asm b/src/rooms/city_building6.asm index 1a5a90ae..dc524afb 100644 --- a/src/rooms/city_building6.asm +++ b/src/rooms/city_building6.asm @@ -169,16 +169,7 @@ _Devices_sDevice_arr: .EXPORT DataA_Dialog_CityBuilding6Screen_sDialog .PROC DataA_Dialog_CityBuilding6Screen_sDialog - dlg_Func _InitialFunc -_InitialFunc: - ;; If the door has already been unlocked, display a message to that effect. - flag_bit Sram_ProgressFlags_arr, eFlag::CityCenterDoorUnlocked - beq @doorStillLocked - ldya #_Unlocked_sDialog - rts - @doorStillLocked: - ldya #_Locked_sDialog - rts + dlg_IfSet CityCenterDoorUnlocked, _Unlocked_sDialog _Locked_sDialog: dlg_Text Screen, DataA_Text0_CityBuilding2Screen_Locked_u8_arr dlg_Done diff --git a/src/rooms/city_outskirts.asm b/src/rooms/city_outskirts.asm index 19d25c05..46cf8c38 100644 --- a/src/rooms/city_outskirts.asm +++ b/src/rooms/city_outskirts.asm @@ -377,15 +377,10 @@ _Look_sCutscene: .EXPORT DataA_Dialog_CityOutskirtsAlex1_sDialog .PROC DataA_Dialog_CityOutskirtsAlex1_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::CityOutskirtsTalkedToAlex - bne @meetAtHotSpring - ldya #_YouMadeIt_sDialog - rts - @meetAtHotSpring: - ldya #DataA_Dialog_CityOutskirtsMeetAtHotSpring_sDialog - rts + .linecont + + dlg_IfSet CityOutskirtsTalkedToAlex, \ + DataA_Dialog_CityOutskirtsMeetAtHotSpring_sDialog + .linecont - _YouMadeIt_sDialog: dlg_Text ChildAlex, DataA_Text1_CityOutskirtsAlex_Part1_u8_arr dlg_Text ChildAlex, DataA_Text1_CityOutskirtsAlex_Part2_u8_arr @@ -398,7 +393,7 @@ _YouMadeIt_sDialog: dlg_Text ChildAlex, DataA_Text1_CityOutskirtsAlex_Part4_u8_arr dlg_Text ChildAlex, DataA_Text1_CityOutskirtsAlex_Part5_u8_arr dlg_Call _MakeAlexFaceAnna - dlg_Quest eFlag::CityOutskirtsTalkedToAlex + dlg_Quest CityOutskirtsTalkedToAlex dlg_Goto DataA_Dialog_CityOutskirtsMeetAtHotSpring_sDialog _MakeAlexFaceAnna: lda #$00 diff --git a/src/rooms/core_boss.asm b/src/rooms/core_boss.asm index 78f8c821..bd6e4a4b 100644 --- a/src/rooms/core_boss.asm +++ b/src/rooms/core_boss.asm @@ -42,7 +42,6 @@ .INCLUDE "../scroll.inc" .IMPORT DataA_Room_Core_sTileset -.IMPORT Data_Empty_sDialog .IMPORT FuncA_Machine_BlasterHorzTryAct .IMPORT FuncA_Machine_BlasterTickMirrors .IMPORT FuncA_Machine_BlasterWriteRegMirrors @@ -138,7 +137,6 @@ .IMPORTZP Zp_BreakerBeingActivated_eFlag .IMPORTZP Zp_Camera_bScroll .IMPORTZP Zp_Current_sMachine_ptr -.IMPORTZP Zp_DialogAnsweredYes_bool .IMPORTZP Zp_FrameCounter_u8 .IMPORTZP Zp_Next_eCutscene .IMPORTZP Zp_PointX_i16 @@ -2099,43 +2097,26 @@ _MakeFinalTerminalAppear: dlg_Text OrcGronta, DataA_Text1_CoreBossGrontaIntro_Part1_u8_arr dlg_Text OrcGronta, DataA_Text1_CoreBossGrontaIntro_Part2_u8_arr dlg_Text OrcGronta, DataA_Text1_CoreBossGrontaIntro_Demand_u8_arr - dlg_Func _DemandFunc -_DemandFunc: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_PreparedToFight_sDialog - rts - @yes: - ldya #_HandItOver_sDialog - rts -_HandItOver_sDialog: + dlg_IfYes _HandItOverQuestion_sDialog +_PreparedToFightQuestion_sDialog: + dlg_Text OrcGronta, DataA_Text1_CoreBossGrontaIntro_PreparedToFight_u8_arr + dlg_IfYes _BeginFight_sDialog +_HandItOverQuestion_sDialog: dlg_Text OrcGronta, DataA_Text1_CoreBossGrontaIntro_HandItOver_u8_arr - dlg_Func _HandItOverFunc -_HandItOverFunc: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_PreparedToFight_sDialog - rts - @yes: + dlg_IfYes _TossRemote_sDialog + dlg_Goto _PreparedToFightQuestion_sDialog +_BeginFight_sDialog: + dlg_Call _LockScrolling + dlg_Done +_TossRemote_sDialog: + dlg_Call _TossRemote + dlg_Done +_TossRemote: lda #eGrontaPhase::GettingRemote sta Zp_RoomState + sState::Current_eGrontaPhase - bne _EndDialogFunc ; unconditional -_PreparedToFight_sDialog: - dlg_Text OrcGronta, DataA_Text1_CoreBossGrontaIntro_PreparedToFight_u8_arr - dlg_Func _PreparedToFightFunc -_PreparedToFightFunc: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_HandItOver_sDialog - rts - @yes: -_EndDialogFunc: +_LockScrolling: lda #bScroll::LockHorz sta Zp_Camera_bScroll - ldya #Data_Empty_sDialog rts .ENDPROC @@ -2159,28 +2140,11 @@ _EndDialogFunc: dlg_Text Screen, DataA_Text1_CoreBossScreen_Intro_u8_arr _ReactivateQuestion_sDialog: dlg_Text Screen, DataA_Text1_CoreBossScreen_Reactivate_u8_arr - dlg_Func @func - @func: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_SelfDestructQuestion_sDialog - rts - @yes: - ldya #_ReactivateCutscene_sDialog - rts + dlg_IfYes _ReactivateCutscene_sDialog _SelfDestructQuestion_sDialog: dlg_Text Screen, DataA_Text1_CoreBossScreen_SelfDestruct_u8_arr - dlg_Func @func - @func: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_ReactivateQuestion_sDialog - rts - @yes: - ldya #_SelfDestructCutscene_sDialog - rts + dlg_IfYes _SelfDestructCutscene_sDialog + dlg_Goto _ReactivateQuestion_sDialog _ReactivateCutscene_sDialog: dlg_Cutscene eCutscene::CoreBossFinaleReactivate _SelfDestructCutscene_sDialog: diff --git a/src/rooms/core_south.asm b/src/rooms/core_south.asm index 0688f357..03dac006 100644 --- a/src/rooms/core_south.asm +++ b/src/rooms/core_south.asm @@ -467,16 +467,7 @@ _AnimateSwimmingUpFunc: .EXPORT DataA_Dialog_CoreSouthCorra_sDialog .PROC DataA_Dialog_CoreSouthCorra_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::CoreSouthCorraHelped - beq @helloAgain - @alreadyHelped: - ldya #_AlreadyHelped_sDialog - rts - @helloAgain: - ldya #_HelloAgain_sDialog - rts + dlg_IfSet CoreSouthCorraHelped, _AlreadyHelped_sDialog _HelloAgain_sDialog: dlg_Text MermaidCorra, DataA_Text0_CoreSouthCorra1_HelloAgain1_u8_arr dlg_Text MermaidCorra, DataA_Text0_CoreSouthCorra1_HelloAgain2_u8_arr diff --git a/src/rooms/factory_east.asm b/src/rooms/factory_east.asm index 85ce1c58..a2be2469 100644 --- a/src/rooms/factory_east.asm +++ b/src/rooms/factory_east.asm @@ -400,16 +400,7 @@ _AnimateSwimmingUpFunc: .EXPORT DataA_Dialog_FactoryEastCorra_sDialog .PROC DataA_Dialog_FactoryEastCorra_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::FactoryEastCorraHelped - bne @alreadyHelped - @offerHelp: - ldya #_OfferHelp_sDialog - rts - @alreadyHelped: - ldya #_AlreadyHelped_sDialog - rts + dlg_IfSet FactoryEastCorraHelped, _AlreadyHelped_sDialog _OfferHelp_sDialog: dlg_Text MermaidCorra, DataA_Text1_FactoryEastCorra_Part1_u8_arr dlg_Cutscene eCutscene::FactoryEastCorraHelping diff --git a/src/rooms/factory_elevator.asm b/src/rooms/factory_elevator.asm index 209568bc..48dd54a1 100644 --- a/src/rooms/factory_elevator.asm +++ b/src/rooms/factory_elevator.asm @@ -618,23 +618,14 @@ _WriteL: .EXPORT DataA_Dialog_FactoryElevatorBrunoHi_sDialog .PROC DataA_Dialog_FactoryElevatorBrunoHi_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::FactoryElevatorTalkedToBruno - bne @aLot - @whew: - ldya #_Whew_sDialog - rts - @aLot: - ldya #_ALot_sDialog - rts + dlg_IfSet FactoryElevatorTalkedToBruno, _ALot_sDialog _Whew_sDialog: dlg_Text ChildBruno, DataA_Text2_FactoryElevatorBruno_Hi1_u8_arr _ALot_sDialog: dlg_Text ChildBruno, DataA_Text2_FactoryElevatorBruno_Hi2_u8_arr dlg_Text ChildBruno, DataA_Text2_FactoryElevatorBruno_Hi3_u8_arr dlg_Text ChildBruno, DataA_Text2_FactoryElevatorBruno_Hi4_u8_arr - dlg_Quest eFlag::FactoryElevatorTalkedToBruno + dlg_Quest FactoryElevatorTalkedToBruno dlg_Text ChildBruno, DataA_Text2_FactoryElevatorBruno_Hi5_u8_arr dlg_Done .ENDPROC diff --git a/src/rooms/factory_vault.asm b/src/rooms/factory_vault.asm index e544d1f4..3db69227 100644 --- a/src/rooms/factory_vault.asm +++ b/src/rooms/factory_vault.asm @@ -161,21 +161,13 @@ _Passages_sPassage_arr: .EXPORT DataA_Dialog_FactoryVaultAlex_sDialog .PROC DataA_Dialog_FactoryVaultAlex_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::FactoryVaultTalkedToAlex - bne @meetAtHotSpring - ldya #_WhatDidYouFindOut_sDialog - rts - @meetAtHotSpring: - ldya #_MeetAtHotSpring_sDialog - rts + dlg_IfSet FactoryVaultTalkedToAlex, _MeetAtHotSpring_sDialog _WhatDidYouFindOut_sDialog: dlg_Text ChildAlex, DataA_Text0_FactoryVaultAlex_Part1_u8_arr dlg_Text ChildAlex, DataA_Text0_FactoryVaultAlex_Part2_u8_arr dlg_Text ChildAlex, DataA_Text0_FactoryVaultAlex_Part3_u8_arr dlg_Text ChildAlex, DataA_Text0_FactoryVaultAlex_Part4_u8_arr - dlg_Quest eFlag::FactoryVaultTalkedToAlex + dlg_Quest FactoryVaultTalkedToAlex _MeetAtHotSpring_sDialog: dlg_Text ChildAlex, DataA_Text0_FactoryVaultAlex_Part5_u8_arr dlg_Done diff --git a/src/rooms/garden_east.asm b/src/rooms/garden_east.asm index 01bdb52c..1a343146 100644 --- a/src/rooms/garden_east.asm +++ b/src/rooms/garden_east.asm @@ -63,7 +63,6 @@ .IMPORT Ram_DeviceType_eDevice_arr .IMPORT Ram_MachineGoalVert_u8_arr .IMPORT Sram_ProgressFlags_arr -.IMPORTZP Zp_DialogAnsweredYes_bool .IMPORTZP Zp_RoomState ;;;=========================================================================;;; @@ -462,34 +461,17 @@ _Done: .EXPORT DataA_Dialog_GardenEastCorra_sDialog .PROC DataA_Dialog_GardenEastCorra_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::GardenEastTalkedToCorra - bne @alreadyTalked - ldya #_Question_sDialog - rts - @alreadyTalked: - ldya #_Later_sDialog - rts + dlg_IfSet GardenEastTalkedToCorra, _Later_sDialog _Question_sDialog: dlg_Text MermaidCorra, DataA_Text0_GardenEastCorra_Question_u8_arr - dlg_Func @func - @func: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_NoAnswer_sDialog - rts - @yes: - ldya #_YesAnswer_sDialog - rts + dlg_IfYes _YesAnswer_sDialog _NoAnswer_sDialog: dlg_Text MermaidCorra, DataA_Text0_GardenEastCorra_No_u8_arr _YesAnswer_sDialog: dlg_Text MermaidCorra, DataA_Text0_GardenEastCorra_Yes_u8_arr _Later_sDialog: dlg_Text MermaidCorra, DataA_Text0_GardenEastCorra_MeetQueen_u8_arr - dlg_Quest eFlag::GardenEastTalkedToCorra + dlg_Quest GardenEastTalkedToCorra dlg_Text MermaidCorra, DataA_Text0_GardenEastCorra_MarkMap_u8_arr dlg_Done .ENDPROC diff --git a/src/rooms/mermaid_hut1.asm b/src/rooms/mermaid_hut1.asm index 22e18a3a..883e8f0a 100644 --- a/src/rooms/mermaid_hut1.asm +++ b/src/rooms/mermaid_hut1.asm @@ -333,7 +333,7 @@ _FirstMeeting_sDialog: dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_FirstMeeting4_u8_arr _GrantAsylum_sDialog: dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_GrantAsylum_u8_arr - dlg_Quest eFlag::MermaidHut1MetQueen + dlg_Quest MermaidHut1MetQueen dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_HelpFarmers_u8_arr dlg_Done _GardenBossDead_sDialog: @@ -341,7 +341,7 @@ _GardenBossDead_sDialog: dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_GardenBossDead2_u8_arr _TempleProblem_sDialog: dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_TempleProblem_u8_arr - dlg_Quest eFlag::TempleEntryPermission + dlg_Quest TempleEntryPermission dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_TempleEntry_u8_arr dlg_Done _TempleBossDead_sDialog: @@ -352,7 +352,7 @@ _TempleBossDead_sDialog: dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_TempleBossDead5_u8_arr _OtherRuins_sDialog: dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_OtherRuins_u8_arr - dlg_Quest eFlag::CoreSouthCorraWaiting + dlg_Quest CoreSouthCorraWaiting dlg_Text MermaidEirene, DataA_Text2_MermaidHut1Queen_FindYourFriends_u8_arr dlg_Done _KidsRescued_sDialog: diff --git a/src/rooms/mermaid_hut2.asm b/src/rooms/mermaid_hut2.asm index 61eb7d22..9fa2ed09 100644 --- a/src/rooms/mermaid_hut2.asm +++ b/src/rooms/mermaid_hut2.asm @@ -30,7 +30,6 @@ .IMPORT DataA_Room_Hut_sTileset .IMPORT Func_Noop .IMPORT Ppu_ChrObjVillage -.IMPORT Sram_ProgressFlags_arr ;;;=========================================================================;;; @@ -113,15 +112,7 @@ _Devices_sDevice_arr: .EXPORT DataA_Dialog_MermaidHut2Guard_sDialog .PROC DataA_Dialog_MermaidHut2Guard_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::CityCenterEnteredCity - bne @impressed - ldya #_WatchOut_sDialog - rts - @impressed: - ldya #_Impressed_sDialog - rts + dlg_IfSet CityCenterEnteredCity, _Impressed_sDialog _WatchOut_sDialog: dlg_Text AdultMan, DataA_Text2_MermaidHut2Guard_WatchOut1_u8_arr dlg_Text AdultMan, DataA_Text2_MermaidHut2Guard_WatchOut2_u8_arr diff --git a/src/rooms/mermaid_hut3.asm b/src/rooms/mermaid_hut3.asm index 237f5f21..c2559761 100644 --- a/src/rooms/mermaid_hut3.asm +++ b/src/rooms/mermaid_hut3.asm @@ -31,7 +31,6 @@ .IMPORT DataA_Room_Hut_sTileset .IMPORT Func_Noop .IMPORT Ppu_ChrObjVillage -.IMPORT Sram_ProgressFlags_arr ;;;=========================================================================;;; @@ -133,15 +132,7 @@ _Devices_sDevice_arr: .EXPORT DataA_Dialog_MermaidHut3Daphne_sDialog .PROC DataA_Dialog_MermaidHut3Daphne_sDialog dlg_Text MermaidDaphne, DataA_Text0_MermaidHut3Daphne_Intro_u8_arr - dlg_Func _HotSpringFunc -_HotSpringFunc: - flag_bit Sram_ProgressFlags_arr, eFlag::MermaidSpringUnplugged - bne @unplugged - ldya #_HotSpringOpen_sDialog - rts - @unplugged: - ldya #_HotSpringClosed_sDialog - rts + dlg_IfSet MermaidSpringUnplugged, _HotSpringClosed_sDialog _HotSpringOpen_sDialog: dlg_Text MermaidDaphne, DataA_Text0_MermaidHut3Daphne_Open_u8_arr dlg_Done diff --git a/src/rooms/mermaid_hut4.asm b/src/rooms/mermaid_hut4.asm index bd1f1e33..c22ea71b 100644 --- a/src/rooms/mermaid_hut4.asm +++ b/src/rooms/mermaid_hut4.asm @@ -42,7 +42,6 @@ .IMPORT Ram_DeviceType_eDevice_arr .IMPORT Sram_CarryingFlower_eFlag .IMPORT Sram_ProgressFlags_arr -.IMPORTZP Zp_DialogAnsweredYes_bool .IMPORTZP Zp_RoomScrollY_u8 .IMPORTZP Zp_ShapePosX_i16 .IMPORTZP Zp_ShapePosY_i16 @@ -214,31 +213,19 @@ _PosY_u8_arr: _MeetFlorist_sDialog: dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_Meet1_u8_arr dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_Meet2_u8_arr - dlg_Func _QuestionFunc -_QuestionFunc: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_NeverMind_sDialog - rts - @yes: - ldx #eFlag::MermaidHut4MetFlorist ; param: flag - jsr Func_SetFlag - ldya #_Zero_sDialog - rts + dlg_IfYes _Zero_sDialog _NeverMind_sDialog: dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_NeverMind1_u8_arr dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_NeverMind2_u8_arr dlg_Done _BroughtFlower_sDialog: dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_Brought_u8_arr - dlg_Func _DeliverFlowerFunc -_DeliverFlowerFunc: ;; Mark that the player has met the florist (i.e. if the player brings a ;; flower before the initial meeting conversation, then we just won't do ;; that conversation). - ldx #eFlag::MermaidHut4MetFlorist ; param: flag - jsr Func_SetFlag + dlg_Call _MetFlorist + dlg_Func _DeliverFlowerFunc +_DeliverFlowerFunc: ;; Mark the carried flower as delivered. ldx Sram_CarryingFlower_eFlag ; param: flag jsr Func_SetFlag @@ -269,7 +256,11 @@ _CountFlowersFunc: d_entry table, 12, _Twelve_sDialog D_END .ENDREPEAT +_MetFlorist: + ldx #eFlag::MermaidHut4MetFlorist ; param: flag + jmp Func_SetFlag _Zero_sDialog: + dlg_Call _MetFlorist dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_Zero1_u8_arr dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_Zero2_u8_arr dlg_Text MermaidFlorist, DataA_Text1_MermaidHut4Florist_Zero3_u8_arr diff --git a/src/rooms/mermaid_spring.asm b/src/rooms/mermaid_spring.asm index 4f54c420..8ff8bf4f 100644 --- a/src/rooms/mermaid_spring.asm +++ b/src/rooms/mermaid_spring.asm @@ -247,14 +247,14 @@ _Devices_sDevice_arr: d_byte Type_eDevice, eDevice::TalkRight d_byte BlockRow_u8, 6 d_byte BlockCol_u8, 10 - d_byte Target_byte, eDialog::MermaidSpringAlex1 + d_byte Target_byte, eDialog::MermaidSpringAlex D_END .assert * - :- = kAlexDeviceIndexLeft * .sizeof(sDevice), error D_STRUCT sDevice d_byte Type_eDevice, eDevice::TalkLeft d_byte BlockRow_u8, 6 d_byte BlockCol_u8, 11 - d_byte Target_byte, eDialog::MermaidSpringAlex1 + d_byte Target_byte, eDialog::MermaidSpringAlex D_END .assert * - :- <= kMaxDevices * .sizeof(sDevice), error .byte eDevice::None @@ -480,7 +480,7 @@ _SpawnExplosionAtPoint: act_WalkNpcAlex kAlexActorIndex, $00b0 act_SetActorState1 kAlexActorIndex, eNpcChild::AlexStanding act_SetActorState2 kAlexActorIndex, 0 - act_RunDialog eDialog::MermaidSpringAlex2 + act_RunDialog eDialog::MermaidSpringAlex act_ContinueExploring _WalkAvatar_sCutscene: act_WalkAvatar $00a0 | kTalkRightAvatarOffset @@ -523,43 +523,23 @@ _FixConsole: .SEGMENT "PRGA_Dialog" -.EXPORT DataA_Dialog_MermaidSpringAlex1_sDialog -.PROC DataA_Dialog_MermaidSpringAlex1_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::MermaidSpringConsoleFixed - bne @outro - @intro: - ldya #_Intro_sDialog - rts - @outro: - ldya #DataA_Dialog_MermaidSpringAlex2_sDialog - rts +.EXPORT DataA_Dialog_MermaidSpringAlex_sDialog +.PROC DataA_Dialog_MermaidSpringAlex_sDialog + dlg_IfSet MermaidSpringConsoleFixed, _Fixed_sDialog _Intro_sDialog: - dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex1_Part1_u8_arr - dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex1_Part2_u8_arr - dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex1_Part3_u8_arr - dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex1_Part4_u8_arr + dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex_Part1_u8_arr + dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex_Part2_u8_arr + dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex_Part3_u8_arr + dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex_Part4_u8_arr dlg_Cutscene eCutscene::MermaidSpringFixConsole -.ENDPROC - -.EXPORT DataA_Dialog_MermaidSpringAlex2_sDialog -.PROC DataA_Dialog_MermaidSpringAlex2_sDialog - dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex2_u8_arr +_Fixed_sDialog: + dlg_Text ChildAlex, DataA_Text0_MermaidSpringAlex_Part5_u8_arr dlg_Done .ENDPROC .EXPORT DataA_Dialog_MermaidSpringSign_sDialog .PROC DataA_Dialog_MermaidSpringSign_sDialog - dlg_Func _InitialFunc -_InitialFunc: - flag_bit Sram_ProgressFlags_arr, eFlag::MermaidSpringUnplugged - bne @unplugged - ldya #_Open_sDialog - rts - @unplugged: - ldya #_Closed_sDialog - rts + dlg_IfSet MermaidSpringUnplugged, _Closed_sDialog _Open_sDialog: dlg_Text Sign, DataA_Text0_MermaidSpringSign_Open_u8_arr dlg_Done @@ -572,35 +552,35 @@ _Closed_sDialog: .SEGMENT "PRGA_Text0" -.PROC DataA_Text0_MermaidSpringAlex1_Part1_u8_arr +.PROC DataA_Text0_MermaidSpringAlex_Part1_u8_arr .byte "Thanks for coming. I$" .byte "hate to ask, but...$" .byte "well, you're the best$" .byte "with these machines.#" .ENDPROC -.PROC DataA_Text0_MermaidSpringAlex1_Part2_u8_arr +.PROC DataA_Text0_MermaidSpringAlex_Part2_u8_arr .byte "I'm convinced we'll$" .byte "find answers in that$" .byte "city, but every way$" .byte "in is blocked off.#" .ENDPROC -.PROC DataA_Text0_MermaidSpringAlex1_Part3_u8_arr +.PROC DataA_Text0_MermaidSpringAlex_Part3_u8_arr .byte "However, I think we$" .byte "can get there via the$" .byte "caves, by approaching$" .byte "from below.#" .ENDPROC -.PROC DataA_Text0_MermaidSpringAlex1_Part4_u8_arr +.PROC DataA_Text0_MermaidSpringAlex_Part4_u8_arr .byte "The mermaids aren't$" .byte "helping. But I found$" .byte "something they had$" .byte "stashed away...#" .ENDPROC -.PROC DataA_Text0_MermaidSpringAlex2_u8_arr +.PROC DataA_Text0_MermaidSpringAlex_Part5_u8_arr .byte "What do you think? I'd$" .byte "say it's time to start$" .byte "delving deeper around$" diff --git a/src/rooms/mermaid_village.asm b/src/rooms/mermaid_village.asm index 8a367155..dc4277d1 100644 --- a/src/rooms/mermaid_village.asm +++ b/src/rooms/mermaid_village.asm @@ -395,25 +395,15 @@ _RemoveAlex: dlg_Text ChildAlex, DataA_Text1_MermaidVillageAlex_Part2_u8_arr dlg_Text ChildAlex, DataA_Text1_MermaidVillageAlex_Part3_u8_arr dlg_Text ChildAlex, DataA_Text1_MermaidVillageAlex_Part4_u8_arr - dlg_Quest eFlag::TempleNaveAlexWaiting + dlg_Quest TempleNaveAlexWaiting dlg_Text ChildAlex, DataA_Text1_MermaidVillageAlex_Part5_u8_arr dlg_Cutscene eCutscene::MermaidVillageAlexLeave .ENDPROC .EXPORT DataA_Dialog_MermaidVillageGuard_sDialog .PROC DataA_Dialog_MermaidVillageGuard_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::BreakerTemple - bne @guarding - flag_bit Sram_ProgressFlags_arr, eFlag::TempleEntryPermission - bne @temple - @guarding: - ldya #_Guarding_sDialog - rts - @temple: - ldya #_Temple_sDialog - rts + dlg_IfSet BreakerTemple, _Guarding_sDialog + dlg_IfSet TempleEntryPermission, _Temple_sDialog _Guarding_sDialog: dlg_Text MermaidGuardF, DataA_Text1_MermaidVillageGuard_Guarding_u8_arr dlg_Done @@ -468,7 +458,7 @@ _NeedHelp_sDialog: dlg_Text MermaidFarmer, DataA_Text1_MermaidVillageFarmer_NeedHelp_u8_arr _Monster_sDialog: dlg_Text MermaidFarmer, DataA_Text1_MermaidVillageFarmer_Monster_u8_arr - dlg_Quest eFlag::GardenTowerCratesPlaced + dlg_Quest GardenTowerCratesPlaced dlg_Text MermaidFarmer, DataA_Text1_MermaidVillageFarmer_OpenTheWay_u8_arr dlg_Done _ThankYou_sDialog: diff --git a/src/rooms/prison_upper.asm b/src/rooms/prison_upper.asm index e1683843..c4af1786 100644 --- a/src/rooms/prison_upper.asm +++ b/src/rooms/prison_upper.asm @@ -694,55 +694,31 @@ _SetFlag: .EXPORT DataA_Dialog_PrisonUpperBruno_sDialog .PROC DataA_Dialog_PrisonUpperBruno_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::PrisonUpperFoundAlex - bne @climbUp - @adults: - ldya #_Adults_sDialog - rts - @climbUp: - ldya #_ClimbUp_sDialog - rts + dlg_IfSet PrisonUpperFoundAlex, _ClimbUp_sDialog _Adults_sDialog: dlg_Text ChildBruno, DataA_Text0_PrisonUpperBruno_Adults_u8_arr dlg_Done _ClimbUp_sDialog: dlg_Text ChildBruno, DataA_Text0_PrisonUpperBruno_ClimbUp_u8_arr - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::PrisonUpperLoosenedBrick - bne @dialogDone - @talkMarie: + dlg_IfSet PrisonUpperLoosenedBrick, Data_Empty_sDialog + dlg_Call _LookAtMarie + .assert kTileIdBgPortraitMarieFirst = kTileIdBgPortraitBrunoFirst, error + dlg_Goto DataA_Dialog_PrisonUpperMarie_LooseBrick_sDialog +_LookAtMarie: ldax #$0100 stax Zp_ScrollGoalX_u16 lda #kPaletteObjAvatarNormal sta Zp_AvatarFlags_bObj - .assert kTileIdBgPortraitMarieFirst = kTileIdBgPortraitBrunoFirst, error - ldya #DataA_Dialog_PrisonUpperMarie_LooseBrick_sDialog - rts - @dialogDone: - ldya #Data_Empty_sDialog rts .ENDPROC .EXPORT DataA_Dialog_PrisonUpperMarie_sDialog .PROC DataA_Dialog_PrisonUpperMarie_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::PrisonUpperLoosenedBrick - bne @standCareful - flag_bit Sram_ProgressFlags_arr, eFlag::PrisonUpperFoundAlex - bne @looseBrick - @talkToAlex: - ldya #_GoTalkToAlex_sDialog - rts - @looseBrick: - ldya #DataA_Dialog_PrisonUpperMarie_LooseBrick_sDialog - rts - @standCareful: - ldya #_StandCareful_sDialog - rts + dlg_IfSet PrisonUpperLoosenedBrick, _StandCareful_sDialog + .linecont + + dlg_IfSet PrisonUpperFoundAlex, \ + DataA_Dialog_PrisonUpperMarie_LooseBrick_sDialog + .linecont - _GoTalkToAlex_sDialog: dlg_Text ChildMarie, DataA_Text0_PrisonUpperMarie_GoTalkToAlex_u8_arr dlg_Done diff --git a/src/rooms/temple_entry.asm b/src/rooms/temple_entry.asm index c2f5ab70..09a2d8fe 100644 --- a/src/rooms/temple_entry.asm +++ b/src/rooms/temple_entry.asm @@ -50,7 +50,6 @@ .IMPORT Ram_PlatformTop_i16_1_arr .IMPORT Sram_ProgressFlags_arr .IMPORTZP Zp_AvatarState_bAvatar -.IMPORTZP Zp_DialogAnsweredYes_bool .IMPORTZP Zp_Next_eCutscene .IMPORTZP Zp_Next_sAudioCtrl .IMPORTZP Zp_PointY_i16 @@ -388,28 +387,10 @@ _MoveColumn: .EXPORT DataA_Dialog_TempleEntryCorraHi_sDialog .PROC DataA_Dialog_TempleEntryCorraHi_sDialog - dlg_Func @func - @func: - flag_bit Sram_ProgressFlags_arr, eFlag::TempleEntryTalkedToCorra - bne @alexAsked - @question: - ldya #_Question_sDialog - rts - @alexAsked: - ldya #_AlexAsked_sDialog - rts + dlg_IfSet TempleEntryTalkedToCorra, _AlexAsked_sDialog _Question_sDialog: dlg_Text MermaidCorra, DataA_Text2_TempleEntryCorra_Question_u8_arr - dlg_Func @func - @func: - bit Zp_DialogAnsweredYes_bool - bmi @yes - @no: - ldya #_NoAnswer_sDialog - rts - @yes: - ldya #_YesAnswer_sDialog - rts + dlg_IfYes _YesAnswer_sDialog _NoAnswer_sDialog: dlg_Text MermaidCorra, DataA_Text2_TempleEntryCorra_No_u8_arr dlg_Text MermaidCorra, DataA_Text2_TempleEntryCorra_Taught_u8_arr @@ -419,7 +400,7 @@ _YesAnswer_sDialog: dlg_Text MermaidCorra, DataA_Text2_TempleEntryCorra_Whom_u8_arr _AlexAsked_sDialog: dlg_Text MermaidCorra, DataA_Text2_TempleEntryCorra_AlexAsked_u8_arr - dlg_Quest eFlag::TempleEntryTalkedToCorra + dlg_Quest TempleEntryTalkedToCorra dlg_Text MermaidCorra, DataA_Text2_TempleEntryCorra_MarkMap_u8_arr dlg_Done .ENDPROC @@ -427,23 +408,17 @@ _AlexAsked_sDialog: .EXPORT DataA_Dialog_TempleEntryGuard_sDialog .PROC DataA_Dialog_TempleEntryGuard_sDialog dlg_Text MermaidGuardF, DataA_Text2_TempleEntryGuard_Intro_u8_arr - dlg_Func _CheckPermissionFunc -_CheckPermissionFunc: - flag_bit Sram_ProgressFlags_arr, eFlag::TempleEntryPermission - bne _RaiseColumnFunc - ldya #_NoPermission_sDialog - rts + dlg_IfSet TempleEntryPermission, _Enter_sDialog _NoPermission_sDialog: dlg_Text MermaidGuardF, DataA_Text2_TempleEntryGuard_NoPermission_u8_arr dlg_Done -_RaiseColumnFunc: - ldx #eFlag::TempleEntryColumnRaised ; param: flag - jsr Func_SetFlag - ldya #_Enter_sDialog - rts _Enter_sDialog: + dlg_Call _RaiseColumn dlg_Text MermaidGuardF, DataA_Text2_TempleEntryGuard_Enter_u8_arr dlg_Done +_RaiseColumn: + ldx #eFlag::TempleEntryColumnRaised ; param: flag + jmp Func_SetFlag .ENDPROC ;;;=========================================================================;;;