aboutsummaryrefslogtreecommitdiff
path: root/space/include/ppu.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2023-10-24 17:40:19 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-02-04 20:58:36 +0100
commit149020464517ff3d021eef5ccd50d3939ad463e6 (patch)
tree056ec1919fe0c0d515e7a0a414916307b768ef84 /space/include/ppu.s
parentbe2414f5b11b182998fca7e87712ff0502c8ee93 (diff)
downloadcode.nes-149020464517ff3d021eef5ccd50d3939ad463e6.tar.gz
code.nes-149020464517ff3d021eef5ccd50d3939ad463e6.zip
Lay out a proper structure for the project
Let's divide things by topic instead of a broad "examples" directory. This will allow for simple files to co-exist together with full-blown projects. Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'space/include/ppu.s')
-rw-r--r--space/include/ppu.s27
1 files changed, 27 insertions, 0 deletions
diff --git a/space/include/ppu.s b/space/include/ppu.s
new file mode 100644
index 0000000..23fd978
--- /dev/null
+++ b/space/include/ppu.s
@@ -0,0 +1,27 @@
+.segment "CODE"
+
+.scope PPU
+ CONTROL = $2000
+ MASK = $2001
+ STATUS = $2002
+ SCROLL = $2005
+ ADDRESS = $2006
+ DATA = $2007
+.endscope
+
+.macro PPU_ADDR address
+ lda #.HIBYTE(address)
+ sta PPU::ADDRESS
+ lda #.LOBYTE(address)
+ sta PPU::ADDRESS
+.endmacro
+
+;; WRITE_PPU_DATA is a macro that will write into PPU::ADDRESS the given address
+;; and into PPU::DATA the given byte value.
+.macro WRITE_PPU_DATA address, value
+ bit PPU::STATUS
+
+ PPU_ADDR address
+ lda #value
+ sta PPU::DATA
+.endmacro