From 21e52eab5ab1d37f91e7a0cbf4abb9d5dcb24bab Mon Sep 17 00:00:00 2001 From: tmbinc Date: Mon, 24 Aug 2009 09:41:10 +0000 Subject: [PATCH] add port to xbox 360 using libxenon library --- Makefile.xenon | 164 ++++++++++++++++++ source/xenon/README | 7 + source/xenon/ffs_content.c | 45 +++++ source/xenon/filebrowser.h | 0 source/xenon/fileop.h | 0 source/xenon/freeze.cpp | 70 ++++++++ source/xenon/freeze.h | 0 source/xenon/gccore.h | 0 source/xenon/main.cpp | 328 ++++++++++++++++++++++++++++++++++++ source/xenon/png.h | 0 source/xenon/pngu/pngu.h | 0 source/xenon/s9xconfig.cpp | 159 +++++++++++++++++ source/xenon/s9xconfig.h | 22 +++ source/xenon/s9xsupport.cpp | 284 +++++++++++++++++++++++++++++++ source/xenon/snes9xGX.h | 0 source/xenon/video.cpp | 116 +++++++++++++ source/xenon/video.h | 4 + 17 files changed, 1199 insertions(+) create mode 100644 Makefile.xenon create mode 100644 source/xenon/README create mode 100644 source/xenon/ffs_content.c create mode 100644 source/xenon/filebrowser.h create mode 100644 source/xenon/fileop.h create mode 100644 source/xenon/freeze.cpp create mode 100644 source/xenon/freeze.h create mode 100644 source/xenon/gccore.h create mode 100644 source/xenon/main.cpp create mode 100644 source/xenon/png.h create mode 100644 source/xenon/pngu/pngu.h create mode 100644 source/xenon/s9xconfig.cpp create mode 100644 source/xenon/s9xconfig.h create mode 100644 source/xenon/s9xsupport.cpp create mode 100644 source/xenon/snes9xGX.h create mode 100644 source/xenon/video.cpp create mode 100644 source/xenon/video.h diff --git a/Makefile.xenon b/Makefile.xenon new file mode 100644 index 0000000..94a08d7 --- /dev/null +++ b/Makefile.xenon @@ -0,0 +1,164 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITXENON)),) +$(error "Please set DEVKITXENON in your environment. export DEVKITXENON=devkitxenon") +endif + +include $(DEVKITXENON)/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-xenon +TARGETDIR := executables +BUILD := build_xenon +SOURCES := source/xenon source/snes9x source/sz +# source/unzip +INCLUDES := source/snes9x source/xenon source/unzip + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- + +CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \ + -DNGC -DNO_SOUND \ + -DNO_ASM -DRIGHTSHIFT_IS_SAR \ + -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \ + -DSPC700_C -DSDD1_DECOMP \ + -DCORRECT_VRAM_READS -DNEW_COLOUR_BLENDING \ + -D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \ + -fomit-frame-pointer \ + -Wno-unused-parameter -Wno-strict-aliasing + +CXXFLAGS = -save-temps -Xassembler -aln=$@.lst $(CFLAGS) + +LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +#LIBS := -ldb -ldi -lpngu -lpng -lmxml -lmetaphrasis \ +# -lfat -lwiiuse -lz -lbte -logc -lasnd -ltremor -lfreetype -ltinysmb +LIBS = -lm -lxenon + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(CURDIR) + +#--------------------------------------------------------------------------------- +# 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)/$(TARGETDIR)/$(TARGET) +export VPATH := $(foreach dir,$(SOURCES),$(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))) +TTFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf))) +PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) +OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg))) +PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm))) + +#--------------------------------------------------------------------------------- +# use CXX for linking C++ projects, CC for standard C +#--------------------------------------------------------------------------------- +ifeq ($(strip $(CPPFILES)),) + export LD := $(CC) +else + export LD := $(CXX) +endif + +export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ + $(sFILES:.s=.o) $(SFILES:.S=.o) \ + $(TTFFILES:.ttf=.ttf.o) $(PNGFILES:.png=.png.o) \ + $(OGGFILES:.ogg=.ogg.o) $(PCMFILES:.pcm=.pcm.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$(LIBXENON_INC) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ + -L$(LIBXENON_LIB) + +export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET) +.PHONY: $(BUILD) clean + +#--------------------------------------------------------------------------------- +$(BUILD): + @[ -d $@ ] || mkdir -p $@ + @[ -d $(TARGETDIR) ] || mkdir -p $(TARGETDIR) + @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.xenon + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).elf32 + +#--------------------------------------------------------------------------------- + +source/xenon/ffs_content.c: genffs.py data/ps.psu data/vs.vsu + python genffs.py > source/xenon/ffs_content.c + +run: $(OUTPUT).elf32 + cp $(OUTPUT).elf32 /tftpboot/xenon + /home/dev360/run + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).elf32: $(OUTPUT).elf +$(OUTPUT).elf: $(OFILES) + +#--------------------------------------------------------------------------------- +# This rule links in binary data with .ttf, .png, and .mp3 extensions +#--------------------------------------------------------------------------------- +%.ttf.o : %.ttf + @echo $(notdir $<) + $(bin2o) + +%.png.o : %.png + @echo $(notdir $<) + $(bin2o) + +%.ogg.o : %.ogg + @echo $(notdir $<) + $(bin2o) + +%.pcm.o : %.pcm + @echo $(notdir $<) + $(bin2o) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/source/xenon/README b/source/xenon/README new file mode 100644 index 0000000..93e08e7 --- /dev/null +++ b/source/xenon/README @@ -0,0 +1,7 @@ +This is a very early port to the xbox 360 using the libxenon library, +available from http://www.free60.org/wiki/Libxenon + +It doesn't yet have sound, a graphical menu, but will load the file +"SNES9XGX.SMC" from the first available USB storage device, and run that. + +Controls are using the first wired controller. diff --git a/source/xenon/ffs_content.c b/source/xenon/ffs_content.c new file mode 100644 index 0000000..47b0f00 --- /dev/null +++ b/source/xenon/ffs_content.c @@ -0,0 +1,45 @@ +static unsigned char content_datapspsu[] = { +0x10, 0x2a, 0x11, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x4b, +0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x30, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, +0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x73, 0x00, 0xab, 0xab, 0x00, 0x04, 0x00, 0x0c, +0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, +0x40, 0x40, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0xab, 0xab, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x21, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, +0x00, 0x00, 0xf0, 0x50, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00, 0x12, 0x00, 0xc4, 0x00, 0x00, 0x00, +0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x01, +0x1f, 0x1f, 0xf6, 0x88, 0x00, 0x00, 0x40, 0x00, 0xc8, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, +0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; +static unsigned char content_datavsvsu[] = { +0x10, 0x2a, 0x11, 0x01, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x23, +0xff, 0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x1c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, +0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0xab, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, +0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x21, +0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x90, +0x00, 0x10, 0x00, 0x03, 0x00, 0x30, 0x50, 0x04, 0x00, 0x00, 0xf0, 0x50, 0x00, 0x00, 0x10, 0x06, +0x30, 0x05, 0x20, 0x03, 0x00, 0x00, 0x12, 0x00, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x05, +0x00, 0x00, 0x12, 0x00, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x06, 0x00, 0x00, 0x22, 0x00, +0x00, 0x00, 0x00, 0x00, 0x05, 0xf8, 0x10, 0x00, 0x00, 0x00, 0x06, 0x88, 0x00, 0x00, 0x00, 0x00, +0x05, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x06, 0x88, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x0f, 0x80, 0x3e, +0x00, 0x00, 0x00, 0x00, 0xe2, 0x01, 0x01, 0x00, 0xc8, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, +0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + + +struct ffs_s +{ + const char *filename; + int size; + void *content; +} ffs_files[] = { + {"ps.psu", 224, content_datapspsu}, + {"vs.vsu", 240, content_datavsvsu}, + {0, 0, 0}, +}; diff --git a/source/xenon/filebrowser.h b/source/xenon/filebrowser.h new file mode 100644 index 0000000..e69de29 diff --git a/source/xenon/fileop.h b/source/xenon/fileop.h new file mode 100644 index 0000000..e69de29 diff --git a/source/xenon/freeze.cpp b/source/xenon/freeze.cpp new file mode 100644 index 0000000..15d8600 --- /dev/null +++ b/source/xenon/freeze.cpp @@ -0,0 +1,70 @@ +#include +#include +#include + +#include "snes9x.h" +#include "memmap.h" +#include "soundux.h" +#include "snapshot.h" +#include "srtc.h" + +int +GetMem (char *buffer, int len) +{ + printf("%s:%d\n", __FILE__, __LINE__); while (1); +} + +void +NGCFreezeBlock (char *name, uint8 * block, int size) +{ + printf("%s:%d\n", __FILE__, __LINE__); while (1); +} + +/**************************************************************************** + * NGCFreezeMembuffer + * + * Copies a snapshot of Snes9x state into memory + ***************************************************************************/ +static int +NGCFreezeMemBuffer () +{ + printf("%s:%d\n", __FILE__, __LINE__); while (1); + + return 0; +} + + +/**************************************************************************** + * NGCFreezeGame + * + * Do freeze game for Nintendo Gamecube + ***************************************************************************/ +int +NGCFreezeGame (char * filepath, int method, bool silent) +{ + printf("%s:%d\n", __FILE__, __LINE__); while (1); +} + +int +NGCFreezeGameAuto (int method, bool silent) +{ + printf("%s:%d\n", __FILE__, __LINE__); while (1); +} + +/**************************************************************************** + * NGCUnFreezeBlock + ***************************************************************************/ +int +NGCUnFreezeBlock (char *name, uint8 * block, int size) +{ + printf("%s:%d\n", __FILE__, __LINE__); while (1); +} + +/**************************************************************************** + * NGCUnfreezeGame + ***************************************************************************/ +int +NGCUnfreezeGame (char * filepath, int method, bool silent) +{ + printf("%s:%d\n", __FILE__, __LINE__); while (1); +} diff --git a/source/xenon/freeze.h b/source/xenon/freeze.h new file mode 100644 index 0000000..e69de29 diff --git a/source/xenon/gccore.h b/source/xenon/gccore.h new file mode 100644 index 0000000..e69de29 diff --git a/source/xenon/main.cpp b/source/xenon/main.cpp new file mode 100644 index 0000000..7874192 --- /dev/null +++ b/source/xenon/main.cpp @@ -0,0 +1,328 @@ +#include +#include + +#include "s9xconfig.h" + +#include "snes9x.h" +#include "memmap.h" +#include "s9xdebug.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 +#include +#include +#include + +//#include "smc.h" + +#include "video.h" + +extern unsigned long SNESROMSize; + +extern void S9xInitSync(); + +void ExitApp(void) +{ + printf(" *** ExitApp\n"); + while (1); +} + +int ResetRequested = 1, ConfigRequested; + +extern "C" { + void usb_do_poll(void); + void kmem_init(void); + void usb_init(void); + +#include + +}; + +void +emulate () +{ + while(1) // emulation loop + { + struct controller_data_s c; + if (get_controller_data(&c, 0)) + { +// printf("got controller data!\n"); + int offset = 0x10; +// printf("a=%d, b=%d, x=%d, y=%d, lb=%d, rb=%d, start=%d, select=%d, up=%d, down=%d, left=%d, right=%d\n", +// c.a, c.b, c.x, c.y, c.lb, c.rb, c.start, c.select, c.up, c.down, c.left, c.right); + S9xReportButton (offset + 0, c.a); + S9xReportButton (offset + 1, c.b); + S9xReportButton (offset + 2, c.x); + S9xReportButton (offset + 3, c.y); + + S9xReportButton (offset + 4, c.lb); + S9xReportButton (offset + 5, c.rb); + + S9xReportButton (offset + 6, c.start); + S9xReportButton (offset + 7, c.select); + + S9xReportButton (offset + 8, c.up); + S9xReportButton (offset + 9, c.down); + S9xReportButton (offset + 10, c.left); + S9xReportButton (offset + 11, c.right); + } + S9xMainLoop (); + + usb_do_poll(); + + if(ResetRequested) + { + S9xSoftReset (); // reset game + ResetRequested = 0; + } + if (ConfigRequested) + { + ConfigRequested = 0; + break; + } + } // main loop +} + +#define ASSIGN_BUTTON_TRUE( keycode, snescmd ) \ + S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), true) + +#define ASSIGN_BUTTON_FALSE( keycode, snescmd ) \ + S9xMapButton( keycode, cmd = S9xGetCommandT(snescmd), false) + +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 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Select"); + 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 Start"); + + 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 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Select"); + 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 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Select"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Up"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Down"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Left"); + ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Right"); + + maxcode = 0x50; + /*** Superscope ***/ + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Fire"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Cursor"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); + ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause"); + + maxcode = 0x60; + /*** 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 Trigger"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Start"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Trigger"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 AimOffscreen"); + ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Start"); + + maxcode = 0x80; + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Superscope"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Mouse1"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Mouse2"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Justifier1"), false); + S9xMapPointer(maxcode++, S9xGetCommandT("Pointer Justifier2"), false); + + maxcode = 0x90; + ASSIGN_BUTTON_FALSE (maxcode++, "Screenshot"); + + // Plugin 2 Joypads by default + S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0); + S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); + S9xVerifyControllers(); +} + + +int main(void) +{ + extern void xenos_init(); + xenos_init(); + console_init(); + printf("SNES9x GX\n"); + + kmem_init(); + usb_init(); + // Set defaults + DefaultSettings (); + + S9xUnmapAllControls (); + SetDefaultButtonMap (); + + // Allocate SNES Memory + if (!Memory.Init ()) + ExitApp(); + + // Allocate APU + if (!S9xInitAPU ()) + ExitApp(); + + // Set Pixel Renderer to match 565 + S9xSetRenderPixelFormat (RGB565); + + // Initialise Snes Sound System + S9xInitSound (5, TRUE, 1024); + + // Initialise Graphics + +// setGFX (); + videoInit(); + + if (!S9xGraphicsInit ()) + ExitApp(); + + S9xSetSoundMute (TRUE); + S9xInitSync(); // initialize frame sync + + // Plugin 2 Joypads by default + S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0); + S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); + S9xVerifyControllers(); + + printf("Waiting for USB storage...\n"); + + extern void xenos_init(); + struct bdev *f; + do { + usb_do_poll(); + f = bdev_open("uda"); + if (f) + break; + } while (1); + + if (f) + { + if (fat_init(f)) + printf(" * FAT init failed\n"); + else if (fat_open("/SNES9X.SMC")) + printf("fat open of /SNES9X.SMC failed\n"); + else + { + printf(" * fat open okay, loading file...\n"); + int r = fat_read(Memory.ROM, 4*1024*1024); + goto ok; + } + printf("fat read failed.\n"); + while (1); + } +ok: + SNESROMSize = 1024*1024*4; +// memcpy(Memory.ROM, smc, SNESROMSize = sizeof(smc)); + + Memory.LoadROM ("BLANK.SMC"); + Memory.LoadSRAM ("BLANK"); + + console_close(); + + emulate(); // main loop + + while (1); + return 0; +} + +extern "C" { + +const char *getcwd(void) +{ + return "/"; +} + +int chdir(const char *f) +{ + return -1; +} + + +int getuid(void) +{ + return 0; +} + +int getgid(void) +{ + return 0; +} + +void chown() +{ +} + +int stat() +{ + return -1; +} + +int unlink() +{ + return -1; +} + +void gettimeofday() +{ +} + +} diff --git a/source/xenon/png.h b/source/xenon/png.h new file mode 100644 index 0000000..e69de29 diff --git a/source/xenon/pngu/pngu.h b/source/xenon/pngu/pngu.h new file mode 100644 index 0000000..e69de29 diff --git a/source/xenon/s9xconfig.cpp b/source/xenon/s9xconfig.cpp new file mode 100644 index 0000000..61567eb --- /dev/null +++ b/source/xenon/s9xconfig.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** + * Snes9x 1.51 Nintendo Wii/Gamecube Port + * + * softdev July 2006 + * crunchy2 May 2007 + * Michniewski 2008 + * Tantric 2008-2009 + * + * s9xconfig.cpp + * + * 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 "snes9x.h" + +// struct SGCSettings GCSettings; + +/**************************************************************************** + * FixInvalidSettings + * + * Attempts to correct at least some invalid settings - the ones that + * might cause crashes + ***************************************************************************/ +void FixInvalidSettings() +{ + +/* if(!(GCSettings.ZoomLevel > 0.5 && GCSettings.ZoomLevel < 1.5)) + GCSettings.ZoomLevel = 1.0; + if(!(GCSettings.xshift > -50 && GCSettings.xshift < 50)) + GCSettings.xshift = 0; + if(!(GCSettings.yshift > -50 && GCSettings.yshift < 50)) + GCSettings.yshift = 0; + if(!(GCSettings.MusicVolume >= 0 && GCSettings.MusicVolume <= 100)) + GCSettings.MusicVolume = 40; + if(!(GCSettings.SFXVolume >= 0 && GCSettings.SFXVolume <= 100)) + GCSettings.SFXVolume = 40; + if(GCSettings.Controller > CTRL_PAD4 || GCSettings.Controller < CTRL_MOUSE) + GCSettings.Controller = CTRL_PAD2; + if(!(GCSettings.render >= 0 && GCSettings.render < 3)) + GCSettings.render = 2; + if(!(GCSettings.videomode >= 0 && GCSettings.videomode < 5)) + GCSettings.videomode = 0; */ +} + +/**************************************************************************** + * DefaultSettings + * + * Sets all the defaults! + ***************************************************************************/ +void +DefaultSettings () +{ +#if 0 + /************** GameCube/Wii Settings *********************/ + ResetControls(); // controller button mappings + + GCSettings.LoadMethod = METHOD_AUTO; // Auto, SD, DVD, USB, Network (SMB) + GCSettings.SaveMethod = METHOD_AUTO; // Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, Network (SMB) + sprintf (GCSettings.LoadFolder,"snes9x/roms"); // Path to game files + sprintf (GCSettings.SaveFolder,"snes9x/saves"); // Path to save files + sprintf (GCSettings.CheatFolder,"snes9x/cheats"); // Path to cheat files + GCSettings.AutoLoad = 1; + GCSettings.AutoSave = 1; + + GCSettings.VerifySaves = 0; + + // custom SMB settings + strncpy (GCSettings.smbip, "", 15); // IP Address of share server + strncpy (GCSettings.smbuser, "", 19); // Your share user + strncpy (GCSettings.smbpwd, "", 19); // Your share user password + strncpy (GCSettings.smbshare, "", 19); // Share name on server + + GCSettings.smbip[15] = 0; + GCSettings.smbuser[19] = 0; + GCSettings.smbpwd[19] = 0; + GCSettings.smbshare[19] = 0; + + GCSettings.Controller = CTRL_PAD2; + + GCSettings.videomode = 0; // automatic video mode detection + GCSettings.ZoomLevel = 1.0; // zoom level + GCSettings.render = 2; // Unfiltered + GCSettings.widescreen = 0; // no aspect ratio correction + GCSettings.FilterMethod = FILTER_NONE; // no hq2x + + GCSettings.xshift = 0; // horizontal video shift + GCSettings.yshift = 0; // vertical video shift + + GCSettings.WiimoteOrientation = 0; + GCSettings.ExitAction = 0; + GCSettings.MusicVolume = 40; + GCSettings.SFXVolume = 40; + GCSettings.Rumble = 1; +#endif + + /****************** SNES9x Settings ***********************/ + + // Default ALL to false + memset (&Settings, 0, sizeof (Settings)); + + // General + + Settings.MouseMaster = false; + Settings.SuperScopeMaster = false; + Settings.MultiPlayer5Master = false; + Settings.JustifierMaster = false; + Settings.ShutdownMaster = true; // needs to be on for ActRaiser 2 + Settings.ApplyCheats = true; + + Settings.BlockInvalidVRAMAccess = false; + Settings.HDMATimingHack = 100; + + // Sound defaults. On GC this is 32Khz/16bit/Stereo/InterpolatedSound + Settings.APUEnabled = true; + Settings.NextAPUEnabled = true; + Settings.SoundPlaybackRate = 32000; + Settings.Stereo = true; + Settings.SixteenBitSound = true; + Settings.SoundEnvelopeHeightReading = true; + Settings.SoundSync = true; + Settings.FixFrequency = false; + Settings.DisableSampleCaching = true; + Settings.InterpolatedSound = true; + Settings.ReverseStereo = true; + + // Graphics + Settings.Transparency = true; + Settings.SupportHiRes = true; + Settings.SkipFrames = AUTO_FRAMERATE; + Settings.TurboSkipFrames = 19; + Settings.DisplayFrameRate = false; + Settings.AutoDisplayMessages = 0; + Settings.InitialInfoStringTimeout = 200; // # frames to display messages for + + // Frame timings in 50hz and 60hz cpu mode + Settings.FrameTimePAL = 20000; + Settings.FrameTimeNTSC = 16667; + + // SDD1 - Star Ocean Returns + Settings.SDD1Pack = true; + + Settings.ForceNTSC = 0; + Settings.ForcePAL = 0; + Settings.ForceHiROM = 0; + Settings.ForceLoROM = 0; + Settings.ForceHeader = 0; + Settings.ForceNoHeader = 0; + Settings.ForceTransparency = 0; + Settings.ForceInterleaved = 0; + Settings.ForceInterleaved2 = 0; + Settings.ForceInterleaveGD24 = 0; + Settings.ForceNotInterleaved = 0; + Settings.ForceNoSuperFX = 0; + Settings.ForceSuperFX = 0; + Settings.ForceDSP1 = 0; + Settings.ForceNoDSP1 = 0; +} diff --git a/source/xenon/s9xconfig.h b/source/xenon/s9xconfig.h new file mode 100644 index 0000000..d255108 --- /dev/null +++ b/source/xenon/s9xconfig.h @@ -0,0 +1,22 @@ +/**************************************************************************** + * Snes9x 1.51 Nintendo Wii/Gamecube Port + * + * softdev July 2006 + * crunchy2 May 2007 + * Michniewski 2008 + * Tantric 2008-2009 + * + * s9xconfig.h + * + * 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_ +#define _S9XCONFIG_ + +void FixInvalidSettings(); +void DefaultSettings(); + +#endif diff --git a/source/xenon/s9xsupport.cpp b/source/xenon/s9xsupport.cpp new file mode 100644 index 0000000..d93b269 --- /dev/null +++ b/source/xenon/s9xsupport.cpp @@ -0,0 +1,284 @@ +#include "snes9x.h" +#include "memmap.h" +#include "s9xdebug.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 "video.h" + + +#include