Skip to content

Commit

Permalink
Add circuit terrain to GardenTower room
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Oct 2, 2024
1 parent a9fb974 commit 7a3ca98
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
32 changes: 30 additions & 2 deletions src/rooms/garden_tower.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -55,13 +56,15 @@
.IMPORT Func_SetFlag
.IMPORT Func_SetPointToActorCenter
.IMPORT Func_ShakeRoom
.IMPORT Int_SetChr04ToParam3ThenLatchWindowFromParam4
.IMPORT Ppu_ChrBgAnimA0
.IMPORT Ppu_ChrBgAnimStatic
.IMPORT Ppu_ChrObjGarden
.IMPORT Ram_ActorPosY_i16_0_arr
.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

Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/rooms/garden_tower.bg
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions src/tilesets/garden.bg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7a3ca98

Please sign in to comment.