diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..357f472 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +.PHONY = all wii gc wii-clean gc-clean wii-run gc-run + +all: wii + +clean: wii-clean gc-clean + +run: wii-run + +wii: + $(MAKE) -f Makefile.wii + +wii-clean: + $(MAKE) -f Makefile.wii clean + +wii-run: wii + $(MAKE) -f Makefile.wii run + +gc: + $(MAKE) -f Makefile.gc + +gc-clean: + $(MAKE) -f Makefile.gc clean + +gc-run: gc + $(MAKE) -f Makefile.gc run diff --git a/Makefile.gc b/Makefile.gc new file mode 100644 index 0000000..d031e36 --- /dev/null +++ b/Makefile.gc @@ -0,0 +1,157 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif + +include $(DEVKITPPC)/gamecube_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 := dosbox_gc +TARGETDIR := executables +BUILD := build_gc +SOURCES := src src/cpu src/debug src/dos src/fpu src/gui \ + src/hardware src/hardware/serialport src/ints src/libs src/misc src/platform/wii src/shell +INCLUDES := include src/platform/wii + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- + +CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \ + -DNGC -DNO_SOUND -DUSE_VM -DWORDS_BIGENDIAN \ + -DC_CORE -D__ppc__ -D__POWERPC__ -DFINAL_VERSION \ + -DSDL -DNO_PNG -DHAVE_ZUTIL_H \ + -D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \ + -fomit-frame-pointer -fexceptions \ + -Wno-unused-parameter -Wno-strict-aliasing +CXXFLAGS = $(CFLAGS) +LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with +#--------------------------------------------------------------------------------- +LIBS := -lSDL_mixer -ljpeg -lpng -lz -lSDL -lfreetype \ + -lpngu -lmxml -lmetaphrasis -lfat -lz -logc + +#--------------------------------------------------------------------------------- +# 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)) \ + $(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))) +TTFFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ttf))) +PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) +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 := $(addsuffix .o,$(BINFILES)) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ + $(TTFFILES:.ttf=.ttf.o) $(PNGFILES:.png=.png.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$(LIBOGC_INC) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ + -L$(LIBOGC_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.gc + +#--------------------------------------------------------------------------------- +clean: + @echo clean ... + @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol + +#--------------------------------------------------------------------------------- +run: + psoload $(OUTPUT).dol + +#--------------------------------------------------------------------------------- +reload: + psoload -r $(OUTPUT).dol + + +#--------------------------------------------------------------------------------- +else + +DEPENDS := $(OFILES:.o=.d) + +#--------------------------------------------------------------------------------- +# main targets +#--------------------------------------------------------------------------------- +$(OUTPUT).dol: $(OUTPUT).elf +$(OUTPUT).elf: $(OFILES) + +#--------------------------------------------------------------------------------- +# This rule links in binary data with .ttf and .png extensions +#--------------------------------------------------------------------------------- +%.ttf.o : %.ttf + @echo $(notdir $<) + $(bin2o) + +%.png.o : %.png + @echo $(notdir $<) + $(bin2o) + +%.pcm.o : %.pcm + @echo $(notdir $<) + $(bin2o) + +-include $(DEPENDS) + +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- diff --git a/Makefile.wii b/Makefile.wii new file mode 100644 index 0000000..223235f --- /dev/null +++ b/Makefile.wii @@ -0,0 +1,163 @@ +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=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 := dosbox_wii +TARGETDIR := executables +BUILD := build_wii +SOURCES := src src/cpu src/debug src/dos src/fpu src/gui \ + src/hardware src/hardware/serialport src/ints src/libs src/misc src/platform/wii src/shell +INCLUDES := include src/platform/wii + +#--------------------------------------------------------------------------------- +# options for code generation +#--------------------------------------------------------------------------------- + +CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \ + -DNGC -DWORDS_BIGENDIAN \ + -DC_CORE -D__ppc__ -D__POWERPC__ -DFINAL_VERSION \ + -DSDL -DNO_PNG -DHAVE_ZUTIL_H \ + -D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \ + -fomit-frame-pointer -fexceptions \ + -Wno-unused-parameter -Wno-strict-aliasing +CXXFLAGS = $(CFLAGS) +LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref + +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with +#--------------------------------------------------------------------------------- +LIBS := -lSDL_ttf -lSDL_gfx -lSDL_mixer -lSDL_image -ljpeg -lpng -lz -lSDL -lfreetype \ + -ldb -ldi -lpngu -lmxml -lmetaphrasis \ + -lfat -lwiiuse -lz -lbte -logc -lasnd -ltremor -lfreetype -ltinysmb + +#--------------------------------------------------------------------------------- +# 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)) \ + $(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))) +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 := $(addsuffix .o,$(BINFILES)) \ + $(CPPFILES:.cpp=.o) $(CFILES:.c=.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$(LIBOGC_INC) + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ + -L$(LIBOGC_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.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 .ttf and .png 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/dosbox-wii.pnproj b/dosbox-wii.pnproj new file mode 100644 index 0000000..25cb82a --- /dev/null +++ b/dosbox-wii.pnproj @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index 14f83c3..a515524 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -22,7 +22,15 @@ #include #include "dosbox.h" #include "cpu.h" +#ifdef HW_RVL +// memory.h doesn't exist for Wii +#else +#ifdef HW_DOL +// memory.h doesn't exist for Gamecube +#else #include "memory.h" +#endif +#endif #include "debug.h" #include "mapper.h" #include "setup.h" diff --git a/src/hardware/adlib.cpp b/src/hardware/adlib.cpp index 3411411..bf356e8 100644 --- a/src/hardware/adlib.cpp +++ b/src/hardware/adlib.cpp @@ -93,7 +93,7 @@ namespace OPL3 { } virtual Bit32u WriteAddr( Bit32u port, Bit8u val ) { adlib_write_index(port, val); - return index; + return opl_index; } virtual void Generate( MixerChannel* chan, Bitu samples ) { Bit16s buf[1024*2]; diff --git a/src/hardware/fmopl.c b/src/hardware/fmopl.c index 9587519..c8ede58 100644 --- a/src/hardware/fmopl.c +++ b/src/hardware/fmopl.c @@ -64,6 +64,7 @@ Revision History: //#include "driver.h" /* use M.A.M.E. */ #include "fmopl.h" +#include "config.h" // INLINE #ifndef PI #define PI 3.14159265358979323846 diff --git a/src/hardware/opl.cpp b/src/hardware/opl.cpp index da78414..d415637 100644 --- a/src/hardware/opl.cpp +++ b/src/hardware/opl.cpp @@ -27,6 +27,7 @@ #include #include +#include // rand() #include "dosbox.h" #include "opl.h" @@ -510,7 +511,7 @@ void adlib_init(Bit32u samplerate) { } status = 0; - index = 0; + opl_index = 0; // create vibrato table @@ -900,11 +901,11 @@ Bitu adlib_reg_read(Bitu port) { } void adlib_write_index(Bitu port, Bit8u val) { - index = val; + opl_index = val; #if defined(OPLTYPE_IS_OPL3) if ((port&3)!=0) { // possibly second set - if (((adlibreg[0x105]&1)!=0) || (index==5)) index |= ARC_SECONDSET; + if (((adlibreg[0x105]&1)!=0) || (opl_index==5)) opl_index |= ARC_SECONDSET; } #endif } diff --git a/src/hardware/opl.h b/src/hardware/opl.h index c545def..3cbcbab 100644 --- a/src/hardware/opl.h +++ b/src/hardware/opl.h @@ -151,7 +151,7 @@ op_type op[MAXOPERATORS]; Bits int_samplerate; Bit8u status; -Bit32u index; +Bit32u opl_index; #if defined(OPLTYPE_IS_OPL3) Bit8u adlibreg[512]; // adlib register set (including second set) Bit8u wave_sel[44]; // waveform selection diff --git a/src/hardware/ymf262.c b/src/hardware/ymf262.c index cbe8ad4..71b59c8 100644 --- a/src/hardware/ymf262.c +++ b/src/hardware/ymf262.c @@ -45,6 +45,14 @@ differences between OPL2 and OPL3 shown in datasheets: //#include "driver.h" /* use M.A.M.E. */ #include "ymf262.h" +#ifdef HW_RVL +#undef INLINE +#define INLINE static inline +#endif +#ifdef HW_DOL +#undef INLINE +#define INLINE static inline +#endif #ifndef PI #define PI 3.14159265358979323846 diff --git a/src/platform/wii/config.h b/src/platform/wii/config.h new file mode 100644 index 0000000..240a12b --- /dev/null +++ b/src/platform/wii/config.h @@ -0,0 +1,77 @@ +#define VERSION "0.72" + +/* Define to 1 to enable internal debugger, requires libcurses */ +#define C_DEBUG 0 + +/* Define to 1 to enable screenshots, requires libpng */ +#define C_SSHOT 0 + +/* Define to 1 to use opengl display output support */ +#define C_OPENGL 0 + +/* Define to 1 to enable internal modem support, requires SDL_net */ +#define C_MODEM 0 + +/* Define to 1 to enable IPX networking support, requires SDL_net */ +#define C_IPX 0 + +/* Enable some heavy debugging options */ +#define C_HEAVY_DEBUG 0 + +/* The type of cpu this host has */ +//#define C_TARGETCPU X86 +//#define C_TARGETCPU X86_64 + +/* Define to 1 to use x86 dynamic cpu core */ +#define C_DYNAMIC_X86 0 + +/* Define to 1 to use recompiling cpu core. Can not be used together with the dynamic-x86 core */ +#define C_DYNREC 0 + +/* Enable memory function inlining in */ +#define C_CORE_INLINE 0 + +/* Enable the FPU module, still only for beta testing */ +#define C_FPU 1 + +/* Define to 1 to use a x86 assembly fpu core */ +#define C_FPU_X86 0 + +/* Define to 1 to use a unaligned memory access */ +#define C_UNALIGNED_MEMORY 0 + +/* environ is defined */ +#define ENVIRON_INCLUDED 0 + +/* environ can be linked */ +#define ENVIRON_LINKED 0 + +/* Define to 1 if you have the header file. */ +#define HAVE_DDRAW_H 0 + +/* Define to 1 if you want serial passthrough support (Win32 only). */ +#define C_DIRECTSERIAL 0 + +#define GCC_ATTRIBUTE(x) /* attribute not supported */ +#define GCC_UNLIKELY(x) (x) + +#define INLINE inline +//#define DB_FASTCALL __fastcall + +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#pragma warning(disable : 4996) +#endif + +typedef double Real64; +/* The internal types */ +typedef unsigned char Bit8u; +typedef signed char Bit8s; +typedef unsigned short Bit16u; +typedef signed short Bit16s; +typedef unsigned long Bit32u; +typedef signed long Bit32s; +typedef unsigned long long Bit64u; +typedef signed long long Bit64s; +typedef unsigned int Bitu; +typedef signed int Bits; + diff --git a/src/platform/wii/missingfunctions.cpp b/src/platform/wii/missingfunctions.cpp new file mode 100644 index 0000000..2b11c2e --- /dev/null +++ b/src/platform/wii/missingfunctions.cpp @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include "dos_inc.h" +#define MAX_FILENAME_LENGTH 256 + +static char tmp[MAX_FILENAME_LENGTH]; +char * dirname(char * file) { + // CAKTODO + char * sep = strrchr(file, '/'); + if (sep == NULL) + sep = strrchr(file, '\\'); + if (sep == NULL) + return ""; + else { + int len = (int)(sep - file); + safe_strncpy(tmp, file, len+1); + return tmp; + } +} +int access(const char *path, int amode) { + FILE *F = fopen(path, "rb"); + if (F) { + fclose(F); + return 0; + } else { + return ENOENT; + } +} +int rmdir(const char *path) { + return remove(path); +} +int execlp(const char *file, const char *arg, ...) { + return -1; +}