aboutsummaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
Diffstat (limited to 'src/example')
-rw-r--r--src/example/Makefile5
-rw-r--r--src/example/nes.asm82
2 files changed, 86 insertions, 1 deletions
diff --git a/src/example/Makefile b/src/example/Makefile
index 3c57e50..e92b2ec 100644
--- a/src/example/Makefile
+++ b/src/example/Makefile
@@ -20,7 +20,7 @@
# Makefile for examples
#
-ALL = spectrum.tap c64.t64 zx81.p gb.gb vcs.bin snes.sfc
+ALL = spectrum.tap c64.t64 zx81.p gb.gb vcs.bin snes.sfc nes.nes
CASM = ../casm
all: $(ALL) $(CASM)
@@ -48,5 +48,8 @@ vcs.bin: vcs.asm $(CASM)
snes.sfc: snes.asm $(CASM)
$(CASM) snes.asm
+nes.nes: nes.asm $(CASM)
+ $(CASM) nes.asm
+
clean:
rm -f $(ALL)
diff --git a/src/example/nes.asm b/src/example/nes.asm
new file mode 100644
index 0000000..c10ca66
--- /dev/null
+++ b/src/example/nes.asm
@@ -0,0 +1,82 @@
+ processor 6502
+
+ option output-file,"nes.nes"
+ option output-format,nes
+
+ option nes-vector,reset,start
+ option nes-vector,nmi,nmi
+ option nes-vector,brk,nmi
+
+start: org $c000
+
+ ;
+ ; Code taken from NES example
+ ;
+
+ sei ; disable IRQs
+ cld ; disable decimal mode
+ ldx #$40
+ stx $4017 ; dsiable APU frame IRQ
+ ldx #$ff ; Set up stack
+ txs ; .
+ inx ; now X = 0
+ stx $2000 ; disable NMI
+ stx $2001 ; disable rendering
+ stx $4010 ; disable DMC IRQs
+
+ ;; first wait for vblank to make sure PPU is ready
+vblankwait1:
+ bit $2002
+ bpl vblankwait1
+
+clear_memory:
+ lda #$00
+ sta $0000, x
+ sta $0100, x
+ sta $0200, x
+ sta $0300, x
+ sta $0400, x
+ sta $0500, x
+ sta $0600, x
+ sta $0700, x
+ inx
+ bne clear_memory
+
+ ;; second wait for vblank, PPU is ready after this
+vblankwait2:
+ bit $2002
+ bpl vblankwait2
+
+clear_palette:
+ ;; Need clear both palettes to $00. Needed for Nestopia. Not
+ ;; needed for FCEU* as they're already $00 on powerup.
+ lda $2002 ; Read PPU status to reset PPU address
+ lda #$3f ; Set PPU address to BG palette RAM ($3F00)
+ sta $2006
+ lda #$00
+ sta $2006
+
+ ldx #$20 ; Loop $20 times (up to $3F20)
+ lda #$00 ; Set each entry to $00
+.loop
+ sta $2007
+ dex
+ bne loop
+
+ lda #%01000000 ; intensify blues
+ sta $2001
+
+forever:
+ jmp forever
+
+nmi:
+ rti
+
+
+;
+; Dummy VROM
+;
+ org 0
+ bank 1
+
+ db 0