diff --git a/src/gu/Makefile.am b/src/gu/Makefile.am index c0cb0145c6..2144d1712e 100644 --- a/src/gu/Makefile.am +++ b/src/gu/Makefile.am @@ -14,101 +14,13 @@ libpspguinclude_HEADERS = pspgu.h lib_LIBRARIES = libpspgu.a -noinst_HEADERS = guInternal.h +noinst_HEADERS = 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/guInternal.c b/src/gu/guInternal.c index 597dc0a1b4..8d7d3bf11b 100644 --- a/src/gu/guInternal.c +++ b/src/gu/guInternal.c @@ -6,7 +6,7 @@ * Copyright (c) 2005 Jesper Svennevid */ -#include "guInternal.h" +#include unsigned int gu_current_frame; GuContext gu_contexts[3]; diff --git a/src/gu/guInternal.h b/src/gu/guInternal.h deleted file mode 100644 index 8c3b5eb2c8..0000000000 --- a/src/gu/guInternal.h +++ /dev/null @@ -1,656 +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 - */ - -#ifndef __guInternal_h__ -#define __guInternal_h__ - -#include "pspgu.h" - -typedef void (*GuCallback)(int); - -typedef struct -{ - GuCallback sig; - GuCallback fin; - short signal_history[16]; - int signal_offset; - int kernel_event_flag; - int ge_callback_id; - - GuSwapBuffersCallback swapBuffersCallback; - int swapBuffersBehaviour; -} GuSettings; - -typedef struct -{ - unsigned int *start; - unsigned int *current; - int parent_context; -} GuDisplayList; - -typedef struct -{ - GuDisplayList list; - int scissor_enable; - int scissor_start[2]; - int scissor_end[2]; - int near_plane; - int far_plane; - int depth_offset; - int fragment_2x; - int texture_function; - int texture_proj_map_mode; - int texture_map_mode; - int sprite_mode[4]; - unsigned int clear_color; - unsigned int clear_stencil; - unsigned int clear_depth; - int texture_mode; -} GuContext; - -typedef struct -{ - int pixel_size; - int frame_width; - void *frame_buffer; - void *disp_buffer; - void *depth_buffer; - int depth_width; - int width; - int height; -} GuDrawBuffer; - -typedef struct -{ - /* row 0 */ - - unsigned char enable; // Light enable - unsigned char type; // Light type - unsigned char xpos; // X position - unsigned char ypos; // Y position - - /* row 1 */ - - unsigned char zpos; // Z position - unsigned char xdir; // X direction - unsigned char ydir; // Y direction - unsigned char zdir; // Z direction - - /* row 2 */ - - unsigned char ambient; // Ambient color - unsigned char diffuse; // Diffuse color - unsigned char specular; // Specular color - unsigned char constant; // Constant attenuation - - /* row 3 */ - - unsigned char linear; // Linear attenuation - unsigned char quadratic; // Quadratic attenuation - unsigned char exponent; // Light exponent - unsigned char cutoff; // Light cutoff -} GuLightSettings; - -extern unsigned int gu_current_frame; -extern GuContext gu_contexts[3]; -extern int ge_list_executed[2]; -extern void *ge_edram_address; -extern GuSettings gu_settings; -extern GuDisplayList *gu_list; -extern int gu_curr_context; -extern int gu_init; -extern int gu_display_on; -extern int gu_call_mode; -extern int gu_states; -extern GuDrawBuffer gu_draw_buffer; - -extern unsigned int *gu_object_stack[]; -extern int gu_object_stack_depth; - -extern GuLightSettings light_settings[4]; - -void callbackSig(int id, void *arg); -void callbackFin(int id, void *arg); -void resetValues(); - -typedef enum GECommand -{ - /* No operation */ - NOP = 0x0, - /* Vertex data */ - VADDR = 0x1, - /* Index data */ - IADDR = 0x2, - /* Draw Primitive */ - PRIM = 0x4, - /* Draw Bezier surface */ - BEZIER = 0x5, - /* Draw Spline surface */ - SPLINE = 0x6, - /* Bounding Box */ - BOUNDING_BOX = 0x7, - /* Jump */ - JUMP = 0x8, - /* Conditional Jump */ - BJUMP = 0x9, - /* List Call */ - CALL = 0xa, - /* List Return */ - RET = 0xb, - /* End reading */ - END = 0xc, - /* Signal interrupt */ - SIGNAL = 0xe, - /* Finish drawing */ - FINISH = 0xf, - /* Address base */ - BASE = 0x10, - /* Vertex type */ - VERTEX_TYPE = 0x12, - /* Offset address */ - OFFSET_ADDR = 0x13, - /* Origin address */ - ORIGIN = 0x14, - /* Drawing region 1, origin */ - REGION1 = 0x15, - /* Drawing region 2, end */ - REGION2 = 0x16, - - /* Lighting enable */ - LIGHTING_ENABLE = 0x17, - /* Light 0 enable */ - LIGHT_ENABLE0 = 0x18, - /* Light 1 enable */ - LIGHT_ENABLE1 = 0x19, - /* Light 2 enable */ - LIGHT_ENABLE2 = 0x1a, - /* Light 3 enable */ - LIGHT_ENABLE3 = 0x1b, - /* Clipping enable */ - DEPTH_CLIP_ENABLE = 0x1c, - /* Culling enable */ - CULL_FACE_ENABLE = 0x1d, - /* Texture mapping enable */ - TEXTURE_ENABLE = 0x1e, - /* Fog enable */ - FOG_ENABLE = 0x1f, - /* Dithering enable */ - DITHER_ENABLE = 0x20, - /* Alpha blending enable */ - ALPHA_BLEND_ENABLE = 0x21, - /* Alpha testing enable */ - ALPHA_TEST_ENABLE = 0x22, - /* Z testing enable */ - Z_TEST_ENABLE = 0x23, - /* Stencil testing enable */ - STENCIL_TEST_ENABLE = 0x24, - /* Anti-aliasing enable */ - ANTI_ALIAS_ENABLE = 0x25, - /* Patch culling enable */ - PATCH_CULL_ENABLE = 0x26, - /* Color testing enable */ - COLOR_TEST_ENABLE = 0x27, - /* Logical operation enable */ - LOGIC_OP_ENABLE = 0x28, - - /* Bone matrix number */ - BONE_MATRIX_NUMBER = 0x2a, - /* Bone matrix data */ - BONE_MATRIX_DATA = 0x2b, - /* Morph weight 0 */ - MORPH_WEIGHT0 = 0x2c, - /* Morph weight 1 */ - MORPH_WEIGHT1 = 0x2d, - /* Morph weight 2 */ - MORPH_WEIGHT2 = 0x2e, - /* Morph weight 3 */ - MORPH_WEIGHT3 = 0x2f, - /* Morph weight 4 */ - MORPH_WEIGHT4 = 0x30, - /* Morph weight 5 */ - MORPH_WEIGHT5 = 0x31, - /* Morph weight 6 */ - MORPH_WEIGHT6 = 0x32, - /* Morph weight 7 */ - MORPH_WEIGHT7 = 0x33, - - /* Patch division count */ - PATCH_DIVISION = 0x36, - /* Patch primitive type */ - PATCH_PRIMITIVE = 0x37, - /* Patch facing */ - PATCH_FACING = 0x38, - /* World matrix number */ - WORLD_MATRIX_NUMBER = 0x3a, - /* World matrix data */ - WORLD_MATRIX_DATA = 0x3b, - /* View matrix number */ - VIEW_MATRIX_NUMBER = 0x3c, - /* View matrix data */ - VIEW_MATRIX_DATA = 0x3d, - /* Projection matrix number */ - PROJ_MATRIX_NUMBER = 0x3e, - /* Projection matrix data */ - PROJ_MATRIX_DATA = 0x3f, - /* Texture generation matrix number */ - TGEN_MATRIX_NUMBER = 0x40, - /* Texture generation matrix data */ - TGEN_MATRIX_DATA = 0x41, - - /* Viewport X scale */ - VIEWPORT_X_SCALE = 0x42, - /* Viewport Y scale */ - VIEWPORT_Y_SCALE = 0x43, - /* Viewport Z scale */ - VIEWPORT_Z_SCALE = 0x44, - /* Viewport X center */ - VIEWPORT_X_CENTER = 0x45, - /* Viewport Y center */ - VIEWPORT_Y_CENTER = 0x46, - /* Viewport Z center */ - VIEWPORT_Z_CENTER = 0x47, - /* Texture scale U */ - TEX_SCALE_U = 0x48, - /* Texture scale V */ - TEX_SCALE_V = 0x49, - /* Texture offset U */ - TEX_OFFSET_U = 0x4a, - /* Texture offset V */ - TEX_OFFSET_V = 0x4b, - /* Screen Offset X */ - OFFSET_X = 0x4c, - /* Screen Offset Y */ - OFFSET_Y = 0x4d, - - /* Shade mode */ - SHADE_MODE = 0x50, - /* Normal reverse */ - NORMAL_REVERSE = 0x51, - /* Material color */ - MATERIAL_COLOR = 0x53, - /* Material emissive */ - MATERIAL_EMISSIVE = 0x54, - /* Ambient color */ - AMBIENT_COLOR = 0x55, - /* Material diffuse */ - MATERIAL_DIFFUSE = 0x56, - /* Material specular */ - MATERIAL_SPECULAR = 0x57, - /* Ambient alpha */ - AMBIENT_ALPHA = 0x58, - /* Material specular coefficient */ - MATERIAL_SPECULAR_COEF = 0x5b, - /* Ambient light color */ - AMBIENT_LIGHT_COLOR = 0x5c, - /* Ambient light alpha */ - AMBIENT_LIGHT_ALPHA = 0x5d, - /* Light mode */ - LIGHT_MODE = 0x5e, - - /* Light type 0 */ - LIGHT_TYPE0 = 0x5f, - /* Light type 1 */ - LIGHT_TYPE1 = 0x60, - /* Light type 2 */ - LIGHT_TYPE2 = 0x61, - /* Light type 3 */ - LIGHT_TYPE3 = 0x62, - /* Light 0 X */ - LIGHT0_X = 0x63, - /* Light 0 Y */ - LIGHT0_Y = 0x64, - /* Light 0 Z */ - LIGHT0_Z = 0x65, - /* Light 1 X */ - LIGHT1_X = 0x66, - /* Light 1 Y */ - LIGHT1_Y = 0x67, - /* Light 1 Z */ - LIGHT1_Z = 0x68, - /* Light 2 X */ - LIGHT2_X = 0x69, - /* Light 2 Y */ - LIGHT2_Y = 0x6a, - /* Light 2 Z */ - LIGHT2_Z = 0x6b, - /* Light 3 X */ - LIGHT3_X = 0x6c, - /* Light 3 Y */ - LIGHT3_Y = 0x6d, - /* Light 3 Z */ - LIGHT3_Z = 0x6e, - - /* Light 0 direction X */ - LIGHT0_DIRECTION_X = 0x6f, - /* Light 0 direction Y */ - LIGHT0_DIRECTION_Y = 0x70, - /* Light 0 direction Z */ - LIGHT0_DIRECTION_Z = 0x71, - /* Light 1 direction X */ - LIGHT1_DIRECTION_X = 0x72, - /* Light 1 direction Y */ - LIGHT1_DIRECTION_Y = 0x73, - /* Light 1 direction Z */ - LIGHT1_DIRECTION_Z = 0x74, - /* Light 2 direction X */ - LIGHT2_DIRECTION_X = 0x75, - /* Light 2 direction Y */ - LIGHT2_DIRECTION_Y = 0x76, - /* Light 2 direction Z */ - LIGHT2_DIRECTION_Z = 0x77, - /* Light 3 direction X */ - LIGHT3_DIRECTION_X = 0x78, - /* Light 3 direction Y */ - LIGHT3_DIRECTION_Y = 0x79, - /* Light 3 direction Z */ - LIGHT3_DIRECTION_Z = 0x7a, - - /* Light 0 constant attenuation */ - LIGHT0_CONSTANT_ATTEN = 0x7b, - /* Light 0 linear attenuation */ - LIGHT0_LINEAR_ATTEN = 0x7c, - /* Light 0 quadratic attenuation */ - LIGHT0_QUADRATIC_ATTEN = 0x7d, - /* Light 1 constant attenuation */ - LIGHT1_CONSTANT_ATTEN = 0x7e, - /* Light 1 linear attenuation */ - LIGHT1_LINEAR_ATTEN = 0x7f, - /* Light 1 quadratic attenuation */ - LIGHT1_QUADRATIC_ATTEN = 0x80, - /* Light 2 constant attenuation */ - LIGHT2_CONSTANT_ATTEN = 0x81, - /* Light 2 linear attenuation */ - LIGHT2_LINEAR_ATTEN = 0x82, - /* Light 2 quadratic attenuation */ - LIGHT2_QUADRATIC_ATTEN = 0x83, - /* Light 3 constant attenuation */ - LIGHT3_CONSTANT_ATTEN = 0x84, - /* Light 3 linear attenuation */ - LIGHT3_LINEAR_ATTEN = 0x85, - /* Light 3 quadratic attenuation */ - LIGHT3_QUADRATIC_ATTEN = 0x86, - - /* Light 0 exponent attenuation */ - LIGHT0_EXPONENT_ATTEN = 0x87, - /* Light 1 exponent attenuation */ - LIGHT1_EXPONENT_ATTEN = 0x88, - /* Light 2 exponent attenuation */ - LIGHT2_EXPONENT_ATTEN = 0x89, - /* Light 3 exponent attenuation */ - LIGHT3_EXPONENT_ATTEN = 0x8a, - - /* Light 0 cutoff attenuation */ - LIGHT0_CUTOFF_ATTEN = 0x8b, - /* Light 1 cutoff attenuation */ - LIGHT1_CUTOFF_ATTEN = 0x8c, - /* Light 2 cutoff attenuation */ - LIGHT2_CUTOFF_ATTEN = 0x8d, - /* Light 3 cutoff attenuation */ - LIGHT3_CUTOFF_ATTEN = 0x8e, - - /* Light 0 ambient */ - LIGHT0_AMBIENT = 0x8f, - /* Light 0 diffuse */ - LIGHT0_DIFFUSE = 0x90, - /* Light 0 specular */ - LIGHT0_SPECULAR = 0x91, - /* Light 1 ambient */ - LIGHT1_AMBIENT = 0x92, - /* Light 1 diffuse */ - LIGHT1_DIFFUSE = 0x93, - /* Light 1 specular */ - LIGHT1_SPECULAR = 0x94, - /* Light 2 ambient */ - LIGHT2_AMBIENT = 0x95, - /* Light 2 diffuse */ - LIGHT2_DIFFUSE = 0x96, - /* Light 2 specular */ - LIGHT2_SPECULAR = 0x97, - /* Light 3 ambient */ - LIGHT3_AMBIENT = 0x98, - /* Light 3 diffuse */ - LIGHT3_DIFFUSE = 0x99, - /* Light 3 specular */ - LIGHT3_SPECULAR = 0x9a, - - /* Culling */ - CULL = 0x9b, - - /* Frame buffer pointer */ - FRAME_BUF_PTR = 0x9c, - /* Frame buffer width */ - FRAME_BUF_WIDTH = 0x9d, - /* Z buffer pointer */ - Z_BUF_PTR = 0x9e, - /* Z buffer width */ - Z_BUF_WIDTH = 0x9f, - - /* Texture address 0 */ - TEX_ADDR0 = 0xa0, - /* Texture address 1 */ - TEX_ADDR1 = 0xa1, - /* Texture address 2 */ - TEX_ADDR2 = 0xa2, - /* Texture address 3 */ - TEX_ADDR3 = 0xa3, - /* Texture address 4 */ - TEX_ADDR4 = 0xa4, - /* Texture address 5 */ - TEX_ADDR5 = 0xa5, - /* Texture address 6 */ - TEX_ADDR6 = 0xa6, - /* Texture address 7 */ - TEX_ADDR7 = 0xa7, - /* Texture buffer width 0 */ - TEX_BUF_WIDTH0 = 0xa8, - /* Texture buffer width 1 */ - TEX_BUF_WIDTH1 = 0xa9, - /* Texture buffer width 2 */ - TEX_BUF_WIDTH2 = 0xaa, - /* Texture buffer width 3 */ - TEX_BUF_WIDTH3 = 0xab, - /* Texture buffer width 4 */ - TEX_BUF_WIDTH4 = 0xac, - /* Texture buffer width 5 */ - TEX_BUF_WIDTH5 = 0xad, - /* Texture buffer width 6 */ - TEX_BUF_WIDTH6 = 0xae, - /* Texture buffer width 7 */ - TEX_BUF_WIDTH7 = 0xaf, - - /* CLUT buffer pointer */ - CLUT_BUF_PTR = 0xb0, - /* CLUT buffer width */ - CLUT_BUF_WIDTH = 0xb1, - - /* Transfer source */ - TRANSFER_SRC = 0xb2, - /* Transfer source width */ - TRANSFER_SRC_W = 0xb3, - /* Transfer destination */ - TRANSFER_DST = 0xb4, - /* Transfer destination width */ - TRANSFER_DST_W = 0xb5, - - /* Texture size 0 */ - TEX_SIZE0 = 0xb8, - /* Texture size 1 */ - TEX_SIZE1 = 0xb9, - /* Texture size 2 */ - TEX_SIZE2 = 0xba, - /* Texture size 3 */ - TEX_SIZE3 = 0xbb, - /* Texture size 4 */ - TEX_SIZE4 = 0xbc, - /* Texture size 5 */ - TEX_SIZE5 = 0xbd, - /* Texture size 6 */ - TEX_SIZE6 = 0xbe, - /* Texture size 7 */ - TEX_SIZE7 = 0xbf, - - /* Texture map mode */ - TEX_MAP_MODE = 0xc0, - /* Texture shade mapping */ - TEX_SHADE_MAPPING = 0xc1, - /* Texture mode */ - TEX_MODE = 0xc2, - /* Texture format */ - TEX_FORMAT = 0xc3, - /* Load CLUT */ - CLUT_LOAD = 0xc4, - /* CLUT format */ - CLUT_FORMAT = 0xc5, - /* Texture filter */ - TEX_FILTER = 0xc6, - /* Texture wrap */ - TEX_WRAP = 0xc7, - /* Texture level */ - TEX_LEVEL = 0xc8, - /* Texture function */ - TEX_FUNC = 0xc9, - /* Texture environment color */ - TEX_ENV_COLOR = 0xca, - /* Texture flush */ - TEX_FLUSH = 0xcb, - /* Texture sync */ - TEX_SYNC = 0xcc, - - /* Fog 1 */ - FOG1 = 0xcd, - /* Fog 2 */ - FOG2 = 0xce, - /* Fog color */ - FOG_COLOR = 0xcf, - /* Texture LOD slope */ - TEX_LOD_SLOPE = 0xd0, - - /* Frame buffer pixel format */ - FRAMEBUF_PIX_FORMAT = 0xd2, - /* Clear mode */ - CLEAR_MODE = 0xd3, - /* Scissor 1 */ - SCISSOR1 = 0xd4, - /* Scissor 2 */ - SCISSOR2 = 0xd5, - - /* Minimum Z */ - MIN_Z = 0xd6, - /* Maximum Z */ - MAX_Z = 0xd7, - /* Color test */ - COLOR_TEST = 0xd8, - /* Color reference */ - COLOR_REF = 0xd9, - /* Color test mask */ - COLOR_TESTMASK = 0xda, - /* Alpha test */ - ALPHA_TEST = 0xdb, - /* Stencil test */ - STENCIL_TEST = 0xdc, - /* Stencil operation */ - STENCIL_OP = 0xdd, - /* Z test */ - Z_TEST = 0xde, - /* Blend mode */ - BLEND_MODE = 0xdf, - /* Blend fixed A */ - BLEND_FIXED_A = 0xe0, - /* Blend fixed B */ - BLEND_FIXED_B = 0xe1, - /* Dither 0 */ - DITH0 = 0xe2, - /* Dither 1 */ - DITH1 = 0xe3, - /* Dither 2 */ - DITH2 = 0xe4, - /* Dither 3 */ - DITH3 = 0xe5, - - /* Logical operation */ - LOGIC_OP = 0xe6, - /* Z mask */ - Z_MASK = 0xe7, - /* Mask color */ - MASK_COLOR = 0xe8, - /* Mask alpha */ - MASK_ALPHA = 0xe9, - - /* Transfer start */ - TRANSFER_START = 0xea, - /* Transfer source offset */ - TRANSFER_SRC_OFFSET = 0xeb, - /* Transfer destination offset */ - TRANSFER_DST_OFFSET = 0xec, - /* Transfer format */ - TRANSFER_FORMAT = 0xed, - /* Transfer size */ - TRANSFER_SIZE = 0xee, - - /* Transfer flip */ - TRANSFER_FLIP = 0xef, - /* Transfer out size */ - TRANSFER_OUT_SIZE = 0xf0, - /* Transfer out format */ - TRANSFER_OUT_FORMAT = 0xf1, - /* Vertex weight */ - VERTEX_WEIGHT = 0xf2, - /* Vertex weight address */ - VERTEX_WEIGHT_ADDR = 0xf3, - /* Vertex weight size */ - VERTEX_WEIGHT_SIZE = 0xf4, - /* Vertex weight type */ - VERTEX_WEIGHT_TYPE = 0xf5, - /* Vertex weight model */ - VERTEX_WEIGHT_MODEL = 0xf6, - /* Vertex weight normalize */ - VERTEX_WEIGHT_NORMALIZE = 0xf7, - /* Vertex weight offset */ - VERTEX_WEIGHT_OFFSET = 0xf8, - /* Vertex weight scale */ - VERTEX_WEIGHT_SCALE = 0xf9, - /* Vertex weight matrix */ - VERTEX_WEIGHT_MATRIX = 0xfa, - /* Vertex weight matrix address */ - VERTEX_WEIGHT_MATRIX_ADDR = 0xfb, - /* Vertex weight matrix size */ - VERTEX_WEIGHT_MATRIX_SIZE = 0xfc, - /* Vertex weight matrix type */ - VERTEX_WEIGHT_MATRIX_TYPE = 0xfd, - /* Vertex weight matrix model */ - VERTEX_WEIGHT_MATRIX_MODEL = 0xfe, - /* Vertex weight matrix normalize */ - VERTEX_WEIGHT_MATRIX_NORMALIZE = 0xff, -} GECommand; - -static inline void sendCommandi(GECommand cmd, int argument) -{ - *(gu_list->current++) = (cmd << 24) | (argument & 0xffffff); -} - -static inline void sendCommandf(GECommand cmd, float argument) -{ - union - { - float f; - unsigned int i; - } t; - t.f = argument; - - sendCommandi(cmd, t.i >> 8); -} - -static inline void sendCommandiStall(GECommand cmd, int argument) -{ - sendCommandi(cmd, argument); - - if (!gu_object_stack_depth && !gu_curr_context) - sceGeListUpdateStallAddr(ge_list_executed[0], gu_list->current); -} - -#endif diff --git a/src/gu/pspgu.h b/src/gu/pspgu.h index 637af41a3b..ad5ee3bc53 100644 --- a/src/gu/pspgu.h +++ b/src/gu/pspgu.h @@ -11,6 +11,8 @@ #include #include +#include +#include /** @defgroup GU Graphics Utility Library * @@ -313,7 +315,7 @@ typedef void (*GuSwapBuffersCallback)(void** display,void** render); * @param zbw - The width of the depth-buffer (block-aligned) * **/ -void sceGuDepthBuffer(void* zbp, int zbw); +static inline void sceGuDepthBuffer(void *zbp, int zbw); /** * Set display buffer parameters @@ -329,7 +331,7 @@ void sceGuDepthBuffer(void* zbp, int zbw); * @param dispbw - Display buffer width (block aligned) * **/ -void sceGuDispBuffer(int width, int height, void* dispbp, int dispbw); +static inline void sceGuDispBuffer(int width, int height, void *dispbp, int dispbw); /** * Set draw buffer parameters (and store in context for buffer-swap) @@ -349,7 +351,7 @@ void sceGuDispBuffer(int width, int height, void* dispbp, int dispbw); * @param fbp - VRAM pointer to where the draw buffer starts * @param fbw - Frame buffer width (block aligned) **/ -void sceGuDrawBuffer(int psm, void* fbp, int fbw); +static inline void sceGuDrawBuffer(int psm, void *fbp, int fbw); /** * Set draw buffer directly, not storing parameters in the context @@ -358,7 +360,7 @@ void sceGuDrawBuffer(int psm, void* fbp, int fbw); * @param fbp - VRAM pointer to where the draw buffer starts * @param fbw - Frame buffer width (block aligned) **/ -void sceGuDrawBufferList(int psm, void* fbp, int fbw); +static inline void sceGuDrawBufferList(int psm, void *fbp, int fbw); /** * Turn display on or off @@ -370,7 +372,7 @@ void sceGuDrawBufferList(int psm, void* fbp, int fbw); * @param state - Turn display on or off * @return State of the display prior to this call **/ -int sceGuDisplay(int state); +static inline int sceGuDisplay(int state); /** * Select which depth-test function to use @@ -387,16 +389,16 @@ int sceGuDisplay(int state); * * @param function - Depth test function to use **/ -void sceGuDepthFunc(int function); +static inline void sceGuDepthFunc(int function); /** * Mask depth buffer writes * * @param mask - GU_TRUE(1) to disable Z writes, GU_FALSE(0) to enable **/ -void sceGuDepthMask(int mask); +static inline void sceGuDepthMask(int mask); -void sceGuDepthOffset(unsigned int offset); +static inline void sceGuDepthOffset(unsigned int offset); /** * Set which range to use for depth calculations. @@ -411,9 +413,9 @@ void sceGuDepthOffset(unsigned int offset); * @param near - Value to use for the near plane * @param far - Value to use for the far plane **/ -void sceGuDepthRange(int near, int far); +static inline void sceGuDepthRange(int near, int far); -void sceGuFog(float near, float far, unsigned int color); +static inline void sceGuFog(float near, float far, unsigned int color); /** * Initalize the GU system @@ -429,9 +431,10 @@ void sceGuInit(void); **/ void sceGuTerm(void); -void sceGuBreak(int a0); -void sceGuContinue(void); +static inline void sceGuBreak(int a0); +static inline void sceGuContinue(void); +typedef void (*GuCallback)(int); /** * Setup signal handler * @@ -443,7 +446,7 @@ void sceGuContinue(void); * @param callback - Callback to call when signal index is triggered * @return The old callback handler **/ -void* sceGuSetCallback(int signal, void (*callback)(int)); +static inline GuCallback sceGuSetCallback(int signal, void (*callback)(int)); /** * Trigger signal to call code from the command stream @@ -455,7 +458,7 @@ void* sceGuSetCallback(int signal, void (*callback)(int)); * @param signal - Signal to trigger * @param behavior - Behavior type **/ -void sceGuSignal(int signal, int behavior); +static inline void sceGuSignal(int signal, int behavior); /** * Send raw float-command to the GE @@ -465,7 +468,7 @@ void sceGuSignal(int signal, int behavior); * @param cmd - Which command to send * @param argument - Argument to pass along **/ -void sceGuSendCommandf(int cmd, float argument); +static inline void sceGuSendCommandf(int cmd, float argument); /** * Send raw command to the GE @@ -475,7 +478,7 @@ void sceGuSendCommandf(int cmd, float argument); * @param cmd - Which command to send * @param argument - Argument to pass along **/ -void sceGuSendCommandi(int cmd, int argument); +static inline void sceGuSendCommandi(int cmd, int argument); /** * Allocate memory on the current display list for temporary storage @@ -487,7 +490,7 @@ void sceGuSendCommandi(int cmd, int argument); * @param size - How much memory to allocate * @return Memory-block ready for use **/ -void* sceGuGetMemory(int size); +void *sceGuGetMemory(int size); /** * Start filling a new display-context @@ -502,7 +505,7 @@ void* sceGuGetMemory(int size); * @param cid - Context Type * @param list - Pointer to display-list (16 byte aligned) **/ -void sceGuStart(int cid, void* list); +void sceGuStart(int cid, void *list); /** * Finish current display list and go back to the parent context @@ -517,7 +520,7 @@ void sceGuStart(int cid, void* list); * * @return Size of finished display list **/ -int sceGuFinish(void); +static inline int sceGuFinish(void); /** * Finish current display list and go back to the parent context, sending argument id for @@ -530,14 +533,14 @@ int sceGuFinish(void); * @param id - Finish callback id (16-bit) * @return Size of finished display list **/ -int sceGuFinishId(unsigned int id); +static inline int sceGuFinishId(unsigned int id); /** * Call previously generated display-list * * @param list - Display list to call **/ -void sceGuCallList(const void* list); +static inline void sceGuCallList(const void *list); /** * Set wether to use stack-based calls or signals to handle execution of called lists. @@ -545,14 +548,14 @@ void sceGuCallList(const void* list); * @param mode - GU_TRUE(1) to enable signals, GU_FALSE(0) to disable signals and use * normal calls instead. **/ -void sceGuCallMode(int mode); +static inline void sceGuCallMode(int mode); /** * Check how large the current display-list is * * @return The size of the current display list **/ -int sceGuCheckList(void); +static inline int sceGuCheckList(void); /** * Send a list to the GE directly @@ -566,14 +569,14 @@ int sceGuCheckList(void); * @param context - Temporary storage for the GE context * @return 0 for success, < 0 for failure **/ -int sceGuSendList(int mode, const void* list, PspGeContext* context); +static inline int sceGuSendList(int mode, const void *list, PspGeContext *context); /** * Swap display and draw buffer * * @return Pointer to the new drawbuffer **/ -void* sceGuSwapBuffers(void); +static inline void *sceGuSwapBuffers(void); /** * Wait until display list has finished executing @@ -601,7 +604,7 @@ void* sceGuSwapBuffers(void); * @param what - What to sync to * @return Unknown at this time **/ -int sceGuSync(int mode, int what); +static inline int sceGuSync(int mode, int what); /** * Draw array of vertices forming primitives @@ -692,7 +695,7 @@ int sceGuSync(int mode, int what); * @param indices - Optional pointer to an index-list * @param vertices - Pointer to a vertex-list **/ -void sceGuDrawArray(int prim, int vtype, int count, const void* indices, const void* vertices); +static inline void sceGuDrawArray(int prim, int vtype, int count, const void *indices, const void *vertices); /** * Begin conditional rendering of object @@ -713,12 +716,12 @@ void sceGuDrawArray(int prim, int vtype, int count, const void* indices, const v * @param indices - Optional list to an index-list * @param vertices - Pointer to a vertex-list **/ -void sceGuBeginObject(int vtype, int count, const void* indices, const void* vertices); +static inline void sceGuBeginObject(int vtype, int count, const void *indices, const void *vertices); /** * End conditional rendering of object **/ -void sceGuEndObject(void); +static inline void sceGuEndObject(void); /** * Enable or disable GE state @@ -728,7 +731,7 @@ void sceGuEndObject(void); * @param state - Which state to change * @param status - Wether to enable or disable the state **/ -void sceGuSetStatus(int state, int status); +static inline void sceGuSetStatus(int state, int status); /** * Get if state is currently enabled or disabled @@ -738,7 +741,7 @@ void sceGuSetStatus(int state, int status); * @param state - Which state to query about * @return Wether state is enabled or not **/ -int sceGuGetStatus(int state); +static inline int sceGuGetStatus(int state); /** * Set the status on all 22 available states @@ -747,7 +750,7 @@ int sceGuGetStatus(int state); * * @param status - Bit-mask (0-21) containing the status of all 22 states **/ -void sceGuSetAllStatus(int status); +static inline void sceGuSetAllStatus(int status); /** * Query status on all 22 available states @@ -756,7 +759,7 @@ void sceGuSetAllStatus(int status); * * @return Status of all 22 states as a bitmask (0-21) **/ -int sceGuGetAllStatus(void); +static inline int sceGuGetAllStatus(void); /** * Enable GE state @@ -779,7 +782,7 @@ int sceGuGetAllStatus(void); * * @param state - Which state to enable **/ -void sceGuEnable(int state); +static inline void sceGuEnable(int state); /** * Disable GE state @@ -788,7 +791,7 @@ void sceGuEnable(int state); * * @param state - Which state to disable **/ -void sceGuDisable(int state); +static inline void sceGuDisable(int state); /** * Set light parameters @@ -808,7 +811,7 @@ void sceGuDisable(int state); * @param components - Light components * @param position - Light position **/ -void sceGuLight(int light, int type, int components, const ScePspFVector3* position); +static inline void sceGuLight(int light, int type, int components, const ScePspFVector3 *position); /** * Set light attenuation @@ -818,7 +821,7 @@ void sceGuLight(int light, int type, int components, const ScePspFVector3* posit * @param atten1 - Linear attenuation factor * @param atten2 - Quadratic attenuation factor **/ -void sceGuLightAtt(int light, float atten0, float atten1, float atten2); +static inline void sceGuLightAtt(int light, float atten0, float atten1, float atten2); /** * Set light color @@ -834,7 +837,7 @@ void sceGuLightAtt(int light, float atten0, float atten1, float atten2); * @param component - Which component to set * @param color - Which color to use **/ -void sceGuLightColor(int light, int component, unsigned int color); +static inline void sceGuLightColor(int light, int component, unsigned int color); /** * Set light mode @@ -848,7 +851,7 @@ void sceGuLightColor(int light, int component, unsigned int color); * * @param mode - Light mode to use **/ -void sceGuLightMode(int mode); +static inline void sceGuLightMode(int mode); /** * Set spotlight parameters @@ -858,7 +861,7 @@ void sceGuLightMode(int mode); * @param exponent - Spotlight exponent * @param cutoff - Spotlight cutoff angle (in radians) **/ -void sceGuLightSpot(int light, const ScePspFVector3* direction, float exponent, float cutoff); +static inline void sceGuLightSpot(int light, const ScePspFVector3 *direction, float exponent, float cutoff); /** * Clear current drawbuffer @@ -870,21 +873,21 @@ void sceGuLightSpot(int light, const ScePspFVector3* direction, float exponent, * * @param flags - Which part of the buffer to clear **/ -void sceGuClear(int flags); +static inline void sceGuClear(int flags); /** * Set the current clear-color * * @param color - Color to clear with **/ -void sceGuClearColor(unsigned int color); +static inline void sceGuClearColor(unsigned int color); /** * Set the current clear-depth * * @param depth - Set which depth to clear with (0x0000-0xffff) **/ -void sceGuClearDepth(unsigned int depth); +static inline void sceGuClearDepth(unsigned int depth); /** * Set the current stencil clear value @@ -892,7 +895,7 @@ void sceGuClearDepth(unsigned int depth); * @param stencil - Set which stencil value to clear with (0-255) * **/ -void sceGuClearStencil(unsigned int stencil); +static inline void sceGuClearStencil(unsigned int stencil); /** * Set mask for which bits of the pixels to write @@ -900,14 +903,14 @@ void sceGuClearStencil(unsigned int stencil); * @param mask - Which bits to filter against writes * **/ -void sceGuPixelMask(unsigned int mask); +static inline void sceGuPixelMask(unsigned int mask); /** * Set current primitive color * * @param color - Which color to use (overriden by vertex-colors) **/ -void sceGuColor(unsigned int color); +static inline void sceGuColor(unsigned int color); /** * Set the color test function @@ -929,7 +932,7 @@ void sceGuColor(unsigned int color); * @param color - Color to test against * @param mask - Mask ANDed against both source and destination when testing **/ -void sceGuColorFunc(int func, unsigned int color, unsigned int mask); +static inline void sceGuColorFunc(int func, unsigned int color, unsigned int mask); /** * Set which color components that the material will receive @@ -941,7 +944,7 @@ void sceGuColorFunc(int func, unsigned int color, unsigned int mask); * * @param components - Which components to receive **/ -void sceGuColorMaterial(int components); +static inline void sceGuColorMaterial(int components); /** * Set the alpha test parameters @@ -960,10 +963,10 @@ void sceGuColorMaterial(int components); * @param value - Specifies the reference value that incoming alpha values are compared to. * @param mask - Specifies the mask that both values are ANDed with before comparison. **/ -void sceGuAlphaFunc(int func, int value, int mask); +static inline void sceGuAlphaFunc(int func, int value, int mask); -void sceGuAmbient(unsigned int color); -void sceGuAmbientColor(unsigned int color); +static inline void sceGuAmbient(unsigned int color); +static inline void sceGuAmbientColor(unsigned int color); /** * Set the blending-mode @@ -999,14 +1002,14 @@ void sceGuAmbientColor(unsigned int color); * @param srcfix - Fix value for GU_FIX (source operand) * @param destfix - Fix value for GU_FIX (dest operand) **/ -void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix); +static inline void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix); -void sceGuMaterial(int mode, int color); +static inline void sceGuMaterial(int mode, int color); /** * **/ -void sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int diffuse, unsigned int specular); +static inline void sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int diffuse, unsigned int specular); /** * Set stencil function and reference value for stencil testing @@ -1025,7 +1028,7 @@ void sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int d * @param ref - The reference value for the stencil test * @param mask - Mask that is ANDed with both the reference value and stored stencil value when the test is done **/ -void sceGuStencilFunc(int func, int ref, int mask); +static inline void sceGuStencilFunc(int func, int ref, int mask); /** * Set the stencil test actions @@ -1045,7 +1048,7 @@ void sceGuStencilFunc(int func, int ref, int mask); * @param zfail - The action to take when stencil test passes, but the depth test fails * @param zpass - The action to take when both stencil test and depth test passes **/ -void sceGuStencilOp(int fail, int zfail, int zpass); +static inline void sceGuStencilOp(int fail, int zfail, int zpass); /** * Set the specular power for the material @@ -1053,7 +1056,7 @@ void sceGuStencilOp(int fail, int zfail, int zpass); * @param power - Specular power * **/ -void sceGuSpecular(float power); +static inline void sceGuSpecular(float power); /** * Set the current face-order (for culling) @@ -1066,7 +1069,7 @@ void sceGuSpecular(float power); * * @param order - Which order to use **/ -void sceGuFrontFace(int order); +static inline void sceGuFrontFace(int order); /** * Set color logical operation @@ -1093,7 +1096,7 @@ void sceGuFrontFace(int order); * * @param op - Operation to execute **/ -void sceGuLogicalOp(int op); +static inline void sceGuLogicalOp(int op); /** * Set ordered pixel dither matrix @@ -1102,7 +1105,7 @@ void sceGuLogicalOp(int op); * * @param matrix - Dither matrix **/ -void sceGuSetDither(const ScePspIMatrix4* matrix); +static inline void sceGuSetDither(const ScePspIMatrix4 *matrix); /** * Set how primitives are shaded @@ -1113,7 +1116,7 @@ void sceGuSetDither(const ScePspIMatrix4* matrix); * * @param mode - Which mode to use **/ -void sceGuShadeModel(int mode); +static inline void sceGuShadeModel(int mode); /** * Image transfer using the GE @@ -1137,7 +1140,7 @@ void sceGuShadeModel(int mode); * @param destw - Destination buffer width (block aligned) * @param dest - Destination pointer **/ -void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void* src, int dx, int dy, int destw, void* dest); +static inline void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void *src, int dx, int dy, int destw, void *dest); /** * Specify the texture environment color @@ -1148,7 +1151,7 @@ void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, vo * * @param color - Constant color (0x00BBGGRR) **/ -void sceGuTexEnvColor(unsigned int color); +static inline void sceGuTexEnvColor(unsigned int color); /** * Set how the texture is filtered @@ -1164,7 +1167,7 @@ void sceGuTexEnvColor(unsigned int color); * @param min - Minimizing filter * @param mag - Magnifying filter **/ -void sceGuTexFilter(int min, int mag); +static inline void sceGuTexFilter(int min, int mag); /** * Flush texture page-cache @@ -1172,7 +1175,7 @@ void sceGuTexFilter(int min, int mag); * Do this if you have copied/rendered into an area currently in the texture-cache * **/ -void sceGuTexFlush(void); +static inline void sceGuTexFlush(void); /** * Set how textures are applied @@ -1204,7 +1207,7 @@ void sceGuTexFlush(void); * @param tfx - Which apply-mode to use * @param tcc - Which component-mode to use **/ -void sceGuTexFunc(int tfx, int tcc); +static inline void sceGuTexFunc(int tfx, int tcc); /** * Set current texturemap @@ -1220,7 +1223,7 @@ void sceGuTexFunc(int tfx, int tcc); * @param tbw - Texture Buffer Width (block-aligned) * @param tbp - Texture buffer pointer (16 byte aligned) **/ -void sceGuTexImage(int mipmap, int width, int height, int tbw, const void* tbp); +static inline void sceGuTexImage(int mipmap, int width, int height, int tbw, const void *tbp); /** * Set texture-level mode (mipmapping) @@ -1233,7 +1236,7 @@ void sceGuTexImage(int mipmap, int width, int height, int tbw, const void* tbp); * @param mode - Which mode to use * @param bias - Which mipmap bias to use **/ -void sceGuTexLevelMode(unsigned int mode, float bias); +static inline void sceGuTexLevelMode(unsigned int mode, float bias); /** * Set the texture-mapping mode @@ -1247,7 +1250,7 @@ void sceGuTexLevelMode(unsigned int mode, float bias); * @param a1 - Unknown * @param a2 - Unknown **/ -void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2); +static inline void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2); /** * Set texture-mode parameters @@ -1265,7 +1268,7 @@ void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2); * @param a2 - Unknown, set to 0 * @param swizzle - GU_TRUE(1) to swizzle texture-reads **/ -void sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle); +static inline void sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle); /** * Set texture offset @@ -1276,7 +1279,7 @@ void sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle); * @param u - Offset to add to the U coordinate * @param v - Offset to add to the V coordinate **/ -void sceGuTexOffset(float u, float v); +static inline void sceGuTexOffset(float u, float v); /** * Set texture projection-map mode @@ -1289,7 +1292,7 @@ void sceGuTexOffset(float u, float v); * * @param mode - Which mode to use **/ -void sceGuTexProjMapMode(int mode); +static inline void sceGuTexProjMapMode(int mode); /** * Set texture scale @@ -1300,8 +1303,8 @@ void sceGuTexProjMapMode(int mode); * @param u - Scalar to multiply U coordinate with * @param v - Scalar to multiply V coordinate with **/ -void sceGuTexScale(float u, float v); -void sceGuTexSlope(float slope); +static inline void sceGuTexScale(float u, float v); +static inline void sceGuTexSlope(float slope); /** * Synchronize rendering pipeline with image upload. @@ -1309,7 +1312,7 @@ void sceGuTexSlope(float slope); * This will stall the rendering pipeline until the current image upload initiated by * sceGuCopyImage() has completed. **/ -void sceGuTexSync(); +static inline void sceGuTexSync(); /** * Set if the texture should repeat or clamp @@ -1321,7 +1324,7 @@ void sceGuTexSync(); * @param u - Wrap-mode for the U direction * @param v - Wrap-mode for the V direction **/ -void sceGuTexWrap(int u, int v); +static inline void sceGuTexWrap(int u, int v); /** * Upload CLUT (Color Lookup Table) @@ -1331,7 +1334,7 @@ void sceGuTexWrap(int u, int v); * @param num_blocks - How many blocks of 8 entries to upload (32*8 is 256 colors) * @param cbp - Pointer to palette (16 byte aligned) **/ -void sceGuClutLoad(int num_blocks, const void* cbp); +static inline void sceGuClutLoad(int num_blocks, const void *cbp); /** * Set current CLUT mode @@ -1347,7 +1350,7 @@ void sceGuClutLoad(int num_blocks, const void* cbp); * @param mask - Masks the color index with this bitmask after the shift (0-0xFF) * @param a3 - Unknown, set to 0 **/ -void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3); +static inline void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3); /** * Set virtual coordinate offset @@ -1362,7 +1365,7 @@ void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, uns * @param x - Offset (0-4095) * @param y - Offset (0-4095) **/ -void sceGuOffset(unsigned int x, unsigned int y); +static inline void sceGuOffset(unsigned int x, unsigned int y); /** * Set what to scissor within the current viewport @@ -1374,7 +1377,7 @@ void sceGuOffset(unsigned int x, unsigned int y); * @param w - Width of scissor region * @param h - Height of scissor region **/ -void sceGuScissor(int x, int y, int w, int h); +static inline void sceGuScissor(int x, int y, int w, int h); /** * Set current viewport @@ -1389,7 +1392,7 @@ void sceGuScissor(int x, int y, int w, int h); * @param width - Width of viewport * @param height - Height of viewport **/ -void sceGuViewport(int cx, int cy, int width, int height); +static inline void sceGuViewport(int cx, int cy, int width, int height); /** * Draw bezier surface @@ -1400,7 +1403,7 @@ void sceGuViewport(int cx, int cy, int width, int height); * @param indices - Pointer to index buffer * @param vertices - Pointer to vertex buffer **/ -void sceGuDrawBezier(int vtype, int ucount, int vcount, const void* indices, const void* vertices); +static inline void sceGuDrawBezier(int vtype, int ucount, int vcount, const void *indices, const void *vertices); /** * Set dividing for patches (beziers and splines) @@ -1408,18 +1411,18 @@ void sceGuDrawBezier(int vtype, int ucount, int vcount, const void* indices, con * @param ulevel - Number of division on u direction * @param vlevel - Number of division on v direction **/ -void sceGuPatchDivide(unsigned int ulevel, unsigned int vlevel); +static inline void sceGuPatchDivide(unsigned int ulevel, unsigned int vlevel); -void sceGuPatchFrontFace(unsigned int a0); +static inline void sceGuPatchFrontFace(unsigned int a0); /** * Set primitive for patches (beziers and splines) * * @param prim - Desired primitive type (GU_POINTS | GU_LINE_STRIP | GU_TRIANGLE_STRIP) **/ -void sceGuPatchPrim(int prim); +static inline void sceGuPatchPrim(int prim); -void sceGuDrawSpline(int vtype, int ucount, int vcount, int uedge, int vedge, const void* indices, const void* vertices); +static inline void sceGuDrawSpline(int vtype, int ucount, int vcount, int uedge, int vedge, const void *indices, const void *vertices); /** * Set transform matrices @@ -1433,7 +1436,7 @@ void sceGuDrawSpline(int vtype, int ucount, int vcount, int uedge, int vedge, co * @param type - Which matrix-type to set * @param matrix - Matrix to load **/ -void sceGuSetMatrix(int type, const ScePspFMatrix4* matrix); +static inline void sceGuSetMatrix(int type, const ScePspFMatrix4 *matrix); /** * Specify skinning matrix entry @@ -1448,7 +1451,7 @@ void sceGuSetMatrix(int type, const ScePspFMatrix4* matrix); * @param index - Skinning matrix index (0-7) * @param matrix - Matrix to set **/ -void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4* matrix); +static inline void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4 *matrix); /** * Specify morph weight entry @@ -1463,9 +1466,9 @@ void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4* matrix); * @param index - Morph weight index (0-7) * @param weight - Weight to set **/ -void sceGuMorphWeight(int index, float weight); +static inline void sceGuMorphWeight(int index, float weight); -void sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, const void* indices, const void* vertices); +static inline void sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, const void *indices, const void *vertices); /** * Set how the display should be set @@ -1477,7 +1480,7 @@ void sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, con * Do remember that this swaps the pointers internally, regardless of setting, so be careful to wait until the next * vertical blank or use another buffering algorithm (see guSwapBuffersCallback()). **/ -void guSwapBuffersBehaviour(int behaviour); +static inline void guSwapBuffersBehaviour(int behaviour); /** * Set a buffer swap callback to allow for more advanced buffer methods without hacking the library. @@ -1500,7 +1503,7 @@ void guSwapBuffersBehaviour(int behaviour); * * @param callback - Callback to access when buffers are swapped. Pass 0 to disable. **/ -void guSwapBuffersCallback(GuSwapBuffersCallback callback); +static inline void guSwapBuffersCallback(GuSwapBuffersCallback callback); /** * Allocate a draw buffer in vram @@ -1547,7 +1550,1877 @@ void* guGetStaticVramTexture(unsigned int width, unsigned int height, unsigned i * * @return State of the display **/ -int guGetDisplayState(); +static inline int guGetDisplayState(); + +//////////////////////// ALL THE INTERNALS & INLINE IMPLEMENTATIONS //////////////////////// + +typedef struct +{ + GuCallback sig; + GuCallback fin; + short signal_history[16]; + int signal_offset; + int kernel_event_flag; + int ge_callback_id; + + GuSwapBuffersCallback swapBuffersCallback; + int swapBuffersBehaviour; +} GuSettings; + +typedef struct +{ + unsigned int *start; + unsigned int *current; + int parent_context; +} GuDisplayList; + +typedef struct +{ + GuDisplayList list; + int scissor_enable; + int scissor_start[2]; + int scissor_end[2]; + int near_plane; + int far_plane; + int depth_offset; + int fragment_2x; + int texture_function; + int texture_proj_map_mode; + int texture_map_mode; + int sprite_mode[4]; + unsigned int clear_color; + unsigned int clear_stencil; + unsigned int clear_depth; + int texture_mode; +} GuContext; + +typedef struct +{ + int pixel_size; + int frame_width; + void *frame_buffer; + void *disp_buffer; + void *depth_buffer; + int depth_width; + int width; + int height; +} GuDrawBuffer; + +typedef struct +{ + /* row 0 */ + + unsigned char enable; // Light enable + unsigned char type; // Light type + unsigned char xpos; // X position + unsigned char ypos; // Y position + + /* row 1 */ + + unsigned char zpos; // Z position + unsigned char xdir; // X direction + unsigned char ydir; // Y direction + unsigned char zdir; // Z direction + + /* row 2 */ + + unsigned char ambient; // Ambient color + unsigned char diffuse; // Diffuse color + unsigned char specular; // Specular color + unsigned char constant; // Constant attenuation + + /* row 3 */ + + unsigned char linear; // Linear attenuation + unsigned char quadratic; // Quadratic attenuation + unsigned char exponent; // Light exponent + unsigned char cutoff; // Light cutoff +} GuLightSettings; + +extern unsigned int gu_current_frame; +extern GuContext gu_contexts[3]; +extern int ge_list_executed[2]; +extern void *ge_edram_address; +extern GuSettings gu_settings; +extern GuDisplayList *gu_list; +extern int gu_curr_context; +extern int gu_init; +extern int gu_display_on; +extern int gu_call_mode; +extern int gu_states; +extern GuDrawBuffer gu_draw_buffer; + +extern unsigned int *gu_object_stack[]; +extern int gu_object_stack_depth; + +extern GuLightSettings light_settings[4]; + +typedef enum GECommand +{ + /* No operation */ + NOP = 0x0, + /* Vertex data */ + VADDR = 0x1, + /* Index data */ + IADDR = 0x2, + /* Draw Primitive */ + PRIM = 0x4, + /* Draw Bezier surface */ + BEZIER = 0x5, + /* Draw Spline surface */ + SPLINE = 0x6, + /* Bounding Box */ + BOUNDING_BOX = 0x7, + /* Jump */ + JUMP = 0x8, + /* Conditional Jump */ + BJUMP = 0x9, + /* List Call */ + CALL = 0xa, + /* List Return */ + RET = 0xb, + /* End reading */ + END = 0xc, + /* Signal interrupt */ + SIGNAL = 0xe, + /* Finish drawing */ + FINISH = 0xf, + /* Address base */ + BASE = 0x10, + /* Vertex type */ + VERTEX_TYPE = 0x12, + /* Offset address */ + OFFSET_ADDR = 0x13, + /* Origin address */ + ORIGIN = 0x14, + /* Drawing region 1, origin */ + REGION1 = 0x15, + /* Drawing region 2, end */ + REGION2 = 0x16, + + /* Lighting enable */ + LIGHTING_ENABLE = 0x17, + /* Light 0 enable */ + LIGHT_ENABLE0 = 0x18, + /* Light 1 enable */ + LIGHT_ENABLE1 = 0x19, + /* Light 2 enable */ + LIGHT_ENABLE2 = 0x1a, + /* Light 3 enable */ + LIGHT_ENABLE3 = 0x1b, + /* Clipping enable */ + DEPTH_CLIP_ENABLE = 0x1c, + /* Culling enable */ + CULL_FACE_ENABLE = 0x1d, + /* Texture mapping enable */ + TEXTURE_ENABLE = 0x1e, + /* Fog enable */ + FOG_ENABLE = 0x1f, + /* Dithering enable */ + DITHER_ENABLE = 0x20, + /* Alpha blending enable */ + ALPHA_BLEND_ENABLE = 0x21, + /* Alpha testing enable */ + ALPHA_TEST_ENABLE = 0x22, + /* Z testing enable */ + Z_TEST_ENABLE = 0x23, + /* Stencil testing enable */ + STENCIL_TEST_ENABLE = 0x24, + /* Anti-aliasing enable */ + ANTI_ALIAS_ENABLE = 0x25, + /* Patch culling enable */ + PATCH_CULL_ENABLE = 0x26, + /* Color testing enable */ + COLOR_TEST_ENABLE = 0x27, + /* Logical operation enable */ + LOGIC_OP_ENABLE = 0x28, + + /* Bone matrix number */ + BONE_MATRIX_NUMBER = 0x2a, + /* Bone matrix data */ + BONE_MATRIX_DATA = 0x2b, + /* Morph weight 0 */ + MORPH_WEIGHT0 = 0x2c, + /* Morph weight 1 */ + MORPH_WEIGHT1 = 0x2d, + /* Morph weight 2 */ + MORPH_WEIGHT2 = 0x2e, + /* Morph weight 3 */ + MORPH_WEIGHT3 = 0x2f, + /* Morph weight 4 */ + MORPH_WEIGHT4 = 0x30, + /* Morph weight 5 */ + MORPH_WEIGHT5 = 0x31, + /* Morph weight 6 */ + MORPH_WEIGHT6 = 0x32, + /* Morph weight 7 */ + MORPH_WEIGHT7 = 0x33, + + /* Patch division count */ + PATCH_DIVISION = 0x36, + /* Patch primitive type */ + PATCH_PRIMITIVE = 0x37, + /* Patch facing */ + PATCH_FACING = 0x38, + /* World matrix number */ + WORLD_MATRIX_NUMBER = 0x3a, + /* World matrix data */ + WORLD_MATRIX_DATA = 0x3b, + /* View matrix number */ + VIEW_MATRIX_NUMBER = 0x3c, + /* View matrix data */ + VIEW_MATRIX_DATA = 0x3d, + /* Projection matrix number */ + PROJ_MATRIX_NUMBER = 0x3e, + /* Projection matrix data */ + PROJ_MATRIX_DATA = 0x3f, + /* Texture generation matrix number */ + TGEN_MATRIX_NUMBER = 0x40, + /* Texture generation matrix data */ + TGEN_MATRIX_DATA = 0x41, + + /* Viewport X scale */ + VIEWPORT_X_SCALE = 0x42, + /* Viewport Y scale */ + VIEWPORT_Y_SCALE = 0x43, + /* Viewport Z scale */ + VIEWPORT_Z_SCALE = 0x44, + /* Viewport X center */ + VIEWPORT_X_CENTER = 0x45, + /* Viewport Y center */ + VIEWPORT_Y_CENTER = 0x46, + /* Viewport Z center */ + VIEWPORT_Z_CENTER = 0x47, + /* Texture scale U */ + TEX_SCALE_U = 0x48, + /* Texture scale V */ + TEX_SCALE_V = 0x49, + /* Texture offset U */ + TEX_OFFSET_U = 0x4a, + /* Texture offset V */ + TEX_OFFSET_V = 0x4b, + /* Screen Offset X */ + OFFSET_X = 0x4c, + /* Screen Offset Y */ + OFFSET_Y = 0x4d, + + /* Shade mode */ + SHADE_MODE = 0x50, + /* Normal reverse */ + NORMAL_REVERSE = 0x51, + /* Material color */ + MATERIAL_COLOR = 0x53, + /* Material emissive */ + MATERIAL_EMISSIVE = 0x54, + /* Ambient color */ + AMBIENT_COLOR = 0x55, + /* Material diffuse */ + MATERIAL_DIFFUSE = 0x56, + /* Material specular */ + MATERIAL_SPECULAR = 0x57, + /* Ambient alpha */ + AMBIENT_ALPHA = 0x58, + /* Material specular coefficient */ + MATERIAL_SPECULAR_COEF = 0x5b, + /* Ambient light color */ + AMBIENT_LIGHT_COLOR = 0x5c, + /* Ambient light alpha */ + AMBIENT_LIGHT_ALPHA = 0x5d, + /* Light mode */ + LIGHT_MODE = 0x5e, + + /* Light type 0 */ + LIGHT_TYPE0 = 0x5f, + /* Light type 1 */ + LIGHT_TYPE1 = 0x60, + /* Light type 2 */ + LIGHT_TYPE2 = 0x61, + /* Light type 3 */ + LIGHT_TYPE3 = 0x62, + /* Light 0 X */ + LIGHT0_X = 0x63, + /* Light 0 Y */ + LIGHT0_Y = 0x64, + /* Light 0 Z */ + LIGHT0_Z = 0x65, + /* Light 1 X */ + LIGHT1_X = 0x66, + /* Light 1 Y */ + LIGHT1_Y = 0x67, + /* Light 1 Z */ + LIGHT1_Z = 0x68, + /* Light 2 X */ + LIGHT2_X = 0x69, + /* Light 2 Y */ + LIGHT2_Y = 0x6a, + /* Light 2 Z */ + LIGHT2_Z = 0x6b, + /* Light 3 X */ + LIGHT3_X = 0x6c, + /* Light 3 Y */ + LIGHT3_Y = 0x6d, + /* Light 3 Z */ + LIGHT3_Z = 0x6e, + + /* Light 0 direction X */ + LIGHT0_DIRECTION_X = 0x6f, + /* Light 0 direction Y */ + LIGHT0_DIRECTION_Y = 0x70, + /* Light 0 direction Z */ + LIGHT0_DIRECTION_Z = 0x71, + /* Light 1 direction X */ + LIGHT1_DIRECTION_X = 0x72, + /* Light 1 direction Y */ + LIGHT1_DIRECTION_Y = 0x73, + /* Light 1 direction Z */ + LIGHT1_DIRECTION_Z = 0x74, + /* Light 2 direction X */ + LIGHT2_DIRECTION_X = 0x75, + /* Light 2 direction Y */ + LIGHT2_DIRECTION_Y = 0x76, + /* Light 2 direction Z */ + LIGHT2_DIRECTION_Z = 0x77, + /* Light 3 direction X */ + LIGHT3_DIRECTION_X = 0x78, + /* Light 3 direction Y */ + LIGHT3_DIRECTION_Y = 0x79, + /* Light 3 direction Z */ + LIGHT3_DIRECTION_Z = 0x7a, + + /* Light 0 constant attenuation */ + LIGHT0_CONSTANT_ATTEN = 0x7b, + /* Light 0 linear attenuation */ + LIGHT0_LINEAR_ATTEN = 0x7c, + /* Light 0 quadratic attenuation */ + LIGHT0_QUADRATIC_ATTEN = 0x7d, + /* Light 1 constant attenuation */ + LIGHT1_CONSTANT_ATTEN = 0x7e, + /* Light 1 linear attenuation */ + LIGHT1_LINEAR_ATTEN = 0x7f, + /* Light 1 quadratic attenuation */ + LIGHT1_QUADRATIC_ATTEN = 0x80, + /* Light 2 constant attenuation */ + LIGHT2_CONSTANT_ATTEN = 0x81, + /* Light 2 linear attenuation */ + LIGHT2_LINEAR_ATTEN = 0x82, + /* Light 2 quadratic attenuation */ + LIGHT2_QUADRATIC_ATTEN = 0x83, + /* Light 3 constant attenuation */ + LIGHT3_CONSTANT_ATTEN = 0x84, + /* Light 3 linear attenuation */ + LIGHT3_LINEAR_ATTEN = 0x85, + /* Light 3 quadratic attenuation */ + LIGHT3_QUADRATIC_ATTEN = 0x86, + + /* Light 0 exponent attenuation */ + LIGHT0_EXPONENT_ATTEN = 0x87, + /* Light 1 exponent attenuation */ + LIGHT1_EXPONENT_ATTEN = 0x88, + /* Light 2 exponent attenuation */ + LIGHT2_EXPONENT_ATTEN = 0x89, + /* Light 3 exponent attenuation */ + LIGHT3_EXPONENT_ATTEN = 0x8a, + + /* Light 0 cutoff attenuation */ + LIGHT0_CUTOFF_ATTEN = 0x8b, + /* Light 1 cutoff attenuation */ + LIGHT1_CUTOFF_ATTEN = 0x8c, + /* Light 2 cutoff attenuation */ + LIGHT2_CUTOFF_ATTEN = 0x8d, + /* Light 3 cutoff attenuation */ + LIGHT3_CUTOFF_ATTEN = 0x8e, + + /* Light 0 ambient */ + LIGHT0_AMBIENT = 0x8f, + /* Light 0 diffuse */ + LIGHT0_DIFFUSE = 0x90, + /* Light 0 specular */ + LIGHT0_SPECULAR = 0x91, + /* Light 1 ambient */ + LIGHT1_AMBIENT = 0x92, + /* Light 1 diffuse */ + LIGHT1_DIFFUSE = 0x93, + /* Light 1 specular */ + LIGHT1_SPECULAR = 0x94, + /* Light 2 ambient */ + LIGHT2_AMBIENT = 0x95, + /* Light 2 diffuse */ + LIGHT2_DIFFUSE = 0x96, + /* Light 2 specular */ + LIGHT2_SPECULAR = 0x97, + /* Light 3 ambient */ + LIGHT3_AMBIENT = 0x98, + /* Light 3 diffuse */ + LIGHT3_DIFFUSE = 0x99, + /* Light 3 specular */ + LIGHT3_SPECULAR = 0x9a, + + /* Culling */ + CULL = 0x9b, + + /* Frame buffer pointer */ + FRAME_BUF_PTR = 0x9c, + /* Frame buffer width */ + FRAME_BUF_WIDTH = 0x9d, + /* Z buffer pointer */ + Z_BUF_PTR = 0x9e, + /* Z buffer width */ + Z_BUF_WIDTH = 0x9f, + + /* Texture address 0 */ + TEX_ADDR0 = 0xa0, + /* Texture address 1 */ + TEX_ADDR1 = 0xa1, + /* Texture address 2 */ + TEX_ADDR2 = 0xa2, + /* Texture address 3 */ + TEX_ADDR3 = 0xa3, + /* Texture address 4 */ + TEX_ADDR4 = 0xa4, + /* Texture address 5 */ + TEX_ADDR5 = 0xa5, + /* Texture address 6 */ + TEX_ADDR6 = 0xa6, + /* Texture address 7 */ + TEX_ADDR7 = 0xa7, + /* Texture buffer width 0 */ + TEX_BUF_WIDTH0 = 0xa8, + /* Texture buffer width 1 */ + TEX_BUF_WIDTH1 = 0xa9, + /* Texture buffer width 2 */ + TEX_BUF_WIDTH2 = 0xaa, + /* Texture buffer width 3 */ + TEX_BUF_WIDTH3 = 0xab, + /* Texture buffer width 4 */ + TEX_BUF_WIDTH4 = 0xac, + /* Texture buffer width 5 */ + TEX_BUF_WIDTH5 = 0xad, + /* Texture buffer width 6 */ + TEX_BUF_WIDTH6 = 0xae, + /* Texture buffer width 7 */ + TEX_BUF_WIDTH7 = 0xaf, + + /* CLUT buffer pointer */ + CLUT_BUF_PTR = 0xb0, + /* CLUT buffer width */ + CLUT_BUF_WIDTH = 0xb1, + + /* Transfer source */ + TRANSFER_SRC = 0xb2, + /* Transfer source width */ + TRANSFER_SRC_W = 0xb3, + /* Transfer destination */ + TRANSFER_DST = 0xb4, + /* Transfer destination width */ + TRANSFER_DST_W = 0xb5, + + /* Texture size 0 */ + TEX_SIZE0 = 0xb8, + /* Texture size 1 */ + TEX_SIZE1 = 0xb9, + /* Texture size 2 */ + TEX_SIZE2 = 0xba, + /* Texture size 3 */ + TEX_SIZE3 = 0xbb, + /* Texture size 4 */ + TEX_SIZE4 = 0xbc, + /* Texture size 5 */ + TEX_SIZE5 = 0xbd, + /* Texture size 6 */ + TEX_SIZE6 = 0xbe, + /* Texture size 7 */ + TEX_SIZE7 = 0xbf, + + /* Texture map mode */ + TEX_MAP_MODE = 0xc0, + /* Texture shade mapping */ + TEX_SHADE_MAPPING = 0xc1, + /* Texture mode */ + TEX_MODE = 0xc2, + /* Texture format */ + TEX_FORMAT = 0xc3, + /* Load CLUT */ + CLUT_LOAD = 0xc4, + /* CLUT format */ + CLUT_FORMAT = 0xc5, + /* Texture filter */ + TEX_FILTER = 0xc6, + /* Texture wrap */ + TEX_WRAP = 0xc7, + /* Texture level */ + TEX_LEVEL = 0xc8, + /* Texture function */ + TEX_FUNC = 0xc9, + /* Texture environment color */ + TEX_ENV_COLOR = 0xca, + /* Texture flush */ + TEX_FLUSH = 0xcb, + /* Texture sync */ + TEX_SYNC = 0xcc, + + /* Fog 1 */ + FOG1 = 0xcd, + /* Fog 2 */ + FOG2 = 0xce, + /* Fog color */ + FOG_COLOR = 0xcf, + /* Texture LOD slope */ + TEX_LOD_SLOPE = 0xd0, + + /* Frame buffer pixel format */ + FRAMEBUF_PIX_FORMAT = 0xd2, + /* Clear mode */ + CLEAR_MODE = 0xd3, + /* Scissor 1 */ + SCISSOR1 = 0xd4, + /* Scissor 2 */ + SCISSOR2 = 0xd5, + + /* Minimum Z */ + MIN_Z = 0xd6, + /* Maximum Z */ + MAX_Z = 0xd7, + /* Color test */ + COLOR_TEST = 0xd8, + /* Color reference */ + COLOR_REF = 0xd9, + /* Color test mask */ + COLOR_TESTMASK = 0xda, + /* Alpha test */ + ALPHA_TEST = 0xdb, + /* Stencil test */ + STENCIL_TEST = 0xdc, + /* Stencil operation */ + STENCIL_OP = 0xdd, + /* Z test */ + Z_TEST = 0xde, + /* Blend mode */ + BLEND_MODE = 0xdf, + /* Blend fixed A */ + BLEND_FIXED_A = 0xe0, + /* Blend fixed B */ + BLEND_FIXED_B = 0xe1, + /* Dither 0 */ + DITH0 = 0xe2, + /* Dither 1 */ + DITH1 = 0xe3, + /* Dither 2 */ + DITH2 = 0xe4, + /* Dither 3 */ + DITH3 = 0xe5, + + /* Logical operation */ + LOGIC_OP = 0xe6, + /* Z mask */ + Z_MASK = 0xe7, + /* Mask color */ + MASK_COLOR = 0xe8, + /* Mask alpha */ + MASK_ALPHA = 0xe9, + + /* Transfer start */ + TRANSFER_START = 0xea, + /* Transfer source offset */ + TRANSFER_SRC_OFFSET = 0xeb, + /* Transfer destination offset */ + TRANSFER_DST_OFFSET = 0xec, + /* Transfer format */ + TRANSFER_FORMAT = 0xed, + /* Transfer size */ + TRANSFER_SIZE = 0xee, + + /* Transfer flip */ + TRANSFER_FLIP = 0xef, + /* Transfer out size */ + TRANSFER_OUT_SIZE = 0xf0, + /* Transfer out format */ + TRANSFER_OUT_FORMAT = 0xf1, + /* Vertex weight */ + VERTEX_WEIGHT = 0xf2, + /* Vertex weight address */ + VERTEX_WEIGHT_ADDR = 0xf3, + /* Vertex weight size */ + VERTEX_WEIGHT_SIZE = 0xf4, + /* Vertex weight type */ + VERTEX_WEIGHT_TYPE = 0xf5, + /* Vertex weight model */ + VERTEX_WEIGHT_MODEL = 0xf6, + /* Vertex weight normalize */ + VERTEX_WEIGHT_NORMALIZE = 0xf7, + /* Vertex weight offset */ + VERTEX_WEIGHT_OFFSET = 0xf8, + /* Vertex weight scale */ + VERTEX_WEIGHT_SCALE = 0xf9, + /* Vertex weight matrix */ + VERTEX_WEIGHT_MATRIX = 0xfa, + /* Vertex weight matrix address */ + VERTEX_WEIGHT_MATRIX_ADDR = 0xfb, + /* Vertex weight matrix size */ + VERTEX_WEIGHT_MATRIX_SIZE = 0xfc, + /* Vertex weight matrix type */ + VERTEX_WEIGHT_MATRIX_TYPE = 0xfd, + /* Vertex weight matrix model */ + VERTEX_WEIGHT_MATRIX_MODEL = 0xfe, + /* Vertex weight matrix normalize */ + VERTEX_WEIGHT_MATRIX_NORMALIZE = 0xff, +} GECommand; + +static inline void sceGuSendCommandi(int cmd, int argument) +{ + *(gu_list->current++) = (cmd << 24) | (argument & 0xffffff); +} + +static inline void sceGuSendCommandf(int cmd, float argument) +{ + union + { + float f; + unsigned int i; + } t; + t.f = argument; + + sceGuSendCommandi(cmd, t.i >> 8); +} + +static inline void sendCommandiStall(GECommand cmd, int argument) +{ + sceGuSendCommandi(cmd, argument); + + if (!gu_object_stack_depth && !gu_curr_context) + sceGeListUpdateStallAddr(ge_list_executed[0], gu_list->current); +} + +static inline void sceGuDepthBuffer(void *zbp, int zbw) +{ + gu_draw_buffer.depth_buffer = zbp; + + if (!gu_draw_buffer.depth_width || (gu_draw_buffer.depth_width != zbw)) + gu_draw_buffer.depth_width = zbw; + + sceGuSendCommandi(Z_BUF_PTR, ((unsigned int)zbp) & 0xffffff); + sceGuSendCommandi(Z_BUF_WIDTH, ((((unsigned int)zbp) & 0xff000000) >> 8) | zbw); +} + +static inline void sceGuDispBuffer(int width, int height, void *dispbp, int dispbw) +{ + int x = 0; + int y = 0; + + gu_draw_buffer.width = width; + gu_draw_buffer.height = height; + gu_draw_buffer.disp_buffer = dispbp; + + if (!gu_draw_buffer.frame_width || (gu_draw_buffer.frame_width != dispbw)) + gu_draw_buffer.frame_width = dispbw; + + sceGuSendCommandi(REGION1, (y << 10) | x); + sceGuSendCommandi(REGION2, (((x + gu_draw_buffer.height) - 1) << 10) | ((y + gu_draw_buffer.width) - 1)); + sceDisplaySetMode(0, gu_draw_buffer.width, gu_draw_buffer.height); + + if (gu_display_on) + sceDisplaySetFrameBuf((void *)(((unsigned int)ge_edram_address) + ((unsigned int)gu_draw_buffer.disp_buffer)), dispbw, gu_draw_buffer.pixel_size, PSP_DISPLAY_SETBUF_NEXTFRAME); +} + +static inline void sceGuDrawBuffer(int psm, void *fbp, int frame_width) +{ + gu_draw_buffer.pixel_size = psm; + gu_draw_buffer.frame_width = frame_width; + gu_draw_buffer.frame_buffer = fbp; + + if (!gu_draw_buffer.depth_buffer && gu_draw_buffer.height) + gu_draw_buffer.depth_buffer = (void *)(((unsigned int)fbp) + (unsigned int)((gu_draw_buffer.height * frame_width) << 2)); + + if (!gu_draw_buffer.depth_width) + gu_draw_buffer.depth_width = frame_width; + + sceGuSendCommandi(FRAMEBUF_PIX_FORMAT, psm); + sceGuSendCommandi(FRAME_BUF_PTR, ((unsigned int)gu_draw_buffer.frame_buffer) & 0xffffff); + sceGuSendCommandi(FRAME_BUF_WIDTH, ((((unsigned int)gu_draw_buffer.frame_buffer) & 0xff000000) >> 8) | gu_draw_buffer.frame_width); + sceGuSendCommandi(Z_BUF_PTR, ((unsigned int)gu_draw_buffer.depth_buffer) & 0xffffff); + sceGuSendCommandi(Z_BUF_WIDTH, ((((unsigned int)gu_draw_buffer.depth_buffer) & 0xff000000) >> 8) | gu_draw_buffer.depth_width); +} + +static inline void sceGuDrawBufferList(int psm, void *fbp, int fbw) +{ + sceGuSendCommandi(FRAMEBUF_PIX_FORMAT, psm); + sceGuSendCommandi(FRAME_BUF_PTR, ((unsigned int)fbp) & 0xffffff); + sceGuSendCommandi(FRAME_BUF_WIDTH, ((((unsigned int)fbp) & 0xff000000) >> 8) | fbw); +} + +static inline int sceGuDisplay(int state) +{ + if (state) + sceDisplaySetFrameBuf((void *)((unsigned int)ge_edram_address + (unsigned int)gu_draw_buffer.disp_buffer), gu_draw_buffer.frame_width, gu_draw_buffer.pixel_size, PSP_DISPLAY_SETBUF_NEXTFRAME); + else + sceDisplaySetFrameBuf(0, 0, 0, PSP_DISPLAY_SETBUF_NEXTFRAME); + + gu_display_on = state; + return state; +} + +static inline void sceGuDepthFunc(int function) +{ + sceGuSendCommandi(Z_TEST, function); +} + +static inline void sceGuDepthMask(int mask) +{ + sceGuSendCommandi(Z_MASK, mask); +} + +static inline void sceGuDepthRange(int near, int far) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + + unsigned int max = (unsigned int)near + (unsigned int)far; + int val = (int)((max >> 31) + max); + float z = (float)(val >> 1); + + context->near_plane = near; + context->far_plane = far; + + sceGuSendCommandf(VIEWPORT_Z_SCALE, z - ((float)near)); + sceGuSendCommandf(VIEWPORT_Z_CENTER, z + ((float)context->depth_offset)); + + if (near > far) + { + int temp = near; + near = far; + far = temp; + } + + sceGuSendCommandi(MIN_Z, near); + sceGuSendCommandi(MAX_Z, far); +} + +static inline void sceGuDepthOffset(unsigned int offset) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + context->depth_offset = offset; + + sceGuDepthRange(context->near_plane, context->far_plane); +} + +static inline void sceGuFog(float near, float far, unsigned int color) +{ + float distance = far - near; + + if (distance) + distance = 1.0f / distance; + + sceGuSendCommandi(FOG_COLOR, color & 0xffffff); + sceGuSendCommandf(FOG1, far); + sceGuSendCommandf(FOG2, distance); +} + +static inline void sceGuBreak(int a0) +{ + // FIXME + // sceGeBreak(a0,0x527a68); +} + +static inline void sceGuContinue(void) +{ + // FIXME + // sceGeContinue(); +} + +static inline GuCallback sceGuSetCallback(int signal, GuCallback callback) +{ + GuCallback old_callback = 0; + + switch (signal) + { + case GU_CALLBACK_SIGNAL: + { + old_callback = gu_settings.sig; + gu_settings.sig = callback; + } + break; + + case GU_CALLBACK_FINISH: + { + old_callback = gu_settings.fin; + gu_settings.fin = callback; + } + break; + } + + return old_callback; +} + +static inline void sceGuSignal(int signal, int argument) +{ + sceGuSendCommandi(SIGNAL, ((signal & 0xff) << 16) | (argument & 0xffff)); + sceGuSendCommandi(END, 0); + + if (signal == 3) + { + sceGuSendCommandi(FINISH, 0); + sceGuSendCommandi(END, 0); + } + + sendCommandiStall(NOP, 0); +} + +static inline int sceGuFinish(void) +{ + switch (gu_curr_context) + { + case GU_DIRECT: + case GU_SEND: + { + sceGuSendCommandi(FINISH, 0); + sendCommandiStall(END, 0); + } + break; + + case GU_CALL: + { + if (gu_call_mode == 1) + { + sceGuSendCommandi(SIGNAL, 0x120000); + sceGuSendCommandi(END, 0); + sendCommandiStall(NOP, 0); + } + else + { + sceGuSendCommandi(RET, 0); + } + } + break; + } + + unsigned int size = ((unsigned int)gu_list->current) - ((unsigned int)gu_list->start); + + // go to parent list + gu_curr_context = gu_list->parent_context; + gu_list = &gu_contexts[gu_curr_context].list; + return size; +} + +static inline int sceGuFinishId(unsigned int id) +{ + switch (gu_curr_context) + { + case GU_DIRECT: + case GU_SEND: + { + sceGuSendCommandi(FINISH, id & 0xffff); + sendCommandiStall(END, 0); + } + break; + + case GU_CALL: + { + if (gu_call_mode == 1) + { + sceGuSendCommandi(SIGNAL, 0x120000); + sceGuSendCommandi(END, 0); + sendCommandiStall(NOP, 0); + } + else + { + sceGuSendCommandi(RET, 0); + } + } + break; + } + + unsigned int size = ((unsigned int)gu_list->current) - ((unsigned int)gu_list->start); + + // go to parent list + gu_curr_context = gu_list->parent_context; + gu_list = &gu_contexts[gu_curr_context].list; + return size; +} + +static inline void sceGuCallList(const void *list) +{ + unsigned int list_addr = (unsigned int)list; + + if (gu_call_mode == 1) + { + sceGuSendCommandi(SIGNAL, (list_addr >> 16) | 0x110000); + sceGuSendCommandi(END, list_addr & 0xffff); + sendCommandiStall(NOP, 0); + } + else + { + sceGuSendCommandi(BASE, (list_addr >> 8) & 0xf0000); + sendCommandiStall(CALL, list_addr & 0xffffff); + } +} + +static inline void sceGuCallMode(int mode) +{ + gu_call_mode = mode; +} + +static inline int sceGuCheckList(void) +{ + return ((int)gu_list->current) - ((int)gu_list->start); +} + +static inline int sceGuSendList(int mode, const void *list, PspGeContext *context) +{ + gu_settings.signal_offset = 0; + + // TODO: figure out this structure + PspGeListArgs args; + args.size = 8; // Size of structure? + args.context = context; + + int list_id = 0; + int callback = gu_settings.ge_callback_id; + + switch (mode) + { + case GU_HEAD: + list_id = sceGeListEnQueueHead(list, NULL, callback, &args); + break; + case GU_TAIL: + list_id = sceGeListEnQueue(list, NULL, callback, &args); + break; + } + + if (list_id < 0) + { + return list_id; + } + + ge_list_executed[1] = list_id; + return 0; +} + +static inline void *sceGuSwapBuffers(void) +{ + if (gu_settings.swapBuffersCallback) + { + gu_settings.swapBuffersCallback(&gu_draw_buffer.disp_buffer, &gu_draw_buffer.frame_buffer); + } + else + { + void *temp = gu_draw_buffer.disp_buffer; + gu_draw_buffer.disp_buffer = gu_draw_buffer.frame_buffer; + gu_draw_buffer.frame_buffer = temp; + } + + if (gu_display_on) + sceDisplaySetFrameBuf((void *)((unsigned int)ge_edram_address + (unsigned int)gu_draw_buffer.disp_buffer), gu_draw_buffer.frame_width, gu_draw_buffer.pixel_size, gu_settings.swapBuffersBehaviour); + + // TODO: remove this? it serves no real purpose + gu_current_frame ^= 1; + + // return (void*)gu_settings.swapBuffersBehaviour; + return gu_draw_buffer.frame_buffer; +} + +static inline int sceGuSync(int mode, int what) +{ + switch (mode) + { + case 0: + return sceGeDrawSync(what); + case 3: + return sceGeListSync(ge_list_executed[0], what); + case 4: + return sceGeListSync(ge_list_executed[1], what); + default: + case 1: + case 2: + return 0; + } +} + +static inline void sceGuDrawArray(int prim, int vtype, int count, const void *indices, const void *vertices) +{ + if (vtype) + sceGuSendCommandi(VERTEX_TYPE, vtype); + + if (indices) + { + sceGuSendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); + sceGuSendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); + } + + if (vertices) + { + sceGuSendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); + sceGuSendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); + } + + sendCommandiStall(PRIM, (prim << 16) | count); +} + +static inline void sceGuBeginObject(int vertex_type, int a1, const void *indices, const void *vertices) +{ + if (vertex_type) + sceGuSendCommandi(VERTEX_TYPE, vertex_type); + + if (indices) + { + sceGuSendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); + sceGuSendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); + } + + if (vertices) + { + sceGuSendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0x0f0000); + sceGuSendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); + } + + sceGuSendCommandi(BOUNDING_BOX, a1); + + // store start to new object + + gu_object_stack[gu_object_stack_depth++] = gu_list->current; + + // dummy commands, overwritten in sceGuEndObject() + sceGuSendCommandi(BASE, 0); + sceGuSendCommandi(BJUMP, 0); +} + +static inline void sceGuEndObject(void) +{ + // rewrite commands from sceGuBeginObject() + + unsigned int *current = gu_list->current; + gu_list->current = gu_object_stack[gu_object_stack_depth - 1]; + + sceGuSendCommandi(BASE, (((unsigned int)current) >> 8) & 0xf0000); + sceGuSendCommandi(BJUMP, ((unsigned int)current) & 0xffffff); + gu_list->current = current; + + gu_object_stack_depth--; +} + +static inline void sceGuSetStatus(int state, int status) +{ + if (status) + sceGuEnable(state); + else + sceGuDisable(state); +} + +static inline int sceGuGetStatus(int state) +{ + if (state < 22) + return (gu_states >> state) & 1; + return 0; +} + +static inline void sceGuSetAllStatus(int status) +{ + unsigned int i; + for (i = 0; i < 22; ++i) + { + if ((status >> i) & 1) + sceGuEnable(i); + else + sceGuDisable(i); + } +} + +static inline int sceGuGetAllStatus(void) +{ + return gu_states; +} + +static inline void sceGuEnable(int state) +{ + switch (state) + { + case GU_ALPHA_TEST: + sceGuSendCommandi(ALPHA_TEST_ENABLE, 1); + break; + case GU_DEPTH_TEST: + sceGuSendCommandi(Z_TEST_ENABLE, 1); + break; + case GU_SCISSOR_TEST: + { + GuContext *context = &gu_contexts[gu_curr_context]; + context->scissor_enable = 1; + sceGuSendCommandi(SCISSOR1, (context->scissor_start[1] << 10) | context->scissor_start[0]); + sceGuSendCommandi(SCISSOR2, (context->scissor_end[1] << 10) | context->scissor_end[0]); + } + break; + case GU_STENCIL_TEST: + sceGuSendCommandi(STENCIL_TEST_ENABLE, 1); + break; + case GU_BLEND: + sceGuSendCommandi(ALPHA_BLEND_ENABLE, 1); + break; + case GU_CULL_FACE: + sceGuSendCommandi(CULL_FACE_ENABLE, 1); + break; + case GU_DITHER: + sceGuSendCommandi(DITHER_ENABLE, 1); + break; + case GU_FOG: + sceGuSendCommandi(FOG_ENABLE, 1); + break; + case GU_CLIP_PLANES: + sceGuSendCommandi(DEPTH_CLIP_ENABLE, 1); + break; + case GU_TEXTURE_2D: + sceGuSendCommandi(TEXTURE_ENABLE, 1); + break; + case GU_LIGHTING: + sceGuSendCommandi(LIGHTING_ENABLE, 1); + break; + case GU_LIGHT0: + sceGuSendCommandi(LIGHT_ENABLE0, 1); + break; + case GU_LIGHT1: + sceGuSendCommandi(LIGHT_ENABLE1, 1); + break; + case GU_LIGHT2: + sceGuSendCommandi(LIGHT_ENABLE2, 1); + break; + case GU_LIGHT3: + sceGuSendCommandi(LIGHT_ENABLE3, 1); + break; + case GU_LINE_SMOOTH: + sceGuSendCommandi(ANTI_ALIAS_ENABLE, 1); + break; + case GU_PATCH_CULL_FACE: + sceGuSendCommandi(PATCH_CULL_ENABLE, 1); + break; + case GU_COLOR_TEST: + sceGuSendCommandi(COLOR_TEST_ENABLE, 1); + break; + case GU_COLOR_LOGIC_OP: + sceGuSendCommandi(LOGIC_OP_ENABLE, 1); + break; + case GU_FACE_NORMAL_REVERSE: + sceGuSendCommandi(NORMAL_REVERSE, 1); + break; + case GU_PATCH_FACE: + sceGuSendCommandi(PATCH_FACING, 1); + break; + case GU_FRAGMENT_2X: + { + GuContext *context = &gu_contexts[gu_curr_context]; + context->fragment_2x = 0x10000; + sceGuSendCommandi(TEX_FUNC, 0x10000 | context->texture_function); + } + break; + } + + if (state < 22) + gu_states |= (1 << state); +} + +static inline void sceGuDisable(int state) +{ + switch (state) + { + case GU_ALPHA_TEST: + sceGuSendCommandi(ALPHA_TEST_ENABLE, 0); + break; + case GU_DEPTH_TEST: + sceGuSendCommandi(Z_TEST_ENABLE, 0); + break; + case GU_SCISSOR_TEST: + { + GuContext *context = &gu_contexts[gu_curr_context]; + context->scissor_enable = 0; + sceGuSendCommandi(SCISSOR1, 0); + sceGuSendCommandi(SCISSOR2, ((gu_draw_buffer.height - 1) << 10) | (gu_draw_buffer.width - 1)); + } + break; + case GU_STENCIL_TEST: + sceGuSendCommandi(STENCIL_TEST_ENABLE, 0); + break; + case GU_BLEND: + sceGuSendCommandi(ALPHA_BLEND_ENABLE, 0); + break; + case GU_CULL_FACE: + sceGuSendCommandi(CULL_FACE_ENABLE, 0); + break; + case GU_DITHER: + sceGuSendCommandi(DITHER_ENABLE, 0); + break; + case GU_FOG: + sceGuSendCommandi(FOG_ENABLE, 0); + break; + case GU_CLIP_PLANES: + sceGuSendCommandi(DEPTH_CLIP_ENABLE, 0); + break; + case GU_TEXTURE_2D: + sceGuSendCommandi(TEXTURE_ENABLE, 0); + break; + case GU_LIGHTING: + sceGuSendCommandi(LIGHTING_ENABLE, 0); + break; + case GU_LIGHT0: + sceGuSendCommandi(LIGHT_ENABLE0, 0); + break; + case GU_LIGHT1: + sceGuSendCommandi(LIGHT_ENABLE1, 0); + break; + case GU_LIGHT2: + sceGuSendCommandi(LIGHT_ENABLE2, 0); + break; + case GU_LIGHT3: + sceGuSendCommandi(LIGHT_ENABLE3, 0); + break; + case GU_LINE_SMOOTH: + sceGuSendCommandi(ANTI_ALIAS_ENABLE, 0); + break; + case GU_PATCH_CULL_FACE: + sceGuSendCommandi(PATCH_CULL_ENABLE, 0); + break; + case GU_COLOR_TEST: + sceGuSendCommandi(COLOR_TEST_ENABLE, 0); + break; + case GU_COLOR_LOGIC_OP: + sceGuSendCommandi(LOGIC_OP_ENABLE, 0); + break; + case GU_FACE_NORMAL_REVERSE: + sceGuSendCommandi(NORMAL_REVERSE, 0); + break; + case GU_PATCH_FACE: + sceGuSendCommandi(PATCH_FACING, 0); + break; + case GU_FRAGMENT_2X: + { + GuContext *context = &gu_contexts[gu_curr_context]; + context->fragment_2x = 0; + sceGuSendCommandi(TEX_FUNC, context->texture_function); + } + break; + } + + if (state < 22) + gu_states &= ~(1 << state); +} + +static inline void sceGuLight(int light, int type, int components, const ScePspFVector3 *position) +{ + GuLightSettings *settings = &light_settings[light]; + + sceGuSendCommandf(settings->xpos, position->x); + sceGuSendCommandf(settings->ypos, position->y); + sceGuSendCommandf(settings->zpos, position->z); + + int kind = 2; + if (components != 8) + kind = (components ^ 6) < 1 ? 1 : 0; + + sceGuSendCommandi(settings->type, ((type & 0x03) << 8) | kind); +} + +static inline void sceGuLightAtt(int light, float atten0, float atten1, float atten2) +{ + GuLightSettings *settings = &light_settings[light]; + + sceGuSendCommandf(settings->constant, atten0); + sceGuSendCommandf(settings->linear, atten1); + sceGuSendCommandf(settings->quadratic, atten2); +} + +static inline void sceGuLightColor(int light, int component, unsigned int color) +{ + GuLightSettings *settings = &light_settings[light]; + + switch (component) + { + case GU_AMBIENT: + sceGuSendCommandi(settings->ambient, color & 0xffffff); + break; + case GU_DIFFUSE: + sceGuSendCommandi(settings->diffuse, color & 0xffffff); + break; + case GU_AMBIENT_AND_DIFFUSE: + { + sceGuSendCommandi(settings->ambient, color & 0xffffff); + break; + sceGuSendCommandi(settings->diffuse, color & 0xffffff); + break; + } + break; + + case GU_SPECULAR: + sceGuSendCommandi(settings->specular, color & 0xffffff); + break; + case GU_DIFFUSE_AND_SPECULAR: + { + sceGuSendCommandi(settings->diffuse, color & 0xffffff); + break; + sceGuSendCommandi(settings->specular, color & 0xffffff); + break; + } + break; + } +} + +static inline void sceGuLightMode(int mode) +{ + sceGuSendCommandi(LIGHT_MODE, mode); +} + +static inline void sceGuLightSpot(int light, const ScePspFVector3 *direction, float exponent, float cutoff) +{ + GuLightSettings *settings = &light_settings[light]; + + sceGuSendCommandf(settings->exponent, exponent); + sceGuSendCommandf(settings->cutoff, cutoff); + + sceGuSendCommandf(settings->xdir, direction->x); + sceGuSendCommandf(settings->ydir, direction->y); + sceGuSendCommandf(settings->zdir, direction->z); +} + +static inline void sceGuClear(int flags) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + unsigned int filter; + struct Vertex + { + u32 color; + u16 x, y, z; + u16 pad; + }; + + switch (gu_draw_buffer.pixel_size) + { + case 0: + filter = context->clear_color & 0xffffff; + break; + case 1: + filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 31); + break; + case 2: + filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 28); + break; + case 3: + filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 24); + break; + default: + filter = 0; + break; + } + + struct Vertex *vertices; + int count; + + if (!(flags & GU_FAST_CLEAR_BIT)) + { + vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex)); + count = 2; + + vertices[0].color = 0; + vertices[0].x = 0; + vertices[0].y = 0; + vertices[0].z = context->clear_depth; + + vertices[1].color = filter; + vertices[1].x = gu_draw_buffer.width; + vertices[1].y = gu_draw_buffer.height; + vertices[1].z = context->clear_depth; + } + else + { + struct Vertex *curr; + unsigned int i; + count = ((gu_draw_buffer.width + 63) / 64) * 2; + vertices = (struct Vertex *)sceGuGetMemory(count * sizeof(struct Vertex)); + curr = vertices; + + for (i = 0; i < count; ++i, ++curr) + { + unsigned int j, k; + + j = i >> 1; + k = (i & 1); + + curr->color = filter; + curr->x = (j + k) * 64; + curr->y = k * gu_draw_buffer.height; + curr->z = context->clear_depth; + } + } + + sceGuSendCommandi(CLEAR_MODE, ((flags & (GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT | GU_DEPTH_BUFFER_BIT)) << 8) | 0x01); + sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, count, 0, vertices); + sceGuSendCommandi(CLEAR_MODE, 0); +} + +static inline void sceGuClearColor(unsigned int color) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + context->clear_color = color; +} + +static inline void sceGuClearDepth(unsigned int depth) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + context->clear_depth = depth; +} + +static inline void sceGuClearStencil(unsigned int stencil) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + context->clear_stencil = stencil; +} + +static inline void sceGuPixelMask(unsigned int mask) +{ + sceGuSendCommandi(MASK_COLOR, mask & 0xffffff); + sceGuSendCommandi(MASK_ALPHA, mask >> 24); +} + +static inline void sceGuColor(unsigned int color) +{ + sceGuMaterial(7, color); +} + +static inline void sceGuColorFunc(int func, unsigned int color, unsigned int mask) +{ + sceGuSendCommandi(COLOR_TEST, func & 0x03); + sceGuSendCommandi(COLOR_REF, color & 0xffffff); + sceGuSendCommandi(COLOR_TESTMASK, mask); +} + +static inline void sceGuMaterial(int mode, int color) +{ + if (mode & 0x01) + { + sceGuSendCommandi(AMBIENT_COLOR, color & 0xffffff); + sceGuSendCommandi(AMBIENT_ALPHA, color >> 24); + } + + if (mode & 0x02) + sceGuSendCommandi(MATERIAL_DIFFUSE, color & 0xffffff); + + if (mode & 0x04) + sceGuSendCommandi(MATERIAL_SPECULAR, color & 0xffffff); +} + +static inline void sceGuColorMaterial(int components) +{ + sceGuSendCommandi(MATERIAL_COLOR, components); +} + +static inline void sceGuAlphaFunc(int a0, int a1, int a2) +{ + int arg = a0 | ((a1 & 0xff) << 8) | ((a2 & 0xff) << 16); + sceGuSendCommandi(ALPHA_TEST, arg); +} + +static inline void sceGuAmbient(unsigned int color) +{ + sceGuSendCommandi(AMBIENT_LIGHT_COLOR, (color & 0xffffff)); + sceGuSendCommandi(AMBIENT_LIGHT_ALPHA, (color >> 24)); +} + +static inline void sceGuAmbientColor(unsigned int color) +{ + sceGuSendCommandi(AMBIENT_COLOR, color & 0xffffff); + sceGuSendCommandi(AMBIENT_ALPHA, color >> 24); +} + +static void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix) +{ + sceGuSendCommandi(BLEND_MODE, src | (dest << 4) | (op << 8)); + sceGuSendCommandi(BLEND_FIXED_A, srcfix & 0xffffff); + sceGuSendCommandi(BLEND_FIXED_B, destfix & 0xffffff); +} + +static inline void sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int diffuse, unsigned int specular) +{ + sceGuSendCommandi(MATERIAL_EMISSIVE, emissive & 0xffffff); + sceGuSendCommandi(MATERIAL_DIFFUSE, diffuse & 0xffffff); + sceGuSendCommandi(AMBIENT_COLOR, ambient & 0xffffff); + sceGuSendCommandi(MATERIAL_SPECULAR, specular & 0xffffff); +} + +static inline void sceGuStencilFunc(int func, int ref, int mask) +{ + sceGuSendCommandi(STENCIL_TEST, func | ((ref & 0xff) << 8) | ((mask & 0xff) << 16)); +} + +static inline void sceGuStencilOp(int fail, int zfail, int zpass) +{ + sceGuSendCommandi(STENCIL_OP, fail | (zfail << 8) | (zpass << 16)); +} + +static inline void sceGuSpecular(float power) // specular power +{ + sceGuSendCommandf(MATERIAL_SPECULAR_COEF, power); +} + +static inline void sceGuFrontFace(int order) +{ + sceGuSendCommandi(CULL, order ? 0 : 1); +} + +static inline void sceGuLogicalOp(int op) +{ + sceGuSendCommandi(LOGIC_OP, op & 0x0f); +} + +static inline void sceGuSetDither(const ScePspIMatrix4 *matrix) +{ + sceGuSendCommandi(DITH0, (matrix->x.x & 0x0f) | ((matrix->x.y & 0x0f) << 4) | ((matrix->x.z & 0x0f) << 8) | ((matrix->x.w & 0x0f) << 12)); + sceGuSendCommandi(DITH1, (matrix->y.x & 0x0f) | ((matrix->y.y & 0x0f) << 4) | ((matrix->y.z & 0x0f) << 8) | ((matrix->y.w & 0x0f) << 12)); + sceGuSendCommandi(DITH2, (matrix->z.x & 0x0f) | ((matrix->z.y & 0x0f) << 4) | ((matrix->z.z & 0x0f) << 8) | ((matrix->z.w & 0x0f) << 12)); + sceGuSendCommandi(DITH3, (matrix->w.x & 0x0f) | ((matrix->w.y & 0x0f) << 4) | ((matrix->w.z & 0x0f) << 8) | ((matrix->w.w & 0x0f) << 12)); +} + +static inline void sceGuShadeModel(int mode) +{ + sceGuSendCommandi(SHADE_MODE, mode ? 1 : 0); +} + +static inline void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void *src, int dx, int dy, int destw, void *dest) +{ + sceGuSendCommandi(TRANSFER_SRC, ((unsigned int)src) & 0xffffff); + sceGuSendCommandi(TRANSFER_SRC_W, ((((unsigned int)src) & 0xff000000) >> 8) | srcw); + sceGuSendCommandi(TRANSFER_SRC_OFFSET, (sy << 10) | sx); + sceGuSendCommandi(TRANSFER_DST, ((unsigned int)dest) & 0xffffff); + sceGuSendCommandi(TRANSFER_DST_W, ((((unsigned int)dest) & 0xff000000) >> 8) | destw); + sceGuSendCommandi(TRANSFER_DST_OFFSET, (dy << 10) | dx); + sceGuSendCommandi(TRANSFER_SIZE, ((height - 1) << 10) | (width - 1)); + sceGuSendCommandi(TRANSFER_START, (psm ^ 0x03) ? 0 : 1); +} + +static inline void sceGuTexEnvColor(unsigned int color) +{ + sceGuSendCommandi(TEX_ENV_COLOR, color & 0xffffff); +} + +static inline void sceGuTexFilter(int min, int mag) +{ + sceGuSendCommandi(TEX_FILTER, (mag << 8) | min); +} + +static inline void sceGuTexFlush(void) +{ + sceGuSendCommandi(TEX_FLUSH, 0); +} + +static void sceGuTexFunc(int tfx, int tcc) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + context->texture_function = (tcc << 8) | tfx; + + sceGuSendCommandi(TEX_FUNC, ((tcc << 8) | tfx) | context->fragment_2x); +} + +static inline void sceGuTexImage(int mipmap, int width, int height, int tbw, const void *tbp) +{ + #define GET_EXP(val) (31 - __builtin_clz(val & 0x3FF)) + + GECommand texAddr = (GECommand)(TEX_ADDR0 + mipmap); + GECommand texBufWidth = (GECommand)(TEX_BUF_WIDTH0 + mipmap); + GECommand texSize = (GECommand)(TEX_SIZE0 + mipmap); + sceGuSendCommandi(texAddr, ((unsigned int)tbp) & 0xffffff); + sceGuSendCommandi(texBufWidth, ((((unsigned int)tbp) >> 8) & 0x0f0000) | tbw); + sceGuSendCommandi(texSize, (GET_EXP(height) << 8) | (GET_EXP(width))); + sceGuTexFlush(); +} + +static inline void sceGuTexLevelMode(unsigned int mode, float bias) +{ + int offset = (int)truncf(bias * 16.0f); + + // mip map bias? + if (offset >= 128) + offset = 128; + else if (offset < -128) + offset = -128; + + sceGuSendCommandi(TEX_LEVEL, (((unsigned int)(offset)) << 16) | mode); +} + +static inline void sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + + context->texture_map_mode = mode & 0x03; + + sceGuSendCommandi(TEX_MAP_MODE, context->texture_proj_map_mode | (mode & 0x03)); + sceGuSendCommandi(TEX_SHADE_MAPPING, (a2 << 8) | (a1 & 0x03)); +} + +static inline void sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + context->texture_mode = tpsm; + + sceGuSendCommandi(TEX_MODE, (maxmips << 16) | (a2 << 8) | (swizzle)); + sceGuSendCommandi(TEX_FORMAT, tpsm); + + sceGuTexFlush(); +} + +static inline void sceGuTexOffset(float u, float v) +{ + sceGuSendCommandf(TEX_OFFSET_U, u); + sceGuSendCommandf(TEX_OFFSET_V, v); +} + +static inline void sceGuTexProjMapMode(int mode) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + + context->texture_proj_map_mode = ((mode & 0x03) << 8); + sceGuSendCommandi(TEX_MAP_MODE, ((mode & 0x03) << 8) | context->texture_map_mode); +} + +static inline void sceGuTexScale(float u, float v) +{ + sceGuSendCommandf(TEX_SCALE_U, u); + sceGuSendCommandf(TEX_SCALE_V, v); +} + +static inline void sceGuTexSlope(float slope) +{ + sceGuSendCommandf(TEX_LOD_SLOPE, slope); +} + +static inline void sceGuTexSync() +{ + sceGuSendCommandi(TEX_SYNC, 0); +} + +static inline void sceGuTexWrap(int u, int v) +{ + sceGuSendCommandi(TEX_WRAP, (v << 8) | (u)); +} + +static inline void sceGuClutLoad(int num_blocks, const void *cbp) +{ + sceGuSendCommandi(CLUT_BUF_PTR, ((unsigned int)cbp) & 0xffffff); + sceGuSendCommandi(CLUT_BUF_WIDTH, (((unsigned int)cbp) >> 8) & 0xf0000); + sceGuSendCommandi(CLUT_LOAD, num_blocks); +} + +static inline void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3) +{ + unsigned int argument = (cpsm) | (shift << 2) | (mask << 8) | (a3 << 16); + sceGuSendCommandi(CLUT_FORMAT, argument); +} + +static void sceGuOffset(unsigned int x, unsigned int y) +{ + sceGuSendCommandi(OFFSET_X, x << 4); + sceGuSendCommandi(OFFSET_Y, y << 4); +} + +static inline void sceGuScissor(int x, int y, int w, int h) +{ + GuContext *context = &gu_contexts[gu_curr_context]; + + context->scissor_start[0] = x; + context->scissor_start[1] = y; + context->scissor_end[0] = w - 1; + context->scissor_end[1] = h - 1; + + if (context->scissor_enable) + { + sceGuSendCommandi(SCISSOR1, (context->scissor_start[1] << 10) | context->scissor_start[0]); + sceGuSendCommandi(SCISSOR2, (context->scissor_end[1] << 10) | context->scissor_end[0]); + } +} + +static inline void sceGuViewport(int cx, int cy, int width, int height) +{ + sceGuSendCommandf(VIEWPORT_X_SCALE, (float)(width >> 1)); + sceGuSendCommandf(VIEWPORT_Y_SCALE, (float)((-height) >> 1)); + sceGuSendCommandf(VIEWPORT_X_CENTER, (float)cx); + sceGuSendCommandf(VIEWPORT_Y_CENTER, (float)cy); +} + +static inline void sceGuDrawBezier(int vertex_type, int ucount, int vcount, const void *indices, const void *vertices) +{ + if (vertex_type) + sceGuSendCommandi(VERTEX_TYPE, vertex_type); + + if (indices) + { + sceGuSendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); + sceGuSendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); + } + + if (vertices) + { + sceGuSendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); + sceGuSendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); + } + + sceGuSendCommandi(BEZIER, (vcount << 8) | ucount); +} + +static inline void sceGuPatchDivide(unsigned int a0, unsigned int a1) +{ + sceGuSendCommandi(PATCH_DIVISION, (a1 << 8) | a0); +} + +static inline void sceGuPatchFrontFace(unsigned int a0) +{ + sceGuSendCommandi(PATCH_FACING, a0); +} + +static inline void sceGuPatchPrim(int prim) +{ + switch (prim) + { + case GU_POINTS: + sceGuSendCommandi(PATCH_PRIMITIVE, 2); + break; + case GU_LINE_STRIP: + sceGuSendCommandi(PATCH_PRIMITIVE, 1); + break; + case GU_TRIANGLE_STRIP: + sceGuSendCommandi(PATCH_PRIMITIVE, 0); + break; + } +} + +static inline void sceGuDrawSpline(int vertex_type, int ucount, int vcount, int uedge, int vedge, const void *indices, const void *vertices) +{ + if (vertex_type) + sceGuSendCommandi(VERTEX_TYPE, vertex_type); + + if (indices) + { + sceGuSendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); + sceGuSendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); + } + + if (vertices) + { + sceGuSendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); + sceGuSendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); + } + + sceGuSendCommandi(SPLINE, (vedge << 18) | (uedge << 16) | (vcount << 8) | ucount); +} + +static inline void sceGuSetMatrix(int type, const ScePspFMatrix4 *matrix) +{ + unsigned int i, j; + const float *fmatrix = (const float *)matrix; + + switch (type) + { + case 0: + { + sceGuSendCommandf(PROJ_MATRIX_NUMBER, 0); + + // 4*4 - most probably projection + for (i = 0; i < 16; ++i) + sceGuSendCommandf(PROJ_MATRIX_DATA, fmatrix[i]); + } + break; + + case 1: + { + sceGuSendCommandf(VIEW_MATRIX_NUMBER, 0); + + // 4*4 -> 3*4 - view matrix? + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 3; ++j) + sceGuSendCommandf(VIEW_MATRIX_DATA, fmatrix[j + i * 4]); + } + } + break; + + case 2: + { + sceGuSendCommandf(WORLD_MATRIX_NUMBER, 0); + + // 4*4 -> 3*4 - ??? + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 3; ++j) + sceGuSendCommandf(WORLD_MATRIX_DATA, fmatrix[j + i * 4]); + } + } + break; + + case 3: + { + sceGuSendCommandf(TGEN_MATRIX_NUMBER, 0); + + // 4*4 -> 3*4 - ??? + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 3; ++j) + sceGuSendCommandf(TGEN_MATRIX_DATA, fmatrix[j + i * 4]); + } + } + break; + } +} + +static inline void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4 *matrix) +{ + unsigned int offset = ((index << 1) + index) << 2; // 3*4 matrix + unsigned int i, j; + const float *fmatrix = (const float *)matrix; + + sceGuSendCommandi(BONE_MATRIX_NUMBER, offset); + for (i = 0; i < 4; ++i) + { + for (j = 0; j < 3; ++j) + { + sceGuSendCommandf(BONE_MATRIX_DATA, fmatrix[j + (i << 2)]); + } + } +} + +static inline void sceGuMorphWeight(int index, float weight) +{ + sceGuSendCommandf(44 + index, weight); +} + +static inline void sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, const void *indices, const void *vertices) +{ + if (vertex_type) + sceGuSendCommandi(VERTEX_TYPE, vertex_type); + + if (indices) + { + sceGuSendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); + sceGuSendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); + } + + if (vertices) + { + sceGuSendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); + sceGuSendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); + } + + if (a3 > 0) + { + // TODO: not sure about this loop, might be off. review + int i; + for (i = a3 - 1; i > 0; --i) + sceGuSendCommandi(PRIM, (primitive_type << 16) | count); + sendCommandiStall(PRIM, (primitive_type << 16) | count); + } +} + +static inline void guSwapBuffersBehaviour(int behaviour) +{ + gu_settings.swapBuffersBehaviour = behaviour; +} + +static inline void guSwapBuffersCallback(GuSwapBuffersCallback callback) +{ + gu_settings.swapBuffersCallback = callback; +} + +static inline int guGetDisplayState() +{ + return gu_display_on; +} /**@}*/ diff --git a/src/gu/resetValues.c b/src/gu/resetValues.c deleted file mode 100644 index 10c596a4f9..0000000000 --- a/src/gu/resetValues.c +++ /dev/null @@ -1,63 +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 resetValues() -{ - unsigned int i; - - gu_init = 0; - - gu_states = 0; - gu_current_frame = 0; - gu_object_stack_depth = 0; - - gu_display_on = 0; - gu_call_mode = 0; - - gu_draw_buffer.pixel_size = 1; - gu_draw_buffer.frame_width = 0; - gu_draw_buffer.frame_buffer = 0; - gu_draw_buffer.disp_buffer = 0; - gu_draw_buffer.depth_buffer = 0; - gu_draw_buffer.depth_width = 0; - gu_draw_buffer.width = 480; - gu_draw_buffer.height = 272; - - for (i = 0; i < 3; ++i) - { - GuContext* context = &gu_contexts[i]; - - context->scissor_enable = 0; - context->scissor_start[0] = 0; - context->scissor_start[1] = 0; - context->scissor_end[0] = 0; - context->scissor_end[1] = 0; - - context->near_plane = 0; - context->far_plane = 1; - - context->depth_offset = 0; - context->fragment_2x = 0; - context->texture_function = 0; - context->texture_proj_map_mode = 0; - context->texture_map_mode = 0; - context->sprite_mode[0] = 0; - context->sprite_mode[1] = 0; - context->sprite_mode[2] = 0; - context->sprite_mode[3] = 0; - context->clear_color = 0; - context->clear_stencil = 0; - context->clear_depth = 0xffff; - context->texture_mode = 0; - } - - gu_settings.sig = 0; - gu_settings.fin = 0; -} diff --git a/src/gu/sceGuAlphaFunc.c b/src/gu/sceGuAlphaFunc.c deleted file mode 100644 index 115a279df9..0000000000 --- a/src/gu/sceGuAlphaFunc.c +++ /dev/null @@ -1,15 +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 sceGuAlphaFunc(int a0, int a1, int a2) -{ - int arg = a0 | ((a1 & 0xff) << 8) | ((a2 & 0xff) << 16); - sendCommandi(ALPHA_TEST, arg); -} diff --git a/src/gu/sceGuAmbient.c b/src/gu/sceGuAmbient.c deleted file mode 100644 index 4326b6177f..0000000000 --- a/src/gu/sceGuAmbient.c +++ /dev/null @@ -1,15 +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 sceGuAmbient(unsigned int color) -{ - sendCommandi(AMBIENT_LIGHT_COLOR,(color & 0xffffff)); - sendCommandi(AMBIENT_LIGHT_ALPHA,(color >> 24)); -} diff --git a/src/gu/sceGuAmbientColor.c b/src/gu/sceGuAmbientColor.c deleted file mode 100644 index b5d4faa920..0000000000 --- a/src/gu/sceGuAmbientColor.c +++ /dev/null @@ -1,15 +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 sceGuAmbientColor(unsigned int color) -{ - sendCommandi(AMBIENT_COLOR, color & 0xffffff); - sendCommandi(AMBIENT_ALPHA, color >> 24); -} diff --git a/src/gu/sceGuBeginObject.c b/src/gu/sceGuBeginObject.c deleted file mode 100644 index fd4c44dd8b..0000000000 --- a/src/gu/sceGuBeginObject.c +++ /dev/null @@ -1,37 +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 sceGuBeginObject(int vertex_type, int a1, const void *indices, const void *vertices) -{ - if (vertex_type) - sendCommandi(VERTEX_TYPE, vertex_type); - - if (indices) - { - sendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); - sendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); - } - - if (vertices) - { - sendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0x0f0000); - sendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); - } - - sendCommandi(BOUNDING_BOX, a1); - - // store start to new object - - gu_object_stack[gu_object_stack_depth++] = gu_list->current; - - // dummy commands, overwritten in sceGuEndObject() - sendCommandi(BASE, 0); - sendCommandi(BJUMP, 0); -} diff --git a/src/gu/sceGuBlendFunc.c b/src/gu/sceGuBlendFunc.c deleted file mode 100644 index 6a1db17201..0000000000 --- a/src/gu/sceGuBlendFunc.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 sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix) -{ - sendCommandi(BLEND_MODE, src | (dest << 4) | (op << 8)); - sendCommandi(BLEND_FIXED_A, srcfix & 0xffffff); - sendCommandi(BLEND_FIXED_B, destfix & 0xffffff); -} diff --git a/src/gu/sceGuBoneMatrix.c b/src/gu/sceGuBoneMatrix.c deleted file mode 100644 index dc3ec15a8c..0000000000 --- a/src/gu/sceGuBoneMatrix.c +++ /dev/null @@ -1,25 +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 sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4 *matrix) -{ - unsigned int offset = ((index << 1) + index) << 2; // 3*4 matrix - unsigned int i, j; - const float *fmatrix = (const float *)matrix; - - sendCommandi(BONE_MATRIX_NUMBER, offset); - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 3; ++j) - { - sendCommandf(BONE_MATRIX_DATA, fmatrix[j + (i << 2)]); - } - } -} diff --git a/src/gu/sceGuBreak.c b/src/gu/sceGuBreak.c deleted file mode 100644 index 4ed549c7d0..0000000000 --- a/src/gu/sceGuBreak.c +++ /dev/null @@ -1,15 +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 sceGuBreak(int a0) -{ - // FIXME - //sceGeBreak(a0,0x527a68); -} diff --git a/src/gu/sceGuCallList.c b/src/gu/sceGuCallList.c deleted file mode 100644 index 6b63ce5ee3..0000000000 --- a/src/gu/sceGuCallList.c +++ /dev/null @@ -1,26 +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 sceGuCallList(const void *list) -{ - unsigned int list_addr = (unsigned int)list; - - if (gu_call_mode == 1) - { - sendCommandi(SIGNAL, (list_addr >> 16) | 0x110000); - sendCommandi(END, list_addr & 0xffff); - sendCommandiStall(NOP, 0); - } - else - { - sendCommandi(BASE, (list_addr >> 8) & 0xf0000); - sendCommandiStall(CALL, list_addr & 0xffffff); - } -} diff --git a/src/gu/sceGuCallMode.c b/src/gu/sceGuCallMode.c deleted file mode 100644 index 7721d5c201..0000000000 --- a/src/gu/sceGuCallMode.c +++ /dev/null @@ -1,14 +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 sceGuCallMode(int mode) -{ - gu_call_mode = mode; -} diff --git a/src/gu/sceGuCheckList.c b/src/gu/sceGuCheckList.c deleted file mode 100644 index 7bd2fb04e8..0000000000 --- a/src/gu/sceGuCheckList.c +++ /dev/null @@ -1,14 +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" - -int sceGuCheckList(void) -{ - return ((int)gu_list->current)-((int)gu_list->start); -} diff --git a/src/gu/sceGuClear.c b/src/gu/sceGuClear.c deleted file mode 100644 index 6a44f9c03a..0000000000 --- a/src/gu/sceGuClear.c +++ /dev/null @@ -1,84 +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 sceGuClear(int flags) -{ - GuContext *context = &gu_contexts[gu_curr_context]; - unsigned int filter; - struct Vertex - { - u32 color; - u16 x, y, z; - u16 pad; - }; - - switch (gu_draw_buffer.pixel_size) - { - case 0: - filter = context->clear_color & 0xffffff; - break; - case 1: - filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 31); - break; - case 2: - filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 28); - break; - case 3: - filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 24); - break; - default: - filter = 0; - break; - } - - struct Vertex *vertices; - int count; - - if (!(flags & GU_FAST_CLEAR_BIT)) - { - vertices = (struct Vertex *)sceGuGetMemory(2 * sizeof(struct Vertex)); - count = 2; - - vertices[0].color = 0; - vertices[0].x = 0; - vertices[0].y = 0; - vertices[0].z = context->clear_depth; - - vertices[1].color = filter; - vertices[1].x = gu_draw_buffer.width; - vertices[1].y = gu_draw_buffer.height; - vertices[1].z = context->clear_depth; - } - else - { - struct Vertex *curr; - unsigned int i; - count = ((gu_draw_buffer.width + 63) / 64) * 2; - vertices = (struct Vertex *)sceGuGetMemory(count * sizeof(struct Vertex)); - curr = vertices; - - for (i = 0; i < count; ++i, ++curr) - { - unsigned int j, k; - - j = i >> 1; - k = (i & 1); - - curr->color = filter; - curr->x = (j + k) * 64; - curr->y = k * gu_draw_buffer.height; - curr->z = context->clear_depth; - } - } - - sendCommandi(CLEAR_MODE, ((flags & (GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT | GU_DEPTH_BUFFER_BIT)) << 8) | 0x01); - sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, count, 0, vertices); - sendCommandi(CLEAR_MODE, 0); -} diff --git a/src/gu/sceGuClearColor.c b/src/gu/sceGuClearColor.c deleted file mode 100644 index 1655c55ef3..0000000000 --- a/src/gu/sceGuClearColor.c +++ /dev/null @@ -1,15 +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 sceGuClearColor(unsigned int color) -{ - GuContext* context = &gu_contexts[gu_curr_context]; - context->clear_color = color; -} diff --git a/src/gu/sceGuClearDepth.c b/src/gu/sceGuClearDepth.c deleted file mode 100644 index 3b61831e2c..0000000000 --- a/src/gu/sceGuClearDepth.c +++ /dev/null @@ -1,15 +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 sceGuClearDepth(unsigned int depth) -{ - GuContext* context = &gu_contexts[gu_curr_context]; - context->clear_depth = depth; -} diff --git a/src/gu/sceGuClearStencil.c b/src/gu/sceGuClearStencil.c deleted file mode 100644 index 2527289890..0000000000 --- a/src/gu/sceGuClearStencil.c +++ /dev/null @@ -1,15 +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 sceGuClearStencil(unsigned int stencil) -{ - GuContext* context = &gu_contexts[gu_curr_context]; - context->clear_stencil = stencil; -} diff --git a/src/gu/sceGuClutLoad.c b/src/gu/sceGuClutLoad.c deleted file mode 100644 index 97c640747b..0000000000 --- a/src/gu/sceGuClutLoad.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 sceGuClutLoad(int num_blocks, const void *cbp) -{ - sendCommandi(CLUT_BUF_PTR, ((unsigned int)cbp) & 0xffffff); - sendCommandi(CLUT_BUF_WIDTH, (((unsigned int)cbp) >> 8) & 0xf0000); - sendCommandi(CLUT_LOAD, num_blocks); -} diff --git a/src/gu/sceGuClutMode.c b/src/gu/sceGuClutMode.c deleted file mode 100644 index 25099f38da..0000000000 --- a/src/gu/sceGuClutMode.c +++ /dev/null @@ -1,15 +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 sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3) -{ - unsigned int argument = (cpsm) | (shift << 2) | (mask << 8) | (a3 << 16); - sendCommandi(CLUT_FORMAT, argument); -} diff --git a/src/gu/sceGuColor.c b/src/gu/sceGuColor.c deleted file mode 100644 index 4ccc45499c..0000000000 --- a/src/gu/sceGuColor.c +++ /dev/null @@ -1,14 +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 sceGuColor(unsigned int color) -{ - sceGuMaterial(7,color); -} diff --git a/src/gu/sceGuColorFunc.c b/src/gu/sceGuColorFunc.c deleted file mode 100644 index 420d8afc18..0000000000 --- a/src/gu/sceGuColorFunc.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 sceGuColorFunc(int func, unsigned int color, unsigned int mask) -{ - sendCommandi(COLOR_TEST, func & 0x03); - sendCommandi(COLOR_REF, color & 0xffffff); - sendCommandi(COLOR_TESTMASK, mask); -} diff --git a/src/gu/sceGuColorMaterial.c b/src/gu/sceGuColorMaterial.c deleted file mode 100644 index 236ced50fa..0000000000 --- a/src/gu/sceGuColorMaterial.c +++ /dev/null @@ -1,14 +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 sceGuColorMaterial(int a0) -{ - sendCommandi(MATERIAL_COLOR, a0); -} diff --git a/src/gu/sceGuContinue.c b/src/gu/sceGuContinue.c deleted file mode 100644 index f3a5d8c7d7..0000000000 --- a/src/gu/sceGuContinue.c +++ /dev/null @@ -1,15 +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 sceGuContinue(void) -{ - // FIXME - //sceGeContinue(); -} diff --git a/src/gu/sceGuCopyImage.c b/src/gu/sceGuCopyImage.c deleted file mode 100644 index 2c59cdd806..0000000000 --- a/src/gu/sceGuCopyImage.c +++ /dev/null @@ -1,21 +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 sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void *src, int dx, int dy, int destw, void *dest) -{ - sendCommandi(TRANSFER_SRC, ((unsigned int)src) & 0xffffff); - sendCommandi(TRANSFER_SRC_W, ((((unsigned int)src) & 0xff000000) >> 8) | srcw); - sendCommandi(TRANSFER_SRC_OFFSET, (sy << 10) | sx); - sendCommandi(TRANSFER_DST, ((unsigned int)dest) & 0xffffff); - sendCommandi(TRANSFER_DST_W, ((((unsigned int)dest) & 0xff000000) >> 8) | destw); - sendCommandi(TRANSFER_DST_OFFSET, (dy << 10) | dx); - sendCommandi(TRANSFER_SIZE, ((height - 1) << 10) | (width - 1)); - sendCommandi(TRANSFER_START, (psm ^ 0x03) ? 0 : 1); -} diff --git a/src/gu/sceGuDepthBuffer.c b/src/gu/sceGuDepthBuffer.c deleted file mode 100644 index a7792e4ece..0000000000 --- a/src/gu/sceGuDepthBuffer.c +++ /dev/null @@ -1,20 +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 sceGuDepthBuffer(void *zbp, int zbw) -{ - gu_draw_buffer.depth_buffer = zbp; - - if (!gu_draw_buffer.depth_width || (gu_draw_buffer.depth_width != zbw)) - gu_draw_buffer.depth_width = zbw; - - sendCommandi(Z_BUF_PTR, ((unsigned int)zbp) & 0xffffff); - sendCommandi(Z_BUF_WIDTH, ((((unsigned int)zbp) & 0xff000000) >> 8) | zbw); -} diff --git a/src/gu/sceGuDepthFunc.c b/src/gu/sceGuDepthFunc.c deleted file mode 100644 index f410d42991..0000000000 --- a/src/gu/sceGuDepthFunc.c +++ /dev/null @@ -1,14 +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 sceGuDepthFunc(int function) -{ - sendCommandi(Z_TEST, function); -} diff --git a/src/gu/sceGuDepthMask.c b/src/gu/sceGuDepthMask.c deleted file mode 100644 index a4046b60ea..0000000000 --- a/src/gu/sceGuDepthMask.c +++ /dev/null @@ -1,14 +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 sceGuDepthMask(int mask) -{ - sendCommandi(Z_MASK, mask); -} diff --git a/src/gu/sceGuDepthOffset.c b/src/gu/sceGuDepthOffset.c deleted file mode 100644 index e794be179e..0000000000 --- a/src/gu/sceGuDepthOffset.c +++ /dev/null @@ -1,17 +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 sceGuDepthOffset(unsigned int offset) -{ - GuContext* context = &gu_contexts[gu_curr_context]; - context->depth_offset = offset; - - sceGuDepthRange(context->near_plane,context->far_plane); -} diff --git a/src/gu/sceGuDepthRange.c b/src/gu/sceGuDepthRange.c deleted file mode 100644 index e5642a22c1..0000000000 --- a/src/gu/sceGuDepthRange.c +++ /dev/null @@ -1,34 +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 sceGuDepthRange(int near, int far) -{ - GuContext *context = &gu_contexts[gu_curr_context]; - - unsigned int max = (unsigned int)near + (unsigned int)far; - int val = (int)((max >> 31) + max); - float z = (float)(val >> 1); - - context->near_plane = near; - context->far_plane = far; - - sendCommandf(VIEWPORT_Z_SCALE, z - ((float)near)); - sendCommandf(VIEWPORT_Z_CENTER, z + ((float)context->depth_offset)); - - if (near > far) - { - int temp = near; - near = far; - far = temp; - } - - sendCommandi(MIN_Z, near); - sendCommandi(MAX_Z, far); -} diff --git a/src/gu/sceGuDisable.c b/src/gu/sceGuDisable.c deleted file mode 100644 index 461fbf5b75..0000000000 --- a/src/gu/sceGuDisable.c +++ /dev/null @@ -1,94 +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 sceGuDisable(int state) -{ - switch (state) - { - case GU_ALPHA_TEST: - sendCommandi(ALPHA_TEST_ENABLE, 0); - break; - case GU_DEPTH_TEST: - sendCommandi(Z_TEST_ENABLE, 0); - break; - case GU_SCISSOR_TEST: - { - GuContext *context = &gu_contexts[gu_curr_context]; - context->scissor_enable = 0; - sendCommandi(SCISSOR1, 0); - sendCommandi(SCISSOR2, ((gu_draw_buffer.height - 1) << 10) | (gu_draw_buffer.width - 1)); - } - break; - case GU_STENCIL_TEST: - sendCommandi(STENCIL_TEST_ENABLE, 0); - break; - case GU_BLEND: - sendCommandi(ALPHA_BLEND_ENABLE, 0); - break; - case GU_CULL_FACE: - sendCommandi(CULL_FACE_ENABLE, 0); - break; - case GU_DITHER: - sendCommandi(DITHER_ENABLE, 0); - break; - case GU_FOG: - sendCommandi(FOG_ENABLE, 0); - break; - case GU_CLIP_PLANES: - sendCommandi(DEPTH_CLIP_ENABLE, 0); - break; - case GU_TEXTURE_2D: - sendCommandi(TEXTURE_ENABLE, 0); - break; - case GU_LIGHTING: - sendCommandi(LIGHTING_ENABLE, 0); - break; - case GU_LIGHT0: - sendCommandi(LIGHT_ENABLE0, 0); - break; - case GU_LIGHT1: - sendCommandi(LIGHT_ENABLE1, 0); - break; - case GU_LIGHT2: - sendCommandi(LIGHT_ENABLE2, 0); - break; - case GU_LIGHT3: - sendCommandi(LIGHT_ENABLE3, 0); - break; - case GU_LINE_SMOOTH: - sendCommandi(ANTI_ALIAS_ENABLE, 0); - break; - case GU_PATCH_CULL_FACE: - sendCommandi(PATCH_CULL_ENABLE, 0); - break; - case GU_COLOR_TEST: - sendCommandi(COLOR_TEST_ENABLE, 0); - break; - case GU_COLOR_LOGIC_OP: - sendCommandi(LOGIC_OP_ENABLE, 0); - break; - case GU_FACE_NORMAL_REVERSE: - sendCommandi(NORMAL_REVERSE, 0); - break; - case GU_PATCH_FACE: - sendCommandi(PATCH_FACING, 0); - break; - case GU_FRAGMENT_2X: - { - GuContext *context = &gu_contexts[gu_curr_context]; - context->fragment_2x = 0; - sendCommandi(TEX_FUNC, context->texture_function); - } - break; - } - - if (state < 22) - gu_states &= ~(1 << state); -} diff --git a/src/gu/sceGuDispBuffer.c b/src/gu/sceGuDispBuffer.c deleted file mode 100644 index 0436522e47..0000000000 --- a/src/gu/sceGuDispBuffer.c +++ /dev/null @@ -1,34 +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 -#include - -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)); -} - -void sceGuDispBuffer(int width, int height, void *dispbp, int dispbw) -{ - gu_draw_buffer.width = width; - gu_draw_buffer.height = height; - gu_draw_buffer.disp_buffer = dispbp; - - if (!gu_draw_buffer.frame_width || (gu_draw_buffer.frame_width != dispbw)) - gu_draw_buffer.frame_width = dispbw; - - drawRegion(0, 0, gu_draw_buffer.width, gu_draw_buffer.height); - sceDisplaySetMode(0, gu_draw_buffer.width, gu_draw_buffer.height); - - if (gu_display_on) - sceDisplaySetFrameBuf((void *)(((unsigned int)ge_edram_address) + ((unsigned int)gu_draw_buffer.disp_buffer)), dispbw, gu_draw_buffer.pixel_size, PSP_DISPLAY_SETBUF_NEXTFRAME); -} diff --git a/src/gu/sceGuDisplay.c b/src/gu/sceGuDisplay.c deleted file mode 100644 index 6006c524af..0000000000 --- a/src/gu/sceGuDisplay.c +++ /dev/null @@ -1,28 +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 -#include - -int sceGuDisplay(int state) -{ - if (state) - sceDisplaySetFrameBuf((void*)((unsigned int)ge_edram_address+(unsigned int)gu_draw_buffer.disp_buffer),gu_draw_buffer.frame_width,gu_draw_buffer.pixel_size,PSP_DISPLAY_SETBUF_NEXTFRAME); - else - sceDisplaySetFrameBuf(0,0,0,PSP_DISPLAY_SETBUF_NEXTFRAME); - - gu_display_on = state; - return state; -} - -int guGetDisplayState() -{ - return gu_display_on; -} diff --git a/src/gu/sceGuDrawArray.c b/src/gu/sceGuDrawArray.c deleted file mode 100644 index 266eb2b8ab..0000000000 --- a/src/gu/sceGuDrawArray.c +++ /dev/null @@ -1,29 +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 sceGuDrawArray(int prim, int vtype, int count, const void *indices, const void *vertices) -{ - if (vtype) - sendCommandi(VERTEX_TYPE, vtype); - - if (indices) - { - sendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); - sendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); - } - - if (vertices) - { - sendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); - sendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); - } - - sendCommandiStall(PRIM, (prim << 16) | count); -} diff --git a/src/gu/sceGuDrawArrayN.c b/src/gu/sceGuDrawArrayN.c deleted file mode 100644 index efd6b7f87f..0000000000 --- a/src/gu/sceGuDrawArrayN.c +++ /dev/null @@ -1,36 +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 sceGuDrawArrayN(int primitive_type, int vertex_type, int count, int a3, const void *indices, const void *vertices) -{ - if (vertex_type) - sendCommandi(VERTEX_TYPE, vertex_type); - - if (indices) - { - sendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); - sendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); - } - - if (vertices) - { - sendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); - sendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); - } - - if (a3 > 0) - { - // TODO: not sure about this loop, might be off. review - int i; - for (i = a3 - 1; i > 0; --i) - sendCommandi(PRIM, (primitive_type << 16) | count); - sendCommandiStall(PRIM, (primitive_type << 16) | count); - } -} diff --git a/src/gu/sceGuDrawBezier.c b/src/gu/sceGuDrawBezier.c deleted file mode 100644 index a5ccd00945..0000000000 --- a/src/gu/sceGuDrawBezier.c +++ /dev/null @@ -1,29 +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 sceGuDrawBezier(int vertex_type, int ucount, int vcount, const void *indices, const void *vertices) -{ - if (vertex_type) - sendCommandi(VERTEX_TYPE, vertex_type); - - if (indices) - { - sendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); - sendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); - } - - if (vertices) - { - sendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); - sendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); - } - - sendCommandi(BEZIER, (vcount << 8) | ucount); -} diff --git a/src/gu/sceGuDrawBuffer.c b/src/gu/sceGuDrawBuffer.c deleted file mode 100644 index b3f7bdf90a..0000000000 --- a/src/gu/sceGuDrawBuffer.c +++ /dev/null @@ -1,28 +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 sceGuDrawBuffer(int psm, void *fbp, int frame_width) -{ - gu_draw_buffer.pixel_size = psm; - gu_draw_buffer.frame_width = frame_width; - gu_draw_buffer.frame_buffer = fbp; - - if (!gu_draw_buffer.depth_buffer && gu_draw_buffer.height) - gu_draw_buffer.depth_buffer = (void *)(((unsigned int)fbp) + (unsigned int)((gu_draw_buffer.height * frame_width) << 2)); - - if (!gu_draw_buffer.depth_width) - gu_draw_buffer.depth_width = frame_width; - - sendCommandi(FRAMEBUF_PIX_FORMAT, psm); - sendCommandi(FRAME_BUF_PTR, ((unsigned int)gu_draw_buffer.frame_buffer) & 0xffffff); - sendCommandi(FRAME_BUF_WIDTH, ((((unsigned int)gu_draw_buffer.frame_buffer) & 0xff000000) >> 8) | gu_draw_buffer.frame_width); - sendCommandi(Z_BUF_PTR, ((unsigned int)gu_draw_buffer.depth_buffer) & 0xffffff); - sendCommandi(Z_BUF_WIDTH, ((((unsigned int)gu_draw_buffer.depth_buffer) & 0xff000000) >> 8) | gu_draw_buffer.depth_width); -} diff --git a/src/gu/sceGuDrawBufferList.c b/src/gu/sceGuDrawBufferList.c deleted file mode 100644 index 6fe1cf3d7f..0000000000 --- a/src/gu/sceGuDrawBufferList.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 sceGuDrawBufferList(int psm, void *fbp, int fbw) -{ - sendCommandi(FRAMEBUF_PIX_FORMAT, psm); - sendCommandi(FRAME_BUF_PTR, ((unsigned int)fbp) & 0xffffff); - sendCommandi(FRAME_BUF_WIDTH, ((((unsigned int)fbp) & 0xff000000) >> 8) | fbw); -} diff --git a/src/gu/sceGuDrawSpline.c b/src/gu/sceGuDrawSpline.c deleted file mode 100644 index 7c475a5b2f..0000000000 --- a/src/gu/sceGuDrawSpline.c +++ /dev/null @@ -1,29 +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 sceGuDrawSpline(int vertex_type, int ucount, int vcount, int uedge, int vedge, const void *indices, const void *vertices) -{ - if (vertex_type) - sendCommandi(VERTEX_TYPE, vertex_type); - - if (indices) - { - sendCommandi(BASE, (((unsigned int)indices) >> 8) & 0xf0000); - sendCommandi(IADDR, ((unsigned int)indices) & 0xffffff); - } - - if (vertices) - { - sendCommandi(BASE, (((unsigned int)vertices) >> 8) & 0xf0000); - sendCommandi(VADDR, ((unsigned int)vertices) & 0xffffff); - } - - sendCommandi(SPLINE, (vedge << 18) | (uedge << 16) | (vcount << 8) | ucount); -} diff --git a/src/gu/sceGuEnable.c b/src/gu/sceGuEnable.c deleted file mode 100644 index ad6d38de4b..0000000000 --- a/src/gu/sceGuEnable.c +++ /dev/null @@ -1,94 +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 sceGuEnable(int state) -{ - switch (state) - { - case GU_ALPHA_TEST: - sendCommandi(ALPHA_TEST_ENABLE, 1); - break; - case GU_DEPTH_TEST: - sendCommandi(Z_TEST_ENABLE, 1); - break; - case GU_SCISSOR_TEST: - { - GuContext *context = &gu_contexts[gu_curr_context]; - context->scissor_enable = 1; - sendCommandi(SCISSOR1, (context->scissor_start[1] << 10) | context->scissor_start[0]); - sendCommandi(SCISSOR2, (context->scissor_end[1] << 10) | context->scissor_end[0]); - } - break; - case GU_STENCIL_TEST: - sendCommandi(STENCIL_TEST_ENABLE, 1); - break; - case GU_BLEND: - sendCommandi(ALPHA_BLEND_ENABLE, 1); - break; - case GU_CULL_FACE: - sendCommandi(CULL_FACE_ENABLE, 1); - break; - case GU_DITHER: - sendCommandi(DITHER_ENABLE, 1); - break; - case GU_FOG: - sendCommandi(FOG_ENABLE, 1); - break; - case GU_CLIP_PLANES: - sendCommandi(DEPTH_CLIP_ENABLE, 1); - break; - case GU_TEXTURE_2D: - sendCommandi(TEXTURE_ENABLE, 1); - break; - case GU_LIGHTING: - sendCommandi(LIGHTING_ENABLE, 1); - break; - case GU_LIGHT0: - sendCommandi(LIGHT_ENABLE0, 1); - break; - case GU_LIGHT1: - sendCommandi(LIGHT_ENABLE1, 1); - break; - case GU_LIGHT2: - sendCommandi(LIGHT_ENABLE2, 1); - break; - case GU_LIGHT3: - sendCommandi(LIGHT_ENABLE3, 1); - break; - case GU_LINE_SMOOTH: - sendCommandi(ANTI_ALIAS_ENABLE, 1); - break; - case GU_PATCH_CULL_FACE: - sendCommandi(PATCH_CULL_ENABLE, 1); - break; - case GU_COLOR_TEST: - sendCommandi(COLOR_TEST_ENABLE, 1); - break; - case GU_COLOR_LOGIC_OP: - sendCommandi(LOGIC_OP_ENABLE, 1); - break; - case GU_FACE_NORMAL_REVERSE: - sendCommandi(NORMAL_REVERSE, 1); - break; - case GU_PATCH_FACE: - sendCommandi(PATCH_FACING, 1); - break; - case GU_FRAGMENT_2X: - { - GuContext *context = &gu_contexts[gu_curr_context]; - context->fragment_2x = 0x10000; - sendCommandi(TEX_FUNC, 0x10000 | context->texture_function); - } - break; - } - - if (state < 22) - gu_states |= (1 << state); -} diff --git a/src/gu/sceGuEndObject.c b/src/gu/sceGuEndObject.c deleted file mode 100644 index 72d0405e64..0000000000 --- a/src/gu/sceGuEndObject.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" - -void sceGuEndObject(void) -{ - // rewrite commands from sceGuBeginObject() - - unsigned int *current = gu_list->current; - gu_list->current = gu_object_stack[gu_object_stack_depth - 1]; - - sendCommandi(BASE, (((unsigned int)current) >> 8) & 0xf0000); - sendCommandi(BJUMP, ((unsigned int)current) & 0xffffff); - gu_list->current = current; - - gu_object_stack_depth--; -} diff --git a/src/gu/sceGuFinish.c b/src/gu/sceGuFinish.c deleted file mode 100644 index afccb303c5..0000000000 --- a/src/gu/sceGuFinish.c +++ /dev/null @@ -1,81 +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" - -int sceGuFinish(void) -{ - switch (gu_curr_context) - { - case GU_DIRECT: - case GU_SEND: - { - sendCommandi(FINISH, 0); - sendCommandiStall(END, 0); - } - break; - - case GU_CALL: - { - if (gu_call_mode == 1) - { - sendCommandi(SIGNAL, 0x120000); - sendCommandi(END, 0); - sendCommandiStall(NOP, 0); - } - else - { - sendCommandi(RET, 0); - } - } - break; - } - - unsigned int size = ((unsigned int)gu_list->current) - ((unsigned int)gu_list->start); - - // go to parent list - gu_curr_context = gu_list->parent_context; - gu_list = &gu_contexts[gu_curr_context].list; - return size; -} - -int sceGuFinishId(unsigned int id) -{ - switch (gu_curr_context) - { - case GU_DIRECT: - case GU_SEND: - { - sendCommandi(FINISH, id & 0xffff); - sendCommandiStall(END, 0); - } - break; - - case GU_CALL: - { - if (gu_call_mode == 1) - { - sendCommandi(SIGNAL, 0x120000); - sendCommandi(END, 0); - sendCommandiStall(NOP, 0); - } - else - { - sendCommandi(RET, 0); - } - } - break; - } - - unsigned int size = ((unsigned int)gu_list->current) - ((unsigned int)gu_list->start); - - // go to parent list - gu_curr_context = gu_list->parent_context; - gu_list = &gu_contexts[gu_curr_context].list; - return size; -} diff --git a/src/gu/sceGuFog.c b/src/gu/sceGuFog.c deleted file mode 100644 index 2e45cdfc48..0000000000 --- a/src/gu/sceGuFog.c +++ /dev/null @@ -1,21 +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 sceGuFog(float near, float far, unsigned int color) -{ - float distance = far - near; - - if (distance) - distance = 1.0f / distance; - - sendCommandi(FOG_COLOR, color & 0xffffff); - sendCommandf(FOG1, far); - sendCommandf(FOG2, distance); -} diff --git a/src/gu/sceGuFrontFace.c b/src/gu/sceGuFrontFace.c deleted file mode 100644 index e2aede145d..0000000000 --- a/src/gu/sceGuFrontFace.c +++ /dev/null @@ -1,14 +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 sceGuFrontFace(int order) -{ - sendCommandi(CULL, order ? 0 : 1); -} diff --git a/src/gu/sceGuGetAllStatus.c b/src/gu/sceGuGetAllStatus.c deleted file mode 100644 index 724ca54dea..0000000000 --- a/src/gu/sceGuGetAllStatus.c +++ /dev/null @@ -1,14 +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" - -int sceGuGetAllStatus(void) -{ - return gu_states; -} diff --git a/src/gu/sceGuGetMemory.c b/src/gu/sceGuGetMemory.c index 0a77ca20b7..f84787dc6c 100644 --- a/src/gu/sceGuGetMemory.c +++ b/src/gu/sceGuGetMemory.c @@ -6,7 +6,7 @@ * Copyright (c) 2005 Jesper Svennevid */ -#include "guInternal.h" +#include #include #include diff --git a/src/gu/sceGuGetStatus.c b/src/gu/sceGuGetStatus.c deleted file mode 100644 index 3b3ece2591..0000000000 --- a/src/gu/sceGuGetStatus.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" - -int sceGuGetStatus(int state) -{ - if (state < 22) - return (gu_states >> state) & 1; - return 0; -} diff --git a/src/gu/sceGuInit.c b/src/gu/sceGuInit.c index 46a428f8e0..03006dd209 100644 --- a/src/gu/sceGuInit.c +++ b/src/gu/sceGuInit.c @@ -6,7 +6,7 @@ * Copyright (c) 2005 Jesper Svennevid */ -#include "guInternal.h" +#include #include #include @@ -235,6 +235,60 @@ static unsigned int __attribute__((aligned(16))) ge_init_list[] = ZV(END), }; +static inline void resetValues() +{ + unsigned int i; + + gu_init = 0; + + gu_states = 0; + gu_current_frame = 0; + gu_object_stack_depth = 0; + + gu_display_on = 0; + gu_call_mode = 0; + + gu_draw_buffer.pixel_size = 1; + gu_draw_buffer.frame_width = 0; + gu_draw_buffer.frame_buffer = 0; + gu_draw_buffer.disp_buffer = 0; + gu_draw_buffer.depth_buffer = 0; + gu_draw_buffer.depth_width = 0; + gu_draw_buffer.width = 480; + gu_draw_buffer.height = 272; + + for (i = 0; i < 3; ++i) + { + GuContext* context = &gu_contexts[i]; + + context->scissor_enable = 0; + context->scissor_start[0] = 0; + context->scissor_start[1] = 0; + context->scissor_end[0] = 0; + context->scissor_end[1] = 0; + + context->near_plane = 0; + context->far_plane = 1; + + context->depth_offset = 0; + context->fragment_2x = 0; + context->texture_function = 0; + context->texture_proj_map_mode = 0; + context->texture_map_mode = 0; + context->sprite_mode[0] = 0; + context->sprite_mode[1] = 0; + context->sprite_mode[2] = 0; + context->sprite_mode[3] = 0; + context->clear_color = 0; + context->clear_stencil = 0; + context->clear_depth = 0xffff; + context->texture_mode = 0; + } + + gu_settings.sig = 0; + gu_settings.fin = 0; +} + void callbackFin(int id, void* arg) { GuSettings* settings = (GuSettings*)arg; diff --git a/src/gu/sceGuLight.c b/src/gu/sceGuLight.c deleted file mode 100644 index 897bbb17eb..0000000000 --- a/src/gu/sceGuLight.c +++ /dev/null @@ -1,24 +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 sceGuLight(int light, int type, int components, const ScePspFVector3* position) -{ - GuLightSettings* settings = &light_settings[light]; - - sendCommandf(settings->xpos,position->x); - sendCommandf(settings->ypos,position->y); - sendCommandf(settings->zpos,position->z); - - int kind = 2; - if (components != 8) - kind = (components^6) < 1 ? 1 : 0; - - sendCommandi(settings->type,((type & 0x03) << 8)|kind); -} diff --git a/src/gu/sceGuLightAtt.c b/src/gu/sceGuLightAtt.c deleted file mode 100644 index cc17e25c7f..0000000000 --- a/src/gu/sceGuLightAtt.c +++ /dev/null @@ -1,18 +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 sceGuLightAtt(int light, float atten0, float atten1, float atten2) -{ - GuLightSettings* settings = &light_settings[light]; - - sendCommandf(settings->constant,atten0); - sendCommandf(settings->linear,atten1); - sendCommandf(settings->quadratic,atten2); -} diff --git a/src/gu/sceGuLightColor.c b/src/gu/sceGuLightColor.c deleted file mode 100644 index 0c7201d00f..0000000000 --- a/src/gu/sceGuLightColor.c +++ /dev/null @@ -1,34 +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 sceGuLightColor(int light, int component, unsigned int color) -{ - GuLightSettings* settings = &light_settings[light]; - - switch (component) - { - case GU_AMBIENT: sendCommandi(settings->ambient, color & 0xffffff); break; - case GU_DIFFUSE: sendCommandi(settings->diffuse, color & 0xffffff); break; - case GU_AMBIENT_AND_DIFFUSE: - { - sendCommandi(settings->ambient, color & 0xffffff); break; - sendCommandi(settings->diffuse, color & 0xffffff); break; - } - break; - - case GU_SPECULAR: sendCommandi(settings->specular, color & 0xffffff); break; - case GU_DIFFUSE_AND_SPECULAR: - { - sendCommandi(settings->diffuse, color & 0xffffff); break; - sendCommandi(settings->specular, color & 0xffffff); break; - } - break; - } -} diff --git a/src/gu/sceGuLightMode.c b/src/gu/sceGuLightMode.c deleted file mode 100644 index 1059972d0f..0000000000 --- a/src/gu/sceGuLightMode.c +++ /dev/null @@ -1,14 +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 sceGuLightMode(int mode) -{ - sendCommandi(LIGHT_MODE, mode); -} diff --git a/src/gu/sceGuLightSpot.c b/src/gu/sceGuLightSpot.c deleted file mode 100644 index 6255b35e66..0000000000 --- a/src/gu/sceGuLightSpot.c +++ /dev/null @@ -1,21 +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 sceGuLightSpot(int light, const ScePspFVector3* direction, float exponent, float cutoff) -{ - GuLightSettings* settings = &light_settings[light]; - - sendCommandf(settings->exponent,exponent); - sendCommandf(settings->cutoff,cutoff); - - sendCommandf(settings->xdir,direction->x); - sendCommandf(settings->ydir,direction->y); - sendCommandf(settings->zdir,direction->z); -} diff --git a/src/gu/sceGuLogicalOp.c b/src/gu/sceGuLogicalOp.c deleted file mode 100644 index d524ff265d..0000000000 --- a/src/gu/sceGuLogicalOp.c +++ /dev/null @@ -1,14 +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 sceGuLogicalOp(int op) -{ - sendCommandi(LOGIC_OP, op & 0x0f); -} diff --git a/src/gu/sceGuMaterial.c b/src/gu/sceGuMaterial.c deleted file mode 100644 index bcd038d83d..0000000000 --- a/src/gu/sceGuMaterial.c +++ /dev/null @@ -1,24 +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 sceGuMaterial(int mode, int color) -{ - if (mode & 0x01) - { - sendCommandi(AMBIENT_COLOR, color & 0xffffff); - sendCommandi(AMBIENT_ALPHA, color >> 24); - } - - if (mode & 0x02) - sendCommandi(MATERIAL_DIFFUSE, color & 0xffffff); - - if (mode & 0x04) - sendCommandi(MATERIAL_SPECULAR, color & 0xffffff); -} diff --git a/src/gu/sceGuModelColor.c b/src/gu/sceGuModelColor.c deleted file mode 100644 index c889043af6..0000000000 --- a/src/gu/sceGuModelColor.c +++ /dev/null @@ -1,17 +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 sceGuModelColor(unsigned int emissive, unsigned int ambient, unsigned int diffuse, unsigned int specular) -{ - sendCommandi(MATERIAL_EMISSIVE, emissive & 0xffffff); - sendCommandi(MATERIAL_DIFFUSE, diffuse & 0xffffff); - sendCommandi(AMBIENT_COLOR, ambient & 0xffffff); - sendCommandi(MATERIAL_SPECULAR, specular & 0xffffff); -} diff --git a/src/gu/sceGuMorphWeight.c b/src/gu/sceGuMorphWeight.c deleted file mode 100644 index d83d89ca14..0000000000 --- a/src/gu/sceGuMorphWeight.c +++ /dev/null @@ -1,14 +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 sceGuMorphWeight(int index,float weight) -{ - sendCommandf(44 + index,weight); -} diff --git a/src/gu/sceGuOffset.c b/src/gu/sceGuOffset.c deleted file mode 100644 index b3dec0824c..0000000000 --- a/src/gu/sceGuOffset.c +++ /dev/null @@ -1,15 +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 sceGuOffset(unsigned int x, unsigned int y) -{ - sendCommandi(OFFSET_X, x << 4); - sendCommandi(OFFSET_Y, y << 4); -} diff --git a/src/gu/sceGuPatchDivide.c b/src/gu/sceGuPatchDivide.c deleted file mode 100644 index 72e6e91406..0000000000 --- a/src/gu/sceGuPatchDivide.c +++ /dev/null @@ -1,14 +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 sceGuPatchDivide(unsigned int a0, unsigned int a1) -{ - sendCommandi(PATCH_DIVISION, (a1 << 8) | a0); -} diff --git a/src/gu/sceGuPatchFrontFace.c b/src/gu/sceGuPatchFrontFace.c deleted file mode 100644 index 4c12688e3d..0000000000 --- a/src/gu/sceGuPatchFrontFace.c +++ /dev/null @@ -1,14 +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 sceGuPatchFrontFace(unsigned int a0) -{ - sendCommandi(PATCH_FACING, a0); -} diff --git a/src/gu/sceGuPatchPrim.c b/src/gu/sceGuPatchPrim.c deleted file mode 100644 index ba0d4285fa..0000000000 --- a/src/gu/sceGuPatchPrim.c +++ /dev/null @@ -1,25 +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 sceGuPatchPrim(int prim) -{ - switch (prim) - { - case GU_POINTS: - sendCommandi(PATCH_PRIMITIVE, 2); - break; - case GU_LINE_STRIP: - sendCommandi(PATCH_PRIMITIVE, 1); - break; - case GU_TRIANGLE_STRIP: - sendCommandi(PATCH_PRIMITIVE, 0); - break; - } -} diff --git a/src/gu/sceGuPixelMask.c b/src/gu/sceGuPixelMask.c deleted file mode 100644 index 7d1c64d916..0000000000 --- a/src/gu/sceGuPixelMask.c +++ /dev/null @@ -1,15 +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 sceGuPixelMask(unsigned int mask) -{ - sendCommandi(MASK_COLOR, mask & 0xffffff); - sendCommandi(MASK_ALPHA, mask >> 24); -} diff --git a/src/gu/sceGuScissor.c b/src/gu/sceGuScissor.c deleted file mode 100644 index 34485e117c..0000000000 --- a/src/gu/sceGuScissor.c +++ /dev/null @@ -1,25 +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 sceGuScissor(int x, int y, int w, int h) -{ - GuContext *context = &gu_contexts[gu_curr_context]; - - context->scissor_start[0] = x; - context->scissor_start[1] = y; - context->scissor_end[0] = w - 1; - context->scissor_end[1] = h - 1; - - if (context->scissor_enable) - { - sendCommandi(SCISSOR1, (context->scissor_start[1] << 10) | context->scissor_start[0]); - sendCommandi(SCISSOR2, (context->scissor_end[1] << 10) | context->scissor_end[0]); - } -} diff --git a/src/gu/sceGuSendCommandf.c b/src/gu/sceGuSendCommandf.c deleted file mode 100644 index 47a175588c..0000000000 --- a/src/gu/sceGuSendCommandf.c +++ /dev/null @@ -1,14 +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 sceGuSendCommandf(int cmd, float argument) -{ - sendCommandf(cmd,argument); -} diff --git a/src/gu/sceGuSendCommandi.c b/src/gu/sceGuSendCommandi.c deleted file mode 100644 index 3e7b07654f..0000000000 --- a/src/gu/sceGuSendCommandi.c +++ /dev/null @@ -1,14 +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 sceGuSendCommandi(int cmd, int argument) -{ - sendCommandi(cmd, argument); -} diff --git a/src/gu/sceGuSendList.c b/src/gu/sceGuSendList.c deleted file mode 100644 index 41ad460efb..0000000000 --- a/src/gu/sceGuSendList.c +++ /dev/null @@ -1,43 +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 -#include - -int sceGuSendList(int mode, const void *list, PspGeContext *context) -{ - gu_settings.signal_offset = 0; - - // TODO: figure out this structure - PspGeListArgs args; - args.size = 8; // Size of structure? - args.context = context; - - int list_id = 0; - int callback = gu_settings.ge_callback_id; - - switch (mode) - { - case GU_HEAD: - list_id = sceGeListEnQueueHead(list, NULL, callback, &args); - break; - case GU_TAIL: - list_id = sceGeListEnQueue(list, NULL, callback, &args); - break; - } - - if (list_id < 0) - { - return list_id; - } - - ge_list_executed[1] = list_id; - return 0; -} diff --git a/src/gu/sceGuSetAllStatus.c b/src/gu/sceGuSetAllStatus.c deleted file mode 100644 index d4fbedf946..0000000000 --- a/src/gu/sceGuSetAllStatus.c +++ /dev/null @@ -1,21 +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 sceGuSetAllStatus(int status) -{ - unsigned int i; - for (i = 0; i < 22; ++i) - { - if ((status >> i)&1) - sceGuEnable(i); - else - sceGuDisable(i); - } -} diff --git a/src/gu/sceGuSetCallback.c b/src/gu/sceGuSetCallback.c deleted file mode 100644 index e101a46e57..0000000000 --- a/src/gu/sceGuSetCallback.c +++ /dev/null @@ -1,33 +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* sceGuSetCallback(int signal, GuCallback callback) -{ - GuCallback old_callback = 0; - - switch (signal) - { - case GU_CALLBACK_SIGNAL: - { - old_callback = gu_settings.sig; - gu_settings.sig = callback; - } - break; - - case GU_CALLBACK_FINISH: - { - old_callback = gu_settings.fin; - gu_settings.fin = callback; - } - break; - } - - return old_callback; -} diff --git a/src/gu/sceGuSetDither.c b/src/gu/sceGuSetDither.c deleted file mode 100644 index ace9d695d5..0000000000 --- a/src/gu/sceGuSetDither.c +++ /dev/null @@ -1,17 +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 sceGuSetDither(const ScePspIMatrix4 *matrix) -{ - sendCommandi(DITH0, (matrix->x.x & 0x0f) | ((matrix->x.y & 0x0f) << 4) | ((matrix->x.z & 0x0f) << 8) | ((matrix->x.w & 0x0f) << 12)); - sendCommandi(DITH1, (matrix->y.x & 0x0f) | ((matrix->y.y & 0x0f) << 4) | ((matrix->y.z & 0x0f) << 8) | ((matrix->y.w & 0x0f) << 12)); - sendCommandi(DITH2, (matrix->z.x & 0x0f) | ((matrix->z.y & 0x0f) << 4) | ((matrix->z.z & 0x0f) << 8) | ((matrix->z.w & 0x0f) << 12)); - sendCommandi(DITH3, (matrix->w.x & 0x0f) | ((matrix->w.y & 0x0f) << 4) | ((matrix->w.z & 0x0f) << 8) | ((matrix->w.w & 0x0f) << 12)); -} diff --git a/src/gu/sceGuSetMatrix.c b/src/gu/sceGuSetMatrix.c deleted file mode 100644 index 219bb39c71..0000000000 --- a/src/gu/sceGuSetMatrix.c +++ /dev/null @@ -1,67 +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 sceGuSetMatrix(int type, const ScePspFMatrix4 *matrix) -{ - unsigned int i, j; - const float *fmatrix = (const float *)matrix; - - switch (type) - { - case 0: - { - sendCommandf(PROJ_MATRIX_NUMBER, 0); - - // 4*4 - most probably projection - for (i = 0; i < 16; ++i) - sendCommandf(PROJ_MATRIX_DATA, fmatrix[i]); - } - break; - - case 1: - { - sendCommandf(VIEW_MATRIX_NUMBER, 0); - - // 4*4 -> 3*4 - view matrix? - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 3; ++j) - sendCommandf(VIEW_MATRIX_DATA, fmatrix[j + i * 4]); - } - } - break; - - case 2: - { - sendCommandf(WORLD_MATRIX_NUMBER, 0); - - // 4*4 -> 3*4 - ??? - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 3; ++j) - sendCommandf(WORLD_MATRIX_DATA, fmatrix[j + i * 4]); - } - } - break; - - case 3: - { - sendCommandf(TGEN_MATRIX_NUMBER, 0); - - // 4*4 -> 3*4 - ??? - for (i = 0; i < 4; ++i) - { - for (j = 0; j < 3; ++j) - sendCommandf(TGEN_MATRIX_DATA, fmatrix[j + i * 4]); - } - } - break; - } -} diff --git a/src/gu/sceGuSetStatus.c b/src/gu/sceGuSetStatus.c deleted file mode 100644 index b127f0327d..0000000000 --- a/src/gu/sceGuSetStatus.c +++ /dev/null @@ -1,17 +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 sceGuSetStatus(int state, int status) -{ - if (status) - sceGuEnable(state); - else - sceGuDisable(state); -} diff --git a/src/gu/sceGuShadeModel.c b/src/gu/sceGuShadeModel.c deleted file mode 100644 index 358086035f..0000000000 --- a/src/gu/sceGuShadeModel.c +++ /dev/null @@ -1,14 +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 sceGuShadeModel(int mode) -{ - sendCommandi(SHADE_MODE, mode ? 1 : 0); -} diff --git a/src/gu/sceGuSignal.c b/src/gu/sceGuSignal.c deleted file mode 100644 index 0bc3db33fa..0000000000 --- a/src/gu/sceGuSignal.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" - -void sceGuSignal(int signal, int argument) -{ - sendCommandi(SIGNAL, ((signal & 0xff) << 16) | (argument & 0xffff)); - sendCommandi(END, 0); - - if (signal == 3) - { - sendCommandi(FINISH, 0); - sendCommandi(END, 0); - } - - sendCommandiStall(NOP, 0); -} diff --git a/src/gu/sceGuSpecular.c b/src/gu/sceGuSpecular.c deleted file mode 100644 index f8d9c6cd3d..0000000000 --- a/src/gu/sceGuSpecular.c +++ /dev/null @@ -1,14 +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 sceGuSpecular(float power) // specular power -{ - sendCommandf(MATERIAL_SPECULAR_COEF, power); -} diff --git a/src/gu/sceGuStart.c b/src/gu/sceGuStart.c index 0f867bc29f..244483d8c4 100644 --- a/src/gu/sceGuStart.c +++ b/src/gu/sceGuStart.c @@ -6,7 +6,7 @@ * Copyright (c) 2005 Jesper Svennevid */ -#include "guInternal.h" +#include #include #include @@ -57,8 +57,8 @@ void sceGuStart(int cid, void *list) { if (gu_draw_buffer.frame_width) { - sendCommandi(FRAME_BUF_PTR, ((unsigned int)gu_draw_buffer.frame_buffer) & 0xffffff); - sendCommandi(FRAME_BUF_WIDTH, ((((unsigned int)gu_draw_buffer.frame_buffer) & 0xff000000) >> 8) | gu_draw_buffer.frame_width); + sceGuSendCommandi(FRAME_BUF_PTR, ((unsigned int)gu_draw_buffer.frame_buffer) & 0xffffff); + sceGuSendCommandi(FRAME_BUF_WIDTH, ((((unsigned int)gu_draw_buffer.frame_buffer) & 0xff000000) >> 8) | gu_draw_buffer.frame_width); } } } diff --git a/src/gu/sceGuStencilFunc.c b/src/gu/sceGuStencilFunc.c deleted file mode 100644 index d065053ba3..0000000000 --- a/src/gu/sceGuStencilFunc.c +++ /dev/null @@ -1,14 +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 sceGuStencilFunc(int func, int ref, int mask) -{ - sendCommandi(STENCIL_TEST, func | ((ref & 0xff) << 8) | ((mask & 0xff) << 16)); -} diff --git a/src/gu/sceGuStencilOp.c b/src/gu/sceGuStencilOp.c deleted file mode 100644 index e144cce49b..0000000000 --- a/src/gu/sceGuStencilOp.c +++ /dev/null @@ -1,14 +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 sceGuStencilOp(int fail, int zfail, int zpass) -{ - sendCommandi(STENCIL_OP, fail | (zfail << 8) | (zpass << 16)); -} diff --git a/src/gu/sceGuSwapBuffers.c b/src/gu/sceGuSwapBuffers.c deleted file mode 100644 index 1a28c87feb..0000000000 --- a/src/gu/sceGuSwapBuffers.c +++ /dev/null @@ -1,43 +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 -#include - -void* sceGuSwapBuffers(void) -{ - if (gu_settings.swapBuffersCallback) - { - gu_settings.swapBuffersCallback(&gu_draw_buffer.disp_buffer,&gu_draw_buffer.frame_buffer); - } else { - void* temp = gu_draw_buffer.disp_buffer; - gu_draw_buffer.disp_buffer = gu_draw_buffer.frame_buffer; - gu_draw_buffer.frame_buffer = temp; - } - - if (gu_display_on) - sceDisplaySetFrameBuf((void*)((unsigned int)ge_edram_address + (unsigned int)gu_draw_buffer.disp_buffer), gu_draw_buffer.frame_width, gu_draw_buffer.pixel_size, gu_settings.swapBuffersBehaviour); - - // TODO: remove this? it serves no real purpose - gu_current_frame ^= 1; - -// return (void*)gu_settings.swapBuffersBehaviour; - return gu_draw_buffer.frame_buffer; -} - -void guSwapBuffersBehaviour(int behaviour) -{ - gu_settings.swapBuffersBehaviour = behaviour; -} - -void guSwapBuffersCallback(GuSwapBuffersCallback callback) -{ - gu_settings.swapBuffersCallback = callback; -} diff --git a/src/gu/sceGuSync.c b/src/gu/sceGuSync.c deleted file mode 100644 index 34e934892c..0000000000 --- a/src/gu/sceGuSync.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 -#include - -int sceGuSync(int mode, int what) -{ - switch (mode) - { - case 0: return sceGeDrawSync(what); - case 3: return sceGeListSync(ge_list_executed[0],what); - case 4: return sceGeListSync(ge_list_executed[1],what); - default: case 1: case 2: return 0; - } -} diff --git a/src/gu/sceGuTerm.c b/src/gu/sceGuTerm.c index 6e9c6900e5..13e77c3517 100644 --- a/src/gu/sceGuTerm.c +++ b/src/gu/sceGuTerm.c @@ -6,11 +6,14 @@ * Copyright (c) 2005 Jesper Svennevid */ -#include "guInternal.h" +#include #include #include +// To avoid including whole headers +int sceKernelDeleteEventFlag(int evid); + void sceGuTerm(void) { sceKernelDeleteEventFlag(gu_settings.kernel_event_flag); diff --git a/src/gu/sceGuTexEnvColor.c b/src/gu/sceGuTexEnvColor.c deleted file mode 100644 index 06fa0a0617..0000000000 --- a/src/gu/sceGuTexEnvColor.c +++ /dev/null @@ -1,14 +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 sceGuTexEnvColor(unsigned int color) -{ - sendCommandi(TEX_ENV_COLOR, color & 0xffffff); -} diff --git a/src/gu/sceGuTexFilter.c b/src/gu/sceGuTexFilter.c deleted file mode 100644 index 31b2d2813c..0000000000 --- a/src/gu/sceGuTexFilter.c +++ /dev/null @@ -1,14 +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 sceGuTexFilter(int min, int mag) -{ - sendCommandi(TEX_FILTER, (mag << 8) | min); -} diff --git a/src/gu/sceGuTexFlush.c b/src/gu/sceGuTexFlush.c deleted file mode 100644 index 51f3979679..0000000000 --- a/src/gu/sceGuTexFlush.c +++ /dev/null @@ -1,14 +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 sceGuTexFlush(void) -{ - sendCommandi(TEX_FLUSH, 0); -} diff --git a/src/gu/sceGuTexFunc.c b/src/gu/sceGuTexFunc.c deleted file mode 100644 index 0ffa11b62a..0000000000 --- a/src/gu/sceGuTexFunc.c +++ /dev/null @@ -1,17 +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 sceGuTexFunc(int tfx, int tcc) -{ - GuContext *context = &gu_contexts[gu_curr_context]; - context->texture_function = (tcc << 8) | tfx; - - sendCommandi(TEX_FUNC, ((tcc << 8) | tfx) | context->fragment_2x); -} diff --git a/src/gu/sceGuTexImage.c b/src/gu/sceGuTexImage.c deleted file mode 100644 index 01a8ef3b52..0000000000 --- a/src/gu/sceGuTexImage.c +++ /dev/null @@ -1,25 +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" - -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) -{ - 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(); -} diff --git a/src/gu/sceGuTexLevelMode.c b/src/gu/sceGuTexLevelMode.c deleted file mode 100644 index a2d15d6696..0000000000 --- a/src/gu/sceGuTexLevelMode.c +++ /dev/null @@ -1,24 +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 sceGuTexLevelMode(unsigned int mode, float bias) -{ - int offset = (int)truncf(bias * 16.0f); - - // mip map bias? - if (offset >= 128) - offset = 128; - else if (offset < -128) - offset = -128; - - sendCommandi(TEX_LEVEL, (((unsigned int)(offset)) << 16) | mode); -} diff --git a/src/gu/sceGuTexMapMode.c b/src/gu/sceGuTexMapMode.c deleted file mode 100644 index affe0b9e40..0000000000 --- a/src/gu/sceGuTexMapMode.c +++ /dev/null @@ -1,19 +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 sceGuTexMapMode(int mode, unsigned int a1, unsigned int a2) -{ - GuContext *context = &gu_contexts[gu_curr_context]; - - context->texture_map_mode = mode & 0x03; - - sendCommandi(TEX_MAP_MODE, context->texture_proj_map_mode | (mode & 0x03)); - sendCommandi(TEX_SHADE_MAPPING, (a2 << 8) | (a1 & 0x03)); -} diff --git a/src/gu/sceGuTexMode.c b/src/gu/sceGuTexMode.c deleted file mode 100644 index 9852245743..0000000000 --- a/src/gu/sceGuTexMode.c +++ /dev/null @@ -1,20 +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 sceGuTexMode(int tpsm, int maxmips, int a2, int swizzle) -{ - GuContext *context = &gu_contexts[gu_curr_context]; - context->texture_mode = tpsm; - - sendCommandi(TEX_MODE, (maxmips << 16) | (a2 << 8) | (swizzle)); - sendCommandi(TEX_FORMAT, tpsm); - - sceGuTexFlush(); -} diff --git a/src/gu/sceGuTexOffset.c b/src/gu/sceGuTexOffset.c deleted file mode 100644 index 6d75ab4c23..0000000000 --- a/src/gu/sceGuTexOffset.c +++ /dev/null @@ -1,15 +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 sceGuTexOffset(float u, float v) -{ - sendCommandf(TEX_OFFSET_U, u); - sendCommandf(TEX_OFFSET_V, v); -} diff --git a/src/gu/sceGuTexProjMapMode.c b/src/gu/sceGuTexProjMapMode.c deleted file mode 100644 index 7ed0d3605f..0000000000 --- a/src/gu/sceGuTexProjMapMode.c +++ /dev/null @@ -1,17 +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 sceGuTexProjMapMode(int mode) -{ - GuContext *context = &gu_contexts[gu_curr_context]; - - context->texture_proj_map_mode = ((mode & 0x03) << 8); - sendCommandi(TEX_MAP_MODE, ((mode & 0x03) << 8) | context->texture_map_mode); -} diff --git a/src/gu/sceGuTexScale.c b/src/gu/sceGuTexScale.c deleted file mode 100644 index 032b63a22b..0000000000 --- a/src/gu/sceGuTexScale.c +++ /dev/null @@ -1,15 +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 sceGuTexScale(float u, float v) -{ - sendCommandf(TEX_SCALE_U, u); - sendCommandf(TEX_SCALE_V, v); -} diff --git a/src/gu/sceGuTexSlope.c b/src/gu/sceGuTexSlope.c deleted file mode 100644 index d12299c8bf..0000000000 --- a/src/gu/sceGuTexSlope.c +++ /dev/null @@ -1,14 +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 sceGuTexSlope(float slope) -{ - sendCommandf(TEX_LOD_SLOPE, slope); -} diff --git a/src/gu/sceGuTexSync.c b/src/gu/sceGuTexSync.c deleted file mode 100644 index b93d84d057..0000000000 --- a/src/gu/sceGuTexSync.c +++ /dev/null @@ -1,14 +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 sceGuTexSync() -{ - sendCommandi(TEX_SYNC, 0); -} diff --git a/src/gu/sceGuTexWrap.c b/src/gu/sceGuTexWrap.c deleted file mode 100644 index b375b23348..0000000000 --- a/src/gu/sceGuTexWrap.c +++ /dev/null @@ -1,14 +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 sceGuTexWrap(int u, int v) -{ - sendCommandi(TEX_WRAP, (v << 8) | (u)); -} diff --git a/src/gu/sceGuViewport.c b/src/gu/sceGuViewport.c deleted file mode 100644 index 3955239f84..0000000000 --- a/src/gu/sceGuViewport.c +++ /dev/null @@ -1,17 +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 sceGuViewport(int cx, int cy, int width, int height) -{ - sendCommandf(VIEWPORT_X_SCALE, (float)(width >> 1)); - sendCommandf(VIEWPORT_Y_SCALE, (float)((-height) >> 1)); - sendCommandf(VIEWPORT_X_CENTER, (float)cx); - sendCommandf(VIEWPORT_Y_CENTER, (float)cy); -}