Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.
;-----------------------demo-------
.inesprg 1
.ineschr 1
.inesmir 1
.inesmap 0
.org $8000
.bank 0
.org $c40d ; replace dashes with load address MINUS $80
.incbin "demo.nsf" ; include NSF tune
Reset_Routine:
cld ; clear decimal flag
sei ; disable interrupts
lda #%00000000 ; disable vblank interrupts by clearing
sta $2000 ; the most significant bit of $2000
Start:
lda #%00001000
sta $2000
lda #%00011110
sta $2001
lda #$3F ;set ppu to start of palette
sta $2006
lda #$00
sta $2006
ldx #$00
loadpal:
lda titlepal, x ;loads a 32 byte palette
sta $2007
inx
cpx #$20 ;gotta be one extra b/c of inx
bne loadpal
vwait:
lda $2002 ;wait...
bpl vwait
lda #$20 ;set ppu to start vram
sta $2006
lda #$20
sta $2006
lda #$01 ;write pattern table tile numbers to the name table
sta $2007
lda #$02
sta $2007
lda #$03
sta $2007
lda #$01
sta $2007
lda #$02
sta $2007
lda #$03
sta $2007
lda #$01
sta $2007
lda #$03
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00 ;write pattern table tile numbers to the name table
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$02
sta $2007
lda #$02
sta $2007
lda #$01
sta $2007
lda #$01
sta $2007
lda #$01
sta $2007
ldx #$00 ;set 2004 to the start SPRRAM
stx $2003
stx $2003
lda #$00 ;Y (w pionie)
sta $2004
lda #$00 ;sprite pattern number (numer tilesa w pliku .SPR)
sta $2004
lda #%00000001
sta $2004
lda #$00 ;X (w poziomie)
sta $2004
lda #$10
sta $2004
lda #$01
sta $2004
lda #%00000001
sta $2004
lda #$10
sta $2004
; *** WAIT 2 VBLANKS ***
WaitV1:
lda $2002 ; give the PPU a little time to initialize
bpl WaitV1 ; by waiting for a vblank
WaitV2:
lda $2002 ; wait for a second vblank to be safe
bpl WaitV2 ; and now the PPU should be initialized
; *** CLEAR SOUND REGISTERS ***
lda #$00 ; clear all the sound registers by setting
ldx #$00 ; everything to 0 in the Clear_Sound loop
Clear_Sound:
sta $4000,x ; store accumulator at $4000 offset by x
inx ; increment x
cpx #$0F ; compare x to $0F
bne Clear_Sound ; branch back to Clear_Sound if x != $0F
lda #$10 ; load accumulator with $10
sta $4010 ; store accumulator in $4010
lda #$00 ; load accumulator with 0
sta $4011 ; clear these 3 registers that are
sta $4012 ; associated with the delta modulation
sta $4013 ; channel of the NES
; *** ENABLE SOUND CHANNELS ***
lda #%00001111 ; enable all sound channels except
sta $4015 ; the delta modulation channel
; *** RESET FRAME COUNTER AND CLOCK DIVIDER ***
lda #$C0 ; synchronize the sound playback routine
sta $4017 ; to the internal timing of the NES
; *** SET SONG # & PAL/NTSC SETTING ***
lda #$00 ; replace dashes with song number
ldx #$00 ; replace with $00 for NTSC or $01 for PAL
jsr $be34 ; replace dashes with init address
; *** ENABLE VBLANK NMI ***
lda #%10000000 ; enable vblank interrupts by setting the
sta $2000 ; most significant bit of $2000
Loop:
jmp Loop
titlepal:
.incbin "demo.pal" ;palette data
NMI_Routine:
lda $2002 ; read $2002 to reset the vblank flag
lda #%00000000 ; clear the first PPU control register
sta $2000 ; writing 0 to it
lda #%10000000 ; reenable vblank interrupts by setting
sta $2000 ; the most significant bit of $2000
jsr $f2d0 ; replace dashes with play address
rti ; return from interrupt routine
IRQ_Routine:
rti ; return from interrupt routine
.bank 1
.org $FFFA
.dw 0 ; NMI_Rutine
.dw Start ; Reset_Rutine
.dw 0 ; IRQ_Rutine
.bank 2
.org $0000
.incbin "demo.bkg"
.incbin "demo.spr"
;-----------------------end----
;-----------------------demo-------
.inesprg 1
.ineschr 1
.inesmir 1
.inesmap 0
.org $8000
.bank 0
.org $c40d ; replace dashes with load address MINUS $80
.incbin "demo.nsf" ; include NSF tune
Reset_Routine:
cld ; clear decimal flag
sei ; disable interrupts
lda #%00000000 ; disable vblank interrupts by clearing
sta $2000 ; the most significant bit of $2000
Start:
lda #%00001000
sta $2000
lda #%00011110
sta $2001
lda #$3F ;set ppu to start of palette
sta $2006
lda #$00
sta $2006
ldx #$00
You need to do the 2 vblank waits before you access $2003-$2007 for the first time.
How to load Name table from file (.map) ???
Have you heard of the "indirect indexed" addressing mode, which uses instructions of the following form?
disable NMI on vblank on $2000 D7 & re-enable it after init.
EDIT: I also don't see any 2 vblank waiting before init
More EDIT: PLUS it doesn't look like you have your interrupts set. I don't know, maybe you did but I overlooked them, I'm too used to how I have my stuff set up. (seperate ASM file for ines, prg, chr in ACME syntax)
;-----------------------demo-------
.inesprg 1
.ineschr 1
.inesmir 1
.inesmap 0
.org $8000
.bank 0
.org $c40d ; replace dashes with load address MINUS $80
.incbin "demo.nsf" ; include NSF tune
Reset_Routine:
cld ; clear decimal flag
sei ; disable interrupts
lda #%00000000 ; disable vblank interrupts by clearing
sta $2000 ; the most significant bit of $2000
Start:
lda #%00001000
sta $2000
lda #%00011110
sta $2001
lda #$3F ;set ppu to start of palette
sta $2006
lda #$00
sta $2006
ldx #$00
loadpal:
lda titlepal, x ;loads a 32 byte palette
sta $2007
inx
cpx #$20 ;gotta be one extra b/c of inx
bne loadpal
vwait:
lda $2002 ;wait...
bpl vwait
lda #$20 ;set ppu to start vram
sta $2006
lda #$20
sta $2006
lda #$01 ;write pattern table tile numbers to the name table
sta $2007
lda #$02
sta $2007
lda #$03
sta $2007
lda #$01
sta $2007
lda #$02
sta $2007
lda #$03
sta $2007
lda #$01
sta $2007
lda #$03
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00 ;write pattern table tile numbers to the name table
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$00
sta $2007
lda #$02
sta $2007
lda #$02
sta $2007
lda #$01
sta $2007
lda #$01
sta $2007
lda #$01
sta $2007
ldx #$00 ;set 2004 to the start SPRRAM
stx $2003
stx $2003
lda #$00 ;Y (w pionie)
sta $2004
lda #$00 ;sprite pattern number (numer tilesa w pliku .SPR)
sta $2004
lda #%00000001
sta $2004
lda #$00 ;X (w poziomie)
sta $2004
lda #$10
sta $2004
lda #$01
sta $2004
lda #%00000001
sta $2004
lda #$10
sta $2004
; *** WAIT 2 VBLANKS ***
WaitV1:
lda $2002 ; give the PPU a little time to initialize
bpl WaitV1 ; by waiting for a vblank
WaitV2:
lda $2002 ; wait for a second vblank to be safe
bpl WaitV2 ; and now the PPU should be initialized
; *** CLEAR SOUND REGISTERS ***
lda #$00 ; clear all the sound registers by setting
ldx #$00 ; everything to 0 in the Clear_Sound loop
Clear_Sound:
sta $4000,x ; store accumulator at $4000 offset by x
inx ; increment x
cpx #$0F ; compare x to $0F
bne Clear_Sound ; branch back to Clear_Sound if x != $0F
lda #$10 ; load accumulator with $10
sta $4010 ; store accumulator in $4010
lda #$00 ; load accumulator with 0
sta $4011 ; clear these 3 registers that are
sta $4012 ; associated with the delta modulation
sta $4013 ; channel of the NES
; *** ENABLE SOUND CHANNELS ***
lda #%00001111 ; enable all sound channels except
sta $4015 ; the delta modulation channel
; *** RESET FRAME COUNTER AND CLOCK DIVIDER ***
lda #$C0 ; synchronize the sound playback routine
sta $4017 ; to the internal timing of the NES
; *** SET SONG # & PAL/NTSC SETTING ***
lda #$00 ; replace dashes with song number
ldx #$00 ; replace with $00 for NTSC or $01 for PAL
jsr $be34 ; replace dashes with init address
; *** ENABLE VBLANK NMI ***
lda #%10000000 ; enable vblank interrupts by setting the
sta $2000 ; most significant bit of $2000
Loop:
jmp Loop
titlepal:
.incbin "demo.pal" ;palette data
NMI_Routine:
lda $2002 ; read $2002 to reset the vblank flag
lda #%00000000 ; clear the first PPU control register
sta $2000 ; writing 0 to it
lda #%10000000 ; reenable vblank interrupts by setting
sta $2000 ; the most significant bit of $2000
jsr $f2d0 ; replace dashes with play address
rti ; return from interrupt routine
IRQ_Routine:
rti ; return from interrupt routine
.bank 1
.org $FFFA
.dw 0 ; NMI_Rutine
.dw Start ; Reset_Rutine
.dw 0 ; IRQ_Rutine
.bank 2
.org $0000
.incbin "demo.bkg"
.incbin "demo.spr"
;-----------------------end----
Same problems I mentioned before still existent, although you can just keep NMI on vblank off for code like this...which you're not doing. The program is looping back to $0000 every 30th of a second, which is probably causing the CPU jam error message.