Skip to content

Commit

Permalink
Merge pull request #228 from fjtrujy/GUCleanUpMethods
Browse files Browse the repository at this point in the history
Clean up some methods
  • Loading branch information
fjtrujy authored Aug 18, 2024
2 parents 7519d6d + c75a9c8 commit 2e0804b
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 65 deletions.
111 changes: 95 additions & 16 deletions src/gu/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

16 changes: 0 additions & 16 deletions src/gu/callbackFin.c

This file was deleted.

23 changes: 0 additions & 23 deletions src/gu/callbackSig.c

This file was deleted.

2 changes: 1 addition & 1 deletion src/gu/sceGuDispBuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <pspkernel.h>
#include <pspdisplay.h>

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));
Expand Down
19 changes: 19 additions & 0 deletions src/gu/sceGuInit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 8 additions & 9 deletions src/gu/sceGuTexImage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 2e0804b

Please sign in to comment.