This commit is contained in:
dborth 2009-03-12 07:07:52 +00:00
parent 57406336d5
commit ac2658e001
12 changed files with 119 additions and 111 deletions

View File

@ -86,10 +86,10 @@ GCMixSamples ()
}
/****************************************************************************
* InitGCAudio
* InitAudio
***************************************************************************/
void
InitGCAudio ()
InitAudio ()
{
LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 150);
}
@ -117,6 +117,16 @@ SwitchAudioMode(int mode)
}
}
void ShutdownAudio()
{
#ifndef NO_SOUND
ASND_Pause(1);
ASND_End();
#endif
AUDIO_StopDMA();
AUDIO_RegisterDMACallback(NULL);
}
/****************************************************************************
* AudioStart
*

View File

@ -9,6 +9,7 @@
* Audio is fixed to 32Khz/16bit/Stereo
***************************************************************************/
void InitGCAudio ();
void InitAudio ();
void AudioStart ();
void SwitchAudioMode(int mode);
void ShutdownAudio();

View File

@ -361,8 +361,8 @@ ParseDirectory()
void
AllocSaveBuffer ()
{
if (savebuffer != NULL)
free(savebuffer);
while(savebuffer != NULL) // save buffer is in use
usleep(50); // wait for it to be free
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
memset (savebuffer, 0, SAVEBUFFERSIZE);

View File

@ -126,6 +126,7 @@ NGCFreezeGame (char * filepath, int method, bool silent)
{
int offset = 0; // bytes written (actual)
int woffset = 0; // bytes written (expected)
int imgSize = 0; // image screenshot bytes written
char msg[100];
if(method == METHOD_AUTO)
@ -196,17 +197,16 @@ done:
if (pngContext != NULL)
{
PNGU_EncodeFromGXTexture(pngContext, 640, 480, gameScreenTex, 0);
imgSize = PNGU_EncodeFromGXTexture(pngContext, 640, 480, gameScreenTex, 0);
PNGU_ReleaseImageContext(pngContext);
}
int size = FindBufferSize((char *)savebuffer, 128*1024);
if(size > 0)
if(imgSize > 0)
{
char screenpath[1024];
filepath[strlen(filepath)-4] = 0;
sprintf(screenpath, "%s.png", filepath);
SaveFile(screenpath, size, method, silent);
SaveFile(screenpath, imgSize, method, silent);
}
FreeSaveBuffer ();

View File

@ -57,7 +57,8 @@ GuiImage::GuiImage(int w, int h, GXColor c)
this->SetPixel(x, y, c);
}
}
DCFlushRange(image, w * h * 4);
int len = w*h*4;
DCFlushRange(image, len+len%32);
}
/**

View File

@ -32,8 +32,9 @@ GuiImageData::GuiImageData(const u8 * img)
height = imgProp.imgHeight;
data = (u8 *)memalign (32, imgProp.imgWidth * imgProp.imgHeight * 4);
PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255);
int len = imgProp.imgWidth * imgProp.imgHeight * 4;
DCFlushRange(data, len+len%32);
PNGU_ReleaseImageContext (ctx);
DCFlushRange (data, imgProp.imgWidth * imgProp.imgHeight * 4);
}
}

View File

@ -295,11 +295,6 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
{
// move list up by 1
listOffset -= 2;
if(selectedItem == 0)
selectedItem = SAVELISTSIZE-2;
else
selectedItem = SAVELISTSIZE-1;
}
}
else

View File

@ -1220,85 +1220,6 @@ static int MenuGameSaves(int action)
if(!ChangeInterface(method, NOTSILENT))
return MENU_GAME;
memset(&saves, 0, sizeof(saves));
if(method == METHOD_MC_SLOTA)
{
ParseMCDirectory(CARD_SLOTA);
}
else if(method == METHOD_MC_SLOTB)
{
ParseMCDirectory(CARD_SLOTB);
}
else
{
strncpy(browser.dir, GCSettings.SaveFolder, 200);
ParseDirectory();
}
if(browser.numEntries <= 0)
return MENU_GAME;
for(i=0; i < browser.numEntries; i++)
{
len = strlen(Memory.ROMFilename);
len2 = strlen(browserList[i].filename);
// find matching files
if(len2 > 5 && strncmp(browserList[i].filename, Memory.ROMFilename, len) == 0)
{
if(strncmp(&browserList[i].filename[len2-4], ".srm", 4) == 0)
saves.type[j] = FILE_SRAM;
else if(strncmp(&browserList[i].filename[len2-4], ".frz", 4) == 0)
saves.type[j] = FILE_SNAPSHOT;
else
saves.type[j] = -1;
if(saves.type[j] != -1)
{
int n = -1;
char tmp[300];
strncpy(tmp, browserList[i].filename, 255);
tmp[len2-4] = 0;
if(len2 - len == 7)
n = atoi(&tmp[len2-5]);
else if(len2 - len == 6)
n = atoi(&tmp[len2-6]);
if(n > 0 && n < 100)
saves.files[saves.type[j]][n] = 1;
strncpy(saves.filename[j], browserList[i].filename, 255);
if(method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
{
if(saves.type[j] == FILE_SNAPSHOT)
{
char scrfile[1024];
sprintf(scrfile, "%s/%s.png", GCSettings.SaveFolder, tmp);
AllocSaveBuffer();
if(LoadFile(scrfile, GCSettings.SaveMethod, SILENT))
saves.previewImg[j] = new GuiImageData(savebuffer);
FreeSaveBuffer();
}
strftime(saves.date[j], 20, "%a %b %d", &browserList[j].mtime);
strftime(saves.time[j], 10, "%I:%M %p", &browserList[j].mtime);
}
j++;
}
}
}
saves.length = j;
if(saves.length == 0 && action == 0)
{
InfoPrompt("No game saves found.");
return MENU_GAME;
}
GuiText titleTxt(NULL, 22, (GXColor){255, 255, 255, 255});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,50);
@ -1350,17 +1271,98 @@ static int MenuGameSaves(int action)
closeBtn.SetTrigger(&trigHome);
closeBtn.SetEffectGrow();
guiReady = false;
GuiWindow w(screenwidth, screenheight);
w.Append(&backBtn);
w.Append(&closeBtn);
mainWindow->Append(&w);
mainWindow->Append(&titleTxt);
guiReady = true;
memset(&saves, 0, sizeof(saves));
if(method == METHOD_MC_SLOTA)
{
ParseMCDirectory(CARD_SLOTA);
}
else if(method == METHOD_MC_SLOTB)
{
ParseMCDirectory(CARD_SLOTB);
}
else
{
strncpy(browser.dir, GCSettings.SaveFolder, 200);
ParseDirectory();
}
for(i=0; i < browser.numEntries; i++)
{
len = strlen(Memory.ROMFilename);
len2 = strlen(browserList[i].filename);
// find matching files
if(len2 > 5 && strncmp(browserList[i].filename, Memory.ROMFilename, len) == 0)
{
if(strncmp(&browserList[i].filename[len2-4], ".srm", 4) == 0)
saves.type[j] = FILE_SRAM;
else if(strncmp(&browserList[i].filename[len2-4], ".frz", 4) == 0)
saves.type[j] = FILE_SNAPSHOT;
else
saves.type[j] = -1;
if(saves.type[j] != -1)
{
int n = -1;
char tmp[300];
strncpy(tmp, browserList[i].filename, 255);
tmp[len2-4] = 0;
if(len2 - len == 7)
n = atoi(&tmp[len2-5]);
else if(len2 - len == 6)
n = atoi(&tmp[len2-6]);
if(n > 0 && n < 100)
saves.files[saves.type[j]][n] = 1;
strncpy(saves.filename[j], browserList[i].filename, 255);
if(method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB)
{
if(saves.type[j] == FILE_SNAPSHOT)
{
char scrfile[1024];
sprintf(scrfile, "%s/%s.png", GCSettings.SaveFolder, tmp);
AllocSaveBuffer();
if(LoadFile(scrfile, GCSettings.SaveMethod, SILENT))
{
saves.previewImg[j] = new GuiImageData(savebuffer);
}
FreeSaveBuffer();
}
strftime(saves.date[j], 20, "%a %b %d", &browserList[j].mtime);
strftime(saves.time[j], 10, "%I:%M %p", &browserList[j].mtime);
}
j++;
}
}
}
saves.length = j;
if(saves.length == 0 && action == 0)
{
InfoPrompt("No game saves found.");
menu = MENU_GAME;
}
GuiSaveBrowser saveBrowser(552, 248, &saves, action);
saveBrowser.SetPosition(0, 108);
saveBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
guiReady = false;
GuiWindow w(screenwidth, screenheight);
w.Append(&backBtn);
w.Append(&closeBtn);
mainWindow->Append(&saveBrowser);
mainWindow->Append(&w);
mainWindow->Append(&titleTxt);
guiReady = true;
while(menu == MENU_NONE)
@ -3091,7 +3093,7 @@ MainMenu (int menu)
memTxt = new GuiText(NULL, 22, (GXColor){255, 255, 255, 255});
memTxt->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
memTxt->SetPosition(-20, 40);
//mainWindow->Append(memTxt);
mainWindow->Append(memTxt);
guiReady = true;
ResumeGui();

View File

@ -202,7 +202,7 @@ void InitializeNetwork(bool silent)
void CloseShare()
{
if(networkShareInit)
smbClose();
smbClose("smb");
networkShareInit = false;
networkInit = false; // trigger a network reinit
}

View File

@ -135,7 +135,7 @@ S9xOpenSoundDevice (int mode, bool8 stereo, int buffer_size)
so.sound_switch = 255;
S9xSetPlaybackRate (so.playback_rate);
InitGCAudio ();
InitAudio ();
return TRUE;
}

View File

@ -4,7 +4,7 @@
* softdev July 2006
* crunchy2 May 2007-July 2007
* Michniewski 2008
* Tantric September 2008
* Tantric 2008-2009
*
* snes9xGX.cpp
*
@ -78,15 +78,16 @@ extern unsigned int timediffallowed;
void ExitCleanup()
{
#ifdef HW_RVL
ShutoffRumble();
#endif
ShutdownAudio();
StopGX();
LWP_SuspendThread (devicethread);
UnmountAllFAT();
#ifdef HW_RVL
ShutoffRumble();
WPAD_Shutdown();
CloseShare();
DI_Close();
#endif
}
@ -431,7 +432,7 @@ main(int argc, char *argv[])
// Initialize font system
fontSystem = new FreeTypeGX();
//fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_GRRLIB);
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
InitGUIThreads();

View File

@ -410,9 +410,6 @@ StartGX ()
void StopGX()
{
free(MEM_K1_TO_K0(xfb[0])); xfb[0] = NULL;
free(MEM_K1_TO_K0(xfb[1])); xfb[1] = NULL;
GX_AbortFrame();
GX_Flush();