aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO37
-rw-r--r--definitions.gbasm6
-rw-r--r--enemiesattacks.gbasm47
-rw-r--r--enemiesattacks/basic.gbasm30
-rw-r--r--enemiesattacks/walk.gbasm137
-rw-r--r--entity/actions.gbasm200
-rw-r--r--entity/bunny.gbasm41
-rw-r--r--entity/collisions.gbasm2
-rw-r--r--entity/init.gbasm8
-rw-r--r--init.gbasm2
-rw-r--r--main.gbasm14
-rw-r--r--map/generation.gbasm14
-rw-r--r--map/loading.gbasm2
-rw-r--r--map/objects.gbasm4
-rw-r--r--playerattacks.gbasm (renamed from attacks.gbasm)8
-rw-r--r--playerattacks/earcoptr.gbasm (renamed from attacks/earcoptr.gbasm)0
-rw-r--r--playerattacks/freeze.gbasm (renamed from attacks/freeze.gbasm)0
-rw-r--r--playerattacks/heal.gbasm (renamed from attacks/heal.gbasm)0
-rw-r--r--playerattacks/hop.gbasm (renamed from attacks/hop.gbasm)2
19 files changed, 319 insertions, 235 deletions
diff --git a/TODO b/TODO
index 2706471..3d91a70 100644
--- a/TODO
+++ b/TODO
@@ -1,26 +1,33 @@
--> Add special attacks/capacities to the bunny
- * Jump x2 (even over an enemy) (attacking or not ?)
+ -> Add special attacks/capacities to the bunny
+x * Jump x2 (even over an enemy) (attacking or not ?)
* Stronger attack
- * Weaker attack on multiple foxes
- * Freeze a/multiple fox(es) for X turns
- -> All with limited number of uses
+x * Weaker attack on multiple foxes
+x * Freeze a/multiple fox(es) for X turns
--> Spawn enemies in far away rooms when less than X enemies on the map. (Maybe despawn some too)
+ -> Limit attacks uses
--> Remove some health to the bunny (probably to 10 points, maybe max health growing ?)
+x -> Spawn enemies in far away rooms when less than X enemies on the map. (Maybe despawn some too)
--> Add objects to heal and get back limited use attacks/learn new attacks
+ -> Remove some health to the bunny (probably to 10 points, maybe max health growing ?)
--> Add attacks for the foxes
+x -> Add objects to heal
--> Add other types of enemies (some stronger and some weaker/fleeing)
+ -> Add objects get back limited use attacks/learn new attacks
--> Have some enemies drop items
+ -> Add attacks for the foxes
--> Allow enemy to join your team after beating/with an item/after completing a quest
+x -> Add other types of enemies
--> Get a safe place (not procedurally generated) with friends where we can get quests and choose to explore dungeons
+ -> Make the different types of enemies behave different (fleeing/ambush/etc...)
--> Find a way to control the difficulty level so its easier at the start and harder at the end.
+ -> Have some enemies drop items
--> (For far future, maybe make a story)
+DEMO
+
+ -> Allow enemy to join your team after beating/with an item/after completing a quest
+
+ -> Get a safe place (not procedurally generated) with friends where we can get quests and choose to explore dungeons
+
+ -> Find a way to control the difficulty level so its easier at the start and harder at the end.
+
+ -> (For far future, maybe make a story)
diff --git a/definitions.gbasm b/definitions.gbasm
index 4fb03f2..77e2f7a 100644
--- a/definitions.gbasm
+++ b/definitions.gbasm
@@ -41,6 +41,7 @@
.DEFINE mem_bunny_health ($cb06)
.DEFINE mem_bunny_flags ($cb07)
+.DEFINE mem_bunny_status ($cb08)
.DEFINE mem_viewport_x ($c008)
.DEFINE mem_viewport_y ($c009)
.DEFINE mem_rng_state_1 ($c00a) ; 2 bytes
@@ -97,7 +98,6 @@
.DEFINE mem_bunny_current_room_idx ($c02a)
.DEFINE mem_enemies_alive_count ($c02b)
-.DEFINE next_free_head_higher_bytes $c7
.DEFINE mem_next_free_head_lower_bytes ($c6ff)
.DEFINE mem_dungeon_generation_heads $c700 ; Takes the memory from c700 to c717
@@ -112,7 +112,6 @@
; a bit of 1 is equivalent to the tile being free
.DEFINE mem_dungeon_map $c800 ; Takes the memory from c800 to c87f
-.DEFINE mem_dungeon_map_high $c8
.DEFINE mem_room_list $c880 ; Takes the memory from c880 to c89f
; struct room {
@@ -137,7 +136,6 @@
; }
.DEFINE mem_oam_buffer $ca00 ; Until $ca9f
-.DEFINE mem_oam_buffer_high $ca
.DEFINE mem_oam_buffer_low ($c980)
.DEFINE dialogue_buffer $caa0 ; Until $cad6
@@ -185,6 +183,8 @@
; health, max health, list of possible attacks, maybe remaining attacks ? AI status (blind, scared, slow, etc..)
; }
+.DEFINE dbg_VBLANK_STATE ($dfff)
+
.DEFINE enum_direction_left $01
.DEFINE enum_direction_right $02
.DEFINE enum_direction_up $03
diff --git a/enemiesattacks.gbasm b/enemiesattacks.gbasm
new file mode 100644
index 0000000..ce8f5f0
--- /dev/null
+++ b/enemiesattacks.gbasm
@@ -0,0 +1,47 @@
+Check_player_next_to: ; BC = XY of the enemy. D is unchanged. Direction to face in E (or 0 if not)
+ .vertical:
+ LD A, $mem_bunny_x
+ CP B
+ JR NZ, =.horizontal
+
+ ; up
+ LD A, $mem_bunny_y
+ SUB $01
+ CP C
+ LD E, $enum_direction_down
+ RET Z
+
+ ; down
+ ADD $02
+ CP C
+ LD E, $enum_direction_up
+ RET Z
+
+ LD E, $00
+ RET
+
+ .horizontal:
+
+ LD A, $mem_bunny_y
+ CP C
+ LD E, $00
+ RET NZ
+
+ ; left
+ LD A, $mem_bunny_x
+ SUB $01
+ CP B
+ LD E, $enum_direction_right
+ RET Z
+
+ ; right
+ ADD $02
+ CP B
+ LD E, $enum_direction_left
+ RET Z
+
+ LD E, $00
+ RET
+
+.INCLUDE "enemiesattacks/walk.gbasm"
+.INCLUDE "enemiesattacks/basic.gbasm"
diff --git a/enemiesattacks/basic.gbasm b/enemiesattacks/basic.gbasm
new file mode 100644
index 0000000..882b1ae
--- /dev/null
+++ b/enemiesattacks/basic.gbasm
@@ -0,0 +1,30 @@
+Basic_Attack: ; Direction to face in E. Result in BC (XY), Direction in D
+ LD A, E
+ OR $10
+ LD D, A
+
+ LD A, $01
+ LD $mem_bunny_status, A
+ LD A, $02
+ LD $mem_bunny_flags, A
+ LD A, $mem_bunny_direction
+ AND $07
+ LD $mem_bunny_direction, A
+ CALL =Fix_Bunny_screen
+
+ LD A, B
+ SUB $04
+ LD B, A
+ ; LD A, $mem_bunny_health
+ ; SUB $01
+ ; JR C, =.health_underflow_fix
+ ; DAA
+ ; LD $mem_bunny_health, A
+ ; JR =.Skip_health_underflow_fix
+
+ ; .health_underflow_fix:
+ ; LD A, $00
+ ; LD $mem_bunny_health, A
+ ; .Skip_health_underflow_fix:
+
+ RET
diff --git a/enemiesattacks/walk.gbasm b/enemiesattacks/walk.gbasm
new file mode 100644
index 0000000..aa66848
--- /dev/null
+++ b/enemiesattacks/walk.gbasm
@@ -0,0 +1,137 @@
+Walking: ; entity XY in BC, Breaks DE
+ ; Is Bunny close enough to follow
+ LD A, $mem_bunny_x
+ SUB B
+ .ABS
+ CP $08
+ JR NC, =.Random_walker
+
+ LD A, $mem_bunny_y
+ SUB C
+ .ABS
+ CP $08
+ JR NC, =.Random_walker
+
+ JR =.Follow_bunny
+
+ .Random_walker:
+ CALL =RNG_Step
+ LD E, $00
+ RR A
+ RR E
+ SWAP E
+ AND $03
+ INC A
+ OR E
+ LD D, A
+ JP =.Check_Collision
+
+ .Follow_bunny:
+ LD A, $mem_bunny_x
+ LD $tmp_var_1, A
+
+ LD A, $mem_bunny_y
+ LD $tmp_var_2, A
+
+ CALL =RNG_Step
+ AND $02
+ LD $tmp_var_3, A
+
+ CP $00
+ JR Z, =.skip_invert_axis
+
+ LD A, $mem_bunny_y
+ LD $tmp_var_1, A
+
+ LD A, $mem_bunny_x
+ LD $tmp_var_2, A
+
+ LD E, B
+ LD B, C
+ LD C, E
+
+ .skip_invert_axis:
+
+ ; Choose direction
+ LD A, B
+ ADD $80
+ LD E, A
+ LD A, $tmp_var_1
+ ADD $80
+ CP E
+ JR Z =.Vertical
+ JR C =.Go_Left
+
+ .Go_Right:
+ LD A, $enum_direction_right
+ JR =.Check_Horizontal_Collision
+ .Go_Left:
+ LD A, $enum_direction_left
+
+ .Check_Horizontal_Collision:
+ LD E, A
+ DEC E
+ LD A, $tmp_var_3
+ XOR E
+ INC E
+ INC A
+ OR $08
+ PUSH BC
+ CALL =Get_Position_After_Move
+ LD A, C
+ CALL =Is_Collisionable
+ POP BC
+ CP $00
+ LD A, E
+ JR Z, =.Direction_check_end
+
+ .Vertical:
+ LD A, C
+ ADD $80
+ LD E, A
+ LD A, $tmp_var_2
+ ADD $80
+ CP E
+
+ JR Z =.No_movement
+ JR C =.Go_Up
+ .Go_Down:
+ LD A, $enum_direction_down
+ JR =.Direction_check_end
+ .Go_Up:
+ LD A, $enum_direction_up
+
+ .Direction_check_end:
+
+ DEC A
+ LD E, A
+ LD A, $tmp_var_3
+ XOR E
+ INC A
+ OR $08
+ LD D, A
+
+ ; Check collision
+
+ .No_movement:
+ LD A, $tmp_var_3
+ CP $00
+ JR Z, =.skip_invert_axis2
+ LD E, B
+ LD B, C
+ LD C, E
+ .skip_invert_axis2:
+
+ .Check_Collision:
+ LD A, D
+ PUSH BC
+ CALL =Get_Position_After_Move
+ LD A, C
+ CALL =Is_Collisionable
+ CALL =Carve_Entity_Collision_Map
+ POP BC
+ CP $00
+ RET Z
+ RES 3, D
+
+ RET
diff --git a/entity/actions.gbasm b/entity/actions.gbasm
index 944ab43..520eb0a 100644
--- a/entity/actions.gbasm
+++ b/entity/actions.gbasm
@@ -276,204 +276,16 @@ Fox_Turn:
CP $00
JP NZ, =.Start_action_or_movement.end
- ; Is bunny right next to fox
- .Check_next_to_vertical:
-
- LD A, $mem_bunny_x
- CP B
- JR NZ, =.Check_next_to_horizontal
-
- ; up
- LD E, $14
- LD A, $mem_bunny_y
- SUB $01
- CP C
- JR Z, =.Start_Attack
-
- ; down
- LD E, $13
- ADD $02
- CP C
- JR Z, =.Start_Attack
-
- JR =.Check_next_to.end
-
- .Check_next_to_horizontal:
-
- LD A, $mem_bunny_y
- CP C
- JR NZ, =.Check_next_to.end
-
- ; left
- LD E, $12
- LD A, $mem_bunny_x
- SUB $01
- CP B
- JR Z, =.Start_Attack
-
- ; right
- LD E, $11
- ADD $02
- CP B
- JR Z, =.Start_Attack
-
- JR NZ, =.Check_next_to.end
-
- .Start_Attack:
- LD D, E
-
- LD A, $mem_bunny_health
- SUB $01
- JR C, =.health_underflow_fix
- DAA
- LD $mem_bunny_health, A
- JR =.Skip_health_underflow_fix
-
- .health_underflow_fix:
- LD A, $00
- LD $mem_bunny_health, A
- .Skip_health_underflow_fix:
-
- JP =.Check_Collision
-
- .Check_next_to.end:
-
- ; Is Bunny close enough to follow
- LD A, $mem_bunny_x
- SUB B
- .ABS
- CP $08
- JR NC, =.Random_walker
-
- LD A, $mem_bunny_y
- SUB C
- .ABS
- CP $08
- JR NC, =.Random_walker
-
- JR =.Follow_bunny
-
- .Random_walker:
- CALL =RNG_Step
- LD E, $00
- RR A
- RR E
- SWAP E
- AND $03
- INC A
- OR E
- LD D, A
- JP =.Check_Collision
-
- .Follow_bunny:
- LD A, $mem_bunny_x
- LD $tmp_var_1, A
-
- LD A, $mem_bunny_y
- LD $tmp_var_2, A
-
- CALL =RNG_Step
- AND $02
- LD $tmp_var_3, A
-
- CP $00
- JR Z, =.skip_invert_axis
-
- LD A, $mem_bunny_y
- LD $tmp_var_1, A
-
- LD A, $mem_bunny_x
- LD $tmp_var_2, A
-
- LD E, B
- LD B, C
- LD C, E
-
- .skip_invert_axis:
-
- ; Choose direction
- LD A, B
- ADD $80
- LD E, A
- LD A, $tmp_var_1
- ADD $80
- CP E
- JR Z =.Vertical
- JR C =.Go_Left
-
- .Go_Right:
- LD A, $enum_direction_right
- JR =.Check_Horizontal_Collision
- .Go_Left:
- LD A, $enum_direction_left
-
- .Check_Horizontal_Collision:
- LD E, A
- DEC E
- LD A, $tmp_var_3
- XOR E
- INC E
- INC A
- OR $08
- PUSH BC
- CALL =Get_Position_After_Move
- LD A, C
- CALL =Is_Collisionable
- POP BC
- CP $00
+ CALL =Check_player_next_to
LD A, E
- JR Z, =.Direction_check_end
-
- .Vertical:
- LD A, C
- ADD $80
- LD E, A
- LD A, $tmp_var_2
- ADD $80
- CP E
-
- JR Z =.No_movement
- JR C =.Go_Up
- .Go_Down:
- LD A, $enum_direction_down
- JR =.Direction_check_end
- .Go_Up:
- LD A, $enum_direction_up
-
- .Direction_check_end:
-
- DEC A
- LD E, A
- LD A, $tmp_var_3
- XOR E
- INC A
- OR $08
- LD D, A
-
- ; Check collision
-
- .No_movement:
- LD A, $tmp_var_3
CP $00
- JR Z, =.skip_invert_axis2
- LD E, B
- LD B, C
- LD C, E
- .skip_invert_axis2:
+ JR Z, =.nyo_basic_attack
- .Check_Collision:
- LD A, D
- PUSH BC
- CALL =Get_Position_After_Move
- LD A, C
- CALL =Is_Collisionable
- CALL =Carve_Entity_Collision_Map
- POP BC
- CP $00
- JR Z, =.Start_action_or_movement.not_collision
- RES 3, D
- .Start_action_or_movement.not_collision:
+ CALL =Basic_Attack
+ JR =.Start_action_or_movement.end
+ .nyo_basic_attack:
+ CALL =Walking
.Start_action_or_movement.end:
.End_movement:
diff --git a/entity/bunny.gbasm b/entity/bunny.gbasm
index 7f274ff..042f94b 100644
--- a/entity/bunny.gbasm
+++ b/entity/bunny.gbasm
@@ -16,6 +16,47 @@ Move_Bunny:
LD E, $02
.Normal_speed:
+ .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, $mem_bunny_direction
+ AND $07
+ LD $mem_bunny_direction, A
+ CALL =RNG_Step
+ CP $55
+ JP NC, =.Skip_turn
+ LD A, $mem_bunny_direction
+ OR $40
+ LD $mem_bunny_direction, A
+
+ CALL =RNG_Step
+ CP $55
+ JP NC, =.Skip_turn
+
+ LD A, $00
+ LD $mem_bunny_status, A
+ LD A, $mem_bunny_flags
+ RES 1, A
+ LD $mem_bunny_flags, A
+ JP =.Skip_turn
+ .Freeze_shiver.end:
+
+ .Should_turn_be_skipped:
+ LD A, $mem_bunny_status
+ BIT 0, A
+ JR Z, =.no_skip
+ .Skip_turn:
+ LD A, $mem_map_loading_flags
+ SET 3, A
+ LD $mem_map_loading_flags, A
+ RET
+
+ .no_skip:
+
.Start_action_or_movement:
LD A, $mem_map_loading_flags
BIT 3, A
diff --git a/entity/collisions.gbasm b/entity/collisions.gbasm
index 022f1ef..13120a6 100644
--- a/entity/collisions.gbasm
+++ b/entity/collisions.gbasm
@@ -61,7 +61,7 @@ Is_Collisionable: ; X in A, Y in B, Result A
LD L, A
LD C, B
- LD B, $mem_dungeon_map_high
+ LD B, high($mem_dungeon_map)
LD A, (BC)
PUSH AF
LD A, C
diff --git a/entity/init.gbasm b/entity/init.gbasm
index 1b2c90b..4924a5b 100644
--- a/entity/init.gbasm
+++ b/entity/init.gbasm
@@ -19,10 +19,10 @@ Initialize_Entities:
CALL =RNG_Bound
SLA A
SLA A
- ADD $80
+ ADD low($mem_room_list)
LD C, A
- LD B, $c8
+ LD B, high($mem_room_list)
LD A, (BC)
LD D, A
@@ -142,10 +142,10 @@ Initialize_Enemy: ; HL => pointer to entity struct
LD $tmp_var_4, A
SLA A
SLA A
- ADD $80
+ ADD low($mem_room_list)
LD C, A
- LD B, $c8
+ LD B, high($mem_room_list)
LD A, (BC)
LD D, A
diff --git a/init.gbasm b/init.gbasm
index 60a1d7c..283217b 100644
--- a/init.gbasm
+++ b/init.gbasm
@@ -89,7 +89,7 @@ Copy_OAM_DMA_Transfer_Routine_To_HRAM:
JP =Entrypoint
OAM_DMA_Transfer_routine_src:
- LD A, $mem_oam_buffer_high
+ LD A, high($mem_oam_buffer)
LD ($46), A
LD A, $28 ; delay for a total of 4×40 = 160 M-cycles
.wait:
diff --git a/main.gbasm b/main.gbasm
index 0ef4cdb..abed6e7 100644
--- a/main.gbasm
+++ b/main.gbasm
@@ -79,11 +79,8 @@ New_Dungeon:
LD HL, $mem_loaded_enemies_indices
LD A, $00
LD (HL+), A
- INC A
LD (HL+), A
- INC A
LD (HL+), A
- INC A
LD (HL+), A
CALL =Dungeon_Generation
CALL =Initialize_Entities
@@ -123,6 +120,10 @@ VBLANK_Entrypoint:
LD A, $mem_bunny_health
CALL =Print_8bit
+ LD HL, $9c12
+ LD A, $dbg_VBLANK_STATE
+ CALL =Print_8bit
+
CALL $OAM_DMA_Transfer_routine
CALL =Loading_Mode_VBlank
@@ -137,6 +138,10 @@ VBLANK_Entrypoint:
CALL =Copy_Dialogue_Buffer
CALL =Display_dialogue_cursor
+ LD A, $reg_lcd_status
+ AND $03
+ LD $dbg_VBLANK_STATE, A
+
; LYC
LD A, $09
LD $reg_lyc, A
@@ -228,6 +233,7 @@ STAT_Entrypoint:
.INCLUDE "entity/display.gbasm"
.INCLUDE "entity/list.gbasm"
.INCLUDE "animation.gbasm"
-.INCLUDE "attacks.gbasm"
+.INCLUDE "playerattacks.gbasm"
+.INCLUDE "enemiesattacks.gbasm"
.INCLUDE "tileset.gbasm"
.INCLUDE "dialogues.gbasm"
diff --git a/map/generation.gbasm b/map/generation.gbasm
index 15a3301..f445d95 100644
--- a/map/generation.gbasm
+++ b/map/generation.gbasm
@@ -22,7 +22,7 @@ Carve_Map: ; X in C, Y in B
LD L, A
LD C, B
- LD B, $mem_dungeon_map_high
+ LD B, high($mem_dungeon_map)
LD A, (BC)
OR (HL)
@@ -51,7 +51,7 @@ Generation_Head_Mitosis:
XOR B
INC A
- LD B, $next_free_head_higher_bytes
+ LD B, high($mem_dungeon_generation_heads)
LD (BC), A
DEC A
@@ -108,11 +108,11 @@ Generation_Head_Explosion:
LD A, (HL+)
LD D, A ; Y
- LD H, $c8
+ LD H, high($mem_room_list)
LD A, $mem_number_of_rooms
SLA A
SLA A
- ADD $80
+ ADD low($mem_room_list)
LD L, A
LD A, E
@@ -335,6 +335,8 @@ Dungeon_Generation:
RET
Reset_Map:
- LD HL, $c6ff
- LD BC, $0281
+ LD A, $00
+ LD $mem_next_free_head_lower_bytes, A
+ LD HL, $mem_dungeon_generation_heads
+ LD BC, $0280
JP =bzero
diff --git a/map/loading.gbasm b/map/loading.gbasm
index 0fa66db..f7ba1ab 100644
--- a/map/loading.gbasm
+++ b/map/loading.gbasm
@@ -320,7 +320,7 @@ Is_Solid: ; X in A, Y in B, Result A
LD L, A
LD C, B
- LD B, $mem_dungeon_map_high
+ LD B, high($mem_dungeon_map)
LD A, (BC)
AND (HL)
diff --git a/map/objects.gbasm b/map/objects.gbasm
index de34a6d..ae62b8e 100644
--- a/map/objects.gbasm
+++ b/map/objects.gbasm
@@ -17,10 +17,10 @@ Spawn_object_in_random_room: ; Object tile in A, Object jump table id in E
CALL =RNG_Bound
SLA A
SLA A
- ADD $80
+ ADD low($mem_room_list)
LD C, A
- LD B, $c8
+ LD B, high($mem_room_list)
LD A, (BC)
LD D, A
diff --git a/attacks.gbasm b/playerattacks.gbasm
index 779ce16..6f1eead 100644
--- a/attacks.gbasm
+++ b/playerattacks.gbasm
@@ -73,7 +73,7 @@ Canceled_Attack:
LD $mem_bunny_direction, A
RET
-.INCLUDE "attacks/hop.gbasm"
-.INCLUDE "attacks/heal.gbasm"
-.INCLUDE "attacks/freeze.gbasm"
-.INCLUDE "attacks/earcoptr.gbasm"
+.INCLUDE "playerattacks/hop.gbasm"
+.INCLUDE "playerattacks/heal.gbasm"
+.INCLUDE "playerattacks/freeze.gbasm"
+.INCLUDE "playerattacks/earcoptr.gbasm"
diff --git a/attacks/earcoptr.gbasm b/playerattacks/earcoptr.gbasm
index 7e74802..7e74802 100644
--- a/attacks/earcoptr.gbasm
+++ b/playerattacks/earcoptr.gbasm
diff --git a/attacks/freeze.gbasm b/playerattacks/freeze.gbasm
index 936bf47..936bf47 100644
--- a/attacks/freeze.gbasm
+++ b/playerattacks/freeze.gbasm
diff --git a/attacks/heal.gbasm b/playerattacks/heal.gbasm
index 281726a..281726a 100644
--- a/attacks/heal.gbasm
+++ b/playerattacks/heal.gbasm
diff --git a/attacks/hop.gbasm b/playerattacks/hop.gbasm
index e159ee4..cd69763 100644
--- a/attacks/hop.gbasm
+++ b/playerattacks/hop.gbasm
@@ -182,6 +182,8 @@ Hop_Attack:
LD $mem_requested_mode, A
.CLOSE_DIALOGUE
+ LD A, $00
+ LD $mem_loading_step, A
RET