player: Added sub-pixel movement
authorLukas Krickl <lukas@krickl.dev>
Tue, 23 Sep 2025 20:47:34 +0000 (22:47 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 23 Sep 2025 20:47:34 +0000 (22:47 +0200)
src/player.s
src/wram.s

index e4e5599328b86b9efea98e0e9eac2055514ae191..1794ae363a8fcf2f1931b95a9350c75fbadb7aed 100644 (file)
@@ -1,4 +1,4 @@
-#define PLAYER_SPEED 1
+#define PLAYER_SPEED 0x80 
 
        ; sets up the player actor
 player_init:
@@ -104,12 +104,18 @@ player_try_scroll_up:
        ;       returns:
        ;               b/c: new y/x position
 player_stage_move_p:
-       ld a, [player+act_pos_y]
+       ld a, [player_sub_pixel_y]
        add a, b
+       ld [player_sub_pixel_y], a
+       ld a, [player+act_pos_y]
+       adc a, 0 
        ld b, a
 
-       ld a, [player+act_pos_x]
+       ld a, [player_sub_pixel_x]
        add a, c
+       ld [player_sub_pixel_x], a
+       ld a, [player+act_pos_x]
+       adc a, 0 
        ld c, a
        
        ret
@@ -120,12 +126,18 @@ player_stage_move_p:
        ;       returns:
        ;               b/c: new y/x position
 player_stage_move_n:
-       ld a, [player+act_pos_y]
+       ld a, [player_sub_pixel_y]
        sub a, b
+       ld [player_sub_pixel_y], a
+       ld a, [player+act_pos_y]
+       sbc a, 0 
        ld b, a
 
-       ld a, [player+act_pos_x]
+       ld a, [player_sub_pixel_x]
        sub a, c
+       ld [player_sub_pixel_x], a
+       ld a, [player+act_pos_x]
+       sbc a, 0 
        ld c, a
        
        ret
index e16109cc9851bf9b11e648a833cd5c1044fdcbcf..e52a323085b649cecf5c9ec5c6ac3ef7a38944f4 100644 (file)
@@ -63,7 +63,9 @@ srand: .adv 2
        ; advance if possible
 player_next_scroll_y: .adv 1
 
-
+; y/x sub pixel movement for player
+player_sub_pixel_y: .adv 1
+player_sub_pixel_x: .adv 1
 player: .adv act_size
 actors: .adv act_size * ACTS_MAX 
 map_objs: .adv mo_size * MAP_OBJ_MAX