diff --git a/Makefile b/Makefile index 37da27d..afbe1ea 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -.PHONY = all wii gc wii-clean gc-clean wii-run gc-run mca mcb sd smb mca-clean mcb-clean sd-clean smb-clean specials specials-clean +.PHONY = all wii gc wii-clean gc-clean wii-run gc-run specials specials-clean specials-wii specials-gc specials-wii-clean specials-gc-clean -VERSION := 003 +VERSION := 004 all: wii gc -clean: wii-clean gc-clean +clean: wii-clean gc-clean specials-clean wii: $(MAKE) -f Makefile.wii @@ -26,39 +26,35 @@ gc-run: # Custom Quicksave Versions -specials: sd mcb mca smb +specials: specials-wii specials-gc -specials-clean: mca-clean mcb-clean smb-clean sd-clean +specials-clean: specials-wii-clean specials-gc-clean -mca: +specials-wii: touch source/ngc/snes9xGX.h $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=0" "LOADTYPE:='"MCSLOTA"'" "VERSION:=$(VERSION)" -f Makefile.wii - touch source/ngc/snes9xGX.h - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=0" "LOADTYPE:='"MCSLOTA"'" "VERSION:=$(VERSION)" -f Makefile.gc -mca-clean: - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=0" "LOADTYPE:='"MCSLOTA"'" "VERSION:=$(VERSION)" -f Makefile.wii clean - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=0" "LOADTYPE:='"MCSLOTA"'" "VERSION:=$(VERSION)" -f Makefile.gc clean - -mcb: touch source/ngc/snes9xGX.h $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=1" "LOADTYPE:='"MCSLOTB"'" "VERSION:=$(VERSION)" -f Makefile.wii - touch source/ngc/snes9xGX.h - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=1" "LOADTYPE:='"MCSLOTB"'" "VERSION:=$(VERSION)" -f Makefile.gc -mcb-clean: - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=1" "LOADTYPE:='"MCSLOTB"'" "VERSION:=$(VERSION)" -f Makefile.wii clean - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=1" "LOADTYPE:='"MCSLOTB"'" "VERSION:=$(VERSION)" -f Makefile.gc clean - -sd: touch source/ngc/snes9xGX.h $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=3" "LOADTYPE:='"SD"'" "VERSION:=$(VERSION)" -f Makefile.wii + +specials-gc: + touch source/ngc/snes9xGX.h + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=0" "LOADTYPE:='"MCSLOTA"'" "VERSION:=$(VERSION)" -f Makefile.gc + touch source/ngc/snes9xGX.h + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=1" "LOADTYPE:='"MCSLOTB"'" "VERSION:=$(VERSION)" -f Makefile.gc touch source/ngc/snes9xGX.h $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=3" "LOADTYPE:='"SD"'" "VERSION:=$(VERSION)" -f Makefile.gc -sd-clean: - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=3" "LOADTYPE:='"SD"'" "VERSION:=$(VERSION)" -f Makefile.wii clean - $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=3" "LOADTYPE:='"SD"'" "VERSION:=$(VERSION)" -f Makefile.gc clean - -smb: touch source/ngc/snes9xGX.h $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=4" "LOADTYPE:='"SMB"'" "VERSION:=$(VERSION)" -f Makefile.gc -smb-clean: + +specials-wii-clean: + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=0" "LOADTYPE:='"MCSLOTA"'" "VERSION:=$(VERSION)" -f Makefile.wii clean + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=1" "LOADTYPE:='"MCSLOTB"'" "VERSION:=$(VERSION)" -f Makefile.wii clean + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=3" "LOADTYPE:='"SD"'" "VERSION:=$(VERSION)" -f Makefile.wii clean + +specials-gc-clean: + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=0" "LOADTYPE:='"MCSLOTA"'" "VERSION:=$(VERSION)" -f Makefile.gc clean + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=1" "LOADTYPE:='"MCSLOTB"'" "VERSION:=$(VERSION)" -f Makefile.gc clean + $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=3" "LOADTYPE:='"SD"'" "VERSION:=$(VERSION)" -f Makefile.gc clean $(MAKE) "CUSTOMFLAGS:=-DQUICK_SAVE_SLOT=4" "LOADTYPE:='"SMB"'" "VERSION:=$(VERSION)" -f Makefile.gc clean \ No newline at end of file diff --git a/Makefile.gc b/Makefile.gc index 8c83d0d..fbbbe5e 100644 --- a/Makefile.gc +++ b/Makefile.gc @@ -9,8 +9,8 @@ endif include $(DEVKITPPC)/gamecube_rules -LOADTYPE = '"sd"' -VERSION = '"version"' +LOADTYPE = "sd" +VERSION = "version" #--------------------------------------------------------------------------------- # TARGET is the name of the output diff --git a/Makefile.wii b/Makefile.wii index dd924ee..f0f8833 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -9,9 +9,8 @@ endif include $(DEVKITPPC)/wii_rules - -LOADTYPE = '"sd"' -VERSION = '"version"' +LOADTYPE = "sd" +VERSION = "version" #--------------------------------------------------------------------------------- # TARGET is the name of the output diff --git a/README.txt b/README.txt index 5016609..3130108 100644 --- a/README.txt +++ b/README.txt @@ -10,13 +10,24 @@ ­———————————————————————————————————————————————————————————————————————•ßrK• ×—–­—–­—–­—–­ –­—–­—–­—–­—–­—–­—–­—–­—–­—–­— ­—–­—–­—–­—–­—–­—–­—–­—-­—–­-–•¬ -|0O×øo· SNES9XGX v003 ·oø×O0| +|0O×øo· SNES9XGX v004 ·oø×O0| `¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨' PLEASE NOTE: THIS DOCUMENT IS A WORK IN PROGRESS -[What's New 003] +[What's New 004] +- added: option to disable AA filtering + (snes graphics 'crisper', AA now default OFF) +- added: mapped zooming and turbo mode to classic controller +- added: preliminary usb support (loading) +- changed: sram and freezes now saved by filename, not internal romname. + If you have multiple versions of the same game, you can now have + srams and freezes for each version. A prompt to convert to the + new naming is provided for sram only. +- changed: by default, autoload/save sram and freeze enabled + +[What Was New 003] - added: alphabetical file sorting - added: background logo/backdrop + nicer menus - added: scrolling in ROM selector @@ -77,11 +88,11 @@ SRAM to any location). filename preferences/sram autoloading location ------------------------- ------------------------------------- - snes9xGX-003-sd-xxxx.dol SD card - snes9xGX-003-mcslota-xxxx.dol Memory card in slot A - snes9xGX-003-mcslotb-xxxx.dol Memory card in slot B - snes9xGX-003-smb-xxxx.dol SMB share (see SMB section below) - snes9xGX-003-noload-xxxx.dol none - doesn't load prefs nor autosave SRAM + snes9xGX-00x-sd-xxxx.dol SD card + snes9xGX-00x-mcslota-xxxx.dol Memory card in slot A + snes9xGX-00x-mcslotb-xxxx.dol Memory card in slot B + snes9xGX-00x-smb-xxxx.dol SMB share (see SMB section below) +// snes9xGX-00x-noload-xxxx.dol none - doesn't load prefs nor autosave SRAM The last part of the filename (shown above as xxxx), denotes the wii and gamecube versions. diff --git a/source/ngc/button_mapping.c b/source/ngc/button_mapping.c index 90a0fb7..bdea889 100644 --- a/source/ngc/button_mapping.c +++ b/source/ngc/button_mapping.c @@ -90,78 +90,6 @@ WPAD_BUTTON_HOME, "HOME", 0, "" }; -/* -// Nunchuk btn def -ctrlr_def[0].type = CTRLR_NUNCHUK; -ctrlr_def[0].num_btns = 13; -ctrlr_def[0].map[] = { WPAD_BUTTON_DOWN, "DOWN", -WPAD_BUTTON_UP, "UP", -WPAD_BUTTON_LEFT, "LEFT", -WPAD_BUTTON_RIGHT, "RIGHT", -WPAD_BUTTON_A, "A", -WPAD_BUTTON_B, "B", -WPAD_BUTTON_1, "1", -WPAD_BUTTON_2, "2", -WPAD_BUTTON_PLUS, "PLUS", -WPAD_BUTTON_MINUS, "MINUS", -WPAD_BUTTON_HOME, "HOME", -WPAD_NUNCHUK_BUTTON_Z, "Z", -WPAD_NUNCHUK_BUTTON_C, "C" -}; -// Classic btn def -ctrlr_def[1].type = CTRLR_CLASSIC; -ctrlr_def[1].num_btns = 15; -ctrlr_def[1].map[] = { WPAD_CLASSIC_BUTTON_DOWN, "DOWN", -WPAD_CLASSIC_BUTTON_UP, "UP", -WPAD_CLASSIC_BUTTON_LEFT, "LEFT", -WPAD_CLASSIC_BUTTON_RIGHT, "RIGHT", -WPAD_CLASSIC_BUTTON_A, "A", -WPAD_CLASSIC_BUTTON_B, "B", -WPAD_CLASSIC_BUTTON_X, "X", -WPAD_CLASSIC_BUTTON_Y, "Y", -WPAD_CLASSIC_BUTTON_PLUS, "PLUS", -WPAD_CLASSIC_BUTTON_MINUS, "MINUS", -WPAD_CLASSIC_BUTTON_HOME, "HOME", -WPAD_CLASSIC_BUTTON_FULL_L, "L TRIG", -WPAD_CLASSIC_BUTTON_FULL_R, "R TRIG", -WPAD_CLASSIC_BUTTON_ZL, "ZL", -WPAD_CLASSIC_BUTTON_ZR, "ZR", -}; -// Gamecube controller btn def -ctrlr_def[2].type = CTRLR_GCPAD; -ctrlr_def[2].num_btns = 13; -ctrlr_def[2].map[] = { PAD_BUTTON_DOWN, "DOWN", -PAD_BUTTON_UP, "UP", -PAD_BUTTON_LEFT, "LEFT", -PAD_BUTTON_RIGHT, "RIGHT", -PAD_BUTTON_A, "A", -PAD_BUTTON_B, "B", -PAD_BUTTON_X, "X", -PAD_BUTTON_Y, "Y", -PAD_BUTTON_MENU, "MENU", -PAD_BUTTON_START, "START", -PAD_BUTTON_L, "L TRIG", -PAD_BUTTON_R, "R TRIG", -PAD_BUTTON_Z, "Z", -}; -// Wiimote btn def -ctrlr_def[3].type = CTRLR_WIIMOTE; -ctrlr_def[3].num_btns = 11; -ctrlr_def[3].map[] = { WPAD_BUTTON_DOWN, "DOWN", -WPAD_BUTTON_UP, "UP", -WPAD_BUTTON_LEFT, "LEFT", -WPAD_BUTTON_RIGHT, "RIGHT", -WPAD_BUTTON_A, "A", -WPAD_BUTTON_B, "B", -WPAD_BUTTON_1, "1", -WPAD_BUTTON_2, "2", -WPAD_BUTTON_PLUS, "PLUS", -WPAD_BUTTON_MINUS, "MINUS", -WPAD_BUTTON_HOME, "HOME" -}; -// end buttonmaps -*/ - /*** * Default controller maps * button press on left, and corresponding snes button on right diff --git a/source/ngc/filesel.cpp b/source/ngc/filesel.cpp index 7062e90..d4b3405 100644 --- a/source/ngc/filesel.cpp +++ b/source/ngc/filesel.cpp @@ -13,6 +13,9 @@ #include #include +#include +#include + #include "snes9x.h" #include "memmap.h" #include "debug.h" @@ -43,7 +46,8 @@ int havedir = 0; int hasloaded = 0; int loadtype = 0; int LoadDVDFile (unsigned char *buffer); -int haveSDdir = 0; +bool haveSDdir = 0; +bool haveUSBdir = 0; extern unsigned long ARAM_ROMSIZE; extern int screenheight; @@ -91,7 +95,7 @@ ShowFiles (int offset, int selection) { - /*** Highlighted text entry ***/ + /*** Highlighted text entry ***/ for ( w = 0; w < 20; w++ ) DrawLineFast( 30, 610, ( j * 20 ) + (ypos-16) + w, 0x80, 0x80, 0x80 ); @@ -128,6 +132,18 @@ int SNESROMSOffset() return 0; } +void strip_ext(char* inputstring, char* returnstring) +{ + char* loc_dot; + + strcpy (returnstring, inputstring); + loc_dot = strrchr(returnstring,'.'); + if (loc_dot != NULL) + *loc_dot = '\0'; // strip file extension + + return; +} + /** * FileSelector * @@ -146,7 +162,9 @@ FileSelector () int redraw = 1; int selectit = 0; float mag = 0; + float mag2 = 0; u16 ang = 0; + u16 ang2 = 0; int scroll_delay = 0; bool move_selection = 0; #define SCROLL_INITIAL_DELAY 15 @@ -165,7 +183,7 @@ FileSelector () #ifdef HW_RVL wp = WPAD_ButtonsDown (0); wh = WPAD_ButtonsHeld (0); - wpad_get_analogues(0, &mag, &ang); // get joystick info from wii expansions + wpad_get_analogues(0, &mag, &ang, &mag2, &ang2); // get joystick info from wii expansions #else wp = 0; wh = 0; @@ -183,27 +201,36 @@ FileSelector () selectit = 0; if (filelist[selection].flags) /*** This is directory ***/ { - if (loadtype == LOAD_SDC) + if (loadtype == LOAD_SDC || loadtype == LOAD_USB) { /* memorize last entries list, actual root directory and selection for next access */ - haveSDdir = 1; + if (loadtype == LOAD_SDC) + haveSDdir = 1; + else + haveUSBdir = 1; /* update current directory and set new entry list if directory has changed */ - int status = updateSDdirname(); + int status = updateFATdirname(); if (status == 1) // ok, open directory { - maxfiles = parseSDdirectory(); + maxfiles = parseFATdirectory(); if (!maxfiles) { WaitPrompt ((char*) "Error reading directory !"); haverom = 1; // quit SD menu - haveSDdir = 0; // reset everything at next access + if (loadtype == LOAD_SDC) // reset everything at next access + haveSDdir = 0; + else + haveUSBdir = 0; } } else if (status == -1) // directory name too long { haverom = 1; // quit SD menu - haveSDdir = 0; // reset everything at next access + if (loadtype == LOAD_SDC) // reset everything at next access + haveSDdir = 0; + else + haveUSBdir = 0; } } else @@ -224,6 +251,9 @@ FileSelector () { rootdir = filelist[selection].offset; rootdirlength = filelist[selection].length; + + /*** store the filename (used for sram/freeze naming) ***/ + strip_ext(filelist[selection].filename, Memory.ROMFilename); // store stripped filename in Memory.ROMFilename switch (loadtype) { @@ -234,11 +264,11 @@ FileSelector () case LOAD_SMB: /*** Load from SMB ***/ - ARAM_ROMSIZE = - LoadSMBFile (filelist[selection].filename, + ARAM_ROMSIZE = LoadSMBFile (filelist[selection].filename, filelist[selection].length); break; + case LOAD_USB: case LOAD_SDC: /*** Load from SD Card ***/ /* memorize last entries list, actual root directory and selection for next access */ @@ -391,7 +421,8 @@ OpenDVD () if (havedir == 0) { offset = selection = 0; /* reset file selector */ - haveSDdir = 0; /* prevent conflicts with SDCARD file selector */ + haveSDdir = 0; /* prevent conflicts with SDCARD, USB file selector */ + haveUSBdir = 0; if ((maxfiles = parsedirectory ())) { @@ -435,6 +466,53 @@ OpenSMB () return 0; } + +// is_mounted +// +// to check whether FAT media are detected. +bool fat_is_mounted(PARTITION_INTERFACE partition) { + char prefix[] = "fatX:/"; + prefix[3] = partition + '0'; + DIR_ITER *dir = diropen(prefix); + if (dir) { + dirclose(dir); + return true; + } + return false; +} + +void fat_enable_readahead_all() { + int i; + for (i=1; i <= 4; ++i) { + if (fat_is_mounted((PARTITION_INTERFACE)i)) fatEnableReadAhead((PARTITION_INTERFACE)i, 64, 128); + } +} + +bool fat_remount(PARTITION_INTERFACE partition) { + //ShowAction("remounting..."); + /* // removed to make usb work... + if (fat_is_mounted(partition)) + { + fatUnmount(partition); + } + */ + + fatMountNormalInterface(partition, 8); + fatSetDefaultInterface(partition); + //fatEnableReadAhead(partition, 64, 128); + + if (fat_is_mounted(partition)) + { + //ShowAction("remount successful."); + sleep(1); + return 1; + } else { + ShowAction("FAT mount failed."); + sleep(1); + return 0; + } +} + /** * OpenSD * @@ -447,18 +525,89 @@ OpenSD () char buf[50] = ""; loadtype = LOAD_SDC; + + /* + fatUnmount(PI_INTERNAL_SD); + fatMountNormalInterface(PI_INTERNAL_SD,8); + //fatEnableReadAhead(PI_INTERNAL_SD, 64, 128); + fatSetDefaultInterface(PI_INTERNAL_SD); + //chdir("fat0:/"); + */ +#ifdef HW_RVL + // only remount on wii + if (!fat_remount (PI_INTERNAL_SD)) + return 0; +#endif if (haveSDdir == 0) { /* don't mess with DVD entries */ - havedir = 0; // gamecube only + havedir = 0; + haveUSBdir = 0; /* change current dir to snes roms directory */ sprintf ( currSDdir, "%s/%s", ROOTSDDIR, SNESROMDIR ); /* Parse initial root directory and get entries list */ - if ((maxfiles = parseSDdirectory ())) + if ((maxfiles = parseFATdirectory ())) + { + /* Select an entry */ + return FileSelector (); + } + else + { + /* no entries found */ + sprintf (msg, "No Files Found!"); + WaitPrompt (msg); + return 0; + } + } + /* Retrieve previous entries list and made a new selection */ + else + return FileSelector (); + + return 0; +} + +/** + * OpenUSB + * + * Function to load from a USB device (wii only) + */ +int +OpenUSB () +{ + char msg[80]; + char buf[50] = ""; + + /* + //fatUnmount(PI_USBSTORAGE); + fatUnmount(PI_INTERNAL_SD); + //if(!fatMountNormalInterface(PI_USBSTORAGE,8)) + // return 0; + //fatEnableReadAhead(PI_USBSTORAGE, 64, 128); + fatSetDefaultInterface(PI_USBSTORAGE); + */ +#ifdef HW_RVL + // make compiler happy + if (!fat_remount (PI_USBSTORAGE)) + return 0; +#endif + + loadtype = LOAD_USB; + + if (haveUSBdir == 0) + { + /* don't mess with DVD, SDCARD entries */ + havedir = 0; + haveSDdir = 0; + + /* change current dir to snes roms directory */ + sprintf ( currSDdir, "%s/%s", ROOTSDDIR, SNESROMDIR ); + + /* Parse initial root directory and get entries list */ + if ((maxfiles = parseFATdirectory ())) { /* Select an entry */ return FileSelector (); diff --git a/source/ngc/filesel.h b/source/ngc/filesel.h index 0e72761..09185f9 100644 --- a/source/ngc/filesel.h +++ b/source/ngc/filesel.h @@ -13,11 +13,13 @@ int OpenDVD (); int OpenSMB (); int OpenSD (); +int OpenUSB (); #define LOAD_DVD 1 #define LOAD_SMB 2 #define LOAD_SDC 4 -#define ROOTSDDIR "fat:/" +#define LOAD_USB 8 +#define ROOTSDDIR "fat3:/" #define SNESROMDIR "snes9x/roms" #define SNESSAVEDIR "snes9x/saves" diff --git a/source/ngc/ftfont.cpp b/source/ngc/ftfont.cpp index 1c7c9f9..488878e 100644 --- a/source/ngc/ftfont.cpp +++ b/source/ngc/ftfont.cpp @@ -534,7 +534,7 @@ DrawMenu (char items[][20], char *title, int maxitems, int selected, int fontsiz if (title != NULL) DrawText (-1, 60, title); setfontsize (12); - DrawText (510, screenheight - 20, "Snes9x GX 003"); + DrawText (510, screenheight - 20, "Snes9x GX 004"); //#endif setfontsize (fontsize); // set font size @@ -579,7 +579,9 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize) int ret = 0; signed char a; float mag = 0; + float mag2 = 0; u16 ang = 0; + u16 ang2 = 0; //while (!(PAD_ButtonsDown (0) & PAD_BUTTON_B) && (quit == 0)) while (quit == 0) @@ -593,7 +595,7 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize) p = PAD_ButtonsDown (0); #ifdef HW_RVL wp = WPAD_ButtonsDown (0); - wpad_get_analogues(0, &mag, &ang); // get joystick info from wii expansions + wpad_get_analogues(0, &mag, &ang, &mag2, &ang2); // get joystick info from wii expansions #else wp = 0; #endif diff --git a/source/ngc/mcsave.cpp b/source/ngc/mcsave.cpp index f10843c..b783707 100644 --- a/source/ngc/mcsave.cpp +++ b/source/ngc/mcsave.cpp @@ -46,6 +46,8 @@ card_dir CardDir; card_file CardFile; card_stat CardStatus; +extern void uselessinquiry(); + /**************************************************************************** * Clear the savebuffer @@ -92,14 +94,16 @@ int MountCard(int cslot) int ret; int tries; - EXI_ProbeReset(); - - /*** Mount the card ***/ + + EXI_ProbeReset(); + + //Mount the card ret = CARD_Mount (cslot, SysArea, NULL); tries = 0; while ( tries < 3 && ret == CARD_ERROR_IOERROR ) { + EXI_ProbeReset (); if (cslot == CARD_SLOTA) WaitPrompt((char*) "Replug card in slot A!"); else @@ -113,6 +117,7 @@ int MountCard(int cslot) tries = 0; while ( tries < 5 && ret == CARD_ERROR_NOCARD ) { + EXI_ProbeReset (); ShowAction ((char*) "Mounting card..."); CARD_Unmount (cslot); usleep(500000); // wait half second @@ -125,6 +130,7 @@ int MountCard(int cslot) tries = 0; while ( tries < 5 && ret == CARD_ERROR_UNLOCKED ) { + EXI_ProbeReset (); ShowAction ((char*) "Waiting for unlock..."); usleep(500000); // wait half second ShowAction ((char*) ""); @@ -468,14 +474,31 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool void LoadSRAMFromMC (int slot, int silent) { - char filename[128]; + char filename[MAXPATHLEN]; + int offset = 0; ShowAction ((char*) "Loading SRAM from MC..."); - - /*** Build SRAM filename ***/ - sprintf (filename, "%s.srm", Memory.ROMName); - int offset = LoadBufferFromMC (savebuffer, slot, filename, silent); + // check for 'old' version of sram + sprintf (filename, "%s.srm", Memory.ROMName); // Build old SRAM filename + + offset = LoadBufferFromMC (savebuffer, slot, filename, silent); // load file + + if (offset > 0) // old sram found + { + if (WaitPromptChoice ((char*)"Old SRAM found. Convert and delete?", (char*)"Cancel", (char*)"Do it")) + { + decodesavedata (offset); + CARD_Delete (slot, filename); // delete old sram + SaveSRAMToMC (slot, silent); + } + } + // + + /*** Build SRAM filename ***/ + sprintf (filename, "%s.srm", Memory.ROMFilename); + + offset = LoadBufferFromMC (savebuffer, slot, filename, silent); if ( offset > 0 ) { @@ -504,7 +527,7 @@ SaveSRAMToMC (int slot, int silent) ShowAction ((char*) "Saving SRAM to MC..."); /*** Build SRAM filename ***/ - sprintf (filename, "%s.srm", Memory.ROMName); + sprintf (filename, "%s.srm", Memory.ROMFilename); datasize = prepareMCsavedata (); offset = SaveBufferToMC (savebuffer, slot, filename, datasize, silent); diff --git a/source/ngc/memfile.cpp b/source/ngc/memfile.cpp index 1c2041f..ac2617e 100644 --- a/source/ngc/memfile.cpp +++ b/source/ngc/memfile.cpp @@ -47,7 +47,7 @@ extern unsigned char savebuffer[]; static int bufoffset; static char membuffer[MEMBUFFER]; -char freezecomment[2][32] = { {"Snes9x GX 003 Freeze"}, {"Freeze"} }; +char freezecomment[2][32] = { {"Snes9x GX 004 Freeze"}, {"Freeze"} }; /** @@ -144,14 +144,14 @@ NGCFreezeGame (int where, bool8 silent) if (where == 4) { /*** Freeze to SMB ***/ - sprintf (filename, "/%s/%s.frz", SNESSAVEDIR, Memory.ROMName); + sprintf (filename, "/%s/%s.frz", SNESSAVEDIR, Memory.ROMFilename); } else if (where == 2 || where == 3) { /*** Freeze to SDCard in slot A or slot B ***/ #ifdef SDUSE_LFN - sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMName); + sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename); #else /*** Until we have LFN on SD ... ***/ sprintf (filename, "%s/%s/%08x.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32); @@ -160,7 +160,7 @@ NGCFreezeGame (int where, bool8 silent) else { /*** Freeze to MC in slot A or slot B ***/ - sprintf (filename, "%s.snz", Memory.ROMName); + sprintf (filename, "%s.snz", Memory.ROMFilename); } S9xSetSoundMute (TRUE); @@ -345,7 +345,7 @@ NGCUnfreezeGame (int from, bool8 silent) if (from == 4) { /*** From SMB ***/ - sprintf (filename, "\\%s\\%s.frz", SNESSAVEDIR, Memory.ROMName); + sprintf (filename, "\\%s\\%s.frz", SNESSAVEDIR, Memory.ROMFilename); ConnectSMB (); /*** Read the file into memory ***/ @@ -379,7 +379,7 @@ NGCUnfreezeGame (int from, bool8 silent) { #ifdef SDUSE_LFN - sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMName); + sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename); #else /*** From SDCard ***/ sprintf (filename, "%s/%s/%08x.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32); @@ -417,7 +417,7 @@ NGCUnfreezeGame (int from, bool8 silent) { ShowAction ((char*) "Loading freeze file..."); - sprintf (filename, "%s.snz", Memory.ROMName); + sprintf (filename, "%s.snz", Memory.ROMFilename); int ret = LoadBufferFromMC ( savebuffer, from, filename, silent ); if ( ret ) diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index 1dd5bf8..56fc2af 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -53,7 +53,7 @@ extern unsigned long ARAM_ROMSIZE; void Reboot() { -#ifdef __wii__ +#ifdef HW_RVL SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); #else #define SOFTRESET_ADR ((volatile u32*)0xCC003024) @@ -149,9 +149,9 @@ FreezeManager () /**************************************************************************** * Load Manager ****************************************************************************/ -int loadmancountwii = 2; +int loadmancountwii = 3; char loadmanwii[][20] = { "Load from SD", - "Return to previous" + "Load from USB", "Return to previous" }; int loadmancount = 4; char loadman[][20] = { "Load from SD", @@ -168,15 +168,32 @@ LoadManager () while (quit == 0) { - if ( isWii ) /* Wii menu */ - { - ret = RunMenu (loadmanwii, loadmancountwii, (char*)"Load Manager"); - if (ret >= loadmancountwii-1) - ret = loadmancount-1; - } - else /* Gamecube menu */ - ret = RunMenu (loadman, loadmancount, (char*)"Load Manager"); - +#ifdef HW_RVL + /* Wii menu */ + ret = RunMenu (loadmanwii, loadmancountwii, (char*)"Load Manager"); + + switch (ret) + { + case 0: + /*** Load from SD ***/ + quit = OpenSD (); + break; + + case 1: + /*** Load from USB ***/ + quit = OpenUSB (); + break; + + case -1: /*** Button B ***/ + case 2: + retval = 0; + quit = 1; + break; + } +#else + /* Gamecube menu */ + ret = RunMenu (loadman, loadmancount, (char*)"Load Manager"); + switch (ret) { case 0: @@ -199,7 +216,8 @@ LoadManager () retval = 0; quit = 1; break; - } + } +#endif } /*** @@ -313,12 +331,12 @@ SaveManager () /**************************************************************************** * Emulator Options ****************************************************************************/ -static int emuCount = 11; +static int emuCount = 12; static char emulatorOptions[][20] = { "Reverse Stereo OFF", "Interp. Sound ON", "Transparency ON", "FPS Display OFF", "MultiTap 5 OFF", "C-Stick Zoom OFF", "Auto Load OFF", "Auto Save OFF", "Verify MC Saves OFF", - "Save Prefs Now", "Return to previous" + "Video Filtering OFF", "Save Prefs Now", "Return to previous" }; void @@ -360,34 +378,32 @@ EmulatorOptions () sprintf (emulatorOptions[8], "Verify MC Saves %s", GCSettings.VerifySaves == true ? " ON" : "OFF"); + + sprintf (emulatorOptions[9], "Video Filtering %s", + GCSettings.render == true ? " ON" : "OFF"); ret = RunMenu (emulatorOptions, emuCount, (char*)"Emulator Options"); switch (ret) { case 0: - Settings.ReverseStereo = - (Settings.ReverseStereo == false ? true : false); + Settings.ReverseStereo ^= 1; break; case 1: - Settings.InterpolatedSound = - (Settings.InterpolatedSound == false ? true : false); + Settings.InterpolatedSound ^= 1; break; case 2: - Settings.Transparency = - (Settings.Transparency == false ? true : false); + Settings.Transparency ^= 1; break; case 3: - Settings.DisplayFrameRate = - (Settings.DisplayFrameRate == false ? true : false); + Settings.DisplayFrameRate ^= 1; break; case 4: - Settings.MultiPlayer5Master = - (Settings.MultiPlayer5Master == false ? true : false); + Settings.MultiPlayer5Master ^= 1; if (Settings.MultiPlayer5Master) { @@ -400,8 +416,7 @@ EmulatorOptions () break; case 5: - GCSettings.NGCZoom = - (GCSettings.NGCZoom == false ? true : false); + GCSettings.NGCZoom ^= 1; break; case 6: @@ -417,16 +432,19 @@ EmulatorOptions () break; case 8: - GCSettings.VerifySaves = - (GCSettings.VerifySaves == false ? true : false); + GCSettings.VerifySaves ^= 1; break; - + case 9: + GCSettings.render ^= 1; + break; + + case 10: quickSavePrefs(NOTSILENT); break; case -1: /*** Button B ***/ - case 10: + case 11: quit = 1; break; @@ -824,7 +842,7 @@ mainmenu () case 7: /*** Exit to Loader ***/ - #ifdef __wii__ + #ifdef HW_RVL exit(0); #else // gamecube if (psoid[0] == PSOSDLOADID) @@ -856,4 +874,5 @@ mainmenu () VIDEO_WaitVSync(); #endif + ReInitGCVideo(); // update video after reading settings } diff --git a/source/ngc/preferences.cpp b/source/ngc/preferences.cpp index f0fb9f4..e73999c 100644 --- a/source/ngc/preferences.cpp +++ b/source/ngc/preferences.cpp @@ -31,7 +31,7 @@ extern unsigned int wmpadmap[]; extern unsigned int ccpadmap[]; extern unsigned int ncpadmap[]; -#define PREFSVERSTRING "Snes9x GX 003 Prefs" +#define PREFSVERSTRING "Snes9x GX 004 Prefs" char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} }; diff --git a/source/ngc/s9xconfig.cpp b/source/ngc/s9xconfig.cpp index 206cb7d..9e7df32 100644 --- a/source/ngc/s9xconfig.cpp +++ b/source/ngc/s9xconfig.cpp @@ -203,8 +203,8 @@ DefaultSettings () /*** SDD1 - Star Ocean Returns -;) ***/ Settings.SDD1Pack = true; - GCSettings.AutoLoad = 0; - GCSettings.AutoSave = 0; + GCSettings.AutoLoad = 1; + GCSettings.AutoSave = 1; strncpy (GCSettings.gcip, GC_IP, 15); strncpy (GCSettings.gwip, GW_IP, 15); @@ -218,6 +218,7 @@ DefaultSettings () GCSettings.NGCZoom = 0; GCSettings.VerifySaves = 0; + GCSettings.render = 0; Settings.ForceNTSC = 0; Settings.ForcePAL = 0; diff --git a/source/ngc/sdload.cpp b/source/ngc/sdload.cpp index 243af1f..039982d 100644 --- a/source/ngc/sdload.cpp +++ b/source/ngc/sdload.cpp @@ -32,6 +32,8 @@ char currSDdir[MAXPATHLEN]; extern int offset; extern int selection; +extern int loadtype; + extern FILEENTRIES filelist[MAXFILES]; /*************************************************************************** @@ -62,9 +64,9 @@ static int FileSortCallback(const void *f1, const void *f2) } /*************************************************************************** - * Update SDCARD curent directory name + * Update FAT (sdcard, usb) curent directory name ***************************************************************************/ -int updateSDdirname() +int updateFATdirname() { int size=0; char *test; @@ -115,9 +117,9 @@ int updateSDdirname() } /*************************************************************************** - * Browse SDCARD subdirectories + * Browse FAT (sdcard, usb) subdirectories ***************************************************************************/ -int parseSDdirectory() { +int parseFATdirectory() { int nbfiles = 0; DIR_ITER *sddir; char filename[MAXPATHLEN]; @@ -130,7 +132,13 @@ int parseSDdirectory() { /* open the directory */ sddir = diropen(currSDdir); if (sddir == NULL) { - sprintf(currSDdir,"%s",ROOTSDDIR); // if we can't open the previous dir, open root dir + /*** if we can't open the previous dir, open root dir ***/ + if (loadtype == LOAD_USB) + sprintf(currSDdir,"fat4:/"); + else // LOAD_SDC + //sprintf(currSDdir,"%s",ROOTSDDIR); + sprintf(currSDdir,"fat3:/"); + sddir = diropen(currSDdir); WaitPrompt(msg); if (sddir == NULL) { @@ -164,7 +172,8 @@ int parseSDdirectory() { /**************************************************************************** * LoadSDFile ****************************************************************************/ -extern int haveSDdir; +extern bool haveSDdir; +extern bool haveUSBdir; int LoadSDFile (char *filename, int length) { @@ -183,9 +192,10 @@ LoadSDFile (char *filename, int length) { WaitPrompt((char*) "Maximum Filename Length reached !"); haveSDdir = 0; // reset everything before next access + haveUSBdir = 0; return -1; } - + handle = fopen (filepath, "rb"); if (handle > 0) { @@ -306,7 +316,7 @@ void SaveSRAMToSD (bool silent) ShowAction ((char*) "Saving SRAM to SD..."); #ifdef SDUSE_LFN - sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMName); + sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename); #else sprintf (filepath, "%s/%s/%08x.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32); #endif @@ -332,13 +342,29 @@ void SaveSRAMToSD (bool silent) void LoadSRAMFromSD (bool silent) { - char filepath[1024]; + char filepath[MAXPATHLEN]; int offset = 0; ShowAction ((char*) "Loading SRAM from SD..."); + + // check for 'old' version of sram + sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMName); // Build old SRAM filename + + offset = LoadBufferFromSD (filepath, silent); // load file + + if (offset > 0) // old sram found + { + if (WaitPromptChoice ((char*)"Old SRAM found. Convert and delete?", (char*)"Cancel", (char*)"Do it")) + { + decodesavedata (offset); + remove (filepath); // delete old sram + SaveSRAMToSD (silent); + } + } + // #ifdef SDUSE_LFN - sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMName); + sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename); #else sprintf (filepath, "%s/%s/%08x.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32); #endif diff --git a/source/ngc/sdload.h b/source/ngc/sdload.h index 28b236d..1332774 100644 --- a/source/ngc/sdload.h +++ b/source/ngc/sdload.h @@ -22,8 +22,8 @@ #include static int FileSortCallback(const void *f1, const void *f2); -int updateSDdirname(); -int parseSDdirectory(); +int updateFATdirname(); +int parseFATdirectory(); int LoadSDFile (char *filename, int length); void SaveSRAMToSD (bool silent); void LoadSRAMFromSD (bool silent); diff --git a/source/ngc/smbload.cpp b/source/ngc/smbload.cpp index 1fd55d8..15ce027 100644 --- a/source/ngc/smbload.cpp +++ b/source/ngc/smbload.cpp @@ -381,7 +381,7 @@ SaveSRAMToSMB (bool8 silent) int datasize; int offset; - sprintf (filepath, "%s\\%s.srm", SNESSAVEDIR, Memory.ROMName); + sprintf (filepath, "%s\\%s.srm", SNESSAVEDIR, Memory.ROMFilename); if (!silent) ShowAction ((char*) "Saving SRAM to SMB..."); @@ -409,7 +409,7 @@ LoadSRAMFromSMB (bool8 silent) char filepath[1024]; int offset; - sprintf (filepath, "%s\\%s.srm", SNESSAVEDIR, Memory.ROMName); + sprintf (filepath, "%s\\%s.srm", SNESSAVEDIR, Memory.ROMFilename); ShowAction ((char*) "Loading SRAM from SMB..."); offset = LoadBufferFromSMB (filepath, silent); diff --git a/source/ngc/smbload.h b/source/ngc/smbload.h index c4f1eba..8581259 100644 --- a/source/ngc/smbload.h +++ b/source/ngc/smbload.h @@ -11,7 +11,6 @@ ****************************************************************************/ #ifndef _NGCSMB_ - #define _NGCSMB_ void ConnectSMB (); @@ -36,5 +35,4 @@ typedef struct } SMBINFO; - #endif diff --git a/source/ngc/snes9xGX.cpp b/source/ngc/snes9xGX.cpp index d3ee5ad..e627718 100644 --- a/source/ngc/snes9xGX.cpp +++ b/source/ngc/snes9xGX.cpp @@ -198,6 +198,8 @@ extern int FrameTimer; extern long long prev; extern unsigned int timediffallowed; +extern void fat_enable_readahead_all(); + /**************************************************************************** * Controller Functions * @@ -298,7 +300,9 @@ decodepad (int pad) u32 jp, wp; float t; float mag = 0; + float mag2 = 0; u16 ang = 0; + u16 ang2 = 0; u32 exp_type; /*** Do analogue updates ***/ @@ -306,7 +310,7 @@ decodepad (int pad) y = PAD_StickY (pad); jp = PAD_ButtonsHeld (pad); #ifdef HW_RVL - exp_type = wpad_get_analogues(pad, &mag, &ang); // get joystick info from wii expansions + exp_type = wpad_get_analogues(pad, &mag, &ang, &mag2, &ang2); // get joystick info from wii expansions wp = WPAD_ButtonsHeld (pad); // wiimote #else wp = 0; @@ -438,7 +442,12 @@ NGCReportButtons () s8 gc_py = PAD_SubStickY (0); u16 gc_pb = PAD_ButtonsHeld (0); #ifdef HW_RVL - u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote + float mag1 = 0; + float mag2 = 0; + u16 ang1 = 0; + u16 ang2 = 0; + u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info + wpad_get_analogues(0, &mag1, &ang1, &mag2, &ang2); // get joystick info from wii expansions #endif /*** Check for video zoom ***/ @@ -446,9 +455,19 @@ NGCReportButtons () { if (gc_py < -18 || gc_py > 18) zoom ((float) gc_py / -18); +#ifdef HW_RVL + if ( mag2>0.2 && (ang2>340 || ang2<20) ) // classic rjs up + zoom ((float) mag2 / -0.2); + if ( mag2>0.2 && (ang2>160 && ang2<200) ) // classic rjs down + zoom ((float) mag2 / 0.2); +#endif } - Settings.TurboMode = (gc_px > 70); + Settings.TurboMode = ( (gc_px > 70) +#ifdef HW_RVL + || (mag2>JOY_THRESHOLD && ang2>75 && ang2<115) +#endif + ); // RIGHT on c-stick and on classic ctrlr right joystick /*** Check for menu: CStick left @@ -512,9 +531,9 @@ NGCReportButtons () * gets the analogue stick magnitude and angle values ( * from classic or nunchuk expansions) ****************************************************************************/ -u32 wpad_get_analogues(int pad, float* mag, u16* ang) +u32 wpad_get_analogues(int pad, float* mag1, u16* ang1, float* mag2, u16* ang2) { - *mag = *ang = 0; + *mag1 = *ang1 = *mag2 = *ang2 = 0; u32 exp_type = 0; #ifdef HW_RVL struct expansion_t exp; @@ -525,13 +544,15 @@ u32 wpad_get_analogues(int pad, float* mag, u16* ang) WPAD_Expansion(pad, &exp); // expansion connected. get info if (exp_type == WPAD_EXP_CLASSIC) { - *ang = exp.classic.ljs.ang; // left cc joystick - *mag = exp.classic.ljs.mag; + *ang1 = exp.classic.ljs.ang; // left cc joystick + *mag1 = exp.classic.ljs.mag; + *ang2 = exp.classic.rjs.ang; // right cc joystick + *mag2 = exp.classic.rjs.mag; } else if (exp_type == WPAD_EXP_NUNCHUK) { - *ang = exp.nunchuk.js.ang; // nunchuk joystick - *mag = exp.nunchuk.js.mag; + *ang1 = exp.nunchuk.js.ang; // nunchuk joystick + *mag1 = exp.nunchuk.js.mag; } } #endif @@ -677,8 +698,8 @@ main () /*** Initialize libFAT and SD cards ***/ fatInitDefault(); - //sdio_Startup(); // wii front sd - //sdgecko_initIODefault(); // sd gecko + //fatInit(8192, false); + //fat_enable_readahead_all(); /*** Initialize DVD subsystem ***/ diff --git a/source/ngc/snes9xGX.h b/source/ngc/snes9xGX.h index 828c6dd..fc1de8e 100644 --- a/source/ngc/snes9xGX.h +++ b/source/ngc/snes9xGX.h @@ -180,6 +180,8 @@ struct SGCSettings{ char smbshare[20]; bool8 NGCZoom; uint8 VerifySaves; + u16 render; // 0 - original, 1 - no AA + u32 QuickSaveSlot; // -1 Disabled - no prefs are loaded, 0 Memory card in slot A, 1 Memory card in slot B, 2 SD card in slot A, 3 SD card in slot B, 4 SMB share, 5 USB }; START_EXTERN_C @@ -187,7 +189,7 @@ extern struct SGCSettings GCSettings; extern unsigned short saveicon[1024]; extern bool8 isWii; -extern u32 wpad_get_analogues(int pad, float* mag, u16* ang); +extern u32 wpad_get_analogues(int pad, float* mag1, u16* ang1, float* mag2, u16* ang2); END_EXTERN_C #define JOY_THRESHOLD 0.70 // for wii (expansion) analogues diff --git a/source/ngc/sram.cpp b/source/ngc/sram.cpp index 3813703..5c2d9d4 100644 --- a/source/ngc/sram.cpp +++ b/source/ngc/sram.cpp @@ -28,7 +28,7 @@ extern int padcal; extern unsigned short gcpadmap[]; //extern unsigned short padmap[4]; -char sramcomment[2][32] = { {"Snes9x GX 003 SRAM"}, {"Savegame"} }; +char sramcomment[2][32] = { {"Snes9x GX 004 SRAM"}, {"Savegame"} }; /**************************************************************************** * Prepare Memory Card SRAM Save Data diff --git a/source/ngc/video.cpp b/source/ngc/video.cpp index c6e4c10..ffb0823 100644 --- a/source/ngc/video.cpp +++ b/source/ngc/video.cpp @@ -29,6 +29,7 @@ //#include "spc7110.h" //#include "controls.h" #include "aram.h" +#include "snes9xGX.h" //#include "video.h" /*** Snes9x GFX Buffer ***/ @@ -382,6 +383,28 @@ InitGCVideo () */ } +void ReInitGCVideo() +{ + Mtx p; + + GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); + GX_SetDispCopyYScale ((f32) vmode->xfbHeight / (f32) vmode->efbHeight); + GX_SetScissor (0, 0, vmode->fbWidth, vmode->efbHeight); + GX_SetDispCopySrc (0, 0, vmode->fbWidth, vmode->efbHeight); + GX_SetDispCopyDst (vmode->fbWidth, vmode->xfbHeight); + GX_SetCopyFilter (vmode->aa, vmode->sample_pattern, GCSettings.render ? GX_TRUE : GX_FALSE, + vmode->vfilter); + GX_SetFieldMode (vmode->field_rendering, + ((vmode->viHeight == + 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); + GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR); + +// GX_CopyDisp (xfb[whichfb], GX_TRUE); + + guPerspective (p, 60, 1.33F, 10.0F, 1000.0F); + GX_LoadProjectionMtx (p, GX_PERSPECTIVE); +} + /**************************************************************************** * Drawing screen ****************************************************************************/ @@ -420,85 +443,6 @@ setGFX () GFX.Pitch = 1024; } -#ifndef NGCC -#if 0 -/**************************************************************************** - * MakeTexture - * - * GC requires RGB565 colour tiles of 4 x 4 pixels. - * Ok, apparently the pipeline stalls waiting for the indexed register to update. - * Solution : Use R9 to mirror R4 - * - * THIS IS NOW UNUSED, BUT LEFT HERE SO I CAN TINKER -;) - ****************************************************************************/ -void -MakeTexture (char *src, /*** R3 Pointer to source ***/ - char *dst, /*** R4 Pointer to output ***/ - int width, /*** R5 Width ***/ - int height, /*** R6 Height ***/ - int w1, /*** R7 Worker ***/ - int w2, /*** R8 Worker ***/ - int w3, /*** R9 Worker ***/ - int w4) /*** R10 Worker ***/ -{ - /*** How many tiles per row ***/ - asm ("srwi 5,5,2"); /*** Width / 4 == Tiles ***/ - asm ("srwi 6,6,2"); /*** Height / 4 == Tiles ***/ - - asm ("mr 9,4"); /*** Mirror R4 ***/ - asm ("subi 4,4,8"); /*** Adjust R4 for index update ***/ - asm ("subi 9,9,4"); /*** Adjust R9 for index update ***/ - - /*** Outer loop ***/ - asm ("DoAllTiles:"); - - asm ("mtctr 5"); /*** Will loop for this number of tiles across ***/ - asm ("mr 8,3"); /*** Preserve current source position ***/ - - asm ("DoOneTile:"); - - /*** Store 4 Horizontal Pixels - ROW 1 ***/ - asm ("lwz 7,0(3)"); - asm ("stwu 7,8(4)"); - asm ("lwz 10,4(3)"); - asm ("stwu 10,8(9)"); - - /*** Store 4 Horizontal Pixels - ROW 2 ***/ - asm ("lwz 7,1024(3)"); - asm ("stwu 7,8(4)"); - asm ("lwz 10,1028(3)"); - asm ("stwu 10,8(9)"); - - /*** Store 4 Horizontal Pixels - ROW 3 ***/ - asm ("lwz 7,2048(3)"); - asm ("stwu 7,8(4)"); - asm ("lwz 10,2052(3)"); - asm ("stwu 10,8(9)"); - - /*** Store 4 Horizontal Pixels - ROW 4 ***/ - asm ("lwz 7,3072(3)"); - asm ("stwu 7,8(4)"); - asm ("lwz 10,3076(3)"); - asm ("stwu 10,8(9)"); - - /*** Move along 4 pixels ***/ - asm ("addi 3,3,8"); - - /*** Repeat for next tile ***/ - asm ("bdnz DoOneTile"); - - /*** Update R3 to be 4 rows down ***/ - asm ("mr 3,8"); - asm ("addi 3,3,4096"); - - /*** Decrement Outer Tile loop ***/ - asm ("subi 6,6,1"); - asm ("cmpwi 6,0"); - asm ("bne DoAllTiles"); - -} -#endif - /**************************************************************************** * MakeTexture * @@ -544,8 +488,6 @@ MakeTexture (const void *src, void *dst, s32 width, s32 height) "r" (height)); } -#endif - /**************************************************************************** * Update Video ****************************************************************************/ @@ -584,46 +526,11 @@ update_video (int width, int height) GX_SetTevOp (GX_TEVSTAGE0, GX_DECAL); GX_SetTevOrder (GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); -#ifdef NGCC - int h, w; - int *dst = (int *) texturemem; - int *src = (int *) GFX.Screen; - int hpos; - /*** Pitch for screen, regardless of size is always the same ***/ - for (h = 0; h < vheight; h += 4) - { - - for (w = 0; w < (vwidth >> 1); w += 2) - { - - hpos = w; - *dst++ = src[hpos++]; - *dst++ = src[hpos]; - - hpos = w + 256; - *dst++ = src[hpos++]; - *dst++ = src[hpos]; - - hpos = w + 512; - *dst++ = src[hpos++]; - *dst++ = src[hpos]; - - hpos = w + 768; - *dst++ = src[hpos++]; - *dst++ = src[hpos]; - - } - - src += GFX.Pitch; - - } - -#else MakeTexture ((char *) GFX.Screen, (char *) texturemem, vwidth, vheight); -#endif + DCFlushRange (texturemem, TEX_WIDTH * TEX_HEIGHT * 2); diff --git a/source/ngc/video.h b/source/ngc/video.h index 8224be8..2065dc2 100644 --- a/source/ngc/video.h +++ b/source/ngc/video.h @@ -17,6 +17,7 @@ #include "snes9x.h" void InitGCVideo (); +void ReInitGCVideo(); void clearscreen (int colour = COLOR_WHITE); void showscreen (); void setGFX ();