lowered sound quality (set to high, does it prevents slowdown now ?), fixed original mode for all TV settings (PAL/EURGB60/NTSC), fixed screen scaling in original modes (uses GX feature instead VI), improved rendering engine speed, fixed timer sychronization

This commit is contained in:
ekeeke31 2008-10-25 15:58:59 +00:00
parent 20c036bcf7
commit 5d62e3b2cf
5 changed files with 213 additions and 161 deletions

172
Makefile
View File

@ -1,23 +1,165 @@
.PHONY = all wii gc wii-clean gc-clean wii-run gc-run
#---------------------------------------------------------------------------------
# Clear the implicit built in rules
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
all: wii gc
include $(DEVKITPPC)/wii_rules
clean: wii-clean gc-clean
#---------------------------------------------------------------------------------
# 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 := fceugx_wii
TARGETDIR := executables
BUILD := build_wii
SOURCES := source/fceultra source/fceultra/boards \
source/fceultra/drivers/common source/fceultra/input \
source/fceultra/mappers source/fceultra/mbshare \
source/ngc source/sz
DATA := data
INCLUDES := source/fceultra source/ngc
LANG := ENGLISH # Supported languages: ENGLISH
wii:
$(MAKE) -f Makefile.wii
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) -DNGC -DWII_DVD \
-DHAVE_ASPRINTF -DSTDC -DFCEU_VERSION_NUMERIC=9812 \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \
-DLANG_$(LANG)
CXXFLAGS = $(CFLAGS)
wii-clean:
$(MAKE) -f Makefile.wii clean
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref
wii-run:
$(MAKE) -f Makefile.wii run
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -ldi -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb
gc:
$(MAKE) -f Makefile.gc
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
gc-clean:
$(MAKE) -f Makefile.gc clean
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(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)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o)
#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
-L$(LIBOGC_LIB)
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@[ -d $(TARGETDIR) ] || mkdir -p $(TARGETDIR)
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.wii
@rm -fr $(OUTPUT).elf
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT).dol source/tags
#---------------------------------------------------------------------------------
run:
wiiload $(TARGET).dol
#---------------------------------------------------------------------------------
reload:
wiiload -r $(TARGET).dol
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).dol: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension
#---------------------------------------------------------------------------------
%.jpg.o : %.jpg
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
tags:
@( cd source; ctags *.c *.h \
boards/*.c boards/*.h \
mappers/*.c mappers/*.h \
input/*.c input/*.h \
mbshare/*.c mbshare/*.h \
drivers/common/*.c drivers/common/*.h \
drivers/gamecube/*.c drivers/gamecube/*.h \
drivers/gamecube/intl/english.h \
iplfont/*.c iplfont/*.h \
sz/*.c sz/*.h \
/opt/devkitpro/libogc/include/*.h \
/opt/devkitpro/libogc/include/mad/*.h \
/opt/devkitpro/libogc/include/ogc/*.h \
/opt/devkitpro/libogc/include/modplay/*.h \
/opt/devkitpro/libogc/include/sdcard/*.h )
gc-run:
$(MAKE) -f Makefile.gc run

View File

@ -147,7 +147,7 @@ int main(int argc, char *argv[])
setFrameTimer(); // set frametimer method before emulation
FCEUI_SetVidSystem(GCSettings.timing);
FCEUI_SetSoundQuality(2); // 0 - low, 1 - high, 2 - high (alt.)
FCEUI_SetSoundQuality(1); // 0 - low, 1 - high, 2 - high (alt.)
ResetVideo_Emu();
while(1) // emulation loop

View File

@ -97,8 +97,9 @@ void InitialiseAudio()
void StopAudio()
{
AUDIO_StopDMA();
ConfigRequested = 1;
IsPlaying = 0;
mixhead = mixtail = 0;
memset(soundbuffer, 0, 3840*2);
}
/****************************************************************************
@ -136,7 +137,6 @@ void PlaySound( int *Buffer, int count )
// Restart Sound Processing if stopped
if (IsPlaying == 0)
{
ConfigRequested = 0;
AudioSwitchBuffers ();
}
}

View File

@ -32,27 +32,23 @@ int FDSSwitchRequested;
GXRModeObj *vmode; // Graphics Mode Object
unsigned int *xfb[2]; // Framebuffers
int whichfb = 0; // Frame buffer toggle
int screenheight;
bool progressive = FALSE;
/*** 3D GX ***/
#define TEX_WIDTH 512
#define TEX_HEIGHT 512
#define TEX_WIDTH 256
#define TEX_HEIGHT 240
#define DEFAULT_FIFO_SIZE ( 256 * 1024 )
static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN(32);
unsigned int copynow = GX_FALSE;
static u32 copynow = GX_FALSE;
static GXTexObj texobj;
static Mtx view;
/*** Texture memory ***/
static unsigned char texturemem[TEX_WIDTH * TEX_HEIGHT * 2] ATTRIBUTE_ALIGN (32);
GXTexObj texobj;
static Mtx view;
int vwidth = 256;
int vheight = 240;
int updateScaling = 1;
bool progressive = false;
int vmode_60hz = 0;
static int updateScaling = 1;
static int vmode_60hz = 0;
#define HASPECT 256
#define VASPECT 240
@ -114,7 +110,7 @@ static camera cam = { {0.0F, 0.0F, 0.0F},
GXRModeObj PAL_240p =
{
VI_TVMODE_PAL_DS, // viDisplayMode
256, // fbWidth
640, // fbWidth
240, // efbHeight
240, // xfbHeight
(VI_MAX_WIDTH_PAL - 640)/2, // viXOrigin
@ -145,48 +141,13 @@ GXRModeObj PAL_240p =
}
};
/* 478 lines interlaced (PAL 50Hz, Deflicker) */
GXRModeObj PAL_480i =
{
VI_TVMODE_PAL_INT, // viDisplayMode
512, // fbWidth
480, // efbHeight
480, // xfbHeight
(VI_MAX_WIDTH_PAL - 640)/2, // viXOrigin
(VI_MAX_HEIGHT_PAL - 480)/2, // viYOrigin
640, // viWidth
480, // viHeight
VI_XFBMODE_DF, // xFBmode
GX_FALSE, // field_rendering
GX_FALSE, // aa
// sample points arranged in increasing Y order
{
{6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each
{6,6},{6,6},{6,6}, // pix 1
{6,6},{6,6},{6,6}, // pix 2
{6,6},{6,6},{6,6} // pix 3
},
// vertical filter[7], 1/64 units, 6 bits each
{
8, // line n-1
8, // line n-1
10, // line n
12, // line n
10, // line n
8, // line n+1
8 // line n+1
}
};
/** Original NES NTSC Resolutions: **/
/* 240 lines progressive (NTSC or PAL 60Hz) */
GXRModeObj NTSC_240p =
{
VI_TVMODE_EURGB60_DS, // viDisplayMode
256, // fbWidth
640, // fbWidth
240, // efbHeight
240, // xfbHeight
(VI_MAX_WIDTH_NTSC - 640)/2, // viXOrigin
@ -217,46 +178,9 @@ GXRModeObj NTSC_240p =
}
};
/* 448 lines interlaced (NTSC or PAL 60Hz, Deflicker) */
GXRModeObj NTSC_480i =
{
VI_TVMODE_EURGB60_INT, // viDisplayMode
512, // fbWidth
480, // efbHeight
480, // xfbHeight
(VI_MAX_WIDTH_NTSC - 640)/2, // viXOrigin
(VI_MAX_HEIGHT_NTSC - 480)/2, // viYOrigin
640, // viWidth
480, // viHeight
VI_XFBMODE_DF, // xFBmode
GX_FALSE, // field_rendering
GX_FALSE, // aa
// sample points arranged in increasing Y order
{
{6,6},{6,6},{6,6}, // pix 0, 3 sample points, 1/12 units, 4 bits each
{6,6},{6,6},{6,6}, // pix 1
{6,6},{6,6},{6,6}, // pix 2
{6,6},{6,6},{6,6} // pix 3
},
// vertical filter[7], 1/64 units, 6 bits each
{
8, // line n-1
8, // line n-1
10, // line n
12, // line n
10, // line n
8, // line n+1
8 // line n+1
}
};
/* TV Modes table */
GXRModeObj *tvmodes[4] = {
&PAL_240p, &PAL_480i, // NES PAL video modes
&NTSC_240p, &NTSC_480i, // NES NTSC video modes
GXRModeObj *tvmodes[2] = {
&NTSC_240p, &PAL_240p
};
/****************************************************************************
@ -279,10 +203,7 @@ void setFrameTimer()
void SyncSpeed()
{
now = gettime();
int diff = normaldiff - diff_usec(prev, now);
if (diff > 0) // ahead - take a nap
usleep(diff);
while (diff_usec(prev, now) < normaldiff) now = gettime();
prev = now;
}
@ -307,9 +228,9 @@ vbgetback (void *arg)
{
while (1)
{
if(GCSettings.timing != vmode_60hz)
/*if(GCSettings.timing != vmode_60hz)
VIDEO_WaitVSync();
else
else*/
SyncSpeed();
LWP_SuspendThread (vbthread);
}
@ -594,46 +515,31 @@ ResetVideo_Emu ()
{
case VI_PAL: /* 576 lines (PAL 50Hz) */
// set video signal mode
PAL_240p.viTVMode = VI_TVMODE_PAL_DS;
PAL_480i.viTVMode = VI_TVMODE_PAL_INT;
// set video signal mode (50Hz only)
NTSC_240p.viTVMode = VI_TVMODE_PAL_DS;
NTSC_480i.viTVMode = VI_TVMODE_PAL_INT;
NTSC_240p.viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2;
break;
case VI_NTSC: /* 480 lines (NTSC 60hz) */
// set video signal mode
// set video signal mode (60Hz only)
PAL_240p.viTVMode = VI_TVMODE_NTSC_DS;
PAL_480i.viTVMode = VI_TVMODE_NTSC_INT;
PAL_240p.viYOrigin = (VI_MAX_HEIGHT_NTSC - 480)/2;
NTSC_240p.viTVMode = VI_TVMODE_NTSC_DS;
NTSC_480i.viTVMode = VI_TVMODE_NTSC_INT;
break;
default: /* 480 lines (PAL 60Hz) */
// set video signal mode
// set video signal mode (supports both 50/60Hz but we use 60hz for both PAL & NTSC settings)
PAL_240p.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_NON_INTERLACE);
PAL_480i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE);
PAL_240p.viYOrigin = (VI_MAX_HEIGHT_NTSC - 480)/2;
NTSC_240p.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_NON_INTERLACE);
NTSC_480i.viTVMode = VI_TVMODE(vmode->viTVMode >> 2, VI_INTERLACE);
break;
}
int i = -1;
if (GCSettings.render == 0) // original render mode
{
for (i=0; i<4; i++) {
if (tvmodes[i]->efbHeight == vheight)
break;
}
if(i >= 0)
rmode = tvmodes[i];
else
{
WaitPrompt("Video mode not found!");
rmode = vmode;
}
rmode = tvmodes[GCSettings.timing];
}
else if (GCSettings.render == 2) // unfiltered
{
@ -659,7 +565,7 @@ ResetVideo_Emu ()
GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight);
GX_SetDispCopyDst (rmode->fbWidth, rmode->xfbHeight);
GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter); // AA on only for filtered mode
GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter); // Deflickering Filter only for filtered mode
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
@ -723,8 +629,8 @@ void RenderFrame(unsigned char *XBuf)
/** Update scaling **/
if (GCSettings.render == 0) // original render mode
{
xscale = vwidth / 2;
yscale = vheight / 2;
xscale = 640 / 2; /* use GX scaler instead VI (less artefacts) */
yscale = 240 / 2;
}
else // unfiltered and filtered mode
{
@ -747,9 +653,10 @@ void RenderFrame(unsigned char *XBuf)
GX_InvVtxCache (); // update vertex cache
GX_InitTexObj (&texobj, texturemem, vwidth, vheight, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); // initialize the texture obj we are going to use
GX_InitTexObj (&texobj, texturemem, TEX_WIDTH, TEX_HEIGHT, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); // initialize the texture obj we are going to use
memset(texturemem, 0, TEX_WIDTH * TEX_HEIGHT * 2);
if (!GCSettings.render&1)
if (!(GCSettings.render&1))
GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,2.5,9.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); // original/unfiltered video mode: force texture filtering OFF
GX_LoadTexObj (&texobj, GX_TEXMAP0); // load texture object so its ready to use
@ -757,40 +664,44 @@ void RenderFrame(unsigned char *XBuf)
updateScaling = 0;
}
int width, height, t, xb;
memset(texturemem, 0, TEX_WIDTH * TEX_HEIGHT * 2);
unsigned short * texture = (unsigned short *)texturemem;
int width, height;
u16 *texture = (unsigned short *)texturemem;
u8 *src1 = XBuf;
u8 *src2,*src3,*src4;
// Now draw the texture
t = 0;
for (height = 0; height < 240; height += 4)
{
xb = (256 * height);
src1 += 768; /* line 4*N */
src2 = src1 + 256; /* line 4*(N+1) */
src3 = src2 + 256; /* line 4*(N+2) */
src4 = src3 + 256; /* line 4*(N+3) */
for (width = 0; width < 256; width += 4)
{
// Row one
texture[t++] = rgb565[XBuf[xb + width + 0]];
texture[t++] = rgb565[XBuf[xb + width + 1]];
texture[t++] = rgb565[XBuf[xb + width + 2]];
texture[t++] = rgb565[XBuf[xb + width + 3]];
*texture++ = rgb565[*src1++];
*texture++ = rgb565[*src1++];
*texture++ = rgb565[*src1++];
*texture++ = rgb565[*src1++];
// Row two
texture[t++] = rgb565[XBuf[xb + 256 + width + 0]];
texture[t++] = rgb565[XBuf[xb + 256 + width + 1]];
texture[t++] = rgb565[XBuf[xb + 256 + width + 2]];
texture[t++] = rgb565[XBuf[xb + 256 + width + 3]];
*texture++ = rgb565[*src2++];
*texture++ = rgb565[*src2++];
*texture++ = rgb565[*src2++];
*texture++ = rgb565[*src2++];
// Row three
texture[t++] = rgb565[XBuf[xb + 512 + width + 0]];
texture[t++] = rgb565[XBuf[xb + 512 + width + 1]];
texture[t++] = rgb565[XBuf[xb + 512 + width + 2]];
texture[t++] = rgb565[XBuf[xb + 512 + width + 3]];
*texture++ = rgb565[*src3++];
*texture++ = rgb565[*src3++];
*texture++ = rgb565[*src3++];
*texture++ = rgb565[*src3++];
// Row four
texture[t++] = rgb565[XBuf[xb + 768 + width + 0]];
texture[t++] = rgb565[XBuf[xb + 768 + width + 1]];
texture[t++] = rgb565[XBuf[xb + 768 + width + 2]];
texture[t++] = rgb565[XBuf[xb + 768 + width + 3]];
*texture++ = rgb565[*src4++];
*texture++ = rgb565[*src4++];
*texture++ = rgb565[*src4++];
*texture++ = rgb565[*src4++];
}
}

View File

@ -32,7 +32,6 @@ struct st_palettes {
extern struct st_palettes palettes[];
extern int FDSSwitchRequested;
extern int vmode_60hz;
extern bool progressive;
#endif