2 Copyright (C) 2002 Rice1964
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 Sprite2DInfo g_Sprite2DInfo;
25 uint32 g_SavedUcode=1;
27 void RSP_GBI_Sprite2DBase(Gfx *gfx)
29 uint32 dwAddr = RSPSegmentAddr((gfx->words.w1));
30 dwAddr &= (g_dwRamSize-1);
32 //RSP_RDP_NOIMPL("RDP: Sprite2D (0x%08x 0x%08x)", (gfx->words.w0), (gfx->words.w1));
34 g_Sprite2DInfo.spritePtr = (SpriteStruct *)(g_pRDRAMs8+dwAddr);
36 DEBUGGER_PAUSE_AND_DUMP_COUNT_N(NEXT_SPRITE_2D, {DebuggerAppendMsg("Pause after Sprite2DBase: Addr=%08X\n", dwAddr);});
40 uint32 SourceImagePointer;
46 char SourceImageBitSize;
53 short SourceImageOffsetS;
57 short SourceImageOffsetT;
64 void RSP_GBI_Sprite2D_PuzzleMaster64(Gfx *gfx)
66 uint32 dwAddr = RSPSegmentAddr((gfx->words.w1));
67 dwAddr &= (g_dwRamSize-1);
69 g_Sprite2DInfo.spritePtr = (SpriteStruct *)(g_pRDRAMs8+dwAddr);
71 g_Sprite2DInfo.flipX = 0;
72 g_Sprite2DInfo.flipY = 0;
73 g_Sprite2DInfo.px = 0;
74 g_Sprite2DInfo.py = 0;
76 SpriteStruct tempInfo;
77 memcpy(&tempInfo, g_Sprite2DInfo.spritePtr, sizeof(SpriteStruct));
78 PuzzleMasterSprite info;
79 memcpy(&info, g_Sprite2DInfo.spritePtr, sizeof(PuzzleMasterSprite));
81 g_Sprite2DInfo.px = info.px>>2;
82 g_Sprite2DInfo.py = info.py>>2;
83 g_Sprite2DInfo.scaleX = info.scaleX / 1024.0f;
84 g_Sprite2DInfo.scaleY = info.scaleY / 1024.0f;
86 tempInfo.SourceImageOffsetS = info.SourceImageOffsetS;
87 tempInfo.SourceImageOffsetT = info.SourceImageOffsetT;
88 g_Sprite2DInfo.spritePtr = &tempInfo;
90 CRender::g_pRender->DrawSprite2D(g_Sprite2DInfo, 1);
91 DEBUGGER_PAUSE_AND_DUMP_COUNT_N(NEXT_SPRITE_2D, {DebuggerAppendMsg("Pause after Sprite2DBase: Addr=%08X\n", dwAddr);});
95 void RSP_GBI1_Sprite2DDraw(Gfx *gfx)
97 // This ucode is shared by PopMtx and gSPSprite2DDraw
98 g_Sprite2DInfo.px = (short)(((gfx->words.w1)>>16)&0xFFFF)/4;
99 g_Sprite2DInfo.py = (short)((gfx->words.w1)&0xFFFF)/4;
101 //RSP_RDP_NOIMPL("gSPSprite2DDraw is not implemented", (gfx->words.w0), (gfx->words.w1));
102 CRender::g_pRender->DrawSprite2D(g_Sprite2DInfo, 1);
103 DEBUGGER_PAUSE_AND_DUMP_COUNT_N(NEXT_SPRITE_2D,
104 {DebuggerAppendMsg("Pause after Sprite2DDraw at (%d, %d)\n", g_Sprite2DInfo.px, g_Sprite2DInfo.py);});
106 LoadedUcodeMap[RSP_SPRITE2D_SCALEFLIP] = &RSP_GBI1_CullDL;
107 LoadedUcodeMap[RSP_SPRITE2D_DRAW] = &RSP_GBI1_PopMtx;
108 LoadedUcodeMap[RSP_SPRITE2D_BASE] = &RSP_GBI1_Sprite2DBase;
112 void RSP_GBI0_Sprite2DDraw(Gfx *gfx)
114 // This ucode is shared by PopMtx and gSPSprite2DDraw
115 g_Sprite2DInfo.px = (short)(((gfx->words.w1)>>16)&0xFFFF)/4;
116 g_Sprite2DInfo.py = (short)((gfx->words.w1)&0xFFFF)/4;
118 //RSP_RDP_NOIMPL("gSPSprite2DDraw is not implemented", (gfx->words.w0), (gfx->words.w1));
119 CRender::g_pRender->DrawSprite2D(g_Sprite2DInfo, 0);
120 DEBUGGER_PAUSE_AND_DUMP_COUNT_N(NEXT_SPRITE_2D, {TRACE0("Pause after Sprite2DDraw\n");});
124 void RSP_GBI1_Sprite2DScaleFlip(Gfx *gfx)
126 g_Sprite2DInfo.scaleX = (((gfx->words.w1)>>16)&0xFFFF)/1024.0f;
127 g_Sprite2DInfo.scaleY = ((gfx->words.w1)&0xFFFF)/1024.0f;
129 if( ((gfx->words.w1)&0xFFFF) < 0x100 )
131 g_Sprite2DInfo.scaleY = g_Sprite2DInfo.scaleX;
134 g_Sprite2DInfo.flipX = (uint8)(((gfx->words.w0)>>8)&0xFF);
135 g_Sprite2DInfo.flipY = (uint8)((gfx->words.w0)&0xFF);
136 //RSP_RDP_NOIMPL("RSP_SPRITE2D_SCALEFLIP is not implemented", (gfx->words.w0), (gfx->words.w1));
137 DEBUGGER_PAUSE_AND_DUMP_COUNT_N(NEXT_SPRITE_2D,
138 {DebuggerAppendMsg("Pause after Sprite2DScaleFlip, Flip (%d,%d), Scale (%f, %f)\n", g_Sprite2DInfo.flipX, g_Sprite2DInfo.flipY,
139 g_Sprite2DInfo.scaleX, g_Sprite2DInfo.scaleY);});
143 void RSP_GBI1_Sprite2DBase(Gfx *gfx)
145 if( !status.bUseModifiedUcodeMap )
147 memcpy( &LoadedUcodeMap, &ucodeMap1, sizeof(UcodeMap));
148 status.bUseModifiedUcodeMap = true;
151 LoadedUcodeMap[RSP_SPRITE2D_BASE] = &RSP_GBI_Sprite2DBase;
152 LoadedUcodeMap[RSP_SPRITE2D_SCALEFLIP] = &RSP_GBI1_Sprite2DScaleFlip;
153 LoadedUcodeMap[RSP_SPRITE2D_DRAW] = &RSP_GBI1_Sprite2DDraw;
155 TRACE0("Adding Sprite2D ucodes to ucode 1");
156 RSP_GBI_Sprite2DBase(gfx);
160 void RSP_GBI0_Sprite2DBase(Gfx *gfx)
162 //Weired, this ucode 0 game is using ucode 1, but sprite2D cmd is working differently from
163 //normal ucode1 sprite2D game
165 TRACE0("Ucode 0 game is using Sprite2D, and using ucode 1 codes, create a new ucode for me");
167 RSP_GBI_Sprite2DBase(gfx);