diff --git a/src/gu/Makefile.am b/src/gu/Makefile.am index 7e7b257ea8..c0cb0145c6 100644 --- a/src/gu/Makefile.am +++ b/src/gu/Makefile.am @@ -16,20 +16,99 @@ lib_LIBRARIES = libpspgu.a noinst_HEADERS = guInternal.h -libpspgu_a_SOURCES = callbackFin.c callbackSig.c guInternal.c resetValues.c sceGuAlphaFunc.c sceGuAmbient.c \ - sceGuAmbientColor.c sceGuBeginObject.c sceGuBlendFunc.c sceGuBoneMatrix.c sceGuBreak.c sceGuCallList.c \ - sceGuCallMode.c sceGuCheckList.c sceGuClear.c sceGuClearColor.c sceGuClearDepth.c sceGuClearStencil.c \ - sceGuClutLoad.c sceGuClutMode.c sceGuColor.c sceGuColorFunc.c sceGuColorMaterial.c sceGuContinue.c \ - sceGuCopyImage.c sceGuDepthBuffer.c sceGuDepthFunc.c sceGuDepthMask.c sceGuDepthOffset.c \ - sceGuDepthRange.c sceGuDisable.c sceGuDispBuffer.c sceGuDisplay.c sceGuDrawArray.c sceGuDrawArrayN.c \ - sceGuDrawBezier.c sceGuDrawBuffer.c sceGuDrawBufferList.c sceGuDrawSpline.c sceGuEnable.c sceGuEndObject.c \ - sceGuFinish.c sceGuFog.c sceGuFrontFace.c sceGuGetAllStatus.c sceGuGetMemory.c sceGuGetStatus.c sceGuInit.c \ - sceGuLight.c sceGuLightAtt.c sceGuLightColor.c sceGuLightMode.c sceGuLightSpot.c sceGuLogicalOp.c \ - sceGuMaterial.c sceGuModelColor.c sceGuMorphWeight.c sceGuOffset.c sceGuPatchDivide.c sceGuPatchFrontFace.c \ - sceGuPatchPrim.c sceGuPixelMask.c sceGuScissor.c sceGuSendCommandf.c sceGuSendCommandi.c sceGuSendList.c \ - sceGuSetAllStatus.c sceGuSetCallback.c sceGuSetDither.c sceGuSetMatrix.c sceGuSetStatus.c sceGuShadeModel.c \ - sceGuSignal.c sceGuSpecular.c sceGuStart.c sceGuStencilFunc.c sceGuStencilOp.c \ - sceGuSwapBuffers.c sceGuSync.c sceGuTerm.c sceGuTexEnvColor.c sceGuTexFilter.c sceGuTexFlush.c sceGuTexFunc.c \ - sceGuTexImage.c sceGuTexLevelMode.c sceGuTexMapMode.c sceGuTexMode.c sceGuTexOffset.c sceGuTexProjMapMode.c \ - sceGuTexScale.c sceGuTexSlope.c sceGuTexSync.c sceGuTexWrap.c sceGuViewport.c vram.c +libpspgu_a_SOURCES = \ + guInternal.c \ + resetValues.c \ + sceGuAlphaFunc.c \ + sceGuAmbient.c \ + sceGuAmbientColor.c \ + sceGuBeginObject.c \ + sceGuBlendFunc.c \ + sceGuBoneMatrix.c \ + sceGuBreak.c \ + sceGuCallList.c \ + sceGuCallMode.c \ + sceGuCheckList.c \ + sceGuClear.c \ + sceGuClearColor.c \ + sceGuClearDepth.c \ + sceGuClearStencil.c \ + sceGuClutLoad.c \ + sceGuClutMode.c \ + sceGuColor.c \ + sceGuColorFunc.c \ + sceGuColorMaterial.c \ + sceGuContinue.c \ + sceGuCopyImage.c \ + sceGuDepthBuffer.c \ + sceGuDepthFunc.c \ + sceGuDepthMask.c \ + sceGuDepthOffset.c \ + sceGuDepthRange.c \ + sceGuDisable.c \ + sceGuDispBuffer.c \ + sceGuDisplay.c \ + sceGuDrawArray.c \ + sceGuDrawArrayN.c \ + sceGuDrawBezier.c \ + sceGuDrawBuffer.c \ + sceGuDrawBufferList.c \ + sceGuDrawSpline.c \ + sceGuEnable.c \ + sceGuEndObject.c \ + sceGuFinish.c \ + sceGuFog.c \ + sceGuFrontFace.c \ + sceGuGetAllStatus.c \ + sceGuGetMemory.c \ + sceGuGetStatus.c \ + sceGuInit.c \ + sceGuLight.c \ + sceGuLightAtt.c \ + sceGuLightColor.c \ + sceGuLightMode.c \ + sceGuLightSpot.c \ + sceGuLogicalOp.c \ + sceGuMaterial.c \ + sceGuModelColor.c \ + sceGuMorphWeight.c \ + sceGuOffset.c \ + sceGuPatchDivide.c \ + sceGuPatchFrontFace.c \ + sceGuPatchPrim.c \ + sceGuPixelMask.c \ + sceGuScissor.c \ + sceGuSendCommandf.c \ + sceGuSendCommandi.c \ + sceGuSendList.c \ + sceGuSetAllStatus.c \ + sceGuSetCallback.c \ + sceGuSetDither.c \ + sceGuSetMatrix.c \ + sceGuSetStatus.c \ + sceGuShadeModel.c \ + sceGuSignal.c \ + sceGuSpecular.c \ + sceGuStart.c \ + sceGuStencilFunc.c \ + sceGuStencilOp.c \ + sceGuSwapBuffers.c \ + sceGuSync.c \ + sceGuTerm.c \ + sceGuTexEnvColor.c \ + sceGuTexFilter.c \ + sceGuTexFlush.c \ + sceGuTexFunc.c \ + sceGuTexImage.c \ + sceGuTexLevelMode.c \ + sceGuTexMapMode.c \ + sceGuTexMode.c \ + sceGuTexOffset.c \ + sceGuTexProjMapMode.c \ + sceGuTexScale.c \ + sceGuTexSlope.c \ + sceGuTexSync.c \ + sceGuTexWrap.c \ + sceGuViewport.c \ + vram.c diff --git a/src/gu/callbackFin.c b/src/gu/callbackFin.c deleted file mode 100644 index a9b459edde..0000000000 --- a/src/gu/callbackFin.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * PSP Software Development Kit - https://github.com/pspdev - * ----------------------------------------------------------------------- - * Licensed under the BSD license, see LICENSE in PSPSDK root for details. - * - * Copyright (c) 2005 Jesper Svennevid - */ - -#include "guInternal.h" - -void callbackFin(int id, void* arg) -{ - GuSettings* settings = (GuSettings*)arg; - if (settings->fin) - settings->fin(id & 0xffff); -} diff --git a/src/gu/callbackSig.c b/src/gu/callbackSig.c deleted file mode 100644 index 7864626fb5..0000000000 --- a/src/gu/callbackSig.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * PSP Software Development Kit - https://github.com/pspdev - * ----------------------------------------------------------------------- - * Licensed under the BSD license, see LICENSE in PSPSDK root for details. - * - * Copyright (c) 2005 Jesper Svennevid - */ - -#include "guInternal.h" - -#include - -void callbackSig(int id, void* arg) -{ - GuSettings* settings = (GuSettings*)arg; - - settings->signal_history[(settings->signal_offset++) & 15] = id & 0xffff; - - if (settings->sig) - settings->sig(id & 0xffff); - - sceKernelSetEventFlag(settings->kernel_event_flag,1); -} diff --git a/src/gu/sceGuDispBuffer.c b/src/gu/sceGuDispBuffer.c index 07a916c596..0436522e47 100644 --- a/src/gu/sceGuDispBuffer.c +++ b/src/gu/sceGuDispBuffer.c @@ -11,7 +11,7 @@ #include #include -void drawRegion(int x, int y, int width, int height) +static inline void drawRegion(int x, int y, int width, int height) { sendCommandi(REGION1, (y << 10) | x); sendCommandi(REGION2, (((y + height) - 1) << 10) | ((x + width) - 1)); diff --git a/src/gu/sceGuInit.c b/src/gu/sceGuInit.c index 80c5b8f674..46a428f8e0 100644 --- a/src/gu/sceGuInit.c +++ b/src/gu/sceGuInit.c @@ -235,6 +235,25 @@ static unsigned int __attribute__((aligned(16))) ge_init_list[] = ZV(END), }; +void callbackFin(int id, void* arg) +{ + GuSettings* settings = (GuSettings*)arg; + if (settings->fin) + settings->fin(id & 0xffff); +} + +void callbackSig(int id, void* arg) +{ + GuSettings* settings = (GuSettings*)arg; + + settings->signal_history[(settings->signal_offset++) & 15] = id & 0xffff; + + if (settings->sig) + settings->sig(id & 0xffff); + + sceKernelSetEventFlag(settings->kernel_event_flag,1); +} + void sceGuInit(void) { PspGeCallbackData callback; diff --git a/src/gu/sceGuTexImage.c b/src/gu/sceGuTexImage.c index 748c4bd10d..01a8ef3b52 100644 --- a/src/gu/sceGuTexImage.c +++ b/src/gu/sceGuTexImage.c @@ -8,19 +8,18 @@ #include "guInternal.h" -static int tbpcmd_tbl[8] = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7 }; // 0x30A18 -static int tbwcmd_tbl[8] = { 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf }; // 0x30A38 -static int tsizecmd_tbl[8] = { 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf }; // 0x30A58 - -int getExp(int val) +static inline int getExp(int val) { return 31 - __builtin_clz(val & 0x3FF); } -void sceGuTexImage(int mipmap, int width, int height, int tbw, const void* tbp) +void sceGuTexImage(int mipmap, int width, int height, int tbw, const void *tbp) { - sendCommandi(tbpcmd_tbl[mipmap],((unsigned int)tbp) & 0xffffff); - sendCommandi(tbwcmd_tbl[mipmap],((((unsigned int)tbp) >> 8) & 0x0f0000)|tbw); - sendCommandi(tsizecmd_tbl[mipmap],(getExp(height) << 8)|(getExp(width))); + GECommand texAddr = (GECommand)(TEX_ADDR0 + mipmap); + GECommand texBufWidth = (GECommand)(TEX_BUF_WIDTH0 + mipmap); + GECommand texSize = (GECommand)(TEX_SIZE0 + mipmap); + sendCommandi(texAddr, ((unsigned int)tbp) & 0xffffff); + sendCommandi(texBufWidth, ((((unsigned int)tbp) >> 8) & 0x0f0000) | tbw); + sendCommandi(texSize, (getExp(height) << 8) | (getExp(width))); sceGuTexFlush(); }