Compare commits

..

2 Commits

Author SHA1 Message Date
RochesterX
7016042cff Stable scrolling and nametable logging 2026-02-21 14:31:21 -05:00
RochesterX
c9e15c5829 What 2026-02-20 19:30:32 -05:00
2 changed files with 113 additions and 68 deletions

BIN
plat.nes

Binary file not shown.

181
plat.s
View File

@@ -279,20 +279,37 @@ level:
level2: level2:
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,1,0,0,1,0,0,0,0,1,0,0,2,7,7,3
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,9
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,1,0,0,1,7,7,7,7,1,7,7,6,0,0,9
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,1,1,0,0,0,0,0,1,0,0,4,8,8,5
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0 .byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10 .byte 0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10
.byte 0,0,1,0,0,0,0,1,0,0,0,11,11,11,11,11
.byte 0,1,2,3,4,5,6,7,8,9,0,11,11,11,11,11
.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 .byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11
.byte 0,1,7,7,7,7,7,7,7,1,0,11,11,11,11,11
.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11 ;level2:
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;.byte 0,0,0,0,0,0,0,0,0,0,0,10,10,10,10,10
;.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11
;.byte 0,1,7,7,7,7,7,7,7,1,0,11,11,11,11,11
;.byte 0,0,0,0,0,0,0,0,0,0,0,11,11,11,11,11
metatiles: metatiles:
.byte 0,0,0,0,0 .byte 0,0,0,0,0
@@ -385,19 +402,9 @@ main:
adc #1 adc #1
sta frame_counter sta frame_counter
lda scroll_x
adc #1
cmp scroll_x
sta scroll_x
bcs :+
lda scroll_nmt
eor #%00000001
sta scroll_nmt
:
jsr controller jsr controller
jsr movement jsr movement
lda player_pos_x jsr move_camera
@draw: @draw:
jsr draw_player jsr draw_player
@@ -405,7 +412,40 @@ main:
jmp @loop jmp @loop
move_camera:
lda scroll_x
clc
adc #0
cmp scroll_x
sta scroll_x
bcs :+
lda scroll_nmt
eor #%00000001
sta scroll_nmt
:
rts
draw_player: draw_player:
; see if we can skip drawing the player because it's off screen
lda player_pos_x
sec
sbc scroll_x
cmp player_pos_x ; if underflow, nametable bits must be different to continue
beq @skip_bcs
bcs :+
@skip_bcs:
lda player_nmt_x
eor scroll_nmt
beq @hide_player
jmp :++
:
; if nothing, nametable bits must be same to continue
lda player_nmt_x
eor scroll_nmt
bne @hide_player
:
lda player_pos_y lda player_pos_y
sec sec
sbc #1 sbc #1
@@ -416,47 +456,6 @@ draw_player:
sta oam + (4 * 0) + 0 sta oam + (4 * 0) + 0
sta oam + (4 * 1) + 0 sta oam + (4 * 1) + 0
jmp @after
; see if we can skip drawing the player because it's off screen
lda player_pos_x
sec
sbc scroll_x
cmp player_pos_x ; if underflow, nametable bits must be different to continue
bcs :+
lda player_status
clc
ror
eor scroll_nmt
beq @end_position_application
jmp :++
:
; if nothing, nametable bits must be same to continue
lda player_status
clc
ror
eor scroll_nmt
bne @end_position_application
:
@after:
;;;;;;;;;;;;;;;;;;;;;;;;;PUT WHEN VELOCITY IS BEING APPLIED
lda player_pos_x
adc #1
cmp player_pos_x
sta player_pos_x
bcs :+
lda player_status
eor #%00000010
sta player_status
:
;;;;;;;;;;;;;;;;;;;;;;;;;
lda player_status lda player_status
and #%00000001 and #%00000001
cmp #0 cmp #0
@@ -482,8 +481,17 @@ jmp @after
sta oam + (4 * 1) + 3 sta oam + (4 * 1) + 3
sta oam + (4 * 3) + 3 sta oam + (4 * 3) + 3
: :
jmp @end_hide_player
@end_position_application: @hide_player:
lda #250
sta oam + (4 * 2) + 0
sta oam + (4 * 3) + 0
sta oam + (4 * 0) + 0
sta oam + (4 * 1) + 0
@end_hide_player:
lda player_status lda player_status
and #%10000000 and #%10000000
@@ -709,6 +717,7 @@ movement:
bne :+ bne :+
; 0: right ; 0: right
lda player_vel_x lda player_vel_x
sta var_o ; store initial velocity in o
and #%01111111 and #%01111111
clc clc
ror ror
@@ -721,6 +730,12 @@ movement:
clc clc
adc player_pos_x adc player_pos_x
sta player_pos_x ; add pixels sta player_pos_x ; add pixels
bcc @end_pixel_overflow_right
lda player_nmt_x
eor #%00000001
sta player_nmt_x
@end_pixel_overflow_right:
lda player_vel_x lda player_vel_x
; A contains signed subpixels ; A contains signed subpixels
@@ -732,15 +747,22 @@ movement:
sta player_subpos_x sta player_subpos_x
beq @end_add_subpos beq @end_add_subpos
bcs @end_add_subpos ; so skip if subpos is smaller than result bcs @end_add_subpos ; so skip if subpos is smaller than result
ldx player_pos_x lda player_pos_x
inx clc
stx player_pos_x adc #1
sta player_pos_x
bcc @end_subpixel_overflow_right
lda player_nmt_x
eor #%00000001
sta player_nmt_x
@end_subpixel_overflow_right:
@end_add_subpos: @end_add_subpos:
jmp :++ jmp :++
: :
; 1: left ; 1: left
lda player_vel_x lda player_vel_x
sta var_o
sec sec
ror ror
sec sec
@@ -751,10 +773,23 @@ movement:
ror ror
ora #%10000000 ora #%10000000
clc clc
adc #1
clc
adc player_pos_x adc player_pos_x
sta player_pos_x ; add pixels sta player_pos_x ; add pixels
bcs @end_pixel_overflow_left
lda player_nmt_x
eor #%00000001
sta player_nmt_x
@end_pixel_overflow_left:
; :|
lda player_pos_x
clc
adc #1
sta player_pos_x ; add... correction?
bcc @end_correction
lda player_nmt_x
eor #%00000001
sta player_nmt_x
@end_correction:
lda player_vel_x lda player_vel_x
@@ -767,13 +802,23 @@ movement:
sta player_subpos_x sta player_subpos_x
beq @end_sub_subpos beq @end_sub_subpos
bcc @end_sub_subpos ; so skip if subpos is bigger than result bcc @end_sub_subpos ; so skip if subpos is bigger than result
ldx player_pos_x lda player_pos_x
dex sec
stx player_pos_x sbc #1
sta player_pos_x
bcs @end_subpixel_overflow_left
lda player_nmt_x
eor #%00000001
sta player_nmt_x
@end_subpixel_overflow_left:
@end_sub_subpos: @end_sub_subpos:
: :
; load x pos, filter blocks, check up and down ; load x pos, filter blocks, check up and down
lda player_vel_y lda player_vel_y