aboutsummaryrefslogtreecommitdiff
path: root/tests/src/shared/diskun.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-08 12:34:47 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-01-09 16:01:39 +0100
commit8b1c270910fce13077864bf39d6e88971a6eb062 (patch)
tree2a441b58d46905f680749c1c074e9b55a27f0d6e /tests/src/shared/diskun.s
parent4f5710aa516ab149d132cdb5863db08f08c10563 (diff)
downloadtools.nes-8b1c270910fce13077864bf39d6e88971a6eb062.tar.gz
tools.nes-8b1c270910fce13077864bf39d6e88971a6eb062.zip
Implement the .include statement
This needed some heavy lifting when it comes to how files were located. This means that statements like .include/.incbin now take into consideration a new list made out of SourceInfo, which holds enough information to translate from which file a node comes from. This has also been added into errors, so they are more informative on what went wrong. In order to tests this, besides all the regular unit tests, a new e2e test has been added. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'tests/src/shared/diskun.s')
-rw-r--r--tests/src/shared/diskun.s96
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/src/shared/diskun.s b/tests/src/shared/diskun.s
new file mode 100644
index 0000000..b644a83
--- /dev/null
+++ b/tests/src/shared/diskun.s
@@ -0,0 +1,96 @@
+;;; Simple sprite that can be moved with the dpad easily. Use it to have
+;;; something funny moving.
+;; Taken from https://github.com/mssola/code.nes.
+
+.include "joypad.s"
+
+.scope Diskun
+ m_screen_x = $30
+ m_screen_y = $31
+
+ .proc init_palettes
+ lda #$3F
+ sta $2006 ; PPUADDR
+ lda #$00
+ sta $2006 ; PPUADDR
+
+ ldx #0
+ @load_palettes_loop:
+ lda palettes, x
+ sta $2007 ; PPUDATA
+ inx
+ cpx #$20
+ bne @load_palettes_loop
+ rts
+ palettes:
+ DEFAULT_COLOR = $11
+
+ ;; Background
+ .byte DEFAULT_COLOR, $36, $17, $0F
+ .byte DEFAULT_COLOR, $00, $00, $00
+ .byte DEFAULT_COLOR, $00, $00, $00
+ .byte DEFAULT_COLOR, $00, $00, $00
+
+ ;; Foreground
+ .byte DEFAULT_COLOR, $28, $0F, $30
+ .byte DEFAULT_COLOR, $00, $00, $00
+ .byte DEFAULT_COLOR, $00, $00, $00
+ .byte DEFAULT_COLOR, $00, $00, $00
+
+ rts
+ .endproc
+
+ .proc update
+ lda #Joypad::BUTTON_UP
+ and Joypad::m_buttons1
+ beq @check_down
+
+ dec Diskun::m_screen_y
+ dec Diskun::m_screen_y
+ jmp @check_left
+ @check_down:
+ lda #Joypad::BUTTON_DOWN
+ and Joypad::m_buttons1
+ beq @check_left
+
+ inc Diskun::m_screen_y
+ inc Diskun::m_screen_y
+ @check_left:
+ lda #Joypad::BUTTON_LEFT
+ and Joypad::m_buttons1
+ beq @check_right
+
+ dec Diskun::m_screen_x
+ dec Diskun::m_screen_x
+ @check_right:
+ lda #Joypad::BUTTON_RIGHT
+ and Joypad::m_buttons1
+ beq @end
+
+ inc Diskun::m_screen_x
+ inc Diskun::m_screen_x
+ @end:
+ rts
+ .endproc
+
+ .proc nmi_update
+ lda Diskun::m_screen_x
+ sta $203
+ sta $20B
+ clc
+ adc #8
+ sta $207
+ sta $20F
+
+ lda Diskun::m_screen_y
+ sta $200
+ sta $204
+ clc
+ adc #8
+ sta $208
+ sta $20C
+
+ rts
+ .endproc
+.endscope
+