voodoo2.h: add floating point register type

This commit is contained in:
Zack Buhman 2025-09-17 14:05:00 -05:00
parent 72f1154aa8
commit 74d3b5183b
5 changed files with 110 additions and 84 deletions

View File

@ -160,15 +160,21 @@ def format_rw(r_w):
def sanitize(name): def sanitize(name):
return name.replace("/", "_") return name.replace("/", "_")
def type(rl):
if "floating point" in rl.description and not rl.name.endswith("CMD"):
return "reg32f"
else:
return "reg32"
def format_register_line(rl, max_length): def format_register_line(rl, max_length):
if rl.start_address == rl.end_address: if rl.start_address == rl.end_address:
space = ' ' * (max_length - len(rl.name)) space = ' ' * (max_length - len(rl.name))
return f"reg32 {sanitize(rl.name)};{space} // ({format_rw(rl.r_w)}) {rl.description}" return f"{type(rl)} {sanitize(rl.name)};{space} // ({format_rw(rl.r_w)}) {rl.description}"
else: else:
length = (rl.end_address - rl.start_address) // 4 + 1 length = (rl.end_address - rl.start_address) // 4 + 1
length_s = f"[{length}]" length_s = f"[{length}]"
space = ' ' * (max_length - (len(rl.name) + len(length_s))) space = ' ' * (max_length - (len(rl.name) + len(length_s)))
return f"reg32 {sanitize(rl.name)}{length_s};{space} // ({format_rw(rl.r_w)}) {rl.description}" return f"{type(rl)} {sanitize(rl.name)}{length_s};{space} // ({format_rw(rl.r_w)}) {rl.description}"
def render_register_struct(rls, max_length): def render_register_struct(rls, max_length):
last_address = -4 last_address = -4

View File

@ -137,21 +137,21 @@ reserved 0x254(596) n/a n/a n/a
fbiSwapHistory 0x258(600) 31:0 Chuck R n/a Swap History Register fbiSwapHistory 0x258(600) 31:0 Chuck R n/a Swap History Register
fbiTrianglesOut 0x25c(604) 23:0 Chuck R n/a Triangle Counter (Number triangles drawn) fbiTrianglesOut 0x25c(604) 23:0 Chuck R n/a Triangle Counter (Number triangles drawn)
sSetupMode 0x260(608) 19:0 Chuck W Yes / Yes Triangle setup mode sSetupMode 0x260(608) 19:0 Chuck W Yes / Yes Triangle setup mode
sVx 0x264(612) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup X sVx 0x264(612) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup X (floating point)
sVy 0x268(616) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Y sVy 0x268(616) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Y (floating point)
sARGB 0x26c(620) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Alpha, Red, Green, Blue sARGB 0x26c(620) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Alpha, Red, Green, Blue
sRed 0x270(624) 31:0 Chuck W Yes / Yes Triangle setup Red value sRed 0x270(624) 31:0 Chuck W Yes / Yes Triangle setup Red value (floating point)
sGreen 0x274(628) 31:0 Chuck W Yes / Yes Triangle setup Green value sGreen 0x274(628) 31:0 Chuck W Yes / Yes Triangle setup Green value (floating point)
sBlue 0x278(632) 31:0 Chuck W Yes / Yes Triangle setup Blue value sBlue 0x278(632) 31:0 Chuck W Yes / Yes Triangle setup Blue value (floating point)
sAlpha 0x27c(636) 31:0 Chuck W Yes / Yes Triangle setup Alpha value sAlpha 0x27c(636) 31:0 Chuck W Yes / Yes Triangle setup Alpha value (floating point)
sVz 0x280(640) 31:0 Chuck W Yes / Yes Triangle setup Z sVz 0x280(640) 31:0 Chuck W Yes / Yes Triangle setup Z (floating point)
sWb 0x284(644) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Global W sWb 0x284(644) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Global W (floating point)
sWtmu0 0x288(648) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 W sWtmu0 0x288(648) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 W (floating point)
sS/W0 0x28c(652) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 S/W sS/W0 0x28c(652) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 S/W (floating point)
sT/W0 0x290(656) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 T/W sT/W0 0x290(656) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 T/W (floating point)
sWtmu1 0x294(660) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only W sWtmu1 0x294(660) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only W (floating point)
sS/Wtmu1 0x298(664) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only S/W sS/Wtmu1 0x298(664) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only S/W (floating point)
sT/Wtmu1 0x29c(668) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only T/W sT/Wtmu1 0x29c(668) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only T/W (floating point)
sDrawTriCMD 0x2a0(672) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup (Draw) sDrawTriCMD 0x2a0(672) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup (Draw)
sBeginTriCMD 0x2a4(676) 31:0 Chuck W Yes / Yes Triangle setup Start New triangle sBeginTriCMD 0x2a4(676) 31:0 Chuck W Yes / Yes Triangle setup Start New triangle
reserved 0x2a8(680) n/a n/a n/a n/a reserved 0x2a8(680) n/a n/a n/a n/a

