From 551aa135ec54c4343f04b3f6936f7959f780cde2 Mon Sep 17 00:00:00 2001 From: RochesterX Date: Fri, 15 May 2026 11:23:10 -0400 Subject: [PATCH] Granular scroll nametable updating, buffering and pointers, etc. --- plat.nes | Bin 40976 -> 40976 bytes plat.s | 126 ++++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 101 insertions(+), 25 deletions(-) diff --git a/plat.nes b/plat.nes index 40f80265618c61cfda6db0e07bfd5947fc1b241d..0888289378e59bf7a50a43ef4e99ff1079bd275d 100644 GIT binary patch delta 1135 zcmah{T}TvB6rR5wcl~K+9aqQN*}bc)yQ4jrWC>aLqNogIP=@tlk>UCfLDW;Bt6ulV zk*sUr%RmV?W|jg&2o~D#MbLuSN1+!X1cQ*3GROz*jz6$!6f<*~^L^)>`R06QVvd=Z zV`gsC&9^k2;#QZz#0JntKx4#ghNZB~q+kG6fv-bgJ^F?LI3R^-7y##DfE@7p)Yhu-iqL&7JHUeJwsSj=tU}1 zU~Z0c%y=QAdJtgB8|sH}5%geh;|f3T%`!6%>}j!Q3RQK;dLfnlxs?<%ZfDefbeE~7 zb@ZG8^lS8v@zbBt64TJF^z=+q;IXB{fknq46x9>Mq2MPEW9*I7Op0}F9*GY&Rm>b((i?uC=+5eJm|gbs)s+04c? zm97}m1>1gbh(YsQ({VW_^-9S!;FN)B8`zE})5Y3&9!QHC^7G$_MN89z$eQjOnCx3oG$vDB;D7Y5I3Nc*qL8XV788mqq z!iwTd;-F=75QoAP41HXtGHYb5tXu(lOaNu_)R-Ks#U4c<_PcP66wbmLTubt6%>a}M z;e=jOAl^v5USp~)VZ04OU!Q?}PivGL121-_pJ+3A%e_>wrZa3x)O40jm1sK0rrert zWBZJb4yjkxDb{QzZjnyp)@gPsxw`BmgYJ%+PRJ5z*2Yl$&c>kCyjQe|p4feY93xAD zi>zf$3pRBLeXyTloN@Ha?mf(1KmkXqAI7CHFZJ(U22p>g14d(x){5`{$tq0D{&1{6 Jn9U#L!5=zWomT(= delta 1163 zcmb7DUr19?7{BMoRP@?dm9-pgsZI7(9%@+ZfYn z_hQ=f7`3aB;=I)1Fp%0W%}ZFCk*FL(SPsLL#3ENbWNhPltq_9?=1DXVu7}kLsEdbb zb#M)($tr@*Uol#BQ7#Hv<0y3o&?2{V*!Y24!4YoU93tgEhHlNPNc`ELyaid z!Sqsx$V%yeTV`-IZC*r0+1SFhETfl!xS2w5#YYzPj(Wx~6MC^_w$ z*mZi1Y)a>%zNK2~3vJ`0&>5#bHV=Vj>|;}9?iK7Z0K3`mH$>b@T>*u4-$DKCtzbWG zjc~Zt@L@M2YOsgZ{v&IYCrgjEO*9P^nhH(ImiY*ZymjP}KM;Lds`}(*Lo$1q`1wFGflJ^MM8^jN#SHroom_buffer + sta column_pattern_pointer+1 + + ; Since column pattern pointer points to the current column we need to draw, we start it at the beginning of the room buffer (which stores columns as rows), then we add 16 (going to the next "row" in memory which is the next column in reality) how many ever times in column_pattern_pointer to point to the correct row. From there, anything can just loop 16 times from that pointer to get the currently drawing row. + lda tile_update_pos + and #%00001111 + tax + : + lda column_pattern_pointer + clc + adc #16 + sta column_pattern_pointer + lda column_pattern_pointer+1 + adc #0 + sta column_pattern_pointer+1 + + dex + cpx #0 + bne :- + rts + update_nmt_column: ; X represents the row of the current tile being updated ldx #0 @row_loop: - lda tile_update_pos_r + lda tile_update_pos clc ; Add offset in tiles from left edge of screen adc #16 @@ -1543,22 +1575,56 @@ update_nmt_column: ; Specifies what tile gets written to the column - lda column_pattern - rol - stx var_m - : - ror - dec var_m - dec var_m - bpl :- + ; + ; T------> + ;lda column_pattern + ;ror + ;sta var_wide1 + ; >-----BX + ;lda column_pattern+1 + ;ror + ;sta var_wide1+1 - and #%00000001 - cmp #0 - beq :+ - ora #%10000000 - : + ;stx var_m + ;: + ;lda var_wide1+1 + ;rol + ;sta var_wide1+1 + ;lda var_wide1 + ;rol + ;sta var_wide1 + ;dec var_m + ;bpl :- + + ;lda var_wide1 + ;and #%10000000 + ;cmp #0 + ;beq :+ + ; What metatile do we load for a non-empty shape? + ;lda #%10000001 + ;: + + ; Preserve Y (our index in to level) + tya + pha + + ; Transfer X to Y (our current row in the updated column) + txa + tay + + ; Instead of all that nonsense constructing the tile that we want to draw, just index in to the column_pattern_pointer + ; Storing in var wide 1 because I know it's not used + lda (column_pattern_pointer), Y + sta var_wide1 + + ; Restore Y + pla + tay + ; Write our new metatile to level (for collision mostly) + lda var_wide1 sta (pointer), Y + ; ...and actually perform a nametable update and #%01111111 ldy #5 jsr mul_y @@ -1619,6 +1685,16 @@ update_nmt_column: rts +update_room_buffer: + ldx #0 + : + lda default_level2, X + sta room_buffer, X + inx + cpx #240 + bne :- + rts + mul_x: cmp #0 beq @zero