aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-12 22:38:12 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-12 22:38:12 +0100
commit2627b459d9a19ce7f1b7f3a359dca3b30b66b34e (patch)
treeb03e7972050d1efac8b3103036bdad2f081c2b03 /include
downloadjetpac.nes-2627b459d9a19ce7f1b7f3a359dca3b30b66b34e.tar.gz
jetpac.nes-2627b459d9a19ce7f1b7f3a359dca3b30b66b34e.zip
Start with a skeleton for the project
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/apu.s4
-rw-r--r--include/globals.s34
-rw-r--r--include/oam.s11
-rw-r--r--include/ppu.s8
4 files changed, 57 insertions, 0 deletions
diff --git a/include/apu.s b/include/apu.s
new file mode 100644
index 0000000..65d9876
--- /dev/null
+++ b/include/apu.s
@@ -0,0 +1,4 @@
+.scope APU
+ DMC = $4010
+ FRAME_COUNTER = $4017
+.endscope
diff --git a/include/globals.s b/include/globals.s
new file mode 100644
index 0000000..d22b217
--- /dev/null
+++ b/include/globals.s
@@ -0,0 +1,34 @@
+;; Global variables used throughout the code base.
+.scope Globals
+ ;;;
+ ;; Argument values as defined in https://github.com/mssola/style.nes. Note
+ ;; that these variables can also be used as temporary variables.
+ zp_arg0 = $00
+ zp_arg1 = $01
+ zp_arg2 = $02
+ zp_arg3 = $03
+ zp_arg4 = $04
+
+ ;;;
+ ;; Random values that can be used inside of functions for temporary values
+ ;; so `zp_argX` variables are not overwritten as often.
+ zp_tmp0 = $05
+ zp_tmp1 = $06
+ zp_tmp2 = $07
+ zp_tmp3 = $08
+
+ ;;;
+ ;; Reserve a byte of memory for preserving indices on memory. This is needed
+ ;; whenever the `x` and `y` registers might not be reliable because of
+ ;; underlying `jsr` calls that might tamper with their values. Sometimes
+ ;; saving the value in memory is enough instead of playing with the stack.
+ zp_idx = $09
+
+ ;; Flags that manage the state of the game.
+ ;;
+ ;; | Bit | Short name | Meaning when set |
+ ;; |-----+------------+-------------------------------------------------------------|
+ ;; | 7 | render | Game logic is over, block main code until NMI code is over. |
+ ;; | 6-0 | - | Unused |
+ zp_flags = $20
+.endscope
diff --git a/include/oam.s b/include/oam.s
new file mode 100644
index 0000000..22935b2
--- /dev/null
+++ b/include/oam.s
@@ -0,0 +1,11 @@
+.scope OAM
+ ADDRESS = $2003
+ DMA = $4014
+.endscope
+
+.macro OAM_WRITE_SPRITES
+ lda #$00
+ sta OAM::ADDR
+ lda #$02
+ sta OAM::DMA
+.endmacro
diff --git a/include/ppu.s b/include/ppu.s
new file mode 100644
index 0000000..fa0df19
--- /dev/null
+++ b/include/ppu.s
@@ -0,0 +1,8 @@
+.scope PPU
+ CONTROL = $2000
+ MASK = $2001
+ STATUS = $2002
+ SCROLL = $2005
+ ADDRESS = $2006
+ DATA = $2007
+.endscope