[What Was New 002]

- added: classic and nunchuk support
- added: all controllers can now be configured
- added: GC version (untested)
- changed: mappings are no longer stored in SRAM, but in config file. This means no per-game configurations, but one global config per controller.
- one makefile to make all versions. (thanks to snes9x143 SVN)
This commit is contained in:
michniewski 2008-08-06 01:45:56 +00:00
parent 6fb28b823a
commit 6892e8152e
14 changed files with 1056 additions and 326 deletions

155
Makefile
View File

@ -1,148 +1,23 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
endif
.PHONY = all wii gc wii-clean gc-clean wii-run gc-run
include $(DEVKITPPC)/wii_rules
all: wii gc
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := snes9xgx-mm-wii
BUILD := build
SOURCES := source/snes9x source/unzip source/ngc source/smb
DATA := data
INCLUDES := source/snes9x source/unzip source/ngc source/smb
clean: wii-clean gc-clean
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
wii:
$(MAKE) -f Makefile.wii
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) \
-DNGC -DNO_ASM -DCPU_SHUTDOWN -DSPC700C \
-DSPC700_SHUTDOWN -DNEW_COLOUR_BLENDING \
-DNO_INLINE_GET_SET -DSDD1_DECOMP -DCORRECT_VRAM_READS \
-DDETECT_NASTY_FX_INTERLEAVE -DNGC_ZOOM -DSDUSE_LFN \
-DQUICK_SAVE_SLOT=3 -DSMB_SVID='"Crunchewy"' \
-DSMB_IP='"192.168.1.111"' -DGW_IP='"192.168.1.1"' -DFORCE_WII=1 \
-fomit-frame-pointer -fno-exceptions -Wno-unused-parameter -pipe
CXXFLAGS = $(CFLAGS)
wii-clean:
$(MAKE) -f Makefile.wii clean
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
# -mogc
wii-run:
$(MAKE) -f Makefile.wii run
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype
# -logcsys
gc:
$(MAKE) -f Makefile.gc
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
gc-clean:
$(MAKE) -f Makefile.gc clean
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
wiiload $(OUTPUT).dol
#---------------------------------------------------------------------------------
reload:
wiiload -r $(OUTPUT).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
gc-run:
$(MAKE) -f Makefile.gc run

View File

@ -4,7 +4,7 @@
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/gamecube_rules
@ -15,8 +15,8 @@ include $(DEVKITPPC)/gamecube_rules
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(BUILD)/snes9xgx-mm-wii
BUILD := build
TARGET := snes9xgx-mm-gc
BUILD := build_gc
SOURCES := source/snes9x source/unzip source/ngc source/smb
DATA := data
INCLUDES := source/snes9x source/unzip source/ngc source/smb
@ -41,8 +41,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lfat -lz -lbte -logc -lm -lfreetype -lbba
# -logcsys
LIBS := -lfat -lz -logc -lm -lfreetype -lbba
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
@ -106,7 +105,7 @@ export OUTPUT := $(CURDIR)/$(TARGET)
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.gc
#---------------------------------------------------------------------------------
clean:

148
Makefile.wii Normal file
View File

@ -0,0 +1,148 @@
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
include $(DEVKITPPC)/wii_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := snes9xgx-mm-wii
BUILD := build_wii
SOURCES := source/snes9x source/unzip source/ngc source/smb
DATA := data
INCLUDES := source/snes9x source/unzip source/ngc source/smb
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE) \
-DNGC -DHW_RVL -DNO_ASM -DCPU_SHUTDOWN -DSPC700C \
-DSPC700_SHUTDOWN -DNEW_COLOUR_BLENDING \
-DNO_INLINE_GET_SET -DSDD1_DECOMP -DCORRECT_VRAM_READS \
-DDETECT_NASTY_FX_INTERLEAVE -DNGC_ZOOM -DSDUSE_LFN \
-DQUICK_SAVE_SLOT=3 -DSMB_SVID='"Crunchewy"' \
-DSMB_IP='"192.168.1.111"' -DGW_IP='"192.168.1.1"' -DFORCE_WII=1 \
-fomit-frame-pointer -fno-exceptions -Wno-unused-parameter -pipe
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
# -mogc
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype
# -logcsys
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
#---------------------------------------------------------------------------------
# automatically build a list of object files for our project
#---------------------------------------------------------------------------------
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.wii
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#---------------------------------------------------------------------------------
run:
wiiload $(OUTPUT).dol
#---------------------------------------------------------------------------------
reload:
wiiload -r $(OUTPUT).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

View File

