this is hopefully enough of the code
Code:
; iNES identifier
.byte "NES",$1a
.byte $10 ; PRG-ROM block
.byte $01 ; CHR-ROM block
.byte $20 ; mapper info (using UNROM)
.byte $00 ; mapper info
.byte 0,0,0,0,0,0,0,0 ; pad header to 16 bytes
...
reset:
sei
cld
ldx #0
stx $2000
stx $2001
; Wait two VBLANKs.
- lda $2002
bpl -
- lda $2002
bpl -
; Clear out RAM.
lda #$00
ldx #$00
- sta $000,x
sta $100,x
sta $200,x
sta $300,x
sta $400,x
sta $500,x
sta $600,x
sta $700,x
inx
bne -
; Reset the stack pointer.
ldx #$FF
txs
; initialize sound hardware
lda #$01
sta $4015
lda #$00
sta $4001
lda #$40
sta $4017
sta $4011
; Disable all graphics.
lda #$00
sta $2000
sta $2001
; reset pcmCount location
lda #$0F
sta palCount
init_sprites:
; Clear page #2, which we'll use to hold sprite data
lda #$00
ldx #$00
- sta sprite, x
inx
bne -
; initialize Sprite 0
lda #$70
sta sprite ; Y coordinate
lda #$01
sta sprite+1 ; Pattern number
sta sprite+3 ; X coordinate
; sprite+2, color, stays 0.
jsr load_palette
jsr load_name_tables
lda #$00
sta $2005 ; Write 0 for Horiz. Scroll value
sta $2005 ; Write the value of 'scroll' for Vert. Scroll value
; Set basic PPU registers. Load background from $0000,
; sprites from $1000, and the name table from $2000.
lda #%10001000
sta $2000
lda #%00011110
sta $2001
cli
inc loaded
...
; Load palette into $3F00
load_palette:
lda #$3F
ldx #$00
sta $2006
stx $2006
lda palCount
and #$0f
cmp #$0f
bne nopal
lda pcmCount+1
and #$f0
lsr
lsr
lsr
lsr
sta $ae
tax
lda #$10
adc $ae
sta $af
-
lda palette,x
sta $2007
inx
inx
inx
inx
cpx $af
bne -
nopal:
inc palCount
rts
load_name_tables:
; Jam some text into the first name table (at $2400, thanks to mirroring)
ldy #$00
ldx #$04
lda #<bg
sta $10
lda #>bg
sta $11
lda #$24
sta $2006
lda #$00
sta $2006
- lda ($10),y
sta $2007
iny
bne -
inc $11
dex
bne -
; Clear out the Name Table at $2800 (where we already are. Yay.)
ldy #$00
ldx #$04
lda #$00
- sta $2007
iny
bne -
dex
bne -
rts
; palette data
palette:
.byte $30,$30,$30,$30, $30,$30,$30,$30, $35,$36,$2B,$39, $30,$30,$30,$30
.byte $22,$22,$22,$22, $33,$33,$33,$33, $00,$00,$00,$00, $00,$00,$00,$00
; Background data
bg:
; .. 32 x 30 byte table
; Attribute table
; 16 x 4 byte table
vblank:
php
pha
phx
phy
lda loaded
beq +
jsr load_palette
ldx #$00
lda doSpin
beq +++
ldx scrollLeft
and #01
bne +five
dec scrollLeft
jmp +++
+five
inc scrollLeft
+++
lda vHeight
cmp #$C7
beq ++
adc #$01
+four
sta vHeight
++ stx $2005 ; Write 0 for Horiz. Scroll value
sta $2005 ; Write the value of 'scroll' for Vert. Scroll value
+
ply
plx
pla
plp
irq:
rti
.pad $FFFA
.word vblank, reset, irq
btw i know it's sloppy i'm just trying stuff out