actor: rt variables are now in regular actor_def
authorLukas Krickl <lukas@krickl.dev>
Wed, 25 Jun 2025 13:53:14 +0000 (15:53 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 25 Jun 2025 13:53:14 +0000 (15:53 +0200)
this saves a macro call.
units now move in sub-tiles in all directions.
Drawing still will need to take this into account.

src/defs.s
src/macros.inc
src/player.s
src/unit.s
src/unit_demo.s

index e53961fce5791cd813bc29fc1bea527d908d4ff9..db3c7cac1c80ed950b5442c0d9a0d3a7765a43d4 100644 (file)
   ; act_effects_def or act_effects_empty
   ; act_st_def
   ; act_def_draw
-  ; act_rt_def
 .se 0
   ; copy of current state
 .de act_state, st_size
 
 .de act_pos_y, 1 ; y/x tile position
 .de act_pos_x, 1
+
   ; custom parameter
 .de act_p0, 1
 
+  ; actor runtime values
+
+  ; last collision with actor
+  ; set during unit_collision_woth_any_other
+.de act_rt_collided_with, 2
+.de act_rt_subtile_y, 1
+.de act_rt_subtile_x, 1
 
   ; stats1
 .de act_level, 1
 .de act_oam_tile, 1
 .de act_oam_flags, 1
 
-  ; actor runtime values
-
-  ; last collision with actor
-  ; set during unit_collision_woth_any_other
-.de act_rt_collided_with, 2
-
-  ; sub-tile position
-  ;   : y subtile
-  ;   : x subtile
-  ; if the subtile position overflows/underflows
-  ; the actor may move on to the next tile
-.de act_rt_subtile_y, 1
-.de act_rt_subtile_x, 1
 .de act_size, 0
   
   ; max bge queue size
index f80505946232bbcff8fa01b60a0f2836162d4096..7237c164b98dca26592b76fd49e40afad20c6f39 100644 (file)
   .db $3 ; y pos
   .db $4 ; x pos
   .db $5 ; p0
+
+  ; act_rt_collided_with
+  dw 0 
+  .db 0  ; y-subtile
+  .db 0  ; x-subtile
 #endmacro
   
   ; defines an actor's stats (1/2)
   dw $4
 #endmacro
 
-  ; defines default values for actor runtime values
-  ; these can generally not be set at build time
-#macro act_rt_def
-  ; act_rt_collided_woth
-  dw 0
-  ; subtile_pos
-  .db 0 
-#endmacro
 
   ; defines an actors attributes
   ; such as weapon skills
index b33d7d51ee5968dcc8ccc781982ca9f943527fb7..0a186ebdc28f29208e4b66031033f7eae00864b2 100644 (file)
@@ -48,7 +48,6 @@ unit_player:
   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 09cd21390a6d3b5d13ced32fcd1bd414587e155a..f9faa481d0a7fb6e6ad362d5e24c77d3d2569b8a 100644 (file)
@@ -346,7 +346,7 @@ unit_calc_movement_speed:
   pop hl
   ; now apply carry to real position
   ld a, [hl]
-  sbc a, 0
+  $3 a, 0
   ld [hl], a
 #endmacro
 
@@ -375,7 +375,6 @@ unit_try_move_up:
   ret z
 
   unit_sub_tile_move act_rt_subtile_y, sub, sbc
-
   ret
 
 unit_try_move_down:
@@ -389,8 +388,7 @@ unit_try_move_down:
   cp a, MAP_H - 1 ; lower bound
   ret z
 
-  inc a
-  ld [hl], a
+  unit_sub_tile_move act_rt_subtile_y, add, adc
   ret
 
 unit_try_move_left:
@@ -404,8 +402,7 @@ unit_try_move_left:
   cp a, 0 ; left bound
   ret z
 
-  dec a
-  ld [hl], a
+  unit_sub_tile_move act_rt_subtile_x, sub, sbc
   ret
 
 unit_try_move_right:
@@ -420,8 +417,7 @@ unit_try_move_right:
   cp a, MAP_W - 1 ; right bound
   ret z
 
-  inc a
-  ld [hl], a
+  unit_sub_tile_move act_rt_subtile_x, add, adc
   ret 
 
 
index 319999ffbe8ff46348ffe86bd05ee2a6f50c6da2..a9f4b903e86cc58fc77ee54b8f6053ca7ddb74de 100644 (file)
@@ -50,7 +50,6 @@ unit_demo_2:
   act_effects_empty
   act_st_def NULL, NULL, st_unit_demo_1_cpu_update_idle, 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_demo_1_cpu_update
@@ -63,7 +62,6 @@ unit_demo_3:
   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: