_arr equ 11
_TEMPB1 equ 13
PPU_REG1 equ 8192
PPU_REG2 equ 8193
PPU_SCROLL_POS equ 8197
PPU_STAT_REG equ 8194
PPU_DMA_ADR equ 16404
bgLoadPal___22 equ _TEMPB1
bgLoadNameTable___26 equ _TEMPB1
oamArray equ 768
setSprite__x equ 0
setSprite__y equ 1
setSprite__index equ 2
setSprite___32 equ 4
setSprite___33 equ 6
setSprite___34 equ 8
setSprite___37 equ 10
_s3__i equ 15
;### (0) 
    opt h-
 .byte('N', 'E', 'S', $1A, $02, $02,$10,$00,$01,$00,$00,$00,$00,$00,$00,$00)
 org $8000
RESET:
   sei
   cld
   ldx #$FF
   txs
start_example:
;### background.atl(34) waitvbl
   jsr waitvbl
;### background.atl(35) waitvbl
   jsr waitvbl
;### background.atl(37) setMMC1Ctrl 24
   lda #24
   jsr setMMC1Ctrl
;### background.atl(38) setMMC1Prog 0
   lda #0
   jsr setMMC1Prog
;### background.atl(39) setMMC1Chr0 0
   lda #0
   jsr setMMC1Chr0
;### background.atl(43) setDisplayMode %00000000 %00000000
   lda #0
   sta PPU_REG1
   sta PPU_REG2
;### background.atl(44) for i:0..255
   sta _s3__i
_lbl11:
;### background.atl(45)       setSprite i 0 0 0 247
   lda #0
   sta setSprite__x
   lda #247
   sta setSprite__y
   lda _s3__i
   ldx #0
   ldy #0
   jsr setSprite
   inc _s3__i
   lda _s3__i
   cmp #0
   jne _lbl11
;### background.atl(47) bgLoadPal quizScreenPal
   lda #<quizScreenPal
   ldx #>quizScreenPal
   jsr bgLoadPal
;### background.atl(49) bgLoadNameTable quizScreenNam
   lda #<quizScreenNam
   ldx #>quizScreenNam
   jsr bgLoadNameTable
;### background.atl(51) setDisplayMode %00001000 %%00111110
   lda #8
   sta PPU_REG1
   lda #62
   sta PPU_REG2
;### background.atl(53) bgSetScrolling 0 0
   lda #0
   sta PPU_SCROLL_POS
   sta PPU_SCROLL_POS
;### background.atl(54) setSprite 0 $11 0 136 160
   lda #136
   sta setSprite__x
   lda #160
   sta setSprite__y
   lda #0
   ldx #17
   ldy #0
   jsr setSprite
;### background.atl(56) x = 0
main:
;### background.atl(60) waitvbl
   jsr waitvbl
;### background.atl(62) setMMC1Chr0 0
   lda #0
   jsr setMMC1Chr0
;### background.atl(65) PPU_DMA_ADR= 3
   lda #3
   sta PPU_DMA_ADR
;### background.atl(68) spriteHit
;### nes.atl(70) 		until PPU_STAT_REG bitand 64 <> 0  
_lbl6:
;### nes.atl(69) 		until PPU_STAT_REG bitand 64 = 0
   lda PPU_STAT_REG
   and #64
   cmp #0
   jne _lbl6
_lbl9:
   lda PPU_STAT_REG
   and #64
   cmp #0
   jeq _lbl9
_lbl8:
;### background.atl(69) setMMC1Chr0 1
   lda #1
   jsr setMMC1Chr0
;### background.atl(73) goto main
   jmp main
quizScreenPal:
;### background.atl(27) const quizScreenPal:bgPal       = file "test.pal"
   ins 'test.pal'
quizScreenNam:
;### background.atl(28) const quizScreenNam:bgNameTable = file "face.nam"
   ins 'face.nam'
   rts
waitvbl .proc
_lbl3:
;### nes.atl(65) 		until PPU_STAT_REG bitand 128 <> 0 
   lda PPU_STAT_REG
   and #128
   cmp #0
   jeq _lbl3
_lbl2:
   rts
.endp
setSprite .proc
   sty setSprite___37
;### nes_sprite.atl(27) 		  index = oamnr * 4
   asl
   sta setSprite__index-0
   lda #0
   rol
   asl setSprite__index-0
   rol
   sta setSprite__index-0+1
;### nes_sprite.atl(28) 		  oamArray(index) = y
   lda #<oamArray
   sta _arr-0
   lda #>oamArray
   clc
   adc setSprite__index+1
   sta _arr-0+1
   ldy setSprite__index-0+0
   lda setSprite__y
   sta (_arr),y
;### nes_sprite.atl(29) 		  oamArray(index + 1) = nr
   lda setSprite__index-0
   clc
   adc #1
   tay
   lda setSprite__index-0+1
   adc #0
   sta setSprite___32-0+1
   lda #>oamArray
   clc
   adc setSprite___32+1
   sta _arr-0+1
   txa
   sta (_arr),y
;### nes_sprite.atl(30) 		  oamArray(index + 2) = palNr
   lda setSprite__index-0
   clc
   adc #2
   tay
   lda setSprite__index-0+1
   adc #0
   sta setSprite___33-0+1
   clc
   lda setSprite___37
   sta (_arr),y
;### nes_sprite.atl(31) 		  oamArray(index + 3) = x
   lda setSprite__index-0
   clc
   adc #3
   tay
   lda setSprite__index-0+1
   adc #0
   sta setSprite___34-0+1
   clc
   lda setSprite__x
   sta (_arr),y
   rts
.endp
   icl 'C:\Users\Anwender\Desktop\My Dropbox\studium\nes\freezed version\beta 2\scratchalan\atalan\platform\nes\nes.asm'
   icl 'C:\Users\Anwender\Desktop\My Dropbox\studium\nes\freezed version\beta 2\scratchalan\atalan\processor\m6502\m6502.asm'
   icl 'C:\Users\Anwender\Desktop\My Dropbox\studium\nes\freezed version\beta 2\scratchalan\atalan\platform\nes\nes_bg.asm'
   icl 'C:\Users\Anwender\Desktop\My Dropbox\studium\nes\freezed version\beta 2\scratchalan\atalan\platform\nes\nes_sprite.asm'
   icl 'C:\Users\Anwender\Desktop\My Dropbox\studium\nes\freezed version\beta 2\scratchalan\atalan\platform\nes\nes_mmc1.asm'
    .align $FFF9,$00
NMI:
    rti
   org $FFFA
   .dw RESET
  .dw RESET
   .dw 0
