aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-02-25 16:54:34 +0900
committerAstatin <[email protected]>2025-02-25 16:54:34 +0900
commitb21954eb05d9285ed7542a1f42ed755a147782a8 (patch)
tree935794c0eb59ff484d4e9c3a9849d588fbd5919b
parent18d7d064daf704193f8dff6b2ef3ae68b7fc3aac (diff)
Fix initialization and flickering issues
-rw-r--r--TODO4
-rw-r--r--animation.gbasm4
-rw-r--r--definitions.gbasm1
-rw-r--r--enemiesattacks/basic.gbasm2
-rw-r--r--entity/bunny.gbasm19
-rw-r--r--entity/display.gbasm5
-rw-r--r--main.gbasm13
-rw-r--r--map/objects.gbasm22
-rw-r--r--playerattacks/earcoptr.gbasm4
-rw-r--r--utils.gbasm12
10 files changed, 60 insertions, 26 deletions
diff --git a/TODO b/TODO
index fbdfa03..8e125ac 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,7 @@
Bugs:
- -> Enemy urn seems to start on dungeon change sometimes (maybe when going to the stairs with hop ?)
- -> Penguins freeze can cancel hops but not freezes
- -> Foxes can attack even if bunny hopped away
-> Emulator crash with "not implemented: Only XKB keymaps are supported when unfocused (or workspace change maybe ?)
-> There is no indicator that the max health is 20
+ -> The bunny should not be able to spawn on the stairs and the enemies should not be able to spawn on top of another entity
Need to be refactored:
-> main is messy and unreadable
diff --git a/animation.gbasm b/animation.gbasm
index b7891f4..c136eb9 100644
--- a/animation.gbasm
+++ b/animation.gbasm
@@ -112,6 +112,10 @@ End_animation:
LD H, high($mem_entities_list)
SET 3, (HL)
+
+ LD A, $1f
+ LD $mem_blinking_animation_counter, A
+
POP HL
RET
diff --git a/definitions.gbasm b/definitions.gbasm
index 1e46ccf..3ff66f8 100644
--- a/definitions.gbasm
+++ b/definitions.gbasm
@@ -72,6 +72,7 @@
.DEFINE enum_dungeon_dialogue_mode $81
.DEFINE enum_loading_mode $82
.DEFINE enum_animation_wait_mode $83
+
.DEFINE mem_menu_cursor_position ($c016)
.DEFINE mem_last_button_direction ($c017)
diff --git a/enemiesattacks/basic.gbasm b/enemiesattacks/basic.gbasm
index 2f08858..c617b7a 100644
--- a/enemiesattacks/basic.gbasm
+++ b/enemiesattacks/basic.gbasm
@@ -30,10 +30,12 @@ Basic_Enemy_Attack: ; Direction to face in E. Result in BC (XY), Direction in D
SET 3, A
LD $mem_bunny_flags, A
+ PUSH BC
LD A, $mem_moving_animation_step
LD B, A
LD A, $1f
SUB B
LD $mem_blinking_animation_counter, A
+ POP BC
RET
diff --git a/entity/bunny.gbasm b/entity/bunny.gbasm
index f8e07ac..d2b9148 100644
--- a/entity/bunny.gbasm
+++ b/entity/bunny.gbasm
@@ -52,9 +52,6 @@ Move_Bunny:
SET 3, A
LD $mem_map_loading_flags, A
- LD A, $mem_bunny_flags
- RES 3, A
- LD $mem_bunny_flags, A
RET
.no_skip:
@@ -76,10 +73,6 @@ Move_Bunny:
SET 3, A
LD $mem_map_loading_flags, A
- LD A, $mem_bunny_flags
- RES 3, A
- LD $mem_bunny_flags, A
-
LD A, $mem_button_action
BIT 1, A
JR NZ, =.Start_action_or_movement.cancel_movement
@@ -130,6 +123,18 @@ Move_Bunny:
LD $mem_map_loading_flags, A
.Start_action_or_movement.end:
+ .Reset_Blinking_flag:
+ LD A, $mem_map_loading_flags
+ BIT 3, A
+ JR Z, =.Reset_Blinking_flag.end
+ LD A, $mem_moving_animation_step
+ CP $00
+ JR NZ, =.Reset_Blinking_flag.end
+ LD A, $mem_bunny_flags
+ RES 3, A
+ LD $mem_bunny_flags, A
+ .Reset_Blinking_flag.end:
+
.Scroll_viewport:
LD A, $mem_map_loading_flags
BIT 3, A
diff --git a/entity/display.gbasm b/entity/display.gbasm
index 75b1e29..b73d393 100644
--- a/entity/display.gbasm
+++ b/entity/display.gbasm
@@ -111,11 +111,6 @@ Display_Entity:
JR Z, =.Blinking_Animation.end
LD A, $mem_blinking_animation_counter
- PUSH DE
- LD E, A
- LD A, $mem_loading_step
- XOR E
- POP DE
AND $02
CP $02
JP Z, =.skip
diff --git a/main.gbasm b/main.gbasm
index 3707c30..a30bb36 100644
--- a/main.gbasm
+++ b/main.gbasm
@@ -126,6 +126,18 @@ New_Dungeon:
LD A, $00
LD $mem_bunny_flags, A
LD $mem_display_flag, A
+ LD $mem_moving_animation_step, A
+ LD $mem_animation_wait_frames, A
+ LD $mem_blinking_animation_counter, A
+
+ LD A, $mem_map_loading_flags
+ RES 3, A
+ LD $mem_map_loading_flags, A
+
+ ; Clear OAM
+ LD HL, $fe00
+ LD BC, $00a0
+ CALL =bzero
LD A, $enum_dungeon_mode
LD $mem_current_mode, A
@@ -157,6 +169,7 @@ VBLANK_Entrypoint:
LD HL, $9d72
LD A, $dbg_VBLANK_STATE
+ LD A, $mem_bunny_x
CALL =Print_8bit
CALL $OAM_DMA_Transfer_routine
diff --git a/map/objects.gbasm b/map/objects.gbasm
index dd89e87..6d084aa 100644
--- a/map/objects.gbasm
+++ b/map/objects.gbasm
@@ -4,14 +4,14 @@ Initialize_Objects:
LD $mem_map_loading_flags, A
LD HL, $mem_object_list
LD BC, $0080
- CALL =bzero
+ CALL =bff
LD HL, $mem_object_list
CALL =Spawn_stairs
CALL =Spawn_carrot
CALL =Spawn_leaf
RET
-Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E
+Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E, Object pointer in HL
LD (HL+), A
LD A, $mem_number_of_rooms
@@ -214,18 +214,25 @@ Display_Object:
AND $f8
LD L, A
- LD A, (HL+)
+ LD A, (HL)
+ CP $FF
+ RET Z
LD C, A
+ CP $00
+ JR NZ, =.skip_remove_object_after_display
+ LD (HL), $FF
+ .skip_remove_object_after_display:
+ INC HL
LD A, (HL+)
ADD $80
LD D, A
LD A, $mem_viewport_x
SUB $83
CP D
- JR NC, =Display_Objects.End
+ RET NC
ADD $0e
CP D
- JR C, =Display_Objects.End
+ RET C
LD A, D
SUB $80
LD D, A
@@ -236,10 +243,10 @@ Display_Object:
LD A, $mem_viewport_y
SUB $83
CP B
- JR NC, =Display_Objects.End
+ RET NC
ADD $0e
CP B
- JR C, =Display_Objects.End
+ RET C
LD A, B
SUB $80
LD B, A
@@ -276,7 +283,6 @@ Display_Object:
LD A, C
LD (DE), A
- Display_Objects.End:
RET
Display_Objects.Nothing:
diff --git a/playerattacks/earcoptr.gbasm b/playerattacks/earcoptr.gbasm
index cc47672..fa174d3 100644
--- a/playerattacks/earcoptr.gbasm
+++ b/playerattacks/earcoptr.gbasm
@@ -50,10 +50,8 @@ Earcoptr_Attack_Loading_Regular:
CP $02
RET NC
- INC C
-
LD A, C
- ADD $03
+ ADD $04
LD C, A
LD A, (BC)
SUB $01
diff --git a/utils.gbasm b/utils.gbasm
index 47fec5a..a8696ed 100644
--- a/utils.gbasm
+++ b/utils.gbasm
@@ -44,6 +44,18 @@ bzero: ; dest = HL, n = BC
JR NZ =.loop
RET
+bff: ; dest = HL, n = BC
+ LD A, $ff
+ .loop:
+ LD (HL+), A
+ INC DE
+ DEC BC
+ CP B
+ JR NZ =.loop
+ CP C
+ JR NZ =.loop
+ RET
+
.MACRODEF ABS
BIT 7, A
JR Z, =$end