Add labels for hardware registers
This commit is contained in:
parent
dae531ab5b
commit
980ae8272c
|
@ -1,5 +1,4 @@
|
|||
includeonce
|
||||
|
||||
lorom
|
||||
|
||||
org $00FFE0
|
||||
|
@ -23,3 +22,144 @@ dw $FFFF
|
|||
dw $FFFF
|
||||
dw Reset
|
||||
dw $FFFF
|
||||
|
||||
|
||||
;; Address synonyms for hardware registers
|
||||
|
||||
|
||||
; PPU registers
|
||||
INIDISP = $2100 ; Control screen brightness and F-blank
|
||||
OBJSEL = $2101 ; Object properties
|
||||
OAMADDL = $2102 ; OAM address (low byte)
|
||||
OAMADDH = $2103 ; ^ (high byte)
|
||||
OAMDATAW = $2104 ; OAM data write
|
||||
BGMODE = $2105 ; Background mode
|
||||
MOSAIC = $2106 ; Mosaic effect switch
|
||||
BG1SC = $2107 ; Background 1 tilemap
|
||||
BG2SC = $2108 ; Background 2 tilemap
|
||||
BG3SC = $2109 ; Background 3 tilemap
|
||||
BG4SC = $210A ; Background 4 tilemap
|
||||
BG12NBA = $210B ; Backgrounds 1 & 2 graphics
|
||||
BG34NBA = $210C ; Backgrounds 3 & 4 graphics
|
||||
BG1HOFS = $210D ; Background 1 horizontal scroll
|
||||
BG1VOFS = $210E ; ^ vertical scroll
|
||||
BG2HOFS = $210F ; Background 2 horizontal scroll
|
||||
BG2VOFS = $2110 ; ^ vertical scroll
|
||||
BG3HOFS = $2111 ; Background 3 horizontal scroll
|
||||
BG3VOFS = $2112 ; ^ vertical scroll
|
||||
BG4HOFS = $2113 ; Background 4 horizontal scroll
|
||||
BG4VOFS = $2114 ; ^ vertical scroll
|
||||
VMAINC = $2115 ; VRAM register settings
|
||||
VMADDL = $2116 ; VRAM address (low byte)
|
||||
VMADDH = $2117 ; ^ (high byte)
|
||||
VMDATALW = $2118 ; VRAM data write (low byte)
|
||||
VMDATAHW = $2119 ; ^ (high byte)
|
||||
M7SEL = $211A ; Mode 7 properties
|
||||
M7A = $211B ; Mode 7 matrix A-coordinate
|
||||
M7B = $211C ; ^ - B-coordinate
|
||||
M7C = $211D ; ^ - C-coordinate
|
||||
M7D = $211E ; ^ - D-coordinate
|
||||
M7X = $211F ; Mode 7 transform center X-coordinate
|
||||
M7Y = $2120 ; ^ Y-coordinate
|
||||
CGADD = $2121 ; CGRAM address
|
||||
CGDATAW = $2122 ; CGRAM data write
|
||||
W12SEL = $2123 ; Window enable switches for BG1&2
|
||||
W34SEL = $2124 ; ^ for BG3&4
|
||||
WOBJSEL = $2125 ; ^ for objects
|
||||
WH0 = $2126 ; Window 1 left bound
|
||||
WH1 = $2127 ; ^ right bound
|
||||
WH2 = $2128 ; Window 2 left bound
|
||||
WH3 = $2129 ; ^ right bound
|
||||
WBGLOG = $212A ; Window intersection logic (for bgs)
|
||||
WOBJLOG = $212B ; ^ (for objects)
|
||||
TM = $212C ; Display on main screen
|
||||
TS = $212D ; ^ on sub screen
|
||||
TMW = $212E ; Enable windowing on main screen
|
||||
TSW = $212F ; ^ on sub screen
|
||||
CGSWSEL = $2130 ; Apply window switch
|
||||
CGADSUB = $2131 ; Color math method
|
||||
COLDATA = $2132 ; Subscreen fixed color
|
||||
INISET = $2133 ; Misc. display settings
|
||||
MPYL = $2134 ; PPU multiplication result (low byte)
|
||||
MPYM = $2135 ; ^ (middle byte)
|
||||
MPYH = $2136 ; ^ (high byte)
|
||||
SLHV = $2137 ; Scan position CPU latch
|
||||
OAMDATAR = $2138 ; OAM data read
|
||||
VMDATALR = $2139 ; VRAM data read (low byte)
|
||||
VMDATAHR = $213A ; ^ (high byte)
|
||||
CGDATAR = $213B ; CGRAM data read
|
||||
OPHCT = $213C ; Horizontal scan position (must be latched)
|
||||
OPVCT = $213D ; Scanline (must be latched)
|
||||
STAT77 = $213E ; PPU flags, read only
|
||||
STAT78 = $213F ; ^
|
||||
APUIO0 = $2140 ; APU I/O port 1
|
||||
APUIO1 = $2141 ; ^ port 2
|
||||
APUIO2 = $2142 ; ^ port 3
|
||||
APUIO3 = $2143 ; ^ port 4
|
||||
|
||||
; WRAM registers
|
||||
WMDATA = $2180 ; WRAM data access
|
||||
WMADDL = $2181 ; WRAM address (low byte)
|
||||
WMADDM = $2182 ; ^ (middle byte)
|
||||
WMADDH = $2183 ; ^ (high byte)
|
||||
|
||||
; Joypad registers
|
||||
JOYPAD1 = $4016
|
||||
JOYPAD2 = $4017
|
||||
|
||||
; CPU registers
|
||||
NMITIMEN = $4200 ; Switch for NMI (V-blank)
|
||||
WRIO = $4201 ; Write to I/O ports of joypads
|
||||
WRMPYA = $4202 ; Multiplication routine input
|
||||
WRMPYB = $4203 ; ^
|
||||
WRDIVL = $4204 ; Division routine input (low byte)
|
||||
WRDIVH = $4205 ; ^ (high byte)
|
||||
WRDIVB = $4206 ; Division routine input 2
|
||||
HTIMEL = $4207 ; Horizontal IRQ timer (low byte)
|
||||
HTIMEH = $4208 ; ^ (high byte)
|
||||
VTIMEL = $4209 ; Vertical IRQ timer (low byte)
|
||||
VTIMEH = $420A ; ^ (high byte)
|
||||
MDMAEN = $420B ; DMA enable flags
|
||||
HDMAEN = $420C ; HDMA enable flags
|
||||
MEMSEL = $420D ; FastROM switch
|
||||
RDNMI = $4210 ; NMI flag (should be read at V-blank)
|
||||
TIMEUP = $4211 ; IRQ flag (should be read at IRQ)
|
||||
HVBJOY = $4212 ; Blanking flags
|
||||
RDIO = $4213 ; Read from I/O ports of joypads
|
||||
RDDIVL = $4214 ; Division result (low byte)
|
||||
RDDIVH = $4215 ; ^ (high byte)
|
||||
RDMPYL = $4216 ; Multiplication result (low byte)
|
||||
RDMPYH = $4217 ; ^ (high byte)
|
||||
STDCNTRL1L = $4218 ; Auto-joypad-read 1 (low byte)
|
||||
STDCNTRL1H = $4219 ; ^ (high byte)
|
||||
STDCNTRL2L = $421A ; Auto-joypad-read 2 (low byte)
|
||||
STDCNTRL2H = $421B ; ^ (high byte)
|
||||
STDCNTRL3L = $421C ; Auto-joypad-read 3 (low byte)
|
||||
STDCNTRL3H = $421D ; ^ (high byte)
|
||||
STDCNTRL4L = $421E ; Auto-joypad-read 4 (low byte)
|
||||
STDCNTRL4H = $421F ; ^ (high byte)
|
||||
|
||||
; DMA registers
|
||||
macro dma(c)
|
||||
DMA<c>PARAM = $43<c>0 ; DMA transfer parameters
|
||||
DMA<c>ADDB = $43<c>1 ; DMA B-bus address ($21XX)
|
||||
DMA<c>ADDAL = $43<c>2 ; DMA A-bus address (low byte)
|
||||
DMA<c>ADDAM = $43<c>3 ; ^ (middle byte)
|
||||
DMA<c>ADDAH = $43<c>4 ; ^ (high byte)
|
||||
DMA<c>AMTL = $43<c>5 ; Number of bytes to transfer (low byte)
|
||||
DMA<c>AMTH = $43<c>6 ; ^ (high byte)
|
||||
DMA<c>INDH = $43<c>7 ; Indirect HDMA transfer address
|
||||
DMA<c>ADDA2L = $43<c>8 ; Automatically generated
|
||||
DMA<c>ADDA2M = $43<c>9 ; ^
|
||||
DMA<c>LINES = $43<c>A ; ^
|
||||
endmacro
|
||||
|
||||
; For each DMA channel
|
||||
%dma(0)
|
||||
%dma(1)
|
||||
%dma(2)
|
||||
%dma(3)
|
||||
%dma(4)
|
||||
%dma(5)
|
||||
%dma(6)
|
||||
%dma(7)
|
||||
|
|
|
@ -13,90 +13,95 @@ endmacro
|
|||
|
||||
org $008000
|
||||
Init:
|
||||
sep #$30 ; X,Y,A are 8 bit numbers
|
||||
lda #$8F ; screen off, full brightness
|
||||
sta $2100 ; brightness + screen enable register
|
||||
stz $2101 ; Sprite register (size + address in VRAM)
|
||||
stz $2102 ; Sprite registers (address of sprite memory [OAM])
|
||||
stz $2103 ; "" ""
|
||||
stz $2105 ; Mode 0, = Graphic mode register
|
||||
stz $2106 ; noplanes, no mosaic, = Mosaic register
|
||||
stz $2107 ; Plane 0 map VRAM location
|
||||
stz $2108 ; Plane 1 map VRAM location
|
||||
stz $2109 ; Plane 2 map VRAM location
|
||||
stz $210A ; Plane 3 map VRAM location
|
||||
stz $210B ; Plane 0+1 Tile data location
|
||||
stz $210C ; Plane 2+3 Tile data location
|
||||
stz $210D ; Plane 0 scroll x (first 8 bits)
|
||||
stz $210D ; Plane 0 scroll x (last 3 bits) #$0 - #$07ff
|
||||
lda #$FF ; The top pixel drawn on the screen isn't the top one in the tilemap, it's the one above that.
|
||||
sta $210E ; Plane 0 scroll y (first 8 bits)
|
||||
sta $2110 ; Plane 1 scroll y (first 8 bits)
|
||||
sta $2112 ; Plane 2 scroll y (first 8 bits)
|
||||
sta $2114 ; Plane 3 scroll y (first 8 bits)
|
||||
lda #$07 ; Since this could get quite annoying, it's better to edit the scrolling registers to fix this.
|
||||
sta $210E ; Plane 0 scroll y (last 3 bits) #$0 - #$07ff
|
||||
sta $2110 ; Plane 1 scroll y (last 3 bits) #$0 - #$07ff
|
||||
sta $2112 ; Plane 2 scroll y (last 3 bits) #$0 - #$07ff
|
||||
sta $2114 ; Plane 3 scroll y (last 3 bits) #$0 - #$07ff
|
||||
stz $210F ; Plane 1 scroll x (first 8 bits)
|
||||
stz $210F ; Plane 1 scroll x (last 3 bits) #$0 - #$07ff
|
||||
stz $2111 ; Plane 2 scroll x (first 8 bits)
|
||||
stz $2111 ; Plane 2 scroll x (last 3 bits) #$0 - #$07ff
|
||||
stz $2113 ; Plane 3 scroll x (first 8 bits)
|
||||
stz $2113 ; Plane 3 scroll x (last 3 bits) #$0 - #$07ff
|
||||
lda #$80 ; increase VRAM address after writing to $2119
|
||||
sta $2115 ; VRAM address increment register
|
||||
stz $2116 ; VRAM address low
|
||||
stz $2117 ; VRAM address high
|
||||
stz $211A ; Initial Mode 7 setting register
|
||||
stz $211B ; Mode 7 matrix parameter A register (low)
|
||||
lda #$01
|
||||
sta $211B ; Mode 7 matrix parameter A register (high)
|
||||
stz $211C ; Mode 7 matrix parameter B register (low)
|
||||
stz $211C ; Mode 7 matrix parameter B register (high)
|
||||
stz $211D ; Mode 7 matrix parameter C register (low)
|
||||
stz $211D ; Mode 7 matrix parameter C register (high)
|
||||
stz $211E ; Mode 7 matrix parameter D register (low)
|
||||
sta $211E ; Mode 7 matrix parameter D register (high)
|
||||
stz $211F ; Mode 7 center position X register (low)
|
||||
stz $211F ; Mode 7 center position X register (high)
|
||||
stz $2120 ; Mode 7 center position Y register (low)
|
||||
stz $2120 ; Mode 7 center position Y register (high)
|
||||
stz $2121 ; Color number register ($0-ff)
|
||||
stz $2123 ; BG1 & BG2 Window mask setting register
|
||||
stz $2124 ; BG3 & BG4 Window mask setting register
|
||||
stz $2125 ; OBJ & Color Window mask setting register
|
||||
stz $2126 ; Window 1 left position register
|
||||
stz $2127 ; Window 2 left position register
|
||||
stz $2128 ; Window 3 left position register
|
||||
stz $2129 ; Window 4 left position register
|
||||
stz $212A ; BG1, BG2, BG3, BG4 Window Logic register
|
||||
stz $212B ; OBJ, Color Window Logic Register (or,and,xor,xnor)
|
||||
stz $212C ; Main Screen designation (planes, sprites enable)
|
||||
stz $212D ; Sub Screen designation
|
||||
stz $212E ; Window mask for Main Screen
|
||||
stz $212F ; Window mask for Sub Screen
|
||||
lda #$30
|
||||
sta $2130 ; Color addition & screen addition init setting
|
||||
stz $2131 ; Add/Sub sub designation for screen, sprite, color
|
||||
lda #$E0
|
||||
sta $2132 ; color data for addition/subtraction
|
||||
stz $2133 ; Screen setting (interlace x,y/enable SFX data)
|
||||
stz $4200 ; Enable V-blank, interrupt, Joypad register
|
||||
;; Set defaults for registers
|
||||
|
||||
sep #$30 ; X,Y,A are 8 bit numbers
|
||||
lda #$8F
|
||||
sta INIDISP ; screen off, full brightness
|
||||
stz OBJSEL ; Objects are 8x8 or 16x16,
|
||||
; use first 2 pages of VRAM
|
||||
stz OAMADDL ; OAM address $0000
|
||||
stz OAMADDH
|
||||
stz BGMODE ; Background mode 0
|
||||
stz MOSAIC
|
||||
stz BG1SC ; All backgrounds use tilemap $0000,
|
||||
stz BG2SC ; 1 page in size (32x32)
|
||||
stz BG3SC
|
||||
stz BG4SC
|
||||
stz BG12NBA ; All backgrounds use character data $0000
|
||||
stz BG34NBA
|
||||
lda #$FF
|
||||
sta $4201 ; Programmable I/O port
|
||||
stz $4202 ; Multiplicand A
|
||||
stz $4203 ; Multiplier B
|
||||
stz $4204 ; Multiplier C
|
||||
stz $4205 ; Multiplicand C
|
||||
stz $4206 ; Divisor B
|
||||
stz $4207 ; Horizontal Count Timer
|
||||
stz $4208 ; Horizontal Count Timer MSB (most significant bit)
|
||||
stz $4209 ; Vertical Count Timer
|
||||
stz $420A ; Vertical Count Timer MSB
|
||||
stz $420B ; General DMA enable (bits 0-7)
|
||||
stz $420C ; Horizontal DMA (HDMA) enable (bits 0-7)
|
||||
stz $420D ; Access cycle designation (slow/fast rom)
|
||||
cli ; Enable interrupts
|
||||
sta BG1VOFS ; Vertical scroll position $07FF
|
||||
sta BG2VOFS
|
||||
sta BG3VOFS
|
||||
sta BG4VOFS
|
||||
lda #$07
|
||||
sta BG1VOFS
|
||||
sta BG2VOFS
|
||||
sta BG3VOFS
|
||||
sta BG4VOFS
|
||||
stz BG1HOFS ; Horizontal scroll position $0000
|
||||
stz BG1HOFS
|
||||
stz BG2HOFS
|
||||
stz BG2HOFS
|
||||
stz BG3HOFS
|
||||
stz BG3HOFS
|
||||
stz BG4HOFS
|
||||
stz BG4HOFS
|
||||
lda #$80
|
||||
sta VMAINC ; Increment after high byte by 1, no remapping
|
||||
stz VMADDL ; VRAM address $0000
|
||||
stz VMADDH
|
||||
stz M7SEL
|
||||
lda #$01
|
||||
stz M7A ; Default to identity matrix
|
||||
sta M7A ; [$0001 $0000]
|
||||
stz M7B ; [$0000 $0001]
|
||||
stz M7B
|
||||
stz M7C
|
||||
stz M7C
|
||||
stz M7D
|
||||
sta M7D
|
||||
stz M7X
|
||||
stz M7X
|
||||
stz M7Y
|
||||
stz M7Y
|
||||
stz CGADD ; CGRAM address $00
|
||||
stz W12SEL ; Disable all layers
|
||||
stz W34SEL
|
||||
stz WOBJSEL
|
||||
stz WH0 ; Disable all windows
|
||||
stz WH1
|
||||
stz WH2
|
||||
stz WH3
|
||||
stz WBGLOG ; Intersection mode OR
|
||||
stz WOBJLOG
|
||||
stz TM ; Disable all layers on main screen
|
||||
stz TS ; Disable all layers on sub screen
|
||||
stz TMW
|
||||
stz TSW
|
||||
lda #$30
|
||||
sta CGSWSEL ; Enable main screen, disable sub screen
|
||||
stz CGADSUB ; Disable color math
|
||||
lda #$E0
|
||||
sta COLDATA ; Fixed subscreen color black
|
||||
stz INISET ; Disable interlacing, overscan,
|
||||
; pseudo-512 mode
|
||||
stz NMITIMEN ; Disable NMIs (V-blank), IRQ timers,
|
||||
; and auto-joypad-read
|
||||
lda #$FF
|
||||
sta WRIO ; Pull all I/O ports low
|
||||
stz WRMPYA
|
||||
stz WRMPYB
|
||||
stz WRDIVL
|
||||
stz WRDIVH
|
||||
stz WRDIVB
|
||||
stz HTIMEL
|
||||
stz HTIMEH
|
||||
stz VTIMEL
|
||||
stz VTIMEH
|
||||
stz MDMAEN ; Disable all DMA & HDMA
|
||||
stz HDMAEN
|
||||
stz MEMSEL ; SlowROM default
|
||||
cli
|
||||
rts
|
||||
|
|
Loading…
Reference in a new issue