開発環境
- Windows 10 Home (64bit)
- ASM6
joypad.asm
;asm6 joypad.asm joypad.nes
joypad = $00
; iNES header
db "NES", $1a
db $01 ; PRG-ROM
db $01 ; CHR-ROM
db $00 ; mapper / mirroring
dsb 9, $00
base $c000
Reset:
lda #$00
sta $2000 ; PPU制御レジスタ1
sta $2001 ; PPU制御レジスタ2
; パレットテーブル $3f00-3f1f
lda #$3f
sta $2006 ; VRAMアドレスレジスタ
lda #$00
sta $2006
ldx #$00
ldy #$10
-
lda palette, x
sta $2007 ; VRAMアクセスレジスタ
inx
dey
bne -
lda #$08
sta $2000 ; PPU制御レジスタ1
lda #$0e
sta $2001 ; PPU制御レジスタ2
loop:
-
lda $2002 ; PPUステータスレジスタ
bmi -
-
lda $2002 ; PPUステータスレジスタ
bpl -
lda #$01
sta $4016 ; ジョイパッド1レジスタ
lda #$00
sta $4016
lda #$01
sta joypad
ldy #$08
-
lda $4016
and #$01
asl joypad
ora joypad
sta joypad
dey
bne -
; ネームテーブル $2000-$23bf
lda #$21
sta $2006 ; VRAMアドレスレジスタ
lda #$f0
sta $2006
lda joypad
sta $2007 ; VRAMアクセスレジスタ
lda #$00
sta $2005 ; スクロールレジスタ
sta $2005
jmp loop
palette:
db $0f, $28, $01, $28
db $00, $00, $00, $00
db $00, $00, $00, $00
db $00, $00, $00, $00
org $fffa
dw 0 ; NMI VBlank
dw Reset
dw 0 ; IRQ/BRK
incbin "joypad.chr"
最終更新:2020年12月08日 17:07