From c3a0d21808cc675a12207e13e2f7100d22399cd3 Mon Sep 17 00:00:00 2001 From: Damian Yerrick Date: Mon, 23 May 2022 15:57:52 -0400 Subject: [PATCH] distinguish addresses (:=) from constants (=) Per https://cc65.github.io/doc/ca65.html#ss6.1 defining a symbol with `:=` marks it as a "label" in debug info so that the debugger can treat it differently from a constant. --- src/bg.s | 2 +- src/init.s | 14 +- src/main.s | 3 - src/player.s | 4 +- src/snes.inc | 380 +++++++++++++++++++++++++------------------------ src/spcimage.s | 11 +- 6 files changed, 207 insertions(+), 207 deletions(-) diff --git a/src/bg.s b/src/bg.s index bcc70f7..ef073cd 100644 --- a/src/bg.s +++ b/src/bg.s @@ -143,5 +143,5 @@ palette: .word RGB( 0, 0,15),RGB(15,15, 0),RGB(23,23, 8),RGB(31,31,16) palette_size = * - palette -layer1_palette = palette +layer1_palette := palette layer1_palette_size = palette_size diff --git a/src/init.s b/src/init.s index 1e06cf9..48f5f0d 100644 --- a/src/init.s +++ b/src/init.s @@ -4,26 +4,26 @@ .smart ; Mask off low byte to allow use of $000000-$00000F as local variables -ZEROPAGE_BASE = __ZEROPAGE_RUN__ & $FF00 +ZEROPAGE_BASE := __ZEROPAGE_RUN__ & $FF00 ; Make sure these conform to the linker script (e.g. lorom256.cfg). -STACK_BASE = $0100 +STACK_BASE := $0100 STACK_SIZE = $0100 -LAST_STACK_ADDR = STACK_BASE + STACK_SIZE - 1 +LAST_STACK_ADDR := STACK_BASE + STACK_SIZE - 1 -PPU_BASE = $2100 -CPUIO_BASE = $4200 +PPU_BASE := $2100 +CPUIO_BASE := $4200 ; MMIO is mirrored into $21xx, $42xx, and $43xx of all banks $00-$3F ; and $80-$BF. To make it work no matter the current data bank, we ; can use a long address in a nonzero bank. ; Bit 0 of MEMSEL enables fast ROM access above $808000. -MEMSEL = $80420D +MEMSEL := $80420D ; Bit 4 of the byte at $FFD5 in the cartridge header specifies ; whether a game should be manufactured with slow or fast ROM. ; The init code enables fast ROM if this bit is true. -map_mode = $00FFD5 +map_mode := $00FFD5 ; A tiny stub in bank $00 needs to set interrupt priority to 1, ; leave 6502 emulation mode, and long jump to the rest of init code diff --git a/src/main.s b/src/main.s index 7d5d8f2..13c487f 100644 --- a/src/main.s +++ b/src/main.s @@ -177,6 +177,3 @@ padwait: jmp forever .endproc - - - diff --git a/src/player.s b/src/player.s index de56907..2b50b45 100644 --- a/src/player.s +++ b/src/player.s @@ -60,7 +60,7 @@ player_facing: .res 1 ; except for STZs and BRAs, the following subroutine is ; direct copypasta from the NES template code -cur_keys = JOY1CUR+1 +cur_keys := JOY1CUR+1 ; constants used by move_player ; PAL frames are about 20% longer than NTSC frames. So if you make @@ -246,7 +246,7 @@ doneWallCollision: ; offset by about a pixel. seta8 lda player_frame - cmp #7 ; C = true for frame 7, false otherwise + cmp #7 ; CF is true for frame 7, false otherwise lda #0 bcc have_xoffset bit player_facing diff --git a/src/snes.inc b/src/snes.inc index 43a9d75..f57e137 100644 --- a/src/snes.inc +++ b/src/snes.inc @@ -27,7 +27,7 @@ ; S-PPU configuration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -PPUBRIGHT = $2100 +PPUBRIGHT := $2100 ; 76543210 ; | ++++- brightness (F: max) ; +-------- 1: disable rendering @@ -40,7 +40,7 @@ PPUBRIGHT = $2100 ; "Negative." FORCEBLANK = $80 -PPURES = $2133 +PPURES := $2133 ; 76543210 ; || |||+- Screen interlace ; || ||+-- Shrink sprites vertically during interlace @@ -55,14 +55,14 @@ BG_TALL = $04 SUB_HIRES = $08 M7_EXTBG = $40 -PPUSTATUS1 = $213E +PPUSTATUS1 := $213E ; 76543210 PPU address generator status ; || ++++- PPU1 version (always 1) ; |+------- 1: sprite overflow (>32 on a line) since the last vblank end ; +-------- 1: sliver overflow (>34 on a line) since the last vblank end ; this parallels bit 5 of $2002 on NES -PPUSTATUS2 = $213F +PPUSTATUS2 := $213F ; 76543210 PPU compositor status ; || |++++- PPU2 version (1-3, not counting minor versions of 3) ; || +----- 1: PPU is configured for 50 Hz (PAL) @@ -71,7 +71,7 @@ PPUSTATUS2 = $213F ; S-PPU sprites ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -OBSEL = $2101 +OBSEL := $2101 ; 76543210 ; ||||| ++- Sprite main pattern table (0=$0000, 1=$2000, 2=$4000, 3=$6000) ; |||++---- Alt pattern table offset (0=$1000, 1=$2000, 2=$3000, 3=$4000) @@ -84,9 +84,9 @@ OBSIZE_16_32 = $60 OBSIZE_16_64 = $80 OBSIZE_32_64 = $A0 -OAMADDR = $2102 ; 16-bit, 128 sprites followed by high-X/size table -OAMDATA = $2104 -OAMDATARD = $2138 +OAMADDR := $2102 ; 16-bit, 128 sprites followed by high-X/size table +OAMDATA := $2104 +OAMDATARD := $2138 ; Parallels NES $2003, except apparently word-addressed. ; OAM random access is working here, unlike on NES. ; If bit 15 is set, value at start of frame apparently also @@ -94,7 +94,7 @@ OAMDATARD = $2138 ; S-PPU background configuration ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -BGMODE = $2105 +BGMODE := $2105 ; 76543210 ; |||||+++- 0: 4 planes 2 bpp ; ||||| 1: 2 planes 4 bpp, 1 plane 2 bpp @@ -112,7 +112,7 @@ BGMODE = $2105 ; Modes 5 and 6 use 16x8 instead of 8x8 ; Mode 7 always uses 8x8 -MOSAIC = $2106 +MOSAIC := $2106 ; 76543210 ; |||||||+- Apply mosaic to plane 0 (or mode 7 high-prio horizontal) ; ||||||+-- Apply mosaic to plane 1 (or mode 7 high-prio vertical) @@ -120,7 +120,7 @@ MOSAIC = $2106 ; ||||+---- Apply mosaic to plane 3 ; ++++----- Pixel size minus 1 (0=1x1, 15=16x16) -NTADDR = $2107 ; through $210A +NTADDR := $2107 ; through $210A ; 76543210 ; ||||||+- Nametable width (0: 1 screen, 1: 2 screens) ; |||||+-- Nametable height (0: 1 screen, 1: 2 screens) @@ -128,14 +128,14 @@ NTADDR = $2107 ; through $210A ; Each nametable in modes 0-6 is 32 rows, each 32 spaces long. .define NTXY(xc,yc) ((xc)|((yc)<<5)) -BGCHRADDR = $210B +BGCHRADDR := $210B ; FEDCBA98 76543210 ; ||| ||| ||| +++- Pattern table base address for plane 0 ; ||| ||| +++----- Same for plane 1 ; ||| +++---------- Same for plane 2 ; +++-------------- Same for plane 3 -M7SEL = $211A +M7SEL := $211A ; 76543210 ; || || ; || |+- Flip screen horizontally @@ -150,8 +150,8 @@ M7_BORDER00 = $C0 ; S-PPU scrolling ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -BGSCROLLX = $210D ; double write low then high (000-3FF m0-6, 000-7FF m7) -BGSCROLLY = $210E ; similar. reg 210F-2114 are same for other planes +BGSCROLLX := $210D ; double write low then high (000-3FF m0-6, 000-7FF m7) +BGSCROLLY := $210E ; similar. reg 210F-2114 are same for other planes ; Hi-res scrolling in modes 5-6 moves by whole (sub+main) pixels in X ; but half scanlines in Y. ; The top visible line is the line below the value written here. @@ -165,7 +165,7 @@ BGSCROLLY = $210E ; similar. reg 210F-2114 are same for other planes ; S-PPU VRAM data port ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -PPUCTRL = $2115 +PPUCTRL := $2115 ; 76543210 ; | ||++- VRAM address increment (1, 32, 128, 128) ; | ++--- Rotate low bits of address left by 3 (off, 8, 9, or 10) @@ -175,37 +175,37 @@ VRAM_DOWN = $01 VRAM_M7DOWN = $02 INC_DATAHI = $80 -PPUADDR = $2116 ; Word address, not double-write anymore -PPUDATA = $2118 -PPUDATAHI = $2119 -PPUDATARD = $2139 ; Same dummy read as on NES is needed -PPUDATARDHI = $213A +PPUADDR := $2116 ; Word address, not double-write anymore +PPUDATA := $2118 +PPUDATAHI := $2119 +PPUDATARD := $2139 ; Same dummy read as on NES is needed +PPUDATARDHI := $213A ; S-PPU palette ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -CGADDR = $2121 -CGDATA = $2122 ; 5-bit BGR, write twice, low byte first -CGDATARD = $213B ; 5-bit BGR, read twice, low byte first +CGADDR := $2121 +CGDATA := $2122 ; 5-bit BGR, write twice, low byte first +CGDATARD := $213B ; 5-bit BGR, read twice, low byte first .define RGB(r,g,b) ((r)|((g)<<5)|((b)<<10)) ; S-PPU window ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -BG12WINDOW = $2123 -BG34WINDOW = $2124 -OBJWINDOW = $2125 +BG12WINDOW := $2123 +BG34WINDOW := $2124 +OBJWINDOW := $2125 ; 76543210 ; ||||||++- 0: disable window 1 on BG1/BG3/OBJ; 2: enable; 3: enable outside ; ||||++--- 0: disable window 2 on BG1/BG3/OBJ; 2: enable; 3: enable outside ; ||++----- 0: disable window 1 on BG2/BG4; 2: enable; 3: enable outside ; ++------- 0: disable window 2 on BG2/BG4; 2: enable; 3: enable outside -WINDOW1L = $2126 -WINDOW1R = $2127 -WINDOW2L = $2128 -WINDOW2R = $2129 +WINDOW1L := $2126 +WINDOW1R := $2127 +WINDOW2L := $2128 +WINDOW2R := $2129 -BGWINDOP = $212A ; Window op is how windows are combined when both -OBJWINDOP = $212B ; windows 1 and 2 are enabled. +BGWINDOP := $212A ; Window op is how windows are combined when both +OBJWINDOP := $212B ; windows 1 and 2 are enabled. ; 76543210 ; ||||||++- Window op for plane 0 or sprites (0: or, 1: and, 2: xor, 3: xnor) ; ||||++--- Window op for plane 1 or color window @@ -216,10 +216,10 @@ OBJWINDOP = $212B ; windows 1 and 2 are enabled. ; The main layer enable reg, corresponding to PPUMASK on the NES, ; is BLENDMAIN. -BLENDMAIN = $212C ; Layers enabled for main input of blending -BLENDSUB = $212D ; Layers enabled for sub input of blending -WINDOWMAIN = $212E ; Windows enabled for main input of blending -WINDOWSUB = $212F ; Windows enabled for sub input of blending +BLENDMAIN := $212C ; Layers enabled for main input of blending +BLENDSUB := $212D ; Layers enabled for sub input of blending +WINDOWMAIN := $212E ; Windows enabled for main input of blending +WINDOWSUB := $212F ; Windows enabled for sub input of blending ; 76543210 ; ||||+- plane 0 ; |||+-- plane 1 @@ -237,29 +237,29 @@ WINDOWSUB = $212F ; Windows enabled for sub input of blending ; When BGMODE is 0-6 (or during vblank in mode 7), a fast 16x8 ; signed multiply is available, finishing by the next CPU cycle. -M7MCAND = $211B ; write low then high -M7MUL = $211C ; 8-bit factor -M7PRODLO = $2134 -M7PRODHI = $2135 -M7PRODBANK = $2136 +M7MCAND := $211B ; write low then high +M7MUL := $211C ; 8-bit factor +M7PRODLO := $2134 +M7PRODHI := $2135 +M7PRODBANK := $2136 -GETXY = $2137 ; read while $4201 D7 is set: populate x and y coords -XCOORD = $213C ; used with light guns, read twice -YCOORD = $213D ; also read twice +GETXY := $2137 ; read while $4201 D7 is set: populate x and y coords +XCOORD := $213C ; used with light guns, read twice +YCOORD := $213D ; also read twice ; SPC700 communication ports ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -APU0 = $2140 -APU1 = $2141 -APU2 = $2142 -APU3 = $2143 +APU0 := $2140 +APU1 := $2141 +APU2 := $2142 +APU3 := $2143 ; S-CPU interrupt control ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -PPUNMI = $4200 +PPUNMI := $4200 ; 76543210 ; | || +- Automatically read controllers in first 4 lines of vblank -; | ++----- 0: No IRQ; 1: IRQs at HTIME; +; | ++----- 0: no IRQ (and acknowledge any pending); 1: IRQs at HTIME; ; | 2: one IRQ at (0, VTIME); 3: one IRQ at (HTIME, VTIME) ; +-------- 1: Enable NMI at start of vblank VBLANK_NMI = $80 @@ -268,26 +268,28 @@ VTIME_IRQ = $20 HVTIME_IRQ = $30 AUTOREAD = $01 -HTIME = $4207 -HTIMEHI = $4208 -VTIME = $4209 -VTIMEHI = $420A +HTIME := $4207 +HTIMEHI := $4208 +VTIME := $4209 +VTIMEHI := $420A -NMISTATUS = $4210 +NMISTATUS := $4210 ; read to acknowledge NMI ; 76543210 ; | |||| ; | ++++- DMA controller version (1, 2) where v1 has an HDMA glitch ; +-------- 1: Vblank has started since last read (like $2002.d7 on NES) -TIMESTATUS = $4211 ; Acknowledge htime/vtime IRQ -VBLSTATUS = $4212 +TIMESTATUS := $4211 ; bit 7: htime/vtime IRQ occurred since last read; + ; read to acknowledge + +VBLSTATUS := $4212 ; 76543210 ; || +- 0: Controller reading finished; 1: busy -; |+------- In hblank -; +-------- In vblank +; |+------- 1: In hblank (including hblank of vblank) +; +-------- 1: In vblank -ROMSPEED = $420D ; 0: slow ROM everywhere; 1: fast ROM in banks 80-FF - ; (requires 120ns or faster PRG ROM) +ROMSPEED := $420D ; 0: slow ROM everywhere; 1: fast ROM in banks 80-FF + ; (requires 120ns or faster PRG ROM) ; S-CPU controller I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -296,22 +298,22 @@ ROMSPEED = $420D ; 0: slow ROM everywhere; 1: fast ROM in banks 80-FF ; as you can enable controller autoreading along with vblank NMIs. ; But for games using (multitap, mouse, etc.), you will need to ; read the extra bits separately after the autoreader finishes. -JOY0 = $4016 -JOY1 = $4017 +JOY0 := $4016 +JOY1 := $4017 ; In addition to the common strobe, each controller port has an ; additional output bit that can be used as, say, a chip select ; for SPI peripherals. -JOYOUT = $4201 +JOYOUT := $4201 ; 76543210 ; |+------- Controller 1 pin 6 output ; +-------- Controller 2 pin 6 output ; Results of the autoreader -JOY1CUR = $4218 ; Bit 0: used by standard controllers -JOY2CUR = $421A -JOY1B1CUR = $421C ; Bit 1: used by multitap and a few oddball -JOY2B1CUR = $421E ; input devices +JOY1CUR := $4218 ; Bit 0: used by standard controllers +JOY2CUR := $421A +JOY1B1CUR := $421C ; Bit 1: used by multitap and a few oddball +JOY2B1CUR := $421E ; input devices ; FEDCBA98 76543210 ; BYSRUDLR AXLRTTTT ; |||||||| ||||++++- controller type (0: controller, 1: mouse) @@ -336,30 +338,30 @@ KEY_R = $0010 ; Multiply unit. Also good for shifting pixels when drawing ; text in a proportional font. -CPUMCAND = $4202 ; unchanged by multiplications -CPUMUL = $4203 ; write here to fill CPUPROD 8 cycles later -CPUPROD = $4216 -CPUPRODHI = $4217 +CPUMCAND := $4202 ; unchanged by multiplications +CPUMUL := $4203 ; write here to fill CPUPROD 8 cycles later +CPUPROD := $4216 +CPUPRODHI := $4217 ; Divide unit -CPUNUM = $4204 -CPUNUMHI = $4205 -CPUDEN = $4206 ; write divisor to fill CPUQUOT/CPUREM 16 cycles later -CPUQUOT = $4214 -CPUQUOTHI = $4215 -CPUREM = CPUPROD -CPUREMHI = CPUPRODHI +CPUNUM := $4204 +CPUNUMHI := $4205 +CPUDEN := $4206 ; write divisor to fill CPUQUOT/CPUREM 16 cycles later +CPUQUOT := $4214 +CPUQUOTHI := $4215 +CPUREM := CPUPROD +CPUREMHI := CPUPRODHI ; S-CPU DMA ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -COPYSTART = $420B ; writes of 1 << n start a DMA copy on channel n -HDMASTART = $420C ; writes of 1 << n start HDMA on channel n +COPYSTART := $420B ; writes of 1 << n start a DMA copy on channel n +HDMASTART := $420C ; writes of 1 << n start HDMA on channel n ; Don't run a DMA copy while HDMA is enabled, or you might run into ; a defect in revision 1 of the S-CPU that causes crashing. ; There are 8 DMA channels. ; Registers for channels 1-7 start at $4310, $4320, ... -DMAMODE = $4300 +DMAMODE := $4300 ; 76543210 ; || ||+++- PPU address offset pattern ; || || 0: 0 1: 01 2: 00 3: 0011 4: 0123 5: 0101 @@ -378,18 +380,18 @@ DMA_BACKWARD = $10 DMA_INDIRECT = $40 DMA_READPPU = $80 -DMAPPUREG = $4301 -DMAADDR = $4302 -DMAADDRHI = $4303 -DMAADDRBANK = $4304 -DMALEN = $4305 ; number of bytes, not number of transfers; 0 means 65536 -DMALENHI = $4306 +DMAPPUREG := $4301 +DMAADDR := $4302 +DMAADDRHI := $4303 +DMAADDRBANK := $4304 +DMALEN := $4305 ; number of bytes, not number of transfers; 0 means 65536 +DMALENHI := $4306 ; A future demo that includes HDMA effects would include port definitions. -;HDMAINDBANK = $4307 -;HDMATABLELO = $4308 -;HDMATABLEHI = $4309 -;HDMALINE = $430A +;HDMAINDBANK := $4307 +;HDMATABLELO := $4308 +;HDMATABLEHI := $4309 +;HDMALINE := $430A ; composite values for use with 16-bit writes to DMAMODE DMAMODE_PPULOFILL = (