diff --git a/genplus-gx/gx/config.c b/genplus-gx/gx/config.c deleted file mode 100644 index d13b15bbb5..0000000000 --- a/genplus-gx/gx/config.c +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************** - * config.c - * - * Genesis Plus GX configuration file support - * - * Copyright Eke-Eke (2007-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "gui.h" -#include "file_load.h" - -static int config_load(void) -{ - /* open configuration file */ - char fname[MAXPATHLEN]; - sprintf (fname, "%s/config.ini", DEFAULT_PATH); - FILE *fp = fopen(fname, "rb"); - if (fp) - { - /* check file size */ - fseek(fp, 0, SEEK_END); - if (ftell(fp) != sizeof(config)) - { - fclose(fp); - return 0; - } - - /* check version */ - char version[16]; - fseek(fp, 0, SEEK_SET); - fread(version, 16, 1, fp); - if (memcmp(version,CONFIG_VERSION,16)) - { - fclose(fp); - return 0; - } - - /* read file */ - fseek(fp, 0, SEEK_SET); - fread(&config, sizeof(config), 1, fp); - fclose(fp); - return 1; - } - return 0; -} - -void config_save(void) -{ - /* open configuration file */ - char fname[MAXPATHLEN]; - sprintf (fname, "%s/config.ini", DEFAULT_PATH); - FILE *fp = fopen(fname, "wb"); - if (fp) - { - /* write file */ - fwrite(&config, sizeof(config), 1, fp); - fclose(fp); - } -} - -void config_default(void) -{ - /* version TAG */ - strncpy(config.version,CONFIG_VERSION,16); - - /* sound options */ - config.psg_preamp = 150; - config.fm_preamp = 100; - config.hq_fm = 1; - config.psgBoostNoise = 1; - config.filter = 1; - config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */ - config.low_freq = 880; - config.high_freq = 5000; - config.lg = 1.0; - config.mg = 1.0; - config.hg = 1.0; - config.dac_bits = 14; - config.ym2413 = 2; /* AUTO */ - config.mono = 0; - - /* system options */ - config.system = 0; /* AUTO */ - config.region_detect = 0; /* AUTO */ - config.vdp_mode = 0; /* AUTO */ - config.master_clock = 0; /* AUTO */ - config.force_dtack = 0; - config.addr_error = 1; - config.bios = 0; - config.lock_on = 0; - config.hot_swap = 0; - - /* video options */ - config.xshift = 0; - config.yshift = 0; - config.xscale = 0; - config.yscale = 0; - config.aspect = 1; - config.overscan = 3; /* FULL */ - config.gg_extra = 0; - config.ntsc = 0; - config.vsync = 1; /* AUTO */ - config.bilinear = 0; - config.vfilter = 1; - - if (VIDEO_HaveComponentCable()) - { - config.render = 2; - } - else - { - config.render = 0; - } - - switch (vmode->viTVMode >> 2) - { - case VI_PAL: - config.tv_mode = 1; /* 50hz only */ - break; - - case VI_EURGB60: - config.tv_mode = 2; /* 50/60hz */ - break; - - default: - config.tv_mode = 0; /* 60hz only */ - break; - } - -#ifdef HW_RVL - config.trap = 0; - config.gamma = VI_GM_1_0 / 10.0; -#endif - - /* controllers options */ - config.gun_cursor[0] = 1; - config.gun_cursor[1] = 1; - config.invert_mouse = 0; - - /* on-screen options */ - config.cd_leds = 0; - config.fps = 0; - - /* menu options */ - config.autoload = 0; - config.autocheat = 0; -#ifdef HW_RVL - config.s_auto = 1; -#else - config.s_auto = 0; - config.v_prog = 1; -#endif - config.s_default = 1; - config.s_device = 0; - config.l_device = 0; - config.bg_overlay = 0; - config.screen_w = 658; - config.bgm_volume = 100.0; - config.sfx_volume = 100.0; - - /* default ROM directories */ -#ifdef HW_RVL - sprintf (config.lastdir[0][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[1][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[2][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[3][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[4][TYPE_SD], "sd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[0][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[1][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[2][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[3][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[4][TYPE_USB], "usb:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); -#else - sprintf (config.lastdir[0][TYPE_SD], "%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[1][TYPE_SD], "%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[2][TYPE_SD], "%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[3][TYPE_SD], "%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[4][TYPE_SD], "%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[0][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[1][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[2][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[3][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); - sprintf (config.lastdir[4][TYPE_DVD], "dvd:%s/roms/", DEFAULT_PATH); -#endif - - /* try to restore user config */ - int loaded = config_load(); - -#ifndef HW_RVL - /* check if component cable was detected */ - if (VIDEO_HaveComponentCable()) - { - /* when component cable is detected, libogc automatically enables progressive mode */ - /* as preferred video mode but it could still be used on TV not supporting 480p/576p */ - PAD_ScanPads(); - - /* detect progressive mode switch requests */ - if (PAD_ButtonsHeld(0) & PAD_BUTTON_B) - { - /* swap progressive mode enable flag */ - config.v_prog ^= 1; - - /* play some sound to inform user */ - ASND_Pause(0); - int voice = ASND_GetFirstUnusedVoice(); - ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL); - sleep (2); - ASND_Pause(1); - } - - /* check if progressive mode should be disabled */ - if (!config.v_prog) - { - /* switch menu video mode to interlaced */ - vmode->viTVMode = (vmode->viTVMode & ~3) | VI_INTERLACE; - VIDEO_Configure (vmode); - VIDEO_Flush(); - VIDEO_WaitVSync(); - VIDEO_WaitVSync(); - } - } -#endif - - /* inform user if default config is used */ - if (!loaded) - { - GUI_WaitPrompt("Warning","Default Settings restored"); - gx_input_SetDefault(); - } - - /* default emulated inputs */ - input.system[0] = SYSTEM_MD_GAMEPAD; - input.system[1] = (config.input[1].device != -1) ? SYSTEM_MD_GAMEPAD : NO_SYSTEM; - input_init(); -} diff --git a/genplus-gx/gx/config.h b/genplus-gx/gx/config.h deleted file mode 100644 index 59b773e1ff..0000000000 --- a/genplus-gx/gx/config.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * config.c - * - * Genesis Plus GX configuration file support - * - * Copyright Eke-Eke (2007-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -#define CONFIG_VERSION "GENPLUS-GX 1.7.5" - -/**************************************************************************** - * Config Option - * - ****************************************************************************/ -typedef struct -{ - char version[16]; - uint8 hq_fm; - uint8 filter; - uint8 psgBoostNoise; - uint8 dac_bits; - uint8 ym2413; - uint8 mono; - int16 psg_preamp; - int16 fm_preamp; - uint32 lp_range; - int16 low_freq; - int16 high_freq; - int16 lg; - int16 mg; - int16 hg; - uint8 system; - uint8 region_detect; - uint8 master_clock; - uint8 vdp_mode; - uint8 force_dtack; - uint8 addr_error; - uint8 bios; - uint8 lock_on; - uint8 hot_swap; - uint8 invert_mouse; - uint8 gun_cursor[2]; - uint8 overscan; - uint8 gg_extra; - uint8 ntsc; - uint8 vsync; - uint8 render; - uint8 tv_mode; - uint8 bilinear; - uint8 vfilter; - uint8 aspect; - int16 xshift; - int16 yshift; - int16 xscale; - int16 yscale; -#ifdef HW_RVL - uint32 trap; - float gamma; -#else - uint8 v_prog; -#endif - t_input_config input[MAX_INPUTS]; - uint16 pad_keymap[4][MAX_KEYS+1]; -#ifdef HW_RVL - uint32 wpad_keymap[4*3][MAX_KEYS]; -#endif - uint8 autoload; - uint8 autocheat; - uint8 s_auto; - uint8 s_default; - uint8 s_device; - uint8 l_device; - uint8 bg_overlay; - uint8 cd_leds; - uint8 fps; - int16 screen_w; - float bgm_volume; - float sfx_volume; - char lastdir[FILETYPE_MAX][TYPE_RECENT][MAXPATHLEN]; -} t_config; - -/* Global data */ -t_config config; - - -extern void config_save(void); -extern void config_default(void); - - -#endif /* _CONFIG_H_ */ - diff --git a/genplus-gx/gx/fileio/file_load.c b/genplus-gx/gx/fileio/file_load.c deleted file mode 100644 index e896c4e312..0000000000 --- a/genplus-gx/gx/fileio/file_load.c +++ /dev/null @@ -1,464 +0,0 @@ -/* - * file_load.c - * - * ROM File loading support - * - * Copyright Eke-Eke (2008-2012) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "file_load.h" -#include "gui.h" -#include "history.h" -#include "filesel.h" -#include "file_slot.h" - -#include -#ifdef HW_RVL -#include -#else -#include -#endif - -char rom_filename[256]; - -/* device root directories */ -#ifdef HW_RVL -static const char rootdir[TYPE_RECENT][10] = {"sd:/","usb:/","dvd:/"}; -#else -static const char rootdir[TYPE_RECENT][10] = {"/","dvd:/"}; -#endif - -/* DVD interface */ -#ifdef HW_RVL -static const DISC_INTERFACE* dvd = &__io_wiidvd; -#else -static const DISC_INTERFACE* dvd = &__io_gcdvd; -#endif - -/* current directory */ -static char *fileDir; - -/* current device */ -static int deviceType = -1; - -/* current file type */ -static int fileType = -1; - -/* DVD status flag */ -static u8 dvd_mounted = 0; - -/*************************************************************************** - * MountDVD - * - * return 0 on error, 1 on success - ***************************************************************************/ -static int MountDVD(void) -{ - GUI_MsgBoxOpen("Information", "Mounting DVD ...",1); - - /* initialize DVD interface if needed */ -#ifdef HW_RVL - DI_Init(); -#else - DVD_Init(); -#endif - - /* check if DVD is already mounted */ - if (dvd_mounted) - { - /* unmount DVD */ - ISO9660_Unmount("dvd:"); - dvd_mounted = 0; - } - - /* check if disc is found */ - if(!dvd->isInserted()) - { - GUI_WaitPrompt("Error","No Disc inserted !"); - return 0; - } - - /* mount DVD */ - if(!ISO9660_Mount("dvd",dvd)) - { - GUI_WaitPrompt("Error","Disc can not be read !"); - return 0; - } - - /* DVD is mounted */ - dvd_mounted = 1; - - GUI_MsgBoxClose(); - return 1; -} - -/*************************************************************************** - * FileSortCallback (thanks to Marty Disibio) - * - * Quick sort callback to sort file entries with the following order: - * . - * .. - * - * - ***************************************************************************/ -static int FileSortCallback(const void *f1, const void *f2) -{ - /* Special case for implicit directories */ - if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.') - { - if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; } - if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; } - if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; } - if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; } - } - - /* If one is a file and one is a directory the directory is first. */ - if(((FILEENTRIES *)f1)->flags && !((FILEENTRIES *)f2)->flags) return -1; - if(!((FILEENTRIES *)f1)->flags && ((FILEENTRIES *)f2)->flags) return 1; - - return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename); -} - -/*************************************************************************** - * UpdateDirectory - * - * Update current browser directory - * return zero if going up while in root - * when going up, return previous dir name - ***************************************************************************/ -int UpdateDirectory(bool go_up, char *dirname) -{ - /* go up to parent directory */ - if (go_up) - { - /* special case */ - if (deviceType == TYPE_RECENT) return 0; - - /* check if we already are at root directory */ - if (!strcmp(rootdir[deviceType], (const char *)fileDir)) return 0; - - int size=0; - char temp[MAXPATHLEN]; - - /* determine last folder name length */ - strcpy(temp, fileDir); - char *test= strtok(temp,"/"); - while (test != NULL) - { - size = strlen(test); - strncpy(dirname,test,size); - dirname[size] = 0; - test = strtok(NULL,"/"); - } - - /* remove last folder from path */ - size = strlen(fileDir) - size; - fileDir[size - 1] = 0; - } - else - { - /* by default, simply append folder name */ - sprintf(fileDir, "%s%s/",fileDir, dirname); - } - - return 1; -} - -/*************************************************************************** - * ParseDirectory - * - * List files into one directory - ***************************************************************************/ -int ParseDirectory(void) -{ - int nbfiles = 0; - - /* open directory */ - DIR *dir = opendir(fileDir); - if (dir == NULL) - { - return -1; - } - - struct dirent *entry = readdir(dir); - - /* list entries */ - while ((entry != NULL)&& (nbfiles < MAXFILES)) - { - /* filter entries */ - if ((entry->d_name[0] != '.') - && strncasecmp(".wav", &entry->d_name[strlen(entry->d_name) - 4], 4) - && strncasecmp(".ogg", &entry->d_name[strlen(entry->d_name) - 4], 4) - && strncasecmp(".mp3", &entry->d_name[strlen(entry->d_name) - 4], 4)) - { - memset(&filelist[nbfiles], 0, sizeof (FILEENTRIES)); - sprintf(filelist[nbfiles].filename,"%s",entry->d_name); - if (entry->d_type == DT_DIR) - { - filelist[nbfiles].flags = 1; - } - nbfiles++; - } - - /* next entry */ - entry = readdir(dir); - } - - /* close directory */ - closedir(dir); - - /* Sort the file list */ - qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback); - - return nbfiles; -} - -/**************************************************************************** - * LoadFile - * - * This function will load a game file into the ROM buffer. - * This functions return the actual size of data copied into the buffer - * - ****************************************************************************/ -int LoadFile(int selection) -{ - int size, cd_mode1, filetype; - char filename[MAXPATHLEN]; - - /* file path */ - char *filepath = (deviceType == TYPE_RECENT) ? history.entries[selection].filepath : fileDir; - - /* full filename */ - sprintf(filename, "%s%s", filepath, filelist[selection].filename); - - /* DVD hot swap */ - if (!strncmp(filepath, rootdir[TYPE_DVD], strlen(rootdir[TYPE_DVD]))) - { - /* Check if file is still accessible */ - struct stat filestat; - if(stat(filename, &filestat) != 0) - { - /* If not, try to mount DVD */ - if (!MountDVD()) return 0; - } - } - - /* open message box */ - GUI_MsgBoxOpen("Information", "Loading game...", 1); - - /* no cartridge or CD game loaded */ - size = cd_mode1 = 0; - - /* check if virtual CD tray was open */ - if ((system_hw == SYSTEM_MCD) && (cdd.status == CD_OPEN)) - { - /* swap CD image file in (without changing region, system,...) */ - size = cdd_load(filename, (char *)(cdc.ram)); - - /* check if a cartridge is currently loaded */ - if (scd.cartridge.boot) - { - /* CD Mode 1 */ - cd_mode1 = size; - } - else - { - /* update game informations from CD image file header */ - getrominfo((char *)(cdc.ram)); - } - } - - /* no CD image file loaded */ - if (!size) - { - /* close CD tray to force system reset */ - cdd.status = NO_DISC; - - /* load game file */ - size = load_rom(filename); - } - - if (size > 0) - { - /* do not update game basename if a CD was loaded with a cartridge (Mode 1) */ - if (cd_mode1) - { - /* add CD image file to history list */ - filetype = 1; - } - else - { - /* auto-save previous game state */ - slot_autosave(config.s_default,config.s_device); - - /* update game basename (for screenshot, save & cheat files) */ - if (romtype & SYSTEM_SMS) - { - /* Master System ROM file */ - filetype = 2; - sprintf(rom_filename,"ms/%s",filelist[selection].filename); - } - else if (romtype & SYSTEM_GG) - { - /* Game Gear ROM file */ - filetype = 3; - sprintf(rom_filename,"gg/%s",filelist[selection].filename); - } - else if (romtype == SYSTEM_SG) - { - /* SG-1000 ROM file */ - filetype = 4; - sprintf(rom_filename,"sg/%s",filelist[selection].filename); - } - else if (romtype == SYSTEM_MCD) - { - /* CD image file */ - filetype = 1; - sprintf(rom_filename,"cd/%s",filelist[selection].filename); - } - else - { - /* by default, Genesis ROM file */ - filetype = 0; - sprintf(rom_filename,"md/%s",filelist[selection].filename); - } - - /* remove file extension */ - int i = strlen(rom_filename) - 1; - while ((i > 0) && (rom_filename[i] != '.')) i--; - if (i > 0) rom_filename[i] = 0; - } - - /* add/move the file to the top of the history. */ - history_add_file(filepath, filelist[selection].filename, filetype); - - /* recent file list may have changed */ - if (deviceType == TYPE_RECENT) deviceType = -1; - - /* close message box */ - GUI_MsgBoxClose(); - - /* valid image has been loaded */ - return 1; - } - - GUI_WaitPrompt("Error", "Unable to load game"); - return 0; -} - -/**************************************************************************** - * OpenDir - * - * Function to open a directory and load ROM file list. - ****************************************************************************/ -int OpenDirectory(int device, int type) -{ - int max = 0; - - if (device == TYPE_RECENT) - { - /* fetch history list */ - int i; - for(i=0; i < NUM_HISTORY_ENTRIES; i++) - { - if(history.entries[i].filepath[0] > 0) - { - filelist[i].flags = 0; - strncpy(filelist[i].filename,history.entries[i].filename, MAXJOLIET-1); - filelist[i].filename[MAXJOLIET-1] = '\0'; - max++; - } - else - { - /* Found the end of the list. */ - break; - } - } - } - else - { - /* only DVD hot swap is supported */ - if (device == TYPE_DVD) - { - /* try to access root directory */ - DIR *dir = opendir(rootdir[TYPE_DVD]); - if (dir == NULL) - { - /* mount DVD */ - if (!MountDVD()) return 0; - deviceType = -1; - } - else - { - closedir(dir); - } - } - - /* parse last directory */ - fileDir = config.lastdir[type][device]; - max = ParseDirectory(); - if (max <= 0) - { - /* parse root directory */ - strcpy(fileDir, rootdir[device]); - max = ParseDirectory(); - if (max < 0) - { - GUI_WaitPrompt("Error","Unable to open directory !"); - return 0; - } - deviceType = -1; - } - } - - if (max == 0) - { - GUI_WaitPrompt("Error","No files found !"); - return 0; - } - - /* check if device or file type has changed */ - if ((device != deviceType) || (type != fileType)) - { - /* reset current types */ - deviceType = device; - fileType = type; - - /* reset File selector */ - ClearSelector(max); - } - - return 1; -} diff --git a/genplus-gx/gx/fileio/file_load.h b/genplus-gx/gx/fileio/file_load.h deleted file mode 100644 index fca2aba1c3..0000000000 --- a/genplus-gx/gx/fileio/file_load.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * file_load.c - * - * ROM File loading support - * - * Copyright Eke-Eke (2008-2012) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _FILE_FAT_H -#define _FILE_FAT_H - -/* suppported load devices */ -typedef enum -{ - TYPE_SD = 0, -#ifdef HW_RVL - TYPE_USB, -#endif - TYPE_DVD, - TYPE_RECENT -}DEVTYPES; - -/* supported file types */ -typedef enum -{ - FILETYPE_MD = 0, - FILETYPE_CD, - FILETYPE_MS, - FILETYPE_GG, - FILETYPE_SG, - FILETYPE_MAX -}FILETYPES; - -extern int OpenDirectory(int device, int type); -extern int UpdateDirectory(bool go_up, char *filename); -extern int ParseDirectory(void); -extern int LoadFile(int selection); - -extern char rom_filename[256]; - -#endif diff --git a/genplus-gx/gx/fileio/file_slot.c b/genplus-gx/gx/fileio/file_slot.c deleted file mode 100644 index 45d117f70d..0000000000 --- a/genplus-gx/gx/fileio/file_slot.c +++ /dev/null @@ -1,830 +0,0 @@ -/* - * file_slot.c - * - * FAT and Memory Card SRAM/State slots managment - * - * Copyright Eke-Eke (2008-2012), based on original code from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "file_slot.h" -#include "file_load.h" -#include "gui.h" -#include "filesel.h" -#include "saveicon.h" - -/** - * libOGC CARD System Work Area - */ -static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32); - -/* Mega CD backup RAM stuff */ -static u32 brm_crc[2]; -static char brm_filename[3][32] = {CD_BRAM_JP, CD_BRAM_EU, CD_BRAM_US}; -static u8 brm_format[0x40] = -{ - 0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x00,0x00,0x00,0x00,0x40, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x53,0x45,0x47,0x41,0x5f,0x43,0x44,0x5f,0x52,0x4f,0x4d,0x00,0x01,0x00,0x00,0x00, - 0x52,0x41,0x4d,0x5f,0x43,0x41,0x52,0x54,0x52,0x49,0x44,0x47,0x45,0x5f,0x5f,0x5f -}; - -/**************************************************************************** - * CardMount - * - * libOGC provides the CARD_Mount function, and it should be all you need. - * However, experience with previous emulators has taught me that you are - * better off doing a little bit more than that! - * - *****************************************************************************/ -static int CardMount(int slot) -{ - int tries = 0; -#ifdef HW_RVL - *(unsigned long *) (0xCD006800) |= 1 << 13; /*** Disable Encryption ***/ -#else - *(unsigned long *) (0xCC006800) |= 1 << 13; /*** Disable Encryption ***/ -#endif - while (tries < 10) - { - VIDEO_WaitVSync (); - if (CARD_Mount(slot, SysArea, NULL) == CARD_ERROR_READY) - return 1; - else - EXI_ProbeReset (); - tries++; - } - return 0; -} - -/**************************************************************************** - * Slot Management - * - * - ****************************************************************************/ -void slot_autoload(int slot, int device) -{ - /* Mega CD backup RAM specific */ - if (!slot && (system_hw == SYSTEM_MCD)) - { - /* automatically load internal backup RAM */ - FILE *fp = fopen(brm_filename[((region_code ^ 0x40) >> 6) - 1], "rb"); - if (fp != NULL) - { - fread(scd.bram, 0x2000, 1, fp); - fclose(fp); - - /* update CRC */ - brm_crc[0] = crc32(0, scd.bram, 0x2000); - } - else - { - /* force internal backup RAM format (does not use previous region backup RAM) */ - scd.bram[0x1fff] = 0; - } - - /* check if internal backup RAM is correctly formatted */ - if (memcmp(scd.bram + 0x2000 - 0x20, brm_format + 0x20, 0x20)) - { - /* clear internal backup RAM */ - memset(scd.bram, 0x00, 0x2000 - 0x40); - - /* internal Backup RAM size fields */ - brm_format[0x10] = brm_format[0x12] = brm_format[0x14] = brm_format[0x16] = 0x00; - brm_format[0x11] = brm_format[0x13] = brm_format[0x15] = brm_format[0x17] = (sizeof(scd.bram) / 64) - 3; - - /* format internal backup RAM */ - memcpy(scd.bram + 0x2000 - 0x40, brm_format, 0x40); - - /* clear CRC to force file saving (in case previous region backup RAM was also formatted) */ - brm_crc[0] = 0; - } - - /* automatically load cartridge backup RAM (if enabled) */ - if (scd.cartridge.id) - { - fp = fopen(CART_BRAM, "rb"); - if (fp != NULL) - { - int filesize = scd.cartridge.mask + 1; - int done = 0; - - /* Read into buffer (2k blocks) */ - while (filesize > CHUNKSIZE) - { - fread(scd.cartridge.area + done, CHUNKSIZE, 1, fp); - done += CHUNKSIZE; - filesize -= CHUNKSIZE; - } - - /* Read remaining bytes */ - if (filesize) - { - fread(scd.cartridge.area + done, filesize, 1, fp); - } - - /* close file */ - fclose(fp); - - /* update CRC */ - brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1); - } - - /* check if cartridge backup RAM is correctly formatted */ - if (memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20)) - { - /* clear cartridge backup RAM */ - memset(scd.cartridge.area, 0x00, scd.cartridge.mask + 1); - - /* Cartridge Backup RAM size fields */ - brm_format[0x10] = brm_format[0x12] = brm_format[0x14] = brm_format[0x16] = (((scd.cartridge.mask + 1) / 64) - 3) >> 8; - brm_format[0x11] = brm_format[0x13] = brm_format[0x15] = brm_format[0x17] = (((scd.cartridge.mask + 1) / 64) - 3) & 0xff; - - /* format cartridge backup RAM */ - memcpy(scd.cartridge.area + scd.cartridge.mask + 1 - 0x40, brm_format, 0x40); - } - } - } - - /* configurable SRAM & State auto-saving */ - if ((slot && !(config.s_auto & 2)) || (!slot && !(config.s_auto & 1))) - { - return; - } - - if (strlen(rom_filename)) - { - SILENT = 1; - slot_load(slot, device); - SILENT = 0; - } -} - -void slot_autosave(int slot, int device) -{ - /* Mega CD backup RAM specific */ - if (!slot && (system_hw == SYSTEM_MCD)) - { - /* verify that internal backup RAM has been modified */ - if (crc32(0, scd.bram, 0x2000) != brm_crc[0]) - { - /* check if it is correctly formatted before saving */ - if (!memcmp(scd.bram + 0x2000 - 0x20, brm_format + 0x20, 0x20)) - { - FILE *fp = fopen(brm_filename[((region_code ^ 0x40) >> 6) - 1], "wb"); - if (fp != NULL) - { - fwrite(scd.bram, 0x2000, 1, fp); - fclose(fp); - - /* update CRC */ - brm_crc[0] = crc32(0, scd.bram, 0x2000); - } - } - } - - /* verify that cartridge backup RAM has been modified */ - if (scd.cartridge.id && (crc32(0, scd.cartridge.area, scd.cartridge.mask + 1) != brm_crc[1])) - { - /* check if it is correctly formatted before saving */ - if (!memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20)) - { - FILE *fp = fopen(CART_BRAM, "wb"); - if (fp != NULL) - { - int filesize = scd.cartridge.mask + 1; - int done = 0; - - /* Write to file (2k blocks) */ - while (filesize > CHUNKSIZE) - { - fwrite(scd.cartridge.area + done, CHUNKSIZE, 1, fp); - done += CHUNKSIZE; - filesize -= CHUNKSIZE; - } - - /* Write remaining bytes */ - if (filesize) - { - fwrite(scd.cartridge.area + done, filesize, 1, fp); - } - - /* Close file */ - fclose(fp); - - /* update CRC */ - brm_crc[1] = crc32(0, scd.cartridge.area, scd.cartridge.mask + 1); - } - } - } - } - - /* configurable SRAM & State auto-saving */ - if ((slot && !(config.s_auto & 2)) || (!slot && !(config.s_auto & 1))) - { - return; - } - - if (strlen(rom_filename)) - { - SILENT = 1; - slot_save(slot, device); - SILENT = 0; - } -} - -void slot_autodetect(int slot, int device, t_slot *ptr) -{ - if (!ptr) return; - - char filename[MAXPATHLEN]; - memset(ptr,0,sizeof(t_slot)); - - if (!device) - { - /* FAT support */ - if (slot > 0) - { - sprintf (filename,"%s/saves/%s.gp%d", DEFAULT_PATH, rom_filename, slot - 1); - } - else - { - sprintf (filename,"%s/saves/%s.srm", DEFAULT_PATH, rom_filename); - } - - /* Open file */ - FILE *fp = fopen(filename, "rb"); - if (fp) - { - /* Retrieve date & close */ - struct stat filestat; - stat(filename, &filestat); - struct tm *timeinfo = localtime(&filestat.st_mtime); - ptr->year = 1900 + timeinfo->tm_year; - ptr->month = timeinfo->tm_mon; - ptr->day = timeinfo->tm_mday; - ptr->hour = timeinfo->tm_hour; - ptr->min = timeinfo->tm_min; - fclose(fp); - ptr->valid = 1; - } - } - else - { - /* Memory Card support */ - if (slot > 0) - sprintf(filename,"MD-%04X.gp%d", rominfo.realchecksum, slot - 1); - else - sprintf(filename,"MD-%04X.srm", rominfo.realchecksum); - - /* Initialise the CARD system */ - memset(&SysArea, 0, CARD_WORKAREA); - CARD_Init("GENP", "00"); - - /* CARD slot */ - device--; - - /* Mount CARD */ - if (CardMount(device)) - { - /* Open file */ - card_file CardFile; - if (CARD_Open(device, filename, &CardFile) == CARD_ERROR_READY) - { - /* Retrieve date & close */ - card_stat CardStatus; - CARD_GetStatus(device, CardFile.filenum, &CardStatus); - time_t rawtime = CardStatus.time; - struct tm *timeinfo = localtime(&rawtime); - ptr->year = 1900 + timeinfo->tm_year; - ptr->month = timeinfo->tm_mon; - ptr->day = timeinfo->tm_mday; - ptr->hour = timeinfo->tm_hour; - ptr->min = timeinfo->tm_min; - CARD_Close(&CardFile); - ptr->valid = 1; - } - CARD_Unmount(device); - } - } -} - -int slot_delete(int slot, int device) -{ - char filename[MAXPATHLEN]; - int ret = 0; - - if (!device) - { - /* FAT support */ - if (slot > 0) - { - /* remove screenshot */ - sprintf(filename,"%s/saves/%s__%d.png", DEFAULT_PATH, rom_filename, slot - 1); - remove(filename); - - sprintf (filename,"%s/saves/%s.gp%d", DEFAULT_PATH, rom_filename, slot - 1); - } - else - { - sprintf (filename,"%s/saves/%s.srm", DEFAULT_PATH, rom_filename); - } - - /* Delete file */ - ret = remove(filename); - } - else - { - /* Memory Card support */ - if (slot > 0) - sprintf(filename,"MD-%04X.gp%d", rominfo.realchecksum, slot - 1); - else - sprintf(filename,"MD-%04X.srm", rominfo.realchecksum); - - /* Initialise the CARD system */ - memset(&SysArea, 0, CARD_WORKAREA); - CARD_Init("GENP", "00"); - - /* CARD slot */ - device--; - - /* Mount CARD */ - if (CardMount(device)) - { - /* Delete file */ - ret = CARD_Delete(device,filename); - CARD_Unmount(device); - } - } - - return ret; -} - -int slot_load(int slot, int device) -{ - char filename[MAXPATHLEN]; - unsigned long filesize, done = 0; - u8 *buffer; - - /* File Type */ - if (slot > 0) - { - GUI_MsgBoxOpen("Information","Loading State ...",1); - } - else - { - if (!sram.on) - { - GUI_WaitPrompt("Error","Backup RAM is disabled !"); - return 0; - } - - GUI_MsgBoxOpen("Information","Loading Backup RAM ...",1); - } - - /* Device Type */ - if (!device) - { - /* FAT file */ - if (slot > 0) - { - sprintf (filename,"%s/saves/%s.gp%d", DEFAULT_PATH, rom_filename, slot - 1); - } - else - { - sprintf (filename,"%s/saves/%s.srm", DEFAULT_PATH, rom_filename); - } - - /* Open file */ - FILE *fp = fopen(filename, "rb"); - if (!fp) - { - GUI_WaitPrompt("Error","Unable to open file !"); - return 0; - } - - /* Get file size */ - fseek(fp, 0, SEEK_END); - filesize = ftell(fp); - fseek(fp, 0, SEEK_SET); - - /* allocate buffer */ - buffer = (u8 *)memalign(32,filesize); - if (!buffer) - { - GUI_WaitPrompt("Error","Unable to allocate memory !"); - fclose(fp); - return 0; - } - - /* Read into buffer (2k blocks) */ - while (filesize > CHUNKSIZE) - { - fread(buffer + done, CHUNKSIZE, 1, fp); - done += CHUNKSIZE; - filesize -= CHUNKSIZE; - } - - /* Read remaining bytes */ - fread(buffer + done, filesize, 1, fp); - done += filesize; - - /* Close file */ - fclose(fp); - } - else - { - /* Memory Card file */ - if (slot > 0) - { - sprintf(filename, "MD-%04X.gp%d", rominfo.realchecksum, slot - 1); - } - else - { - sprintf(filename, "MD-%04X.srm", rominfo.realchecksum); - } - - /* Initialise the CARD system */ - char action[64]; - memset(&SysArea, 0, CARD_WORKAREA); - CARD_Init("GENP", "00"); - - /* CARD slot */ - device--; - - /* Attempt to mount the card */ - if (!CardMount(device)) - { - GUI_WaitPrompt("Error","Unable to mount memory card"); - return 0; - } - - /* Retrieve the sector size */ - u32 SectorSize = 0; - int CardError = CARD_GetSectorSize(device, &SectorSize); - if (!SectorSize) - { - sprintf(action, "Invalid sector size (%d)", CardError); - GUI_WaitPrompt("Error",action); - CARD_Unmount(device); - return 0; - } - - /* Open file */ - card_file CardFile; - CardError = CARD_Open(device, filename, &CardFile); - if (CardError) - { - sprintf(action, "Unable to open file (%d)", CardError); - GUI_WaitPrompt("Error",action); - CARD_Unmount(device); - return 0; - } - - /* Get file size */ - filesize = CardFile.len; - if (filesize % SectorSize) - { - filesize = ((filesize / SectorSize) + 1) * SectorSize; - } - - /* Allocate buffer */ - u8 *in = (u8 *)memalign(32, filesize); - if (!in) - { - GUI_WaitPrompt("Error","Unable to allocate memory !"); - CARD_Close(&CardFile); - CARD_Unmount(device); - return 0; - } - - /* Read file sectors */ - while (filesize > 0) - { - CARD_Read(&CardFile, &in[done], SectorSize, done); - done += SectorSize; - filesize -= SectorSize; - } - - /* Close file */ - CARD_Close(&CardFile); - CARD_Unmount(device); - - /* Uncompressed file size */ - memcpy(&filesize, in + 2112, 4); - buffer = (u8 *)memalign(32, filesize); - if (!buffer) - { - free(in); - GUI_WaitPrompt("Error","Unable to allocate memory !"); - return 0; - } - - /* Uncompress file */ - uncompress ((Bytef *)buffer, &filesize, (Bytef *)(in + 2112 + 4), done - 2112 - 4); - free(in); - } - - if (slot > 0) - { - /* Load state */ - if (state_load(buffer) <= 0) - { - free(buffer); - GUI_WaitPrompt("Error","Invalid state file !"); - return 0; - } - } - else - { - /* load SRAM */ - memcpy(sram.sram, buffer, 0x10000); - - /* update CRC */ - sram.crc = crc32(0, sram.sram, 0x10000); - } - - free(buffer); - GUI_MsgBoxClose(); - return 1; -} - -int slot_save(int slot, int device) -{ - char filename[MAXPATHLEN]; - unsigned long filesize, done = 0; - u8 *buffer; - - if (slot > 0) - { - GUI_MsgBoxOpen("Information","Saving State ...",1); - - /* allocate buffer */ - buffer = (u8 *)memalign(32,STATE_SIZE); - if (!buffer) - { - GUI_WaitPrompt("Error","Unable to allocate memory !"); - return 0; - } - - filesize = state_save(buffer); - } - else - { - /* only save if SRAM is enabled */ - if (!sram.on) - { - GUI_WaitPrompt("Error","Backup RAM disabled !"); - return 0; - } - - /* only save if SRAM has been modified */ - if (crc32(0, &sram.sram[0], 0x10000) == sram.crc) - { - GUI_WaitPrompt("Warning","Backup RAM not modified !"); - return 0; - } - - GUI_MsgBoxOpen("Information","Saving Backup RAM ...",1); - - /* allocate buffer */ - buffer = (u8 *)memalign(32, 0x10000); - if (!buffer) - { - GUI_WaitPrompt("Error","Unable to allocate memory !"); - return 0; - } - - /* copy SRAM data */ - memcpy(buffer, sram.sram, 0x10000); - filesize = 0x10000; - - /* update CRC */ - sram.crc = crc32(0, sram.sram, 0x10000); - } - - /* Device Type */ - if (!device) - { - /* FAT filename */ - if (slot > 0) - { - sprintf(filename, "%s/saves/%s.gp%d", DEFAULT_PATH, rom_filename, slot - 1); - } - else - { - sprintf(filename, "%s/saves/%s.srm", DEFAULT_PATH, rom_filename); - } - - /* Open file */ - FILE *fp = fopen(filename, "wb"); - if (!fp) - { - GUI_WaitPrompt("Error","Unable to open file !"); - free(buffer); - return 0; - } - - /* Write from buffer (2k blocks) */ - while (filesize > CHUNKSIZE) - { - fwrite(buffer + done, CHUNKSIZE, 1, fp); - done += CHUNKSIZE; - filesize -= CHUNKSIZE; - } - - /* Write remaining bytes */ - fwrite(buffer + done, filesize, 1, fp); - done += filesize; - - /* Close file */ - fclose(fp); - free(buffer); - - /* Close message box */ - GUI_MsgBoxClose(); - - /* Save state screenshot */ - if (slot > 0) - { - sprintf(filename,"%s/saves/%s__%d.png", DEFAULT_PATH, rom_filename, slot - 1); - gxSaveScreenshot(filename); - } - } - else - { - /* Memory Card filename */ - if (slot > 0) - { - sprintf(filename, "MD-%04X.gp%d", rominfo.realchecksum, slot - 1); - } - else - { - sprintf(filename, "MD-%04X.srm", rominfo.realchecksum); - } - - /* Initialise the CARD system */ - char action[64]; - memset(&SysArea, 0, CARD_WORKAREA); - CARD_Init("GENP", "00"); - - /* CARD slot */ - device--; - - /* Attempt to mount the card */ - if (!CardMount(device)) - { - GUI_WaitPrompt("Error","Unable to mount memory card"); - free(buffer); - return 0; - } - - /* Retrieve sector size */ - u32 SectorSize = 0; - int CardError = CARD_GetSectorSize(device, &SectorSize); - if (!SectorSize) - { - sprintf(action, "Invalid sector size (%d)", CardError); - GUI_WaitPrompt("Error",action); - CARD_Unmount(device); - free(buffer); - return 0; - } - - /* Build output buffer */ - u8 *out = (u8 *)memalign(32, filesize + 2112 + 4); - if (!out) - { - GUI_WaitPrompt("Error","Unable to allocate memory !"); - CARD_Unmount(device); - free(buffer); - return 0; - } - - /* Memory Card file header */ - char comment[2][32] = { {"Genesis Plus GX"}, {"SRAM Save"} }; - strcpy (comment[1], filename); - memcpy (&out[0], &icon, 2048); - memcpy (&out[2048], &comment[0], 64); - - /* uncompressed size */ - done = filesize; - memcpy(&out[2112], &done, 4); - - /* compress file */ - compress2 ((Bytef *)&out[2112 + 4], &filesize, (Bytef *)buffer, done, 9); - - /* Adjust file size */ - filesize = filesize + 4 + 2112; - if (filesize % SectorSize) - { - filesize = ((filesize / SectorSize) + 1) * SectorSize; - } - - /* Check if file already exists */ - card_file CardFile; - if (CARD_Open(device, filename, &CardFile) == CARD_ERROR_READY) - { - int size = filesize - CardFile.len; - CARD_Close(&CardFile); - memset(&CardFile,0,sizeof(CardFile)); - - /* Check file new size */ - if (size > 0) - { - CardError = CARD_Create(device, "TEMP", size, &CardFile); - if (CardError) - { - sprintf(action, "Unable to increase file size (%d)", CardError); - GUI_WaitPrompt("Error",action); - CARD_Unmount(device); - free(out); - free(buffer); - return 0; - } - - /* delete temporary file */ - CARD_Close(&CardFile); - memset(&CardFile,0,sizeof(CardFile)); - CARD_Delete(device, "TEMP"); - } - - /* delete previously existing file */ - CARD_Delete(device, filename); - } - - /* Create a new file */ - CardError = CARD_Create(device, filename, filesize, &CardFile); - if (CardError) - { - sprintf(action, "Unable to create file (%d)", CardError); - GUI_WaitPrompt("Error",action); - CARD_Unmount(device); - free(out); - free(buffer); - return 0; - } - - /* Update file informations */ - time_t rawtime; - time(&rawtime); - card_stat CardStatus; - CARD_GetStatus(device, CardFile.filenum, &CardStatus); - CardStatus.icon_addr = 0x0; - CardStatus.icon_fmt = 2; - CardStatus.icon_speed = 1; - CardStatus.comment_addr = 2048; - CardStatus.time = rawtime; - CARD_SetStatus(device, CardFile.filenum, &CardStatus); - - /* Write file sectors */ - while (filesize > 0) - { - CARD_Write(&CardFile, &out[done], SectorSize, done); - filesize -= SectorSize; - done += SectorSize; - } - - /* Close file */ - CARD_Close(&CardFile); - CARD_Unmount(device); - free(out); - free(buffer); - - /* Close message box */ - GUI_MsgBoxClose(); - } - - return 1; -} diff --git a/genplus-gx/gx/fileio/file_slot.h b/genplus-gx/gx/fileio/file_slot.h deleted file mode 100644 index fe227a8936..0000000000 --- a/genplus-gx/gx/fileio/file_slot.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * file_slot.c - * - * FAT and Memory Card SRAM/Savestate files managment - * - * Copyright Eke-Eke (2008-2012), based on original code from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _FILE_SLOT_H -#define _FILE_SLOT_H - -typedef struct -{ - int valid; - u16 year; - u8 month; - u8 day; - u8 hour; - u8 min; -} t_slot; - -extern void slot_autoload(int slot, int device); -extern void slot_autosave(int slot, int device); -extern void slot_autodetect(int slot, int device, t_slot *ptr); -extern int slot_delete(int slot, int device); -extern int slot_load(int slot, int device); -extern int slot_save(int slot, int device); - -#endif diff --git a/genplus-gx/gx/fileio/fileio.c b/genplus-gx/gx/fileio/fileio.c deleted file mode 100644 index 4d97eb05a6..0000000000 --- a/genplus-gx/gx/fileio/fileio.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * fileio.c - * - * Load a normal file, or ZIP/GZ archive into ROM buffer. - * Returns loaded ROM size (zero if an error occured). - * - * Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "file_load.h" -#include "gui.h" - -/* - * Zip file header definition - */ -typedef struct -{ - unsigned int zipid __attribute__ ((__packed__)); // 0x04034b50 - unsigned short zipversion __attribute__ ((__packed__)); - unsigned short zipflags __attribute__ ((__packed__)); - unsigned short compressionMethod __attribute__ ((__packed__)); - unsigned short lastmodtime __attribute__ ((__packed__)); - unsigned short lastmoddate __attribute__ ((__packed__)); - unsigned int crc32 __attribute__ ((__packed__)); - unsigned int compressedSize __attribute__ ((__packed__)); - unsigned int uncompressedSize __attribute__ ((__packed__)); - unsigned short filenameLength __attribute__ ((__packed__)); - unsigned short extraDataLength __attribute__ ((__packed__)); -} PKZIPHEADER; - - -/* - * Zip files are stored little endian - * Support functions for short and int types - */ -static inline u32 FLIP32 (u32 b) -{ - unsigned int c; - c = (b & 0xff000000) >> 24; - c |= (b & 0xff0000) >> 8; - c |= (b & 0xff00) << 8; - c |= (b & 0xff) << 24; - return c; -} - -static inline u16 FLIP16 (u16 b) -{ - u16 c; - c = (b & 0xff00) >> 8; - c |= (b & 0xff) << 8; - return c; -} - -int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension) -{ - int size = 0; - char in[CHUNKSIZE]; - char msg[64] = "Unable to open file"; - - /* Open file */ - FILE *fd = fopen(filename, "rb"); - - /* Master System & Game Gear BIOS are optional files */ - if (!strcmp(filename,MS_BIOS_US) || !strcmp(filename,MS_BIOS_EU) || !strcmp(filename,MS_BIOS_JP) || !strcmp(filename,GG_BIOS)) - { - /* disable all messages */ - SILENT = 1; - } - - /* Mega CD BIOS are required files */ - if (!strcmp(filename,CD_BIOS_US) || !strcmp(filename,CD_BIOS_EU) || !strcmp(filename,CD_BIOS_JP)) - { - sprintf(msg,"Unable to open %s", filename + 14); - } - - if (!fd) - { - GUI_WaitPrompt("Error", msg); - SILENT = 0; - return 0; - } - - /* Read first chunk */ - fread(in, CHUNKSIZE, 1, fd); - - /* Detect Zip file */ - if (memcmp(in, "PK", 2) == 0) - { - /* Inflate buffer */ - char out[CHUNKSIZE]; - - /* PKZip header pointer */ - PKZIPHEADER *pkzip = (PKZIPHEADER *) in; - - /* Retrieve uncompressed ROM size */ - size = FLIP32(pkzip->uncompressedSize); - - /* Check ROM size */ - if (size > maxsize) - { - fclose(fd); - GUI_WaitPrompt("Error","File is too large"); - SILENT = 0; - return 0; - } - - sprintf (msg, "Unzipping %d bytes ...", size); - GUI_MsgBoxUpdate("Information",msg); - - /* Initialize zip stream */ - z_stream zs; - memset (&zs, 0, sizeof (z_stream)); - zs.zalloc = Z_NULL; - zs.zfree = Z_NULL; - zs.opaque = Z_NULL; - zs.avail_in = 0; - zs.next_in = Z_NULL; - int res = inflateInit2(&zs, -MAX_WBITS); - - if (res != Z_OK) - { - fclose(fd); - GUI_WaitPrompt("Error","Unable to unzip file"); - SILENT = 0; - return 0; - } - - /* Compressed filename offset */ - int offset = sizeof (PKZIPHEADER) + FLIP16(pkzip->filenameLength); - - if (extension) - { - memcpy(extension, &in[offset - 3], 3); - extension[3] = 0; - } - - - /* Initial Zip buffer offset */ - offset += FLIP16(pkzip->extraDataLength); - zs.next_in = (Bytef *)&in[offset]; - - /* Initial Zip remaining chunk size */ - zs.avail_in = CHUNKSIZE - offset; - - /* Start unzipping file */ - do - { - /* Inflate data until output buffer is empty */ - do - { - zs.avail_out = CHUNKSIZE; - zs.next_out = (Bytef *) out; - res = inflate(&zs, Z_NO_FLUSH); - - if (res == Z_MEM_ERROR) - { - inflateEnd(&zs); - fclose(fd); - GUI_WaitPrompt("Error","Unable to unzip file"); - SILENT = 0; - return 0; - } - - offset = CHUNKSIZE - zs.avail_out; - if (offset) - { - memcpy(buffer, out, offset); - buffer += offset; - } - } - while (zs.avail_out == 0); - - /* Read next chunk of zipped data */ - fread(in, CHUNKSIZE, 1, fd); - zs.next_in = (Bytef *)&in[0]; - zs.avail_in = CHUNKSIZE; - } - while (res != Z_STREAM_END); - inflateEnd (&zs); - } - else - { - /* Get file size */ - fseek(fd, 0, SEEK_END); - size = ftell(fd); - fseek(fd, 0, SEEK_SET); - - /* size limit */ - if(size > maxsize) - { - fclose(fd); - GUI_WaitPrompt("Error","File is too large"); - SILENT = 0; - return 0; - } - - sprintf((char *)msg,"Loading %d bytes ...", size); - GUI_MsgBoxUpdate("Information", (char *)msg); - - /* filename extension */ - if (extension) - { - memcpy(extension, &filename[strlen(filename) - 3], 3); - extension[3] = 0; - } - - /* Read into buffer */ - int left = size; - while (left > CHUNKSIZE) - { - fread(buffer, CHUNKSIZE, 1, fd); - buffer += CHUNKSIZE; - left -= CHUNKSIZE; - } - - /* Read remaining bytes */ - fread(buffer, left, 1, fd); - } - - /* Close file */ - fclose(fd); - - /* Return loaded ROM size */ - SILENT = 0; - return size; -} diff --git a/genplus-gx/gx/fileio/fileio.h b/genplus-gx/gx/fileio/fileio.h deleted file mode 100644 index 4e1c6c6050..0000000000 --- a/genplus-gx/gx/fileio/fileio.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * fileio.c - * - * Load a normal file, or ZIP/GZ archive into ROM buffer. - * Returns loaded ROM size (zero if an error occured). - * - * Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _FILEIO_H_ -#define _FILEIO_H_ - -/* Function prototypes */ -int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension); - -#endif /* _FILEIO_H_ */ diff --git a/genplus-gx/gx/fileio/history.c b/genplus-gx/gx/fileio/history.c deleted file mode 100644 index a28219fd3a..0000000000 --- a/genplus-gx/gx/fileio/history.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * history.c - * - * Generic ROM history list managment - * - * Copyright Eke-Eke (2008-2012), based on original code from Martin Disibio (2008) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "history.h" - -t_history history; - - -/**************************************************************************** - * history_add_file - * - * Adds the given file path to the top of the history list, shifting each - * existing entry in the history down one place. If given file path is - * already in the list then the existing entry is (in effect) moved to the - * top instead. - ****************************************************************************/ -void history_add_file(char *filepath, char *filename, u8 filetype) -{ - /* Create the new entry for this path. */ - t_history_entry newentry; - strncpy(newentry.filepath, filepath, MAXJOLIET - 1); - strncpy(newentry.filename, filename, MAXJOLIET - 1); - newentry.filepath[MAXJOLIET - 1] = '\0'; - newentry.filename[MAXJOLIET - 1] = '\0'; - newentry.filetype = filetype; - - t_history_entry oldentry; /* Old entry is the one being shuffled down a spot. */ - t_history_entry currentry; /* Curr entry is the one that just replaced old path. */ - - /* Initially set curr entry to the new value. */ - memcpy(¤try, &newentry, sizeof(t_history_entry)); - - int i; - for(i=0; i < NUM_HISTORY_ENTRIES; i++) - { - /* Save off the next entry. */ - memcpy(&oldentry, &history.entries[i], sizeof(t_history_entry)); - - /* Overwrite with the previous entry. */ - memcpy(&history.entries[i], ¤try, sizeof(t_history_entry)); - - /* Switch the old entry to the curr entry now. */ - memcpy(¤try, &oldentry, sizeof(t_history_entry)); - - /* If the entry in the list at this spot matches - the new entry then do nothing and let this - entry get deleted. */ - if(strcmp(newentry.filepath, currentry.filepath) == 0 && strcmp(newentry.filename, currentry.filename) == 0) - break; - } - - /* now save to disk */ - history_save(); -} - -void history_save() -{ - /* open file */ - char fname[MAXPATHLEN]; - sprintf (fname, "%s/history.ini", DEFAULT_PATH); - FILE *fp = fopen(fname, "wb"); - if (fp) - { - /* write file */ - fwrite(&history, sizeof(history), 1, fp); - fclose(fp); - } -} - -void history_load(void) -{ - /* open file */ - char fname[MAXPATHLEN]; - sprintf (fname, "%s/history.ini", DEFAULT_PATH); - FILE *fp = fopen(fname, "rb"); - if (fp) - { - /* read file */ - if (fread(&history, sizeof(history), 1, fp) != 1) - { - /* an error ocurred, better clear hoistory */ - memset(&history, 0, sizeof(history)); - } - - /* close file */ - fclose(fp); - } -} - -void history_default(void) -{ - int i; - for(i=0; i < NUM_HISTORY_ENTRIES; i++) - memset(&history.entries[i], 0, sizeof(t_history_entry)); - - /* restore history */ - history_load(); -} - - - diff --git a/genplus-gx/gx/fileio/history.h b/genplus-gx/gx/fileio/history.h deleted file mode 100644 index e40081a5d8..0000000000 --- a/genplus-gx/gx/fileio/history.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * history.c - * - * Generic ROM history list managment - * - * Copyright Eke-Eke (2008-2012), based on original code from Martin Disibio (2008) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _HISTORY_H -#define _HISTORY_H - -#include "filesel.h" - -#define NUM_HISTORY_ENTRIES (10) - -/**************************************************************************** - * ROM Play History - * - ****************************************************************************/ -typedef struct -{ - char filepath[MAXJOLIET]; - char filename[MAXJOLIET]; - u8 filetype; -} t_history_entry; - -typedef struct -{ - t_history_entry entries[NUM_HISTORY_ENTRIES]; -} t_history; - -extern t_history history; -extern void history_add_file(char *filepath, char *filename, u8 filetype); -extern void history_save(void); -extern void history_load(void); -extern void history_default(void); - -#endif diff --git a/genplus-gx/gx/gui/cheats.c b/genplus-gx/gx/gui/cheats.c deleted file mode 100644 index 829044cbfe..0000000000 --- a/genplus-gx/gx/gui/cheats.c +++ /dev/null @@ -1,1492 +0,0 @@ -/* - * cheats.c - * - * Cheats menu - * - * Copyright Eke-Eke (2010-2012) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "file_load.h" -#include "cheats.h" -#include "font.h" -#include "gui.h" - -#define BG_COLOR_1 {0x49,0x49,0x49,0xff} -#define BG_COLOR_2 {0x66,0x66,0x66,0xff} - -#define MAX_CHEATS (150) -#define MAX_DESC_LENGTH (63) - -#ifdef HW_RVL -extern const u8 Key_Minus_wii_png[]; -extern const u8 Key_Plus_wii_png[]; -#else -extern const u8 Key_R_gcn_png[]; -extern const u8 Key_L_gcn_png[]; -#endif -extern const u8 Key_DPAD_png[]; - -typedef struct -{ - char code[12]; - char text[MAX_DESC_LENGTH]; - u8 enable; - u16 data; - u16 old; - u32 address; - u8 *prev; -} CHEATENTRY; - -static int string_offset = 0; -static int selection = 0; -static int offset = 0; -static int type = 0; -static int maxcheats = 0; -static int maxROMcheats = 0; -static int maxRAMcheats = 0; - -static CHEATENTRY cheatlist[MAX_CHEATS]; -static u8 cheatIndexes[MAX_CHEATS]; - -static void cheatmenu_cb(void); - -/*****************************************************************************/ -/* GUI Buttons data */ -/*****************************************************************************/ -static butn_data arrow_up_data = -{ - {NULL,NULL}, - {Button_up_png,Button_up_over_png} -}; - -static butn_data arrow_down_data = -{ - {NULL,NULL}, - {Button_down_png,Button_down_over_png} -}; -static butn_data button_digit_data = -{ - {NULL,NULL}, - {Button_digit_png,Button_digit_over_png} -}; - -/*****************************************************************************/ -/* GUI Arrows button */ -/*****************************************************************************/ - -static gui_butn arrow_up = {&arrow_up_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{0,0,0,0},14,76,360,32}; -static gui_butn arrow_down = {&arrow_down_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{0,0,0,0},14,368,360,32}; - - -/*****************************************************************************/ -/* GUI helpers */ -/*****************************************************************************/ -static gui_item action_cancel = -{ - NULL,Key_B_png,"","Exit",10,422,28,28 -}; - -static gui_item action_select = -{ - NULL,Key_A_png,"","Edit Entry",602,422,28,28 -}; - -/*****************************************************************************/ -/* GUI Background images */ -/*****************************************************************************/ -static gui_image bg_cheats[7] = -{ - {NULL,Bg_layer_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Banner_top_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,0,0,640,108,255}, - {NULL,Banner_bottom_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,0,380,640,100,255}, - {NULL,Main_logo_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,466,40,152,44,255}, - {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,152}, - {NULL,Frame_s1_png,IMAGE_SLIDE_RIGHT,411,109,372,296,76}, -}; - -/*****************************************************************************/ -/* Menu Items description */ -/*****************************************************************************/ -static gui_item items_cheats[30] = -{ - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"","Edit Entry",0,0,0,0}, - {NULL,NULL,"0","Add Character" ,440,136,40,40}, - {NULL,NULL,"1","Add Character" ,486,136,40,40}, - {NULL,NULL,"2","Add Character" ,532,136,40,40}, - {NULL,NULL,"3","Add Character" ,578,136,40,40}, - {NULL,NULL,"4","Add Character" ,440,182,40,40}, - {NULL,NULL,"5","Add Character" ,486,182,40,40}, - {NULL,NULL,"6","Add Character" ,532,182,40,40}, - {NULL,NULL,"7","Add Character" ,578,182,40,40}, - {NULL,NULL,"8","Add Character" ,440,228,40,40}, - {NULL,NULL,"9","Add Character" ,486,228,40,40}, - {NULL,NULL,"A","Add Character" ,532,228,40,40}, - {NULL,NULL,"B","Add Character" ,578,228,40,40}, - {NULL,NULL,"C","Add Character" ,440,274,40,40}, - {NULL,NULL,"D","Add Character" ,486,274,40,40}, - {NULL,NULL,"E","Add Character" ,532,274,40,40}, - {NULL,NULL,"F","Add Character" ,578,274,40,40}, - {NULL,NULL,"del","Backspace" ,440,338,40,40}, - {NULL,NULL,":","Add Separator" ,486,338,40,40}, - {NULL,NULL,"+","Next Characters",532,338,40,40}, - {NULL,NULL,"ok","Save Entry" ,578,338,40,40} -}; - -/*****************************************************************************/ -/* Menu Buttons description */ -/*****************************************************************************/ -static gui_butn buttons_cheats[30] = -{ - {NULL, BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,108,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,134,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,160,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,186,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,212,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,238,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,264,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,290,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,316,358,26}, - {NULL, BUTTON_VISIBLE|BUTTON_SELECT_SFX|BUTTON_OVER_SFX,{1,0,0,0},15,342,358,26}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{0,4,0,1},440,136,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{0,4,1,1},486,136,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{0,4,1,1},532,136,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{0,4,1,0},578,136,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,0,1},440,182,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,1},486,182,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,1},532,182,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,0},578,182,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,0,1},440,228,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,1},486,228,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,1},532,228,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,0},578,228,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,0,1},440,274,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,1},486,274,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,1},532,274,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,4,1,0},578,274,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,0,0,1},440,338,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,0,1,1},486,338,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,0,1,1},532,338,40,40}, - {&button_digit_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{4,0,1,0},578,338,40,40} -}; - -/*****************************************************************************/ -/* Menu description */ -/*****************************************************************************/ -static gui_menu menu_cheats = -{ - "Cheats Manager", - 0,0, - 30,30,7,0, - items_cheats, - buttons_cheats, - bg_cheats, - {&action_cancel, &action_select}, - {&arrow_up,&arrow_down}, - cheatmenu_cb -}; - -static char ggvalidchars[] = "ABCDEFGHJKLMNPRSTVWXYZ0123456789"; - -static char arvalidchars[] = "0123456789ABCDEF"; - -static u32 decode_cheat(char *string, int index) -{ - char *p; - int i,n; - u32 len = 0; - u32 address = 0; - u16 data = 0; - u8 ref = 0; - - /* 16-bit Game Genie code (ABCD-EFGH) */ - if ((strlen(string) >= 9) && (string[4] == '-')) - { - /* 16-bit system only */ - if ((system_hw & SYSTEM_PBC) != SYSTEM_MD) - { - return 0; - } - - for (i = 0; i < 8; i++) - { - if (i == 4) string++; - p = strchr (ggvalidchars, *string++); - if (p == NULL) return 0; - n = p - ggvalidchars; - - switch (i) - { - case 0: - data |= n << 3; - break; - - case 1: - data |= n >> 2; - address |= (n & 3) << 14; - break; - - case 2: - address |= n << 9; - break; - - case 3: - address |= (n & 0xF) << 20 | (n >> 4) << 8; - break; - - case 4: - data |= (n & 1) << 12; - address |= (n >> 1) << 16; - break; - - case 5: - data |= (n & 1) << 15 | (n >> 1) << 8; - break; - - case 6: - data |= (n >> 3) << 13; - address |= (n & 7) << 5; - break; - - case 7: - address |= n; - break; - } - } - - /* code length */ - len = 9; - } - - /* 8-bit Game Genie code (DDA-AAA-XXX) */ - else if ((strlen(string) >= 11) && (string[3] == '-') && (string[7] == '-')) - { - /* 8-bit system only */ - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - return 0; - } - - /* decode 8-bit data */ - for (i=0; i<2; i++) - { - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - data |= (n << ((1 - i) * 4)); - } - - /* decode 16-bit address (low 12-bits) */ - for (i=0; i<3; i++) - { - if (i==1) string++; /* skip separator */ - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - address |= (n << ((2 - i) * 4)); - } - - /* decode 16-bit address (high 4-bits) */ - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - n ^= 0xF; /* bits inversion */ - address |= (n << 12); - - /* RAM address are also supported */ - if (address >= 0xC000) - { - /* convert to 24-bit Work RAM address */ - address = 0xFF0000 | (address & 0x1FFF); - } - - /* decode reference 8-bit data */ - for (i=0; i<2; i++) - { - string++; /* skip separator and 2nd digit */ - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - ref |= (n << ((1 - i) * 4)); - } - ref = (ref >> 2) | ((ref & 0x03) << 6); /* 2-bit right rotation */ - ref ^= 0xBA; /* XOR */ - - /* update old data value */ - cheatlist[index].old = ref; - - /* code length */ - len = 11; - } - - /* Action Replay code */ - else if (string[6] == ':') - { - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - /* 16-bit code (AAAAAA:DDDD) */ - if (strlen(string) < 11) return 0; - - /* decode 24-bit address */ - for (i=0; i<6; i++) - { - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - address |= (n << ((5 - i) * 4)); - } - - /* decode 16-bit data */ - string++; - for (i=0; i<4; i++) - { - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - data |= (n << ((3 - i) * 4)); - } - - /* code length */ - len = 11; - } - else - { - /* 8-bit code (xxAAAA:DD) */ - if (strlen(string) < 9) return 0; - - /* decode 16-bit address */ - string+=2; - for (i=0; i<4; i++) - { - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - address |= (n << ((3 - i) * 4)); - } - - /* ROM addresses are not supported */ - if (address < 0xC000) return 0; - - /* convert to 24-bit Work RAM address */ - address = 0xFF0000 | (address & 0x1FFF); - - /* decode 8-bit data */ - string++; - for (i=0; i<2; i++) - { - p = strchr (arvalidchars, *string++); - if (p == NULL) return 0; - n = (p - arvalidchars) & 0xF; - data |= (n << ((1 - i) * 4)); - } - - /* code length */ - len = 9; - } - } - - /* Valid code found ? */ - if (len) - { - /* update cheat address & data values */ - cheatlist[index].address = address; - cheatlist[index].data = data; - } - - /* return code length (0 = invalid) */ - return len; -} - -static void apply_cheats(void) -{ - u8 *ptr; - - /* clear ROM&RAM patches counter */ - maxROMcheats = maxRAMcheats = 0; - - int i; - for (i = 0; i < maxcheats; i++) - { - if (cheatlist[i].enable) - { - if (cheatlist[i].address < cart.romsize) - { - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - /* patch ROM data */ - cheatlist[i].old = *(u16 *)(cart.rom + (cheatlist[i].address & 0xFFFFFE)); - *(u16 *)(cart.rom + (cheatlist[i].address & 0xFFFFFE)) = cheatlist[i].data; - } - else - { - /* add ROM patch */ - maxROMcheats++; - cheatIndexes[MAX_CHEATS - maxROMcheats] = i; - - /* get current banked ROM address */ - ptr = &z80_readmap[(cheatlist[i].address) >> 10][cheatlist[i].address & 0x03FF]; - - /* check if reference matches original ROM data */ - if (((u8)cheatlist[i].old) == *ptr) - { - /* patch data */ - *ptr = cheatlist[i].data; - - /* save patched ROM address */ - cheatlist[i].prev = ptr; - } - else - { - /* no patched ROM address yet */ - cheatlist[i].prev = NULL; - } - } - } - else if (cheatlist[i].address >= 0xFF0000) - { - /* add RAM patch */ - cheatIndexes[maxRAMcheats++] = i; - } - } - } -} - -static void clear_cheats(void) -{ - int i = maxcheats; - - /* disable cheats in reversed order in case the same address is used by multiple patches */ - while (i > 0) - { - if (cheatlist[i-1].enable) - { - if (cheatlist[i-1].address < cart.romsize) - { - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - /* restore original ROM data */ - *(u16 *)(cart.rom + (cheatlist[i-1].address & 0xFFFFFE)) = cheatlist[i-1].old; - } - else - { - /* check if previous banked ROM address has been patched */ - if (cheatlist[i-1].prev != NULL) - { - /* restore original data */ - *cheatlist[i-1].prev = cheatlist[i-1].old; - - /* no more patched ROM address */ - cheatlist[i-1].prev = NULL; - } - } - } - } - - i--; - } -} - -static void switch_chars(void) -{ - int i; - gui_menu *m = &menu_cheats; - - if (m->items[10].text[0] == '0') - { - m->items[10].text[0] = 'G'; - m->items[11].text[0] = 'H'; - m->items[12].text[0] = 'J'; - m->items[13].text[0] = 'K'; - m->items[14].text[0] = 'L'; - m->items[15].text[0] = 'M'; - m->items[16].text[0] = 'N'; - m->items[17].text[0] = 'P'; - m->items[18].text[0] = 'R'; - m->items[19].text[0] = 'S'; - m->items[20].text[0] = 'T'; - m->items[21].text[0] = 'V'; - m->items[22].text[0] = 'W'; - m->items[23].text[0] = 'X'; - m->items[24].text[0] = 'Y'; - m->items[25].text[0] = 'Z'; - } - else if (m->items[10].text[0] == 'G') - { - m->items[10].text[0] = '0'; - m->items[11].text[0] = '1'; - m->items[12].text[0] = '2'; - m->items[13].text[0] = '3'; - m->items[14].text[0] = '4'; - m->items[15].text[0] = '5'; - m->items[16].text[0] = '6'; - m->items[17].text[0] = '7'; - m->items[18].text[0] = '8'; - m->items[19].text[0] = '9'; - m->items[20].text[0] = 'A'; - m->items[21].text[0] = 'B'; - m->items[22].text[0] = 'C'; - m->items[23].text[0] = 'D'; - m->items[24].text[0] = 'E'; - m->items[25].text[0] = 'F'; - } - else if (m->items[10].text[0] == 'A') - { - m->items[10].text[0] = 'Q'; - m->items[11].text[0] = 'R'; - m->items[12].text[0] = 'S'; - m->items[13].text[0] = 'T'; - m->items[14].text[0] = 'U'; - m->items[15].text[0] = 'V'; - m->items[16].text[0] = 'W'; - m->items[17].text[0] = 'X'; - m->items[18].text[0] = 'Y'; - m->items[19].text[0] = 'Z'; - m->items[20].text[0] = '0'; - m->items[21].text[0] = '1'; - m->items[22].text[0] = '2'; - m->items[23].text[0] = '3'; - m->items[24].text[0] = '4'; - m->items[25].text[0] = '5'; - } - else if (m->items[10].text[0] == 'Q') - { - m->items[10].text[0] = '6'; - m->items[11].text[0] = '7'; - m->items[12].text[0] = '8'; - m->items[13].text[0] = '9'; - - /* hide unused buttons */ - for (i=14; i<26; i++) - { - m->buttons[i].state &= ~BUTTON_VISIBLE; - } - m->buttons[10].shift[1] = 16; - m->buttons[11].shift[1] = 16; - m->buttons[12].shift[1] = 16; - m->buttons[13].shift[1] = 16; - m->buttons[26].shift[0] = 16; - m->buttons[27].shift[0] = 16; - m->buttons[28].shift[0] = 16; - m->buttons[29].shift[0] = 16; - } - else if (m->items[10].text[0] == '6') - { - m->items[10].text[0] = 'A'; - m->items[11].text[0] = 'B'; - m->items[12].text[0] = 'C'; - m->items[13].text[0] = 'D'; - m->items[14].text[0] = 'E'; - m->items[15].text[0] = 'F'; - m->items[16].text[0] = 'G'; - m->items[17].text[0] = 'H'; - m->items[18].text[0] = 'I'; - m->items[19].text[0] = 'J'; - m->items[20].text[0] = 'K'; - m->items[21].text[0] = 'L'; - m->items[22].text[0] = 'M'; - m->items[23].text[0] = 'N'; - m->items[24].text[0] = 'O'; - m->items[25].text[0] = 'P'; - - /* show previously unused buttons */ - for (i=14; i<26; i++) - { - m->buttons[i].state |= BUTTON_VISIBLE; - } - m->buttons[10].shift[1] = 4; - m->buttons[11].shift[1] = 4; - m->buttons[12].shift[1] = 4; - m->buttons[13].shift[1] = 4; - m->buttons[26].shift[0] = 4; - m->buttons[27].shift[0] = 4; - m->buttons[28].shift[0] = 4; - m->buttons[29].shift[0] = 4; - } -} - -static void cheatmenu_cb(void) -{ - int i; - int yoffset = 108; - gui_image bar_over; - gui_image star; - char temp[MAX_DESC_LENGTH]; - - /* Initialize textures */ - bar_over.texture = gxTextureOpenPNG(Overlay_bar_png,0); - star.texture = gxTextureOpenPNG(Star_full_png,0); - - /* Draw browser array */ - gxDrawRectangle(15, 108, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 134, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 160, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 186, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 212, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 238, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 264, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 290, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 316, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 342, 358, 26, 127, (GXColor)BG_COLOR_2); - - /* Draw Cheat list */ - for (i=0; ((offset + i) < maxcheats) && (i < 10); i++) - { - if (i == selection) - { - /* selection bar */ - gxDrawTexture(bar_over.texture,16,yoffset+1,356,24,255); - - /* cheat description need to be specifically handled */ - if (type) - { - /* check if text is being edited */ - if (menu_cheats.bg_images[6].state & IMAGE_VISIBLE) - { - /* adjust offset so that last characters are visible */ - string_offset += FONT_writeCenter(cheatlist[offset + i].text+string_offset,16,40,366,yoffset+21,(GXColor)WHITE); - } - else - { - /* scroll text (speed = 1/10 frame) */ - if ((string_offset/10) >= strlen(cheatlist[offset + i].text)) - { - string_offset = 0; - } - - if (string_offset) - { - sprintf(temp,"%s ",cheatlist[offset + i].text+string_offset/10); - strncat(temp, cheatlist[offset + i].text, string_offset/10); - } - else - { - strcpy(temp, cheatlist[offset + i].text); - } - - if (FONT_writeCenter(temp,16,40,366,yoffset+21,(GXColor)WHITE)) - { - /* scroll text if string does not fit */ - string_offset ++; - } - } - } - else - { - FONT_writeCenter(cheatlist[offset + i].code,18,40,366,yoffset+22,(GXColor)WHITE); - } - } - else - { - if (type) - { - FONT_writeCenter(cheatlist[offset + i].text,16,40,366,yoffset+21,(GXColor)WHITE); - } - else - { - FONT_writeCenter(cheatlist[offset + i].code,18,40,366,yoffset+22,(GXColor)WHITE); - } - } - - /* draw cheat enable mark */ - if (cheatlist[offset + i].enable) - { - gxDrawTexture(star.texture,20,yoffset+5,16,16,255); - } - - yoffset += 26; - } - - /* New Entry */ - if (i < 10) - { - if (i == selection) - { - /* selection bar */ - gxDrawTexture(bar_over.texture,16,yoffset+1,356,24,255); - - /* check if new code is being edited */ - if (menu_cheats.bg_images[6].state & IMAGE_VISIBLE) - { - FONT_writeCenter(cheatlist[offset + selection].code,18,40,366,yoffset+22,(GXColor)WHITE); - } - else - { - FONT_writeCenter("New Code",18,40,366,yoffset+22,(GXColor)WHITE); - } - } - else - { - FONT_writeCenter("New Code",18,40,366,yoffset+22,(GXColor)WHITE); - } - } - - gxTextureClose(&bar_over.texture); - gxTextureClose(&star.texture); - - /* Extra helpers */ - if (maxcheats && !(menu_cheats.bg_images[6].state & IMAGE_VISIBLE)) - { - /* switch between cheat code & description preview */ - gui_image key_switch; - key_switch.texture = gxTextureOpenPNG(Key_DPAD_png,0); -#ifdef HW_RVL - gxDrawTexture(key_switch.texture,268,424,24,24,255); - FONT_write(type ? "View\nCode":"View\nText",16,300,436,640,(GXColor)WHITE); -#else - gxDrawTexture(key_switch.texture,272,424,24,24,255); - FONT_write(type ? "View\nCode":"View\nText",16,304,436,640,(GXColor)WHITE); -#endif - gxTextureClose(&key_switch.texture); - - /* delete & enable cheats */ - if ((offset + selection) < maxcheats) - { - gui_image key_enable; - gui_image key_delete; - #ifdef HW_RVL - key_enable.texture = gxTextureOpenPNG(Key_Plus_wii_png,0); - key_delete.texture = gxTextureOpenPNG(Key_Minus_wii_png,0); - gxDrawTexture(key_enable.texture,152,424,24,24,255); - gxDrawTexture(key_delete.texture,372,424,24,24,255); - FONT_write(cheatlist[offset + selection].enable ? "Disable\nCheat":"Enable\nCheat",16,184,436,640,(GXColor)WHITE); - FONT_write("Delete\nCheat",16,404,436,640,(GXColor)WHITE); - #else - key_enable.texture = gxTextureOpenPNG(Key_L_gcn_png,0); - key_delete.texture = gxTextureOpenPNG(Key_R_gcn_png,0); - gxDrawTexture(key_enable.texture,136,426,44,20,255); - gxDrawTexture(key_delete.texture,368,426,44,20,255); - FONT_write(cheatlist[offset + selection].enable ? "Disable\nCheat":"Enable\nCheat",16,188,436,640,(GXColor)WHITE); - FONT_write("Delete\nCheat",16,420,436,640,(GXColor)WHITE); - #endif - gxTextureClose(&key_enable.texture); - gxTextureClose(&key_delete.texture); - } - } -} - - -/**************************************************************************** - * CheatMenu - * - * Manage cheats for the currently loaded game - * - ****************************************************************************/ -void CheatMenu(void) -{ - int i, update = 0; - int digit_cnt = 0; - int max = 0; - char temp[256]; - char *str = NULL; - gui_menu *m = &menu_cheats; - - /* clear existing ROM patches */ - clear_cheats(); - - /* reset scrolling */ - string_offset = 0; - - /* background overlay */ - if (config.bg_overlay) - { - bg_cheats[1].state |= IMAGE_VISIBLE; - } - else - { - bg_cheats[1].state &= ~IMAGE_VISIBLE; - } - - /* selected item */ - m->selected = selection; - - /* slide-in menu */ - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - m->cb = cheatmenu_cb; - - /* lock background elements */ - m->bg_images[2].state &= ~IMAGE_SLIDE_TOP; - m->bg_images[3].state &= ~IMAGE_SLIDE_BOTTOM; - m->bg_images[4].state &= ~IMAGE_SLIDE_TOP; - - while (update != -1) - { - /* update arrows buttons */ - if (offset > 0) m->arrows[0]->state |= BUTTON_VISIBLE; - else m->arrows[0]->state &= ~BUTTON_VISIBLE; - if ((offset + 10) < (maxcheats + 1)) m->arrows[1]->state |= BUTTON_VISIBLE; - else m->arrows[1]->state &= ~BUTTON_VISIBLE; - - /* draw menu */ - GUI_DrawMenu(m); - - /* restore cheats offset */ - if (!(menu_cheats.bg_images[6].state & IMAGE_VISIBLE)) - { - m->offset = offset; - m->max_items = maxcheats + 1; - m->max_buttons = 10; - } - - /* update menu */ - update = GUI_UpdateMenu(m); - - /* update selected cheat */ - if ((m->selected < 10) && (selection != m->selected)) - { - selection = m->selected; - string_offset = 0; - } - - /* save offset then restore default */ - if (!(m->bg_images[6].state & IMAGE_VISIBLE)) - { - offset = m->offset; - m->offset = 0; - m->max_items = m->max_buttons = 30; - } - - - /* handle pressed buttons */ - if (update > 0) - { - switch (m->selected) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: /* Edit cheat */ - { - if (type && ((selection + offset) != maxcheats)) - { - /* cheat description */ - str = cheatlist[offset + selection].text; - strcpy(temp, str); - max = MAX_DESC_LENGTH - 2; - digit_cnt = strlen(str); - if (digit_cnt <= max) - { - str[digit_cnt] = '*'; - str[digit_cnt+1] = 0; - } - - /* init specific characters */ - m->items[10].text[0] = '6'; - m->items[27].text[0] = ' '; - strcpy(m->items[27].comment,"Add White Space"); - switch_chars(); - } - else - { - /* cheat code */ - str = cheatlist[offset + selection].code; - strcpy(temp, str); - if ((offset + selection) == maxcheats) - { - /* initialize code */ - max = 0; - digit_cnt = 0; - str[0] = '*'; - str[1] = 0; - } - else - { - /* code type */ - if (str[6] == ':') - { - /* Action Replay code */ - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - /* 16-bit code */ - max = 10; - } - else - { - /* 8-bit code */ - max = 8; - } - } - else if (str[4] == '-') - { - /* 16-bit Game Genie code */ - max = 8; - } - else - { - /* 8-bit Game Genie code */ - max = 10; - } - - /* set cursor to end of code */ - digit_cnt = max + 1; - } - - /* init specific characters */ - m->items[10].text[0] = 'G'; - m->items[27].text[0] = ':'; - strcpy(m->items[27].comment,"Add Code Separator"); - switch_chars(); - } - - /* show digit buttons */ - for (i=10; i<30; i++) m->buttons[i].state |= BUTTON_VISIBLE; - - /* show right window */ - m->bg_images[6].state |= IMAGE_VISIBLE; - - /* disable left buttons */ - for (i=0; i<10; i++) m->buttons[i].state &= ~BUTTON_ACTIVE; - - /* disable arrow buttons */ - m->arrows[0]->state &= ~BUTTON_ACTIVE; - m->arrows[1]->state &= ~BUTTON_ACTIVE; - - /* slide in right window */ - GUI_DrawMenuFX(m,20,0); - - /* update helper */ - strcpy(action_cancel.comment,"Cancel"); - - /* select first digit */ - m->selected = 10; - - /* reset scrolling */ - string_offset = 0; - break; - } - - case 26: /* Backspace */ - { - if (digit_cnt > 0) - { - /* delete last character */ - str[digit_cnt--] = 0; - - /* code separator is being deleted */ - if ((str[digit_cnt] == ':') || (str[digit_cnt] == '-')) - { - /* reset detected code type (except 8-bit Game Genie code using 2 separators) */ - if (((system_hw & SYSTEM_PBC) == SYSTEM_MD) || (digit_cnt != 7)) - { - max = 0; - } - } - - /* edit mark */ - str[digit_cnt] = '*'; - - /* update scroll value if necessary */ - if (string_offset > 0) string_offset--; - } - break; - } - - case 27: - { - if (type && ((offset + selection) != maxcheats)) - { - /* SPACE character */ - if (digit_cnt <= max) - { - str[digit_cnt++] = ' '; - str[digit_cnt] = 0; - if (digit_cnt <= max) - { - str[digit_cnt] = '*'; - str[digit_cnt+1] = 0; - } - } - } - else - { - /* Separator character */ - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - /* 16-bit codes */ - if (digit_cnt == 4) - { - /* Game Genie code */ - max = 8; - str[4] = '-'; - } - else if ((digit_cnt == 6) && (max != 8)) - { - /* Action Replay code */ - max = 10; - str[6] = ':'; - } - else - { - break; - } - } - else - { - /* 8-bit codes */ - if (digit_cnt == 3) - { - /* Game Genie code */ - max = 10; - str[3] = '-'; - } - else if ((digit_cnt == 7) && (max == 10)) - { - /* Game Genie code (last part) */ - str[7] = '-'; - } - else if ((digit_cnt == 6) && (max != 10)) - { - /* Action Replay code */ - max = 8; - str[6] = ':'; - } - else - { - break; - } - } - - digit_cnt++; - str[digit_cnt] = '*'; - str[digit_cnt+1] = 0; - } - break; - } - - case 28: /* Next character set */ - { - GUI_DrawMenuFX(m,40,1); - switch_chars(); - GUI_DrawMenuFX(m,40,0); - break; - } - - case 29: /* Validate entry */ - { - /* check if entry is valid */ - if (type && ((offset + selection) != maxcheats)) - { - str[digit_cnt] = 0; - update = -1; - } - else if (max && (digit_cnt > max)) - { - if (decode_cheat(cheatlist[offset + selection].code, offset + selection)) - { - /* new cheat ? */ - if ((offset + selection) == maxcheats) - { - /* increase cheat count */ - maxcheats++; - - /* enable cheat by default */ - cheatlist[offset + selection].enable = 1; - - /* no description by default */ - strcpy(cheatlist[offset + selection].text,"No Description"); - } - - /* return to cheat selection */ - update = -1; - } - else - { - GUI_WaitPrompt("Error", "Invalid Cheat Code"); - } - } - break; - } - - default: /* Add Character */ - { - /* force code separator if none has been set yet */ - if ((max == 0) && (digit_cnt == 6)) break; - - /* force 8-bit Game Genie code last separator */ - if (((system_hw & SYSTEM_PBC) != SYSTEM_MD) && (max == 10) && (digit_cnt == 7)) break; - - /* add character */ - if ((digit_cnt <= max) || (max == 0)) - { - str[digit_cnt++] = m->items[m->selected].text[0]; - str[digit_cnt] = 0; - if ((digit_cnt <= max) || (max == 0)) - { - str[digit_cnt] = '*'; - str[digit_cnt+1] = 0; - } - if (string_offset > 0) string_offset ++; - } - break; - } - } - } - else if (update < 0) - { - if (m->bg_images[6].state & IMAGE_VISIBLE) - { - /* Restore old entry */ - strcpy(str, temp); - } - } - else - { - if (maxcheats && !(m->bg_images[6].state & IMAGE_VISIBLE)) - { - if ((m_input.keys & PAD_BUTTON_LEFT) || (m_input.keys & PAD_BUTTON_RIGHT)) - { - /* Switch between cheat code & description */ - type ^= 1; - - /* reset scrolling */ - string_offset = 0; - } - - if ((offset + selection) < maxcheats) - { - /* Special inputs */ - if (m_input.keys & PAD_TRIGGER_R) - { - /* sort cheat list */ - for (i = offset + selection + 1; i < maxcheats; i++) - { - strcpy(cheatlist[i-1].text,cheatlist[i].text); - strcpy(cheatlist[i-1].code,cheatlist[i].code); - cheatlist[i-1].address = cheatlist[i].address; - cheatlist[i-1].data = cheatlist[i].data; - cheatlist[i-1].enable = cheatlist[i].enable; - } - - /* clear last cheat */ - cheatlist[maxcheats-1].text[0] = 0; - cheatlist[maxcheats-1].code[0] = 0; - cheatlist[maxcheats-1].address = 0; - cheatlist[maxcheats-1].data = 0; - cheatlist[maxcheats-1].enable = 0; - - /* disable last button */ - if ((maxcheats - offset) < 10) - { - m->buttons[maxcheats - offset].state &= ~BUTTON_ACTIVE; - m->buttons[maxcheats - offset - 1].shift[1] = 0; - } - - /* decrease cheat count */ - maxcheats--; - - /* reset scrolling */ - string_offset = 0; - } - else if (m_input.keys & PAD_TRIGGER_L) - { - /* cheat ON/OFF */ - cheatlist[offset + selection].enable ^= 1; - } - } - } - } - - if (update < 0) - { - if (m->bg_images[6].state & IMAGE_VISIBLE) - { - /* slide out right window */ - GUI_DrawMenuFX(m,20,1); - - /* hide digit buttons */ - for (i=10; i<30; i++) m->buttons[i].state &= ~BUTTON_VISIBLE; - - /* hide right window */ - m->bg_images[6].state &= ~IMAGE_VISIBLE; - - /* update left buttons */ - for (i=0; i<10; i++) - { - if ((offset + i) < maxcheats) - { - m->buttons[i].state |= BUTTON_ACTIVE; - m->buttons[i].shift[1] = 1; - } - else if ((offset + i) == maxcheats) - { - m->buttons[i].state |= BUTTON_ACTIVE; - m->buttons[i].shift[1] = 0; - } - else - { - m->buttons[i].state &= ~BUTTON_ACTIVE; - m->buttons[i].shift[1] = 0; - } - } - - /* enable arrow buttons */ - m->arrows[0]->state |= BUTTON_ACTIVE; - m->arrows[1]->state |= BUTTON_ACTIVE; - - /* restore helper */ - strcpy(action_cancel.comment,"Back"); - - /* select current cheat */ - m->selected = selection; - - /* stay in menu */ - update = 0; - } - } - } - - /* apply ROM patches */ - apply_cheats(); - - /* save cheats to file */ - sprintf(temp, "%s/cheats/%s.pat", DEFAULT_PATH, rom_filename); - - if (maxcheats) - { - /* open file */ - FILE *f = fopen(temp, "w"); - - /* write cheats */ - if (f) - { - for (i=0; ibg_images[2].state |= IMAGE_SLIDE_TOP; - m->bg_images[3].state |= IMAGE_SLIDE_BOTTOM; - m->bg_images[4].state |= IMAGE_SLIDE_TOP; - - /* leave menu */ - m->cb = NULL; - GUI_DeleteMenu(m); - GUI_DrawMenuFX(m,30,1); -} - - -/**************************************************************************** - * CheatLoad - * - * Load cheats from associated .pat file, called when loading a new game - * ROM patches are automatically applied. - * RAM patches are applied once per frame. - * - ****************************************************************************/ -void CheatLoad(void) -{ - int len; - int cnt = 0; - char temp[256]; - - /* reset cheat count */ - maxcheats = 0; - - /* make cheat filename */ - sprintf(temp, "%s/cheats/%s.pat", DEFAULT_PATH, rom_filename); - - /* open file */ - FILE *f = fopen(temp, "r"); - if (f) - { - /* clear string */ - memset(temp, 0, 256); - - /* read cheats from file (one line per cheat) */ - while (fgets(temp, 256, f) && (maxcheats < MAX_CHEATS) && (cnt < MAX_CHEATS)) - { - /* remove CR & EOL chars */ - if ((temp[strlen(temp) - 2] == 0x0d) || (temp[strlen(temp) - 2] == 0x0a)) temp[strlen(temp) - 2] = 0; - else temp[strlen(temp) - 1] = 0; - - /* check cheat validty */ - len = decode_cheat(temp, maxcheats); - - if (len) - { - /* copy cheat code */ - strncpy(cheatlist[maxcheats].code, temp, len); - cheatlist[maxcheats].code[len] = 0; - len++; - - /* jump TAB and SPACE characters */ - while ((temp[len] == 0x20) || (temp[len] == 0x09)) len++; - - /* copy cheat description */ - strncpy(cheatlist[maxcheats].text, &temp[len], MAX_DESC_LENGTH - 1); - cheatlist[maxcheats].text[MAX_DESC_LENGTH - 1] = 0; - - /* increment cheat count */ - maxcheats++; - } - else if (!strcmp(temp,"ON") && config.autocheat) - { - /* enable flag */ - cheatlist[cnt++].enable = 1; - } - else if (!strcmp(temp,"OFF") && config.autocheat) - { - /* disable flag */ - cheatlist[cnt++].enable = 0; - } - } - - /* by default, disable cheats that were not flagged */ - while (cnt < maxcheats) cheatlist[cnt++].enable = 0; - - /* close file */ - fclose(f); - } - - /* apply ROM patches */ - apply_cheats(); - - /* adjust menu buttons */ - for (cnt=0; cnt<10; cnt++) - { - if (cnt < maxcheats) - { - menu_cheats.buttons[cnt].state |= BUTTON_ACTIVE; - menu_cheats.buttons[cnt].shift[1] = 1; - } - else if (cnt == maxcheats) - { - menu_cheats.buttons[cnt].state |= BUTTON_ACTIVE; - menu_cheats.buttons[cnt].shift[1] = 0; - } - else - { - menu_cheats.buttons[cnt].shift[1] = 0; - menu_cheats.buttons[cnt].state &= ~BUTTON_ACTIVE; - } - } - - /* reset menu */ - selection = offset = 0; -} - -/**************************************************************************** - * RAMCheatUpdate - * - * Apply RAM patches (this should be called once per frame) - * - ****************************************************************************/ -void RAMCheatUpdate(void) -{ - int index, cnt = maxRAMcheats; - - while (cnt) - { - /* get cheat index */ - index = cheatIndexes[--cnt]; - - /* apply RAM patch */ - if (cheatlist[index].data & 0xFF00) - { - /* word patch */ - *(u16 *)(work_ram + (cheatlist[index].address & 0xFFFE)) = cheatlist[index].data; - } - else - { - /* byte patch */ - work_ram[cheatlist[index].address & 0xFFFF] = cheatlist[index].data; - } - } -} - - -/**************************************************************************** - * ROMCheatUpdate - * - * Apply ROM patches (this should be called each time banking is changed) - * - ****************************************************************************/ -void ROMCheatUpdate(void) -{ - int index, cnt = maxROMcheats; - u8 *ptr; - - while (cnt) - { - /* get cheat index */ - index = cheatIndexes[MAX_CHEATS - cnt]; - - /* check if previous banked ROM address was patched */ - if (cheatlist[index].prev != NULL) - { - /* restore original data */ - *cheatlist[index].prev = cheatlist[index].old; - - /* no more patched ROM address */ - cheatlist[index].prev = NULL; - } - - /* get current banked ROM address */ - ptr = &z80_readmap[(cheatlist[index].address) >> 10][cheatlist[index].address & 0x03FF]; - - /* check if reference matches original ROM data */ - if (((u8)cheatlist[index].old) == *ptr) - { - /* patch data */ - *ptr = cheatlist[index].data; - - /* save patched ROM address */ - cheatlist[index].prev = ptr; - } - - /* next ROM patch */ - cnt--; - } -} diff --git a/genplus-gx/gx/gui/cheats.h b/genplus-gx/gx/gui/cheats.h deleted file mode 100644 index e6759a6a8a..0000000000 --- a/genplus-gx/gx/gui/cheats.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * cheats.c - * - * Cheats menu - * - * Copyright Eke-Eke (2010-2012) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _CHEATS_H -#define _CHEATS_H - -#define CHEATS_UPDATE() ROMCheatUpdate() - -extern void CheatMenu(void); -extern void CheatLoad(void); -extern void RAMCheatUpdate(void); -extern void ROMCheatUpdate(void); - -#endif diff --git a/genplus-gx/gx/gui/filesel.c b/genplus-gx/gx/gui/filesel.c deleted file mode 100644 index 0ed07a0c4c..0000000000 --- a/genplus-gx/gx/gui/filesel.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * filesel.c - * - * ROM File Browser - * - * Copyright Eke-Eke (2009-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "filesel.h" -#include "font.h" -#include "gui.h" -#include "file_load.h" -#include "history.h" - -#define BG_COLOR_1 {0x49,0x49,0x49,0xff} -#define BG_COLOR_2 {0x66,0x66,0x66,0xff} - -#define SCROLL_SPEED 10 - -extern const u8 Browser_dir_png[]; -extern const u8 Snap_empty_png[]; -extern const u8 Cart_md_png[]; -extern const u8 Cart_ms_png[]; -extern const u8 Cart_gg_png[]; -extern const u8 Cart_sg_png[]; - -FILEENTRIES filelist[MAXFILES]; - -static int offset = 0; -static int selection = 0; -static int maxfiles = 0; -static int string_offset = 0; -static char prev_folder[MAXJOLIET]; -static void selector_cb(void); - -/*****************************************************************************/ -/* GUI Buttons data */ -/*****************************************************************************/ -static butn_data arrow_up_data = -{ - {NULL,NULL}, - {Button_up_png,Button_up_over_png} -}; - -static butn_data arrow_down_data = -{ - {NULL,NULL}, - {Button_down_png,Button_down_over_png} -}; - -/*****************************************************************************/ -/* GUI Arrows button */ -/*****************************************************************************/ - -static gui_butn arrow_up = {&arrow_up_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{0,0,0,0},14,76,360,32}; -static gui_butn arrow_down = {&arrow_down_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{0,0,0,0},14,368,360,32}; - -/*****************************************************************************/ -/* GUI helpers */ -/*****************************************************************************/ -static gui_item action_cancel = -{ - NULL,Key_B_png,"","Previous Directory",10,422,28,28 -}; - -static gui_item action_select = -{ - NULL,Key_A_png,"","Load ROM file",602,422,28,28 -}; - -/*****************************************************************************/ -/* GUI Background images */ -/*****************************************************************************/ -static gui_image bg_filesel[14] = -{ - {NULL,Bg_layer_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255}, - {NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255}, - {NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255}, - {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,152}, - {NULL,Frame_s2_png,0,384,264,248,140,152}, - {NULL,Snap_empty_png,IMAGE_VISIBLE,424,148,160,112,255}, - {NULL,NULL,0,424,148,160,112,255}, - {NULL,NULL,0,388,147,240,152,255}, - {NULL,NULL,0,388,147,240,152,255}, - {NULL,NULL,0,392,118,232,148,255}, - {NULL,NULL,0,414,116,184,188,255}, - {NULL,NULL,0,416,144,180,228,255} -}; - -static const u8 *Cart_png[FILETYPE_MAX] = -{ - Cart_md_png, - Cart_md_png, - Cart_ms_png, - Cart_gg_png, - Cart_sg_png -}; - -static const char *Cart_dir[FILETYPE_MAX] = -{ - "md", - "cd", - "ms", - "gg", - "sg" -}; - -/*****************************************************************************/ -/* GUI Descriptor */ -/*****************************************************************************/ -static gui_menu menu_selector = -{ - "Game Selection", - -1,-1, - 0,0,14,0, - NULL, - NULL, - bg_filesel, - {&action_cancel, &action_select}, - {&arrow_up,&arrow_down}, - selector_cb -}; - - -static void selector_cb(void) -{ - int i; - char text[MAXPATHLEN]; - int yoffset = 108; - - /* Initialize directory icon */ - gui_image dir_icon; - dir_icon.texture = gxTextureOpenPNG(Browser_dir_png,0); - dir_icon.w = dir_icon.texture->width; - dir_icon.h = dir_icon.texture->height; - dir_icon.x = 26; - dir_icon.y = (26 - dir_icon.h)/2; - - /* Initialize selection bar */ - gui_image bar_over; - bar_over.texture = gxTextureOpenPNG(Overlay_bar_png,0); - bar_over.w = bar_over.texture->width; - bar_over.h = bar_over.texture->height; - bar_over.x = 16; - bar_over.y = (26 - bar_over.h)/2; - - /* Draw browser array */ - gxDrawRectangle(15, 108, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 134, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 160, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 186, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 212, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 238, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 264, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 290, 358, 26, 127, (GXColor)BG_COLOR_2); - gxDrawRectangle(15, 316, 358, 26, 127, (GXColor)BG_COLOR_1); - gxDrawRectangle(15, 342, 358, 26, 127, (GXColor)BG_COLOR_2); - - /* Draw Files list */ - for (i = offset; (i < (offset + 10)) && (i < maxfiles); i++) - { - if (i == selection) - { - /* selection bar */ - gxDrawTexture(bar_over.texture,bar_over.x,yoffset+bar_over.y,bar_over.w,bar_over.h,255); - - /* scrolling text */ - if ((string_offset/SCROLL_SPEED) >= strlen(filelist[i].filename)) - { - string_offset = 0; - } - - if (string_offset) - { - sprintf(text,"%s ",filelist[i].filename+string_offset/SCROLL_SPEED); - strncat(text, filelist[i].filename, string_offset/SCROLL_SPEED); - } - else - { - strcpy(text, filelist[i].filename); - } - - /* print text */ - if (filelist[i].flags) - { - /* directory icon */ - gxDrawTexture(dir_icon.texture,dir_icon.x,yoffset+dir_icon.y,dir_icon.w,dir_icon.h,255); - if (FONT_write(text,18,dir_icon.x+dir_icon.w+6,yoffset+22,bar_over.w-dir_icon.w-26,(GXColor)WHITE)) - { - /* text scrolling */ - string_offset ++; - } - } - else - { - if (FONT_write(text,18,dir_icon.x,yoffset+22,bar_over.w-20,(GXColor)WHITE)) - { - /* text scrolling */ - string_offset ++; - } - } - } - else - { - if (filelist[i].flags) - { - /* directory icon */ - gxDrawTexture(dir_icon.texture,dir_icon.x,yoffset+dir_icon.y,dir_icon.w,dir_icon.h,255); - FONT_write(filelist[i].filename,18,dir_icon.x+dir_icon.w+6,yoffset+22,bar_over.w-dir_icon.w-26,(GXColor)WHITE); - } - else - { - FONT_write(filelist[i].filename,18,dir_icon.x,yoffset+22,bar_over.w-20,(GXColor)WHITE); - } - } - - yoffset += 26; - } - - gxTextureClose(&bar_over.texture); - gxTextureClose(&dir_icon.texture); -} - - -/**************************************************************************** - * FileSelector - * - * Browse directories and select a file from the file listing - * return ROM size - * - ****************************************************************************/ -int FileSelector(int type) -{ - short p; - int i; - int old = -1; - char fname[MAXPATHLEN]; - FILE *snap; - gui_menu *m = &menu_selector; - -#ifdef HW_RVL - int x,y; - gui_butn *button; -#endif - - /* Background overlay */ - if (config.bg_overlay) - { - bg_filesel[1].state |= IMAGE_VISIBLE; - } - else - { - bg_filesel[1].state &= ~IMAGE_VISIBLE; - } - - /* Hide all cartridge labels */ - for (i=0; i select all cartridge type */ - for (i=0; i variable game types */ - if (type < 0) - { - /* hide all cartridge labels */ - for (i=0; i 0) && (fname[i] != '.')) i--; - if (i > 0) fname[i] = 0; - - /* add PNG file extension */ - strcat(fname, ".png"); - - /* try to load screenshot file */ - snap = fopen(fname, "rb"); - if (snap) - { - bg_filesel[8].texture = gxTextureOpenPNG(0,snap); - if (bg_filesel[8].texture) - { - bg_filesel[8].state |= IMAGE_VISIBLE; - } - fclose(snap); - } - } - } - - /* update helper */ - if (m->selected != -1) - { - /* out of focus */ - strcpy(action_select.comment,""); - } - else if (filelist[selection].flags) - { - /* this is a directory */ - strcpy(action_select.comment,"Open Directory"); - } - else - { - /* this is a ROM file */ - strcpy(action_select.comment,"Load File"); - } - - /* Draw menu*/ - GUI_DrawMenu(m); - -#ifdef HW_RVL - if (Shutdown) - { - gxTextureClose(&w_pointer); - GUI_DeleteMenu(m); - GUI_FadeOut(); - shutdown(); - SYS_ResetSystem(SYS_POWEROFF, 0, 0); - } - else if (m_input.ir.valid) - { - /* get cursor position */ - x = m_input.ir.x; - y = m_input.ir.y; - - /* draw wiimote pointer */ - gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); - - /* ensure we are in the selectable area */ - if ((x < 380) && (y >= 108) && (y <= 368)) - { - /* find selected item */ - selection = (y - 108) / 26; - if (selection > 9) selection = 9; - selection += offset; - if (selection >= maxfiles) selection = old; - - /* reset selection */ - m->selected = -1; - } - else - { - /* disable selection */ - m->selected = m->max_buttons + 2; - - /* find selected button */ - for (i=0; i<2; i++) - { - button = m->arrows[i]; - if (button) - { - if (button->state & BUTTON_VISIBLE) - { - if ((x>=button->x)&&(x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) - { - m->selected = m->max_buttons + i; - break; - } - } - } - } - } - } - else - { - /* reset selection */ - m->selected = -1; - } -#endif - - /* copy EFB to XFB */ - gxSetScreen(); - - p = m_input.keys; - - /* highlight next item */ - if (p & PAD_BUTTON_DOWN) - { - selection++; - if (selection == maxfiles) - selection = offset = 0; - if ((selection - offset) >= 10) - offset += 10; - } - - /* highlight previous item */ - else if (p & PAD_BUTTON_UP) - { - selection--; - if (selection < 0) - { - selection = maxfiles - 1; - offset = maxfiles - 10; - } - if (selection < offset) - offset -= 10; - if (offset < 0) - offset = 0; - } - - /* go back one page */ - else if (p & (PAD_TRIGGER_L | PAD_BUTTON_LEFT)) - { - if (maxfiles >= 10) - { - selection -= 10; - if (selection < 0) - { - selection = offset = 0; - } - else if (selection < offset) - { - offset -= 10; - if (offset < 0) offset = 0; - } - } - } - - /* go forward one page */ - else if (p & (PAD_TRIGGER_R | PAD_BUTTON_RIGHT)) - { - if (maxfiles >= 10) - { - selection += 10; - if (selection > maxfiles - 1) - { - /* last page */ - selection = maxfiles - 1; - offset = maxfiles - 10; - } - else if (selection >= (offset + 10)) - { - /* next page */ - offset += 10; - if (offset > (maxfiles - 10)) offset = maxfiles - 10; - } - } - } - - /* quit */ - else if (p & PAD_TRIGGER_Z) - { - GUI_DeleteMenu(m); - return 0; - } - - /* previous directory */ - else if (p & PAD_BUTTON_B) - { - string_offset = 0; - - /* update browser directory (and get current folder)*/ - if (UpdateDirectory(1, prev_folder)) - { - /* get directory entries */ - maxfiles = ParseDirectory(); - - /* clear selection by default */ - selection = offset = 0; - old = -1; - - /* select previous directory */ - for (i=0; i= (offset + 10)) - { - offset += 10; - if (offset > (maxfiles - 10)) offset = maxfiles - 10; - } - break; - } - } - } - else - { - /* exit */ - GUI_DeleteMenu(m); - return 0; - } - } - - /* open selected file or directory */ - else if (p & PAD_BUTTON_A) - { - string_offset = 0; - - /* ensure we are in focus area */ - if (m->selected < m->max_buttons) - { - if (filelist[selection].flags) - { - /* get new directory */ - UpdateDirectory(0, filelist[selection].filename); - - /* get directory entries */ - maxfiles = ParseDirectory(); - - /* clear selection by default */ - selection = offset = 0; - old = -1; - } - else - { - /* load ROM file from device */ - int ret = LoadFile(selection); - - /* exit menu */ - GUI_DeleteMenu(m); - - /* return ROM size (or zero if an error occured) */ - return ret; - } - } - -#ifdef HW_RVL - /* arrow buttons selected */ - else if (m->selected == m->max_buttons) - { - /* up arrow */ - selection--; - if (selection < 0) - { - selection = maxfiles - 1; - offset = selection - 10 + 1; - } - if (selection < offset) offset -= 10; - if (offset < 0) offset = 0; - } - else if (m->selected == (m->max_buttons+1)) - { - /* down arrow */ - selection++; - if (selection == maxfiles) - selection = offset = 0; - if ((selection - offset) >= 10) - offset += 10; - } -#endif - } - } -} - -void ClearSelector(u32 max) -{ - maxfiles = max; - offset = 0; - selection = 0; -} diff --git a/genplus-gx/gx/gui/filesel.h b/genplus-gx/gx/gui/filesel.h deleted file mode 100644 index 213e304f69..0000000000 --- a/genplus-gx/gx/gui/filesel.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * filesel.c - * - * ROM File Browser - * - * Copyright Eke-Eke (2009-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _FILESEL_H -#define _FILESEL_H - -#define MAXJOLIET 256 -#define MAXFILES 1000 - -/* Filelist structure */ -typedef struct -{ - u8 flags; - char filename[MAXJOLIET]; -}FILEENTRIES; - -/* Globals */ -extern int FileSelector(int type); -extern void ClearSelector(u32 max); -extern FILEENTRIES filelist[MAXFILES]; - -#endif diff --git a/genplus-gx/gx/gui/font.c b/genplus-gx/gx/gui/font.c deleted file mode 100644 index 36582147e1..0000000000 --- a/genplus-gx/gx/gui/font.c +++ /dev/null @@ -1,400 +0,0 @@ -/***************************************************************************** - * font.c - * - * IPL font engine (using GX rendering) - * - * Copyright Eke-Eke (2009-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "font.h" - -#define _SHIFTR(v, s, w) \ - ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) - -typedef struct _yay0header { - unsigned int id ATTRIBUTE_PACKED; - unsigned int dec_size ATTRIBUTE_PACKED; - unsigned int links_offset ATTRIBUTE_PACKED; - unsigned int chunks_offset ATTRIBUTE_PACKED; -} yay0header; - -static u8 *fontImage; -static u8 *fontTexture; -static void *ipl_fontarea; -static sys_fontheader *fontHeader; -static u8 font_size[256]; - -#ifndef HW_RVL - -/* disable Qoob Modchip before IPL access (emukiddid) */ -static void ipl_set_config(unsigned char c) -{ - volatile unsigned long* exi = (volatile unsigned long*)0xCC006800; - unsigned long val,addr; - addr=0xc0000000; - val = c << 24; - exi[0] = ((((exi[0]) & 0x405) | 256) | 48); //select IPL - //write addr of IPL - exi[0 * 5 + 4] = addr; - exi[0 * 5 + 3] = ((4 - 1) << 4) | (1 << 2) | 1; - while (exi[0 * 5 + 3] & 1); - //write the ipl we want to send - exi[0 * 5 + 4] = val; - exi[0 * 5 + 3] = ((4 - 1) << 4) | (1 << 2) | 1; - while (exi[0 * 5 + 3] & 1); - exi[0] &= 0x405; //deselect IPL -} - -#endif - -static void decode_szp(void *src,void *dest) -{ - u32 i,k,link; - u8 *dest8,*tmp; - u32 loff,coff,roff; - u32 size,cnt,cmask,bcnt; - yay0header *header; - - dest8 = (u8*)dest; - header = (yay0header*)src; - size = header->dec_size; - loff = header->links_offset; - coff = header->chunks_offset; - - roff = sizeof(yay0header); - cmask = 0; - cnt = 0; - bcnt = 0; - - do { - if(!bcnt) { - cmask = *(u32*)(src+roff); - roff += 4; - bcnt = 32; - } - - if(cmask&0x80000000) { - dest8[cnt++] = *(u8*)(src+coff); - coff++; - } else { - link = *(u16*)(src+loff); - loff += 2; - - tmp = dest8+(cnt-(link&0x0fff)-1); - k = link>>12; - if(k==0) { - k = (*(u8*)(src+coff))+18; - coff++; - } else k += 2; - - for(i=0;isheet_format==0x0000) { - cnt = (sys_fontdata->sheet_fullsize/2)-1; - - while(cnt>=0) { - idx = _SHIFTR(src[cnt],6,2); - val1 = data[idx]; - - idx = _SHIFTR(src[cnt],4,2); - val2 = data[idx]; - - dest[(cnt<<1)+0] =((val1&0xf0)|(val2&0x0f)); - - idx = _SHIFTR(src[cnt],2,2); - val1 = data[idx]; - - idx = _SHIFTR(src[cnt],0,2); - val2 = data[idx]; - - dest[(cnt<<1)+1] =((val1&0xf0)|(val2&0x0f)); - - cnt--; - } - } - DCStoreRange(dest,sys_fontdata->sheet_fullsize); -} - -static void GetFontTexel(s32 c,void *image,s32 pos,s32 stride) -{ - u32 sheets,rem; - u32 xoff,yoff; - u32 xpos,ypos; - u8 *img_start; - u8 *ptr1,*ptr2; - sys_fontheader *sys_fontdata = fontHeader; - - if(cfirst_char || c>sys_fontdata->last_char) c = sys_fontdata->inval_char; - else c -= sys_fontdata->first_char; - - sheets = sys_fontdata->sheet_column*sys_fontdata->sheet_row; - rem = c%sheets; - sheets = c/sheets; - xoff = (rem%sys_fontdata->sheet_column)*sys_fontdata->cell_width; - yoff = (rem/sys_fontdata->sheet_column)*sys_fontdata->cell_height; - img_start = fontImage+(sys_fontdata->sheet_size*sheets); - - ypos = 0; - while(yposcell_height) { - xpos = 0; - while(xposcell_width) { - ptr1 = img_start+(((sys_fontdata->sheet_width/8)<<5)*((ypos+yoff)/8)); - ptr1 = ptr1+(((xpos+xoff)/8)<<5); - ptr1 = ptr1+(((ypos+yoff)%8)<<2); - ptr1 = ptr1+(((xpos+xoff)%8)/2); - - ptr2 = image+((ypos/8)*(((stride<<1)/8)<<5)); - ptr2 = ptr2+(((xpos+pos)/8)<<5); - ptr2 = ptr2+(((xpos+pos)%8)/2); - ptr2 = ptr2+((ypos%8)<<2); - - *ptr2 = *ptr1; - - xpos += 2; - } - ypos++; - } -} - -static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor color) -{ - /* reintialize texture object */ - GXTexObj texobj; - GX_InitTexObj(&texobj, fontTexture, fontHeader->cell_width, fontHeader->cell_height, GX_TF_I4, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_LoadTexObj(&texobj, GX_TEXMAP0); - - /* reinitialize font texture data */ - memset(fontTexture,0,fontHeader->cell_width * fontHeader->cell_height / 2); - GetFontTexel(c,fontTexture,0,fontHeader->cell_width/2); - DCFlushRange(fontTexture, fontHeader->cell_width * fontHeader->cell_height / 2); - GX_InvalidateTexAll(); - - /* adjust texture width */ - s32 width = (fontHeader->cell_width * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); - - /* adjust texture height */ - size = (size * vmode->efbHeight) / 480; - - /* GX rendering */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(xpos, ypos - size); - GX_Color4u8(color.r, color.g, color.b, 0xff); - GX_TexCoord2f32(0.0, 0.0); - GX_Position2s16(xpos + width, ypos - size); - GX_Color4u8(color.r, color.g, color.b, 0xff); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(xpos + width, ypos); - GX_Color4u8(color.r, color.g, color.b, 0xff); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(xpos, ypos); - GX_Color4u8(color.r, color.g, color.b, 0xff); - GX_TexCoord2f32(0.0, 1.0); - GX_End(); - GX_DrawDone(); -} - -/**************************************************************************** - * IPL font support - * - ****************************************************************************/ -extern void __SYS_ReadROM(void *buf,u32 len,u32 offset); - -int FONT_Init(void) -{ -#ifndef HW_RVL - /* --- Game Cube --- disable Qoob before accessing IPL */ - ipl_set_config(6); -#endif - - /* read IPL font (ASCII) from Mask ROM */ - ipl_fontarea = memalign(32,131360); - if (!ipl_fontarea) - return 0; - memset(ipl_fontarea,0,131360); - __SYS_ReadROM(ipl_fontarea+119072,12288,0x1FCF00); - - /* YAY0 decompression */ - decode_szp(ipl_fontarea+119072,ipl_fontarea); - - /* retrieve IPL font data */ - fontHeader = (sys_fontheader*)ipl_fontarea; - fontImage = (u8*)((((u32)ipl_fontarea+fontHeader->sheet_image)+31)&~31); - - /* expand to I4 format */ - expand_font((u8*)ipl_fontarea+fontHeader->sheet_image,fontImage); - - /* character width table */ - int i,c; - for (i=0; i<256; ++i) - { - if ((i < fontHeader->first_char) || (i > fontHeader->last_char)) - c = fontHeader->inval_char; - else - c = i - fontHeader->first_char; - - font_size[i] = ((u8*)fontHeader)[fontHeader->width_table + c]; - } - - /* initialize texture data */ - fontTexture = memalign(32, fontHeader->cell_width * fontHeader->cell_height / 2); - if (!fontTexture) - { - free(ipl_fontarea); - return 0; - } - - return 1; -} - -void FONT_Shutdown(void) -{ - if (fontHeader) - free(ipl_fontarea); - if (fontTexture) - free(fontTexture); -} - -int FONT_write(char *string, int size, int x, int y, int max_width, GXColor color) -{ - int w, ox; - - x -= (vmode->fbWidth / 2); - y -= (vmode->efbHeight / 2); - - ox = x; - - while (*string) - { - if (*string == '\n') - { - x = ox; - y += size; - } - else - { - w = (font_size[(u8)*string] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); - if ((x + w) > (ox + max_width)) return strlen(string); - DrawChar(*string, x, y, size,color); - x += w; - } - string++; - } - - return 0; -} - -int FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color) -{ - int x; - int i = 0; - int w = 0; - - while (string[i] && (string[i] != '\n')) - { - w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); - } - - if ((x1 + w) > x2) w = x2 - x1; - x = x1 + (x2 - x1 - w - vmode->fbWidth) / 2; - x2 -= (vmode->fbWidth / 2); - y -= (vmode->efbHeight / 2); - - while (*string && (*string != '\n')) - { - w = (font_size[(u8)*string] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); - if ((x + w) > x2) return strlen(string); - DrawChar(*string, x, y, size,color); - x += w; - string++; - } - - if (*string == '\n') - { - string++; - return FONT_writeCenter(string, size, x1, x2 + (vmode->fbWidth / 2), y + size + (vmode->efbHeight / 2), color); - } - - return 0; -} - -int FONT_alignRight(char *string, int size, int x, int y, GXColor color) -{ - int ox; - int i = 0; - int w = 0; - - while (string[i] && (string[i] != '\n')) - { - w += (font_size[(u8)string[i++]] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); - } - - x -= (vmode->fbWidth / 2); - y -= (vmode->efbHeight / 2); - - ox = x; - x -= w; - - while (*string && (*string != '\n')) - { - w = (font_size[(u8)*string] * size * vmode->fbWidth) / (fontHeader->cell_height * vmode->viWidth); - if ((x + w) > ox) return strlen(string); - DrawChar(*string, x, y, size,color); - x += w; - string++; - } - - if (*string == '\n') - { - string++; - return FONT_alignRight(string, size, ox + (vmode->fbWidth / 2), y + size + (vmode->efbHeight / 2), color); - } - - return 0; -} diff --git a/genplus-gx/gx/gui/font.h b/genplus-gx/gx/gui/font.h deleted file mode 100644 index 8f516558af..0000000000 --- a/genplus-gx/gx/gui/font.h +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************************** - * font.c - * - * IPL font engine (using GX rendering) - * - * Copyright Eke-Eke (2009-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _FONT_H -#define _FONT_H - -extern int FONT_Init(void); -extern void FONT_Shutdown(void); -extern int FONT_write(char *string, int size, int x, int y, int max_width, GXColor color); -extern int FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color); -extern int FONT_alignRight(char *string, int size, int x, int y, GXColor color); - -#endif diff --git a/genplus-gx/gx/gui/gui.c b/genplus-gx/gx/gui/gui.c deleted file mode 100644 index 21fc49065e..0000000000 --- a/genplus-gx/gx/gui/gui.c +++ /dev/null @@ -1,1968 +0,0 @@ -/**************************************************************************** - * gui.c - * - * generic GUI Engine (using GX rendering) - * - * Copyright Eke-Eke (2009-2010) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "gui.h" -#include "font.h" - -#ifdef HW_RVL -gx_texture *w_pointer; -#endif - -u8 SILENT = 0; - -/* message box */ -static gui_message message_box; -static lwp_t msgboxthread; - -/* background color (black) */ -static const GXColor bg_color = {0x00,0x00,0x00,0xff}; - -/****************************************************************************/ -/* Generic GUI routines */ -/*****************************************************************************/ - -/* Allocate Menu texture images data */ -void GUI_InitMenu(gui_menu *menu) -{ - int i; - gui_item *item; - gui_butn *button; - gui_image *image; - - /* background elements */ - for (i=0; imax_images; i++) - { - image = &menu->bg_images[i]; - image->texture = gxTextureOpenPNG(image->data,0); - } - - for (i=0; i<2; i++) - { - /* key helpers */ - item = menu->helpers[i]; - if (item) - item->texture = gxTextureOpenPNG(item->data,0); - - /* arrows */ - button = menu->arrows[i]; - if (button) - { - if (!button->data->texture[0]) - button->data->texture[0] = gxTextureOpenPNG(button->data->image[0],0); - if (!button->data->texture[1]) - button->data->texture[1] = gxTextureOpenPNG(button->data->image[1],0); - - /* initial state */ - button->state &= ~BUTTON_VISIBLE; - if (((i==0) && (menu->offset != 0)) || ((i==1) && (menu->offset + menu->max_buttons) < menu->max_items)) - button->state |= BUTTON_VISIBLE; - } - } - - /* menu buttons */ - for (i=0; imax_buttons; i++) - { - button = &menu->buttons[i]; - if (button->data) - { - if (!button->data->texture[0]) - button->data->texture[0] = gxTextureOpenPNG(button->data->image[0],0); - if (!button->data->texture[1]) - button->data->texture[1] = gxTextureOpenPNG(button->data->image[1],0); - } - } - - /* menu items */ - for (i=0; imax_items; i++) - { - item = &menu->items[i]; - if (item->data) - item->texture = gxTextureOpenPNG(item->data,0); - } - - /* update message box */ - message_box.parent = menu; -} - -/* Release Menu allocated memory */ -void GUI_DeleteMenu(gui_menu *menu) -{ - int i; - gui_butn *button; - gui_item *item; - gui_image *image; - - /* background elements */ - for (i=0; imax_images; i++) - { - image = &menu->bg_images[i]; - gxTextureClose(&image->texture); - } - - for (i=0; i<2; i++) - { - /* key helpers */ - item = menu->helpers[i]; - if (item) - gxTextureClose(&item->texture); - - /* arrows */ - button = menu->arrows[i]; - if (button) - { - gxTextureClose(&button->data->texture[0]); - gxTextureClose(&button->data->texture[1]); - } - } - - /* menu buttons */ - for (i=0; imax_buttons; i++) - { - button = &menu->buttons[i]; - if (button->data) - { - gxTextureClose(&button->data->texture[0]); - gxTextureClose(&button->data->texture[1]); - } - } - - /* menu items */ - for (i=0; imax_items; i++) - { - item = &menu->items[i]; - gxTextureClose(&item->texture); - } -} - -extern void gxSnapshot(void); - -/* Draw Menu */ -void GUI_DrawMenu(gui_menu *menu) -{ - int i; - gui_item *item; - gui_butn *button; - gui_image *image; - - /* background color */ - if (menu->screenshot) - { - gxClearScreen((GXColor)BLACK); - gxDrawScreenshot(menu->screenshot); - } - else - { - gxClearScreen(bg_color); - } - - /* background elements */ - for (i=0; imax_images; i++) - { - image = &menu->bg_images[i]; - if (image->state & IMAGE_VISIBLE) - { - if (image->state & IMAGE_REPEAT) - gxDrawTextureRepeat(image->texture,image->x,image->y,image->w,image->h,image->alpha); - else - gxDrawTexture(image->texture,image->x,image->y,image->w,image->h,image->alpha); - } - } - - /* menu title */ - FONT_write(menu->title, 22,10,56,640,(GXColor)WHITE); - - /* draw buttons + items */ - for (i=0; imax_buttons; i++) - { - button = &menu->buttons[i]; - - if (button->state & BUTTON_VISIBLE) - { - /* item select (text or image) */ - item = (menu->items) ? (&menu->items[menu->offset + i]) : NULL; - - /* draw button + items */ - if ((i == menu->selected) || (button->state & BUTTON_SELECTED)) - { - if (button->data) - gxDrawTexture(button->data->texture[1],button->x-4,button->y-4,button->w+8,button->h+8,255); - - if (item) - { - if (item->texture) - { - gxDrawTexture(item->texture, item->x-4,item->y-4,item->w+8,item->h+8,255); - FONT_writeCenter(item->text,18,button->x+4,item->x-4,button->y+(button->h - 36)/2+18,(GXColor)DARK_GREY); - } - else - { - FONT_writeCenter(item->text,18,item->x-4,item->x+item->w+4,button->y+(button->h-18)/2+18,(GXColor)DARK_GREY); - } - } - } - else - { - if (button->data) - gxDrawTexture(button->data->texture[0],button->x,button->y,button->w, button->h,255); - - if (item) - { - if (item->texture) - { - gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); - FONT_writeCenter(item->text,16,button->x+8,item->x,button->y+(button->h - 32)/2+16,(GXColor)DARK_GREY); - } - else - { - FONT_writeCenter(item->text,16,item->x,item->x+item->w,button->y+(button->h - 16)/2+16,(GXColor)DARK_GREY); - } - } - } - } - } - - /* draw arrow */ - for (i=0; i<2; i++) - { - button = menu->arrows[i]; - if (button) - { - if (button->state & BUTTON_VISIBLE) - { - if (menu->selected == (menu->max_buttons + i)) - gxDrawTexture(button->data->texture[1],button->x-2,button->y-2,button->w+4,button->h+4,255); - else - gxDrawTexture(button->data->texture[0],button->x,button->y,button->w, button->h,255); - } - } - } - - /* left comment */ - item = menu->helpers[0]; - if (item) - { - if (item->data && strlen(item->comment)) - { - gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); - FONT_write(item->comment,16,item->x+item->w+6,item->y+(item->h-16)/2 + 16,640,(GXColor)WHITE); - } - } - - /* right comment */ - item = menu->helpers[1]; - if (item) - { - if (item->data && strlen(item->comment)) - { - gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); - FONT_alignRight(item->comment,16,item->x-6,item->y+(item->h-16)/2+16,(GXColor)WHITE); - } - } - - if (menu->cb) - menu->cb(); -} - -/* Draw Menu with transitions effects */ -void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out) -{ - int i,temp,xoffset,yoffset; - int max_offset = 0; - u8 item_alpha = 255; - GXColor text_color = DARK_GREY; - gui_item *item; - gui_butn *button; - gui_image *image; - - /* find maximal offset */ - for (i=0; imax_images; i++) - { - image = &menu->bg_images[i]; - - if (image->state & IMAGE_SLIDE_LEFT) - { - temp = image->x + image->w; - if (max_offset < temp) - max_offset = temp; - } - else if (image->state & IMAGE_SLIDE_RIGHT) - { - temp = 640 - image->x; - if (max_offset < temp) - max_offset = temp; - } - - if (image->state & IMAGE_SLIDE_TOP) - { - temp = image->y + image->h; - if (max_offset < temp) - max_offset = temp; - } - else if (image->state & IMAGE_SLIDE_BOTTOM) - { - temp = 480 - image->y; - if (max_offset < temp) - max_offset = temp; - } - } - - temp = max_offset; - - /* Alpha steps */ - int alpha = 0; - int alpha_step = (255 * speed) / max_offset; - if (out) - { - alpha = 255; - alpha_step = -alpha_step; - } - - /* Let's loop until final position has been reached */ - while (temp > 0) - { - /* background color */ - if (menu->screenshot) - { - gxClearScreen((GXColor)BLACK); - if (alpha >= menu->screenshot) - gxDrawScreenshot(menu->screenshot); - else - gxDrawScreenshot(255 - alpha); - } - else - { - gxClearScreen(bg_color); - } - - /* background images */ - for (i=0; imax_images; i++) - { - image = &menu->bg_images[i]; - - /* X offset */ - if (image->state & IMAGE_SLIDE_LEFT) - xoffset = out ? (temp - max_offset) : (-temp); - else if (image->state & IMAGE_SLIDE_RIGHT) - xoffset = out ? (max_offset - temp) : (temp); - else - xoffset = 0; - - /* Y offset */ - if (image->state & IMAGE_SLIDE_TOP) - yoffset = out ? (temp - max_offset) : (-temp); - else if (image->state & IMAGE_SLIDE_BOTTOM) - yoffset = out ? (max_offset - temp) : (temp); - else - yoffset = 0; - - /* draw image */ - if ((image->state & IMAGE_FADE) && ((out && (image->alpha > alpha)) || (!out && (image->alpha < alpha)))) - { - /* FADE In-Out */ - if (image->state & IMAGE_VISIBLE) - { - if (image->state & IMAGE_REPEAT) - gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha); - else - gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,alpha); - } - } - else - { - if (image->state & IMAGE_VISIBLE) - { - if (image->state & IMAGE_REPEAT) - gxDrawTextureRepeat(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha); - else - gxDrawTexture(image->texture,image->x+xoffset,image->y+yoffset,image->w,image->h,image->alpha); - } - } - } - - /* menu title */ - if ((menu->bg_images[2].state & IMAGE_SLIDE_TOP) || (menu->bg_images[3].state & IMAGE_SLIDE_TOP)) - FONT_write(menu->title, 22,10,out ? (56 + temp - max_offset) : (56 - temp),640,(GXColor)WHITE); - else - FONT_write(menu->title, 22,10,56,640,(GXColor)WHITE); - - /* draw buttons + items */ - for (i=0; imax_buttons; i++) - { - button = &menu->buttons[i]; - - if (button->state & BUTTON_VISIBLE) - { - /* X offset */ - if (button->state & BUTTON_SLIDE_LEFT) - xoffset = out ? (temp - max_offset) : (-temp); - else if (button->state & BUTTON_SLIDE_RIGHT) - xoffset = out ? (max_offset - temp) : (temp); - else - xoffset = 0; - - /* Y offset */ - if (button->state & BUTTON_SLIDE_TOP) - yoffset = out ? (temp - max_offset) : (-temp); - else if (button->state & BUTTON_SLIDE_BOTTOM) - yoffset = out ? (max_offset - temp) : (temp); - else - yoffset = 0; - - /* Alpha transparency */ - if (button->state & BUTTON_FADE) - { - item_alpha = alpha; - text_color.a = alpha; - } - else - { - item_alpha = 255; - text_color.a = 255; - } - - /* item select (text or image) */ - item = (menu->items) ? (&menu->items[menu->offset + i]) : NULL; - - /* draw button + items */ - if ((i == menu->selected) || (button->state & BUTTON_SELECTED)) - { - if (button->data) - gxDrawTexture(button->data->texture[1],button->x+xoffset-4,button->y+yoffset-4,button->w+8,button->h+8,item_alpha); - - if (item) - { - if (item->texture) - { - gxDrawTexture(item->texture, item->x+xoffset-4,item->y+yoffset-4,item->w+8,item->h+8,item_alpha); - FONT_writeCenter(item->text,18,button->x+xoffset+4,item->x+xoffset-4,button->y+yoffset+(button->h - 36)/2+18,text_color); - } - else - { - FONT_writeCenter(item->text,18,item->x+xoffset+2,item->x+item->w+xoffset+2,button->y+yoffset+(button->h-18)/2+18,text_color); - } - } - } - else - { - if (button->data) - gxDrawTexture(button->data->texture[0],button->x+xoffset,button->y+yoffset,button->w, button->h,item_alpha); - - if (item) - { - if (item->texture) - { - gxDrawTexture(item->texture,item->x+xoffset,item->y+yoffset,item->w,item->h,item_alpha); - FONT_writeCenter(item->text,16,button->x+xoffset+8,item->x+xoffset,button->y+yoffset+(button->h - 32)/2+16,text_color); - } - else - { - FONT_writeCenter(item->text,16,item->x+xoffset,item->x+item->w+xoffset,button->y+yoffset+(button->h - 16)/2+16,text_color); - } - } - } - } - } - - /* draw arrow */ - for (i=0; i<2; i++) - { - button = menu->arrows[i]; - if (button) - { - if (button->state & BUTTON_VISIBLE) - { - if (menu->selected == (menu->max_buttons + i)) - gxDrawTexture(button->data->texture[1],button->x-2,button->y-2,button->w+4,button->h+4,255); - else - gxDrawTexture(button->data->texture[0],button->x,button->y,button->w, button->h,255); - } - } - } - - if (!(menu->bg_images[3].state & IMAGE_SLIDE_BOTTOM) && !(menu->bg_images[4].state & IMAGE_SLIDE_BOTTOM)) - { - /* left comment */ - item = menu->helpers[0]; - if (item) - { - if (item->data && strlen(item->comment)) - { - gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); - FONT_write(item->comment,16,item->x+item->w+6,item->y+(item->h-16)/2 + 16,640,(GXColor)WHITE); - } - } - - /* right comment */ - item = menu->helpers[1]; - if (item) - { - if (item->data && strlen(item->comment)) - { - gxDrawTexture(item->texture,item->x,item->y,item->w,item->h,255); - FONT_alignRight(item->comment,16,item->x-6,item->y+(item->h-16)/2+16,(GXColor)WHITE); - } - } - } - - if (menu->cb) - menu->cb(); - - /* update offset */ - temp -= speed; - - /* update alpha */ - alpha += alpha_step; - if (alpha > 255) - alpha = 255; - else if (alpha < 0) - alpha = 0; - - - /* copy EFB to XFB */ - gxSetScreen(); - } - - /* final position */ - if (!out) - { - GUI_DrawMenu(menu); - gxSetScreen(); - } - else if (menu->screenshot) - { - gxClearScreen((GXColor)BLACK); - gxDrawScreenshot(255); - gxSetScreen(); - } -} - -/* Basic menu title slide effect */ -void GUI_SlideMenuTitle(gui_menu *m, int title_offset) -{ -#ifdef HW_RVL - gui_butn *button; - int i,x,y; -#endif - - char title[64]; - strcpy(title,m->title); - - while (title_offset > 0) - { - /* update title */ - strcpy(m->title,title+title_offset); - m->title[strlen(title)-title_offset-1] = 0; - - /* draw menu */ - GUI_DrawMenu(m); - -#ifdef HW_RVL - /* keep pointer active */ - if (m_input.ir.valid) - { - /* get cursor position */ - x = m_input.ir.x; - y = m_input.ir.y; - - /* draw wiimote pointer */ - gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); - - /* check for valid buttons */ - m->selected = m->max_buttons + 2; - for (i=0; imax_buttons; i++) - { - button = &m->buttons[i]; - if ((button->state & BUTTON_ACTIVE)&&(x>=button->x)&&(x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) - { - m->selected = i; - break; - } - } - - for (i=0; i<2; i++) - { - button = m->arrows[i]; - if (button) - { - if (button->state & BUTTON_VISIBLE) - { - if ((x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) - { - m->selected = m->max_buttons + i; - break; - } - } - } - } - } -#endif - gxSetScreen(); - usleep(6000); - title_offset--; - } - strcpy(m->title,title); -} - -/* Update current menu */ -int GUI_UpdateMenu(gui_menu *menu) -{ - u16 p; - int ret = 0; - int selected = menu->selected; - int max_items = menu->max_items; - int max_buttons = menu->max_buttons; - gui_butn *button; - -#ifdef HW_RVL - if (Shutdown) - { - GUI_DeleteMenu(menu); - GUI_FadeOut(); - shutdown(); - SYS_ResetSystem(SYS_POWEROFF, 0, 0); - } - else if (m_input.ir.valid) - { - /* get cursor position */ - int x = m_input.ir.x; - int y = m_input.ir.y; - - /* draw wiimote pointer */ - gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); - - /* check for valid buttons */ - selected = max_buttons + 2; - int i; - for (i=0; ibuttons[i]; - if ((button->state & BUTTON_ACTIVE) && (button->state & BUTTON_VISIBLE)) - { - if((x>=button->x)&&(x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) - { - selected = i; - break; - } - } - } - - for (i=0; i<2; i++) - { - button = menu->arrows[i]; - if (button) - { - if ((button->state & BUTTON_ACTIVE) && (button->state & BUTTON_VISIBLE)) - { - if ((x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h))) - { - selected = max_buttons + i; - break; - } - } - } - } - } - else - { - /* reinitialize selection */ - if (selected >= menu->max_buttons) - { - selected = 0; - while ((selected < (menu->max_buttons + 2)) && - (!(menu->buttons[selected].state & BUTTON_ACTIVE) || - !(menu->buttons[selected].state & BUTTON_VISIBLE))) - selected++; - } - } -#endif - - /* update screen */ - gxSetScreen(); - - /* update menu */ - p = m_input.keys; - - if (selected < max_buttons) - { - button = &menu->buttons[selected]; - if (p & PAD_BUTTON_UP) - { - selected -= button->shift[0]; - if (selected < 0) - { - selected = 0; - if (menu->offset) - menu->offset --; - } - } - else if (p & PAD_BUTTON_DOWN) - { - selected += button->shift[1]; - if (selected >= max_buttons) - { - selected = max_buttons - 1; - if ((menu->offset + selected) < (max_items - 1)) - menu->offset ++; - } - } - else if (p & PAD_BUTTON_LEFT) - { - selected -= button->shift[2]; - if (selected < 0) - { - selected = 0; - if (menu->offset) - menu->offset --; - } - } - else if (p & PAD_BUTTON_RIGHT) - { - selected += button->shift[3]; - if (selected >= max_buttons) - { - selected = max_buttons - 1; - if ((menu->offset + selected) < (max_items - 1)) - menu->offset ++; - } - } - } - - if (p & PAD_BUTTON_A) - { - if (selected < max_buttons) - ret = 1; /* menu clicked */ - else if (selected == max_buttons) - menu->offset --; /* up arrow */ - else if (selected == (max_buttons+1)) - menu->offset ++; /* down arrow */ - } - else if ((p & PAD_BUTTON_B) || (p & PAD_TRIGGER_Z)) - { - /* quit menu */ - ret = -1; - } - - /* selected item has changed ? */ - if (menu->selected != selected) - { - if (selected < max_buttons) - { - /* sound fx */ - button = &menu->buttons[selected]; - if (button->state & BUTTON_OVER_SFX) - { - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, - ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); - } - } - else if (selected < (max_buttons + 2)) - { - /* sound fx */ - button = menu->arrows[selected-max_buttons]; - if (button->state & BUTTON_OVER_SFX) - { - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, - ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); - } - } - - /* update selection */ - menu->selected = selected; - } - - /* update helper comment */ - if (menu->helpers[1]) - { - if ((menu->offset + selected) < max_items) - { - gui_item *item = &menu->items[menu->offset + selected]; - strcpy(menu->helpers[1]->comment,item->comment); - } - else - { - strcpy(menu->helpers[1]->comment,""); - } - } - - if (ret > 0) - { - if (selected < max_buttons) - { - /* sound fx */ - button = &menu->buttons[selected]; - if (button->state & BUTTON_SELECT_SFX) - { - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_select_pcm,button_select_pcm_size, - ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); - } - } - } - - return ret; -} - -/* Generic routine to render & update menus */ -int GUI_RunMenu(gui_menu *menu) -{ - int update = 0; - - /* update menu */ - while (!update) - { - GUI_DrawMenu(menu); - update = GUI_UpdateMenu(menu); - - /* update arrows buttons status (items list) */ - if (menu->arrows[0]) - { - if (menu->offset > 0) - menu->arrows[0]->state |= BUTTON_VISIBLE; - else - menu->arrows[0]->state &= ~BUTTON_VISIBLE; - } - - if (menu->arrows[1]) - { - if ((menu->offset + menu->max_buttons) < menu->max_items) - menu->arrows[1]->state |= BUTTON_VISIBLE; - else - menu->arrows[1]->state &= ~BUTTON_VISIBLE; - } - } - - if (update == 2) - return (-2-menu->offset-menu->selected); - else if (update == 1) - return (menu->offset + menu->selected); - else - return -1; - } - -/* Text Window */ -void GUI_TextWindow(gui_menu *parent, char *title, char items[][64], u8 nb_items, u8 fontsize) -{ - int i, quit = 0; - -#ifdef HW_RVL - int x,y; -#endif - - /* initialize window */ - gx_texture *window = gxTextureOpenPNG(Frame_s1_png,0); - gx_texture *top = gxTextureOpenPNG(Frame_s1_title_png,0); - - /* window position */ - int xwindow = (640 - window->width) /2; - int ywindow = (480 - window->height)/2; - - /* text position */ - int ypos = ywindow + top->height + (window->height - top->height - fontsize*nb_items) / 2 + fontsize/2; - - /* disable helper comment */ - const u8 *data = NULL; - if (parent->helpers[1]) - { - data = parent->helpers[1]->data; - parent->helpers[1]->data = NULL; - } - - /* slide in */ - int yoffset = ywindow + window->height; - while (yoffset > 0) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); - gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); - - /* draw title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* draw text */ - for (i=0; iwidth,ypos+i*fontsize-yoffset,(GXColor)WHITE); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset -= 60; - } - - /* draw menu + text window */ - while (quit == 0) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230); - gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255); - - /* draw title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20,(GXColor)WHITE); - - /* draw text */ - for (i=0; iwidth,ypos+i*fontsize,(GXColor)WHITE); - } - -#ifdef HW_RVL - if (Shutdown) - { - gxTextureClose(&window); - gxTextureClose(&top); - gxTextureClose(&w_pointer); - GUI_DeleteMenu(parent); - GUI_FadeOut(); - shutdown(); - SYS_ResetSystem(SYS_POWEROFF, 0, 0); - } - else if (m_input.ir.valid) - { - /* get cursor position */ - x = m_input.ir.x; - y = m_input.ir.y; - - /* draw wiimote pointer */ - gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); - } -#endif - - /* update screen */ - gxSetScreen(); - - /* wait for exit buttons */ - if (m_input.keys) - quit = 1; - } - - /* reset initial vertical offset */ - - /* slide out */ - yoffset = 0; - while (yoffset < (ywindow + window->height)) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); - gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); - - /* draw title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* draw text */ - for (i=0; iwidth,ypos+i*fontsize-yoffset,(GXColor)WHITE); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset += 60; - } - - /* restore helper comment */ - if (parent->helpers[1]) - parent->helpers[1]->data = data; - - /* final position */ - GUI_DrawMenu(parent); - gxSetScreen(); - - /* close textures */ - gxTextureClose(&window); - gxTextureClose(&top); -} - -/* Option Window (returns selected item) */ -int GUI_OptionWindow(gui_menu *parent, char *title, char *items[], u8 nb_items) -{ - int i, ret, quit = 0; - int old, selected = 0; - s16 p; - butn_data button; - -#ifdef HW_RVL - int x,y; -#endif - - /* initialize buttons data */ - button.texture[0] = gxTextureOpenPNG(Button_text_png,0); - button.texture[1] = gxTextureOpenPNG(Button_text_over_png,0); - - /* initialize texture window */ - gx_texture *window = gxTextureOpenPNG(Frame_s1_png,0); - gx_texture *top = gxTextureOpenPNG(Frame_s1_title_png,0); - - /* get initial positions */ - int w = button.texture[0]->width; - int h = button.texture[0]->height; - int xwindow = (640 - window->width)/2; - int ywindow = (480 - window->height)/2; - int xpos = xwindow + (window->width - w)/2; - int ypos = (window->height - top->height - (h*nb_items) - (nb_items-1)*20)/2; - ypos = ypos + ywindow + top->height; - - /* disable helper comment */ - const u8 *data = NULL; - if (parent->helpers[1]) - { - data = parent->helpers[1]->data; - parent->helpers[1]->data = 0; - } - - /* slide in */ - int yoffset = ywindow + window->height; - while (yoffset > 0) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); - gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); - - /* draw title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* draw buttons + text */ - for (i=0; iwidth,window->height,230); - gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255); - - /* draw title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20,(GXColor)WHITE); - - /* draw buttons + text */ - for (i=0; iwidth/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); - - /* check for valid buttons */ - selected = -1; - for (i=0; i=xpos)&&(x<=(xpos+w))&&(y>=ypos+i*(20 + h))&&(y<=(ypos+i*(20+h)+h))) - { - selected = i; - break; - } - } - } - else - { - /* reinitialize selection */ - if (selected == -1) - selected = 0; - } -#endif - - /* update screen */ - gxSetScreen(); - - /* update selection */ - if (p & PAD_BUTTON_UP) - { - if (selected > 0) - selected --; - } - else if (p & PAD_BUTTON_DOWN) - { - if (selected < (nb_items -1)) - selected ++; - } - - /* sound fx */ - if (selected != old) - { - if (selected >= 0) - { - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, - ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); - } - } - - if (p & PAD_BUTTON_A) - { - if (selected >= 0) - { - quit = 1; - ret = selected; - } - } - else if (p & PAD_BUTTON_B) - { - quit = 1; - ret = -1; - } - } - - /* slide out */ - yoffset = 0; - while (yoffset < (ywindow + window->height)) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window + header */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); - gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); - - /* draw title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* draw buttons + text */ - for (i=0; ihelpers[1]) - parent->helpers[1]->data = data; - - /* final position */ - GUI_DrawMenu(parent); - gxSetScreen(); - - /* close textures */ - gxTextureClose(&window); - gxTextureClose(&top); - gxTextureClose(&button.texture[0]); - gxTextureClose(&button.texture[1]); - - return ret; -} - -/* Option Box */ -void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type) -{ - gx_texture *arrow[2]; - arrow[0] = gxTextureOpenPNG(Button_arrow_png,0); - arrow[1] = gxTextureOpenPNG(Button_arrow_over_png,0); - gx_texture *window = gxTextureOpenPNG(Frame_s2_png,0); - gx_texture *top = gxTextureOpenPNG(Frame_s2_title_png,0); - - /* window position */ - int xwindow = 166; - int ywindow = 160; - - /* arrows position */ - int xleft = 206; - int xright = 392; - int yleft = 238; - int yright = 238; - - /* disable action button helper */ - if (parent->helpers[1]) - parent->helpers[1]->data = 0; - - /* slide in */ - char msg[16]; - int yoffset = ywindow + window->height; - while (yoffset > 0) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,225); - gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); - - /* display title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset -= 60; - } - - /* display option box */ - int quit = 0; - int modified = 0; - int selected = -1; - s16 p; -#ifdef HW_RVL - int x,y; -#endif - - while (!quit) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow,window->width,window->height,225); - gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255); - - /* display title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20,(GXColor)WHITE); - - /* option type */ - if (type) - { - /* integer type */ - if (*(s16 *)option < 0) - sprintf(msg,"-%d",abs(*(s16 *)option)); - else - sprintf(msg,"%d",abs(*(s16 *)option)); - } - else - { - /* float type */ - if (*(float *)option < 0.0) - sprintf(msg,"-%1.2f",fabs(*(float *)option)); - else - sprintf(msg,"%1.2f",fabs(*(float *)option)); - } - - /* draw option text */ - FONT_writeCenter(msg,24,xwindow,xwindow+window->width,272,(GXColor)WHITE); - - /* update inputs */ - p = m_input.keys; - - /* draw buttons */ - if (selected < 0) - { - /* nothing selected */ - gxDrawTexture(arrow[0],xleft,yleft,arrow[0]->width,arrow[0]->height,255); - gxDrawTextureRotate(arrow[0],xright,yright,arrow[0]->width,arrow[0]->height,180.0,255); - } - -#ifdef HW_RVL - else if (selected) - { - /* right button selected */ - gxDrawTexture(arrow[0],xleft,yleft,arrow[0]->width,arrow[0]->height,255); - gxDrawTextureRotate(arrow[1],xright-4,yright-4,arrow[1]->width+8,arrow[1]->height+8,180.0,255); - } - else - { - /* left button selected */ - gxDrawTexture(arrow[1],xleft-4,yleft-4,arrow[1]->width+8,arrow[1]->height+8,255); - gxDrawTextureRotate(arrow[0],xright,yright,arrow[0]->width,arrow[0]->height,180.0,255); - } - - selected = -1; - if (Shutdown) - { - gxTextureClose(&arrow[0]); - gxTextureClose(&arrow[1]); - gxTextureClose(&window); - gxTextureClose(&top); - gxTextureClose(&w_pointer); - GUI_DeleteMenu(parent); - GUI_FadeOut(); - shutdown(); - SYS_ResetSystem(SYS_POWEROFF, 0, 0); - } - else if (m_input.ir.valid) - { - /* get cursor position */ - x = m_input.ir.x; - y = m_input.ir.y; - - /* draw wiimote pointer */ - gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); - - /* check for valid buttons */ - if ((x>=xleft)&&(x<=(xleft+arrow[0]->width))&&(y>=yleft)&&(y<=(yleft+arrow[0]->height))) - { - selected = 0; - if (p & PAD_BUTTON_A) - p |= PAD_BUTTON_LEFT; - } - else if ((x>=xright)&&(x<=(xright+arrow[0]->width))&&(y>=yright)&&(y<=(yright+arrow[0]->height))) - { - selected = 1; - if (p & PAD_BUTTON_A) - p |= PAD_BUTTON_RIGHT; - } - } -#endif - - /* update screen */ - gxSetScreen(); - - /* check input */ - if (p&PAD_BUTTON_LEFT) - { - /* decrement option value */ - if (type) - { - /* integer type */ - *(s16 *)option -= (s16)step; - if (*(s16 *)option < (s16)min) - *(s16 *)option = (s16)max; - } - else - { - /* float type */ - *(float *)option -= step; - if (*(float *)option < min) - *(float *)option = max; - } - - modified = 1; - } - else if (p&PAD_BUTTON_RIGHT) - { - /* increment option value */ - if (type) - { - /* integer type */ - *(s16 *)option += (s16)step; - if (*(s16 *)option > (s16)max) - *(s16 *)option = (s16)min; - } - else - { - /* float type */ - *(float *)option += step; - if (*(float *)option > max) - *(float *)option = min; - } - - modified = 1; - } - else if (p & PAD_BUTTON_B) - { - quit = 1; - } - - if (modified) - { - modified = 0; - - /* play sound effect */ - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, - ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); - - /* option callback */ - if (cb) - cb(); - } - } - - /* slide out */ - yoffset = 0; ; - while (yoffset < (ywindow + window->height)) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,225); - gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); - - /* display title */ - FONT_writeCenter(title,20,xwindow,xwindow+window->width,ywindow+(top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset += 60; - } - - /* restore action button helper */ - if (parent->helpers[1]) - parent->helpers[1]->data = Key_A_png; - - /* final position */ - GUI_DrawMenu(parent); - gxSetScreen(); - - /* close textures */ - gxTextureClose(&arrow[0]); - gxTextureClose(&arrow[1]); - gxTextureClose(&window); - gxTextureClose(&top); -} - -/* Option Box with two parameters */ -void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1, s16 *option_2, s16 step, s16 min, s16 max) -{ - gx_texture *arrow[2]; - arrow[0] = gxTextureOpenPNG(Button_arrow_png,0); - arrow[1] = gxTextureOpenPNG(Button_arrow_over_png,0); - gx_texture *window = gxTextureOpenPNG(Frame_s2_png,0); - - /* window position */ - int xwindow = 166; - int ywindow = 160; - - /* arrows position */ - int arrow_pos[4][2] = - { - {144,218}, - {452,218}, - {298,138}, - {298,298} - }; - - /* disable action button helper */ - if (parent->helpers[1]) - parent->helpers[1]->data = 0; - - /* slide in */ - char msg[16]; - int yoffset = ywindow + window->height; - while (yoffset > 0) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,225); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset -= 60; - } - - /* display option box */ - int quit = 0; - int modified = 0; - s16 p; -#ifdef HW_RVL - int selected = -1; - int i,x,y; -#endif - - while (!quit) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow,window->width,window->height,225); - - /* draw options text */ - if (*option_1 < 0) - sprintf(msg,"%s: -%02d",text_1,abs(*option_1)); - else - sprintf(msg,"%s: +%02d",text_1,abs(*option_1)); - FONT_writeCenter(msg,24,xwindow,xwindow+window->width,240,(GXColor)WHITE); - if (*option_2 < 0) - sprintf(msg,"%s: -%02d",text_2,abs(*option_2)); - else - sprintf(msg,"%s: +%02d",text_2,abs(*option_2)); - FONT_writeCenter(msg,24,xwindow,xwindow+window->width,264,(GXColor)WHITE); - - /* update inputs */ - p = m_input.keys; - - /* draw buttons */ -#ifdef HW_RVL - switch (selected) - { - case 0: /* left button */ - gxDrawTexture(arrow[1],arrow_pos[0][0]-4,arrow_pos[0][1]-4,arrow[0]->width+8,arrow[0]->height+8,255); - gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); - if (p & PAD_BUTTON_A) p |= PAD_BUTTON_LEFT; - break; - - case 1: /* right button */ - gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); - gxDrawTextureRotate(arrow[1],arrow_pos[1][0]-4,arrow_pos[1][1]-4,arrow[0]->width+8,arrow[0]->height+8,180.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); - if (p & PAD_BUTTON_A) p |= PAD_BUTTON_RIGHT; - break; - - case 2: /* up button */ - gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); - gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); - gxDrawTextureRotate(arrow[1],arrow_pos[2][0]-4,arrow_pos[2][1]-4,arrow[0]->width+8,arrow[0]->height+8,90.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); - if (p & PAD_BUTTON_A) p |= PAD_BUTTON_UP; - break; - - case 3: /* down button */ - gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); - gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); - gxDrawTextureRotate(arrow[1],arrow_pos[3][0]-4,arrow_pos[3][1]-4,arrow[0]->width+8,arrow[0]->height+8,270.0,255); - if (p & PAD_BUTTON_A) p |= PAD_BUTTON_DOWN; - break; - - default: /* nothing selected */ - gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); - gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); - break; - } - - if (Shutdown) - { - gxTextureClose(&arrow[0]); - gxTextureClose(&arrow[1]); - gxTextureClose(&window); - gxTextureClose(&w_pointer); - GUI_DeleteMenu(parent); - GUI_FadeOut(); - shutdown(); - SYS_ResetSystem(SYS_POWEROFF, 0, 0); - } - - /* update selection */ - selected = -1; - if (m_input.ir.valid) - { - /* get cursor position */ - x = m_input.ir.x; - y = m_input.ir.y; - - /* draw wiimote pointer */ - gxDrawTextureRotate(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,m_input.ir.angle,255); - - /* check for valid buttons */ - for (i=0; i<4; i++) - { - if ((x>=arrow_pos[i][0])&&(x<=(arrow_pos[i][0]+arrow[0]->width))&&(y>=arrow_pos[i][1])&&(y<=(arrow_pos[i][1]+arrow[0]->height))) - selected = i; - } - } -#else - gxDrawTexture(arrow[0],arrow_pos[0][0],arrow_pos[0][1],arrow[0]->width,arrow[0]->height,255); - gxDrawTextureRotate(arrow[0],arrow_pos[1][0],arrow_pos[1][1],arrow[0]->width,arrow[0]->height,180.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[2][0],arrow_pos[2][1],arrow[0]->width,arrow[0]->height,90.0,255); - gxDrawTextureRotate(arrow[0],arrow_pos[3][0],arrow_pos[3][1],arrow[0]->width,arrow[0]->height,270.0,255); -#endif - - /* update screen */ - gxSetScreen(); - - if (p&PAD_BUTTON_LEFT) - { - /* decrement option 1 value */ - *option_1 -= step; - if (*option_1 < min) - *option_1 = max; - modified = 1; - } - else if (p&PAD_BUTTON_RIGHT) - { - /* decrement option 1 value */ - *option_1 += step; - if (*option_1 > max) - *option_1 = min; - modified = 1; - } - else if (p&PAD_BUTTON_UP) - { - /* decrement option 2 value */ - *option_2 -= step; - if (*option_2 < min) - *option_2 = max; - modified = 1; - } - else if (p&PAD_BUTTON_DOWN) - { - /* increment option 2 value */ - *option_2 += step; - if (*option_2 > max) - *option_2 = min; - modified = 1; - } - else if (p & PAD_BUTTON_B) - { - quit = 1; - } - - if (modified) - { - modified = 0; - /* play sound effect */ - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, - ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); - } - } - - /* slide out */ - yoffset = 0; ; - while (yoffset < (ywindow + window->height)) - { - /* draw parent menu */ - GUI_DrawMenu(parent); - - /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,225); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset += 60; - } - - /* restore action button helper */ - if (parent->helpers[1]) - parent->helpers[1]->data = Key_A_png; - - /* final position */ - GUI_DrawMenu(parent); - gxSetScreen(); - - /* close textures */ - gxTextureClose(&arrow[0]); - gxTextureClose(&arrow[1]); - gxTextureClose(&window); -} - -/* Interactive Message Box */ -/* Message Box displays a message until a specific action is completed */ - -/* Message Box LWP Thread */ -static void *MsgBox_Thread(gui_message *message_box) -{ - while (message_box->refresh) - { - /* draw parent menu */ - if (message_box->parent) - { - GUI_DrawMenu(message_box->parent); - } - else - { - gxClearScreen(bg_color); - } - - /* draw window */ - gxDrawTexture(message_box->window,166,160,message_box->window->width,message_box->window->height,230); - gxDrawTexture(message_box->top,166,160,message_box->top->width,message_box->top->height,255); - - /* draw title */ - if (message_box->title) - FONT_writeCenter(message_box->title,20,166,166+message_box->window->width,160+(message_box->top->height-20)/2+20,(GXColor)WHITE); - - /* draw box message */ - if (message_box->msg) - FONT_writeCenter(message_box->msg,18,166,166+message_box->window->width,248,(GXColor)WHITE); - - /* draw throbber */ - if (message_box->throbber) - gxDrawTextureRotate(message_box->throbber,166+(message_box->window->width-message_box->throbber->width)/2,160+message_box->window->height-message_box->throbber->height-20,message_box->throbber->width,message_box->throbber->height,(message_box->progress * 360.0) / 100.0, 255); - - /* draw exit message */ - if (message_box->buttonA) - { - FONT_writeCenter("Press to continue.",18,166,166+message_box->window->width,248+22,(GXColor)WHITE); - gxDrawTexture(message_box->buttonA, 166+116, 248+4+(18-message_box->buttonA->height)/2,message_box->buttonA->width, message_box->buttonA->height,255); - } - - /* update display */ - gxSetScreen(); - - /* update progression */ - message_box->progress++; - if (message_box->progress > 100) - message_box->progress = 0; - usleep(10); - } - - return 0; -} - -/* update current Message Box */ -void GUI_MsgBoxUpdate(char *title, char *msg) -{ - if (title) - strncpy(message_box.title,title,64); - if (msg) - strncpy(message_box.msg,msg,64); -} - -/* setup current Message Box */ -void GUI_MsgBoxOpen(char *title, char *msg, bool throbber) -{ - if (SILENT) - return; - - /* update text */ - GUI_MsgBoxUpdate(title,msg); - - /* ensure we are not already running */ - if (!message_box.refresh) - { - /* initialize default textures */ - message_box.window = gxTextureOpenPNG(Frame_s2_png,0); - message_box.top = gxTextureOpenPNG(Frame_s2_title_png,0); - if (throbber) - message_box.throbber = gxTextureOpenPNG(Frame_throbber_png,0); - - /* window position */ - int xwindow = 166; - int ywindow = 160; - int ypos = 248; - - /* disable helper comments */ - if (message_box.parent) - { - if (message_box.parent->helpers[0]) - message_box.parent->helpers[0]->data = 0; - if (message_box.parent->helpers[1]) - message_box.parent->helpers[1]->data = 0; - } - - /* slide in */ - int yoffset = ywindow + message_box.window->height; - while (yoffset > 0) - { - /* draw parent menu */ - if (message_box.parent) - { - GUI_DrawMenu(message_box.parent); - } - else - { - gxClearScreen(bg_color); - } - - /* draw window */ - gxDrawTexture(message_box.window,xwindow,ywindow-yoffset,message_box.window->width,message_box.window->height,230); - gxDrawTexture(message_box.top,xwindow,ywindow-yoffset,message_box.top->width,message_box.top->height,255); - - /* draw title */ - if (title) - FONT_writeCenter(title,20,xwindow,xwindow+message_box.window->width,ywindow+(message_box.top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* draw box message */ - if (msg) - FONT_writeCenter(msg,18,xwindow,xwindow+message_box.window->width,ypos-yoffset,(GXColor)WHITE); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset -= 60; - } - - /* create LWP thread for MessageBox refresh */ - message_box.refresh = TRUE; - LWP_CreateThread (&msgboxthread, (void *)MsgBox_Thread, &message_box, NULL, 0, 70); - } -} - -/* Close current messagebox */ -void GUI_MsgBoxClose(void) -{ - if (message_box.refresh) - { - /* suspend MessageBox refresh */ - message_box.refresh = FALSE; - LWP_JoinThread(msgboxthread, NULL); - - /* window position */ - int xwindow = 166; - int ywindow = 160; - int ypos = 248; - - /* slide out */ - int yoffset = 0; - while (yoffset < (ywindow + message_box.window->height)) - { - /* draw parent menu */ - if (message_box.parent) - { - GUI_DrawMenu(message_box.parent); - } - else - { - gxClearScreen(bg_color); - } - - /* draw window */ - gxDrawTexture(message_box.window,xwindow,ywindow-yoffset,message_box.window->width,message_box.window->height,230); - gxDrawTexture(message_box.top,xwindow,ywindow-yoffset,message_box.top->width,message_box.top->height,255); - - /* draw title */ - if (message_box.title) - FONT_writeCenter(message_box.title,20,xwindow,xwindow+message_box.window->width,ywindow+(message_box.top->height-20)/2+20-yoffset,(GXColor)WHITE); - - /* draw text */ - if (message_box.msg) - FONT_writeCenter(message_box.msg,18,xwindow,xwindow+message_box.window->width,ypos-yoffset,(GXColor)WHITE); - - /* update display */ - gxSetScreen(); - - /* slide speed */ - yoffset += 60; - } - - if (message_box.parent) - { - /* restore helper comment */ - if (message_box.parent->helpers[0]) - message_box.parent->helpers[0]->data = Key_B_png; - if (message_box.parent->helpers[1]) - message_box.parent->helpers[1]->data = Key_A_png; - - /* final position */ - GUI_DrawMenu(message_box.parent); - } - else - { - gxClearScreen(bg_color); - } - - gxSetScreen(); - - /* clear all textures */ - gxTextureClose(&message_box.window); - gxTextureClose(&message_box.top); - gxTextureClose(&message_box.buttonA); - gxTextureClose(&message_box.throbber); - } -} - -void GUI_WaitPrompt(char *title, char *msg) -{ - if (SILENT) - return; - - /* clear unused texture */ - gxTextureClose(&message_box.throbber); - - /* open or update message box */ - GUI_MsgBoxOpen(title, msg, 0); - - /* allocate texture */ - message_box.buttonA = gxTextureOpenPNG(Key_A_png,0); - - /* wait for button A */ - while (m_input.keys & PAD_BUTTON_A) - VIDEO_WaitVSync(); - while (!(m_input.keys & PAD_BUTTON_A)) - VIDEO_WaitVSync(); - - /* always close message box */ - GUI_MsgBoxClose(); -} - -/* Basic Fading */ -void GUI_FadeOut() -{ - int alpha = 0; - while (alpha < 256) - { - gxDrawRectangle(0, 0, 640, 480, alpha, (GXColor)BLACK); - gxSetScreen(); - alpha +=3; - } -} diff --git a/genplus-gx/gx/gui/gui.h b/genplus-gx/gx/gui/gui.h deleted file mode 100644 index 3f53a471be..0000000000 --- a/genplus-gx/gx/gui/gui.h +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** - * gui.c - * - * generic GUI Engine (using GX rendering) - * - * Copyright Eke-Eke (2009-2010) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _GUI_H -#define _GUI_H - -#define BG_COLOR_MAX 15 - -/*****************************************************************************/ -/* GUI Buttons state */ -/*****************************************************************************/ -#define BUTTON_VISIBLE 0x01 -#define BUTTON_ACTIVE 0x02 -#define BUTTON_SELECTED 0x04 -#define BUTTON_OVER_SFX 0x08 -#define BUTTON_SELECT_SFX 0x10 -#define BUTTON_FADE 0x20 -#define BUTTON_SLIDE_LEFT 0x40 -#define BUTTON_SLIDE_RIGHT 0x80 -#define BUTTON_SLIDE_TOP 0x100 -#define BUTTON_SLIDE_BOTTOM 0x200 - -/*****************************************************************************/ -/* GUI Image state */ -/*****************************************************************************/ -#define IMAGE_VISIBLE 0x01 -#define IMAGE_REPEAT 0x02 -#define IMAGE_FADE 0x04 -#define IMAGE_SLIDE_LEFT 0x08 -#define IMAGE_SLIDE_RIGHT 0x10 -#define IMAGE_SLIDE_TOP 0x20 -#define IMAGE_SLIDE_BOTTOM 0x40 - -/*****************************************************************************/ -/* Generic GUI structures */ -/*****************************************************************************/ - -/* Item descriptor*/ -typedef struct -{ - gx_texture *texture; /* temporary texture data */ - const u8 *data; /* pointer to png image data (items icon only) */ - char text[64]; /* item string (items list only) */ - char comment[64]; /* item comment */ - u16 x; /* item image or text X position (upper left corner) */ - u16 y; /* item image or text Y position (upper left corner) */ - u16 w; /* item image or text width */ - u16 h; /* item image or text height */ -} gui_item; - -/* Button Data descriptor */ -typedef struct -{ - gx_texture *texture[2]; /* temporary texture datas */ - const u8 *image[2]; /* pointer to png image datas (default) */ -} butn_data; - -/* Button descriptor */ -typedef struct -{ - butn_data *data; /* pointer to button image/texture data */ - u16 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */ - u8 shift[4]; /* direction offsets */ - u16 x; /* button image X position (upper left corner) */ - u16 y; /* button image Y position (upper left corner) */ - u16 w; /* button image pixels width */ - u16 h; /* button image pixels height */ -} gui_butn; - -/* Image descriptor */ -typedef struct -{ - gx_texture *texture; /* temporary texture data */ - const u8 *data; /* pointer to png image data */ - u8 state; /* image state (VISIBLE) */ - u16 x; /* image X position (upper left corner) */ - u16 y; /* image Y position (upper left corner) */ - u16 w; /* image width */ - u16 h; /* image height */ - u8 alpha; /* alpha transparency */ -} gui_image; - -/* Menu descriptor */ -typedef struct -{ - char title[64]; /* menu title */ - s8 selected; /* index of selected item */ - s8 offset; /* items list offset */ - u8 max_items; /* total number of items */ - u8 max_buttons; /* total number of buttons */ - u8 max_images; /* total number of background images */ - u8 screenshot; /* game screen background */ - gui_item *items; /* menu items */ - gui_butn *buttons; /* menu buttons */ - gui_image *bg_images; /* background images */ - gui_item *helpers[2]; /* left & right key comments */ - gui_butn *arrows[2]; /* arrows buttons */ - void (*cb)(void); /* specific draw callback */ -} gui_menu; - -typedef struct -{ - u32 progress; /* progress counter */ - bool refresh; /* messagebox current state */ - gui_menu *parent; /* parent menu */ - char title[64]; /* box title */ - char msg[64]; /* box message */ - gx_texture *window; /* pointer to box texture */ - gx_texture *top; /* pointer to box title texture */ - gx_texture *buttonA; /* pointer to button A texture */ - gx_texture *throbber; /* pointer to throbber texture */ -} gui_message; - -/* Menu inputs */ -struct t_input_menu -{ - u16 keys; -#ifdef HW_RVL - struct ir_t ir; -#endif -} m_input; - -/* Optionbox callback */ -typedef void (*optioncallback)(void); - -/* Generic textures*/ -#ifdef HW_RVL -extern gx_texture *w_pointer; -#endif - -/* Generic backgrounds */ -extern const u8 Bg_layer_png[]; -extern const u8 Bg_overlay_png[]; -extern const u8 Banner_main_png[]; -extern const u8 Banner_bottom_png[]; -extern const u8 Banner_top_png[]; -extern const u8 Main_logo_png[]; - -/* Generic frames */ -extern const u8 Frame_s1_png[]; -extern const u8 Frame_s2_png[]; -extern const u8 Frame_s3_png[]; -extern const u8 Frame_s1_title_png[]; -extern const u8 Frame_s2_title_png[]; -extern const u8 Frame_throbber_png[]; - -/* Generic Buttons */ -extern const u8 Button_text_png[]; -extern const u8 Button_text_over_png[]; -extern const u8 Button_icon_png[]; -extern const u8 Button_icon_over_png[]; -extern const u8 Button_icon_sm_png[]; -extern const u8 Button_icon_sm_over_png[]; -extern const u8 Button_up_png[]; -extern const u8 Button_up_over_png[]; -extern const u8 Button_down_png[]; -extern const u8 Button_down_over_png[]; -extern const u8 Button_arrow_png[]; -extern const u8 Button_arrow_over_png[]; -extern const u8 Button_digit_png[]; -extern const u8 Button_digit_over_png[]; - -/* Generic images*/ -#ifdef HW_RVL -#define Key_A_png Key_A_wii_png -#define Key_B_png Key_B_wii_png -extern const u8 generic_point_png[]; -extern const u8 Key_A_wii_png[]; -extern const u8 Key_B_wii_png[]; -#else -#define Key_A_png Key_A_gcn_png -#define Key_B_png Key_B_gcn_png -extern const u8 Key_A_gcn_png[]; -extern const u8 Key_B_gcn_png[]; -#endif -extern const u8 Star_full_png[]; -extern const u8 Star_empty_png[]; -extern const u8 Overlay_bar_png[]; - -/* Generic Sounds */ -extern const u8 button_over_pcm[]; -extern const u8 button_select_pcm[]; -extern const u8 intro_pcm[]; -extern const u32 button_select_pcm_size; -extern const u32 button_over_pcm_size; -extern const u32 intro_pcm_size; - -extern u8 SILENT; - -extern void GUI_InitMenu(gui_menu *menu); -extern void GUI_DeleteMenu(gui_menu *menu); -extern void GUI_DrawMenu(gui_menu *menu); -extern void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out); -extern void GUI_SlideMenuTitle(gui_menu *m, int title_offset); -extern int GUI_UpdateMenu(gui_menu *menu); -extern int GUI_RunMenu(gui_menu *menu); -extern void GUI_TextWindow(gui_menu *parent, char *title, char items[][64], u8 nb_items, u8 fontsize); -extern int GUI_OptionWindow(gui_menu *parent, char *title, char *items[], u8 nb_items); -extern void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type); -extern void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1, s16 *option_2, s16 step, s16 min, s16 max); -extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber); -extern void GUI_MsgBoxUpdate(char *title, char *msg); -extern void GUI_MsgBoxClose(void); -extern void GUI_WaitPrompt(char *title, char *msg); -extern void GUI_FadeOut(); -extern GXColor *GUI_GetBgColor(void); -extern void GUI_SetBgColor(u8 color); - -#endif diff --git a/genplus-gx/gx/gui/legal.c b/genplus-gx/gx/gui/legal.c deleted file mode 100644 index c3d49da8c6..0000000000 --- a/genplus-gx/gx/gui/legal.c +++ /dev/null @@ -1,172 +0,0 @@ -/**************************************************************************** - * legal.c - * - * Genesis Plus GX Disclaimer - * - * Copyright Eke-Eke (2009-2012) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "font.h" -#include "gui.h" - -extern const u8 Bg_intro_c1_png[]; -extern const u8 Bg_intro_c2_png[]; -extern const u8 Bg_intro_c3_png[]; -extern const u8 Bg_intro_c4_png[]; - -/* - * This is the legal stuff - which must be shown at program startup - * Any derivative work MUST include the same textual output. - * - */ - -static void show_disclaimer(int ypos) -{ - FONT_writeCenter ("DISCLAIMER",22,0,640,ypos,(GXColor)WHITE); - ypos += 32; - FONT_writeCenter ("This is a free software, and you are welcome",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("to redistribute it under the conditions of the",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("license that you should have received with this",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("program. You may not sell, lease, rent or generally",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("use this software in any commercial product or activity.",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("Authors can not be held responsible for any damage or",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("or dysfunction that could occur while using this port.",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("You may not distribute this software with any ROM image",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("unless you have the legal right to distribute them.",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("This software is not endorsed by or affiliated",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("with Sega Enterprises Ltd or Nintendo Co Ltd.",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("All trademarks and registered trademarks are",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("the property of their respective owners.",20,0,640,ypos,(GXColor)WHITE); - ypos += 38; -} - -void legal () -{ - int count = 2000; - int vis = 0; - -#ifdef HW_RVL - gx_texture *button = gxTextureOpenPNG(Key_A_wii_png,0); -#else - gx_texture *button = gxTextureOpenPNG(Key_A_gcn_png,0); -#endif - gx_texture *logo = gxTextureOpenPNG(Bg_intro_c4_png,0); - - gxClearScreen((GXColor)BLACK); - show_disclaimer(56); - gxDrawTexture(logo, (640-logo->width)/2, 480-24-logo->height, logo->width, logo->height,255); - gxSetScreen(); - sleep(1); - - while (!m_input.keys && count) - { - gxClearScreen((GXColor)BLACK); - show_disclaimer(56); - if (count%25 == 0) vis^=1; - if (vis) - { - FONT_writeCenter("Press button to continue.",24,0,640,366,(GXColor)SKY_BLUE); - gxDrawTexture(button, 220, 366-24+(24-button->height)/2, button->width, button->height,255); - } - gxDrawTexture(logo, (640-logo->width)/2, 480-24-logo->height, logo->width, logo->height,255); - gxSetScreen(); - count--; - } - - gxTextureClose(&button); - gxTextureClose(&logo); - - if (count > 0) - { - ASND_Pause(0); - int voice = ASND_GetFirstUnusedVoice(); - ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)button_select_pcm,button_select_pcm_size,200,200,NULL); - GUI_FadeOut(); - ASND_Pause(1); - return; - } - - gxClearScreen((GXColor)BLACK); - gx_texture *texture = gxTextureOpenPNG(Bg_intro_c1_png,0); - if (texture) - { - gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); - if (texture->data) free(texture->data); - free(texture); - } - gxSetScreen(); - - sleep (1); - - gxClearScreen((GXColor)WHITE); - texture = gxTextureOpenPNG(Bg_intro_c2_png,0); - if (texture) - { - gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); - if (texture->data) free(texture->data); - free(texture); - } - gxSetScreen(); - - sleep (1); - - gxClearScreen((GXColor)BLACK); - texture = gxTextureOpenPNG(Bg_intro_c3_png,0); - if (texture) - { - gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); - if (texture->data) free(texture->data); - free(texture); - } - gxSetScreen(); - - ASND_Pause(0); - int voice = ASND_GetFirstUnusedVoice(); - ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL); - sleep (2); - ASND_Pause(1); -} diff --git a/genplus-gx/gx/gui/menu.c b/genplus-gx/gx/gui/menu.c deleted file mode 100644 index 1ca3651e32..0000000000 --- a/genplus-gx/gx/gui/menu.c +++ /dev/null @@ -1,3683 +0,0 @@ -/**************************************************************************** - * menu.c - * - * Genesis Plus GX menu - * - * Copyright Eke-Eke (2009-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "font.h" -#include "gui.h" -#include "filesel.h" -#include "cheats.h" -#include "file_load.h" -#include "file_slot.h" - -#ifdef HW_RVL -#include -#endif - -#include -#include - -/* Credits */ -extern const u8 Bg_credits_png[]; - -/* Main menu */ -extern const u8 Main_load_png[]; -extern const u8 Main_options_png[]; -extern const u8 Main_quit_png[]; -extern const u8 Main_file_png[]; -extern const u8 Main_reset_png[]; -extern const u8 Main_cheats_png[]; -extern const u8 Main_showinfo_png[]; -extern const u8 Main_takeshot_png[]; -#ifdef HW_RVL -extern const u8 Main_play_wii_png[]; -#else -extern const u8 Main_play_gcn_png[]; -#endif - -/* Options menu */ -extern const u8 Option_menu_png[]; -extern const u8 Option_ctrl_png[]; -extern const u8 Option_sound_png[]; -extern const u8 Option_video_png[]; -extern const u8 Option_system_png[]; - -/* Load ROM menu */ -extern const u8 Load_recent_png[]; -extern const u8 Load_md_png[]; -extern const u8 Load_ms_png[]; -extern const u8 Load_gg_png[]; -extern const u8 Load_sg_png[]; -extern const u8 Load_cd_png[]; - -/* Save Manager menu */ -extern const u8 Button_load_png[]; -extern const u8 Button_load_over_png[]; -extern const u8 Button_save_png[]; -extern const u8 Button_save_over_png[]; -extern const u8 Button_special_png[]; -extern const u8 Button_special_over_png[]; -extern const u8 Button_delete_png[]; -extern const u8 Button_delete_over_png[]; - -/* Controller Settings */ -extern const u8 Ctrl_4wayplay_png[]; -extern const u8 Ctrl_gamepad_md_png[]; -extern const u8 Ctrl_gamepad_ms_png[]; -extern const u8 Ctrl_justifiers_png[]; -extern const u8 Ctrl_menacer_png[]; -extern const u8 Ctrl_mouse_png[]; -extern const u8 Ctrl_xe_a1p_png[]; -extern const u8 Ctrl_activator_png[]; -extern const u8 Ctrl_lightphaser_png[]; -extern const u8 Ctrl_paddle_png[]; -extern const u8 Ctrl_sportspad_png[]; -extern const u8 Ctrl_none_png[]; -extern const u8 Ctrl_teamplayer_png[]; -extern const u8 Ctrl_pad3b_png[]; -extern const u8 Ctrl_pad6b_png[]; -extern const u8 Ctrl_config_png[]; -extern const u8 ctrl_option_off_png[]; -extern const u8 ctrl_option_on_png[]; -extern const u8 ctrl_gamecube_png[]; -#ifdef HW_RVL -extern const u8 ctrl_classic_png[]; -extern const u8 ctrl_nunchuk_png[]; -extern const u8 ctrl_wiimote_png[]; -#endif - -/* Generic images */ -extern const u8 Button_sm_blue_png[]; -extern const u8 Button_sm_grey_png[]; -extern const u8 Button_sm_yellow_png[]; - -/* Exit callback */ -void (*reload)(void); - - -/*****************************************************************************/ -/* Specific Menu Callbacks */ -/*****************************************************************************/ -static void ctrlmenu_cb(void); -static void savemenu_cb(void); -static void mainmenu_cb(void); - -/*****************************************************************************/ -/* Generic Buttons data */ -/*****************************************************************************/ -static butn_data arrow_up_data = -{ - {NULL,NULL}, - {Button_up_png,Button_up_over_png} -}; - -static butn_data arrow_down_data = -{ - {NULL,NULL}, - {Button_down_png,Button_down_over_png} -}; - -static butn_data button_text_data = -{ - {NULL,NULL}, - {Button_text_png,Button_text_over_png} -}; - -static butn_data button_icon_data = -{ - {NULL,NULL}, - {Button_icon_png,Button_icon_over_png} -}; - -static butn_data button_icon_sm_data = -{ - {NULL,NULL}, - {Button_icon_sm_png,Button_icon_sm_over_png} -}; - -static butn_data button_player_data = -{ - {NULL,NULL}, - {Button_sm_blue_png,Button_sm_yellow_png} -}; - -static butn_data button_player_none_data = -{ - {NULL,NULL}, - {Button_sm_grey_png,NULL} -}; - -static butn_data button_load_data = -{ - {NULL,NULL}, - {Button_load_png,Button_load_over_png} -}; - -static butn_data button_save_data = -{ - {NULL,NULL}, - {Button_save_png,Button_save_over_png} -}; - -static butn_data button_special_data = -{ - {NULL,NULL}, - {Button_special_png,Button_special_over_png} -}; - -static butn_data button_delete_data = -{ - {NULL,NULL}, - {Button_delete_png,Button_delete_over_png} -}; - -/*****************************************************************************/ -/* Generic GUI items */ -/*****************************************************************************/ -static gui_item action_cancel = -{ - NULL,Key_B_png,"","Back",10,422,28,28 -}; - -static gui_item action_select = -{ - NULL,Key_A_png,"","",602,422,28,28 -}; - -/*****************************************************************************/ -/* GUI backgrounds images */ -/*****************************************************************************/ -static gui_image bg_main[4] = -{ - {NULL,Bg_layer_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Banner_main_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,0,340,640,140,255}, - {NULL,Main_logo_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,202,362,232,56,255} -}; - -static gui_image bg_misc[5] = -{ - {NULL,Bg_layer_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Banner_top_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,0,0,640,108,255}, - {NULL,Banner_bottom_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,0,380,640,100,255}, - {NULL,Main_logo_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,466,40,152,44,255} -}; - -static gui_image bg_ctrls[8] = -{ - {NULL,Bg_layer_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255}, - {NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255}, - {NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255}, - {NULL,Frame_s2_png,IMAGE_VISIBLE,38,72,316,168,128}, - {NULL,Frame_s2_png,IMAGE_VISIBLE,38,242,316,168,128}, - {NULL,Frame_s3_png,IMAGE_SLIDE_RIGHT,400,134,292,248,128} -}; - -static gui_image bg_list[6] = -{ - {NULL,Bg_layer_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255}, - {NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255}, - {NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255}, - {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,76} -}; - -static gui_image bg_saves[8] = -{ - {NULL,NULL,0,0,0,0,0,255}, - {NULL,Bg_layer_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255}, - {NULL,Banner_top_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,0,0,640,108,255}, - {NULL,Banner_bottom_png,IMAGE_VISIBLE|IMAGE_SLIDE_BOTTOM,0,380,640,100,255}, - {NULL,Main_logo_png,IMAGE_VISIBLE|IMAGE_SLIDE_TOP,466,40,152,44,255}, - {NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,76}, - {NULL,Frame_s1_png,IMAGE_SLIDE_RIGHT,468,108,372,296,76} -}; - -/*****************************************************************************/ -/* Menu Items description */ -/*****************************************************************************/ - -/* Main menu */ -static gui_item items_main[10] = -{ - {NULL,Main_load_png ,"","",114,162,80,92}, - {NULL,Main_options_png ,"","",290,166,60,88}, - {NULL,Main_quit_png ,"","",460,170,52,84}, - {NULL,Main_file_png ,"","",114,216,80,92}, - {NULL,Main_reset_png ,"","",294,227,52,80}, - {NULL,Main_cheats_png ,"","",454,218,64,92}, - {NULL,NULL ,"","", 10,334,84,32}, -#ifdef HW_RVL - {NULL,Main_play_wii_png,"","", 10,372,84,32}, -#else - {NULL,Main_play_gcn_png,"","", 10,372,84,32}, -#endif - {NULL,Main_takeshot_png,"","",546,334,84,32}, - {NULL,Main_showinfo_png,"","",546,372,84,32} -}; - -/* Controllers menu */ -static gui_item items_ctrls[13] = -{ - {NULL,NULL,"","", 0, 0, 0, 0}, - {NULL,NULL,"","", 0, 0, 0, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","",305, 0, 24, 0}, - {NULL,NULL,"","", 0, 0, 0, 0}, - {NULL,NULL,"","", 0, 0, 0, 0}, - {NULL,Ctrl_config_png,"Keys\nConfig","Configure Controller Keys",530,306,32,32} -}; - -/* Load menu */ -static gui_item items_load[6] = -{ - {NULL,Load_recent_png,"","Load recently played games", 119,144,72, 92}, - {NULL,Load_md_png, "","Load Mega Drive/Genesis games", 278,141,84, 92}, - {NULL,Load_cd_png, "","Load Sega/Mega CD games", 454,141,64, 92}, - {NULL,Load_ms_png, "","Load Master System games", 114,284,84, 96}, - {NULL,Load_gg_png, "","Load Game Gear games", 278,283,84,100}, - {NULL,Load_sg_png, "","Load SG-1000 games", 454,281,64, 96} -}; - -/* Option menu */ -static gui_item items_options[5] = -{ - {NULL,Option_system_png,"","System settings", 114,142,80,92}, - {NULL,Option_video_png, "","Video settings", 288,150,64,84}, - {NULL,Option_sound_png, "","Audio settings", 464,154,44,80}, - {NULL,Option_ctrl_png, "","Controllers settings", 192,286,88,92}, - {NULL,Option_menu_png, "","Menu settings", 370,286,60,92} -}; - -/* Audio options */ -static gui_item items_audio[13] = -{ - {NULL,NULL,"Master System FM: AUTO", "Enable/disable YM2413 chip", 56,132,276,48}, - {NULL,NULL,"High-Quality FM: ON", "Adjust YM2612/YM2413 resampling quality", 56,132,276,48}, - {NULL,NULL,"FM Resolution: MAX", "Adjust YM2612 DAC precision", 56,132,276,48}, - {NULL,NULL,"FM Volume: 1.00", "Adjust YM2612/YM2413 output level", 56,132,276,48}, - {NULL,NULL,"PSG Volume: 2.50", "Adjust SN76489 output level", 56,132,276,48}, - {NULL,NULL,"PSG Noise Boost: OFF", "Boost SN76489 Noise Channel", 56,132,276,48}, - {NULL,NULL,"Audio Out: STEREO", "Select audio mixing output type", 56,132,276,48}, - {NULL,NULL,"Filtering: 3-BAND EQ", "Setup Audio filtering", 56,132,276,48}, - {NULL,NULL,"Low Gain: 1.00", "Adjust EQ Low Band Gain", 56,132,276,48}, - {NULL,NULL,"Mid Gain: 1.00", "Adjust EQ Mid Band Gain", 56,132,276,48}, - {NULL,NULL,"High Gain: 1.00", "Adjust EQ High Band Gain", 56,132,276,48}, - {NULL,NULL,"Low Freq: 200 Hz", "Adjust EQ Lowest Frequency", 56,132,276,48}, - {NULL,NULL,"High Freq: 20000 Hz", "Adjust EQ Highest Frequency", 56,132,276,48} -}; - -/* System options */ -static gui_item items_system[10] = -{ - {NULL,NULL,"Console Hardware: AUTO", "Select system hardware model", 56,132,276,48}, - {NULL,NULL,"Console Region: AUTO", "Select system region", 56,132,276,48}, - {NULL,NULL,"VDP Mode: AUTO", "Select VDP mode", 56,132,276,48}, - {NULL,NULL,"System Clock: AUTO", "Select system clock frequency", 56,132,276,48}, - {NULL,NULL,"System Boot: BIOS&CART", "Select system booting method", 56,132,276,48}, - {NULL,NULL,"System Lockups: ON", "Enable/disable original system lock-ups", 56,132,276,48}, - {NULL,NULL,"68k Address Error: ON", "Enable/disable 68k address error exceptions", 56,132,276,48}, - {NULL,NULL,"Lock-on: OFF", "Select Lock-On cartridge type", 56,132,276,48}, - {NULL,NULL,"Cartridge Swap: OFF", "Enable/disable cartridge hot swap", 56,132,276,48}, - {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 56,132,276,48} -}; - -/* Video options */ -#ifdef HW_RVL -static gui_item items_video[13] = -#else -static gui_item items_video[11] = -#endif -{ - {NULL,NULL,"Display: PROGRESSIVE", "Select video mode", 56,132,276,48}, - {NULL,NULL,"TV mode: 50/60Hz", "Select video refresh rate", 56,132,276,48}, - {NULL,NULL,"VSYNC: AUTO", "Enable/disable sync with Video Hardware", 56,132,276,48}, - {NULL,NULL,"GX Bilinear Filter: OFF", "Enable/disable texture hardware filtering", 56,132,276,48}, - {NULL,NULL,"GX Deflickering Filter: OFF","Enable/disable GX hardware filtering", 56,132,276,48}, -#ifdef HW_RVL - {NULL,NULL,"VI Trap Filter: ON", "Enable/disable video hardware filtering", 56,132,276,48}, - {NULL,NULL,"VI Gamma Correction: 1.0", "Adjust video hardware gamma correction", 56,132,276,48}, -#endif - {NULL,NULL,"NTSC Filter: COMPOSITE", "Enable/disable NTSC software filtering", 56,132,276,48}, - {NULL,NULL,"Borders: OFF", "Enable/disable overscan emulation", 56,132,276,48}, - {NULL,NULL,"GG screen: ORIGINAL", "Enable/disable Game Gear extended screen", 56,132,276,48}, - {NULL,NULL,"Aspect: ORIGINAL (4:3)", "Select display aspect ratio", 56,132,276,48}, - {NULL,NULL,"Screen Position (+0,+0)", "Adjust display position", 56,132,276,48}, - {NULL,NULL,"Screen Scaling (+0,+0)", "Adjust display scaling", 56,132,276,48} -}; - -/* Menu options */ -static gui_item items_prefs[11] = -{ - {NULL,NULL,"Auto ROM Load: OFF", "Enable/disable automatic ROM loading on startup", 56,132,276,48}, - {NULL,NULL,"Auto Cheats: OFF", "Enable/disable automatic cheats activation", 56,132,276,48}, - {NULL,NULL,"Auto Saves: OFF", "Enable/disable automatic saves", 56,132,276,48}, - {NULL,NULL,"ROM Load Device: SD", "Configure default device for ROM files", 56,132,276,48}, - {NULL,NULL,"Saves Device: FAT", "Configure default device for Save files", 56,132,276,48}, - {NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 56,132,276,48}, - {NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 56,132,276,48}, - {NULL,NULL,"BG Overlay: ON", "Enable/disable background overlay", 56,132,276,48}, - {NULL,NULL,"Screen Width: 658", "Adjust menu screen width in pixels", 56,132,276,48}, - {NULL,NULL,"Show CD Leds: OFF", "Enable/disable CD leds display", 56,132,276,48}, - {NULL,NULL,"Show FPS: OFF", "Enable/disable FPS counter", 56,132,276,48}, -}; - -/* Save Manager */ -static gui_item items_saves[9] = -{ - {NULL,NULL,"","" ,0,0,0,0}, - {NULL,NULL,"","" ,0,0,0,0}, - {NULL,NULL,"","" ,0,0,0,0}, - {NULL,NULL,"","" ,0,0,0,0}, - {NULL,NULL,"","" ,0,0,0,0}, - {NULL,NULL,"","Load file" ,0,0,0,0}, - {NULL,NULL,"","Set as default file",0,0,0,0}, - {NULL,NULL,"","Delete file" ,0,0,0,0}, - {NULL,NULL,"","Save file" ,0,0,0,0} -}; - -/*****************************************************************************/ -/* Menu Buttons description */ -/*****************************************************************************/ - -/* Generic Buttons for list menu */ -static gui_butn arrow_up = {&arrow_up_data,BUTTON_ACTIVE|BUTTON_OVER_SFX,{0,0,0,0},14,76,360,32}; -static gui_butn arrow_down = {&arrow_down_data,BUTTON_ACTIVE|BUTTON_OVER_SFX,{0,0,0,0},14,368,360,32}; - -/* Generic list menu */ -static gui_butn buttons_list[4] = -{ - {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},56,132,276,48}, - {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},56,188,276,48}, - {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},56,244,276,48}, - {&button_text_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0},56,300,276,48} -}; - -/* Main menu */ -static gui_butn buttons_main[10] = -{ - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,0,0,1}, 80,140,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,0,1,1},246,140,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,0,1,0},412,140,148,132}, - {&button_icon_data, BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,4,0,1}, 80,194,148,132}, - {&button_icon_data, BUTTON_OVER_SFX ,{3,4,1,1},246,194,148,132}, - {&button_icon_data, BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,3,1,0},412,194,148,132}, - {NULL , BUTTON_OVER_SFX ,{3,1,0,2}, 10,334, 84, 32}, - {NULL , BUTTON_OVER_SFX ,{4,0,0,2}, 10,372, 84, 32}, - {NULL , BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,1,1,0},546,334, 84, 32}, - {NULL , BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,0,2,0},546,372, 84, 32} -}; - -/* Controllers Menu */ -static gui_butn buttons_ctrls[13] = -{ - {&button_icon_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX ,{0,1,0,2}, 60, 88,148,132}, - {&button_icon_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX ,{1,0,0,5}, 60,258,148,132}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,1,2,0},250, 79, 84, 32}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,3,0},250,117, 84, 32}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,4,0},250,155, 84, 32}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,5,0},250,193, 84, 32}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,5,0},250,249, 84, 32}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,6,0},250,287, 84, 32}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,1,7,0},250,325, 84, 32}, - {NULL ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{1,0,8,0},250,363, 84, 32}, - {&button_icon_sm_data ,BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX ,{0,1,1,0},436,168,160, 52}, - {&button_icon_sm_data ,BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX ,{1,1,0,0},436,232,160, 52}, - {&button_icon_sm_data ,BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX|BUTTON_SELECT_SFX ,{1,0,0,0},436,296,160, 52} -}; - -/* Load Game menu */ -static gui_butn buttons_load[6] = -{ - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,0,1}, 80,120,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,1,1},246,120,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,1,0},412,120,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,0,0,1}, 80,264,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,0,1,1},246,264,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,0,1,0},412,264,148,132} -}; - -/* Options menu */ -static gui_butn buttons_options[5] = -{ - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,0,1}, 80,120,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,3,1,1},246,120,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{0,2,1,1},412,120,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{3,0,1,1},162,264,148,132}, - {&button_icon_data,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX|BUTTON_SELECT_SFX,{2,0,1,0},330,264,148,132} -}; - -/* Save Manager Menu */ -static gui_butn buttons_saves[9] = -{ - {&button_text_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{0,1,0,0}, 56,102,276,48}, - {&button_text_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0}, 56,158,276,48}, - {&button_text_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0}, 56,214,276,48}, - {&button_text_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,1,0,0}, 56,270,276,48}, - {&button_text_data ,BUTTON_VISIBLE|BUTTON_ACTIVE|BUTTON_OVER_SFX,{1,0,0,0}, 56,326,276,48}, - {&button_load_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{0,1,0,0},530,130, 56,56}, - {&button_special_data,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{1,1,0,0},530,196, 56,56}, - {&button_delete_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{1,1,0,0},530,262, 56,56}, - {&button_save_data ,BUTTON_ACTIVE|BUTTON_SLIDE_RIGHT|BUTTON_OVER_SFX,{1,0,0,0},530,328, 56,56} -}; - -/*****************************************************************************/ -/* Menu descriptions */ -/*****************************************************************************/ - -/* Main menu */ -static gui_menu menu_main = -{ - "", - 0,0, - 10,10,4,0, - items_main, - buttons_main, - bg_main, - {NULL,NULL}, - {NULL,NULL}, - NULL -}; - -/* Main menu */ -gui_menu menu_ctrls = -{ - "Controller Settings", - 0,0, - 13,13,8,0, - items_ctrls, - buttons_ctrls, - bg_ctrls, - {&action_cancel, &action_select}, - {NULL,NULL}, - ctrlmenu_cb -}; - -/* Load Game menu */ -static gui_menu menu_load = -{ - "Load Game", - 0,0, - 6,6,5,0, - items_load, - buttons_load, - bg_misc, - {&action_cancel, &action_select}, - {NULL,NULL}, - NULL -}; - -/* Options menu */ -static gui_menu menu_options = -{ - "Settings", - 0,0, - 5,5,5,0, - items_options, - buttons_options, - bg_misc, - {&action_cancel, &action_select}, - {NULL,NULL}, - NULL -}; - -/* System Options menu */ -static gui_menu menu_system = -{ - "System Settings", - 0,0, - 10,4,6,0, - items_system, - buttons_list, - bg_list, - {&action_cancel, &action_select}, - {&arrow_up,&arrow_down}, - NULL -}; - -/* Video Options menu */ -static gui_menu menu_video = -{ - "Video Settings", - 0,0, - 10,4,6,0, - items_video, - buttons_list, - bg_list, - {&action_cancel, &action_select}, - {&arrow_up,&arrow_down}, - NULL -}; - -/* Sound Options menu */ -static gui_menu menu_audio = -{ - "Audio Settings", - 0,0, - 9,4,6,0, - items_audio, - buttons_list, - bg_list, - {&action_cancel, &action_select}, - {&arrow_up,&arrow_down}, - NULL -}; - -/* Sound Options menu */ -static gui_menu menu_prefs = -{ - "Menu Settings", - 0,0, - 11,4,6,0, - items_prefs, - buttons_list, - bg_list, - {&action_cancel, &action_select}, - {&arrow_up,&arrow_down}, - NULL -}; - - -/* Save Manager menu */ -static gui_menu menu_saves = -{ - "Save Manager", - 0,0, - 9,9,8,0, - items_saves, - buttons_saves, - bg_saves, - {&action_cancel, &action_select}, - {NULL,NULL}, - savemenu_cb -}; - -/**************************************************************************** - * GUI Settings menu - * - ****************************************************************************/ -static void update_screen_w(void) -{ - vmode->viWidth = config.screen_w; - vmode->viXOrigin = (VI_MAX_WIDTH_NTSC -config.screen_w)/2; - VIDEO_Configure(vmode); - VIDEO_Flush(); -} - -static void update_bgm(void) -{ - SetVolumeOgg(((int)config.bgm_volume * 255) / 100); -} - -static void prefmenu () -{ - int ret, quit = 0; - gui_menu *m = &menu_prefs; - gui_item *items = m->items; - - sprintf (items[0].text, "Auto ROM Load: %s", config.autoload ? "ON":"OFF"); - sprintf (items[1].text, "Auto Cheats: %s", config.autocheat ? "ON":"OFF"); - if (config.s_auto == 3) sprintf (items[2].text, "Auto Saves: ALL"); - else if (config.s_auto == 2) sprintf (items[2].text, "Auto Saves: STATE ONLY"); - else if (config.s_auto == 1) sprintf (items[2].text, "Auto Saves: SRAM ONLY"); - else sprintf (items[2].text, "Auto Saves: NONE"); -#ifdef HW_RVL - if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: USB"); - else if (config.l_device == 2) sprintf (items[3].text, "ROM Load Device: DVD"); -#else - if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: DVD"); -#endif - else sprintf (items[3].text, "ROM Load Device: SD"); - if (config.s_device == 1) sprintf (items[4].text, "Saves Device: MCARD A"); - else if (config.s_device == 2) sprintf (items[4].text, "Saves Device: MCARD B"); - else sprintf (items[4].text, "Saves Device: FAT"); - sprintf (items[5].text, "SFX Volume: %1.1f", config.sfx_volume); - sprintf (items[6].text, "BGM Volume: %1.1f", config.bgm_volume); - sprintf (items[7].text, "BG Overlay: %s", config.bg_overlay ? "ON":"OFF"); - sprintf (items[8].text, "Screen Width: %d", config.screen_w); - sprintf (items[9].text, "Show CD Leds: %s", config.cd_leds ? "ON":"OFF"); - sprintf (items[10].text, "Show FPS: %s", config.fps ? "ON":"OFF"); - - GUI_InitMenu(m); - GUI_SlideMenuTitle(m,strlen("Menu ")); - - while (quit == 0) - { - ret = GUI_RunMenu(m); - - switch (ret) - { - case 0: /* Auto load last ROM file on startup */ - config.autoload ^= 1; - sprintf (items[0].text, "Auto ROM Load: %s", config.autoload ? "ON":"OFF"); - break; - - case 1: /* Cheats automatic activation */ - config.autocheat ^= 1; - sprintf (items[1].text, "Auto Cheats: %s", config.autocheat ? "ON":"OFF"); - break; - - case 2: /*** Auto load/save STATE & SRAM files ***/ - config.s_auto = (config.s_auto + 1) % 4; - if (config.s_auto == 3) sprintf (items[2].text, "Auto Saves: ALL"); - else if (config.s_auto == 2) sprintf (items[2].text, "Auto Saves: STATE ONLY"); - else if (config.s_auto == 1) sprintf (items[2].text, "Auto Saves: SRAM ONLY"); - else sprintf (items[2].text, "Auto Saves: NONE"); - break; - - case 3: /*** Default ROM device ***/ -#ifdef HW_RVL - config.l_device = (config.l_device + 1) % 3; - if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: USB"); - else if (config.l_device == 2) sprintf (items[3].text, "ROM Load Device: DVD"); -#else - config.l_device ^= 1; - if (config.l_device == 1) sprintf (items[3].text, "ROM Load Device: DVD"); -#endif - else sprintf (items[3].text, "ROM Load Device: SD"); - break; - - case 4: /*** Default saves device ***/ - config.s_device = (config.s_device + 1) % 3; - if (config.s_device == 1) sprintf (items[4].text, "Saves Device: MCARD A"); - else if (config.s_device == 2) sprintf (items[4].text, "Saves Device: MCARD B"); - else sprintf (items[4].text, "Saves Device: FAT"); - break; - - case 5: /*** Sound effects volume ***/ - GUI_OptionBox(m,0,"SFX Volume",(void *)&config.sfx_volume,10.0,0.0,100.0,0); - sprintf (items[5].text, "SFX Volume: %1.1f", config.sfx_volume); - break; - - case 6: /*** Background music volume ***/ - GUI_OptionBox(m,update_bgm,"BGM Volume",(void *)&config.bgm_volume,10.0,0.0,100.0,0); - sprintf (items[6].text, "BGM Volume: %1.1f", config.bgm_volume); - break; - - case 7: /*** Background overlay ***/ - config.bg_overlay ^= 1; - if (config.bg_overlay) - { - bg_main[1].state |= IMAGE_VISIBLE; - bg_misc[1].state |= IMAGE_VISIBLE; - bg_ctrls[1].state |= IMAGE_VISIBLE; - bg_list[1].state |= IMAGE_VISIBLE; - bg_saves[2].state |= IMAGE_VISIBLE; - sprintf (items[7].text, "BG Overlay: ON"); - } - else - { - bg_main[1].state &= ~IMAGE_VISIBLE; - bg_misc[1].state &= ~IMAGE_VISIBLE; - bg_ctrls[1].state &= ~IMAGE_VISIBLE; - bg_list[1].state &= ~IMAGE_VISIBLE; - bg_saves[2].state &= ~IMAGE_VISIBLE; - sprintf (items[7].text, "BG Overlay: OFF"); - } - break; - - case 8: /*** Screen Width ***/ - GUI_OptionBox(m,update_screen_w,"Screen Width",(void *)&config.screen_w,2,640,VI_MAX_WIDTH_NTSC,1); - sprintf (items[8].text, "Screen Width: %d", config.screen_w); - break; - - case 9: /*** CD LEDS ***/ - config.cd_leds ^= 1; - sprintf (items[9].text, "Show CD Leds: %s", config.cd_leds ? "ON":"OFF"); - break; - - case 10: /*** FPS counter ***/ - config.fps ^= 1; - sprintf (items[10].text, "Show FPS: %s", config.fps ? "ON":"OFF"); - break; - - case -1: - quit = 1; - break; - } - } - - /* stop DVD drive when not in use */ - if (config.l_device != 2) - { -#ifdef HW_RVL - DI_StopMotor(); -#else - vu32* const dvd = (u32*)0xCC006000; - dvd[0] = 0x2e; - dvd[1] = 0; - dvd[2] = 0xe3000000; - dvd[3] = 0; - dvd[4] = 0; - dvd[5] = 0; - dvd[6] = 0; - dvd[7] = 1; - while (dvd[7] & 1); - dvd[0] = 0x14; - dvd[1] = 0; -#endif - } - - GUI_DeleteMenu(m); -} - -/**************************************************************************** - * Audio Settings menu - * - ****************************************************************************/ -static void soundmenu () -{ - int ret, quit = 0; - float fm_volume = (float)config.fm_preamp/100.0; - float psg_volume = (float)config.psg_preamp/100.0; - gui_menu *m = &menu_audio; - gui_item *items = m->items; - - if (config.ym2413 == 0) sprintf (items[0].text, "Master System FM: OFF"); - else if (config.ym2413 == 1) sprintf (items[0].text, "Master System FM: ON"); - else sprintf (items[0].text, "Master System FM: AUTO"); - - if (config.hq_fm) sprintf (items[1].text, "High-Quality FM: ON"); - else sprintf (items[1].text, "High-Quality FM: OFF"); - - if (config.dac_bits < 14) sprintf (items[2].text, "FM Resolution: %d bits", config.dac_bits); - else sprintf (items[2].text, "FM Resolution: MAX"); - - sprintf (items[3].text, "FM Volume: %1.2f", fm_volume); - sprintf (items[4].text, "PSG Volume: %1.2f", psg_volume); - sprintf (items[5].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF"); - sprintf (items[6].text, "Audio Out: %s", config.mono ? "MONO":"STEREO"); - - if (config.filter == 2) - { - float lg = (float)config.lg/100.0; - float mg = (float)config.mg/100.0; - float hg = (float)config.hg/100.0; - - sprintf(items[7].text, "Filtering: 3-BAND EQ"); - sprintf(items[8].text, "Low Gain: %1.2f", lg); - strcpy(items[8].comment, "Adjust EQ Low Band Gain"); - sprintf(items[9].text, "Middle Gain: %1.2f", mg); - sprintf(items[10].text, "High Gain: %1.2f", hg); - sprintf(items[11].text, "Low Freq: %d", config.low_freq); - sprintf(items[12].text, "High Freq: %d", config.high_freq); - m->max_items = 13; - } - else if (config.filter == 1) - { - int16 lp_range = (config.lp_range * 100 + 0xffff) / 0x10000; - sprintf (items[7].text, "Filtering: LOW-PASS"); - sprintf (items[8].text, "Low-Pass Rate: %d %%", lp_range); - strcpy (items[9].comment, "Adjust Low Pass filter"); - m->max_items = 9; - } - else - { - sprintf (items[7].text, "Filtering: OFF"); - m->max_items = 8; - } - - GUI_InitMenu(m); - GUI_SlideMenuTitle(m,strlen("Audio ")); - - while (quit == 0) - { - ret = GUI_RunMenu(m); - - switch (ret) - { - case 0: - { - config.ym2413++; - if (config.ym2413 > 2) config.ym2413 = 0; - if (config.ym2413 == 0) sprintf (items[0].text, "Master System FM: OFF"); - else if (config.ym2413 == 1) sprintf (items[0].text, "Master System FM: ON"); - else sprintf (items[0].text, "Master System FM: AUTO"); - - /* Automatic detection */ - if ((config.ym2413 & 2) && system_hw && ((system_hw & SYSTEM_PBC) != SYSTEM_MD)) - { - /* detect if game is using YM2413 */ - sms_cart_init(); - - /* restore SRAM */ - slot_autoload(0,config.s_device); - } - break; - } - - case 1: - { - config.hq_fm ^= 1; - if (config.hq_fm) sprintf (items[1].text, "High-Quality FM: ON"); - else sprintf (items[1].text, "High-Quality FM: OFF"); - break; - } - - case 2: - { - config.dac_bits++; - if (config.dac_bits > 14) config.dac_bits = 7; - if (config.dac_bits < 14) sprintf (items[2].text, "FM Resolution: %d bits", config.dac_bits); - else sprintf (items[2].text, "FM Resolution: MAX"); - YM2612Config(config.dac_bits); - break; - } - - case 3: - { - GUI_OptionBox(m,0,"FM Volume",(void *)&fm_volume,0.01,0.0,5.0,0); - sprintf (items[3].text, "FM Volume: %1.2f", fm_volume); - config.fm_preamp = (int)(fm_volume * 100.0 + 0.5); - break; - } - - case 4: - { - GUI_OptionBox(m,0,"PSG Volume",(void *)&psg_volume,0.01,0.0,5.0,0); - sprintf (items[4].text, "PSG Volume: %1.2f", psg_volume); - config.psg_preamp = (int)(psg_volume * 100.0 + 0.5); - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - SN76489_Config(0, config.psg_preamp, config.psgBoostNoise, 0xff); - } - else - { - SN76489_Config(0, config.psg_preamp, config.psgBoostNoise, io_reg[6]); - } - break; - } - - case 5: - { - config.psgBoostNoise ^= 1; - sprintf (items[5].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF"); - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - SN76489_Config(0, config.psg_preamp, config.psgBoostNoise, 0xff); - } - else - { - SN76489_Config(0, config.psg_preamp, config.psgBoostNoise, io_reg[6]); - } - break; - } - - case 6: - { - config.mono ^= 1; - sprintf (items[6].text, "Audio Out: %s", config.mono ? "MONO":"STEREO"); - break; - } - - case 7: - { - config.filter = (config.filter + 1) % 3; - if (config.filter == 2) - { - float lg = (float)config.lg/100.0; - sprintf (items[7].text, "Filtering: 3-BAND EQ"); - sprintf (items[8].text, "Low Gain: %1.2f", lg); - strcpy (items[8].comment, "Adjust EQ Low Band Gain"); - m->max_items = 13; - audio_set_equalizer(); - } - else if (config.filter == 1) - { - int lp_range = (config.lp_range * 100 + 0xffff) / 0x10000; - sprintf (items[7].text, "Filtering: LOW-PASS"); - sprintf (items[8].text, "Low-Pass Rate: %d %%", lp_range); - strcpy (items[8].comment, "Adjust Low Pass filter"); - m->max_items = 9; - } - else - { - sprintf (items[7].text, "Filtering: OFF"); - m->max_items = 8; - } - - while ((m->offset + 4) > m->max_items) - { - m->offset--; - m->selected++; - } - break; - } - - case 8: - { - if (config.filter == 1) - { - int16 lp_range = (config.lp_range * 100 + 0xffff) / 0x10000; - GUI_OptionBox(m,0,"Low-Pass Rate",(void *)&lp_range,1,0,100,1); - sprintf (items[8].text, "Low-Pass Rate: %d %%", lp_range); - config.lp_range = (lp_range * 0x10000) / 100; - } - else - { - float lg = (float)config.lg/100.0; - GUI_OptionBox(m,0,"Low Gain",(void *)&lg,0.01,0.0,2.0,0); - sprintf (items[8].text, "Low Gain: %1.2f", lg); - config.lg = (int)(lg * 100.0); - audio_set_equalizer(); - } - break; - } - - case 9: - { - float mg = (float)config.mg/100.0; - GUI_OptionBox(m,0,"Middle Gain",(void *)&mg,0.01,0.0,2.0,0); - sprintf (items[9].text, "Middle Gain: %1.2f", mg); - config.mg = (int)(mg * 100.0); - audio_set_equalizer(); - break; - } - - case 10: - { - float hg = (float)config.hg/100.0; - GUI_OptionBox(m,0,"High Gain",(void *)&hg,0.01,0.0,2.0,0); - sprintf (items[10].text, "High Gain: %1.2f", hg); - config.hg = (int)(hg * 100.0); - audio_set_equalizer(); - break; - } - - case 11: - { - GUI_OptionBox(m,0,"Low Frequency",(void *)&config.low_freq,10,0,config.high_freq,1); - sprintf (items[11].text, "Low Freq: %d", config.low_freq); - audio_set_equalizer(); - break; - } - - case 12: - { - GUI_OptionBox(m,0,"High Frequency",(void *)&config.high_freq,100,config.low_freq,30000,1); - sprintf (items[12].text, "High Freq: %d", config.high_freq); - audio_set_equalizer(); - break; - } - - case -1: - { - quit = 1; - break; - } - } - } - - GUI_DeleteMenu(m); -} - -/**************************************************************************** - * System Settings menu - * - ****************************************************************************/ -static const uint16 vc_table[4][2] = -{ - /* NTSC, PAL */ - {0xDA , 0xF2}, /* Mode 4 (192 lines) */ - {0xEA , 0x102}, /* Mode 5 (224 lines) */ - {0xDA , 0xF2}, /* Mode 4 (192 lines) */ - {0x106, 0x10A} /* Mode 5 (240 lines) */ -}; - -static void systemmenu () -{ - int ret, quit = 0; - int reinit = 0; - gui_menu *m = &menu_system; - gui_item *items = m->items; - - if (config.system == 0) - sprintf (items[0].text, "Console Type: AUTO"); - else if (config.system == SYSTEM_SG) - sprintf (items[0].text, "Console Type: SG-1000"); - else if (config.system == SYSTEM_MARKIII) - sprintf (items[0].text, "Console Type: MARK-III"); - else if (config.system == SYSTEM_SMS) - sprintf (items[0].text, "Console Type: SMS"); - else if (config.system == SYSTEM_SMS2) - sprintf (items[0].text, "Console Type: SMS II"); - else if (config.system == SYSTEM_GG) - sprintf (items[0].text, "Console Type: GG"); - else if (config.system == SYSTEM_MD) - sprintf (items[0].text, "Console Type: MD"); - - if (config.region_detect == 0) - sprintf (items[1].text, "Console Region: AUTO"); - else if (config.region_detect == 1) - sprintf (items[1].text, "Console Region: USA"); - else if (config.region_detect == 2) - sprintf (items[1].text, "Console Region: EUROPE"); - else if (config.region_detect == 3) - sprintf (items[1].text, "Console Region: JAPAN"); - - if (config.vdp_mode == 0) - sprintf (items[2].text, "VDP Mode: AUTO"); - else if (config.vdp_mode == 1) - sprintf (items[2].text, "VDP Mode: NTSC"); - else if (config.vdp_mode == 2) - sprintf (items[2].text, "VDP Mode: PAL"); - - if (config.master_clock == 0) - sprintf (items[3].text, "System Clock: AUTO"); - else if (config.master_clock == 1) - sprintf (items[3].text, "System Clock: NTSC"); - else if (config.master_clock == 2) - sprintf (items[3].text, "System Clock: PAL"); - - sprintf (items[4].text, "System Boot: %s", (config.bios & 1) ? ((config.bios & 2) ? "BIOS&CART" : "BIOS ONLY") : "CART"); - sprintf (items[5].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); - sprintf (items[6].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); - - if (config.lock_on == TYPE_GG) - sprintf (items[7].text, "Lock-On: GAME GENIE"); - else if (config.lock_on == TYPE_AR) - sprintf (items[7].text, "Lock-On: ACTION REPLAY"); - else if (config.lock_on == TYPE_SK) - sprintf (items[7].text, "Lock-On: SONIC&KNUCKLES"); - else - sprintf (items[7].text, "Lock-On: OFF"); - - sprintf (items[8].text, "Cartridge Swap: %s", (config.hot_swap & 1) ? "ON":"OFF"); - - if (svp) - { - sprintf (items[9].text, "SVP Cycles: %d", SVP_cycles); - m->max_items = 10; - } - else - { - m->max_items = 9; - } - - GUI_InitMenu(m); - GUI_SlideMenuTitle(m,strlen("System ")); - - while (quit == 0) - { - ret = GUI_RunMenu(m); - - switch (ret) - { - case 0: /*** Force System Hardware ***/ - { - if (config.system == SYSTEM_MD) - { - config.system = 0; - sprintf (items[0].text, "Console Type: AUTO"); - - /* Default system hardware (auto) */ - if (system_hw) system_hw = romtype; - } - else if (config.system == 0) - { - config.system = SYSTEM_SG; - sprintf (items[0].text, "Console Type: SG-1000"); - if (system_hw) system_hw = SYSTEM_SG; - } - else if (config.system == SYSTEM_SG) - { - config.system = SYSTEM_MARKIII; - sprintf (items[0].text, "Console Type: MARK-III"); - if (system_hw) system_hw = SYSTEM_MARKIII; - } - else if (config.system == SYSTEM_MARKIII) - { - config.system = SYSTEM_SMS; - sprintf (items[0].text, "Console Type: SMS"); - if (system_hw) system_hw = SYSTEM_SMS; - } - else if (config.system == SYSTEM_SMS) - { - config.system = SYSTEM_SMS2; - sprintf (items[0].text, "Console Type: SMS II"); - if (system_hw) system_hw = SYSTEM_SMS2; - } - else if (config.system == SYSTEM_SMS2) - { - config.system = SYSTEM_GG; - sprintf (items[0].text, "Console Type: GG"); - - if (romtype == SYSTEM_GG) - { - /* Game Gear mode */ - if (system_hw) system_hw = SYSTEM_GG; - } - else - { - /* Game Gear in MS compatibility mode */ - if (system_hw) system_hw = SYSTEM_GGMS; - } - } - else if (config.system == SYSTEM_GG) - { - config.system = SYSTEM_MD; - sprintf (items[0].text, "Console Type: MD"); - - if (romtype & SYSTEM_MD) - { - /* Default mode */ - if (system_hw) system_hw = romtype; - } - else - { - /* Mega Drive in MS compatibility mode */ - if (system_hw) system_hw = SYSTEM_PBC; - } - } - - if (system_hw) - { - /* restore previous input settings */ - if (old_system[0] != -1) - { - input.system[0] = old_system[0]; - } - if (old_system[1] != -1) - { - input.system[1] = old_system[1]; - } - - /* reinitialize audio streams */ - audio_init(snd.sample_rate, snd.frame_rate); - - /* force hard reset */ - system_init(); - system_reset(); - - /* restore SRAM */ - slot_autoload(0,config.s_device); - } - - break; - } - - case 1: /*** Force Region ***/ - { - config.region_detect = (config.region_detect + 1) % 4; - if (config.region_detect == 0) - sprintf (items[1].text, "Console Region: AUTO"); - else if (config.region_detect == 1) - sprintf (items[1].text, "Console Region: USA"); - else if (config.region_detect == 2) - sprintf (items[1].text, "Console Region: EUR"); - else if (config.region_detect == 3) - sprintf (items[1].text, "Console Region: JAPAN"); - - /* force system reinitialization + region BIOS */ - reinit = 2; - break; - } - - case 2: /*** Force VDP mode ***/ - { - config.vdp_mode = (config.vdp_mode + 1) % 3; - if (config.vdp_mode == 0) - sprintf (items[2].text, "VDP Mode: AUTO"); - else if (config.vdp_mode == 1) - sprintf (items[2].text, "VDP Mode: NTSC"); - else if (config.vdp_mode == 2) - sprintf (items[2].text, "VDP Mode: PAL"); - - /* force system reinitialization */ - reinit = 1; - break; - } - - case 3: /*** Force Master Clock ***/ - { - config.master_clock = (config.master_clock + 1) % 3; - if (config.master_clock == 0) - sprintf (items[3].text, "System Clock: AUTO"); - else if (config.master_clock == 1) - sprintf (items[3].text, "System Clock: NTSC"); - else if (config.master_clock == 2) - sprintf (items[3].text, "System Clock: PAL"); - - /* force system reinitialization */ - reinit = 1; - break; - } - - case 4: /*** BIOS support ***/ - { - if (config.bios == 0) config.bios = 3; - else if (config.bios == 3) config.bios = 1; - else config.bios = 0; - sprintf (items[4].text, "System Boot: %s", (config.bios & 1) ? ((config.bios & 2) ? "BIOS&CART " : "BIOS ONLY") : "CART"); - if ((system_hw == SYSTEM_MD) || (system_hw & SYSTEM_GG) || (system_hw & SYSTEM_SMS)) - { - /* force hard reset */ - system_init(); - system_reset(); - - /* restore SRAM */ - slot_autoload(0,config.s_device); - } - break; - } - - case 5: /*** force DTACK ***/ - { - config.force_dtack ^= 1; - sprintf (items[5].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); - break; - } - - case 6: /*** 68k Address Error ***/ - { - config.addr_error ^= 1; - m68k.aerr_enabled = config.addr_error; - sprintf (items[6].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); - break; - } - - case 7: /*** Cart Lock-On ***/ - { - config.lock_on = (config.lock_on + 1) % (TYPE_SK + 1); - if (config.lock_on == TYPE_GG) - sprintf (items[7].text, "Lock-On: GAME GENIE"); - else if (config.lock_on == TYPE_AR) - sprintf (items[7].text, "Lock-On: ACTION REPLAY"); - else if (config.lock_on == TYPE_SK) - sprintf (items[7].text, "Lock-On: SONIC&KNUCKLES"); - else - sprintf (items[7].text, "Lock-On: OFF"); - - if ((system_hw == SYSTEM_MD) || (system_hw == SYSTEM_PICO)) - { - /* force hard reset */ - system_init(); - system_reset(); - - /* restore SRAM */ - slot_autoload(0,config.s_device); - - /* Action Replay switch */ - if (areplay_get_status() < 0) - { - menu_main.buttons[6].state &= ~(BUTTON_VISIBLE | BUTTON_ACTIVE); - menu_main.items[6].data = NULL; - menu_main.cb = NULL; - menu_main.buttons[3].shift[1] = 4; - menu_main.buttons[7].shift[0] = 4; - menu_main.buttons[8].shift[2] = 1; - } - else - { - menu_main.buttons[6].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - menu_main.items[6].data = Button_sm_grey_png; - menu_main.cb = mainmenu_cb; - menu_main.buttons[3].shift[1] = 3; - menu_main.buttons[7].shift[0] = 1; - menu_main.buttons[8].shift[2] = 2; - } - } - break; - } - - case 8: /*** Cartridge Hot Swap ***/ - { - config.hot_swap ^= 1; - sprintf (items[8].text, "Cartridge Swap: %s", (config.hot_swap & 1) ? "ON":"OFF"); - break; - } - - case 9: /*** SVP cycles per line ***/ - { - GUI_OptionBox(m,0,"SVP Cycles",(void *)&SVP_cycles,1,1,1500,1); - sprintf (items[9].text, "SVP Cycles: %d", SVP_cycles); - break; - } - - case -1: - { - quit = 1; - break; - } - } - } - - if (reinit && system_hw) - { - /* reinitialize console region */ - get_region(NULL); - - /* framerate might have changed, reinitialize audio timings */ - audio_init(snd.sample_rate, get_framerate()); - - /* system with region BIOS should be reinitialized if region code has changed */ - if ((reinit & 2) && ((system_hw == SYSTEM_MCD) || ((system_hw & SYSTEM_SMS) && (config.bios & 1)))) - { - system_init(); - system_reset(); - - /* restore SRAM */ - slot_autoload(0,config.s_device); - } - else - { - /* reinitialize I/O region register */ - if (system_hw == SYSTEM_MD) - { - io_reg[0x00] = 0x20 | region_code | (config.bios & 1); - } - else if (system_hw == SYSTEM_MCD) - { - io_reg[0x00] = region_code | (config.bios & 1); - } - else - { - io_reg[0x00] = 0x80 | (region_code >> 1); - } - - /* reinitialize VDP */ - if (vdp_pal) - { - status |= 1; - lines_per_frame = 313; - } - else - { - status &= ~1; - lines_per_frame = 262; - } - - /* reinitialize VC max value */ - switch (bitmap.viewport.h) - { - case 192: - vc_max = vc_table[0][vdp_pal]; - break; - case 224: - vc_max = vc_table[1][vdp_pal]; - break; - case 240: - vc_max = vc_table[3][vdp_pal]; - break; - } - } - } - - GUI_DeleteMenu(m); -} - -/**************************************************************************** - * Video Settings menu - * - ****************************************************************************/ -#ifdef HW_RVL -#define VI_OFFSET 7 -static void update_gamma(void) -{ - VIDEO_SetGamma((int)(config.gamma * 10.0)); - VIDEO_Flush(); -} -#else -#define VI_OFFSET 5 -#endif - -static void videomenu () -{ - u16 state[2]; - int ret, quit = 0; - int reinit = 0; - gui_menu *m = &menu_video; - gui_item *items = m->items; - - if (config.render == 1) - sprintf (items[0].text,"Display: INTERLACED"); - else if (config.render == 2) - sprintf (items[0].text, "Display: PROGRESSIVE"); - else - sprintf (items[0].text, "Display: ORIGINAL"); - - if (config.tv_mode == 0) - sprintf (items[1].text, "TV Mode: 60HZ"); - else if (config.tv_mode == 1) - sprintf (items[1].text, "TV Mode: 50HZ"); - else - sprintf (items[1].text, "TV Mode: 50/60HZ"); - - if (config.vsync) - sprintf (items[2].text, "VSYNC: AUTO"); - else - sprintf (items[2].text, "VSYNC: OFF"); - - sprintf (items[3].text, "GX Bilinear Filter: %s", config.bilinear ? " ON" : "OFF"); - sprintf (items[4].text, "GX Deflickering Filter: %s", config.vfilter ? " ON" : "OFF"); - -#ifdef HW_RVL - sprintf (items[5].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); - sprintf (items[6].text, "VI Gamma Correction: %1.1f", config.gamma); -#endif - - if (config.ntsc == 1) - sprintf (items[VI_OFFSET].text, "NTSC Filter: COMPOSITE"); - else if (config.ntsc == 2) - sprintf (items[VI_OFFSET].text, "NTSC Filter: S-VIDEO"); - else if (config.ntsc == 3) - sprintf (items[VI_OFFSET].text, "NTSC Filter: RGB"); - else - sprintf (items[VI_OFFSET].text, "NTSC Filter: OFF"); - - if (config.overscan == 3) - sprintf (items[VI_OFFSET+1].text, "Borders: FULL"); - else if (config.overscan == 2) - sprintf (items[VI_OFFSET+1].text, "Borders: H ONLY"); - else if (config.overscan == 1) - sprintf (items[VI_OFFSET+1].text, "Borders: V ONLY"); - else - sprintf (items[VI_OFFSET+1].text, "Borders: NONE"); - - sprintf(items[VI_OFFSET+2].text, "GG Screen: %s", config.gg_extra ? "EXTENDED":"ORIGINAL"); - - if (config.aspect == 1) - sprintf (items[VI_OFFSET+3].text,"Aspect: ORIGINAL (4:3)"); - else if (config.aspect == 2) - sprintf (items[VI_OFFSET+3].text, "Aspect: ORIGINAL (16:9)"); - else - sprintf (items[VI_OFFSET+3].text, "Aspect: SCALED"); - - sprintf (items[VI_OFFSET+4].text, "Screen Position: (%s%02d,%s%02d)", - (config.xshift < 0) ? "":"+", config.xshift, - (config.yshift < 0) ? "":"+", config.yshift); - - sprintf (items[VI_OFFSET+5].text, "Screen Scaling: (%s%02d,%s%02d)", - (config.xscale < 0) ? "":"+", config.xscale, - (config.yscale < 0) ? "":"+", config.yscale); - - if (config.aspect) - m->max_items = VI_OFFSET+5; - else - m->max_items = VI_OFFSET+6; - - GUI_InitMenu(m); - GUI_SlideMenuTitle(m,strlen("Video ")); - - while (quit == 0) - { - ret = GUI_RunMenu(m); - - switch (ret) - { - case 0: /*** rendering ***/ - config.render = (config.render + 1) % 3; - if (config.render == 2) - { - /* progressive mode is only possible through component cable */ - if (!VIDEO_HaveComponentCable()) - { - config.render = 0; - } - } - if (config.render == 1) - sprintf (items[0].text,"Display: INTERLACED"); - else if (config.render == 2) - sprintf (items[0].text, "Display: PROGRESSIVE"); - else - sprintf (items[0].text, "Display: ORIGINAL"); - reinit = 1; - break; - - case 1: /*** tv mode ***/ - config.tv_mode = (config.tv_mode + 1) % 3; - if (config.tv_mode == 0) - sprintf (items[1].text, "TV Mode: 60HZ"); - else if (config.tv_mode == 1) - sprintf (items[1].text, "TV Mode: 50HZ"); - else - sprintf (items[1].text, "TV Mode: 50/60HZ"); - reinit = 1; - break; - - case 2: /*** VSYNC ***/ - config.vsync ^= 1; - if (config.vsync) - sprintf (items[2].text, "VSYNC: AUTO"); - else - sprintf (items[2].text, "VSYNC: OFF"); - reinit = 1; - break; - - case 3: /*** GX Texture filtering ***/ - config.bilinear ^= 1; - sprintf (items[3].text, "GX Bilinear Filter: %s", config.bilinear ? " ON" : "OFF"); - break; - - case 4: /*** GX Copy filtering (deflickering filter) ***/ - config.vfilter ^= 1; - sprintf (items[4].text, "GX Deflicker Filter: %s", config.vfilter ? " ON" : "OFF"); - break; - -#ifdef HW_RVL - case 5: /*** VIDEO Trap filtering ***/ - config.trap ^= 1; - sprintf (items[5].text, "VI Trap Filter: %s", config.trap ? " ON" : "OFF"); - break; - - case 6: /*** VIDEO Gamma correction ***/ - if (system_hw) - { - update_gamma(); - state[0] = m->arrows[0]->state; - state[1] = m->arrows[1]->state; - m->max_buttons = 0; - m->max_images = 0; - m->arrows[0]->state = 0; - m->arrows[1]->state = 0; - m->screenshot = 255; - strcpy(m->title,""); - GUI_OptionBox(m,update_gamma,"VI Gamma Correction",(void *)&config.gamma,0.1,0.1,3.0,0); - m->max_buttons = 4; - m->max_images = 6; - m->arrows[0]->state = state[0]; - m->arrows[1]->state = state[1]; - m->screenshot = 0; - strcpy(m->title,"Video Settings"); - sprintf (items[6].text, "VI Gamma Correction: %1.1f", config.gamma); - VIDEO_SetGamma(VI_GM_1_0); - VIDEO_Flush(); - } - else - { - GUI_WaitPrompt("Error","Please load a game first !\n"); - } - break; -#endif - - case VI_OFFSET: /*** NTSC filter ***/ - config.ntsc = (config.ntsc + 1) & 3; - if (config.ntsc == 1) - sprintf (items[VI_OFFSET].text, "NTSC Filter: COMPOSITE"); - else if (config.ntsc == 2) - sprintf (items[VI_OFFSET].text, "NTSC Filter: S-VIDEO"); - else if (config.ntsc == 3) - sprintf (items[VI_OFFSET].text, "NTSC Filter: RGB"); - else - sprintf (items[VI_OFFSET].text, "NTSC Filter: OFF"); - break; - - case VI_OFFSET+1: /*** overscan emulation ***/ - config.overscan = (config.overscan + 1) & 3; - if (config.overscan == 3) - sprintf (items[VI_OFFSET+1].text, "Borders: FULL"); - else if (config.overscan == 2) - sprintf (items[VI_OFFSET+1].text, "Borders: H ONLY"); - else if (config.overscan == 1) - sprintf (items[VI_OFFSET+1].text, "Borders: V ONLY"); - else - sprintf (items[VI_OFFSET+1].text, "Borders: NONE"); - break; - - case VI_OFFSET+2: /*** Game Gear extended screen */ - config.gg_extra ^= 1; - sprintf(items[VI_OFFSET+2].text, "GG Screen: %s", config.gg_extra ? "EXTENDED":"ORIGINAL"); - break; - - case VI_OFFSET+3: /*** aspect ratio ***/ - config.aspect = (config.aspect + 1) % 3; - if (config.aspect == 1) - sprintf (items[VI_OFFSET+3].text,"Aspect: ORIGINAL (4:3)"); - else if (config.aspect == 2) - sprintf (items[VI_OFFSET+3].text, "Aspect: ORIGINAL (16:9)"); - else - sprintf (items[VI_OFFSET+3].text, "Aspect: SCALED"); - - if (config.aspect) - { - /* disable items */ - m->max_items = VI_OFFSET+5; - - /* reset menu selection */ - if (m->offset > VI_OFFSET) - { - m->offset = VI_OFFSET; - m->selected = 3; - } - } - else - { - /* enable items */ - m->max_items = VI_OFFSET+6; - } - - break; - - case VI_OFFSET+4: /*** screen position ***/ - if (system_hw) - { - state[0] = m->arrows[0]->state; - state[1] = m->arrows[1]->state; - m->max_buttons = 0; - m->max_images = 0; - m->arrows[0]->state = 0; - m->arrows[1]->state = 0; - m->screenshot = 255; - strcpy(m->title,""); - GUI_OptionBox2(m,"X Offset","Y Offset",&config.xshift,&config.yshift,1,-99,99); - m->max_buttons = 4; - m->max_images = 6; - m->arrows[0]->state = state[0]; - m->arrows[1]->state = state[1]; - m->screenshot = 0; - strcpy(m->title,"Video Settings"); - sprintf (items[VI_OFFSET+4].text, "Screen Position: (%s%02d,%s%02d)", - (config.xshift < 0) ? "":"+", config.xshift, - (config.yshift < 0) ? "":"+", config.yshift); - } - else - { - GUI_WaitPrompt("Error","Please load a game first !\n"); - } - break; - - case VI_OFFSET+5: /*** screen scaling ***/ - if (system_hw) - { - state[0] = m->arrows[0]->state; - state[1] = m->arrows[1]->state; - m->max_buttons = 0; - m->max_images = 0; - m->arrows[0]->state = 0; - m->arrows[1]->state = 0; - m->screenshot = 255; - strcpy(m->title,""); - GUI_OptionBox2(m,"X Scale","Y Scale",&config.xscale,&config.yscale,1,-99,99); - m->max_buttons = 4; - m->max_images = 6; - m->arrows[0]->state = state[0]; - m->arrows[1]->state = state[1]; - m->screenshot = 0; - strcpy(m->title,"Video Settings"); - sprintf (items[VI_OFFSET+5].text, "Screen Scaling: (%s%02d,%s%02d)", - (config.xscale < 0) ? "":"+", config.xscale, - (config.yscale < 0) ? "":"+", config.yscale); - } - else - { - GUI_WaitPrompt("Error","Please load a game first !\n"); - } - break; - - case -1: - quit = 1; - break; - } - } - - if (reinit && system_hw) - { - /* framerate might have changed, reinitialize audio timings */ - audio_init(snd.sample_rate, get_framerate()); - } - - GUI_DeleteMenu(m); -} - -/**************************************************************************** - * Controllers Settings menu - ****************************************************************************/ -static int player = 0; -static void ctrlmenu_cb(void) -{ - int i, cnt = 1; - char msg[16]; - gui_menu *m = &menu_ctrls; - - if (m->bg_images[7].state & IMAGE_VISIBLE) - { - /* draw device port number */ - if (config.input[player].device != -1) - { - sprintf(msg,"%d",config.input[player].port + 1); - if (m->selected == 11) - FONT_write(msg,16,m->items[11].x+m->items[11].w+2,m->items[11].y+m->items[11].h+2,640,(GXColor)DARK_GREY); - else - FONT_write(msg,14,m->items[11].x+m->items[11].w,m->items[11].y+m->items[11].h,640,(GXColor)DARK_GREY); - } - } - - /* draw players index */ - for (i=2; iselected == i) - { - FONT_writeCenter("Player", 16, m->buttons[i].x + 2, m->buttons[i].x + 54, m->buttons[i].y + (m->buttons[i].h - 16)/2 + 16, (GXColor)DARK_GREY); - } - else - { - FONT_writeCenter("Player", 14, m->buttons[i].x + 4, m->buttons[i].x + 54, m->buttons[i].y + (m->buttons[i].h - 14)/2 + 14, (GXColor)DARK_GREY); - } - - if (input.dev[i-2] != NO_DEVICE) - { - sprintf(msg,"%d",cnt++); - if (m->selected == i) - { - FONT_writeCenter(msg,18,m->items[i].x+2,m->items[i].x+m->items[i].w+2,m->buttons[i].y+(m->buttons[i].h-18)/2+18,(GXColor)DARK_GREY); - } - else - { - FONT_writeCenter(msg,16,m->items[i].x,m->items[i].x+m->items[i].w,m->buttons[i].y+(m->buttons[i].h - 16)/2+16,(GXColor)DARK_GREY); - } - } - } -} - -/* Set menu elements depending on current system configuration */ -static void ctrlmenu_raz(void) -{ - int i,max = 0; - gui_menu *m = &menu_ctrls; - - /* update players buttons */ - for (i=0; ibuttons[i+2].data = &button_player_none_data; - m->buttons[i+2].state &= ~BUTTON_ACTIVE; - strcpy(m->items[i+2].comment,""); - } - else - { - m->buttons[i+2].data = &button_player_data; - m->buttons[i+2].state |= BUTTON_ACTIVE; - if ((cart.special & HW_J_CART) && (i > 4)) - sprintf(m->items[i+2].comment,"Configure Player %d (J-CART) settings", max + 1); - else - sprintf(m->items[i+2].comment,"Configure Player %d settings", max + 1); - max++; - } - } - - /* update buttons navigation */ - if (input.dev[0] != NO_DEVICE) - m->buttons[0].shift[3] = 2; - else if (input.dev[4] != NO_DEVICE) - m->buttons[0].shift[3] = 6; - else if (input.dev[5] != NO_DEVICE) - m->buttons[0].shift[3] = 7; - else - m->buttons[0].shift[3] = 0; - if (input.dev[4] != NO_DEVICE) - m->buttons[1].shift[3] = 5; - else if (input.dev[5] != NO_DEVICE) - m->buttons[1].shift[3] = 6; - else if (input.dev[0] != NO_DEVICE) - m->buttons[1].shift[3] = 1; - else - m->buttons[1].shift[3] = 0; - - if (input.dev[1] != NO_DEVICE) - m->buttons[2].shift[1] = 1; - else if (input.dev[4] != NO_DEVICE) - m->buttons[2].shift[1] = 4; - else if (input.dev[5] != NO_DEVICE) - m->buttons[2].shift[1] = 5; - else - m->buttons[2].shift[1] = 0; - - if (input.dev[4] != NO_DEVICE) - m->buttons[5].shift[1] = 1; - else if (input.dev[5] != NO_DEVICE) - m->buttons[5].shift[1] = 2; - else - m->buttons[5].shift[1] = 0; - - if (input.dev[3] != NO_DEVICE) - m->buttons[6].shift[0] = 1; - else if (input.dev[0] != NO_DEVICE) - m->buttons[6].shift[0] = 4; - else - m->buttons[6].shift[0] = 0; - - if (input.dev[5] != NO_DEVICE) - m->buttons[6].shift[1] = 1; - else - m->buttons[6].shift[1] = 0; - - if (input.dev[6] != NO_DEVICE) - m->buttons[7].shift[1] = 1; - else - m->buttons[7].shift[1] = 0; - - if (input.dev[7] != NO_DEVICE) - m->buttons[8].shift[1] = 1; - else - m->buttons[8].shift[1] = 0; - - if (input.dev[4] != NO_DEVICE) - m->buttons[7].shift[0] = 1; - else if (input.dev[3] != NO_DEVICE) - m->buttons[7].shift[0] = 2; - else if (input.dev[0] != NO_DEVICE) - m->buttons[7].shift[0] = 5; - else - m->buttons[7].shift[0] = 0; -} - -static void ctrlmenu(void) -{ - int old_player = -1; - int i = 0; - int update = 0; - gui_item *items = NULL; - u8 *special = NULL; - u32 exp; - u8 type = 0; - - /* System devices */ - gui_item items_sys[2][13] = - { - { - {NULL,Ctrl_none_png ,"","Select Port 1 device",110,130,48,72}, - {NULL,Ctrl_gamepad_md_png ,"","Select Port 1 device", 85,117,96,84}, - {NULL,Ctrl_mouse_png ,"","Select Port 1 device", 97,113,64,88}, - {NULL,Ctrl_menacer_png ,"","Select Port 1 device", 94,113,80,88}, - {NULL,Ctrl_justifiers_png ,"","Select Port 1 device", 88,117,80,84}, - {NULL,Ctrl_xe_a1p_png ,"","Select Port 1 device", 98,118,72,84}, - {NULL,Ctrl_activator_png ,"","Select Port 1 device", 94,121,72,80}, - {NULL,Ctrl_gamepad_ms_png ,"","Select Port 1 device", 91,125,84,76}, - {NULL,Ctrl_lightphaser_png,"","Select Port 1 device", 89,109,88,92}, - {NULL,Ctrl_paddle_png ,"","Select Port 1 device", 86,117,96,84}, - {NULL,Ctrl_sportspad_png ,"","Select Port 1 device", 95,117,76,84}, - {NULL,Ctrl_teamplayer_png ,"","Select Port 1 device", 94,109,80,92}, - {NULL,Ctrl_4wayplay_png ,"","Select Port 1 device", 98,110,72,92} - }, - { - {NULL,Ctrl_none_png ,"","Select Port 2 device",110,300,48,72}, - {NULL,Ctrl_gamepad_md_png ,"","Select Port 2 device", 85,287,96,84}, - {NULL,Ctrl_mouse_png ,"","Select Port 2 device", 97,283,64,88}, - {NULL,Ctrl_menacer_png ,"","Select Port 2 device", 94,283,80,88}, - {NULL,Ctrl_justifiers_png ,"","Select Port 2 device", 88,287,80,84}, - {NULL,Ctrl_xe_a1p_png ,"","Select Port 2 device", 98,288,72,84}, - {NULL,Ctrl_activator_png ,"","Select Port 2 device", 94,291,72,80}, - {NULL,Ctrl_gamepad_ms_png ,"","Select Port 2 device", 91,295,84,76}, - {NULL,Ctrl_lightphaser_png,"","Select Port 2 device", 89,279,88,92}, - {NULL,Ctrl_paddle_png ,"","Select Port 2 device", 86,287,96,84}, - {NULL,Ctrl_sportspad_png ,"","Select Port 2 device", 95,287,76,84}, - {NULL,Ctrl_teamplayer_png ,"","Select Port 2 device", 94,279,80,92}, - {NULL,Ctrl_4wayplay_png ,"","Select Port 2 device", 98,280,72,92} - } - }; - - /* Specific controller options */ - gui_item items_special[4][2] = - { - { - /* Gamepad option */ - {NULL,Ctrl_pad3b_png,"Pad\nType","Use 3-buttons Pad",528,180,44,28}, - {NULL,Ctrl_pad6b_png,"Pad\nType","Use 6-buttons Pad",528,180,44,28} - }, - { - /* Mouse option */ - {NULL,ctrl_option_off_png,"Invert\nMouse","Enable/Disable Y-Axis inversion",534,180,24,24}, - {NULL,ctrl_option_on_png ,"Invert\nMouse","Enable/Disable Y-Axis inversion",534,180,24,24}, - }, - { - /* Gun option */ - {NULL,ctrl_option_off_png,"Show\nCursor","Enable/Disable Lightgun cursor",534,180,24,24}, - {NULL,ctrl_option_on_png ,"Show\nCursor","Enable/Disable Lightgun cursor",534,180,24,24}, - }, - { - /* no option */ - {NULL,NULL,"No Option","",436,180,160,52}, - {NULL,NULL,"","",0,0,0,0}, - } - }; - - /* Player Configuration device items */ -#ifdef HW_RVL - gui_item items_device[5] = - { - {NULL,ctrl_option_off_png ,"Input\nDevice","Select Input Controller",534,244,24,24}, - {NULL,ctrl_gamecube_png ,"Input\nDevice","Select Input Controller",530,246,36,24}, - {NULL,ctrl_wiimote_png ,"Input\nDevice","Select Input Controller",526,250,40,12}, - {NULL,ctrl_nunchuk_png ,"Input\nDevice","Select Input Controller",532,242,32,32}, - {NULL,ctrl_classic_png ,"Input\nDevice","Select Input Controller",526,242,40,32}, - }; -#else - gui_item items_device[2] = - { - {NULL,ctrl_option_off_png ,"Input\nDevice","Select Input Controller",534,244,24,24}, - {NULL,ctrl_gamecube_png ,"Input\nDevice","Select Input Controller",530,246,36,24} - }; -#endif - - /* initialize menu */ - gui_menu *m = &menu_ctrls; - GUI_InitMenu(m); - - /* initialize custom buttons */ - button_player_data.texture[0] = gxTextureOpenPNG(button_player_data.image[0],0); - button_player_data.texture[1] = gxTextureOpenPNG(button_player_data.image[1],0); - button_player_none_data.texture[0] = gxTextureOpenPNG(button_player_none_data.image[0],0); - - /* initialize custom images */ - for (i=0; i<13; i++) - { - items_sys[1][i].texture = items_sys[0][i].texture = gxTextureOpenPNG(items_sys[0][i].data,0); - } - items_special[0][0].texture = gxTextureOpenPNG(items_special[0][0].data,0); - items_special[0][1].texture = gxTextureOpenPNG(items_special[0][1].data,0); - items_special[2][0].texture = items_special[1][0].texture = gxTextureOpenPNG(items_special[1][0].data,0); - items_special[2][1].texture = items_special[1][1].texture = gxTextureOpenPNG(items_special[1][1].data,0); - items_device[0].texture = items_special[1][0].texture; - items_device[1].texture = gxTextureOpenPNG(items_device[1].data,0); -#ifdef HW_RVL - items_device[2].texture = gxTextureOpenPNG(items_device[2].data,0); - items_device[3].texture = gxTextureOpenPNG(items_device[3].data,0); - items_device[4].texture = gxTextureOpenPNG(items_device[4].data,0); -#endif - - /* restore current menu elements */ - player = 0; - ctrlmenu_raz(); - memcpy(&m->items[0],&items_sys[0][input.system[0]],sizeof(gui_item)); - memcpy(&m->items[1],&items_sys[1][input.system[1]],sizeof(gui_item)); - - /* menu title slide effect */ - m->selected = 0; - GUI_SlideMenuTitle(m,strlen("Controller ")); - - while (update != -1) - { - /* draw menu */ - GUI_DrawMenu(m); - - /* update menu */ - update = GUI_UpdateMenu(m); - - if (update > 0) - { - switch (m->selected) - { - case 0: /* update port 1 system */ - { - /* fixed configurations */ - if (system_hw) - { - if (cart.special & HW_TEREBI_OEKAKI) - { - GUI_WaitPrompt("Error","Terebi Oekaki detected !"); - break; - } - else if (system_hw == SYSTEM_PICO) - { - GUI_WaitPrompt("Error","PICO hardware detected !"); - break; - } - } - - /* next connected device */ - input.system[0]++; - - /* allow only one connected mouse */ - if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE)) - { - input.system[0] += 3; - } - - /* Menacer & Justifiers on Port B only */ - if (input.system[0] == SYSTEM_MENACER) - { - input.system[0] += 2; - } - - /* allow only one gun type */ - if ((input.system[0] == SYSTEM_LIGHTPHASER) && ((input.system[1] == SYSTEM_MENACER) || (input.system[1] == SYSTEM_JUSTIFIER))) - { - input.system[0]++; - } - - /* 4-wayplay uses both ports */ - if (input.system[0] == SYSTEM_WAYPLAY) - { - input.system[1] = SYSTEM_WAYPLAY; - } - - /* loop back */ - if (input.system[0] > SYSTEM_WAYPLAY) - { - input.system[0] = NO_SYSTEM; - input.system[1] = SYSTEM_MD_GAMEPAD; - } - - /* reset I/O ports */ - io_init(); - input_reset(); - - /* save current configuration */ - old_system[0] = input.system[0]; - old_system[1] = input.system[1]; - - /* update menu elements */ - ctrlmenu_raz(); - memcpy(&m->items[0],&items_sys[0][input.system[0]],sizeof(gui_item)); - memcpy(&m->items[1],&items_sys[1][input.system[1]],sizeof(gui_item)); - - if (m->bg_images[7].state & IMAGE_VISIBLE) - { - /* slide out configuration window */ - GUI_DrawMenuFX(m, 20, 1); - - /* remove configuration window */ - m->bg_images[7].state &= ~IMAGE_VISIBLE; - - /* disable configuration buttons */ - m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - - /* update directions */ - m->buttons[2].shift[3] = 0; - m->buttons[3].shift[3] = 0; - m->buttons[4].shift[3] = 0; - m->buttons[5].shift[3] = 0; - m->buttons[6].shift[3] = 0; - m->buttons[7].shift[3] = 0; - m->buttons[8].shift[3] = 0; - m->buttons[9].shift[3] = 0; - - /* update title */ - sprintf(m->title,"Controller Settings"); - } - break; - } - - case 1: /* update port 2 system */ - { - /* fixed configurations */ - if (system_hw) - { - if (cart.special & HW_J_CART) - { - GUI_WaitPrompt("Error","J-CART detected !"); - break; - } - else if (cart.special & HW_TEREBI_OEKAKI) - { - GUI_WaitPrompt("Error","Terebi Oekaki detected !"); - break; - } - else if (system_hw == SYSTEM_PICO) - { - GUI_WaitPrompt("Error","PICO hardware detected !"); - break; - } - } - - /* next connected device */ - input.system[1]++; - - /* allow only one connected mouse */ - if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE)) - { - input.system[1]++; - } - - /* allow only one gun type */ - if ((input.system[0] == SYSTEM_LIGHTPHASER) && (input.system[1] == SYSTEM_MENACER)) - { - input.system[1] += 3; - } - - /* allow only one gun type */ - if ((input.system[0] == SYSTEM_LIGHTPHASER) && (input.system[1] == SYSTEM_JUSTIFIER)) - { - input.system[1] += 2; - } - - /* 4-wayplay uses both ports */ - if (input.system[1] == SYSTEM_WAYPLAY) - { - input.system[0] = SYSTEM_WAYPLAY; - } - - /* loop back */ - if (input.system[1] > SYSTEM_WAYPLAY) - { - input.system[1] = NO_SYSTEM; - input.system[0] = SYSTEM_MD_GAMEPAD; - } - - /* reset I/O ports */ - io_init(); - input_reset(); - - /* save current configuration */ - old_system[0] = input.system[0]; - old_system[1] = input.system[1]; - - /* update menu elements */ - ctrlmenu_raz(); - memcpy(&m->items[0],&items_sys[0][input.system[0]],sizeof(gui_item)); - memcpy(&m->items[1],&items_sys[1][input.system[1]],sizeof(gui_item)); - - if (m->bg_images[7].state & IMAGE_VISIBLE) - { - /* slide out configuration window */ - GUI_DrawMenuFX(m, 20, 1); - - /* remove configuration window */ - m->bg_images[7].state &= ~IMAGE_VISIBLE; - - /* disable configuration buttons */ - m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - - /* update directions */ - m->buttons[2].shift[3] = 0; - m->buttons[3].shift[3] = 0; - m->buttons[4].shift[3] = 0; - m->buttons[5].shift[3] = 0; - m->buttons[6].shift[3] = 0; - m->buttons[7].shift[3] = 0; - m->buttons[8].shift[3] = 0; - m->buttons[9].shift[3] = 0; - - /* update title */ - sprintf(m->title,"Controller Settings"); - } - - break; - } - - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - { - /* remove duplicate assigned inputs */ - for (i=0; iselected-2); i++) - { - if (input.dev[i] != NO_DEVICE) player ++; - } - - if (m->bg_images[7].state & IMAGE_VISIBLE) - { - /* if already displayed, do nothing */ - if (old_player == player) break; - - /* slide out configuration window */ - GUI_DrawMenuFX(m, 20, 1); - } - else - { - /* append configuration window */ - m->bg_images[7].state |= IMAGE_VISIBLE; - - /* enable configuration buttons */ - m->buttons[10].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - m->buttons[11].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - m->buttons[12].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - - /* update directions */ - m->buttons[2].shift[3] = 8; - m->buttons[3].shift[3] = 7; - m->buttons[4].shift[3] = 6; - m->buttons[5].shift[3] = 5; - m->buttons[6].shift[3] = 4; - m->buttons[7].shift[3] = 3; - m->buttons[8].shift[3] = 2; - m->buttons[9].shift[3] = 1; - } - - /* emulated device type */ - type = input.dev[m->selected - 2]; - - /* retrieve current player informations */ - switch (type) - { - case DEVICE_PAD3B: - case DEVICE_PAD6B: - { - items = items_special[0]; - special = &config.input[player].padtype; - break; - } - - case DEVICE_MOUSE: - { - items = items_special[1]; - special = &config.invert_mouse; - break; - } - - case DEVICE_LIGHTGUN: - { - items = items_special[2]; - - if ((input.system[1] == SYSTEM_MENACER) || (input.system[1] == SYSTEM_JUSTIFIER)) - { - /* Menacer & Justifiers affected to devices 4 & 5 */ - special = &config.gun_cursor[m->selected & 1]; - } - else - { - /* Lightphasers affected to devices 0 & 4 */ - special = &config.gun_cursor[m->selected >> 2]; - } - break; - } - - default: - { - items = items_special[3]; - special = NULL; - break; - } - } - - if (special) - { - memcpy(&m->items[10],&items[*special],sizeof(gui_item)); - } - else - { - memcpy(&m->items[10],&items[0],sizeof(gui_item)); - } - - memcpy(&m->items[11],&items_device[config.input[player].device + 1],sizeof(gui_item)); - - /* slide in configuration window */ - m->buttons[10].shift[2] = 10 - m->selected; - m->buttons[11].shift[2] = 11 - m->selected; - m->buttons[12].shift[2] = 12 - m->selected; - m->selected = 10; - GUI_DrawMenuFX(m, 20, 0); - - /* some devices require analog sticks */ - if ((type == DEVICE_XE_A1P) && ((config.input[player].device == -1) || (config.input[player].device == 1))) - { - GUI_WaitPrompt("Warning","One Analog Stick required !"); - } - else if ((type == DEVICE_ACTIVATOR) && ((config.input[player].device != 0) && (config.input[player].device != 3))) - { - GUI_WaitPrompt("Warning","Two Analog Sticks required !"); - } - - /* update title */ - if ((cart.special & HW_J_CART) && (player > 1)) - { - sprintf(m->title,"Controller Settings (Player %d) (J-CART)",player+1); - } - else - { - sprintf(m->title,"Controller Settings (Player %d)",player+1); - } - break; - } - - case 10: /* specific option */ - { - if (special) - { - /* switch option */ - *special ^= 1; - - /* specific case: controller type */ - if (type < 2) - { - /* re-initialize emulated device */ - input_init(); - input_reset(); - - /* update emulated device type */ - type = *special; - } - - /* update menu items */ - memcpy(&m->items[10],&items[*special],sizeof(gui_item)); - } - break; - } - - case 11: /* input controller selection */ - { - /* no input device */ - if (config.input[player].device < 0) - { - /* always try gamecube controllers first */ - config.input[player].device = 0; - config.input[player].port = 0; - } - else - { - /* try next port */ - config.input[player].port ++; - } - - /* autodetect connected gamecube controllers */ - if (config.input[player].device == 0) - { - /* find first connected controller */ - exp = 0; - while ((config.input[player].port < 4) && !exp) - { - VIDEO_WaitVSync (); - exp = PAD_ScanPads() & (1<= 4) - { -#ifdef HW_RVL - /* test wiimote */ - config.input[player].port = 0; - config.input[player].device = 1; -#else - /* no input controller left */ - config.input[player].device = -1; - config.input[player].port = player%4; -#endif - } - } - -#ifdef HW_RVL - /* autodetect connected wiimotes (without nunchuk) */ - if (config.input[player].device == 1) - { - /* test current port */ - exp = 255; - if (config.input[player].port < 4) - { - WPAD_Probe(config.input[player].port,&exp); - } - - /* find first connected controller */ - while ((config.input[player].port < 4) && (exp == 255)) - { - /* try next port */ - config.input[player].port ++; - if (config.input[player].port < 4) - { - exp = 255; - WPAD_Probe(config.input[player].port,&exp); - } - } - - /* no more wiimote */ - if (config.input[player].port >= 4) - { - /* test wiimote+nunchuk */ - config.input[player].port = 0; - config.input[player].device = 2; - } - } - - /* autodetect connected wiimote+nunchuk */ - if (config.input[player].device == 2) - { - /* test current port */ - exp = 255; - if (config.input[player].port < 4) - { - WPAD_Probe(config.input[player].port,&exp); - } - - /* find first connected controller */ - while ((config.input[player].port < 4) && (exp != WPAD_EXP_NUNCHUK)) - { - /* try next port */ - config.input[player].port ++; - if (config.input[player].port < 4) - { - exp = 255; - WPAD_Probe(config.input[player].port,&exp); - } - } - - /* no more wiimote+nunchuk */ - if (config.input[player].port >= 4) - { - /* test classic controllers */ - config.input[player].port = 0; - config.input[player].device = 3; - } - } - - /* autodetect connected classic controllers */ - if (config.input[player].device == 3) - { - /* test current port */ - exp = 255; - if (config.input[player].port < 4) - { - WPAD_Probe(config.input[player].port,&exp); - } - - /* find first connected controller */ - while ((config.input[player].port<4) && (exp != WPAD_EXP_CLASSIC)) - { - /* try next port */ - config.input[player].port ++; - if (config.input[player].port < 4) - { - exp = 255; - WPAD_Probe(config.input[player].port,&exp); - } - } - - if (config.input[player].port >= 4) - { - /* no input controller left */ - config.input[player].device = -1; - config.input[player].port = player%4; - } - } -#endif - - /* update menu items */ - memcpy(&m->items[11],&items_device[config.input[player].device + 1],sizeof(gui_item)); - - break; - } - - case 12: /* Controller Keys Configuration */ - { - if (config.input[player].device >= 0) - { - GUI_MsgBoxOpen("Keys Configuration", "",0); - gx_input_Config(config.input[player].port, config.input[player].device, type); - GUI_MsgBoxClose(); - } - break; - } - } - } - - /* Close Window */ - else if (update < 0) - { - if (m->bg_images[7].state & IMAGE_VISIBLE) - { - /* slide out configuration window */ - GUI_DrawMenuFX(m, 20, 1); - - /* disable configuration window */ - m->bg_images[7].state &= ~IMAGE_VISIBLE; - - /* disable configuration buttons */ - m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - - /* clear directions */ - m->buttons[2].shift[3] = 0; - m->buttons[3].shift[3] = 0; - m->buttons[4].shift[3] = 0; - m->buttons[5].shift[3] = 0; - m->buttons[6].shift[3] = 0; - m->buttons[7].shift[3] = 0; - m->buttons[8].shift[3] = 0; - m->buttons[9].shift[3] = 0; - - /* update selector */ - m->selected -= m->buttons[m->selected].shift[2]; - - /* restore title */ - sprintf(m->title,"Controller Settings"); - - /* stay in menu */ - update = 0; - } - else - { - /* check we have at least one connected input before leaving */ - old_player = player; - player = 0; - for (i=0; ibg_images[7].state &= ~IMAGE_VISIBLE; - - /* disable configuration buttons */ - m->buttons[10].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[11].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - m->buttons[12].state &= (~BUTTON_VISIBLE & ~BUTTON_ACTIVE); - - /* clear directions */ - m->buttons[2].shift[3] = 0; - m->buttons[3].shift[3] = 0; - m->buttons[4].shift[3] = 0; - m->buttons[5].shift[3] = 0; - m->buttons[6].shift[3] = 0; - m->buttons[7].shift[3] = 0; - m->buttons[8].shift[3] = 0; - m->buttons[9].shift[3] = 0; - - /* clear menu items */ - memset(&m->items[0],0,sizeof(gui_item)); - memset(&m->items[1],0,sizeof(gui_item)); - memset(&m->items[10],0,sizeof(gui_item)); - memset(&m->items[11],0,sizeof(gui_item)); - - /* clear player buttons */ - m->buttons[2].data = NULL; - m->buttons[3].data = NULL; - m->buttons[4].data = NULL; - m->buttons[5].data = NULL; - m->buttons[6].data = NULL; - m->buttons[7].data = NULL; - m->buttons[8].data = NULL; - m->buttons[9].data = NULL; - - /* delete menu */ - GUI_DeleteMenu(m); - - /* delete custom buttons */ - gxTextureClose(&button_player_data.texture[0]); - gxTextureClose(&button_player_data.texture[1]); - gxTextureClose(&button_player_none_data.texture[0]); - - /* delete custom images */ - for (i=0; i<13; i++) - { - gxTextureClose(&items_sys[0][i].texture); - } - gxTextureClose(&items_special[0][0].texture); - gxTextureClose(&items_special[0][1].texture); - gxTextureClose(&items_special[1][0].texture); - gxTextureClose(&items_special[1][1].texture); - gxTextureClose(&items_device[1].texture); -#ifdef HW_RVL - gxTextureClose(&items_device[2].texture); - gxTextureClose(&items_device[3].texture); - gxTextureClose(&items_device[4].texture); -#endif -} - -/**************************************************************************** - * Main Option menu - * - ****************************************************************************/ -static void optionmenu(void) -{ - int ret, quit = 0; - gui_menu *m = &menu_options; - - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - - while (quit == 0) - { - ret = GUI_RunMenu(m); - - switch (ret) - { - case 0: - GUI_DeleteMenu(m); - systemmenu(); - GUI_InitMenu(m); - break; - case 1: - GUI_DeleteMenu(m); - videomenu(); - GUI_InitMenu(m); - break; - case 2: - GUI_DeleteMenu(m); - soundmenu(); - GUI_InitMenu(m); - break; - case 3: - GUI_DeleteMenu(m); - ctrlmenu(); - GUI_InitMenu(m); - break; - case 4: - GUI_DeleteMenu(m); - prefmenu(); - GUI_InitMenu(m); - break; - case -1: - quit = 1; - break; - } - } - - config_save(); - GUI_DrawMenuFX(m,30,1); - GUI_DeleteMenu(m); -} - -/**************************************************************************** -* Save Manager menu -* -****************************************************************************/ -static t_slot slots[5]; -static void savemenu_cb(void) -{ - int i; - char msg[16]; - gx_texture *star = gxTextureOpenPNG(Star_full_png,0); - - if (sram.on) - { - FONT_write("Backup Memory",16,buttons_saves[0].x+16,buttons_saves[0].y+(buttons_saves[0].h-16)/2+16,buttons_saves[0].x+buttons_saves[0].w,(GXColor)DARK_GREY); - if (slots[0].valid) - { - sprintf(msg,"%d/%02d/%02d",slots[0].day,slots[0].month,slots[0].year); - FONT_alignRight(msg,12,buttons_saves[0].x+buttons_saves[0].w-16,buttons_saves[0].y+(buttons_saves[0].h-28)/2+12,(GXColor)DARK_GREY); - sprintf(msg,"%02d:%02d",slots[0].hour,slots[0].min); - FONT_alignRight(msg,12,buttons_saves[0].x+buttons_saves[0].w-16,buttons_saves[0].y+(buttons_saves[0].h-28)/2+28,(GXColor)DARK_GREY); - } - - if (sram.crc != crc32(0, &sram.sram[0], 0x10000)) - gxDrawTexture(star,22,buttons_saves[0].y+(buttons_saves[0].h-star->height)/2,star->width,star->height,255); - } - else - { - FONT_writeCenter("Backup Memory disabled",16,buttons_saves[0].x,buttons_saves[0].x+buttons_saves[0].w,buttons_saves[0].y+(buttons_saves[0].h-16)/2+16,(GXColor)DARK_GREY); - } - - for (i=1; i<5; i++) - { - if (slots[i].valid) - { - sprintf(msg,"Slot %d",i); - FONT_write(msg,16,buttons_saves[i].x+16,buttons_saves[i].y+(buttons_saves[i].h-16)/2+16,buttons_saves[i].x+buttons_saves[i].w,(GXColor)DARK_GREY); - sprintf(msg,"%d/%02d/%02d",slots[i].day,slots[i].month,slots[i].year); - FONT_alignRight(msg,12,buttons_saves[i].x+buttons_saves[i].w-16,buttons_saves[i].y+(buttons_saves[i].h-28)/2+12,(GXColor)DARK_GREY); - sprintf(msg,"%02d:%02d",slots[i].hour,slots[i].min); - FONT_alignRight(msg,12,buttons_saves[i].x+buttons_saves[i].w-16,buttons_saves[i].y+(buttons_saves[i].h-28)/2+28,(GXColor)DARK_GREY); - } - else - { - FONT_write("Empty Slot",16,buttons_saves[i].x+16,buttons_saves[i].y+(buttons_saves[i].h-16)/2+16,buttons_saves[i].x+buttons_saves[i].h,(GXColor)DARK_GREY); - } - - if (i == config.s_default) - gxDrawTexture(star,22,buttons_saves[i].y+(buttons_saves[i].h-star->height)/2,star->width,star->height,255); - } - gxTextureClose(&star); -} - -static int savemenu(void) -{ - int i, update = 0; - int ret = 0; - int slot = -1; - char filename[MAXPATHLEN]; - gui_menu *m = &menu_saves; - FILE *snap; - - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - - m->bg_images[3].state &= ~IMAGE_SLIDE_TOP; - m->bg_images[4].state &= ~IMAGE_SLIDE_BOTTOM; - m->bg_images[5].state &= ~IMAGE_SLIDE_TOP; - - /* detect existing files */ - for (i=0; i<5; i++) - slot_autodetect(i, config.s_device, &slots[i]); - - /* SRAM disabled */ - if (sram.on) - { - m->buttons[0].state |= BUTTON_ACTIVE; - m->buttons[1].shift[0] = 1; - } - else - { - m->buttons[0].state &= ~BUTTON_ACTIVE; - m->buttons[1].shift[0] = 0; - if (m->selected == 0) - m->selected = 1; - } - - while (update != -1) - { - /* slot selection */ - if ((m->selected < 5) && (slot != m->selected)) - { - /* update slot */ - slot = m->selected; - - /* delete previous texture if any */ - gxTextureClose(&bg_saves[0].texture); - bg_saves[0].state &= ~IMAGE_VISIBLE; - bg_saves[1].state |= IMAGE_VISIBLE; - - /* state slot */ - if (!config.s_device && slot && slots[slot].valid) - { - /* open screenshot file */ - sprintf (filename, "%s/saves/%s__%d.png", DEFAULT_PATH, rom_filename, slot - 1); - snap = fopen(filename, "rb"); - if (snap) - { - /* load texture from file */ - bg_saves[0].texture = gxTextureOpenPNG(0,snap); - if (bg_saves[0].texture) - { - /* set menu background */ - bg_saves[0].w = bg_saves[0].texture->width * 2; - if (config.aspect & 2) bg_saves[0].w = (bg_saves[0].w * 3) / 4; - bg_saves[0].h = bg_saves[0].texture->height * 2; - bg_saves[0].x = (vmode->fbWidth - bg_saves[0].w) / 2; - bg_saves[0].y = (vmode->efbHeight - bg_saves[0].h) / 2; - bg_saves[0].state |= IMAGE_VISIBLE; - bg_saves[1].state &= ~IMAGE_VISIBLE; - } - fclose(snap); - } - } - } - - /* draw menu */ - GUI_DrawMenu(m); - - /* update menu */ - update = GUI_UpdateMenu(m); - - if (update > 0) - { - switch (m->selected) - { - case 0: - case 1: - case 2: - case 3: - case 4: /* Slot selection */ - { - /* enable right window */ - m->bg_images[7].state |= IMAGE_VISIBLE; - m->buttons[5].state |= BUTTON_VISIBLE; - m->buttons[6].state |= BUTTON_VISIBLE; - m->buttons[7].state |= BUTTON_VISIBLE; - m->buttons[8].state |= BUTTON_VISIBLE; - - /* only enable valid options */ - if (slots[slot].valid) - { - m->buttons[5].state |= BUTTON_ACTIVE; - m->buttons[7].state |= BUTTON_ACTIVE; - m->buttons[6].shift[0] = 1; - m->buttons[6].shift[1] = 1; - m->buttons[8].shift[0] = 1; - m->selected = 5; - } - else - { - m->buttons[5].state &= ~BUTTON_ACTIVE; - m->buttons[7].state &= ~BUTTON_ACTIVE; - m->buttons[6].shift[0] = 0; - m->buttons[6].shift[1] = 2; - m->buttons[8].shift[0] = (slot > 0) ? 2 : 0; - m->selected = 8; - } - - /* state slot 'only' button */ - if (slot > 0) - { - m->buttons[6].state |= BUTTON_ACTIVE; - m->buttons[5].shift[1] = 1; - m->buttons[7].shift[0] = 1; - } - else - { - m->buttons[6].state &= ~BUTTON_ACTIVE; - m->buttons[5].shift[1] = 2; - m->buttons[7].shift[0] = 2; - } - - /* disable left buttons */ - m->buttons[0].state &= ~BUTTON_ACTIVE; - m->buttons[1].state &= ~BUTTON_ACTIVE; - m->buttons[2].state &= ~BUTTON_ACTIVE; - m->buttons[3].state &= ~BUTTON_ACTIVE; - m->buttons[4].state &= ~BUTTON_ACTIVE; - - /* keep current selection highlighted */ - m->buttons[slot].state |= BUTTON_SELECTED; - - /* slide in window */ - GUI_DrawMenuFX(m, 20, 0); - - break; - } - - case 5: /* load file */ - { - if (slots[slot].valid) - { - ret = slot_load(slot,config.s_device); - - /* force exit */ - if (ret > 0) - { - GUI_DrawMenuFX(m, 20, 1); - m->buttons[slot].state &= ~BUTTON_SELECTED; - m->bg_images[7].state &= ~IMAGE_VISIBLE; - if (sram.on) - m->buttons[0].state |= BUTTON_ACTIVE; - m->buttons[1].state |= BUTTON_ACTIVE; - m->buttons[2].state |= BUTTON_ACTIVE; - m->buttons[3].state |= BUTTON_ACTIVE; - m->buttons[4].state |= BUTTON_ACTIVE; - m->buttons[5].state &= ~BUTTON_VISIBLE; - m->buttons[6].state &= ~BUTTON_VISIBLE; - m->buttons[7].state &= ~BUTTON_VISIBLE; - m->buttons[8].state &= ~BUTTON_VISIBLE; - m->selected = slot; - update = -1; - } - } - break; - } - - case 6: /* set default slot */ - { - config.s_default = slot; - config_save(); - break; - } - - case 7: /* delete file */ - { - if (slots[slot].valid) - { - if (slot_delete(slot,config.s_device) >= 0) - { - /* hide screenshot */ - gxTextureClose(&bg_saves[0].texture); - bg_saves[0].state &= ~IMAGE_VISIBLE; - slots[slot].valid = 0; - update = -1; - } - } - break; - } - - case 8: /* save file */ - { - ret = slot_save(slot,config.s_device); - - /* force exit */ - if (ret > 0) - { - GUI_DrawMenuFX(m, 20, 1); - m->buttons[slot].state &= ~BUTTON_SELECTED; - m->bg_images[7].state &= ~IMAGE_VISIBLE; - if (sram.on) - m->buttons[0].state |= BUTTON_ACTIVE; - m->buttons[1].state |= BUTTON_ACTIVE; - m->buttons[2].state |= BUTTON_ACTIVE; - m->buttons[3].state |= BUTTON_ACTIVE; - m->buttons[4].state |= BUTTON_ACTIVE; - m->buttons[5].state &= ~BUTTON_VISIBLE; - m->buttons[6].state &= ~BUTTON_VISIBLE; - m->buttons[7].state &= ~BUTTON_VISIBLE; - m->buttons[8].state &= ~BUTTON_VISIBLE; - m->selected = slot; - update = -1; - } - break; - } - - default: - break; - } - } - - if (update < 0) - { - /* close right window */ - if (m->bg_images[7].state & IMAGE_VISIBLE) - { - /* slide out window */ - GUI_DrawMenuFX(m, 20, 1); - - /* clear current selection */ - m->buttons[slot].state &= ~BUTTON_SELECTED; - - /* enable left buttons */ - if (sram.on) - m->buttons[0].state |= BUTTON_ACTIVE; - m->buttons[1].state |= BUTTON_ACTIVE; - m->buttons[2].state |= BUTTON_ACTIVE; - m->buttons[3].state |= BUTTON_ACTIVE; - m->buttons[4].state |= BUTTON_ACTIVE; - - /* disable right window */ - m->bg_images[7].state &= ~IMAGE_VISIBLE; - m->buttons[5].state &= ~BUTTON_VISIBLE; - m->buttons[6].state &= ~BUTTON_VISIBLE; - m->buttons[7].state &= ~BUTTON_VISIBLE; - m->buttons[8].state &= ~BUTTON_VISIBLE; - - /* stay in menu */ - m->selected = slot; - update = 0; - } - } - } - - /* leave menu */ - m->bg_images[3].state |= IMAGE_SLIDE_TOP; - m->bg_images[4].state |= IMAGE_SLIDE_BOTTOM; - m->bg_images[5].state |= IMAGE_SLIDE_TOP; - GUI_DrawMenuFX(m,30,1); - GUI_DeleteMenu(m); - return ret; -} - -/**************************************************************************** - * Load Game menu - * - ****************************************************************************/ -static int loadgamemenu () -{ - int ret, filetype; - gui_menu *m = &menu_load; - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - - while (1) - { - ret = GUI_RunMenu(m); - - switch (ret) - { - /*** Button B ***/ - case -1: - GUI_DrawMenuFX(m,30,1); - GUI_DeleteMenu(m); - return 0; - - /*** Load from selected device */ - default: - { - /* ROM File type */ - filetype = ret - 1; - - /* Try to open current directory */ - if (ret > 0) - { - ret = OpenDirectory(config.l_device, filetype); - } - else - { - ret = OpenDirectory(TYPE_RECENT, filetype); - } - - if (ret) - { - GUI_DeleteMenu(m); - if (FileSelector(filetype)) - { - /* directly jump to game */ - return 1; - } - GUI_InitMenu(m); - } - break; - } - } - } - - return 0; -} - -/*************************************************************************** - * Show rom info screen - ***************************************************************************/ -static void showrominfo (void) -{ - char items[15][64]; - char msg[32]; - - /* fill ROM infos */ - sprintf (items[0], "Console Type: %s", rominfo.consoletype); - sprintf (items[1], "Copyright: %s", rominfo.copyright); - sprintf (items[2], "Company Name: %s", get_company()); - sprintf (items[3], "Domestic Name:"); - sprintf (items[4], "%s",rominfo.domestic); - sprintf (items[5], "International Name:"); - sprintf (items[6], "%s",rominfo.international); - sprintf (items[7], "Type: %s (%s)",rominfo.ROMType, strcmp(rominfo.ROMType, "AI") ? "Game" : "Educational"); - sprintf (items[8], "Product ID: %s", rominfo.product); - sprintf (items[9], "Checksum: %04x (%04x) (%s)", rominfo.checksum, rominfo.realchecksum, - (rominfo.checksum == rominfo.realchecksum) ? "GOOD" : "BAD"); - - sprintf (items[10], "Supports: "); - if (rominfo.peripherals & (1 << 1)) - { - strcat(items[10],get_peripheral(1)); - strcat(items[10],", "); - } - else if (rominfo.peripherals & (1 << 0)) - { - strcat(items[10],get_peripheral(0)); - strcat(items[10],", "); - } - if (rominfo.peripherals & (1 << 7)) - { - strcat(items[10],get_peripheral(7)); - strcat(items[10],", "); - } - if (rominfo.peripherals & (1 << 8)) - { - strcat(items[10],get_peripheral(8)); - strcat(items[10],", "); - } - if (rominfo.peripherals & (1 << 11)) - { - strcat(items[10],get_peripheral(11)); - strcat(items[10],", "); - } - if (rominfo.peripherals & (1 << 13)) - { - strcat(items[10],get_peripheral(13)); - strcat(items[10],", "); - } - if (strlen(items[10]) > 10) - items[10][strlen(items[10]) - 2] = 0; - - sprintf (items[11], "ROM end: $%06X", rominfo.romend); - - if (sram.custom) - sprintf (items[12], "Serial EEPROM"); - else if (sram.detected) - sprintf (items[12], "SRAM Start: $%06X", sram.start); - else - sprintf (items[12], "No Backup Memory specified"); - - if (sram.custom == 1) - sprintf (items[13], "Type: I2C (24Cxx)"); - else if (sram.custom == 2) - sprintf (items[13], "Type: SPI (25x512/95x512)"); - else if (sram.custom == 3) - sprintf (items[13], "Type: I2C (93C46)"); - else if (sram.detected) - sprintf (items[13], "SRAM End: $%06X", sram.end); - else if (sram.on) - sprintf (items[13], "SRAM enabled by default"); - else - sprintf (items[13], "SRAM disabled by default"); - - if (region_code == REGION_USA) - sprintf (items[14], "Region Code: %s (USA)", rominfo.country); - else if (region_code == REGION_EUROPE) - sprintf (items[14], "Region Code: %s (EUR)", rominfo.country); - else if (region_code == REGION_JAPAN_NTSC) - sprintf (items[14], "Region Code: %s (JPN)", rominfo.country); - else if (region_code == REGION_JAPAN_PAL) - sprintf (items[14], "Region Code: %s (JPN-PAL)", rominfo.country); - -#ifdef USE_BENCHMARK - /* ROM benchmark */ - if (!config.ntsc) - { - int frames = 0; - u64 start = gettime(); - do - { - system_frame(0); - audio_update(); - } - while (++frames < 300); - u64 end = gettime(); - sprintf(msg,"ROM Header Info (%d fps)", (300 * 1000000) / diff_usec(start,end)); - } - else -#endif - { - strcpy(msg,"ROM Header Info"); - } - - GUI_TextWindow(&menu_main, msg, items, 15, 15); -} - -/*************************************************************************** - * Show credits - ***************************************************************************/ -static void showcredits(void) -{ - int offset = 0; - - gx_texture *texture = gxTextureOpenPNG(Bg_credits_png,0); - s16 p = 0; - - while (!p) - { - gxClearScreen ((GXColor)BLACK); - if (texture) - gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255); - - FONT_writeCenter("Genesis Plus Core", 24, 0, 640, 480 - offset, (GXColor)LIGHT_BLUE); - FONT_writeCenter("improved emulation code, fixes & extra features by Eke-Eke", 18, 0, 640, 516 - offset, (GXColor)WHITE); - FONT_writeCenter("original 1.3 version by Charles MacDonald", 18, 0, 640, 534 - offset, (GXColor)WHITE); - FONT_writeCenter("original Z80 core by Juergen Buchmueller", 18, 0, 640, 552 - offset, (GXColor)WHITE); - FONT_writeCenter("original 68k core (Musashi) by Karl Stenerud", 18, 0, 640, 570 - offset, (GXColor)WHITE); - FONT_writeCenter("original YM2612/2413 cores by Jarek Burczynski, Tatsuyuki Satoh", 18, 0, 640, 588 - offset, (GXColor)WHITE); - FONT_writeCenter("original SN76489 core by Maxim", 18, 0, 640, 606 - offset, (GXColor)WHITE); - FONT_writeCenter("SVP core by Gravydas Ignotas (Notaz)", 18, 0, 640, 624 - offset, (GXColor)WHITE); - FONT_writeCenter("Blip Buffer Library & NTSC Video Filter by Shay Green (Blargg)", 18, 0, 640, 642 - offset, (GXColor)WHITE); - FONT_writeCenter("3-Band EQ implementation by Neil C", 18, 0, 640, 660 - offset, (GXColor)WHITE); - - FONT_writeCenter("Special thanks to ...", 20, 0, 640, 700 - offset, (GXColor)LIGHT_GREEN); - FONT_writeCenter("Nemesis, Tasco Deluxe, Bart Trzynadlowski, Jorge Cwik, Haze,", 18, 0, 640, 736 - offset, (GXColor)WHITE); - FONT_writeCenter("Stef Dallongeville, Notaz, AamirM, Steve Snake, Charles MacDonald", 18, 0, 640, 754 - offset, (GXColor)WHITE); - FONT_writeCenter("Spritesmind & SMS Power forums members for their technical help", 18, 0, 640, 772 - offset, (GXColor)WHITE); - - FONT_writeCenter("Gamecube & Wii port", 24, 0, 640, 830 - offset, (GXColor)LIGHT_BLUE); - FONT_writeCenter("porting code, GUI engine & design by Eke-Eke", 18, 0, 640, 866 - offset, (GXColor)WHITE); - FONT_writeCenter("original Gamecube port by Softdev, Honkeykong & Markcube", 18, 0, 640, 884 - offset, (GXColor)WHITE); - FONT_writeCenter("original icons, logo & button design by Low Lines", 18, 0, 640, 906 - offset, (GXColor)WHITE); - FONT_writeCenter("credit illustration by Orioto (Deviant Art)", 18, 0, 640, 924 - offset, (GXColor)WHITE); - FONT_writeCenter("memory card icon design by Brakken", 18, 0, 640, 942 - offset, (GXColor)WHITE); - FONT_writeCenter("libogc by Shagkur & various other contibutors", 18, 0, 640, 960 - offset, (GXColor)WHITE); - FONT_writeCenter("libfat by Chism", 18, 0, 640, 978 - offset, (GXColor)WHITE); - FONT_writeCenter("wiiuse by Michael Laforest (Para)", 18, 0, 640, 996 - offset, (GXColor)WHITE); - FONT_writeCenter("asndlib & OGG player by Francisco Muñoz (Hermes)", 18, 0, 640, 1014 - offset, (GXColor)WHITE); - FONT_writeCenter("zlib, libpng & libtremor by their respective authors", 18, 0, 640, 1032 - offset, (GXColor)WHITE); - FONT_writeCenter("devkitPPC by Wintermute", 18, 0, 640, 1050 - offset, (GXColor)WHITE); - - FONT_writeCenter("Special thanks to ...", 20, 0, 640, 1090 - offset, (GXColor)LIGHT_GREEN); - FONT_writeCenter("Softdev, Tmbinc, Costis, Emukiddid, Team Twiizer", 18, 0, 640, 1126 - offset, (GXColor)WHITE); - FONT_writeCenter("Brakken & former Tehskeen members for their support", 18, 0, 640, 1144 - offset, (GXColor)WHITE); - FONT_writeCenter("Anca, my wife, for her patience & various ideas", 18, 0, 640, 1162 - offset, (GXColor)WHITE); - - gxSetScreen(); - p = m_input.keys; - gxSetScreen(); - p |= m_input.keys; - offset ++; - if (offset > 1144) - offset = 0; - } - - gxTextureClose(&texture); -} - -static void exitmenu(void) -{ - char *items[3] = - { - "View Credits", -#ifdef HW_RVL - "Exit to System Menu", -#else - "Reset System", -#endif - "Return to Loader", - }; - - /* check if loader stub exists */ - int maxitems = reload ? 3 : 2; - - /* display option window */ - switch (GUI_OptionWindow(&menu_main, osd_version, items, maxitems)) - { - case 0: /* credits */ - GUI_DeleteMenu(&menu_main); - showcredits(); - GUI_InitMenu(&menu_main); - break; - - case 1: /* reset */ -#ifdef HW_RVL - gxTextureClose(&w_pointer); -#endif - GUI_DeleteMenu(&menu_main); - GUI_FadeOut(); - shutdown(); -#ifdef HW_RVL - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); -#else - SYS_ResetSystem(SYS_HOTRESET,0,0); -#endif - break; - - case 2: /* exit to loader */ -#ifdef HW_RVL - gxTextureClose(&w_pointer); -#endif - GUI_DeleteMenu(&menu_main); - GUI_FadeOut(); - shutdown(); - SYS_ResetSystem(SYS_SHUTDOWN,0,0); - __lwp_thread_stopmultitasking(*reload); - break; - - default: - break; - } -} - -/**************************************************************************** - * Main Menu - * - ****************************************************************************/ - -static void mainmenu_cb(void) -{ - char temp[4]; - gui_menu *m = &menu_main; - int status = areplay_get_status(); - - /* Action Replay Switch current status */ - if (status == AR_SWITCH_TRAINER) strcpy(temp,"TM"); - else if (status == AR_SWITCH_ON) strcpy(temp,"ON"); - else strcpy(temp,"OFF"); - - /* Display informations */ - if (m->selected == 6) - { - FONT_writeCenter("Action\nReplay", 14, m->items[6].x, m->items[6].x + 54, m->items[6].y + (m->items[6].h - 28)/2 + 14, (GXColor)DARK_GREY); - FONT_writeCenter(temp, 11, m->items[6].x + 56 + 3, m->items[6].x + 78 + 2, m->items[6].y + (m->items[6].h - 11)/2 + 11, (GXColor)DARK_GREY); - } - else - { - FONT_writeCenter("Action\nReplay", 12, m->items[6].x + 4, m->items[6].x + 54, m->items[6].y + (m->items[6].h - 24)/2 + 12, (GXColor)DARK_GREY); - FONT_writeCenter(temp, 10, m->items[6].x + 56, m->items[6].x + 78, m->items[6].y + (m->items[6].h - 10)/2 + 10, (GXColor)DARK_GREY); - } -} - -void mainmenu(void) -{ - char filename[MAXPATHLEN]; - int status, quit = 0; - - /* Autosave Backup RAM */ - slot_autosave(0, config.s_device); - -#ifdef HW_RVL - /* Detect shutdown request */ - if (Shutdown) - { - GUI_FadeOut(); - shutdown(); - if (reload) - { - /* exit to loader if requested */ - SYS_ResetSystem(SYS_SHUTDOWN,0,0); - __lwp_thread_stopmultitasking(*reload); - } - else - { - /* shutdown system by default */ - SYS_ResetSystem(SYS_POWEROFF, 0, 0); - } - } - - /* Wiimote pointer */ - w_pointer = gxTextureOpenPNG(generic_point_png,0); -#endif - - gui_menu *m = &menu_main; - - /* Update main menu */ - if (!m->screenshot) - { - if (config.bg_overlay) - { - bg_main[1].state |= IMAGE_VISIBLE; - bg_misc[1].state |= IMAGE_VISIBLE; - bg_ctrls[1].state |= IMAGE_VISIBLE; - bg_list[1].state |= IMAGE_VISIBLE; - bg_saves[2].state |= IMAGE_VISIBLE; - } - else - { - bg_main[1].state &= ~IMAGE_VISIBLE; - bg_misc[1].state &= ~IMAGE_VISIBLE; - bg_ctrls[1].state &= ~IMAGE_VISIBLE; - bg_list[1].state &= ~IMAGE_VISIBLE; - bg_saves[2].state &= ~IMAGE_VISIBLE; - } - - if (system_hw) - { - m->screenshot = 128; - m->bg_images[0].state &= ~IMAGE_VISIBLE; - m->items[0].y -= 90; - m->items[1].y -= 90; - m->items[2].y -= 90; - m->buttons[0].y -= 90; - m->buttons[1].y -= 90; - m->buttons[2].y -= 90; - m->buttons[0].shift[1] = 3; - m->buttons[1].shift[1] = 3; - m->buttons[2].shift[1] = 3; - m->buttons[3].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - m->buttons[4].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - m->buttons[5].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - m->buttons[7].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - m->buttons[8].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - m->buttons[9].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - if (areplay_get_status() >= 0) - { - menu_main.buttons[6].state |= (BUTTON_VISIBLE | BUTTON_ACTIVE); - menu_main.items[6].data = Button_sm_grey_png; - menu_main.cb = mainmenu_cb; - menu_main.buttons[3].shift[1] = 3; - menu_main.buttons[7].shift[0] = 1; - menu_main.buttons[8].shift[2] = 2; - } - } - } - - GUI_InitMenu(m); - GUI_DrawMenuFX(m,10,0); - - while (quit == 0) - { - switch (GUI_RunMenu(m)) - { - /*** Load Game Menu ***/ - case 0: - { - GUI_DrawMenuFX(m,30,1); - GUI_DeleteMenu(m); - - if (loadgamemenu()) - { - /* restart emulation */ - reloadrom(); - - /* check current controller configuration */ - if (!gx_input_FindDevices()) - { - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - GUI_WaitPrompt("Error","Invalid Controllers Settings"); - break; - } - - /* exit to game and reinitialize emulation */ - gxClearScreen((GXColor)BLACK); - gxSetScreen(); - quit = 1; - break; - } - - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - break; - } - - /*** Options Menu */ - case 1: - { - GUI_DrawMenuFX(m,30,1); - GUI_DeleteMenu(m); - optionmenu(); - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - break; - } - - /*** Exit Menu ***/ - case 2: - { - exitmenu(); - break; - } - - /*** Save Manager ***/ - case 3: - { - GUI_DrawMenuFX(m,30,1); - GUI_DeleteMenu(m); - - if (savemenu()) - { - /* check current controller configuration */ - if (!gx_input_FindDevices()) - { - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - GUI_WaitPrompt("Error","Invalid Controllers Settings"); - break; - } - - /* exit to game */ - quit = 1; - break; - } - - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - break; - } - - /*** Soft / Hard reset ***/ - case 4: - { - /* check current controller configuration */ - if (!gx_input_FindDevices()) - { - GUI_WaitPrompt("Error","Invalid Controllers Settings"); - break; - } - - /* reinitialize emulation */ - GUI_DrawMenuFX(m,10,1); - GUI_DeleteMenu(m); - gxClearScreen((GXColor)BLACK); - gxSetScreen(); - - if (system_hw & SYSTEM_MD) - { - /* Soft Reset */ - gen_reset(0); - } - else if (system_hw == SYSTEM_SMS) - { - /* assert RESET input (Master System model 1 only) */ - io_reg[0x0D] &= ~IO_RESET_HI; - } - else - { - /* Hard Reset */ - system_init(); - system_reset(); - - /* restore SRAM */ - slot_autoload(0,config.s_device); - } - - /* exit to game */ - quit = 1; - break; - } - - /*** Cheats menu ***/ - case 5: - { - GUI_DrawMenuFX(m,30,1); - GUI_DeleteMenu(m); - CheatMenu(); - GUI_InitMenu(m); - GUI_DrawMenuFX(m,30,0); - break; - } - - /*** Action Replay switch ***/ - case 6: - { - status = (areplay_get_status() + 1) % (AR_SWITCH_TRAINER + 1); - areplay_set_status(status); - status = areplay_get_status(); - GUI_DeleteMenu(m); - if (status == AR_SWITCH_TRAINER) m->items[6].data = Button_sm_blue_png; - else if (status == AR_SWITCH_ON) m->items[6].data = Button_sm_yellow_png; - else m->items[6].data = Button_sm_grey_png; - GUI_InitMenu(m); - break; - } - - /*** Return to Game ***/ - case 7: - case -1: - { - if (system_hw) - { - /* check current controller configuration */ - if (!gx_input_FindDevices()) - { - GUI_WaitPrompt("Error","Invalid Controllers Settings"); - break; - } - - /* exit to game */ - GUI_DrawMenuFX(m,10,1); - GUI_DeleteMenu(m); - quit = 1; - } - break; - } - - /*** Game Capture ***/ - case 8: - { - /* PNG filename */ - sprintf(filename,"%s/snaps/%s.png", DEFAULT_PATH, rom_filename); - - /* Save file and return */ - gxSaveScreenshot(filename); - break; - } - - /*** ROM information screen ***/ - case 9: - { - showrominfo(); - break; - } - } - } - - /*** Remove any still held buttons ***/ - while (PAD_ButtonsHeld(0)) - { - VIDEO_WaitVSync(); - PAD_ScanPads(); - } -#ifdef HW_RVL - while (WPAD_ButtonsHeld(0)) - { - VIDEO_WaitVSync(); - WPAD_ScanPads(); - } - gxTextureClose(&w_pointer); - - /* USB Mouse support */ - if ((input.system[0] == SYSTEM_MOUSE) || (input.system[1] == SYSTEM_MOUSE)) - { - MOUSE_Init(); - } - else - { - MOUSE_Deinit(); - } -#endif -} diff --git a/genplus-gx/gx/gui/menu.h b/genplus-gx/gx/gui/menu.h deleted file mode 100644 index e10c2255a3..0000000000 --- a/genplus-gx/gx/gui/menu.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** - * menu.c - * - * Genesis Plus GX menus - * - * Copyright Eke-Eke (2009-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _MENU_H -#define _MENU_H - -extern void mainmenu(void); -extern void (*reload)(void); - -#endif diff --git a/genplus-gx/gx/gui/saveicon.h b/genplus-gx/gx/gui/saveicon.h deleted file mode 100644 index a0ae7547da..0000000000 --- a/genplus-gx/gx/gui/saveicon.h +++ /dev/null @@ -1,136 +0,0 @@ -/*********************************************************** - * Genesis Plus Save Icon - * Made by Brakken (http://www.tehskeen.com) - * - ************************************************************/ -unsigned short icon[1024] = { - - 0xFFFF, 0xFFFF, 0xFBDE, 0xFBDE, 0xFBDE, 0xFBDE, 0xFBDE, 0xEB5A, - 0xFBDE, 0xFBDE, 0xFBDE, 0xBDCD, 0xFBDE, 0xF7BD, 0xF7BD, 0xAD49, - 0xEB59, 0xB9AD, 0xC1EF, 0xC1EF, 0x9062, 0x8000, 0x8C41, 0x8C41, - 0x8000, 0x9CE6, 0xA0E6, 0xA507, 0x8400, 0x9CC5, 0xA0E6, 0xA0E6, - 0xC1EF, 0xC1EF, 0xC1EF, 0xC1EF, 0x8000, 0x8000, 0x8000, 0x8000, - 0x9083, 0x8C63, 0x8C63, 0x9484, 0x8C63, 0x9083, 0x9484, 0x94A4, - 0xC1EF, 0xC20F, 0xC20F, 0xBDCE, 0x8000, 0x8000, 0x8000, 0x8000, - 0x9083, 0x8821, 0x8842, 0x8842, 0x8842, 0xA107, 0xB58C, 0xAD6B, - 0xA529, 0x94A4, 0x9083, 0x94A4, 0x8000, 0x8000, 0x8400, 0x8400, - 0x8842, 0x8842, 0x8842, 0x8821, 0xB18B, 0xA949, 0xA108, 0xA107, - 0xA528, 0xB9AD, 0xC630, 0xCE51, 0x8000, 0x8000, 0x8000, 0x8000, - 0x8821, 0x8821, 0x8821, 0x8400, 0xA108, 0xA529, 0xA108, 0xA529, - 0xCA30, 0xC630, 0xCA30, 0xFBDE, 0x8000, 0x8000, 0x8000, 0xAD27, - 0x8400, 0x9083, 0x8863, 0x8400, 0x9CE6, 0x8842, 0x8C63, 0x8C20, - 0xFBDE, 0xFBDE, 0xFFFF, 0xFFFF, 0xFBDE, 0xFBDE, 0xFBDE, 0xFBDE, - 0xDA92, 0xFBDE, 0xFBDE, 0xFBDE, 0xC1AB, 0xF7BD, 0xFBDE, 0xFBDE, - 0xF7BD, 0xF7BD, 0xF7BD, 0xA0E6, 0xF7BD, 0xF7BD, 0xF39C, 0x9484, - 0xF39C, 0xF39C, 0xDEF7, 0x8C41, 0xF39C, 0xEF7B, 0xD272, 0x8400, - 0x8C42, 0x9CE6, 0xA507, 0xA0E6, 0x8C63, 0x9CC5, 0xA107, 0x9CE6, - 0x9484, 0x98A5, 0x9CE6, 0x98C5, 0x9CC5, 0x98C5, 0xA0E7, 0x98C5, - 0x8C42, 0x9083, 0x94A5, 0x9083, 0x8C42, 0x9083, 0x9084, 0x8C62, - 0x8C62, 0x9083, 0x9084, 0x8C62, 0x8C63, 0x9083, 0x94A4, 0x8C63, - 0x8842, 0x9CC6, 0xA107, 0xA0E7, 0x8842, 0x8842, 0xA108, 0xA54A, - 0x8842, 0x8C63, 0xB5AD, 0xB5AD, 0x8C63, 0x8C62, 0x8842, 0x8C63, - 0x98C5, 0xA528, 0xB5AC, 0xB5AC, 0xA52A, 0xBDEF, 0xC631, 0xCA52, - 0xB9CE, 0xB9CE, 0xA94A, 0xAD6B, 0x8C63, 0x8821, 0x8821, 0x8821, - 0xA529, 0x98C5, 0x98C5, 0xA0E6, 0xC210, 0xA529, 0xA529, 0xA529, - 0xB5AD, 0xB5CD, 0xB5AD, 0xBDEF, 0x8400, 0x8821, 0x8C62, 0x8821, - 0xA0E7, 0x8842, 0x8842, 0x8C41, 0x9083, 0x8842, 0x8842, 0x8842, - 0x94A5, 0x8842, 0x8C62, 0x8C62, 0x8C42, 0x9083, 0x8C62, 0x8C62, - 0xB548, 0xF7BD, 0xF7BD, 0xF7BD, 0xA4C4, 0xF7BD, 0xF7BD, 0xF7BD, - 0x9461, 0xDED5, 0xF39C, 0xF39C, 0x8C20, 0xD271, 0xF39C, 0xF39C, - 0xEF7B, 0xEF7B, 0xC610, 0x8400, 0xEF7B, 0xEB5A, 0xB9AC, 0x8000, - 0xEB5A, 0xEB5A, 0xA528, 0x9CC5, 0xE739, 0xE739, 0x9CC6, 0x98A5, - 0x98C5, 0x98C5, 0xA0E6, 0x94A4, 0x94A4, 0x98C5, 0x94A5, 0x9484, - 0xA528, 0x98C5, 0x9CE6, 0xA0E7, 0x9CE6, 0xA4E6, 0x98A4, 0xA507, - 0x8C62, 0x9083, 0x9484, 0x9083, 0x94A4, 0x94A5, 0x98C5, 0x98C5, - 0xA107, 0xA107, 0xA107, 0xB18B, 0xA907, 0x9062, 0x9484, 0x9CE6, - 0x8842, 0x94A4, 0x9484, 0x9084, 0x8C62, 0x8C63, 0x9CC5, 0x9CC5, - 0x98C6, 0x8C63, 0x9484, 0xA0E6, 0x9CE6, 0x9084, 0x94A4, 0x90A5, - 0x8C63, 0x8C42, 0x8C62, 0x8C62, 0x8C63, 0xA108, 0xA94A, 0xA528, - 0x94A5, 0x8884, 0x8884, 0x8884, 0xB0A5, 0xBC84, 0xA483, 0xA484, - 0x8C63, 0x8C42, 0x8C63, 0x9083, 0xA94A, 0x9083, 0x8C62, 0x94A4, - 0x8884, 0x8063, 0x90A5, 0x94A4, 0xA483, 0xBC63, 0xA884, 0x8884, - 0x9083, 0x8C63, 0x8C42, 0x8C63, 0x9084, 0x8842, 0x9083, 0x9084, - 0x8C42, 0x8C62, 0x98C6, 0xAD6A, 0x9083, 0x8C63, 0x98C5, 0xA107, - 0x8400, 0xC1ED, 0xEF7B, 0xEF7B, 0x8400, 0xAD27, 0xEF7B, 0xEF7B, - 0x9CE6, 0x9CA4, 0xEB5A, 0xEB5A, 0x9CE6, 0x9062, 0xDAB4, 0xE739, - 0xE739, 0xE318, 0x9483, 0x8C63, 0xE318, 0xCE72, 0x9062, 0x9CC5, - 0xDEF7, 0xC20F, 0x8C41, 0x9CE6, 0xDAD6, 0xB9AC, 0x8C20, 0x9CC5, - 0xA0E6, 0xA528, 0x9CC5, 0xA528, 0xA508, 0x94A5, 0x98C6, 0xA108, - 0x9CE6, 0x9CC5, 0xA0E7, 0xA94A, 0xA0E6, 0xA0E7, 0xA507, 0xAD6B, - 0xA107, 0x98C6, 0x9CE6, 0x9083, 0x98C6, 0xA108, 0xA107, 0x98C5, - 0xB9CD, 0xB18B, 0xA107, 0x9CC6, 0xC210, 0xB9CE, 0xA528, 0x9CC6, - 0x98C5, 0x94A5, 0x9084, 0x8884, 0x9CC6, 0x9CE6, 0x9CC6, 0x94A5, - 0x9CE6, 0x9CE6, 0x9CE7, 0xA108, 0x98C5, 0x98C5, 0x98C6, 0x98C6, - 0xB0C6, 0xD0C6, 0xD0C6, 0xD0C6, 0x90A4, 0x90A4, 0x98A5, 0x9CA4, - 0x9CE6, 0x90A4, 0x9084, 0x9084, 0x98C6, 0x98C6, 0x98C6, 0x98C6, - 0xD0A5, 0xD0A5, 0xA484, 0x8483, 0x9484, 0x9083, 0x8C83, 0x9084, - 0x90A5, 0x94A5, 0x9CE6, 0x9CE6, 0x98C6, 0x98C6, 0x9CE6, 0x98C6, - 0x8C63, 0x9084, 0x9484, 0x9083, 0x98C5, 0x98C5, 0x94A4, 0x94A5, - 0x98C6, 0x98C6, 0x98C5, 0x98C5, 0x98C6, 0x98C6, 0x98C6, 0x98C6, - 0x9084, 0x8821, 0xCE51, 0xE739, 0x94A5, 0x8C20, 0xBDCE, 0xE318, - 0x98C5, 0x8821, 0xB18B, 0xE318, 0x98C6, 0x8842, 0xAD49, 0xDEF7, - 0xDAD6, 0xAD49, 0x8C41, 0xA508, 0xD6B5, 0xBDCC, 0x8C20, 0x8C41, - 0xD6B5, 0xD294, 0xB98A, 0xAD06, 0xD294, 0xCE73, 0xCE73, 0xCA52, - 0xA94A, 0xB5AD, 0xB18C, 0xAD6B, 0x9062, 0x9062, 0x9062, 0x9062, - 0xAD27, 0xAD06, 0xAD06, 0xAD06, 0xCA52, 0xC631, 0xC631, 0xC210, - 0xA94B, 0xB18C, 0xB58D, 0xAD6B, 0x9062, 0x9484, 0x98A4, 0x98A4, - 0xA906, 0xA906, 0xA506, 0xA907, 0xC210, 0xC210, 0xB9F0, 0xBDEF, - 0xA94B, 0xA94B, 0xA94B, 0xA94B, 0x98A5, 0x98A5, 0x98A4, 0x98A4, - 0xA907, 0xA907, 0xA907, 0xA506, 0xBDEF, 0xBDEF, 0xBDEF, 0xB1F2, - 0xA94B, 0xA94A, 0xA54A, 0xA529, 0x9484, 0x9484, 0x9483, 0x9483, - 0xA4E6, 0xA4E6, 0xA4E6, 0xA4E6, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, - 0xA529, 0xA529, 0xA529, 0xA108, 0x9062, 0x8C63, 0x9062, 0x9062, - 0xA4E6, 0x9CE6, 0xA0E6, 0xA506, 0xBDEF, 0xC210, 0xC210, 0xC210, - 0xA108, 0x9CE7, 0x9CE7, 0x98C6, 0x8C41, 0x8C42, 0x8C41, 0x8C41, - 0xA507, 0xA508, 0xAD27, 0xB127, 0xC631, 0xC631, 0xCA52, 0xCA52, - 0x98C6, 0x8C63, 0xA0E6, 0xDAD6, 0x8C41, 0x8400, 0xB548, 0xDAD6, - 0xB127, 0xB548, 0xD6B5, 0xD6B5, 0xCE73, 0xCE73, 0xD294, 0xD6B5, - 0xD294, 0xCA74, 0xBA56, 0xB635, 0x9A3B, 0x81FF, 0x81FF, 0x81FF, - 0x81FF, 0x8A1F, 0xA27F, 0xA27F, 0x81FF, 0xA27F, 0xFFFF, 0xFFFF, - 0xB635, 0xB214, 0xB214, 0xBE11, 0x81FF, 0x81FF, 0x81FF, 0x81FF, - 0xA27F, 0xA27F, 0xA27F, 0x8A1F, 0xFFFF, 0xFFFF, 0xFFFF, 0xDF7F, - 0xA1F7, 0x91FA, 0x81FF, 0x95F9, 0x81FF, 0x81FF, 0x8A1F, 0x81FF, - 0x81FF, 0xD75F, 0xBEFF, 0x81FF, 0x81FF, 0xFFFF, 0xBEFF, 0x81FF, - 0xB9CE, 0xB9CE, 0x8DFC, 0x81FF, 0xA9D2, 0xA9D2, 0x81FF, 0x9A5F, - 0x99D6, 0x99D6, 0x81FF, 0xBEFF, 0x99D6, 0x99D6, 0x81FF, 0xBEFF, - 0x85FD, 0x95F9, 0xB5CF, 0xB1F1, 0x81FF, 0x81FF, 0x95F9, 0x81FF, - 0xEFBF, 0x81FF, 0x85FD, 0x81FF, 0xFFFF, 0x81FF, 0x81FF, 0x81FF, - 0xA5F5, 0xA5F5, 0xB5F2, 0xB214, 0x81FF, 0x81FF, 0x81FF, 0x81FF, - 0xB2BF, 0xB2BF, 0x81FF, 0x9A5F, 0xDF7F, 0xDF7F, 0x81FF, 0xE79F, - 0xA218, 0xA218, 0xA218, 0xA639, 0x81FF, 0x81FF, 0x81FF, 0x81FF, - 0xBEFF, 0xBEFF, 0xBEFF, 0xBEFF, 0xF7DF, 0xDF7F, 0xDF7F, 0xDF7F, - 0xA639, 0xB657, 0xCA75, 0xD294, 0x81FF, 0x81FF, 0x861E, 0xCA95, - 0xBEFF, 0xAA9F, 0x81FF, 0xB658, 0xD75F, 0x8A1F, 0x81FF, 0xCA75, - 0x81FF, 0xA27F, 0xFFFF, 0xA27F, 0x81FF, 0xA27F, 0xFFFF, 0xFFFF, - 0x81FF, 0xA27F, 0xFFFF, 0xBADF, 0x81FF, 0xA27F, 0xFFFF, 0xA27F, - 0x81FF, 0x81FF, 0xCF3F, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xBADF, - 0xA27F, 0xA27F, 0xA27F, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x81FF, - 0x923F, 0xFFFF, 0xBEFF, 0x81FF, 0x81FF, 0xFFFF, 0xBEFF, 0x81FF, - 0x81FF, 0xFFFF, 0xCF3F, 0xA27F, 0x81FF, 0xFFFF, 0xFFFF, 0xFFFF, - 0x99D6, 0x99D6, 0x81FF, 0xBEFF, 0x81FF, 0x81FF, 0x81FF, 0xBEFF, - 0xA27F, 0xA27F, 0x9A5F, 0xBADF, 0xFFFF, 0xFFFF, 0xA27F, 0x81FF, - 0xFFFF, 0x81FF, 0x81FF, 0x81FF, 0xFFFF, 0x81FF, 0x81FF, 0x81FF, - 0xFFFF, 0xBEFF, 0xBEFF, 0xBEFF, 0xC71F, 0xDF7F, 0xDF7F, 0xDF7F, - 0xDF7F, 0xDF7F, 0x923F, 0xF7DF, 0xDF7F, 0xDF7F, 0x81FF, 0xAA9F, - 0xEFBF, 0xC71F, 0x81FF, 0x9A5F, 0xCF3F, 0x81FF, 0x8A1F, 0xD75F, - 0xE79F, 0xBEFF, 0xBEFF, 0xBEFF, 0xDF7F, 0xDF7F, 0xDF7F, 0xDF7F, - 0xBEFF, 0xBEFF, 0xBEFF, 0xC71F, 0xDF7F, 0xDF7F, 0xDF7F, 0xDF7F, - 0xBEFF, 0x81FF, 0x81FF, 0xB657, 0xFFFF, 0xC71F, 0x81FF, 0xA23A, - 0xFFFF, 0xC71F, 0x81FF, 0xA23A, 0xD75F, 0x8A1F, 0x81FF, 0xB658, - 0x81FF, 0x9A5F, 0xAA9F, 0x81FF, 0x921D, 0x81FF, 0x81FF, 0x85FE, - 0xD294, 0xBE55, 0xB657, 0xC653, 0xD294, 0xD294, 0xCE73, 0xCA52, - 0x8A1D, 0xB214, 0xB214, 0x8DFC, 0xBA34, 0xC631, 0xC210, 0xB612, - 0xC631, 0xC631, 0xC631, 0xC210, 0xCA52, 0xCA52, 0xC631, 0xC631, - 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x8DFC, 0x81FF, 0x81FF, 0x81FF, - 0xC210, 0xBE10, 0xBDEF, 0xBDEF, 0xC210, 0xC210, 0xC210, 0xBE10, - 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x8DFB, 0xA5D4, - 0xBDEF, 0xB9CE, 0xB9CE, 0xB9CE, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, - 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x99F8, 0x8DFB, 0x8DFB, 0x8DFB, - 0xB9CE, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, 0xBDEF, 0xBE10, 0xC210, - 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x95F9, 0xA5F5, 0xA1F7, 0x91FA, - 0xBDEF, 0xBE10, 0xC210, 0xC210, 0xC210, 0xC210, 0xC631, 0xC631, - 0x81FF, 0x81FF, 0x81FF, 0x81FF, 0x921C, 0x921C, 0x921C, 0x921C, - 0xC631, 0xC631, 0xCA52, 0xCA52, 0xC631, 0xCA52, 0xCA52, 0xCE73, - 0x81FF, 0x81FF, 0x9A3B, 0xD294, 0x961B, 0xAA39, 0xD294, 0xD294, - 0xCE73, 0xCE73, 0xD294, 0xD6B5, 0xCE73, 0xD294, 0xD6B5, 0xD6B5, -}; diff --git a/genplus-gx/gx/gx_audio.c b/genplus-gx/gx/gx_audio.c deleted file mode 100644 index b237c0e8d7..0000000000 --- a/genplus-gx/gx/gx_audio.c +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** - * gx_audio.c - * - * Genesis Plus GX audio support - * - * Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" - -/* Length is dimensionned for at least one frame of emulation */ -#define SOUND_BUFFER_LEN 4096 - -/* Number of sound buffers */ -#define SOUND_BUFFER_NUM 3 - -/* audio DMA status */ -u32 audioStarted; - -/* DMA soundbuffers (required to be 32-bytes aligned) */ -static u8 soundbuffer[SOUND_BUFFER_NUM][SOUND_BUFFER_LEN] ATTRIBUTE_ALIGN(32); - -/* Current work soundbuffer */ -static u8 mixbuffer; - -/* Background music */ -static u8 *Bg_music_ogg = NULL; -static u32 Bg_music_ogg_size = 0; - -/* Frame Sync */ -u32 audioSync; -static u32 audioWait; - -/***************************************************************************************/ -/* Audio engine */ -/***************************************************************************************/ - -/* Audio DMA callback */ -static void ai_callback(void) -{ - audioWait = 0; -} - -/* AUDIO engine initialization */ -void gx_audio_Init(void) -{ - /* Initialize AUDIO processing library (ASNDLIB) */ - /* AUDIO & DSP hardware are initialized */ - /* Default samplerate is set to 48kHz */ - ASND_Init(); - - /* Load background music from FAT device */ - char fname[MAXPATHLEN]; - sprintf(fname,"%s/Bg_music.ogg",DEFAULT_PATH); - FILE *f = fopen(fname,"rb"); - if (f) - { - struct stat filestat; - stat(fname, &filestat); - Bg_music_ogg_size = filestat.st_size; - Bg_music_ogg = memalign(32,Bg_music_ogg_size); - if (Bg_music_ogg) - { - fread(Bg_music_ogg,1,Bg_music_ogg_size,f); - } - fclose(f); - } - - /* emulation is synchronized with audio hardware by default */ - audioSync = 1; -} - -/* AUDIO engine shutdown */ -void gx_audio_Shutdown(void) -{ - PauseOgg(1); - StopOgg(); - ASND_Pause(1); - ASND_End(); - if (Bg_music_ogg) - { - free(Bg_music_ogg); - } -} - -/*** - gx_audio_Update - - This function retrieves samples for the frame then set the next DMA parameters - Parameters will be taken in account only when current DMA operation is over - ***/ -int gx_audio_Update(void) -{ - if (!audioWait) - { - /* Current available soundbuffer */ - s16 *sb = (s16 *)(soundbuffer[mixbuffer]); - - /* Retrieve audio samples (size must be multiple of 32 bytes) */ - int size = audio_update(sb) * 4; - - /* Update DMA settings */ - DCFlushRange((void *)sb, size); - AUDIO_InitDMA((u32) sb, size); - mixbuffer = (mixbuffer + 1) % SOUND_BUFFER_NUM; - audioWait = audioSync; - - /* Start Audio DMA */ - /* this is called once to kick-off DMA from external memory to audio interface */ - /* DMA operation is automatically restarted when all samples have been sent. */ - /* If DMA settings are not updated at that time, previous sound buffer will be used. */ - /* Therefore we need to make sure frame emulation is completed before current DMA is */ - /* completed, by synchronizing frame emulation with DMA start and also by syncing it */ - /* with Video Interrupt and outputing a suitable number of samples per frame. */ - if (!audioStarted) - { - /* restart audio DMA */ - AUDIO_StopDMA(); - AUDIO_StartDMA(); - audioStarted = 1; - } - - return SYNC_AUDIO; - } - - return SYNC_WAIT; -} - -/*** - gx_audio_Start - - This function restart the audio engine - This is called when coming back from Main Menu - ***/ -void gx_audio_Start(void) -{ - /* shutdown background music */ - PauseOgg(1); - StopOgg(); - - /* shutdown menu audio processing */ - ASND_Pause(1); - ASND_End(); - AUDIO_StopDMA(); - AUDIO_RegisterDMACallback(NULL); - DSP_Halt(); - - /* DMA Interrupt callback */ - AUDIO_RegisterDMACallback(ai_callback); - - /* reset emulation audio processing */ - memset(soundbuffer, 0, sizeof(soundbuffer)); - audioStarted = 0; - mixbuffer = 0; - audioWait = 0; -} - -/*** - gx_audio_Stop - - This function stops current Audio DMA process - This is called when going back to Main Menu - DMA need to be restarted when going back to the game (see above) - ***/ -void gx_audio_Stop(void) -{ - /* restart menu audio processing */ - DSP_Unhalt(); - ASND_Init(); - ASND_Pause(0); - - /* play background music */ - if (Bg_music_ogg && !Shutdown) - { - PauseOgg(0); - PlayOgg((char *)Bg_music_ogg, Bg_music_ogg_size, 0, OGG_INFINITE_TIME); - SetVolumeOgg(((int)config.bgm_volume * 255) / 100); - } -} diff --git a/genplus-gx/gx/gx_audio.h b/genplus-gx/gx/gx_audio.h deleted file mode 100644 index 174a3ca45b..0000000000 --- a/genplus-gx/gx/gx_audio.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** - * gx_audio.c - * - * Genesis Plus GX audio support - * - * Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _GC_AUDIO_H_ -#define _GC_AUDIO_H_ - -extern u32 audioStarted; -extern u32 audioSync; - -extern void gx_audio_Init(void); -extern void gx_audio_Shutdown(void); -extern void gx_audio_Start(void); -extern void gx_audio_Stop(void); -extern int gx_audio_Update(void); - -#endif diff --git a/genplus-gx/gx/gx_input.c b/genplus-gx/gx/gx_input.c deleted file mode 100644 index b175cb2500..0000000000 --- a/genplus-gx/gx/gx_input.c +++ /dev/null @@ -1,1641 +0,0 @@ -/**************************************************************************** - * gx_input.c - * - * Genesis Plus GX input support - * - * Copyright Eke-Eke (2007-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "font.h" -#include "gui.h" -#include "cheats.h" - -#ifdef HW_RVL -#include -#endif - -/* Analog sticks sensitivity */ -#define ANALOG_SENSITIVITY 30 - -/* Delay before held keys triggering */ -/* higher is the value, less responsive is the key update */ -#define HELD_DELAY 30 - -/* Direction & selection update speed when a key is being held */ -/* lower is the value, faster is the key update */ -#define HELD_SPEED 4 - - -/* Configurable keys */ -#define KEY_BUTTONA 0 -#define KEY_BUTTONB 1 -#define KEY_BUTTONC 2 -#define KEY_START 3 -#define KEY_BUTTONX 4 -#define KEY_BUTTONY 5 -#define KEY_BUTTONZ 6 -#define KEY_MODE 7 -#define KEY_MENU 8 - -#ifdef HW_RVL - -#define PAD_UP 0 -#define PAD_DOWN 1 -#define PAD_LEFT 2 -#define PAD_RIGHT 3 - -/* default directions mapping */ -static u32 wpad_dirmap[3][4] = -{ - {WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, /* WIIMOTE */ - {WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, /* WIIMOTE + NUNCHUK */ - {WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN, WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT} /* CLASSIC */ -}; - -#define WPAD_BUTTONS_HELD (WPAD_BUTTON_UP | WPAD_BUTTON_DOWN | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT | \ - WPAD_BUTTON_MINUS | WPAD_BUTTON_PLUS | WPAD_BUTTON_A | WPAD_BUTTON_2 | \ - WPAD_CLASSIC_BUTTON_UP | WPAD_CLASSIC_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_RIGHT | \ - WPAD_CLASSIC_BUTTON_FULL_L | WPAD_CLASSIC_BUTTON_FULL_R | WPAD_CLASSIC_BUTTON_A) - -#endif - -#define PAD_BUTTONS_HELD (PAD_BUTTON_UP | PAD_BUTTON_DOWN | PAD_BUTTON_LEFT | PAD_BUTTON_RIGHT | \ - PAD_TRIGGER_L | PAD_TRIGGER_R | PAD_BUTTON_A) - -static char keyname[MAX_KEYS][16]; - -static int held_cnt = 0; -static int inputs_disabled = 0; - -/***************************************************************************************/ -/* Gamecube PAD support */ -/***************************************************************************************/ -static void pad_config(int chan, int first_key, int last_key) -{ - u16 p = 0; - char msg[64]; - - /* disable background PAD scanning */ - inputs_disabled = 1; - - /* Check if PAD is connected */ - VIDEO_WaitVSync(); - if (!(PAD_ScanPads() & (1< ANALOG_SENSITIVITY) - { - ConfigRequested = 1; - return; - } - - /* D-PAD */ - if ((p & PAD_BUTTON_UP) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; - else if ((p & PAD_BUTTON_DOWN) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; - if ((p & PAD_BUTTON_LEFT) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; - else if ((p & PAD_BUTTON_RIGHT) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; - - /* Buttons */ - if (p & pad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_A; - if (p & pad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_B; - if (p & pad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_C; - if (p & pad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_XE_A1P: - { - /* Left Stick analog position [0-255] */ - input.analog[i][0] = (x + 128); - input.analog[i][1] = y ? (127 - y) : (128 - y); - - /* Right Stick analog position [0-255] */ - x = PAD_SubStickX(chan); - y = PAD_SubStickY(chan); - - /* Emulated stick is unidirectional but can be rotated */ - if (abs(x) > abs(y)) - { - input.analog[i+1][0] = (x + 128); - } - else - { - input.analog[i+1][0] = (y + 128); - } - - /* Buttons */ - if (p & pad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_XE_A; - if (p & pad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_XE_B; - if (p & pad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_XE_C; - if (p & pad_keymap[KEY_START]) input.pad[i] |= INPUT_XE_START; - if (p & pad_keymap[KEY_BUTTONX]) input.pad[i] |= INPUT_XE_D; - if (p & pad_keymap[KEY_BUTTONY]) input.pad[i] |= INPUT_XE_E1; - if (p & pad_keymap[KEY_BUTTONZ]) input.pad[i] |= INPUT_XE_E2; - if (p & pad_keymap[KEY_MODE]) input.pad[i] |= INPUT_XE_SELECT; - - break; - } - - case DEVICE_SPORTSPAD: - { - /* Y analog position [0-255] */ - input.analog[i][1] = y ? (127 - y) : (128 - y); - - /* default inputs are checked below */ - } - - case DEVICE_PADDLE: - { - /* Default menu key (right analog stick) */ - if (PAD_SubStickX(chan) > ANALOG_SENSITIVITY) - { - ConfigRequested = 1; - return; - } - - /* X analog position [0-255] */ - input.analog[i][0] = (x + 128); - - /* Buttons */ - if (p & pad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_BUTTON1; - if (p & pad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_BUTTON2; - if (p & pad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_PAD2B: - { - /* Default menu key (right analog stick) */ - if (PAD_SubStickX(chan) > ANALOG_SENSITIVITY) - { - ConfigRequested = 1; - return; - } - - /* D-PAD */ - if ((p & PAD_BUTTON_UP) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; - else if ((p & PAD_BUTTON_DOWN) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; - if ((p & PAD_BUTTON_LEFT) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; - else if ((p & PAD_BUTTON_RIGHT) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; - - /* Buttons */ - if (p & pad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_BUTTON1; - if (p & pad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_BUTTON2; - if (p & pad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_LIGHTGUN: - { - /* Default menu key (right analog stick) */ - if (PAD_SubStickX(chan) > ANALOG_SENSITIVITY) - { - ConfigRequested = 1; - return; - } - - /* Gun screen position (x,y) */ - input.analog[i][0] += x / ANALOG_SENSITIVITY; - input.analog[i][1] -= y / ANALOG_SENSITIVITY; - - /* Limits */ - if (input.analog[i][0] < 0) input.analog[i][0] = 0; - else if (input.analog[i][0] > bitmap.viewport.w) input.analog[i][0] = bitmap.viewport.w; - if (input.analog[i][1] < 0) input.analog[i][1] = 0; - else if (input.analog[i][1] > bitmap.viewport.h) input.analog[i][1] = bitmap.viewport.h; - - /* Buttons */ - if (p & pad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_A; - if (p & pad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_B; - if (p & pad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_C; - if (p & pad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_MOUSE: - { - /* Default menu key (right analog stick) */ - if (PAD_SubStickX(chan) > ANALOG_SENSITIVITY) - { - ConfigRequested = 1; - return; - } - - /* Mouse relative movement (-255,255) */ - input.analog[i][0] = (x / ANALOG_SENSITIVITY) * 2; - input.analog[i][1] = (y / ANALOG_SENSITIVITY) * 2; - - /* Y-Axis inversion */ - if (config.invert_mouse) - { - input.analog[i][1] = -input.analog[i][1]; - } - - /* Buttons */ - if (p & pad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_MOUSE_CENTER; - if (p & pad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_MOUSE_LEFT; - if (p & pad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_MOUSE_RIGHT; - if (p & pad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_PICO: - { - /* Default menu key (right analog stick) */ - if (PAD_SubStickX(chan) > ANALOG_SENSITIVITY) - { - ConfigRequested = 1; - return; - } - - /* D-PAD */ - if (p & PAD_BUTTON_UP) input.pad[0] |= INPUT_UP; - else if (p & PAD_BUTTON_DOWN) input.pad[0] |= INPUT_DOWN; - if (p & PAD_BUTTON_LEFT) input.pad[0] |= INPUT_LEFT; - else if (p & PAD_BUTTON_RIGHT) input.pad[0] |= INPUT_RIGHT; - - /* PEN screen position (x,y) */ - input.analog[0][0] += x / ANALOG_SENSITIVITY; - input.analog[0][1] -= y / ANALOG_SENSITIVITY; - - /* Limits */ - if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c; - else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c; - if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc; - else if (input.analog[0][1] > 0x3f3) input.analog[0][1] = 0x3f3; - - /* PEN button */ - if (p & pad_keymap[KEY_BUTTONA]) input.pad[0] |= INPUT_PICO_RED; - - /* RED button */ - if (p & pad_keymap[KEY_BUTTONB]) input.pad[0] |= INPUT_PICO_PEN; - - /* PAGE index increment */ - if (p & pad_keymap[KEY_BUTTONC]) pico_current = (pico_current + 1) & 7; - - break; - } - - case DEVICE_TEREBI: - { - /* Default menu key (right analog stick) */ - if (PAD_SubStickX(chan) > ANALOG_SENSITIVITY) - { - ConfigRequested = 1; - return; - } - - /* PEN screen position (x,y) */ - input.analog[0][0] += x / ANALOG_SENSITIVITY; - input.analog[0][1] -= y / ANALOG_SENSITIVITY; - - /* Limits */ - if (input.analog[0][0] < 0) input.analog[0][0] = 0; - else if (input.analog[0][0] > 250) input.analog[0][0] = 250; - if (input.analog[0][1] < 0) input.analog[0][1] = 0; - else if (input.analog[0][1] > 250) input.analog[0][1] = 250; - - /* PEN button */ - if (p & pad_keymap[KEY_BUTTONA]) input.pad[0] |= INPUT_BUTTON1; - - break; - } - - case DEVICE_ACTIVATOR: - { - /* Left & right analog stick angle [0-360] */ - float ang; - - /* Left stick values */ - if ((abs(x) > ANALOG_SENSITIVITY) || (abs(y) > ANALOG_SENSITIVITY)) - { - /* Calculate angle (in degree) */ - ang = 90.0 - (atan((float)y / (float)x) * 180.0 / M_PI); - if (x < 0) ang += 180.0; - - /* 8 bottom sensors = 8 areas */ - if ((ang > 22.5) && (ang <= 67.5)) input.pad[i] |= INPUT_ACTIVATOR_2L; - else if ((ang > 67.5) && (ang <= 112.5)) input.pad[i] |= INPUT_ACTIVATOR_3L; - else if ((ang > 112.5) && (ang <= 157.5)) input.pad[i] |= INPUT_ACTIVATOR_4L; - else if ((ang > 157.5) && (ang <= 202.5)) input.pad[i] |= INPUT_ACTIVATOR_5L; - else if ((ang > 202.5) && (ang <= 247.5)) input.pad[i] |= INPUT_ACTIVATOR_6L; - else if ((ang > 247.5) && (ang <= 292.5)) input.pad[i] |= INPUT_ACTIVATOR_7L; - else if ((ang > 292.5) && (ang <= 337.5)) input.pad[i] |= INPUT_ACTIVATOR_8L; - else input.pad[i] |= INPUT_ACTIVATOR_1L; - } - - /* Right stick values */ - x = PAD_SubStickX(chan); - y = PAD_SubStickY(chan); - - if ((abs(x) > ANALOG_SENSITIVITY) || (abs(y) > ANALOG_SENSITIVITY)) - { - /* Calculate angle (in degree) */ - ang = 90.0 - (atan((float)y / (float)x) * 180.0 / M_PI); - if (x < 0) ang += 180.0; - - /* 8 top sensors = 8 areas */ - if ((ang > 22.5) && (ang <= 67.5)) input.pad[i] |= INPUT_ACTIVATOR_2U; - else if ((ang > 67.5) && (ang <= 112.5)) input.pad[i] |= INPUT_ACTIVATOR_3U; - else if ((ang > 112.5) && (ang <= 157.5)) input.pad[i] |= INPUT_ACTIVATOR_4U; - else if ((ang > 157.5) && (ang <= 202.5)) input.pad[i] |= INPUT_ACTIVATOR_5U; - else if ((ang > 202.5) && (ang <= 247.5)) input.pad[i] |= INPUT_ACTIVATOR_6U; - else if ((ang > 247.5) && (ang <= 292.5)) input.pad[i] |= INPUT_ACTIVATOR_7U; - else if ((ang > 292.5) && (ang <= 337.5)) input.pad[i] |= INPUT_ACTIVATOR_8U; - else input.pad[i] |= INPUT_ACTIVATOR_1U; - } - - break; - } - } -} - -/***************************************************************************************/ -/* Wii WPAD support */ -/***************************************************************************************/ -#ifdef HW_RVL - -static int wpad_StickX(WPADData *data, u8 right) -{ - struct joystick_t* js = NULL; - - switch (data->exp.type) - { - case WPAD_EXP_NUNCHUK: - js = right ? NULL : &data->exp.nunchuk.js; - break; - - case WPAD_EXP_CLASSIC: - js = right ? &data->exp.classic.rjs : &data->exp.classic.ljs; - break; - - default: - break; - } - - if (js) - { - /* raw X value */ - int x = js->pos.x; - - /* value returned is sometime above calibrated limits */ - if (x > js->max.x) return 127; - if (x < js->min.x) return -128; - - /* adjust against center position */ - x -= js->center.x; - - /* return interpolated range [-128;127] */ - if (x > 0) - { - return (int)(127.0 * ((float)x / (float)(js->max.x - js->center.x))); - } - { - return (int)(128.0 * ((float)x / (float)(js->center.x - js->min.x))); - } - } - - return 0; -} - -static int wpad_StickY(WPADData *data, u8 right) -{ - struct joystick_t* js = NULL; - - switch (data->exp.type) - { - case WPAD_EXP_NUNCHUK: - js = right ? NULL : &data->exp.nunchuk.js; - break; - - case WPAD_EXP_CLASSIC: - js = right ? &data->exp.classic.rjs : &data->exp.classic.ljs; - break; - - default: - break; - } - - if (js) - { - /* raw Y value */ - int y = js->pos.y; - - /* value returned is sometime above calibrated limits */ - if (y > js->max.y) return 127; - if (y < js->min.y) return -128; - - /* adjust against center position */ - y -= js->center.y; - - /* return interpolated range [-128;127] */ - if (y > 0) - { - return (int)(127.0 * ((float)y / (float)(js->max.y - js->center.y))); - } - { - return (int)(128.0 * ((float)y / (float)(js->center.y - js->min.y))); - } - } - - return 0; -} - -static void wpad_config(u8 exp, int chan, int first_key, int last_key) -{ - char msg[64]; - u32 p = 255; - - /* Disable background PAD scanning */ - inputs_disabled = 1; - - /* Check if device is connected */ - WPAD_Probe(chan, &p); - if (((exp > WPAD_EXP_NONE) && (p != exp)) || (p == 255)) - { - /* device not detected */ - if (exp == WPAD_EXP_NONE) sprintf(msg, "WIIMOTE #%d is not connected !", chan+1); - if (exp == WPAD_EXP_NUNCHUK) sprintf(msg, "NUNCHUK #%d is not connected !", chan+1); - if (exp == WPAD_EXP_CLASSIC) sprintf(msg, "CLASSIC #%d is not connected !", chan+1); - GUI_WaitPrompt("Error",msg); - - /* re-enable background PAD scanning and exit */ - inputs_disabled = 0; - return; - } - - /* Configure each keys */ - do - { - /* ignore unused keys */ - if (strcmp(keyname[first_key], "N.A")) - { - /* remove any pending buttons */ - while (WPAD_ButtonsHeld(chan)) - { - VIDEO_WaitVSync(); - WPAD_ScanPads(); - } - - /* configurable button */ - sprintf(msg,"Press key for %s\n(HOME to return)",keyname[first_key]); - GUI_MsgBoxUpdate(0,msg); - - /* wait for user input */ - p = 0; - while (!p) - { - VIDEO_WaitVSync(); - WPAD_ScanPads(); - p = WPAD_ButtonsDown(chan); - } - - /* detect pressed key */ - switch (exp) - { - /* Wiimote (TODO: add motion sensing !) */ - case WPAD_EXP_NONE: - { - if (p & WPAD_BUTTON_2) p = WPAD_BUTTON_2; - else if (p & WPAD_BUTTON_1) p = WPAD_BUTTON_1; - else if (p & WPAD_BUTTON_B) p = WPAD_BUTTON_B; - else if (p & WPAD_BUTTON_A) p = WPAD_BUTTON_A; - else if (p & WPAD_BUTTON_PLUS) p = WPAD_BUTTON_PLUS; - else if (p & WPAD_BUTTON_MINUS) p = WPAD_BUTTON_MINUS; - else first_key = MAX_KEYS; - break; - } - - /* Wiimote + Nunchuk (TODO: add motion sensing !) */ - case WPAD_EXP_NUNCHUK: - { - if (p & WPAD_BUTTON_2) p = WPAD_BUTTON_2; - else if (p & WPAD_BUTTON_1) p = WPAD_BUTTON_1; - else if (p & WPAD_BUTTON_B) p = WPAD_BUTTON_B; - else if (p & WPAD_BUTTON_A) p = WPAD_BUTTON_A; - else if (p & WPAD_BUTTON_PLUS) p = WPAD_BUTTON_PLUS; - else if (p & WPAD_BUTTON_MINUS) p= WPAD_BUTTON_MINUS; - else if (p & WPAD_NUNCHUK_BUTTON_Z) p = WPAD_NUNCHUK_BUTTON_Z; - else if (p & WPAD_NUNCHUK_BUTTON_C) p = WPAD_NUNCHUK_BUTTON_C; - else first_key = MAX_KEYS; - break; - } - - /* Classic Controller */ - case WPAD_EXP_CLASSIC: - { - if (p & WPAD_CLASSIC_BUTTON_X) p = WPAD_CLASSIC_BUTTON_X; - else if (p & WPAD_CLASSIC_BUTTON_A) p = WPAD_CLASSIC_BUTTON_A; - else if (p & WPAD_CLASSIC_BUTTON_Y) p = WPAD_CLASSIC_BUTTON_Y; - else if (p & WPAD_CLASSIC_BUTTON_B) p = WPAD_CLASSIC_BUTTON_B; - else if (p & WPAD_CLASSIC_BUTTON_ZL) p = WPAD_CLASSIC_BUTTON_ZL; - else if (p & WPAD_CLASSIC_BUTTON_ZR) p = WPAD_CLASSIC_BUTTON_ZR; - else if (p & WPAD_CLASSIC_BUTTON_PLUS) p = WPAD_CLASSIC_BUTTON_PLUS; - else if (p & WPAD_CLASSIC_BUTTON_MINUS) p = WPAD_CLASSIC_BUTTON_MINUS; - else if (p & WPAD_CLASSIC_BUTTON_FULL_L) p = WPAD_CLASSIC_BUTTON_FULL_L; - else if (p & WPAD_CLASSIC_BUTTON_FULL_R) p = WPAD_CLASSIC_BUTTON_FULL_R; - else first_key = MAX_KEYS; - break; - } - - default: - { - first_key = MAX_KEYS; - break; - } - } - - /* update key mapping */ - if (first_key < MAX_KEYS) - { - config.wpad_keymap[exp + (chan * 3)][first_key] = p; - } - } - } - while (first_key++ < last_key); - - /* remove any pending buttons */ - while (WPAD_ButtonsHeld(chan)) - { - VIDEO_WaitVSync(); - WPAD_ScanPads(); - } - - /* re-enable background PAD scanning and exit */ - inputs_disabled = 0; -} - -static void wpad_update(s8 chan, u8 i, u32 exp) -{ - /* WPAD data */ - WPADData *data = WPAD_Data(chan); - - /* WPAD status */ - u32 p = data->btns_h; - - /* Analog sticks */ - s8 x = 0; - s8 y = 0; - - if (exp != WPAD_EXP_NONE) - { - x = wpad_StickX(data,0); - y = wpad_StickY(data,0); - } - - /* Retrieve current key mapping */ - u32 *wpad_keymap = config.wpad_keymap[exp + (chan * 3)]; - - /* Emulated device */ - switch (input.dev[i]) - { - case DEVICE_PAD6B: - { - /* Extra buttons */ - if (p & wpad_keymap[KEY_BUTTONX]) input.pad[i] |= INPUT_X; - if (p & wpad_keymap[KEY_BUTTONY]) input.pad[i] |= INPUT_Y; - if (p & wpad_keymap[KEY_BUTTONZ]) input.pad[i] |= INPUT_Z; - if (p & wpad_keymap[KEY_MODE]) input.pad[i] |= INPUT_MODE; - } - - case DEVICE_PAD3B: - { - /* D- PAD */ - if ((p & wpad_dirmap[exp][PAD_UP]) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; - else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; - if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; - else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; - - /* Buttons */ - if (p & wpad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_A; - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_B; - if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_C; - if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_XE_A1P: - { - /* Left Stick analog position [0-255] */ - input.analog[i][0] = (x + 128); - input.analog[i][1] = y ? (127 - y) : (128 - y); - - /* Right Stick analog position [0-255] */ - if (exp == WPAD_EXP_CLASSIC) - { - /* Classic Controller right stick */ - x = wpad_StickX(data,1); - y = wpad_StickY(data,1); - - /* Emulated stick is unidirectional but can be rotated */ - if (abs(x) > abs(y)) - { - input.analog[i+1][0] = (x + 128); - } - else - { - input.analog[i+1][0] = (y + 128); - } - } - else - { - /* Wiimote D-PAD */ - if ((p & wpad_dirmap[exp][PAD_DOWN]) || (p & wpad_dirmap[exp][PAD_LEFT])) input.analog[i+1][0]-=2; - else if ((p & wpad_dirmap[exp][PAD_UP]) || (p & wpad_dirmap[exp][PAD_RIGHT])) input.analog[i+1][0]+=2; - - /* Limits */ - if (input.analog[i+1][0] < 0) input.analog[i+1][0] = 0; - else if (input.analog[i+1][0] > 255) input.analog[i+1][0] = 255; - } - - /* Buttons */ - if (p & wpad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_XE_A; - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_XE_B; - if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_XE_C; - if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_XE_START; - if (p & wpad_keymap[KEY_BUTTONX]) input.pad[i] |= INPUT_XE_D; - if (p & wpad_keymap[KEY_BUTTONY]) input.pad[i] |= INPUT_XE_E1; - if (p & wpad_keymap[KEY_BUTTONZ]) input.pad[i] |= INPUT_XE_E2; - if (p & wpad_keymap[KEY_MODE]) input.pad[i] |= INPUT_XE_SELECT; - - break; - } - - case DEVICE_SPORTSPAD: - { - /* X analog position [0-255] */ - if (p & wpad_dirmap[exp][PAD_LEFT]) input.analog[i][0]-=2; - else if (p & wpad_dirmap[exp][PAD_RIGHT]) input.analog[i][0]+=2; - else input.analog[i][0] = (x + 128); - - /* Y analog position [0-255] */ - if (p & wpad_dirmap[exp][PAD_UP]) input.analog[i][1]-=2; - else if (p & wpad_dirmap[exp][PAD_DOWN]) input.analog[i][1]+=2; - else input.analog[i][1] = y ? (127 - y) : (128 - y); - - /* Limits */ - if (input.analog[i][0] < 0) input.analog[i][0] = 0; - else if (input.analog[i][0] > 255) input.analog[i][0] = 255; - if (input.analog[i][1] < 0) input.analog[i][1] = 0; - else if (input.analog[i][1] > 255) input.analog[i][1] = 255; - - /* Buttons */ - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_BUTTON1; - if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_BUTTON2; - if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_PADDLE: - { - /* X analog position [0-255] */ - if (exp == WPAD_EXP_NONE) - { - /* Wiimote D-PAD */ - if (p & wpad_dirmap[exp][PAD_LEFT]) input.analog[i][0]-=2; - else if (p & wpad_dirmap[exp][PAD_RIGHT]) input.analog[i][0]+=2; - - /* Limits */ - if (input.analog[i][0] < 0) input.analog[i][0] = 0; - else if (input.analog[i][0] > 255) input.analog[i][0] = 255; - } - else - { - /* Left analog stick */ - input.analog[i][0] = (x + 128); - } - - /* Buttons */ - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_BUTTON1; - if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_PAD2B: - { - /* D-PAD */ - if ((p & wpad_dirmap[exp][PAD_UP]) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; - else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; - if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; - else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; - - /* Buttons */ - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_BUTTON1; - if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_BUTTON2; - if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_LIGHTGUN: - { - /* Gun screen position (x,y) */ - if (exp != WPAD_EXP_CLASSIC) - { - /* Wiimote IR */ - struct ir_t ir; - WPAD_IR(chan, &ir); - - if (ir.valid) - { - /* screen position */ - input.analog[i][0] = (ir.x * bitmap.viewport.w) / 640; - input.analog[i][1] = (ir.y * bitmap.viewport.h) / 480; - } - else - { - /* lightgun should point outside screen area */ - input.analog[i][0] = 512; - input.analog[i][1] = 512; - } - } - else - { - /* Classic Controller analog stick */ - input.analog[i][0] += x / ANALOG_SENSITIVITY; - input.analog[i][1] -= y / ANALOG_SENSITIVITY; - - /* Limits */ - if (input.analog[i][0] < 0) input.analog[i][0] = 0; - else if (input.analog[i][0] > bitmap.viewport.w) input.analog[i][0] = bitmap.viewport.w; - if (input.analog[i][1] < 0) input.analog[i][1] = 0; - else if (input.analog[i][1] > bitmap.viewport.h) input.analog[i][1] = bitmap.viewport.h; - } - - /* Buttons */ - if (p & wpad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_A; - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_B; - if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_C; - if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_MOUSE: - { - /* Mouse relative movement (-255,255) */ - input.analog[i][0] = (x / ANALOG_SENSITIVITY) * 2; - input.analog[i][1] = (y / ANALOG_SENSITIVITY) * 2; - - /* Wiimote IR (buggy) */ - if (exp != WPAD_EXP_CLASSIC) - { - struct ir_t ir; - WPAD_IR(chan, &ir); - - /* Only if Wiimote is pointed to screen */ - if(ir.smooth_valid) - { - input.analog[i][0] = (int)((ir.sx - 512) / 2 / ANALOG_SENSITIVITY); - input.analog[i][1] = (int)((ir.sy - 384) * 2 / 3 / ANALOG_SENSITIVITY); - } - } - - /* USB mouse support */ - if (MOUSE_IsConnected()) - { - /* read mouse data */ - mouse_event event; - MOUSE_GetEvent(&event); - MOUSE_FlushEvents(); - - /* mouse position (-127;+127) -> (-255;+255) */ - input.analog[i][0] = event.rx * 2; - input.analog[i][1] = event.ry * 2; - - /* mouse buttons */ - if (event.button & 1) input.pad[i] |= INPUT_MOUSE_RIGHT; - if (event.button & 2) input.pad[i] |= INPUT_MOUSE_CENTER; - if (event.button & 4) input.pad[i] |= INPUT_MOUSE_LEFT; - } - - /* Y-Axis inversion */ - if (config.invert_mouse) - { - input.analog[i][1] = -input.analog[i][1]; - } - - /* Buttons */ - if (p & wpad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_MOUSE_CENTER; - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_MOUSE_LEFT; - if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_MOUSE_RIGHT; - if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; - - break; - } - - case DEVICE_PICO: - { - /* D-PAD */ - if (p & PAD_BUTTON_UP) input.pad[i] |= INPUT_UP; - else if (p & PAD_BUTTON_DOWN) input.pad[i] |= INPUT_DOWN; - if (p & PAD_BUTTON_LEFT) input.pad[i] |= INPUT_LEFT; - else if (p & PAD_BUTTON_RIGHT) input.pad[i] |= INPUT_RIGHT; - - /* PEN screen position (x,y) */ - input.analog[0][0] += x / ANALOG_SENSITIVITY; - input.analog[0][1] -= y / ANALOG_SENSITIVITY; - - /* Limits */ - if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c; - else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c; - if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc; - else if (input.analog[0][1] > 0x3f3) input.analog[0][1] = 0x3f3; - - /* Wiimote IR */ - if (exp != WPAD_EXP_CLASSIC) - { - struct ir_t ir; - WPAD_IR(chan, &ir); - if (ir.valid) - { - input.analog[0][0] = 0x3c + (ir.x * (0x17c - 0x3c + 1)) / 640; - input.analog[0][1] = 0x1fc + (ir.y * (0x3f3 - 0x1fc + 1)) / 480; - } - } - - /* PEN button */ - if (p & wpad_keymap[KEY_BUTTONA]) input.pad[0] |= INPUT_PICO_PEN; - - /* RED button */ - if (p & wpad_keymap[KEY_BUTTONB]) input.pad[0] |= INPUT_PICO_RED; - - /* PAGE index increment */ - if (p & wpad_keymap[KEY_BUTTONC]) pico_current = (pico_current + 1) & 7; - - break; - } - - case DEVICE_TEREBI: - { - /* PEN screen position (x,y) */ - input.analog[0][0] += x / ANALOG_SENSITIVITY; - input.analog[0][1] -= y / ANALOG_SENSITIVITY; - - /* Limits */ - if (input.analog[0][0] < 0) input.analog[0][0] = 0; - else if (input.analog[0][0] > 250) input.analog[0][0] = 250; - if (input.analog[0][1] < 0) input.analog[0][1] = 0; - else if (input.analog[0][1] > 250) input.analog[0][1] = 250; - - /* Wiimote IR */ - if (exp != WPAD_EXP_CLASSIC) - { - struct ir_t ir; - WPAD_IR(chan, &ir); - if (ir.valid) - { - input.analog[0][0] = (ir.x * 250) / 640; - input.analog[0][1] = (ir.y * 250) / 480; - } - } - - /* PEN button */ - if (p & wpad_keymap[KEY_BUTTONA]) input.pad[0] |= INPUT_BUTTON1; - - break; - } - - case DEVICE_ACTIVATOR: - { - /* Classic Controller only */ - if (exp == WPAD_EXP_CLASSIC) - { - /* Left stick */ - float mag = data->exp.classic.ljs.mag; - float ang = data->exp.classic.ljs.ang; - - if (mag > 0.5) - { - /* 8 bottom sensors = 8 areas */ - if ((ang > 22.5) && (ang <= 67.5)) input.pad[i] |= INPUT_ACTIVATOR_2L; - else if ((ang > 67.5) && (ang <= 112.5)) input.pad[i] |= INPUT_ACTIVATOR_3L; - else if ((ang > 112.5) && (ang <= 157.5)) input.pad[i] |= INPUT_ACTIVATOR_4L; - else if ((ang > 157.5) && (ang <= 202.5)) input.pad[i] |= INPUT_ACTIVATOR_5L; - else if ((ang > 202.5) && (ang <= 247.5)) input.pad[i] |= INPUT_ACTIVATOR_6L; - else if ((ang > 247.5) && (ang <= 292.5)) input.pad[i] |= INPUT_ACTIVATOR_7L; - else if ((ang > 292.5) && (ang <= 337.5)) input.pad[i] |= INPUT_ACTIVATOR_8L; - else input.pad[i] |= INPUT_ACTIVATOR_1L; - } - - /* Right stick */ - mag = data->exp.classic.rjs.mag; - ang = data->exp.classic.rjs.ang; - - if (mag > 0.5) - { - /* 8 top sensors = 8 areas */ - if ((ang > 22.5) && (ang <= 67.5)) input.pad[i] |= INPUT_ACTIVATOR_2U; - else if ((ang > 67.5) && (ang <= 112.5)) input.pad[i] |= INPUT_ACTIVATOR_3U; - else if ((ang > 112.5) && (ang <= 157.5)) input.pad[i] |= INPUT_ACTIVATOR_4U; - else if ((ang > 157.5) && (ang <= 202.5)) input.pad[i] |= INPUT_ACTIVATOR_5U; - else if ((ang > 202.5) && (ang <= 247.5)) input.pad[i] |= INPUT_ACTIVATOR_6U; - else if ((ang > 247.5) && (ang <= 292.5)) input.pad[i] |= INPUT_ACTIVATOR_7U; - else if ((ang > 292.5) && (ang <= 337.5)) input.pad[i] |= INPUT_ACTIVATOR_8U; - else input.pad[i] |= INPUT_ACTIVATOR_1U; - } - } - - break; - } - } -} -#endif - - -/***************************************************************************************/ -/* GX Input interface */ -/***************************************************************************************/ -void gx_input_Init(void) -{ - PAD_Init(); -#ifdef HW_RVL - WPAD_Init(); - WPAD_SetIdleTimeout(60); - WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); - WPAD_SetVRes(WPAD_CHAN_ALL,640,480); -#endif -} - -int gx_input_FindDevices(void) -{ - int i; -#ifdef HW_RVL - u32 wpad; -#endif - int found = 0; - int player = 0; - - VIDEO_WaitVSync(); - u32 pad = PAD_ScanPads(); - - for (i=0; i 0) - { - wpad_update(config.input[player].port, i, config.input[player].device - 1); - } -#endif - - /* increment player index */ - player ++; - } - } - - /* Update RAM patches */ - RAMCheatUpdate(); -} - -/* Menu inputs update function */ -void gx_input_UpdateMenu(void) -{ - /* Check if inputs update are disabled */ - if (inputs_disabled) return; - - /* PAD status update */ - PAD_ScanPads(); - - /* PAD pressed keys */ - s16 pp = PAD_ButtonsDown(0); - - /* PAD held keys (direction/selection) */ - s16 hp = PAD_ButtonsHeld(0) & PAD_BUTTONS_HELD; - - /* PAD analog sticks (handled as PAD held direction keys) */ - s8 x = PAD_StickX(0); - s8 y = PAD_StickY(0); - if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT; - else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT; - else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP; - else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN; - -#ifdef HW_RVL - /* WPAD status update */ - WPAD_ScanPads(); - WPADData *data = WPAD_Data(0); - - /* WPAD pressed keys */ - u32 pw = data->btns_d; - - /* WPAD held keys (direction/selection) */ - u32 hw = data->btns_h & WPAD_BUTTONS_HELD; - - /* WPAD analog sticks (handled as PAD held direction keys) */ - x = wpad_StickX(data, 0); - y = wpad_StickY(data, 0); - if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT; - else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT; - else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP; - else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN; -#endif - - /* check if any direction/selection key is being held or just being pressed/released */ -#ifdef HW_RVL - if (pp||pw) held_cnt = 0; - else if (hp||hw) held_cnt++; - else held_cnt = 0; -#else - if (pp) held_cnt = 0; - else if (hp) held_cnt++; - else held_cnt = 0; -#endif - - /* initial delay (prevents triggering to start immediately) */ - if (held_cnt > HELD_DELAY) - { - /* key triggering */ - pp |= hp; -#ifdef HW_RVL - pw |= hw; -#endif - - /* delay until next triggering (adjusts direction/selection update speed) */ - held_cnt -= HELD_SPEED; - } - -#ifdef HW_RVL - /* Wiimote direction keys */ - WPAD_IR(0, &m_input.ir); - if (m_input.ir.valid) - { - /* Wiimote is handled vertically */ - if (pw & WPAD_BUTTON_UP) pp |= PAD_BUTTON_UP; - else if (pw & WPAD_BUTTON_DOWN) pp |= PAD_BUTTON_DOWN; - else if (pw & WPAD_BUTTON_LEFT) pp |= PAD_BUTTON_LEFT; - else if (pw & WPAD_BUTTON_RIGHT) pp |= PAD_BUTTON_RIGHT; - } - else - { - /* Wiimote is handled horizontally */ - if (pw & WPAD_BUTTON_UP) pp |= PAD_BUTTON_LEFT; - else if (pw & WPAD_BUTTON_DOWN) pp |= PAD_BUTTON_RIGHT; - else if (pw & WPAD_BUTTON_LEFT) pp |= PAD_BUTTON_DOWN; - else if (pw & WPAD_BUTTON_RIGHT) pp |= PAD_BUTTON_UP; - } - - /* Classic Controller direction keys */ - if (pw & WPAD_CLASSIC_BUTTON_UP) pp |= PAD_BUTTON_UP; - else if (pw & WPAD_CLASSIC_BUTTON_DOWN) pp |= PAD_BUTTON_DOWN; - else if (pw & WPAD_CLASSIC_BUTTON_LEFT) pp |= PAD_BUTTON_LEFT; - else if (pw & WPAD_CLASSIC_BUTTON_RIGHT) pp |= PAD_BUTTON_RIGHT; - - /* WPAD buttons */ - if (pw & WPAD_BUTTON_A) pp |= PAD_BUTTON_A; - if (pw & WPAD_BUTTON_B) pp |= PAD_BUTTON_B; - if (pw & WPAD_BUTTON_2) pp |= PAD_BUTTON_A; - if (pw & WPAD_BUTTON_1) pp |= PAD_BUTTON_B; - if (pw & WPAD_BUTTON_HOME) pp |= PAD_TRIGGER_Z; - if (pw & WPAD_BUTTON_PLUS) pp |= PAD_TRIGGER_L; - if (pw & WPAD_BUTTON_MINUS) pp |= PAD_TRIGGER_R; - if (pw & WPAD_CLASSIC_BUTTON_FULL_L) pp |= PAD_TRIGGER_L; - if (pw & WPAD_CLASSIC_BUTTON_FULL_R) pp |= PAD_TRIGGER_R; - if (pw & WPAD_CLASSIC_BUTTON_A) pp |= PAD_BUTTON_A; - if (pw & WPAD_CLASSIC_BUTTON_B) pp |= PAD_BUTTON_B; - if (pw & WPAD_CLASSIC_BUTTON_HOME) pp |= PAD_TRIGGER_Z; -#endif - - /* Update menu inputs */ - m_input.keys = pp; -} diff --git a/genplus-gx/gx/gx_input.h b/genplus-gx/gx/gx_input.h deleted file mode 100644 index 77143b465e..0000000000 --- a/genplus-gx/gx/gx_input.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** - * gx_input.c - * - * Genesis Plus GX input support - * - * Copyright Eke-Eke (2007-2013) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _GC_INPUT_H_ -#define _GC_INPUT_H_ - -#define osd_input_update() gx_input_UpdateEmu() - -/* max. supported inputs */ -#ifdef HW_RVL -#define MAX_INPUTS 8 -#else -#define MAX_INPUTS 4 -#endif - -/* Configurable keys */ -#define MAX_KEYS 8 - - -/* Key configuration structure */ -typedef struct -{ - s8 device; - u8 port; - u8 padtype; -} t_input_config; - - -extern void gx_input_Init(void); -extern int gx_input_FindDevices(void); -extern void gx_input_SetDefault(void); -extern void gx_input_Config(u8 chan, u8 device, u8 type); -extern void gx_input_UpdateEmu(void); -extern void gx_input_UpdateMenu(void); - -#endif diff --git a/genplus-gx/gx/gx_video.c b/genplus-gx/gx/gx_video.c deleted file mode 100644 index 5521b238df..0000000000 --- a/genplus-gx/gx/gx_video.c +++ /dev/null @@ -1,2041 +0,0 @@ -/**************************************************************************** - * gx_video.c - * - * Genesis Plus GX video & rendering support - * - * Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "font.h" -#include "md_ntsc.h" -#include "sms_ntsc.h" -#include "gx_input.h" - -#include -#include - -#define TEX_WIDTH 720 -#define TEX_HEIGHT 576 -#define TEX_SIZE (TEX_WIDTH * TEX_HEIGHT * 2) -#define DEFAULT_FIFO_SIZE 256 * 1024 -#define HASPECT 320 -#define VASPECT 240 - -/* libpng wrapper */ -typedef struct -{ - u8 *buffer; - u32 offset; -} png_image; - -extern const u8 Crosshair_p1_png[]; -extern const u8 Crosshair_p2_png[]; -extern const u8 CD_access_off_png[]; -extern const u8 CD_access_on_png[]; -extern const u8 CD_ready_off_png[]; -extern const u8 CD_ready_on_png[]; - -/*** VI ***/ -GXRModeObj *vmode; /* Default Video Mode */ -u8 *texturemem; /* Texture Data */ -u8 *screenshot; /* Texture Data */ - -/*** 50/60hz flag ***/ -u32 gc_pal; - -/*** NTSC Filters ***/ -sms_ntsc_t *sms_ntsc; -md_ntsc_t *md_ntsc; - -/*** GX FIFO ***/ -static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN (32); - -/*** GX Textures ***/ -static u32 vwidth, vheight; -static gx_texture *crosshair[2]; -static gx_texture *cd_leds[2][2]; - -/*** Framebuffers ***/ -static u32 *xfb[2]; -static u32 whichfb = 0; - -/*** Frame Sync ***/ -u32 videoSync; -static u32 videoWait; -static u32 frameCount; -static u64 starttime; - -/*** OSD ***/ -static u32 osd; -static char msg[16]; - -/***************************************************************************************/ -/* Emulation video modes */ -/***************************************************************************************/ -static GXRModeObj *rmode; - -/* 288 lines progressive (PAL 50Hz) */ -static GXRModeObj TV50hz_288p = -{ - VI_TVMODE_PAL_DS, // viDisplayMode - 640, // fbWidth - VI_MAX_HEIGHT_PAL/2, // efbHeight - VI_MAX_HEIGHT_PAL/2, // xfbHeight - 0, // viXOrigin - 0, // viYOrigin - VI_MAX_WIDTH_PAL, // viWidth - VI_MAX_HEIGHT_PAL, // viHeight - VI_XFBMODE_SF, // xFBmode - GX_FALSE, // field_rendering - GX_FALSE, // aa - - // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, - - // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } -}; - -/* 288 lines interlaced (PAL 50Hz) */ -static GXRModeObj TV50hz_288i = -{ - VI_TVMODE_PAL_INT, // viDisplayMode - 640, // fbWidth - VI_MAX_HEIGHT_PAL/2, // efbHeight - VI_MAX_HEIGHT_PAL/2, // xfbHeight - 0, // viXOrigin - 0, // viYOrigin - VI_MAX_WIDTH_PAL, // viWidth - VI_MAX_HEIGHT_PAL, // viHeight - VI_XFBMODE_SF, // xFBmode - GX_TRUE, // field_rendering - GX_FALSE, // aa - - // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, - - // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } -}; - -/* 576 lines interlaced (PAL 50Hz, scaled) */ -static GXRModeObj TV50hz_576i = -{ - VI_TVMODE_PAL_INT, // viDisplayMode - 640, // fbWidth - 480, // efbHeight - VI_MAX_HEIGHT_PAL, // xfbHeight - 0, // viXOrigin - 0, // viYOrigin - VI_MAX_WIDTH_PAL, // viWidth - VI_MAX_HEIGHT_PAL, // viHeight - VI_XFBMODE_DF, // xFBmode - GX_FALSE, // field_rendering - GX_FALSE, // aa - - // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, - - // vertical filter[7], 1/64 units, 6 bits each - { - 8, // line n-1 - 8, // line n-1 - 10, // line n - 12, // line n - 10, // line n - 8, // line n+1 - 8 // line n+1 - } -}; - -/* 240 lines progressive (NTSC or PAL 60Hz) */ -static GXRModeObj TV60hz_240p = -{ - VI_TVMODE_EURGB60_DS, // viDisplayMode - 640, // fbWidth - VI_MAX_HEIGHT_NTSC/2, // efbHeight - VI_MAX_HEIGHT_NTSC/2, // xfbHeight - 0, // viXOrigin - 0, // viYOrigin - VI_MAX_WIDTH_NTSC, // viWidth - VI_MAX_HEIGHT_NTSC, // viHeight - VI_XFBMODE_SF, // xFBmode - GX_FALSE, // field_rendering - GX_FALSE, // aa - - // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, - - // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } -}; - -/* 240 lines interlaced (NTSC or PAL 60Hz) */ -static GXRModeObj TV60hz_240i = -{ - VI_TVMODE_EURGB60_INT, // viDisplayMode - 640, // fbWidth - VI_MAX_HEIGHT_NTSC/2, // efbHeight - VI_MAX_HEIGHT_NTSC/2, // xfbHeight - 0, // viXOrigin - 0, // viYOrigin - VI_MAX_WIDTH_NTSC, // viWidth - VI_MAX_HEIGHT_NTSC, // viHeight - VI_XFBMODE_SF, // xFBmode - GX_TRUE, // field_rendering - GX_FALSE, // aa - - // sample points arranged in increasing Y order - { - {3,2},{9,6},{3,10}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {3,2},{9,6},{3,10}, // pix 1 - {9,2},{3,6},{9,10}, // pix 2 - {9,2},{3,6},{9,10} // pix 3 - }, - - // vertical filter[7], 1/64 units, 6 bits each - { - 0, // line n-1 - 0, // line n-1 - 21, // line n - 22, // line n - 21, // line n - 0, // line n+1 - 0 // line n+1 - } -}; - -/* 480 lines interlaced (NTSC or PAL 60Hz) */ -static GXRModeObj TV60hz_480i = -{ - VI_TVMODE_EURGB60_INT,// viDisplayMode - 640, // fbWidth - VI_MAX_HEIGHT_NTSC, // efbHeight - VI_MAX_HEIGHT_NTSC, // xfbHeight - 0, // viXOrigin - 0, // viYOrigin - VI_MAX_WIDTH_NTSC, // viWidth - VI_MAX_HEIGHT_NTSC, // viHeight - VI_XFBMODE_DF, // xFBmode - GX_FALSE, // field_rendering - GX_FALSE, // aa - - // sample points arranged in increasing Y order - { - {6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each - {6,6},{6,6},{6,6}, // pix 1 - {6,6},{6,6},{6,6}, // pix 2 - {6,6},{6,6},{6,6} // pix 3 - }, - - // vertical filter[7], 1/64 units, 6 bits each - { - 8, // line n-1 - 8, // line n-1 - 10, // line n - 12, // line n - 10, // line n - 8, // line n+1 - 8 // line n+1 - } -}; - -/* TV modes pointer table */ -static GXRModeObj *tvmodes[6] = -{ - /* 60hz modes */ - &TV60hz_240p, - &TV60hz_240i, - &TV60hz_480i, - - /* 50Hz modes */ - &TV50hz_288p, - &TV50hz_288i, - &TV50hz_576i -}; - -/***************************************************************************************/ -/* GX rendering engine */ -/***************************************************************************************/ - -typedef struct tagcamera -{ - guVector pos; - guVector up; - guVector view; -} camera; - -/*** Square Matrix - This structure controls the size of the image on the screen. - Think of the output as a -80 x 80 by -60 x 60 graph. -***/ -static s16 square[] ATTRIBUTE_ALIGN (32) = -{ - /* - * X, Y, Z - * Values set are for roughly 4:3 aspect - */ - -HASPECT, VASPECT, 0, // 0 - HASPECT, VASPECT, 0, // 1 - HASPECT, -VASPECT, 0, // 2 - -HASPECT, -VASPECT, 0, // 3 -}; - -static camera cam = { - {0.0F, 0.0F, -100.0F}, - {0.0F, -1.0F, 0.0F}, - {0.0F, 0.0F, 0.0F} -}; - -/*** GX Display List ***/ -static u8 d_list[32] ATTRIBUTE_ALIGN(32) = -{ - GX_QUADS | GX_VTXFMT0, /* textured quad rendering (Vertex Format 0) */ - 0x00, 0x04, /* one quad = 4x vertex */ - 0x03, 0x00, 0x00, 0x00, 0x00, /* top left corner */ - 0x02, 0x00, 0x01, 0x00, 0x00, /* top right corner */ - 0x01, 0x00, 0x01, 0x00, 0x01, /* bottom right corner */ - 0x00, 0x00, 0x00, 0x00, 0x01, /* bottom left corner */ - 0x00, 0x00, 0x00, 0x00, 0x00, /* padding */ - 0x00, 0x00, 0x00, 0x00 -}; - -/* VSYNC callback */ -static void vi_callback(u32 cnt) -{ - videoWait = 0; -} - -/* Initialize GX */ -static void gxStart(void) -{ - /*** Clear out FIFO area ***/ - memset(&gp_fifo, 0, DEFAULT_FIFO_SIZE); - - /*** GX default ***/ - GX_Init(&gp_fifo, DEFAULT_FIFO_SIZE); - GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); - GX_SetCullMode(GX_CULL_NONE); - GX_SetClipMode(GX_CLIP_DISABLE); - GX_SetDispCopyGamma(GX_GM_1_0); - GX_SetZMode(GX_FALSE, GX_ALWAYS, GX_FALSE); - GX_SetColorUpdate(GX_TRUE); - GX_SetAlphaUpdate(GX_FALSE); - - /* Modelview */ - Mtx view; - memset (&view, 0, sizeof (Mtx)); - guLookAt(view, &cam.pos, &cam.up, &cam.view); - GX_LoadPosMtxImm(view, GX_PNMTX0); - GX_Flush(); -} - -/* Reset GX rendering */ -static void gxResetRendering(u8 type) -{ - GX_ClearVtxDesc(); - - if (type) - { - /* uses direct positionning, alpha blending & color channel (menu rendering) */ - GX_SetBlendMode(GX_BM_BLEND,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); - GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_S16, 0); - GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); - GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); - GX_SetVtxDesc(GX_VA_POS, GX_DIRECT); - GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT); - /* - Color.out = Color.rasterized*Color.texture - Alpha.out = Alpha.rasterized*Alpha.texture - */ - GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); - GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); - GX_SetNumTexGens(1); - GX_SetNumChans(1); - } - else - { - /* uses array positionning, no alpha blending, no color channel (video emulation) */ - GX_SetBlendMode(GX_BM_NONE,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); - GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0); - GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_S16, 0); - GX_SetVtxDesc(GX_VA_POS, GX_INDEX8); - GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - GX_SetArray(GX_VA_POS, square, 3 * sizeof (s16)); - /* - Color.out = Color.texture - Alpha.out = Alpha.texture - */ - GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE); - GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL); - GX_SetNumTexGens(1); - GX_SetNumChans(0); - } - - GX_Flush(); -} - -/* Reset GX rendering mode */ -static void gxResetMode(GXRModeObj *tvmode, int vfilter_enabled) -{ - Mtx44 p; - f32 yScale = GX_GetYScaleFactor(tvmode->efbHeight, tvmode->xfbHeight); - u16 xfbHeight = GX_SetDispCopyYScale(yScale); - u16 xfbWidth = VIDEO_PadFramebufferWidth(tvmode->fbWidth); - - GX_SetCopyClear((GXColor)BLACK,0x00ffffff); - GX_SetViewport(0.0F, 0.0F, tvmode->fbWidth, tvmode->efbHeight, 0.0F, 1.0F); - GX_SetScissor(0, 0, tvmode->fbWidth, tvmode->efbHeight); - GX_SetDispCopySrc(0, 0, tvmode->fbWidth, tvmode->efbHeight); - GX_SetDispCopyDst(xfbWidth, xfbHeight); - GX_SetCopyFilter(tvmode->aa, tvmode->sample_pattern, (tvmode->xfbMode == VI_XFBMODE_SF) ? GX_FALSE : vfilter_enabled, tvmode->vfilter); - GX_SetFieldMode(tvmode->field_rendering, ((tvmode->viHeight == 2 * tvmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); - guOrtho(p, tvmode->efbHeight/2, -(tvmode->efbHeight/2), -(tvmode->fbWidth/2), tvmode->fbWidth/2, 100, 1000); - GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC); - GX_Flush(); -} - -/* Update Aspect Ratio */ -static void gxSetAspectRatio(int *xscale, int *yscale) -{ - /* Vertical Scaling is disabled by default */ - *yscale = (bitmap.viewport.h + (2 * bitmap.viewport.y)) / 2; - - /* Original aspect ratio */ - if (config.aspect) - { - /* Adjust vertical scaling when input & output video heights are different */ - if (vdp_pal && (!gc_pal || config.render)) - { - *yscale = *yscale * VI_MAX_HEIGHT_NTSC / VI_MAX_HEIGHT_PAL; - } - else if (!vdp_pal && gc_pal && !config.render) - { - *yscale = *yscale * VI_MAX_HEIGHT_PAL / VI_MAX_HEIGHT_NTSC; - } - - /* Horizontal Scaling */ - /* Wii/Gamecube pixel clock = 13.5 Mhz */ - /* "H32" pixel clock = Master Clock / 10 = 5.3693175 Mhz (NTSC) or 5.3203424 (PAL) */ - /* "H40" pixel clock = Master Clock / 8 = 6,711646875 Mhz (NTSC) or 6,650428 Mhz (PAL) */ - if (config.overscan & 2) - { - /* Horizontal borders are emulated */ - if (reg[12] & 1) - { - /* 348 "H40" pixels = 348 * Wii/GC pixel clock / "H40" pixel clock = approx. 700 (NTSC) or 707 (PAL) Wii/GC pixels */ - *xscale = (system_clock == MCLOCK_NTSC) ? 350 : 354; - } - else - { - /* 284 "H32" pixels = 284 * Wii/GC pixel clock / "H40" pixel clock = approx. 714 (NTSC) or 721 (PAL) Wii/GC pixels */ - *xscale = (system_clock == MCLOCK_NTSC) ? 357 : 361; - } - } - else - { - /* Horizontal borders are simulated */ - if ((system_hw == SYSTEM_GG) && !config.gg_extra) - { - /* 160 "H32" pixels = 160 * Wii/GC pixel clock / "H32" pixel clock = approx. 403 Wii/GC pixels (NTSC only) */ - *xscale = 202; - } - else - { - /* 320 "H40" pixels = 256 "H32" pixels = 256 * Wii/GC pixel clock / "H32" pixel clock = approx. 644 (NTSC) or 650 (PAL) Wii/GC pixels */ - *xscale = (system_clock == MCLOCK_NTSC) ? 322 : 325; - } - } - - /* Aspect correction for widescreen TV */ - if (config.aspect & 2) - { - /* Keep 4:3 aspect ratio on 16:9 output */ - *xscale = (*xscale * 3) / 4; - } - } - - /* Manual aspect ratio */ - else - { - /* By default, disable horizontal scaling */ - *xscale = bitmap.viewport.w + (2 * bitmap.viewport.x); - - /* Keep original aspect ratio in H32 modes */ - if (!(reg[12] & 1)) - { - *xscale = (*xscale * 320) / 256; - } - - /* Game Gear specific: if borders are disabled, upscale to fullscreen */ - if ((system_hw == SYSTEM_GG) && !config.gg_extra) - { - if (!(config.overscan & 1)) - { - /* Active area height = approx. 224 non-interlaced lines (60hz) */ - *yscale = 112; - } - - if (!(config.overscan & 2)) - { - /* Active area width = approx. 640 pixels */ - *xscale = 320; - } - } - - /* By default, keep NTSC aspect ratio */ - if (gc_pal && !config.render) - { - /* Upscale PAL output */ - *yscale = *yscale * VI_MAX_HEIGHT_PAL / VI_MAX_HEIGHT_NTSC; - } - - /* Add user scaling */ - *xscale += config.xscale; - *yscale += config.yscale; - } -} - -/* Reset GX/VI hardware scaler */ -static void gxResetScaler(u32 width) -{ - int xscale = 0; - int yscale = 0; - int offset = 0; - - /* retrieve screen aspect ratio */ - gxSetAspectRatio(&xscale, &yscale); - - /* default EFB width */ - rmode->fbWidth = 640; - - /* no filtering, disable GX horizontal scaling */ - if (!config.bilinear && !config.ntsc) - { - if ((width <= 320) && (width <= xscale)) - rmode->fbWidth = width * 2; - else if (width <= 640) - rmode->fbWidth = width; - } - - /* configure VI width */ - if ((xscale * 2) > rmode->fbWidth) - { - /* max width = 720 pixels */ - if (xscale > 360) - { - /* save offset for later */ - offset = ((xscale - 360) * rmode->fbWidth) / rmode->viWidth; - - /* maximal width */ - xscale = 360; - } - - /* enable VI upscaling */ - rmode->viWidth = xscale * 2; - rmode->viXOrigin = (720 - (xscale * 2)) / 2; - - /* default GX horizontal scaling */ - xscale = (rmode->fbWidth / 2); - - /* handle additional upscaling */ - if (offset) - { - /* no filtering, reduce EFB width to increase VI upscaling */ - if (!config.bilinear && !config.ntsc) - rmode->fbWidth -= (offset * 2); - - /* increase GX horizontal scaling */ - else - xscale += offset; - } - } - else - { - /* VI horizontal scaling is disabled */ - rmode->viWidth = rmode->fbWidth; - rmode->viXOrigin = (720 - rmode->fbWidth) / 2; - } - - /* Adjust screen position */ - int xshift = (config.xshift * rmode->fbWidth) / rmode->viWidth; - int yshift = (config.yshift * rmode->efbHeight) / rmode->viHeight; - - /* Double Resolution modes (480i/576i/480p) */ - if (config.render) - { - yscale = yscale * 2; - } - - /* Set GX scaler (Vertex Position matrix) */ - square[6] = square[3] = xshift + xscale; - square[0] = square[9] = xshift - xscale; - square[4] = square[1] = yshift + yscale; - square[7] = square[10] = yshift - yscale; - DCFlushRange(square, 32); - GX_InvVtxCache(); -} - -static void gxDrawCrosshair(gx_texture *texture, int x, int y) -{ - /* adjust texture dimensions to XFB->VI scaling */ - int w = (texture->width * rmode->fbWidth) / (rmode->viWidth); - int h = (texture->height * rmode->efbHeight) / (rmode->viHeight); - - /* Aspect correction for widescreen TV */ - if (config.aspect & 2) w = (w * 3) / 4; - - /* EFB scale & shift */ - int xwidth = square[3] - square[9]; - int ywidth = square[4] - square[10]; - - /* adjust texture coordinates to EFB */ - x = (((x + bitmap.viewport.x) * xwidth) / vwidth) + square[9] - w/2; - y = (((y + bitmap.viewport.y) * ywidth) / vheight) + square[10] - h/2; - - /* load texture object */ - GXTexObj texObj; - GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); - GX_LoadTexObj(&texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* Draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 1.0); - GX_Position2s16(x+w,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(x+w,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(x,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 0.0); - GX_End(); -} - -static void gxDrawCdLeds(gx_texture *texture_l, gx_texture *texture_r) -{ - /* adjust texture dimensions to XFB->VI scaling */ - int w = (texture_l->width * rmode->fbWidth) / (rmode->viWidth); - int h = (texture_l->height * rmode->efbHeight) / (rmode->viHeight); - - /* Aspect correction for widescreen TV */ - if (config.aspect & 2) w = (w * 3) / 4; - - /* EFB scale & shift */ - int xwidth = square[3] - square[9]; - int ywidth = square[4] - square[10]; - - /* adjust texture coordinates to EFB */ - int xl = ((bitmap.viewport.x * xwidth) / vwidth) + square[9] + 8; - int xr = (((bitmap.viewport.x + bitmap.viewport.w) * xwidth) / vwidth) + square[9] - 8 - w; - int y = (((bitmap.viewport.y + bitmap.viewport.h - 4) * ywidth) / vheight) + square[10] - h; - - /* load left screen texture */ - GXTexObj texObj; - GX_InitTexObj(&texObj, texture_l->data, texture_l->width, texture_l->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); - GX_LoadTexObj(&texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* Draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(xl,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 1.0); - GX_Position2s16(xl+w,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(xl+w,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(xl,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 0.0); - GX_End(); - - /* load right screen texture */ - GX_InitTexObj(&texObj, texture_r->data, texture_r->width, texture_r->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); - GX_LoadTexObj(&texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* Draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(xr,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 1.0); - GX_Position2s16(xr+w,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(xr+w,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(xr,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 0.0); - GX_End(); -} - -static void gxDrawOnScreenText(char *msg) -{ - GXRModeObj *temp = vmode; - int y = (40 * rmode->efbHeight) / 480; - int x = (bitmap.viewport.x > 0) ? (24 + bitmap.viewport.x) : 24; - x = (x * rmode->fbWidth) / rmode->viWidth; - - vmode = rmode; - FONT_write(msg, 20, x, y, rmode->fbWidth, (GXColor)WHITE); - vmode = temp; -} - -void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color) -{ - /* GX only use Color channel for rendering */ - GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); - GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); - GX_Flush(); - - /* vertex coordinate */ - x -= (vmode->fbWidth/2); - y -= (vmode->efbHeight/2); - - /* draw colored quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x,y+h); - GX_Color4u8(color.r,color.g,color.b,alpha); - GX_Position2s16(x+w,y+h); - GX_Color4u8(color.r,color.g,color.b,alpha); - GX_Position2s16(x+w,y); - GX_Color4u8(color.r,color.g,color.b,alpha); - GX_Position2s16(x,y); - GX_Color4u8(color.r,color.g,color.b,alpha); - GX_End(); - GX_DrawDone(); - - /* restore GX rendering */ - GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT); - GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE); - GX_Flush(); -} - -void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha) -{ - if (!texture) return; - if (texture->data) - { - /* load texture object */ - GXTexObj texObj; - GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); /* does this really change anything ? */ - GX_LoadTexObj(&texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* vertex coordinate */ - x -= (vmode->fbWidth/2); - y -= (vmode->efbHeight/2); - - /* draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x,y+h); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, 1.0); - GX_Position2s16(x+w,y+h); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(x+w,y); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(x,y); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, 0.0); - GX_End(); - GX_DrawDone(); - } -} - -void gxDrawTextureRotate(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, f32 angle, u8 alpha) -{ - if (!texture) return; - if (texture->data) - { - /* load texture object */ - GXTexObj texObj; - GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); - GX_LoadTexObj(&texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* vertex coordinate */ - x -= (vmode->fbWidth/2); - y -= (vmode->efbHeight/2); - - /* Modelview rotation */ - Mtx m,mv; - guVector axis = (guVector) {0,0,1}; - guLookAt(mv, &cam.pos, &cam.up, &cam.view); - guMtxRotAxisDeg (m, &axis, angle); - guMtxTransApply(m,m, x+w/2,y+h/2,0); - guMtxConcat(mv,m,mv); - GX_LoadPosMtxImm(mv, GX_PNMTX0); - GX_Flush(); - - /* draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(-w/2,-h/2); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, 0.0); - GX_Position2s16(w/2,-h/2); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(w/2,h/2); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(-w/2,h/2); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, 1.0); - GX_End(); - GX_DrawDone(); - - /* restore default Modelview */ - guLookAt(mv, &cam.pos, &cam.up, &cam.view); - GX_LoadPosMtxImm(mv, GX_PNMTX0); - GX_Flush(); - } -} - -void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha) -{ - if (!texture) return; - if (texture->data) - { - /* load texture object */ - GXTexObj texObj; - GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_REPEAT, GX_REPEAT, GX_FALSE); - GX_LoadTexObj(&texObj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* vertex coordinate */ - x -= (vmode->fbWidth/2); - y -= (vmode->efbHeight/2); - - /* texture coordinates */ - f32 s = (f32)w / (f32)texture->width; - f32 t = (f32)h / (f32)texture->height; - - /* draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x,y+h); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, t); - GX_Position2s16(x+w,y+h); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(s, t); - GX_Position2s16(x+w,y); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(s, 0.0); - GX_Position2s16(x,y); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, 0.0); - GX_End(); - GX_DrawDone(); - } -} - -void gxDrawScreenshot(u8 alpha) -{ - if (!rmode) return; - - /* get current game screen texture */ - GXTexObj texobj; - GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_LoadTexObj(&texobj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* get current aspect ratio */ - int xscale,yscale; - gxSetAspectRatio(&xscale, &yscale); - - /* adjust horizontal scaling */ - xscale = (xscale * vmode->fbWidth) / vmode->viWidth; - - /* adjust screen position */ - int xshift = (config.xshift * vmode->fbWidth) / vmode->viWidth; - int yshift = (config.yshift * vmode->efbHeight) / vmode->viHeight; - - /* set vertices position & size */ - s32 x = xshift - xscale; - s32 y = yshift - (yscale * 2); - s32 w = xscale * 2; - s32 h = yscale * 4; - - /* black out surrounding area if necessary (Game Gear without borders) */ - if ((w < 640) || (h < 480)) - { - gxDrawRectangle(0, 0, 640, 480, 255, (GXColor)BLACK); - } - - /* draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x,y+h); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, 1.0); - GX_Position2s16(x+w,y+h); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(x+w,y); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(x,y); - GX_Color4u8(0xff,0xff,0xff,alpha); - GX_TexCoord2f32(0.0, 0.0); - GX_End(); - GX_DrawDone(); -} - -void gxCopyScreenshot(gx_texture *texture) -{ - /* retrieve gamescreen texture */ - GXTexObj texobj; - GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); - GX_LoadTexObj(&texobj, GX_TEXMAP0); - GX_InvalidateTexAll(); - - /* scale texture to EFB width */ - s32 w = ((bitmap.viewport.w + 2*bitmap.viewport.x) * 640) / bitmap.viewport.w; - s32 h = (bitmap.viewport.h + 2*bitmap.viewport.y) * 2; - s32 x = -w/2; - s32 y = -(240+ 2*bitmap.viewport.y); - - /* black out surrounding area if necessary (Game Gear without borders) */ - if ((w < 640) || (h < 480)) - { - gxDrawRectangle(0, 0, 640, 480, 255, (GXColor)BLACK); - } - - /* draw textured quad */ - GX_Begin(GX_QUADS, GX_VTXFMT0, 4); - GX_Position2s16(x,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 1.0); - GX_Position2s16(x+w,y+h); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 1.0); - GX_Position2s16(x+w,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(1.0, 0.0); - GX_Position2s16(x,y); - GX_Color4u8(0xff,0xff,0xff,0xff); - GX_TexCoord2f32(0.0, 0.0); - GX_End(); - - /* copy EFB to texture */ - texture->format = GX_TF_RGBA8; - texture->width = 320; - texture->height = bitmap.viewport.h; - texture->data = screenshot; - GX_SetTexCopySrc(0, 0, texture->width * 2, texture->height * 2); - GX_SetTexCopyDst(texture->width, texture->height, texture->format, GX_TRUE); - GX_DrawDone(); - GX_CopyTex(texture->data, GX_TRUE); - GX_Flush(); - - /* wait for copy operation to finish */ - /* GX_PixModeSync is only useful if GX_ command follows */ - /* we use dummy GX commands to stall CPU execution */ - GX_PixModeSync(); - GX_LoadTexObj(&texobj, GX_TEXMAP0); - GX_InvalidateTexAll(); - GX_Flush(); - DCFlushRange(texture->data, texture->width * texture->height * 4); -} - -/* Take Screenshot */ -void gxSaveScreenshot(char *filename) -{ - /* capture screenshot into a texture */ - gx_texture texture; - gxCopyScreenshot(&texture); - - /* open PNG file */ - FILE *f = fopen(filename,"wb"); - if (f) - { - /* encode screenshot into PNG file */ - gxTextureWritePNG(&texture,f); - fclose(f); - } -} - -void gxSetScreen(void) -{ - GX_DrawDone(); - GX_CopyDisp(xfb[whichfb], GX_FALSE); - GX_Flush(); - VIDEO_SetNextFramebuffer (xfb[whichfb]); - VIDEO_Flush (); - VIDEO_WaitVSync (); - gx_input_UpdateMenu(); -} - -void gxClearScreen(GXColor color) -{ - whichfb ^= 1; - GX_SetCopyClear(color,0x00ffffff); - GX_CopyDisp(xfb[whichfb], GX_TRUE); - GX_Flush(); -} - -/***************************************************************************************/ -/* GX Texture <-> LibPNG routines */ -/***************************************************************************************/ - -/* libpng read callback function */ -static void png_read_from_mem (png_structp png_ptr, png_bytep data, png_size_t length) -{ - png_image *image = (png_image *)png_get_io_ptr(png_ptr); - - /* copy data from image buffer */ - memcpy (data, image->buffer + image->offset, length); - - /* advance in the file */ - image->offset += length; -} - -/* convert PNG image (from file or data buffer) into RGBA8 texture */ -gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file) -{ - int i; - - /* create a png read struct */ - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL); - if (!png_ptr) return NULL; - - /* create a png info struct */ - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr,NULL,NULL); - return NULL; - } - - if (png_data) - { - /* init PNG image structure */ - png_image image; - image.buffer = (u8 *) png_data; - image.offset = 0; - - /* set callback for the read function */ - png_set_read_fn(png_ptr,(png_voidp *)(&image),png_read_from_mem); - } - else if (png_file) - { - /* check for valid magic number */ - png_byte magic[8]; - if (fread (magic, 1, 8, png_file) != 8) - { - png_destroy_read_struct(&png_ptr,&info_ptr,NULL); - return NULL; - } - - if (png_sig_cmp (magic, 0, 8)) - { - png_destroy_read_struct(&png_ptr,&info_ptr,NULL); - return NULL; - } - - /* set IO callback for read function */ - png_init_io (png_ptr, png_file); - png_set_sig_bytes (png_ptr, 8); - } - else - { - png_destroy_read_struct(&png_ptr,&info_ptr,NULL); - return NULL; - } - - /* read png info */ - png_read_info(png_ptr,info_ptr); - - /* retrieve image information */ - u32 width = png_get_image_width(png_ptr,info_ptr); - u32 height = png_get_image_height(png_ptr,info_ptr); - u32 bit_depth = png_get_bit_depth(png_ptr,info_ptr); - u32 color_type = png_get_color_type(png_ptr,info_ptr); - - /* ensure PNG file is in the supported format */ - if (png_file) - { - /* support for RGBA8 textures ONLY !*/ - if ((color_type != PNG_COLOR_TYPE_RGB_ALPHA) || (bit_depth != 8)) - { - png_destroy_read_struct(&png_ptr, &info_ptr,NULL); - return NULL; - } - - /* 4x4 tiles are required */ - if ((width%4) || (height%4)) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return NULL; - } - } - - /* allocate memory to store raw image data */ - u32 stride = width << 2; - u8 *img_data = memalign (32, stride * height); - if (!img_data) - { - png_destroy_read_struct(&png_ptr,&info_ptr,NULL); - return NULL; - } - - /* allocate row pointer data */ - png_bytep *row_pointers = (png_bytep *)memalign (32, sizeof (png_bytep) * height); - if (!row_pointers) - { - free (img_data); - png_destroy_read_struct(&png_ptr,&info_ptr,NULL); - return NULL; - } - - /* store raw image data */ - for (i = 0; i < height; i++) - { - row_pointers[i] = img_data + (i * stride); - } - - /* decode image */ - png_read_image(png_ptr, row_pointers); - - /* finish decompression and release memory */ - png_read_end(png_ptr, NULL); - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - free(row_pointers); - - /* initialize texture */ - gx_texture *texture = (gx_texture *)memalign(32, sizeof(gx_texture)); - if (!texture) - { - free (img_data); - return NULL; - } - - /* initialize texture data */ - texture->data = memalign(32, stride * height); - if (!texture->data) - { - free (img_data); - free(texture); - return NULL; - } - - memset(texture->data, 0, stride * height); - texture->width = width; - texture->height = height; - texture->format = GX_TF_RGBA8; - - /* encode to GX_TF_RGBA8 format (4x4 pixels paired titles) */ - u16 *dst_ar = (u16 *)(texture->data); - u16 *dst_gb = (u16 *)(texture->data + 32); - u32 *src1 = (u32 *)(img_data); - u32 *src2 = (u32 *)(img_data + stride); - u32 *src3 = (u32 *)(img_data + 2*stride); - u32 *src4 = (u32 *)(img_data + 3*stride); - u32 pixel,h,w; - - for (h=0; h> 24) & 0x00ff); - *dst_gb++= (pixel >> 8) & 0xffff; - } - - /* line N + 1 (4 pixels) */ - for (i=0; i<4; i++) - { - pixel = *src2++; - *dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff); - *dst_gb++= (pixel >> 8) & 0xffff; - } - - /* line N + 2 (4 pixels) */ - for (i=0; i<4; i++) - { - pixel = *src3++; - *dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff); - *dst_gb++= (pixel >> 8) & 0xffff; - } - - /* line N + 3 (4 pixels) */ - for (i=0; i<4; i++) - { - pixel = *src4++; - *dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff); - *dst_gb++= (pixel >> 8) & 0xffff; - } - - /* next paired tiles */ - dst_ar += 16; - dst_gb += 16; - } - - /* next 4 lines */ - src1 = src4; - src2 = src1 + width; - src3 = src2 + width; - src4 = src3 + width; - } - - /* release memory */ - free(img_data); - - /* flush texture data from cache */ - DCFlushRange(texture->data, height * stride); - - return texture; -} - -/* Write RGBA8 Texture to PNG file */ -void gxTextureWritePNG(gx_texture *texture, FILE *png_file) -{ - /* allocate PNG data buffer */ - u8 *img_data = (u8 *)memalign(32, texture->width * texture->height * 4); - if(!img_data) return; - - /* decode GX_TF_RGBA8 format (4x4 pixels paired titles) */ - u16 *ar = (u16 *)(texture->data); - u16 *gb = (u16 *)(texture->data + 32); - u32 *dst1 = (u32 *)(img_data); - u32 *dst2 = dst1 + texture->width; - u32 *dst3 = dst2 + texture->width; - u32 *dst4 = dst3 + texture->width; - u32 i,h,w,pixel; - - for (h=0; hheight; h+=4) - { - for (w=0; wwidth; w+=4) - { - /* line N (4 pixels) */ - for (i=0; i<4; i++) - { - pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); - *dst1++ = pixel; - ar++; - gb++; - } - - /* line N + 1 (4 pixels) */ - for (i=0; i<4; i++) - { - pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); - *dst2++ = pixel; - ar++; - gb++; - } - - /* line N + 2 (4 pixels) */ - for (i=0; i<4; i++) - { - pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); - *dst3++ = pixel; - ar++; - gb++; - } - - /* line N + 3 (4 pixels) */ - for (i=0; i<4; i++) - { - pixel = ((*ar & 0xff) << 24) | (*gb << 8) | ((*ar & 0xff00) >> 8); - *dst4++ = pixel; - ar++; - gb++; - } - - /* next paired tiles */ - ar += 16; - gb += 16; - } - - /* next 4 lines */ - dst1 = dst4; - dst2 = dst1 + texture->width; - dst3 = dst2 + texture->width; - dst4 = dst3 + texture->width; - } - - /* create a png write struct */ - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if(!png_ptr) - { - free(img_data); - return; - } - - /* create a png info struct */ - png_infop info_ptr = png_create_info_struct (png_ptr); - if (!info_ptr) - { - free(img_data); - png_destroy_write_struct(&png_ptr, NULL); - return; - } - - /* set IO callback for the write function */ - png_init_io(png_ptr, png_file); - - /* set PNG file properties */ - png_set_IHDR(png_ptr, info_ptr, texture->width, texture->height, 8, PNG_COLOR_TYPE_RGB_ALPHA, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - /* allocate row pointer data */ - png_bytep *row_pointers = (png_bytep *)memalign (32, sizeof (png_bytep) * texture->height); - if (!row_pointers) - { - free (img_data); - png_destroy_write_struct(&png_ptr, &info_ptr); - return; - } - - /* store raw image data */ - for (i = 0; i < texture->height; i++) - { - row_pointers[i] = img_data + (i * texture->width * 4); - } - - /* configure libpng for image data */ - png_set_rows(png_ptr,info_ptr,row_pointers); - - /* write data to PNG file */ - png_write_png(png_ptr,info_ptr,PNG_TRANSFORM_IDENTITY,NULL); - - /* finish compression and release memory */ - png_write_end(png_ptr, NULL); - free(row_pointers); - free(img_data); - png_destroy_write_struct(&png_ptr, &info_ptr); -} - - -void gxTextureClose(gx_texture **p_texture) -{ - gx_texture *texture = *p_texture; - - if (texture) - { - if (texture->data) free(texture->data); - free(texture); - *p_texture = NULL; - } -} - - -/***************************************************************************************/ -/* VIDEO engine */ -/***************************************************************************************/ - -/* Emulation mode -> Menu mode */ -void gx_video_Stop(void) -{ - /* wait for next VBLANK */ - VIDEO_WaitVSync (); - - /* unallocate NTSC filters */ - if (sms_ntsc) free(sms_ntsc); - if (md_ntsc) free(md_ntsc); - sms_ntsc = NULL; - md_ntsc = NULL; - - /* lightgun textures */ - gxTextureClose(&crosshair[0]); - gxTextureClose(&crosshair[1]); - - /* CD leds textures */ - gxTextureClose(&cd_leds[0][0]); - gxTextureClose(&cd_leds[0][1]); - gxTextureClose(&cd_leds[1][0]); - gxTextureClose(&cd_leds[1][1]); - - /* GX menu rendering */ - gxResetRendering(1); - gxResetMode(vmode, GX_TRUE); - - /* render game snapshot */ - gxClearScreen((GXColor)BLACK); - gxDrawScreenshot(0xff); - - /* default VI settings */ - VIDEO_SetPostRetraceCallback(NULL); -#ifdef HW_RVL - VIDEO_SetTrapFilter(1); - VIDEO_SetGamma(VI_GM_1_0); -#endif - - /* adjust TV width */ - vmode->viWidth = config.screen_w; - vmode->viXOrigin = (VI_MAX_WIDTH_NTSC - vmode->viWidth)/2; - VIDEO_Configure(vmode); - - /* wait for VSYNC */ - gxSetScreen(); -} - -/* Menu mode -> Emulation mode */ -void gx_video_Start(void) -{ -#ifdef HW_RVL - VIDEO_SetTrapFilter(config.trap); - VIDEO_SetGamma((int)(config.gamma * 10.0)); -#endif - - /* TV mode */ - if ((config.tv_mode == 1) || ((config.tv_mode == 2) && vdp_pal)) - { - /* 50 Hz */ - gc_pal = 1; - } - else - { - /* 60 Hz */ - gc_pal = 0; - } - - /* When VSYNC is set to AUTO & console TV mode matches emulated video mode, emulation is synchronized with video hardware as well */ - if (config.vsync && (gc_pal == vdp_pal)) - { - /* VSYNC callback */ - VIDEO_SetPostRetraceCallback(vi_callback); - VIDEO_Flush(); - videoSync = audioSync; - } - else - { - videoSync = 0; - } - - /* Enable progressive or interlaced video mode */ - if (config.render == 2) - { - /* 480p */ - tvmodes[2]->viTVMode = (tvmodes[2]->viTVMode & ~3) | VI_PROGRESSIVE; - tvmodes[2]->xfbMode = VI_XFBMODE_SF; - - /* 576p */ - tvmodes[5]->viTVMode = VI_TVMODE_PAL_PROG; - tvmodes[5]->xfbMode = VI_XFBMODE_SF; - } - else if (config.render == 1) - { - /* 480i */ - tvmodes[2]->viTVMode = (tvmodes[2]->viTVMode & ~3) | VI_INTERLACE; - tvmodes[2]->xfbMode = VI_XFBMODE_DF; - - /* 576i */ - tvmodes[5]->viTVMode = VI_TVMODE_PAL_INT; - tvmodes[5]->xfbMode = VI_XFBMODE_DF; - } - - /* update horizontal border width */ - if ((system_hw == SYSTEM_GG) && !config.gg_extra) - { - bitmap.viewport.x = (config.overscan & 2) ? 14 : -48; - } - else - { - bitmap.viewport.x = (config.overscan & 2) * 7; - } - - /* force viewport update */ - bitmap.viewport.changed = 3; - - /* NTSC filter */ - if (config.ntsc) - { - /* allocate filters */ - if (!sms_ntsc) - { - sms_ntsc = (sms_ntsc_t *)memalign(32,sizeof(sms_ntsc_t)); - } - if (!md_ntsc) - { - md_ntsc = (md_ntsc_t *)memalign(32,sizeof(md_ntsc_t)); - } - - /* setup filters default configuration */ - switch (config.ntsc) - { - case 1: - sms_ntsc_init(sms_ntsc, &sms_ntsc_composite); - md_ntsc_init(md_ntsc, &md_ntsc_composite); - break; - case 2: - sms_ntsc_init(sms_ntsc, &sms_ntsc_svideo); - md_ntsc_init(md_ntsc, &md_ntsc_svideo); - break; - case 3: - sms_ntsc_init(sms_ntsc, &sms_ntsc_rgb); - md_ntsc_init(md_ntsc, &md_ntsc_rgb); - break; - } - } - - /* on-screen display enable flag */ - osd = config.fps; - - /* clear any on-screen text */ - memset(msg, 0, sizeof(msg)); - - /* lightgun textures */ - int i, player = 0; - for (i=0; i= 0) - { - if ((i == 0) || ((i == 4) && (input.system[1] != SYSTEM_LIGHTPHASER))) - { - /* Lightgun #1 */ - if (config.gun_cursor[0]) - { - crosshair[0] = gxTextureOpenPNG(Crosshair_p1_png,0); - osd = 1; - } - } - else - { - /* Lightgun #2 */ - if (config.gun_cursor[1]) - { - crosshair[1] = gxTextureOpenPNG(Crosshair_p2_png,0); - osd = 1; - } - } - } - } - - /* Check for any emulated device */ - if (input.dev[i] != NO_DEVICE) - { - /* increment player index */ - player++; - } - } - - /* CD leds textures */ - if (system_hw == SYSTEM_MCD) - { - if (config.cd_leds) - { - cd_leds[0][0] = gxTextureOpenPNG(CD_access_off_png,0); - cd_leds[0][1] = gxTextureOpenPNG(CD_access_on_png,0); - cd_leds[1][0] = gxTextureOpenPNG(CD_ready_off_png,0); - cd_leds[1][1] = gxTextureOpenPNG(CD_ready_on_png,0); - osd = 1; - } - } - - /* GX emulation rendering */ - gxResetRendering(0); - - /* resynchronize emulation with VSYNC */ - VIDEO_WaitVSync(); - - /* restart frame sync */ - videoWait = 0; - frameCount = 0; - starttime = gettime(); -} - -/* GX render update */ -int gx_video_Update(u32 done) -{ - if (videoWait || done) return SYNC_WAIT; - - videoWait = videoSync; - - /* check if display has changed during frame */ - if (bitmap.viewport.changed & 1) - { - /* update texture size */ - vwidth = bitmap.viewport.w + (2 * bitmap.viewport.x); - vheight = bitmap.viewport.h + (2 * bitmap.viewport.y); - - /* interlaced mode */ - if (config.render && interlaced) - { - vheight = vheight << 1; - } - - /* ntsc filter */ - if (config.ntsc) - { - vwidth = (reg[12] & 1) ? MD_NTSC_OUT_WIDTH(vwidth) : SMS_NTSC_OUT_WIDTH(vwidth); - - /* texel width must remain multiple of 4 */ - vwidth = (vwidth >> 2) << 2; - } - - /* initialize texture object */ - GXTexObj texobj; - GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); - - /* configure texture filtering */ - if (!config.bilinear) - { - GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); - } - - /* load texture object */ - GX_LoadTexObj(&texobj, GX_TEXMAP0); - - /* update rendering mode */ - if (config.render) - { - rmode = tvmodes[gc_pal*3 + 2]; - } - else - { - rmode = tvmodes[gc_pal*3 + interlaced]; - } - - /* update aspect ratio */ - gxResetScaler(vwidth); - - /* update GX rendering mode */ - gxResetMode(rmode, config.vfilter); - - /* update VI mode */ - VIDEO_Configure(rmode); - } - - /* texture is now directly mapped by the line renderer */ - - /* force texture cache update */ - DCFlushRange(texturemem, TEX_SIZE); - GX_InvalidateTexAll(); - - /* render textured quad */ - GX_CallDispList(d_list, 32); - - /* on-screen display */ - if (osd) - { - /* reset GX rendering */ - gxResetRendering(1); - - /* lightgun # 1 screen mark */ - if (crosshair[0]) - { - if (input.system[0] == SYSTEM_LIGHTPHASER) - { - gxDrawCrosshair(crosshair[0], input.analog[0][0],input.analog[0][1]); - } - else - { - gxDrawCrosshair(crosshair[0], input.analog[4][0],input.analog[4][1]); - } - } - - /* lightgun #2 screen mark */ - if (crosshair[1]) - { - if (input.system[1] == SYSTEM_LIGHTPHASER) - { - gxDrawCrosshair(crosshair[1], input.analog[4][0],input.analog[4][1]); - } - else - { - gxDrawCrosshair(crosshair[1], input.analog[5][0],input.analog[5][1]); - } - } - - /* CD LEDS */ - if (cd_leds[1][1]) - { - /* CD LEDS status */ - u8 mode = scd.regs[0x06 >> 1].byte.h; - gxDrawCdLeds(cd_leds[1][(mode >> 1) & 1], cd_leds[0][mode & 1]); - } - - /* FPS counter */ - if (config.fps) - { - u32 delta = diff_usec(starttime, gettime()); - frameCount++; - if (delta > 1000000) - { - sprintf(msg,"%3.2f FPS", (float)frameCount * 1000000.0 / (float)delta); - frameCount = 0; - starttime = gettime(); - } - - /* disable EFB alpha blending for text background */ - GX_SetBlendMode(GX_BM_NONE,GX_BL_SRCALPHA,GX_BL_INVSRCALPHA,GX_LO_CLEAR); - GX_Flush(); - - gxDrawOnScreenText(msg); - } - - /* restore GX rendering */ - gxResetRendering(0); - - /* restore texture object */ - GXTexObj texobj; - GX_InitTexObj(&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); - if (!config.bilinear) - { - GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,0.0,10.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); - } - GX_LoadTexObj(&texobj, GX_TEXMAP0); - GX_InvalidateTexAll(); - } - - /* swap XFB */ - whichfb ^= 1; - - /* copy EFB to XFB */ - GX_DrawDone(); - GX_CopyDisp(xfb[whichfb], GX_TRUE); - GX_Flush(); - - /* XFB is ready to be displayed */ - VIDEO_SetNextFramebuffer(xfb[whichfb]); - VIDEO_Flush(); - - if (bitmap.viewport.changed & 1) - { - /* clear update flags */ - bitmap.viewport.changed &= ~1; - - /* field synchronization */ - VIDEO_WaitVSync(); - if (rmode->viTVMode & VI_NON_INTERLACE) - { - VIDEO_WaitVSync(); - } - else while (VIDEO_GetNextField() != odd_frame) - { - VIDEO_WaitVSync(); - } - - /* Audio DMA need to be resynchronized with VSYNC */ - audioStarted = 0; - } - - return SYNC_VIDEO; -} - -/* Initialize VIDEO subsystem */ -void gx_video_Init(void) -{ - /* - * Before doing anything else under libogc, - * Call VIDEO_Init - */ - VIDEO_Init(); - - /* Get the current VIDEO mode then : - - set menu video mode (480p/576p/480i/576i) - - set emulator rendering 60hz TV modes (MPAL/NTSC/EURGB60) - */ - vmode = VIDEO_GetPreferredMode(NULL); - - /* Adjust display settings */ - switch (vmode->viTVMode >> 2) - { - case VI_PAL: /* 576 lines scaled (PAL 50Hz) */ - TV60hz_240p.viTVMode = VI_TVMODE_EURGB60_DS; - TV60hz_240i.viTVMode = VI_TVMODE_EURGB60_INT; - TV60hz_480i.viTVMode = VI_TVMODE_EURGB60_INT; - break; - - default: /* 480 lines (NTSC, MPAL or PAL 60Hz) */ - TV60hz_240p.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_NON_INTERLACE); - TV60hz_240i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE); - TV60hz_480i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE); - break; - } - - /* Configure VI */ - VIDEO_Configure (vmode); - - /* Configure the framebuffers (double-buffering) */ - xfb[0] = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i)); - xfb[1] = (u32 *) MEM_K0_TO_K1((u32 *) SYS_AllocateFramebuffer(&TV50hz_576i)); - - /* Define a console */ - console_init(xfb[0], 20, 64, 640, 574, 574 * 2); - - /* Clear framebuffers to black */ - VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK); - VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK); - - /* Set the framebuffer to be displayed at next VBlank */ - VIDEO_SetNextFramebuffer(xfb[0]); - - /* Enable Video Interface */ - VIDEO_SetBlack(FALSE); - - /* Update VIDEO settings for next VBlank */ - VIDEO_Flush(); - - /* Wait for VBlank */ - VIDEO_WaitVSync(); - VIDEO_WaitVSync(); - - /* Initialize GX */ - gxStart(); - gxResetRendering(1); - gxResetMode(vmode, GX_TRUE); - - /* initialize FONT */ - FONT_Init(); - - /* Initialize textures */ - texturemem = memalign(32, TEX_SIZE); - screenshot = memalign(32, HASPECT*VASPECT*4); -} - -void gx_video_Shutdown(void) -{ - if (texturemem) free(texturemem); - if (screenshot) free(screenshot); - FONT_Shutdown(); - VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK); - VIDEO_Flush(); - VIDEO_WaitVSync(); -} - -/* Custom NTSC blitters */ -typedef unsigned short sms_ntsc_out_t; -typedef unsigned short md_ntsc_out_t; - -void sms_ntsc_blit( sms_ntsc_t const* ntsc, SMS_NTSC_IN_T const* table, unsigned char* input, - int in_width, int vline) -{ - int const chunk_count = in_width / sms_ntsc_in_chunk; - - /* handle extra 0, 1, or 2 pixels by placing them at beginning of row */ - int const in_extra = in_width - chunk_count * sms_ntsc_in_chunk; - unsigned const extra2 = (unsigned) -(in_extra >> 1 & 1); /* (unsigned) -1 = ~0 */ - unsigned const extra1 = (unsigned) -(in_extra & 1) | extra2; - - /* use palette entry 0 for unused pixels */ - SMS_NTSC_IN_T border = table[0]; - - SMS_NTSC_BEGIN_ROW( ntsc, border, - (SMS_NTSC_ADJ_IN( table[input[0]] )) & extra2, - (SMS_NTSC_ADJ_IN( table[input[extra2 & 1]] )) & extra1 ); - - /* directly fill the RGB565 texture */ - /* one tile is 32 byte = 4x4 pixels */ - /* tiles are stored continuously in texture memory */ - in_width = SMS_NTSC_OUT_WIDTH(in_width) / 4; - int offset = ((in_width * 32) * (vline / 4)) + ((vline & 3) * 8); - sms_ntsc_out_t* __restrict__ line_out = (sms_ntsc_out_t*)(texturemem + offset); - offset = 0; - - int n; - input += in_extra; - - for ( n = chunk_count; n; --n ) - { - /* order of input and output pixels must not be altered */ - SMS_NTSC_COLOR_IN( 0, ntsc, SMS_NTSC_ADJ_IN( table[*input++] ) ); - SMS_NTSC_RGB_OUT( 0, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 1, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - - SMS_NTSC_COLOR_IN( 1, ntsc, SMS_NTSC_ADJ_IN( table[*input++] ) ); - SMS_NTSC_RGB_OUT( 2, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 3, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - - SMS_NTSC_COLOR_IN( 2, ntsc, SMS_NTSC_ADJ_IN( table[*input++] ) ); - SMS_NTSC_RGB_OUT( 4, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 5, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 6, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - } - - /* finish final pixels */ - SMS_NTSC_COLOR_IN( 0, ntsc, border ); - SMS_NTSC_RGB_OUT( 0, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 1, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - - SMS_NTSC_COLOR_IN( 1, ntsc, border ); - SMS_NTSC_RGB_OUT( 2, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 3, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - - SMS_NTSC_COLOR_IN( 2, ntsc, border ); - SMS_NTSC_RGB_OUT( 4, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 5, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; - SMS_NTSC_RGB_OUT( 6, line_out[offset++] ); - if ((offset % 4) == 0) offset += 12; -} - -void md_ntsc_blit( md_ntsc_t const* ntsc, MD_NTSC_IN_T const* table, unsigned char* input, - int in_width, int vline) -{ - int const chunk_count = in_width / md_ntsc_in_chunk - 1; - - /* use palette entry 0 for unused pixels */ - MD_NTSC_IN_T border = table[0]; - - MD_NTSC_BEGIN_ROW( ntsc, border, - MD_NTSC_ADJ_IN( table[*input++] ), - MD_NTSC_ADJ_IN( table[*input++] ), - MD_NTSC_ADJ_IN( table[*input++] ) ); - - /* directly fill the RGB565 texture */ - /* one tile is 32 byte = 4x4 pixels */ - /* tiles are stored continuously in texture memory */ - in_width = MD_NTSC_OUT_WIDTH(in_width) >> 2; - int offset = ((in_width << 5) * (vline >> 2)) + ((vline & 3) * 8); - md_ntsc_out_t* __restrict__ line_out = (md_ntsc_out_t*)(texturemem + offset); - - int n; - - for ( n = chunk_count; n; --n ) - { - /* order of input and output pixels must not be altered */ - MD_NTSC_COLOR_IN( 0, ntsc, MD_NTSC_ADJ_IN( table[*input++] ) ); - MD_NTSC_RGB_OUT( 0, *line_out++ ); - MD_NTSC_RGB_OUT( 1, *line_out++ ); - - MD_NTSC_COLOR_IN( 1, ntsc, MD_NTSC_ADJ_IN( table[*input++] ) ); - MD_NTSC_RGB_OUT( 2, *line_out++ ); - MD_NTSC_RGB_OUT( 3, *line_out++ ); - - line_out += 12; - - MD_NTSC_COLOR_IN( 2, ntsc, MD_NTSC_ADJ_IN( table[*input++] ) ); - MD_NTSC_RGB_OUT( 4, *line_out++ ); - MD_NTSC_RGB_OUT( 5, *line_out++ ); - - MD_NTSC_COLOR_IN( 3, ntsc, MD_NTSC_ADJ_IN( table[*input++] ) ); - MD_NTSC_RGB_OUT( 6, *line_out++ ); - MD_NTSC_RGB_OUT( 7, *line_out++ ); - - line_out += 12; -} - - /* finish final pixels */ - MD_NTSC_COLOR_IN( 0, ntsc, MD_NTSC_ADJ_IN( table[*input++] ) ); - MD_NTSC_RGB_OUT( 0, *line_out++ ); - MD_NTSC_RGB_OUT( 1, *line_out++ ); - - MD_NTSC_COLOR_IN( 1, ntsc, border ); - MD_NTSC_RGB_OUT( 2, *line_out++ ); - MD_NTSC_RGB_OUT( 3, *line_out++ ); - - line_out += 12; - - MD_NTSC_COLOR_IN( 2, ntsc, border ); - MD_NTSC_RGB_OUT( 4, *line_out++ ); - MD_NTSC_RGB_OUT( 5, *line_out++ ); - - MD_NTSC_COLOR_IN( 3, ntsc, border ); - MD_NTSC_RGB_OUT( 6, *line_out++ ); - MD_NTSC_RGB_OUT( 7, *line_out++ ); -} diff --git a/genplus-gx/gx/gx_video.h b/genplus-gx/gx/gx_video.h deleted file mode 100644 index d069bffbdd..0000000000 --- a/genplus-gx/gx/gx_video.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** - * gx_video.c - * - * Genesis Plus GX video support - * - * Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _GC_VIDEO_H_ -#define _GC_VIDEO_H_ - -/* EFB colors */ -#define BLACK {0x00,0x00,0x00,0xff} -#define DARK_GREY {0x22,0x22,0x22,0xff} -#define LIGHT_BLUE {0xb8,0xc7,0xda,0xff} -#define SKY_BLUE {0x99,0xcc,0xff,0xff} -#define LIGHT_GREEN {0xa9,0xc7,0xc6,0xff} -#define WHITE {0xff,0xff,0xff,0xff} - -/* Directly fill a RGB565 texture */ -/* One tile is 32 byte = 4x4 pixels */ -/* Tiles are stored continuously in texture memory */ -#define CUSTOM_BLITTER(line, width, table, in) \ - width >>= 2; \ - u16 *out = (u16 *) (texturemem + (((width << 5) * (line >> 2)) + ((line & 3) << 3))); \ - do \ - { \ - *out++ = table[*in++]; \ - *out++ = table[*in++]; \ - *out++ = table[*in++]; \ - *out++ = table[*in++]; \ - out += 12; \ - } \ - while (--width); - -/* image texture */ -typedef struct -{ - u8 *data; - u16 width; - u16 height; - u8 format; -} gx_texture; - -/* Global variables */ -extern GXRModeObj *vmode; -extern u8 *texturemem; -extern u32 gc_pal; -extern u32 videoSync; - -/* GX rendering */ -extern void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color); -extern void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha); -extern void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha); -extern void gxDrawTextureRotate(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, f32 angle, u8 alpha); -extern void gxDrawScreenshot(u8 alpha); -extern void gxCopyScreenshot(gx_texture *texture); -extern void gxSaveScreenshot(char *filename); -extern void gxClearScreen(GXColor color); -extern void gxSetScreen(void); - -/* PNG textures */ -extern gx_texture *gxTextureOpenPNG(const u8 *png_data, FILE *png_file); -extern void gxTextureWritePNG(gx_texture *p_texture, FILE *png_file); -extern void gxTextureClose(gx_texture **p_texture); - -/* GX video engine */ -extern void gx_video_Init(void); -extern void gx_video_Shutdown(void); -extern void gx_video_Start(void); -extern void gx_video_Stop(void); -extern int gx_video_Update(u32 done); - -#endif diff --git a/genplus-gx/gx/images/Banner_bottom.png b/genplus-gx/gx/images/Banner_bottom.png deleted file mode 100644 index 85545b1a16..0000000000 Binary files a/genplus-gx/gx/images/Banner_bottom.png and /dev/null differ diff --git a/genplus-gx/gx/images/Banner_main.png b/genplus-gx/gx/images/Banner_main.png deleted file mode 100644 index ee11383b8e..0000000000 Binary files a/genplus-gx/gx/images/Banner_main.png and /dev/null differ diff --git a/genplus-gx/gx/images/Banner_top.png b/genplus-gx/gx/images/Banner_top.png deleted file mode 100644 index 1ac9b04316..0000000000 Binary files a/genplus-gx/gx/images/Banner_top.png and /dev/null differ diff --git a/genplus-gx/gx/images/Bg_credits.png b/genplus-gx/gx/images/Bg_credits.png deleted file mode 100644 index 9f8c4c519a..0000000000 Binary files a/genplus-gx/gx/images/Bg_credits.png and /dev/null differ diff --git a/genplus-gx/gx/images/Bg_intro_c1.png b/genplus-gx/gx/images/Bg_intro_c1.png deleted file mode 100644 index d285f63fcd..0000000000 Binary files a/genplus-gx/gx/images/Bg_intro_c1.png and /dev/null differ diff --git a/genplus-gx/gx/images/Bg_intro_c2.png b/genplus-gx/gx/images/Bg_intro_c2.png deleted file mode 100644 index ae9e40921f..0000000000 Binary files a/genplus-gx/gx/images/Bg_intro_c2.png and /dev/null differ diff --git a/genplus-gx/gx/images/Bg_intro_c3.png b/genplus-gx/gx/images/Bg_intro_c3.png deleted file mode 100644 index f382e73b0c..0000000000 Binary files a/genplus-gx/gx/images/Bg_intro_c3.png and /dev/null differ diff --git a/genplus-gx/gx/images/Bg_intro_c4.png b/genplus-gx/gx/images/Bg_intro_c4.png deleted file mode 100644 index 97883686dc..0000000000 Binary files a/genplus-gx/gx/images/Bg_intro_c4.png and /dev/null differ diff --git a/genplus-gx/gx/images/Bg_layer.png b/genplus-gx/gx/images/Bg_layer.png deleted file mode 100644 index b37186ea9a..0000000000 Binary files a/genplus-gx/gx/images/Bg_layer.png and /dev/null differ diff --git a/genplus-gx/gx/images/Bg_overlay.png b/genplus-gx/gx/images/Bg_overlay.png deleted file mode 100644 index 3bf6be7356..0000000000 Binary files a/genplus-gx/gx/images/Bg_overlay.png and /dev/null differ diff --git a/genplus-gx/gx/images/Browser_dir.png b/genplus-gx/gx/images/Browser_dir.png deleted file mode 100644 index e4becfdbd3..0000000000 Binary files a/genplus-gx/gx/images/Browser_dir.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_arrow.png b/genplus-gx/gx/images/Button_arrow.png deleted file mode 100644 index 7ddab41ade..0000000000 Binary files a/genplus-gx/gx/images/Button_arrow.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_arrow_over.png b/genplus-gx/gx/images/Button_arrow_over.png deleted file mode 100644 index e62a59d535..0000000000 Binary files a/genplus-gx/gx/images/Button_arrow_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_delete.png b/genplus-gx/gx/images/Button_delete.png deleted file mode 100644 index 8b36501854..0000000000 Binary files a/genplus-gx/gx/images/Button_delete.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_delete_over.png b/genplus-gx/gx/images/Button_delete_over.png deleted file mode 100644 index 09500d4362..0000000000 Binary files a/genplus-gx/gx/images/Button_delete_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_digit.png b/genplus-gx/gx/images/Button_digit.png deleted file mode 100644 index e4d47b5917..0000000000 Binary files a/genplus-gx/gx/images/Button_digit.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_digit_over.png b/genplus-gx/gx/images/Button_digit_over.png deleted file mode 100644 index 20d5a47d81..0000000000 Binary files a/genplus-gx/gx/images/Button_digit_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_down.png b/genplus-gx/gx/images/Button_down.png deleted file mode 100644 index d57a41b5aa..0000000000 Binary files a/genplus-gx/gx/images/Button_down.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_down_over.png b/genplus-gx/gx/images/Button_down_over.png deleted file mode 100644 index 22860db3c7..0000000000 Binary files a/genplus-gx/gx/images/Button_down_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_icon.png b/genplus-gx/gx/images/Button_icon.png deleted file mode 100644 index bb89bf530e..0000000000 Binary files a/genplus-gx/gx/images/Button_icon.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_icon_over.png b/genplus-gx/gx/images/Button_icon_over.png deleted file mode 100644 index 1a6c51fa9e..0000000000 Binary files a/genplus-gx/gx/images/Button_icon_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_icon_sm.png b/genplus-gx/gx/images/Button_icon_sm.png deleted file mode 100644 index 307580db08..0000000000 Binary files a/genplus-gx/gx/images/Button_icon_sm.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_icon_sm_over.png b/genplus-gx/gx/images/Button_icon_sm_over.png deleted file mode 100644 index 934bac8603..0000000000 Binary files a/genplus-gx/gx/images/Button_icon_sm_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_load.png b/genplus-gx/gx/images/Button_load.png deleted file mode 100644 index a9ac2adb47..0000000000 Binary files a/genplus-gx/gx/images/Button_load.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_load_over.png b/genplus-gx/gx/images/Button_load_over.png deleted file mode 100644 index 44469c4a5c..0000000000 Binary files a/genplus-gx/gx/images/Button_load_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_save.png b/genplus-gx/gx/images/Button_save.png deleted file mode 100644 index 11040f059d..0000000000 Binary files a/genplus-gx/gx/images/Button_save.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_save_over.png b/genplus-gx/gx/images/Button_save_over.png deleted file mode 100644 index 7d1d50012b..0000000000 Binary files a/genplus-gx/gx/images/Button_save_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_sm_blue.png b/genplus-gx/gx/images/Button_sm_blue.png deleted file mode 100644 index 72ee4384fb..0000000000 Binary files a/genplus-gx/gx/images/Button_sm_blue.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_sm_grey.png b/genplus-gx/gx/images/Button_sm_grey.png deleted file mode 100644 index 346a43d448..0000000000 Binary files a/genplus-gx/gx/images/Button_sm_grey.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_sm_yellow.png b/genplus-gx/gx/images/Button_sm_yellow.png deleted file mode 100644 index 68cc1eae2e..0000000000 Binary files a/genplus-gx/gx/images/Button_sm_yellow.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_special.png b/genplus-gx/gx/images/Button_special.png deleted file mode 100644 index 0ef9c75a90..0000000000 Binary files a/genplus-gx/gx/images/Button_special.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_special_over.png b/genplus-gx/gx/images/Button_special_over.png deleted file mode 100644 index fe7d7298e4..0000000000 Binary files a/genplus-gx/gx/images/Button_special_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_text.png b/genplus-gx/gx/images/Button_text.png deleted file mode 100644 index 5d4ca9b007..0000000000 Binary files a/genplus-gx/gx/images/Button_text.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_text_over.png b/genplus-gx/gx/images/Button_text_over.png deleted file mode 100644 index 1e6ad5b382..0000000000 Binary files a/genplus-gx/gx/images/Button_text_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_up.png b/genplus-gx/gx/images/Button_up.png deleted file mode 100644 index db35cbb352..0000000000 Binary files a/genplus-gx/gx/images/Button_up.png and /dev/null differ diff --git a/genplus-gx/gx/images/Button_up_over.png b/genplus-gx/gx/images/Button_up_over.png deleted file mode 100644 index df777b2f77..0000000000 Binary files a/genplus-gx/gx/images/Button_up_over.png and /dev/null differ diff --git a/genplus-gx/gx/images/CD_access_off.png b/genplus-gx/gx/images/CD_access_off.png deleted file mode 100644 index d7e5f79308..0000000000 Binary files a/genplus-gx/gx/images/CD_access_off.png and /dev/null differ diff --git a/genplus-gx/gx/images/CD_access_on.png b/genplus-gx/gx/images/CD_access_on.png deleted file mode 100644 index 3dbaa1b0fd..0000000000 Binary files a/genplus-gx/gx/images/CD_access_on.png and /dev/null differ diff --git a/genplus-gx/gx/images/CD_ready_off.png b/genplus-gx/gx/images/CD_ready_off.png deleted file mode 100644 index b13a8711a5..0000000000 Binary files a/genplus-gx/gx/images/CD_ready_off.png and /dev/null differ diff --git a/genplus-gx/gx/images/CD_ready_on.png b/genplus-gx/gx/images/CD_ready_on.png deleted file mode 100644 index c4865963e1..0000000000 Binary files a/genplus-gx/gx/images/CD_ready_on.png and /dev/null differ diff --git a/genplus-gx/gx/images/Cart_gg.png b/genplus-gx/gx/images/Cart_gg.png deleted file mode 100644 index b96cfb9b40..0000000000 Binary files a/genplus-gx/gx/images/Cart_gg.png and /dev/null differ diff --git a/genplus-gx/gx/images/Cart_md.png b/genplus-gx/gx/images/Cart_md.png deleted file mode 100644 index ee9e99cbbe..0000000000 Binary files a/genplus-gx/gx/images/Cart_md.png and /dev/null differ diff --git a/genplus-gx/gx/images/Cart_ms.png b/genplus-gx/gx/images/Cart_ms.png deleted file mode 100644 index 4de57a935c..0000000000 Binary files a/genplus-gx/gx/images/Cart_ms.png and /dev/null differ diff --git a/genplus-gx/gx/images/Cart_sg.png b/genplus-gx/gx/images/Cart_sg.png deleted file mode 100644 index d52bc23007..0000000000 Binary files a/genplus-gx/gx/images/Cart_sg.png and /dev/null differ diff --git a/genplus-gx/gx/images/Crosshair_p1.png b/genplus-gx/gx/images/Crosshair_p1.png deleted file mode 100644 index eb5aa1cc6b..0000000000 Binary files a/genplus-gx/gx/images/Crosshair_p1.png and /dev/null differ diff --git a/genplus-gx/gx/images/Crosshair_p2.png b/genplus-gx/gx/images/Crosshair_p2.png deleted file mode 100644 index c942c11716..0000000000 Binary files a/genplus-gx/gx/images/Crosshair_p2.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_4wayplay.png b/genplus-gx/gx/images/Ctrl_4wayplay.png deleted file mode 100644 index 26663170cf..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_4wayplay.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_activator.png b/genplus-gx/gx/images/Ctrl_activator.png deleted file mode 100644 index b72cebca88..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_activator.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_config.png b/genplus-gx/gx/images/Ctrl_config.png deleted file mode 100644 index 1d6e1c4326..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_config.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_gamepad_md.png b/genplus-gx/gx/images/Ctrl_gamepad_md.png deleted file mode 100644 index 298b3520dc..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_gamepad_md.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_gamepad_ms.png b/genplus-gx/gx/images/Ctrl_gamepad_ms.png deleted file mode 100644 index 4428f41bec..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_gamepad_ms.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_justifiers.png b/genplus-gx/gx/images/Ctrl_justifiers.png deleted file mode 100644 index a2bee99f93..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_justifiers.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_lightphaser.png b/genplus-gx/gx/images/Ctrl_lightphaser.png deleted file mode 100644 index ebb223dce1..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_lightphaser.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_menacer.png b/genplus-gx/gx/images/Ctrl_menacer.png deleted file mode 100644 index 5de755a890..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_menacer.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_mouse.png b/genplus-gx/gx/images/Ctrl_mouse.png deleted file mode 100644 index 1888c1afbf..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_mouse.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_none.png b/genplus-gx/gx/images/Ctrl_none.png deleted file mode 100644 index 71ef75ee04..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_none.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_pad3b.png b/genplus-gx/gx/images/Ctrl_pad3b.png deleted file mode 100644 index 8f36c1aaef..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_pad3b.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_pad6b.png b/genplus-gx/gx/images/Ctrl_pad6b.png deleted file mode 100644 index f08bcff061..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_pad6b.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_paddle.png b/genplus-gx/gx/images/Ctrl_paddle.png deleted file mode 100644 index 45f5146a0b..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_paddle.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_sportspad.png b/genplus-gx/gx/images/Ctrl_sportspad.png deleted file mode 100644 index fa87f31adb..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_sportspad.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_teamplayer.png b/genplus-gx/gx/images/Ctrl_teamplayer.png deleted file mode 100644 index ab8706c41f..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_teamplayer.png and /dev/null differ diff --git a/genplus-gx/gx/images/Ctrl_xe_a1p.png b/genplus-gx/gx/images/Ctrl_xe_a1p.png deleted file mode 100644 index d0179fca6b..0000000000 Binary files a/genplus-gx/gx/images/Ctrl_xe_a1p.png and /dev/null differ diff --git a/genplus-gx/gx/images/Frame_s1.png b/genplus-gx/gx/images/Frame_s1.png deleted file mode 100644 index f4f1f27e4a..0000000000 Binary files a/genplus-gx/gx/images/Frame_s1.png and /dev/null differ diff --git a/genplus-gx/gx/images/Frame_s1_title.png b/genplus-gx/gx/images/Frame_s1_title.png deleted file mode 100644 index 1022718075..0000000000 Binary files a/genplus-gx/gx/images/Frame_s1_title.png and /dev/null differ diff --git a/genplus-gx/gx/images/Frame_s2.png b/genplus-gx/gx/images/Frame_s2.png deleted file mode 100644 index 191c6742a6..0000000000 Binary files a/genplus-gx/gx/images/Frame_s2.png and /dev/null differ diff --git a/genplus-gx/gx/images/Frame_s2_title.png b/genplus-gx/gx/images/Frame_s2_title.png deleted file mode 100644 index 05c8b237ae..0000000000 Binary files a/genplus-gx/gx/images/Frame_s2_title.png and /dev/null differ diff --git a/genplus-gx/gx/images/Frame_s3.png b/genplus-gx/gx/images/Frame_s3.png deleted file mode 100644 index c12f11c9dd..0000000000 Binary files a/genplus-gx/gx/images/Frame_s3.png and /dev/null differ diff --git a/genplus-gx/gx/images/Frame_throbber.png b/genplus-gx/gx/images/Frame_throbber.png deleted file mode 100644 index 98d5316fb8..0000000000 Binary files a/genplus-gx/gx/images/Frame_throbber.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_A_gcn.png b/genplus-gx/gx/images/Key_A_gcn.png deleted file mode 100644 index d95ade8104..0000000000 Binary files a/genplus-gx/gx/images/Key_A_gcn.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_A_wii.png b/genplus-gx/gx/images/Key_A_wii.png deleted file mode 100644 index 5cc2a470de..0000000000 Binary files a/genplus-gx/gx/images/Key_A_wii.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_B_gcn.png b/genplus-gx/gx/images/Key_B_gcn.png deleted file mode 100644 index 9e77da1f74..0000000000 Binary files a/genplus-gx/gx/images/Key_B_gcn.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_B_wii.png b/genplus-gx/gx/images/Key_B_wii.png deleted file mode 100644 index 99e7cfd634..0000000000 Binary files a/genplus-gx/gx/images/Key_B_wii.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_DPAD.png b/genplus-gx/gx/images/Key_DPAD.png deleted file mode 100644 index 1316cfd661..0000000000 Binary files a/genplus-gx/gx/images/Key_DPAD.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_L_gcn.png b/genplus-gx/gx/images/Key_L_gcn.png deleted file mode 100644 index 15689b635e..0000000000 Binary files a/genplus-gx/gx/images/Key_L_gcn.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_Minus_wii.png b/genplus-gx/gx/images/Key_Minus_wii.png deleted file mode 100644 index f848646777..0000000000 Binary files a/genplus-gx/gx/images/Key_Minus_wii.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_Plus_wii.png b/genplus-gx/gx/images/Key_Plus_wii.png deleted file mode 100644 index 47568bace1..0000000000 Binary files a/genplus-gx/gx/images/Key_Plus_wii.png and /dev/null differ diff --git a/genplus-gx/gx/images/Key_R_gcn.png b/genplus-gx/gx/images/Key_R_gcn.png deleted file mode 100644 index ea7bfcba26..0000000000 Binary files a/genplus-gx/gx/images/Key_R_gcn.png and /dev/null differ diff --git a/genplus-gx/gx/images/Load_cd.png b/genplus-gx/gx/images/Load_cd.png deleted file mode 100644 index d852a355af..0000000000 Binary files a/genplus-gx/gx/images/Load_cd.png and /dev/null differ diff --git a/genplus-gx/gx/images/Load_gg.png b/genplus-gx/gx/images/Load_gg.png deleted file mode 100644 index a5d9a1750f..0000000000 Binary files a/genplus-gx/gx/images/Load_gg.png and /dev/null differ diff --git a/genplus-gx/gx/images/Load_md.png b/genplus-gx/gx/images/Load_md.png deleted file mode 100644 index 86dcf89113..0000000000 Binary files a/genplus-gx/gx/images/Load_md.png and /dev/null differ diff --git a/genplus-gx/gx/images/Load_ms.png b/genplus-gx/gx/images/Load_ms.png deleted file mode 100644 index ecf17d0cc2..0000000000 Binary files a/genplus-gx/gx/images/Load_ms.png and /dev/null differ diff --git a/genplus-gx/gx/images/Load_recent.png b/genplus-gx/gx/images/Load_recent.png deleted file mode 100644 index f97e5775b0..0000000000 Binary files a/genplus-gx/gx/images/Load_recent.png and /dev/null differ diff --git a/genplus-gx/gx/images/Load_sg.png b/genplus-gx/gx/images/Load_sg.png deleted file mode 100644 index 52ad1672f3..0000000000 Binary files a/genplus-gx/gx/images/Load_sg.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_cheats.png b/genplus-gx/gx/images/Main_cheats.png deleted file mode 100644 index a9fdaf62df..0000000000 Binary files a/genplus-gx/gx/images/Main_cheats.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_file.png b/genplus-gx/gx/images/Main_file.png deleted file mode 100644 index 0332f5ce92..0000000000 Binary files a/genplus-gx/gx/images/Main_file.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_load.png b/genplus-gx/gx/images/Main_load.png deleted file mode 100644 index 11aa6d9800..0000000000 Binary files a/genplus-gx/gx/images/Main_load.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_logo.png b/genplus-gx/gx/images/Main_logo.png deleted file mode 100644 index 8efaa5222b..0000000000 Binary files a/genplus-gx/gx/images/Main_logo.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_options.png b/genplus-gx/gx/images/Main_options.png deleted file mode 100644 index 9536d9f712..0000000000 Binary files a/genplus-gx/gx/images/Main_options.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_play_gcn.png b/genplus-gx/gx/images/Main_play_gcn.png deleted file mode 100644 index aa6bb17d4c..0000000000 Binary files a/genplus-gx/gx/images/Main_play_gcn.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_play_wii.png b/genplus-gx/gx/images/Main_play_wii.png deleted file mode 100644 index 4aab2c5904..0000000000 Binary files a/genplus-gx/gx/images/Main_play_wii.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_quit.png b/genplus-gx/gx/images/Main_quit.png deleted file mode 100644 index 00dcc7deed..0000000000 Binary files a/genplus-gx/gx/images/Main_quit.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_reset.png b/genplus-gx/gx/images/Main_reset.png deleted file mode 100644 index fc28747d6f..0000000000 Binary files a/genplus-gx/gx/images/Main_reset.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_showinfo.png b/genplus-gx/gx/images/Main_showinfo.png deleted file mode 100644 index 1c011196dd..0000000000 Binary files a/genplus-gx/gx/images/Main_showinfo.png and /dev/null differ diff --git a/genplus-gx/gx/images/Main_takeshot.png b/genplus-gx/gx/images/Main_takeshot.png deleted file mode 100644 index 963abab6f3..0000000000 Binary files a/genplus-gx/gx/images/Main_takeshot.png and /dev/null differ diff --git a/genplus-gx/gx/images/Option_ctrl.png b/genplus-gx/gx/images/Option_ctrl.png deleted file mode 100644 index b5c0e0a3a3..0000000000 Binary files a/genplus-gx/gx/images/Option_ctrl.png and /dev/null differ diff --git a/genplus-gx/gx/images/Option_menu.png b/genplus-gx/gx/images/Option_menu.png deleted file mode 100644 index 6df9dc9bc6..0000000000 Binary files a/genplus-gx/gx/images/Option_menu.png and /dev/null differ diff --git a/genplus-gx/gx/images/Option_sound.png b/genplus-gx/gx/images/Option_sound.png deleted file mode 100644 index bc0a856a85..0000000000 Binary files a/genplus-gx/gx/images/Option_sound.png and /dev/null differ diff --git a/genplus-gx/gx/images/Option_system.png b/genplus-gx/gx/images/Option_system.png deleted file mode 100644 index aef047a9ae..0000000000 Binary files a/genplus-gx/gx/images/Option_system.png and /dev/null differ diff --git a/genplus-gx/gx/images/Option_video.png b/genplus-gx/gx/images/Option_video.png deleted file mode 100644 index ec8d745307..0000000000 Binary files a/genplus-gx/gx/images/Option_video.png and /dev/null differ diff --git a/genplus-gx/gx/images/Overlay_bar.png b/genplus-gx/gx/images/Overlay_bar.png deleted file mode 100644 index db667bd3c2..0000000000 Binary files a/genplus-gx/gx/images/Overlay_bar.png and /dev/null differ diff --git a/genplus-gx/gx/images/Snap_empty.png b/genplus-gx/gx/images/Snap_empty.png deleted file mode 100644 index 1aaf1e17b9..0000000000 Binary files a/genplus-gx/gx/images/Snap_empty.png and /dev/null differ diff --git a/genplus-gx/gx/images/Star_empty.png b/genplus-gx/gx/images/Star_empty.png deleted file mode 100644 index 746ea71113..0000000000 Binary files a/genplus-gx/gx/images/Star_empty.png and /dev/null differ diff --git a/genplus-gx/gx/images/Star_full.png b/genplus-gx/gx/images/Star_full.png deleted file mode 100644 index a355c6fa9e..0000000000 Binary files a/genplus-gx/gx/images/Star_full.png and /dev/null differ diff --git a/genplus-gx/gx/images/ctrl_classic.png b/genplus-gx/gx/images/ctrl_classic.png deleted file mode 100644 index b933deda07..0000000000 Binary files a/genplus-gx/gx/images/ctrl_classic.png and /dev/null differ diff --git a/genplus-gx/gx/images/ctrl_gamecube.png b/genplus-gx/gx/images/ctrl_gamecube.png deleted file mode 100644 index de72f951c8..0000000000 Binary files a/genplus-gx/gx/images/ctrl_gamecube.png and /dev/null differ diff --git a/genplus-gx/gx/images/ctrl_nunchuk.png b/genplus-gx/gx/images/ctrl_nunchuk.png deleted file mode 100644 index fc9ea5ff0b..0000000000 Binary files a/genplus-gx/gx/images/ctrl_nunchuk.png and /dev/null differ diff --git a/genplus-gx/gx/images/ctrl_option_off.png b/genplus-gx/gx/images/ctrl_option_off.png deleted file mode 100644 index 8def647fd6..0000000000 Binary files a/genplus-gx/gx/images/ctrl_option_off.png and /dev/null differ diff --git a/genplus-gx/gx/images/ctrl_option_on.png b/genplus-gx/gx/images/ctrl_option_on.png deleted file mode 100644 index 63d809143c..0000000000 Binary files a/genplus-gx/gx/images/ctrl_option_on.png and /dev/null differ diff --git a/genplus-gx/gx/images/ctrl_wiimote.png b/genplus-gx/gx/images/ctrl_wiimote.png deleted file mode 100644 index 05b00d67df..0000000000 Binary files a/genplus-gx/gx/images/ctrl_wiimote.png and /dev/null differ diff --git a/genplus-gx/gx/images/generic_point.png b/genplus-gx/gx/images/generic_point.png deleted file mode 100644 index eb79fbd420..0000000000 Binary files a/genplus-gx/gx/images/generic_point.png and /dev/null differ diff --git a/genplus-gx/gx/main.c b/genplus-gx/gx/main.c deleted file mode 100644 index 51b3ae915f..0000000000 --- a/genplus-gx/gx/main.c +++ /dev/null @@ -1,614 +0,0 @@ -/**************************************************************************** - * main.c - * - * Genesis Plus GX - * - * Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include "shared.h" -#include "font.h" -#include "gui.h" -#include "menu.h" -#include "history.h" -#include "file_slot.h" -#include "file_load.h" -#include "filesel.h" -#include "cheats.h" - -#include - -#ifdef HW_RVL -#include -#include - -extern bool sdio_Deinitialize(); -extern void USBStorage_Deinitialize(); -#endif - -/* output samplerate, adjusted to take resampler precision in account */ -#define SAMPLERATE_48KHZ 47992 - -u32 Shutdown = 0; -u32 ConfigRequested = 1; -char osd_version[32]; - -#ifdef HW_RVL -/**************************************************************************** - * Power Button callbacks - ***************************************************************************/ -static void PowerOff_cb(void) -{ - Shutdown = 1; - ConfigRequested = 1; - reload = 0; -} - -static void Reload_cb(void) -{ - Shutdown = 1; - ConfigRequested = 1; -} - -#endif - -/**************************************************************************** - * Reset Button callback - ***************************************************************************/ -static void Reset_cb(void) -{ - if (system_hw & SYSTEM_MD) - { - /* Soft Reset */ - gen_reset(0); - } - else if (system_hw == SYSTEM_SMS) - { - /* assert RESET input (Master System model 1 only) */ - io_reg[0x0D] &= ~IO_RESET_HI; - } -} - -/*************************************************************************** - * Genesis Plus Virtual Machine - * - ***************************************************************************/ -static void init_machine(void) -{ - /* system is not initialized */ - config.hot_swap &= 0x01; - - /* mark all BIOS as unloaded */ - system_bios = 0; - - /* Genesis BOOT ROM support (2KB max) */ - memset(boot_rom, 0xFF, 0x800); - FILE *fp = fopen(MD_BIOS, "rb"); - if (fp != NULL) - { - /* read BOOT ROM */ - fread(boot_rom, 1, 0x800, fp); - fclose(fp); - - /* check BOOT ROM */ - if (!memcmp((char *)(boot_rom + 0x120),"GENESIS OS", 10)) - { - /* mark Genesis BIOS as loaded */ - system_bios = SYSTEM_MD; - } - } - - /* allocate global work bitmap */ - memset(&bitmap, 0, sizeof (bitmap)); - bitmap.width = 720; - bitmap.height = 576; - bitmap.pitch = bitmap.width * 2; - bitmap.viewport.w = 256; - bitmap.viewport.h = 224; - bitmap.viewport.x = 0; - bitmap.viewport.y = 0; - bitmap.data = texturemem; -} - -static void run_emulation(void) -{ - u32 sync; - - /* main emulation loop */ - while (1) - { - /* emulated system */ - if (system_hw == SYSTEM_MCD) - { - /* 16-bit hardware + CD */ - while (!ConfigRequested) - { - /* render frame */ - system_frame_scd(0); - - /* audio/video sync */ - sync = SYNC_WAIT; - while (sync != (SYNC_VIDEO | SYNC_AUDIO)) - { - /* update video */ - sync |= gx_video_Update(sync & SYNC_VIDEO); - - /* update audio */ - sync |= gx_audio_Update(); - } - - /* check interlaced mode change */ - if (bitmap.viewport.changed & 4) - { - /* VSYNC "original" mode */ - if (!config.render && config.vsync && (gc_pal == vdp_pal)) - { - /* framerate has changed, reinitialize audio timings */ - audio_init(SAMPLERATE_48KHZ, get_framerate()); - } - - /* clear flag */ - bitmap.viewport.changed &= ~4; - } - } - } - else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - /* 16-bit hardware */ - while (!ConfigRequested) - { - /* render frame */ - system_frame_gen(0); - - /* audio/video sync */ - sync = SYNC_WAIT; - while (sync != (SYNC_VIDEO | SYNC_AUDIO)) - { - /* update video */ - sync |= gx_video_Update(sync & SYNC_VIDEO); - - /* update audio */ - sync |= gx_audio_Update(); - } - - /* check interlaced mode change */ - if (bitmap.viewport.changed & 4) - { - /* VSYNC "original" mode */ - if (!config.render && config.vsync && (gc_pal == vdp_pal)) - { - /* framerate has changed, reinitialize audio timings */ - audio_init(SAMPLERATE_48KHZ, get_framerate()); - } - - /* clear flag */ - bitmap.viewport.changed &= ~4; - } - } - } - else - { - /* 8-bit hardware */ - while (!ConfigRequested) - { - /* render frame */ - system_frame_sms(0); - - /* audio/video sync */ - sync = SYNC_WAIT; - while (sync != (SYNC_VIDEO | SYNC_AUDIO)) - { - /* update video */ - sync |= gx_video_Update(sync & SYNC_VIDEO); - - /* update audio */ - sync |= gx_audio_Update(); - } - - /* check interlaced mode change (PBC mode only) */ - if (bitmap.viewport.changed & 4) - { - /* "original" mode */ - if (!config.render && config.vsync && (gc_pal == vdp_pal)) - { - /* framerate has changed, reinitialize audio timings */ - audio_init(SAMPLERATE_48KHZ, get_framerate()); - } - - /* clear flag */ - bitmap.viewport.changed &= ~4; - } - } - } - - /* stop video & audio */ - gx_audio_Stop(); - gx_video_Stop(); - - /* show menu */ - ConfigRequested = 0; - mainmenu(); - - /* restart video & audio */ - gx_audio_Start(); - gx_video_Start(); - } -} - -/********************************************************************************************************************************************************* - Get emulator input framerate (actually used by audio emulation to approximate number of samples rendered on each frame, see audio_init in system.c) -*********************************************************************************************************************************************************/ -double get_framerate(void) -{ - /* Run emulator at original VDP framerate if console TV mode does not match emulated TV mode or VSYNC is disabled */ - if (!config.vsync || (config.tv_mode == !vdp_pal)) - { - return 0.0; - } - - /* Otherwise, run emulator at Wii/Gamecube framerate to ensure perfect video synchronization */ - if (vdp_pal) - { - /* 288p -> 13500000 pixels/sec, 864 pixels/line, 312 lines/field -> fps = 13500000/864/312 = 50.08 hz */ - /* 288i,576i -> 13500000 pixels/sec, 864 pixels/line, 312.5 lines/field (two fields = one frame = 625 lines) -> fps = 13500000/864/312.5 = 50.00 hz */ - return (config.render || interlaced) ? (27000000.0/864.0/625.0) : (13500000.0/864.0/312.0); - } - else - { - /* 240p -> 13500000 pixels/sec, 858 pixels/line, 263 lines/field -> fps = 13500000/858/263 = 59.83 hz */ - /* 240i,480i -> 13500000 pixels/sec, 858 pixels/line, 262.5 lines/field (two fields = one frame = 525 lines) -> fps = 13500000/858/262.5 = 59.94 hz */ - /* 480p -> 27000000 pixels/sec, 858 pixels/line, 525 lines/field -> fps = 27000000/858/525 = 59.94 hz */ - return (config.render || interlaced) ? (27000000.0/858.0/525.0) : (13500000.0/858.0/263.0); - } -} - -/******************************************* - Restart emulation when loading a new game -********************************************/ -void reloadrom(void) -{ - /* Cartridge "Hot Swap" support (make sure system has already been inited once and use cartridges) */ - if ((config.hot_swap == 3) && ((system_hw != SYSTEM_MCD) || scd.cartridge.boot)) - { - /* Only initialize cartridge hardware */ - if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - /* 16-bit cartridge */ - md_cart_init(); - md_cart_reset(1); - } - else - { - /* 8-bit cartridge */ - sms_cart_init(); - sms_cart_reset(); - } - } - - /* Disc Swap support (automatically enabled if CD tray is open) */ - else if ((system_hw != SYSTEM_MCD) || (cdd.status != CD_OPEN)) - { - /* Initialize audio emulation */ - interlaced = 0; - audio_init(SAMPLERATE_48KHZ, get_framerate()); - - /* System Power-On */ - system_init(); - system_reset(); - - /* Allow hot swap */ - config.hot_swap |= 2; - } - - /* Auto-Load Backup RAM */ - slot_autoload(0,config.s_device); - - /* Auto-Load State */ - slot_autoload(config.s_default,config.s_device); - - /* Load Cheat file */ - CheatLoad(); -} - -/************************************************** - Shutdown everything properly -***************************************************/ -void shutdown(void) -{ - /* save current config */ - config_save(); - - /* auto-save State file */ - slot_autosave(config.s_default,config.s_device); - - /* shutdown emulation core */ - audio_shutdown(); - - /* shutdown audio & video engines */ - gx_audio_Shutdown(); - gx_video_Shutdown(); - -#ifdef HW_RVL - /* unmount all devices */ - ISO9660_Unmount("dvd:"); - fatUnmount("sd"); - fatUnmount("usb"); - - /* shutdown all devices */ - DI_Close(); - sdio_Deinitialize(); - USBStorage_Deinitialize(); - MOUSE_Deinit(); -#endif -} - -/*************************************************************************** - * M A I N - * - ***************************************************************************/ -int main (int argc, char *argv[]) -{ - #ifdef HW_RVL - /* enable 64-byte fetch mode for L2 cache */ - L2Enhance(); - - /* disable DVD cache */ - DI_UseCache(0); - - /* autodetect loader arguments */ - if ((argc >= 3) && (argv[1] != NULL)) - { - /* check if autoloading from USB is requested */ - if (!strncasecmp(argv[1], "usb:/", 5)) - { - /* reload to IOS58 for USB2 support */ - if (IOS_GetVersion() != 58) - { - /* warning: DVD support will be disabled after IOS reloading ! */ - IOS_ReloadIOS(58); - } - } - } - - sprintf(osd_version, "%s (IOS %d)", VERSION, IOS_GetVersion()); -#else - sprintf(osd_version, "%s (GCN)", VERSION); -#endif - - /* initialize video engine */ - gx_video_Init(); - - /* initialize input engine */ - gx_input_Init(); - - /* initialize FAT devices */ - int retry = 0; - int fatMounted = 0; - - /* try to mount FAT devices during 3 seconds */ - while (!fatMounted && (retry < 12)) - { - fatMounted = fatInitDefault(); - usleep(250000); - retry++; - } - - if (fatMounted) - { - /* base directory */ - char pathname[MAXPATHLEN]; - sprintf (pathname, DEFAULT_PATH); - DIR *dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - - /* default SRAM & Savestate files directories */ - sprintf (pathname, "%s/saves",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/saves/md",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/saves/ms",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/saves/gg",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/saves/sg",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/saves/cd",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - - /* default Snapshot files directories */ - sprintf (pathname, "%s/snaps",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/snaps/md",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/snaps/ms",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/snaps/gg",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/snaps/sg",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/snaps/cd",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - - /* default Cheat files directories */ - sprintf (pathname, "%s/cheats",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/cheats/md",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/cheats/ms",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/cheats/gg",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/cheats/sg",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - sprintf (pathname, "%s/cheats/cd",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - - /* default BIOS ROM files directories */ - sprintf (pathname, "%s/bios",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - - /* default LOCK-ON ROM files directories */ - sprintf (pathname, "%s/lock-on",DEFAULT_PATH); - dir = opendir(pathname); - if (dir) closedir(dir); - else mkdir(pathname,S_IRWXU); - } - - /* initialize audio engine */ - gx_audio_Init(); - - /* initialize emulation */ - history_default(); - config_default(); - init_machine(); - - /* file autoloading */ - int autoload = config.autoload; - - /* autodetect loader arguments */ - if ((argc >= 3) && (argv[1] != NULL) && (argv[2] != NULL)) - { - /* automatically load any file passed as argument */ - autoload = 1; - - /* add the file to the top of the history. */ - history_add_file(argv[1], argv[2], 0); - } - - /* automatically load first file from history list if requested */ - if (autoload) - { - SILENT = 1; - if (OpenDirectory(TYPE_RECENT, -1)) - { - if (LoadFile(0)) - { - reloadrom(); - gx_video_Start(); - gx_audio_Start(); - ConfigRequested = 0; - } - } - SILENT = 0; - } - - /* show disclaimer before entering menu */ - if (ConfigRequested) - { - legal(); - } - - /* initialize stub loader detection */ - reload = 0; - -#ifdef HW_RVL - /* autodetect loader arguments */ - if ((argc >= 4) && (argv[3] != NULL)) - { - /* assume proper loader stub exists */ - reload = (void(*)())0x80001800; - - /* return to loader when POWER buttons are pressed */ - SYS_SetPowerCallback(Reload_cb); - } - else - { - /* autodetect HomeBrew Channel stub */ - u32 *sig = (u32*)0x80001800; - if ((sig[1] == 0x53545542) && (sig[2] == 0x48415858)) - { - reload = (void(*)())0x80001800; - } - - /* by default, shutdown system when POWER buttons are pressed */ - SYS_SetPowerCallback(PowerOff_cb); - - } -#else - /* autodetect SDLoad stub */ - u32 *sig = (u32*)0x80001800; - if (sig[0] == 0x7c6000a6) - { - reload = (void(*)())0x80001800; - } -#endif - - /* RESET button callback */ - SYS_SetResetCallback(Reset_cb); - - /* main emulation loop */ - run_emulation(); - - /* we should never return anyway */ - return 0; -} diff --git a/genplus-gx/gx/osd.h b/genplus-gx/gx/osd.h deleted file mode 100644 index 4caec0e8c8..0000000000 --- a/genplus-gx/gx/osd.h +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************/ -/* port specific stuff should be put there */ -/*************************************************/ - -#ifndef _OSD_H_ -#define _OSD_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HW_RVL -#include -#include -#include "vi_encoder.h" -#endif - -#include "gx_input.h" -#include "gx_audio.h" -#include "gx_video.h" -#include "file_load.h" -#include "cheats.h" - -#include "config.h" -#include "fileio.h" - -#define DEFAULT_PATH "/genplus" - -/*************************************************/ -/* required by Genesis Plus GX core */ -/*************************************************/ -#define GG_ROM "/genplus/lock-on/ggenie.bin" -#define AR_ROM "/genplus/lock-on/areplay.bin" -#define SK_ROM "/genplus/lock-on/sk.bin" -#define SK_UPMEM "/genplus/lock-on/sk2chip.bin" -#define MS_BIOS_US "/genplus/bios/bios_U.sms" -#define MS_BIOS_EU "/genplus/bios/bios_E.sms" -#define MS_BIOS_JP "/genplus/bios/bios_J.sms" -#define GG_BIOS "/genplus/bios/bios.gg" -#define MD_BIOS "/genplus/bios/bios_MD.bin" -#define CD_BIOS_US "/genplus/bios/bios_CD_U.bin" -#define CD_BIOS_EU "/genplus/bios/bios_CD_E.bin" -#define CD_BIOS_JP "/genplus/bios/bios_CD_J.bin" -#define CD_BRAM_US "/genplus/saves/cd/scd_U.brm" -#define CD_BRAM_EU "/genplus/saves/cd/scd_E.brm" -#define CD_BRAM_JP "/genplus/saves/cd/scd_J.brm" -#define CART_BRAM "/genplus/saves/cd/cart.brm" - -/*********************************************************/ -/* implemented by Genesis Plus GX core (GC/Wii specific) */ -/*********************************************************/ - -/* 32 bytes aligned sound buffers (8 samples alignment) */ -#define ALIGN_SND 0xfffffff8 - -/* use Wii DVD LED to indicate when virtual CD tray is open */ -#ifdef HW_RVL -#define CD_TRAY_CALLBACK *(u32*)0xcd0000c0 = (*(u32*)0xcd0000c0 & ~0x20) | ((cdd.status == CD_OPEN) << 5); -#endif - -/*************************************************/ - -#define VERSION "Genesis Plus GX 1.7.5" - -#define SYNC_WAIT 0 -#define SYNC_VIDEO 1 -#define SYNC_AUDIO 2 - -/* globals */ -extern void legal(void); -extern double get_framerate(void); -extern void reloadrom(void); -extern void shutdown(void); -extern u32 Shutdown; -extern u32 ConfigRequested; -extern char osd_version[32]; - -#endif /* _OSD_H_ */ diff --git a/genplus-gx/gx/sounds/button_over.pcm b/genplus-gx/gx/sounds/button_over.pcm deleted file mode 100644 index 8c4d88adbb..0000000000 Binary files a/genplus-gx/gx/sounds/button_over.pcm and /dev/null differ diff --git a/genplus-gx/gx/sounds/button_select.pcm b/genplus-gx/gx/sounds/button_select.pcm deleted file mode 100644 index d58260f856..0000000000 Binary files a/genplus-gx/gx/sounds/button_select.pcm and /dev/null differ diff --git a/genplus-gx/gx/sounds/intro.pcm b/genplus-gx/gx/sounds/intro.pcm deleted file mode 100644 index 1cee395cdc..0000000000 Binary files a/genplus-gx/gx/sounds/intro.pcm and /dev/null differ diff --git a/genplus-gx/gx/utils/oggplayer.c b/genplus-gx/gx/utils/oggplayer.c deleted file mode 100644 index 2dcd37b8dc..0000000000 --- a/genplus-gx/gx/utils/oggplayer.c +++ /dev/null @@ -1,536 +0,0 @@ -/* - Copyright (c) 2008 Francisco Muñoz 'Hermes' - All rights reserved. - - Proper (standard) vorbis usage by Tantric, 2009 - Threading modifications/corrections by Tantric, 2009 - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other - materials provided with the distribution. - - The names of the contributors may not be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "oggplayer.h" -#include -#include -#include - -/* functions to read the Ogg file from memory */ - -static struct -{ - char *mem; - int size; - int pos; -} file[4]; - -static int f_read(void * punt, int bytes, int blocks, int *f) -{ - int b; - int c; - int d; - - if (bytes * blocks <= 0) - return 0; - - blocks = bytes * blocks; - c = 0; - - while (blocks > 0) - { - b = blocks; - if (b > 4096) - b = 4096; - - if (*f >= 0x666 && *f <= 0x669) - { - d = (*f) - 0x666; - if (file[d].size == 0) - return -1; - if ((file[d].pos + b) > file[d].size) - b = file[d].size - file[d].pos; - if (b > 0) - { - memcpy(punt, file[d].mem + file[d].pos, b); - file[d].pos += b; - } - } - else - b = read(*f, ((char *) punt) + c, b); - - if (b <= 0) - { - return c / bytes; - } - c += b; - blocks -= b; - } - return c / bytes; -} - -static int f_seek(int *f, ogg_int64_t offset, int mode) -{ - if(f==NULL) return(-1); - - int k, d; - mode &= 3; - if (*f >= 0x666 && *f <= 0x669) - { - d = (*f) - 0x666; - k = 0; - - if (file[d].size == 0) - return -1; - - if (mode == 0) - { - if ((offset) >= file[d].size) - { - file[d].pos = file[d].size; - k = -1; - } - else if ((offset) < 0) - { - file[d].pos = 0; - k = -1; - } - else - file[d].pos = offset; - } - if (mode == 1) - { - if ((file[d].pos + offset) >= file[d].size) - { - file[d].pos = file[d].size; - k = -1; - } - else if ((file[d].pos + offset) < 0) - { - file[d].pos = 0; - k = -1; - } - else - file[d].pos += offset; - } - if (mode == 2) - { - - if ((file[d].size + offset) >= file[d].size) - { - file[d].pos = file[d].size; - k = -1; - } - else if ((file[d].size + offset) < 0) - { - file[d].pos = 0; - k = -1; - } - else - file[d].pos = file[d].size + offset; - } - - } - else - k = lseek(*f, (int) offset, mode); - - if (k < 0) - k = -1; - else - k = 0; - return k; -} - -static int f_close(int *f) -{ - int d; - if (*f >= 0x666 && *f <= 0x669) - { - d = (*f) - 0x666; - file[d].size = 0; - file[d].pos = 0; - if (file[d].mem) - { - file[d].mem = (void *) 0; - } - return 0; - } - else - return close(*f); - return 0; -} - -static long f_tell(int *f) -{ - int k, d; - - if (*f >= 0x666 && *f <= 0x669) - { - d = (*f) - 0x666; - k = file[d].pos; - } - else - k = lseek(*f, 0, 1); - - return (long) k; -} - -static int mem_open(char * ogg, int size) -{ - static int one = 1; - int n; - if (one) - { - one = 0; - for (n = 0; n < 4; n++) - file[n].size = 0; - } - - for (n = 0; n < 4; n++) - { - if (file[n].size == 0) - { - file[n].mem = ogg; - file[n].size = size; - file[n].pos = 0; - return (0x666 + n); - } - } - return -1; -} - -static int mem_close(int fd) -{ - if (fd >= 0x666 && fd <= 0x669) // it is a memory file descriptor? - { - fd -= 0x666; - file[fd].size = 0; - return 0; - } - else - return f_close(&fd); -} - -static ov_callbacks callbacks = { - (size_t (*)(void *, size_t, size_t, void *)) f_read, - (int (*)(void *, ogg_int64_t, int)) f_seek, - (int (*)(void *)) f_close, - (long (*)(void *)) f_tell -}; - -/* OGG control */ - -#define READ_SAMPLES 4096 /* samples that it must read before to send */ -#define MAX_PCMOUT 4096 /* minimum size to read ogg samples */ -typedef struct -{ - OggVorbis_File vf; - vorbis_info *vi; - int current_section; - - /* OGG file operation */ - int fd; - int mode; - int eof; - int flag; - int volume; - int seek_time; - - /* OGG buffer control */ - short pcmout[2][READ_SAMPLES + MAX_PCMOUT * 2]; /* take 4k out of the data segment, not the stack */ - int pcmout_pos; - int pcm_indx; - -} private_data_ogg; - -static private_data_ogg private_ogg; - -/* OGG thread control */ - -#define STACKSIZE 8192 - -static u8 oggplayer_stack[STACKSIZE]; -static lwpq_t oggplayer_queue = LWP_TQUEUE_NULL; -static lwp_t h_oggplayer = LWP_THREAD_NULL; -static int ogg_thread_running = 0; - -static void ogg_add_callback(int voice) -{ - if (!ogg_thread_running) - { - ASND_StopVoice(0); - return; - } - - if (private_ogg.flag & 128) - return; /* Ogg is paused */ - - if (private_ogg.pcm_indx >= READ_SAMPLES) - { - if (ASND_AddVoice(0, - (void *) private_ogg.pcmout[private_ogg.pcmout_pos], - private_ogg.pcm_indx << 1) == 0) - { - private_ogg.pcmout_pos ^= 1; - private_ogg.pcm_indx = 0; - private_ogg.flag = 0; - LWP_ThreadSignal(oggplayer_queue); - } - } - else - { - if (private_ogg.flag & 64) - { - private_ogg.flag &= ~64; - LWP_ThreadSignal(oggplayer_queue); - } - } -} - -static void * ogg_player_thread(private_data_ogg * priv) -{ - int first_time = 1; - long ret; - - /* init */ - LWP_InitQueue(&oggplayer_queue); - - priv[0].vi = ov_info(&priv[0].vf, -1); - - ASND_Pause(0); - - priv[0].pcm_indx = 0; - priv[0].pcmout_pos = 0; - priv[0].eof = 0; - priv[0].flag = 0; - priv[0].current_section = 0; - - ogg_thread_running = 1; - - while (!priv[0].eof && ogg_thread_running) - { - if (priv[0].flag) - LWP_ThreadSleep(oggplayer_queue); /* wait only when i have samples to send */ - - if (priv[0].flag == 0) /* wait to all samples are sended */ - { - if (ASND_TestPointer(0, priv[0].pcmout[priv[0].pcmout_pos]) - && ASND_StatusVoice(0) != SND_UNUSED) - { - priv[0].flag |= 64; - continue; - } - if (priv[0].pcm_indx < READ_SAMPLES) - { - priv[0].flag = 3; - - if (priv[0].seek_time >= 0) - { - ov_time_seek(&priv[0].vf, priv[0].seek_time); - priv[0].seek_time = -1; - } - - ret - = ov_read( - &priv[0].vf, - (void *) &priv[0].pcmout[priv[0].pcmout_pos][priv[0].pcm_indx], - MAX_PCMOUT,/*0,2,1,*/&priv[0].current_section); - priv[0].flag &= 192; - if (ret == 0) - { - /* EOF */ - if (priv[0].mode & 1) - ov_time_seek(&priv[0].vf, 0); /* repeat */ - else - priv[0].eof = 1; /* stops */ - } - else if (ret < 0) - { - /* error in the stream. Not a problem, just reporting it in - case we (the app) cares. In this case, we don't. */ - if (ret != OV_HOLE) - { - if (priv[0].mode & 1) - ov_time_seek(&priv[0].vf, 0); /* repeat */ - else - priv[0].eof = 1; /* stops */ - } - } - else - { - /* we don't bother dealing with sample rate changes, etc, but - you'll have to */ - priv[0].pcm_indx += ret >> 1; /* get 16 bits samples */ - } - } - else - priv[0].flag = 1; - } - - if (priv[0].flag == 1) - { - if (ASND_StatusVoice(0) == SND_UNUSED || first_time) - { - first_time = 0; - if (priv[0].vi->channels == 2) - { - ASND_SetVoice(0, VOICE_STEREO_16BIT, priv[0].vi->rate, 0, - (void *) priv[0].pcmout[priv[0].pcmout_pos], - priv[0].pcm_indx << 1, priv[0].volume, - priv[0].volume, ogg_add_callback); - priv[0].pcmout_pos ^= 1; - priv[0].pcm_indx = 0; - priv[0].flag = 0; - } - else - { - ASND_SetVoice(0, VOICE_MONO_16BIT, priv[0].vi->rate, 0, - (void *) priv[0].pcmout[priv[0].pcmout_pos], - priv[0].pcm_indx << 1, priv[0].volume, - priv[0].volume, ogg_add_callback); - priv[0].pcmout_pos ^= 1; - priv[0].pcm_indx = 0; - priv[0].flag = 0; - } - } - } - usleep(10); - } - ov_clear(&priv[0].vf); - priv[0].fd = -1; - priv[0].pcm_indx = 0; - - return 0; -} - -void StopOgg() -{ - ASND_StopVoice(0); - ogg_thread_running = 0; - - if(h_oggplayer != LWP_THREAD_NULL) - { - if(oggplayer_queue != LWP_TQUEUE_NULL) - LWP_ThreadSignal(oggplayer_queue); - LWP_JoinThread(h_oggplayer, NULL); - h_oggplayer = LWP_THREAD_NULL; - } - if(oggplayer_queue != LWP_TQUEUE_NULL) - { - LWP_CloseQueue(oggplayer_queue); - oggplayer_queue = LWP_TQUEUE_NULL; - } -} - -int PlayOgg(char * buf, int buflen, int time_pos, int mode) -{ - StopOgg(); - - private_ogg.fd = mem_open(buf, buflen); - - if (private_ogg.fd < 0) - { - private_ogg.fd = -1; - return -1; - } - - private_ogg.mode = mode; - private_ogg.eof = 0; - private_ogg.volume = 127; - private_ogg.flag = 0; - private_ogg.seek_time = -1; - - if (time_pos > 0) - private_ogg.seek_time = time_pos; - - if (ov_open_callbacks((void *) &private_ogg.fd, &private_ogg.vf, NULL, 0, callbacks) < 0) - { - mem_close(private_ogg.fd); /* mem_close() can too close files from devices */ - private_ogg.fd = -1; - ogg_thread_running = 0; - return -1; - } - - if (LWP_CreateThread(&h_oggplayer, (void *) ogg_player_thread, - &private_ogg, oggplayer_stack, STACKSIZE, 80) == -1) - { - ogg_thread_running = 0; - ov_clear(&private_ogg.vf); - private_ogg.fd = -1; - return -1; - } - return 0; -} - -void PauseOgg(int pause) -{ - if (pause) - { - private_ogg.flag |= 128; - } - else - { - if (private_ogg.flag & 128) - { - private_ogg.flag |= 64; - private_ogg.flag &= ~128; - if (ogg_thread_running > 0) - { - LWP_ThreadSignal(oggplayer_queue); - } - } - } -} - -int StatusOgg() -{ - if (ogg_thread_running == 0) - return -1; /* Error */ - else if (private_ogg.eof) - return 255; /* EOF */ - else if (private_ogg.flag & 128) - return 2; /* paused */ - else - return 1; /* running */ -} - -void SetVolumeOgg(int volume) -{ - private_ogg.volume = volume; - ASND_ChangeVolumeVoice(0, volume, volume); -} - -s32 GetTimeOgg() -{ - int ret; - if (ogg_thread_running == 0 || private_ogg.fd < 0) - return 0; - ret = ((s32) ov_time_tell(&private_ogg.vf)); - if (ret < 0) - ret = 0; - - return ret; -} - -void SetTimeOgg(s32 time_pos) -{ - if (time_pos >= 0) - private_ogg.seek_time = time_pos; -} - diff --git a/genplus-gx/gx/utils/oggplayer.h b/genplus-gx/gx/utils/oggplayer.h deleted file mode 100644 index 85b95c6a88..0000000000 --- a/genplus-gx/gx/utils/oggplayer.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - Copyright (c) 2008 Francisco Muñoz 'Hermes' - All rights reserved. - - Proper (standard) vorbis usage by Tantric, 2009 - Threading modifications/corrections by Tantric, 2009 - - Redistribution and use in source and binary forms, with or without modification, are - permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other - materials provided with the distribution. - - The names of the contributors may not be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef NO_SOUND - -#ifndef __OGGPLAYER_H__ -#define __OGGPLAYER_H__ - -#include -#include "tremor/ivorbiscodec.h" -#include "tremor/ivorbisfile.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define OGG_ONE_TIME 0 -#define OGG_INFINITE_TIME 1 - -#define OGG_STATUS_RUNNING 1 -#define OGG_STATUS_ERR -1 -#define OGG_STATUS_PAUSED 2 -#define OGG_STATUS_EOF 255 - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ -/* Player OGG functions */ -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* int PlayOgg(int fd, int time_pos, int mode); - - Play an Ogg file. This file can be loaded from memory (mem_open(void *ogg, int size_ogg)) or from device with open("device:file.ogg",O_RDONLY,0); - - NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. - - -- Params --- - - buf: pointer to sound data - - buflen: buffer size in bytes - - time_pos: initial time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds - - mode: Use OGG_ONE_TIME or OGG_INFINITE_TIME. When you use OGG_ONE_TIME the sound stops and StatusOgg() return OGG_STATUS_EOF - - return: 0- Ok, -1 Error - - */ - -int PlayOgg(char * buf, int buflen, int time_pos, int mode); - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* void StopOgg(); - - Stop an Ogg file. - - NOTE: The file is closed and the player thread is released - - -- Params --- - - - */ - -void StopOgg(); - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* void PauseOgg(int pause); - - Pause an Ogg file. - - -- Params --- - - pause: 0 -> continue, 1-> pause - - */ - -void PauseOgg(int pause); - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* int StatusOgg(); - - Return the Ogg status - - -- Params --- - - - return: OGG_STATUS_RUNNING - OGG_STATUS_ERR -> not initialized? - OGG_STATUS_PAUSED - OGG_STATUS_EOF -> player stopped by End Of File - - */ - -int StatusOgg(); - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* void SetVolumeOgg(int volume); - - Set the Ogg playing volume. - NOTE: it change the volume of voice 0 (used for the Ogg player) - - -- Params --- - - volume: 0 to 255 (max) - - */ - -void SetVolumeOgg(int volume); - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* s32 GetTimeOgg(); - - Return the Ogg time from the starts of the file - - -- Params --- - - return: 0 -> Ok or error condition (you must ignore this value) - >0 -> time in milliseconds from the starts - - */ - -s32 GetTimeOgg(); - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -/* void SetTimeOgg(s32 time_pos); - - Set the time position - - NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. - - -- Params --- - - time_pos: time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds - - */ - -void SetTimeOgg(s32 time_pos); - -/*------------------------------------------------------------------------------------------------------------------------------------------------------*/ - -#ifdef __cplusplus -} -#endif - -#endif - -#endif diff --git a/genplus-gx/gx/utils/vi_encoder.c b/genplus-gx/gx/utils/vi_encoder.c deleted file mode 100644 index 402fa79199..0000000000 --- a/genplus-gx/gx/utils/vi_encoder.c +++ /dev/null @@ -1,565 +0,0 @@ -/**************************************************************************** - * vi_encoder.c - * - * Wii Audio/Video Encoder support - * - * Copyright (C) 2009 Eke-Eke, with some code from libogc (C) Hector Martin - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifdef HW_RVL - -#include -#include -#include -#include - -#include "vi_encoder.h" - -/**************************************************************************** - * I2C driver by Hector Martin (marcan) - * - ****************************************************************************/ - -#define _SHIFTL(v, s, w) \ - ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s))) -#define _SHIFTR(v, s, w) \ - ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) - -extern void udelay(int us); - -static u32 i2cIdentFirst = 0; -static u32 i2cIdentFlag = 1; -static vu16* const _viReg = (u16*)0xCC002000; -static vu32* const _i2cReg = (u32*)0xCD800000; - -static inline void __viOpenI2C(u32 channel) -{ - u32 val = ((_i2cReg[49]&~0x8000)|0x4000); - val |= _SHIFTL(channel,15,1); - _i2cReg[49] = val; -} - -static inline u32 __viSetSCL(u32 channel) -{ - u32 val = (_i2cReg[48]&~0x4000); - val |= _SHIFTL(channel,14,1); - _i2cReg[48] = val; - return 1; -} -static inline u32 __viSetSDA(u32 channel) -{ - u32 val = (_i2cReg[48]&~0x8000); - val |= _SHIFTL(channel,15,1); - _i2cReg[48] = val; - return 1; -} - -static inline u32 __viGetSDA() -{ - return _SHIFTR(_i2cReg[50],15,1); -} - -static inline void __viCheckI2C() -{ - __viOpenI2C(0); - udelay(4); - - i2cIdentFlag = 0; - if(__viGetSDA()!=0) i2cIdentFlag = 1; -} - -static u32 __sendSlaveAddress(u8 addr) -{ - u32 i; - - __viSetSDA(i2cIdentFlag^1); - udelay(2); - - __viSetSCL(0); - for(i=0;i<8;i++) { - if(addr&0x80) __viSetSDA(i2cIdentFlag); - else __viSetSDA(i2cIdentFlag^1); - udelay(2); - - __viSetSCL(1); - udelay(2); - - __viSetSCL(0); - addr <<= 1; - } - - __viOpenI2C(0); - udelay(2); - - __viSetSCL(1); - udelay(2); - - if(i2cIdentFlag==1 && __viGetSDA()!=0) return 0; - - __viSetSDA(i2cIdentFlag^1); - __viOpenI2C(1); - __viSetSCL(0); - - return 1; -} - -static u32 __VISendI2CData(u8 addr,void *val,u32 len) -{ - u8 c; - s32 i,j; - u32 level,ret; - - if(i2cIdentFirst==0) { - __viCheckI2C(); - i2cIdentFirst = 1; - } - - _CPU_ISR_Disable(level); - - __viOpenI2C(1); - __viSetSCL(1); - - __viSetSDA(i2cIdentFlag); - udelay(4); - - ret = __sendSlaveAddress(addr); - if(ret==0) { - _CPU_ISR_Restore(level); - return 0; - } - - __viOpenI2C(1); - for(i=0;i> 8; - buf[2] = data & 0xFF; - __VISendI2CData(0xe0,buf,3); - udelay(2); -} - -static void __VIWriteI2CRegister32(u8 reg, u32 data) -{ - u8 buf[5]; - buf[0] = reg; - buf[1] = data >> 24; - buf[2] = (data >> 16) & 0xFF; - buf[3] = (data >> 8) & 0xFF; - buf[4] = data & 0xFF; - __VISendI2CData(0xe0,buf,5); - udelay(2); -} - -static void __VIWriteI2CRegisterBuf(u8 reg, int size, u8 *data) -{ - u8 buf[0x100]; - buf[0] = reg; - memcpy(&buf[1], data, size); - __VISendI2CData(0xe0,buf,size+1); - udelay(2); -} - -/**************************************************************************** - * A/V functions support (Eke-Eke) - * - ****************************************************************************/ -static const u8 gamma_coeffs[][33] = -{ - /* GM_0_0 */ - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - - }, - - /* GM_0_1 */ - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0x97, 0x3B, 0x49, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x80, 0x1B, 0x80, 0xEB, 0x00 - }, - - /* GM_0_2 */ - { - 0x00, 0x00, 0x00, 0x28, 0x00, 0x5A, 0x02, 0xDB, 0x0D, 0x8D, 0x30, 0x49, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x10, 0x00, 0x10, 0x40, 0x11, 0x00, 0x18, 0x80, 0x42, 0x00, 0xEB, 0x00 - }, - - /* GM_0_3 */ - { - 0x00, 0x00, 0x00, 0x7A, 0x02, 0x3C, 0x07, 0x6D, 0x12, 0x9C, 0x27, 0x24, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x10, 0x00, 0x10, 0xC0, 0x15, 0x80, 0x29, 0x00, 0x62, 0x00, 0xEB, 0x00 - }, - - /* GM_0_4 */ - { - 0x00, 0x4E, 0x01, 0x99, 0x05, 0x2D, 0x0B, 0x24, 0x14, 0x29, 0x20, 0xA4, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x00, 0x10, 0x10, 0x40, 0x12, 0xC0, 0x1D, 0xC0, 0x3B, 0x00, 0x78, 0xC0, 0xEB, 0x00 - }, - - /* GM_0_5 */ - { - 0x00, 0xEC, 0x03, 0xD7, 0x08, 0x00, 0x0D, 0x9E, 0x14, 0x3E, 0x1B, 0xDB, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x10, 0xC0, 0x16, 0xC0, 0x27, 0xC0, 0x4B, 0x80, 0x89, 0x80, 0xEB, 0x00 - }, - - /* GM_0_6 */ - { - 0x02, 0x76, 0x06, 0x66, 0x0A, 0x96, 0x0E, 0xF3, 0x13, 0xAC, 0x18, 0x49, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x12, 0x00, 0x1C, 0x00, 0x32, 0x80, 0x59, 0xC0, 0x96, 0x00, 0xEB, 0x00 - }, - - /* GM_0_7 */ - { - 0x04, 0xEC, 0x08, 0xF5, 0x0C, 0x96, 0x0F, 0xCF, 0x12, 0xC6, 0x15, 0x80, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x14, 0x00, 0x22, 0x00, 0x3C, 0xC0, 0x66, 0x40, 0x9F, 0xC0, 0xEB, 0x00 - }, - - /* GM_0_8 */ - { - 0x08, 0x00, 0x0B, 0xAE, 0x0E, 0x00, 0x10, 0x30, 0x11, 0xCB, 0x13, 0x49, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x16, 0x80, 0x28, 0xC0, 0x46, 0x80, 0x71, 0x00, 0xA7, 0x80, 0xEB, 0x00 - }, - - /* GM_0_9 */ - { - 0x0B, 0xB1, 0x0E, 0x14, 0x0F, 0x2D, 0x10, 0x18, 0x10, 0xE5, 0x11, 0x80, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x19, 0x80, 0x2F, 0x80, 0x4F, 0xC0, 0x7A, 0x00, 0xAD, 0xC0, 0xEB, 0x00 - }, - - /* GM_1_0 */ - { - 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, - 0x10, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xEB, - 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x60, 0x00, 0x80, 0x00, 0xA0, 0x00, 0xEB, 0x00 - }, - - /* GM_1_1 */ - { - 0x14, 0xEC, 0x11, 0xC2, 0x10, 0x78, 0x0F, 0xB6, 0x0F, 0x2F, 0x0E, 0xB6, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x21, 0x00, 0x3C, 0xC0, 0x5F, 0xC0, 0x89, 0x00, 0xB7, 0x80, 0xEB, 0x00 - }, - - /* GM_1_2 */ - { - 0x19, 0xD8, 0x13, 0x33, 0x10, 0xD2, 0x0F, 0x6D, 0x0E, 0x5E, 0x0D, 0xA4, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x25, 0x00, 0x43, 0x00, 0x66, 0xC0, 0x8F, 0x40, 0xBB, 0x40, 0xEB, 0x00 - }, - - /* GM_1_3 */ - { - 0x1E, 0xC4, 0x14, 0x7A, 0x11, 0x0F, 0xF, 0x0C, 0x0D, 0xA1, 0x0C, 0xB6, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x29, 0x00, 0x49, 0x00, 0x6D, 0x40, 0x94, 0xC0, 0xBE, 0x80, 0xEB, 0x00 - }, - - /* GM_1_4 */ - { - 0x24, 0x00, 0x15, 0x70, 0x11, 0x0F, 0x0E, 0xAA, 0x0D, 0x0F, 0x0B, 0xDB, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x2D, 0x40, 0x4E, 0xC0, 0x73, 0x00, 0x99, 0x80, 0xC1, 0x80, 0xEB, 0x00 - }, - - /* GM_1_5 */ - { - 0x29, 0x3B, 0x16, 0x3D, 0x11, 0x0F, 0x0E, 0x30, 0x0C, 0x7D, 0x0B, 0x24, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x31, 0x80, 0x54, 0x40, 0x78, 0x80, 0x9D, 0xC0, 0xC4, 0x00, 0xEB, 0x00 - }, - - /* GM_1_6 */ - { - 0x2E, 0x27, 0x17, 0x0A, 0x10, 0xD2, 0x0D, 0xE7, 0x0B, 0xEB, 0x0A, 0x80, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x35, 0x80, 0x59, 0x80, 0x7D, 0x40, 0xA1, 0xC0, 0xC6, 0x40, 0xEB, 0x00 - }, - - /* GM_1_7 */ - { - 0x33, 0x62, 0x17, 0x5C, 0x10, 0xD2, 0x0D, 0x6D, 0x0B, 0x6D, 0x09, 0xED, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x39, 0xC0, 0x5E, 0x40, 0x82, 0x00, 0xA5, 0x40, 0xC8, 0x40, 0xEB, 0x00 - }, - - /* GM_1_8 */ - { - 0x38, 0x4E, 0x17, 0xAE, 0x10, 0xB4, 0x0D, 0x0C, 0x0A, 0xF0, 0x09, 0x6D, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x3D, 0xC0, 0x62, 0xC0, 0x86, 0x40, 0xA8, 0x80, 0xCA, 0x00, 0xEB, 0x00 - }, - - /* GM_1_9 */ - { - 0x3D, 0x3B, 0x18, 0x00, 0x10, 0x5A, 0x0C, 0xC3, 0x0A, 0x72, 0x09, 0x00, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x41, 0xC0, 0x67, 0x40, 0x8A, 0x00, 0xAB, 0x80, 0xCB, 0x80, 0xEB, 0x00 - }, - - /* GM_2_0 */ - { - 0x41, 0xD8, 0x18, 0x28, 0x10, 0x3C, 0x0C, 0x49, 0x0A, 0x1F, 0x08, 0x92, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x45, 0x80, 0x6B, 0x40, 0x8D, 0xC0, 0xAE, 0x00, 0xCD, 0x00, 0xEB, 0x00 - }, - - /* GM_2_1 */ - { - 0x46, 0x76, 0x18, 0x51, 0x0F, 0xE1, 0x0C, 0x00, 0x09, 0xB6, 0x08, 0x36, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x49, 0x40, 0x6F, 0x40, 0x91, 0x00, 0xB0, 0x80, 0xCE, 0x40, 0xEB, 0x00 - }, - - /* GM_2_2 */ - { - 0x4A, 0xC4, 0x18, 0x7A, 0x0F, 0xA5, 0x0B, 0x9E, 0x09, 0x63, 0x07, 0xDB, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x4C, 0xC0, 0x73, 0x00, 0x94, 0x40, 0xB2, 0xC0, 0xCF, 0x80, 0xEB, 0x00 - }, - - /* GM_2_3 */ - { - 0x4F, 0x13, 0x18, 0x51, 0x0F, 0x69, 0x0B, 0x6D, 0x09, 0x0F, 0x07, 0x80, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x50, 0x40, 0x76, 0x40, 0x97, 0x00, 0xB5, 0x00, 0xD0, 0xC0, 0xEB, 0x00 - }, - - /* GM_2_4 */ - { - 0x53, 0x13, 0x18, 0x7A, 0x0F, 0x0F, 0x0B, 0x24, 0x08, 0xBC, 0x07, 0x36, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x53, 0x80, 0x79, 0xC0, 0x99, 0xC0, 0xB7, 0x00, 0xD1, 0xC0, 0xEB, 0x00 - }, - - /* GM_2_5 */ - { - 0x57, 0x13, 0x18, 0x51, 0x0E, 0xF0, 0x0A, 0xC3, 0x08, 0x7D, 0x06, 0xED, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x56, 0xC0, 0x7C, 0xC0, 0x9C, 0x80, 0xB8, 0xC0, 0xD2, 0xC0, 0xEB, 0x00 - }, - - /* GM_2_6 */ - { - 0x5B, 0x13, 0x18, 0x28, 0x0E, 0x96, 0x0A, 0x92, 0x08, 0x29, 0x06, 0xB6, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x5A, 0x00, 0x7F, 0xC0, 0x9E, 0xC0, 0xBA, 0x80, 0xD3, 0x80, 0xEB, 0x00 - }, - - /* GM_2_7 */ - { - 0x5E, 0xC4, 0x18, 0x00, 0x0E, 0x78, 0x0A, 0x30, 0x08, 0x00, 0x06, 0x6D, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x5D, 0x00, 0x82, 0x80, 0xA1, 0x40, 0xBC, 0x00, 0xD4, 0x80, 0xEB, 0x00 - }, - - /* GM_2_8 */ - { - 0x62, 0x76, 0x17, 0xD7, 0x0E, 0x1E, 0x0A, 0x00, 0x07, 0xC1, 0x06, 0x36, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x60, 0x00, 0x85, 0x40, 0xA3, 0x40, 0xBD, 0x80, 0xD5, 0x40, 0xEB, 0x00 - }, - - /* GM_2_9 */ - { - 0x65, 0xD8, 0x17, 0xAE, 0x0D, 0xE1, 0x09, 0xCF, 0x07, 0x82, 0x06, 0x00, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x62, 0xC0, 0x87, 0xC0, 0xA5, 0x40, 0xBF, 0x00, 0xD6, 0x00, 0xEB, 0x00 - }, - - /* GM_3_0 */ - { - 0x69, 0x3B, 0x17, 0x85, 0x0D, 0xA5, 0x09, 0x86, 0x07, 0x43, 0x05, 0xDB, - 0x10, 0x1D, 0x36, 0x58, 0x82, 0xB3, 0xEB, - 0x10, 0x00, 0x65, 0x80, 0x8A, 0x40, 0xA7, 0x40, 0xC0, 0x40, 0xD6, 0x80, 0xEB, 0x00 - } -}; - -void __VISetTiming(u8 timing) -{ - __VIWriteI2CRegister8(0x00,timing); -} - -void __VISetYUVSEL(u8 dtvstatus) -{ - u8 vdacFlagRegion = 0; - u32 currTvMode = _SHIFTR(_viReg[1],8,2); - if(currTvMode==VI_PAL || currTvMode==VI_EURGB60) - vdacFlagRegion = 2; - else if(currTvMode==VI_MPAL) - vdacFlagRegion = 1; - - __VIWriteI2CRegister8(0x01, _SHIFTL(dtvstatus,5,3)|(vdacFlagRegion&0x1f)); -} - -void __VISetVBICtrl(u16 data) -{ - __VIWriteI2CRegister16(0x02, data); -} - -void __VISetTrapFilter(u8 disable) -{ - if (disable) - __VIWriteI2CRegister8(0x03, 0); - else - __VIWriteI2CRegister8(0x03, 1); -} - -void __VISet3in1Output(u8 enable) -{ - __VIWriteI2CRegister8(0x04,enable); -} - -void __VISetCGMS(u16 value) -{ - __VIWriteI2CRegister16(0x05, value); -} - -void __VISetWSS(u16 value) -{ - __VIWriteI2CRegister16(0x08, value); -} - -void __VISetRGBOverDrive(u8 value) -{ - u32 currTvMode = _SHIFTR(_viReg[1],8,2); - if (currTvMode == VI_DEBUG) - __VIWriteI2CRegister8(0x0A,(value<<1)|1); - else - __VIWriteI2CRegister8(0x0A,0); -} - -void __VISetOverSampling(void) -{ - __VIWriteI2CRegister8(0x65,1); -} - -void __VISetCCSEL(void) -{ - __VIWriteI2CRegister8(0x6a,1); -} - -void __VISetFilterEURGB60(u8 enable) -{ - __VIWriteI2CRegister8(0x6e, enable); -} - -void __VISetVolume(u16 value) -{ - __VIWriteI2CRegister16(0x71,value); -} - -void __VISetClosedCaption(u32 value) -{ - __VIWriteI2CRegister32(0x7a, value); -} - -void __VISetGamma(VIGamma gamma) -{ - u8 *data = (u8 *)&gamma_coeffs[gamma][0]; - __VIWriteI2CRegisterBuf(0x10, 0x21, data); -} - -/* User Configurable */ - -void VIDEO_SetGamma(VIGamma gamma) -{ - __VISetGamma(gamma); -} - -void VIDEO_SetTrapFilter(bool enable) -{ - if (enable) - __VISetTrapFilter(0); - else - __VISetTrapFilter(1); -} - -#endif diff --git a/genplus-gx/gx/utils/vi_encoder.h b/genplus-gx/gx/utils/vi_encoder.h deleted file mode 100644 index f5290dc568..0000000000 --- a/genplus-gx/gx/utils/vi_encoder.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** - * vi_encoder.c - * - * Wii Audio/Video Encoder support - * - * Copyright (C) 2009 Eke-Eke, with some code from libogc (C) Hector Martin - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ -#ifdef HW_RVL - -typedef enum -{ - VI_GM_0_1=1, - VI_GM_0_2, - VI_GM_0_3, - VI_GM_0_4, - VI_GM_0_5, - VI_GM_0_6, - VI_GM_0_7, - VI_GM_0_8, - VI_GM_0_9, - VI_GM_1_0, - VI_GM_1_1, - VI_GM_1_2, - VI_GM_1_3, - VI_GM_1_4, - VI_GM_1_5, - VI_GM_1_6, - VI_GM_1_7, - VI_GM_1_8, - VI_GM_1_9, - VI_GM_2_0, - VI_GM_2_1, - VI_GM_2_2, - VI_GM_2_3, - VI_GM_2_4, - VI_GM_2_5, - VI_GM_2_6, - VI_GM_2_7, - VI_GM_2_8, - VI_GM_2_9, - VI_GM_3_0 -} VIGamma; - -extern void VIDEO_SetGamma(VIGamma gamma); -extern void VIDEO_SetTrapFilter(bool enable); - - -#endif diff --git a/genplus-gx/sdl/CHANGELOG.txt b/genplus-gx/sdl/CHANGELOG.txt deleted file mode 100644 index 7d7d2cc780..0000000000 --- a/genplus-gx/sdl/CHANGELOG.txt +++ /dev/null @@ -1,694 +0,0 @@ --------------------- -Genesis Plus History --------------------- - -All recent changes were backported from the GX version (Gamecube/Wii port), maintained by Eke-Eke. -Please look at http://code.google.com/p/genplus-gx/ for more infos. - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.7.4 (21/06/2013) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core/SCD] ---------------- -* fixed access to read-only registers on Main-CPU side ("Batman Returns" platform level freeze) -* fixed & improved emulation of PRG-RAM write protection register ("Lunar Eternal Blue" japanese version freeze) -* improved SUB & MAIN-CPU synchronization ("Dracula Unleashed" freeze when using US Model 2 BIOS) -* improved CPU polling detection -* improved CDD emulation & added CD drive access time for SEEK command ("Panic!/Switch" intro missing scene) -* added missing reinitialization of MAIN-CPU PRG-RAM bank on reset -* added .OGG audio tracks support through LIBTREMOR - -[Core/Sound] ---------------- -* fixed YM2612 configurable DAC depth emulation -* improved Low-Pass filter -* added optional "MONO" output mode - -[Core/VDP] ---------------- -* fixed FIFO access timings when using invalid write code value ("Clue" menu) -* fixed DMA Copy with undocumented code value ("Fatal Labyrinth" end sequence) -* minor code fixes & optimizations - -[Core/CPU] ---------------- -* optimized 68k stack read/write functions -* fixed broken 68k address error emulation -* fixed 68k interrupt behavior (prevents interrupts from being executed multiple time when 68k is halted) -* fixed Z80 registers initial state, added proper initialization when using PBC (verified on real hardware by Charles McDonald) - -[Core/MD] ---------------- -* fixed SRAM incompatibilities between BIG ENDIAN & LITTLE ENDIAN platforms (note: this breaks old .srm files with LITTLE ENDIAN platform ports) -* added support for a few recently dumped unlicensed games -* added auto-detection of byte-swapped ROM files - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.7.3 (26/11/2012) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -no win32/SDL port changes - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.7.2 (24/11/2012) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core/SCD] ---------------- -* added default TOC for Shadow of the Beast II (prevent hangs when audio tracks are missing) -* fixed CD-DA fader muting -* fixed PCM channels panning on reset -* fixed backup RAM file management when using disc swap with Mode 1 cartridge -* incremented CD drive read latency: fixes Space Adventure Cobra (freeze when opening coffin at 2nd morgue scene) -* improved CDD emulation accuracy: fixes Snatcher (freeze at the end of Act 2) & various CD player bugs -* improved MAIN-SUB memory map mirroring in SCD mode (verified on real hardware by Charles McDonald) -* implemented cycle-accurate "stopwatch" register emulation - -[Core/Sound] ---------------- -* fixed broken PSG noise frequency -* fixed incorrect Game Gear PSG stereo emulation -* implemented cycle-accurate Game Gear PSG stereo - -[Core/VDP] ---------------- -* fixed broken VDP DMA from SVP ROM latency (graphic errors in Virtua Racing) - -[Core/MD] ---------------- -* added Super Mario World 64 (unlicensed) cartridge hardware emulation - -[Core/Input] ---------------- -* added automatic detection for CD games with Justifier/Menacer support -* improved Justifier/Menacer emulation - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.7.1 (13/10/2012) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core/SCD] ---------------- -* added support for CUE files -* added CD-DA tracks emulation (needs CUE+BIN or ISO+WAV images) -* added CD fader emulation -* added CDD "Fast FW" & "Fast RW" commands emulation -* improved CDD TOC emulation (random freezes in Sonic CD, Switch/Panic, Final Fight CD and probably many others) -* improved PCM chip synchronization with SUB-CPU (missing speeches in Willy Beamish) -* fixed PCM chip emulation (random hangs in Snatcher, missing sound effects in Switch/Panic, Final Fight CD, Wonderdog...) -* fixed Word-RAM memory mode on soft-reset (missing logo gfx effects) -* fixed SUB-CPU access to unused areas when using PC-relative instructions (Final Fight CD first boss random crash) -* fixed CPU idle loop detection on memory mode register access (Pugsy CD first boss slowdown) -* fixed Mode 1 emulation (cartridge boot mode) - -[Core/Sound] ---------------- -* replaced FIR resampler by Blip Buffer for FM resampling -* modified SN76489 core for use of Blip Buffer -* improved PSG & FM chips synchronization using Blip Buffer -* added Game Gear PSG stereo support -* fixed SG-1000 specific PSG noise -* fixed YM2612 LFO AM waveform (California Games surfing event) -* fixed YM2612 phase precision -* minor optimizations to YM2612 core - -[Core/Game Gear] ---------------- -* added support for CJ Elephant Fugitive (recently released by SMS Power) -* added Game Gear extended screen option - -[Core/Genesis] ---------------- -* added support for a few recently dumped (but unreleased) games - -[Core/General] ---------------- -* improved ROM & CD image file loading -* various code cleanup - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.7.0 (01/07/2012) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core/SCD] ---------------- -* added Mega CD / Sega CD hardware emulation (incl. Sub 68K, CDD, CDC, PCM, GFX rotation/scaling, etc) -* added .ISO & .BIN CD image file support -* added 512K backup cartridge RAM support -* added savestate support for CD games - -NOTES: -~~~~~~ -* to play CD games, original BIOS ROM files are required in /genplus/bios/ directory: unzip & rename them to bios_CD_U.bin, bios_CD_E.bin, bios_CD_J.bin -* CD audio tracks (CD-DA) are not supported (yet) - -[Core/CPU] ---------------- -* modified 68k core for Mega CD / Sega CD support -* optimized 68k core using prebuild const tables - -[Core/VDP] ---------------- -* improved DMA accuracy -* improved accuracy of nametables register & VSRAM writes during HBLANK: fixes "The Adventures of Batman & Robin" (graphical issues during 2nd Boss fight). -* added support for 8-bit VRAM writes with undocumented code value (verified on real hardware by Nemesis) - -[Core/Sound] ---------------- -* improved synchronization between SN76489 & YM2162 cores. -* improved accuracy of SN76489 core timings. - -[Core/MD] ---------------- -* added support for some recently dumped unlicensed games. -* improved emulation of 32k bankswitch hardware used by a few unlicensed games. -* fixed behavior of Z80 banked reads from 68k RAM (verified on real hardware). -* fixed support for 128K Pro Action Replay ROM. - -[Core/MS] ---------------- -* added support for all recent korean ROM dumps by SMS Power. -* added emulation of korean multi-game mapper (4-Pak All Action) -* added pseudo-random RAM pattern initialization on Mark-III and Japanese Master System (fixes "Alibaba and 40 Thieves" & "Block Hole") -* added port $3E emulation & internal BOOTROM support (Master System & Game Gear only). - -[Core/General] ---------------- -* added an option to set VDP mode (PAL/NTSC) independently from console region. -* added an option to select original system master clock frequency (PAL/NTSC/AUTO), emulation will run at selected frequency when VSYNC is disabled. -* fixed 68k context loading/saving (Sol Deace). -* fixed C89 incompatibilities for better portability. -* removed use of "long int" type for portability on 64-bit platforms. -* moved savestate zlib compression out of emulation core (for ports that don't use it). -* various optimizations. - -[Gamecube/Wii] ---------------- -* removed ROM load device selection from Load Menu: default ROM device must now be configured in menu settings. -* added specific load buttons, browsers & saved paths for each systems, this also fixes slowdowns caused by screenshot loading when browsing from slow devices. -* added support for left/right buttons as page up/down keys in ROM browsers -* added right analog stick as default "return to menu" key for Gamecube controllers -* added alternate remappable menu key combo for Gamecube controllers -* added an option to disable VSYNC (emulator is synced with audio hardware instead of video). -* added an option to boot system from "BIOS", with or without cartridge. -* added Master System & Game Gear "BIOS" support (files should be named bios_U.sms, bios_J.sms, bios_E.sms & bios.gg and copied to /genplus/bios directory). -* replaced "Hard Reset" button by a Soft Reset for systems having a Reset button (Mega Drive / Genesis & Master System) -* State & SRAM files are now only compressed when saving to Gamecube Memory Cards -* various fixes & cleanup. -* compiled with devkitPPC r26 & libogc 1.8.11. - -[Gamecube] ----------- -* improved progressive mode support when component cable is detected (hold B during startup to switch menu video mode configuration) - - ---------------------------------------------------------------------------------------------------------- -[07/08/2011] version 1.6.0 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core/Sound] ---------------- -* added YM2413 emulation in Master System compatibility mode. -* fixed SN76489 noise boost initialization. -* minor YM2612 core optimizations. - -[Core/VDP] ---------------- -* added accurate emulation of SG-1000, Master System (315-5124, 315-5246) & Game Gear VDP. -* added support for all TMS9918 rendering modes. -* improved Mega Drive VDP timings accuracy in Master System Compatibility mode. -* fixed color palette initialization. -* fixed shifted sprites rendering in Mode 4. -* modified pixel rendering support (pixel depth is now forced at compilation time). - -[Core/CPU] ---------------- -* optimized 68k core (rewrote 68k interrupt handling, removed multiple CPU types support & unused code) for 5~8% speed improvment - -[Core/IO] ---------------- -* added accurate emulation of Master System (315-5216, 315-5237, 315-5297) & Game Gear I/O controllers. -* added Terebi Oekaki tablet emulation. -* improved Mouse emulation (fixes mouse support in Cannon Fodder). -* improved Justifier emulation (fixes gun support in Lethal Enforcers 2). -* improved 6-Buttons control pad emulation (fixes Duke Nukem 3D) -* modified lightgun emulation to use common key inputs for all devices. -* 2-buttons controller is now picked by default for Master System games. - -[Core/MD] ---------------- -* added copy-protection hardware emulation for some new dumped games (Tiny Toon Adventures 3, Mighty Morphin Power Rangers & The Battle of Red Cliffs). -* added Game Toshokan in EEPROM database (verified on real cartridge). -* fixed Micro Machines 2 - Turbo Tournament EEPROM size (verified on real cartridge). -* modified SRAM banswitch hardware emulation to be more compatible with some hacks. - -[Core/MS] ---------------- -* added Cyborg Z to Korean mapper database. - -[Core/GG] ---------------- -* added 93C46 EEPROM emulation (Majors Pro Baseball, World Series Baseball & World Series Baseball 95). - -[Core/General] ---------------- -* added support for .mdx ROM format. -* added Game Gear & SG-1000 ROM support. -* added accurate emulation of SG-1000, Master System (I, II) & Game Gear hardware models for 100% compatibility. -* updated to new Genesis Plus license (see http://cgfm2.emuviews.com/) -* removed DOS port -* various code cleanup. - - ---------------------------------------------------------------------------------------------------------- -[31/03/2011] version 1.5.0 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core/VDP] ---------------- -* added support for Master System compatibility mode (Z80 ports access mode), incl. Mode 5 rendering. -* added Mode 4 rendering for both Genesis & Master System modes. -* added alternate BG planes rendering functions (should be faster on PPC architectures). - -[Core/IO] ---------------- -* added support for Master System compatibility mode (Z80 ports access mode). -* added Master System peripherals emulation (Control Pad, Paddle, Sports Pad & Light Phaser). -* added XE-1AP (analog controller) emulation. -* added Activator emulation. - -[Core/Extra] ---------------- -* added support for all known Master System cartridge mappers. -* added copy-protection hardware emulation for a few MD unlicensed games: fixes 777 Casino (crash when talking to bunny girls). -(NB: most of those unlicensed games seem to have been already patched by ROM dumpers, main purpose is documenting them) -* added support for Top Shooter arcade board controller. (A=Shoot, B=Bet, C/RIGHT=Coins, START=Start, hold UP on startup to enter service mode) -* improved King of Fighters 98 mapper emulation (registers address decoding is now 100% accurate) -* fixed Game Genie when several codes affect same ROM address. -* fixed EEPROM types for Brian Lara Cricket & NBA Jam TE (verified on real cartridges) - -[Core/General] ---------------- -* added Master System compatibility mode emulation (automatically enabled when loading ROM file with .sms extension). -* improved savestate stability & compatibility (support for old 1.4.x savestates is preserved) -* various code cleanup & comments. - - ---------------------------------------------------------------------------------------------------------- -[04/12/2010] version 1.4.1 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core/Sound] ---------------- -* implemented Blargg's blip buffer in SN76489 core (all channels are now lineary interpolated) - -[Core/VDP] ---------------- -* improved 2-cell vscroll emulation accuracy, as verified on real hardware (Gynoug, Cutie Suzuki no Ringside Angel, Formula One, Kawasaki Superbike Challenge) -* improved VBLANK flag accuracy, as observed on real hardware. -* improved DMA operations accuracy, writes are now performed on a scanline basis: fixes Gaiares (flickering title screen). -* improved DMA Fill timing accuracy. -* fixed DMA with bad code values: fixes Williams Arcade Classics (corrupted gfx after soft reset). -* fixed horizontal resolution changes during HBLANK: fixes Bugs Bunny in Double Trouble (2nd stage). -* fixed Vertical Counter in interlace mode 1, as observed on real hardware. -* fixed horizontal border width, as observed on real hardware. -* various code improvments & optimizations. - -[Core/CPU] ---------------- -* fixed state of Z80 registers on reset (sound issues with Defender & Defender 2 in Williams Arcade Classics) -* implemented 68k undocumented flags behavior for DIVU/DIVS instructions (Bloodshot / Battle Frenzy) - -[Core/Extra] ---------------- -* improved emulation of copy-protection hardware found in some unlicensed cartridges (Mulan, Pocket Monsters II). -* enabled simultaneous use of multitap & J-CART (Super Skidmarks 6-player mode) -* improved savestate format: added DMA, SVP, cartridge mapping & internal registers state informations -* improved unlicensed ROM mappers emulation -* added Chinese Fighters III mapper support -* added Top Fighter mapper support -* fixed Barver Battle Saga mapper support -* fixed cartridge hardware soft-reset (Game Genie, SVP, ...) -* fixed Game Genie registers byte reads - - ----------------------------------------------------------------------------------------------------------------------------------------------------- -[06/30/10] version 1.4.0 (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -[Core/Sound] - -* completely rewrote sound processing/mixing: sound chips are now clocked with exact output framerate -to ensure 100% smooth video & audio playback, with no lag or skipping, while rendering an accurate number -of samples per frame and keeping PSG & FM chips in sync. -* improved PSG & FM chips synchronization with CPU execution (fixed point precision). -* improved YM2612 core general accuracy (SSG-EG, CSM mode,...) (based upon Nemesis recent tests on real hardware) -* improved YM2612 LFO emulation accuracy: fixes "Spider-Man & Venom : Separation Anxiety" (intro) -* fixed YM2612 bug with Timer B: fixes "Langrisser Hikari II"/"Der Langrisser II" (Sega logo) -* fixed YM2612 context saving/loading. -* fixed YM2612 state on reset. -* removed outdated & less accurate Gens YM2612 core -* added configurable YM2612 DAC resolution emulation. -* added configurable & faster FIR resampler (thanks to Blargg & AamirM), removed libsamplerate support. -* added configurable Low-Pass filtering -* added configurable 3-Band Equalizer (thanks to Neil C). -* added an option to boost SN76489 Noise Channel. -* adjusted SN76489 cut-off frequency. - - -[Core/VDP] - -* added support for CRAM writes during horizontal blanking (Striker, Zero the Kamikaze Squirrel,...) -* added support for 2-Cell vertical scrolling in Interlaced 2 mode -* added support for some undocumented mode register bits -* added proper emulation of HV Counter latch: fixes Sunset Riders intro -* added pixel-accurate emulation of mid-line display on/off (Nigel Mansell World Championship PAL, Ren & Stimpy's Invention PAL,...) -* improved FIFO timings accuracy: fixes Sol Deace intro -* improved sprite masking accuracy (thanks to Nemesis for his test program) -* improved sprites processing accuracy: fixes (un)masked sprites in Mickey Mania (3D level), Sonic 2 (VS mode). -* improved HBLANK flag timing accuracy: fixes Mega Turrican (Sky level) -* improved horizontal blanking & HINT/VINT occurence timing accuracy, as measured on real hardware. -* improved HCounter accuracy in 40-cell mode, as measured on real hardware. -* improved color accuracy in VDP highlight mode to match results observed on real hardware - - -[Core/CPU] - -* updated Z80 core to last version (fixes interrupt Mode 0 timing and some BIT instructions). -* fixed some Z80 instructions timing. -* improved Z80 interrupt accuracy -* improved 68k accuracy (initial Reset timing + auto-vectored interrupts handling). -* improved 68k timing accuracy for DIVU/DVIS (thanks to Jorge Cwik) & MULU/MULS instructions. -* improved Z80 & 68k cpu execution/synchronization accuracy by using Master Clock as common reference (now run exactly 3420 M-Cycles per line). -* modified Z80 & 68k cores to directly use external cycle count instead of intermediate counters. - - -[Core/Extra] - -* added Game Genie hardware emulation (Game Genie ROM is now fully supported). -* added Action Replay hardware emulation (Action replay ROM is now fully supported). -* added S&K "Lock-On" hardware emulation (you can "lock" any games to Sonic & Knuckles). -* added Cartridge "hot swap" feature. -* added missing EEPROM support in some games. -* added accurate TMSS emulation (VDP lock-out) -* fixed Realtec mapper emulation: fixes missing sound in Balloon Boy / Funny World. -* fixed lightgun auto-detection: fixes default cursor position in Lethal Enforcers II. -* lots of code cleanup, bugfixes & optimization. - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [12/14/08] version 1.3.0 (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* YM2612 bugfixes (MAME core): - .fixed EG Decay->Substain transition when SL & DR are minimals: fix tracks #3 and #9 in "Mega Turrican" - .fixed a bug in SSG-EG emulation code: fix Level 1 music in "Alisia Dragoon" - .modified SSG-EG Decay End Level: fix some sound effects (ChainSaw, Zap...) in "Beavis & Butthead" - .improved Detune overflow accuracy: fix very high frequency sounds in many games - .fixed registers 0x20-0x26 Reset state: fix intro music in "B.O.B" - .reverted incorrect fix with KEY ON: fix "Flamethrower" sound effect in "Alien 3" and many others -* adjusted HCounter values: fixes line flickering in "Sonic 3D" bonus stage -* adjusted VINT timing: fixes hang-up in "V.R Troopers" -* improved HBLANK flag accuracy: fixes line flickering in "Gouketsuji Ichizoku" -* fixed broken Z80 access to WRAM: fixes hang-up in "Mamono Hunter Youko" -* modified JCART emulation: fixes corrupted tracks logo in "Micro Machines 2" -* added Blargg's NTSC Filters support (NTSC video artifacts emulation) -* optimized VDP rendering core, rewrote 68k interface (memory handlers, cycle execution, interrupts): greatly improved emulation speed - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [08/26/08] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* YM2612(MAME): fixed LFO phase update for CH3 special mode: fix sound effects in Warlock & Aladdin (thanks to AamirM) -* YM2612(MAME): fixed EG attenuation level on "KEY ON": fix Ecco 2's splash sound -* YM2612(MAME): fixed SSG-EG emulation: fix Bubba'n Stix (Track 5) and many others -* YM2612(MAME): replaced sample interpolation with libsamplerate support, High Quality mode is now more accurate -* implemented cycle-accurate HINT timings: every timing sensitive games/demos are now *finally* working fine -* fixed a bug affecting CRAM/VSRAM DMA timings -* fixed Sprite Attribute Table address mask for VRAM writes -* improved accuracy of 68k access to Z80: fix music in Pacman 2 when entering PAUSE menu -* disabled "Address Error" emulation when UMK3 hack is loaded: fix game crashing after a round ends up -* added support for some more unlicensed games: Pocket Monster, King of Fighter 98, Soul Blade (credits to Haze) -* improved Menacer emulation: fix lightgun support in Body Count & T2: The Arcade Game -* added Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2 -* added Sega Mouse emulation (Populous 2, Body Count, Shangai 2, Fun'n Games, ...) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [07/16/08] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* adjusted (again) HINT timings: fix Double Dragon 2 (game freezed), hopefully does not break anything else -* fixed broken EEPROM support for Codemaster games -* modified input update timings: fix Dungeons & Dragons * Warriors of the Eternal Sun (thanks to Notaz) -* added support for "Ultimate Mortal Kombat Trilogy" hack (max. size supported is 10MBytes) -* added (VERY) preliminar support for PICO roms (credits to Notaz for his documentation) -* improved YM2612 emulation (credits to Nemesis for his tests on real hardware): - .implemented phase overflow emulation: improved fix for special music instrument used in Comix Zone, Flashback, Ariel, Shaq Fu... - .improved SSG-EG emulation in MAME core (also based on additional code from Alone Coder) - .improved Timers emulation accuracy - .improved Enveloppe Generator accuracy - .fixed Channel 3 CSM mode emulation - .implemented sample interpolation in MAME core to emulate the chip at original frequency (HQ YM2612 mode, from gens) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [06/01/08] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* improved HCounter accuracy: fix graphic glitches in "Striker (Europe)" -* improved HINT timing accuracy: fix flickering in "Zero The Kamikaze Squirrel (USA)" -* improved rendering accuracy when backdrop color is modified during HBLANK (Road Rash I/II/III) -* fixed broken Game Genie support - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [04/19/08] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* modified VINT timings a little bit: fix lockup during Desert Strike's intro -* corrected 68k interrupts handling: fix graphic glitches in Darius II/Sagaia - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [04/06/08] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* updated SVP core: fix some perspective issues in Virtua Racing (thanks to Notaz) -* added internal SAT update during VRAM Fill: fix unmasked sprites during Battletech's intro -* fixed m68k core issues with gcc 4.2.3: fix Xperts, Lemmings 2, M1 Abrams Battle Tank -* forced YM2612 Enveloppe update: fix intro music in Batman&Robin (thanks to Aamir) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [03/01/08] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* added SVP emulation: Virtua Racing is now emulated (big thanks to Notaz and TascoDeluxe) -* fixed VDP registers behaviour when VDP Mode 4 is enabled: fix Bass Masters Classic Pro, Captain Planet & The Planeeters -* corrected a bug in DMA Fill operation: fix James Pond 3, Rockman World/Megaman Willy Wars (corrupted VRAM) -* corrected typo errors in CPU cycle counters update: fix optiom screen music in "College Slam" and probably others games. -* added preliminary support of undocumented YM2612 bug: fixes soundtracks of Shaq Fu, Spiderman, Comix Zone, Ariel and some others -* added support for mappers & copy protection devices used in many unlicensed/pirate cartridges (see cart_hw.c for details) -* rewrote memory handlers for better modularity and some (little) speedup -* reduced Savestate size - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [01/07/08] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* fixed interleaved rom detection: roms with .smd extension should now work fine -* fixed a recently introduced bug in VDP registers writes: fixes bad colors in Toy Story (intro) -* updated list of games using EEPROM: added Sports Talk Baseball (internal memory check fixed) and Brian Lara Cricket -* fixed VINT flag update when VINT is disabled: fixes NCAA College Football -* adjusted DMA timings in H32 mode: fixes flickering in Out of this World, Kawasaki Superbike Challenge & Formula One -* adjusted line rendering and HBLANK timings: fixes flickering in Nigel Mansell's World Championship Racing, Deadly Moves/Power Athlete -* fixed unmapped ROM reads through Z80 Bank: fixes Zombie High (Proto) -* added support for custom ROM/RAM mapping used by Game no Kanzume Otokuyou - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [12/28/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* many sourcecode cleanup and optimization -* completely rewrote EEPROM emulation: now support all known EEPROM types (24C01-24C65) and mappers (Sega, Acclaim, EA, Codemasters) -used in a few games (now use internal game database) as external RAM. This should at least fix save support in the following games: - . NBA Jam (alternate Acclaim mapper) - . College Slam, Frank Thomas Big Hurt Baseball (24C65 type) - . NHLPA Hockey 93, Rings of Power (EA mapper) - . Micro Machines serie, Brian Lara Cricket 96/Shane Warne Cricket (Codemasters mapper) -* external RAM is now initialized to 0xFF by default: fix Micromachines 2, Dino Dini Soccer -* fixed SRAM 16-bits memory handlers: fix some Sega Sports and EA Sports games (NFL95, NBA Action 95, NHL97, NHL98,...) -* modified WRITE_xxx & READ_xxx macros for better portability and faster memory access on BIG ENDIAN platform -* completely rewrote BIG ENDIAN support in render.c and vdp.c: rendering should be a little faster -* rewrote ROM bankswitch emulation (Super Street Fighter II): ROM access are faster, using memory pointers instead of reading ROM copy from ARAM -* fixed leftmost Window/PlaneA column render and implemented Window bug (as described by Charles Mc Donald) -* improved "Sprite Limit" and "Sprite Collision" detection accuracy -* modified RGB565 Color Palette to use the full available color range (0-31;0-63) -* implemented "cycle accurate" HV Interrupt timings: fix Sesame's Street Counting Cafe, Legend of Galahad (intro) -* improved VDP access timings accuracy (added FIFO emulation): fix Double Clutch -* improved DMA timings accuracy: fix Winter Olympics (E), Arch Rivals and probably more -* fixed HCounter again: Road Rash serie (I,II,III) don't need timing hacks anymore -* fixed VCounter in Interlaced 2 mode: fix Combat Cars "VS-Mode" -* improved Interlaced 2 mode (double resolution) rendering: Sonic 2, Combat Cars ("VS-Modes") look far better -* added TMSS BIOS support (optional) -* rewrote part of the YM2162 MAME's core: fixed internal FM timers handling, removed non-YM2612 emulation code and unused multiple cpu support -* implemented "cycle accurate" FM timers & sound samples rendering -* improved Z80 Interrupt timing accuracy: fix Sonic 3 music slowdowns -* updated Z80 & 68000 cores to last MAME versions -* improved Soft Reset emulation: X-Men 2 and Eternal Champions (random character selection) now work more like on real hardware. -* added full overscan emulation (vertical & horizontal borders) for "pixel perfect" aspect ratio (tested against a real genesis) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [07/20/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* corrected TeamPlayer support: fix multiplayer in Gauntlet 4 (Sept. version), Pengo and a lot of others -* added J-Cart support: enable multiplayer in Codemasters games (Pete Sampras, Micromachines games, Super Skidmarks) -* added serial EEPROM autodetection: fix games with bad SRAM informations in header (NBA Jam TE) -* added SVP faking: display 2D graphics in Virtua Racing (the game is however still unplayable) -* added support for more internal IO registers: fixe some unlicensed games (Wisdom Tree games...) -* added preliminary support for unmapped protection device: fix some unlicensed games with special built-in hardware (Squirell King, Lion King 2...) -* added "Soft Reset" combo (in game, use L+Z triggers): this should be like pressing the RESET button on a real Genesis and this is required - in some games to enable special features or even complete the game (ex: X-Men). - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [06/21/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* added Multitap support (EA 4-Way Play and Sega Teamplayer): allowed up to four players in games supporting those peripherals -* added partial Sega Menacer lightgun support (use Analog Stick): automatically set when detecting the 6-in-1 Menacer game - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [05/18/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* you can now switch between FM cores without reseting the game. FM registers value are automatically restored when switching. -* removed the previous VINT timings modification because it brokes some games (Rocket Knight, Thunderforce III,...) -* added automatic Timing configuration (VDP latency, VINT timing & alternate Line Timing) at game loading, based upon specific romname detection. -This means you can still modify some of these options afterwards but they are now automatically set/unset when loading a game which need -special timing fixes. These fixes are also automatically desactivated when the current game doesn't need them. -For information, games that are actually detected and need special timings to run properly are: - .Legend of Galahad & Road Rash series (single line not rendered properly) - .Sesame Street Counting Cafe (don't boot) - .Chaos Engine/Soldiers of Fortune (graphic glitches on scrolling) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [05/08/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* VINT timings are now a little more accurate: fixes Sesame's Street Counting Cafe -* SN76496 MAX_OUTPUT back to normal -* modified FB_WNOISE value in SN76496 core according to John Kortink's last informations -* added support for Maxim's PSG core, same as used in SMSPLUS (it becomes the default PSG core) -* updated FM core to the latest MAME version -* corrected DAC output level (fixes voices and some special FX being too low) -* added support for Gens YM2612 (FM) core (MAME's one still remains default FM core) -* added configurable preamplification for each sound cores (see Emulator Options) -* added some other configurable sound options (boost overall volume, FM improvment for Gens YM2612) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [04/11/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* corrected MAX_OUTPUT value in SN76496 core: fix PSG sound (SFX) volume - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [03/17/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - - * added an option to enable alternate line rendering timing (fix single line error in Road Rash series and Legend of Galahad's Intro) - * Color RAM update now always reset color 0 to border color (fix color glitches in Mortal Kombat,...) (thanks to Noop's for the idea) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [03/09/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* modified HV counter tables (fix graphic glitches in Skitchin's sky, Lotus 2 Recs, Panorama Cotton, Dashin Desperados & maybe more) -* completely rewrote DMA timings emulation so that it works for all games (no more cpu freezing) -* added all DMA tranfer rates handling for each three DMA modes and added dma busy flag emulation -* modified interrupts handling on VDP register #0 and #1 writes (fix Lemmings status bar) -* added VDP RAM write latency (fix Chaos Engine/Soldier of Fortune gfx glitches) -* modified FM timers handling a bit (fix Vectorman2 music) -* corrected Sprite Limit rendering (fix Sonic 1 & Micromachines 2 title screens) -* corrected IO Registers writes (fix Decap' Attack controls, no more need for alternate input) -* corrected 6 Buttons Pad emulation (fix 6buttons detection in Mortal Kombat 3, Comix Zone and other 6-buttons compatible games) -* modified sound mixing a bit according to Generator sourcecode (FM and PSG ratios seems more correct) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [02/07/07] (Eke-Eke) ----------------------------------------------------------------------------------------------------------------------------------------------------- - -* fixed fm timers (fix missing music in Castle of Illusion, Quackshot, Undead Line, Wonderboy in Monster Lair, Cal 50, Turbo Outrun, Thundeforce 4 and maybe more) -* added complete EEPROM emulation (save support now works fine in Wonderboy5, Megaman Willy Wars, NBA Jam...) (credits to Notaz, adapted from Picodrive code) -* added preliminar dma timing emulation (fix bottom screen in Legend of Galahad) (credits to Notaz, adapted from Picodrive code) -* hack: clear Vint pending after Hint (INT level 4) acknowledge (fix Fatal Rewind) -* hack: modify read_bus16 to return a random value (fake fetch) (fix Time Killers) -* modified cpu execution timings, with more correct hblank and interrupts timing (fix ISS Deluxe, Double Dragon 2 and certainly more) (Based on Gens code) -* modified busreq mechanism: better synchro between z80 & 68k (no need to dejitter anymore) (Based on Gens code) -* added sprite collision detection (fix Strider 2) -* modified dma fill operation for big endian platform (fix Contra Hardcorps gfx garbage) - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [05/25/03] (Charles MacDonald) ----------------------------------------------------------------------------------------------------------------------------------------------------- - - * Fixed a typo that made Z80 banked access to the VDP registers always fail. - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [05/17/03] (Charles MacDonald) ----------------------------------------------------------------------------------------------------------------------------------------------------- - - * Modified the rendering code to handle unaligned longword access to memory. - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [04/20/03] (Charles MacDonald) ----------------------------------------------------------------------------------------------------------------------------------------------------- - - * Modified 68000 emulator to prevent 'tas.b $mem' from writing data back - after a read (fixes Gargoyles). - * Fixed bug in 68000 emulator to swap order of words written for address - register indirect pre-decremented writes (fixes Jim Power graphics). - * Added support for 240-line displays (for Super Skidmarks). - * Rewrote part of the interrupt handling (fixes some raster effects). - * Removed sprite collision detection code (never really worked). - * Optimized sprite rendering inner loop. - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [04/13/03] (Charles MacDonald) ----------------------------------------------------------------------------------------------------------------------------------------------------- - * Finished up memory map for VDP DMA V-bus reads. - * Fixed handling of 68000 writes to I/O chip at even addresses. - * Fixed bit 7 handling of control register in I/O chip. - * Finished up Z80 memory map. - * Added code to handle Genesis hardware lock-ups. - * Removed some faulty code from the 68000 memory map handlers. - - ----------------------------------------------------------------------------------------------------------------------------------------------------- - [03/22/03] (Charles MacDonald) ----------------------------------------------------------------------------------------------------------------------------------------------------- - - * Completed implementation of Z80 banked memory handlers. - diff --git a/genplus-gx/sdl/LICENSE.txt b/genplus-gx/sdl/LICENSE.txt deleted file mode 100644 index a8d781cfd8..0000000000 --- a/genplus-gx/sdl/LICENSE.txt +++ /dev/null @@ -1,585 +0,0 @@ - -Unless otherwise explicitly stated, all code in Genesis Plus is released -under the following license: - -Copyright Charles MacDonald -Some portions copyright Nicola Salmoria and the MAME team -All rights reserved. - -Copyright (c) 2006-2013 Eke-Eke -All rights reserved. - -Redistribution and use of this code or any derivative works are permitted -provided that the following conditions are met: - -* Redistributions may not be sold, nor may they be used in a commercial -product or activity. - -* Redistributions that are modified from the original source must include the -complete source code, including the source code for all components used by a -binary built from the modified sources. However, as a special exception, the -source code distributed need not include anything that is normally distributed -(in either source or binary form) with the major components (compiler, kernel, -and so on) of the operating system on which the executable runs, unless that -component itself accompanies the executable. - -* Redistributions must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - ----------------------------------------------------------------------------------------- - -TREMOR library is distributed under the following license: - -Copyright (c) 2002, Xiph.org Foundation - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of the Xiph.org Foundation nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - ----------------------------------------------------------------------------------------- - -NTSC Filter and Blip Buffer libraries are distributed under the -terms of the GNU Lesser General Public License - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/genplus-gx/sdl/Makefile.sdl b/genplus-gx/sdl/Makefile.sdl deleted file mode 100644 index 1dd05ce166..0000000000 --- a/genplus-gx/sdl/Makefile.sdl +++ /dev/null @@ -1,173 +0,0 @@ - -# Makefile for genplus SDL -# -# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald -# modified by Eke-Eke -# -# Defines : -# -DLSB_FIRST : for little endian systems. -# -DLOGERROR : enable message logging -# -DLOGVDP : enable VDP debug messages -# -DLOGSOUND : enable AUDIO debug messages -# -DLOG_SCD : enable SCD debug messages -# -DLOG_CDD : enable CDD debug messages -# -DLOG_CDC : enable CDC debug messages -# -DLOG_PCM : enable PCM debug messages -# -DLOGSOUND : enable AUDIO debug messages -# -D8BPP_RENDERING - configure for 8-bit pixels (RGB332) -# -D15BPP_RENDERING - configure for 15-bit pixels (RGB555) -# -D16BPP_RENDERING - configure for 16-bit pixels (RGB565) -# -D32BPP_RENDERING - configure for 32-bit pixels (RGB888) - -NAME = gen_sdl.exe - -CC = gcc -CFLAGS = `sdl-config --cflags` -march=i686 -O6 -fomit-frame-pointer -Wall -Wno-strict-aliasing -ansi -std=c89 -pedantic-errors -#-g -ggdb -pg -#-fomit-frame-pointer -#LDFLAGS = -pg -DEFINES = -DLSB_FIRST -DUSE_16BPP_RENDERING -DUSE_LIBTREMOR - -SRCDIR = ../core -INCLUDES = -I$(SRCDIR) -I$(SRCDIR)/z80 -I$(SRCDIR)/m68k -I$(SRCDIR)/sound -I$(SRCDIR)/input_hw -I$(SRCDIR)/cart_hw -I$(SRCDIR)/cart_hw/svp -I$(SRCDIR)/cd_hw -I$(SRCDIR)/ntsc -I$(SRCDIR)/tremor -I$(SRCDIR)/../sdl -LIBS = `sdl-config --libs` -lz -lm - -OBJDIR = ./build_sdl - -OBJECTS = $(OBJDIR)/z80.o - -OBJECTS += $(OBJDIR)/m68kcpu.o \ - $(OBJDIR)/s68kcpu.o - -OBJECTS += $(OBJDIR)/genesis.o \ - $(OBJDIR)/vdp_ctrl.o \ - $(OBJDIR)/vdp_render.o \ - $(OBJDIR)/system.o \ - $(OBJDIR)/io_ctrl.o \ - $(OBJDIR)/mem68k.o \ - $(OBJDIR)/memz80.o \ - $(OBJDIR)/membnk.o \ - $(OBJDIR)/state.o \ - $(OBJDIR)/loadrom.o - -OBJECTS += $(OBJDIR)/input.o \ - $(OBJDIR)/gamepad.o \ - $(OBJDIR)/lightgun.o \ - $(OBJDIR)/mouse.o \ - $(OBJDIR)/activator.o \ - $(OBJDIR)/xe_a1p.o \ - $(OBJDIR)/teamplayer.o \ - $(OBJDIR)/paddle.o \ - $(OBJDIR)/sportspad.o \ - $(OBJDIR)/terebi_oekaki.o - -OBJECTS += $(OBJDIR)/sound.o \ - $(OBJDIR)/sn76489.o \ - $(OBJDIR)/ym2413.o \ - $(OBJDIR)/ym2612.o - -OBJECTS += $(OBJDIR)/blip_buf.o - -OBJECTS += $(OBJDIR)/eq.o - -OBJECTS += $(OBJDIR)/sram.o \ - $(OBJDIR)/svp.o \ - $(OBJDIR)/ssp16.o \ - $(OBJDIR)/ggenie.o \ - $(OBJDIR)/areplay.o \ - $(OBJDIR)/eeprom_93c.o \ - $(OBJDIR)/eeprom_i2c.o \ - $(OBJDIR)/eeprom_spi.o \ - $(OBJDIR)/md_cart.o \ - $(OBJDIR)/sms_cart.o - -OBJECTS += $(OBJDIR)/scd.o \ - $(OBJDIR)/cdd.o \ - $(OBJDIR)/cdc.o \ - $(OBJDIR)/gfx.o \ - $(OBJDIR)/pcm.o \ - $(OBJDIR)/cd_cart.o - -OBJECTS += $(OBJDIR)/sms_ntsc.o \ - $(OBJDIR)/md_ntsc.o - -OBJECTS += $(OBJDIR)/main.o \ - $(OBJDIR)/config.o \ - $(OBJDIR)/error.o \ - $(OBJDIR)/unzip.o \ - $(OBJDIR)/fileio.o - -OBJECTS += $(OBJDIR)/bitwise.o \ - $(OBJDIR)/block.o \ - $(OBJDIR)/codebook.o \ - $(OBJDIR)/floor0.o \ - $(OBJDIR)/floor1.o \ - $(OBJDIR)/framing.o \ - $(OBJDIR)/info.o \ - $(OBJDIR)/mapping0.o \ - $(OBJDIR)/mdct.o \ - $(OBJDIR)/registry.o \ - $(OBJDIR)/res012.o \ - $(OBJDIR)/sharedbook.o \ - $(OBJDIR)/synthesis.o \ - $(OBJDIR)/vorbisfile.o \ - $(OBJDIR)/window.o - -OBJECTS += $(OBJDIR)/icon.o - -all: $(NAME) - -$(NAME): $(OBJDIR) $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@ - -$(OBJDIR) : - @[ -d $@ ] || mkdir -p $@ - -$(OBJDIR)/%.o : $(SRCDIR)/%.c $(SRCDIR)/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/sound/%.c $(SRCDIR)/sound/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/input_hw/%.c $(SRCDIR)/input_hw/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/%.c $(SRCDIR)/cart_hw/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/svp/%.c - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/svp/%.c $(SRCDIR)/cart_hw/svp/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/cd_hw/%.c $(SRCDIR)/cd_hw/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/z80/%.c $(SRCDIR)/z80/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/m68k/%.c - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/ntsc/%.c $(SRCDIR)/ntsc/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/tremor/%.c $(SRCDIR)/tremor/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/tremor/%.c - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/%.o : $(SRCDIR)/../sdl/%.c $(SRCDIR)/../sdl/%.h - $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ - -$(OBJDIR)/icon.o : - windres $(SRCDIR)/../sdl/icon.rc $@ - -pack : - strip $(NAME) - upx -9 $(NAME) - -clean: - rm -f $(OBJECTS) $(NAME) diff --git a/genplus-gx/sdl/README.txt b/genplus-gx/sdl/README.txt deleted file mode 100644 index 500adecab7..0000000000 --- a/genplus-gx/sdl/README.txt +++ /dev/null @@ -1,146 +0,0 @@ - -DISCLAIMER: - -THIS IS A VERY BASIC & UNSTABLE PORT WHICH ONLY PURPOSE -IS TO SHOW HOW TO USE GENESIS PLUS GX CORE & INTERFACE IT -WITH SDL IN PARTICULAR. BUILDS ARE NOT MEANT TO BE REALLY -USED FOR ANYTHING ELSE BUT EASIER CORE DEBUGGING ON WINDOWS. -PLEASE DO NOT DISTRIBUTE WIN32 BINARIES WITHOUT THIS NOTICE. -END USERS SHOULD PREFERABLY USE LIBRETRO PORT WITH RETROARCH. - ----------------------------------------------------------------------------- - Genesis Plus (Windows Port) ----------------------------------------------------------------------------- - - based on the original version 1.3 - by Charles Mac Donald - WWW: http://cgfm2.emuviews.com - - version 1.7.4 - backported from Genesis Plus GX - by Eke-Eke - WWW: http://code.google.com/p/genplus-gx - E-mail: ekeeke31@gmail.com - - - What's New - ---------- - - see CHANGELOG.txt - - - Features - --------- - - * accurate emulation of SG-1000, Mark-III, Master System (I & II), Game Gear, Genesis / Mega Drive, Sega / Mega CD hardware models (incl. backwards compatibility modes) - * NTSC (60Hz) & PAL (50Hz) video hardware emulation - * accurate CDD, CDC & GFX chip emulation (Sega/Mega CD) - * CD-DA fader emulation (Sega/Mega CD) - * Mode 1 cartridge support (Sega/Mega CD) - * highly accurate 68000 & Z80 CPU emulation - * highly accurate VDP emulation (all rendering modes, mid-line changes, undocumented registers,…) & timings (HBLANK, DMA, FIFO, HV interrupts,…) - * sample-accurate YM2612,YM2413, PSG, & PCM emulation (all sound chips are running at the original frequency) - * cycle-accurate chip synchronization (68000’s/Z80/YM2612/PSG/PCM) - * high-quality audio resampling using Blip Buffer - * basic hardware latency emulation (VDP/68k, Z80/68k) - * full overscan area emulation (horizontal & vertical color borders) - * optional Game Gear extended screen mode - * internal BOOT ROM support (Master System, Genesis / Mega Drive, Sega / Mega CD) - * optional TMSS hardware emulation (Genesis / Mega Drive) - * support for Blargg's software NTSC filters - * preliminary PICO emulation - * support for raw (.bin, .gen, .md, .sms, .gg & .sg) and interleaved (.smd & .mdx) ROM files - * support for CUE+BIN, ISO+OGG & ISO+WAV CD image files - * 2-buttons, 3-buttons & 6-buttons controllers emulation - * Sega Team Player & EA 4-Way Play multitaps emulation - * Sega Mouse emulation - * Sega Paddle Control & Sports Pad analog emulation - * Terebi Oekaki tablet emulation - * Sega Light Phaser, Menacer & Justifiers lightgun emulation - * Sega Activator & XE-1AP analog controller emulation - * SVP DSP (Virtua Racing) emulation - * J-Cart adapter (Micro Machines & Pete Sampras series, Super Skidmarks) emulation - * Backup RAM (max. 64KB), I2C (24Cxx), SPI (95xxx) & MicroWire (93C46) EEPROMs emulation - * Sega/Mega CD RAM cart (max. 512KB) emulation - * “official” ROM bankswitch hardware (Super Street Fighter 2) emulation - * “official” backup RAM bankswitch hardware (Phantasy Star 4, Legend of Thor, Sonic the Hedgehog 3) emulation - * support for all known unlicensed/pirate cartridges bankswitch & copy protection hardware - * emulation of all known Master System & Game Gear cartridge “mappers” (incl. unlicensed Korean ones) - * Game Genie & Action Replay hardware emulation - * Sonic & Knuckles “Lock-On” hardware emulation - * support for ROM image up to 10MB (Ultimate MK3 hack) - - - Usage - ----- - - The Windows version runs windowed in a 16-bit desktop with 48Hz sound using SDL but - without joystick support. - - - Controls - ----- - - Arrow Keys - Directional pad - A/Q,S,D,F - buttons A, B(1), C(2), START - W,X,C,V - buttons X, Y, Z, MODE if 6-buttons controller is enabled - Tab - Hard Reset - Esc - Exit program - - F2 - Toggle Fullscreen/Windowed mode - F4 - Toggle Audio (Turbo mode must be disabled first) - F6 - Toggle Turbo mode (Audio must be disabled first) - F7 - Load Savestate (game.gpz) - F8 - Save Savestate (game.gpz) - F9 - Toggle VDP mode: PAL(50hz)/NTSC(60hz) - F10 - Soft Reset - F11 - Toggle Border emulation - F12 - Toggle Player # (test only) - - - The mouse is used for lightguns, Sega Mouse, PICO & Terebi Oekaki tablet (automatically detected when loading supported game). - - A SRAM file (game.srm) is automatically saved on exit and loaded on startup. - - - Credits - -------- - - Core(s) improvements & additional features by Eke-Eke - - Original code by Charles MacDonald - - Original Z80 core by Juergen Buchmueller - - Original Musashi 68k core by Karl Stenerud - - Original YM2612/YM2413 cores by Jarek Burczynski & Tatsuyuki Satoh - - Original SN76489 core by Maxim - - Original SVP core by Notaz - - Blip Buffer & NTSC Video filter libraries by Shay Green (Blargg) - - 3-Band EQ implementation by Neil C - - TREMOR VORBIS decoding library by Xiph.org - - Zlib by Jean-Loup Gailly & Mark Adler - - - Aknowledgements - ---------------- - - The following emulator authors: Bart Trzynadlowski, Steve Snake, Stef, Notaz, AamirM - - The regular people at spritesmind.net and smspower.org. - - The MAME team for the CPU and sound chip emulators. - - Nemesis for the researches on the YM2612 and VDP. - - Tasco Deluxe for the documentation of Realtec mapper. - - Haze for the reverse-engineering of many unlicensed games protection. - diff --git a/genplus-gx/sdl/config.c b/genplus-gx/sdl/config.c deleted file mode 100644 index 408cac5423..0000000000 --- a/genplus-gx/sdl/config.c +++ /dev/null @@ -1,52 +0,0 @@ - -#include "osd.h" - -t_config config; - - -void set_config_defaults(void) -{ - int i; - - /* sound options */ - config.psg_preamp = 150; - config.fm_preamp = 100; - config.hq_fm = 1; - config.psgBoostNoise = 1; - config.filter = 1; - config.low_freq = 200; - config.high_freq = 8000; - config.lg = 1.0; - config.mg = 1.0; - config.hg = 1.0; - config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */ - config.dac_bits = 14; - config.ym2413 = 2; /* = AUTO (0 = always OFF, 1 = always ON) */ - config.mono = 0; - - /* system options */ - config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */ - config.region_detect = 0; /* = AUTO (1 = USA, 2 = EUROPE, 3 = JAPAN/NTSC, 4 = JAPAN/PAL) */ - config.vdp_mode = 0; /* = AUTO (1 = NTSC, 2 = PAL) */ - config.master_clock = 0; /* = AUTO (1 = NTSC, 2 = PAL) */ - config.force_dtack = 0; - config.addr_error = 1; - config.bios = 0; - config.lock_on = 0; /* = OFF (can be TYPE_SK, TYPE_GG & TYPE_AR) */ - - /* display options */ - config.overscan = 0; /* 3 = all borders (0 = no borders , 1 = vertical borders only, 2 = horizontal borders only) */ - config.gg_extra = 0; /* 1 = show extended Game Gear screen (256x192) */ - config.render = 0; /* 1 = double resolution output (only when interlaced mode 2 is enabled) */ - - /* controllers options */ - input.system[0] = SYSTEM_MD_GAMEPAD; - input.system[1] = SYSTEM_MD_GAMEPAD; - config.gun_cursor[0] = 1; - config.gun_cursor[1] = 1; - config.invert_mouse = 0; - for (i=0;i - -static int check_zip(char *filename); - -int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension) -{ - int size = 0; - - if(check_zip(filename)) - { - unz_file_info info; - int ret = 0; - char fname[256]; - - /* Attempt to open the archive */ - unzFile *fd = unzOpen(filename); - if (!fd) return 0; - - /* Go to first file in archive */ - ret = unzGoToFirstFile(fd); - if(ret != UNZ_OK) - { - unzClose(fd); - return 0; - } - - /* Get file informations and update filename */ - ret = unzGetCurrentFileInfo(fd, &info, fname, 256, NULL, 0, NULL, 0); - if(ret != UNZ_OK) - { - unzClose(fd); - return 0; - } - - /* Compressed filename extension */ - if (extension) - { - strncpy(extension, &fname[strlen(fname) - 3], 3); - extension[3] = 0; - } - - /* Open the file for reading */ - ret = unzOpenCurrentFile(fd); - if(ret != UNZ_OK) - { - unzClose(fd); - return 0; - } - - /* Retrieve uncompressed file size */ - size = info.uncompressed_size; - if(size > maxsize) - { - size = maxsize; - } - - /* Read (decompress) the file */ - ret = unzReadCurrentFile(fd, buffer, size); - if(ret != size) - { - unzCloseCurrentFile(fd); - unzClose(fd); - return 0; - } - - /* Close the current file */ - ret = unzCloseCurrentFile(fd); - if(ret != UNZ_OK) - { - unzClose(fd); - return 0; - } - - /* Close the archive */ - ret = unzClose(fd); - if(ret != UNZ_OK) return 0; - } - else - { - /* Open file */ - gzFile *gd = gzopen(filename, "rb"); - if (!gd) return 0; - - /* Read file data */ - size = gzread(gd, buffer, maxsize); - - /* filename extension */ - if (extension) - { - strncpy(extension, &filename[strlen(filename) - 3], 3); - extension[3] = 0; - } - - /* Close file */ - gzclose(gd); - } - - /* Return loaded ROM size */ - return size; -} - -/* - Verifies if a file is a ZIP archive or not. - Returns: 1= ZIP archive, 0= not a ZIP archive -*/ -static int check_zip(char *filename) -{ - uint8 buf[2]; - FILE *fd = fopen(filename, "rb"); - if(!fd) return (0); - fread(buf, 2, 1, fd); - fclose(fd); - if(memcmp(buf, "PK", 2) == 0) return (1); - return (0); -} diff --git a/genplus-gx/sdl/fileio.h b/genplus-gx/sdl/fileio.h deleted file mode 100644 index 30db2e0ec4..0000000000 --- a/genplus-gx/sdl/fileio.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * fileio.c - * - * Load a normal file, or ZIP/GZ archive. - * Returns loaded ROM size (zero if an error occured) - * - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald - * modified by Eke-Eke (Genesis Plus GX) - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#ifndef _FILEIO_H_ -#define _FILEIO_H_ - -/* Function prototypes */ -extern int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension); - -#endif /* _FILEIO_H_ */ diff --git a/genplus-gx/sdl/icon.rc b/genplus-gx/sdl/icon.rc deleted file mode 100644 index 0b47594d50..0000000000 --- a/genplus-gx/sdl/icon.rc +++ /dev/null @@ -1 +0,0 @@ -MAINICON ICON "md.ico" diff --git a/genplus-gx/sdl/main.c b/genplus-gx/sdl/main.c deleted file mode 100644 index 1b867e1cab..0000000000 --- a/genplus-gx/sdl/main.c +++ /dev/null @@ -1,934 +0,0 @@ -#ifdef __WIN32__ -#include -#else -#define MessageBox(owner, text, caption, type) printf("%s: %s\n", caption, text) -#endif - -#include "SDL.h" -#include "SDL_thread.h" - -#include "shared.h" -#include "sms_ntsc.h" -#include "md_ntsc.h" - -#define SOUND_FREQUENCY 48000 -#define SOUND_SAMPLES_SIZE 2048 - -#define VIDEO_WIDTH 320 -#define VIDEO_HEIGHT 240 - -int joynum = 0; - -int log_error = 0; -int debug_on = 0; -int turbo_mode = 0; -int use_sound = 1; -int fullscreen = 0; /* SDL_FULLSCREEN */ - -/* sound */ - -struct { - char* current_pos; - char* buffer; - int current_emulated_samples; -} sdl_sound; - - -static uint8 brm_format[0x40] = -{ - 0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x5f,0x00,0x00,0x00,0x00,0x40, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x53,0x45,0x47,0x41,0x5f,0x43,0x44,0x5f,0x52,0x4f,0x4d,0x00,0x01,0x00,0x00,0x00, - 0x52,0x41,0x4d,0x5f,0x43,0x41,0x52,0x54,0x52,0x49,0x44,0x47,0x45,0x5f,0x5f,0x5f -}; - - -static short soundframe[SOUND_SAMPLES_SIZE]; - -static void sdl_sound_callback(void *userdata, Uint8 *stream, int len) -{ - if(sdl_sound.current_emulated_samples < len) { - memset(stream, 0, len); - } - else { - memcpy(stream, sdl_sound.buffer, len); - /* loop to compensate desync */ - do { - sdl_sound.current_emulated_samples -= len; - } while(sdl_sound.current_emulated_samples > 2 * len); - memcpy(sdl_sound.buffer, - sdl_sound.current_pos - sdl_sound.current_emulated_samples, - sdl_sound.current_emulated_samples); - sdl_sound.current_pos = sdl_sound.buffer + sdl_sound.current_emulated_samples; - } -} - -static int sdl_sound_init() -{ - int n; - SDL_AudioSpec as_desired, as_obtained; - - if(SDL_Init(SDL_INIT_AUDIO) < 0) { - MessageBox(NULL, "SDL Audio initialization failed", "Error", 0); - return 0; - } - - as_desired.freq = SOUND_FREQUENCY; - as_desired.format = AUDIO_S16LSB; - as_desired.channels = 2; - as_desired.samples = SOUND_SAMPLES_SIZE; - as_desired.callback = sdl_sound_callback; - - if(SDL_OpenAudio(&as_desired, &as_obtained) == -1) { - MessageBox(NULL, "SDL Audio open failed", "Error", 0); - return 0; - } - - if(as_desired.samples != as_obtained.samples) { - MessageBox(NULL, "SDL Audio wrong setup", "Error", 0); - return 0; - } - - sdl_sound.current_emulated_samples = 0; - n = SOUND_SAMPLES_SIZE * 2 * sizeof(short) * 20; - sdl_sound.buffer = (char*)malloc(n); - if(!sdl_sound.buffer) { - MessageBox(NULL, "Can't allocate audio buffer", "Error", 0); - return 0; - } - memset(sdl_sound.buffer, 0, n); - sdl_sound.current_pos = sdl_sound.buffer; - return 1; -} - -static void sdl_sound_update(enabled) -{ - int size = audio_update(soundframe) * 2; - - if (enabled) - { - int i; - short *out; - - SDL_LockAudio(); - out = (short*)sdl_sound.current_pos; - for(i = 0; i < size; i++) - { - *out++ = soundframe[i]; - } - sdl_sound.current_pos = (char*)out; - sdl_sound.current_emulated_samples += size * sizeof(short); - SDL_UnlockAudio(); - } -} - -static void sdl_sound_close() -{ - SDL_PauseAudio(1); - SDL_CloseAudio(); - if (sdl_sound.buffer) - free(sdl_sound.buffer); -} - -/* video */ -md_ntsc_t *md_ntsc; -sms_ntsc_t *sms_ntsc; - -struct { - SDL_Surface* surf_screen; - SDL_Surface* surf_bitmap; - SDL_Rect srect; - SDL_Rect drect; - Uint32 frames_rendered; -} sdl_video; - -static int sdl_video_init() -{ - if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { - MessageBox(NULL, "SDL Video initialization failed", "Error", 0); - return 0; - } - sdl_video.surf_screen = SDL_SetVideoMode(VIDEO_WIDTH, VIDEO_HEIGHT, 16, SDL_SWSURFACE | fullscreen); - sdl_video.surf_bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, 720, 576, 16, 0, 0, 0, 0); - sdl_video.frames_rendered = 0; - SDL_ShowCursor(0); - return 1; -} - -static void sdl_video_update() -{ - if (system_hw == SYSTEM_MCD) - { - system_frame_scd(0); - } - else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) - { - system_frame_gen(0); - } - else - { - system_frame_sms(0); - } - - /* viewport size changed */ - if(bitmap.viewport.changed & 1) - { - bitmap.viewport.changed &= ~1; - - /* source bitmap */ - sdl_video.srect.w = bitmap.viewport.w+2*bitmap.viewport.x; - sdl_video.srect.h = bitmap.viewport.h+2*bitmap.viewport.y; - sdl_video.srect.x = 0; - sdl_video.srect.y = 0; - if (sdl_video.srect.w > VIDEO_WIDTH) - { - sdl_video.srect.x = (sdl_video.srect.w - VIDEO_WIDTH) / 2; - sdl_video.srect.w = VIDEO_WIDTH; - } - if (sdl_video.srect.h > VIDEO_HEIGHT) - { - sdl_video.srect.y = (sdl_video.srect.h - VIDEO_HEIGHT) / 2; - sdl_video.srect.h = VIDEO_HEIGHT; - } - - /* destination bitmap */ - sdl_video.drect.w = sdl_video.srect.w; - sdl_video.drect.h = sdl_video.srect.h; - sdl_video.drect.x = (VIDEO_WIDTH - sdl_video.drect.w) / 2; - sdl_video.drect.y = (VIDEO_HEIGHT - sdl_video.drect.h) / 2; - - /* clear destination surface */ - SDL_FillRect(sdl_video.surf_screen, 0, 0); - -#if 0 - if (config.render && (interlaced || config.ntsc)) rect.h *= 2; - if (config.ntsc) rect.w = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(rect.w) : SMS_NTSC_OUT_WIDTH(rect.w); - if (config.ntsc) - { - sms_ntsc = (sms_ntsc_t *)malloc(sizeof(sms_ntsc_t)); - md_ntsc = (md_ntsc_t *)malloc(sizeof(md_ntsc_t)); - - switch (config.ntsc) - { - case 1: - sms_ntsc_init(sms_ntsc, &sms_ntsc_composite); - md_ntsc_init(md_ntsc, &md_ntsc_composite); - break; - case 2: - sms_ntsc_init(sms_ntsc, &sms_ntsc_svideo); - md_ntsc_init(md_ntsc, &md_ntsc_svideo); - break; - case 3: - sms_ntsc_init(sms_ntsc, &sms_ntsc_rgb); - md_ntsc_init(md_ntsc, &md_ntsc_rgb); - break; - } - } - else - { - if (sms_ntsc) - { - free(sms_ntsc); - sms_ntsc = NULL; - } - - if (md_ntsc) - { - free(md_ntsc); - md_ntsc = NULL; - } - } -#endif - } - - SDL_BlitSurface(sdl_video.surf_bitmap, &sdl_video.srect, sdl_video.surf_screen, &sdl_video.drect); - SDL_UpdateRect(sdl_video.surf_screen, 0, 0, 0, 0); - - ++sdl_video.frames_rendered; -} - -static void sdl_video_close() -{ - if (sdl_video.surf_bitmap) - SDL_FreeSurface(sdl_video.surf_bitmap); - if (sdl_video.surf_screen) - SDL_FreeSurface(sdl_video.surf_screen); -} - -/* Timer Sync */ - -struct { - SDL_sem* sem_sync; - unsigned ticks; -} sdl_sync; - -static Uint32 sdl_sync_timer_callback(Uint32 interval) -{ - SDL_SemPost(sdl_sync.sem_sync); - sdl_sync.ticks++; - if (sdl_sync.ticks == (vdp_pal ? 50 : 20)) - { - SDL_Event event; - SDL_UserEvent userevent; - - userevent.type = SDL_USEREVENT; - userevent.code = vdp_pal ? (sdl_video.frames_rendered / 3) : sdl_video.frames_rendered; - userevent.data1 = NULL; - userevent.data2 = NULL; - sdl_sync.ticks = sdl_video.frames_rendered = 0; - - event.type = SDL_USEREVENT; - event.user = userevent; - - SDL_PushEvent(&event); - } - return interval; -} - -static int sdl_sync_init() -{ - if(SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_EVENTTHREAD) < 0) - { - MessageBox(NULL, "SDL Timer initialization failed", "Error", 0); - return 0; - } - - sdl_sync.sem_sync = SDL_CreateSemaphore(0); - sdl_sync.ticks = 0; - return 1; -} - -static void sdl_sync_close() -{ - if(sdl_sync.sem_sync) - SDL_DestroySemaphore(sdl_sync.sem_sync); -} - -static const uint16 vc_table[4][2] = -{ - /* NTSC, PAL */ - {0xDA , 0xF2}, /* Mode 4 (192 lines) */ - {0xEA , 0x102}, /* Mode 5 (224 lines) */ - {0xDA , 0xF2}, /* Mode 4 (192 lines) */ - {0x106, 0x10A} /* Mode 5 (240 lines) */ -}; - -static int sdl_control_update(SDLKey keystate) -{ - switch (keystate) - { - case SDLK_TAB: - { - system_reset(); - break; - } - - case SDLK_F1: - { - if (SDL_ShowCursor(-1)) SDL_ShowCursor(0); - else SDL_ShowCursor(1); - break; - } - - case SDLK_F2: - { - if (fullscreen) fullscreen = 0; - else fullscreen = SDL_FULLSCREEN; - sdl_video.surf_screen = SDL_SetVideoMode(VIDEO_WIDTH, VIDEO_HEIGHT, 16, SDL_SWSURFACE | fullscreen); - break; - } - - case SDLK_F3: - { - if (config.bios == 0) config.bios = 3; - else if (config.bios == 3) config.bios = 1; - break; - } - - case SDLK_F4: - { - if (!turbo_mode) use_sound ^= 1; - break; - } - - case SDLK_F5: - { - log_error ^= 1; - break; - } - - case SDLK_F6: - { - if (!use_sound) - { - turbo_mode ^=1; - sdl_sync.ticks = 0; - } - break; - } - - case SDLK_F7: - { - FILE *f = fopen("game.gp0","rb"); - if (f) - { - uint8 buf[STATE_SIZE]; - fread(&buf, STATE_SIZE, 1, f); - state_load(buf); - fclose(f); - } - break; - } - - case SDLK_F8: - { - FILE *f = fopen("game.gp0","wb"); - if (f) - { - uint8 buf[STATE_SIZE]; - int len = state_save(buf); - fwrite(&buf, len, 1, f); - fclose(f); - } - break; - } - - case SDLK_F9: - { - config.region_detect = (config.region_detect + 1) % 5; - get_region(0); - - /* framerate has changed, reinitialize audio timings */ - audio_init(snd.sample_rate, 0); - - /* system with region BIOS should be reinitialized */ - if ((system_hw == SYSTEM_MCD) || ((system_hw & SYSTEM_SMS) && (config.bios & 1))) - { - system_init(); - system_reset(); - } - else - { - /* reinitialize I/O region register */ - if (system_hw == SYSTEM_MD) - { - io_reg[0x00] = 0x20 | region_code | (config.bios & 1); - } - else - { - io_reg[0x00] = 0x80 | (region_code >> 1); - } - - /* reinitialize VDP */ - if (vdp_pal) - { - status |= 1; - lines_per_frame = 313; - } - else - { - status &= ~1; - lines_per_frame = 262; - } - - /* reinitialize VC max value */ - switch (bitmap.viewport.h) - { - case 192: - vc_max = vc_table[0][vdp_pal]; - break; - case 224: - vc_max = vc_table[1][vdp_pal]; - break; - case 240: - vc_max = vc_table[3][vdp_pal]; - break; - } - } - break; - } - - case SDLK_F10: - { - gen_reset(0); - break; - } - - case SDLK_F11: - { - config.overscan = (config.overscan + 1) & 3; - if ((system_hw == SYSTEM_GG) && !config.gg_extra) - { - bitmap.viewport.x = (config.overscan & 2) ? 14 : -48; - } - else - { - bitmap.viewport.x = (config.overscan & 2) * 7; - } - bitmap.viewport.changed = 3; - break; - } - - case SDLK_F12: - { - joynum = (joynum + 1) % MAX_DEVICES; - while (input.dev[joynum] == NO_DEVICE) - { - joynum = (joynum + 1) % MAX_DEVICES; - } - break; - } - - case SDLK_ESCAPE: - { - return 0; - } - - default: - break; - } - - return 1; -} - -int sdl_input_update(void) -{ - uint8 *keystate = SDL_GetKeyState(NULL); - - /* reset input */ - input.pad[joynum] = 0; - - switch (input.dev[joynum]) - { - case DEVICE_LIGHTGUN: - { - /* get mouse coordinates (absolute values) */ - int x,y; - int state = SDL_GetMouseState(&x,&y); - - /* X axis */ - input.analog[joynum][0] = x - (VIDEO_WIDTH-bitmap.viewport.w)/2; - - /* Y axis */ - input.analog[joynum][1] = y - (VIDEO_HEIGHT-bitmap.viewport.h)/2; - - /* TRIGGER, B, C (Menacer only), START (Menacer & Justifier only) */ - if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_A; - if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_B; - if(state & SDL_BUTTON_MMASK) input.pad[joynum] |= INPUT_C; - if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; - break; - } - - case DEVICE_PADDLE: - { - /* get mouse (absolute values) */ - int x; - int state = SDL_GetMouseState(&x, NULL); - - /* Range is [0;256], 128 being middle position */ - input.analog[joynum][0] = x * 256 /VIDEO_WIDTH; - - /* Button I -> 0 0 0 0 0 0 0 I*/ - if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; - - break; - } - - case DEVICE_SPORTSPAD: - { - /* get mouse (relative values) */ - int x,y; - int state = SDL_GetRelativeMouseState(&x,&y); - - /* Range is [0;256] */ - input.analog[joynum][0] = (unsigned char)(-x & 0xFF); - input.analog[joynum][1] = (unsigned char)(-y & 0xFF); - - /* Buttons I & II -> 0 0 0 0 0 0 II I*/ - if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; - if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_C; - - break; - } - - case DEVICE_MOUSE: - { - /* get mouse (relative values) */ - int x,y; - int state = SDL_GetRelativeMouseState(&x,&y); - - /* Sega Mouse range is [-256;+256] */ - input.analog[joynum][0] = x * 2; - input.analog[joynum][1] = y * 2; - - /* Vertical movement is upsidedown */ - if (!config.invert_mouse) - input.analog[joynum][1] = 0 - input.analog[joynum][1]; - - /* Start,Left,Right,Middle buttons -> 0 0 0 0 START MIDDLE RIGHT LEFT */ - if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; - if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_C; - if(state & SDL_BUTTON_MMASK) input.pad[joynum] |= INPUT_A; - if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; - - break; - } - - case DEVICE_XE_A1P: - { - /* A,B,C,D,Select,START,E1,E2 buttons -> E1(?) E2(?) START SELECT(?) A B C D */ - if(keystate[SDLK_a]) input.pad[joynum] |= INPUT_START; - if(keystate[SDLK_s]) input.pad[joynum] |= INPUT_A; - if(keystate[SDLK_d]) input.pad[joynum] |= INPUT_C; - if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_Y; - if(keystate[SDLK_z]) input.pad[joynum] |= INPUT_B; - if(keystate[SDLK_x]) input.pad[joynum] |= INPUT_X; - if(keystate[SDLK_c]) input.pad[joynum] |= INPUT_MODE; - if(keystate[SDLK_v]) input.pad[joynum] |= INPUT_Z; - - /* Left Analog Stick (bidirectional) */ - if(keystate[SDLK_UP]) input.analog[joynum][1]-=2; - else if(keystate[SDLK_DOWN]) input.analog[joynum][1]+=2; - else input.analog[joynum][1] = 128; - if(keystate[SDLK_LEFT]) input.analog[joynum][0]-=2; - else if(keystate[SDLK_RIGHT]) input.analog[joynum][0]+=2; - else input.analog[joynum][0] = 128; - - /* Right Analog Stick (unidirectional) */ - if(keystate[SDLK_KP8]) input.analog[joynum+1][0]-=2; - else if(keystate[SDLK_KP2]) input.analog[joynum+1][0]+=2; - else if(keystate[SDLK_KP4]) input.analog[joynum+1][0]-=2; - else if(keystate[SDLK_KP6]) input.analog[joynum+1][0]+=2; - else input.analog[joynum+1][0] = 128; - - /* Limiters */ - if (input.analog[joynum][0] > 0xFF) input.analog[joynum][0] = 0xFF; - else if (input.analog[joynum][0] < 0) input.analog[joynum][0] = 0; - if (input.analog[joynum][1] > 0xFF) input.analog[joynum][1] = 0xFF; - else if (input.analog[joynum][1] < 0) input.analog[joynum][1] = 0; - if (input.analog[joynum+1][0] > 0xFF) input.analog[joynum+1][0] = 0xFF; - else if (input.analog[joynum+1][0] < 0) input.analog[joynum+1][0] = 0; - if (input.analog[joynum+1][1] > 0xFF) input.analog[joynum+1][1] = 0xFF; - else if (input.analog[joynum+1][1] < 0) input.analog[joynum+1][1] = 0; - - break; - } - - case DEVICE_PICO: - { - /* get mouse (absolute values) */ - int x,y; - int state = SDL_GetMouseState(&x,&y); - - /* Calculate X Y axis values */ - input.analog[0][0] = 0x3c + (x * (0x17c-0x03c+1)) / VIDEO_WIDTH; - input.analog[0][1] = 0x1fc + (y * (0x2f7-0x1fc+1)) / VIDEO_HEIGHT; - - /* Map mouse buttons to player #1 inputs */ - if(state & SDL_BUTTON_MMASK) pico_current = (pico_current + 1) & 7; - if(state & SDL_BUTTON_RMASK) input.pad[0] |= INPUT_PICO_RED; - if(state & SDL_BUTTON_LMASK) input.pad[0] |= INPUT_PICO_PEN; - - break; - } - - case DEVICE_TEREBI: - { - /* get mouse (absolute values) */ - int x,y; - int state = SDL_GetMouseState(&x,&y); - - /* Calculate X Y axis values */ - input.analog[0][0] = (x * 250) / VIDEO_WIDTH; - input.analog[0][1] = (y * 250) / VIDEO_HEIGHT; - - /* Map mouse buttons to player #1 inputs */ - if(state & SDL_BUTTON_RMASK) input.pad[0] |= INPUT_B; - - break; - } - - case DEVICE_ACTIVATOR: - { - if(keystate[SDLK_g]) input.pad[joynum] |= INPUT_ACTIVATOR_7L; - if(keystate[SDLK_h]) input.pad[joynum] |= INPUT_ACTIVATOR_7U; - if(keystate[SDLK_j]) input.pad[joynum] |= INPUT_ACTIVATOR_8L; - if(keystate[SDLK_k]) input.pad[joynum] |= INPUT_ACTIVATOR_8U; - } - - default: - { - if(keystate[SDLK_a]) input.pad[joynum] |= INPUT_A; - if(keystate[SDLK_s]) input.pad[joynum] |= INPUT_B; - if(keystate[SDLK_d]) input.pad[joynum] |= INPUT_C; - if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; - if(keystate[SDLK_z]) input.pad[joynum] |= INPUT_X; - if(keystate[SDLK_x]) input.pad[joynum] |= INPUT_Y; - if(keystate[SDLK_c]) input.pad[joynum] |= INPUT_Z; - if(keystate[SDLK_v]) input.pad[joynum] |= INPUT_MODE; - - if(keystate[SDLK_UP]) input.pad[joynum] |= INPUT_UP; - else - if(keystate[SDLK_DOWN]) input.pad[joynum] |= INPUT_DOWN; - if(keystate[SDLK_LEFT]) input.pad[joynum] |= INPUT_LEFT; - else - if(keystate[SDLK_RIGHT]) input.pad[joynum] |= INPUT_RIGHT; - - break; - } - } - return 1; -} - - -int main (int argc, char **argv) -{ - FILE *fp; - int running = 1; - - /* Print help if no game specified */ - if(argc < 2) - { - char caption[256]; - sprintf(caption, "Genesis Plus GX\\SDL\nusage: %s gamename\n", argv[0]); - MessageBox(NULL, caption, "Information", 0); - exit(1); - } - - /* set default config */ - error_init(); - set_config_defaults(); - - /* mark all BIOS as unloaded */ - system_bios = 0; - - /* Genesis BOOT ROM support (2KB max) */ - memset(boot_rom, 0xFF, 0x800); - fp = fopen(MD_BIOS, "rb"); - if (fp != NULL) - { - int i; - - /* read BOOT ROM */ - fread(boot_rom, 1, 0x800, fp); - fclose(fp); - - /* check BOOT ROM */ - if (!memcmp((char *)(boot_rom + 0x120),"GENESIS OS", 10)) - { - /* mark Genesis BIOS as loaded */ - system_bios = SYSTEM_MD; - } - - /* Byteswap ROM */ - for (i=0; i<0x800; i+=2) - { - uint8 temp = boot_rom[i]; - boot_rom[i] = boot_rom[i+1]; - boot_rom[i+1] = temp; - } - } - - /* initialize SDL */ - if(SDL_Init(0) < 0) - { - char caption[256]; - sprintf(caption, "SDL initialization failed"); - MessageBox(NULL, caption, "Error", 0); - exit(1); - } - sdl_video_init(); - if (use_sound) sdl_sound_init(); - sdl_sync_init(); - - /* initialize Genesis virtual system */ - SDL_LockSurface(sdl_video.surf_bitmap); - memset(&bitmap, 0, sizeof(t_bitmap)); - bitmap.width = 720; - bitmap.height = 576; -#if defined(USE_8BPP_RENDERING) - bitmap.pitch = (bitmap.width * 1); -#elif defined(USE_15BPP_RENDERING) - bitmap.pitch = (bitmap.width * 2); -#elif defined(USE_16BPP_RENDERING) - bitmap.pitch = (bitmap.width * 2); -#elif defined(USE_32BPP_RENDERING) - bitmap.pitch = (bitmap.width * 4); -#endif - bitmap.data = sdl_video.surf_bitmap->pixels; - SDL_UnlockSurface(sdl_video.surf_bitmap); - bitmap.viewport.changed = 3; - - /* Load game file */ - if(!load_rom(argv[1])) - { - char caption[256]; - sprintf(caption, "Error loading file `%s'.", argv[1]); - MessageBox(NULL, caption, "Error", 0); - exit(1); - } - - /* initialize system hardware */ - audio_init(SOUND_FREQUENCY, 0); - system_init(); - - /* Mega CD specific */ - if (system_hw == SYSTEM_MCD) - { - /* load internal backup RAM */ - fp = fopen("./scd.brm", "rb"); - if (fp!=NULL) - { - fread(scd.bram, 0x2000, 1, fp); - fclose(fp); - } - - /* check if internal backup RAM is formatted */ - if (memcmp(scd.bram + 0x2000 - 0x20, brm_format + 0x20, 0x20)) - { - /* clear internal backup RAM */ - memset(scd.bram, 0x00, 0x200); - - /* Internal Backup RAM size fields */ - brm_format[0x10] = brm_format[0x12] = brm_format[0x14] = brm_format[0x16] = 0x00; - brm_format[0x11] = brm_format[0x13] = brm_format[0x15] = brm_format[0x17] = (sizeof(scd.bram) / 64) - 3; - - /* format internal backup RAM */ - memcpy(scd.bram + 0x2000 - 0x40, brm_format, 0x40); - } - - /* load cartridge backup RAM */ - if (scd.cartridge.id) - { - fp = fopen("./cart.brm", "rb"); - if (fp!=NULL) - { - fread(scd.cartridge.area, scd.cartridge.mask + 1, 1, fp); - fclose(fp); - } - - /* check if cartridge backup RAM is formatted */ - if (memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20)) - { - /* clear cartridge backup RAM */ - memset(scd.cartridge.area, 0x00, scd.cartridge.mask + 1); - - /* Cartridge Backup RAM size fields */ - brm_format[0x10] = brm_format[0x12] = brm_format[0x14] = brm_format[0x16] = (((scd.cartridge.mask + 1) / 64) - 3) >> 8; - brm_format[0x11] = brm_format[0x13] = brm_format[0x15] = brm_format[0x17] = (((scd.cartridge.mask + 1) / 64) - 3) & 0xff; - - /* format cartridge backup RAM */ - memcpy(scd.cartridge.area + scd.cartridge.mask + 1 - sizeof(brm_format), brm_format, sizeof(brm_format)); - } - } - } - - if (sram.on) - { - /* load SRAM */ - fp = fopen("./game.srm", "rb"); - if (fp!=NULL) - { - fread(sram.sram,0x10000,1, fp); - fclose(fp); - } - } - - /* reset system hardware */ - system_reset(); - - if(use_sound) SDL_PauseAudio(0); - - /* 3 frames = 50 ms (60hz) or 60 ms (50hz) */ - if(sdl_sync.sem_sync) - SDL_SetTimer(vdp_pal ? 60 : 50, sdl_sync_timer_callback); - - /* emulation loop */ - while(running) - { - SDL_Event event; - if (SDL_PollEvent(&event)) - { - switch(event.type) - { - case SDL_USEREVENT: - { - char caption[100]; - sprintf(caption,"Genesis Plus GX - %d fps - %s)", event.user.code, (rominfo.international[0] != 0x20) ? rominfo.international : rominfo.domestic); - SDL_WM_SetCaption(caption, NULL); - break; - } - - case SDL_QUIT: - { - running = 0; - break; - } - - case SDL_KEYDOWN: - { - running = sdl_control_update(event.key.keysym.sym); - break; - } - } - } - - sdl_video_update(); - sdl_sound_update(use_sound); - - if(!turbo_mode && sdl_sync.sem_sync && sdl_video.frames_rendered % 3 == 0) - { - SDL_SemWait(sdl_sync.sem_sync); - } - } - - if (system_hw == SYSTEM_MCD) - { - /* save internal backup RAM (if formatted) */ - if (!memcmp(scd.bram + 0x2000 - 0x20, brm_format + 0x20, 0x20)) - { - fp = fopen("./scd.brm", "wb"); - if (fp!=NULL) - { - fwrite(scd.bram, 0x2000, 1, fp); - fclose(fp); - } - } - - /* save cartridge backup RAM (if formatted) */ - if (scd.cartridge.id) - { - if (!memcmp(scd.cartridge.area + scd.cartridge.mask + 1 - 0x20, brm_format + 0x20, 0x20)) - { - fp = fopen("./cart.brm", "wb"); - if (fp!=NULL) - { - fwrite(scd.cartridge.area, scd.cartridge.mask + 1, 1, fp); - fclose(fp); - } - } - } - } - - if (sram.on) - { - /* save SRAM */ - fp = fopen("./game.srm", "wb"); - if (fp!=NULL) - { - fwrite(sram.sram,0x10000,1, fp); - fclose(fp); - } - } - - audio_shutdown(); - error_shutdown(); - - sdl_video_close(); - sdl_sound_close(); - sdl_sync_close(); - SDL_Quit(); - - return 0; -} diff --git a/genplus-gx/sdl/main.h b/genplus-gx/sdl/main.h deleted file mode 100644 index dfa5d8d52e..0000000000 --- a/genplus-gx/sdl/main.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef _MAIN_H_ -#define _MAIN_H_ - -#define MAX_INPUTS 8 - -extern int debug_on; -extern int log_error; -extern int sdl_input_update(void); - -#endif /* _MAIN_H_ */ diff --git a/genplus-gx/sdl/md.ico b/genplus-gx/sdl/md.ico deleted file mode 100644 index 7cf20f88c4..0000000000 Binary files a/genplus-gx/sdl/md.ico and /dev/null differ diff --git a/genplus-gx/sdl/osd.h b/genplus-gx/sdl/osd.h deleted file mode 100644 index ad95a52b00..0000000000 --- a/genplus-gx/sdl/osd.h +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef _OSD_H_ -#define _OSD_H_ - -#include -#include -#include -#include - -#include -#include - -#include "shared.h" -#include "main.h" -#include "config.h" -#include "error.h" -#include "unzip.h" -#include "fileio.h" - -#define osd_input_update sdl_input_update - -#define GG_ROM "./ggenie.bin" -#define AR_ROM "./areplay.bin" -#define SK_ROM "./sk.bin" -#define SK_UPMEM "./sk2chip.bin" -#define CD_BIOS_US "./bios_CD_U.bin" -#define CD_BIOS_EU "./bios_CD_E.bin" -#define CD_BIOS_JP "./bios_CD_J.bin" -#define MD_BIOS "./bios_MD.bin" -#define MS_BIOS_US "./bios_U.sms" -#define MS_BIOS_EU "./bios_E.sms" -#define MS_BIOS_JP "./bios_J.sms" -#define GG_BIOS "./bios.gg" - -#endif /* _OSD_H_ */ diff --git a/genplus-gx/sdl/readme-sdl.txt b/genplus-gx/sdl/readme-sdl.txt deleted file mode 100644 index 3c8eb6485a..0000000000 --- a/genplus-gx/sdl/readme-sdl.txt +++ /dev/null @@ -1,5 +0,0 @@ -Compile with MinGW. -You will also need to install the SDL library (http://www.libsdl.org/). -Zlib is required for zipped rom support. - -Please distribute required dlls with the executable. \ No newline at end of file diff --git a/genplus-gx/sdl/unzip.c b/genplus-gx/sdl/unzip.c deleted file mode 100644 index ef52bc6269..0000000000 --- a/genplus-gx/sdl/unzip.c +++ /dev/null @@ -1,1294 +0,0 @@ -/* unzip.c -- IO on .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Read unzip.h for more info -*/ - - -#include -#include -#include -#include -#include "unzip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else - #include -#endif - - -#ifndef local - #define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - - - -#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ - !defined(CASESENSITIVITYDEFAULT_NO) -#define CASESENSITIVITYDEFAULT_NO -#endif - - -#ifndef UNZ_BUFSIZE -#define UNZ_BUFSIZE (16384) -#endif - -#ifndef UNZ_MAXFILENAMEINZIP -#define UNZ_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -const char unz_copyright[] = - " unzip 0.15 Copyright 1998 Gilles Vollant "; - -/* unz_file_info_interntal contain internal info about a file in zipfile*/ -typedef struct unz_file_info_internal_s -{ - uLong offset_curfile;/* relative offset of local header 4 bytes */ -} unz_file_info_internal; - - -/* file_in_zip_read_info_s contain internal information about a file in zipfile, - when reading and decompress it */ -typedef struct -{ - char *read_buffer; /* internal buffer for compressed data */ - z_stream stream; /* zLib stream structure for inflate */ - - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ - - uLong offset_local_extrafield;/* offset of the local extra field */ - uInt size_local_extrafield;/* size of the local extra field */ - uLong pos_local_extrafield; /* position in the local extra field in read*/ - - uLong crc32; /* crc32 of all data uncompressed */ - uLong crc32_wait; /* crc32 we must obtain after decompress all */ - uLong rest_read_compressed; /* number of byte to be decompressed */ - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - FILE* file; /* io structore of the zipfile */ - uLong compression_method; /* compression method (0==store) */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ -} file_in_zip_read_info_s; - - -/* unz_s contain internal information about the zipfile -*/ -typedef struct -{ - FILE* file; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with - respect to the starting disk number */ - - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ - file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current - file if we are decompressing it */ -} unz_s; - - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been sucessfully opened for reading. -*/ - - -local int unzlocal_getByte(fin,pi) - FILE *fin; - int *pi; -{ - unsigned char c; - int err = fread(&c, 1, 1, fin); - if (err==1) - { - *pi = (int)c; - return UNZ_OK; - } - else - { - if (ferror(fin)) - return UNZ_ERRNO; - else - return UNZ_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int unzlocal_getShort (fin,pX) - FILE* fin; - uLong *pX; -{ - uLong x ; - int i = 0; - int err; - - err = unzlocal_getByte(fin,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int unzlocal_getLong (fin,pX) - FILE* fin; - uLong *pX; -{ - uLong x ; - int i = 0; - int err; - - err = unzlocal_getByte(fin,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<16; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<24; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - - -/* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (fileName1,fileName2) - const char* fileName1; - const char* fileName2; -{ - for (;;) - { - char c1=*(fileName1++); - char c2=*(fileName2++); - if ((c1>='a') && (c1<='z')) - c1 -= 0x20; - if ((c2>='a') && (c2<='z')) - c2 -= 0x20; - if (c1=='\0') - return ((c2=='\0') ? 0 : -1); - if (c2=='\0') - return 1; - if (c1c2) - return 1; - } -} - - -#ifdef CASESENSITIVITYDEFAULT_NO -#define CASESENSITIVITYDEFAULTVALUE 2 -#else -#define CASESENSITIVITYDEFAULTVALUE 1 -#endif - -#ifndef STRCMPCASENOSENTIVEFUNCTION -#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal -#endif - -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) - -*/ -extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; -{ - if (iCaseSensitivity==0) - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; - - if (iCaseSensitivity==1) - return strcmp(fileName1,fileName2); - - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); -} - -#define BUFREADCOMMENT (0x400) - -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local uLong unzlocal_SearchCentralDir(fin) - FILE *fin; -{ - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (fseek(fin,0,SEEK_END) != 0) - return 0; - - - uSizeFile = ftell( fin ); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (fseek(fin,uReadPos,SEEK_SET)!=0) - break; - - if (fread(buf,(uInt)uReadSize,1,fin)!=1) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; -} - -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer - "zlib/zlib109.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ -extern unzFile ZEXPORT unzOpen (path) - const char *path; -{ - unz_s us; - unz_s *s; - uLong central_pos,uL; - FILE * fin ; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - - int err=UNZ_OK; - - if (unz_copyright[0]!=' ') - return NULL; - - fin=fopen(path,"rb"); - if (fin==NULL) - return NULL; - - central_pos = unzlocal_SearchCentralDir(fin); - if (central_pos==0) - err=UNZ_ERRNO; - - if (fseek(fin,central_pos,SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unzlocal_getLong(fin,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir */ - if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; - - /* size of the central directory */ - if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* zipfile comment length */ - if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((central_pospfile_in_zip_read!=NULL) - unzCloseCurrentFile(file); - - fclose(s->file); - TRYFREE(s); - return UNZ_OK; -} - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; -{ - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; -} - - -/* - Translate date/time from Dos format to tm_unz (readable more easilty) -*/ -local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) - uLong ulDosDate; - tm_unz* ptm; -{ - uLong uDate; - uDate = (uLong)(ulDosDate>>16); - ptm->tm_mday = (uInt)(uDate&0x1f) ; - ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; - ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; - - ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); - ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; - ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; -} - -/* - Get Info about the current file in the zipfile, with internal only info -*/ -local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, - unz_file_info *pfile_info, - unz_file_info_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -local int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) - err=UNZ_ERRNO; - - - /* we check the magic */ - if (err==UNZ_OK) - { - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; - } - - if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; - - unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - - if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename0) && (fileNameBufferSize>0)) - if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } - - if ((err==UNZ_OK) && (extraField!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - } - - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; - } - else - lSeek+=file_info.size_file_extra; - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - } - - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; - } - else - lSeek+=file_info.size_file_comment; - - if ((err==UNZ_OK) && (pfile_info!=NULL)) - *pfile_info=file_info; - - if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) - *pfile_info_internal=file_info_internal; - - return err; -} - - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. -*/ -extern int ZEXPORT unzGetCurrentFileInfo (file, - pfile_info, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); -} - -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ -extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; -{ - int err=UNZ_OK; - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - - -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ -extern int ZEXPORT unzGoToNextFile (file) - unzFile file; -{ - unz_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; - - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; - s->num_file++; - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - - -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzipStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ -extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; -{ - unz_s* s; - int err; - - uLong num_fileSaved; - uLong pos_in_central_dirSaved; - - if (file==NULL) - return UNZ_PARAMERROR; - - if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) - return UNZ_PARAMERROR; - - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - num_fileSaved = s->num_file; - pos_in_central_dirSaved = s->pos_in_central_dir; - - err = unzGoToFirstFile(file); - - while (err == UNZ_OK) - { - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - unzGetCurrentFileInfo(file,NULL, - szCurrentFileName,sizeof(szCurrentFileName)-1, - NULL,0,NULL,0); - if (unzStringFileNameCompare(szCurrentFileName, - szFileName,iCaseSensitivity)==0) - return UNZ_OK; - err = unzGoToNextFile(file); - } - - s->num_file = num_fileSaved ; - s->pos_in_central_dir = pos_in_central_dirSaved ; - return err; -} - - -/* - Read the local header of the current zipfile - Check the coherency of the local header and info in the end of central - directory about this file - store in *piSizeVar the size of extra info in local header - (filename and size of extra field data) -*/ -local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; -{ - uLong uMagic,uData,uFlags; - uLong size_filename; - uLong size_extra_field; - int err=UNZ_OK; - - *piSizeVar = 0; - *poffset_local_extrafield = 0; - *psize_local_extrafield = 0; - - if (fseek(s->file,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - - - if (err==UNZ_OK) - { - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; - } - - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; -/* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; -*/ - if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) - err=UNZ_BADZIPFILE; - - if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - - if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) - err=UNZ_BADZIPFILE; - - *piSizeVar += (uInt)size_filename; - - if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) - err=UNZ_ERRNO; - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; - *psize_local_extrafield = (uInt)size_extra_field; - - *piSizeVar += (uInt)size_extra_field; - - return err; -} - -/* - Open for reading data the current file in the zipfile. - If there is no error and the file is opened, the return value is UNZ_OK. -*/ -extern int ZEXPORT unzOpenCurrentFile (file) - unzFile file; -{ - int err=UNZ_OK; - int Store; - uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; - - if (s->pfile_in_zip_read != NULL) - unzCloseCurrentFile(file); - - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; - - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); - if (pfile_in_zip_read_info==NULL) - return UNZ_INTERNALERROR; - - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; - pfile_in_zip_read_info->pos_local_extrafield=0; - - if (pfile_in_zip_read_info->read_buffer==NULL) - { - TRYFREE(pfile_in_zip_read_info); - return UNZ_INTERNALERROR; - } - - pfile_in_zip_read_info->stream_initialised=0; - - if ((s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - Store = s->cur_file_info.compression_method==0; - - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = - s->cur_file_info.compression_method; - pfile_in_zip_read_info->file=s->file; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; - - pfile_in_zip_read_info->stream.total_out = 0; - - if (!Store) - { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. - * In unzip, i don't wait absolutely Z_STREAM_END because I known the - * size of both compressed and uncompressed data - */ - } - pfile_in_zip_read_info->rest_read_compressed = - s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = - s->cur_file_info.uncompressed_size ; - - pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; - - - s->pfile_in_zip_read = pfile_in_zip_read_info; - return UNZ_OK; -} - - -/* - Read bytes from the current file. - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ -extern int ZEXPORT unzReadCurrentFile (file, buf, len) - unzFile file; - voidp buf; - unsigned len; -{ - int err=UNZ_OK; - uInt iRead = 0; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - if ((pfile_in_zip_read_info->read_buffer == NULL)) - return UNZ_END_OF_LIST_OF_FILE; - if (len==0) - return 0; - - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; - - pfile_in_zip_read_info->stream.avail_out = (uInt)len; - - if (len>pfile_in_zip_read_info->rest_read_uncompressed) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - - while (pfile_in_zip_read_info->stream.avail_out>0) - { - if ((pfile_in_zip_read_info->stream.avail_in==0) && - (pfile_in_zip_read_info->rest_read_compressed>0)) - { - uInt uReadThis = UNZ_BUFSIZE; - if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, - pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - - pfile_in_zip_read_info->rest_read_compressed-=uReadThis; - - pfile_in_zip_read_info->stream.next_in = - (Bytef*)pfile_in_zip_read_info->read_buffer; - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; - } - - if (pfile_in_zip_read_info->compression_method==0) - { - uInt uDoCopy,i ; - if (pfile_in_zip_read_info->stream.avail_out < - pfile_in_zip_read_info->stream.avail_in) - uDoCopy = pfile_in_zip_read_info->stream.avail_out ; - else - uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - - for (i=0;istream.next_out+i) = - *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; - pfile_in_zip_read_info->stream.avail_in -= uDoCopy; - pfile_in_zip_read_info->stream.avail_out -= uDoCopy; - pfile_in_zip_read_info->stream.next_out += uDoCopy; - pfile_in_zip_read_info->stream.next_in += uDoCopy; - pfile_in_zip_read_info->stream.total_out += uDoCopy; - iRead += uDoCopy; - } - else - { - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong uOutThis; - int flush=Z_SYNC_FLUSH; - - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; - bufBefore = pfile_in_zip_read_info->stream.next_out; - - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ - err=inflate(&pfile_in_zip_read_info->stream,flush); - - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->crc32 = - crc32(pfile_in_zip_read_info->crc32,bufBefore, - (uInt)(uOutThis)); - - pfile_in_zip_read_info->rest_read_uncompressed -= - uOutThis; - - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - - if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; - if (err!=Z_OK) - break; - } - } - - if (err==Z_OK) - return iRead; - return err; -} - - -/* - Give the current position in uncompressed data -*/ -extern z_off_t ZEXPORT unztell (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - return (z_off_t)pfile_in_zip_read_info->stream.total_out; -} - - -/* - return 1 if the end of file was reached, 0 elsewhere -*/ -extern int ZEXPORT unzeof (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - return 1; - else - return 0; -} - -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field that can be read - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ -extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) - unzFile file; - voidp buf; - unsigned len; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uInt read_now; - uLong size_to_read; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - size_to_read = (pfile_in_zip_read_info->size_local_extrafield - - pfile_in_zip_read_info->pos_local_extrafield); - - if (buf==NULL) - return (int)size_to_read; - - if (len>size_to_read) - read_now = (uInt)size_to_read; - else - read_now = (uInt)len ; - - if (read_now==0) - return 0; - - if (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->offset_local_extrafield + - pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) - return UNZ_ERRNO; - - if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; - - return (int)read_now; -} - -/* - Close the file in zip opened with unzipOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ -extern int ZEXPORT unzCloseCurrentFile (file) - unzFile file; -{ - int err=UNZ_OK; - - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - { - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) - err=UNZ_CRCERROR; - } - - - TRYFREE(pfile_in_zip_read_info->read_buffer); - pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised) - inflateEnd(&pfile_in_zip_read_info->stream); - - pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); - - s->pfile_in_zip_read=NULL; - - return err; -} - - -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ -extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; -{ -/* int err=UNZ_OK; */ - unz_s* s; - uLong uReadThis ; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - - uReadThis = uSizeBuf; - if (uReadThis>s->gi.size_comment) - uReadThis = s->gi.size_comment; - - if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) - return UNZ_ERRNO; - - if (uReadThis>0) - { - *szComment='\0'; - if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) - return UNZ_ERRNO; - } - - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) - *(szComment+s->gi.size_comment)='\0'; - return (int)uReadThis; -} diff --git a/genplus-gx/sdl/unzip.h b/genplus-gx/sdl/unzip.h deleted file mode 100644 index a30f79cb44..0000000000 --- a/genplus-gx/sdl/unzip.h +++ /dev/null @@ -1,273 +0,0 @@ -/* unzip.h -- IO for uncompress .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Copyright (C) 1998 Gilles Vollant - - This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE - CAN CHANGE IN FUTURE VERSION !! - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution - - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* for more info about .ZIP format, see - ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip */ - -#ifndef _unz_H -#define _unz_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unzFile__; -typedef unzFile__ *unzFile; -#else -typedef voidp unzFile; -#endif - - -#define UNZ_OK (0) -#define UNZ_END_OF_LIST_OF_FILE (-100) -#define UNZ_ERRNO (Z_ERRNO) -#define UNZ_EOF (0) -#define UNZ_PARAMERROR (-102) -#define UNZ_BADZIPFILE (-103) -#define UNZ_INTERNALERROR (-104) -#define UNZ_CRCERROR (-105) - -/* tm_unz contain date/time info */ -typedef struct tm_unz_s -{ - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ -} tm_unz; - -/* unz_global_info structure contain global data about the ZIPfile - These data comes from the end of central dir */ -typedef struct unz_global_info_s -{ - uLong number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ -} unz_global_info; - - -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_info_s -{ - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ - - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ - - tm_unz tmu_date; -} unz_file_info; - -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) -*/ - - -extern unzFile ZEXPORT unzOpen OF((const char *path)); -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer - "zlib/zlib111.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ - -extern int ZEXPORT unzClose OF((unzFile file)); -/* - Close a ZipFile opened with unzipOpen. - If there is files inside the .Zip opened with unzOpenCurrentFile (see later), - these files MUST be closed with unzipCloseCurrentFile before call unzipClose. - return UNZ_OK if there is no problem. */ - -extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ - - -extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ - - -/***************************************************************************/ -/* Unzip package allow you browse the directory of the zipfile */ - -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ - -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ - -extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ - - -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); -/* - Get Info about the current file - if pfile_info!=NULL, the *pfile_info structure will contain somes info about - the current file - if szFileName!=NULL, the filemane string will be copied in szFileName - (fileNameBufferSize is the size of the buffer) - if extraField!=NULL, the extra field information will be copied in extraField - (extraFieldBufferSize is the size of the buffer). - This is the Central-header version of the extra field - if szComment!=NULL, the comment string of the file will be copied in szComment - (commentBufferSize is the size of the buffer) -*/ - -/***************************************************************************/ -/* for reading the content of the current zipfile, you can open it, read data - from it, and close it (you can close it before reading all the file) - */ - -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); -/* - Open for reading data the current file in the zipfile. - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); -/* - Close the file in zip opened with unzOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ - -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read bytes from the current file (opened by unzOpenCurrentFile) - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ - -extern z_off_t ZEXPORT unztell OF((unzFile file)); -/* - Give the current position in uncompressed data -*/ - -extern int ZEXPORT unzeof OF((unzFile file)); -/* - return 1 if the end of file was reached, 0 elsewhere -*/ - -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _unz_H */