aboutsummaryrefslogtreecommitdiff
path: root/entity
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-05-13 15:52:37 +0200
committerAstatin <[email protected]>2025-05-13 15:52:37 +0200
commitef9de76cd0bc313385b7edac3659e03ab36d3c1e (patch)
tree4125a1ba04438d8e9db5262d24b525f370a41f2f /entity
parentb0f9e2e6d53983faa9d213b40d2bd6a23473e134 (diff)
Add bugs and poison
Diffstat (limited to 'entity')
-rw-r--r--entity/actions.gbasm37
-rw-r--r--entity/bug.gbasm130
-rw-r--r--entity/bunny.gbasm78
-rw-r--r--entity/list.gbasm76
-rw-r--r--entity/penguin.gbasm2
5 files changed, 282 insertions, 41 deletions
diff --git a/entity/actions.gbasm b/entity/actions.gbasm
index 92c2c5f..5b16891 100644
--- a/entity/actions.gbasm
+++ b/entity/actions.gbasm
@@ -62,44 +62,7 @@ Entity_Action:
LD L, A
RET
-Turn_Jump_table:
- ; 00
- RET
- NOP
- NOP
- NOP
-
- ; 01
- JP =Move_Bunny
- NOP
-
- ; 02
- JP =Fox_Turn
- NOP
- ; 03
- JP =Cat_Turn
- NOP
-
- ; 04
- JP =Penguin_Turn
- NOP
-
- ; 05
- JP =QuestGoal_Turn
- NOP
-
- ; 06
- JP =Fimsh_Turn
- NOP
-
- ; 07
- JP =Mouse_Turn
- NOP
-
- ; 08
- JP =Frog_Turn
- NOP
Interaction_Jump_table:
; 00
diff --git a/entity/bug.gbasm b/entity/bug.gbasm
new file mode 100644
index 0000000..29e5b77
--- /dev/null
+++ b/entity/bug.gbasm
@@ -0,0 +1,130 @@
+Bug_Drop:
+ PUSH DE
+ LD D, $64
+ LD E, $02
+ CALL =RNG_Step
+ AND $03
+ CP $00
+ CALL Z, =Spawn_object
+ POP DE
+ RET
+
+Bug_Turn:
+ LD A, $mem_map_loading_flags
+ BIT 3, A
+ RET Z
+
+ PUSH HL
+ PUSH BC
+ PUSH DE
+ INC HL
+ LD A, (HL+)
+ LD B, A
+ LD A, (HL+)
+ LD C, A
+ LD A, (HL+)
+ LD D, A
+
+ .ENTITY_HEALTH_CHECK =.Skip_turn =Mouse_Drop
+ .ENTITY_FREEZE_SHIVER =.Skip_turn
+ .ENTITY_STATUS_SKIP_TURN =.Skip_turn
+
+ .RESET_BLINKING_MODE
+
+ LD A, $mem_moving_animation_step
+ CP $00
+ JR NZ, =.attack_end
+
+ .ENTITY_TRY_ATTACK =Poison_sight_check =Poison_Enemy_Attack =.attack_end
+ CALL =Walking
+ BIT 3, D
+ JR Z, =.attack_end
+ LD A, L
+ AND $f0
+ OR $0a
+ LD L, A
+ LD (HL), $05
+ LD A, (HL)
+ DBG
+ .attack_end:
+
+ .Mid_movement:
+ LD A, $mem_moving_animation_step
+ CP $07
+ JR NZ, =.Mid_movement.end
+
+ BIT 3, D
+ JR Z, =.Mid_movement.end
+
+ LD A, L
+ AND $f0
+ OR $0a
+ LD L, A
+ LD A, $05
+ CP (HL)
+ LD A, (HL)
+ JR NZ, =.Mid_movement.end
+
+ LD A, L
+ AND $f0
+ OR $0a
+ LD L, A
+ LD (HL), $00
+
+ LD A, D
+ RES 3, A
+ LD D, A
+ LD A, $01
+ .ADD_A_TO_DIRECTION_BC
+
+ .Mid_movement.Try_Walking:
+ PUSH DE
+ CALL =Walking
+ BIT 3, D
+ JR Z, =.Mid_movement.Walk_cancelled
+ LD A, L
+ AND $f0
+ OR $0a
+ LD L, A
+ LD (HL), $05
+ ADD SP, $02
+ JR =.Mid_movement.end
+ .Mid_movement.Walk_cancelled:
+ POP DE
+ RES 3, D
+ .Mid_movement.end:
+
+ .Die_After_Attack:
+ LD A, $mem_moving_animation_step
+ CP $07
+ JR NZ, =.Die_After_Attack.end
+ LD A, L
+ AND $f0
+ OR $07
+ LD L, A
+ BIT 2, (HL)
+ JR Z, =.Die_After_Attack.end
+
+ DEC HL
+
+ LD (HL), $00
+
+ .Die_After_Attack.end:
+
+ CALL =Entity_End_movement
+
+ .Skip_Turn:
+ LD A, L
+ AND $f0
+ LD L, A
+ INC HL
+ LD A, B
+ LD (HL+), A
+ LD A, C
+ LD (HL+), A
+ LD A, D
+ LD (HL+), A
+ POP DE
+ POP BC
+ POP HL
+ RET
diff --git a/entity/bunny.gbasm b/entity/bunny.gbasm
index dc04535..3806df4 100644
--- a/entity/bunny.gbasm
+++ b/entity/bunny.gbasm
@@ -6,6 +6,9 @@ Move_Bunny:
LD E, $02
.Normal_speed:
+ LD A, $00
+ LD $mem_bunny_status_tile, A
+
.Finish_unfreeze:
LD A, $mem_moving_animation_step
CP $00
@@ -18,12 +21,14 @@ Move_Bunny:
.Finish_unfreeze.end:
.Freeze_shiver:
- LD A, $mem_moving_animation_step
- CP $00
- JP NZ, =.Freeze_shiver.end
LD A, $mem_bunny_status
CP $01
JR NZ, =.Freeze_shiver.end
+ LD A, $f5
+ LD $mem_bunny_status_tile, A
+ LD A, $mem_moving_animation_step
+ CP $00
+ JP NZ, =.Freeze_shiver.end
LD A, $mem_bunny_direction
RES 3, A
LD $mem_bunny_direction, A
@@ -55,6 +60,73 @@ Move_Bunny:
JP =.Skip_turn
.Freeze_shiver.end:
+ .Poison_effect:
+ LD A, $mem_bunny_status
+ CP $08
+ JR NZ, =.Poison_effect.end
+ LD A, $f6
+ LD $mem_bunny_status_tile, A
+ LD A, $mem_moving_animation_step
+ CP $0c
+ JR NZ, =.Poison_effect.end
+
+ LD A, $mem_bunny_status_clear_turn_counter
+ DEC A
+ CP $00
+ LD $mem_bunny_status_clear_turn_counter, A
+ JR Z, =.Unpoison
+
+ CALL =RNG_Step
+ AND $07
+ CP $00
+ JR Z, =.Unpoison
+
+ CALL =RNG_Step
+ AND $01
+ CP $00
+ JR Z, =.Poison_effect.end
+
+ PUSH BC
+ LD A, $mem_moving_animation_step
+ LD B, A
+ LD A, $1f
+ SUB B
+ LD $mem_blinking_animation_counter, A
+ LD A, $mem_bunny_flags
+ SET 3, A
+ LD $mem_bunny_flags, A
+ POP BC
+
+ LD A, $mem_bunny_health
+ SUB $01
+ JR C, =.Poison_effect.health_underflow_fix
+ DAA
+ LD $mem_bunny_health, A
+ JR =.Poison_effect.Skip_health_underflow_fix
+ .Poison_effect.health_underflow_fix:
+ LD A, $00
+ LD $mem_bunny_health, A
+ .Poison_effect.Skip_health_underflow_fix:
+
+ PUSH BC
+ LD A, $mem_bunny_predicted_x
+ LD B, A
+ LD A, $mem_bunny_predicted_y
+ LD C, A
+ LD A, $04
+ PUSH DE
+ LD E, $20
+ LD D, $00
+ CALL =Try_Launch_Animation
+ POP DE
+ POP BC
+ JR =.Poison_effect.end
+
+ .Unpoison:
+ LD A, $00
+ LD $mem_bunny_status, A
+ .Poison_effect.end:
+
.Should_turn_be_skipped:
LD A, $mem_bunny_status
BIT 0, A
diff --git a/entity/list.gbasm b/entity/list.gbasm
index 3038a40..3b6649a 100644
--- a/entity/list.gbasm
+++ b/entity/list.gbasm
@@ -166,3 +166,79 @@ Entity_list:
.DB 0b00
.PADTO =.QuestGoalBunny+8
+
+ .Bug:
+ ; Sprite address
+ .DB =OBJ_Tile_Image_Data.Bug
+
+ ; Turn Jump Table index
+ .DB $09
+
+ ; Interaction Jump Table index
+ .DB $01
+
+ ; Starting health
+ .DB $01
+
+ ; Starting status
+ .DB $00
+
+ ; Starting mana
+ .DB $05
+
+ ; Spawning rate (2 lsb)
+ .DB 0b11
+
+ .PADTO =.Bug+8
+
+Turn_Jump_table:
+ ; 00
+ RET
+ NOP
+ NOP
+ NOP
+
+ ; 01
+ JP =Move_Bunny
+ NOP
+
+ ; 02
+ JP =Fox_Turn
+ NOP
+
+ ; 03
+ JP =Cat_Turn
+ NOP
+
+ ; 04
+ JP =Penguin_Turn
+ NOP
+
+ ; 05
+ JP =QuestGoal_Turn
+ NOP
+
+ ; 06
+ JP =Fimsh_Turn
+ NOP
+
+ ; 07
+ JP =Mouse_Turn
+ NOP
+
+ ; 08
+ JP =Frog_Turn
+ NOP
+
+ ; 09
+ JP =Bug_Turn
+ NOP
+
+.INCLUDE "entity/bunny.gbasm"
+.INCLUDE "entity/fox.gbasm"
+.INCLUDE "entity/cat.gbasm"
+.INCLUDE "entity/mouse.gbasm"
+.INCLUDE "entity/penguin.gbasm"
+.INCLUDE "entity/fimsh.gbasm"
+.INCLUDE "entity/frog.gbasm"
+.INCLUDE "entity/bug.gbasm"
diff --git a/entity/penguin.gbasm b/entity/penguin.gbasm
index a3b4937..3b58586 100644
--- a/entity/penguin.gbasm
+++ b/entity/penguin.gbasm
@@ -42,7 +42,7 @@ Penguin_Turn:
LD A, (HL+)
LD D, A
- .ENTITY_HEALTH_CHECK =.Skip_turn =Cat_Drop
+ .ENTITY_HEALTH_CHECK =.Skip_turn =Penguin_Drop
.ENTITY_FREEZE_SHIVER =.Skip_turn
.ENTITY_STATUS_SKIP_TURN =.Skip_turn