diff --git a/source/game/emancipation.c b/source/game/emancipation.c index 1d0b2b8..f203be2 100644 --- a/source/game/emancipation.c +++ b/source/game/emancipation.c @@ -38,8 +38,8 @@ float emancipationRectangleData[] = {1.0f, 1.0f, 0.0f, u32* emancipationRectangleVertexData = NULL; -extern u32 __linear_heap; -#define emancipationBaseAddr __linear_heap +extern u32 __ctru_linear_heap; +#define emancipationBaseAddr __ctru_linear_heap int emancipationUniformTextureDimensions; @@ -309,7 +309,7 @@ void drawEmancipationGrid(emancipationGrid_s* eg) textureBind(&gridSurfaceTexture, GPU_TEXUNIT0); GPU_SetFloatUniform(GPU_VERTEX_SHADER, emancipationUniformTextureDimensions, (u32*)(float[]){0.0f, 0.0f, 0.7f, l/8}, 1); - GPU_DrawArray(GPU_TRIANGLES, 12); + GPU_DrawArray(GPU_TRIANGLES, 0, 12); gsPopMatrix(); } diff --git a/source/game/player.c b/source/game/player.c index d53c605..901172c 100644 --- a/source/game/player.c +++ b/source/game/player.c @@ -14,8 +14,8 @@ texture_s crosshairTexture; DVLB_s* passthroughDvlb; shaderProgram_s passthroughProgram; -extern u32 __linear_heap; -#define rectangleBaseAddr __linear_heap +extern u32 __ctru_linear_heap; +#define rectangleBaseAddr __ctru_linear_heap float rectangleData[] = {1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f, @@ -240,14 +240,14 @@ void drawPlayerGun(player_s* p) gsSetShader(&passthroughProgram); - GPU_DrawArray(GPU_TRIANGLES, 6); + GPU_DrawArray(GPU_TRIANGLES, 0, 6); GPU_SetDepthTestAndWriteMask(true, GPU_ALWAYS, GPU_WRITE_ALL); - GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_CONFIG0, (u32)crosshairVertexData-rectangleBaseAddr); + GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_OFFSET, (u32)crosshairVertexData-rectangleBaseAddr); textureBind(&crosshairTexture, GPU_TEXUNIT0); - GPU_DrawArray(GPU_TRIANGLES, 6); + GPU_DrawArray(GPU_TRIANGLES, 0, 6); GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL); gsSwitchRenderMode(md2GsMode); diff --git a/source/game/portal.c b/source/game/portal.c index de8ddea..c773e8b 100644 --- a/source/game/portal.c +++ b/source/game/portal.c @@ -14,8 +14,8 @@ DVLB_s* portalDvlb; shaderProgram_s portalProgram; -extern u32 __linear_heap; -#define portalBaseAddr __linear_heap +extern u32 __ctru_linear_heap; +#define portalBaseAddr __ctru_linear_heap portal_s portals[NUM_PORTALS]; @@ -178,7 +178,7 @@ void GPU_SetScissorTest_(GPU_SCISSORMODE mode, u32 x, u32 y, u32 w, u32 h) param[0x1]=0x0000000F; param[0x2]=0x00000002; param[0x3]=0x00000002; - GPUCMD_AddIncrementalWrites(GPUREG_0112, param, 0x00000004); + GPUCMD_AddIncrementalWrites(GPUREG_COLORBUFFER_READ, param, 0x00000004); } void getPortalBoundingBox(portal_s* p, camera_s* c, vect3Di_s* topleft, vect3Di_s* bottomright, float* depth) @@ -282,7 +282,7 @@ void drawPortals(portal_s* portals[], int n, renderSceneCallback_t callback, cam gsUpdateTransformation(); - GPU_DrawArray(GPU_TRIANGLE_STRIP, portalNumVertices); + GPU_DrawArray(GPU_TRIANGLE_STRIP, 0, portalNumVertices); gsPopMatrix(); } @@ -295,10 +295,10 @@ void drawPortals(portal_s* portals[], int n, renderSceneCallback_t callback, cam 0xFFFFFFFF); GPU_SetFloatUniform(GPU_VERTEX_SHADER, colorUniformLoc, (u32*)(float[]){1.0f, 1.0f, 1.0f, 1.0f}, 1); - GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_CONFIG0, (u32)portalVertexData-portalBaseAddr); + GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_OFFSET, (u32)portalVertexData-portalBaseAddr); GPU_SetDepthTestAndWriteMask(true, GPU_GEQUAL, GPU_WRITE_COLOR); - GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_XOR); + GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_INVERT); for(i=0; iboolUniforms); GPU_SetDepthTestAndWriteMask(true, GPU_ALWAYS, GPU_WRITE_DEPTH); - GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP); + GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP); for(i=0; iindexBufferTextures[i], GPU_TEXUNIT0); textureBind(r->lightingData.data.lightMap.texture, GPU_TEXUNIT1); GPU_SetFloatUniform(GPU_VERTEX_SHADER, roomUniformTextureDimensions, (u32*)(float[]){0.0f, 0.0f, 1.0f / r->indexBufferTextures[i]->height, 1.0f / r->indexBufferTextures[i]->width}, 1); - GPU_DrawElements(GPU_UNKPRIM, (u32*)((u32)r->indexBuffers[i]-roomBaseAddr), r->numIndices[i]); + GPU_DrawElements(GPU_GEOMETRY_PRIM, (u32*)((u32)r->indexBuffers[i]-roomBaseAddr), r->numIndices[i]); } GPU_SetTextureEnable(GPU_TEXUNIT0); diff --git a/source/game/sludge.c b/source/game/sludge.c index 2154cfb..8fe2e30 100644 --- a/source/game/sludge.c +++ b/source/game/sludge.c @@ -99,8 +99,8 @@ int sludgeAnimationCounter=0; extern shaderProgram_s roomProgram; extern int roomUniformTextureDimensions; -extern u32 __linear_heap; -#define roomBaseAddr __linear_heap +extern u32 __ctru_linear_heap; +#define roomBaseAddr __ctru_linear_heap void drawSludge(room_s* r) { @@ -133,7 +133,7 @@ void drawSludge(room_s* r) textureBind(&sludgeTexture, GPU_TEXUNIT0); GPU_SetFloatUniform(GPU_VERTEX_SHADER, roomUniformTextureDimensions, (u32*)(float[]){0.0f, 0.0f, 1.0f / sludgeTexture.height, 1.0f / sludgeTexture.width}, 1); - GPU_DrawElements(GPU_UNKPRIM, (u32*)((u32)sludgeIndexBuffer-roomBaseAddr), sludgeNumIndices); + GPU_DrawElements(GPU_GEOMETRY_PRIM, (u32*)((u32)sludgeIndexBuffer-roomBaseAddr), sludgeNumIndices); gsPopMatrix(); } diff --git a/source/gfx/gs.c b/source/gfx/gs.c index 2a57018..998c29d 100644 --- a/source/gfx/gs.c +++ b/source/gfx/gs.c @@ -2,6 +2,7 @@ #include #include #include <3ds.h> +//#include <3ds/gpu/gx.h> #include "gfx/gs.h" #include "utils/math.h" @@ -517,7 +518,7 @@ int gsVboPrecomputeCommands(gsVbo_s* vbo) GPUCMD_SetBuffer(tmpBuffer, 128, 0); // GPU_DrawArrayDirectly(GPU_TRIANGLES, vbo->data, vbo->numVertices); - GPU_DrawArrayDirectly(GPU_UNKPRIM, vbo->data, vbo->numVertices); + GPU_DrawArrayDirectly(GPU_GEOMETRY_PRIM, vbo->data, vbo->numVertices); GPUCMD_GetBuffer(NULL, NULL, &vbo->commandsSize); vbo->commands=memalign(0x4, vbo->commandsSize*4); @@ -568,7 +569,7 @@ int gsVboDraw(gsVbo_s* vbo) } extern Handle gspEventThread; -extern Handle gspEvents[GSPEVENT_MAX]; +extern Handle gspEvents[GSPGPU_EVENT_MAX]; //stolen from blargsnes void gsSafeWait(Handle evt) @@ -609,47 +610,47 @@ void gsDrawFrame() {mtx44 m; loadIdentity44((float*)m); translateMatrix((float*)m, interaxial*0.5f, 0.0f, 0.0f); gsAdjustBufferMatrices(m);} //draw left framebuffer - GPUCMD_FlushAndRun(NULL); + GPUCMD_FlushAndRun(); //while GPU starts drawing the left buffer, adjust right one for 3D ! GPUCMD_SetBuffer(gsGpuCmdRight, gsGpuCmdSize, offset); {mtx44 m; loadIdentity44((float*)m); translateMatrix((float*)m, -interaxial*0.5f, 0.0f, 0.0f); gsAdjustBufferMatrices(m);} //we wait for the left buffer to finish drawing - gsSafeWait(gspEvents[GSPEVENT_P3D]); - GX_SetDisplayTransfer(NULL, (u32*)gsGpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019000F0, 0x00001000); - gsSafeWait(gspEvents[GSPEVENT_PPF]); + gsSafeWait(gspEvents[GSPGPU_EVENT_P3D]); + GX_DisplayTransfer((u32*)gsGpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019000F0, 0x00001000); + gsSafeWait(gspEvents[GSPGPU_EVENT_PPF]); //we draw the right buffer, wait for it to finish and then switch back to left one //clear the screen - GX_SetMemoryFill(NULL, (u32*)gsGpuOut, gsBackgroundColor, (u32*)&gsGpuOut[0x2EE00], 0x201, (u32*)gsGpuDOut, 0x00000000, (u32*)&gsGpuDOut[0x2EE00], 0x201); - gsSafeWait(gspEvents[GSPEVENT_PSC0]); + GX_MemoryFill((u32*)gsGpuOut, gsBackgroundColor, (u32*)&gsGpuOut[0x2EE00], 0x201, (u32*)gsGpuDOut, 0x00000000, (u32*)&gsGpuDOut[0x2EE00], 0x201); + gsSafeWait(gspEvents[GSPGPU_EVENT_PSC0]); //draw the right framebuffer - GPUCMD_FlushAndRun(NULL); - gsSafeWait(gspEvents[GSPEVENT_P3D]); + GPUCMD_FlushAndRun(); + gsSafeWait(gspEvents[GSPGPU_EVENT_P3D]); //transfer from GPU output buffer to actual framebuffer - GX_SetDisplayTransfer(NULL, (u32*)gsGpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), 0x019000F0, 0x00001000); - gsSafeWait(gspEvents[GSPEVENT_PPF]); + GX_DisplayTransfer((u32*)gsGpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), 0x019000F0, 0x00001000); + gsSafeWait(gspEvents[GSPGPU_EVENT_PPF]); GPUCMD_SetBuffer(gsGpuCmd, gsGpuCmdSize, 0); }else{ //boring old 2D ! //draw the frame - GPUCMD_FlushAndRun(NULL); - gsSafeWait(gspEvents[GSPEVENT_P3D]); + GPUCMD_FlushAndRun(); + gsSafeWait(gspEvents[GSPGPU_EVENT_P3D]); //transfer from GPU output buffer to actual framebuffer - GX_SetDisplayTransfer(NULL, (u32*)gsGpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019000F0, 0x00001000); - gsSafeWait(gspEvents[GSPEVENT_PPF]); + GX_DisplayTransfer((u32*)gsGpuOut, 0x019000F0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019000F0, 0x00001000); + gsSafeWait(gspEvents[GSPGPU_EVENT_PPF]); } gsDrawBottom(NULL, NULL); //clear the screen - GX_SetMemoryFill(NULL, (u32*)gsGpuOut, gsBackgroundColor, (u32*)&gsGpuOut[0x2EE00], 0x201, (u32*)gsGpuDOut, 0x00000000, (u32*)&gsGpuDOut[0x2EE00], 0x201); - gsSafeWait(gspEvents[GSPEVENT_PSC0]); + GX_MemoryFill((u32*)gsGpuOut, gsBackgroundColor, (u32*)&gsGpuOut[0x2EE00], 0x201, (u32*)gsGpuDOut, 0x00000000, (u32*)&gsGpuDOut[0x2EE00], 0x201); + gsSafeWait(gspEvents[GSPGPU_EVENT_PSC0]); gfxSwapBuffersGpu(); } diff --git a/source/gfx/md2.c b/source/gfx/md2.c index 0ef2465..1a5163d 100644 --- a/source/gfx/md2.c +++ b/source/gfx/md2.c @@ -41,8 +41,8 @@ u8 normalPermutation[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, DVLB_s* md2Dvlb; shaderProgram_s md2Program; -extern u32 __linear_heap; -#define md2BaseAddr __linear_heap +extern u32 __ctru_linear_heap; +#define md2BaseAddr __ctru_linear_heap int md2UniformScale0; int md2UniformTranslation0; @@ -324,11 +324,11 @@ void md2RenderFrame(md2_model_t *mdl, int n1, int n2, float interp, float alpha, textureBind(t, GPU_TEXUNIT0); - GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_CONFIG0, (u32)mdl->frames[n1].verts-md2BaseAddr); - GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER1_CONFIG0, (u32)mdl->frames[n2].verts-md2BaseAddr); - GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER2_CONFIG0, (u32)mdl->texcoords-md2BaseAddr); + GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_OFFSET, (u32)mdl->frames[n1].verts-md2BaseAddr); + GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER1_OFFSET, (u32)mdl->frames[n2].verts-md2BaseAddr); + GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER2_OFFSET, (u32)mdl->texcoords-md2BaseAddr); - GPU_DrawElements(GPU_UNKPRIM, (u32*)((u32)mdl->indices-md2BaseAddr), mdl->header.num_tris*3); + GPU_DrawElements(GPU_GEOMETRY_PRIM, (u32*)((u32)mdl->indices-md2BaseAddr), mdl->header.num_tris*3); } void md2InstanceInit(md2_instance_t* mi, md2_model_t* mdl, texture_s* t) diff --git a/source/gfx/text.c b/source/gfx/text.c index 26c86cc..bff3a9b 100644 --- a/source/gfx/text.c +++ b/source/gfx/text.c @@ -9,8 +9,8 @@ DVLB_s* textDvlb; shaderProgram_s textProgram; texture_s textTexture; -extern u32 __linear_heap; -#define textBaseAddr __linear_heap +extern u32 __ctru_linear_heap; +#define textBaseAddr __ctru_linear_heap int textUniformOffset; @@ -80,9 +80,9 @@ void textDrawString(float x, float y, const char* s) if(!s)return; if((u32)s < textBaseAddr)return; - GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_CONFIG0, (u32)s-textBaseAddr); + GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_OFFSET, (u32)s-textBaseAddr); GPU_SetFloatUniform(GPU_GEOMETRY_SHADER, textUniformOffset, (u32*)(float[]){1.0f, 0.0f, x, y}, 1); - GPU_DrawArray(GPU_UNKPRIM, strlen(s)); + GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, strlen(s)); } diff --git a/source/gfx/texture.c b/source/gfx/texture.c index c749d3d..5d825e2 100644 --- a/source/gfx/texture.c +++ b/source/gfx/texture.c @@ -252,7 +252,7 @@ void textureBind(texture_s* t, GPU_TEXUNIT unit) if(!t)return; GPU_SetTexture(unit, (u32*)osConvertVirtToPhys((u32)t->data), t->width, t->height, t->param, t->format); - GPUCMD_AddWrite(GPUREG_0084, t->mipmap<<16); + GPUCMD_AddWrite(GPUREG_TEXUNIT0_LOD, t->mipmap<<16); } void textureFree(texture_s* t) diff --git a/source/main.c b/source/main.c index 6863314..530a0a8 100644 --- a/source/main.c +++ b/source/main.c @@ -4,6 +4,7 @@ #include #include #include <3ds.h> +//#include <3ds/services/gsp.h> #include "gfx/gs.h" #include "gfx/text.h" @@ -104,12 +105,12 @@ void renderFrame(u32* outBuffer, u32* outDepthBuffer) GPU_DepthMap(-1.0f, 0.0f); GPU_SetFaceCulling(GPU_CULL_FRONT_CCW); GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00); - GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP); + GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP); GPU_SetBlendingColor(0,0,0,0); GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL); - GPUCMD_AddMaskedWrite(GPUREG_0062, 0x1, 0); - GPUCMD_AddWrite(GPUREG_0118, 0); + GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 0x1, 0); + GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, 0); GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00); @@ -344,7 +345,7 @@ bool gameFrame() gsDrawFrame(); - gspWaitForEvent(GSPEVENT_VBlank0, true); + gspWaitForEvent(GSPGPU_EVENT_VBlank0, true); return false; } @@ -378,7 +379,7 @@ int main(int argc, char** argv) gfxSet3D(true); aptOpenSession(); - APT_SetAppCpuTimeLimit(NULL, 30); + APT_SetAppCpuTimeLimit(30); aptCloseSession(); //init fs @@ -440,7 +441,7 @@ int main(int argc, char** argv) } aptOpenSession(); - APT_SetAppCpuTimeLimit(NULL, 0); + APT_SetAppCpuTimeLimit(0); aptCloseSession(); gfxExit(); diff --git a/source/menu/menu.c b/source/menu/menu.c index 88d6061..6ff281e 100644 --- a/source/menu/menu.c +++ b/source/menu/menu.c @@ -39,8 +39,8 @@ float logoangle; u32* logoRectangleVertexData = NULL; -extern u32 __linear_heap; -#define logoBaseAddr __linear_heap +extern u32 __ctru_linear_heap; +#define logoBaseAddr __ctru_linear_heap int logoUniformTextureDimensions; @@ -77,12 +77,12 @@ void renderMenuFrame(u32* outBuffer, u32* outDepthBuffer) GPU_DepthMap(-1.0f, 0.0f); GPU_SetFaceCulling(GPU_CULL_FRONT_CCW); GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00); - GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP); + GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP); GPU_SetBlendingColor(0,0,0,0); GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL); - GPUCMD_AddMaskedWrite(GPUREG_0062, 0x1, 0); - GPUCMD_AddWrite(GPUREG_0118, 0); + GPUCMD_AddMaskedWrite(GPUREG_EARLYDEPTH_TEST1, 0x1, 0); + GPUCMD_AddWrite(GPUREG_EARLYDEPTH_TEST2, 0); GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA); GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00); @@ -150,7 +150,7 @@ void renderMenuFrame(u32* outBuffer, u32* outDepthBuffer) textureBind(&rotateLogoTexture, GPU_TEXUNIT0); GPU_SetFloatUniform(GPU_VERTEX_SHADER, logoUniformTextureDimensions, (u32*)(float[]){0.0f, 0.0f, 1.0f, 1.0f}, 1); - GPU_DrawArray(GPU_TRIANGLES, 6); + GPU_DrawArray(GPU_TRIANGLES, 0, 6); gsPopMatrix(); gsPushMatrix(); @@ -163,7 +163,7 @@ void renderMenuFrame(u32* outBuffer, u32* outDepthBuffer) textureBind(&logoTexture, GPU_TEXUNIT0); GPU_SetFloatUniform(GPU_VERTEX_SHADER, logoUniformTextureDimensions, (u32*)(float[]){0.0f, 0.0f, 1.0f, 1.0f}, 1); - GPU_DrawArray(GPU_TRIANGLES, 6); + GPU_DrawArray(GPU_TRIANGLES, 0, 6); gsPopMatrix(); gsPopMatrix(); } @@ -359,7 +359,7 @@ bool menuFrame() gsDrawFrame(); - gspWaitForEvent(GSPEVENT_VBlank0, true); + gspWaitForEvent(GSPGPU_EVENT_VBlank0, true); return false; }