2008-08-06 03:09:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Snes9x 1.50
|
|
|
|
*
|
|
|
|
* Nintendo Gamecube Port
|
|
|
|
* softdev July 2006
|
|
|
|
* crunchy2 May 2007-July 2007
|
|
|
|
*
|
|
|
|
* 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
|
2008-08-07 05:25:02 +02:00
|
|
|
and source form, for non-commercial purposes, is hereby granted without
|
|
|
|
fee, providing that this license information and copyright notice appear
|
2008-08-06 03:09:59 +02:00
|
|
|
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>
|
|
|
|
|
2008-08-06 03:39:43 +02:00
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
|
|
|
#include <sdcard/card_cmn.h>
|
|
|
|
#include <sdcard/wiisd_io.h>
|
|
|
|
#include <sdcard/card_io.h>
|
2008-08-07 05:25:02 +02:00
|
|
|
#include <fat.h>
|
2008-08-06 03:39:43 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "snes9x.h"
|
|
|
|
#include "memmap.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "cpuexec.h"
|
|
|
|
#include "ppu.h"
|
|
|
|
#include "apu.h"
|
|
|
|
#include "display.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
#include "soundux.h"
|
|
|
|
#include "spc700.h"
|
|
|
|
#include "spc7110.h"
|
|
|
|
#include "controls.h"
|
|
|
|
|
|
|
|
#include "snes9xGX.h"
|
|
|
|
#include "dvd.h"
|
|
|
|
#include "video.h"
|
2008-08-07 07:19:17 +02:00
|
|
|
#include "menudraw.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "s9xconfig.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "sram.h"
|
|
|
|
#include "memfile.h"
|
|
|
|
#include "preferences.h"
|
|
|
|
#include "gctime.h"
|
2008-08-06 03:45:56 +02:00
|
|
|
#include "button_mapping.h"
|
2008-08-07 07:19:17 +02:00
|
|
|
#include "fileop.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
unsigned long ARAM_ROMSIZE = 0;
|
|
|
|
int ConfigRequested = 0;
|
|
|
|
extern int FrameTimer;
|
|
|
|
|
2008-08-06 03:39:43 +02:00
|
|
|
extern long long prev;
|
2008-08-06 03:09:59 +02:00
|
|
|
extern unsigned int timediffallowed;
|
|
|
|
|
2008-08-08 04:09:02 +02:00
|
|
|
// hold superscope/mouse/justifier cursor positions
|
|
|
|
int cursor_x[5] = {0,0,0,0,0};
|
|
|
|
int cursor_y[5] = {0,0,0,0,0};
|
2008-08-06 04:55:44 +02:00
|
|
|
|
2008-08-06 04:31:44 +02:00
|
|
|
extern void fat_enable_readahead_all();
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* 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)
|
|
|
|
|
|
|
|
#define ASSIGN_BUTTON_FALSE( keycode, snescmd ) \
|
|
|
|
S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), false)
|
|
|
|
|
|
|
|
#define MAXJP 12
|
|
|
|
int padcal = 50;
|
2008-08-06 03:45:56 +02:00
|
|
|
/*** Gamecube controller Padmap ***/
|
|
|
|
unsigned int gcpadmap[] = { PAD_BUTTON_A, PAD_BUTTON_B,
|
2008-08-06 03:09:59 +02:00
|
|
|
PAD_BUTTON_X, PAD_BUTTON_Y,
|
|
|
|
PAD_TRIGGER_L, PAD_TRIGGER_R,
|
|
|
|
PAD_TRIGGER_Z, PAD_BUTTON_START,
|
|
|
|
PAD_BUTTON_UP, PAD_BUTTON_DOWN,
|
|
|
|
PAD_BUTTON_LEFT, PAD_BUTTON_RIGHT
|
|
|
|
};
|
2008-08-06 03:45:56 +02:00
|
|
|
/*** Wiimote Padmap ***/
|
|
|
|
unsigned int wmpadmap[] = { WPAD_BUTTON_B, WPAD_BUTTON_2,
|
2008-08-06 03:39:43 +02:00
|
|
|
WPAD_BUTTON_1, WPAD_BUTTON_A,
|
|
|
|
0x0000, 0x0000,
|
|
|
|
WPAD_BUTTON_MINUS, WPAD_BUTTON_PLUS,
|
|
|
|
WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT,
|
|
|
|
WPAD_BUTTON_UP, WPAD_BUTTON_DOWN
|
|
|
|
};
|
2008-08-06 03:45:56 +02:00
|
|
|
/*** Classic Controller Padmap ***/
|
|
|
|
unsigned int ccpadmap[] = { WPAD_CLASSIC_BUTTON_A, WPAD_CLASSIC_BUTTON_B,
|
2008-08-06 03:55:59 +02:00
|
|
|
WPAD_CLASSIC_BUTTON_X, WPAD_CLASSIC_BUTTON_Y,
|
2008-08-06 03:45:56 +02:00
|
|
|
WPAD_CLASSIC_BUTTON_FULL_L, WPAD_CLASSIC_BUTTON_FULL_R,
|
|
|
|
WPAD_CLASSIC_BUTTON_MINUS, WPAD_CLASSIC_BUTTON_PLUS,
|
|
|
|
WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN,
|
|
|
|
WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT
|
|
|
|
};
|
|
|
|
/*** Nunchuk + wiimote Padmap ***/
|
|
|
|
unsigned int ncpadmap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B,
|
|
|
|
WPAD_NUNCHUK_BUTTON_C, WPAD_NUNCHUK_BUTTON_Z,
|
|
|
|
WPAD_BUTTON_MINUS, WPAD_BUTTON_PLUS,
|
|
|
|
WPAD_BUTTON_2, WPAD_BUTTON_1,
|
|
|
|
WPAD_BUTTON_UP, WPAD_BUTTON_DOWN,
|
|
|
|
WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT
|
|
|
|
};
|
2008-08-06 04:55:44 +02:00
|
|
|
/*** Superscope : GC controller button mapping ***/
|
|
|
|
unsigned int gcscopemap[] = { PAD_TRIGGER_Z, PAD_BUTTON_B,
|
2008-08-08 04:09:02 +02:00
|
|
|
PAD_BUTTON_A, PAD_BUTTON_Y, PAD_BUTTON_START
|
2008-08-06 04:55:44 +02:00
|
|
|
};
|
2008-08-06 16:40:28 +02:00
|
|
|
/*** Superscope : wiimote button mapping ***/
|
|
|
|
unsigned int wmscopemap[] = { WPAD_BUTTON_MINUS, WPAD_BUTTON_B,
|
2008-08-08 04:09:02 +02:00
|
|
|
WPAD_BUTTON_A, WPAD_BUTTON_DOWN, WPAD_BUTTON_PLUS
|
2008-08-06 16:40:28 +02:00
|
|
|
};
|
2008-08-08 04:09:02 +02:00
|
|
|
/*** Mouse : GC controller button mapping ***/
|
|
|
|
unsigned int gcmousemap[] = { PAD_BUTTON_A, PAD_BUTTON_B };
|
|
|
|
/*** Mouse : wiimote button mapping ***/
|
|
|
|
unsigned int wmmousemap[] = { WPAD_BUTTON_A, WPAD_BUTTON_B };
|
|
|
|
/*** Justifier : GC controller button mapping ***/
|
|
|
|
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 };
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 16:40:28 +02:00
|
|
|
void UpdateCursorPosition (int pad, int &pos_x, int &pos_y)
|
2008-08-07 07:19:17 +02:00
|
|
|
{
|
2008-08-06 16:40:28 +02:00
|
|
|
// gc left joystick
|
2008-08-07 07:19:17 +02:00
|
|
|
signed char pad_x = PAD_StickX (pad);
|
2008-08-06 16:40:28 +02:00
|
|
|
signed char pad_y = PAD_StickY (pad);
|
2008-08-08 04:09:02 +02:00
|
|
|
int SCOPEPADCAL = 20;
|
2008-08-06 16:40:28 +02:00
|
|
|
#ifdef HW_RVL
|
|
|
|
// wiimote ir
|
|
|
|
struct ir_t ir;
|
|
|
|
#endif
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 16:40:28 +02:00
|
|
|
if (pad_x > SCOPEPADCAL){
|
2008-08-08 04:09:02 +02:00
|
|
|
pos_x += (pad_x*1.0)/SCOPEPADCAL;
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pos_x > 256) pos_x = 256;
|
|
|
|
}
|
2008-08-06 16:40:28 +02:00
|
|
|
if (pad_x < -SCOPEPADCAL){
|
2008-08-08 04:09:02 +02:00
|
|
|
pos_x -= (pad_x*-1.0)/SCOPEPADCAL;
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pos_x < 0) pos_x = 0;
|
|
|
|
}
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 16:40:28 +02:00
|
|
|
if (pad_y < -SCOPEPADCAL){
|
2008-08-08 04:09:02 +02:00
|
|
|
pos_y += (pad_y*-1.0)/SCOPEPADCAL;
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pos_y > 224) pos_y = 224;
|
|
|
|
}
|
2008-08-06 16:40:28 +02:00
|
|
|
if (pad_y > SCOPEPADCAL){
|
2008-08-08 04:09:02 +02:00
|
|
|
pos_y -= (pad_y*1.0)/SCOPEPADCAL;
|
2008-08-07 07:19:17 +02:00
|
|
|
if (pos_y < 0) pos_y = 0;
|
2008-08-06 04:55:44 +02:00
|
|
|
}
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 16:40:28 +02:00
|
|
|
#ifdef HW_RVL
|
|
|
|
// read wiimote IR
|
|
|
|
WPAD_IR(pad, &ir);
|
|
|
|
if (ir.valid)
|
|
|
|
{
|
2008-08-08 04:09:02 +02:00
|
|
|
pos_x = (ir.x * 256) / 640;
|
|
|
|
pos_y = (ir.y * 224) / 480;
|
2008-08-06 16:40:28 +02:00
|
|
|
}
|
|
|
|
#endif
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* This is the joypad algorithm submitted by Krullo.
|
|
|
|
****************************************************************************/
|
|
|
|
void
|
|
|
|
decodepad (int pad)
|
|
|
|
{
|
|
|
|
int i, offset;
|
2008-08-06 04:55:44 +02:00
|
|
|
signed char pad_x, pad_y;
|
2008-08-06 03:39:43 +02:00
|
|
|
//unsigned short jp, wp; //
|
2008-08-06 03:45:56 +02:00
|
|
|
u32 jp, wp;
|
2008-08-06 03:09:59 +02:00
|
|
|
float t;
|
2008-08-06 03:45:56 +02:00
|
|
|
float mag = 0;
|
2008-08-06 04:31:44 +02:00
|
|
|
float mag2 = 0;
|
2008-08-06 03:45:56 +02:00
|
|
|
u16 ang = 0;
|
2008-08-06 04:31:44 +02:00
|
|
|
u16 ang2 = 0;
|
2008-08-06 03:45:56 +02:00
|
|
|
u32 exp_type;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 03:45:56 +02:00
|
|
|
/*** Do analogue updates ***/
|
2008-08-06 04:55:44 +02:00
|
|
|
pad_x = PAD_StickX (pad);
|
|
|
|
pad_y = PAD_StickY (pad);
|
2008-08-06 03:09:59 +02:00
|
|
|
jp = PAD_ButtonsHeld (pad);
|
2008-08-06 03:45:56 +02:00
|
|
|
#ifdef HW_RVL
|
2008-08-06 04:31:44 +02:00
|
|
|
exp_type = wpad_get_analogues(pad, &mag, &ang, &mag2, &ang2); // get joystick info from wii expansions
|
2008-08-06 03:39:43 +02:00
|
|
|
wp = WPAD_ButtonsHeld (pad); // wiimote
|
2008-08-06 03:45:56 +02:00
|
|
|
#else
|
|
|
|
wp = 0;
|
|
|
|
#endif
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 03:45:56 +02:00
|
|
|
/***
|
|
|
|
Gamecube Joystick input
|
|
|
|
***/
|
|
|
|
// Is XY inside the "zone"?
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_x * pad_x + pad_y * pad_y > padcal * padcal)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
|
2008-08-06 03:45:56 +02:00
|
|
|
/*** we don't want division by ZERO ***/
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_x > 0 && pad_y == 0)
|
2008-08-06 03:09:59 +02:00
|
|
|
jp |= PAD_BUTTON_RIGHT;
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_x < 0 && pad_y == 0)
|
2008-08-06 03:09:59 +02:00
|
|
|
jp |= PAD_BUTTON_LEFT;
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_x == 0 && pad_y > 0)
|
2008-08-06 03:09:59 +02:00
|
|
|
jp |= PAD_BUTTON_UP;
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_x == 0 && pad_y < 0)
|
2008-08-06 03:09:59 +02:00
|
|
|
jp |= PAD_BUTTON_DOWN;
|
|
|
|
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_x != 0 && pad_y != 0)
|
2008-08-06 03:45:56 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
/*** Recalc left / right ***/
|
2008-08-06 04:55:44 +02:00
|
|
|
t = (float) pad_y / pad_x;
|
2008-08-06 03:45:56 +02:00
|
|
|
if (t >= -2.41421356237 && t < 2.41421356237)
|
|
|
|
{
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_x >= 0)
|
2008-08-06 03:45:56 +02:00
|
|
|
jp |= PAD_BUTTON_RIGHT;
|
|
|
|
else
|
|
|
|
jp |= PAD_BUTTON_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** Recalc up / down ***/
|
2008-08-06 04:55:44 +02:00
|
|
|
t = (float) pad_x / pad_y;
|
2008-08-06 03:45:56 +02:00
|
|
|
if (t >= -2.41421356237 && t < 2.41421356237)
|
|
|
|
{
|
2008-08-06 04:55:44 +02:00
|
|
|
if (pad_y >= 0)
|
2008-08-06 03:45:56 +02:00
|
|
|
jp |= PAD_BUTTON_UP;
|
|
|
|
else
|
|
|
|
jp |= PAD_BUTTON_DOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef HW_RVL
|
|
|
|
/***
|
|
|
|
Wii Joystick (classic, nunchuk) input
|
|
|
|
***/
|
|
|
|
if (exp_type == WPAD_EXP_NUNCHUK)
|
|
|
|
{
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>300 || ang<50) )
|
|
|
|
wp |= WPAD_BUTTON_UP;
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>130 && ang<230) )
|
|
|
|
wp |= WPAD_BUTTON_DOWN;
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>220 && ang<320) )
|
|
|
|
wp |= WPAD_BUTTON_LEFT;
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>40 && ang<140) )
|
|
|
|
wp |= WPAD_BUTTON_RIGHT;
|
|
|
|
} else if (exp_type == WPAD_EXP_CLASSIC)
|
|
|
|
{
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>300 || ang<50) )
|
|
|
|
wp |= WPAD_CLASSIC_BUTTON_UP;
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>130 && ang<230) )
|
|
|
|
wp |= WPAD_CLASSIC_BUTTON_DOWN;
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>220 && ang<320) )
|
|
|
|
wp |= WPAD_CLASSIC_BUTTON_LEFT;
|
|
|
|
if ( mag>JOY_THRESHOLD && (ang>40 && ang<140) )
|
2008-08-07 07:19:17 +02:00
|
|
|
wp |= WPAD_CLASSIC_BUTTON_RIGHT;
|
2008-08-06 03:45:56 +02:00
|
|
|
}
|
|
|
|
#endif
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Fix offset to pad ***/
|
2008-08-06 04:55:44 +02:00
|
|
|
offset = ((pad + 1) << 4);
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 04:55:44 +02:00
|
|
|
/*** Report pressed buttons (gamepads) ***/
|
|
|
|
for (i = 0; i < MAXJP; i++)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-06 04:55:44 +02:00
|
|
|
if ( (jp & gcpadmap[i]) // gamecube controller
|
2008-08-06 03:45:56 +02:00
|
|
|
#ifdef HW_RVL
|
2008-08-06 04:55:44 +02:00
|
|
|
|| ( (exp_type == WPAD_EXP_NONE) && (wp & wmpadmap[i]) ) // wiimote
|
|
|
|
|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & ccpadmap[i]) ) // classic controller
|
|
|
|
|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & ncpadmap[i]) ) // nunchuk + wiimote
|
2008-08-06 03:45:56 +02:00
|
|
|
#endif
|
2008-08-06 04:55:44 +02:00
|
|
|
)
|
|
|
|
S9xReportButton (offset + i, true);
|
|
|
|
else
|
|
|
|
S9xReportButton (offset + i, false);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 04:55:44 +02:00
|
|
|
/*** Superscope ***/
|
2008-08-06 16:40:28 +02:00
|
|
|
if (pad == GCSettings.Superscope-1) // report only once
|
2008-08-06 04:55:44 +02:00
|
|
|
{
|
|
|
|
// buttons
|
|
|
|
offset = 0x50;
|
|
|
|
for (i = 0; i < 6; i++)
|
2008-08-06 16:40:28 +02:00
|
|
|
{
|
2008-08-07 07:19:17 +02:00
|
|
|
if ( jp & gcscopemap[i]
|
2008-08-06 16:40:28 +02:00
|
|
|
#ifdef HW_RVL
|
|
|
|
|| wp & wmscopemap[i]
|
|
|
|
#endif
|
|
|
|
)
|
2008-08-06 04:55:44 +02:00
|
|
|
S9xReportButton (offset + i, true);
|
|
|
|
else
|
|
|
|
S9xReportButton (offset + i, false);
|
|
|
|
}
|
|
|
|
// pointer
|
2008-08-08 04:09:02 +02:00
|
|
|
offset = 0x80;
|
|
|
|
UpdateCursorPosition (pad, cursor_x[0], cursor_y[0]);
|
|
|
|
S9xReportPointer(offset, (u16)cursor_x[0], (u16)cursor_y[0]);
|
|
|
|
}
|
|
|
|
/*** Mouse ***/
|
|
|
|
else if (Settings.MouseMaster && pad < GCSettings.Mouse)
|
|
|
|
{
|
|
|
|
// buttons
|
|
|
|
offset = 0x60+(2*pad);
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
if ( jp & gcmousemap[i]
|
|
|
|
#ifdef HW_RVL
|
|
|
|
|| wp & wmmousemap[i]
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
S9xReportButton (offset + i, true);
|
|
|
|
else
|
|
|
|
S9xReportButton (offset + i, false);
|
|
|
|
}
|
|
|
|
// pointer
|
|
|
|
offset = 0x81;
|
|
|
|
UpdateCursorPosition (pad, cursor_x[1+pad], cursor_y[1+pad]);
|
|
|
|
S9xReportPointer(offset+pad, (u16)cursor_x[1+pad], (u16)cursor_y[1+pad]);
|
|
|
|
}
|
|
|
|
/*** Justifier ***/
|
|
|
|
else if (Settings.JustifierMaster && pad < GCSettings.Justifier)
|
|
|
|
{
|
|
|
|
// buttons
|
|
|
|
offset = 0x70+(3*pad);
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
if ( jp & gcjustmap[i]
|
|
|
|
#ifdef HW_RVL
|
|
|
|
|| wp & wmjustmap[i]
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
S9xReportButton (offset + i, true);
|
|
|
|
else
|
|
|
|
S9xReportButton (offset + i, false);
|
|
|
|
}
|
|
|
|
// pointer
|
|
|
|
offset = 0x83;
|
|
|
|
UpdateCursorPosition (pad, cursor_x[3+pad], cursor_y[3+pad]);
|
|
|
|
S9xReportPointer(offset+pad, (u16)cursor_x[3+pad], (u16)cursor_y[3+pad]);
|
2008-08-06 04:55:44 +02:00
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
2008-08-06 03:55:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* setFrameTimerMethod()
|
2008-08-07 07:19:17 +02:00
|
|
|
* change frametimer method depending on whether ROM is NTSC or PAL
|
2008-08-06 03:55:59 +02:00
|
|
|
****************************************************************************/
|
|
|
|
extern u8 vmode_60hz;
|
|
|
|
int timerstyle;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 03:55:59 +02:00
|
|
|
void setFrameTimerMethod()
|
|
|
|
{
|
|
|
|
/*
|
2008-08-07 07:19:17 +02:00
|
|
|
Set frametimer method
|
|
|
|
(timerstyle: 0=NTSC vblank, 1=PAL int timer)
|
2008-08-06 03:55:59 +02:00
|
|
|
*/
|
|
|
|
if ( Settings.PAL ) {
|
|
|
|
if(vmode_60hz == 1)
|
|
|
|
timerstyle = 1;
|
|
|
|
else
|
|
|
|
timerstyle = 0;
|
|
|
|
//timediffallowed = Settings.FrameTimePAL;
|
|
|
|
} else {
|
|
|
|
if(vmode_60hz == 1)
|
|
|
|
timerstyle = 0;
|
|
|
|
else
|
|
|
|
timerstyle = 1;
|
|
|
|
//timediffallowed = Settings.FrameTimeNTSC;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* NGCReportButtons
|
2008-08-07 07:19:17 +02:00
|
|
|
* Called on each rendered frame
|
2008-08-06 03:09:59 +02:00
|
|
|
****************************************************************************/
|
|
|
|
void
|
|
|
|
NGCReportButtons ()
|
|
|
|
{
|
2008-08-06 03:39:43 +02:00
|
|
|
s8 gc_px = PAD_SubStickX (0);
|
|
|
|
s8 gc_py = PAD_SubStickY (0);
|
|
|
|
u16 gc_pb = PAD_ButtonsHeld (0);
|
2008-08-06 03:45:56 +02:00
|
|
|
#ifdef HW_RVL
|
2008-08-06 04:31:44 +02:00
|
|
|
float mag1 = 0;
|
|
|
|
float mag2 = 0;
|
|
|
|
u16 ang1 = 0;
|
|
|
|
u16 ang2 = 0;
|
|
|
|
u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info
|
|
|
|
wpad_get_analogues(0, &mag1, &ang1, &mag2, &ang2); // get joystick info from wii expansions
|
2008-08-06 03:45:56 +02:00
|
|
|
#endif
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Check for video zoom ***/
|
|
|
|
if (GCSettings.NGCZoom)
|
|
|
|
{
|
2008-08-06 03:39:43 +02:00
|
|
|
if (gc_py < -18 || gc_py > 18)
|
|
|
|
zoom ((float) gc_py / -18);
|
2008-08-06 04:31:44 +02:00
|
|
|
#ifdef HW_RVL
|
|
|
|
if ( mag2>0.2 && (ang2>340 || ang2<20) ) // classic rjs up
|
|
|
|
zoom ((float) mag2 / -0.2);
|
|
|
|
if ( mag2>0.2 && (ang2>160 && ang2<200) ) // classic rjs down
|
|
|
|
zoom ((float) mag2 / 0.2);
|
|
|
|
#endif
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-08-07 07:19:17 +02:00
|
|
|
Settings.TurboMode = ( (gc_px > 70)
|
2008-08-06 04:31:44 +02:00
|
|
|
#ifdef HW_RVL
|
2008-08-07 07:19:17 +02:00
|
|
|
|| (mag2>JOY_THRESHOLD && ang2>75 && ang2<115)
|
2008-08-06 04:31:44 +02:00
|
|
|
#endif
|
|
|
|
); // RIGHT on c-stick and on classic ctrlr right joystick
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
/*** Check for menu:
|
|
|
|
CStick left
|
2008-08-07 07:19:17 +02:00
|
|
|
OR "L+R+X+Y" (eg. Hombrew/Adapted SNES controllers)
|
2008-08-06 03:45:56 +02:00
|
|
|
OR "Home" on the wiimote or classic controller ***/
|
2008-08-06 03:39:43 +02:00
|
|
|
|
|
|
|
if ((gc_px < -70) ||
|
|
|
|
((gc_pb & PAD_TRIGGER_L) &&
|
|
|
|
(gc_pb & PAD_TRIGGER_R ) &&
|
|
|
|
(gc_pb & PAD_BUTTON_X) &&
|
2008-08-06 03:45:56 +02:00
|
|
|
(gc_pb & PAD_BUTTON_Y ))
|
|
|
|
#ifdef HW_RVL
|
|
|
|
|| (wm_pb & WPAD_BUTTON_HOME)
|
|
|
|
|| (wm_pb & WPAD_CLASSIC_BUTTON_HOME)
|
|
|
|
#endif
|
2008-08-06 03:09:59 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ConfigRequested = 1;
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
VIDEO_WaitVSync ();
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
if ( GCSettings.AutoSave == 1 )
|
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
quickSaveSRAM ( SILENT );
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
else if ( GCSettings.AutoSave == 2 )
|
|
|
|
{
|
2008-08-06 03:39:43 +02:00
|
|
|
if ( WaitPromptChoice ((char*)"Save Freeze State?", (char*)"Don't Save", (char*)"Save") )
|
2008-08-06 03:09:59 +02:00
|
|
|
quickSaveFreeze ( SILENT );
|
|
|
|
}
|
|
|
|
else if ( GCSettings.AutoSave == 3 )
|
|
|
|
{
|
2008-08-06 03:39:43 +02:00
|
|
|
if ( WaitPromptChoice ((char*)"Save SRAM and Freeze State?", (char*)"Don't Save", (char*)"Save") )
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
quickSaveSRAM ( SILENT );
|
|
|
|
quickSaveFreeze ( SILENT );
|
|
|
|
}
|
|
|
|
}
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
mainmenu (3); // go to game menu
|
2008-08-06 03:09:59 +02:00
|
|
|
FrameTimer = 0;
|
|
|
|
ConfigRequested = 0;
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 03:55:59 +02:00
|
|
|
setFrameTimerMethod(); // set frametimer method every time a ROM is loaded
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 04:55:44 +02:00
|
|
|
S9xReportControllers(); // FIX
|
2008-08-07 07:19:17 +02:00
|
|
|
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int j = (Settings.MultiPlayer5Master == true ? 4 : 2);
|
|
|
|
for (int i = 0; i < j; i++)
|
|
|
|
decodepad (i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-06 03:45:56 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* wpad_get_analogues()
|
|
|
|
*
|
|
|
|
* gets the analogue stick magnitude and angle values (
|
2008-08-07 07:19:17 +02:00
|
|
|
* from classic or nunchuk expansions)
|
2008-08-06 03:45:56 +02:00
|
|
|
****************************************************************************/
|
2008-08-06 04:31:44 +02:00
|
|
|
u32 wpad_get_analogues(int pad, float* mag1, u16* ang1, float* mag2, u16* ang2)
|
2008-08-06 03:45:56 +02:00
|
|
|
{
|
2008-08-06 04:31:44 +02:00
|
|
|
*mag1 = *ang1 = *mag2 = *ang2 = 0;
|
2008-08-06 03:45:56 +02:00
|
|
|
u32 exp_type = 0;
|
|
|
|
#ifdef HW_RVL
|
|
|
|
struct expansion_t exp;
|
2008-08-06 03:55:59 +02:00
|
|
|
memset( &exp, 0, sizeof(exp) );
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 03:45:56 +02:00
|
|
|
if ( WPAD_Probe( pad, &exp_type) == 0) // check wiimote and expansion status (first if wiimote is connected & no errors)
|
|
|
|
{
|
|
|
|
WPAD_Expansion(pad, &exp); // expansion connected. get info
|
|
|
|
if (exp_type == WPAD_EXP_CLASSIC)
|
|
|
|
{
|
2008-08-06 04:31:44 +02:00
|
|
|
*ang1 = exp.classic.ljs.ang; // left cc joystick
|
|
|
|
*mag1 = exp.classic.ljs.mag;
|
|
|
|
*ang2 = exp.classic.rjs.ang; // right cc joystick
|
|
|
|
*mag2 = exp.classic.rjs.mag;
|
2008-08-06 03:45:56 +02:00
|
|
|
}
|
|
|
|
else if (exp_type == WPAD_EXP_NUNCHUK)
|
|
|
|
{
|
2008-08-06 04:31:44 +02:00
|
|
|
*ang1 = exp.nunchuk.js.ang; // nunchuk joystick
|
|
|
|
*mag1 = exp.nunchuk.js.mag;
|
2008-08-06 03:45:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return exp_type; // return expansion type
|
|
|
|
}
|
|
|
|
|
2008-08-06 16:40:28 +02:00
|
|
|
void SetControllers ()
|
|
|
|
{
|
|
|
|
if (Settings.MultiPlayer5Master == true)
|
|
|
|
{
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 16:40:28 +02:00
|
|
|
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
|
|
|
S9xSetController (1, CTL_MP5, 1, 2, 3, -1);
|
|
|
|
}
|
|
|
|
else if (Settings.SuperScopeMaster == true)
|
|
|
|
{
|
|
|
|
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
2008-08-07 07:19:17 +02:00
|
|
|
S9xSetController (1, CTL_SUPERSCOPE, 1, 0, 0, 0);
|
2008-08-06 16:40:28 +02:00
|
|
|
}
|
2008-08-07 08:46:36 +02:00
|
|
|
else if (Settings.MouseMaster == true)
|
|
|
|
{
|
2008-08-08 04:09:02 +02:00
|
|
|
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
|
|
|
S9xSetController (1, CTL_MOUSE, (GCSettings.Mouse == 2), 0, 0, 0);
|
|
|
|
}
|
|
|
|
else if (Settings.JustifierMaster == true)
|
|
|
|
{
|
|
|
|
S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0);
|
|
|
|
S9xSetController(1, CTL_JUSTIFIER, (GCSettings.Justifier == 2), 0, 0, 0);
|
2008-08-07 08:46:36 +02:00
|
|
|
}
|
2008-08-06 16:40:28 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/*** Plugin 2 Joypads by default ***/
|
|
|
|
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
|
|
|
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2008-08-06 03:45:56 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Set the default mapping for NGC
|
|
|
|
****************************************************************************/
|
|
|
|
void
|
|
|
|
SetDefaultButtonMap ()
|
|
|
|
{
|
|
|
|
int maxcode = 0x10;
|
|
|
|
s9xcommand_t cmd;
|
|
|
|
|
|
|
|
/*** Joypad 1 ***/
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 A");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 B");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 X");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Y");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 L");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 R");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Select");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Start");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Up");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Down");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Left");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Right");
|
|
|
|
|
|
|
|
maxcode = 0x20;
|
|
|
|
/*** Joypad 2 ***/
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 A");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 B");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 X");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Y");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 L");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 R");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Select");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Start");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Up");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Down");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Left");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Right");
|
|
|
|
|
|
|
|
maxcode = 0x30;
|
|
|
|
/*** Joypad 3 ***/
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 A");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 B");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 X");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Y");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 L");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 R");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Select");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Start");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Up");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Down");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Left");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Right");
|
|
|
|
|
|
|
|
maxcode = 0x40;
|
|
|
|
/*** Joypad 4 ***/
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 A");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 B");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 X");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Y");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 L");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 R");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Select");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Start");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Up");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Down");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Left");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Right");
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 04:55:44 +02:00
|
|
|
maxcode = 0x50;
|
|
|
|
/*** Superscope ***/
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Superscope AimOffscreen");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Fire");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Cursor");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause");
|
2008-08-08 04:09:02 +02:00
|
|
|
|
2008-08-06 04:55:44 +02:00
|
|
|
maxcode = 0x60;
|
2008-08-08 04:09:02 +02:00
|
|
|
/*** Mouse ***/
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 L");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 R");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 L");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 R");
|
|
|
|
|
|
|
|
maxcode = 0x70;
|
|
|
|
/*** Justifier ***/
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 AimOffscreen");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Trigger");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Start");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 AimOffscreen");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Trigger");
|
|
|
|
ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Start");
|
|
|
|
|
|
|
|
maxcode = 0x80;
|
2008-08-06 04:55:44 +02:00
|
|
|
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Superscope"), false);
|
2008-08-08 04:09:02 +02:00
|
|
|
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse1"), false);
|
|
|
|
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse2"), false);
|
|
|
|
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier1"), false);
|
|
|
|
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier2"), false);
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 16:40:28 +02:00
|
|
|
SetControllers ();
|
2008-08-06 03:09:59 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Emulation loop
|
|
|
|
*
|
|
|
|
* The 'clock' timer is long gone.
|
2008-08-07 05:25:02 +02:00
|
|
|
* System now only uses vbl as hardware clock, so force PAL50 if you need 50hz
|
2008-08-06 03:09:59 +02:00
|
|
|
****************************************************************************/
|
|
|
|
/* Eke-Eke: initialize frame Sync */
|
|
|
|
extern void S9xInitSync();
|
|
|
|
|
|
|
|
void
|
|
|
|
emulate ()
|
|
|
|
{
|
|
|
|
|
2008-08-06 03:39:43 +02:00
|
|
|
S9xSetSoundMute (TRUE);
|
|
|
|
AudioStart ();
|
|
|
|
S9xInitSync();
|
2008-08-06 03:55:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
setFrameTimerMethod(); // also called in NGCReportButtons()
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 03:39:43 +02:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
S9xMainLoop ();
|
|
|
|
NGCReportButtons ();
|
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MAIN
|
|
|
|
*
|
|
|
|
* Steps to Snes9x Emulation :
|
|
|
|
* 1. Initialise GC Video
|
|
|
|
* 2. Initialise libfreetype (Nice to read something)
|
|
|
|
* 3. Set S9xSettings to standard defaults (s9xconfig.h)
|
|
|
|
* 4. Allocate Snes9x Memory
|
|
|
|
* 5. Allocate APU Memory
|
|
|
|
* 6. Set Pixel format to RGB565 for GL Rendering
|
|
|
|
* 7. Initialise Snes9x/GC Sound System
|
|
|
|
* 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,
|
|
|
|
* 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 ()
|
|
|
|
{
|
|
|
|
unsigned int save_flags;
|
2008-08-07 05:25:02 +02:00
|
|
|
int selectedMenu = -1;
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Initialise GC ***/
|
|
|
|
InitGCVideo (); /*** Get the ball rolling ***/
|
2008-08-07 05:25:02 +02:00
|
|
|
|
|
|
|
/*** Initialize libFAT for SD and USB ***/
|
2008-08-06 03:39:43 +02:00
|
|
|
fatInitDefault();
|
2008-08-06 04:31:44 +02:00
|
|
|
//fatInit(8192, false);
|
|
|
|
//fat_enable_readahead_all();
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-06 03:39:43 +02:00
|
|
|
/*** Initialize DVD subsystem ***/
|
|
|
|
DVD_Init ();
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
#ifdef FORCE_WII
|
|
|
|
isWii = TRUE;
|
|
|
|
#else
|
|
|
|
int drvid = dvd_driveid ();
|
|
|
|
if ( drvid == 4 || drvid == 6 || drvid == 8 )
|
|
|
|
isWii = FALSE;
|
|
|
|
else
|
|
|
|
isWii = TRUE;
|
|
|
|
#endif
|
2008-08-06 03:39:43 +02:00
|
|
|
|
2008-08-06 03:45:56 +02:00
|
|
|
#ifdef HW_RVL
|
2008-08-06 03:39:43 +02:00
|
|
|
WPAD_Init();
|
2008-08-06 16:40:28 +02:00
|
|
|
// read wiimote accelerometer and IR data
|
|
|
|
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
|
|
|
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
2008-08-06 03:45:56 +02:00
|
|
|
#endif
|
2008-08-06 03:39:43 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Initialise freetype ***/
|
|
|
|
if (FT_Init ())
|
|
|
|
{
|
|
|
|
printf ("Cannot initialise font subsystem!\n");
|
|
|
|
while (1);
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Set defaults ***/
|
|
|
|
DefaultSettings ();
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
S9xUnmapAllControls ();
|
|
|
|
SetDefaultButtonMap ();
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
printf ("Initialise Memory\n");
|
|
|
|
/*** Allocate SNES Memory ***/
|
|
|
|
if (!Memory.Init ())
|
|
|
|
while (1);
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
printf ("Initialise APU\n");
|
|
|
|
/*** Allocate APU ***/
|
|
|
|
if (!S9xInitAPU ())
|
|
|
|
while (1);
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Set Pixel Renderer to match 565 ***/
|
|
|
|
S9xSetRenderPixelFormat (RGB565);
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Initialise Snes Sound System ***/
|
|
|
|
S9xInitSound (5, TRUE, 1024);
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
printf ("Initialise GFX\n");
|
|
|
|
/*** Initialise Graphics ***/
|
|
|
|
setGFX ();
|
|
|
|
if (!S9xGraphicsInit ())
|
|
|
|
while (1);
|
2008-08-07 05:25:02 +02:00
|
|
|
|
|
|
|
unpackbackdrop ();
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
// Load preferences
|
2008-08-07 05:25:02 +02:00
|
|
|
if(!quickLoadPrefs(SILENT))
|
|
|
|
{
|
|
|
|
WaitPrompt((char*) "Preferences reset - check settings!");
|
|
|
|
selectedMenu = 2; // change to preferences menu
|
|
|
|
}
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
// Correct any relevant saved settings that are invalid
|
|
|
|
Settings.FrameTimeNTSC = 16667;
|
|
|
|
Settings.FrameTimePAL = 20000;
|
|
|
|
if ( Settings.TurboSkipFrames <= Settings.SkipFrames )
|
|
|
|
Settings.TurboSkipFrames = 20;
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** No appended ROM, so get the user to load one ***/
|
|
|
|
if (ARAM_ROMSIZE == 0)
|
|
|
|
{
|
|
|
|
while (ARAM_ROMSIZE == 0)
|
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
mainmenu (selectedMenu);
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*** Load ROM ***/
|
|
|
|
save_flags = CPU.Flags;
|
|
|
|
if (!Memory.LoadROM ("VIRTUAL.ROM"))
|
|
|
|
while (1);
|
|
|
|
CPU.Flags = save_flags;
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Load SRAM ***/
|
|
|
|
Memory.LoadSRAM ("DVD");
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Emulate ***/
|
|
|
|
emulate ();
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** NO! - We're never leaving here ! ***/
|
|
|
|
while (1);
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|