add/update code comments, minor refactor

This commit is contained in:
dborth 2008-09-12 05:28:40 +00:00
parent 55795bcacf
commit 2ac740bf64
42 changed files with 472 additions and 885 deletions

View File

@ -14,7 +14,7 @@
`¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨'
SNES9x GX is a Super Nintendo emulator for the Wii based on the PC emulator
SNES9x 1.50 (http://snes9x.ipherswipsite.com/). SoftDev is responsible for
SNES9x 1.51 (http://snes9x.ipherswipsite.com/). SoftDev is responsible for
the original SNES9x 1.50 GameCube port, whose work was continued by crunchy2.
It was updated for the Wii by michniewski and is currently being maintained
by michniewski and Tantric.
@ -25,6 +25,7 @@ michniewski
- added: Superscope/mouse/justifier support, with Wii remote
Tantric
- added: now uses SNES 1.51 core (thanks to eke-eke for help with this)
- added: cheats menu! Loads .CHT file from /snes9x/cheats folder,
.CHT file name must match file name of ROM
- added: load/save preference selector. ROM, SRAM, Freeze, and preferences

View File

@ -1,12 +1,16 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Audio RAM
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
****************************************************************************/
*
* aram.cpp
*
* Gamecube Audio RAM storage
***************************************************************************/
#include <gccore.h>
#include <string.h>
#include "aram.h"
#define ARAM_READ 1
@ -15,11 +19,11 @@
#define TEMPSIZE 32768
static char tempbuffer[TEMPSIZE] ATTRIBUTE_ALIGN (32);
/**
/****************************************************************************
* ARAMPut
*
* Move data from MAIN memory to ARAM
*/
***************************************************************************/
void
ARAMPut (char *src, char *dst, int len)
{
@ -28,11 +32,11 @@ ARAMPut (char *src, char *dst, int len)
while (AR_GetDMAStatus());
}
/**
/****************************************************************************
* ARAMFetch
*
* This function will move data from ARAM to MAIN memory
*/
***************************************************************************/
void
ARAMFetch (char *dst, char *src, int len)
{
@ -41,11 +45,11 @@ ARAMFetch (char *dst, char *src, int len)
while (AR_GetDMAStatus ());
}
/**
/****************************************************************************
* ARAMFetchSlow
*
* Required as SNES memory may NOT be 32-byte aligned
*/
***************************************************************************/
void
ARAMFetchSlow (char *dst, char *src, int len)
{

View File

@ -1,10 +1,13 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Audio RAM
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
****************************************************************************/
*
* aram.h
*
* Gamecube Audio RAM storage
***************************************************************************/
#ifndef _GCARAMI_
#define _GCARAMI_

View File

@ -1,17 +1,20 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Audio
*
* Audio is fixed to 32Khz/16bit/Stereo
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
****************************************************************************/
*
* audio.cpp
*
* Audio driver
* Audio is fixed to 32Khz/16bit/Stereo
***************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "snes9x.h"
#include "memmap.h"
#include "debug.h"
@ -40,9 +43,9 @@ lwpq_t audioqueue;
lwp_t athread;
static uint8 astack[AUDIOSTACK];
/**
/****************************************************************************
* Audio Threading
*/
***************************************************************************/
static void *
AudioThread (void *arg)
{
@ -64,10 +67,10 @@ AudioThread (void *arg)
return NULL;
}
/**
/****************************************************************************
* MixSamples
* This continually calls S9xMixSamples On each DMA Completion
*/
***************************************************************************/
static void
GCMixSamples ()
{
@ -80,9 +83,9 @@ GCMixSamples ()
LWP_ThreadSignal (audioqueue);
}
/**
/****************************************************************************
* InitGCAudio
*/
***************************************************************************/
void
InitGCAudio ()
{
@ -92,11 +95,11 @@ InitGCAudio ()
LWP_CreateThread (&athread, AudioThread, NULL, astack, AUDIOSTACK, 80);
}
/**
/****************************************************************************
* AudioStart
*
* Called to kick off the Audio Queue
*/
***************************************************************************/
void
AudioStart ()
{

View File

@ -1,12 +1,13 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Audio
*
* Audio is fixed to 32Khz/16bit/Stereo
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
****************************************************************************/
*
* audio.h
*
* Audio driver
* Audio is fixed to 32Khz/16bit/Stereo
***************************************************************************/
void InitGCAudio ();
void AudioStart ();

View File

@ -1,29 +1,28 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Wii/Gamecube Port
* michniewski August 2008
*
* button_mapping.c
*
* Controller button mapping
****************************************************************************/
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ogcsys.h>
#include <unistd.h>
#include <wiiuse/wpad.h>
#include "button_mapping.h"
/***
/****************************************************************************
* Controller Button Descriptions:
* used for identifying which buttons have been pressed when configuring
* and for displaying the name of said button
***/
***************************************************************************/
CtrlrMap ctrlr_def[4] = {
// Nunchuk btn def

View File

@ -1,13 +1,12 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Wii/Gamecube Port
* michniewski August 2008
*
* button_mapping.h
*
* Controller button mapping
****************************************************************************/
***************************************************************************/
#ifndef BTN_MAP_H
#define BTN_MAP_H

View File

@ -1,14 +1,12 @@
/****************************************************************************
* Snes9x 1.51
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Tantric August 2008
*
* cheatmgr.cpp
*
* Cheat handling
****************************************************************************/
***************************************************************************/
#include "memmap.h"
#include "cheats.h"
@ -27,7 +25,7 @@ extern unsigned char savebuffer[];
*
* Loads cheat file from save buffer
* Custom version of S9xLoadCheatFile()
****************************************************************************/
***************************************************************************/
bool8 NGCLoadCheatFile (int length)
{
@ -61,7 +59,7 @@ bool8 NGCLoadCheatFile (int length)
*
* Erases any prexisting cheats, loads cheats from a cheat file
* Called when a ROM is first loaded
****************************************************************************/
***************************************************************************/
void
SetupCheats()
{

View File

@ -1,12 +1,11 @@
/****************************************************************************
* Snes9x 1.51
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Wii/Gamecube Port
* Tantric August 2008
*
* cheatmgr.h
*
* Cheat handling
****************************************************************************/
***************************************************************************/
void SetupCheats();

View File

@ -1,11 +1,15 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube DVD
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* svpe & crunchy2 June 2007
****************************************************************************/
* Tantric September 2008
*
* dvd.cpp
*
* DVD I/O functions
***************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
@ -43,12 +47,12 @@ unsigned char DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32);
unsigned char dvdbuffer[2048];
/**
/****************************************************************************
* dvd_read
*
* The only DVD function we need - you gotta luv gc-linux self-boots!
* returns: 1 - ok ; 0 - error
*/
***************************************************************************/
int
dvd_read (void *dst, unsigned int len, u64 offset)
{
@ -60,7 +64,8 @@ dvd_read (void *dst, unsigned int len, u64 offset)
DCInvalidateRange ((void *) buffer, len);
if(offset < 0x57057C00 || (isWii && offset < 0x118244F00LL)) // don't read past the end of the DVD
// don't read past the end of the DVD (1.5 GB for GC DVD, 4.7 GB for DVD)
if(offset < 0x57057C00 || (isWii && offset < 0x118244F00LL))
{
#ifdef HW_DOL
@ -106,12 +111,12 @@ dvd_read (void *dst, unsigned int len, u64 offset)
#define PVDROOT 0x9c
static int IsJoliet = 0;
/**
/****************************************************************************
* Primary Volume Descriptor
*
* The PVD should reside between sector 16 and 31.
* This is for single session DVD only.
*/
***************************************************************************/
int
getpvd ()
{
@ -174,7 +179,7 @@ getpvd ()
* TestDVD()
*
* Tests if a ISO9660 DVD is inserted and available
****************************************************************************/
***************************************************************************/
bool TestDVD()
{
@ -193,12 +198,12 @@ bool TestDVD()
return true;
}
/**
/****************************************************************************
* getentry
*
* Support function to return the next file entry, if any
* Declared static to avoid accidental external entry.
*/
***************************************************************************/
static int diroffset = 0;
static int
getentry (int entrycount)
@ -304,7 +309,7 @@ getentry (int entrycount)
return 0;
}
/**
/****************************************************************************
* parseDVDdirectory
*
* This function will parse the directory tree.
@ -312,7 +317,7 @@ getentry (int entrycount)
* getpvd, a previous parse or a menu selection.
*
* The return value is number of files collected, or 0 on failure.
*/
***************************************************************************/
int
ParseDVDdirectory ()
{
@ -356,12 +361,12 @@ ParseDVDdirectory ()
return filecount;
}
/**
/****************************************************************************
* DirectorySearch
*
* Searches for the directory name specified within the current directory
* Returns the index of the directory, or -1 if not found
*/
***************************************************************************/
int DirectorySearch(char dir[512])
{
for (int i = 0; i < maxfiles; i++ )
@ -370,13 +375,13 @@ int DirectorySearch(char dir[512])
return -1;
}
/**
/****************************************************************************
* SwitchDVDFolder
*
* Recursively searches for any directory path 'dir' specified
* Also loads the directory contents via ParseDVDdirectory()
* It relies on dvddir, dvddirlength, and filelist being pre-populated
*/
***************************************************************************/
bool SwitchDVDFolder(char * dir, int maxDepth)
{
if(maxDepth > 8) // only search to a max depth of 8 levels
@ -434,7 +439,7 @@ bool SwitchDVDFolder(char origdir[])
* dvddirlength.
*
* The buffer parameter should re-use the initial ROM buffer.
****************************************************************************/
***************************************************************************/
int
LoadDVDFile (unsigned char *buffer)
@ -485,7 +490,7 @@ LoadDVDFile (unsigned char *buffer)
* memcard interface.
*
* libOGC tends to foul up if you don't, and sometimes does if you do!
****************************************************************************/
***************************************************************************/
#ifdef HW_DOL
void uselessinquiry ()
{
@ -501,6 +506,10 @@ void uselessinquiry ()
while (dvd[7] & 1);
}
/****************************************************************************
* dvd_motor_off( )
* Turns off DVD drive motor so it doesn't make noise (Gamecube only)
***************************************************************************/
void dvd_motor_off( )
{
dvd[0] = 0x2e;
@ -518,11 +527,11 @@ void dvd_motor_off( )
dvd[1] = 0;
}
/**
/****************************************************************************
* dvd_driveid
*
* Gets and returns the dvd driveid
**/
***************************************************************************/
int dvd_driveid()
{
@ -546,6 +555,11 @@ int dvd_driveid()
#endif
/****************************************************************************
* SetDVDDriveType()
*
* Sets the DVD drive ID for use to determine disc size (1.5 GB or 4.7 GB)
***************************************************************************/
void SetDVDDriveType()
{
#ifdef HW_RVL

View File

@ -1,11 +1,14 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube DVD
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* svpe & crunchy2 June 2007
****************************************************************************/
* Tantric September 2008
*
* dvd.h
*
* DVD I/O functions
***************************************************************************/
#ifndef _NGCDVD_
#define _NGCDVD_

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007
@ -9,8 +7,9 @@
*
* fileop.cpp
*
* File operations
****************************************************************************/
* FAT File operations
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <string.h>
@ -39,7 +38,7 @@ extern FILEENTRIES filelist[MAXFILES];
/****************************************************************************
* fat_is_mounted
* to check whether FAT media are detected.
****************************************************************************/
***************************************************************************/
bool FatIsMounted(PARTITION_INTERFACE partition) {
char prefix[] = "fatX:/";
@ -56,7 +55,7 @@ bool FatIsMounted(PARTITION_INTERFACE partition) {
* changeFATInterface
* Checks if the device (method) specified is available, and
* sets libfat to use the device
****************************************************************************/
***************************************************************************/
bool ChangeFATInterface(int method, bool silent)
{
bool devFound = false;
@ -110,7 +109,7 @@ bool ChangeFATInterface(int method, bool silent)
/***************************************************************************
* Browse FAT subdirectories
***************************************************************************/
**************************************************************************/
int
ParseFATdirectory(int method)
{
@ -171,7 +170,7 @@ ParseFATdirectory(int method)
/****************************************************************************
* LoadFATFile
****************************************************************************/
***************************************************************************/
int
LoadFATFile (char *filename, int length)
{
@ -225,7 +224,7 @@ LoadFATFile (char *filename, int length)
/****************************************************************************
* Load savebuffer from FAT file
****************************************************************************/
***************************************************************************/
int
LoadBufferFromFAT (char *filepath, bool silent)
{
@ -261,7 +260,7 @@ LoadBufferFromFAT (char *filepath, bool silent)
/****************************************************************************
* Write savebuffer to FAT card file
****************************************************************************/
***************************************************************************/
int
SaveBufferToFAT (char *filepath, int datasize, bool silent)
{

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007
@ -9,7 +7,7 @@
*
* fileop.h
*
* File operations
* FAT File operations
****************************************************************************/
#ifndef _FATFILESC_

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* svpe June 2007
@ -11,7 +9,8 @@
* filesel.cpp
*
* Generic file routines - reading, writing, browsing
****************************************************************************/
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
@ -60,8 +59,9 @@ FILEENTRIES filelist[MAXFILES];
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN (32);
/****************************************************************************
* ClearSaveBuffer ()
* Clear the savebuffer
****************************************************************************/
***************************************************************************/
void
ClearSaveBuffer ()
{
@ -118,8 +118,9 @@ int autoSaveMethod()
}
}
/***************************************************************************
* Update curent directory name
/****************************************************************************
* UpdateDirName()
* Update curent directory name for file browser
***************************************************************************/
int UpdateDirName(int method)
{
@ -176,7 +177,7 @@ int UpdateDirName(int method)
}
}
/***************************************************************************
/****************************************************************************
* FileSortCallback
*
* Quick sort callback to sort file entries with the following order:
@ -207,7 +208,7 @@ int FileSortCallback(const void *f1, const void *f2)
* StripExt
*
* Strips an extension from a filename
****************************************************************************/
***************************************************************************/
void StripExt(char* returnstring, char * inputstring)
{
@ -223,7 +224,7 @@ void StripExt(char* returnstring, char * inputstring)
* FileSelector
*
* Let user select a file from the listing
****************************************************************************/
***************************************************************************/
int FileSelector (int method)
{
u32 p = 0;
@ -455,7 +456,7 @@ int FileSelector (int method)
* OpenDVD
*
* Function to load a DVD directory and display to user.
****************************************************************************/
***************************************************************************/
int
OpenDVD (int method)
{
@ -504,7 +505,7 @@ OpenDVD (int method)
* OpenSMB
*
* Function to load from an SMB share
****************************************************************************/
***************************************************************************/
int
OpenSMB (int method)
{
@ -533,7 +534,7 @@ OpenSMB (int method)
* OpenFAT
*
* Function to load from FAT
****************************************************************************/
***************************************************************************/
int
OpenFAT (int method)
{
@ -562,7 +563,7 @@ OpenFAT (int method)
/****************************************************************************
* OpenROM
* Opens device specified by method, displays a list of ROMS
****************************************************************************/
***************************************************************************/
int
OpenROM (int method)

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007-July 2007
@ -11,12 +9,10 @@
*
* Snapshots Memory File System
*
* This is a single global memory file controller. Don't even think of opening two
* at the same time !
*
* There's just enough here to do SnapShots - you should add anything else you
* need.
****************************************************************************/
* This is a single global memory file controller.
* Don't even think of opening two at the same time!
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
@ -50,11 +46,11 @@ static int bufoffset;
char freezecomment[2][32];
/**
/****************************************************************************
* GetMem
*
* Return x bytes from memory buffer
*/
***************************************************************************/
int
GetMem (char *buffer, int len)
{
@ -64,11 +60,11 @@ GetMem (char *buffer, int len)
return len;
}
/**
/****************************************************************************
* PutMem
*
* Put some values in memory buffer
*/
***************************************************************************/
static void
PutMem (char *buffer, int len)
{
@ -85,9 +81,11 @@ NGCFreezeBlock (char *name, uint8 * block, int size)
PutMem ((char *) block, size);
}
/**
/****************************************************************************
* NGCFreezeMembuffer
*/
*
* Copies a snapshot of Snes9x state into memory
***************************************************************************/
static int
NGCFreezeMemBuffer ()
{
@ -120,11 +118,11 @@ NGCFreezeMemBuffer ()
}
/**
/****************************************************************************
* NGCFreezeGame
*
* Do freeze game for Nintendo Gamecube
*/
***************************************************************************/
int
NGCFreezeGame (int method, bool8 silent)
{
@ -209,9 +207,9 @@ NGCFreezeGame (int method, bool8 silent)
return 0;
}
/**
/****************************************************************************
* NGCUnFreezeBlock
*/
***************************************************************************/
int
NGCUnFreezeBlock (char *name, uint8 * block, int size)
{
@ -246,9 +244,9 @@ NGCUnFreezeBlock (char *name, uint8 * block, int size)
return SUCCESS;
}
/**
/****************************************************************************
* NGCUnfreezeGame
*/
***************************************************************************/
int
NGCUnfreezeGame (int method, bool8 silent)
{

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007-July 2007
@ -11,12 +9,9 @@
*
* Snapshots Memory File System
*
* This is a single global memory file controller. Don't even think of opening two
* at the same time !
*
* There's just enough here to do SnapShots - you should add anything else you
* need.
****************************************************************************/
* This is a single global memory file controller.
* Don't even think of opening two at the same time!
***************************************************************************/
#ifndef _NGCMEMFILE_
#define _NGCMEMFILE_

View File

@ -1,10 +0,0 @@
/****************************************************************************
* gctime.h
****************************************************************************/
extern "C" {
long long gettime();
u32 diff_usec(long long start,long long end);
}

View File

@ -1,3 +1,15 @@
/****************************************************************************
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May-June 2007
* Tantric September 2008
*
* input.cpp
*
* Wii/Gamecube controller management
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
@ -25,7 +37,7 @@ extern int ConfigRequested;
* Controller Functions
*
* The following map the NGC Pads to the *NEW* controller system.
****************************************************************************/
***************************************************************************/
#define ASSIGN_BUTTON_TRUE( keycode, snescmd ) \
S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), true)
@ -83,6 +95,12 @@ unsigned int gcjustmap[] = { PAD_BUTTON_A, PAD_BUTTON_B, PAD_BUTTON_START };
/*** Justifier : wiimote button mapping ***/
unsigned int wmjustmap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B, WPAD_BUTTON_PLUS };
/****************************************************************************
* WPAD_StickX
*
* Get X value from Wii Joystick (classic, nunchuk) input
***************************************************************************/
s8 WPAD_StickX(u8 chan,u8 right)
{
float mag = 0.0;
@ -125,6 +143,12 @@ s8 WPAD_StickX(u8 chan,u8 right)
return (s8)(val * 128.0f);
}
/****************************************************************************
* WPAD_StickY
*
* Get Y value from Wii Joystick (classic, nunchuk) input
***************************************************************************/
s8 WPAD_StickY(u8 chan, u8 right)
{
float mag = 0.0;
@ -171,6 +195,12 @@ s8 WPAD_StickY(u8 chan, u8 right)
static int cursor_x[5] = {0,0,0,0,0};
static int cursor_y[5] = {0,0,0,0,0};
/****************************************************************************
* UpdateCursorPosition
*
* Updates X/Y coordinates for Superscope/mouse/justifier position
***************************************************************************/
void UpdateCursorPosition (int pad, int &pos_x, int &pos_y)
{
#define SCOPEPADCAL 20
@ -233,8 +263,12 @@ void UpdateCursorPosition (int pad, int &pos_x, int &pos_y)
}
/****************************************************************************
* This is the joypad algorithm submitted by Krullo.
* decodepad
*
* Reads the changes (buttons pressed, etc) from a controller and reports
* these changes to Snes9x
****************************************************************************/
void decodepad (int pad)
{
int i, offset;
@ -424,8 +458,10 @@ void decodepad (int pad)
/****************************************************************************
* NGCReportButtons
*
* Called on each rendered frame
****************************************************************************/
* Our way of putting controller input into Snes9x
***************************************************************************/
void NGCReportButtons ()
{
s8 gc_px = PAD_SubStickX (0);
@ -521,10 +557,9 @@ void SetControllers ()
}
}
/****************************************************************************
* Set the default mapping for NGC
****************************************************************************/
***************************************************************************/
void SetDefaultButtonMap ()
{
int maxcode = 0x10;

View File

@ -1,3 +1,14 @@
/****************************************************************************
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May-June 2007
* Tantric September 2008
*
* input.h
*
* Wii/Gamecube controller management
***************************************************************************/
#ifndef _INPUT_H_
#define _INPUT_H_
@ -18,8 +29,6 @@ extern unsigned int wmmousemap[];
extern unsigned int gcjustmap[];
extern unsigned int wmjustmap[];
//START_EXTERN_C
s8 WPAD_StickX(u8 chan,u8 right);
s8 WPAD_StickY(u8 chan, u8 right);
@ -29,6 +38,4 @@ void NGCReportButtons ();
void SetControllers ();
void SetDefaultButtonMap ();
//END_EXTERN_C
#endif

View File

@ -1,14 +1,15 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* softdev July 2006
* crunchy2 May-June 2007
* Tantric September 2008
*
* memcardop.cpp
*
* Memory Card Routines.
****************************************************************************/
* Memory Card routines
***************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
@ -52,7 +53,7 @@ card_stat CardStatus;
*
* Wrapper to search through the files on the card.
* Returns TRUE if found.
****************************************************************************/
***************************************************************************/
int
CardFileExists (char *filename, int slot)
{
@ -74,7 +75,7 @@ CardFileExists (char *filename, int slot)
* TestCard
*
* Checks to see if a card is in the card slot specified
****************************************************************************/
***************************************************************************/
bool TestCard(int slot, bool silent)
{
// Memory Cards do not work in Wii mode - disable
@ -119,7 +120,7 @@ bool TestCard(int slot, bool silent)
*
* Mounts the memory card in the given slot.
* Returns the result of the last attempted CARD_Mount command.
****************************************************************************/
***************************************************************************/
int MountCard(int cslot, bool silent)
{
int ret = -1;
@ -139,7 +140,7 @@ int MountCard(int cslot, bool silent)
/****************************************************************************
* Verify Memory Card file against buffer
****************************************************************************/
***************************************************************************/
int
VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize)
{
@ -217,10 +218,9 @@ VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize)
return 0;
}
/****************************************************************************
* Load savebuffer from Memory Card file
****************************************************************************/
***************************************************************************/
int
LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
{
@ -285,7 +285,7 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
/****************************************************************************
* Write savebuffer to Memory Card file
****************************************************************************/
***************************************************************************/
int
SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool8 silent)
{
@ -325,31 +325,6 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
return 0;
}
// if ( (s32)blocks < CardFile.len ) /*** new data is shorter ***/
// {
// CARD_Close (&CardFile);
//
// /*** Delete the existing longer file ***/
// CardError = CARD_Delete(slot, filename);
// if (CardError)
// {
// CARD_Unmount (slot);
// WaitPrompt((char*) "Unable to delete existing file!");
// return 0;
// }
//
// /*** Create new, shorter file ***/
// CardError = CARD_Create (slot, filename, blocks, &CardFile);
// if (CardError)
// {
// CARD_Unmount (slot);
// WaitPrompt((char*) "Unable to create updated card file!");
// return 0;
// }
//
// }
// else
if ( (s32)blocks > CardFile.len ) /*** new data is longer ***/
{
CARD_Close (&CardFile);
@ -457,5 +432,3 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
return 0;
}

View File

@ -1,14 +1,14 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* softdev July 2006
* crunchy2 May 2007
* crunchy2 May-June 2007
* Tantric September 2008
*
* memcardop.h
* memcardop.cpp
*
* Memory Card Routines.
****************************************************************************/
* Memory Card routines
***************************************************************************/
#ifndef _NGCMCSAVE_
#define _NGCMCSAVE_

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.51
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May-June 2007
@ -9,8 +7,9 @@
*
* menu.cpp
*
* Menu flow routines
****************************************************************************/
* Menu flow routines - handles all menu logic
***************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
@ -19,12 +18,10 @@
#include <wiiuse/wpad.h>
#ifdef WII_DVD
#ifdef __cplusplus
extern "C" {
#include <di/di.h>
}
#endif
#endif
#include "snes9x.h"
#include "memmap.h"
@ -69,7 +66,7 @@ extern unsigned long ARAM_ROMSIZE;
/****************************************************************************
* Reboot / Exit
****************************************************************************/
***************************************************************************/
#ifndef HW_RVL
#define PSOSDLOADID 0x7c6000a6
@ -89,7 +86,7 @@ void Reboot()
/****************************************************************************
* Load Manager
****************************************************************************/
***************************************************************************/
int
LoadManager ()
@ -115,7 +112,7 @@ LoadManager ()
/****************************************************************************
* Preferences Menu
****************************************************************************/
***************************************************************************/
static int prefmenuCount = 16;
static char prefmenu[][50] = {
@ -334,7 +331,7 @@ PreferencesMenu ()
/****************************************************************************
* Cheat Menu
****************************************************************************/
***************************************************************************/
static int cheatmenuCount = 0;
static char cheatmenu[MAX_CHEATS][50];
static char cheatmenuvalue[MAX_CHEATS][50];
@ -512,7 +509,7 @@ void CheatMenu()
/****************************************************************************
* Game Options Menu
****************************************************************************/
***************************************************************************/
int
GameMenu ()
@ -610,10 +607,10 @@ GameMenu ()
/****************************************************************************
* Controller Configuration
*
* Snes9x 1.50 uses a cmd system to work out which button has been pressed.
* Here, I simply move the designated value to the gcpadmaps array, which saves
* on updating the cmd sequences.
****************************************************************************/
* Snes9x 1.51 uses a cmd system to work out which button has been pressed.
* Here, I simply move the designated value to the gcpadmaps array, which
* saves on updating the cmd sequences.
***************************************************************************/
u32
GetInput (u16 ctrlr_type)
{
@ -936,7 +933,7 @@ ConfigureControllers ()
/****************************************************************************
* Main Menu
****************************************************************************/
***************************************************************************/
int menucount = 7;
char menuitems[][50] = {
"Choose Game", "Controller Configuration", "Preferences",

View File

@ -1,10 +1,14 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
****************************************************************************/
* crunchy2 May-June 2007
* Tantric August 2008
*
* menu.h
*
* Menu flow routines - handles all menu logic
***************************************************************************/
#ifndef _NGCMENU_

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 June 2007
@ -17,7 +15,8 @@
* **WARNING***
*
* ONLY USE GUARANTEED PATENT FREE FONTS.
****************************************************************************/
***************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
@ -65,7 +64,7 @@ u32 getrgb( u32 ycbr, u32 low );
/****************************************************************************
* Initialisation of libfreetype
****************************************************************************/
***************************************************************************/
int
FT_Init ()
{
@ -94,7 +93,7 @@ FT_Init ()
* setfontsize
*
* Set the screen font size in pixels
****************************************************************************/
***************************************************************************/
void
setfontsize (int pixelsize)
{
@ -109,7 +108,7 @@ setfontsize (int pixelsize)
/****************************************************************************
* DrawCharacter
* Draws a single character on the screen
****************************************************************************/
***************************************************************************/
static void
DrawCharacter (FT_Bitmap * bmp, FT_Int x, FT_Int y)
{
@ -151,7 +150,7 @@ DrawCharacter (FT_Bitmap * bmp, FT_Int x, FT_Int y)
* DrawText
*
* Place the font bitmap on the screen
****************************************************************************/
***************************************************************************/
void
DrawText (int x, int y, char *text)
{
@ -207,7 +206,7 @@ DrawText (int x, int y, char *text)
* setfontcolour
*
* Uses RGB triple values.
****************************************************************************/
***************************************************************************/
void
setfontcolour (u8 r, u8 g, u8 b)
{
@ -222,7 +221,7 @@ setfontcolour (u8 r, u8 g, u8 b)
* Display credits, legal copyright and licence
*
* THIS MUST NOT BE REMOVED IN ANY DERIVATIVE WORK.
****************************************************************************/
***************************************************************************/
void
Credits ()
{
@ -280,7 +279,7 @@ Credits ()
* Simply converts RGB to Y1CbY2Cr format
*
* I got this from a pastebin, so thanks to whoever originally wrote it!
****************************************************************************/
***************************************************************************/
unsigned int
getcolour (u8 r1, u8 g1, u8 b1)
@ -308,7 +307,9 @@ getcolour (u8 r1, u8 g1, u8 b1)
/****************************************************************************
* Unpackbackdrop
****************************************************************************/
*
* Decompress menu background and store it in ARAM or memory
***************************************************************************/
void
unpackbackdrop ()
{
@ -346,7 +347,7 @@ unpackbackdrop ()
/****************************************************************************
* Wait for user to press A
****************************************************************************/
***************************************************************************/
void
WaitButtonA ()
{
@ -361,7 +362,7 @@ WaitButtonA ()
/****************************************************************************
* Wait for user to press A or B. Returns 0 = B; 1 = A
****************************************************************************/
***************************************************************************/
int
WaitButtonAB ()
@ -400,7 +401,7 @@ WaitButtonAB ()
/****************************************************************************
* Show a prompt
****************************************************************************/
***************************************************************************/
void
WaitPrompt (char *msg)
{
@ -422,7 +423,7 @@ WaitPrompt (char *msg)
/****************************************************************************
* Show a prompt with choice of two options. Returns 1 if A button was pressed
and 0 if B button was pressed.
****************************************************************************/
***************************************************************************/
int
WaitPromptChoice (char *msg, char *bmsg, char *amsg)
{
@ -445,7 +446,7 @@ WaitPromptChoice (char *msg, char *bmsg, char *amsg)
/****************************************************************************
* Show an action in progress
****************************************************************************/
***************************************************************************/
void
ShowAction (char *msg)
{
@ -463,7 +464,7 @@ ShowAction (char *msg)
/****************************************************************************
* Generic Menu Routines
****************************************************************************/
***************************************************************************/
void
DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsize, int x)
{
@ -530,7 +531,7 @@ DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsiz
*
* Help function to find the next visible menu item on the list
* Supports menu wrap-around
****************************************************************************/
***************************************************************************/
int FindMenuItem(char items[][50], int maxitems, int currentItem, int direction)
{
@ -552,7 +553,7 @@ int FindMenuItem(char items[][50], int maxitems, int currentItem, int direction)
*
* Call this with the menu array defined in menu.cpp
* It's here to keep all the font / interface stuff together.
****************************************************************************/
***************************************************************************/
int menu = 0;
int
@ -631,7 +632,7 @@ RunMenu (char items[][50], int maxitems, char *title, int fontsize, int x)
* Showfile screen
*
* Display the file selection to the user
****************************************************************************/
***************************************************************************/
void
ShowFiles (FILEENTRIES filelist[], int maxfiles, int offset, int selection)
@ -693,7 +694,7 @@ ShowFiles (FILEENTRIES filelist[], int maxfiles, int offset, int selection)
* Cheats screen
*
* Displays a scrollable list of cheats to the user
****************************************************************************/
***************************************************************************/
void
ShowCheats (char items[][50], char itemvalues[][50], int maxitems, int offset, int selection)
@ -740,7 +741,7 @@ ShowCheats (char items[][50], char itemvalues[][50], int maxitems, int offset, i
/****************************************************************************
* ROM Information Screen
****************************************************************************/
***************************************************************************/
void RomInfo()
{
@ -827,7 +828,7 @@ void RomInfo()
* DrawLine
*
* Quick'n'Dirty Bresenham line drawing routine.
****************************************************************************/
***************************************************************************/
#define SIGN(x) ((x<0)?-1:((x>0)?1:0))
void
@ -912,7 +913,7 @@ DrawLine (int x1, int y1, int x2, int y2, u8 r, u8 g, u8 b)
* Progress Bar
*
* Show the user what's happening
****************************************************************************/
***************************************************************************/
void
ShowProgress (char *msg, int done, int total)
{
@ -944,7 +945,7 @@ ShowProgress (char *msg, int done, int total)
/****************************************************************************
* DrawPolygon
****************************************************************************/
***************************************************************************/
void
DrawPolygon (int vertices, int varray[], u8 r, u8 g, u8 b)
{
@ -960,12 +961,12 @@ DrawPolygon (int vertices, int varray[], u8 r, u8 g, u8 b)
varray[(vertices << 1) - 1], r, g, b);
}
/*****************************************************************************
/****************************************************************************
* Draw Line Fast
*
* This routine requires that start and endx are 32bit aligned.
* It tries to perform a semi-transparency over the existing image.
*****************************************************************************/
***************************************************************************/
#define SRCWEIGHT 0.7f
#define DSTWEIGHT (1.0f - SRCWEIGHT)
@ -1017,10 +1018,10 @@ void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b )
}
}
/*****************************************************************************
/****************************************************************************
* Ok, I'm useless with Y1CBY2CR colour.
* So convert back to RGB so I can work with it -;)
****************************************************************************/
***************************************************************************/
u32 getrgb( u32 ycbr, u32 low )
{
u8 r,g,b;

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 June 2007
@ -17,7 +15,7 @@
* **WARNING***
*
* ONLY USE GUARANTEED PATENT FREE FONTS.
****************************************************************************/
***************************************************************************/
#ifndef _NGCMENUDRAW_
#define _NGCMENUDRAW_

View File

@ -1,181 +0,0 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Port
* softdev July 2006
*
* ngc_missing.cpp
*
* This file contains the missing low-level file I/O function definitions.
* Note that these are DUMMY functions, and only allow Snes9x to
* compile. Where possible, they will return an error signal.
****************************************************************************/
/****************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 Brad Jorsch (anomie@users.sourceforge.net),
funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com),
Nach (n-a-c-h@users.sourceforge.net), and
zones (kasumitokoduck@yahoo.com)
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x filter
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
*****************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*** splitpath function ***/
void
_splitpath (char const *buffer, char *drive, char *dir, char *fname,
char *ext)
{
return; /*** Do nothing - NGC code should NEVER call a function which relies on it ***/
}
void
_makepath (char *filename, const char *drive, const char *dir,
const char *fname, const char *ext)
{
return; /*** Do nothing - NGC code should NEVER call a function which relies on it ***/
}
char *
S9xBasename (char *name)
{
return name;
}

View File

@ -1,13 +1,13 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* crunchy2 April 2007-July 2007
* Tantric September 2008
*
* preferences.cpp
*
* Preferences save/load preferences utilities
****************************************************************************/
* Preferences save/load to XML file
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <string.h>
@ -43,7 +43,7 @@ char prefscomment[2][32];
* Prepare Preferences Data
*
* This sets up the save buffer for saving.
****************************************************************************/
***************************************************************************/
mxml_node_t *xml;
mxml_node_t *data;
mxml_node_t *section;
@ -191,8 +191,11 @@ preparePrefsData (int method)
/****************************************************************************
* Decode Preferences Data
****************************************************************************/
* loadXMLSetting
*
* Load XML elements into variables for an individual variable
***************************************************************************/
void loadXMLSetting(char * var, const char * name)
{
item = mxmlFindElement(xml, xml, "setting", "name", name, MXML_DESCEND);
@ -212,6 +215,12 @@ void loadXMLSetting(bool8 * var, const char * name)
*var = atoi(mxmlElementGetAttr(item, "value"));
}
/****************************************************************************
* loadXMLController
*
* Load XML elements into variables for a controller mapping
***************************************************************************/
void loadXMLController(unsigned int controller[], const char * name)
{
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
@ -228,6 +237,12 @@ void loadXMLController(unsigned int controller[], const char * name)
}
}
/****************************************************************************
* decodePrefsData
*
* Decodes preferences - parses XML and loads preferences into the variables
***************************************************************************/
bool
decodePrefsData (int method)
{
@ -297,7 +312,7 @@ decodePrefsData (int method)
/****************************************************************************
* Save Preferences
****************************************************************************/
***************************************************************************/
bool
SavePrefs (int method, bool silent)
{
@ -346,7 +361,7 @@ SavePrefs (int method, bool silent)
/****************************************************************************
* Load Preferences from specified method
****************************************************************************/
***************************************************************************/
bool
LoadPrefsFromMethod (int method)
{
@ -385,7 +400,7 @@ LoadPrefsFromMethod (int method)
/****************************************************************************
* Load Preferences
* Checks sources consecutively until we find a preference file
****************************************************************************/
***************************************************************************/
bool LoadPrefs()
{
ShowAction ((char*) "Loading preferences...");

View File

@ -1,13 +1,12 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* crunchy2 April 2007
* Tantric September 2008
*
* preferences.cpp
* preferences.h
*
* Preferences save/load preferences utilities
****************************************************************************/
* Preferences save/load to XML file
***************************************************************************/
bool SavePrefs (int method, bool silent);
bool LoadPrefs ();

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.51
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007
@ -12,7 +10,7 @@
* Configuration parameters are here for easy maintenance.
* Refer to Snes9x.h for all combinations.
* The defaults used here are taken directly from porting.html
****************************************************************************/
***************************************************************************/
#include <gccore.h>
#include "snes9x.h"

View File

@ -1,15 +1,16 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* softdev July 2006
* crunchy2 May 2007
* Tantric September 2008
*
* s9xconfig.h
*
* Configuration parameters have been moved here for easier maintenance.
* Configuration parameters are here for easy maintenance.
* Refer to Snes9x.h for all combinations.
* The defaults used here are taken directly from porting.html
****************************************************************************/
***************************************************************************/
#ifndef _S9XCONFIG_

View File

@ -1,158 +1,16 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* softdev July 2006
* crunchy2 May 2007
* Tantric September 2008
*
* s9xsupport.cpp
*
* This file contains the supporting functions defined in porting.html, with
* others taken from unix/x11.cpp and unix/unix.cpp
****************************************************************************/
***************************************************************************/
/****************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 Brad Jorsch (anomie@users.sourceforge.net),
funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com),
Nach (n-a-c-h@users.sourceforge.net), and
zones (kasumitokoduck@yahoo.com)
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x filter
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
*****************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
@ -173,7 +31,6 @@
#include "spc7110.h"
#include "controls.h"
#include "gctime.h"
#include "snes9xGX.h"
#include "video.h"
#include "audio.h"
@ -183,6 +40,12 @@ extern u32 FrameTimer;
long long prev;
long long now;
extern "C" {
long long gettime();
u32 diff_usec(long long start,long long end);
}
/*** Miscellaneous Functions ***/
void
@ -259,7 +122,7 @@ S9xToggleSoundChannel (int c)
* OpenSoundDevice
*
* Main initialisation for NGC sound system
****************************************************************************/
***************************************************************************/
bool8
S9xOpenSoundDevice (int mode, bool8 stereo, int buffer_size)
{
@ -431,3 +294,29 @@ S9xLoadSDD1Data ()
return;
}
/****************************************************************************
* Note that these are DUMMY functions, and only allow Snes9x to
* compile. Where possible, they will return an error signal.
***************************************************************************/
/*** splitpath function ***/
void
_splitpath (char const *buffer, char *drive, char *dir, char *fname,
char *ext)
{
return; /*** Do nothing - NGC code should NEVER call a function which relies on it ***/
}
void
_makepath (char *filename, const char *drive, const char *dir,
const char *fname, const char *ext)
{
return; /*** Do nothing - NGC code should NEVER call a function which relies on it ***/
}
char *
S9xBasename (char *name)
{
return name;
}

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007
@ -11,6 +9,7 @@
*
* SMB support routines
****************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <string.h>

View File

@ -1,12 +1,11 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Wii/Gamecube Port
* softdev July 2006
* crunchy2 May 2007
* Tantric August 2008
*
* smbop.h
* smbload.h
*
* SMB support routines
****************************************************************************/

View File

@ -1,157 +1,15 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* softdev July 2006
* crunchy2 May 2007-July 2007
* Tantric September 2008
*
* snes9xGX.cpp
*
* This file controls overall program flow. Most things start and end here!
****************************************************************************/
***************************************************************************/
/****************************************************************************
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
(c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and
Jerremy Koot (jkoot@snes9x.com)
(c) Copyright 2002 - 2004 Matthew Kendora
(c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org)
(c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/)
(c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net)
(c) Copyright 2002 - 2006 Brad Jorsch (anomie@users.sourceforge.net),
funkyass (funkyass@spam.shaw.ca),
Kris Bleakley (codeviolation@hotmail.com),
Nach (n-a-c-h@users.sourceforge.net), and
zones (kasumitokoduck@yahoo.com)
BS-X C emulator code
(c) Copyright 2005 - 2006 Dreamer Nom,
zones
C4 x86 assembler and some C emulation code
(c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com),
Nach,
zsKnight (zsknight@zsnes.com)
C4 C++ code
(c) Copyright 2003 - 2006 Brad Jorsch,
Nach
DSP-1 emulator code
(c) Copyright 1998 - 2006 _Demo_,
Andreas Naive (andreasnaive@gmail.com)
Gary Henderson,
Ivar (ivar@snes9x.com),
John Weidman,
Kris Bleakley,
Matthew Kendora,
Nach,
neviksti (neviksti@hotmail.com)
DSP-2 emulator code
(c) Copyright 2003 John Weidman,
Kris Bleakley,
Lord Nightmare (lord_nightmare@users.sourceforge.net),
Matthew Kendora,
neviksti
DSP-3 emulator code
(c) Copyright 2003 - 2006 John Weidman,
Kris Bleakley,
Lancer,
z80 gaiden
DSP-4 emulator code
(c) Copyright 2004 - 2006 Dreamer Nom,
John Weidman,
Kris Bleakley,
Nach,
z80 gaiden
OBC1 emulator code
(c) Copyright 2001 - 2004 zsKnight,
pagefault (pagefault@zsnes.com),
Kris Bleakley,
Ported from x86 assembler to C by sanmaiwashi
SPC7110 and RTC C++ emulator code
(c) Copyright 2002 Matthew Kendora with research by
zsKnight,
John Weidman,
Dark Force
S-DD1 C emulator code
(c) Copyright 2003 Brad Jorsch with research by
Andreas Naive,
John Weidman
S-RTC C emulator code
(c) Copyright 2001-2006 byuu,
John Weidman
ST010 C++ emulator code
(c) Copyright 2003 Feather,
John Weidman,
Kris Bleakley,
Matthew Kendora
Super FX x86 assembler emulator code
(c) Copyright 1998 - 2003 _Demo_,
pagefault,
zsKnight,
Super FX C emulator code
(c) Copyright 1997 - 1999 Ivar,
Gary Henderson,
John Weidman
Sound DSP emulator code is derived from SNEeSe and OpenSPC:
(c) Copyright 1998 - 2003 Brad Martin
(c) Copyright 1998 - 2006 Charles Bilyue'
SH assembler code partly based on x86 assembler code
(c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)
2xSaI filter
(c) Copyright 1999 - 2001 Derek Liauw Kie Fa
HQ2x filter
(c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com)
Specific ports contains the works of other authors. See headers in
individual files.
Snes9x homepage: http://www.snes9x.com
Permission to use, copy, modify and/or distribute Snes9x in both binary
and source form, for non-commercial purposes, is hereby granted without
fee, providing that this license information and copyright notice appear
with all copies and any derived work.
This software is provided 'as-is', without any express or implied
warranty. In no event shall the authors be held liable for any damages
arising from the use of this software or it's derivatives.
Snes9x is freeware for PERSONAL USE only. Commercial users should
seek permission of the copyright holders first. Commercial use includes,
but is not limited to, charging money for Snes9x or software derived from
Snes9x, including Snes9x or derivatives in commercial game bundles, and/or
using Snes9x as a promotion for your commercial product.
The copyright holders request that bug fixes and improvements to the code
should be forwarded to them so everyone can benefit from the modifications
in future versions.
Super NES and Super Nintendo Entertainment System are trademarks of
Nintendo Co., Limited and its subsidiary companies.
*****************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
@ -166,12 +24,10 @@
#include <fat.h>
#ifdef WII_DVD
#ifdef __cplusplus
extern "C" {
#include <di/di.h>
}
#endif
#endif
#include "snes9x.h"
#include "memmap.h"
@ -197,7 +53,6 @@ extern "C" {
#include "sram.h"
#include "freeze.h"
#include "preferences.h"
#include "gctime.h"
#include "button_mapping.h"
#include "fileop.h"
#include "input.h"
@ -217,7 +72,7 @@ extern void fat_enable_readahead_all();
/****************************************************************************
* setFrameTimerMethod()
* change frametimer method depending on whether ROM is NTSC or PAL
****************************************************************************/
***************************************************************************/
extern u8 vmode_60hz;
int timerstyle;
@ -245,11 +100,7 @@ void setFrameTimerMethod()
/****************************************************************************
* Emulation loop
*
* The 'clock' timer is long gone.
* System now only uses vbl as hardware clock, so force PAL50 if you need 50hz
****************************************************************************/
/* Eke-Eke: initialize frame Sync */
***************************************************************************/
extern void S9xInitSync();
bool CheckVideo = 0; // for forcing video reset in video.cpp
extern uint32 prevRenderedFrameCount;
@ -259,7 +110,7 @@ emulate ()
{
S9xSetSoundMute (TRUE);
AudioStart ();
S9xInitSync();
S9xInitSync(); // Eke-Eke: initialize frame Sync
setFrameTimerMethod(); // set frametimer method every time a ROM is loaded
@ -336,12 +187,12 @@ emulate ()
* 8. Initialise Snes9x Graphics subsystem
* 9. Let's Party!
*
* NB: The SNES ROM is now delivered from ARAM. (AR_SNESROM)
* Any method of loading a ROM, RAM, DVD, SMB, SDCard,
* The SNES ROM is delivered from ARAM. (AR_SNESROM)
* Any method of loading a ROM - RAM, DVD, SMB, SDCard, etc
* MUST place the unpacked ROM at this location.
* This provides a single consistent interface in memmap.cpp.
* Refer to that file if you need to change it.
****************************************************************************/
***************************************************************************/
int
main ()
{
@ -424,20 +275,17 @@ main ()
}
else
{
/*** Load ROM ***/
// Load ROM
save_flags = CPU.Flags;
if (!Memory.LoadROM ("VIRTUAL.ROM"))
while (1);
CPU.Flags = save_flags;
/*** Load SRAM ***/
//Memory.LoadSRAM ("DVD");
}
/*** Emulate ***/
// Emulate
emulate ();
/*** NO! - We're never leaving here ! ***/
// NO! - We're never leaving here!
while (1);
return 0;
}

View File

@ -1,14 +1,14 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* softdev July 2006
* crunchy2 May 2007-July 2007
* Tantric September 2008
*
* snes9xGX.h
*
* This file controls overall program flow. Most things start and end here!
****************************************************************************/
***************************************************************************/
#ifndef _SNES9XGX_H_
#define _SNES9XGX_H_

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* crunchy2 April 2007-July 2007
* Tantric September 2008
@ -9,7 +7,8 @@
* sram.cpp
*
* SRAM save/load/import/export handling
****************************************************************************/
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <string.h>
@ -37,8 +36,8 @@ char sramcomment[2][32];
* Prepare SRAM Save Data
*
* This sets up the savebuffer for saving in a format compatible with
* snes9x on other platforms. This is used when saving to SD / USB / SMB.
****************************************************************************/
* snes9x on other platforms.
***************************************************************************/
int
preparesavedata (int method)
{
@ -91,7 +90,7 @@ preparesavedata (int method)
/****************************************************************************
* Decode Save Data
****************************************************************************/
***************************************************************************/
void
decodesavedata (int method, int readsize)
{
@ -143,7 +142,7 @@ decodesavedata (int method, int readsize)
/****************************************************************************
* Load SRAM
****************************************************************************/
***************************************************************************/
int
LoadSRAM (int method, bool silent)
{
@ -192,7 +191,7 @@ LoadSRAM (int method, bool silent)
/****************************************************************************
* Save SRAM
****************************************************************************/
***************************************************************************/
bool
SaveSRAM (int method, bool silent)
{

View File

@ -1,13 +1,13 @@
/****************************************************************************
* Snes9x 1.50
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* Nintendo Gamecube Port
* crunchy2 April 2007
* crunchy2 April 2007-July 2007
* Tantric September 2008
*
* sram.cpp
*
* SRAM save/load/import/export handling
****************************************************************************/
***************************************************************************/
bool SaveSRAM (int method, bool silent);
int LoadSRAM (int method, bool silent);

View File

@ -1,10 +1,14 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Unzip - borrowed from the GPP
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
****************************************************************************/
* Tantric September 2008
*
* unzip.cpp
*
* File unzip routines
***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -1,9 +1,12 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Unzip - borrowed from the GPP
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* Tantric September 2008
*
* unzip.h
*
* File unzip routines
****************************************************************************/
#ifndef _UNZIP_
#define _UNZIP_

View File

@ -1,7 +1,5 @@
/****************************************************************************
* Snes9x 1.51
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
* crunchy2 May 2007
@ -9,7 +7,8 @@
* video.cpp
*
* Video routines
****************************************************************************/
***************************************************************************/
#include <gccore.h>
#include <ogcsys.h>
#include <stdio.h>
@ -248,7 +247,7 @@ GXRModeObj *tvmodes[4] = {
#ifdef VIDEO_THREADING
/****************************************************************************
* VideoThreading
****************************************************************************/
***************************************************************************/
#define TSTACK 16384
lwpq_t videoblankqueue;
lwp_t vbthread;
@ -261,7 +260,7 @@ static unsigned char vbstack[TSTACK];
* vertical blank.
*
* Putting LWP to good use :)
****************************************************************************/
***************************************************************************/
static void *
vbgetback (void *arg)
{
@ -280,7 +279,7 @@ vbgetback (void *arg)
*
* libOGC provides a nice wrapper for LWP access.
* This function sets up a new local queue and attaches the thread to it.
****************************************************************************/
***************************************************************************/
void
InitVideoThread ()
{
@ -298,7 +297,7 @@ InitVideoThread ()
*
* Stock code to copy the GX buffer to the current display mode.
* Also increments the frameticker, as it's called for each vb.
****************************************************************************/
***************************************************************************/
static void
copy_to_xfb (u32 arg)
{
@ -316,7 +315,7 @@ copy_to_xfb (u32 arg)
/****************************************************************************
* Scaler Support Functions
****************************************************************************/
***************************************************************************/
static void
draw_init ()
{
@ -376,7 +375,7 @@ draw_square (Mtx v)
* StartGX
*
* This function initialises the GX.
****************************************************************************/
***************************************************************************/
static void
StartGX ()
{
@ -426,7 +425,7 @@ StartGX ()
* UpdatePadsCB
*
* called by postRetraceCallback in InitGCVideo - scans gcpad and wpad
****************************************************************************/
***************************************************************************/
void
UpdatePadsCB ()
{
@ -441,7 +440,7 @@ UpdatePadsCB ()
*
* This function MUST be called at startup.
* - also sets up menu video mode
****************************************************************************/
***************************************************************************/
void
InitGCVideo ()
{
@ -537,7 +536,7 @@ InitGCVideo ()
/****************************************************************************
* ResetVideo_Emu
*
* reset the video/rendering mode for the emulator rendering
* Reset the video/rendering mode for the emulator rendering
****************************************************************************/
void
ResetVideo_Emu ()
@ -658,7 +657,7 @@ ResetVideo_Emu ()
/****************************************************************************
* ResetVideo_Menu
*
* reset the video/rendering mode for the menu
* Reset the video/rendering mode for the menu
****************************************************************************/
void
ResetVideo_Menu ()
@ -693,7 +692,7 @@ ResetVideo_Menu ()
* MakeTexture
*
* Proper GNU Asm rendition of the above, converted by shagkur. - Thanks!
****************************************************************************/
***************************************************************************/
void
MakeTexture (const void *src, void *dst, s32 width, s32 height)
{
@ -736,7 +735,7 @@ MakeTexture (const void *src, void *dst, s32 width, s32 height)
/****************************************************************************
* Update Video
****************************************************************************/
***************************************************************************/
uint32 prevRenderedFrameCount = 0;
extern bool CheckVideo;
@ -840,7 +839,7 @@ update_video (int width, int height)
// FIX
/****************************************************************************
* Zoom Functions
****************************************************************************/
***************************************************************************/
void
zoom (float speed)
{
@ -871,7 +870,7 @@ zoom_reset ()
/****************************************************************************
* Drawing screen
****************************************************************************/
***************************************************************************/
void
clearscreen (int colour)
{
@ -899,12 +898,10 @@ showscreen ()
* setGFX
*
* Setup the global GFX information for Snes9x
****************************************************************************/
***************************************************************************/
void
setGFX ()
{
GFX.Screen = (unsigned short *) snes9xgfx;
GFX.Pitch = 1024;
}

View File

@ -1,14 +1,13 @@
/****************************************************************************
* Snes9x 1.51
*
* Nintendo Wii/Gamecube Port
* Snes9x 1.51 Nintendo Wii/Gamecube Port
*
* softdev July 2006
*
* video.h
*
* Video routines
****************************************************************************/
***************************************************************************/
#ifndef _GCVIDEOH_
#define _GCVIDEOH_