OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
superfx.h
Go to the documentation of this file.
1
18
19#ifndef SNES_SUPERFX_H
20#define SNES_SUPERFX_H
21
22#include <snes/types.h>
23
24/*============================================================================
25 * GSU Register Definitions ($3000-$303F)
26 *============================================================================*/
27
28#define REG_GSU_R0 (*(volatile u16*)0x3000)
29#define REG_GSU_R1 (*(volatile u16*)0x3002)
30#define REG_GSU_R2 (*(volatile u16*)0x3004)
31#define REG_GSU_R3 (*(volatile u16*)0x3006)
32#define REG_GSU_R4 (*(volatile u16*)0x3008)
33#define REG_GSU_R5 (*(volatile u16*)0x300A)
34#define REG_GSU_R6 (*(volatile u16*)0x300C)
35#define REG_GSU_R7 (*(volatile u16*)0x300E)
36#define REG_GSU_R8 (*(volatile u16*)0x3010)
37#define REG_GSU_R9 (*(volatile u16*)0x3012)
38#define REG_GSU_R10 (*(volatile u16*)0x3014)
39#define REG_GSU_R11 (*(volatile u16*)0x3016)
40#define REG_GSU_R12 (*(volatile u16*)0x3018)
41#define REG_GSU_R13 (*(volatile u16*)0x301A)
42#define REG_GSU_R14 (*(volatile u16*)0x301C)
43#define REG_GSU_R15 (*(volatile u16*)0x301E)
44
45#define REG_SFR (*(volatile u16*)0x3030)
46#define REG_SFR_L (*(volatile u8*)0x3030)
47#define SFR_GO 0x20
48
49#define REG_BRAMR (*(volatile u8*)0x3033)
50#define REG_PBR (*(volatile u8*)0x3034)
51#define REG_CFGR (*(volatile u8*)0x3037)
52#define REG_ROMBR (*(volatile u8*)0x3036)
53#define REG_SCBR (*(volatile u8*)0x3038)
54#define REG_CLSR (*(volatile u8*)0x3039)
55#define REG_SCMR (*(volatile u8*)0x303A)
56#define REG_VCR (*(volatile u8*)0x303B)
57#define REG_RAMBR (*(volatile u8*)0x303C)
58#define REG_CBR (*(volatile u16*)0x303E)
59
60#define CLSR_10MHZ 0x00
61#define CLSR_21MHZ 0x01
62
63#define SCMR_2BPP 0x00
64#define SCMR_4BPP 0x01
65#define SCMR_8BPP 0x03
66#define SCMR_RAN 0x08
67#define SCMR_RON 0x10
68#define SCMR_H128 0x00
69#define SCMR_H160 0x04
70#define SCMR_H192 0x20
71
72#define CFGR_IRQ_MASK 0x80
73#define CFGR_FAST_MUL 0x20
74
75#define GSU_SRAM_BASE 0x700000
76
77/*============================================================================
78 * Library Configuration Variables (defined in lib/source/superfx.asm)
79 * Set these BEFORE calling gsuLaunch().
80 *============================================================================*/
81
83extern u8 gsu_prog_bank;
84
86extern u16 gsu_prog_addr;
87
95extern u8 gsu_cfgr;
96
98extern u8 gsu_scmr;
99
101extern u8 gsu_scbr;
102
104extern u8 gsu_dma_src_hi;
105
107extern u8 superfx_status;
108
121extern volatile u8 gsu_stop_irqs;
122
132extern u8 gsu_owns_cart;
133
143extern u8 gsu_scmr_live;
144
145
146/*============================================================================
147 * API Functions
148 *============================================================================*/
149
158inline u8 gsuIsPresent(void) {
159 return superfx_status != 0;
160}
161
170inline u8 gsuInit(void) {
171 gsu_cfgr = 0x80; /* IRQ mask, no fast multiply */
172 gsu_scmr = 0x19; /* 4bpp + RAN + RON (most common for PLOT) */
173 gsu_scbr = 0x00; /* Buffer A */
174 gsu_dma_src_hi = 0x00; /* DMA from buffer A */
175 return superfx_status != 0;
176}
177
194void gsuSetProgram(const void *program);
195
210extern void gsuLaunch(void);
211
232void gsuCall(u16 entry);
233
271
282void gsuCacheLoad(const void *code, u16 size);
283
295
301
308void gsuWait(void);
309
311
344
351
363#define GSU_PRESENT_ON_LAG_FRAMES 0x01
364
378u8 gsuPresentInit(u16 vram_a, u16 vram_b, u8 flags);
379
388void gsuPresent(void);
389
392
394void gsuPresentWait(void);
395
397
406extern void gsuSetupBitmapTilemap(u16 vramAddr);
407
429extern void gsuDmaFullFrame(void);
430
450extern void gsuSetupHdmaBlanking(u16 topBlank, u16 bottomBlank);
451
452#endif /* SNES_SUPERFX_H */
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:53
unsigned char u8
8-bit unsigned integer (0 to 255)
Definition types.h:47
void gsuCall(u16 entry)
Launch the program at one of its entry points and wait (WRAM-safe).
u8 gsu_dma_src_hi
DMA source high byte ($00=buffer A at $70:0000, $40=buffer B at $70:4000).
void gsuWait(void)
Wait for the end of the job, then give the Game Pak back to the CPU.
u8 gsuPresentBusy(void)
1 while a presented frame is still being moved to VRAM
void gsuSetupBitmapTilemap(u16 vramAddr)
Setup column-major tilemap for SuperFX PLOT framebuffer.
u8 gsu_scmr_live
The value last written to SCMR (write-only), kept by the library.
u8 gsu_cfgr
CFGR register value written by the launchers ($80 = IRQ mask). CFGR_FAST_MUL (bit 5,...
void gsuPresent(void)
Queue the frame the last job drew; the next job draws in the other.
u8 gsu_prog_bank
GSU program bank byte (set by gsuSetProgram).
u8 gsuBusy(void)
Is the GSU still running? (SFR GO bit).
void gsuSetProgram(const void *program)
Tell the library where the GSU program lives.
u8 gsuPresentInit(u16 vram_a, u16 vram_b, u8 flags)
Set up presentation for gsu_scmr's geometry.
void gsuPresentWait(void)
Wait until the last presented frame is on screen.
u8 gsu_owns_cart
1 while a GSU job owns the Game Pak ROM (crt0)
void gsuStartCached(u16 pc)
Start the program loaded by gsuCacheLoad() and return at once.
void gsuCacheLoad(const void *code, u16 size)
Copy a GSU program into the GSU code cache ($3100-$32FF).
u16 gsu_prog_addr
GSU program 16-bit address (set by gsuSetProgram).
volatile u8 gsu_stop_irqs
GSU IRQs on STOP acknowledged so far (crt0, wraps at 256).
u8 gsuIsPresent(void)
Is a GSU on this cartridge? (crt0 detects it; this reads the outcome).
Definition superfx.h:158
u8 gsu_scbr
SCBR screen base ($00=buffer A, $10=buffer B).
u8 gsuInit(void)
Set the GSU default configuration; returns gsuIsPresent().
Definition superfx.h:170
void gsuDmaFullFrame(void)
One 16 KB DMA from Game Pak RAM to VRAM $0000, in the letterbox.
void gsuSetupHdmaBlanking(u16 topBlank, u16 bottomBlank)
Setup HDMA screen blanking for DMA bandwidth.
u16 gsuFrameBytes(void)
Bytes of one framebuffer for gsu_scmr's height and depth.
u8 superfx_status
SuperFX status from crt0 init (VCR chip version, 0=not detected).
u8 gsu_scmr
SCMR register value ($18=RAN+RON, $19=4bpp+RAN+RON).
void gsuLaunch(void)
Launch GSU program and wait for completion (WRAM-safe).
OpenSNES Standard Types.