23
main.c
View File

@ -271,7 +271,7 @@ int main()
| FBIINIT1__DRIVE_VIDEO_TIMING_BLANK_OUTPUTS | FBIINIT1__DRIVE_VIDEO_TIMING_BLANK_OUTPUTS
| FBIINIT1__DRIVE_VIDEO_TIMING_HSYNC_VSYNC_OUTPUTS | FBIINIT1__DRIVE_VIDEO_TIMING_HSYNC_VSYNC_OUTPUTS
| FBIINIT1__DRIVE_VIDEO_TIMING_DCLK_OUTPUT | FBIINIT1__DRIVE_VIDEO_TIMING_DCLK_OUTPUT
| FBIINIT1__VIDEO_TIMING_VCLK_INPUT_SELECT_0(0) | FBIINIT1__VIDEO_TIMING_VCLK_INPUT_SELECT_0(0) // vid_clk_2x
| FBIINIT1__VIDEO_TIMING_VCLK_SOURCE_SELECT__VID_CLK_2X_SEL | FBIINIT1__VIDEO_TIMING_VCLK_SOURCE_SELECT__VID_CLK_2X_SEL
| FBIINIT1__NUMBER_OF_32X32_VIDEO_TILES_IN_HORIZONTAL_DIMENSION_5(x_tiles_5) | FBIINIT1__NUMBER_OF_32X32_VIDEO_TILES_IN_HORIZONTAL_DIMENSION_5(x_tiles_5)
; ;
@ -299,7 +299,8 @@ int main()
wait_graphics_busy(voodoo2); wait_graphics_busy(voodoo2);
voodoo2->fbiInit5 voodoo2->fbiInit5
= FBIINIT5__INVERT_DAC_HSYNC_OUTPUT_TO_DAC = FBIINIT5__VIDEO_TIMING_VCLK_INPUT_SELECT_1(0) // vid_clk_2x
| FBIINIT5__INVERT_DAC_HSYNC_OUTPUT_TO_DAC
| FBIINIT5__INVERT_DAC_VSYNC_OUTPUT_TO_DAC | FBIINIT5__INVERT_DAC_VSYNC_OUTPUT_TO_DAC
; ;
wait_graphics_busy(voodoo2); wait_graphics_busy(voodoo2);
@ -358,6 +359,7 @@ int main()
write_fd_u32(config_fd, PCI__CONFIG__INIT_ENABLE, init_enable); write_fd_u32(config_fd, PCI__CONFIG__INIT_ENABLE, init_enable);
wait_graphics_busy(voodoo2); wait_graphics_busy(voodoo2);
if (0) {
static const uint16_t panda[] __attribute__((aligned(4))) = { static const uint16_t panda[] __attribute__((aligned(4))) = {
#include "panda.rgb565.inc" #include "panda.rgb565.inc"
}; };
@ -386,6 +388,23 @@ int main()
} }
sleep(1); sleep(1);
} }
}
////////////////////////////////////////////////////////////////////////
// triangle
////////////////////////////////////////////////////////////////////////
voodoo2->sSetupMode
= SSETUPMODE__SETUP_RED_GREEN_BLUE
;
voodoo2->sBeginTriCMD = 1;
voodoo2->sVx = 10;
voodoo2->sVy = 10;
voodoo2->sVy = 10;
voodoo2->sDrawTriCMD = 1;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// cleanup // cleanup

1
reg.h
View File

@ -3,3 +3,4 @@
typedef volatile uint8_t reg8; typedef volatile uint8_t reg8;
typedef volatile uint16_t reg16; typedef volatile uint16_t reg16;
typedef volatile uint32_t reg32; typedef volatile uint32_t reg32;
typedef volatile float reg32f;

View File

