player: Added basic movement and rendering origin/map-direct-render
authorLukas Krickl <lukas@krickl.dev>
Mon, 12 Jan 2026 12:21:44 +0000 (13:21 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 12 Jan 2026 12:21:44 +0000 (13:21 +0100)
src/map.s
src/player.s
src/update.s
src/wram.s

index 739509449dac92d0a0538f718dd89122a9b08827..d6324492d70b67baa48030a39dead9eb5e1fef20 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -440,6 +440,17 @@ map_full_draw_row:
        ; transferts to redraw state
 map_full_draw:
        call map_set_visible_range
+
+       ; set map offset
+       ld a, b
+       mul8 a
+       sub a, OBJ_OFF_Y
+       ld [map_offset_y], a
+
+       ld a, c
+       mul8 a
+       sub a, OBJ_OFF_X
+       ld [map_offset_x], a
        
        ; render destination
        ld hl, render_buffer
index 8e707a5277ee29a12d5996b3c6afec8c91e50a64..375a7f7ed704fb1b493cef16b1b47d2f5fb7f50e 100644 (file)
@@ -60,6 +60,30 @@ player_update:
        call player_handle_move
        
 
+       ret
+
+       ; draws player
+player_draw:
+       ld a, 1
+       call oamalloc 
+       
+       ; y pos
+       ld a, 72
+       add a, b
+       ld [hl+], a
+
+       ; x pos
+       ld a, 88
+       ld [hl+], a
+
+       ; tile
+       ld a, 0xA5
+       ld [hl+], a
+
+       ; flags
+       xor a, a
+       ld [hl], a
+
        ret
 
        
@@ -80,21 +104,38 @@ player_handle_move:
 
        ld b, DIRLEFT
        input_just
+       jr z, @not_left REL
+               ld a, [player+act_pos_x]
+               dec a
+               ld [player+act_pos_x], a
+               call map_full_draw
 @not_left:
 
        ld b, DIRRIGHT
        input_just
        jr z, @not_right REL
+               ld a, [player+act_pos_x]
+               inc a
+               ld [player+act_pos_x], a
+               call map_full_draw
 @not_right:
 
        ld b, DIRUP
        input_just
        jr z, @not_up REL
+               ld a, [player+act_pos_y]
+               dec a
+               ld [player+act_pos_y], a
+               call map_full_draw
 @not_up:
 
        ld b, DIRDOWN
        input_just
        jr z, @not_down REL
+               ld a, [player+act_pos_y]
+               inc a
+               ld [player+act_pos_y], a
+               call map_full_draw
 @not_down:
        ret
        
index 112cb7ea067340a5313391020226b86f1c5ce273..96defe76d980ce5854f9573668eb4a35d9ffed5c 100644 (file)
@@ -8,6 +8,7 @@ update_game:
        
        ; player should update even in debug mode
        call player_update
+       call player_draw
 
   ; tick rng every frame
        call rand
index ea5b850f79772e335bbd58c52b047a424f1d54b8..0e8da633459e248eafed7f8977282c060b1cf65f 100644 (file)
@@ -57,6 +57,10 @@ empty_oam: .adv oamsize
   ; scroll location
 scroll_y: .adv 1
 scroll_x: .adv 1
+       ; map offset in pixels
+       ; use to render actors
+map_offset_y: .adv 1
+map_offset_x: .adv 1
        
        ; global animation timer
        ; increments from 0-30