Thanks, that's very kind that you'll be looking at the whole code, thought first it would be too big to post here (didn't want to spam)
Code:
.inesprg 1 ; one (1) bank of program code
.ineschr 1 ; one (1) bank of picture data
.inesmap 0 ; we use mapper 0
.inesmir 1 ; Mirror setting always 1.
.bank 1 ; following goes in bank 1
.org $FFFA ; start at $FFFA
.dw 0 ; dw stands for Define Word and we give 0 as address for NMI routine
.dw Start ; give address of start of our code for execution on reset of NES.
.dw 0 ; give 0 for address of VBlank interrupt handler, we tell PPU not to
; make an interrupt for VBlank.
.bank 0 ; bank 0 - our place for code.
.org $0000
addrLO .db 0
addrHI .db 0
counter .db 0
temp .db 0
timer .db 0
sintable .db 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 56, 60, 64, 68, 73, 77, 81, 86, 90
;sintable2 .db 94, 98;, 103, 107, 111, 115, 120, 124, 128, 133, 137, 141, 145, 150, 154, 158,
sintable3 .db 162, 167, 171, 175, 180, 184, 188, 192, 197, 201, 205, 210, 214, 218, 222; as said these values look wrong to me
;227, 231, 235, 239, 244, 248, 252, 256
.org $0200
.org $8000 ; code starts at $8000
Start:
lda #%00001000 ; do the setup of PPU
sta $2000 ; that we
lda #%10011110 ; talked about
sta $2001 ; on a previous day
ldx #$00 ; clear X
lda #$3F ; have $2006 tell
sta $2006 ; $2007 to start
lda #$00 ; at $3F00 (pallete).
sta $2006
loadpal: ; this is a freaky loop
lda tilepal, x ; that gives 32 numbers
sta $2007 ; to $2007, ending when
inx ; X is 32, meaning we
cpx #32 ; are done.
bne loadpal ; if X isn't =32, goto "loadpal:" line.
;Background/Titelbild laden
ldx #0
lda #$20 ; set the destination address in PPU memory
sta $2006 ; should be $2000
stx $2006
lda #low(nametable1) ; put the high and low bytes of the address "backg"
sta addrLO ; into the variables so we can use indirect addressing.
lda #high(nametable1)
sta addrHI
ldx #4 ; number of 256-byte chunks to load
ldy #0
loopTable1:
lda [addrLO],y
sta $2007 ; load 256 bytes
iny
bne loopTable1
;--------------------
inc addrHI ; increment high byte of address backg to next 256 byte chunk
dex ; one chunk done so X = X - 1.
bne loopTable1 ; if X isn't zero, do again
ldx #0
lda #$24 ; set the destination address in PPU memory
sta $2006 ; should be $2000
stx $2006
lda #low(nametable2) ; put the high and low bytes of the address "backg"
sta addrLO ; into the variables so we can use indirect addressing.
lda #high(nametable2)
sta addrHI
ldx #4 ; number of 256-byte chunks to load
ldy #0
loopTable2:
lda [addrLO],y
sta $2007 ; load 256 bytes
iny
bne loopTable2
;--------------------
inc addrHI ; increment high byte of address backg to next 256 byte chunk
dex ; one chunk done so X = X - 1.
bne loopTable2 ; if X isn't zero, do again
lda #0
sta counter
sta timer
waitblank: ; this is the wait for VBlank code from above
lda $2002 ; load A with value at location $2002
bpl waitblank ; if bit 7 is not set (not VBlank) keep checking
lda #$00 ; these lines tell $2003
sta $2003 ; to tell
lda #$00 ; $2004 to start
sta $2003 ; at $0000.
;Screen abschalten
lda #$00
sta $2001
lda #%00001000
sta $2000
lda #%10011110
sta $2001
lda timer
cmp #20
beq resettimer
inc timer
jmp dontresettimer
resettimer:
lda #0
sta timer
jmp screenon
dontresettimer
lda counter
cmp #15
beq resetcounter
ldy counter
lda sintable,y
sta temp
inc counter
jmp screenon
resetcounter:
lda #0
sta counter
sta temp
screenon:
lda temp
sta $2005
lda #0
sta $2005
;Screen anschalten
lda #%00001000
sta $2000
lda #%10011110
sta $2001
jmp waitblank
tilepal: .incbin "scroll.pal"
nametable1: .incbin "scroll.nam"
nametable2: .incbin "scroll2.nam"
.bank 2 ; switch to bank 2
.org $0000 ; start at $0000
.incbin "scroll.bkg"
.incbin "scroll.spr"