@ -40,36 +40,36 @@ struct voodoo2_reg {
reg32 dWdY; // ( w) Change in 1/W with respect to Y (2.30 format) reg32 dWdY; // ( w) Change in 1/W with respect to Y (2.30 format)
reg32 triangleCMD; // ( w) Execute TRIANGLE command (floating point) reg32 triangleCMD; // ( w) Execute TRIANGLE command (floating point)
reg32 _reserved0[1]; reg32 _reserved0[1];
reg32 fvertexAx; // ( w) Vertex A x-coordinate location (floating point) reg32f fvertexAx; // ( w) Vertex A x-coordinate location (floating point)
reg32 fvertexAy; // ( w) Vertex A y-coordinate location (floating point) reg32f fvertexAy; // ( w) Vertex A y-coordinate location (floating point)
reg32 fvertexBx; // ( w) Vertex B x-coordinate location (floating point) reg32f fvertexBx; // ( w) Vertex B x-coordinate location (floating point)
reg32 fvertexBy; // ( w) Vertex B y-coordinate location (floating point) reg32f fvertexBy; // ( w) Vertex B y-coordinate location (floating point)
reg32 fvertexCx; // ( w) Vertex C x-coordinate location (floating point) reg32f fvertexCx; // ( w) Vertex C x-coordinate location (floating point)
reg32 fvertexCy; // ( w) Vertex C y-coordinate location (floating point) reg32f fvertexCy; // ( w) Vertex C y-coordinate location (floating point)
reg32 fstartR; // ( w) Starting Red parameter (floating point) reg32f fstartR; // ( w) Starting Red parameter (floating point)
reg32 fstartG; // ( w) Starting Green parameter (floating point) reg32f fstartG; // ( w) Starting Green parameter (floating point)
reg32 fstartB; // ( w) Starting Blue parameter (floating point) reg32f fstartB; // ( w) Starting Blue parameter (floating point)
reg32 fstartZ; // ( w) Starting Z parameter (floating point) reg32f fstartZ; // ( w) Starting Z parameter (floating point)
reg32 fstartA; // ( w) Starting Alpha parameter (floating point) reg32f fstartA; // ( w) Starting Alpha parameter (floating point)
reg32 fstartS; // ( w) Starting S/W parameter (floating point) reg32f fstartS; // ( w) Starting S/W parameter (floating point)
reg32 fstartT; // ( w) Starting T/W parameter (floating point) reg32f fstartT; // ( w) Starting T/W parameter (floating point)
reg32 fstartW; // ( w) Starting 1/W parameter (floating point) reg32f fstartW; // ( w) Starting 1/W parameter (floating point)
reg32 fdRdX; // ( w) Change in Red with respect to X (floating point) reg32f fdRdX; // ( w) Change in Red with respect to X (floating point)
reg32 fdGdX; // ( w) Change in Green with respect to X (floating point) reg32f fdGdX; // ( w) Change in Green with respect to X (floating point)
reg32 fdBdX; // ( w) Change in Blue with respect to X (floating point) reg32f fdBdX; // ( w) Change in Blue with respect to X (floating point)
reg32 fdZdX; // ( w) Change in Z with respect to X (floating point) reg32f fdZdX; // ( w) Change in Z with respect to X (floating point)
reg32 fdAdX; // ( w) Change in Alpha with respect to X (floating point) reg32f fdAdX; // ( w) Change in Alpha with respect to X (floating point)
reg32 fdSdX; // ( w) Change in S/W with respect to X (floating point) reg32f fdSdX; // ( w) Change in S/W with respect to X (floating point)
reg32 fdTdX; // ( w) Change in T/W with respect to X (floating point) reg32f fdTdX; // ( w) Change in T/W with respect to X (floating point)
reg32 fdWdX; // ( w) Change in 1/W with respect to X (floating point) reg32f fdWdX; // ( w) Change in 1/W with respect to X (floating point)
reg32 fdRdY; // ( w) Change in Red with respect to Y (floating point) reg32f fdRdY; // ( w) Change in Red with respect to Y (floating point)
reg32 fdGdY; // ( w) Change in Green with respect to Y (floating point) reg32f fdGdY; // ( w) Change in Green with respect to Y (floating point)
reg32 fdBdY; // ( w) Change in Blue with respect to Y (floating point) reg32f fdBdY; // ( w) Change in Blue with respect to Y (floating point)
reg32 fdZdY; // ( w) Change in Z with respect to Y (floating point) reg32f fdZdY; // ( w) Change in Z with respect to Y (floating point)
reg32 fdAdY; // ( w) Change in Alpha with respect to Y (floating point) reg32f fdAdY; // ( w) Change in Alpha with respect to Y (floating point)
reg32 fdSdY; // ( w) Change in S/W with respect to Y (floating point) reg32f fdSdY; // ( w) Change in S/W with respect to Y (floating point)
reg32 fdTdY; // ( w) Change in T/W with respect to Y (floating point) reg32f fdTdY; // ( w) Change in T/W with respect to Y (floating point)
reg32 fdWdY; // ( w) Change in 1/W with respect to Y (floating point) reg32f fdWdY; // ( w) Change in 1/W with respect to Y (floating point)
reg32 ftriangleCMD; // ( w) Execute TRIANGLE command (floating point) reg32 ftriangleCMD; // ( w) Execute TRIANGLE command (floating point)
reg32 fbzColorPath; // (rw) Chuck Color Path Control reg32 fbzColorPath; // (rw) Chuck Color Path Control
reg32 fogMode; // (rw) Fog Mode Control reg32 fogMode; // (rw) Fog Mode Control
@ -127,21 +127,21 @@ struct voodoo2_reg {
reg32 fbiSwapHistory; // (r ) Swap History Register reg32 fbiSwapHistory; // (r ) Swap History Register
reg32 fbiTrianglesOut; // (r ) Triangle Counter (Number triangles drawn) reg32 fbiTrianglesOut; // (r ) Triangle Counter (Number triangles drawn)
reg32 sSetupMode; // ( w) Triangle setup mode reg32 sSetupMode; // ( w) Triangle setup mode
reg32 sVx; // ( w) Triangle setup X reg32f sVx; // ( w) Triangle setup X (floating point)
reg32 sVy; // ( w) Triangle setup Y reg32f sVy; // ( w) Triangle setup Y (floating point)
reg32 sARGB; // ( w) Triangle setup Alpha, Red, Green, Blue reg32 sARGB; // ( w) Triangle setup Alpha, Red, Green, Blue
reg32 sRed; // ( w) Triangle setup Red value reg32f sRed; // ( w) Triangle setup Red value (floating point)
reg32 sGreen; // ( w) Triangle setup Green value reg32f sGreen; // ( w) Triangle setup Green value (floating point)
reg32 sBlue; // ( w) Triangle setup Blue value reg32f sBlue; // ( w) Triangle setup Blue value (floating point)
reg32 sAlpha; // ( w) Triangle setup Alpha value reg32f sAlpha; // ( w) Triangle setup Alpha value (floating point)
reg32 sVz; // ( w) Triangle setup Z reg32f sVz; // ( w) Triangle setup Z (floating point)
reg32 sWb; // ( w) Triangle setup Global W reg32f sWb; // ( w) Triangle setup Global W (floating point)
reg32 sWtmu0; // ( w) Triangle setup Tmu0 & Tmu1 W reg32f sWtmu0; // ( w) Triangle setup Tmu0 & Tmu1 W (floating point)
reg32 sS_W0; // ( w) Triangle setup Tmu0 & Tmu1 S/W reg32f sS_W0; // ( w) Triangle setup Tmu0 & Tmu1 S/W (floating point)
reg32 sT_W0; // ( w) Triangle setup Tmu0 & Tmu1 T/W reg32f sT_W0; // ( w) Triangle setup Tmu0 & Tmu1 T/W (floating point)
reg32 sWtmu1; // ( w) Triangle setup Tmu1 only W reg32f sWtmu1; // ( w) Triangle setup Tmu1 only W (floating point)
reg32 sS_Wtmu1; // ( w) Triangle setup Tmu1 only S/W reg32f sS_Wtmu1; // ( w) Triangle setup Tmu1 only S/W (floating point)
reg32 sT_Wtmu1; // ( w) Triangle setup Tmu1 only T/W reg32f sT_Wtmu1; // ( w) Triangle setup Tmu1 only T/W (floating point)
reg32 sDrawTriCMD; // ( w) Triangle setup (Draw) reg32 sDrawTriCMD; // ( w) Triangle setup (Draw)
reg32 sBeginTriCMD; // ( w) Triangle setup Start New triangle reg32 sBeginTriCMD; // ( w) Triangle setup Start New triangle
reg32 _reserved3[6]; reg32 _reserved3[6];