@ -31,7 +31,17 @@ is not based on any previous SNES emulators that have existed for the
GameCube. You can get more information on SNES9X here from the below URL.
http://snes9x.ipherswipsite.com/
[What's New 001]
[What's New 002]
- added: classic and nunchuk support
- added: all controllers can now be configured
- added: GC version (untested)
- changed: mappings are no longer stored in SRAM, but in config file.
This means no per-game configurations, but one global
config per controller.
- one makefile to make all versions. (thanks to snes9x143 SVN)
[What Was New 001]
- compiles with latest devkitppc (r15)
- now uses libfat (can use front sd slot on wii)
- updated menu items a bit
@ -195,7 +205,7 @@ tehskeen forums:
http://www.tehskeen.com/forums/
×—–­—–­—–­—–­ –­—–­—–­—–­—–­—–­—–­—–­—–­—–­— ­—–­—–­—–­—–­—–­—–­—–­—-­—–­-–•¬
|0O×øo· WIIMOTE CONTROLLER MAPPING ·oø×O0|
|0O×øo· DEFAULT CONTROLLER MAPPING ·oø×O0|
`¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨'
Wiimote SNES
@ -212,8 +222,40 @@ HOME Emulator menu
This configuration allows you to play with the wiimote held sideways.
NOTE: snes Left Trigger and Right Trigger are not mapped.
You can change the mapping in ngc/snes9xGX.cpp (search 'wmpadmap') and recompile.
Nunchuk SNES
---------------------
Z Y
B B
A A
C X
2 SELECT
1 START
HOME Emulator menu
- LT
+ RT
Classic SNES
---------------------
X Y
B B
A A
Y X
- SELECT
+ START
HOME Emulator menu
LT LT
RT RT
GC PAD SNES
---------------------
Y Y
B B
A A
X X
Z SELECT
START START
LT LT
RT RT
×—–­—–­—–­—–­ –­—–­—–­—–­—–­—–­—–­—–­—–­—–­— ­—–­—–­—–­—–­—–­—–­—–­—-­—–­-–•¬

240
source/ngc/button_mapping.c Normal file
View File

@ -0,0 +1,240 @@
#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];
CtrlrMap ctrlr_def[4] = {
// Nunchuk btn def
CTRLR_NUNCHUK,
13,
WPAD_BUTTON_DOWN, "DOWN",
WPAD_BUTTON_UP, "UP",
WPAD_BUTTON_LEFT, "LEFT",
WPAD_BUTTON_RIGHT, "RIGHT",
WPAD_BUTTON_A, "A",
WPAD_BUTTON_B, "B",
WPAD_BUTTON_1, "1",
WPAD_BUTTON_2, "2",
WPAD_BUTTON_PLUS, "PLUS",
WPAD_BUTTON_MINUS, "MINUS",
WPAD_BUTTON_HOME, "HOME",
WPAD_NUNCHUK_BUTTON_Z, "Z",
WPAD_NUNCHUK_BUTTON_C, "C",
0, "",
0, "",
// Classic btn def
CTRLR_CLASSIC,
15,
WPAD_CLASSIC_BUTTON_DOWN, "DOWN",
WPAD_CLASSIC_BUTTON_UP, "UP",
WPAD_CLASSIC_BUTTON_LEFT, "LEFT",
WPAD_CLASSIC_BUTTON_RIGHT, "RIGHT",
WPAD_CLASSIC_BUTTON_A, "A",
WPAD_CLASSIC_BUTTON_B, "B",
WPAD_CLASSIC_BUTTON_X, "X",
WPAD_CLASSIC_BUTTON_Y, "Y",
WPAD_CLASSIC_BUTTON_PLUS, "PLUS",
WPAD_CLASSIC_BUTTON_MINUS, "MINUS",
WPAD_CLASSIC_BUTTON_HOME, "HOME",
WPAD_CLASSIC_BUTTON_FULL_L, "L TRIG",
WPAD_CLASSIC_BUTTON_FULL_R, "R TRIG",
WPAD_CLASSIC_BUTTON_ZL, "ZL",
WPAD_CLASSIC_BUTTON_ZR, "ZR",
// Gamecube controller btn def
CTRLR_GCPAD,
13,
PAD_BUTTON_DOWN, "DOWN",
PAD_BUTTON_UP, "UP",
PAD_BUTTON_LEFT, "LEFT",
PAD_BUTTON_RIGHT, "RIGHT",
PAD_BUTTON_A, "A",
PAD_BUTTON_B, "B",
PAD_BUTTON_X, "X",
PAD_BUTTON_Y, "Y",
PAD_BUTTON_MENU, "MENU",
PAD_BUTTON_START, "START",
PAD_TRIGGER_L, "L TRIG",
PAD_TRIGGER_R, "R TRIG",
PAD_TRIGGER_Z, "Z",
0, "",
0, "",
// Wiimote btn def
CTRLR_WIIMOTE,
11,
WPAD_BUTTON_DOWN, "DOWN",
WPAD_BUTTON_UP, "UP",
WPAD_BUTTON_LEFT, "LEFT",
WPAD_BUTTON_RIGHT, "RIGHT",
WPAD_BUTTON_A, "A",
WPAD_BUTTON_B, "B",
WPAD_BUTTON_1, "1",
WPAD_BUTTON_2, "2",
WPAD_BUTTON_PLUS, "PLUS",
WPAD_BUTTON_MINUS, "MINUS",
WPAD_BUTTON_HOME, "HOME",
0, "",
0, "",
0, "",
0, ""
};
/*
// Nunchuk btn def
ctrlr_def[0].type = CTRLR_NUNCHUK;
ctrlr_def[0].num_btns = 13;
ctrlr_def[0].map[] = { WPAD_BUTTON_DOWN, "DOWN",
WPAD_BUTTON_UP, "UP",
WPAD_BUTTON_LEFT, "LEFT",
WPAD_BUTTON_RIGHT, "RIGHT",
WPAD_BUTTON_A, "A",
WPAD_BUTTON_B, "B",
WPAD_BUTTON_1, "1",
WPAD_BUTTON_2, "2",
WPAD_BUTTON_PLUS, "PLUS",
WPAD_BUTTON_MINUS, "MINUS",
WPAD_BUTTON_HOME, "HOME",
WPAD_NUNCHUK_BUTTON_Z, "Z",
WPAD_NUNCHUK_BUTTON_C, "C"
};
// Classic btn def
ctrlr_def[1].type = CTRLR_CLASSIC;
ctrlr_def[1].num_btns = 15;
ctrlr_def[1].map[] = { WPAD_CLASSIC_BUTTON_DOWN, "DOWN",
WPAD_CLASSIC_BUTTON_UP, "UP",
WPAD_CLASSIC_BUTTON_LEFT, "LEFT",
WPAD_CLASSIC_BUTTON_RIGHT, "RIGHT",
WPAD_CLASSIC_BUTTON_A, "A",
WPAD_CLASSIC_BUTTON_B, "B",
WPAD_CLASSIC_BUTTON_X, "X",
WPAD_CLASSIC_BUTTON_Y, "Y",
WPAD_CLASSIC_BUTTON_PLUS, "PLUS",
WPAD_CLASSIC_BUTTON_MINUS, "MINUS",
WPAD_CLASSIC_BUTTON_HOME, "HOME",
WPAD_CLASSIC_BUTTON_FULL_L, "L TRIG",
WPAD_CLASSIC_BUTTON_FULL_R, "R TRIG",
WPAD_CLASSIC_BUTTON_ZL, "ZL",
WPAD_CLASSIC_BUTTON_ZR, "ZR",
};
// Gamecube controller btn def
ctrlr_def[2].type = CTRLR_GCPAD;
ctrlr_def[2].num_btns = 13;
ctrlr_def[2].map[] = { PAD_BUTTON_DOWN, "DOWN",
PAD_BUTTON_UP, "UP",
PAD_BUTTON_LEFT, "LEFT",
PAD_BUTTON_RIGHT, "RIGHT",
PAD_BUTTON_A, "A",
PAD_BUTTON_B, "B",
PAD_BUTTON_X, "X",
PAD_BUTTON_Y, "Y",
PAD_BUTTON_MENU, "MENU",
PAD_BUTTON_START, "START",
PAD_BUTTON_L, "L TRIG",
PAD_BUTTON_R, "R TRIG",
PAD_BUTTON_Z, "Z",
};
// Wiimote btn def
ctrlr_def[3].type = CTRLR_WIIMOTE;
ctrlr_def[3].num_btns = 11;
ctrlr_def[3].map[] = { WPAD_BUTTON_DOWN, "DOWN",
WPAD_BUTTON_UP, "UP",
WPAD_BUTTON_LEFT, "LEFT",
WPAD_BUTTON_RIGHT, "RIGHT",
WPAD_BUTTON_A, "A",
WPAD_BUTTON_B, "B",
WPAD_BUTTON_1, "1",
WPAD_BUTTON_2, "2",
WPAD_BUTTON_PLUS, "PLUS",
WPAD_BUTTON_MINUS, "MINUS",
WPAD_BUTTON_HOME, "HOME"
};
// end buttonmaps
*/
/***
* Default controller maps
* button press on left, and corresponding snes button on right
* arguably some data is unnecessary here but lets stick to one struct type ok?
CtrlrMap defaultmap[4];
// Nunchuk Default
defaultmap[0].type = CTRLR_NUNCHUK;
defaultmap[0].num_btns = 12;
defaultmap[0].map[] = { WPAD_BUTTON_A, "A",
WPAD_BUTTON_B, "B",
WPAD_NUNCHUK_BUTTON_C, "X",
WPAD_NUNCHUK_BUTTON_Z, "Y",
WPAD_BUTTON_MINUS, "L",
WPAD_BUTTON_PLUS, "R",
WPAD_BUTTON_2, "SELECT",
WPAD_BUTTON_1, "START",
WPAD_BUTTON_UP, "UP",
WPAD_BUTTON_DOWN, "DOWN",
WPAD_BUTTON_LEFT, "LEFT",
WPAD_BUTTON_RIGHT, "RIGHT"
};
// Classic Default
defaultmap[1].type = CTRLR_CLASSIC;
defaultmap[1].num_btns = 12;
defaultmap[1].map[] = { WPAD_CLASSIC_BUTTON_A, "A",
WPAD_CLASSIC_BUTTON_B, "B",
WPAD_CLASSIC_BUTTON_Y, "X",
WPAD_CLASSIC_BUTTON_X, "Y",
WPAD_CLASSIC_BUTTON_FULL_L, "L",
WPAD_CLASSIC_BUTTON_FULL_R, "R",
WPAD_CLASSIC_BUTTON_MINUS, "SELECT",
WPAD_CLASSIC_BUTTON_PLUS, "START",
WPAD_CLASSIC_BUTTON_UP, "UP",
WPAD_CLASSIC_BUTTON_DOWN, "DOWN",
WPAD_CLASSIC_BUTTON_LEFT, "LEFT",
WPAD_CLASSIC_BUTTON_RIGHT, "RIGHT"
};
// Gamecube Controller Default
defaultmap[2].type = CTRLR_GCPAD;
defaultmap[2].num_btns = 12;
defaultmap[2].map[] = {PAD_BUTTON_A, "A",
PAD_BUTTON_B, "B",
PAD_BUTTON_X, "X",
PAD_BUTTON_Y, "Y",
PAD_TRIGGER_L, "L",
PAD_TRIGGER_R, "R",
PAD_TRIGGER_Z, "SELECT",
PAD_BUTTON_START, "START",
PAD_BUTTON_UP, "UP",
PAD_BUTTON_DOWN, "DOWN",
PAD_BUTTON_LEFT, "LEFT",
PAD_BUTTON_RIGHT, "RIGHT"
};
// Wiimote Default
defaultmap[3].type = CTRLR_WIIMOTE;
defaultmap[3].num_btns = 12;
defaultmap[3].map[] = { WPAD_BUTTON_B, "A",
WPAD_BUTTON_2, "B",
WPAD_BUTTON_1, "X",
WPAD_BUTTON_A, "Y",
0x0000, "L",
0x0000, "R",
WPAD_BUTTON_MINUS, "SELECT",
WPAD_BUTTON_PLUS, "START",
WPAD_BUTTON_RIGHT, "UP",
WPAD_BUTTON_LEFT, "DOWN",
WPAD_BUTTON_UP, "LEFT",
WPAD_BUTTON_DOWN, "RIGHT"
};
// end default padmaps
***/
// eof

View File

@ -0,0 +1,28 @@
#ifndef BTN_MAP_H
#define BTN_MAP_H
enum {
CTRLR_NONE = -1,
CTRLR_NUNCHUK,
CTRLR_CLASSIC,
CTRLR_GCPAD,
CTRLR_WIIMOTE,
CTRLR_SNES = 7 // give some other value for the snes padmap
};
typedef struct _btn_map {
u32 btn; // button 'id'
char* name; // button name
} BtnMap;
typedef struct _ctrlr_map {
u16 type; // controller type
int num_btns; // number of buttons on the controller
BtnMap map[15]; // controller button map
} CtrlrMap;
// externs:
extern CtrlrMap ctrlr_def[4];
#endif

View File

@ -73,11 +73,6 @@ ShowFiles (int offset, int selection)
ypos += 10;
// show offset and selection at top
sprintf(text,"offset: %d, selection: %d",offset, selection);
DrawText (-1, 20, text);
j = 0;
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
@ -145,21 +140,32 @@ int selection = 0;
int
FileSelector ()
{
int p, wp;
u32 p, wp;
signed char a;
int haverom = 0;
int redraw = 1;
int selectit = 0;
float mag = 0;
u16 ang = 0;
while (haverom == 0)
{
if (redraw)
ShowFiles (offset, selection);
redraw = 0;
p = PAD_ButtonsDown (0);
#ifdef HW_RVL
wp = WPAD_ButtonsDown (0);
wpad_get_analogues(0, &mag, &ang); // get joystick info from wii expansions
#else
wp = 0;
#endif
a = PAD_StickY (0);
if ( (p & PAD_BUTTON_A) || (wp & WPAD_BUTTON_A) || selectit )
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
{
if ( selectit )
selectit = 0;
@ -247,9 +253,13 @@ FileSelector ()
}
redraw = 1;
} // End of A
if ( (p & PAD_BUTTON_B) || (wp & WPAD_BUTTON_B) )
if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) )
{
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B) || (PAD_ButtonsDown(0) & WPAD_BUTTON_B) )
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
#ifdef HW_RVL
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
#endif
)
VIDEO_WaitVSync();
//if ((strcmp(filelist[1].filename,"..") == 0) && (strlen (filelist[0].filename) != 0))
if ( strcmp(filelist[0].filename,"..") == 0 )
@ -264,7 +274,7 @@ FileSelector ()
return 0;
}
} // End of B
if ( (p & PAD_BUTTON_DOWN) || (wp & WPAD_BUTTON_DOWN) || (a < -PADCAL) )
if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (a < -PADCAL) || (mag>JOY_THRESHOLD && (ang>130 && ang<230)) )
{
selection++;
if (selection == maxfiles)
@ -273,7 +283,7 @@ FileSelector ()
offset += PAGESIZE;
redraw = 1;
} // End of down
if ( (p & PAD_BUTTON_UP) || (wp & WPAD_BUTTON_UP) || (a > PADCAL) )
if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > PADCAL) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) )
{
selection--;
if (selection < 0)
@ -287,7 +297,7 @@ FileSelector ()
offset = 0;
redraw = 1;
} // End of Up
if ( (PAD_ButtonsHeld(0) & PAD_BUTTON_LEFT) || (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) )
if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) )
{
/*** Go back a page ***/
selection -= PAGESIZE;
@ -302,7 +312,7 @@ FileSelector ()
offset = 0;
redraw = 1;
}
if ( (PAD_ButtonsHeld(0) & PAD_BUTTON_RIGHT) || (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) )
if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) )
{
/*** Go forward a page ***/
selection += PAGESIZE;

View File

@ -30,6 +30,7 @@
#include "ftfont.h"
#include "dkpro.h"
#include "tempgfx.h"
#include "snes9xGX.h"
#include "aram.h"
#include <zlib.h>
@ -51,7 +52,12 @@ extern int whichfb;
* Unpack the devkit pro logo
*/
static u32 *dkproraw;
static u32 *backdrop; /*** Permanent backdrop ***/
/*** Permanent backdrop ***/
#ifdef HW_RVL
u32 *backdrop;
#else
static u32 *backdrop;
#endif
static void unpackbackdrop ();
unsigned int getcolour (u8 r1, u8 g1, u8 b1);
void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b );
@ -338,7 +344,8 @@ unpackbackdrop ()
int offset;
int i;
backdrop = (unsigned int *) malloc (screenheight * 1280);
// backdrop = (unsigned int *) malloc (screenheight * 1280);
backdrop = (u32 *) malloc (screenheight * 1280);
colour = getcolour (0x00, 0x00, 0x00);
/*** Fill with black for now ***/
@ -354,10 +361,12 @@ unpackbackdrop ()
uncompress ((Bytef *) backdrop + offset, &outbytes, (Bytef *) tempgfx,
inbytes);
#ifndef HW_RVL
/*** Now store the backdrop in ARAM ***/
ARAMPut ((char *) backdrop, (char *) AR_BACKDROP, 640 * screenheight * 2);
free (backdrop);
#endif
// otherwise (on wii) backdrop is stored in memory
}
@ -380,29 +389,52 @@ legal ()
void
WaitButtonA ()
{
while ( (PAD_ButtonsDown (0) & PAD_BUTTON_A) || (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) );
while (!(PAD_ButtonsDown (0) & PAD_BUTTON_A) && !(WPAD_ButtonsDown(0) & WPAD_BUTTON_A) );
#ifdef HW_RVL
while ( (PAD_ButtonsDown (0) & PAD_BUTTON_A) || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) );
while (!(PAD_ButtonsDown (0) & PAD_BUTTON_A) && !(WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) );
#else
while ( PAD_ButtonsDown (0) & PAD_BUTTON_A );
while (!(PAD_ButtonsDown (0) & PAD_BUTTON_A) );
#endif
}
/**
* Wait for user to press A or B. Returns 0 = B; 1 = A
*/
int
WaitButtonAB ()
{
#ifdef HW_RVL
u32 gc_btns, wm_btns;
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B)) || (WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_BUTTON_B)) );
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B))
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_B))
);
while ( TRUE )
{
gc_btns = PAD_ButtonsDown (0);
wm_btns = WPAD_ButtonsDown (0);
if ( (gc_btns & PAD_BUTTON_A) || (wm_btns & WPAD_BUTTON_A) )
if ( (gc_btns & PAD_BUTTON_A) || (wm_btns & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
return 1;
else if ( (gc_btns & PAD_BUTTON_B) || (wm_btns & WPAD_BUTTON_B) )
else if ( (gc_btns & PAD_BUTTON_B) || (wm_btns & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) )
return 0;
}
#else
u32 gc_btns;
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B)) );
while ( TRUE )
{
gc_btns = PAD_ButtonsDown (0);
if ( gc_btns & PAD_BUTTON_A )
return 1;
else if ( gc_btns & PAD_BUTTON_B )
return 0;
}
#endif
}
/**
@ -535,9 +567,11 @@ RunMenu (char items[][20], int maxitems, char *title)
{
int redraw = 1;
int quit = 0;
int p, wp;
u32 p, wp;
int ret = 0;
signed char a;
float mag = 0;
u16 ang = 0;
//while (!(PAD_ButtonsDown (0) & PAD_BUTTON_B) && (quit == 0))
while (quit == 0)
@ -549,30 +583,37 @@ RunMenu (char items[][20], int maxitems, char *title)
}
p = PAD_ButtonsDown (0);
#ifdef HW_RVL
wp = WPAD_ButtonsDown (0);
wpad_get_analogues(0, &mag, &ang); // get joystick info from wii expansions
#else
wp = 0;
#endif
a = PAD_StickY (0);
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
/*** Look for up ***/
if ((p & PAD_BUTTON_UP) || (wp & WPAD_BUTTON_UP) || (a > 70))
if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > 70) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) )
{
redraw = 1;
menu--;
}
/*** Look for down ***/
if ((p & PAD_BUTTON_DOWN) || (wp & WPAD_BUTTON_DOWN) || (a < -70))
if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (a < -70) || (mag>JOY_THRESHOLD && (ang>130 && ang<230)) )
{
redraw = 1;
menu++;
}
if ((p & PAD_BUTTON_A) || (wp & WPAD_BUTTON_A))
if ((p & PAD_BUTTON_A) || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)))
{
quit = 1;
ret = menu;
}
if ((p & PAD_BUTTON_B) || (wp & WPAD_BUTTON_B))
if ((p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)))
{
quit = -1;
ret = -1;
@ -585,12 +626,15 @@ RunMenu (char items[][20], int maxitems, char *title)
menu = maxitems - 1;
}
if ((PAD_ButtonsDown(0) & PAD_BUTTON_B) || (WPAD_ButtonsDown(0) & WPAD_BUTTON_B))
{
/*** Wait for B button to be released before proceeding ***/
while ((PAD_ButtonsDown(0) & PAD_BUTTON_B) || (WPAD_ButtonsDown(0) & WPAD_BUTTON_B))
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
#ifdef HW_RVL
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
#endif
)
{
ret = -1;
VIDEO_WaitVSync();
return -1;
}
return ret;

View File

@ -40,6 +40,11 @@
#include "sram.h"
#include "preferences.h"
#include "button_mapping.h"
#include "ftfont.h"
extern void DrawMenu (char items[][20], char *title, int maxitems, int selected);
#define PSOSDLOADID 0x7c6000a6
extern int menu;
extern unsigned long ARAM_ROMSIZE;
@ -86,12 +91,12 @@ FreezeManager ()
{
if ( isWii ) /* Wii menu */
{
ret = RunMenu (freezemenuwii, freezecountwii, "Freeze Manager");
ret = RunMenu (freezemenuwii, freezecountwii, (char*)"Freeze Manager");
if (ret >= freezecountwii-1)
ret = freezecount-1;
}
else /* Gamecube menu */
ret = RunMenu (freezemenu, freezecount, "Freeze Manager");
ret = RunMenu (freezemenu, freezecount, (char*)"Freeze Manager");
switch (ret)
{
@ -432,35 +437,227 @@ EmulatorOptions ()
}
/****************************************************************************
* Configure Joypads
* 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.
****************************************************************************/
int padcount = 7;
char padmenu[][20] = { "SNES BUTTON A - A",
"SNES BUTTON B - B",
"SNES BUTTON X - X",
"SNES BUTTON Y - Y",
"ANALOG CLIP - 70",
"Save SRAM/Config",
u32
GetInput (u16 ctrlr_type)
{
u32 exp_type, pressed;
pressed=0;
while( PAD_ButtonsHeld(0)
#ifdef HW_RVL
| WPAD_ButtonsHeld(0)
#endif
) VIDEO_WaitVSync(); // button 'debounce'
while (pressed == 0)
{
VIDEO_WaitVSync();
// get input based on controller type
//if (ctrlr_type == CTRLR_GCPAD)
//{
pressed = PAD_ButtonsHeld (0);
//}
#ifdef HW_RVL
//else
//{
// if ( WPAD_Probe( 0, &exp_type) == 0) // check wiimote and expansion status (first if wiimote is connected & no errors)
// {
pressed = WPAD_ButtonsHeld (0);
// if (ctrlr_type != CTRLR_WIIMOTE && exp_type != ctrlr_type+1) // if we need input from an expansion, and its not connected...
// pressed = 0;
// }
//}
#endif
} // end while
while( pressed == (PAD_ButtonsHeld(0)
#ifdef HW_RVL
| WPAD_ButtonsHeld(0)
#endif
) ) VIDEO_WaitVSync();
return pressed;
} // end GetInput()
int cfg_text_count = 4;
char cfg_text[][20] = {
" ",
"Press Any Button",
"on the",
" " // identify controller
};
u32
GetButtonMap(u16 ctrlr_type, char* btn_name)
{
u32 pressed, previous;
char title[20];
pressed = 0; previous = 1;
switch (ctrlr_type) {
case CTRLR_NUNCHUK:
strncpy (cfg_text[3], (char*)"NUNCHUK", 7);
break;
case CTRLR_CLASSIC:
strncpy (cfg_text[3], (char*)"CLASSIC", 7);
break;
case CTRLR_GCPAD:
strncpy (cfg_text[3], (char*)"GC PAD", 7);
break;
case CTRLR_WIIMOTE:
strncpy (cfg_text[3], (char*)"WIIMOTE", 7);
break;
};
sprintf (cfg_text[0], "Remapping %s", btn_name); // note which button we are remapping
DrawMenu(&cfg_text[0], title, cfg_text_count, 1); // display text
// while (previous != pressed && pressed == 0); // get two consecutive button presses (which are the same)
// {
// previous = pressed;
// VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
pressed = GetInput(ctrlr_type);
// }
return pressed;
} // end getButtonMap()
int cfg_btns_count = 13;
char cfg_btns_menu[][20] = {
"A - ",
"B - ",
"X - ",
"Y - ",
"L TRIG - ",
"R TRIG - ",
"SELECT - ",
"START - ",
"UP - ",
"DOWN - ",
"LEFT - ",
"RIGHT - ",
"Return to previous"
};
unsigned short padmap[4] = { PAD_BUTTON_A,
PAD_BUTTON_B,
PAD_BUTTON_X,
PAD_BUTTON_Y
};
int currconfig[4] = { 0, 1, 2, 3 };
static char *padnames = "ABXY";
extern unsigned short gcpadmap[];
extern int padcal;
extern unsigned int gcpadmap[];
extern unsigned int wmpadmap[];
extern unsigned int ccpadmap[];
extern unsigned int ncpadmap[];
void
ConfigureJoyPads ()
ConfigureButtons (u16 ctrlr_type)
{
int quit = 0;
int ret = 0;
int oldmenu = menu;
menu = 0;
char* menu_title;
u32 pressed;
unsigned int* currentpadmap;
char temp[20] = "";
int i, j;
/*** Update Menu Title (based on controller we're configuring) ***/
switch (ctrlr_type) {
case CTRLR_NUNCHUK:
menu_title = (char*)"SNES - NUNCHUK";
currentpadmap = ncpadmap;
break;
case CTRLR_CLASSIC:
menu_title = (char*)"SNES - CLASSIC";
currentpadmap = ccpadmap;
break;
case CTRLR_GCPAD:
menu_title = (char*)"SNES - GC PAD";
currentpadmap = gcpadmap;
break;
case CTRLR_WIIMOTE:
menu_title = (char*)"SNES - WIIMOTE";
currentpadmap = wmpadmap;
break;
};
while (quit == 0)
{
/*** Update Menu with Current ButtonMap ***/
for (i=0; i<12; i++) // snes pad has 12 buttons to config (go thru them)
{
// get current padmap button name to display
for ( j=0;
currentpadmap[i] != ctrlr_def[ctrlr_type].map[j].btn // match padmap button press with button names
&& j < ctrlr_def[ctrlr_type].num_btns
; j++ );
memset (temp, 0, sizeof(temp));
strncpy (temp, cfg_btns_menu[i], 12); // copy snes button information
if (currentpadmap[i] == ctrlr_def[ctrlr_type].map[j].btn) // check if a match was made
strncat (temp, ctrlr_def[ctrlr_type].map[j].name, 6); // update button map display
else
strcat (temp, (char*)"---"); // otherwise, button is 'unmapped'
strncpy (cfg_btns_menu[i], temp, 19); // move back updated information
}
ret = RunMenu (cfg_btns_menu, cfg_btns_count, menu_title);
switch (ret)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
/*** Change button map ***/
// wait for input
memset (temp, 0, sizeof(temp));
strncpy(temp, cfg_btns_menu[ret], 6); // get the name of the snes button we're changing
pressed = GetButtonMap(ctrlr_type, temp); // get a button selection from user
// FIX: check if input is valid for this controller
currentpadmap[ret] = pressed; // update mapping
break;
case -1: /*** Button B ***/
case 12:
/*** Return ***/
quit = 1;
break;
}
}
menu = oldmenu;
} // end configurebuttons()
int cfg_ctrlr_count_wii = 6;
char cfg_ctrlr_menu_wii[][20] = { "Nunchuk",
"Classic Controller",
"Gamecube Pad",
"Wiimote",
"Save Prefs Now",
"Return to previous"
};
int cfg_ctrlr_count_gc = 3;
char cfg_ctrlr_menu_gc[][20] = { "Gamecube Pad",
"Save Prefs Now",
"Return to previous"
};
void
ConfigureControllers ()
{
int quit = 0;
int ret = 0;
@ -469,66 +666,66 @@ ConfigureJoyPads ()
while (quit == 0)
{
/*** Update the menu information ***/
for (ret = 0; ret < 4; ret++)
padmenu[ret][16] = padnames[currconfig[ret]];
sprintf (padmenu[4], "ANALOG CLIP - %d", padcal);
ret = RunMenu (padmenu, padcount, (char*)"Configure Joypads");
#ifdef HW_RVL
/*** Wii Controller Config Menu ***/
ret = RunMenu (cfg_ctrlr_menu_wii, cfg_ctrlr_count_wii, (char*)"Configure Controllers");
switch (ret)
{
case 0:
/*** Configure Button A ***/
currconfig[0]++;
currconfig[0] &= 3;
gcpadmap[0] = padmap[currconfig[0]];
/*** Configure Nunchuk ***/
ConfigureButtons (CTRLR_NUNCHUK);
break;
case 1:
/*** Configure Button B ***/
currconfig[1]++;
currconfig[1] &= 3;
gcpadmap[1] = padmap[currconfig[1]];
/*** Configure Classic ***/
ConfigureButtons (CTRLR_CLASSIC);
break;
case 2:
/*** Configure Button X ***/
currconfig[2]++;
currconfig[2] &= 3;
gcpadmap[2] = padmap[currconfig[2]];
/*** Configure GC Pad ***/
ConfigureButtons (CTRLR_GCPAD);
break;
case 3:
/*** Configure Button Y ***/
currconfig[3]++;
currconfig[3] &= 3;
gcpadmap[3] = padmap[currconfig[3]];
/*** Configure Wiimote ***/
ConfigureButtons (CTRLR_WIIMOTE);
break;
case 4:
/*** Pad Calibration ***/
padcal += 5;
if (padcal > 80)
padcal = 40;
break;
case 5:
/*** Quick Save SRAM ***/
if ( ARAM_ROMSIZE > 0 )
quickSaveSRAM(NOTSILENT);
else
WaitPrompt((char*) "No ROM loaded - can't save SRAM");
/*** Save Preferences Now ***/
quickSavePrefs(NOTSILENT);
break;
case -1: /*** Button B ***/
case 6:
case 5:
/*** Return ***/
quit = 1;
break;
}
#else
/*** Gamecube Controller Config Menu ***/
ret = RunMenu (cfg_ctrlr_menu_gc, cfg_ctrlr_count_gc, (char*)"Configure Controllers");
switch (ret)
{
case 0:
/*** Configure Nunchuk ***/
ConfigureButtons (CTRLR_GCPAD);
break;
case 1:
/*** Save Preferences Now ***/
quickSavePrefs(NOTSILENT);
break;
case -1: /*** Button B ***/
case 2:
/*** Return ***/
quit = 1;
break;
}
#endif
}
menu = oldmenu;
@ -540,7 +737,7 @@ ConfigureJoyPads ()
int menucount = 10;
char menuitems[][20] = { "Choose Game",
"SRAM Manager", "Freeze Manager",
"Configure Joypads", "Emulator Options",
"Config Controllers", "Emulator Options",
"Reset Game", "Stop DVD Drive", "Exit to Loader",
"Reboot System", "Return to Game"
};
@ -588,8 +785,8 @@ mainmenu ()
break;
case 3:
/*** Configure Joypads ***/
ConfigureJoyPads ();
/*** Configure Controllers ***/
ConfigureControllers ();
break;
case 4:
@ -634,7 +831,12 @@ mainmenu ()
}
/*** Remove any still held buttons ***/
#ifdef HW_RVL
while( PAD_ButtonsHeld(0) || WPAD_ButtonsHeld(0) )
VIDEO_WaitVSync();
#else
while( PAD_ButtonsHeld(0) )
VIDEO_WaitVSync();
#endif
}

View File

@ -25,7 +25,13 @@
extern unsigned char savebuffer[];
extern int currconfig[4];
#define PREFSVERSTRING "Snes9x GX 2.0.1b8 Prefs"
// button map configurations
extern unsigned int gcpadmap[];
extern unsigned int wmpadmap[];
extern unsigned int ccpadmap[];
extern unsigned int ncpadmap[];
#define PREFSVERSTRING "Snes9x GX 002 Prefs"
char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} };
@ -59,6 +65,17 @@ preparePrefsData ()
memcpy (savebuffer + offset, &GCSettings, size);
offset += size;
/*** Save buttonmaps ***/
size = sizeof (unsigned int) *12; // this size applies to all padmaps
memcpy (savebuffer + offset, &gcpadmap, size);
offset += size;
memcpy (savebuffer + offset, &wmpadmap, size);
offset += size;
memcpy (savebuffer + offset, &ccpadmap, size);
offset += size;
memcpy (savebuffer + offset, &ncpadmap, size);
offset += size;
return offset;
}
@ -71,6 +88,7 @@ decodePrefsData ()
{
int offset;
char prefscomment[32];
int size;
offset = sizeof (saveicon);
memcpy (prefscomment, savebuffer + offset, 32);
@ -81,6 +99,16 @@ decodePrefsData ()
memcpy (&Settings, savebuffer + offset, sizeof (Settings));
offset += sizeof (Settings);
memcpy (&GCSettings, savebuffer + offset, sizeof (GCSettings));
offset += sizeof (GCSettings);
// load padmaps (order important)
size = sizeof (unsigned int) *12;
memcpy (&gcpadmap, savebuffer + offset, size);
offset += size;
memcpy (&wmpadmap, savebuffer + offset, size);
offset += size;
memcpy (&ccpadmap, savebuffer + offset, size);
offset += size;
memcpy (&ncpadmap, savebuffer + offset, size);
}
else
WaitPrompt((char*) "Preferences reset - check settings!");

View File

@ -189,6 +189,7 @@
#include "memfile.h"
#include "preferences.h"
#include "gctime.h"
#include "button_mapping.h"
unsigned long ARAM_ROMSIZE = 0;
int ConfigRequested = 0;
@ -210,20 +211,38 @@ extern unsigned int timediffallowed;
#define MAXJP 12
int padcal = 50;
unsigned short gcpadmap[] = { PAD_BUTTON_A, PAD_BUTTON_B,
/*** Gamecube controller Padmap ***/
unsigned int gcpadmap[] = { PAD_BUTTON_A, PAD_BUTTON_B,
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
};
unsigned short wmpadmap[] = { WPAD_BUTTON_B, WPAD_BUTTON_2,
/*** Wiimote Padmap ***/
unsigned int wmpadmap[] = { WPAD_BUTTON_B, WPAD_BUTTON_2,
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
};
/*** Classic Controller Padmap ***/
unsigned int ccpadmap[] = { WPAD_CLASSIC_BUTTON_A, WPAD_CLASSIC_BUTTON_B,
WPAD_CLASSIC_BUTTON_Y, WPAD_CLASSIC_BUTTON_X,
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
};
#if 0
/****************************************************************************
@ -276,20 +295,31 @@ decodepad (int pad)
int i, offset;
signed char x, y;
//unsigned short jp, wp; //
u16 jp, wp;
u32 jp, wp;
float t;
float mag = 0;
u16 ang = 0;
u32 exp_type;
/*** Do analogue updates ***/
x = PAD_StickX (pad);
y = PAD_StickY (pad);
jp = PAD_ButtonsHeld (pad);
#ifdef HW_RVL
exp_type = wpad_get_analogues(pad, &mag, &ang); // get joystick info from wii expansions
wp = WPAD_ButtonsHeld (pad); // wiimote
#else
wp = 0;
#endif
/*** Is XY inside the "zone"? ***/
/***
Gamecube Joystick input
***/
// Is XY inside the "zone"?
if (x * x + y * y > padcal * padcal)
{
/*** we don't want division by ZERO ***/
/*** we don't want division by ZERO ***/
if (x > 0 && y == 0)
jp |= PAD_BUTTON_RIGHT;
if (x < 0 && y == 0)
@ -302,7 +332,7 @@ decodepad (int pad)
if (x != 0 && y != 0)
{
/*** Recalc left / right ***/
/*** Recalc left / right ***/
t = (float) y / x;
if (t >= -2.41421356237 && t < 2.41421356237)
{
@ -312,7 +342,7 @@ decodepad (int pad)
jp |= PAD_BUTTON_LEFT;
}
/*** Recalc up / down ***/
/*** Recalc up / down ***/
t = (float) x / y;
if (t >= -2.41421356237 && t < 2.41421356237)
{
@ -323,20 +353,49 @@ decodepad (int pad)
}
}
}
#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) )
wp |= WPAD_CLASSIC_BUTTON_RIGHT;
}
#endif
/*** Fix offset to pad ***/
offset = ((pad + 1) << 4);
for (i = 0; i < MAXJP; i++)
{
if (jp & gcpadmap[i])
/*** Report pressed buttons ***/
if ( (jp & gcpadmap[i]) // gamecube controller
#ifdef HW_RVL
|| ( (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
#endif
)
S9xReportButton (offset + i, true);
else
S9xReportButton (offset + i, false);
if (wp & wmpadmap[i]) // wiimote
S9xReportButton (offset + i, true); //
else //
S9xReportButton (offset + i, false); //
}
}
@ -351,7 +410,9 @@ NGCReportButtons ()
s8 gc_px = PAD_SubStickX (0);
s8 gc_py = PAD_SubStickY (0);
u16 gc_pb = PAD_ButtonsHeld (0);
u16 wm_pb = WPAD_ButtonsHeld (0); // wiimote
#ifdef HW_RVL
u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote
#endif
/*** Check for video zoom ***/
if (GCSettings.NGCZoom)
@ -365,14 +426,17 @@ NGCReportButtons ()
/*** Check for menu:
CStick left
OR "L+R+X+Y" (eg. Hombrew/Adapted SNES controllers)
OR "Home" on the wiimote ***/
OR "Home" on the wiimote or classic controller ***/
if ((gc_px < -70) ||
((gc_pb & PAD_TRIGGER_L) &&
(gc_pb & PAD_TRIGGER_R ) &&
(gc_pb & PAD_BUTTON_X) &&
(gc_pb & PAD_BUTTON_Y )) ||
(wm_pb & WPAD_BUTTON_HOME) // wiimote
(gc_pb & PAD_BUTTON_Y ))
#ifdef HW_RVL
|| (wm_pb & WPAD_BUTTON_HOME)
|| (wm_pb & WPAD_CLASSIC_BUTTON_HOME)
#endif
)
{
ConfigRequested = 1;
@ -410,6 +474,39 @@ NGCReportButtons ()
}
}
/****************************************************************************
* wpad_get_analogues()
*
* gets the analogue stick magnitude and angle values (
* from classic or nunchuk expansions)
****************************************************************************/
u32 wpad_get_analogues(int pad, float* mag, u16* ang)
{
*mag = *ang = 0;
u32 exp_type = 0;
#ifdef HW_RVL
struct expansion_t exp;
memset( &exp, 0, sizeof(exp) ); // FIX: necessary? we only look at the struct if an expansion is connected...
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)
{
*ang = exp.classic.ljs.ang; // left cc joystick
*mag = exp.classic.ljs.mag;
}
else if (exp_type == WPAD_EXP_NUNCHUK)
{
*ang = exp.nunchuk.js.ang; // nunchuk joystick
*mag = exp.nunchuk.js.mag;
}
}
#endif
return exp_type; // return expansion type
}
/****************************************************************************
* Set the default mapping for NGC
****************************************************************************/
@ -583,7 +680,9 @@ main ()
isWii = TRUE;
#endif
#ifdef HW_RVL
WPAD_Init();
#endif
/*** Initialise freetype ***/

View File

@ -156,10 +156,12 @@
#ifndef _SNES9XGX_H_
#define _SNES9XGX_H_
#include <gccore.h>
#include "snes9x.h"
#define GCVERSION "2.0.1b8"
#define GCVERSIONSTRING "Snes9x GX 2.0.1b8"
// FIX: these are unused, but could be... must also change "freezecomment", PREFSVERSTRING, and "sramcomment"
#define GCVERSION "002"
#define GCVERSIONSTRING "Snes9x 1.5 v002"
#define NOTSILENT 0
#define SILENT 1
@ -184,8 +186,12 @@ START_EXTERN_C
extern struct SGCSettings GCSettings;
extern unsigned short saveicon[1024];
extern bool8 isWii;
extern u32 wpad_get_analogues(int pad, float* mag, u16* ang);
END_EXTERN_C
#define JOY_THRESHOLD 0.70 // for wii (expansion) analogues
#endif
/*** QUICK_SAVE_SLOT defines where preferences are loaded and saved, and also

View File

@ -23,10 +23,10 @@
#include "smbload.h"
extern unsigned char savebuffer[];
extern int currconfig[4];
//extern int currconfig[4];
extern int padcal;
extern unsigned short gcpadmap[];
extern unsigned short padmap[4];
//extern unsigned short padmap[4];
char sramcomment[2][32] = { {"Snes9x GX 2.0.1b8 SRAM"}, {"Savegame"} };
@ -67,10 +67,10 @@ prepareMCsavedata ()
offset += size;
}
/*** Save Joypad Configuration ***/
memcpy (savebuffer + offset, &currconfig, 16);
// /*** Save Joypad Configuration ***/
// memcpy (savebuffer + offset, &currconfig, 16);
offset += 16;
memcpy (savebuffer + offset, &padcal, 4);
// memcpy (savebuffer + offset, &padcal, 4);
offset += 4;
return offset;
@ -95,10 +95,10 @@ prepareEXPORTsavedata ()
memcpy (savebuffer + offset, sramcomment, 64);
offset += 64;
/*** Save Joypad Configuration ***/
memcpy (savebuffer + offset, &currconfig, 16);
// /*** Save Joypad Configuration ***/
// memcpy (savebuffer + offset, &currconfig, 16);
offset += 16;
memcpy (savebuffer + offset, &padcal, 4);
// memcpy (savebuffer + offset, &padcal, 4);
offset += 4;
if ( offset <= 512 )
@ -145,13 +145,13 @@ decodesavedata (int readsize)
offset = 64;
// Get the control pad configuration
memcpy (&currconfig, savebuffer + offset, 16);
// memcpy (&currconfig, savebuffer + offset, 16);
offset += 16;
memcpy (&padcal, savebuffer + offset, 4);
// memcpy (&padcal, savebuffer + offset, 4);
offset += 4;
for (size = 0; size < 4; size++)
gcpadmap[size] = padmap[currconfig[size]];
// for (size = 0; size < 4; size++)
// gcpadmap[size] = padmap[currconfig[size]];
// move to start of SRAM which is after the 512 byte header
offset = 512;
@ -164,7 +164,7 @@ decodesavedata (int readsize)
memcpy (Memory.SRAM, savebuffer + offset, size);
offset += size;
}
}
else
{
// else, check for a v2.0 memory card format save
@ -186,13 +186,13 @@ decodesavedata (int readsize)
offset += sizeof (Settings);
// Get the control pad configuration
memcpy (&currconfig, savebuffer + offset, 16);
// memcpy (&currconfig, savebuffer + offset, 16);
offset += 16;
memcpy (&padcal, savebuffer + offset, 4);
// memcpy (&padcal, savebuffer + offset, 4);
offset += 4;
for (size = 0; size < 4; size++)
gcpadmap[size] = padmap[currconfig[size]];
// for (size = 0; size < 4; size++)
// gcpadmap[size] = padmap[currconfig[size]];
}
else if ( strncmp (sramcomment, "Snes9x 1.43 SRAM (GX", 20) == 0)
{
@ -228,7 +228,7 @@ decodesavedata (int readsize)
memcpy (Memory.SRAM, savebuffer, size);
}
else
WaitPrompt("Incompatible SRAM save!");
WaitPrompt((char*)"Incompatible SRAM save!");
}
}
}

View File

@ -43,6 +43,7 @@ unsigned int *xfb[2] = { NULL, NULL }; /*** Double buffered ***/
int whichfb = 0; /*** Switch ***/
GXRModeObj *vmode; /*** General video mode ***/
int screenheight;
extern u32* backdrop;
/*** GX ***/
#define TEX_WIDTH 512
@ -269,7 +270,9 @@ StartGX ()
****************************************************************************/
void UpdatePadsCB()
{
#ifdef HW_RVL
WPAD_ScanPads();
#endif
PAD_ScanPads();
}
@ -386,8 +389,14 @@ void
clearscreen (int colour)
{
whichfb ^= 1;
//ARAMFetch ((char *) xfb[whichfb], (char *) AR_BACKDROP, 640 * screenheight * 2); // FIX
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], colour);
#ifdef HW_RVL
// on wii copy from memory
//memcpy ((char *) xfb[whichfb], (char *) backdrop, 640 * screenheight * 2);
#else
// on gc copy from aram
//ARAMFetch ((char *) xfb[whichfb], (char *) AR_BACKDROP, 640 * screenheight * 2); // FIX
#endif
}
void