Can make that two NAMETABLE during scrolling passed smoothly? When the first screen scroll to the right and enter a second, then everything is running smoothly. But when the second screen NT1 comes back to the first NT0, doing it one big leap.
I would like to do, to both sides NAMETABLE overlap smoothly.
http://www.youtube.com/watch?v=jd1k0OOySRk
I would like to do, to both sides NAMETABLE overlap smoothly.
http://www.youtube.com/watch?v=jd1k0OOySRk
Code:
.inesprg 1 ; 1x 16KB PRG code
.ineschr 1 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0
.inesmir 1 ; set 1 to 2xNT scroll
.bank 0
.org $C000
RESET:
SEI ; disable IRQs
CLD ; disable decimal mode
LDX #$40
STX $4017 ; disable APU frame IRQ
LDX #$FF
TXS ; Set up stack
INX ; now X = 0
STX $2000 ; disable NMI
STX $2001 ; disable rendering
STX $4010 ; disable DMC IRQs
JSR VBlankWait
ClearMemory:
LDA #$00
STA $0000, x
STA $0100, x
STA $0200, x
STA $0400, x
STA $0500, x
STA $0600, x
STA $0700, x
LDA #$FE
STA $0300, x
INX
BNE ClearMemory
JSR VBlankWait
JSR LoadPalettes
JSR LoadNT1
JSR EnablePPU
Forever:
JMP Forever
;#########################SUBRUTINES##############################
VBlankWait:
BIT $2002
BPL VBlankWait
RTS
LoadNT1:
LDX #$20
STX $2006
LDX #$00
STX $2006
STY $2006
LDX #$08 ;i change 4 to 8 when 2NT load..
LDA #low(NameTable1)
STA <$0000
LDA #high(NameTable1)
STA <$0001
LoadMap1:
LDA [$0000], y
STA $2007
INY
BNE LoadMap1
INC <$0001
DEX
BNE LoadMap1
RTS
;--------------------------NMI------------------------------------------------------
NMI:
LDA #$00 ; pierwsze load 00 do pionowego scrollingu (0 = nic nie scroluje)
STA $2005
LDA $0002 ; drugie wczytanie do poziomego scrollingu wiec w poziomie scroll.
STA $2005 ; uzyta trzecia wolna komorka pamieci czyli $0002 (pierwszy load 00 zablokowal pionowy scroll)
LatchController:
LDA #$01
STA $4016
LDA #$00
STA $4016 ; tell both the controllers to latch buttons
ReadA:
LDA $4016 ; player 1 - A
AND #%00000001 ; only look at bit 0
BEQ ReadADone ; branch to ReadADone if button is NOT pressed (0)
ReadADone:
ReadB:
LDA $4016
AND #%00000001
BEQ ReadBDone
ReadBDone:
ReadSelect:
LDA $4016
AND #%00000001
BEQ ReadSelectDone
ReadSelectDone:
ReadStart:
LDA $4016
AND #%00000001
BEQ ReadStartDone
ReadStartDone:
ReadUp:
LDA $4016
AND #%00000001
BEQ ReadUpDone
ReadUpDone:
ReadDown:
LDA $4016
AND #%00000001
BEQ ReadDownDone
ReadDownDone:
ReadLeft:
LDA $4016
AND #%00000001
BEQ ReadLeftDone
JSR ScrollLeft
ReadLeftDone:
ReadRight:
LDA $4016
AND #%00000001
BEQ ReadRightDone
JSR ScrollRight
ReadRightDone:
RTI
LoadPalettes:
LDA $2002 ; read PPU status to reset the high/low latch
LDA #$3F
STA $2006 ; write the high byte of $3F00 address
LDA #$00
STA $2006 ; write the low byte of $3F00 address
LDX #$00 ; start out at 0
LoadPalettesLoop:
LDA Palette, x ; load data from address (palette + the value in x)
; 1st time through loop it will load palette+0
; 2nd time through loop it will load palette+1
; 3rd time through loop it will load palette+2
; etc
STA $2007 ; write to PPU
INX ; X = X + 1
CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
; if compare was equal to 32, keep going down
RTS
EnablePPU:
LDA #%10010000 ; enable NMI, sprites from Pattern Table 1
STA $2000
LDA #%00011110 ; enable sprites
STA $2001
RTS
ScrollRight:
LDA $0002
CLC
ADC #$01
STA $0002
RTS
ScrollLeft:
LDA $0002
SEC
SBC #$01
STA $0002
RTS
;#########################SUBRUTINES END###########################
NameTable1:
.incbin "test.na1"
.incbin "test.na2"
Palette:
.incbin "test.pal"
.bank 1
.org $FFFA ; three vectors
.dw NMI
.dw RESET
.dw 0
.bank 2
.org $0000
.incbin "test.spr"
.incbin "test.chr"
.ineschr 1 ; 1x 8KB CHR data
.inesmap 0 ; mapper 0
.inesmir 1 ; set 1 to 2xNT scroll
.bank 0
.org $C000
RESET:
SEI ; disable IRQs
CLD ; disable decimal mode
LDX #$40
STX $4017 ; disable APU frame IRQ
LDX #$FF
TXS ; Set up stack
INX ; now X = 0
STX $2000 ; disable NMI
STX $2001 ; disable rendering
STX $4010 ; disable DMC IRQs
JSR VBlankWait
ClearMemory:
LDA #$00
STA $0000, x
STA $0100, x
STA $0200, x
STA $0400, x
STA $0500, x
STA $0600, x
STA $0700, x
LDA #$FE
STA $0300, x
INX
BNE ClearMemory
JSR VBlankWait
JSR LoadPalettes
JSR LoadNT1
JSR EnablePPU
Forever:
JMP Forever
;#########################SUBRUTINES##############################
VBlankWait:
BIT $2002
BPL VBlankWait
RTS
LoadNT1:
LDX #$20
STX $2006
LDX #$00
STX $2006
STY $2006
LDX #$08 ;i change 4 to 8 when 2NT load..
LDA #low(NameTable1)
STA <$0000
LDA #high(NameTable1)
STA <$0001
LoadMap1:
LDA [$0000], y
STA $2007
INY
BNE LoadMap1
INC <$0001
DEX
BNE LoadMap1
RTS
;--------------------------NMI------------------------------------------------------
NMI:
LDA #$00 ; pierwsze load 00 do pionowego scrollingu (0 = nic nie scroluje)
STA $2005
LDA $0002 ; drugie wczytanie do poziomego scrollingu wiec w poziomie scroll.
STA $2005 ; uzyta trzecia wolna komorka pamieci czyli $0002 (pierwszy load 00 zablokowal pionowy scroll)
LatchController:
LDA #$01
STA $4016
LDA #$00
STA $4016 ; tell both the controllers to latch buttons
ReadA:
LDA $4016 ; player 1 - A
AND #%00000001 ; only look at bit 0
BEQ ReadADone ; branch to ReadADone if button is NOT pressed (0)
ReadADone:
ReadB:
LDA $4016
AND #%00000001
BEQ ReadBDone
ReadBDone:
ReadSelect:
LDA $4016
AND #%00000001
BEQ ReadSelectDone
ReadSelectDone:
ReadStart:
LDA $4016
AND #%00000001
BEQ ReadStartDone
ReadStartDone:
ReadUp:
LDA $4016
AND #%00000001
BEQ ReadUpDone
ReadUpDone:
ReadDown:
LDA $4016
AND #%00000001
BEQ ReadDownDone
ReadDownDone:
ReadLeft:
LDA $4016
AND #%00000001
BEQ ReadLeftDone
JSR ScrollLeft
ReadLeftDone:
ReadRight:
LDA $4016
AND #%00000001
BEQ ReadRightDone
JSR ScrollRight
ReadRightDone:
RTI
LoadPalettes:
LDA $2002 ; read PPU status to reset the high/low latch
LDA #$3F
STA $2006 ; write the high byte of $3F00 address
LDA #$00
STA $2006 ; write the low byte of $3F00 address
LDX #$00 ; start out at 0
LoadPalettesLoop:
LDA Palette, x ; load data from address (palette + the value in x)
; 1st time through loop it will load palette+0
; 2nd time through loop it will load palette+1
; 3rd time through loop it will load palette+2
; etc
STA $2007 ; write to PPU
INX ; X = X + 1
CPX #$20 ; Compare X to hex $10, decimal 16 - copying 16 bytes = 4 sprites
BNE LoadPalettesLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero
; if compare was equal to 32, keep going down
RTS
EnablePPU:
LDA #%10010000 ; enable NMI, sprites from Pattern Table 1
STA $2000
LDA #%00011110 ; enable sprites
STA $2001
RTS
ScrollRight:
LDA $0002
CLC
ADC #$01
STA $0002
RTS
ScrollLeft:
LDA $0002
SEC
SBC #$01
STA $0002
RTS
;#########################SUBRUTINES END###########################
NameTable1:
.incbin "test.na1"
.incbin "test.na2"
Palette:
.incbin "test.pal"
.bank 1
.org $FFFA ; three vectors
.dw NMI
.dw RESET
.dw 0
.bank 2
.org $0000
.incbin "test.spr"
.incbin "test.chr"