Scroll input

This commit is contained in:
RochesterX
2026-02-21 16:40:26 -05:00
parent 8cc2052c99
commit ba59a23daa
2 changed files with 68 additions and 30 deletions

BIN
plat.nes

Binary file not shown.

86
plat.s
View File

@@ -355,6 +355,7 @@ player_status: .res 1 ; 76543210 | 0: facing (0 right, 1 left)
; | 2: nametable Y
; | 7: talking
horizontal_speed: .res 1
camera_speed: .res 1
cursor_x: .res 1
cursor_y: .res 1
@@ -413,7 +414,13 @@ main:
jmp @loop
move_camera:
lda #%1
jmp @no
lda player_pos_x
clc
adc #240
cmp scroll_x
bmi :++
lda #1
clc
adc scroll_x
cmp scroll_x
@@ -423,6 +430,50 @@ move_camera:
eor #%00000001
sta scroll_nmt
:
:
rts
@no:
jsr btn_select
cmp #0
beq :+
lda #%11111111
sta camera_speed
jmp @end
:
jsr btn_start
cmp #0
beq :+
lda #1
sta camera_speed
:
@end:
lda camera_speed
bmi @left
clc
adc scroll_x
cmp scroll_x
sta scroll_x
bcs :+
lda scroll_nmt
eor #%00000001
sta scroll_nmt
:
rts
@left:
clc
adc scroll_x
cmp scroll_x
sta scroll_x
bcc :+
lda scroll_nmt
eor #%00000001
sta scroll_nmt
:
rts
draw_player:
@@ -595,38 +646,25 @@ draw_player:
rts
init_objects:
lda #0
sta var_n
ldx #0
:
lda var_n
clc
adc #8
sta var_n
sta player_pos_y, X ; Set Y position
sta player_pos_x, X ; Set X position
txa
lsr
lsr
sta oam+1, X
inx
inx
inx
inx
cpx #(8*4)
bne :-
lda #96
sta player_pos_x ; Set X position
lda #128
sta player_pos_y ; Set Y position
lda #0
sta player_vel_x
sta player_vel_y
sta player_status
sta scroll_nmt
lda #1
sta player_nmt_x
lda #%00101000
sta horizontal_speed
lda #0
sta camera_speed
rts
draw: