SAVESTATE_t* SaveSlot(void *lpInput) { CALC* lpCalc = (CALC*) lpInput; SAVESTATE_t* save; bool runsave; if (lpCalc->active == false) return nullptr; runsave = lpCalc->running; lpCalc->running = false; save = CreateSave(("Revsoft"), ("Test save"), lpCalc->model); SaveCPU(save, &lpCalc->cpu); SaveMEM(save, &lpCalc->mem_c); SaveTIMER(save, &lpCalc->timer_c); SaveLCD(save, lpCalc->cpu.pio.lcd); SaveLINK(save, lpCalc->cpu.pio.link); SaveSTDINT(save, lpCalc->cpu.pio.stdint); SaveSE_AUX(save, lpCalc->cpu.pio.se_aux); lpCalc->running = runsave; return save; }
SAVESTATE_t* SaveSlot(void *lpInput) { LPCALC lpCalc = (LPCALC) lpInput; SAVESTATE_t* save; BOOL runsave; if (lpCalc->active == FALSE) return NULL; runsave = lpCalc->running; lpCalc->running = FALSE; save = CreateSave(_T("Revsoft"), _T("Test save"), lpCalc->model); SaveCPU(save, &lpCalc->cpu); SaveMEM(save, &lpCalc->mem_c); SaveTIMER(save, &lpCalc->timer_c); SaveLCD(save, lpCalc->cpu.pio.lcd); SaveLINK(save, lpCalc->cpu.pio.link); SaveSTDINT(save, lpCalc->cpu.pio.stdint); SaveSE_AUX(save, lpCalc->cpu.pio.se_aux); lpCalc->running = runsave; return save; }
int main() { int fd, ret; int i; // Initialise SifInitRpc(0); LoadModules(); #ifdef TYPE_MC if(mcInit(MC_TYPE_MC) < 0) { printf("Failed to initialise memcard server!\n"); SleepThread(); } #else if(mcInit(MC_TYPE_XMC) < 0) { printf("Failed to initialise memcard server!\n"); SleepThread(); } #endif printf("\nMemory card library example code - by Sjeep\n\n"); // int mcGetInfo(int port, int slot, int* type, int* free, int* format); // // mcGetInfo retrieves memcard state info, such as the memcard type, free blocks and // the format status. // // mcGetInfo is passed pointers to three variables, which are filled upon completion // of the getinfo rpc command. The mcGetInfo return values are as follows: // // 0 : The same memory card has been connected since the last mcGetInfo call. // -1 : Switched to a formatted memory card. // -2 : Switched to an unformatted memory card. // -10 or less : The memory card could not be detected. // // NOTE: With the MCMAN/MCSERV, *format is always returned as 0 regardless of if // if the memcard is formatted or not. // Since this is the first call, -1 should be returned. mcGetInfo(0, 0, &mc_Type, &mc_Free, &mc_Format); mcSync(0, NULL, &ret); printf("mcGetInfo returned %d\n",ret); printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format); // Assuming that the same memory card is connected, this should return 0 mcGetInfo(0,0,&mc_Type,&mc_Free,&mc_Format); mcSync(0, NULL, &ret); printf("mcGetInfo returned %d\n",ret); printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format); // int mcGetDir(int port, int slot, char *name, unsigned mode, int maxent, mcTable* table); // // mcGetDir retrieves the directory structure of a specific path on the memory card. // // The filename is relative to the root of the memory card. Wildcards such as '*' and '?' // may be used. "maxent" is the maximum number of mcTable elements your array specified // by "table" can hold. The mc_getdir return values are as follows: // // 0 or more : The number of file entries that were obtained. // -2 : The memory card is unformatted // -4 : A non-existant path was specified in the "name" parameter // -10 or less : The memory card could not be detected. mcGetDir(0, 0, "/*", 0, ARRAY_ENTRIES - 10, mcDir); mcSync(0, NULL, &ret); printf("mcGetDir returned %d\n\nListing of root directory on memory card:\n\n", ret); for(i=0; i < ret; i++) { if(mcDir[i].attrFile & MC_ATTR_SUBDIR) printf("[DIR] %s\n", mcDir[i].name); else printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte); } // Check if existing save is present fd = fioOpen("mc0:PS2DEV/icon.sys", O_RDONLY); if(fd <= 0) { printf("\nNo previous save exists, creating...\n"); if((ret = CreateSave()) < 0) { printf("Failed to create save! Errorno: %d\n",ret); SleepThread(); } } else { printf("\nPrevious save exists, listing directory\n\n"); ret = mcGetDir(0, 0, "/PS2DEV/*", 0, ARRAY_ENTRIES, mcDir); printf("mcGetDir returned %d\n\n", ret); for(i=0; i < ret; i++) { if(mcDir[i].attrFile & MC_ATTR_SUBDIR) printf("[DIR] %s\n", mcDir[i].name); else printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte); } } // Return to the browser, so you can see the PS2Dev icon :) SifExitRpc(); return 0; }