From 97490cdd4982a49ad541e28ff110c71305ba5a4d Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 14 Dec 2019 02:33:31 +1100 Subject: voodoo: hopefully enough to stop it from crashing when device memory isn't pre-cleared; also some cleanup (nw) --- src/devices/video/voodoo.cpp | 747 +++++++++++++++++++++++++++++++++++----- src/devices/video/voodoo.h | 804 +++++++------------------------------------ 2 files changed, 785 insertions(+), 766 deletions(-) diff --git a/src/devices/video/voodoo.cpp b/src/devices/video/voodoo.cpp index 92d937346d5..8e4a6215b2f 100644 --- a/src/devices/video/voodoo.cpp +++ b/src/devices/video/voodoo.cpp @@ -177,6 +177,549 @@ bits(7:4) and bit(24)), X, and Y: #define EAT_CYCLES (1) +namespace { + +/************************************* + * + * Alias map of the first 64 + * registers when remapped + * + *************************************/ + +const uint8_t register_alias_map[0x40] = +{ + vdstatus, 0x004/4, vertexAx, vertexAy, + vertexBx, vertexBy, vertexCx, vertexCy, + startR, dRdX, dRdY, startG, + dGdX, dGdY, startB, dBdX, + dBdY, startZ, dZdX, dZdY, + startA, dAdX, dAdY, startS, + dSdX, dSdY, startT, dTdX, + dTdY, startW, dWdX, dWdY, + + triangleCMD,0x084/4, fvertexAx, fvertexAy, + fvertexBx, fvertexBy, fvertexCx, fvertexCy, + fstartR, fdRdX, fdRdY, fstartG, + fdGdX, fdGdY, fstartB, fdBdX, + fdBdY, fstartZ, fdZdX, fdZdY, + fstartA, fdAdX, fdAdY, fstartS, + fdSdX, fdSdY, fstartT, fdTdX, + fdTdY, fstartW, fdWdX, fdWdY +}; + + +/************************************* + * + * Table of per-register access rights + * + *************************************/ + +const uint8_t voodoo_register_access[0x100] = +{ + /* 0x000 */ + REG_RP, 0, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x040 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x080 */ + REG_WPF, 0, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x0c0 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x100 */ + REG_WPF, REG_RWPF, REG_RWPF, REG_RWPF, + REG_RWF, REG_RWF, REG_RWF, REG_RWF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, 0, 0, + + /* 0x140 */ + REG_RWF, REG_RWF, REG_RWF, REG_R, + REG_R, REG_R, REG_R, REG_R, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x180 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x1c0 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + 0, 0, 0, 0, + 0, 0, 0, 0, + + /* 0x200 */ + REG_RW, REG_R, REG_RW, REG_RW, + REG_RW, REG_RW, REG_RW, REG_RW, + REG_W, REG_W, REG_W, REG_W, + REG_W, 0, 0, 0, + + /* 0x240 */ + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + + /* 0x280 */ + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + + /* 0x2c0 */ + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + + /* 0x300 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x340 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x380 */ + REG_WF +}; + +const uint8_t voodoo2_register_access[0x100] = +{ + /* 0x000 */ + REG_RP, REG_RWPT, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x040 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x080 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x0c0 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x100 */ + REG_WPF, REG_RWPF, REG_RWPF, REG_RWPF, + REG_RWF, REG_RWF, REG_RWF, REG_RWF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x140 */ + REG_RWF, REG_RWF, REG_RWF, REG_R, + REG_R, REG_R, REG_R, REG_R, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x180 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x1c0 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_RWT, REG_RWT, REG_RWT, REG_RWT, + REG_RWT, REG_RWT, REG_RWT, REG_RW, + + /* 0x200 */ + REG_RWT, REG_R, REG_RWT, REG_RWT, + REG_RWT, REG_RWT, REG_RWT, REG_RWT, + REG_WT, REG_WT, REG_WF, REG_WT, + REG_WT, REG_WT, REG_WT, REG_WT, + + /* 0x240 */ + REG_R, REG_RWT, REG_RWT, REG_RWT, + 0, 0, REG_R, REG_R, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x280 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, 0, 0, + 0, 0, 0, 0, + + /* 0x2c0 */ + REG_RWPF, REG_RWPF, REG_RWPF, REG_RWPF, + REG_RWPF, REG_RWPF, REG_RWPF, REG_RWPF, + REG_RWPF, REG_RWPF, REG_RWPF, REG_RWPF, + REG_RWPF, REG_RWPF, REG_RWPF, REG_WPF, + + /* 0x300 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x340 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x380 */ + REG_WF +}; + +const uint8_t banshee_register_access[0x100] = +{ + /* 0x000 */ + REG_RP, REG_RWPT, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x040 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x080 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x0c0 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x100 */ + REG_WPF, REG_RWPF, REG_RWPF, REG_RWPF, + REG_RWF, REG_RWF, REG_RWF, REG_RWF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x140 */ + REG_RWF, REG_RWF, REG_RWF, REG_R, + REG_R, REG_R, REG_R, REG_R, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x180 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x1c0 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + 0, 0, 0, REG_RWF, + REG_RWF, REG_RWF, REG_RWF, 0, + + /* 0x200 */ + REG_RWF, REG_RWF, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + + /* 0x240 */ + 0, 0, 0, REG_WT, + REG_RWF, REG_RWF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_R, REG_R, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + + /* 0x280 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, 0, 0, + 0, 0, 0, 0, + + /* 0x2c0 */ + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + 0, 0, 0, 0, + + /* 0x300 */ + REG_WPF, REG_WPF, REG_WPF, REG_WPF, + REG_WPF, REG_WPF, REG_WPF, 0, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x340 */ + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + REG_WF, REG_WF, REG_WF, REG_WF, + + /* 0x380 */ + REG_WF +}; + + +/************************************* + * + * Register string table for debug + * + *************************************/ + +const char *const voodoo_reg_name[] = +{ + /* 0x000 */ + "status", "{intrCtrl}", "vertexAx", "vertexAy", + "vertexBx", "vertexBy", "vertexCx", "vertexCy", + "startR", "startG", "startB", "startZ", + "startA", "startS", "startT", "startW", + /* 0x040 */ + "dRdX", "dGdX", "dBdX", "dZdX", + "dAdX", "dSdX", "dTdX", "dWdX", + "dRdY", "dGdY", "dBdY", "dZdY", + "dAdY", "dSdY", "dTdY", "dWdY", + /* 0x080 */ + "triangleCMD", "reserved084", "fvertexAx", "fvertexAy", + "fvertexBx", "fvertexBy", "fvertexCx", "fvertexCy", + "fstartR", "fstartG", "fstartB", "fstartZ", + "fstartA", "fstartS", "fstartT", "fstartW", + /* 0x0c0 */ + "fdRdX", "fdGdX", "fdBdX", "fdZdX", + "fdAdX", "fdSdX", "fdTdX", "fdWdX", + "fdRdY", "fdGdY", "fdBdY", "fdZdY", + "fdAdY", "fdSdY", "fdTdY", "fdWdY", + /* 0x100 */ + "ftriangleCMD", "fbzColorPath", "fogMode", "alphaMode", + "fbzMode", "lfbMode", "clipLeftRight","clipLowYHighY", + "nopCMD", "fastfillCMD", "swapbufferCMD","fogColor", + "zaColor", "chromaKey", "{chromaRange}","{userIntrCMD}", + /* 0x140 */ + "stipple", "color0", "color1", "fbiPixelsIn", + "fbiChromaFail","fbiZfuncFail", "fbiAfuncFail", "fbiPixelsOut", + "fogTable160", "fogTable164", "fogTable168", "fogTable16c", + "fogTable170", "fogTable174", "fogTable178", "fogTable17c", + /* 0x180 */ + "fogTable180", "fogTable184", "fogTable188", "fogTable18c", + "fogTable190", "fogTable194", "fogTable198", "fogTable19c", + "fogTable1a0", "fogTable1a4", "fogTable1a8", "fogTable1ac", + "fogTable1b0", "fogTable1b4", "fogTable1b8", "fogTable1bc", + /* 0x1c0 */ + "fogTable1c0", "fogTable1c4", "fogTable1c8", "fogTable1cc", + "fogTable1d0", "fogTable1d4", "fogTable1d8", "fogTable1dc", + "{cmdFifoBaseAddr}","{cmdFifoBump}","{cmdFifoRdPtr}","{cmdFifoAMin}", + "{cmdFifoAMax}","{cmdFifoDepth}","{cmdFifoHoles}","reserved1fc", + /* 0x200 */ + "fbiInit4", "vRetrace", "backPorch", "videoDimensions", + "fbiInit0", "fbiInit1", "fbiInit2", "fbiInit3", + "hSync", "vSync", "clutData", "dacData", + "maxRgbDelta", "{hBorder}", "{vBorder}", "{borderColor}", + /* 0x240 */ + "{hvRetrace}", "{fbiInit5}", "{fbiInit6}", "{fbiInit7}", + "reserved250", "reserved254", "{fbiSwapHistory}","{fbiTrianglesOut}", + "{sSetupMode}", "{sVx}", "{sVy}", "{sARGB}", + "{sRed}", "{sGreen}", "{sBlue}", "{sAlpha}", + /* 0x280 */ + "{sVz}", "{sWb}", "{sWtmu0}", "{sS/Wtmu0}", + "{sT/Wtmu0}", "{sWtmu1}", "{sS/Wtmu1}", "{sT/Wtmu1}", + "{sDrawTriCMD}","{sBeginTriCMD}","reserved2a8", "reserved2ac", + "reserved2b0", "reserved2b4", "reserved2b8", "reserved2bc", + /* 0x2c0 */ + "{bltSrcBaseAddr}","{bltDstBaseAddr}","{bltXYStrides}","{bltSrcChromaRange}", + "{bltDstChromaRange}","{bltClipX}","{bltClipY}","reserved2dc", + "{bltSrcXY}", "{bltDstXY}", "{bltSize}", "{bltRop}", + "{bltColor}", "reserved2f4", "{bltCommand}", "{bltData}", + /* 0x300 */ + "textureMode", "tLOD", "tDetail", "texBaseAddr", + "texBaseAddr_1","texBaseAddr_2","texBaseAddr_3_8","trexInit0", + "trexInit1", "nccTable0.0", "nccTable0.1", "nccTable0.2", + "nccTable0.3", "nccTable0.4", "nccTable0.5", "nccTable0.6", + /* 0x340 */ + "nccTable0.7", "nccTable0.8", "nccTable0.9", "nccTable0.A", + "nccTable0.B", "nccTable1.0", "nccTable1.1", "nccTable1.2", + "nccTable1.3", "nccTable1.4", "nccTable1.5", "nccTable1.6", + "nccTable1.7", "nccTable1.8", "nccTable1.9", "nccTable1.A", + /* 0x380 */ + "nccTable1.B" +}; + +const char *const banshee_reg_name[] = +{ + /* 0x000 */ + "status", "intrCtrl", "vertexAx", "vertexAy", + "vertexBx", "vertexBy", "vertexCx", "vertexCy", + "startR", "startG", "startB", "startZ", + "startA", "startS", "startT", "startW", + /* 0x040 */ + "dRdX", "dGdX", "dBdX", "dZdX", + "dAdX", "dSdX", "dTdX", "dWdX", + "dRdY", "dGdY", "dBdY", "dZdY", + "dAdY", "dSdY", "dTdY", "dWdY", + /* 0x080 */ + "triangleCMD", "reserved084", "fvertexAx", "fvertexAy", + "fvertexBx", "fvertexBy", "fvertexCx", "fvertexCy", + "fstartR", "fstartG", "fstartB", "fstartZ", + "fstartA", "fstartS", "fstartT", "fstartW", + /* 0x0c0 */ + "fdRdX", "fdGdX", "fdBdX", "fdZdX", + "fdAdX", "fdSdX", "fdTdX", "fdWdX", + "fdRdY", "fdGdY", "fdBdY", "fdZdY", + "fdAdY", "fdSdY", "fdTdY", "fdWdY", + /* 0x100 */ + "ftriangleCMD", "fbzColorPath", "fogMode", "alphaMode", + "fbzMode", "lfbMode", "clipLeftRight","clipLowYHighY", + "nopCMD", "fastfillCMD", "swapbufferCMD","fogColor", + "zaColor", "chromaKey", "chromaRange", "userIntrCMD", + /* 0x140 */ + "stipple", "color0", "color1", "fbiPixelsIn", + "fbiChromaFail","fbiZfuncFail", "fbiAfuncFail", "fbiPixelsOut", + "fogTable160", "fogTable164", "fogTable168", "fogTable16c", + "fogTable170", "fogTable174", "fogTable178", "fogTable17c", + /* 0x180 */ + "fogTable180", "fogTable184", "fogTable188", "fogTable18c", + "fogTable190", "fogTable194", "fogTable198", "fogTable19c", + "fogTable1a0", "fogTable1a4", "fogTable1a8", "fogTable1ac", + "fogTable1b0", "fogTable1b4", "fogTable1b8", "fogTable1bc", + /* 0x1c0 */ + "fogTable1c0", "fogTable1c4", "fogTable1c8", "fogTable1cc", + "fogTable1d0", "fogTable1d4", "fogTable1d8", "fogTable1dc", + "reserved1e0", "reserved1e4", "reserved1e8", "colBufferAddr", + "colBufferStride","auxBufferAddr","auxBufferStride","reserved1fc", + /* 0x200 */ + "clipLeftRight1","clipTopBottom1","reserved208","reserved20c", + "reserved210", "reserved214", "reserved218", "reserved21c", + "reserved220", "reserved224", "reserved228", "reserved22c", + "reserved230", "reserved234", "reserved238", "reserved23c", + /* 0x240 */ + "reserved240", "reserved244", "reserved248", "swapPending", + "leftOverlayBuf","rightOverlayBuf","fbiSwapHistory","fbiTrianglesOut", + "sSetupMode", "sVx", "sVy", "sARGB", + "sRed", "sGreen", "sBlue", "sAlpha", + /* 0x280 */ + "sVz", "sWb", "sWtmu0", "sS/Wtmu0", + "sT/Wtmu0", "sWtmu1", "sS/Wtmu1", "sT/Wtmu1", + "sDrawTriCMD", "sBeginTriCMD", "reserved2a8", "reserved2ac", + "reserved2b0", "reserved2b4", "reserved2b8", "reserved2bc", + /* 0x2c0 */ + "reserved2c0", "reserved2c4", "reserved2c8", "reserved2cc", + "reserved2d0", "reserved2d4", "reserved2d8", "reserved2dc", + "reserved2e0", "reserved2e4", "reserved2e8", "reserved2ec", + "reserved2f0", "reserved2f4", "reserved2f8", "reserved2fc", + /* 0x300 */ + "textureMode", "tLOD", "tDetail", "texBaseAddr", + "texBaseAddr_1","texBaseAddr_2","texBaseAddr_3_8","reserved31c", + "trexInit1", "nccTable0.0", "nccTable0.1", "nccTable0.2", + "nccTable0.3", "nccTable0.4", "nccTable0.5", "nccTable0.6", + /* 0x340 */ + "nccTable0.7", "nccTable0.8", "nccTable0.9", "nccTable0.A", + "nccTable0.B", "nccTable1.0", "nccTable1.1", "nccTable1.2", + "nccTable1.3", "nccTable1.4", "nccTable1.5", "nccTable1.6", + "nccTable1.7", "nccTable1.8", "nccTable1.9", "nccTable1.A", + /* 0x380 */ + "nccTable1.B" +}; + + +/************************************* + * + * Register string table for debug + * + *************************************/ + +const char *const banshee_io_reg_name[] = +{ + /* 0x000 */ + "status", "pciInit0", "sipMonitor", "lfbMemoryConfig", + "miscInit0", "miscInit1", "dramInit0", "dramInit1", + "agpInit", "tmuGbeInit", "vgaInit0", "vgaInit1", + "dramCommand", "dramData", "reserved38", "reserved3c", + + /* 0x040 */ + "pllCtrl0", "pllCtrl1", "pllCtrl2", "dacMode", + "dacAddr", "dacData", "rgbMaxDelta", "vidProcCfg", + "hwCurPatAddr", "hwCurLoc", "hwCurC0", "hwCurC1", + "vidInFormat", "vidInStatus", "vidSerialParallelPort","vidInXDecimDeltas", + + /* 0x080 */ + "vidInDecimInitErrs","vidInYDecimDeltas","vidPixelBufThold","vidChromaMin", + "vidChromaMax", "vidCurrentLine","vidScreenSize","vidOverlayStartCoords", + "vidOverlayEndScreenCoord","vidOverlayDudx","vidOverlayDudxOffsetSrcWidth","vidOverlayDvdy", + "vga[b0]", "vga[b4]", "vga[b8]", "vga[bc]", + + /* 0x0c0 */ + "vga[c0]", "vga[c4]", "vga[c8]", "vga[cc]", + "vga[d0]", "vga[d4]", "vga[d8]", "vga[dc]", + "vidOverlayDvdyOffset","vidDesktopStartAddr","vidDesktopOverlayStride","vidInAddr0", + "vidInAddr1", "vidInAddr2", "vidInStride", "vidCurrOverlayStartAddr" +}; + + +/************************************* + * + * Register string table for debug + * + *************************************/ + +const char *const banshee_agp_reg_name[] = +{ + /* 0x000 */ + "agpReqSize", "agpHostAddressLow","agpHostAddressHigh","agpGraphicsAddress", + "agpGraphicsStride","agpMoveCMD","reserved18", "reserved1c", + "cmdBaseAddr0", "cmdBaseSize0", "cmdBump0", "cmdRdPtrL0", + "cmdRdPtrH0", "cmdAMin0", "reserved38", "cmdAMax0", + + /* 0x040 */ + "reserved40", "cmdFifoDepth0","cmdHoleCnt0", "reserved4c", + "cmdBaseAddr1", "cmdBaseSize1", "cmdBump1", "cmdRdPtrL1", + "cmdRdPtrH1", "cmdAMin1", "reserved68", "cmdAMax1", + "reserved70", "cmdFifoDepth1","cmdHoleCnt1", "reserved7c", + + /* 0x080 */ + "cmdFifoThresh","cmdHoleInt", "reserved88", "reserved8c", + "reserved90", "reserved94", "reserved98", "reserved9c", + "reserveda0", "reserveda4", "reserveda8", "reservedac", + "reservedb0", "reservedb4", "reservedb8", "reservedbc", + + /* 0x0c0 */ + "reservedc0", "reservedc4", "reservedc8", "reservedcc", + "reservedd0", "reservedd4", "reservedd8", "reserveddc", + "reservede0", "reservede4", "reservede8", "reservedec", + "reservedf0", "reservedf4", "reservedf8", "reservedfc", + + /* 0x100 */ + "yuvBaseAddress","yuvStride", "reserved108", "reserved10c", + "reserved110", "reserved114", "reserved118", "reserved11c", + "crc1", "reserved124", "reserved128", "reserved12c", + "crc2", "reserved134", "reserved138", "reserved13c" +}; + +} // anonymous namespace + + struct voodoo_device::poly_extra_data { voodoo_device * device; @@ -430,7 +973,7 @@ void voodoo_device::voodoo_set_init_enable(uint32_t newval) { pci.init_enable = newval; if (LOG_REGISTERS) - logerror("VOODOO.%d.REG:initEnable write = %08X\n", index, newval); + logerror("VOODOO.REG:initEnable write = %08X\n", newval); } @@ -443,8 +986,6 @@ void voodoo_device::voodoo_set_init_enable(uint32_t newval) void voodoo_device::init_fbi(voodoo_device* vd,fbi_state *f, void *memory, int fbmem) { - int pen; - /* allocate frame buffer RAM and set pointers */ f->ram = (uint8_t *)memory; f->mask = fbmem - 1; @@ -461,13 +1002,13 @@ void voodoo_device::init_fbi(voodoo_device* vd,fbi_state *f, void *memory, int f f->clut_dirty = true; if (vd->vd_type <= TYPE_VOODOO_2) { - for (pen = 0; pen < 32; pen++) + for (int pen = 0; pen < 32; pen++) vd->fbi.clut[pen] = rgb_t(pen, pal5bit(pen), pal5bit(pen), pal5bit(pen)); vd->fbi.clut[32] = rgb_t(32,0xff,0xff,0xff); } else { - for (pen = 0; pen < 512; pen++) + for (int pen = 0; pen < 512; pen++) vd->fbi.clut[pen] = rgb_t(pen,pen,pen); } @@ -534,6 +1075,8 @@ void voodoo_device::tmu_shared_state::init() EXTRACT_4444_TO_8888(val, a, r, g, b); argb4444[val] = rgb_t(a, r, g, b); } + + rgb565 = nullptr; } @@ -607,8 +1150,6 @@ void voodoo_device::voodoo_postload() void voodoo_device::init_save_state(voodoo_device *vd) { - int index, subindex; - vd->machine().save().register_postload(save_prepost_delegate(FUNC(voodoo_device::voodoo_postload), vd)); /* register states: core */ @@ -686,44 +1227,38 @@ void voodoo_device::init_save_state(voodoo_device *vd) vd->save_item(NAME(vd->fbi.lfb_stats.clip_fail)); vd->save_item(NAME(vd->fbi.lfb_stats.stipple_count)); vd->save_item(NAME(vd->fbi.sverts)); - for (index = 0; index < ARRAY_LENGTH(vd->fbi.svert); index++) - { - vd->save_item(NAME(vd->fbi.svert[index].x), index); - vd->save_item(NAME(vd->fbi.svert[index].y), index); - vd->save_item(NAME(vd->fbi.svert[index].a), index); - vd->save_item(NAME(vd->fbi.svert[index].r), index); - vd->save_item(NAME(vd->fbi.svert[index].g), index); - vd->save_item(NAME(vd->fbi.svert[index].b), index); - vd->save_item(NAME(vd->fbi.svert[index].z), index); - vd->save_item(NAME(vd->fbi.svert[index].wb), index); - vd->save_item(NAME(vd->fbi.svert[index].w0), index); - vd->save_item(NAME(vd->fbi.svert[index].s0), index); - vd->save_item(NAME(vd->fbi.svert[index].t0), index); - vd->save_item(NAME(vd->fbi.svert[index].w1), index); - vd->save_item(NAME(vd->fbi.svert[index].s1), index); - vd->save_item(NAME(vd->fbi.svert[index].t1), index); - } + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, x)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, y)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, a)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, r)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, g)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, b)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, z)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, wb)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, w0)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, s0)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, t0)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, w1)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, s1)); + vd->save_item(STRUCT_MEMBER(vd->fbi.svert, t1)); vd->save_item(NAME(vd->fbi.fifo.size)); vd->save_item(NAME(vd->fbi.fifo.in)); vd->save_item(NAME(vd->fbi.fifo.out)); - for (index = 0; index < ARRAY_LENGTH(vd->fbi.cmdfifo); index++) - { - vd->save_item(NAME(vd->fbi.cmdfifo[index].enable), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].count_holes), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].base), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].end), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].rdptr), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].amin), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].amax), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].depth), index); - vd->save_item(NAME(vd->fbi.cmdfifo[index].holes), index); - } + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, enable)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, count_holes)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, base)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, end)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, rdptr)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, amin)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, amax)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, depth)); + vd->save_item(STRUCT_MEMBER(vd->fbi.cmdfifo, holes)); vd->save_item(NAME(vd->fbi.fogblend)); vd->save_item(NAME(vd->fbi.fogdelta)); vd->save_item(NAME(vd->fbi.clut)); /* register states: tmu */ - for (index = 0; index < ARRAY_LENGTH(vd->tmu); index++) + for (int index = 0; index < ARRAY_LENGTH(vd->tmu); index++) { tmu_state *tmu = &vd->tmu[index]; if (tmu->ram == nullptr) @@ -739,16 +1274,13 @@ void voodoo_device::init_save_state(voodoo_device *vd) vd->save_item(NAME(tmu->dsdy), index); vd->save_item(NAME(tmu->dtdy), index); vd->save_item(NAME(tmu->dwdy), index); - for (subindex = 0; subindex < ARRAY_LENGTH(tmu->ncc); subindex++) - { - vd->save_item(NAME(tmu->ncc[subindex].ir), index * ARRAY_LENGTH(tmu->ncc) + subindex); - vd->save_item(NAME(tmu->ncc[subindex].ig), index * ARRAY_LENGTH(tmu->ncc) + subindex); - vd->save_item(NAME(tmu->ncc[subindex].ib), index * ARRAY_LENGTH(tmu->ncc) + subindex); - vd->save_item(NAME(tmu->ncc[subindex].qr), index * ARRAY_LENGTH(tmu->ncc) + subindex); - vd->save_item(NAME(tmu->ncc[subindex].qg), index * ARRAY_LENGTH(tmu->ncc) + subindex); - vd->save_item(NAME(tmu->ncc[subindex].qb), index * ARRAY_LENGTH(tmu->ncc) + subindex); - vd->save_item(NAME(tmu->ncc[subindex].y), index * ARRAY_LENGTH(tmu->ncc) + subindex); - } + vd->save_item(STRUCT_MEMBER(tmu->ncc, ir), index); + vd->save_item(STRUCT_MEMBER(tmu->ncc, ig), index); + vd->save_item(STRUCT_MEMBER(tmu->ncc, ib), index); + vd->save_item(STRUCT_MEMBER(tmu->ncc, qr), index); + vd->save_item(STRUCT_MEMBER(tmu->ncc, qg), index); + vd->save_item(STRUCT_MEMBER(tmu->ncc, qb), index); + vd->save_item(STRUCT_MEMBER(tmu->ncc, y), index); } /* register states: banshee */ @@ -1079,7 +1611,7 @@ void voodoo_device::recompute_video_memory() } fbi.rowpixels = fbi.tile_width * fbi.x_tiles; -// logerror("VOODOO.%d.VIDMEM: buffer_pages=%X fifo=%X-%X tiles=%X rowpix=%d\n", index, buffer_pages, fifo_start_page, fifo_last_page, fbi.x_tiles, fbi.rowpixels); +// logerror("VOODOO.VIDMEM: buffer_pages=%X fifo=%X-%X tiles=%X rowpix=%d\n", buffer_pages, fifo_start_page, fifo_last_page, fbi.x_tiles, fbi.rowpixels); /* first RGB buffer always starts at 0 */ fbi.rgboffs[0] = 0; @@ -1091,7 +1623,7 @@ void voodoo_device::recompute_video_memory() switch (memory_config) { case 3: /* reserved */ - logerror("VOODOO.%d.ERROR:Unexpected memory configuration in recompute_video_memory!\n", index); + logerror("VOODOO.ERROR:Unexpected memory configuration in recompute_video_memory!\n"); case 0: /* 2 color buffers, 1 aux buffer */ fbi.rgboffs[2] = ~0; @@ -2062,9 +2594,12 @@ void voodoo_device::cmdfifo_w(voodoo_device *vd, cmdfifo_info *f, offs_t offset, vd->pci.op_pending = true; vd->pci.op_end_time = vd->machine().time() + attotime(0, (attoseconds_t)cycles * vd->attoseconds_per_cycle); - if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", vd->index, - vd->machine().time().seconds(), (uint32_t)(vd->machine().time().attoseconds() >> 32), (uint32_t)vd->machine().time().attoseconds(), - vd->pci.op_end_time.seconds(), (uint32_t)(vd->pci.op_end_time.attoseconds() >> 32), (uint32_t)vd->pci.op_end_time.attoseconds()); + if (LOG_FIFO_VERBOSE) + { + vd->logerror("VOODOO.FIFO:direct write start at %d.%018d end at %d.%018d\n", + vd->machine().time().seconds(), vd->machine().time().attoseconds(), + vd->pci.op_end_time.seconds(), vd->pci.op_end_time.attoseconds()); + } } } } @@ -2120,7 +2655,7 @@ void voodoo_device::check_stalled_cpu(attotime current_time) /* resume if necessary */ if (resume || !pci.op_pending) { - if (LOG_FIFO) logerror("VOODOO.%d.FIFO:Stall condition cleared; resuming\n", index); + if (LOG_FIFO) logerror("VOODOO.FIFO:Stall condition cleared; resuming\n"); pci.stall_state = NOT_STALLED; /* either call the callback, or trigger the trigger */ @@ -2191,7 +2726,7 @@ int32_t voodoo_device::register_w(voodoo_device *vd, offs_t offset, uint32_t dat /* first make sure this register is readable */ if (!(vd->regaccess[regnum] & REGISTER_WRITE)) { - vd->logerror("VOODOO.%d.ERROR:Invalid attempt to write %s\n", vd->index, vd->regnames[regnum]); + vd->logerror("VOODOO.ERROR:Invalid attempt to write %s\n", vd->regnames[regnum]); return 0; } @@ -2874,7 +3409,7 @@ int32_t voodoo_device::register_w(voodoo_device *vd, offs_t offset, uint32_t dat break; case trexInit1: - vd->logerror("VOODOO.%d.REG:%s(%d) write = %08X\n", vd->index, (regnum < 0x384 / 4) ? vd->regnames[regnum] : "oob", chips, data); + vd->logerror("VOODOO.REG:%s(%d) write = %08X\n", (regnum < 0x384 / 4) ? vd->regnames[regnum] : "oob", chips, data); /* send tmu config data to the frame buffer */ vd->send_config = (TREXINIT_SEND_TMU_CONFIG(data) > 0); goto default_case; @@ -2906,9 +3441,9 @@ default_case: if (LOG_REGISTERS) { if (regnum < fvertexAx || regnum > fdWdY) - vd->logerror("VOODOO.%d.REG:%s(%d) write = %08X\n", vd->index, (regnum < 0x384/4) ? vd->regnames[regnum] : "oob", chips, origdata); + vd->logerror("VOODOO.REG:%s(%d) write = %08X\n", (regnum < 0x384/4) ? vd->regnames[regnum] : "oob", chips, origdata); else - vd->logerror("VOODOO.%d.REG:%s(%d) write = %f\n", vd->index, (regnum < 0x384/4) ? vd->regnames[regnum] : "oob", chips, (double) u2f(origdata)); + vd->logerror("VOODOO.REG:%s(%d) write = %f\n", (regnum < 0x384/4) ? vd->regnames[regnum] : "oob", chips, (double) u2f(origdata)); } return cycles; @@ -2950,7 +3485,7 @@ int32_t voodoo_device::lfb_direct_w(offs_t offset, uint32_t data, uint32_t mem_m uint32_t const destmax = (fbi.mask + 1 - fbi.lfb_base*4) / 2; uint32_t const bufoffs = y * fbi.rowpixels + x; if (bufoffs >= destmax) { - logerror("lfb_direct_w: Buffer offset out of bounds x=%i y=%i offset=%08X bufoffs=%08X data=%08X\n", x, y, offset, (uint32_t) bufoffs, data); + logerror("lfb_direct_w: Buffer offset out of bounds x=%i y=%i offset=%08X bufoffs=%08X data=%08X\n", x, y, offset, bufoffs, data); return 0; } if (ACCESSING_BITS_0_15) @@ -2959,7 +3494,7 @@ int32_t voodoo_device::lfb_direct_w(offs_t offset, uint32_t data, uint32_t mem_m dest[bufoffs + 1] = data>>16; // Need to notify that frame buffer has changed fbi.video_changed = true; - if (LOG_LFB) logerror("VOODOO.%d.LFB:write direct (%d,%d) = %08X & %08X\n", index, x, y, data, mem_mask); + if (LOG_LFB) logerror("VOODOO.LFB:write direct (%d,%d) = %08X & %08X\n", x, y, data, mem_mask); return 0; } @@ -3215,7 +3750,7 @@ int32_t voodoo_device::lfb_w(voodoo_device* vd, offs_t offset, uint32_t data, ui DECLARE_DITHER_POINTERS_NO_DITHER_VAR; uint32_t bufoffs; - if (LOG_LFB) vd->logerror("VOODOO.%d.LFB:write raw mode %X (%d,%d) = %08X & %08X\n", vd->index, LFBMODE_WRITE_FORMAT(vd->reg[lfbMode].u), x, y, data, mem_mask); + if (LOG_LFB) vd->logerror("VOODOO.LFB:write raw mode %X (%d,%d) = %08X & %08X\n", LFBMODE_WRITE_FORMAT(vd->reg[lfbMode].u), x, y, data, mem_mask); /* determine the screen Y */ scry = y; @@ -3273,7 +3808,7 @@ int32_t voodoo_device::lfb_w(voodoo_device* vd, offs_t offset, uint32_t data, ui { DECLARE_DITHER_POINTERS; - if (LOG_LFB) vd->logerror("VOODOO.%d.LFB:write pipelined mode %X (%d,%d) = %08X & %08X\n", vd->index, LFBMODE_WRITE_FORMAT(vd->reg[lfbMode].u), x, y, data, mem_mask); + if (LOG_LFB) vd->logerror("VOODOO.LFB:write pipelined mode %X (%d,%d) = %08X & %08X\n", LFBMODE_WRITE_FORMAT(vd->reg[lfbMode].u), x, y, data, mem_mask); /* determine the screen Y */ scry = y; @@ -3554,9 +4089,12 @@ void voodoo_device::flush_fifos(voodoo_device *vd, attotime current_time) if (!vd->pci.op_pending) fatalerror("flush_fifos called with no pending operation\n"); - if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.%d.FIFO:flush_fifos start -- pending=%d.%08X%08X cur=%d.%08X%08X\n", vd->index, - vd->pci.op_end_time.seconds(), (uint32_t)(vd->pci.op_end_time.attoseconds() >> 32), (uint32_t)vd->pci.op_end_time.attoseconds(), - current_time.seconds(), (uint32_t)(current_time.attoseconds() >> 32), (uint32_t)current_time.attoseconds()); + if (LOG_FIFO_VERBOSE) + { + vd->logerror("VOODOO.FIFO:flush_fifos start -- pending=%d.%018d cur=%d.%018d\n", + vd->pci.op_end_time.seconds(), vd->pci.op_end_time.attoseconds(), + current_time.seconds(), current_time.attoseconds()); + } /* loop while we still have cycles to burn */ while (vd->pci.op_end_time <= current_time) @@ -3580,7 +4118,7 @@ void voodoo_device::flush_fifos(voodoo_device *vd, attotime current_time) { vd->pci.op_pending = false; in_flush = false; - if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.%d.FIFO:flush_fifos end -- CMDFIFO empty\n", vd->index); + if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.FIFO:flush_fifos end -- CMDFIFO empty\n"); return; } } @@ -3592,7 +4130,7 @@ void voodoo_device::flush_fifos(voodoo_device *vd, attotime current_time) { vd->pci.op_pending = false; in_flush = false; - if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.%d.FIFO:flush_fifos end -- CMDFIFO empty\n", vd->index); + if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.FIFO:flush_fifos end -- CMDFIFO empty\n"); return; } } @@ -3609,7 +4147,7 @@ void voodoo_device::flush_fifos(voodoo_device *vd, attotime current_time) { vd->pci.op_pending = false; in_flush = false; - if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.%d.FIFO:flush_fifos end -- FIFOs empty\n", vd->index); + if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.FIFO:flush_fifos end -- FIFOs empty\n"); return; } @@ -3652,13 +4190,19 @@ void voodoo_device::flush_fifos(voodoo_device *vd, attotime current_time) /* account for those cycles */ vd->pci.op_end_time += attotime(0, (attoseconds_t)cycles * vd->attoseconds_per_cycle); - if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.%d.FIFO:update -- pending=%d.%08X%08X cur=%d.%08X%08X\n", vd->index, - vd->pci.op_end_time.seconds(), (uint32_t)(vd->pci.op_end_time.attoseconds() >> 32), (uint32_t)vd->pci.op_end_time.attoseconds(), - current_time.seconds(), (uint32_t)(current_time.attoseconds() >> 32), (uint32_t)current_time.attoseconds()); + if (LOG_FIFO_VERBOSE) + { + vd->logerror("VOODOO.FIFO:update -- pending=%d.%018d cur=%d.%018d\n", + vd->pci.op_end_time.seconds(), vd->pci.op_end_time.attoseconds(), + current_time.seconds(), current_time.attoseconds()); + } } - if (LOG_FIFO_VERBOSE) vd->logerror("VOODOO.%d.FIFO:flush_fifos end -- pending command complete at %d.%08X%08X\n", vd->index, - vd->pci.op_end_time.seconds(), (uint32_t)(vd->pci.op_end_time.attoseconds() >> 32), (uint32_t)vd->pci.op_end_time.attoseconds()); + if (LOG_FIFO_VERBOSE) + { + vd->logerror("VOODOO.FIFO:flush_fifos end -- pending command complete at %d.%018d\n", + vd->pci.op_end_time.seconds(), vd->pci.op_end_time.attoseconds()); + } in_flush = false; } @@ -3769,9 +4313,12 @@ void voodoo_device::voodoo_w(offs_t offset, u32 data, u32 mem_mask) pci.op_pending = true; pci.op_end_time = machine().time() + attotime(0, (attoseconds_t)cycles * attoseconds_per_cycle); - if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", index, - machine().time().seconds(), (uint32_t)(machine().time().attoseconds() >> 32), (uint32_t)machine().time().attoseconds(), - pci.op_end_time.seconds(), (uint32_t)(pci.op_end_time.attoseconds() >> 32), (uint32_t)pci.op_end_time.attoseconds()); + if (LOG_FIFO_VERBOSE) + { + logerror("VOODOO.FIFO:direct write start at %d.%018d end at %d.%018d\n", + machine().time().seconds(), machine().time().attoseconds(), + pci.op_end_time.seconds(), pci.op_end_time.attoseconds()); + } } g_profiler.stop(); return; @@ -3808,7 +4355,7 @@ void voodoo_device::voodoo_w(offs_t offset, u32 data, u32 mem_mask) valid[2] = valid[3] = FBIINIT0_TEXMEM_TO_MEMORY_FIFO(reg[fbiInit0].u); /* flush everything we can */ - if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w moving PCI FIFO to memory FIFO\n", index); + if (LOG_FIFO_VERBOSE) logerror("VOODOO.FIFO:voodoo_w moving PCI FIFO to memory FIFO\n"); while (!pci.fifo.empty() && valid[(pci.fifo.peek() >> 22) & 3]) { fbi.fifo.add(pci.fifo.remove()); @@ -3819,7 +4366,7 @@ void voodoo_device::voodoo_w(offs_t offset, u32 data, u32 mem_mask) if (FBIINIT0_STALL_PCIE_FOR_HWM(reg[fbiInit0].u) && fbi.fifo.items() >= 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(reg[fbiInit0].u)) { - if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit memory FIFO HWM -- stalling\n", index); + if (LOG_FIFO) logerror("VOODOO.FIFO:voodoo_w hit memory FIFO HWM -- stalling\n"); stall_cpu(STALLED_UNTIL_FIFO_LWM, machine().time()); } } @@ -3828,14 +4375,14 @@ void voodoo_device::voodoo_w(offs_t offset, u32 data, u32 mem_mask) if (FBIINIT0_STALL_PCIE_FOR_HWM(reg[fbiInit0].u) && pci.fifo.space() <= 2 * FBIINIT0_PCI_FIFO_LWM(reg[fbiInit0].u)) { - if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit PCI FIFO free LWM -- stalling\n", index); + if (LOG_FIFO) logerror("VOODOO.FIFO:voodoo_w hit PCI FIFO free LWM -- stalling\n"); stall_cpu(STALLED_UNTIL_FIFO_LWM, machine().time()); } /* if we weren't ready, and this is a non-FIFO access, stall until the FIFOs are clear */ if (stall) { - if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w wrote non-FIFO register -- stalling until clear\n", index); + if (LOG_FIFO_VERBOSE) logerror("VOODOO.FIFO:voodoo_w wrote non-FIFO register -- stalling until clear\n"); stall_cpu(STALLED_UNTIL_FIFO_EMPTY, machine().time()); } @@ -3861,7 +4408,7 @@ uint32_t voodoo_device::register_r(voodoo_device *vd, offs_t offset) /* first make sure this register is readable */ if (!(vd->regaccess[regnum] & REGISTER_READ)) { - vd->logerror("VOODOO.%d.ERROR:Invalid attempt to read %s\n", vd->index, regnum < 225 ? vd->regnames[regnum] : "unknown register"); + vd->logerror("VOODOO.ERROR:Invalid attempt to read %s\n", regnum < 225 ? vd->regnames[regnum] : "unknown register"); return 0xffffffff; } @@ -4035,7 +4582,7 @@ uint32_t voodoo_device::register_r(voodoo_device *vd, offs_t offset) logit = false; if (logit) - vd->logerror("VOODOO.%d.REG:%s read = %08X\n", vd->index, vd->regnames[regnum], result); + vd->logerror("VOODOO.REG:%s read = %08X\n", vd->regnames[regnum], result); } return result; @@ -4124,7 +4671,7 @@ static uint32_t lfb_r(voodoo_device *vd, offs_t offset, bool lfb_3d) if (LFBMODE_BYTE_SWIZZLE_READS(vd->reg[lfbMode].u)) data = swapendian_int32(data); - if (LOG_LFB) vd->logerror("VOODOO.%d.LFB:read (%d,%d) = %08X\n", vd->index, x, y, data); + if (LOG_LFB) vd->logerror("VOODOO.LFB:read (%d,%d) = %08X\n", x, y, data); return data; } @@ -5063,11 +5610,6 @@ void voodoo_device::device_start() if (!m_screen || !m_cpu) throw device_missing_dependencies(); - const raster_info *info; - void *fbmem, *tmumem[2]; - uint32_t tmumem0, tmumem1; - int val; - /* validate configuration */ assert(m_fbmem > 0); @@ -5083,7 +5625,7 @@ void voodoo_device::device_start() /* create a table of precomputed 1/n and log2(n) values */ /* n ranges from 1.0000 to 2.0000 */ - for (val = 0; val <= (1 << RECIPLOG_LOOKUP_BITS); val++) + for (int val = 0; val <= (1 << RECIPLOG_LOOKUP_BITS); val++) { uint32_t value = (1 << RECIPLOG_LOOKUP_BITS) + val; voodoo_reciplog[val*2 + 0] = (1 << (RECIPLOG_LOOKUP_PREC + RECIPLOG_LOOKUP_BITS)) / value; @@ -5091,7 +5633,7 @@ void voodoo_device::device_start() } /* create dithering tables */ - for (val = 0; val < 256*16*2; val++) + for (int val = 0; val < 256*16*2; val++) { int g = (val >> 0) & 1; int x = (val >> 1) & 3; @@ -5166,7 +5708,8 @@ void voodoo_device::device_start() trigger = 51324 + index; /* build the rasterizer table */ - for (info = predef_raster_table; info->callback; info++) + std::fill(std::begin(raster_hash), std::end(raster_hash), nullptr); + for (const raster_info *info = predef_raster_table; info->callback; info++) add_rasterizer(this, info); /* set up the PCI FIFO */ @@ -5177,8 +5720,9 @@ void voodoo_device::device_start() pci.continue_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(voodoo_device::stall_cpu_callback), this), nullptr); /* allocate memory */ - tmumem0 = m_tmumem0; - tmumem1 = m_tmumem1; + void *fbmem, *tmumem[2]; + uint32_t tmumem0 = m_tmumem0; + uint32_t tmumem1 = m_tmumem1; if (vd_type <= TYPE_VOODOO_2) { /* separate FB/TMU memory */ @@ -5214,7 +5758,8 @@ void voodoo_device::device_start() } /* initialize some registers */ - memset(reg, 0, sizeof(reg)); + for (voodoo_reg &r : reg) + r.u = 0; pci.init_enable = 0; reg[fbiInit0].u = (1 << 4) | (0x10 << 6); reg[fbiInit1].u = (1 << 1) | (1 << 8) | (1 << 12) | (2 << 20); @@ -5890,9 +6435,25 @@ voodoo_device::voodoo_device(const machine_config &mconfig, device_type type, co , m_pciint(*this) , m_screen_finder(*this, finder_base::DUMMY_TAG) , m_cpu_finder(*this, finder_base::DUMMY_TAG) + , index(0) , m_screen(nullptr) , m_cpu(nullptr) , vd_type(vdt) + , chipmask(0) + , freq(0) + , attoseconds_per_cycle(0) + , extra_cycles(0) + , trigger(0) + , regaccess(nullptr) + , regnames(nullptr) + , alt_regmap(0) + , poly(nullptr) + , thread_stats(nullptr) + , last_status_pc(0) + , last_status_value(0) + , next_rasterizer(0) + , send_config(false) + , tmu_config(0) { } diff --git a/src/devices/video/voodoo.h b/src/devices/video/voodoo.h index e9a568af501..c8b74b90813 100644 --- a/src/devices/video/voodoo.h +++ b/src/devices/video/voodoo.h @@ -334,477 +334,6 @@ enum #define banshee2D_command (0x070/4) -/************************************* - * - * Alias map of the first 64 - * registers when remapped - * - *************************************/ - -static const uint8_t register_alias_map[0x40] = -{ - vdstatus, 0x004/4, vertexAx, vertexAy, - vertexBx, vertexBy, vertexCx, vertexCy, - startR, dRdX, dRdY, startG, - dGdX, dGdY, startB, dBdX, - dBdY, startZ, dZdX, dZdY, - startA, dAdX, dAdY, startS, - dSdX, dSdY, startT, dTdX, - dTdY, startW, dWdX, dWdY, - - triangleCMD,0x084/4, fvertexAx, fvertexAy, - fvertexBx, fvertexBy, fvertexCx, fvertexCy, - fstartR, fdRdX, fdRdY, fstartG, - fdGdX, fdGdY, fstartB, fdBdX, - fdBdY, fstartZ, fdZdX, fdZdY, - fstartA, fdAdX, fdAdY, fstartS, - fdSdX, fdSdY, fstartT, fdTdX, - fdTdY, fstartW, fdWdX, fdWdY -}; - - - -/************************************* - * - * Table of per-register access rights - * - *************************************/ - -static const uint8_t voodoo_register_access[0x100] = -{ - /* 0x000 */ - REG_RP, 0, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x040 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x080 */ - REG_WPF, 0, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x0c0 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x100 */ - REG_WPF, REG_RWPF, REG_RWPF, REG_RWPF, - REG_RWF, REG_RWF, REG_RWF, REG_RWF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, 0, 0, - - /* 0x140 */ - REG_RWF, REG_RWF, REG_RWF, REG_R, - REG_R, REG_R, REG_R, REG_R, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x180 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x1c0 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - 0, 0, 0, 0, - 0, 0, 0, 0, - - /* 0x200 */ - REG_RW, REG_R, REG_RW, REG_RW, - REG_RW, REG_RW, REG_RW, REG_RW, - REG_W, REG_W, REG_W, REG_W, - REG_W, 0, 0, 0, - - /* 0x240 */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - - /* 0x280 */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - - /* 0x2c0 */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - - /* 0x300 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x340 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x380 */ - REG_WF -}; - - -static const uint8_t voodoo2_register_access[0x100] = -{ - /* 0x000 */ - REG_RP, REG_RWPT, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x040 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x080 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x0c0 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x100 */ - REG_WPF, REG_RWPF, REG_RWPF, REG_RWPF, - REG_RWF, REG_RWF, REG_RWF, REG_RWF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x140 */ - REG_RWF, REG_RWF, REG_RWF, REG_R, - REG_R, REG_R, REG_R, REG_R, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x180 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x1c0 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_RWT, REG_RWT, REG_RWT, REG_RWT, - REG_RWT, REG_RWT, REG_RWT, REG_RW, - - /* 0x200 */ - REG_RWT, REG_R, REG_RWT, REG_RWT, - REG_RWT, REG_RWT, REG_RWT, REG_RWT, - REG_WT, REG_WT, REG_WF, REG_WT, - REG_WT, REG_WT, REG_WT, REG_WT, - - /* 0x240 */ - REG_R, REG_RWT, REG_RWT, REG_RWT, - 0, 0, REG_R, REG_R, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x280 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, 0, 0, - 0, 0, 0, 0, - - /* 0x2c0 */ - REG_RWPF, REG_RWPF, REG_RWPF, REG_RWPF, - REG_RWPF, REG_RWPF, REG_RWPF, REG_RWPF, - REG_RWPF, REG_RWPF, REG_RWPF, REG_RWPF, - REG_RWPF, REG_RWPF, REG_RWPF, REG_WPF, - - /* 0x300 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x340 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x380 */ - REG_WF -}; - - -static const uint8_t banshee_register_access[0x100] = -{ - /* 0x000 */ - REG_RP, REG_RWPT, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x040 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x080 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x0c0 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x100 */ - REG_WPF, REG_RWPF, REG_RWPF, REG_RWPF, - REG_RWF, REG_RWF, REG_RWF, REG_RWF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x140 */ - REG_RWF, REG_RWF, REG_RWF, REG_R, - REG_R, REG_R, REG_R, REG_R, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x180 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x1c0 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - 0, 0, 0, REG_RWF, - REG_RWF, REG_RWF, REG_RWF, 0, - - /* 0x200 */ - REG_RWF, REG_RWF, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - - /* 0x240 */ - 0, 0, 0, REG_WT, - REG_RWF, REG_RWF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_R, REG_R, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - - /* 0x280 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, 0, 0, - 0, 0, 0, 0, - - /* 0x2c0 */ - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - - /* 0x300 */ - REG_WPF, REG_WPF, REG_WPF, REG_WPF, - REG_WPF, REG_WPF, REG_WPF, 0, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x340 */ - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - REG_WF, REG_WF, REG_WF, REG_WF, - - /* 0x380 */ - REG_WF -}; - - - -/************************************* - * - * Register string table for debug - * - *************************************/ - -static const char *const voodoo_reg_name[] = -{ - /* 0x000 */ - "status", "{intrCtrl}", "vertexAx", "vertexAy", - "vertexBx", "vertexBy", "vertexCx", "vertexCy", - "startR", "startG", "startB", "startZ", - "startA", "startS", "startT", "startW", - /* 0x040 */ - "dRdX", "dGdX", "dBdX", "dZdX", - "dAdX", "dSdX", "dTdX", "dWdX", - "dRdY", "dGdY", "dBdY", "dZdY", - "dAdY", "dSdY", "dTdY", "dWdY", - /* 0x080 */ - "triangleCMD", "reserved084", "fvertexAx", "fvertexAy", - "fvertexBx", "fvertexBy", "fvertexCx", "fvertexCy", - "fstartR", "fstartG", "fstartB", "fstartZ", - "fstartA", "fstartS", "fstartT", "fstartW", - /* 0x0c0 */ - "fdRdX", "fdGdX", "fdBdX", "fdZdX", - "fdAdX", "fdSdX", "fdTdX", "fdWdX", - "fdRdY", "fdGdY", "fdBdY", "fdZdY", - "fdAdY", "fdSdY", "fdTdY", "fdWdY", - /* 0x100 */ - "ftriangleCMD", "fbzColorPath", "fogMode", "alphaMode", - "fbzMode", "lfbMode", "clipLeftRight","clipLowYHighY", - "nopCMD", "fastfillCMD", "swapbufferCMD","fogColor", - "zaColor", "chromaKey", "{chromaRange}","{userIntrCMD}", - /* 0x140 */ - "stipple", "color0", "color1", "fbiPixelsIn", - "fbiChromaFail","fbiZfuncFail", "fbiAfuncFail", "fbiPixelsOut", - "fogTable160", "fogTable164", "fogTable168", "fogTable16c", - "fogTable170", "fogTable174", "fogTable178", "fogTable17c", - /* 0x180 */ - "fogTable180", "fogTable184", "fogTable188", "fogTable18c", - "fogTable190", "fogTable194", "fogTable198", "fogTable19c", - "fogTable1a0", "fogTable1a4", "fogTable1a8", "fogTable1ac", - "fogTable1b0", "fogTable1b4", "fogTable1b8", "fogTable1bc", - /* 0x1c0 */ - "fogTable1c0", "fogTable1c4", "fogTable1c8", "fogTable1cc", - "fogTable1d0", "fogTable1d4", "fogTable1d8", "fogTable1dc", - "{cmdFifoBaseAddr}","{cmdFifoBump}","{cmdFifoRdPtr}","{cmdFifoAMin}", - "{cmdFifoAMax}","{cmdFifoDepth}","{cmdFifoHoles}","reserved1fc", - /* 0x200 */ - "fbiInit4", "vRetrace", "backPorch", "videoDimensions", - "fbiInit0", "fbiInit1", "fbiInit2", "fbiInit3", - "hSync", "vSync", "clutData", "dacData", - "maxRgbDelta", "{hBorder}", "{vBorder}", "{borderColor}", - /* 0x240 */ - "{hvRetrace}", "{fbiInit5}", "{fbiInit6}", "{fbiInit7}", - "reserved250", "reserved254", "{fbiSwapHistory}","{fbiTrianglesOut}", - "{sSetupMode}", "{sVx}", "{sVy}", "{sARGB}", - "{sRed}", "{sGreen}", "{sBlue}", "{sAlpha}", - /* 0x280 */ - "{sVz}", "{sWb}", "{sWtmu0}", "{sS/Wtmu0}", - "{sT/Wtmu0}", "{sWtmu1}", "{sS/Wtmu1}", "{sT/Wtmu1}", - "{sDrawTriCMD}","{sBeginTriCMD}","reserved2a8", "reserved2ac", - "reserved2b0", "reserved2b4", "reserved2b8", "reserved2bc", - /* 0x2c0 */ - "{bltSrcBaseAddr}","{bltDstBaseAddr}","{bltXYStrides}","{bltSrcChromaRange}", - "{bltDstChromaRange}","{bltClipX}","{bltClipY}","reserved2dc", - "{bltSrcXY}", "{bltDstXY}", "{bltSize}", "{bltRop}", - "{bltColor}", "reserved2f4", "{bltCommand}", "{bltData}", - /* 0x300 */ - "textureMode", "tLOD", "tDetail", "texBaseAddr", - "texBaseAddr_1","texBaseAddr_2","texBaseAddr_3_8","trexInit0", - "trexInit1", "nccTable0.0", "nccTable0.1", "nccTable0.2", - "nccTable0.3", "nccTable0.4", "nccTable0.5", "nccTable0.6", - /* 0x340 */ - "nccTable0.7", "nccTable0.8", "nccTable0.9", "nccTable0.A", - "nccTable0.B", "nccTable1.0", "nccTable1.1", "nccTable1.2", - "nccTable1.3", "nccTable1.4", "nccTable1.5", "nccTable1.6", - "nccTable1.7", "nccTable1.8", "nccTable1.9", "nccTable1.A", - /* 0x380 */ - "nccTable1.B" -}; - - -static const char *const banshee_reg_name[] = -{ - /* 0x000 */ - "status", "intrCtrl", "vertexAx", "vertexAy", - "vertexBx", "vertexBy", "vertexCx", "vertexCy", - "startR", "startG", "startB", "startZ", - "startA", "startS", "startT", "startW", - /* 0x040 */ - "dRdX", "dGdX", "dBdX", "dZdX", - "dAdX", "dSdX", "dTdX", "dWdX", - "dRdY", "dGdY", "dBdY", "dZdY", - "dAdY", "dSdY", "dTdY", "dWdY", - /* 0x080 */ - "triangleCMD", "reserved084", "fvertexAx", "fvertexAy", - "fvertexBx", "fvertexBy", "fvertexCx", "fvertexCy", - "fstartR", "fstartG", "fstartB", "fstartZ", - "fstartA", "fstartS", "fstartT", "fstartW", - /* 0x0c0 */ - "fdRdX", "fdGdX", "fdBdX", "fdZdX", - "fdAdX", "fdSdX", "fdTdX", "fdWdX", - "fdRdY", "fdGdY", "fdBdY", "fdZdY", - "fdAdY", "fdSdY", "fdTdY", "fdWdY", - /* 0x100 */ - "ftriangleCMD", "fbzColorPath", "fogMode", "alphaMode", - "fbzMode", "lfbMode", "clipLeftRight","clipLowYHighY", - "nopCMD", "fastfillCMD", "swapbufferCMD","fogColor", - "zaColor", "chromaKey", "chromaRange", "userIntrCMD", - /* 0x140 */ - "stipple", "color0", "color1", "fbiPixelsIn", - "fbiChromaFail","fbiZfuncFail", "fbiAfuncFail", "fbiPixelsOut", - "fogTable160", "fogTable164", "fogTable168", "fogTable16c", - "fogTable170", "fogTable174", "fogTable178", "fogTable17c", - /* 0x180 */ - "fogTable180", "fogTable184", "fogTable188", "fogTable18c", - "fogTable190", "fogTable194", "fogTable198", "fogTable19c", - "fogTable1a0", "fogTable1a4", "fogTable1a8", "fogTable1ac", - "fogTable1b0", "fogTable1b4", "fogTable1b8", "fogTable1bc", - /* 0x1c0 */ - "fogTable1c0", "fogTable1c4", "fogTable1c8", "fogTable1cc", - "fogTable1d0", "fogTable1d4", "fogTable1d8", "fogTable1dc", - "reserved1e0", "reserved1e4", "reserved1e8", "colBufferAddr", - "colBufferStride","auxBufferAddr","auxBufferStride","reserved1fc", - /* 0x200 */ - "clipLeftRight1","clipTopBottom1","reserved208","reserved20c", - "reserved210", "reserved214", "reserved218", "reserved21c", - "reserved220", "reserved224", "reserved228", "reserved22c", - "reserved230", "reserved234", "reserved238", "reserved23c", - /* 0x240 */ - "reserved240", "reserved244", "reserved248", "swapPending", - "leftOverlayBuf","rightOverlayBuf","fbiSwapHistory","fbiTrianglesOut", - "sSetupMode", "sVx", "sVy", "sARGB", - "sRed", "sGreen", "sBlue", "sAlpha", - /* 0x280 */ - "sVz", "sWb", "sWtmu0", "sS/Wtmu0", - "sT/Wtmu0", "sWtmu1", "sS/Wtmu1", "sT/Wtmu1", - "sDrawTriCMD", "sBeginTriCMD", "reserved2a8", "reserved2ac", - "reserved2b0", "reserved2b4", "reserved2b8", "reserved2bc", - /* 0x2c0 */ - "reserved2c0", "reserved2c4", "reserved2c8", "reserved2cc", - "reserved2d0", "reserved2d4", "reserved2d8", "reserved2dc", - "reserved2e0", "reserved2e4", "reserved2e8", "reserved2ec", - "reserved2f0", "reserved2f4", "reserved2f8", "reserved2fc", - /* 0x300 */ - "textureMode", "tLOD", "tDetail", "texBaseAddr", - "texBaseAddr_1","texBaseAddr_2","texBaseAddr_3_8","reserved31c", - "trexInit1", "nccTable0.0", "nccTable0.1", "nccTable0.2", - "nccTable0.3", "nccTable0.4", "nccTable0.5", "nccTable0.6", - /* 0x340 */ - "nccTable0.7", "nccTable0.8", "nccTable0.9", "nccTable0.A", - "nccTable0.B", "nccTable1.0", "nccTable1.1", "nccTable1.2", - "nccTable1.3", "nccTable1.4", "nccTable1.5", "nccTable1.6", - "nccTable1.7", "nccTable1.8", "nccTable1.9", "nccTable1.A", - /* 0x380 */ - "nccTable1.B" -}; - - - /************************************* * * Voodoo Banshee I/O space registers @@ -883,41 +412,6 @@ static const char *const banshee_reg_name[] = -/************************************* - * - * Register string table for debug - * - *************************************/ - -static const char *const banshee_io_reg_name[] = -{ - /* 0x000 */ - "status", "pciInit0", "sipMonitor", "lfbMemoryConfig", - "miscInit0", "miscInit1", "dramInit0", "dramInit1", - "agpInit", "tmuGbeInit", "vgaInit0", "vgaInit1", - "dramCommand", "dramData", "reserved38", "reserved3c", - - /* 0x040 */ - "pllCtrl0", "pllCtrl1", "pllCtrl2", "dacMode", - "dacAddr", "dacData", "rgbMaxDelta", "vidProcCfg", - "hwCurPatAddr", "hwCurLoc", "hwCurC0", "hwCurC1", - "vidInFormat", "vidInStatus", "vidSerialParallelPort","vidInXDecimDeltas", - - /* 0x080 */ - "vidInDecimInitErrs","vidInYDecimDeltas","vidPixelBufThold","vidChromaMin", - "vidChromaMax", "vidCurrentLine","vidScreenSize","vidOverlayStartCoords", - "vidOverlayEndScreenCoord","vidOverlayDudx","vidOverlayDudxOffsetSrcWidth","vidOverlayDvdy", - "vga[b0]", "vga[b4]", "vga[b8]", "vga[bc]", - - /* 0x0c0 */ - "vga[c0]", "vga[c4]", "vga[c8]", "vga[cc]", - "vga[d0]", "vga[d4]", "vga[d8]", "vga[dc]", - "vidOverlayDvdyOffset","vidDesktopStartAddr","vidDesktopOverlayStride","vidInAddr0", - "vidInAddr1", "vidInAddr2", "vidInStride", "vidCurrOverlayStartAddr" -}; - - - /************************************* * * Voodoo Banshee AGP space registers @@ -964,47 +458,6 @@ static const char *const banshee_io_reg_name[] = -/************************************* - * - * Register string table for debug - * - *************************************/ - -static const char *const banshee_agp_reg_name[] = -{ - /* 0x000 */ - "agpReqSize", "agpHostAddressLow","agpHostAddressHigh","agpGraphicsAddress", - "agpGraphicsStride","agpMoveCMD","reserved18", "reserved1c", - "cmdBaseAddr0", "cmdBaseSize0", "cmdBump0", "cmdRdPtrL0", - "cmdRdPtrH0", "cmdAMin0", "reserved38", "cmdAMax0", - - /* 0x040 */ - "reserved40", "cmdFifoDepth0","cmdHoleCnt0", "reserved4c", - "cmdBaseAddr1", "cmdBaseSize1", "cmdBump1", "cmdRdPtrL1", - "cmdRdPtrH1", "cmdAMin1", "reserved68", "cmdAMax1", - "reserved70", "cmdFifoDepth1","cmdHoleCnt1", "reserved7c", - - /* 0x080 */ - "cmdFifoThresh","cmdHoleInt", "reserved88", "reserved8c", - "reserved90", "reserved94", "reserved98", "reserved9c", - "reserveda0", "reserveda4", "reserveda8", "reservedac", - "reservedb0", "reservedb4", "reservedb8", "reservedbc", - - /* 0x0c0 */ - "reservedc0", "reservedc4", "reservedc8", "reservedcc", - "reservedd0", "reservedd4", "reservedd8", "reserveddc", - "reservede0", "reservede4", "reservede8", "reservedec", - "reservedf0", "reservedf4", "reservedf8", "reservedfc", - - /* 0x100 */ - "yuvBaseAddress","yuvStride", "reserved108", "reserved10c", - "reserved110", "reserved114", "reserved118", "reserved11c", - "crc1", "reserved124", "reserved128", "reserved12c", - "crc2", "reserved134", "reserved138", "reserved13c" -}; - - - /************************************* * * Dithering tables @@ -1013,9 +466,9 @@ static const char *const banshee_agp_reg_name[] = static const uint8_t dither_matrix_4x4[16] = { - 0, 8, 2, 10, + 0, 8, 2, 10, 12, 4, 14, 6, - 3, 11, 1, 9, + 3, 11, 1, 9, 15, 7, 13, 5 }; @@ -1486,25 +939,31 @@ protected: struct voodoo_stats { - uint8_t lastkey; // last key state - uint8_t display; // display stats? - int32_t swaps; // total swaps - int32_t stalls; // total stalls - int32_t total_triangles; // total triangles - int32_t total_pixels_in; // total pixels in - int32_t total_pixels_out; // total pixels out - int32_t total_chroma_fail; // total chroma fail - int32_t total_zfunc_fail; // total z func fail - int32_t total_afunc_fail; // total a func fail - int32_t total_clipped; // total clipped - int32_t total_stippled; // total stippled - int32_t lfb_writes; // LFB writes - int32_t lfb_reads; // LFB reads - int32_t reg_writes; // register writes - int32_t reg_reads; // register reads - int32_t tex_writes; // texture writes + voodoo_stats() + { + std::fill(std::begin(texture_mode), std::end(texture_mode), 0); + buffer[0] = 0; + } + + uint8_t lastkey = 0; // last key state + uint8_t display = 0; // display stats? + int32_t swaps = 0; // total swaps + int32_t stalls = 0; // total stalls + int32_t total_triangles = 0; // total triangles + int32_t total_pixels_in = 0; // total pixels in + int32_t total_pixels_out = 0; // total pixels out + int32_t total_chroma_fail = 0; // total chroma fail + int32_t total_zfunc_fail = 0; // total z func fail + int32_t total_afunc_fail = 0; // total a func fail + int32_t total_clipped = 0; // total clipped + int32_t total_stippled = 0; // total stippled + int32_t lfb_writes = 0; // LFB writes + int32_t lfb_reads = 0; // LFB reads + int32_t reg_writes = 0; // register writes + int32_t reg_reads = 0; // register reads + int32_t tex_writes = 0; // texture writes int32_t texture_mode[16]; // 16 different texture modes - uint8_t render_override; // render override + uint8_t render_override = 0; // render override char buffer[1024]; // string }; @@ -1512,13 +971,13 @@ protected: /* note that this structure is an even 64 bytes long */ struct stats_block { - int32_t pixels_in; // pixels in statistic - int32_t pixels_out; // pixels out statistic - int32_t chroma_fail; // chroma test fail statistic - int32_t zfunc_fail; // z function test fail statistic - int32_t afunc_fail; // alpha function test fail statistic - int32_t clip_fail; // clipping fail statistic - int32_t stipple_count; // stipple statistic + int32_t pixels_in = 0; // pixels in statistic + int32_t pixels_out = 0; // pixels out statistic + int32_t chroma_fail = 0; // chroma test fail statistic + int32_t zfunc_fail = 0; // z function test fail statistic + int32_t afunc_fail = 0; // alpha function test fail statistic + int32_t clip_fail = 0; // clipping fail statistic + int32_t stipple_count = 0; // stipple statistic int32_t filler[64/4 - 7]; // pad this structure to 64 bytes }; @@ -1534,35 +993,35 @@ protected: int32_t items() const; int32_t space() const { return size - 1 - items(); } - uint32_t * base; // base of the FIFO - int32_t size; // size of the FIFO - int32_t in; // input pointer - int32_t out; // output pointer + uint32_t * base = nullptr; // base of the FIFO + int32_t size = 0; // size of the FIFO + int32_t in = 0; // input pointer + int32_t out = 0; // output pointer }; struct cmdfifo_info { - uint8_t enable; // enabled? - uint8_t count_holes; // count holes? - uint32_t base; // base address in framebuffer RAM - uint32_t end; // end address in framebuffer RAM - uint32_t rdptr; // current read pointer - uint32_t amin; // minimum address - uint32_t amax; // maximum address - uint32_t depth; // current depth - uint32_t holes; // number of holes + uint8_t enable = 0; // enabled? + uint8_t count_holes = 0; // count holes? + uint32_t base = 0; // base address in framebuffer RAM + uint32_t end = 0; // end address in framebuffer RAM + uint32_t rdptr = 0; // current read pointer + uint32_t amin = 0; // minimum address + uint32_t amax = 0; // maximum address + uint32_t depth = 0; // current depth + uint32_t holes = 0; // number of holes }; struct pci_state { fifo_state fifo; // PCI FIFO - uint32_t init_enable; // initEnable value - uint8_t stall_state; // state of the system if we're stalled - uint8_t op_pending; // true if an operation is pending - attotime op_end_time; // time when the pending operation ends - emu_timer * continue_timer; // timer to use to continue processing + uint32_t init_enable = 0; // initEnable value + uint8_t stall_state = 0; // state of the system if we're stalled + uint8_t op_pending = 0; // true if an operation is pending + attotime op_end_time = attotime::zero; // time when the pending operation ends + emu_timer * continue_timer = nullptr; // timer to use to continue processing uint32_t fifo_mem[64*2]; // memory backing the PCI FIFO }; @@ -1582,47 +1041,47 @@ protected: void write(offs_t regnum, uint32_t data); void update(); - uint8_t dirty; // is the texel lookup dirty? - voodoo_reg * reg; // pointer to our registers + uint8_t dirty = 0; // is the texel lookup dirty? + voodoo_reg * reg = nullptr; // pointer to our registers int32_t ir[4], ig[4], ib[4]; // I values for R,G,B int32_t qr[4], qg[4], qb[4]; // Q values for R,G,B int32_t y[16]; // Y values - rgb_t * palette; // pointer to associated RGB palette - rgb_t * palettea; // pointer to associated ARGB palette + rgb_t * palette = nullptr; // pointer to associated RGB palette + rgb_t * palettea = nullptr; // pointer to associated ARGB palette rgb_t texel[256]; // texel lookup }; - uint8_t * ram; // pointer to our RAM - uint32_t mask; // mask to apply to pointers - voodoo_reg * reg; // pointer to our register base - uint32_t regdirty; // true if the LOD/mode/base registers have changed + uint8_t * ram = nullptr; // pointer to our RAM + uint32_t mask = 0; // mask to apply to pointers + voodoo_reg * reg = nullptr; // pointer to our register base + uint32_t regdirty = 0; // true if the LOD/mode/base registers have changed - uint32_t texaddr_mask; // mask for texture address - uint8_t texaddr_shift; // shift for texture address + uint32_t texaddr_mask = 0; // mask for texture address + uint8_t texaddr_shift = 0; // shift for texture address - int64_t starts, startt; // starting S,T (14.18) - int64_t startw; // starting W (2.30) - int64_t dsdx, dtdx; // delta S,T per X - int64_t dwdx; // delta W per X - int64_t dsdy, dtdy; // delta S,T per Y - int64_t dwdy; // delta W per Y + int64_t starts = 0, startt = 0; // starting S,T (14.18) + int64_t startw = 0; // starting W (2.30) + int64_t dsdx = 0, dtdx = 0; // delta S,T per X + int64_t dwdx = 0; // delta W per X + int64_t dsdy = 0, dtdy = 0; // delta S,T per Y + int64_t dwdy = 0; // delta W per Y - int32_t lodmin, lodmax; // min, max LOD values - int32_t lodbias; // LOD bias - uint32_t lodmask; // mask of available LODs + int32_t lodmin = 0, lodmax = 0; // min, max LOD values + int32_t lodbias = 0; // LOD bias + uint32_t lodmask = 0; // mask of available LODs uint32_t lodoffset[9]; // offset of texture base for each LOD - int32_t detailmax; // detail clamp - int32_t detailbias; // detail bias - uint8_t detailscale; // detail scale + int32_t detailmax = 0; // detail clamp + int32_t detailbias = 0; // detail bias + uint8_t detailscale = 0; // detail scale - uint32_t wmask; // mask for the current texture width - uint32_t hmask; // mask for the current texture height + uint32_t wmask = 0; // mask for the current texture width + uint32_t hmask = 0; // mask for the current texture height - uint32_t bilinear_mask; // mask for bilinear resolution (0xf0 for V1, 0xff for V2) + uint32_t bilinear_mask = 0; // mask for bilinear resolution (0xf0 for V1, 0xff for V2) ncc_table ncc[2]; // two NCC tables - rgb_t * lookup; // currently selected lookup + rgb_t * lookup = nullptr; // currently selected lookup rgb_t * texel[16]; // texel lookups for each format rgb_t palette[256]; // palette lookup table @@ -1656,41 +1115,41 @@ protected: float s1, t1, w1; // W, S, T for TMU 1 }; - uint8_t * ram; // pointer to frame buffer RAM - uint32_t mask; // mask to apply to pointers - uint32_t rgboffs[3]; // word offset to 3 RGB buffers - uint32_t auxoffs; // word offset to 1 aux buffer - - uint8_t frontbuf; // front buffer index - uint8_t backbuf; // back buffer index - uint8_t swaps_pending; // number of pending swaps - uint8_t video_changed; // did the frontbuffer video change? - - uint32_t yorigin; // Y origin subtract value - uint32_t lfb_base; // base of LFB in memory - uint8_t lfb_stride; // stride of LFB accesses in bits - - uint32_t width; // width of current frame buffer - uint32_t height; // height of current frame buffer - uint32_t xoffs; // horizontal offset (back porch) - uint32_t yoffs; // vertical offset (back porch) - uint32_t vsyncstart; // vertical sync start scanline - uint32_t vsyncstop; // veritcal sync stop - uint32_t rowpixels; // pixels per row - uint32_t tile_width; // width of video tiles - uint32_t tile_height; // height of video tiles - uint32_t x_tiles; // number of tiles in the X direction - - emu_timer * vsync_stop_timer; // VBLANK End timer - emu_timer * vsync_start_timer; // VBLANK timer - uint8_t vblank; // VBLANK state - uint8_t vblank_count; // number of VBLANKs since last swap - uint8_t vblank_swap_pending; // a swap is pending, waiting for a vblank - uint8_t vblank_swap; // swap when we hit this count - uint8_t vblank_dont_swap; // don't actually swap when we hit this point + uint8_t * ram = nullptr; // pointer to frame buffer RAM + uint32_t mask = 0; // mask to apply to pointers + uint32_t rgboffs[3] = { 0, 0, 0 }; // word offset to 3 RGB buffers + uint32_t auxoffs = 0; // word offset to 1 aux buffer + + uint8_t frontbuf = 0; // front buffer index + uint8_t backbuf = 0; // back buffer index + uint8_t swaps_pending = 0; // number of pending swaps + uint8_t video_changed = 0; // did the frontbuffer video change? + + uint32_t yorigin = 0; // Y origin subtract value + uint32_t lfb_base = 0; // base of LFB in memory + uint8_t lfb_stride = 0; // stride of LFB accesses in bits + + uint32_t width = 0; // width of current frame buffer + uint32_t height = 0; // height of current frame buffer + uint32_t xoffs = 0; // horizontal offset (back porch) + uint32_t yoffs = 0; // vertical offset (back porch) + uint32_t vsyncstart = 0; // vertical sync start scanline + uint32_t vsyncstop = 0; // veritcal sync stop + uint32_t rowpixels = 0; // pixels per row + uint32_t tile_width = 0; // width of video tiles + uint32_t tile_height = 0; // height of video tiles + uint32_t x_tiles = 0; // number of tiles in the X direction + + emu_timer * vsync_stop_timer = nullptr; // VBLANK End timer + emu_timer * vsync_start_timer = nullptr; // VBLANK timer + uint8_t vblank = 0; // VBLANK state + uint8_t vblank_count = 0; // number of VBLANKs since last swap + uint8_t vblank_swap_pending = 0;// a swap is pending, waiting for a vblank + uint8_t vblank_swap = 0; // swap when we hit this count + uint8_t vblank_dont_swap = 0; // don't actually swap when we hit this point /* triangle setup info */ - uint8_t cheating_allowed; // allow cheating? + uint8_t cheating_allowed = 0; // allow cheating? int32_t sign; // triangle sign int16_t ax, ay; // vertex A x,y (12.4) int16_t bx, by; // vertex B x,y (12.4) @@ -1707,7 +1166,7 @@ protected: stats_block lfb_stats; // LFB-access statistics - uint8_t sverts; // number of vertices ready */ + uint8_t sverts = 0; // number of vertices ready */ setup_vertex svert[3]; // 3 setup vertices */ fifo_state fifo; // framebuffer memory fifo */ @@ -1719,7 +1178,7 @@ protected: rgb_t pen[65536]; // mapping from pixels to pens */ rgb_t clut[512]; // clut gamma data */ - uint8_t clut_dirty; // do we need to recompute? */ + uint8_t clut_dirty = 1; // do we need to recompute? */ rgb_t rgb565[65536]; // RGB 5-6-5 lookup table */ }; @@ -1738,9 +1197,9 @@ protected: { uint32_t compute_hash() const; - raster_info * next; // pointer to next entry with the same hash - poly_draw_scanline_func callback; // callback pointer - bool is_generic; // true if this is one of the generic rasterizers + raster_info * next = nullptr; // pointer to next entry with the same hash + poly_draw_scanline_func callback = nullptr; // callback pointer + bool is_generic = false; // true if this is one of the generic rasterizers uint8_t display; // display index uint32_t hits; // how many hits (pixels) we've used this for uint32_t polys; // how many polys we've used this for @@ -1750,7 +1209,7 @@ protected: uint32_t eff_fbz_mode; // effective fbzMode value uint32_t eff_tex_mode_0; // effective textureMode value for TMU #0 uint32_t eff_tex_mode_1; // effective textureMode value for TMU #1 - uint32_t hash; + uint32_t hash = 0U; }; @@ -1769,21 +1228,21 @@ protected: uint8_t attff; // VGA attribute flip-flop uint32_t blt_regs[0x20]; // 2D Blitter registers - uint32_t blt_dst_base; - uint32_t blt_dst_x; - uint32_t blt_dst_y; - uint32_t blt_dst_width; - uint32_t blt_dst_height; - uint32_t blt_dst_stride; - uint32_t blt_dst_bpp; - uint32_t blt_cmd; - uint32_t blt_src_base; - uint32_t blt_src_x; - uint32_t blt_src_y; - uint32_t blt_src_width; - uint32_t blt_src_height; - uint32_t blt_src_stride; - uint32_t blt_src_bpp; + uint32_t blt_dst_base = 0; + uint32_t blt_dst_x = 0; + uint32_t blt_dst_y = 0; + uint32_t blt_dst_width = 0; + uint32_t blt_dst_height = 0; + uint32_t blt_dst_stride = 0; + uint32_t blt_dst_bpp = 0; + uint32_t blt_cmd = 0; + uint32_t blt_src_base = 0; + uint32_t blt_src_x = 0; + uint32_t blt_src_y = 0; + uint32_t blt_src_width = 0; + uint32_t blt_src_height = 0; + uint32_t blt_src_stride = 0; + uint32_t blt_src_bpp = 0; }; @@ -1889,7 +1348,6 @@ public: bool send_config; uint32_t tmu_config; - }; class voodoo_1_device : public voodoo_device -- cgit v1.2.3