Hi, I'm toying with something at the moment. I've got a scrolling background, and I'm trying to change the background on the next screen. It's making the changes, and is changing them at the right times, but I get a quick flash on the screen every time it runs.
I've attached the files as well as the rom. I haven't finished setting the background attributes, so please ignore that for the time being. I'm using NESASM and running it on MESEN.
Here is the code:
I've attached the files as well as the rom. I haven't finished setting the background attributes, so please ignore that for the time being. I'm using NESASM and running it on MESEN.
Here is the code:
Code:
.inesprg 1 .ineschr 1 .inesmap 0 .inesmir 1 ;;;;;;;;;;;;;;; .bank 0 .org $C000 .rsset $0000bgLowByte .rs 1bgHighByte .rs 1scroll .rs 1ppuctrl .rs 1currentScreen .rs 1 RESET: SEI CLD LDX #$40 STX $4017 LDX #$FF TXS INX STX $2000 STX $2001 STX $4010 vblankwait1: BIT $2002 BPL vblankwait1 clrmem: LDA #$00 STA $0000, x STA $0100, x STA $0400, x STA $0500, x STA $0600, x STA $0700, x LDA #$FE STA $0300, x INX BNE clrmem vblankwait2: BIT $2002 BPL vblankwait2 lda #%00000000 sta $2000 lda #%00000000 sta $2001 loadPalette: lda #$3f sta $2006 lda #$00 sta $2006 ;first palette lda #$0f sta $2007 lda #$11 sta $2007 lda #$10 sta $2007 lda #$30 sta $2007 ;second lda #$0f sta $2007 lda #$06 sta $2007 lda #$16 sta $2007 lda $26 sta $2007setPPUControl: lda #%10010000 sta ppuctrl initScroll: lda #$01 sta scroll setCurrentScreen: lda #$00 sta currentScreen drawBackground1Tiles: ldy #$00 ldx #$00 lda $2002 lda #$20 sta $2006 lda #$00 sta $2006 lda #LOW(firstBG) sta bgLowByte lda #HIGH(firstBG) sta bgHighByte bgLoop1: lda [bgLowByte], y sta $2007 iny cpy #$00 bne bgLoop1 inc bgHighByte inx cpx #$04 bne bgLoop1 drawBackground2Tiles: ldy #$00 ldx #$00 lda $2002 lda #$24 sta $2006 lda #$00 sta $2006 lda #LOW(secondBG) sta bgLowByte lda #HIGH(secondBG) sta bgHighByte bgLoop2: lda [bgLowByte], y sta $2007 iny cpy #$00 bne bgLoop2 inc bgHighByte inx cpx #$04 bne bgLoop2loadAttributes: lda $2002 lda #$23 sta $2006 lda #$C0 sta $2006 ldx #$00attrLoop: lda bgAttr, x sta $2007 inx cpx #$40 bne attrLoop resetPPU: lda ppuctrl sta $2000 lda #%00011110 sta $2001 Foreverloop: JMP Foreverloop NMI: lda #$00 sta $2003 lda #$02 sta $4014 inc scroll lda scroll cmp #$FF bne setScroll inc currentScreen ;jsr updateScreenByPage jsr updateBaseNametable RTI setScroll: lda scroll sta $2005 lda #$00 sta $2005 rts updateBaseNametable: lda #%00000000 sta $2000 jsr updateScreenByPage lda ppuctrl eor #%00000001 sta ppuctrl sta $2000 rts updateScreenByPage: lda currentScreen cmp #$03 beq setUpScreen3 cmp #$05 beq setUpScreen4 rts setUpScreen3: lda $2002 lda #$23 sta $2006 lda #$33 sta $2006 lda #$02 sta $2007 rts setUpScreen4: lda $2002 lda #$23 sta $2006 lda #$33 sta $2006 lda #$00 sta $2007 lda #$23 sta $2006 lda #$0C sta $2006 lda #$02 sta $2007 lda #$23 sta $2006 lda #$2C sta $2006 lda #$02 sta $2007 rts ;;;;;;;;;;;;;; .bank 1 .org $E000 firstBG: .include "flight1.asm"secondBG: .include "flight2.asm"bgAttr: .include "bg_attr.asm" .org $FFFA .dw NMI .dw RESET .dw 0 ;;;;;;;;;;;;;; .bank 2 .org $0000 .incbin "flight.chr"
Statistics: Posted by sneed_generator — Sat Mar 09, 2024 6:28 pm — Replies 1 — Views 83