unit: code cleanup
authorLukas Krickl <lukas@krickl.dev>
Fri, 20 Jun 2025 17:30:38 +0000 (19:30 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 20 Jun 2025 17:30:38 +0000 (19:30 +0200)
src/actortables.s
src/player.s
src/unit.s
src/unit_demo.s [new file with mode: 0644]

index 51c22615d6f050a59564277609d77a55f60955ca..331ecc8c521ed620d34c18fcba6b24979cb696c4 100644 (file)
@@ -1,4 +1,9 @@
+#include "unit_demo.s"
+
 default_map_actor_table:
 .db 2 ; size
 dw unit_demo_2
 dw unit_demo_3
+
+
+
index 822a4a688aefc3a5591a73dceaa3c043a371f269..a2d31fc48ed2bab6441811f2d95d822834bb5430 100644 (file)
@@ -1,2 +1,56 @@
 .def int CURSOR_TILE = 0x04
 
+  ; loads the default player unit
+  ; and hands over control
+unit_load_default_player:  
+  ld de, unit_player
+  ld hl, p0_units
+  ld bc, act_size
+  call memcpy
+
+  ld de, p_empty_unit
+  call unit_next_request
+  ret
+
+unit_player_init:
+  ldnull bc
+  ret
+
+  ; inputs
+  ;   de: actor
+unit_player_update:
+  push de
+  ld hl, act_oam_flags
+  add hl, de
+  ld a, [hl]
+  or a, OAM_FXFLIP 
+  ld [hl], a
+  pop de
+  
+
+  push de
+  call unit_handle_inputs
+  pop de
+  push de
+  call unit_scroll_center
+  pop de
+
+  ret
+
+
+unit_player:
+  st_def 0x00, unit_player_init, st_unit_idle
+  act_def ACT_T_DEMO_1, 0, 2, 2, 0
+  act_stat_def1 1, 1, 1, 1, 1, 1 
+  act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1 
+  act_attr_def_empty
+  act_inventory_empty
+  act_equipment_empty
+  act_effects_empty
+  act_st_def NULL, NULL, st_unit_player_update, st_unit_idle
+  act_def_draw unit_draw, 0x84, 0
+  act_rt_def
+
+st_unit_player_update:
+  st_def 0x00, unit_player_update, st_unit_player_update 
index b837c43163dd4ead5f1f78bd21ff8420e5b7c1c3..a04511cbdd088a93b5f99ac189bf47dc117be540 100644 (file)
@@ -63,44 +63,6 @@ unit_update_draw:
   call_hl
   ret
 
-unit_player_init:
-  ldnull bc
-  ret
-
-unit_demo_1_init:
-  ldnull bc
-  ret
-  
-  ; inputs
-  ;   de: actor
-unit_player_update:
-  push de
-  ld hl, act_oam_flags
-  add hl, de
-  ld a, [hl]
-  or a, OAM_FXFLIP 
-  ld [hl], a
-  pop de
-  
-
-  push de
-  call unit_handle_inputs
-  pop de
-  push de
-  call unit_scroll_center
-  pop de
-
-  ret
-
-  ; cpu controllerd unit update
-unit_demo_1_cpu_update:
-  push de
-  call unit_handle_cpu_inputs
-  pop de
-  ret
-
 unit_handle_cpu_inputs:
   ; pick where to go 
   call roll_d16
@@ -791,63 +753,6 @@ unit_get_inventory:
 unit_get_equipment:
   ret
 
-  ; loads the default player unit
-  ; and hands over control
-unit_load_default_player:  
-  ld de, unit_player
-  ld hl, p0_units
-  ld bc, act_size
-  call memcpy
-
-  ld de, p_empty_unit
-  call unit_next_request
-  ret
-
-unit_player:
-  st_def 0x00, unit_player_init, st_unit_idle
-  act_def ACT_T_DEMO_1, 0, 2, 2, 0
-  act_stat_def1 1, 1, 1, 1, 1, 1 
-  act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1 
-  act_attr_def_empty
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
-  act_st_def NULL, NULL, st_unit_player_update, st_unit_idle
-  act_def_draw unit_draw, 0x84, 0
-  act_rt_def
-
-unit_demo_2:
-  st_def 0x00, unit_demo_1_init, st_unit_idle
-  act_def ACT_T_DEMO_1, 0, 3, 3, 0 
-  act_stat_def1 1, 1, 1, 1, 1, 1 
-  act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1 
-  act_attr_def_empty
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
-  act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
-  act_def_draw unit_draw, 0x84, 0
-  act_rt_def
-
-unit_demo_3:
-  st_def 0x00, unit_demo_1_init, st_unit_idle
-  act_def ACT_T_DEMO_1, 0, 4, 4, 0 
-  act_stat_def1 1, 1, 1, 1, 1, 1 
-  act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1 
-  act_attr_def_empty
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
-  act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
-  act_def_draw unit_draw, 0x84, 0
-  act_rt_def
-
-st_unit_player_update:
-  st_def 0x00, unit_player_update, st_unit_player_update 
-
-st_unit_demo_1_cpu_update:
-  st_def 0x00, unit_demo_1_cpu_update, st_unit_demo_1_cpu_update
-
 st_unit_idle:
   st_def 0x00, unit_idle, st_unit_idle
 
diff --git a/src/unit_demo.s b/src/unit_demo.s
new file mode 100644 (file)
index 0000000..21ada6b
--- /dev/null
@@ -0,0 +1,43 @@
+
+unit_demo_1_init:
+  ldnull bc
+  ret
+
+  ; cpu controllerd unit update
+unit_demo_1_cpu_update:
+  push de
+  call unit_handle_cpu_inputs
+  pop de
+  ret
+
+unit_demo_2:
+  st_def 0x00, unit_demo_1_init, st_unit_idle
+  act_def ACT_T_DEMO_1, 0, 3, 3, 0 
+  act_stat_def1 1, 1, 1, 1, 1, 1 
+  act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1 
+  act_attr_def_empty
+  act_inventory_empty
+  act_equipment_empty
+  act_effects_empty
+  act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
+  act_def_draw unit_draw, 0x84, 0
+  act_rt_def
+
+unit_demo_3:
+  st_def 0x00, unit_demo_1_init, st_unit_idle
+  act_def ACT_T_DEMO_1, 0, 4, 4, 0 
+  act_stat_def1 1, 1, 1, 1, 1, 1 
+  act_stat_def2 1, 1, 1, 1, 1, 1, 1, 1 
+  act_attr_def_empty
+  act_inventory_empty
+  act_equipment_empty
+  act_effects_empty
+  act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
+  act_def_draw unit_draw, 0x84, 0
+  act_rt_def
+
+
+st_unit_demo_1_cpu_update:
+  st_def 0x00, unit_demo_1_cpu_update, st_unit_demo_1_cpu_update
+