Basically, I'm trying to build a room in a map in quarters--there's a certain number of possible patterns stored in bank 1, all under the label "quarters." There's another section directly beneath it called "quarterAddresses."
My problem I'm having is that it works for the first twelve quarters, but thirteen draws nonsense on the screen, and fourteen, which I created so I could figure out what's going on, just shows a blank screen.
Does anybody know what I'm doing wrong? Here's my code:
My problem I'm having is that it works for the first twelve quarters, but thirteen draws nonsense on the screen, and fourteen, which I created so I could figure out what's going on, just shows a blank screen.
Does anybody know what I'm doing wrong? Here's my code:
Code:
.inesprg 1 ; 2x 16KB PRG code banks (banks 0, 1, 2, 3) .ineschr 1 ; 1x 8KB CHR data banks (bank 4) .inesmap 0 ; mapper (0 = NROM), no bank swapping .inesmir 1 ; 0 = horizontal background mirroring (for vertical scrolling) .bank 0 .org $C000 .rsset $0000bgLow .rs 1bgHigh .rs 1smLow .rs 1smHigh .rs 1compPtr .rs 1rowFlag .rs 1randSeed .rs 1randNum .rs 1quarter .rs 1roomIndex .rs 1qOffset .rs 1urQOffset .rs 1RESET: sei ; ignore 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 ; Optional (omitted): ; Set up mapper and jmp to further init code here. ; The vblank flag is in an unknown state after reset, ; so it is cleared here to make sure that @vblankwait1 ; does not exit immediately. bit $2002 ; First of two waits for vertical blank to make sure that the ; PPU has stabilizedvblankwait1: bit $2002 bpl vblankwait1 ; We now have about 30,000 cycles to burn before the PPU stabilizes. ; One thing we can do with this time is put RAM in a known state. ; Here we fill it with $00, which matches what (say) a C compiler ; expects for BSS. Conveniently, X is still 0. txaclrmem: sta $000,x sta $000,x sta $200,x sta $300,x sta $400,x sta $500,x sta $600,x sta $700,x inx bne clrmem ; Other things you can do between vblank waits are set up audio ; or set up other mapper registers. vblankwait2: bit $2002 bpl vblankwait2setZeroes: lda #$00 sta bgHigh sta bgLow sta rowFlag sta compPtr sta qOffsetdisableNMI: lda #%00000000 sta $2000 lda #%00000000 sta $2001 loadPalettes: lda #HIGH(bgPalettes) sta bgHigh lda #LOW(bgPalettes) sta bgLow ldy #$00 lda $2002 lda #$3F sta $2006 lda #$00 sta $2006 lda #$0F sta $2007 loadPalettesLoop: lda bgPalettes, y sta $2007 iny cpy #8 bne loadPalettesLoop lockScroll: lda #$00 sta $2005 sta $2005 lda #14 sta quarter jsr loadBasicMap jsr loadQuarter ;inc quarter inc qOffset jsr loadQuarter ;inc quarter inc qOffset jsr loadQuarter ;inc quarter inc qOffset jsr loadQuarter jsr loadTestMap lda #$00 sta randSeed lda $2002 lda #%10010000 sta $2000 lda #%00111110 sta $2001 infinite: jmp infiniteNMI: lda #$00 sta $2003 lda #$02 sta $4014 lda #$00 sta $2005 sta $2005 rti loadQuarter: lda qOffset sta urQOffset ldx #$00 lda #HIGH($0500) sta smHigh lda #LOW($0500) sta smLow pha txa pha ldy qOffset clc adc quarterStart, y sta smLow pla tax pla ldy quarter lda qHigh, y sta bgHigh lda qLow, y sta bgLow ldy #$00 ldx #$00 loadQuarterLoop: lda [bgLow], y sta [smLow], y iny cpy #7 bne loadQuarterLoop lda smLow clc adc #16 sta smLow lda bgLow clc adc #$07 sta bgLow ldy #$00 inx cpx #$06 bne loadQuarterLoop rts loadTestMap: ldy #$00 ldx #$00 lda $2002 lda #$20 sta $2006 lda #$00 sta $2006 ldy #$00 loadTestMapLoop: lda $0500, y tax lda TL, x sta $2007 lda TR, x sta $2007 tya pha ldy compPtr lda BL, x sta $0400, y iny lda BR, x sta $0400, y iny tya sta compPtr pla tay lda compPtr cmp #32 beq dropSecondRow returnFromSecondRow: iny cpy #240 bne loadTestMapLoop rts dropSecondRow: tya pha ldy #$00 loadSecondRowLoop: lda $0400, y sta $2007 lda #$00 sta $0400, y iny cpy #32 bne loadSecondRowLoop lda #$00 sta compPtr pla tay jmp returnFromSecondRow rtsloadBasicMap: tya pha lda #$01 ldy #$00 loadBasicMapLoop: lda baseMap, y sta $0500, y iny cpy #240 bne loadBasicMapLoop pla tay rts .bank 1 .org $E000 quarters: quarter1: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $01, $01, $01, $01, $04 .byte $04, $01, $04, $04, $04, $04, $04 .byte $04, $01, $04, $04, $01, $01, $04 .byte $04, $01, $04, $04, $01, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter2: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $01, $01, $01, $01, $04 .byte $04, $04, $04, $04, $04, $01, $04 .byte $04, $01, $01, $04, $04, $01, $04 .byte $04, $01, $01, $04, $04, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter3: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $04, $04, $01, $01, $04 .byte $04, $01, $04, $04, $01, $01, $04 .byte $04, $01, $04, $04, $04, $04, $04 .byte $04, $01, $01, $01, $01, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter4: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $01, $04, $04, $01, $04 .byte $04, $01, $01, $04, $04, $01, $04 .byte $04, $04, $04, $04, $04, $01, $04 .byte $04, $01, $01, $01, $01, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter5: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter6: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $04, $01, $04, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $04, $01, $04, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $04, $01, $04, $01, $04 quarter7: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $01, $04, $01, $04, $01 .byte $01, $04, $01, $04, $01, $04, $01 .byte $01, $04, $01, $04, $01, $04, $01 .byte $04, $04, $01, $04, $01, $04, $01 .byte $04, $04, $04, $04, $04, $04, $04 quarter8: .byte $04, $04, $04, $04, $04, $04, $04 .byte $01, $04, $01, $04, $01, $04, $04 .byte $01, $04, $01, $04, $01, $04, $01 .byte $01, $04, $01, $04, $01, $04, $01 .byte $01, $04, $01, $04, $01, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter9: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $01, $04, $01, $04, $04 .byte $04, $01, $04, $04, $04, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $01, $04, $01, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter10: .byte $04, $01, $04, $01, $04, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $01, $04, $01, $04, $01, $04, $01 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $04, $01, $04, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter11: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $01, $01, $01, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $01, $01, $01, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter12: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $01, $04, $04, $04, $01, $04 .byte $04, $01, $04, $01, $04, $01, $04 .byte $04, $01, $04, $01, $04, $01, $04 .byte $04, $01, $04, $04, $04, $01, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter13: .byte $04, $04, $04, $04, $04, $04, $04 .byte $04, $04, $04, $01, $04, $04, $04 .byte $04, $01, $04, $04, $04, $01, $04 .byte $04, $01, $04, $04, $04, $01, $04 .byte $04, $04, $04, $01, $04, $04, $04 .byte $04, $04, $04, $04, $04, $04, $04 quarter14: .byte $01, $01, $01, $01, $01, $01, $01 .byte $01, $01, $01, $01, $01, $01, $01 .byte $01, $01, $01, $01, $01, $01, $01 .byte $01, $01, $01, $01, $01, $01, $01 .byte $01, $01, $01, $01, $01, $01, $01 .byte $01, $01, $01, $01, $01, $01, $01 quarterAddresses: qHigh: .byte $E0, $E0, $E0, $E0, $E0, $E0, $E0, $E1, $E1, $E1, $E1, $E1, $E1, $E2 qLow: .byte $00, $2A, $54, $7E, $A8, $D2, $FC, $26, $50, $7A, $A4, $CE, $F8, $22 quarterStart: .byte $21, $28, $81, $88 tileDefinitions: TL: .byte $00, $01, $05, $00, $21, $22, $26, $27, $28, $29 TR: .byte $00, $02, $06, $00, $21, $23, $26, $27, $28, $29 BL: .byte $00, $03, $07, $00, $21, $24, $26, $27, $28, $29 BR: .byte $00, $04, $08, $00, $21, $25, $26, $27, $28, $29 bgPalettes: .byte $0F, $09, $16, $27, $04, $0B, $1A, $29 baseMap: .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00 .byte $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $04, $01 .byte $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01 .org $FFFA ; first of the three vectors starts here .dw NMI ; when an NMI happens (once per frame if enabled) the processor will jump to the label NMI: .dw RESET ; when the processor first turns on or is reset, it will jump to the label RESET: .dw 0 ; external interrupt IRQ unused .bank 2 .org $0000 .incbin "bwzrd.chr"
Statistics: Posted by sneed_generator — Thu Sep 26, 2024 2:58 am — Replies 4 — Views 170