diff --git a/.clang-tidy b/.clang-tidy index 79af26fb..e15f4608 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,6 @@ Checks: 'readability-*,-readability-magic-numbers,-readability-uppercase-literal-suffix,-readability-non-const-parameter,-readability-else-after-return,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.*,-clang-analyzer-deadcode.DeadStores,-clang-analyzer-core.uninitialized.ArraySubscript,-clang-analyzer-core.UndefinedBinaryOperatorResult,bugprone*,-bugprone-macro-parentheses,-bugprone-reserved-identifier,-bugprone-narrowing-conversions,-bugprone-too-small-loop-variable,-bugprone-integer-division,-bugprone-sizeof-expression,-bugprone-suspicious-include,modernize*,-bugprone-branch-clone,-bugprone-signed-char-misuse,performance*,portability*,diagnostic-*,analyzer-*,misc*' WarningsAsErrors: '' -HeaderFilterRegex: '^(src|include)\/.*\.h$' +HeaderFilterRegex: '^(?!.*\/libultra\/)(src|include)\/.*\.h$' FormatStyle: 'file' CheckOptions: # Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index a83d14c3..3d363f7c 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -14,7 +14,8 @@ "include" ], "defines": [ - "_LANGUAGE_C" + "_LANGUAGE_C", + "_MIPS_SZLONG=32" ], "cStandard": "gnu89", // C89 + some GNU extensions from C99 like C++ comments "cppStandard": "${default}" diff --git a/.vscode/settings.json b/.vscode/settings.json index 5e499b4c..0cc202d3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,7 +14,7 @@ "tools/gfxsotn/**": false, }, "defines": [ - "_LANGUAGE_C" // For gbi.h + "_LANGUAGE_C", // For gbi.h ], "files.associations": { "hud.h": "c", @@ -22,6 +22,9 @@ "ultratypes.h": "c", "mbi.h": "c", "common.h": "c", - "sf64math.h": "c" + "sf64math.h": "c", + "ultra64.h": "c", + "os_internal.h": "c", + "structs.h": "c" }, } \ No newline at end of file diff --git a/Makefile b/Makefile index d853d80e..b8c73629 100644 --- a/Makefile +++ b/Makefile @@ -191,6 +191,7 @@ build/src/main/1EB50.o: OPTFLAGS := -O1 -g0 build/src/libultra/2BDF0.o: OPTFLAGS := -O1 -g0 build/src/libultra/2C700.o: OPTFLAGS := -O1 -g0 build/src/libultra/2D300.o: OPTFLAGS := -O1 -g0 +build/src/libultra/gu/guSqrtf.o: OPTFLAGS := -O1 -g0 build/src/libultra/gu/ortho.o: OPTFLAGS := -O3 -g0 build/src/libultra/gu/lookat.o: OPTFLAGS := -O3 -g0 build/src/libultra/io/controller.o: OPTFLAGS := -O1 -g0 diff --git a/include/PR/gbi.h b/include/PR/gbi.h index d8c7896c..b418e032 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -12,8 +12,8 @@ **************************************************************************/ /************************************************************************** * - * $Revision: 1.121 $ - * $Date: 1997/02/11 08:21:52 $ + * $Revision: 1.128 $ + * $Date: 1997/11/26 00:30:51 $ * $Source: /disk6/Master/cvsmdev2/PR/include/gbi.h,v $ * **************************************************************************/ @@ -86,6 +86,33 @@ * */ +#ifdef F3DEX_GBI_2 +#define G_NOOP 0x00 +#define G_RDPHALF_2 0xf1 +#define G_SETOTHERMODE_H 0xe3 +#define G_SETOTHERMODE_L 0xe2 +#define G_RDPHALF_1 0xe1 +#define G_SPNOOP 0xe0 +#define G_ENDDL 0xdf +#define G_DL 0xde +#define G_LOAD_UCODE 0xdd +#define G_MOVEMEM 0xdc +#define G_MOVEWORD 0xdb +#define G_MTX 0xda +#define G_GEOMETRYMODE 0xd9 +#define G_POPMTX 0xd8 +#define G_TEXTURE 0xd7 +#define G_SUBMODULE 0xd6 + +#define G_VTX 0x01 +#define G_MODIFYVTX 0x02 +#define G_CULLDL 0x03 +#define G_BRANCH_Z 0x04 +#define G_TRI1 0x05 +#define G_TRI2 0x06 +#define G_LINE3D 0x07 +#else /* F3DEX_GBI_2 */ + /* DMA commands: */ #define G_SPNOOP 0 /* handle 0 gracefully */ #define G_MTX 1 @@ -130,6 +157,10 @@ /* RDP commands: */ #define G_NOOP 0xc0 /* 0 */ + +#endif /* F3DEX_GBI_2 */ + +/* RDP commands: */ #define G_SETCIMG 0xff /* -1 */ #define G_SETZIMG 0xfe /* -2 */ #define G_SETTIMG 0xfd /* -3 */ @@ -158,6 +189,7 @@ #define G_TEXRECTFLIP 0xe5 /* -27 */ #define G_TEXRECT 0xe4 /* -28 */ + /* * The following commands are the "generated" RDP commands; the user * never sees them, the RSP microcode generates them. @@ -256,12 +288,21 @@ /* * G_MTX: parameter flags */ -#define G_MTX_MODELVIEW 0x00 /* matrix types */ -#define G_MTX_PROJECTION 0x01 -#define G_MTX_MUL 0x00 /* concat or load */ -#define G_MTX_LOAD 0x02 -#define G_MTX_NOPUSH 0x00 /* push or not */ -#define G_MTX_PUSH 0x04 +#ifdef F3DEX_GBI_2x +# define G_MTX_MODELVIEW 0x00 /* matrix types */ +# define G_MTX_PROJECTION 0x04 +# define G_MTX_MUL 0x00 /* concat or load */ +# define G_MTX_LOAD 0x02 +# define G_MTX_NOPUSH 0x00 /* push or not */ +# define G_MTX_PUSH 0x01 +#else /* F3DEX_GBI_2 */ +# define G_MTX_MODELVIEW 0x00 /* matrix types */ +# define G_MTX_PROJECTION 0x01 +# define G_MTX_MUL 0x00 /* concat or load */ +# define G_MTX_LOAD 0x02 +# define G_MTX_NOPUSH 0x00 /* push or not */ +# define G_MTX_PUSH 0x04 +#endif /* F3DEX_GBI_2 */ /* * flags for G_SETGEOMETRYMODE @@ -431,7 +472,7 @@ #define G_CC_MODULATEIDECALA_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0 #define G_CC_MODULATERGB_PRIM G_CC_MODULATEI_PRIM #define G_CC_MODULATERGBA_PRIM G_CC_MODULATEIA_PRIM -#define G_CC_MODULATERGBDECALA_PRIM G_CC_MODULATEIA_PRIM +#define G_CC_MODULATERGBDECALA_PRIM G_CC_MODULATEIDECALA_PRIM #define G_CC_DECALRGB 0, 0, 0, TEXEL0, 0, 0, 0, SHADE #define G_CC_DECALRGBA 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0 #define G_CC_BLENDI ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE @@ -1134,22 +1175,40 @@ typedef union { * which to store a 1-4 word DMA. * */ -#define G_MV_VIEWPORT 0x80 -#define G_MV_LOOKATY 0x82 -#define G_MV_LOOKATX 0x84 -#define G_MV_L0 0x86 -#define G_MV_L1 0x88 -#define G_MV_L2 0x8a -#define G_MV_L3 0x8c -#define G_MV_L4 0x8e -#define G_MV_L5 0x90 -#define G_MV_L6 0x92 -#define G_MV_L7 0x94 -#define G_MV_TXTATT 0x96 -#define G_MV_MATRIX_1 0x9e /* NOTE: this is in moveword table */ -#define G_MV_MATRIX_2 0x98 -#define G_MV_MATRIX_3 0x9a -#define G_MV_MATRIX_4 0x9c +#ifdef F3DEX_GBI_2x +/* 0,2,4,6 are reserved by G_MTX */ +# define G_MV_VIEWPORT 8 +# define G_MV_LIGHT 10 +# define G_MV_POINT 12 +# define G_MV_MATRIX 14 /* NOTE: this is in moveword table */ +# define G_MVO_LOOKATX (0*24) +# define G_MVO_LOOKATY (1*24) +# define G_MVO_L0 (2*24) +# define G_MVO_L1 (3*24) +# define G_MVO_L2 (4*24) +# define G_MVO_L3 (5*24) +# define G_MVO_L4 (6*24) +# define G_MVO_L5 (7*24) +# define G_MVO_L6 (8*24) +# define G_MVO_L7 (9*24) +#else /* F3DEX_GBI_2 */ +# define G_MV_VIEWPORT 0x80 +# define G_MV_LOOKATY 0x82 +# define G_MV_LOOKATX 0x84 +# define G_MV_L0 0x86 +# define G_MV_L1 0x88 +# define G_MV_L2 0x8a +# define G_MV_L3 0x8c +# define G_MV_L4 0x8e +# define G_MV_L5 0x90 +# define G_MV_L6 0x92 +# define G_MV_L7 0x94 +# define G_MV_TXTATT 0x96 +# define G_MV_MATRIX_1 0x9e /* NOTE: this is in moveword table */ +# define G_MV_MATRIX_2 0x98 +# define G_MV_MATRIX_3 0x9a +# define G_MV_MATRIX_4 0x9c +#endif /* F3DEX_GBI_2 */ /* * MOVEWORD indices @@ -1165,7 +1224,11 @@ typedef union { #define G_MW_SEGMENT 0x06 #define G_MW_FOG 0x08 #define G_MW_LIGHTCOL 0x0a -#define G_MW_POINTS 0x0c +#ifdef F3DEX_GBI_2x +# define G_MW_FORCEMTX 0x0c +#else /* F3DEX_GBI_2 */ +# define G_MW_POINTS 0x0c +#endif /* F3DEX_GBI_2 */ #define G_MW_PERSPNORM 0x0e /* @@ -1634,11 +1697,32 @@ typedef union { (unsigned int)(s) \ } +#define gDma2p(pkt, c, adrs, len, idx, ofs) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL((c),24,8)|_SHIFTL((ofs)/8,16,8)| \ + _SHIFTL(((len)-1)/8,8,8)|_SHIFTL((idx),0,8)); \ + _g->words.w1 = (unsigned int)(adrs); \ +} +#define gsDma2p(c, adrs, len, idx, ofs) \ +{ \ + (_SHIFTL((c),24,8)|_SHIFTL((ofs)/8,16,8)| \ + _SHIFTL(((len)-1)/8,8,8)|_SHIFTL((idx),0,8)), \ + (unsigned int)(adrs) \ +} + #define gSPNoOp(pkt) gDma0p(pkt, G_SPNOOP, 0, 0) #define gsSPNoOp() gsDma0p(G_SPNOOP, 0, 0) -#define gSPMatrix(pkt, m, p) gDma1p(pkt, G_MTX, m, sizeof(Mtx), p) -#define gsSPMatrix(m, p) gsDma1p(G_MTX, m, sizeof(Mtx), p) +#ifdef F3DEX_GBI_2x +# define gSPMatrix(pkt, m, p) \ + gDma2p((pkt),G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) +# define gsSPMatrix(m, p) \ + gsDma2p( G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) +#else /* F3DEX_GBI_2 */ +# define gSPMatrix(pkt, m, p) gDma1p(pkt, G_MTX, m, sizeof(Mtx), p) +# define gsSPMatrix(m, p) gsDma1p(G_MTX, m, sizeof(Mtx), p) +#endif /* F3DEX_GBI_2 */ /* * F3DEX_GBI: G_VTX GBI format was changed to support 64 vertice. @@ -1661,8 +1745,14 @@ typedef union { gsDma1p(G_VTX, v, sizeof(Vtx)*(n), ((n)-1)<<4|(v0)) #endif -#define gSPViewport(pkt, v) gDma1p(pkt, G_MOVEMEM, v, sizeof(Vp), G_MV_VIEWPORT) -#define gsSPViewport(v) gsDma1p(G_MOVEMEM, v, sizeof(Vp), G_MV_VIEWPORT) + +#ifdef F3DEX_GBI_2x +# define gSPViewport(pkt, v) gDma2p(pkt,G_MOVEMEM,v,sizeof(Vp),G_MV_VIEWPORT,0) +# define gsSPViewport(v) gsDma2p( G_MOVEMEM,v,sizeof(Vp),G_MV_VIEWPORT,0) +#else /* F3DEX_GBI_2 */ +# define gSPViewport(pkt,v) gDma1p(pkt,G_MOVEMEM,(v),sizeof(Vp),G_MV_VIEWPORT) +# define gsSPViewport(v) gsDma1p( G_MOVEMEM,(v),sizeof(Vp),G_MV_VIEWPORT) +#endif /* F3DEX_GBI_2 */ #define gSPDisplayList(pkt,dl) gDma1p(pkt,G_DL,dl,0,G_DL_PUSH) #define gsSPDisplayList( dl) gsDma1p( G_DL,dl,0,G_DL_PUSH) @@ -1744,12 +1834,17 @@ typedef union { (unsigned int) (dat) \ } +#ifdef F3DEX_GBI_2x #define gMoveWd(pkt, index, offset, data) \ - gImmp21(pkt, G_MOVEWORD, offset, index, data) - + gDma1p((pkt), G_MOVEWORD, data, offset, index) #define gsMoveWd( index, offset, data) \ - gsImmp21( G_MOVEWORD, offset, index, data) - + gsDma1p( G_MOVEWORD, data, offset, index) +#else /* F3DEX_GBI_2 */ +#define gMoveWd(pkt, index, offset, data) \ + gImmp21((pkt), G_MOVEWORD, offset, index, data) +#define gsMoveWd( index, offset, data) \ + gsImmp21( G_MOVEWORD, offset, index, data) +#endif /* F3DEX_GBI_2 */ /* Sprite immediate macros, there is also a sprite dma macro above */ @@ -1895,10 +1990,33 @@ typedef union { /*** *** 1 Quadrangle ***/ -#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \ - gSP2Triangles(pkt, v1, v2, v3, 0, v1, v3, v0, 0) -#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ - gsSP2Triangles(v1, v2, v3, 0, v1, v3, v0, 0) +#define __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag) \ + (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2): \ + ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v3): \ + ((flag) == 2) ? __gsSP1Triangle_w1(v2, v3, v0): \ + __gsSP1Triangle_w1(v3, v0, v1)) + +#define __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ + (((flag) == 0) ? __gsSP1Triangle_w1(v0, v2, v3): \ + ((flag) == 1) ? __gsSP1Triangle_w1(v1, v3, v0): \ + ((flag) == 2) ? __gsSP1Triangle_w1(v2, v0, v1): \ + __gsSP1Triangle_w1(v3, v1, v2)) + +#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8)| \ + __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)); \ + _g->words.w1 = __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag); \ +} + +#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ +{ \ + (_SHIFTL(G_TRI2, 24, 8)| \ + __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \ + __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ +} #endif /* F3DEX_GBI/F3DLP_GBI */ #if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) @@ -1935,9 +2053,9 @@ typedef union { #endif #define gSPSegment(pkt, segment, base) \ - gMoveWd(pkt, G_MW_SEGMENT, (segment*4), base) + gMoveWd(pkt, G_MW_SEGMENT, (segment)*4, base) #define gsSPSegment(segment, base) \ - gsMoveWd( G_MW_SEGMENT, (segment*4), base) + gsMoveWd( G_MW_SEGMENT, (segment)*4, base) /* * Clipping Macros @@ -1978,17 +2096,30 @@ typedef union { * num = new element (32 bit value replacing 2 int or 2 frac matrix * componants */ +#ifdef F3DEX_GBI_2x +ERROR!! gSPInsertMatrix is no longer supported. +#else #define gSPInsertMatrix(pkt, where, num) \ gMoveWd(pkt, G_MW_MATRIX, where, num) - #define gsSPInsertMatrix(where, num) \ gsMoveWd(G_MW_MATRIX, where, num) +#endif /* * Load new matrix directly * * mptr = pointer to matrix */ +#ifdef F3DEX_GBI_2x +#define gSPForceMatrix(pkt, mptr) \ +{ gDma2p((pkt),G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0); \ + gMoveWd((pkt), G_MW_FORCEMTX,0,0x00010000); \ +} +#define gsSPForceMatrix(mptr) \ + gsDma2p(G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0), \ + gsMoveWd(G_MW_FORCEMTX,0,0x00010000) + +#else /* F3DEX_GBI_2 */ #define gSPForceMatrix(pkt, mptr) \ { \ gDma1p(pkt, G_MOVEMEM, mptr, 16, G_MV_MATRIX_1); \ @@ -2001,6 +2132,7 @@ typedef union { gsDma1p( G_MOVEMEM, (char *)(mptr)+16, 16, G_MV_MATRIX_2), \ gsDma1p( G_MOVEMEM, (char *)(mptr)+32, 16, G_MV_MATRIX_3), \ gsDma1p( G_MOVEMEM, (char *)(mptr)+48, 16, G_MV_MATRIX_4) +#endif /* F3DEX_GBI_2 */ /* * Insert values into Points @@ -2142,8 +2274,11 @@ typedef union { /* * Lighting Macros */ -#define NUML(n) (((n)+1)*32 + 0x80000000) - +#ifdef F3DEX_GBI_2x +# define NUML(n) ((n)*24) +#else +# define NUML(n) (((n)+1)*32 + 0x80000000) +#endif #define NUMLIGHTS_0 1 #define NUMLIGHTS_1 1 #define NUMLIGHTS_2 2 @@ -2178,8 +2313,17 @@ typedef union { * LIGHT_1 through LIGHT_3 will be the directional lights and light * LIGHT_4 will be the ambient light. */ -#define gSPLight(pkt, l, n) gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) -#define gsSPLight(l, n) gsDma1p( G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) +#ifdef F3DEX_GBI_2x +# define gSPLight(pkt, l, n) \ + gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*3+3) +# define gsSPLight(l, n) \ + gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*3+3) +#else /* F3DEX_GBI_2 */ +# define gSPLight(pkt, l, n) \ + gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) +# define gsSPLight(l, n) \ + gsDma1p( G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) +#endif /* F3DEX_GBI_2 */ /* * gSPLightColor changes color of light without recalculating light direction @@ -2333,20 +2477,34 @@ typedef union { /* * Reflection/Hiliting Macros */ -#define gSPLookAtX(pkt, l) gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) -#define gsSPLookAtX(l) gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) - -#define gSPLookAtY(pkt, l) gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) -#define gsSPLookAtY(l) gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) +#ifdef F3DEX_GBI_2 +# define gSPLookAtX(pkt, l) \ + gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATX,0) +# define gsSPLookAtX(l) \ + gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATX,0) +# define gSPLookAtY(pkt, l) \ + gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATY,0) +# define gsSPLookAtY(l) \ + gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATY,0) +#else /* F3DEX_GBI_2 */ +# define gSPLookAtX(pkt, l) \ + gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) +# define gsSPLookAtX(l) \ + gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) +# define gSPLookAtY(pkt, l) \ + gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) +# define gsSPLookAtY(l) \ + gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) +#endif /* F3DEX_GBI_2 */ #define gSPLookAt(pkt, la) \ { \ gSPLookAtX(pkt,la) \ - gSPLookAtY(pkt,((char *)la)+16) \ + gSPLookAtY(pkt,(char *)(la)+16) \ } #define gsSPLookAt(la) \ gsSPLookAtX(la), \ - gsSPLookAtY(((char *)la)+16) + gsSPLookAtY((char *)(la)+16) #define gDPSetHilite1Tile(pkt, tile, hilite, width, height) \ gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ @@ -2385,13 +2543,13 @@ typedef union { #define gSPFogPosition(pkt, min, max) \ gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL((128000/(max-min)),16,16) | \ - _SHIFTL(((500-min)*256/(max-min)),0,16))) + (_SHIFTL((128000/((max)-(min))),16,16) | \ + _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) #define gsSPFogPosition(min, max) \ gsMoveWd(G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL((128000/(max-min)),16,16) | \ - _SHIFTL(((500-min)*256/(max-min)),0,16))) + (_SHIFTL((128000/((max)-(min))),16,16) | \ + _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) /* * Macros to turn texture on/off @@ -2442,8 +2600,15 @@ typedef union { #define gsSPPerspNormalize(s) \ gsMoveWd( G_MW_PERSPNORM, 0, (s)) -#define gSPPopMatrix(pkt, n) gImmp1(pkt, G_POPMTX, n) -#define gsSPPopMatrix(n) gsImmp1(G_POPMTX, n) +#ifdef F3DEX_GBI_2x +# define gSPPopMatrixN(pkt, n, num) gDma2p((pkt),G_POPMTX,(num)*64,64,2,0) +# define gsSPPopMatrixN(n, num) gsDma2p( G_POPMTX,(num)*64,64,2,0) +# define gSPPopMatrix(pkt, n) gSPPopMatrixN((pkt), (n), 1) +# define gsSPPopMatrix(n) gsSPPopMatrixN( (n), 1) +#else /* F3DEX_GBI_2 */ +# define gSPPopMatrix(pkt, n) gImmp1(pkt, G_POPMTX, n) +# define gsSPPopMatrix(n) gsImmp1( G_POPMTX, n) +#endif /* F3DEX_GBI_2 */ #define gSPEndDisplayList(pkt) \ { \ @@ -2458,6 +2623,34 @@ typedef union { _SHIFTL(G_ENDDL, 24, 8), 0 \ } +#ifdef F3DEX_GBI_2x +/* + * One gSPGeometryMode(pkt,c,s) GBI is equal to these two GBIs. + * + * gSPClearGeometryMode(pkt,c) + * gSPSetGeometryMode(pkt,s) + * + * gSPLoadGeometryMode(pkt, word) sets GeometryMode directly. + */ +#define gSPGeometryMode(pkt, c, s) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = _SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24);\ + _g->words.w1 = (u32)(s); \ +} + +#define gsSPGeometryMode(c, s) \ +{ \ + (_SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24)),(u32)(s) \ +} +#define gSPSetGeometryMode(pkt, word) gSPGeometryMode((pkt),0,(word)) +#define gsSPSetGeometryMode(word) gsSPGeometryMode(0,(word)) +#define gSPClearGeometryMode(pkt, word) gSPGeometryMode((pkt),(word),0) +#define gsSPClearGeometryMode(word) gsSPGeometryMode((word),0) +#define gSPLoadGeometryMode(pkt, word) gSPGeometryMode((pkt),-1,(word)) +#define gsSPLoadGeometryMode(pkt, word) gsSPGeometryMode(-1,(word)) + +#else /* F3DEX_GBI_2 */ #define gSPSetGeometryMode(pkt, word) \ { \ Gfx *_g = (Gfx *)(pkt); \ @@ -2483,7 +2676,23 @@ typedef union { { \ _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8), (unsigned int)(word) \ } +#endif /* F3DEX_GBI_2 */ +#ifdef F3DEX_GBI_2x +#define gSPSetOtherMode(pkt, cmd, sft, len, data) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + _g->words.w0 = (_SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)| \ + _SHIFTL((len)-1,0,8)); \ + _g->words.w1 = (unsigned int)(data); \ +} + +#define gsSPSetOtherMode(cmd, sft, len, data) \ +{ \ + _SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)|_SHIFTL((len)-1,0,8), \ + (unsigned int)(data) \ +} +#else #define gSPSetOtherMode(pkt, cmd, sft, len, data) \ { \ Gfx *_g = (Gfx *)(pkt); \ @@ -2498,6 +2707,7 @@ typedef union { _SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | _SHIFTL(len, 0, 8), \ (unsigned int)(data) \ } +#endif /* * RDP setothermode register commands - register shadowed in RSP @@ -2767,6 +2977,47 @@ typedef union { _SHIFTL(a, 0, 8)) \ } +/* + * gDPSetOtherMode (This is for expert user.) + * + * This command makes all othermode parameters set. + * Do not use this command in the same DL with another g*SPSetOtherMode DLs. + * + * [Usage] + * gDPSetOtherMode(pkt, modeA, modeB) + * + * 'modeA' is described all parameters of GroupA GBI command. + * 'modeB' is also described all parameters of GroupB GBI command. + * + * GroupA: + * gDPPipelineMode, gDPSetCycleType, gSPSetTexturePersp, + * gDPSetTextureDetail, gDPSetTextureLOD, gDPSetTextureLUT, + * gDPSetTextureFilter, gDPSetTextureConvert, gDPSetCombineKey, + * gDPSetColorDither, gDPSetAlphaDither + * + * GroupB: + * gDPSetAlphaCompare, gDPSetDepthSource, gDPSetRenderMode + * + * Use 'OR' operation to get modeA and modeB. + * + * modeA = G_PM_* | G_CYC_* | G_TP_* | G_TD_* | G_TL_* | G_TT_* | G_TF_* + * G_TC_* | G_CK_* | G_CD_* | G_AD_*; + * + * modeB = G_AC_* | G_ZS_* | G_RM_* | G_RM_*2; + */ +#define gDPSetOtherMode(pkt, mode0, mode1) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24);\ + _g->words.w1 = (unsigned int)(mode1); \ +} + +#define gsDPSetOtherMode(mode0, mode1) \ +{ \ + _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24), \ + (unsigned int)(mode1) \ +} /* * Texturing macros @@ -3994,6 +4245,19 @@ typedef union { _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ } +#define gDPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + if (pkt); \ + _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)); \ + _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ + _SHIFTL(yl, 0, 12)); \ + _g ++; \ + _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ + _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ +} + #define gsDPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ { \ (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ @@ -4005,6 +4269,18 @@ typedef union { _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ } +#define gDPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + if (pkt); \ + _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ + _SHIFTL(yh, 0, 12)); \ + _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ + _SHIFTL(yl, 0, 12)); \ + _g ++; \ + _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ + _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ +} #define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ diff --git a/include/PR/gs2dex.h b/include/PR/gs2dex.h new file mode 100644 index 00000000..7e2b2c6a --- /dev/null +++ b/include/PR/gs2dex.h @@ -0,0 +1,364 @@ +/*--------------------------------------------------------------------- + Copyright (C) 1997, Nintendo. + + File gs2dex.h + Coded by Yoshitaka Yasumoto. Jul 31, 1997. + Modified by + Comments Header file for S2DEX ucode. + + $Id: gs2dex.h,v 1.15 1997/10/17 08:19:07 yasu Exp $ + ---------------------------------------------------------------------*/ + +#ifndef _GS2DEX_H_ +#define _GS2DEX_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +/*===========================================================================* + * Macro + *===========================================================================*/ +#define GS_CALC_DXT(line) (((1<< G_TX_DXT_FRAC)-1)/(line)+1) +#define GS_PIX2TMEM(pix, siz) ((pix)>>(4-(siz))) +#define GS_PIX2DXT(pix, siz) GS_CALC_DXT(GS_PIX2TMEM((pix), (siz))) + +/*===========================================================================* + * Data structures for S2DEX microcode + *===========================================================================*/ + +/*---------------------------------------------------------------------------* + * Background + *---------------------------------------------------------------------------*/ +#define G_BGLT_LOADBLOCK 0x0033 +#define G_BGLT_LOADTILE 0xfff4 + +#define G_BG_FLAG_FLIPS 0x01 +#define G_BG_FLAG_FLIPT 0x10 + +/* Non scalable background plane */ +typedef struct { + u16 imageX; /* The x-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageW; /* The width of the texture. (u10.2)*/ + s16 frameX; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameW; /* The width of the transferred frame. (u10.2)*/ + + u16 imageY; /* The y-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageH; /* The height of the texture. (u10.2)*/ + s16 frameY; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameH; /* The height of the transferred frame. (u10.2)*/ + + u64 *imagePtr; /* The texture source address on DRAM. */ + u16 imageLoad; /* Which to use, LoadBlock or LoadTile? */ + u8 imageFmt; /* The format of the texel. G_IM_FMT_* */ + u8 imageSiz; /* The size of the texel G_IM_SIZ_* */ + u16 imagePal; /* The pallet number. */ + u16 imageFlip; /* The right & left inversion of the image. Inverted by G_BG_FLAG_FLIPS*/ + + /* Because the following are set in the initialization routine guS2DInitBg(), the user doesn't + have to set it.*/ + u16 tmemW; /* The TMEM width and Work size of the frame 1 line. + At LoadBlock, GS_PIX2TMEM(imageW/4,imageSiz) + At LoadTile GS_PIX2TMEM(frameW/4,imageSiz)+1 */ + u16 tmemH; /* The height of TMEM loadable at a time. (s13.2) The 4 times value. + When the normal texture, 512/tmemW*4 + When the CI texture, 256/tmemW*4 */ + u16 tmemLoadSH; /* The SH value + At LoadBlock, tmemSize/2-1 + At LoadTile, tmemW*16-1 */ + u16 tmemLoadTH; /* The TH value or the Stride value + At LoadBlock, GS_CALC_DXT(tmemW) + At LoadTile, tmemH-1 */ + u16 tmemSizeW; /* The skip value of imagePtr for image 1-line. + At LoadBlock, tmemW*2 + At LoadTile, GS_PIX2TMEM(imageW/4,imageSiz)*2 */ + u16 tmemSize; /* The skip value of imagePtr for 1-loading. + = tmemSizeW*tmemH */ +} uObjBg_t; /* 40 bytes */ + +/* Scalable background plane */ +typedef struct { + u16 imageX; /* The x-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageW; /* The width of the texture. (u10.2)*/ + s16 frameX; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameW; /* The width of the transferred frame. (u10.2)*/ + + u16 imageY; /* The y-coordinate of the upper-left position of the texture. (u11.5)*/ + u16 imageH; /* The height of the texture. (u10.2)*/ + s16 frameY; /* The upper-left position of the transferred frame. (s10.2)*/ + u16 frameH; /* The height of the transferred frame. (u10.2)*/ + + u64 *imagePtr; /* The texture source address on DRAM. */ + u16 imageLoad; /* Which to use, LoadBlock or LoadTile? */ + u8 imageFmt; /* The format of the texel. G_IM_FMT_* */ + u8 imageSiz; /* The size of the texel G_IM_SIZ_* */ + u16 imagePal; /* The pallet number. */ + u16 imageFlip; /* The right & left inversion of the image. Inverted by G_BG_FLAG_FLIPS*/ + + u16 scaleW; /* The scale value of the X-direction. (u5.10)*/ + u16 scaleH; /* The scale value of the Y-direction. (u5.10)*/ + s32 imageYorig; /* The start point of drawing on the image. (s20.5)*/ + + u8 padding[4]; + +} uObjScaleBg_t; /* 40 bytes */ + +typedef union { + uObjBg_t b; + uObjScaleBg_t s; + long long int force_structure_alignment; +} uObjBg; + +/*---------------------------------------------------------------------------* + * 2D Objects + *---------------------------------------------------------------------------*/ +#define G_OBJ_FLAG_FLIPS 1<<0 /* The inversion to the S-direction. */ +#define G_OBJ_FLAG_FLIPT 1<<4 /* The inversion to the T-direction. */ + +typedef struct { + s16 objX; /* The x-coordinate of the upper-left end. s10.2 OBJ */ + u16 scaleW; /* Scaling of the u5.10 width direction. */ + u16 imageW; /* The width of the u10.5 texture. (The length of the S-direction.) */ + u16 paddingX; /* Unused. Always 0. */ + s16 objY; /* The y-coordinate of the s10.2 OBJ upper-left end. */ + u16 scaleH; /* Scaling of the u5.10 height direction. */ + u16 imageH; /* The height of the u10.5 texture. (The length of the T-direction.)*/ + u16 paddingY; /* Unused. Always 0. */ + u16 imageStride; /* The folding width of the texel. (In units of 64bit word.) */ + u16 imageAdrs; /* The texture header position in TMEM. (In units of 64bit word.) */ + u8 imageFmt; /* The format of the texel. G_IM_FMT_* */ + u8 imageSiz; /* The size of the texel. G_IM_SIZ_* */ + u8 imagePal; /*The pallet number. 0-7 */ + u8 imageFlags; /* The display flag. G_OBJ_FLAG_FLIP* */ +} uObjSprite_t; /* 24 bytes */ + +typedef union { + uObjSprite_t s; + long long int force_structure_alignment; +} uObjSprite; + +/*---------------------------------------------------------------------------* + * 2D Matrix + *---------------------------------------------------------------------------*/ +typedef struct { + s32 A, B, C, D; /* s15.16 */ + s16 X, Y; /* s10.2 */ + u16 BaseScaleX; /* u5.10 */ + u16 BaseScaleY; /* u5.10 */ +} uObjMtx_t; /* 24 bytes */ + +typedef union { + uObjMtx_t m; + long long int force_structure_alignment; +} uObjMtx; + +typedef struct { + s16 X, Y; /* s10.2 */ + u16 BaseScaleX; /* u5.10 */ + u16 BaseScaleY; /* u5.10 */ +} uObjSubMtx_t; /* 8 bytes */ + +typedef union { + uObjSubMtx_t m; + long long int force_structure_alignment; +} uObjSubMtx; + +/*---------------------------------------------------------------------------* + * Loading into TMEM + *---------------------------------------------------------------------------*/ +#define G_OBJLT_TXTRBLOCK 0x00001033 +#define G_OBJLT_TXTRTILE 0x00fc1034 +#define G_OBJLT_TLUT 0x00000030 + +#define GS_TB_TSIZE(pix,siz) (GS_PIX2TMEM((pix),(siz))-1) +#define GS_TB_TLINE(pix,siz) (GS_CALC_DXT(GS_PIX2TMEM((pix),(siz)))) + +typedef struct { + u32 type; /* G_OBJLT_TXTRBLOCK divided into types. */ + u64 *image; /* The texture source address on DRAM. */ + u16 tmem; /* The transferred TMEM word address. (8byteWORD) */ + u16 tsize; /* The Texture size. Specified by the macro GS_TB_TSIZE(). */ + u16 tline; /* The width of the Texture 1-line. Specified by the macro GS_TB_TLINE()*/ + u16 sid; /* STATE ID Multipled by 4. Either one of 0,4,8 and 12. */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrBlock_t; /* 24 bytes */ + +#define GS_TT_TWIDTH(pix,siz) ((GS_PIX2TMEM((pix), (siz))<<2)-1) +#define GS_TT_THEIGHT(pix,siz) (((pix)<<2)-1) + +typedef struct { + u32 type; /* G_OBJLT_TXTRTILE divided into types. */ + u64 *image; /* The texture source address on DRAM. */ + u16 tmem; /* The loaded texture source address on DRAM. (8byteWORD) */ + u16 twidth; /* The width of the Texture. Specified by the macro GS_TT_TWIDTH() */ + u16 theight; /* The height of the Texture. Specified by the macro GS_TT_THEIGHT()*/ + u16 sid; /* STATE ID Multiplied by 4. Either one of 0,4,8 and 12. */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrTile_t; /* 24 bytes */ + +#define GS_PAL_HEAD(head) ((head)+256) +#define GS_PAL_NUM(num) ((num)-1) + +typedef struct { + u32 type; /* G_OBJLT_TLUT divided into types. */ + u64 *image; /* the texture source address on DRAM. */ + u16 phead; /* The pallet number of the load header. Between 256 and 511. */ + u16 pnum; /* The loading pallet number -1. */ + u16 zero; /* Assign 0 all the time. */ + u16 sid; /* STATE ID Multiplied by 4. Either one of 0,4,8 and 12. */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrTLUT_t; /* 24 bytes */ + +typedef union { + uObjTxtrBlock_t block; + uObjTxtrTile_t tile; + uObjTxtrTLUT_t tlut; + long long int force_structure_alignment; +} uObjTxtr; + +/*---------------------------------------------------------------------------* + * Loading into TMEM & 2D Objects + *---------------------------------------------------------------------------*/ +typedef struct { + uObjTxtr txtr; + uObjSprite sprite; +} uObjTxSprite; /* 48 bytes */ + +/*===========================================================================* + * GBI Commands for S2DEX microcode + *===========================================================================*/ +/* GBI Header */ +#define G_BG_1CYC 0x01 +#define G_BG_COPY 0x02 +#define G_OBJ_RECTANGLE 0x03 +#define G_OBJ_SPRITE 0x04 +#define G_OBJ_MOVEMEM 0x05 +#define G_SELECT_DL 0xb0 +#define G_OBJ_RENDERMODE 0xb1 +#define G_OBJ_RECTANGLE_R 0xb2 +#define G_OBJ_LOADTXTR 0xc1 +#define G_OBJ_LDTX_SPRITE 0xc2 +#define G_OBJ_LDTX_RECT 0xc3 +#define G_OBJ_LDTX_RECT_R 0xc4 +#define G_RDPHALF_0 0xe4 + + +/*---------------------------------------------------------------------------* + * Background wrapped screen + *---------------------------------------------------------------------------*/ +#define gSPBgRectangle(pkt, m, mptr) gDma0p((pkt),(m),(mptr),0) +#define gsSPBgRectangle(m, mptr) gsDma0p( (m),(mptr),0) +#define gSPBgRectCopy(pkt, mptr) gSPBgRectangle((pkt), G_BG_COPY, (mptr)) +#define gsSPBgRectCopy(mptr) gsSPBgRectangle( G_BG_COPY, (mptr)) +#define gSPBgRect1Cyc(pkt, mptr) gSPBgRectangle((pkt), G_BG_1CYC, (mptr)) +#define gsSPBgRect1Cyc(mptr) gsSPBgRectangle( G_BG_1CYC, (mptr)) + +/*---------------------------------------------------------------------------* + * 2D Objects + *---------------------------------------------------------------------------*/ +#define gSPObjSprite(pkt, mptr) gDma0p((pkt),G_OBJ_SPRITE, (mptr),0) +#define gsSPObjSprite(mptr) gsDma0p( G_OBJ_SPRITE, (mptr),0) +#define gSPObjRectangle(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE, (mptr),0) +#define gsSPObjRectangle(mptr) gsDma0p( G_OBJ_RECTANGLE, (mptr),0) +#define gSPObjRectangleR(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE_R,(mptr),0) +#define gsSPObjRectangleR(mptr) gsDma0p( G_OBJ_RECTANGLE_R,(mptr),0) + +/*---------------------------------------------------------------------------* + * 2D Matrix + *---------------------------------------------------------------------------*/ +#define gSPObjMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),0,23) +#define gsSPObjMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),0,23) +#define gSPObjSubMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),2, 7) +#define gsSPObjSubMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),2, 7) + +/*---------------------------------------------------------------------------* + * Loading into TMEM + *---------------------------------------------------------------------------*/ +#define gSPObjLoadTxtr(pkt, tptr) gDma0p((pkt),G_OBJ_LOADTXTR, (tptr),23) +#define gsSPObjLoadTxtr(tptr) gsDma0p( G_OBJ_LOADTXTR, (tptr),23) +#define gSPObjLoadTxSprite(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_SPRITE,(tptr),47) +#define gsSPObjLoadTxSprite(tptr) gsDma0p( G_OBJ_LDTX_SPRITE,(tptr),47) +#define gSPObjLoadTxRect(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT, (tptr),47) +#define gsSPObjLoadTxRect(tptr) gsDma0p( G_OBJ_LDTX_RECT, (tptr),47) +#define gSPObjLoadTxRectR(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT_R,(tptr),47) +#define gsSPObjLoadTxRectR(tptr) gsDma0p( G_OBJ_LDTX_RECT_R,(tptr),47) + +/*---------------------------------------------------------------------------* + * Select Display List + *---------------------------------------------------------------------------*/ +#define gSPSelectDL(pkt, mptr, sid, flag, mask) \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } +#define gsSPSelectDL(mptr, sid, flag, mask) \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } +#define gSPSelectBranchDL(pkt, mptr, sid, flag, mask) \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } +#define gsSPSelectBranchDL(mptr, sid, flag, mask) \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } + +/*---------------------------------------------------------------------------* + * Set general status + *---------------------------------------------------------------------------*/ +#define G_MW_GENSTAT 0x08 /* Note that it is the same value of G_MW_FOG. */ + +#define gSPSetStatus(pkt, sid, val) \ + gMoveWd((pkt), G_MW_GENSTAT, (sid), (val)) +#define gsSPSetStatus(sid, val) \ + gsMoveWd( G_MW_GENSTAT, (sid), (val)) + +/*---------------------------------------------------------------------------* + * Set Object Render Mode + *---------------------------------------------------------------------------*/ +#define G_OBJRM_NOTXCLAMP 0x01 +#define G_OBJRM_XLU 0x02 /* Ignored */ +#define G_OBJRM_ANTIALIAS 0x04 /* Ignored */ +#define G_OBJRM_BILERP 0x08 +#define G_OBJRM_SHRINKSIZE_1 0x10 +#define G_OBJRM_SHRINKSIZE_2 0x20 +#define G_OBJRM_WIDEN 0x40 + +#define gSPObjRenderMode(pkt, mode) gImmp1((pkt),G_OBJ_RENDERMODE,(mode)) +#define gsSPObjRenderMode(mode) gsImmp1( G_OBJ_RENDERMODE,(mode)) + +/*===========================================================================* + * Render Mode Macro + *===========================================================================*/ +#define RM_RA_SPRITE(clk) \ + AA_EN | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define G_RM_SPRITE G_RM_OPA_SURF +#define G_RM_SPRITE2 G_RM_OPA_SURF2 +#define G_RM_RA_SPRITE RM_RA_SPRITE(1) +#define G_RM_RA_SPRITE2 RM_RA_SPRITE(2) +#define G_RM_AA_SPRITE G_RM_AA_TEX_TERR +#define G_RM_AA_SPRITE2 G_RM_AA_TEX_TERR2 +#define G_RM_XLU_SPRITE G_RM_XLU_SURF +#define G_RM_XLU_SPRITE2 G_RM_XLU_SURF2 +#define G_RM_AA_XLU_SPRITE G_RM_AA_XLU_SURF +#define G_RM_AA_XLU_SPRITE2 G_RM_AA_XLU_SURF2 + +/*===========================================================================* + * External functions + *===========================================================================*/ +extern u64 gspS2DEX_fifoTextStart[], gspS2DEX_fifoTextEnd[]; +extern u64 gspS2DEX_fifoDataStart[], gspS2DEX_fifoDataEnd[]; +extern u64 gspS2DEX_fifo_dTextStart[], gspS2DEX_fifo_dTextEnd[]; +extern u64 gspS2DEX_fifo_dDataStart[], gspS2DEX_fifo_dDataEnd[]; +extern void guS2DInitBg(uObjBg *); +extern void guS2DEmuSetScissor(u32, u32, u32, u32, u8); +extern void guS2DEmuBgRect1Cyc(Gfx **, uObjBg *); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* _GS2DEX_H_ */ + +/*======== End of gs2dex.h ========*/ diff --git a/include/PR/gu.h b/include/PR/gu.h index 1f6afaf4..1cae0990 100644 --- a/include/PR/gu.h +++ b/include/PR/gu.h @@ -15,8 +15,8 @@ /************************************************************************** * - * $Revision: 1.45 $ - * $Date: 1997/02/11 08:23:46 $ + * $Revision: 1.46 $ + * $Date: 1997/11/26 00:30:53 $ * $Source: /disk6/Master/cvsmdev2/PR/include/gu.h,v $ * **************************************************************************/ @@ -32,12 +32,12 @@ #define MIN(a,b) (((a)<(b))?(a):(b)) #endif -#define M_PI 3.14159265358979323846 -#define M_DTOR (3.14159265358979323846/180.0) +#define D_PI 3.14159265358979323846 +#define D_DTOR (3.14159265358979323846/180.0) -#define FTOFIX32(x) ((x) * 0x10000) -#define FIX32TOF(x) ((float)(((float)x) / (float)(0x10000))) -#define FTOFRAC8(x) ((int) MIN(((x) * (128.0)),127.0) & 0xff) +#define FTOFIX32(x) (long)((x) * (float)0x00010000) +#define FIX32TOF(x) ((float)(x) * (1.0f / (float)0x00010000)) +#define FTOFRAC8(x) ((int) MIN(((x) * (128.0f)), 127.0f) & 0xff) #define FILTER_WRAP 0 #define FILTER_CLAMP 1 @@ -191,7 +191,7 @@ extern float sinf(float angle); extern float cosf(float angle); extern signed short sins (unsigned short angle); extern signed short coss (unsigned short angle); -extern float sqrtf(float value); +extern float guSqrtf(float value); /* * Dump routines for low-level display lists diff --git a/include/PR/leo.h b/include/PR/leo.h deleted file mode 100644 index 8611d15b..00000000 --- a/include/PR/leo.h +++ /dev/null @@ -1,238 +0,0 @@ - -/************************************************************************** - * - * $Revision: 1.8 $ - * $Date: 1997/02/13 14:54:47 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/leo.h,v $ - * - **************************************************************************/ - -#ifndef _LEO_H_ -#define _LEO_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ -typedef u32 LEOError; - -typedef u8 LEOSpdlMode; - -typedef u8 LEOStatus; - -typedef struct -{ - u8 drive; /* version of hw */ - u8 driver; /* version of sw */ - u8 deviceType; /* dev type, always 00 */ - u8 ndevices; /* # of devices, always 01 */ -} LEOVersion; - -typedef struct -{ - u32 startLBA; - u32 endLBA; - u32 nbytes; -} LEOCapacity; - -typedef struct -{ - u8 pad; - u8 yearhi; - u8 yearlo; - u8 month; - u8 day; - u8 hour; - u8 minute; - u8 second; -} LEODiskTime; - -typedef struct -{ - u64 lineNumber; - LEODiskTime time; -} LEOSerialNum; - -typedef struct -{ - u8 gameName[4]; - u8 gameVersion; - u8 diskNumber; - u16 diskUsage; - LEOSerialNum serialNumber; - u64 reserve; -} LEODiskID; - -typedef struct -{ - LEOCmdHeader header; - union - { - struct - { - u32 lba; - u32 xfer_blks; - void *buff_ptr; - u32 rw_bytes; - } readwrite; - struct - { - u32 lba; - } seek; - struct - { - void *buffer_pointer; - } readdiskid; - LEODiskTime time; - } data; - -} LEOCmd; - -#define _nbytes readwrite.rw_bytes -#define _result header.status - - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ -#define LEO_SW_VERSION 1 /* This will be returned by */ - /* LeoInquiry command */ - -#define OS_PRIORITY_LEOMGR OS_PRIORITY_PIMGR - -/* - * Drive Rom offset address - */ -#define DDROM_FONT_START 0x000a0000 -#define DDROM_WAVEDATA_START 0x00140000 - -/* - * Definition for osLeoSpdlMotor() - */ -#define ACTIVE 0 -#define STANDBY 1 -#define SLEEP 2 - -#define LEO_MOTOR_ACTIVE 0 -#define LEO_MOTOR_STANDBY 1 -#define LEO_MOTOR_SLEEP 2 - -#define NUM_LBAS 4292 /* total number of LBAs */ - -#define BLK_SIZE_ZONE0 19720 -#define BLK_SIZE_ZONE1 18360 -#define BLK_SIZE_ZONE2 17680 -#define BLK_SIZE_ZONE3 16320 -#define BLK_SIZE_ZONE4 14960 -#define BLK_SIZE_ZONE5 13600 -#define BLK_SIZE_ZONE6 12240 -#define BLK_SIZE_ZONE7 10880 -#define BLK_SIZE_ZONE8 9520 - -#define MAX_BLK_SIZE BLK_SIZE_ZONE0 -#define MIN_BLK_SIZE BLK_SIZE_ZONE8 - -/* - * Error codes - */ -#define LEO_ERROR_GOOD 0 -#define LEO_ERROR_DRIVE_NOT_READY 1 -#define LEO_ERROR_DIAGNOSTIC_FAILURE 2 -#define LEO_ERROR_COMMAND_PHASE_ERROR 3 -#define LEO_ERROR_DATA_PHASE_ERROR 4 -#define LEO_ERROR_REAL_TIME_CLOCK_FAILURE 5 -#define LEO_ERROR_BUSY 8 -#define LEO_ERROR_INCOMPATIBLE_MEDIUM_INSTALLED 11 -#define LEO_ERROR_UNKNOWN_FORMAT 11 -#define LEO_ERROR_NO_SEEK_COMPLETE 21 -#define LEO_ERROR_WRITE_FAULT 22 -#define LEO_ERROR_UNRECOVERED_READ_ERROR 23 -#define LEO_ERROR_NO_REFERENCE_POSITION_FOUND 24 -#define LEO_ERROR_TRACK_FOLLOWING_ERROR 25 -#define LEO_ERROR_TRACKING_OR_SPDL_SERVO_FAILURE 25 -#define LEO_ERROR_INVALID_COMMAND_OPERATION_CODE 31 -#define LEO_ERROR_LBA_OUT_OF_RANGE 32 -#define LEO_ERROR_WRITE_PROTECT_ERROR 33 -#define LEO_ERROR_COMMAND_CLEARED_BY_HOST 34 -#define LEO_ERROR_COMMAND_TERMINATED 34 -#define LEO_ERROR_QUEUE_FULL 35 -#define LEO_ERROR_DEVICE_COMMUNICATION_FAILURE 41 -#define LEO_ERROR_MEDIUM_NOT_PRESENT 42 -#define LEO_ERROR_POWERONRESET_DEVICERESET_OCCURED 43 -#define LEO_ERROR_RAMPACK_NOT_CONNECTED 44 -#define LEO_ERROR_NOT_BOOTED_DISK 45 -#define LEO_ERROR_DIDNOT_CHANGED_DISK_AS_EXPECTED 46 -#define LEO_ERROR_MEDIUM_MAY_HAVE_CHANGED 47 -#define LEO_ERROR_RTC_NOT_SET_CORRECTLY 48 -#define LEO_ERROR_DISK_EJECTED_WHEN_ACCESSED 49 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ -#define GET_ERROR(x) ((x).header.sense) - -/************************************************************************** - * - * Extern variables - * - */ -extern LEODiskID leoBootID; - -/************************************************************************** - * - * Function prototypes - * - */ -/* Initialize routine */ -extern s32 LeoCreateLeoManager(OSPri comPri, OSPri intPri, - OSMesg *cmdBuf, s32 cmdMsgCnt); - -/* Synchronous functions */ -extern s32 LeoClearQueue(void); -extern s32 LeoByteToLBA(s32 startLBA, u32 nbytes, s32 *lbas); -extern s32 LeoLBAToByte(s32 startLBA, u32 nLBAs, s32 *bytes); -extern s32 LeoReadCapacity(LEOCapacity *cap, s32 dir); -extern s32 LeoInquiry(LEOVersion *ver); -extern s32 LeoTestUnitReady(LEOStatus *status); -extern s32 LeoModeSelect(u32 standby, u32 sleep); - -/* Asynchronous functions */ -extern s32 LeoSpdlMotor(LEOCmd *cmdBlock, LEOSpdlMode mode, OSMesgQueue *mq); -extern s32 LeoSeek(LEOCmd *cmdBlock, u32 lba, OSMesgQueue *mq); -extern s32 LeoRezero(LEOCmd *cmdBlock, OSMesgQueue *mq); -extern s32 LeoReadWrite(LEOCmd *cmdBlock, s32 direction, - u32 LBA, void *vAddr, u32 nLBAs, OSMesgQueue *mq); -extern s32 LeoReadDiskID(LEOCmd *cmdBlock, LEODiskID *vaddr, OSMesgQueue *mq); -extern s32 LeoSetRTC(LEOCmd *cmdBlock, LEODiskTime *RTCdata, OSMesgQueue *mq); -extern s32 LeoReadRTC(LEOCmd *cmdBlock, OSMesgQueue *mq); - -/* Font routines */ -extern int LeoGetKAdr(int sjis); -extern int LeoGetAAdr(int code,int *dx,int *dy, int *cy); - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_LEO_H */ diff --git a/include/PR/leoappli.h b/include/PR/leoappli.h deleted file mode 100644 index 5e401a41..00000000 --- a/include/PR/leoappli.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * F i l e N a m e : l e o a p p l i . h - * - **************************************************************************** - * (C) Copyright ALPS Electric Co., Ltd. 1995-1996 - **************************************************************************** -*/ - -/************************************************************************** - * - * $Revision: 1.4 $ - * $Date: 1997/02/11 16:14:19 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/leoappli.h,v $ - * - **************************************************************************/ - -/*-----------------------------------*/ -/* DRIVE PARAMETER */ -/*-----------------------------------*/ -#define LEO_DISK_TYPE_MIN 0 -#define LEO_DISK_TYPE_MAX 6 - -#define LEO_LBA_MIN 0 -#define LEO_LBA_MAX 4291 - -#define LEO_LBA_ROM_TOP LEO_LBA_MIN -#define LEO_LBA_ROM_END0 1417 -#define LEO_LBA_ROM_END1 1965 -#define LEO_LBA_ROM_END2 2513 -#define LEO_LBA_ROM_END3 3061 -#define LEO_LBA_ROM_END4 3609 -#define LEO_LBA_ROM_END5 4087 -#define LEO_LBA_ROM_END6 LEO_LBA_MAX -#define LEO_LBA_RAM_TOP0 (LEO_LBA_ROM_END0+1) -#define LEO_LBA_RAM_TOP1 (LEO_LBA_ROM_END1+1) -#define LEO_LBA_RAM_TOP2 (LEO_LBA_ROM_END2+1) -#define LEO_LBA_RAM_TOP3 (LEO_LBA_ROM_END3+1) -#define LEO_LBA_RAM_TOP4 (LEO_LBA_ROM_END4+1) -#define LEO_LBA_RAM_TOP5 (LEO_LBA_ROM_END5+1) -#define LEO_LBA_RAM_TOP6 (LEO_LBA_ROM_END6+1) -#define LEO_LBA_RAM_END6 LEO_LBA_MAX - -/*-----------------------------------*/ -/* LEO FUNCTION DEFINITIONS */ -/*-----------------------------------*/ -extern void leoInitialize(OSPri PRI_WRK, OSPri PRI_INT, OSMesg *command_que_buf, u32 cmd_buff_size); -extern void leoCommand(void *CDB); -extern void leoReset(void); - -/*-----------------------------------*/ -/* THREAD PRIORITY */ -/*-----------------------------------*/ -#define LEO_PRIORITY_WRK (OS_PRIORITY_PIMGR-1) -#define LEO_PRIORITY_INT OS_PRIORITY_PIMGR - -/*-----------------------------------*/ -/* COMMAND CODE */ -/*-----------------------------------*/ -#define LEO_COMMAND_CLEAR_QUE 0x01 -#define LEO_COMMAND_INQUIRY 0x02 -#define LEO_COMMAND_TEST_UNIT_READY 0x03 -#define LEO_COMMAND_REZERO 0x04 -#define LEO_COMMAND_READ 0x05 -#define LEO_COMMAND_WRITE 0x06 -#define LEO_COMMAND_SEEK 0x07 -#define LEO_COMMAND_START_STOP 0x08 -#define LEO_COMMAND_READ_CAPACITY 0x09 -#define LEO_COMMAND_TRANSLATE 0x0a -#define LEO_COMMAND_MODE_SELECT 0x0b -#define LEO_COMMAND_READ_DISK_ID 0x0c -#define LEO_COMMAND_READ_TIMER 0x0d -#define LEO_COMMAND_SET_TIMER 0x0e - -/*-----------------------------------*/ -/* CONTROL BIT */ -/*-----------------------------------*/ -#define LEO_CONTROL_POST 0x80 /* ENABLE POST QUEUE */ -#define LEO_CONTROL_START 0x01 /* START COMMAND */ -#define LEO_CONTROL_STBY 0x02 /* STAND-BY MODE(NOT SLEEP MODE) */ -#define LEO_CONTROL_WRT 0x01 /* READ RE-WRITE-ABLE CAPACITY */ -#define LEO_CONTROL_TBL 0x01 /* TRANSLATE BYTE TO LBA */ - -/*-----------------------------------*/ -/* BIT FIELD PARAMETER */ -/*-----------------------------------*/ -#define LEO_TEST_UNIT_MR 0x01 /* MEDIUM REMOVED */ -#define LEO_TEST_UNIT_RE 0x02 /* HEAD RETRACTED */ -#define LEO_TEST_UNIT_SS 0x04 /* SPINDLE STOPPED */ - -/*-----------------------------------*/ -/* STATUS */ -/*-----------------------------------*/ -#define LEO_STATUS_GOOD 0x00 -#define LEO_STATUS_CHECK_CONDITION 0x02 -#define LEO_STATUS_BUSY 0x08 - -/*-----------------------------------*/ -/* SENSE CODE */ -/*-----------------------------------*/ -#define LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION 00 -#define LEO_SENSE_DRIVE_NOT_READY 01 -#define LEO_SENSE_DIAGNOSTIC_FAILURE 02 -#define LEO_SENSE_COMMAND_PHASE_ERROR 03 -#define LEO_SENSE_DATA_PHASE_ERROR 04 -#define LEO_SENSE_REAL_TIME_CLOCK_FAILURE 05 -#define LEO_SENSE_INCOMPATIBLE_MEDIUM_INSTALLED 11 -#define LEO_SENSE_UNKNOWN_FORMAT 11 -#define LEO_SENSE_NO_SEEK_COMPLETE 21 -#define LEO_SENSE_WRITE_FAULT 22 -#define LEO_SENSE_UNRECOVERED_READ_ERROR 23 -#define LEO_SENSE_NO_REFERENCE_POSITION_FOUND 24 -#define LEO_SENSE_TRACK_FOLLOWING_ERROR 25 -#define LEO_SENSE_TRACKING_OR_SPDL_SERVO_FAILURE 25 -#define LEO_SENSE_INVALID_COMMAND_OPERATION_CODE 31 -#define LEO_SENSE_LBA_OUT_OF_RANGE 32 -#define LEO_SENSE_WRITE_PROTECT_ERROR 33 -#define LEO_SENSE_COMMAND_TERMINATED 34 -#define LEO_SENSE_QUEUE_FULL 35 -#define LEO_SENSE_ILLEGAL_TIMER_VALUE 36 -#define LEO_SENSE_DEVICE_COMMUNICATION_FAILURE 41 -#define LEO_SENSE_MEDIUM_NOT_PRESENT 42 -#define LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED 43 -#define LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED 47 - -/*-----------------------------------*/ -/* Command Block Header */ -/*-----------------------------------*/ -typedef struct{ - u8 command; - u8 reserve1; - u8 control; - u8 reserve3; - u8 status; - u8 sense; - u8 reserve6; - u8 reserve7; - OSMesgQueue *post; -} LEOCmdHeader; - -/*-----------------------------------*/ -/* CLEAR QUEUE(01H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; -} LEOCmdClearQue; - -/*-----------------------------------*/ -/* INQUIRY(02H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u8 dev_type; - u8 version; - u8 dev_num; - u8 leo_bios_ver; - u32 reserve5; -} LEOCmdInquiry; - -/*-----------------------------------*/ -/* TEST UNIT READY(03H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u8 test; - u8 reserve2; - u8 reserve3; - u8 reserve4; -} LEOCmdTestUnitReady; - -/*-----------------------------------*/ -/* REZERO(04H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; -} LEOCmdRezero; - -/*-----------------------------------*/ -/* READ(05H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u32 lba; - u32 xfer_blks; - void *buff_ptr; - u32 rw_bytes; -} LEOCmdRead; - -/*-----------------------------------*/ -/* WRITE(06H) command */ -/*-----------------------------------*/ -typedef LEOCmdRead LEOCmdWrite; - -/*-----------------------------------*/ -/* SEEK(07H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u32 lba; -} LEOCmdSeek; - -/*-----------------------------------*/ -/* START/STOP(08H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; -} LEOCmdStartStop; - -/*-----------------------------------*/ -/* READ CAPACITY(09H) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u32 start_lba; - u32 end_lba; - u32 capa_bytes; -} LEOCmdReadCapacity; - -/*-----------------------------------*/ -/* TRANSLATE(0AH) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u32 start_lba; - u32 in_param; - u32 out_param; -} LEOCmdTranslate; - -/*-----------------------------------*/ -/* MODE SELECT(0BH) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u8 page_code; - u8 reserve1; - u8 standby_time; - u8 sleep_time; - u8 led_on_time; - u8 led_off_time; - u8 reserve18; - u8 reserve19; -} LEOCmdModeSelect; - -/*-----------------------------------*/ -/* READ DISK ID(0CH) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - void *buffer_pointer; -} LEOCmdReadDiskId; - -/*-----------------------------------*/ -/* READ TIMER(0DH) command */ -/*-----------------------------------*/ -typedef struct { - LEOCmdHeader header; - u8 reserve12; - u8 reserve13; - u8 year; - u8 month; - u8 day; - u8 hour; - u8 minute; - u8 second; -} LEOCmdReadTimer; - -/*-----------------------------------*/ -/* SET TIMER(0EH) command */ -/*-----------------------------------*/ -typedef LEOCmdReadTimer LEOCmdSetTimer; - -/*-------end of leoappli.h--------------------------*/ - - diff --git a/include/PR/libaudio.h b/include/PR/libaudio.h index 0ae18ba7..55f22c84 100644 --- a/include/PR/libaudio.h +++ b/include/PR/libaudio.h @@ -20,8 +20,8 @@ /************************************************************************** * - * $Revision: 1.172 $ - * $Date: 1997/02/11 08:24:57 $ + * $Revision: 1.173 $ + * $Date: 1997/12/01 12:42:21 $ * $Source: /disk6/Master/cvsmdev2/PR/include/libaudio.h,v $ * **************************************************************************/ @@ -57,7 +57,9 @@ extern "C" { # endif /* AUD_PROFILE */ #endif /* EMULATOR */ +#ifndef NULL #define NULL 0 +#endif #define AL_FX_BUFFER_SIZE 8192 #define AL_FRAME_INIT -1 diff --git a/include/PR/libnos.h b/include/PR/libnos.h deleted file mode 100644 index 042d229c..00000000 --- a/include/PR/libnos.h +++ /dev/null @@ -1,18 +0,0 @@ -/*--------------------------------------------------------------------- - File : libnos.h version 1.3 - - Coded by Yoshitaka Yasumoto. Apr 13, 1996. - - Copyright by Nintendo, Co., Ltd. 1996. - ---------------------------------------------------------------------*/ -#ifndef __libnos_h__ -#define __libnos_h__ - -#define FONTSIZE_E 2112 -#define FONTSIZE_J 4768 - -extern void nosLoadFont(u16 *); -extern int nosPakMenu(OSMesgQueue *, OSMesgQueue *); - -#endif - diff --git a/include/PR/mbi.h b/include/PR/mbi.h index 712dada4..9956ef20 100644 --- a/include/PR/mbi.h +++ b/include/PR/mbi.h @@ -15,8 +15,8 @@ /************************************************************************** * - * $Revision: 1.134 $ - * $Date: 1997/02/11 08:25:28 $ + * $Revision: 1.135 $ + * $Date: 1997/11/26 00:30:54 $ * $Source: /disk6/Master/cvsmdev2/PR/include/mbi.h,v $ * **************************************************************************/ @@ -88,7 +88,7 @@ #define NUM_SEGMENTS (16) #define SEGMENT_OFFSET(a) ((unsigned int)(a) & 0x00ffffff) -#define SEGMENT_NUMBER(a) ((unsigned int)(a) >> 24) +#define SEGMENT_NUMBER(a) (((unsigned int)(a) << 4) >> 28) #define SEGMENT_ADDR(num, off) (((num) << 24) + (off)) #ifndef NULL diff --git a/include/PR/ncode.h b/include/PR/ncode.h deleted file mode 100644 index 6791ea7f..00000000 --- a/include/PR/ncode.h +++ /dev/null @@ -1,155 +0,0 @@ -/*--------------------------------------------------------------------- - File : ncode.h - - Coded by Yoshitaka Yasumoto. Feb 14, 1996. - Copyright by Nintendo, Co., Ltd. 1996. - ---------------------------------------------------------------------*/ -#ifndef __ncode_h__ -#define __ncode_h__ - -//------------------------------------------------------ -// Nintendo code for letter(upper case) & digit -//------------------------------------------------------ -#define __NUL 0x00 -#define __SPC 0x0f -#define __0 0x10 -#define __1 0x11 -#define __2 0x12 -#define __3 0x13 -#define __4 0x14 -#define __5 0x15 -#define __6 0x16 -#define __7 0x17 -#define __8 0x18 -#define __9 0x19 -#define __A 0x1a -#define __B 0x1b -#define __C 0x1c -#define __D 0x1d -#define __E 0x1e -#define __F 0x1f -#define __G 0x20 -#define __H 0x21 -#define __I 0x22 -#define __J 0x23 -#define __K 0x24 -#define __L 0x25 -#define __M 0x26 -#define __N 0x27 -#define __O 0x28 -#define __P 0x29 -#define __Q 0x2a -#define __R 0x2b -#define __S 0x2c -#define __T 0x2d -#define __U 0x2e -#define __V 0x2f -#define __W 0x30 -#define __X 0x31 -#define __Y 0x32 -#define __Z 0x33 -#define __EXCLAM 0x34 // ! -#define __2QUOTE 0x35 // " -#define __NUMBR 0x36 // # -#define __1QUOTE 0x37 // ' -#define __ASTER 0x38 // * -#define __PLUS 0x39 // + -#define __COMMA 0x3a // , -#define __MINUS 0x3b // - -#define __PERIOD 0x3c // . -#define __SLASH 0x3d // / -#define __COLON 0x3e // : -#define __EQUAL 0x3f // = -#define __QUEST 0x40 // ? -#define __AT 0x41 // @ - -//----------------------------------------------- -// Nintendo code for JAPANESE letter -//----------------------------------------------- -#ifdef LANG_JAPANESE -# define j_MARU 0x42 -# define j_DAKU 0x43 -# define j_HANDAKU 0x44 -# define j_XA 0x45 -# define j_XI 0x46 -# define j_XU 0x47 -# define j_XE 0x48 -# define j_XO 0x49 -# define j_XTSU 0x4a -# define j_XYA 0x4b -# define j_XYU 0x4c -# define j_XYO 0x4d -# define j_WO 0x4e -# define j_N 0x4f -# define j_A 0x50 -# define j_I 0x51 -# define j_U 0x52 -# define j_E 0x53 -# define j_O 0x54 -# define j_KA 0x55 -# define j_KI 0x56 -# define j_KU 0x57 -# define j_KE 0x58 -# define j_KO 0x59 -# define j_SA 0x5a -# define j_SHI 0x5b -# define j_SU 0x5c -# define j_SE 0x5d -# define j_SO 0x5e -# define j_TA 0x5f -# define j_CHI 0x60 -# define j_TSU 0x61 -# define j_TE 0x62 -# define j_TO 0x63 -# define j_NA 0x64 -# define j_NI 0x65 -# define j_NU 0x66 -# define j_NE 0x67 -# define j_NO 0x68 -# define j_HA 0x69 -# define j_HI 0x6a -# define j_FU 0x6b -# define j_HE 0x6c -# define j_HO 0x6d -# define j_MA 0x6e -# define j_MI 0x6f -# define j_MU 0x70 -# define j_ME 0x71 -# define j_MO 0x72 -# define j_YA 0x73 -# define j_YU 0x74 -# define j_YO 0x75 -# define j_RA 0x76 -# define j_RI 0x77 -# define j_RU 0x78 -# define j_RE 0x79 -# define j_RO 0x7a -# define j_WA 0x7b -# define j_GA 0x7c -# define j_GI 0x7d -# define j_GU 0x7e -# define j_GE 0x7f -# define j_GO 0x80 -# define j_ZA 0x81 -# define j_JI 0x82 -# define j_ZU 0x83 -# define j_ZE 0x84 -# define j_ZO 0x85 -# define j_DA 0x86 -# define j_DI 0x87 -# define j_DU 0x88 -# define j_DE 0x89 -# define j_DO 0x8a -# define j_BA 0x8b -# define j_BI 0x8c -# define j_BU 0x8d -# define j_BE 0x8e -# define j_BO 0x8f -# define j_PA 0x90 -# define j_PI 0x91 -# define j_PU 0x92 -# define j_PE 0x93 -# define j_PO 0x94 -#endif - -#endif diff --git a/include/PR/os.h b/include/PR/os.h index 073232e7..cd0aea18 100644 --- a/include/PR/os.h +++ b/include/PR/os.h @@ -21,8 +21,8 @@ /************************************************************************** * - * $Revision: 1.137 $ - * $Date: 1997/02/13 14:54:14 $ + * $Revision: 1.149 $ + * $Date: 1997/12/15 04:30:52 $ * $Source: /disk6/Master/cvsmdev2/PR/include/os.h,v $ * **************************************************************************/ @@ -555,6 +555,10 @@ typedef struct { #define CONT_RELATIVE 0x0002 #define CONT_JOYPORT 0x0004 #define CONT_EEPROM 0x8000 +#define CONT_EEP16K 0x4000 +#define CONT_TYPE_MASK 0x1f07 +#define CONT_TYPE_NORMAL 0x0005 +#define CONT_TYPE_MOUSE 0x0002 /* Controller status */ @@ -563,6 +567,11 @@ typedef struct { #define CONT_ADDR_CRC_ER 0x04 #define CONT_EEPROM_BUSY 0x80 +/* EEPROM TYPE */ + +#define EEPROM_TYPE_4K 0x01 +#define EEPROM_TYPE_16K 0x02 + /* Buttons */ #define CONT_A 0x8000 @@ -598,6 +607,9 @@ typedef struct { #define D_CBUTTONS CONT_D /* File System size */ +#define OS_PFS_VERSION 0x0200 +#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) +#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) #define PFS_FILE_NAME_LEN 16 #define PFS_FILE_EXT_LEN 4 @@ -633,8 +645,15 @@ typedef struct { /* definition for EEPROM */ #define EEPROM_MAXBLOCKS 64 +#define EEP16K_MAXBLOCKS 256 #define EEPROM_BLOCK_SIZE 8 +/* + * PI/EPI + */ +#define PI_DOMAIN1 0 +#define PI_DOMAIN2 1 + /* * Profiler constants */ @@ -683,11 +702,12 @@ typedef struct { */ extern u64 osClockRate; -#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(osClockRate))/1000000000LL) -#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(osClockRate))/1000000LL) -#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*1000000000LL)/(osClockRate)) -#define OS_CYCLES_TO_USEC(c) (((u64)(c)*1000000LL)/(osClockRate)) - +#define OS_CLOCK_RATE 62500000LL +#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) +#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) +#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) +#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) +#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) /************************************************************************** * @@ -864,7 +884,7 @@ extern void osViSetEvent(OSMesgQueue *, OSMesg, u32); extern void osViSwapBuffer(void *); extern void osViBlack(u8); extern void osViFade(u8, u16); -extern void osRepeatLine(u8); +extern void osViRepeatLine(u8); extern void osCreateViManager(OSPri); /* Timer interface */ @@ -877,7 +897,7 @@ extern int osStopTimer(OSTimer *); /* Controller interface */ -extern s32 osContInit(OSMesgQueue * mq, u8 * bitpattern, OSContStatus * data); +extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); extern s32 osContReset(OSMesgQueue *, OSContStatus *); extern s32 osContStartQuery(OSMesgQueue *); extern s32 osContStartReadData(OSMesgQueue *); @@ -904,7 +924,6 @@ extern s32 osPfsSetLabel(OSPfs *, u8 *); extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); extern s32 osPfsFreeBlocks(OSPfs *, s32 *); extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); -extern s32 osPfsReSizeFile(OSPfs *, u16 , u32 , u8 *, u8 *, int); /* EEPROM interface */ @@ -933,6 +952,7 @@ extern s32 osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 ); extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 ); extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *); extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32); +extern s32 osEPiLinkHandle(OSPiHandle *); /* Profiler Interface */ @@ -961,6 +981,7 @@ extern void bzero(void *, int); extern void osInitialize(void); extern u32 osGetCount(void); extern void osExit(void); +extern u32 osGetMemSize(void); /* Printf */ diff --git a/include/PR/os_inter.h b/include/PR/os_inter.h deleted file mode 100644 index 544eb32f..00000000 --- a/include/PR/os_inter.h +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.18 $ - * $Date: 1997/02/11 08:26:14 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/os_internal.h,v $ - * - **************************************************************************/ - -#ifndef _OS_INTERNAL_H_ -#define _OS_INTERNAL_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/* Routines to get/fetch coprocessor 0 registers */ - -extern u32 __osGetCause(void); -extern void __osSetCause(u32); -extern u32 __osGetCompare(void); -extern void __osSetCompare(u32); -extern u32 __osGetConfig(void); -extern void __osSetConfig(u32); -extern void __osSetCount(u32); -extern u32 __osGetSR(void); -extern void __osSetSR(u32); -extern u32 __osDisableInt(void); -extern void __osRestoreInt(u32); - -/* Routines to get/set floating-point control and status register */ -extern u32 __osSetFpcCsr(u32); -extern u32 __osGetFpcCsr(void); - -/* Routine for HW interrupt "handler" */ -extern void __osSetHWIntrRoutine(OSHWIntr, s32 (*handler)(void)); - -/* Routine for global interrupt mask */ -extern void __osSetGlobalIntMask(OSHWIntr); -extern void __osResetGlobalIntMask(OSHWIntr); - -/* Routine for global interrupt mask */ -extern s32 __osLeoInterrupt(void); - -/* Routines for fetch TLB info */ - -extern u32 __osGetTLBASID(void); -extern u32 __osGetTLBPageMask(s32); -extern u32 __osGetTLBHi(s32); -extern u32 __osGetTLBLo0(s32); -extern u32 __osGetTLBLo1(s32); - -/* Serial interface (Si) */ - -extern u32 __osSiGetStatus(void); -extern s32 __osSiRawWriteIo(u32, u32); -extern s32 __osSiRawReadIo(u32, u32 *); -extern s32 __osSiRawStartDma(s32, void *); - -/* Signal processor interface (Sp) */ - -extern u32 __osSpGetStatus(void); -extern void __osSpSetStatus(u32); -extern s32 __osSpSetPc(u32); -extern s32 __osSpRawWriteIo(u32, u32); -extern s32 __osSpRawReadIo(u32, u32 *); -extern s32 __osSpRawStartDma(s32, u32, void *, u32); - -/* Error handling */ - -extern void __osError(s16, s16, ...); -extern OSThread * __osGetCurrFaultedThread(void); -extern OSThread * __osGetNextFaultedThread(OSThread *); - -/* Development board functions */ - -extern void __osGIOInit(s32); -extern void __osGIOInterrupt(s32); -extern void __osGIORawInterrupt(s32); - -/* For debugger use */ - -extern OSThread * __osGetActiveQueue(void); - -/* Debug port */ -extern void __osSyncPutChars(int, int, const char *); -extern int __osSyncGetChars(char *); -extern void __osAsyncPutChars(int, int, const char *); -extern int __osAsyncGetChars(char *); -extern int __osAtomicInc(unsigned int *p); -extern int __osAtomicDec(unsigned int *p); - -/* routine for rdb port */ -extern u32 __osRdbSend(u8 *buf, u32 size, u32 type); - - -#endif /* _LANGUAGE_C */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_INTERNAL_H */ diff --git a/include/PR/primage.h b/include/PR/primage.h index 158a7013..407894fb 100644 --- a/include/PR/primage.h +++ b/include/PR/primage.h @@ -1,7 +1,7 @@ /************************************************************************** * - * $Revision: 1.3 $ - * $Date: 1997/02/11 08:13:08 $ + * $Revision: 1.4 $ + * $Date: 1997/11/26 00:30:50 $ * $Source: /disk6/Master/cvsmdev2/PR/include/PRimage.h,v $ * **************************************************************************/ @@ -45,7 +45,7 @@ extern "C" { #define BPP(type) ((type) & BPPMASK) #define RLE(bpp) (ITYPE_RLE | (bpp)) #define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) -#define IBUFSIZE(pixels) ((pixels+(pixels>>6))<<2) +#define IBUFSIZE(pixels) (((pixels)+((pixels)>>6))<<2) #define RLE_NOP 0x00 #define ierror(p) (((p)->flags&_IOERR)!=0) diff --git a/include/PR/rcp.h b/include/PR/rcp.h index e092bf06..3795ff72 100644 --- a/include/PR/rcp.h +++ b/include/PR/rcp.h @@ -18,8 +18,8 @@ * File: rcp.h * * This file contains register and bit definitions for RCP memory map. - * $Revision: 1.17 $ - * $Date: 1997/02/11 08:28:14 $ + * $Revision: 1.20 $ + * $Date: 1997/07/23 08:35:21 $ * $Source: /disk6/Master/cvsmdev2/PR/include/rcp.h,v $ * **************************************************************************/ @@ -160,7 +160,7 @@ The Indy development board use cartridge domain 1: #define DEVICE_TYPE_CART 0 /* ROM cartridge */ #define DEVICE_TYPE_BULK 1 /* ROM bulk */ #define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */ - +#define DEVICE_TYPE_SRAM 3 /* SRAM */ /************************************************************************* * SP Memory @@ -270,7 +270,12 @@ The Indy development board use cartridge domain 1: #define SP_CLR_TASKDONE SP_CLR_SIG2 #define SP_SET_TASKDONE SP_SET_SIG2 #define SP_STATUS_TASKDONE SP_STATUS_SIG2 - +#define SP_CLR_RSPSIGNAL SP_CLR_SIG3 +#define SP_SET_RSPSIGNAL SP_SET_SIG3 +#define SP_STATUS_RSPSIGNAL SP_STATUS_SIG3 +#define SP_CLR_CPUSIGNAL SP_CLR_SIG4 +#define SP_SET_CPUSIGNAL SP_SET_SIG4 +#define SP_STATUS_CPUSIGNAL SP_STATUS_SIG4 /* SP IMEM BIST REG (R/W): [6:0] BIST status bits; see below for detail */ #define SP_IBIST_REG 0x04080004 diff --git a/include/PR/region.h b/include/PR/region.h index 55071696..9f8bb7f1 100644 --- a/include/PR/region.h +++ b/include/PR/region.h @@ -15,9 +15,9 @@ * * Module: region.h * - * $Revision: 1.7 $ - * $Date: 1995/06/07 05:11:42 $ - * $Author: chn $ + * $Revision: 1.8 $ + * $Date: 1997/11/26 00:30:56 $ + * $Author: mitu $ * $Source: /disk6/Master/cvsmdev2/PR/include/region.h,v $ * * Description: @@ -73,7 +73,7 @@ extern "C" { */ /* Perform alignment on input 's' */ -#define ALIGN(s, align) (((u32)(s) + (align-1)) & ~(align-1)) +#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1)) /*************************************** diff --git a/include/PR/sptask.h b/include/PR/sptask.h index d4706e86..8d6ea412 100644 --- a/include/PR/sptask.h +++ b/include/PR/sptask.h @@ -12,8 +12,8 @@ /************************************************************************** * - * $Revision: 1.7 $ - * $Date: 1997/02/11 08:33:45 $ + * $Revision: 1.8 $ + * $Date: 1997/11/10 10:48:35 $ * $Source: /disk6/Master/cvsmdev2/PR/include/sptask.h,v $ * **************************************************************************/ @@ -124,6 +124,7 @@ typedef u32 OSYieldResult; #define OS_TASK_YIELDED 0x0001 #define OS_TASK_DP_WAIT 0x0002 #define OS_TASK_LOADABLE 0x0004 +#define OS_TASK_SP_ONLY 0x0008 #define OS_TASK_USR0 0x0010 #define OS_TASK_USR1 0x0020 #define OS_TASK_USR2 0x0040 diff --git a/include/PR/ucode.h b/include/PR/ucode.h index 828c564a..1025d2f9 100644 --- a/include/PR/ucode.h +++ b/include/PR/ucode.h @@ -12,8 +12,8 @@ /************************************************************************** * - * $Revision: 1.12 $ - * $Date: 1997/02/11 08:36:39 $ + * $Revision: 1.13 $ + * $Date: 1997/11/07 04:55:12 $ * $Source: /disk6/Master/cvsmdev2/PR/include/ucode.h,v $ * **************************************************************************/ @@ -152,6 +152,25 @@ extern long long int gspF3DLP_Rej_fifoDataStart[], gspF3DLP_Rej_fifoDataEnd[]; extern long long int gspL3DEX_fifoTextStart[], gspL3DEX_fifoTextEnd[]; extern long long int gspL3DEX_fifoDataStart[], gspL3DEX_fifoDataEnd[]; +/*========== F3DEX2/F3DLX2/F3DLP2/L3DEX2 ==========*/ +/* FIFO version only */ +extern long long int gspF3DEX2_fifoTextStart[], gspF3DEX2_fifoTextEnd[]; +extern long long int gspF3DEX2_fifoDataStart[], gspF3DEX2_fifoDataEnd[]; +extern long long int gspF3DEX2_NoN_fifoTextStart[],gspF3DEX2_NoN_fifoTextEnd[]; +extern long long int gspF3DEX2_NoN_fifoDataStart[],gspF3DEX2_NoN_fifoDataEnd[]; + +extern long long int gspF3DLX2_fifoTextStart[], gspF3DLX2_fifoTextEnd[]; +extern long long int gspF3DLX2_fifoDataStart[], gspF3DLX2_fifoDataEnd[]; +extern long long int gspF3DLX2_NoN_fifoTextStart[],gspF3DLX2_NoN_fifoTextEnd[]; +extern long long int gspF3DLX2_NoN_fifoDataStart[],gspF3DLX2_NoN_fifoDataEnd[]; +extern long long int gspF3DLX2_Rej_fifoTextStart[],gspF3DLX2_Rej_fifoTextEnd[]; +extern long long int gspF3DLX2_Rej_fifoDataStart[],gspF3DLX2_Rej_fifoDataEnd[]; + +extern long long int gspF3DLP2_Rej_fifoTextStart[],gspF3DLP2_Rej_fifoTextEnd[]; +extern long long int gspF3DLP2_Rej_fifoDataStart[],gspF3DLP2_Rej_fifoDataEnd[]; +extern long long int gspL3DEX2_fifoTextStart[], gspL3DEX2_fifoTextEnd[]; +extern long long int gspL3DEX2_fifoDataStart[], gspL3DEX2_fifoDataEnd[]; + /************************************************************************** * * Function prototypes diff --git a/include/PR/ultraerr.h b/include/PR/ultraerr.h deleted file mode 100644 index ef470ba7..00000000 --- a/include/PR/ultraerr.h +++ /dev/null @@ -1,165 +0,0 @@ -/*==================================================================== - * ultraerror.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/************************************************************************** - * - * $Revision: 1.23 $ - * $Date: 1997/02/11 08:38:08 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/ultraerror.h,v $ - * - **************************************************************************/ - -#ifndef __ULTRAERROR_H__ -#define __ULTRAERROR_H__ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#define OS_ERROR_FMT "/usr/lib/PR/error.fmt" -#define OS_ERROR_MAGIC 0x6b617479 - -/* OS error codes */ - -#define ERR_OSCREATETHREAD_SP 1 -#define ERR_OSCREATETHREAD_PRI 2 -#define ERR_OSSTARTTHREAD 3 -#define ERR_OSSETTHREADPRI 4 -#define ERR_OSCREATEMESGQUEUE 5 -#define ERR_OSSENDMESG 6 -#define ERR_OSJAMMESG 7 -#define ERR_OSRECVMESG 8 -#define ERR_OSSETEVENTMESG 9 -#define ERR_OSMAPTLB_INDEX 10 -#define ERR_OSMAPTLB_ASID 11 -#define ERR_OSUNMAPTLB 12 -#define ERR_OSSETTLBASID 13 -#define ERR_OSAISETFREQUENCY 14 -#define ERR_OSAISETNEXTBUFFER_ADDR 15 -#define ERR_OSAISETNEXTBUFFER_SIZE 16 -#define ERR_OSDPSETNEXTBUFFER_ADDR 17 -#define ERR_OSDPSETNEXTBUFFER_SIZE 18 -#define ERR_OSPIRAWREADIO 19 -#define ERR_OSPIRAWWRITEIO 20 -#define ERR_OSPIRAWSTARTDMA_DIR 21 -#define ERR_OSPIRAWSTARTDMA_DEVADDR 22 -#define ERR_OSPIRAWSTARTDMA_ADDR 23 -#define ERR_OSPIRAWSTARTDMA_SIZE 24 -#define ERR_OSPIRAWSTARTDMA_RANGE 25 -#define ERR_OSPIREADIO 26 -#define ERR_OSPIWRITEIO 27 -#define ERR_OSPISTARTDMA_PIMGR 28 -#define ERR_OSPISTARTDMA_PRI 29 -#define ERR_OSPISTARTDMA_DIR 30 -#define ERR_OSPISTARTDMA_DEVADDR 31 -#define ERR_OSPISTARTDMA_ADDR 32 -#define ERR_OSPISTARTDMA_SIZE 33 -#define ERR_OSPISTARTDMA_RANGE 34 -#define ERR_OSCREATEPIMANAGER 35 -#define ERR_OSVIGETCURRENTMODE 36 -#define ERR_OSVIGETCURRENTFRAMEBUFFER 37 -#define ERR_OSVIGETNEXTFRAMEBUFFER 38 -#define ERR_OSVISETXSCALE_VALUE 39 -#define ERR_OSVISETXSCALE_VIMGR 40 -#define ERR_OSVISETYSCALE_VALUE 41 -#define ERR_OSVISETYSCALE_VIMGR 42 -#define ERR_OSVISETSPECIAL_VALUE 43 -#define ERR_OSVISETSPECIAL_VIMGR 44 -#define ERR_OSVISETMODE 45 -#define ERR_OSVISETEVENT 46 -#define ERR_OSVISWAPBUFFER_ADDR 47 -#define ERR_OSVISWAPBUFFER_VIMGR 48 -#define ERR_OSCREATEVIMANAGER 49 -#define ERR_OSCREATEREGION_ALIGN 50 -#define ERR_OSCREATEREGION_SIZE 51 -#define ERR_OSMALLOC 52 -#define ERR_OSFREE_REGION 53 -#define ERR_OSFREE_ADDR 54 -#define ERR_OSGETREGIONBUFCOUNT 55 -#define ERR_OSGETREGIONBUFSIZE 56 -#define ERR_OSSPTASKLOAD_DRAM 57 -#define ERR_OSSPTASKLOAD_OUT 58 -#define ERR_OSSPTASKLOAD_OUTSIZE 59 -#define ERR_OSSPTASKLOAD_YIELD 60 -#define ERR_OSPROFILEINIT_STR 61 -#define ERR_OSPROFILEINIT_CNT 62 -#define ERR_OSPROFILEINIT_ALN 63 -#define ERR_OSPROFILEINIT_ORD 64 -#define ERR_OSPROFILEINIT_SIZ 65 -#define ERR_OSPROFILESTART_TIME 66 -#define ERR_OSPROFILESTART_FLAG 67 -#define ERR_OSPROFILESTOP_FLAG 68 -#define ERR_OSPROFILESTOP_TIMER 69 -#define ERR_OSREADHOST_ADDR 70 -#define ERR_OSREADHOST_SIZE 71 -#define ERR_OSWRITEHOST_ADDR 72 -#define ERR_OSWRITEHOST_SIZE 73 -#define ERR_OSGETTIME 74 -#define ERR_OSSETTIME 75 -#define ERR_OSSETTIMER 76 -#define ERR_OSSTOPTIMER 77 -#define ERR_ALSEQP_NO_SOUND 100 -#define ERR_ALSEQP_NO_VOICE 101 -#define ERR_ALSEQP_MAP_VOICE 102 -#define ERR_ALSEQP_OFF_VOICE 103 -#define ERR_ALSEQP_POLY_VOICE 104 -#define ERR_ALSNDP_NO_VOICE 105 -#define ERR_ALSYN_NO_UPDATE 106 -#define ERR_ALSNDPDEALLOCATE 107 -#define ERR_ALSNDPDELETE 108 -#define ERR_ALSNDPPLAY 109 -#define ERR_ALSNDPSETSOUND 110 -#define ERR_ALSNDPSETPRIORITY 111 -#define ERR_ALSNDPSETPAR 112 -#define ERR_ALBNKFNEW 113 -#define ERR_ALSEQNOTMIDI 114 -#define ERR_ALSEQNOTMIDI0 115 -#define ERR_ALSEQNUMTRACKS 116 -#define ERR_ALSEQTIME 117 -#define ERR_ALSEQTRACKHDR 118 -#define ERR_ALSEQSYSEX 119 -#define ERR_ALSEQMETA 120 -#define ERR_ALSEQPINVALIDPROG 121 -#define ERR_ALSEQPUNKNOWNMIDI 122 -#define ERR_ALSEQPUNMAP 123 -#define ERR_ALEVENTNOFREE 124 -#define ERR_ALHEAPNOFREE 125 -#define ERR_ALHEAPCORRUPT 126 -#define ERR_ALHEAPFIRSTBLOCK 127 -#define ERR_ALCSEQZEROSTATUS 128 -#define ERR_ALCSEQZEROVEL 129 -#define ERR_ALCSPVNOTFREE 130 -#define ERR_ALSEQOVERRUN 131 -#define ERR_OSAISETNEXTBUFFER_ENDADDR 132 -#define ERR_ALMODDELAYOVERFLOW 133 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -typedef void (*OSErrorHandler)(s16, s16, ...); - -OSErrorHandler osSetErrorHandler(OSErrorHandler); -#endif - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* __ULTRAERROR_H__ */ diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index ad665164..58fef8bd 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -21,8 +21,8 @@ * * This file contains various types used in Ultra64 interfaces. * - * $Revision: 1.5 $ - * $Date: 1997/02/11 08:39:54 $ + * $Revision: 1.6 $ + * $Date: 1997/12/17 04:02:06 $ * $Source: /disk6/Master/cvsmdev2/PR/include/ultratypes.h,v $ * **************************************************************************/ @@ -57,11 +57,16 @@ typedef volatile long long vs64; /* signed 64-bit */ typedef float f32; /* single prec floating point */ typedef double f64; /* double prec floating point */ -typedef u32 size_t; - -typedef unsigned long int uintptr_t; - -typedef float Matrix[4][4]; +#if !defined(_SIZE_T) && !defined(_SIZE_T_) && !defined(_SIZE_T_DEF) +#define _SIZE_T +#define _SIZE_T_DEF /* exeGCC size_t define label */ +#if (_MIPS_SZLONG == 32) +typedef unsigned int size_t; +#endif +#if (_MIPS_SZLONG == 64) +typedef unsigned long size_t; +#endif +#endif #endif /* _LANGUAGE_C */ diff --git a/include/PR/xstdio.h b/include/PR/xstdio.h index f8a26218..9850d88f 100644 --- a/include/PR/xstdio.h +++ b/include/PR/xstdio.h @@ -2,7 +2,7 @@ #define PR_XSTDIO_H #include "ultratypes.h" -// #include "libc/stdarg.h" +#include "libc/stdarg.h" typedef struct { /* 0x0 */ union { diff --git a/include/functions.h b/include/functions.h index f6477d09..5022409d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1,7 +1,16 @@ #ifndef FUNCTIONS_H #define FUNCTIONS_H +f32 func_80004E20(f32 arg0, f32 arg1); +void func_80004E4C(void); +f32 func_80004EB0(void); +void func_80004FC8(s32 arg0, s32 arg1, s32 arg2); +f32 func_80004FE8(void); f32 func_80005100(f32 arg0, f32 arg1); +f32 func_80005320(f32 arg0, f32 arg1); +f32 func_800055DC(f32 arg0, s32 arg1); +void func_80005604(s32* arg0, s32* arg1, s32 arg2, s32 arg3, s32 arg4); + void func_80005680(Matrix*, Matrix*); void func_80005708(Matrix ** mtx); void func_80005740(Matrix** mtx); @@ -10,26 +19,54 @@ void func_80005C34(Matrix*, f32, f32, f32, s32); void func_80006EB8(Gfx **); void func_80006F20(void); +void func_800070C8(s64); + +s32 func_800071FC(s32*); +s32 func_800072E0(s32*); + +void func_80007D58(void*); + +void func_80008018(void); + void func_800182F4(s32); void func_80019218(u32, f32*, u8, f32*, f32*, s8*); void func_8001A838(u32 arg0); void func_8001AF40(s32 arg0); void func_8001DC6C(s32, s32); +s32 func_8001EF10(void); + +f32 func_8001FBE8(f32); + +void func_800227A0(s32, OSMesgQueue*, OSMesg*, s32); + +s32 func_80022B60(void); + +s64 __ull_div(s64, s64); +s64 __ll_mul(s64, s64); +s64 __ll_rshift(s64, s64); + +void __osSiCreateAccessQueue(void); + +OSMesgQueue* osPiGetCmdQueue(void); + +s32 func_8002DE78(void*, s32, s32); // Not real signature + void func_80084688(s32, s32); void func_80086664(f32, f32); s32 func_8008B774(void); -s32 func_8008BCBC(s32 arg0); +s32 func_8008BCBC(s32 arg0); void func_8009BC2C(f32*, f32, f32, f32, f32); void func_8009D994(Gfx**, void*, u32, u32, f32, f32, f32, f32); void func_8009FEA0(s32, s32, s32); -void func_800A1200(s32, s32, f32, f32, char*); +void func_800A1200(s32, s32, f32, f32, char*); void func_800A5D6C(void); void func_800B8DD0(Gfx **, s16); void func_800BB5D0(void); void func_800B6F50(f32, f32, f32, f32, f32, f32); + void func_801877F0_EBFEB0(void); s32 func_80187ABC_EC017C(void); void func_80187B00_EC01C0(void); diff --git a/include/global.h b/include/global.h index b62c335c..c6673dd1 100644 --- a/include/global.h +++ b/include/global.h @@ -1,12 +1,25 @@ #ifndef GLOBAL_H #define GLOBAL_H -#include "PR/ultratypes.h" -#include "PR/mbi.h" +#include "PR/os_internal.h" +#include "libultra/ultra64.h" +#include "libc/math.h" +#include "libc/stdarg.h" +#include "libc/stdbool.h" +#include "libc/stdint.h" +#include "libc/stddef.h" +#include "libc/string.h" #include "functions.h" #include "variables.h" #include "structs.h" #include "macros.h" #include "sf64math.h" +extern Gfx* D_80137E64; + +extern OSDevMgr __osPiDevMgr; + +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 240 + #endif // GLOBAL_H diff --git a/include/hardware.h b/include/hardware.h deleted file mode 100644 index d2302376..00000000 --- a/include/hardware.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _HARDWARE_H_ -#define _HARDWARE_H_ - -#define HW_REG(reg, type) *(volatile type *)(uintptr_t)((reg) | 0xa0000000) - -#define AI_STATUS_REG 0x0450000C -#define AI_LEN_REG 0x04500004 -#define AI_CONTROL_REG 0x04500008 -#define AI_STATUS_AI_FULL (1 << 31) -#define AI_DACRATE_REG 0x04500010 -#define AI_BITRATE_REG 0x04500014 - -#endif \ No newline at end of file diff --git a/include/hud.h b/include/hud.h index b09babe1..fdbd1440 100644 --- a/include/hud.h +++ b/include/hud.h @@ -40,6 +40,7 @@ void func_80090E8C(void); void func_800910C0(void); void func_8009C320(Gfx**, s32*, s32*, s32, s32, f32, f32, f32, f32); void func_8009D0BC(Gfx**, void*, void*, u32, u32, f32, f32, f32, f32); +void func_8009D994(Gfx**, void*, u32, u32, f32, f32, f32, f32); void func_8009E1E8(Gfx**, s32*, s32, s32, f32, f32, f32, f32); // Weird addresses, assets maybe? diff --git a/include/libc/math.h b/include/libc/math.h new file mode 100644 index 00000000..5422d5fe --- /dev/null +++ b/include/libc/math.h @@ -0,0 +1,50 @@ +#ifndef LIBC_MATH_H +#define LIBC_MATH_H + +#include "PR/ultratypes.h" + +#define M_PI 3.14159265358979323846f +#define M_DTOR (M_PI / 180.0f) +#define M_SQRT2 1.41421356237309504880f +#define M_SQRT1_2 0.70710678118654752440f /* 1/sqrt(2) */ +#define FLT_MAX 340282346638528859811704183484516925440.0f +#define SHT_MAX 32767.0f +#define SHT_MINV (1.0f / SHT_MAX) + +typedef union { + struct { + u32 hi; + u32 lo; + } word; + + f64 d; +} du; + +typedef union { + u32 i; + f32 f; +} fu; + +typedef float Matrix[4][4]; + +extern f32 __libm_qnan_f; + +float fabsf(float f); +#pragma intrinsic(fabsf) +#ifdef __GNUC__ +#define fabsf(f) __builtin_fabsf((float)(f)) +#endif + +double fabs(double f); +#pragma intrinsic(fabs) +#ifdef __GNUC__ +#define fabs(f) __builtin_fabs((double)(f)) +#endif + +float sqrtf(float f); +#pragma intrinsic(sqrtf) + +double sqrt(double d); +#pragma intrinsic(sqrt) + +#endif diff --git a/include/libc/stdarg.h b/include/libc/stdarg.h new file mode 100644 index 00000000..55f69438 --- /dev/null +++ b/include/libc/stdarg.h @@ -0,0 +1,44 @@ +#ifndef LIBC_STDARG_H +#define LIBC_STDARG_H + +// When building with GCC, use the official vaarg macros to avoid warnings +// and possibly bad codegen. +#ifdef __GNUC__ +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end +#else + +typedef char *va_list; +#define _FP 1 +#define _INT 0 +#define _STRUCT 2 + +#define _VA_FP_SAVE_AREA 0x10 +#define _VA_ALIGN(p, a) (((unsigned int)(((char *)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4)) +#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) + +#define __va_stack_arg(list, mode) \ + ( \ + ((list) = (char *)_VA_ALIGN(list, __builtin_alignof(mode)) + \ + _VA_ALIGN(sizeof(mode), 4)), \ + (((char *)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode)))) + +#define __va_double_arg(list, mode) \ + ( \ + (((long)list & 0x1) /* 1 byte aligned? */ \ + ? (list = (char *)((long)list + 7), (char *)((long)list - 6 - _VA_FP_SAVE_AREA)) \ + : (((long)list & 0x2) /* 2 byte aligned? */ \ + ? (list = (char *)((long)list + 10), (char *)((long)list - 24 - _VA_FP_SAVE_AREA)) \ + : __va_stack_arg(list, mode)))) + +#define va_arg(list, mode) ((mode *)(((__builtin_classof(mode) == _FP && \ + __builtin_alignof(mode) == sizeof(double)) \ + ? __va_double_arg(list, mode) \ + : __va_stack_arg(list, mode))))[-1] +#define va_end(__list) + +#endif /* __GNUC__ */ + +#endif /* STDARG_H */ diff --git a/include/libc/stdbool.h b/include/libc/stdbool.h new file mode 100644 index 00000000..52546edb --- /dev/null +++ b/include/libc/stdbool.h @@ -0,0 +1,14 @@ +#ifndef LIBC_STDBOOL_H +#define LIBC_STDBOOL_H + +#define __bool_true_false_are_defined 1 + +#ifndef __cplusplus + +#define bool u32 +#define false 0 +#define true 1 + +#endif /* __cplusplus */ + +#endif /* STDBOOL */ diff --git a/include/libc/stddef.h b/include/libc/stddef.h index 1dc74697..d7533961 100644 --- a/include/libc/stddef.h +++ b/include/libc/stddef.h @@ -11,4 +11,4 @@ typedef s32 ptrdiff_t; #define offsetof(structure, member) ((size_t)&(((structure*)0)->member)) #endif -#endif /* STDDEF_H */ \ No newline at end of file +#endif /* STDDEF_H */ diff --git a/include/libc/stdint.h b/include/libc/stdint.h new file mode 100644 index 00000000..854fd254 --- /dev/null +++ b/include/libc/stdint.h @@ -0,0 +1,29 @@ +#ifndef LIBC_STDINT_H +#define LIBC_STDINT_H + +#include "PR/ultratypes.h" + +typedef s32 intptr_t; +typedef u32 uintptr_t; + +#define INT8_MIN (-0x80) +#define INT16_MIN (-0x8000) +#define INT32_MIN (-0x80000000) +#define INT64_MIN (-0x8000000000000000) + +#define INT8_MAX 0x7F +#define INT16_MAX 0x7FFF +#define INT32_MAX 0x7FFFFFFF +#define INT64_MAX 0x7FFFFFFFFFFFFFFF + +#define UINT8_MAX 0xFF +#define UINT16_MAX 0xFFFF +#define UINT32_MAX 0xFFFFFFFF +#define UINT64_MAX 0xFFFFFFFFFFFFFFFF + +#define INTPTR_MIN (-0x80000000) +#define INTPTR_MAX 0x7FFFFFFF +#define UINTPTR_MAX 0xFFFFFFFF + + +#endif /* STDINT_H */ diff --git a/include/libc/string.h b/include/libc/string.h index 6ca142ff..9c6a1cb0 100644 --- a/include/libc/string.h +++ b/include/libc/string.h @@ -9,4 +9,4 @@ size_t strlen(const char* s); void* memcpy(void* s1, const void* s2, size_t n); -#endif \ No newline at end of file +#endif diff --git a/include/libultra/assert.h b/include/libultra/assert.h deleted file mode 100644 index a3736e37..00000000 --- a/include/libultra/assert.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __ASSERT_H__ -#define __ASSERT_H__ -#ifdef __cplusplus -extern "C" { -#endif -/************************************************************************** - * * - * Copyright (C) 1984, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ -/* Copyright (c) 1984 AT&T */ -/* All Rights Reserved */ - -/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ -/* The copyright notice above does not evidence any */ -/* actual or intended publication of such source code. */ - -#ident "$Revision: 1.17 $" - -/* ANSI C Notes: - * - * - THE IDENTIFIERS APPEARING OUTSIDE OF #ifdef __EXTENSIONS__ IN THIS - * standard header ARE SPECIFIED BY ANSI! CONFORMANCE WILL BE ALTERED - * IF ANY NEW IDENTIFIERS ARE ADDED TO THIS AREA UNLESS THEY ARE IN ANSI's - * RESERVED NAMESPACE. (i.e., unless they are prefixed by __[a-z] or - * _[A-Z]. For external objects, identifiers with the prefix _[a-z] - * are also reserved.) - */ - -#ifdef NDEBUG -#undef assert -#define assert(EX) ((void)0) - -#else - -extern void __assert(const char *, const char *, int); -#ifdef __ANSI_CPP__ -#define assert(EX) ((EX)?((void)0):__assert( # EX , __FILE__, __LINE__)) -#else -#define assert(EX) ((EX)?((void)0):__assert("EX", __FILE__, __LINE__)) -#endif -#endif /* NDEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* !__ASSERT_H__ */ diff --git a/include/libultra/bstring.h b/include/libultra/bstring.h deleted file mode 100644 index 4ed25959..00000000 --- a/include/libultra/bstring.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __BSTRING_H__ -#define __BSTRING_H__ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * bstring(3C) -- byte string operations - * - * Copyright 1990, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; - * the contents of this file may not be disclosed to third parties, copied or - * duplicated in any form, in whole or in part, without the prior written - * permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to restrictions - * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data - * and Computer Software clause at DFARS 252.227-7013, and/or in similar or - * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - - * rights reserved under the Copyright Laws of the United States. - */ - -#ident "$Revision: 1.4 $" - -extern void bcopy(const void *, void *, int); -extern int bcmp(const void *, const void *, int); -extern void bzero(void *, int); -extern void blkclr(void *, int); - -#ifdef __cplusplus -} -#endif -#endif /* !__BSTRING_H__ */ diff --git a/include/libultra/math.h b/include/libultra/math.h deleted file mode 100644 index d2d059dd..00000000 --- a/include/libultra/math.h +++ /dev/null @@ -1,485 +0,0 @@ -#ifndef __MATH_H__ -#define __MATH_H__ -#ifdef __cplusplus -extern "C" { -#endif -#if (!defined(__SGIDEFS_H__) && defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 400)) -#include -#endif -/* Copyright (C) 1989 Silicon Graphics, Inc. All rights reserved. */ -/* ------------------------------------------------------------------ */ -/* | Copyright Unpublished, MIPS Computer Systems, Inc. All Rights | */ -/* | Reserved. This software contains proprietary and confidential | */ -/* | information of MIPS and its suppliers. Use, disclosure or | */ -/* | reproduction is prohibited without the prior express written | */ -/* | consent of MIPS. | */ -/* ------------------------------------------------------------------ */ - -/* #ident "$Revision: 7.28 $" */ - -/* ANSI C Notes: - * - * - THE IDENTIFIERS APPEARING OUTSIDE OF #ifdef __EXTENSIONS__ IN THIS - * standard header ARE SPECIFIED BY ANSI! CONFORMANCE WILL BE ALTERED - * IF ANY NEW IDENTIFIERS ARE ADDED TO THIS AREA UNLESS THEY ARE IN ANSI's - * RESERVED NAMESPACE. (i.e., unless they are prefixed by __[a-z] or - * _[A-Z]. For external objects, identifiers with the prefix _[a-z] - * are also reserved.) - * - * - Names created by appending either the suffix 'l' or 'f' - * to one of the reserved function names are reserved for the corresponding - * single- or extended- precision version of the function. - */ - -/* Power C Notes: - * - * - Power C assumes that all external functions (unless otherwise marked) - * might modify global data and therefore calls to such functions can - * not be safely concurrentized. - * - * - The pragma "no side effects" indicates that the named function is - * free from such side effects and calls to it can be concurrentized. - * - * - This pragma has been added below for each function in the math library - * which is "safe". - * - * - The pragma is properly passed on by 'cpp' & 'c++' and ignored by - * 'ccom'. It only has meaning to 'pca'. - */ - -/* - * ANSI-standard functions. Each is listed with - * its single-precision counterpart, if it exists. - */ -#if defined (_XOPEN_SOURCE) - -extern double lgamma(double); -#pragma no side effects (lgamma) -extern int isnan(double); -#pragma no side effects (isnan) - -extern double erf(double); -#pragma no side effects (erf) -extern double erfc(double); -#pragma no side effects (erfc) - -extern double gamma(double); -extern double hypot(double, double); -#pragma no side effects (hypot) - -extern double j0(double); -#pragma no side effects (j0) -extern double j1(double); -#pragma no side effects (j1) -extern double jn(int, double); -#pragma no side effects (jn) - -extern double y0(double); -#pragma no side effects (y0) -extern double y1(double); -#pragma no side effects (y1) -extern double yn(int, double); -#pragma no side effects (yn) - -/* Some useful constants */ -#define M_E 2.7182818284590452354 -#define M_LOG2E 1.4426950408889634074 -#define M_LOG10E 0.43429448190325182765 -#define M_LN2 0.69314718055994530942 -#define M_LN10 2.30258509299404568402 -#define M_PI 3.14159265358979323846 -#define M_PI_2 1.57079632679489661923 -#define M_PI_4 0.78539816339744830962 -#define M_1_PI 0.31830988618379067154 -#define M_2_PI 0.63661977236758134308 -#define M_2_SQRTPI 1.12837916709551257390 -#define M_SQRT2 1.41421356237309504880 -#define M_SQRT1_2 0.70710678118654752440 - -#ifndef _MAXFLOAT -#define _MAXFLOAT -#define MAXFLOAT ((float)3.40282346638528860e+38) -#endif /* _MAXFLOAT */ - -extern int signgam; - -#endif /* _XOPEN_SOURCE */ - -extern double acos(double); -#pragma no side effects (acos) -extern float acosf(float); -#pragma no side effects (acosf) - -extern double asin(double); -#pragma no side effects (asin) -extern float asinf(float); -#pragma no side effects (asinf) - -extern double atan(double); -#pragma no side effects (atan) -extern float atanf(float); -#pragma no side effects (atanf) - -extern double atan2(double, double); -#pragma no side effects (atan2) -extern float atan2f(float, float); -#pragma no side effects (atan2f) - -extern double cos(double); -#pragma no side effects (cos) -extern float cosf(float); -#pragma no side effects (cosf) - -extern double sin(double); -#pragma no side effects (sin) -extern float sinf(float); -#pragma no side effects (sinf) - -extern double tan(double); -#pragma no side effects (tan) -extern float tanf(float); -#pragma no side effects (tanf) - -extern double cosh(double); -#pragma no side effects (cosh) -extern float coshf(float); -#pragma no side effects (coshf) - -extern double sinh(double); -#pragma no side effects (sinh) -extern float sinhf(float); -#pragma no side effects (sinhf) - -extern double tanh(double); -#pragma no side effects (tanh) -extern float tanhf(float); -#pragma no side effects (tanhf) - -extern double exp(double); -#pragma no side effects (exp) -extern float expf(float); -#pragma no side effects (expf) - -extern double frexp(double, int *); -#if 0 -/* not yet implemented */ -extern float frexpf(float, int *); -#endif - -extern double ldexp(double, int); -#if 0 -/* not yet implemented */ -extern float ldexpf(float, int); -#endif - -extern double log(double); -#pragma no side effects (log) -extern float logf(float); -#pragma no side effects (logf) - -extern double log10(double); -#pragma no side effects (log10) -extern float log10f(float); -#pragma no side effects (log10f) - -extern double modf(double, double *); -/* version of modff implemented for completeness only */ -extern float modff(float, float *); - -extern double pow(double, double); -#pragma no side effects (pow) -/* version of powf implemented for completeness only */ -extern float powf(float, float); -#pragma no side effects (powf) - -extern double sqrt(double); -#pragma no side effects (sqrt) -extern float sqrtf(float); -#pragma no side effects (sqrtf) - -extern double ceil(double); -#pragma no side effects (ceil) -extern float ceilf(float); -#pragma no side effects (ceilf) - -extern double fabs(double); -#pragma no side effects (fabs) -/* version of fabsf implemented for completeness only */ -extern float fabsf(float); -#pragma no side effects (fabsf) - -extern double floor(double); -#pragma no side effects (floor) -extern float floorf(float); -#pragma no side effects (floorf) - -extern double fmod(double, double); -#pragma no side effects (fmod) -/* version of fmodf implemented for completeness only */ -extern float fmodf(float, float); -#pragma no side effects (fmodf) - -#ifndef HUGE_VAL /* Also in limits.h */ -#ifdef _SVR4_SOURCE -#ifndef __TYPEDEF_H_VAL -#define __TYPEDEF_H_VAL -typedef union _h_val { -#if (_MIPS_SZLONG == 32) - unsigned long i[2]; -#endif -#if (_MIPS_SZLONG == 64) - __uint32_t i[2]; -#endif - double d; -} _h_val; -#endif /* __TYPEDEF_H_VAL */ - -extern const _h_val __huge_val; -#define HUGE_VAL __huge_val.d -#else -/* __infinity is a double-precision variable in libc set to infinity */ -extern const double __infinity; -#define HUGE_VAL __infinity -#endif /* _SVR4_SOURCE */ -#endif /* !HUGE_VAL */ - -#if (defined(__EXTENSIONS__) || defined (_POSIX_SOURCE)) -extern int errno, signgam; - -extern double atof(const char *); -extern int rand(void); -extern void srand(unsigned); -#endif /* __EXTENSIONS__ || _POSIX_SOURCE */ - - -#if (defined(__EXTENSIONS__) && (!defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE))) - -enum version { c_issue_4, ansi_1, strict_ansi }; -extern const enum version _lib_version; - -/* Features from 4.3BSD */ -extern double rint(double); -#pragma no side effects (rint) -extern double asinh(double); -#pragma no side effects (asinh) -extern double acosh(double); -#pragma no side effects (acosh) -extern double atanh(double); -#pragma no side effects (atanh) -extern double log1p(double); -#pragma no side effects (log1p) -extern double erf(double); -#pragma no side effects (erf) -extern double erfc(double); -#pragma no side effects (erfc) -extern double expm1(double); -#pragma no side effects (expm1) -extern double gamma(double); -extern double hypot(double, double); -#pragma no side effects (hypot) -struct __cabs_s { double a,b; }; -extern double cabs(struct __cabs_s); -#pragma no side effects (cabs) -extern double copysign(double, double); -#pragma no side effects (copysign) -extern double drem(double, double); -#pragma no side effects (drem) -extern double logb(double); -#pragma no side effects (logb) -#if (defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 400)) -extern double nextafter(double, double); -#pragma no side effects (nextafter) -extern double remainder(double, double); -#pragma no side effects (remainder) -#endif -extern double scalb(double, double); -#pragma no side effects (scalb) -extern int finite(double); -#pragma no side effects (finite) -extern double j0(double); -#pragma no side effects (j0) -extern double j1(double); -#pragma no side effects (j1) -extern double jn(int, double); -#pragma no side effects (jn) -extern double y0(double); -#pragma no side effects (y0) -extern double y1(double); -#pragma no side effects (y1) -extern double yn(int, double); -#pragma no side effects (yn) -extern double cbrt(double); -#pragma no side effects (cbrt) -extern double atof(const char *); -extern double strtod(const char *, char **); -extern double trunc(double); -#pragma no side effects (trunc) - -extern int rand(void); -extern void srand(unsigned); - -extern long random(void); -extern int srandom(unsigned);/* doesn't return a value -- should be void */ -extern char * initstate(unsigned int, char *, int); -extern char * setstate(char *); - -extern double drand48(void); -extern double erand48(unsigned short [3]); -extern long lrand48(void); -extern long nrand48(unsigned short [3]); -extern long mrand48(void); -extern long jrand48(unsigned short [3]); -extern void srand48(long); -extern unsigned short * seed48(const unsigned short [3]); -extern void lcong48(const unsigned short [7]); - -/* Map old MIPS names of single-precision forms to ANSI names.*/ - -#define facos acosf -#define fasin asinf -#define fatan atanf -#define fatan2 atan2f -#define fcos cosf -#define fsin sinf -#define ftan tanf -#define fcosh coshf -#define fsinh sinhf -#define ftanh tanhf -#define fexp expf -#define flog logf -#define flog10 log10f -#define fsqrt sqrtf -#define fceil ceilf -#define ffloor floorf - -/* similar mapping of old MIPS names to ANSI-like names */ -#undef flog1p -#define flog1p log1pf -#define ftrunc truncf - -#ifdef __cplusplus -#ifndef _ABS_ -#define _ABS_ -inline int abs(int x) {return x > 0 ? x : -x;} -#endif -#endif - -/* additional single-percision forms */ -extern float fhypot(float, float); -#pragma no side effects (fhypot) -extern float hypotf(float, float); -#pragma no side effects (hypotf) -struct __fcabs_s { float a,b; }; -extern float fcabs(struct __fcabs_s); -#pragma no side effects (fcabs) -extern float fexpm1(float); -#pragma no side effects (fexpm1) -extern float expm1f(float); -#pragma no side effects (expm1f) -extern float log1pf(float); -#pragma no side effects (log1pf) -extern float truncf(float); -#pragma no side effects (truncf) -#if (defined(__INLINE_INTRINSICS) && defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 400)) -#if _MIPS_ISA != _MIPS_ISA_MIPS1 -#pragma intrinsic (hypotf) -#pragma intrinsic (fhypot) -#endif -#endif - -#if 0 /* These are not implemented yet. */ -extern float ferf(float); -extern float ferfc(float); -extern float flgamma(float); -extern float fcopysign(float, float); -extern float fdrem(float, float); -extern float flogb(float); -extern float fscalb(float, int); -extern int ffinite(float); -extern float fj0(float); -extern float fj1(float); -extern float fjn(int, float); -extern float fy0(float); -extern float fy1(float); -extern float fyn(int, float); -extern float fatof(char *); -extern float frint(float); -extern float facosh(float); -extern float fatanh(float); -extern float fcbrt(float); -#endif /* 0 */ - -/* Some useful constants */ -#define M_E 2.7182818284590452354 -#define M_LOG2E 1.4426950408889634074 -#define M_LOG10E 0.43429448190325182765 -#define M_LN2 0.69314718055994530942 -#define M_LN10 2.30258509299404568402 -#define M_PI 3.14159265358979323846 -#define M_PI_2 1.57079632679489661923 -#define M_PI_4 0.78539816339744830962 -#define M_1_PI 0.31830988618379067154 -#define M_2_PI 0.63661977236758134308 -#define M_2_SQRTPI 1.12837916709551257390 -#define M_SQRT2 1.41421356237309504880 -#define M_SQRT1_2 0.70710678118654752440 -#ifndef HUGE -#ifdef MAXFLOAT -#define HUGE MAXFLOAT -#else -#define HUGE ((float)3.40282346638528860e+38) /* value of MAXFLOAT */ -#endif /* MAXFLOAT */ -#endif /* !HUGE */ - -#define _ABS(x) ((x) < 0 ? -(x) : (x)) -#define _REDUCE(TYPE, X, XN, C1, C2) { \ - double x1 = (double)(TYPE)X, x2 = X - x1; \ - X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); } -#define _POLY1(x, c) ((c)[0] * (x) + (c)[1]) -#define _POLY2(x, c) (_POLY1((x), (c)) * (x) + (c)[2]) -#define _POLY3(x, c) (_POLY2((x), (c)) * (x) + (c)[3]) -#define _POLY4(x, c) (_POLY3((x), (c)) * (x) + (c)[4]) -#define _POLY5(x, c) (_POLY4((x), (c)) * (x) + (c)[5]) -#define _POLY6(x, c) (_POLY5((x), (c)) * (x) + (c)[6]) -#define _POLY7(x, c) (_POLY6((x), (c)) * (x) + (c)[7]) -#define _POLY8(x, c) (_POLY7((x), (c)) * (x) + (c)[8]) -#define _POLY9(x, c) (_POLY8((x), (c)) * (x) + (c)[9]) - - -struct exception { - int type; - char *name; - double arg1; - double arg2; - double retval; -}; - -extern int matherr(struct exception *p); - - -#include - -#endif /* __EXTENSIONS__ && !_POSIX_SOURCE */ - -#ifdef __INLINE_INTRINSICS -/* The functions made intrinsic here can be activated by the driver -** passing -D__INLINE_INTRINSICS to cfe, but cfe should ensure that -** this has no effect unless the hardware architecture directly -** supports these basic operations. -*/ -#if _MIPS_ISA != _MIPS_ISA_MIPS1 -#pragma intrinsic (sqrt) -#pragma intrinsic (sqrtf) -#if (defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 400)) -#pragma intrinsic (pow) -#pragma intrinsic (powf) -#endif -#endif -#pragma intrinsic (fabs) -#pragma intrinsic (fabsf) -#endif - -#ifdef __cplusplus -} -#endif -#endif /* !__MATH_H__ */ diff --git a/include/libultra/svr4_mat.h b/include/libultra/svr4_mat.h deleted file mode 100644 index 40e49947..00000000 --- a/include/libultra/svr4_mat.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 1989 Silicon Graphics, Inc. All rights reserved. */ -/* - * |-----------------------------------------------------------| - * | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc. | - * | All Rights Reserved | - * |-----------------------------------------------------------| - * | Restricted Rights Legend | - * | Use, duplication, or disclosure by the Government is | - * | subject to restrictions as set forth in | - * | subparagraph (c)(1)(ii) of the Rights in Technical | - * | Data and Computer Software Clause of DFARS 252.227-7013. | - * | MIPS Computer Systems, Inc. | - * | 950 DeGuigne Avenue | - * | Sunnyvale, California 94088-3650, USA | - * |-----------------------------------------------------------| - */ - -/* $Header: /proj/irix5.3/isms/cmplrs/commonlib/include/RCS/svr4_math.h,v 1.3 1993/06/08 01:20:14 bettina Exp $ */ - -#ifndef __SVR4_MATH_H__ -#define __SVR4_MATH_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define DOMAIN 1 -#define SING 2 -#define OVERFLOW 3 -#define UNDERFLOW 4 -#define TLOSS 5 -#define PLOSS 6 - -#ifdef __cplusplus -} -#endif - -#endif /* __SVR4_MATH_H__ */ diff --git a/include/libultra/svr4_math.h b/include/libultra/svr4_math.h deleted file mode 100644 index 40e49947..00000000 --- a/include/libultra/svr4_math.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 1989 Silicon Graphics, Inc. All rights reserved. */ -/* - * |-----------------------------------------------------------| - * | Copyright (c) 1991, 1990 MIPS Computer Systems, Inc. | - * | All Rights Reserved | - * |-----------------------------------------------------------| - * | Restricted Rights Legend | - * | Use, duplication, or disclosure by the Government is | - * | subject to restrictions as set forth in | - * | subparagraph (c)(1)(ii) of the Rights in Technical | - * | Data and Computer Software Clause of DFARS 252.227-7013. | - * | MIPS Computer Systems, Inc. | - * | 950 DeGuigne Avenue | - * | Sunnyvale, California 94088-3650, USA | - * |-----------------------------------------------------------| - */ - -/* $Header: /proj/irix5.3/isms/cmplrs/commonlib/include/RCS/svr4_math.h,v 1.3 1993/06/08 01:20:14 bettina Exp $ */ - -#ifndef __SVR4_MATH_H__ -#define __SVR4_MATH_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#define DOMAIN 1 -#define SING 2 -#define OVERFLOW 3 -#define UNDERFLOW 4 -#define TLOSS 5 -#define PLOSS 6 - -#ifdef __cplusplus -} -#endif - -#endif /* __SVR4_MATH_H__ */ diff --git a/include/libultra/sys/u64drive.h b/include/libultra/sys/u64drive.h deleted file mode 100644 index db4fe336..00000000 --- a/include/libultra/sys/u64drive.h +++ /dev/null @@ -1,131 +0,0 @@ -#ifndef __SYS_U64DRIVER_H__ -#define __SYS_U64DRIVER_H__ - -/* - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; - * the contents of this file may not be disclosed to third parties, copied or - * duplicated in any form, in whole or in part, without the prior written - * permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to restrictions - * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data - * and Computer Software clause at DFARS 252.227-7013, and/or in similar or - * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - - * rights reserved under the Copyright Laws of the United States. - * - */ - -#include -#include -#include "u64gio.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - - -#define U64_MINOR_PRINT 1 -#define U64_MINOR_DEBUG 2 -#define U64_MINOR_LOGGING 3 -#define U64_MINOR_DATA 4 -#define U64_MINOR_FAULT 5 -#define U64_MINOR_KDEBUG 6 -#define U64_MINOR_PROFILE 7 -#define NUMBER_MINORS 8 /* don't use minor zero , but must count 0-7 */ - -#define U64_MINOR_PRINT_BUF_SIZE 0x80000 /* buffer used by incoming printf data */ -#define U64_MINOR_DEBUG_BUF_SIZE 0x4000 -#define U64_MINOR_LOGGING_BUF_SIZE RDB_LOG_MAX_BLOCK_SIZE /* buffer used by incoming logging data */ -#define U64_MINOR_DATA_BUF_SIZE RDB_DATA_MAX_BLOCK_SIZE /* buffer used by incoming data */ -#define U64_MINOR_FAULT_BUF_SIZE 1024 /* buffer used for incoming fault data */ -#define U64_MINOR_KDEBUG_BUF_SIZE 1024 /* buffer used for incoming kdebug data */ -#define U64_MINOR_PROFILE_BUF_SIZE 2048 /* buffer used for incoming profile data */ -#define U64_MINOR_PROFILE_SEND_BUF_SIZE 16 /* only send one byte messages */ -#define U64_INTERNAL_WRITE_BUF_SIZE 0x8000 /* buffer used to store packets waiting to go out */ - - - -#define u64_increment_Qptr(x) { ((x) = ((x) + 1) & 0xff) ; } - - -typedef struct { - sema_t minor_sema; /* used to allow only one app to open the minor */ - sema_t read_sema; /* used to block while waiting for data */ - sema_t write_sema; /* only allow one entry to write at a time */ - int read_count; /* the number of bytes waiting to be read */ - int write_count; /* the number of bytes waiting to be written */ - int read_cur_write; - int write_cur_write; - int read_cur_read; - int write_cur_read; - unsigned char *read_buf; - unsigned char *write_buf; - int read_buf_size; /* measured in unsigned char's */ - int write_buf_size; /* measured in unsigned char's */ - int incoming_ct; /* used by minors that receive data from game */ - /* indicates how many bytes left in block */ - /* before signaling game that transfer is done */ - /* used by logging and game to host data stuff */ - int message; /* when not zero, send this message to game to */ - /* indicate that data or log data has been read */ - struct pollhead *phead; -} u64_minor; - -/* - * Our private one-per-board data structure - * The user can't get at any of this - */ -struct u64_data { - - volatile struct u64_board *board; - unsigned char *memaddr; /* 16/32 bit access R/W */ - - /* - * Only one client may be in the kernel at a time; this semaphore is used - * to prevent multiple clients from overrunning each other's interactions - * with the hardware. - */ - sema_t ioctl_sema; - - /* - * The ramrom_sema is used by the driver so that it can arbitrate for the - * control of ramrom with the game, and sleep while waiting for the game - * to respond. - */ - sema_t ramrom_sema; - - /* - * Allocate a megabyte buffer which we can use when reading/writing data - * to or from the board (we can't copyin/copyout directly from the user's - * buffer, because those routines use 64 bit transfers). - */ - unsigned int *oneMeg; - - union { - u64_write_arg_t u64_write; /* WRITE, SAFE_WRITE */ - u64_read_arg_t u64_read; /* READ, SAFE_READ */ - } args; - - /* rdb port */ - unsigned int *write_buf; - unsigned int write_buf_cur_write; - unsigned int write_buf_cur_read; - unsigned int write_buf_ct; /* number of packets waiting for transmission */ - unsigned int write_buf_size; /* measured in rdbPackets */ - sema_t write_buf_sema; - u64_minor minors[NUMBER_MINORS]; - -}; - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#endif /* __SYS_U64DRIVER_H__ */ - - - - - - diff --git a/include/libultra/ultrahost.h b/include/libultra/ultrahost.h index 83ddeef2..25c772ae 100644 --- a/include/libultra/ultrahost.h +++ b/include/libultra/ultrahost.h @@ -12,8 +12,8 @@ /************************************************************************** * - * $Revision: 1.7 $ - * $Date: 1997/02/11 08:38:37 $ + * $Revision: 1.8 $ + * $Date: 1997/07/02 02:35:06 $ * $Source: /disk6/Master/cvsmdev2/PR/include/ultrahost.h,v $ * **************************************************************************/ @@ -21,29 +21,22 @@ #ifndef _ULTRAHOST_H_ #define _ULTRAHOST_H_ -#ifdef WIN32 /* { */ - -int __stdcall uhOpenGame(char *); -int __stdcall uhCloseGame(int); -int __stdcall uhReadGame(int hfd,void *buf,int count); -int __stdcall uhWriteGame(int hfd,void *buf,int count); -int __stdcall uhReadRamrom(int hfd,void *ramrom_adr,void *buf,int count); -int __stdcall uhWriteRamrom(int hfd,void *ramrom_adr,void *buf,int count); -int __stdcall uhPartnerInit(int hfd); -int __stdcall uhPartnerCmd(int hfd,char *ptcmd); -int __stdcall uhGload(int hfd,char *loadfile); - -#else /* }{ */ #ifdef PTN64 /* { */ #define execl execl_pt #define uhOpenGame uhOpenGame_pt #define uhCloseGame uhCloseGame_pt + #define uhReadGame uhReadGame_pt #define uhWriteGame uhWriteGame_pt #define uhReadRamrom uhReadRamrom_pt #define uhWriteRamrom uhWriteRamrom_pt +#define uhPartnerCmd uhPartnerCmd_pt +#define uhGload uhGload_pt + +int uhPartnerCmd(int,char *); +int uhGload(int,char *); #endif /* } */ @@ -61,6 +54,5 @@ int uhReadRamrom(int, void *, void*, int); #ifdef __cplusplus } #endif -#endif /* } */ #endif /* ULTRAHOST */ diff --git a/include/sf64math.h b/include/sf64math.h index eb8f02f8..154b7cd1 100644 --- a/include/sf64math.h +++ b/include/sf64math.h @@ -3,16 +3,6 @@ #include "PR/ultratypes.h" -double fabsf(double f); -#pragma intrinsic(fabsf) - -#define M_PI 3.14159265358979323846f -#define M_SQRT2 1.41421356237309504880f -#define M_SQRT1_2 0.70710678118654752440f /* 1/sqrt(2) */ -#define FLT_MAX 340282346638528859811704183484516925440.0f -#define SHT_MAX 32767.0f -#define SHT_MINV (1.0f / SHT_MAX) - typedef struct { /* 0x0 */ f32 x; /* 0x4 */ f32 y; diff --git a/include/variables.h b/include/variables.h index 91963a84..2c8ee45a 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3,6 +3,16 @@ #include "structs.h" +extern OSThread D_800DEAA0; +extern OSThread D_800DFC50; // no gap +extern OSThread D_800E0E00; // 0x1000 gap +extern s32 D_800E1FB0; // 0x1000 gap, probably OSScTask +extern OSMesgQueue D_800E2010; +extern OSMesg D_800E2028; +extern OSMesgQueue D_800E2148; +extern OSMesgQueue D_800E2238; +extern OSMesgQueue D_800E2278; + extern f32 D_800C5D34; extern s8 D_800C5D3C; extern s32 D_800CFF90; @@ -174,5 +184,27 @@ extern Gfx D_6004570[]; extern Gfx D_D0098B0[]; extern Gfx D_F014180[]; + +extern u8 D_800DD8B8[]; +extern OSContStatus D_800DD8F0; +extern OSMesgQueue D_800E2128; +extern OSMesgQueue D_800E2318; +extern u8 D_80137E80; +extern s32 D_80144F60; + +extern s8 D_800C7C50; +extern s8 D_800C7C54; +extern OSMesgQueue* D_800C7C58; +extern OSMesgQueue* D_800C7C5C; +extern OSMesgQueue* D_800C7C60; +extern OSMesgQueue* D_800C7C64; +extern OSMesg D_80156600; +extern OSMesg D_80156608; +extern OSMesg D_80156618; +extern OSMesg D_8015661C; + +extern OSThread D_80138E90; +extern OSThread D_8013A040; // 0x1000 gap +extern OSThread D_8013B1F0; // 0x1000 gap #endif // VARIABLES_H diff --git a/linker_scripts/us/symbol_addrs_libultra.txt b/linker_scripts/us/symbol_addrs_libultra.txt index 7826859e..5b729aec 100644 --- a/linker_scripts/us/symbol_addrs_libultra.txt +++ b/linker_scripts/us/symbol_addrs_libultra.txt @@ -35,7 +35,7 @@ osSetThreadPri = 0x80022A80; osGetTime = 0x80023000; __sinf = 0x80023090; __cosf = 0x80023250; -sqrtf = 0x800233C0; +guSqrtf = 0x800233C0; osSetTimer = 0x800233D0; osEepromRead = 0x800234B0; osEepromWrite = 0x800237B0; diff --git a/src/libultra/2BDF0.c b/src/libultra/2BDF0.c index f794f1bd..e1ccbeaf 100644 --- a/src/libultra/2BDF0.c +++ b/src/libultra/2BDF0.c @@ -8,15 +8,8 @@ #pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/2BDF0/func_8002B28C.s") -void func_8002B2C0(s32* arg0, s32* arg1, s32 arg2, u32 arg3) { - s32 pad; - - arg3 = arg2; - arg2--; - - while (arg3 > 0) { - arg3 = arg2; - arg2--; +void func_8002B2C0(s32* arg0, s32* arg1, s32 arg2) { + while (arg2--) { *arg0++ = *arg1++; } } diff --git a/src/libultra/2C700.c b/src/libultra/2C700.c index d111ffd4..c0d97266 100644 --- a/src/libultra/2C700.c +++ b/src/libultra/2C700.c @@ -1,9 +1,7 @@ -#include "common.h" +#include "global.h" // OPTFLAGS := -O1 -g0 -s32 func_8002DE78(s32, s32, s32); - #pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/2C700/func_8002BB00.s") #pragma GLOBAL_ASM("asm/us/nonmatchings/libultra/2C700/func_8002BB7C.s") diff --git a/src/libultra/gu/guSqrtf.c b/src/libultra/gu/guSqrtf.c new file mode 100644 index 00000000..311571a0 --- /dev/null +++ b/src/libultra/gu/guSqrtf.c @@ -0,0 +1,5 @@ +#include "global.h" + +f32 guSqrtf(f32 value) { + return sqrtf(value); +} diff --git a/src/libultra/gu/lookat.c b/src/libultra/gu/lookat.c index 89ca18f3..e39ccf8d 100644 --- a/src/libultra/gu/lookat.c +++ b/src/libultra/gu/lookat.c @@ -19,7 +19,7 @@ void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, float xAt, fl zLook = zAt - zEye; /* Negate because positive Z is behind us: */ - len = -1.0 / sqrtf(xLook * xLook + yLook * yLook + zLook * zLook); + len = -1.0 / guSqrtf(xLook * xLook + yLook * yLook + zLook * zLook); xLook *= len; yLook *= len; zLook *= len; @@ -29,7 +29,7 @@ void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, float xAt, fl xRight = yUp * zLook - zUp * yLook; yRight = zUp * xLook - xUp * zLook; zRight = xUp * yLook - yUp * xLook; - len = 1.0 / sqrtf(xRight * xRight + yRight * yRight + zRight * zRight); + len = 1.0 / guSqrtf(xRight * xRight + yRight * yRight + zRight * zRight); xRight *= len; yRight *= len; zRight *= len; @@ -39,7 +39,7 @@ void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, float xAt, fl xUp = yLook * zRight - zLook * yRight; yUp = zLook * xRight - xLook * zRight; zUp = xLook * yRight - yLook * xRight; - len = 1.0 / sqrtf(xUp * xUp + yUp * yUp + zUp * zUp); + len = 1.0 / guSqrtf(xUp * xUp + yUp * yUp + zUp * zUp); xUp *= len; yUp *= len; zUp *= len; diff --git a/src/libultra/io/ai.c b/src/libultra/io/ai.c index 41491008..64dd0de9 100644 --- a/src/libultra/io/ai.c +++ b/src/libultra/io/ai.c @@ -1,13 +1,12 @@ #include "global.h" #include "PR/rcp.h" -#include "hardware.h" s32 __osAiDeviceBusy(void) { - register s32 status = HW_REG(AI_STATUS_REG, u32); + register s32 status = IO_READ(AI_STATUS_REG); - if (status & AI_STATUS_AI_FULL) { - return 1; + if (status & AI_STATUS_FIFO_FULL) { + return true; } else { - return 0; + return false; } } diff --git a/src/libultra/io/aigetlen.c b/src/libultra/io/aigetlen.c index 8233f4c3..ec37b969 100644 --- a/src/libultra/io/aigetlen.c +++ b/src/libultra/io/aigetlen.c @@ -1,6 +1,5 @@ #include "global.h" -#include "hardware.h" u32 osAiGetLength() { - return HW_REG(AI_LEN_REG, u32); + return IO_READ(AI_LEN_REG); } diff --git a/src/libultra/io/aisetfreq.c b/src/libultra/io/aisetfreq.c index 29a9cdf5..c8a1a8a4 100644 --- a/src/libultra/io/aisetfreq.c +++ b/src/libultra/io/aisetfreq.c @@ -1,5 +1,4 @@ #include "global.h" -#include "hardware.h" extern s32 osViClock; @@ -20,8 +19,8 @@ s32 osAiSetFrequency(u32 freq) { a2 = 16; } - HW_REG(AI_DACRATE_REG, u32) = a1 - 1; - HW_REG(AI_BITRATE_REG, u32) = a2 - 1; - HW_REG(AI_CONTROL_REG, u32) = 1; // enable dma + IO_WRITE(AI_DACRATE_REG, a1 - 1); + IO_WRITE(AI_BITRATE_REG, a2 - 1); + IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON); // enable dma return osViClock / (s32) a1; } diff --git a/src/libultra/io/pidma.c b/src/libultra/io/pidma.c index 23bddae3..80329836 100644 --- a/src/libultra/io/pidma.c +++ b/src/libultra/io/pidma.c @@ -1,44 +1,29 @@ #include "global.h" -// OPTFLAGS := -O1 -g0 - -typedef struct { - s16 unk0; - s8 unk2; - s8 pad; - s32 unk4; - s32 unk8; - s32 unkC; - s32 unk10; - s32 unk14; -} test; - -extern s32 __osPiDevMgr; - -s32 osPiStartDma(test* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { +s32 osPiStartDma(OSIoMesg* mb, s32 pri, s32 rw, u32 devAddr, void* dramAddr, u32 size, OSMesgQueue* piHandle) { register s32 result; - if (__osPiDevMgr == 0) { + if (!__osPiDevMgr.active) { return -1; } - if (arg2 == 0) { - arg0->unk0 = 0xB; + if (rw == OS_READ) { + mb->hdr.type = OS_MESG_TYPE_DMAREAD; } else { - arg0->unk0 = 0xC; + mb->hdr.type = OS_MESG_TYPE_DMAWRITE; } - arg0->unk2 = (s8) arg1; - arg0->unk4 = arg6; - arg0->unk8 = arg4; - arg0->unkC = arg3; - arg0->unk10 = arg5; - arg0->unk14 = 0; + mb->hdr.pri = pri; + mb->hdr.retQueue = piHandle; + mb->dramAddr = dramAddr; + mb->devAddr = devAddr; + mb->size = size; + mb->piHandle = NULL; - if (arg1 == 1) { - result = osJamMesg(osPiGetCmdQueue(), arg0, 0); + if (pri == OS_MESG_PRI_HIGH) { + result = osJamMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); } else { - result = osSendMesg(osPiGetCmdQueue(), arg0, 0); + result = osSendMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); } return result; } diff --git a/src/main/1EB50.c b/src/main/1EB50.c index e190c4db..7e7a7f86 100644 --- a/src/main/1EB50.c +++ b/src/main/1EB50.c @@ -1,7 +1,5 @@ #include "global.h" -// OPTFLAGS := -O1 -g0 - #pragma GLOBAL_ASM("asm/us/nonmatchings/main/1EB50/func_8001DF50.s") #pragma GLOBAL_ASM("asm/us/nonmatchings/main/1EB50/func_8001E444.s") @@ -10,19 +8,6 @@ #pragma GLOBAL_ASM("asm/us/nonmatchings/main/1EB50/func_8001E778.s") -void osCreateMesgQueue(s32, s32*, s32); - -extern s8 D_800C7C50; -extern s8 D_800C7C54; -extern s32 D_800C7C58; -extern s32 D_800C7C5C; -extern s32 D_800C7C60; -extern s32 D_800C7C64; -extern s32 D_80156600; -extern s32 D_80156608; -extern s32 D_80156618; -extern s32 D_8015661C; - void func_8001E7C8(void) { D_800C7C50 = 0; D_800C7C54 = 0; diff --git a/src/main/3440.c b/src/main/3440.c index 9fcc777a..c9271a28 100644 --- a/src/main/3440.c +++ b/src/main/3440.c @@ -1,38 +1,16 @@ -#include "common.h" - -extern s32 func_800071FC(s32*); -extern s32 func_800072E0(s32*); -extern void osContInit(s32*, u8*, s32*); -extern s32 osSendMesg(s32*, s32, s32); - -extern s8 D_800DD8B0; -extern s8 D_800DD8B1; -extern s8 D_800DD8B2; -extern s8 D_800DD8B3; -extern s8 D_800DD8B8; -extern s8 D_800DD8B9; -extern s8 D_800DD8BA; -extern s8 D_800DD8BB; -extern s32 D_800DD8F0; -extern s32 D_800E2128; -extern s32 D_800E2318; -extern u8 D_80137E80; -extern s32 D_80144F60; +#include "global.h" #pragma GLOBAL_ASM("asm/us/nonmatchings/main/3440/func_80002840.s") void func_8000291C(void) { u8 sp1F; + s32 i; osContInit(&D_800E2128, &sp1F, &D_800DD8F0); - D_800DD8B0 = sp1F & 1; - D_800DD8B8 = 0; - D_800DD8B1 = (sp1F >> 1) & 1; - D_800DD8B9 = 0; - D_800DD8B2 = (sp1F >> 2) & 1; - D_800DD8BA = 0; - D_800DD8B3 = (sp1F >> 3) & 1; - D_800DD8BB = 0; + for (i = 0; i < 4; i++) { + D_800DD8B0[i] = (sp1F >> i) & 1; + D_800DD8B8[i] = 0; + } } #pragma GLOBAL_ASM("asm/us/nonmatchings/main/3440/func_800029A8.s") diff --git a/src/main/4650.c b/src/main/4650.c index 4f417c24..397e4cae 100644 --- a/src/main/4650.c +++ b/src/main/4650.c @@ -1,23 +1,13 @@ -#include "common.h" - -extern s32 D_800E2010; -extern s32 D_800E2028; -extern s32 D_8013A040; -extern s32 D_8013B1F0; -extern s32 D_80138E90; +#include "global.h" void func_800034E8(s32); s32 func_80003A50(void); +void func_80003B48(void*); void func_80003EE0(void); -void func_80004ABC(s32); -void func_80008018(void); -void osCreateThread(s32*, s32, void*, s32, s32*, s32); -void osStartThread(s32*); -void osCreateViManager(s32); -void func_800227A0(s32, s32*, s32*, s32); -void osSetThreadPri(s32, s32); -s32 func_8001EF10(void); -s32 func_80022B60(void); +void func_80003FEC(void*); +void func_800040D4(void*); +void func_80004144(void*); +void func_80004ABC(void*); #pragma GLOBAL_ASM("asm/us/nonmatchings/main/4650/func_80003A50.s") @@ -48,12 +38,12 @@ s32 func_80022B60(void); #pragma GLOBAL_ASM("asm/us/nonmatchings/main/4650/func_80004ABC.s") -void func_80004D00(s32 arg0) { - osCreateViManager(0xFE); +void func_80004D00(void* arg0) { + osCreateViManager(254); func_80003EE0(); func_800034E8(1); - func_800227A0(0x96, &D_800E2010, &D_800E2028, 0x32); - osCreateThread(&D_8013A040, 3, &func_80004ABC, arg0, &D_8013B1F0, 0x64); + func_800227A0(150, &D_800E2010, &D_800E2028, 50); + osCreateThread(&D_8013A040, 3, &func_80004ABC, arg0, &D_8013B1F0, 100); osStartThread(&D_8013A040); func_80008018(); osSetThreadPri(0, 0); @@ -65,6 +55,6 @@ void bootproc(void) { func_8001EF10(); func_80022B60(); func_80003A50(); - osCreateThread(&D_80138E90, 1, &func_80004D00, 0, &D_8013A040, 0xFF); + osCreateThread(&D_80138E90, 1, &func_80004D00, 0, &D_8013A040, 255); osStartThread(&D_80138E90); } diff --git a/src/main/5A20.c b/src/main/5A20.c index d0a0577b..5f807340 100644 --- a/src/main/5A20.c +++ b/src/main/5A20.c @@ -7,9 +7,6 @@ extern s32 D_8013B3AC; extern s32 D_8013B3B0; extern s32 D_8013B3B4; -extern f32 func_8001FBE8(f32); -extern u64 osGetTime(void); - f32 func_80004E20(f32 arg0, f32 arg1) { return arg0 - ((s32) (arg0 / arg1) * arg1); } @@ -20,7 +17,13 @@ void func_80004E4C(void) { D_8013B3AC = (s32) osGetTime() % 30000; } -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/5A20/func_80004EB0.s") +f32 func_80004EB0(void) { + D_8013B3A4 = (D_8013B3A4 * 0xAB) % 30269; + D_8013B3A8 = (D_8013B3A8 * 0xAC) % 30307; + D_8013B3AC = (D_8013B3AC * 0xAA) % 30323; + + return fabsf(func_80004E20((D_8013B3A4 / 30269.0f) + (D_8013B3A8 / 30307.0f) + (D_8013B3AC / 30323.0f), 1.0f)); +} void func_80004FC8(s32 arg0, s32 arg1, s32 arg2) { D_8013B3B0 = arg0; @@ -28,7 +31,13 @@ void func_80004FC8(s32 arg0, s32 arg1, s32 arg2) { D_8013B3A0 = arg2; } -#pragma GLOBAL_ASM("asm/us/nonmatchings/main/5A20/func_80004FE8.s") +f32 func_80004FE8(void) { + D_8013B3B0 = (D_8013B3B0 * 0xAB) % 30269; + D_8013B3B4 = (D_8013B3B4 * 0xAC) % 30307; + D_8013B3A0 = (D_8013B3A0 * 0xAA) % 30323; + + return fabsf(func_80004E20((D_8013B3B0 / 30269.0f) + (D_8013B3B4 / 30307.0f) + (D_8013B3A0 / 30323.0f), 1.0f)); +} f32 func_80005100(f32 arg0, f32 arg1) { if ((arg0 == 0.0f) && (arg1 == 0.0f)) { @@ -45,9 +54,9 @@ f32 func_80005100(f32 arg0, f32 arg1) { if (arg1 < 0.0f) { if (arg0 < 0.0f) { - return -(M_PI - func_8001FBE8(fabsf(arg0 / arg1))); + return -(M_PI - func_8001FBE8(fabs(arg0 / arg1))); } else { - return M_PI - func_8001FBE8(fabsf(arg0 / arg1)); + return M_PI - func_8001FBE8(fabs(arg0 / arg1)); } } else { return func_8001FBE8(arg0 / arg1); diff --git a/src/main/7D30.c b/src/main/7D30.c index ca9d2925..bd43177e 100644 --- a/src/main/7D30.c +++ b/src/main/7D30.c @@ -1,30 +1,21 @@ -#include "common.h" +#include "global.h" -extern s64 osClockRate; -extern s32 D_800E2128; - -extern s32 osEepromRead(s32*, u8, s32, s32); -extern s32 osEepromWrite(s32*, u8, s32); -extern s64 __ull_div(s64, s64); -extern s64 __ll_mul(s64, s64); -extern void func_800070C8(s64); - -s32 func_80007130(s32 arg0, s32 arg1) { - if (osEepromRead(&D_800E2128, arg0, arg1, arg0) != 0) { +s32 func_80007130(s32 arg0, u8* arg1) { + if (osEepromRead(&D_800E2128, arg0, arg1)) { return -1; } else { return 0; } } -s32 func_8000716C(s32 arg0, s32 arg1) { +s32 func_8000716C(s32 arg0, u8* arg1) { s64 temp_ret; s64 temp_ret_2; s64 temp_ret_3; - if (osEepromWrite(&D_800E2128, arg0, arg1) != 0) { + if (osEepromWrite(&D_800E2128, arg0, arg1)) { return -1; } temp_ret = __ull_div(osClockRate, 0x3D09); diff --git a/src/main/7FC0.c b/src/main/7FC0.c index 62cc61c3..655dcda1 100644 --- a/src/main/7FC0.c +++ b/src/main/7FC0.c @@ -1,21 +1,18 @@ -#include "common.h" +#include "global.h" typedef struct { - char pad_0[0x9CC]; - s32 unk9CC; + OSThread thread; + char unk_1B0[0x800]; + OSMesgQueue msgQueue; + OSMesg msg; + s32 unk9CC; // probably FaultDrawer s16 unk9D0; s16 unk9D2; } UnkStruct_D_80145360; -void osCreateMesgQueue(s32*, s32*, s32); -void osCreateThread(UnkStruct_D_80145360*, s32, s32*, s32, s32*, s32); -void osStartThread(UnkStruct_D_80145360*); - extern UnkStruct_D_80145360 D_80145360; extern s32 D_80145D10; extern s32 D_80145D28; -extern s32 func_80007D58; -extern s32 osMemSize; #pragma GLOBAL_ASM("asm/us/nonmatchings/main/7FC0/func_800073C0.s") @@ -97,10 +94,10 @@ void func_80007FE4(s32 arg0, u16 arg1, u16 arg2) { #endif void func_80008018(void) { - D_80145360.unk9CC = (osMemSize | 0x80000000) + 0xFFFDA800; - D_80145360.unk9D0 = 0x140; - D_80145360.unk9D2 = 0xF0; - osCreateMesgQueue(&D_80145D10, &D_80145D28, 1); - osCreateThread(&D_80145360, 2, &func_80007D58, 0, &D_80145D10, 0x7F); - osStartThread(&D_80145360); + D_80145360.unk9CC = (PHYS_TO_K0(osMemSize) - sizeof(u16[SCREEN_HEIGHT][SCREEN_WIDTH])); + D_80145360.unk9D0 = SCREEN_WIDTH; + D_80145360.unk9D2 = SCREEN_HEIGHT; + osCreateMesgQueue(&D_80145360.msgQueue, &D_80145360.msg, 1); + osCreateThread(&D_80145360.thread, 2, func_80007D58, 0, &D_80145360.msgQueue, 0x7F); + osStartThread(&D_80145360.thread); } diff --git a/src/overlays/segment_DF4260/DF4260.h b/src/overlays/segment_DF4260/DF4260.h index 52193157..428087be 100644 --- a/src/overlays/segment_DF4260/DF4260.h +++ b/src/overlays/segment_DF4260/DF4260.h @@ -17,4 +17,4 @@ typedef struct { void func_8007C120(s32, s32, s32, f32, f32, f32, f32, s32); -#endif \ No newline at end of file +#endif diff --git a/src/overlays/segment_DF4260/DFEE30.h b/src/overlays/segment_DF4260/DFEE30.h index 288e3ba7..0c08d36c 100644 --- a/src/overlays/segment_DF4260/DFEE30.h +++ b/src/overlays/segment_DF4260/DFEE30.h @@ -20,4 +20,4 @@ typedef struct { extern s8 D_80177A98; extern s8 D_80177AB0; -#endif \ No newline at end of file +#endif diff --git a/src/overlays/segment_EBFBE0/EBFCA0.c b/src/overlays/segment_EBFBE0/EBFCA0.c index 76dd3898..c5c1cfa7 100644 --- a/src/overlays/segment_EBFBE0/EBFCA0.c +++ b/src/overlays/segment_EBFBE0/EBFCA0.c @@ -293,11 +293,6 @@ void func_80187E28_EC04E8(void) { extern UnkStruct_D_801B8350 D_801B8350[]; -#define M_PI 3.1415927f - -f32 sqrtf(f32 f); -#pragma intrinsic(sqrtf); - void func_80189208_EC18C8(void) { s32 i; diff --git a/yamls/us/main.yaml b/yamls/us/main.yaml index bcd5e84e..8670e95d 100644 --- a/yamls/us/main.yaml +++ b/yamls/us/main.yaml @@ -67,7 +67,7 @@ - [0x23C00, c, ../libultra/os/gettime] - [0x23C90, c, ../libultra/gu/sinf] - [0x23E50, c, ../libultra/gu/cosf] - - [0x23FC0, hasm, ../libultra/gu/sqrtf] + - [0x23FC0, c, ../libultra/gu/guSqrtf] - [0x23FD0, c, ../libultra/os/settimer] - [0x240B0, c, ../libultra/conteepread] - [0x243B0, c, ../libultra/conteepwrite]