Skip to content

Commit

Permalink
Make the crypt boss's eye flash when hit
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsteele committed Feb 26, 2024
1 parent 4ce6519 commit b1697a7
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 182 deletions.
27 changes: 13 additions & 14 deletions src/chr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ _chr_begin:
chr_res $06
chr_inc "anim_conveyor_0"
chr_res $05
chr_inc "anim_boss_lava_2", kTileIdBgAnimBossLavaFirst
chr_inc "anim_boss_lava_2", kTileIdBgAnimBossLavaFirst
chr_inc "anim_rocks_fall_0"
chr_inc "gazer_anim0"
chr_inc "anim_boss_crypt_0", kTileIdBgAnimBossCryptFirst
END_CHR_BANK
.ENDPROC

Expand All @@ -288,9 +288,9 @@ _chr_begin:
chr_res $06
chr_inc "anim_conveyor_1"
chr_res $05
chr_inc "anim_boss_lava_1", kTileIdBgAnimBossLavaFirst
chr_inc "anim_boss_lava_1", kTileIdBgAnimBossLavaFirst
chr_inc "anim_rocks_fall_1"
chr_inc "gazer_anim1"
chr_inc "anim_boss_crypt_1", kTileIdBgAnimBossCryptFirst
END_CHR_BANK
.ENDPROC

Expand All @@ -304,9 +304,9 @@ _chr_begin:
chr_res $06
chr_inc "anim_conveyor_2"
chr_res $05
chr_inc "anim_boss_lava_2", kTileIdBgAnimBossLavaFirst
chr_inc "anim_boss_lava_2", kTileIdBgAnimBossLavaFirst
chr_inc "anim_rocks_fall_2"
chr_inc "gazer_anim2"
chr_inc "anim_boss_crypt_2", kTileIdBgAnimBossCryptFirst
END_CHR_BANK
.ENDPROC

Expand All @@ -320,9 +320,9 @@ _chr_begin:
chr_res $06
chr_inc "anim_conveyor_3"
chr_res $05
chr_inc "anim_boss_lava_3", kTileIdBgAnimBossLavaFirst
chr_inc "anim_boss_lava_3", kTileIdBgAnimBossLavaFirst
chr_inc "anim_rocks_fall_3"
chr_inc "gazer_anim3"
chr_inc "anim_boss_crypt_3", kTileIdBgAnimBossCryptFirst
END_CHR_BANK
.ENDPROC

Expand Down Expand Up @@ -460,11 +460,10 @@ _chr_begin:
chr_inc "crypt"
chr_res $02
chr_inc "cobweb"
chr_res $08
chr_inc "gazer_eye"
chr_res $04
chr_inc "arch"
chr_res $0c
chr_inc "boss_crypt_eye_white", kTileIdBgBossCryptEyeWhiteFirst
chr_inc "arch"
chr_inc "boss_crypt_eye_red", kTileIdBgBossCryptEyeRedFirst
END_CHR_BANK
.ENDPROC

Expand Down Expand Up @@ -1066,8 +1065,8 @@ _chr_begin:
chr_inc "boss_garden_eye_mini", kTileIdObjBossGardenEyeMiniFirst
chr_inc "boss_garden_eye_red", kTileIdObjBossGardenEyeRedFirst
chr_inc "platform_crypt_bricks", kTileIdObjPlatformCryptBricksFirst
chr_inc "gazer_obj", kTileIdObjGazerFirst
chr_res $09
chr_inc "boss_crypt_pupil", kTileIdObjBossCryptPupilFirst
chr_res $08
chr_inc "minigun_vert", kTileIdObjMinigunVertFirst
chr_inc "crusher", kTileIdObjCrusherFirst
chr_inc "winch", kTileIdObjWinchFirst
Expand Down
1 change: 1 addition & 0 deletions src/ppu.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
;;; Copies one or more transfer entries into the PPU transfer buffer.
;;; @param AX Pointer to the start of the transfer entry(ies) to copy.
;;; @param Y The number of bytes to buffer (including any transfer headers).
;;; @preserve T3+
.EXPORT Func_BufferPpuTransfer
.PROC Func_BufferPpuTransfer
stax T1T0 ; pointer to start of data to copy
Expand Down
83 changes: 76 additions & 7 deletions src/rooms/boss_crypt.asm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
.IMPORT Ram_MachineState1_byte_arr
.IMPORT Ram_PlatformLeft_i16_0_arr
.IMPORT Ram_PlatformTop_i16_0_arr
.IMPORT Ram_PpuTransfer_arr
.IMPORTZP Zp_Active_sIrq
.IMPORTZP Zp_Buffered_sIrq
.IMPORTZP Zp_Chr04Bank_u8
Expand All @@ -90,6 +91,7 @@
.IMPORTZP Zp_NextIrq_int_ptr
.IMPORTZP Zp_PointX_i16
.IMPORTZP Zp_PointY_i16
.IMPORTZP Zp_PpuTransferLen_u8
.IMPORTZP Zp_RoomScrollY_u8
.IMPORTZP Zp_RoomState
.IMPORTZP Zp_ShapePosX_i16
Expand Down Expand Up @@ -188,10 +190,8 @@ kBossHurtMoveDistPx = 60

