diff --git a/gen/voodoo2.py b/gen/voodoo2.py index 59e0166..9a98e16 100644 --- a/gen/voodoo2.py +++ b/gen/voodoo2.py @@ -160,15 +160,21 @@ def format_rw(r_w): def sanitize(name): 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): if rl.start_address == rl.end_address: 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: length = (rl.end_address - rl.start_address) // 4 + 1 length_s = f"[{length}]" 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): last_address = -4 diff --git a/gen/voodoo2.txt b/gen/voodoo2.txt index 71a473a..917ef10 100644 --- a/gen/voodoo2.txt +++ b/gen/voodoo2.txt @@ -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 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 -sVx 0x264(612) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup X -sVy 0x268(616) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Y +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 (floating point) 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 -sGreen 0x274(628) 31:0 Chuck W Yes / Yes Triangle setup Green value -sBlue 0x278(632) 31:0 Chuck W Yes / Yes Triangle setup Blue value -sAlpha 0x27c(636) 31:0 Chuck W Yes / Yes Triangle setup Alpha value -sVz 0x280(640) 31:0 Chuck W Yes / Yes Triangle setup Z -sWb 0x284(644) 31:0 Chuck+Bruce* W Yes / Yes Triangle setup Global W -sWtmu0 0x288(648) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 W -sS/W0 0x28c(652) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 S/W -sT/W0 0x290(656) 31:0 Bruce* W Yes / Yes Triangle setup Tmu0 & Tmu1 T/W -sWtmu1 0x294(660) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only W -sS/Wtmu1 0x298(664) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only S/W -sT/Wtmu1 0x29c(668) 31:0 Bruce-1 W Yes / Yes Triangle setup Tmu1 only T/W +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 (floating point) +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 (floating point) +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 (floating point) +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 (floating point) +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 (floating point) +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 (floating point) 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 reserved 0x2a8(680) n/a n/a n/a n/a diff --git a/main.c b/main.c index a587230..b55e125 100644 --- a/main.c +++ b/main.c @@ -271,7 +271,7 @@ int main() | FBIINIT1__DRIVE_VIDEO_TIMING_BLANK_OUTPUTS | FBIINIT1__DRIVE_VIDEO_TIMING_HSYNC_VSYNC_OUTPUTS | 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__NUMBER_OF_32X32_VIDEO_TILES_IN_HORIZONTAL_DIMENSION_5(x_tiles_5) ; @@ -299,7 +299,8 @@ int main() wait_graphics_busy(voodoo2); 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 ; wait_graphics_busy(voodoo2); @@ -358,35 +359,53 @@ int main() write_fd_u32(config_fd, PCI__CONFIG__INIT_ENABLE, init_enable); wait_graphics_busy(voodoo2); - static const uint16_t panda[] __attribute__((aligned(4))) = { - #include "panda.rgb565.inc" - }; - static const uint16_t bear[] __attribute__((aligned(4))) = { - #include "bear.rgb565.inc" - }; + if (0) { + static const uint16_t panda[] __attribute__((aligned(4))) = { + #include "panda.rgb565.inc" + }; + static const uint16_t bear[] __attribute__((aligned(4))) = { + #include "bear.rgb565.inc" + }; - while (true) { - volatile uint16_t * framebuffer - = (volatile uint16_t * )(((ptrdiff_t)resource0_base) + 0x0400000); + while (true) { + volatile uint16_t * framebuffer + = (volatile uint16_t * )(((ptrdiff_t)resource0_base) + 0x0400000); - printf("panda\n"); - for (int y = 0; y < 600; y++) { - for (int x = 0; x < 800; x++) { - framebuffer[y * 1024 + x] = panda[y * 800 + x]; - wait_graphics_busy(voodoo2); + printf("panda\n"); + for (int y = 0; y < 600; y++) { + for (int x = 0; x < 800; x++) { + framebuffer[y * 1024 + x] = panda[y * 800 + x]; + wait_graphics_busy(voodoo2); + } } - } - sleep(1); - printf("bear\n"); - for (int y = 0; y < 600; y++) { - for (int x = 0; x < 800; x++) { - framebuffer[y * 1024 + x] = bear[y * 800 + x]; - wait_graphics_busy(voodoo2); + sleep(1); + printf("bear\n"); + for (int y = 0; y < 600; y++) { + for (int x = 0; x < 800; x++) { + framebuffer[y * 1024 + x] = bear[y * 800 + x]; + wait_graphics_busy(voodoo2); + } } + 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 //////////////////////////////////////////////////////////////////////// diff --git a/reg.h b/reg.h index 5d9ce13..acc73ce 100644 --- a/reg.h +++ b/reg.h @@ -3,3 +3,4 @@ typedef volatile uint8_t reg8; typedef volatile uint16_t reg16; typedef volatile uint32_t reg32; +typedef volatile float reg32f; diff --git a/voodoo2.h b/voodoo2.h index c2a0fe5..4b3616a 100644 --- a/voodoo2.h +++ b/voodoo2.h @@ -40,36 +40,36 @@ struct voodoo2_reg { reg32 dWdY; // ( w) Change in 1/W with respect to Y (2.30 format) reg32 triangleCMD; // ( w) Execute TRIANGLE command (floating point) reg32 _reserved0[1]; - reg32 fvertexAx; // ( w) Vertex A x-coordinate location (floating point) - reg32 fvertexAy; // ( w) Vertex A y-coordinate location (floating point) - reg32 fvertexBx; // ( w) Vertex B x-coordinate location (floating point) - reg32 fvertexBy; // ( w) Vertex B y-coordinate location (floating point) - reg32 fvertexCx; // ( w) Vertex C x-coordinate location (floating point) - reg32 fvertexCy; // ( w) Vertex C y-coordinate location (floating point) - reg32 fstartR; // ( w) Starting Red parameter (floating point) - reg32 fstartG; // ( w) Starting Green parameter (floating point) - reg32 fstartB; // ( w) Starting Blue parameter (floating point) - reg32 fstartZ; // ( w) Starting Z parameter (floating point) - reg32 fstartA; // ( w) Starting Alpha parameter (floating point) - reg32 fstartS; // ( w) Starting S/W parameter (floating point) - reg32 fstartT; // ( w) Starting T/W parameter (floating point) - reg32 fstartW; // ( w) Starting 1/W parameter (floating point) - reg32 fdRdX; // ( w) Change in Red with respect to X (floating point) - reg32 fdGdX; // ( w) Change in Green with respect to X (floating point) - reg32 fdBdX; // ( w) Change in Blue with respect to X (floating point) - reg32 fdZdX; // ( w) Change in Z with respect to X (floating point) - reg32 fdAdX; // ( w) Change in Alpha with respect to X (floating point) - reg32 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) - reg32 fdWdX; // ( w) Change in 1/W with respect to X (floating point) - reg32 fdRdY; // ( w) Change in Red with respect to Y (floating point) - reg32 fdGdY; // ( w) Change in Green with respect to Y (floating point) - reg32 fdBdY; // ( w) Change in Blue with respect to Y (floating point) - reg32 fdZdY; // ( w) Change in Z with respect to Y (floating point) - reg32 fdAdY; // ( w) Change in Alpha with respect to Y (floating point) - reg32 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) - reg32 fdWdY; // ( w) Change in 1/W with respect to Y (floating point) + reg32f fvertexAx; // ( w) Vertex A x-coordinate location (floating point) + reg32f fvertexAy; // ( w) Vertex A y-coordinate location (floating point) + reg32f fvertexBx; // ( w) Vertex B x-coordinate location (floating point) + reg32f fvertexBy; // ( w) Vertex B y-coordinate location (floating point) + reg32f fvertexCx; // ( w) Vertex C x-coordinate location (floating point) + reg32f fvertexCy; // ( w) Vertex C y-coordinate location (floating point) + reg32f fstartR; // ( w) Starting Red parameter (floating point) + reg32f fstartG; // ( w) Starting Green parameter (floating point) + reg32f fstartB; // ( w) Starting Blue parameter (floating point) + reg32f fstartZ; // ( w) Starting Z parameter (floating point) + reg32f fstartA; // ( w) Starting Alpha parameter (floating point) + reg32f fstartS; // ( w) Starting S/W parameter (floating point) + reg32f fstartT; // ( w) Starting T/W parameter (floating point) + reg32f fstartW; // ( w) Starting 1/W parameter (floating point) + reg32f fdRdX; // ( w) Change in Red with respect to X (floating point) + reg32f fdGdX; // ( w) Change in Green with respect to X (floating point) + reg32f fdBdX; // ( w) Change in Blue with respect to X (floating point) + reg32f fdZdX; // ( w) Change in Z with respect to X (floating point) + reg32f fdAdX; // ( w) Change in Alpha with respect to X (floating point) + reg32f fdSdX; // ( w) Change in S/W with respect to X (floating point) + reg32f fdTdX; // ( w) Change in T/W with respect to X (floating point) + reg32f fdWdX; // ( w) Change in 1/W with respect to X (floating point) + reg32f fdRdY; // ( w) Change in Red with respect to Y (floating point) + reg32f fdGdY; // ( w) Change in Green with respect to Y (floating point) + reg32f fdBdY; // ( w) Change in Blue with respect to Y (floating point) + reg32f fdZdY; // ( w) Change in Z with respect to Y (floating point) + reg32f fdAdY; // ( w) Change in Alpha with respect to Y (floating point) + reg32f fdSdY; // ( w) Change in S/W with respect to Y (floating point) + reg32f fdTdY; // ( w) Change in T/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 fbzColorPath; // (rw) Chuck Color Path Control reg32 fogMode; // (rw) Fog Mode Control @@ -127,21 +127,21 @@ struct voodoo2_reg { reg32 fbiSwapHistory; // (r ) Swap History Register reg32 fbiTrianglesOut; // (r ) Triangle Counter (Number triangles drawn) reg32 sSetupMode; // ( w) Triangle setup mode - reg32 sVx; // ( w) Triangle setup X - reg32 sVy; // ( w) Triangle setup Y + reg32f sVx; // ( w) Triangle setup X (floating point) + reg32f sVy; // ( w) Triangle setup Y (floating point) reg32 sARGB; // ( w) Triangle setup Alpha, Red, Green, Blue - reg32 sRed; // ( w) Triangle setup Red value - reg32 sGreen; // ( w) Triangle setup Green value - reg32 sBlue; // ( w) Triangle setup Blue value - reg32 sAlpha; // ( w) Triangle setup Alpha value - reg32 sVz; // ( w) Triangle setup Z - reg32 sWb; // ( w) Triangle setup Global W - reg32 sWtmu0; // ( w) Triangle setup Tmu0 & Tmu1 W - reg32 sS_W0; // ( w) Triangle setup Tmu0 & Tmu1 S/W - reg32 sT_W0; // ( w) Triangle setup Tmu0 & Tmu1 T/W - reg32 sWtmu1; // ( w) Triangle setup Tmu1 only W - reg32 sS_Wtmu1; // ( w) Triangle setup Tmu1 only S/W - reg32 sT_Wtmu1; // ( w) Triangle setup Tmu1 only T/W + reg32f sRed; // ( w) Triangle setup Red value (floating point) + reg32f sGreen; // ( w) Triangle setup Green value (floating point) + reg32f sBlue; // ( w) Triangle setup Blue value (floating point) + reg32f sAlpha; // ( w) Triangle setup Alpha value (floating point) + reg32f sVz; // ( w) Triangle setup Z (floating point) + reg32f sWb; // ( w) Triangle setup Global W (floating point) + reg32f sWtmu0; // ( w) Triangle setup Tmu0 & Tmu1 W (floating point) + reg32f sS_W0; // ( w) Triangle setup Tmu0 & Tmu1 S/W (floating point) + reg32f sT_W0; // ( w) Triangle setup Tmu0 & Tmu1 T/W (floating point) + reg32f sWtmu1; // ( w) Triangle setup Tmu1 only W (floating point) + reg32f sS_Wtmu1; // ( w) Triangle setup Tmu1 only S/W (floating point) + reg32f sT_Wtmu1; // ( w) Triangle setup Tmu1 only T/W (floating point) reg32 sDrawTriCMD; // ( w) Triangle setup (Draw) reg32 sBeginTriCMD; // ( w) Triangle setup Start New triangle reg32 _reserved3[6];