diff --git a/src/rooms/garden_tower.asm b/src/rooms/garden_tower.asm index 0c717f8..e5fbe75 100644 --- a/src/rooms/garden_tower.asm +++ b/src/rooms/garden_tower.asm @@ -22,6 +22,7 @@ .INCLUDE "../charmap.inc" .INCLUDE "../device.inc" .INCLUDE "../flag.inc" +.INCLUDE "../irq.inc" .INCLUDE "../machine.inc" .INCLUDE "../machines/cannon.inc" .INCLUDE "../macros.inc" @@ -55,6 +56,7 @@ .IMPORT Func_SetFlag .IMPORT Func_SetPointToActorCenter .IMPORT Func_ShakeRoom +.IMPORT Int_SetChr04ToParam3ThenLatchWindowFromParam4 .IMPORT Ppu_ChrBgAnimA0 .IMPORT Ppu_ChrBgAnimStatic .IMPORT Ppu_ChrObjGarden @@ -62,6 +64,7 @@ .IMPORT Ram_ActorPosY_i16_1_arr .IMPORT Ram_PlatformType_ePlatform_arr .IMPORT Sram_ProgressFlags_arr +.IMPORTZP Zp_Buffered_sIrq .IMPORTZP Zp_Chr04Bank_u8 .IMPORTZP Zp_RoomState @@ -83,6 +86,10 @@ kThornsFirstPlatformIndex = 4 ;;; The number of thorns platforms. kThornsNumPlatforms = 5 +;;; The screen pixel Y-position at which the circuit IRQ should change the +;;; CHR04 bank. +kCircuitChr04IrqY = $90 + ;;;=========================================================================;;; ;;; The index of the passage that is sometimes blocked by crates. @@ -540,19 +547,40 @@ _ResetMachine: _AnimateThorns: flag_bit Sram_ProgressFlags_arr, eFlag::BossGarden beq @bossAlive - ;; If the garden boss has been defeated, disable the BG thorns animation. + ;; If the garden boss has been defeated, disable the BG thorns animation, + ;; but animate the circuit normally. @bossDead: + lda Zp_Chr04Bank_u8 + sta Zp_Buffered_sIrq + sIrq::Param3_byte ; circuit CHR04 bank lda #<.bank(Ppu_ChrBgAnimStatic) sta Zp_Chr04Bank_u8 .assert <.bank(Ppu_ChrBgAnimStatic) > 0, error bne @done ; unconditional - ;; If the garden boss hasn't been defeated, animate the thorns. + ;; If the garden boss hasn't been defeated, animate the thorns, but make + ;; the circuit animation static. @bossAlive: lda Zp_RoomState + sState::ThornCounter_u8 div #4 and #$07 add #<.bank(Ppu_ChrBgAnimA0) sta Zp_Chr04Bank_u8 + lda #<.bank(Ppu_ChrBgAnimStatic) + sta Zp_Buffered_sIrq + sIrq::Param3_byte ; circuit CHR04 bank + @done: +_SetUpCircuitIrq: + ;; Compute the IRQ latch value to set between the top of the circuit + ;; animation zone and the top of the window (if any), and set that as + ;; Param4_byte. + lda #kCircuitChr04IrqY + sta T0 ; IRQ latch for circuit anim + rsub Zp_Buffered_sIrq + sIrq::Latch_u8 + blt @done ; window top is above circuit top + sta Zp_Buffered_sIrq + sIrq::Param4_byte ; window latch + ;; Set up our own sIrq struct to handle circuit animation. + lda T0 ; IRQ latch for lava + sta Zp_Buffered_sIrq + sIrq::Latch_u8 + ldax #Int_SetChr04ToParam3ThenLatchWindowFromParam4 + stax Zp_Buffered_sIrq + sIrq::FirstIrq_int_ptr @done: _BreakableWall: ;; If the breakble wall platform is completely destroyed, we're done. diff --git a/src/rooms/garden_tower.bg b/src/rooms/garden_tower.bg index 7198d73..fdccc6d 100644 --- a/src/rooms/garden_tower.bg +++ b/src/rooms/garden_tower.bg @@ -26,7 +26,7 @@ GAGFAM FI FMFLCHCIAIFKFM FJCH FAAL FMFLAK BF AGBL BL GEGAGAFJ FAFAFAFAFA BE ANFBFC BG BLAH AH FKFMFMFJ BCBOBEBN BF ANFKGDGD GAGFAM BE GGGHGI AH GB BEBM FAFAFA - FJ BF BL BLGB BL GC BEBC BABEBB - FJ BG AGAH GEFJ BL FA BCBGBD GPGKGK - FJ BF GB BLAHFIFJBL BKAH BE BF GMAL + FJ BF BL BLGB BL GBEC BEBC BABEBB + FJ BG AGAH GEFJ GCEBEC FA BCBGBD GPGKGK + FJ BF GB BLAHFIFJBL BKBLEAEBECBE BF GMAL FEFEFBFEFEFEFDGEGAGAGA GAGAGAGAGFFCFDFEFEFEFEFCFEFEFEFEFB diff --git a/src/tilesets/garden.bg b/src/tilesets/garden.bg index 85265de..17c8b1e 100644 --- a/src/tilesets/garden.bg +++ b/src/tilesets/garden.bg @@ -8,6 +8,7 @@ >terrain_shared_1 >thorns_anim0 >water_anim0 +>circuit_anim0 FMFN GIGJ ACADDE DEHPHB DN DIDJDJ DIDI DJ FOFPFEFF AAABACADDE DEHMHJDDDDDP DLDL DL @@ -17,8 +18,8 @@ DODPEC EC EGEHEGEFEEEH EMEBEDEN DEDFDGDHDMDPEC EGEH EEEF HEHFHL HPHFHF HAHI HEHBHLHMHNHAHKHBHPHBHF HL HCHHHJHDHEHPHLHMHJHDHAHEHBHFHAHKHBHBHPHBHFHCHNHKHGHFHKHPHBHG HEHBHGHGHBHPHLHMHN HKHFHEHBHLHKHGHFHCHDHMHD HAHBHFHEHBHFHMHJHN - HNHKHBHBHFHC HC HKHLHCHOHNHCHHHNHKHBHBHFHC - HBHFHKHL HAHLHEHKHFHHHNHMHJHNHA HIHKHBHLHA + JJJIJHJG HNHKHBHBHFHC HC HKHLHCHOHNHCHHHNHKHBHBHFHC + JJJIJHJG HBHFHKHL HAHLHEHKHFHHHNHMHJHNHA HIHKHBHLHA CACBCECFCEDBDACFDADAELELDADADADACI CJCI CJ DADADADBDADA CCCDCGCHCG CH CK CLCK CLCMCOCPCNEKCOCMCOEKCOCPCN EOEPCICJCICJ CIEPEOCJCIEPEOEPEOCJGAGBGAGBGAGBGA GB GAGB