/* Copyright (c) 2013-2017 Jeffrey Pfau * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include mLOG_DEFINE_CATEGORY(DS_GX, "DS GX"); #define DS_GX_FIFO_SIZE 256 static const int32_t _gxCommandCycleBase[DS_GX_CMD_MAX] = { [DS_GX_CMD_NOP] = 0, [DS_GX_CMD_MTX_MODE] = 2, [DS_GX_CMD_MTX_PUSH] = 34, [DS_GX_CMD_MTX_POP] = 72, [DS_GX_CMD_MTX_STORE] = 34, [DS_GX_CMD_MTX_RESTORE] = 72, [DS_GX_CMD_MTX_IDENTITY] = 38, [DS_GX_CMD_MTX_LOAD_4x4] = 68, [DS_GX_CMD_MTX_LOAD_4x3] = 60, [DS_GX_CMD_MTX_MULT_4x4] = 70, [DS_GX_CMD_MTX_MULT_4x3] = 62, [DS_GX_CMD_MTX_MULT_3x3] = 56, [DS_GX_CMD_MTX_SCALE] = 44, [DS_GX_CMD_MTX_TRANS] = 44, [DS_GX_CMD_COLOR] = 2, [DS_GX_CMD_NORMAL] = 18, [DS_GX_CMD_TEXCOORD] = 2, [DS_GX_CMD_VTX_16] = 18, [DS_GX_CMD_VTX_10] = 16, [DS_GX_CMD_VTX_XY] = 16, [DS_GX_CMD_VTX_XZ] = 16, [DS_GX_CMD_VTX_YZ] = 16, [DS_GX_CMD_VTX_DIFF] = 16, [DS_GX_CMD_POLYGON_ATTR] = 2, [DS_GX_CMD_TEXIMAGE_PARAM] = 2, [DS_GX_CMD_PLTT_BASE] = 2, [DS_GX_CMD_DIF_AMB] = 8, [DS_GX_CMD_SPE_EMI] = 8, [DS_GX_CMD_LIGHT_VECTOR] = 12, [DS_GX_CMD_LIGHT_COLOR] = 2, [DS_GX_CMD_SHININESS] = 64, [DS_GX_CMD_BEGIN_VTXS] = 2, [DS_GX_CMD_END_VTXS] = 2, [DS_GX_CMD_SWAP_BUFFERS] = 784, [DS_GX_CMD_VIEWPORT] = 2, [DS_GX_CMD_BOX_TEST] = 206, [DS_GX_CMD_POS_TEST] = 18, [DS_GX_CMD_VEC_TEST] = 10, }; void DSGXInit(struct DSGX* gx) { CircleBufferInit(&gx->fifo, sizeof(struct DSGXEntry) * DS_GX_FIFO_SIZE); } void DSGXDeinit(struct DSGX* gx) { CircleBufferDeinit(&gx->fifo); } void DSGXReset(struct DSGX* gx) { CircleBufferClear(&gx->fifo); } uint16_t DSGXWriteRegister(struct DSGX* gx, uint32_t address, uint16_t value) { switch (address) { case DS9_REG_DISP3DCNT: case DS9_REG_GXSTAT_LO: case DS9_REG_GXSTAT_HI: mLOG(DS_GX, STUB, "Unimplemented GX write %03X:%04X", address, value); break; default: if (address < DS9_REG_GXFIFO_00) { mLOG(DS_GX, STUB, "Unimplemented GX write %03X:%04X", address, value); } else if (address < DS9_REG_GXSTAT_LO) { mLOG(DS_GX, STUB, "Unimplemented FIFO write %03X:%04X", address, value); } else { mLOG(DS_GX, STUB, "Unimplemented GX write %03X:%04X", address, value); } break; } return value; } uint32_t DSGXWriteRegister32(struct DSGX* gx, uint32_t address, uint32_t value) { switch (address) { case DS9_REG_DISP3DCNT: case DS9_REG_GXSTAT_LO: mLOG(DS_GX, STUB, "Unimplemented GX write %03X:%04X", address, value); break; default: if (address < DS9_REG_GXFIFO_00) { mLOG(DS_GX, STUB, "Unimplemented GX write %03X:%04X", address, value); } else if (address < DS9_REG_GXSTAT_LO) { mLOG(DS_GX, STUB, "Unimplemented FIFO write %03X:%04X", address, value); } else { mLOG(DS_GX, STUB, "Unimplemented GX write %03X:%04X", address, value); } break; } return value; }