;;;=========================================================================;;;

;;; The OBJ tile ID for the pupil of the boss's eye.
kTileIdObjBossPupil = kTileIdObjGazerFirst + 0
;;; The OBJ palette number to use for the pupil of the boss's eye.
kPaletteObjBossPupil = 0
kPaletteObjBossPupil = 1

;;;=========================================================================;;;

Expand Down Expand Up @@ -699,6 +699,23 @@ _Dir_eEyeDir_arr8:
.byte eEyeDir::Down, eEyeDir::DownLeft, eEyeDir::Left, eEyeDir::Left
.ENDPROC

;;; A template (with unset payload bytes) for a pair of PPU transfer entries
;;; for changing the BG tiles of the boss's eye.
.PROC DataC_Boss_CryptEyeTransferTemplate_arr
.assert kBossWidthTiles = 6, error
.assert kBossHeightTiles = 4, error
;; Column 2:
.byte kPpuCtrlFlagsVert
.dbyt Ppu_BossRow1Start + 2 ; transfer destination
.byte 2 ; transfer length
.res 2
;; Column 3:
.byte kPpuCtrlFlagsVert
.dbyt Ppu_BossRow1Start + 3 ; transfer destination
.byte 2 ; transfer length
.res 2
.ENDPROC

;;; Draw function for the crypt boss.
;;; @prereq PRGA_Objects is loaded.
.PROC FuncC_Boss_Crypt_DrawBoss
Expand Down Expand Up @@ -737,15 +754,64 @@ _SetUpIrq:
sub Zp_ShapePosY_i16 + 0
sub Zp_RoomScrollY_u8
sta <(Zp_Buffered_sIrq + sIrq::Param2_byte) ; boss scroll-Y
_CalculateBossEyeLean:
lda #0 ; TODO: calculate eye lean offset from X-velocity
sta T4 ; eye lean offset (-2, 0, or 2)
_CalculateBossEyeFlash:
;; If the boss is hurt, make its eye flash.
ldx #0
lda Zp_RoomState + sState::Current_eBossMode
cmp #eBossMode::Hurt
bne @noFlash
lda Zp_FrameCounter_u8
and #$02
beq @noFlash
ldx #$10
@noFlash:
stx T3 ; flash bit (0 or $10)
_DrawBossPupil:
;; Adjust the shape position to the top left of the boss's 1x1 pupil shape.
ldx Zp_RoomState + sState::Boss_eEyeDir
lda _EyeOffsetX_u8_arr, x ; param: offset
sub T4 ; eye lean offset (-2, 0, or 2)
jsr FuncA_Objects_MoveShapeLeftByA ; preserves X
lda _EyeOffsetY_u8_arr, x ; param: offset
jsr FuncA_Objects_MoveShapeUpByA
;; Draw the pupil white or red, depending on the flash bit.
lda T3 ; flash bit (0 or $10)
div #$10
.assert kTileIdObjBossCryptPupilFirst .mod 2 = 0, error
ora #kTileIdObjBossCryptPupilFirst ; param: tile ID
ldy #kPaletteObjBossPupil ; param: object flags
lda #kTileIdObjBossPupil ; param: tile ID
jsr FuncA_Objects_Draw1x1Shape
jsr FuncA_Objects_Draw1x1Shape ; preserves T2+
_TransferBossEye:
;; We're going to buffer a PPU transfer to update the BG tiles for the
;; boss's eye. Start by copying the transfer template into the buffer,
;; leaving X as the index for the start of the transfer entries.
lda Zp_PpuTransferLen_u8
pha ; transfer start
ldax #DataC_Boss_CryptEyeTransferTemplate_arr ; param: data pointer
ldy #.sizeof(DataC_Boss_CryptEyeTransferTemplate_arr) ; param: data length
jsr Func_BufferPpuTransfer ; preserves T3+
pla ; transfer start
tax ; transfer start
;; Fill in the payloads of the two transfer entries with the BG tile IDs to
;; set, taking the eye lean offset and flash bit into account.
lda T4 ; eye lean offset (-2, 0, or 2)
mul #2
add #kTileIdBgBossCryptEyeWhiteFirst + 4
.linecont +
.assert kTileIdBgBossCryptEyeWhiteFirst | $10 = \
kTileIdBgBossCryptEyeRedFirst, error
ora T3 ; flash bit (0 or $10)
sta Ram_PpuTransfer_arr + 4 + 0, x
add #1
sta Ram_PpuTransfer_arr + 4 + 1, x
adc #1
sta Ram_PpuTransfer_arr + 4 + 2 + 4 + 0, x
adc #1
sta Ram_PpuTransfer_arr + 4 + 2 + 4 + 1, x
.linecont -
_DrawSideWalls:
ldx #kLeftWallPlatformIndex ; param: platform index
jsr FuncA_Objects_DrawPlatformCryptBricksVert
Expand Down Expand Up @@ -903,17 +969,20 @@ _Return:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_BossRow0Start ; transfer destination
.byte 6
.assert kTileIdBgAnimBossCryptFirst = $6c, error
.byte $6c, $6d, $6e, $6f, $70, $71
;; Row 1:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_BossRow1Start ; transfer destination
.byte 6
.byte $72, $73, $a4, $a6, $74, $75
.assert kTileIdBgBossCryptEyeWhiteFirst = $a4, error
.byte $72, $73, $a8, $aa, $74, $75
;; Row 2:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_BossRow2Start ; transfer destination
.byte 6
.byte $7c, $7d, $a5, $a7, $7e, $7f
.assert kTileIdBgBossCryptEyeWhiteFirst = $a4, error
.byte $7c, $7d, $a9, $ab, $7e, $7f
;; Row 3:
.byte kPpuCtrlFlagsHorz
.dbyt Ppu_BossRow3Start ; transfer destination
Expand Down
7 changes: 6 additions & 1 deletion src/rooms/boss_crypt.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
;;; with Annalog. If not, see <http://www.gnu.org/licenses/>. ;;;
;;;=========================================================================;;;

