mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 00:15:14 +01:00
add port to xbox 360 using libxenon library
This commit is contained in:
parent
a5948af88a
commit
21e52eab5a
164
Makefile.xenon
Normal file
164
Makefile.xenon
Normal file
@ -0,0 +1,164 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(DEVKITXENON)),)
|
||||
$(error "Please set DEVKITXENON in your environment. export DEVKITXENON=<path to>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
|
||||
#---------------------------------------------------------------------------------
|
7
source/xenon/README
Normal file
7
source/xenon/README
Normal file
@ -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.
|
45
source/xenon/ffs_content.c
Normal file
45
source/xenon/ffs_content.c
Normal file
@ -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},
|
||||
};
|
0
source/xenon/filebrowser.h
Normal file
0
source/xenon/filebrowser.h
Normal file
0
source/xenon/fileop.h
Normal file
0
source/xenon/fileop.h
Normal file
70
source/xenon/freeze.cpp
Normal file
70
source/xenon/freeze.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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);
|
||||
}
|
0
source/xenon/freeze.h
Normal file
0
source/xenon/freeze.h
Normal file
0
source/xenon/gccore.h
Normal file
0
source/xenon/gccore.h
Normal file
328
source/xenon/main.cpp
Normal file
328
source/xenon/main.cpp
Normal file
@ -0,0 +1,328 @@
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#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 <console/console.h>
|
||||
#include <diskio/diskio.h>
|
||||
#include <fat/fat.h>
|
||||
#include <xenos/xenos.h>
|
||||
|
||||
//#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 <input/input.h>
|
||||
|
||||
};
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
0
source/xenon/png.h
Normal file
0
source/xenon/png.h
Normal file
0
source/xenon/pngu/pngu.h
Normal file
0
source/xenon/pngu/pngu.h
Normal file
159
source/xenon/s9xconfig.cpp
Normal file
159
source/xenon/s9xconfig.cpp
Normal file
@ -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;
|
||||
}
|
22
source/xenon/s9xconfig.h
Normal file
22
source/xenon/s9xconfig.h
Normal file
@ -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
|
284
source/xenon/s9xsupport.cpp
Normal file
284
source/xenon/s9xsupport.cpp
Normal file
@ -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 <time/time.h>
|
||||
#include <ppc/timebase.h>
|
||||
|
||||
int FrameTimer, timerstyle = 1;
|
||||
unsigned long long prev, now;
|
||||
|
||||
unsigned long long gettime(void)
|
||||
{
|
||||
return mftb();
|
||||
}
|
||||
|
||||
int diff_usec(unsigned long long prev, unsigned long long now)
|
||||
{
|
||||
return (now - prev) /(PPC_TIMEBASE_FREQ/1000000);
|
||||
}
|
||||
|
||||
|
||||
extern void S9xSetInfoString (const char *string);
|
||||
|
||||
/*** Miscellaneous Functions ***/
|
||||
void S9xMessage(int /*type */, int /*number */, const char *message)
|
||||
{
|
||||
#define MAX_MESSAGE_LEN (36 * 3)
|
||||
|
||||
static char buffer[MAX_MESSAGE_LEN + 1];
|
||||
strncpy(buffer, message, MAX_MESSAGE_LEN);
|
||||
buffer[MAX_MESSAGE_LEN] = 0;
|
||||
S9xSetInfoString(buffer);
|
||||
}
|
||||
|
||||
void S9xExit()
|
||||
{
|
||||
printf(" *** EXIT\n");
|
||||
while (1);
|
||||
}
|
||||
|
||||
/*** File based functions ***/
|
||||
const char *
|
||||
S9xChooseFilename(bool8 read_only)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
S9xChooseMovieFilename(bool8 read_only)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
S9xGetDirectory(enum s9x_getdirtype dirtype)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
S9xGetFilename(const char *ex, enum s9x_getdirtype dirtype)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
S9xGetFilenameInc(const char *e, enum s9x_getdirtype dirtype)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*** Memory based functions ***/
|
||||
void S9xAutoSaveSRAM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*** Sound based functions ***/
|
||||
void S9xToggleSoundChannel(int c)
|
||||
{
|
||||
if (c == 8)
|
||||
so.sound_switch = 255;
|
||||
else
|
||||
so.sound_switch ^= 1 << c;
|
||||
S9xSetSoundControl(so.sound_switch);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* OpenSoundDevice
|
||||
*
|
||||
* Main initialisation for NGC sound system
|
||||
***************************************************************************/
|
||||
bool8 S9xOpenSoundDevice(int mode, bool8 stereo, int buffer_size)
|
||||
{
|
||||
so.stereo = TRUE;
|
||||
so.playback_rate = 32000;
|
||||
so.sixteen_bit = TRUE;
|
||||
so.encoded = 0;
|
||||
so.buffer_size = 4096;
|
||||
so.sound_switch = 255;
|
||||
S9xSetPlaybackRate(so.playback_rate);
|
||||
|
||||
// init audio
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*** Deprecated function. NGC uses threaded sound ***/
|
||||
void S9xGenerateSound()
|
||||
{
|
||||
}
|
||||
|
||||
/* eke-eke */
|
||||
void S9xInitSync()
|
||||
{
|
||||
FrameTimer = 0;
|
||||
prev = gettime();
|
||||
}
|
||||
|
||||
/*** Synchronisation ***/
|
||||
|
||||
void S9xSyncSpeed ()
|
||||
{
|
||||
uint32 skipFrms = Settings.SkipFrames;
|
||||
|
||||
if (Settings.TurboMode)
|
||||
skipFrms = Settings.TurboSkipFrames;
|
||||
|
||||
if (timerstyle == 0) /* use NGC vertical sync (VSYNC) with NTSC roms */
|
||||
{
|
||||
while (FrameTimer == 0)
|
||||
{
|
||||
udelay(50);
|
||||
}
|
||||
|
||||
if (FrameTimer > skipFrms)
|
||||
FrameTimer = skipFrms;
|
||||
|
||||
if ((FrameTimer > 1) && (IPPU.SkippedFrames < skipFrms))
|
||||
{
|
||||
IPPU.SkippedFrames++;
|
||||
IPPU.RenderThisFrame = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPPU.SkippedFrames = 0;
|
||||
IPPU.RenderThisFrame = TRUE;
|
||||
}
|
||||
}
|
||||
else /* use internal timer for PAL roms */
|
||||
{
|
||||
unsigned int timediffallowed = Settings.TurboMode ? 0 : Settings.FrameTime;
|
||||
now = gettime();
|
||||
|
||||
if (diff_usec(prev, now) > timediffallowed)
|
||||
{
|
||||
printf("L\n");
|
||||
/* Timer has already expired */
|
||||
if (IPPU.SkippedFrames < skipFrms)
|
||||
{
|
||||
IPPU.SkippedFrames++;
|
||||
IPPU.RenderThisFrame = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
IPPU.SkippedFrames = 0;
|
||||
IPPU.RenderThisFrame = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*** Ahead - so hold up ***/
|
||||
while (diff_usec(prev, now) < timediffallowed)
|
||||
{
|
||||
now = gettime();
|
||||
udelay(50);
|
||||
}
|
||||
IPPU.RenderThisFrame = TRUE;
|
||||
IPPU.SkippedFrames = 0;
|
||||
}
|
||||
|
||||
prev = now;
|
||||
}
|
||||
|
||||
if (!Settings.TurboMode)
|
||||
FrameTimer--;
|
||||
return;
|
||||
}
|
||||
|
||||
/*** Video / Display related functions ***/
|
||||
bool8 S9xInitUpdate()
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
bool8 S9xDeinitUpdate(int Width, int Height)
|
||||
{
|
||||
// update_video(Width, Height);
|
||||
videoBlit(Width, Height);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
bool8 S9xContinueUpdate(int Width, int Height)
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
void S9xSetPalette()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*** Input functions ***/
|
||||
void S9xHandlePortCommand(s9xcommand_t cmd, int16 data1, int16 data2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool S9xPollButton(uint32 id, bool * pressed)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool S9xPollAxis(uint32 id, int16 * value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool S9xPollPointer(uint32 id, int16 * x, int16 * y)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S9xLoadSDD1Data()
|
||||
{
|
||||
Memory.FreeSDD1Data();
|
||||
|
||||
Settings.SDD1Pack = FALSE;
|
||||
|
||||
if (strncmp(Memory.ROMName, "Star Ocean", 10) == 0)
|
||||
Settings.SDD1Pack = TRUE;
|
||||
|
||||
if (strncmp(Memory.ROMName, "STREET FIGHTER ALPHA2", 21) == 0)
|
||||
Settings.SDD1Pack = TRUE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Note that these are DUMMY functions, and only allow Snes9x to
|
||||
* compile. Where possible, they will return an error signal.
|
||||
***************************************************************************/
|
||||
|
||||
/*** splitpath function ***/
|
||||
void _splitpath(char const *buffer, char *drive, char *dir, char *fname,
|
||||
char *ext)
|
||||
{
|
||||
return; // Do nothing - NGC code should NEVER call a function which relies on it
|
||||
}
|
||||
|
||||
void _makepath(char *filename, const char *drive, const char *dir,
|
||||
const char *fname, const char *ext)
|
||||
{
|
||||
return; // Do nothing - NGC code should NEVER call a function which relies on it
|
||||
}
|
||||
|
||||
char *
|
||||
S9xBasename(char *name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
unsigned long SNESROMSize = 0;
|
0
source/xenon/snes9xGX.h
Normal file
0
source/xenon/snes9xGX.h
Normal file
116
source/xenon/video.cpp
Normal file
116
source/xenon/video.cpp
Normal file
@ -0,0 +1,116 @@
|
||||
#include <xenos/xe.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gfx.h"
|
||||
|
||||
extern "C" void do_edram_foo(struct XenosDevice *xe, int complete);
|
||||
|
||||
struct XenosSurface *gfxplane;
|
||||
struct XenosDevice _xe, *xe;
|
||||
struct XenosShader *sh_ps, *sh_vs;
|
||||
struct XenosVertexBuffer *vb;
|
||||
struct XenosIndexBuffer *ib;
|
||||
|
||||
void videoInit(void)
|
||||
{
|
||||
xe = &_xe;
|
||||
/* initialize the GPU */
|
||||
Xe_Init(xe);
|
||||
|
||||
gfxplane = Xe_CreateTexture(xe, MAX_SNES_WIDTH, MAX_SNES_HEIGHT, 1, 4 | 0x40, 0);
|
||||
|
||||
GFX.Screen = (uint16*)(((unsigned char*)gfxplane->base) + gfxplane->pitch * 2 + 2 * 2);
|
||||
GFX.Pitch = gfxplane->pitch;
|
||||
|
||||
/* create a render target (the framebuffer) */
|
||||
struct XenosSurface *fb = Xe_GetFramebufferSurface(xe);
|
||||
Xe_SetRenderTarget(xe, fb);
|
||||
|
||||
printf("framebuffer at: %p, pitch %d\n", fb->base, fb->pitch);
|
||||
|
||||
/* let's define a vertex buffer format */
|
||||
static const struct XenosVBFFormat vbf =
|
||||
{
|
||||
2, {
|
||||
{XE_USAGE_POSITION, 0, XE_TYPE_FLOAT2},
|
||||
{XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
|
||||
}
|
||||
};
|
||||
|
||||
float rect[] = {
|
||||
-1, 1, 0, 0,
|
||||
-1, -1, 0, 1,
|
||||
1, 1, 1, 0,
|
||||
1, -1, 1, 1
|
||||
};
|
||||
|
||||
unsigned short rect_indices[] = {0, 2, 1, 1, 2, 3};
|
||||
|
||||
printf("loading pixel shader...\n");
|
||||
/* load pixel shader */
|
||||
sh_ps = Xe_LoadShader(xe, "ps.psu");
|
||||
Xe_InstantiateShader(xe, sh_ps, 0);
|
||||
|
||||
printf("loading vertex shader...\n");
|
||||
/* load vertex shader */
|
||||
sh_vs = Xe_LoadShader(xe, "vs.vsu");
|
||||
Xe_InstantiateShader(xe, sh_vs, 0);
|
||||
Xe_ShaderApplyVFetchPatches(xe, sh_vs, 0, &vbf);
|
||||
|
||||
printf("create vb...\n");
|
||||
/* create and fill vertex buffer */
|
||||
vb = Xe_CreateVertexBuffer(xe, sizeof(rect));
|
||||
void *v = Xe_VB_Lock(xe, vb, 0, sizeof(rect), XE_LOCK_WRITE);
|
||||
memcpy(v, rect, sizeof(rect));
|
||||
Xe_VB_Unlock(xe, vb);
|
||||
|
||||
printf("create ib...\n");
|
||||
/* create and fill index buffer */
|
||||
ib = Xe_CreateIndexBuffer(xe, sizeof(rect_indices), XE_FMT_INDEX16);
|
||||
unsigned short *i = (unsigned short*)Xe_IB_Lock(xe, ib, 0, sizeof(rect_indices), XE_LOCK_WRITE);
|
||||
memcpy(i, rect_indices, sizeof(rect_indices));
|
||||
Xe_IB_Unlock(xe, ib);
|
||||
|
||||
do_edram_foo(xe, 1);
|
||||
}
|
||||
|
||||
void videoBlit(int xres, int yres)
|
||||
{
|
||||
/* flush cache */
|
||||
Xe_Surface_LockRect(xe, gfxplane, 0, 0, 0, 0, XE_LOCK_WRITE);
|
||||
Xe_Surface_Unlock(xe, gfxplane);
|
||||
|
||||
|
||||
/* we don't want the border. Note that because of interpolation, some fractional pixel values might get through. */
|
||||
float *v = (float*)Xe_VB_Lock(xe, vb, 0, 16*4, XE_LOCK_WRITE);
|
||||
v[2] = v[6] = 2.0 / xres;
|
||||
v[3] = v[11] = 2.0 / yres;
|
||||
Xe_VB_Unlock(xe, vb);
|
||||
|
||||
/* create new surface with right size */
|
||||
XenosSurface surface = *gfxplane;
|
||||
surface.width = xres;
|
||||
surface.height = yres;
|
||||
/* begin a new frame, i.e. reset all renderstates to the default */
|
||||
Xe_InvalidateState(xe);
|
||||
|
||||
int max_vertices = 4;
|
||||
int nr_primitives = 2;
|
||||
|
||||
/* draw cube */
|
||||
Xe_SetShader(xe, SHADER_TYPE_PIXEL, sh_ps, 0);
|
||||
Xe_SetShader(xe, SHADER_TYPE_VERTEX, sh_vs, 0);
|
||||
Xe_SetStreamSource(xe, 0, vb, 0, 4); /* using this vertex buffer */
|
||||
Xe_SetIndices(xe, ib); /* ... this index buffer... */
|
||||
Xe_SetTexture(xe, 0, &surface); /* ... and this texture */
|
||||
Xe_DrawIndexedPrimitive(xe, XE_PRIMTYPE_TRIANGLELIST, 0, 0, max_vertices, 0, nr_primitives);
|
||||
|
||||
/* clear to white */
|
||||
Xe_SetClearColor(xe, ~0);
|
||||
|
||||
/* resolve (and clear) */
|
||||
Xe_Resolve(xe);
|
||||
|
||||
/* wait for render finish */
|
||||
Xe_Sync(xe);
|
||||
}
|
4
source/xenon/video.h
Normal file
4
source/xenon/video.h
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
void videoInit(void);
|
||||
void videoBlit(int xres, int yres);
|
||||
|
Loading…
Reference in New Issue
Block a user