Code: Select all
globalLabel:
@localLabel:
- someOpcode
generalBranch -
jmp @localLabel
Code: Select all
; HEADER
INES_MAPPER = 0 ; 0 = NROM
INES_MIRROR = 1 ; 0 = horizontal mirroring, 1 = vertical mirroring
INES_SRAM = 0 ; 1 = battery backed SRAM at $6000-7FFF
.db 'N', 'E', 'S', $1A ; ID
.db $02 ; 16k PRG bank count
.db $01 ; 8k CHR bank count
.db INES_MIRROR | (INES_SRAM << 1) | ((INES_MAPPER & $f) << 4)
.db (INES_MAPPER & %11110000)
.db $0, $0, $0, $0, $0, $0, $0, $0 ; padding
.fillvalue $ff
.enum $0000
isVBlank: db 0;
.ende
.enum $0300
Sprite0_Y: .db 0 ; sprite #0's Y value
Sprite0_T: .db 0 ; sprite #0's Tile Number
Sprite0_S: .db 0 ; sprite #0's special byte
Sprite0_X: .db 0 ; sprite #0's X value
.ende
.base $8000
; FamiStudio config.
FAMISTUDIO_CFG_EXTERNAL = 1
FAMISTUDIO_CFG_NTSC_SUPPORT = 1
FAMISTUDIO_USE_PITCH_TRACK = 1
; ASM6-specific config.
FAMISTUDIO_ASM6_ZP_ENUM = $0000
FAMISTUDIO_ASM6_BSS_ENUM = $0200
FAMISTUDIO_ASM6_CODE_BASE = $8000
.include "include\famistudio_asm6.asm"
VBlank_Routine:
; Start of function to execute on VBlank
inc isVBlank ; add one to VBlankOrNo, will be 1 if Vblank, 0 if not.
rti
Start:
; Init PPU
lda #%10001000
sta $2000
lda #%00011110
sta $2001
; Init Palette
lda #$3F
sta $2006
lda #$00
sta $2006 ; Where to store the palette in PPU
ldx #$00
- lda ourpal, x ; loop through every palette color
sta $2007 ; store color into PPU
inx
cpx #32
bne -
; Init bkg Map
lda #$20
sta $2006
sta $2006
ldx #$00
- lda ourMap, X ; load A with a byte from address (ourMap + X)
inx
sta $2007
cpx #128 ; map in previous section 64 bytes long
bne - ; if not all 64 done, loop and do some more
; Init Sound
lda #%0
sta $4015
lda #$40
sta $4017
; Init Vars
lda #80
sta Sprite0_X
sta Sprite0_Y
lda #$01
sta Sprite0_T
; Init Music
lda #1
ldx #<untitled_music_data
ldy #>untitled_music_data
jsr famistudio_init
lda #0
jsr famistudio_music_play
@infin:
; Get Input
lda #$01
sta $4016
lda #$00
sta $4016
lda $4016 ; A key
lda $4016 ; B key
lda $4016 ; Select key
lda $4016 ; Start key
lda $4016 ; Up key
and #1
beq +
dec Sprite0_Y
+ lda $4016 ; Down key
and #1
beq +
inc Sprite0_Y
+ lda $4016 ; Left key
and #1
beq +
dec Sprite0_X
+ lda $4016 ; Right key
and #1
beq +
inc Sprite0_X
+
; Wait for VBlank
- lda isVBlank ; A = isVBlank
cmp #1 ; if A == 1 then is VBlank
bne - ; if not VBlank, then loop and do again
dec isVBlank ; isVBlank--. isVBlank will be 0 again.
; Draw Sprite
lda #$3 ; Copy sprite info to OAM mem in PPU
sta $4014
jmp @infin
ourpal: ; The palette
.db $0F,$31,$32,$33,$0F,$35,$36,$37,$0F,$39,$3A,$3B,$0F,$3D,$3E,$00 ;background palette data
.db $0F,$1C,$15,$14,$0F,$02,$38,$3C,$0F,$1C,$15,$14,$0F,$02,$38,$3C ;sprite palette data
ourMap: ; The bkg Map
.incbin "incbin\bkgMap.map"
.org $a000
song_testMusic: .include "include\testSong.asm"
; Vectors
.org $fffa
.dw VBlank_Routine ; address to execute on VBlank
.dw Start ; address to execute at RESET.
.dw 0 ; address to execute during a BRK instruction (Another Day, Another time).
; CHARS
.incbin "incbin/bkg.chr"
.incbin "incbin/spr.chr"