;;; BG tile IDs for drawing the crypt boss.
kTileIdBgAnimBossCryptFirst = $6c
kTileIdBgBossCryptEyeRedFirst = $b4
kTileIdBgBossCryptEyeWhiteFirst = $a4

;;; OBJ tile IDs for drawing the crypt boss.
kTileIdObjGazerFirst = $ce
kTileIdObjBossCryptPupilFirst = $ce

;;;=========================================================================;;;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions src/tiles/boss_crypt_eye_red.ahi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ahi1 f0 p1 i3 w16 h16

;0;982220;ECEEEC;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0

0033111111130000
3311111111130000
1111222211130003
1121222122113331
1222221222211111
1112222222211111
2221222221221111
2222222222111111
2222222221221111
2212222222221111
1122222222211111
1222222221211111
1122221222113331
1111212211130003
3311111111130000
0033111111130000

0003111111113000
0003111111113000
3331112222111333
1111212221221111
1112222212222111
1111122222222111
1122212222212211
1122222222221111
1122222222212211
1122122222222211
1111222222222111
1112222222212111
1111222212221111
3331112122111333
0003111111113000
0003111111113000

0000311111113300
0000311111111133
3000311122221111
1333112122212211
1111122222122221
1111111222222221
1111222122222122
1111222222222211
1111222222222122
1111221222222222
1111112222222221
1111122222222121
1333112222122211
3000311121221111
0000311111111133
0000311111113300
26 changes: 13 additions & 13 deletions src/tiles/gazer_eye.ahi → src/tiles/boss_crypt_eye_white.ahi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ahi1 f0 p1 i3 w16 h16

0008;0;54;ECEEEC;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0
;0;982220;ECEEEC;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0

0031111111130000
0311111111300000
3111333311130003
0033111111130000
3311111111130000
1111333311130003
1132333233113331
1333332333311111
1223333333311111
Expand All @@ -15,9 +15,9 @@ ahi1 f0 p1 i3 w16 h16
1233333333311111
1333333332311111
1133332333113331
3111323311130003
0311111111300000
0031111111130000
1111323311130003
3311111111130000
0033111111130000

0003111111113000
0003111111113000
Expand All @@ -36,9 +36,9 @@ ahi1 f0 p1 i3 w16 h16
0003111111113000
0003111111113000

0000311111111300
0000031111111130
3000311133331113
0000311111113300
0000311111111133
3000311133331111
1333113233323311
1111133333233331
1111122333333331
Expand All @@ -49,6 +49,6 @@ ahi1 f0 p1 i3 w16 h16
1111123333333331
1111133333333231
1333113333233311
3000311132331113
0000031111111130
0000311111111300
3000311132331111
0000311111111133
0000311111113300
21 changes: 21 additions & 0 deletions src/tiles/boss_crypt_pupil.ahi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ahi1 f0 p1 i2 w8 h8

;0;982220;ECEEEC;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0;FF0

00333300
03333330
33311333
33111133
33111133
33311333
03333330
00333300

00222200
02222220
22211222
22111122
22111122
22211222
02222220
00222200
Loading

0 comments on commit b1697a7

Please sign in to comment.