Compiles for Wii now! Haven't tried running it. It would compile for GameCube too, except there is no SDL for GameCube yet.

This commit is contained in:
Carl.Kenner 2009-05-03 02:37:49 +00:00
parent d64459fd7a
commit 0127b6dab7
12 changed files with 483 additions and 5 deletions

25
Makefile Normal file
View File

@ -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

157
Makefile.gc Normal file
View File

@ -0,0 +1,157 @@
#---------------------------------------------------------------------------------
# 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)/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
#---------------------------------------------------------------------------------

163
Makefile.wii Normal file
View File

@ -0,0 +1,163 @@
#---------------------------------------------------------------------------------
# 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 := 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
#---------------------------------------------------------------------------------

1
dosbox-wii.pnproj Normal file

File diff suppressed because one or more lines are too long

View File

@ -22,7 +22,15 @@
#include <sstream>
#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"

View File

@ -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];

View File

@ -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

View File

@ -27,6 +27,7 @@
#include <math.h>
#include <string.h>
#include <stdlib.h> // 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
}

View File

@ -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

View File

@ -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

77
src/platform/wii/config.h Normal file
View File

@ -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 <ddraw.h> 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;

View File

@ -0,0 +1,37 @@
#include <cstdio>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <libgen.h>
#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;
}