+ improved GUI engine (more flexibility)

+ improved Menu transition effects
+ added support for ogg background music
+ improved ROM Selection Menu (automatic text scrolling, wiimote support, ...)
+ changed arrow buttons aspect (feel better now ?)
+ minor bufgixes and menu adjustments
This commit is contained in:
ekeeke31 2009-04-19 22:31:08 +00:00
parent a01bd4f375
commit 39194bfaf3
26 changed files with 1624 additions and 900 deletions

View File

@ -20,7 +20,7 @@ BUILD := build_cube
SOURCES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \ SOURCES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \
source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds
INCLUDES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \ INCLUDES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \
source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds build_cube source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation
@ -34,7 +34,7 @@ LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project # any extra libraries we wish to link with the project
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
LIBS := -lpng -lfat -lasnd -logc -lm -lz LIBS := -lpng -lfat -ltremor -lasnd -logc -lm -lz
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing
@ -66,6 +66,7 @@ SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm))) PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm)))
OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg)))
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C # use CXX for linking C++ projects, CC for standard C
@ -77,8 +78,8 @@ else
endif endif
export OFILES := $(addsuffix .o,$(BINFILES)) \ export OFILES := $(addsuffix .o,$(BINFILES)) \
$(PNGFILES:.png=.png.o) $(PCMFILES:.pcm=.pcm.o) $(OGGFILES:.ogg=.ogg.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(PNGFILES:.png=.png.o) $(PCMFILES:.pcm=.pcm.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -135,6 +136,10 @@ $(OUTPUT).elf: $(OFILES)
@echo $(notdir $<) @echo $(notdir $<)
$(bin2o) $(bin2o)
%.ogg.o : %.ogg
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS) -include $(DEPENDS)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -20,7 +20,7 @@ BUILD := build_wii
SOURCES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \ SOURCES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \
source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds
INCLUDES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \ INCLUDES := source source/m68k source/z80 source/sound source/sound/SRC source/ntsc source/cart_hw source/cart_hw/svp \
source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds build_wii source/gx source/gx/gui source/gx/fileio source/gx/images source/gx/sounds
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation
@ -34,7 +34,7 @@ LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project # any extra libraries we wish to link with the project
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
LIBS := -lpng -ldi -lfat -lasnd -lwiiuse -lbte -logc -lm -lz LIBS := -lpng -ldi -lfat -ltremor -lasnd -lwiiuse -lbte -logc -lm -lz
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing
@ -52,7 +52,7 @@ ifneq ($(BUILD),$(notdir $(CURDIR)))
export OUTPUT := $(CURDIR)/$(TARGET) export OUTPUT := $(CURDIR)/$(TARGET)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) $(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD) export DEPSDIR := $(CURDIR)/$(BUILD)
@ -66,6 +66,7 @@ SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png))) PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm))) PCMFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pcm)))
OGGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.ogg)))
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C # use CXX for linking C++ projects, CC for standard C
@ -77,8 +78,8 @@ else
endif endif
export OFILES := $(addsuffix .o,$(BINFILES)) \ export OFILES := $(addsuffix .o,$(BINFILES)) \
$(PNGFILES:.png=.png.o) $(PCMFILES:.pcm=.pcm.o) $(OGGFILES:.ogg=.ogg.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
$(PNGFILES:.png=.png.o) $(PCMFILES:.pcm=.pcm.o) \
$(sFILES:.s=.o) $(SFILES:.S=.o) $(sFILES:.s=.o) $(SFILES:.S=.o)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -135,6 +136,10 @@ $(OUTPUT).elf: $(OFILES)
@echo $(notdir $<) @echo $(notdir $<)
$(bin2o) $(bin2o)
%.ogg.o : %.ogg
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS) -include $(DEPENDS)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -85,9 +85,9 @@ void config_setDefault(void)
config.filter = 1; config.filter = 1;
/* system options */ /* system options */
config.freeze_auto = -1; config.state_auto = -1;
#ifdef HW_RVL #ifdef HW_RVL
config.sram_auto = 0; /* assume we always got SDCARD */ config.sram_auto = 0; /* let's assume we always have a FAT device by default */
#else #else
config.sram_auto = -1; config.sram_auto = -1;
#endif #endif

View File

@ -37,7 +37,7 @@ typedef struct
uint8 filter; uint8 filter;
uint8 hq_fm; uint8 hq_fm;
int8 sram_auto; int8 sram_auto;
int8 freeze_auto; int8 state_auto;
uint8 region_detect; uint8 region_detect;
uint8 force_dtack; uint8 force_dtack;
uint8 bios_enabled; uint8 bios_enabled;

View File

@ -53,23 +53,23 @@ int ManageState(u8 direction, u8 device);
* *
* *
*****************************************************************************/ *****************************************************************************/
void memfile_autoload() void memfile_autoload(s8 autosram, s8 autostate)
{ {
/* this should be transparent to the user */ /* this should be transparent to the user */
SILENT = 1; SILENT = 1;
/* SRAM */ /* SRAM */
if (config.sram_auto != -1) if (autosram != -1)
ManageSRAM(1,config.sram_auto); ManageSRAM(1,autosram);
/* STATE */ /* STATE */
if (config.freeze_auto != -1) if (autostate != -1)
ManageState(1,config.freeze_auto); ManageState(1,autostate);
SILENT = 0; SILENT = 0;
} }
void memfile_autosave() void memfile_autosave(s8 autosram, s8 autostate)
{ {
int crccheck = crc32 (0, sram.sram, 0x10000); int crccheck = crc32 (0, sram.sram, 0x10000);
@ -77,12 +77,12 @@ void memfile_autosave()
SILENT = 1; SILENT = 1;
/* SRAM */ /* SRAM */
if ((config.sram_auto != -1) && (crccheck != sram.crc)) if ((autosram != -1) && (crccheck != sram.crc))
ManageSRAM(0, config.sram_auto); ManageSRAM(0, autosram);
/* STATE */ /* STATE */
if (config.freeze_auto != -1) if (autostate != -1)
ManageState(0,config.freeze_auto); ManageState(0,autostate);
SILENT = 0; SILENT = 0;
} }

View File

@ -33,8 +33,8 @@
#endif #endif
/* this is emulator specific ! */ /* this is emulator specific ! */
#define PAGESIZE 13 #define PAGESIZE 11
#define PAGEOFFSET 86 #define PAGEOFFSET 120
/* Global Variables */ /* Global Variables */
@ -49,6 +49,82 @@ int haveFATdir = 0;
FILEENTRIES filelist[MAXFILES]; FILEENTRIES filelist[MAXFILES];
/*****************************************************************************/
/* GUI Buttons data */
/*****************************************************************************/
static butn_data arrow_up_data =
{
{NULL,NULL},
{Button_up_png,Button_up_over_png}
};
static butn_data arrow_down_data =
{
{NULL,NULL},
{Button_down_png,Button_down_over_png}
};
/*****************************************************************************/
/* GUI Buttons */
/*****************************************************************************/
static gui_butn arrow_up = {&arrow_up_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,14,76,360,32};
static gui_butn arrow_down = {&arrow_down_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,14,368,360,32};
/*****************************************************************************/
/* GUI helpers */
/*****************************************************************************/
static gui_item action_cancel =
{
#ifdef HW_RVL
NULL,Key_B_wii_png,"","Previous",10,422,28,28
#else
NULL,Key_B_gcn_png,"","Previous",10,422,28,28
#endif
};
static gui_item action_select =
{
#ifdef HW_RVL
NULL,Key_A_wii_png,"","Load ROM file",602,422,28,28
#else
NULL,Key_A_gcn_png,"","Load ROM file",602,422,28,28
#endif
};
/*****************************************************************************/
/* GUI Background images */
/*****************************************************************************/
static gui_image bg_filesel[9] =
{
{NULL,Bg_main_png,IMAGE_VISIBLE,356,144,348,288,255,{0,0},{0,0}},
{NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255,{0,0},{0,0}},
{NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255,{0,0},{0,0}},
{NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255,{0,0},{0,0}},
{NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255,{0,0},{0,0}},
{NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,200,{0,0},{0,0}},
{NULL,Frame_s2_png,0,384,264,248,140,200,{0,0},{0,0}},
{NULL,Snap_empty_png,IMAGE_VISIBLE,422,114,164,116,255,{0,0},{0,0}},
{NULL,Snap_frame_png,IMAGE_VISIBLE,388,112,236,148,255,{0,0},{0,0}}
};
/*****************************************************************************/
/* GUI Descriptor */
/*****************************************************************************/
static gui_menu menu_browser =
{
"ROM Selection",
-1,0,
0,0,9,
{0,0},
NULL,
NULL,
bg_filesel,
{&action_cancel, &action_select},
{&arrow_up,&arrow_down},
FALSE
};
/*************************************************************************** /***************************************************************************
* FileSortCallback (Marty Disibio) * FileSortCallback (Marty Disibio)
* *
@ -84,186 +160,195 @@ int FileSortCallback(const void *f1, const void *f2)
* ROM size is returned * ROM size is returned
* *
****************************************************************************/ ****************************************************************************/
int FileSelector(unsigned char *buffer) int FileSelector(unsigned char *buffer)
{ {
#ifdef HW_RVL
int x,y;
gui_butn *button;
#endif
short p; short p;
// int redraw = 1; int ret,i,yoffset,string_offset;
int go_up = 0; int go_up = 0;
int quit =0; int quit =0;
int ret;
int i,size;
int yoffset;
char text[MAXJOLIET+2]; char text[MAXJOLIET+2];
FILE *xml; char fname[MAXPATHLEN];
FILE *snap; FILE *xml,*snap;
#ifdef HW_RVL /* Initialize Menu */
/* allocate wiimote pointer data (only done once) */ gui_menu *m = &menu_browser;
// gx_texture *pointer = gxTextureOpenPNG(generic_point_png); GUI_InitMenu(m);
#endif
/* allocate background overlay texture */ /* Initialize directory icon */
gui_image *overlay = &bg_overlay_line; gui_image dir_icon;
if (!overlay->texture) overlay->texture = gxTextureOpenPNG(overlay->data); dir_icon.texture = gxTextureOpenPNG(Browser_dir_png);
dir_icon.w = dir_icon.texture->width;
dir_icon.h = dir_icon.texture->height;
dir_icon.x = 26;
dir_icon.y = PAGEOFFSET;
/* allocate background image texture */ /* Initialize selection bar */
gui_image *bg = &bg_right; gui_image bar_over;
if (!bg->texture) bg->texture = gxTextureOpenPNG(bg->data); bar_over.texture = gxTextureOpenPNG(Overlay_bar_png);
bar_over.w = bar_over.texture->width;
bar_over.h = bar_over.texture->height;
bar_over.x = 22;
bar_over.y = -(bar_over.h - dir_icon.h)/2;
/* allocate logo texture */ /* Initialize star icons */
gui_image *logo = &logo_small; //gx_texture *star_full = gxTextureOpenPNG(Star_full_png);
if (!logo->texture) logo->texture = gxTextureOpenPNG(logo->data); //gx_texture *star_empty = gxTextureOpenPNG(Star_empty_png);
/* allocate generic elements textures */
gui_image *frames[2] = {&left_frame,&right_frame};
gui_image *banners[2] = {&top_banner,&bottom_banner};
gui_item *helpers[2] = {&action_cancel, &action_select};
for (i=0; i<2; i++)
{
/* frames */
if (!frames[i]->texture) frames[i]->texture = gxTextureOpenPNG(frames[i]->data);
/* banners */
if (!banners[i]->texture) banners[i]->texture = gxTextureOpenPNG(banners[i]->data);
/* key helpers */
if (!helpers[i]->texture) helpers[i]->texture = gxTextureOpenPNG(helpers[i]->data);
}
/* snapshots */
gx_texture *snap_frame = gxTextureOpenPNG(Snap_frame_png);
gx_texture *snap_empty = gxTextureOpenPNG(Snap_empty_png);
/* selection bar */
gx_texture *bar_over = gxTextureOpenPNG(Overlay_bar_png);
/* directory icon */
gx_texture *dir_icon = gxTextureOpenPNG(Browser_dir_png);
#ifdef NEW_GUI
/* arrows */
gx_texture *arrow_up = gxTextureOpenPNG(Button_up_png);
gx_texture *arrow_up_over = gxTextureOpenPNG(Button_up_over_png);
gx_texture *arrow_down = gxTextureOpenPNG(Button_down_png);
gx_texture *arrow_down_over = gxTextureOpenPNG(Button_down_over_png);
/* stars */
gx_texture *star_full = gxTextureOpenPNG(Star_full_png);
gx_texture *star_empty = gxTextureOpenPNG(Star_empty_png);
#endif
while (!quit) while (!quit)
{ {
/* Draw menu*/ /* get ROM filename without extension */
gxClearScreen ((GXColor)BACKGROUND); sprintf (text, "%s", filelist[selection].filename);
text[strlen(text) - 4] = 0;
gxDrawRepeat(overlay->texture,overlay->x,overlay->y,overlay->w,overlay->h);
gxDrawTexture(bg->texture,bg->x,bg->y,bg->w,bg->h,255);
gxDrawTexture(banners[0]->texture,banners[0]->x,banners[0]->y,banners[0]->w,banners[0]->h,255);
gxDrawTexture(banners[1]->texture,banners[1]->x,banners[1]->y,banners[1]->w,banners[1]->h,255);
gxDrawTexture(helpers[0]->texture,helpers[0]->x,helpers[0]->y,helpers[0]->w,helpers[0]->h,255);
gxDrawTexture(helpers[1]->texture,helpers[1]->x,helpers[1]->y,helpers[1]->w,helpers[1]->h,255);
gxDrawTexture(logo->texture,logo->x,logo->y,logo->w,logo->h,255);
/* Draw title & helps */
FONT_alignLeft("ROM Selection", 22,10,56, (GXColor)WHITE);
FONT_alignLeft("Back", 16, helpers[0]->x+helpers[0]->w+6,helpers[0]->y+(helpers[0]->h-16)/2 + 16, (GXColor)WHITE);
FONT_alignRight("Load ROM File", 16, helpers[1]->x - 6, helpers[1]->y+(helpers[1]->h-16)/2 + 16, (GXColor)WHITE);
gxDrawTexture(snap_empty,422,114,snap_empty->width,snap_empty->height,255);
gxDrawTexture(frames[0]->texture,frames[0]->x,frames[0]->y,frames[0]->w,frames[0]->h,200);
#ifdef NEW_GUI
/* ROM database informations */ /* ROM database informations */
strncpy(fname, filelist[selection].filename, strlen(filelist[selection].filename) - 4); sprintf (fname, "%s/db/%s.xml", DEFAULT_PATH, text);
sprintf(fname, "%s/db/%s.xml",DEFAULT_PATH,fname);
xml = fopen(fname, "rb"); xml = fopen(fname, "rb");
if (xml) if (xml)
{ {
gxDrawTexture(frames[1]->texture,frames[1]->x,frames[1]->y,frames[1]->w,frames[1]->h,200); bg_filesel[6].state |= IMAGE_VISIBLE;
fclose(xml); /* TODO */ fclose(xml); /* TODO */
} }
else
{
bg_filesel[6].state &= ~IMAGE_VISIBLE;
}
/* ROM snapshot */ /* ROM snapshot */
strncpy(fname, filelist[selection].filename, strlen(filelist[selection].filename) - 4); sprintf (fname, "%s/snaps/%s.png", DEFAULT_PATH, text);
sprintf(fname, "%s/snap/%s.png",DEFAULT_PATH,fname);
snap = fopen(fname, "rb"); snap = fopen(fname, "rb");
if (snap) if (snap)
{ {
fclose(snap); /* TODO */ fclose(snap); /* TODO */
} }
else
{
gxDrawTexture(snap_empty,422,114,snap_empty->width,snap_empty->height,255);
}
#endif
/* Cartridge picture */ /* Draw menu*/
gxDrawTexture(snap_frame,388,112,snap_frame->width,snap_frame->height,255); GUI_DrawMenu(m);
/* File list */ /* Draw Files list */
gxDrawTexture(frames[0]->texture,frames[0]->x,frames[0]->y,frames[0]->w,frames[0]->h,200); yoffset = PAGEOFFSET;
yoffset = 86;
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++) for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
{ {
sprintf (text, "%s", filelist[i].filename + filelist[i].filename_offset);
if (i == selection) if (i == selection)
{ {
gxDrawTexture(bar_over,22,yoffset - ((bar_over->height - dir_icon->height)/2), bar_over->width,bar_over->height,255); /* scrolling text */
} string_offset = filelist[i].filename_offset/10;
if (string_offset >= strlen(filelist[i].filename))
{
string_offset = 0;
filelist[i].filename_offset = 0;
}
sprintf(text, "%s ",filelist[i].filename + string_offset);
strncat(text, filelist[i].filename, string_offset);
if (filelist[i].flags) gxDrawTexture(bar_over.texture,bar_over.x,yoffset+bar_over.y,bar_over.w,bar_over.h,255);
{ if (filelist[i].flags)
/* directory icon */ {
gxDrawTexture(dir_icon,26,yoffset,dir_icon->width,dir_icon->height,255); /* directory icon */
FONT_alignLeft(text, 16,26+dir_icon->width+6,yoffset + 16, (GXColor)WHITE); gxDrawTexture(dir_icon.texture,dir_icon.x-1,yoffset-1,dir_icon.w+2,dir_icon.h+2,255);
if (FONT_write(text,18,dir_icon.x+dir_icon.w+6,yoffset+16,bar_over.w-dir_icon.w-14,(GXColor)WHITE))
{
filelist[i].filename_offset ++;
}
}
else
{
if (FONT_write(text,18,dir_icon.x,yoffset+16,bar_over.w-8,(GXColor)WHITE))
{
filelist[i].filename_offset ++;
}
}
} }
else else
{ {
FONT_alignLeft(text, 16,26,yoffset+16, (GXColor)WHITE); filelist[i].filename_offset = 0;
if (filelist[i].flags)
{
/* directory icon */
gxDrawTexture(dir_icon.texture,dir_icon.x,yoffset,dir_icon.w,dir_icon.h,255);
FONT_write(filelist[i].filename,16,dir_icon.x+dir_icon.w+6,yoffset+16,bar_over.w-dir_icon.w-14,(GXColor)WHITE);
}
else
{
FONT_write(filelist[i].filename,16,dir_icon.x,yoffset+16,bar_over.w-8,(GXColor)WHITE);
}
} }
yoffset += 20; yoffset += 22;
} }
#ifdef HW_RVL
if (Shutdown)
{
gxTextureClose(&w_pointer);
GUI_DeleteMenu(m);
shutdown();
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
}
else if (m_input.ir.valid)
{
/* get cursor position */
x = m_input.ir.x;
y = m_input.ir.y;
/* draw wiimote pointer */
gxResetAngle(m_input.ir.angle);
gxDrawTexture(w_pointer, x-w_pointer->width/2, y-w_pointer->height/2, w_pointer->width, w_pointer->height,255);
gxResetAngle(0.0);
/* find selected item */
yoffset = PAGEOFFSET;
m->selected = m->max_buttons + 2;
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
{
if ((x<=380)&&(y>=yoffset)&&(y<(yoffset+22)))
{
selection = i;
m->selected = -1;
break;
}
yoffset += 22;
}
/* find selected button */
for (i=0; i<2; i++)
{
button = m->arrows[i];
if (button)
{
if (button->state & BUTTON_VISIBLE)
{
if ((x>=button->x)&&(x<=(button->x+button->w))&&(y>=button->y)&&(y<=(button->y+button->h)))
{
m->selected = m->max_buttons + i;
break;
}
}
}
}
}
else
{
/* reset indicator */
m->selected = -1;
}
#endif
/* copy EFB to XFB */ /* copy EFB to XFB */
gxSetScreen (); gxSetScreen ();
p = m_input.keys; p = m_input.keys;
/* scroll displayed filename */
if (p & PAD_BUTTON_LEFT)
{
if (filelist[selection].filename_offset > 0)
{
filelist[selection].filename_offset --;
//redraw = 1;
}
}
else if (p & PAD_BUTTON_RIGHT)
{
size = 0;
for (i=filelist[selection].filename_offset; i<strlen(filelist[selection].filename); i++)
size += font_size[(int)filelist[selection].filename[i]];
if (size > back_framewidth)
{
filelist[selection].filename_offset ++;
//redraw = 1;
}
}
/* highlight next item */ /* highlight next item */
else if (p & PAD_BUTTON_DOWN) if (p & PAD_BUTTON_DOWN)
{ {
filelist[selection].filename_offset = 0; filelist[selection].filename_offset = 0;
selection++; selection++;
if (selection == maxfiles) selection = offset = 0; if (selection == maxfiles) selection = offset = 0;
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
//redraw = 1;
} }
/* highlight previous item */ /* highlight previous item */
@ -278,7 +363,6 @@ int FileSelector(unsigned char *buffer)
} }
if (selection < offset) offset -= PAGESIZE; if (selection < offset) offset -= PAGESIZE;
if (offset < 0) offset = 0; if (offset < 0) offset = 0;
//redraw = 1;
} }
/* go back one page */ /* go back one page */
@ -293,7 +377,6 @@ int FileSelector(unsigned char *buffer)
} }
if (selection < offset) offset -= PAGESIZE; if (selection < offset) offset -= PAGESIZE;
if (offset < 0) offset = 0; if (offset < 0) offset = 0;
//redraw = 1;
} }
/* go forward one page */ /* go forward one page */
@ -303,18 +386,17 @@ int FileSelector(unsigned char *buffer)
selection += PAGESIZE; selection += PAGESIZE;
if (selection > maxfiles - 1) selection = offset = 0; if (selection > maxfiles - 1) selection = offset = 0;
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE; if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
//redraw = 1;
} }
/* quit */ /* quit */
if (p & PAD_TRIGGER_Z) else if (p & PAD_TRIGGER_Z)
{ {
filelist[selection].filename_offset = 0; filelist[selection].filename_offset = 0;
quit = 2; quit = 2;
} }
/* open selected file or directory */ /* open selected file or directory */
if ((p & PAD_BUTTON_A) || (p & PAD_BUTTON_B)) else if ((p & PAD_BUTTON_A) || (p & PAD_BUTTON_B))
{ {
filelist[selection].filename_offset = 0; filelist[selection].filename_offset = 0;
go_up = 0; go_up = 0;
@ -325,63 +407,71 @@ int FileSelector(unsigned char *buffer)
go_up = 1; go_up = 1;
selection = useFAT ? 0 : 1; selection = useFAT ? 0 : 1;
} }
#ifdef HW_RVL
/*** This is directory ***/
if (filelist[selection].flags)
{
/* get new directory */
if (useFAT) ret =FAT_UpdateDir(go_up);
else ret = DVD_UpdateDir(go_up);
/* get new entry list or quit */
if (ret)
{
if (useFAT) maxfiles = FAT_ParseDirectory();
else maxfiles = DVD_ParseDirectory();
}
else
{
quit = 2;
}
}
/*** This is a file ***/
else else
{ {
/* root directory ? */ /* arrow buttons selected */
if (go_up) quit = 2; if (m->selected == m->max_buttons) /* up arrow */
else quit = 1; {
filelist[selection].filename_offset = 0;
selection--;
if (selection < 0)
{
selection = maxfiles - 1;
offset = selection - PAGESIZE + 1;
}
if (selection < offset) offset -= PAGESIZE;
if (offset < 0) offset = 0;
}
else if (m->selected == (m->max_buttons+1)) /* down arrow */
{
filelist[selection].filename_offset = 0;
selection++;
if (selection == maxfiles) selection = offset = 0;
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
}
}
#endif
/* ensure we are in focus area */
if (m->selected < m->max_buttons)
{
/*** This is directory ***/
if (filelist[selection].flags)
{
/* get new directory */
if (useFAT) ret =FAT_UpdateDir(go_up);
else ret = DVD_UpdateDir(go_up);
/* get new entry list or quit */
if (ret)
{
if (useFAT) maxfiles = FAT_ParseDirectory();
else maxfiles = DVD_ParseDirectory();
}
else
{
quit = 2;
}
}
/*** This is a file ***/
else
{
/* root directory ? */
if (go_up) quit = 2;
else quit = 1;
}
} }
//redraw = 1;
} }
} }
#ifdef HW_RVL /* Delete Menu */
/* allocate wiimote pointer data (only done once) */ GUI_DeleteMenu(m);
// gxTextureClose(&pointer); gxTextureClose(&bar_over.texture);
#endif gxTextureClose(&dir_icon.texture);
//gxTextureClose(&star_full);
gxTextureClose(&overlay->texture); //gxTextureClose(&star_empty);
gxTextureClose(&bg->texture);
gxTextureClose(&logo->texture);
for (i=0; i<2; i++)
{
gxTextureClose(&frames[i]->texture);
gxTextureClose(&banners[i]->texture);
gxTextureClose(&helpers[i]->texture);
}
gxTextureClose(&snap_frame);
gxTextureClose(&snap_empty);
gxTextureClose(&bar_over);
gxTextureClose(&dir_icon);
#ifdef NEW_GUI
gxTextureClose(&arrow_up);
gxTextureClose(&arrow_up_over);
gxTextureClose(&arrow_down);
gxTextureClose(&arrow_down_over);
gxTextureClose(&star_full);
gxTextureClose(&star_empty);
#endif
if (quit == 2) return 0; if (quit == 2) return 0;
else if (useFAT) return FAT_LoadFile(buffer); else if (useFAT) return FAT_LoadFile(buffer);

View File

@ -164,15 +164,41 @@ void WriteCentre_HL( int y, char *string)
WriteCentre(y, string); WriteCentre(y, string);
} }
void FONT_alignLeft(char *string, int size, int x, int y, GXColor color) int FONT_write(char *string, int size, int x, int y, int max_width, GXColor color)
{ {
x -= (vmode->fbWidth / 2); x -= (vmode->fbWidth / 2);
y -= (vmode->efbHeight / 2); y -= (vmode->efbHeight / 2);
int w, ox = x;
while (*string)
{
w = (font_size[(u8)*string] * size) / fheight;
if ((x + w) <= (ox + max_width))
{
DrawChar(*string, x, y, size,color);
x += w;
string++;
}
else return 1;
}
return 0;
}
void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color)
{
int i;
u16 width = 0;
for (i=0; i<strlen(string); i++)
width += (font_size[(u8)string[i]] * size) / fheight;
x1 += (x2 - x1 - width - vmode->fbWidth) / 2;
y -= (vmode->efbHeight / 2);
while (*string) while (*string)
{ {
DrawChar(*string, x, y, size,color); DrawChar(*string, x1, y, size,color);
x += (font_size[(u8)*string++] * size) / fheight; x1 += (font_size[(u8)*string++] * size) / fheight;
} }
} }
@ -194,24 +220,6 @@ void FONT_alignRight(char *string, int size, int x, int y, GXColor color)
} }
} }
void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color)
{
int i;
u16 width = 0;
for (i=0; i<strlen(string); i++)
width += (font_size[(u8)string[i]] * size) / fheight;
x1 += (x2 - x1 - width - vmode->fbWidth) / 2;
y -= (vmode->efbHeight / 2);
while (*string)
{
DrawChar(*string, x1, y, size,color);
x1 += (font_size[(u8)*string++] * size) / fheight;
}
}
/**************************************************************************** /****************************************************************************
* Draw functions (FrameBuffer) * Draw functions (FrameBuffer)
* *

View File

@ -27,9 +27,9 @@
extern int FONT_Init(void); extern int FONT_Init(void);
extern void FONT_Shutdown(void); extern void FONT_Shutdown(void);
extern void FONT_alignLeft(char *string, int size, int x, int y, GXColor color); extern int FONT_write(char *string, int size, int x, int y, int max_width, GXColor color);
extern void FONT_alignRight(char *string, int size, int x, int y, GXColor color);
extern void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color); extern void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color);
extern void FONT_alignRight(char *string, int size, int x, int y, GXColor color);
extern void WaitButtonA (); extern void WaitButtonA ();

View File

@ -26,6 +26,9 @@
#include "font.h" #include "font.h"
#include "menu.h" #include "menu.h"
#include "intro_pcm.h"
#include <asndlib.h>
/* /*
* This is the legal stuff - which must be shown at program startup * This is the legal stuff - which must be shown at program startup
* Any derivative work MUST include the same textual output. * Any derivative work MUST include the same textual output.
@ -113,5 +116,11 @@ void legal ()
} }
gxSetScreen (); gxSetScreen ();
ASND_Init();
ASND_Pause(0);
int voice = ASND_GetFirstUnusedVoice();
ASND_SetVoice(voice,VOICE_MONO_16BIT,44100,0,(u8 *)intro_pcm,intro_pcm_size,200,200,NULL);
sleep (2); sleep (2);
ASND_Pause(1);
ASND_End();
} }

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,23 @@
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#endif #endif
/*****************************************************************************/
/* GUI Buttons state */
/*****************************************************************************/
#define BUTTON_VISIBLE 0x01
#define BUTTON_OVER_SFX 0x10
#define BUTTON_SELECT_SFX 0x20
/*****************************************************************************/
/* GUI Image state */
/*****************************************************************************/
#define IMAGE_VISIBLE 0x01
#define IMAGE_REPEAT 0x02
#define IMAGE_FADE 0x10
#define IMAGE_SLIDE_X 0x20
#define IMAGE_SLIDE_Y 0x40
/*****************************************************************************/ /*****************************************************************************/
/* GUI png data */ /* GUI png data */
/*****************************************************************************/ /*****************************************************************************/
@ -120,27 +137,28 @@ typedef struct
/* Item descriptor*/ /* Item descriptor*/
typedef struct typedef struct
{ {
gx_texture *texture; /* temporary texture data */ gx_texture *texture; /* temporary texture data */
const u8 *data; /* pointer to png image data (items icon only) */ const u8 *data; /* pointer to png image data (items icon only) */
char text[64]; /* item string (items list only) */ char text[64]; /* item string (items list only) */
char comment[64]; /* item comment */ char comment[64]; /* item comment */
u16 x; /* button image or text X position (upper left corner) */ u16 x; /* item image or text X position (upper left corner) */
u16 y; /* button image or text Y position (upper left corner) */ u16 y; /* item image or text Y position (upper left corner) */
u16 w; /* button image or text width */ u16 w; /* item image or text width */
u16 h; /* button image or text height */ u16 h; /* item image or text height */
} gui_item; } gui_item;
/* Button descriptor */ /* Button descriptor */
typedef struct typedef struct
{ {
gx_texture *texture[2]; /* temporary texture datas */ gx_texture *texture[2]; /* temporary texture datas */
const u8 *image[2]; /* pointer to png image datas (default) */ const u8 *image[2]; /* pointer to png image datas (default) */
} butn_data; } butn_data;
/* Button descriptor */ /* Button descriptor */
typedef struct typedef struct
{ {
butn_data *data; /* pointer to button image/texture data */ butn_data *data; /* pointer to button image/texture data */
u8 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */
u16 x; /* button image X position (upper left corner) */ u16 x; /* button image X position (upper left corner) */
u16 y; /* button image Y position (upper left corner) */ u16 y; /* button image Y position (upper left corner) */
u16 w; /* button image pixels width */ u16 w; /* button image pixels width */
@ -150,32 +168,34 @@ typedef struct
/* Image descriptor */ /* Image descriptor */
typedef struct typedef struct
{ {
gx_texture *texture; /* temporary texture data */ gx_texture *texture; /* temporary texture data */
const u8 *data; /* pointer to png image data */ const u8 *data; /* pointer to png image data */
u16 x; /* button image or text X position (upper left corner) */ u8 state; /* image state (VISIBLE) */
u16 y; /* button image or text Y position (upper left corner) */ u16 x; /* image X position (upper left corner) */
u16 w; /* button image or text width */ u16 y; /* image Y position (upper left corner) */
u16 h; /* button image or text height */ u16 w; /* image width */
u16 h; /* image height */
u8 alpha; /* alpha transparency */
u16 xrange[2]; /* image X range (slide effect) */
u16 yrange[2]; /* image Y range (slide effect) */
} gui_image; } gui_image;
/* Menu descriptor */ /* Menu descriptor */
typedef struct typedef struct
{ {
char title[64]; /* menu title */ char title[64]; /* menu title */
s8 selected; /* index of selected item */ s8 selected; /* index of selected item */
u8 offset; /* items list offset */ u8 offset; /* items list offset */
u8 max_items; /* total number of items */ u8 max_items; /* total number of items */
u8 max_buttons; /* total number of buttons (not necessary identical) */ u8 max_buttons; /* total number of buttons */
u8 shift; /* number of items by line */ u8 max_images; /* total number of background images */
gui_item *items; /* menu items table */ u8 shift[2]; /* number of buttons per line */
gui_butn *buttons; /* menu buttons table */ gui_item *items; /* menu items */
gui_image *overlay; /* overlay image */ gui_butn *buttons; /* menu buttons */
gui_image *background; /* background image */ gui_image *bg_images; /* background images */
gui_image *logo; /* logo image */ gui_item *helpers[2]; /* left & right key comments */
gui_image *frames[2]; /* windows (max. 2) */ gui_butn *arrows[2]; /* arrows buttons */
gui_image *banners[2]; /* bottom & top banners */ bool screenshot; /* use gamescreen as background */
gui_item *helpers[2]; /* left & right key comments */
gui_butn *arrows[2]; /* items list up & down arrows */
} gui_menu; } gui_menu;
@ -183,25 +203,15 @@ typedef struct
extern u8 SILENT; extern u8 SILENT;
extern t_input_menu m_input; extern t_input_menu m_input;
/*****************************************************************************/ #ifdef HW_RVL
/* Common GUI images */ extern gx_texture *w_pointer;
/*****************************************************************************/ #endif
extern gui_image logo_main;
extern gui_image logo_small;
extern gui_image top_banner;
extern gui_image bottom_banner;
extern gui_image main_banner;
extern gui_image bg_right;
extern gui_image bg_center;
extern gui_image bg_overlay_line;
extern gui_image left_frame;
extern gui_image right_frame;
/*****************************************************************************/
/* Common GUI items */ extern void MainMenu(void);
/*****************************************************************************/ extern void GUI_InitMenu(gui_menu *menu);
extern gui_item action_cancel; extern void GUI_DeleteMenu(gui_menu *menu);
extern gui_item action_select; extern void GUI_DrawMenu(gui_menu *menu);
extern gui_item action_exit; extern int GUI_RunMenu(gui_menu *menu);
#endif #endif

354
source/gx/gui/oggplayer.c Normal file
View File

@ -0,0 +1,354 @@
/*
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
- The names of the contributors may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NO_SOUND
#include "oggplayer.h"
#include <gccore.h>
/* OGG control */
#define READ_SAMPLES 4096 // samples that it must read before to send
#define MAX_PCMOUT 4096 // minimum size to read ogg samples
typedef struct
{
OggVorbis_File vf;
vorbis_info *vi;
int current_section;
// OGG file operation
int fd;
int mode;
int eof;
int flag;
int volume;
int seek_time;
/* OGG buffer control */
short pcmout[2][READ_SAMPLES + MAX_PCMOUT * 2]; /* take 4k out of the data segment, not the stack */
int pcmout_pos;
int pcm_indx;
} private_data_ogg;
static private_data_ogg private_ogg;
// OGG thread control
#define STACKSIZE 8192
static u8 oggplayer_stack[STACKSIZE];
static lwpq_t oggplayer_queue;
static lwp_t h_oggplayer;
static int ogg_thread_running = 0;
static void ogg_add_callback(int voice)
{
if (ogg_thread_running <= 0)
{
SND_StopVoice(0);
return;
}
if (private_ogg.flag & 128)
return; // Ogg is paused
if (private_ogg.pcm_indx >= READ_SAMPLES)
{
if (SND_AddVoice(0,
(void *) private_ogg.pcmout[private_ogg.pcmout_pos],
private_ogg.pcm_indx << 1) == 0)
{
private_ogg.pcmout_pos ^= 1;
private_ogg.pcm_indx = 0;
private_ogg.flag = 0;
LWP_ThreadSignal(oggplayer_queue);
}
}
else
{
if (private_ogg.flag & 64)
{
private_ogg.flag &= ~64;
LWP_ThreadSignal(oggplayer_queue);
}
}
}
static void * ogg_player_thread(private_data_ogg * priv)
{
int first_time = 1;
ogg_thread_running = 0;
//init
LWP_InitQueue(&oggplayer_queue);
priv[0].vi = ov_info(&priv[0].vf, -1);
SND_Pause(0);
priv[0].pcm_indx = 0;
priv[0].pcmout_pos = 0;
priv[0].eof = 0;
priv[0].flag = 0;
priv[0].current_section = 0;
ogg_thread_running = 1;
while (!priv[0].eof)
{
long ret;
if (ogg_thread_running <= 0)
break;
if (priv[0].flag)
LWP_ThreadSleep(oggplayer_queue); // wait only when i have samples to send
if (ogg_thread_running <= 0)
break;
if (priv[0].flag == 0) // wait to all samples are sended
{
if (SND_TestPointer(0, priv[0].pcmout[priv[0].pcmout_pos])
&& SND_StatusVoice(0) != SND_UNUSED)
{
priv[0].flag |= 64;
continue;
}
if (priv[0].pcm_indx < READ_SAMPLES)
{
priv[0].flag = 3;
if (priv[0].seek_time >= 0)
{
ov_time_seek(&priv[0].vf, priv[0].seek_time);
priv[0].seek_time = -1;
}
ret
= ov_read(
&priv[0].vf,
(void *) &priv[0].pcmout[priv[0].pcmout_pos][priv[0].pcm_indx],
MAX_PCMOUT,/*0,2,1,*/&priv[0].current_section);
priv[0].flag &= 192;
if (ret == 0)
{
/* EOF */
if (priv[0].mode & 1)
ov_time_seek(&priv[0].vf, 0); // repeat
else
priv[0].eof = 1; // stops
//
}
else if (ret < 0)
{
/* error in the stream. Not a problem, just reporting it in
case we (the app) cares. In this case, we don't. */
if (ret != OV_HOLE)
{
if (priv[0].mode & 1)
ov_time_seek(&priv[0].vf, 0); // repeat
else
priv[0].eof = 1; // stops
}
}
else
{
/* we don't bother dealing with sample rate changes, etc, but
you'll have to*/
priv[0].pcm_indx += ret >> 1; //get 16 bits samples
}
}
else
priv[0].flag = 1;
}
if (priv[0].flag == 1)
{
if (SND_StatusVoice(0) == SND_UNUSED || first_time)
{
first_time = 0;
if (priv[0].vi->channels == 2)
{
SND_SetVoice(0, VOICE_STEREO_16BIT, priv[0].vi->rate, 0,
(void *) priv[0].pcmout[priv[0].pcmout_pos],
priv[0].pcm_indx << 1, priv[0].volume,
priv[0].volume, ogg_add_callback);
priv[0].pcmout_pos ^= 1;
priv[0].pcm_indx = 0;
priv[0].flag = 0;
}
else
{
SND_SetVoice(0, VOICE_MONO_16BIT, priv[0].vi->rate, 0,
(void *) priv[0].pcmout[priv[0].pcmout_pos],
priv[0].pcm_indx << 1, priv[0].volume,
priv[0].volume, ogg_add_callback);
priv[0].pcmout_pos ^= 1;
priv[0].pcm_indx = 0;
priv[0].flag = 0;
}
}
else
{
// if(priv[0].pcm_indx==0) priv[0].flag=0; // all samples sended
}
}
}
ov_clear(&priv[0].vf);
priv[0].fd = -1;
priv[0].pcm_indx = 0;
ogg_thread_running = 0;
return 0;
}
void StopOgg()
{
SND_StopVoice(0);
if (ogg_thread_running > 0)
{
ogg_thread_running = -2;
LWP_ThreadSignal(oggplayer_queue);
LWP_JoinThread(h_oggplayer, NULL);
while (((volatile int) ogg_thread_running) != 0)
{
;;;
}
}
}
int PlayOgg(int fd, int time_pos, int mode)
{
StopOgg();
ogg_thread_running = 0;
private_ogg.fd = fd;
private_ogg.mode = mode;
private_ogg.eof = 0;
private_ogg.volume = 127;
private_ogg.flag = 0;
private_ogg.seek_time = -1;
if (time_pos > 0)
private_ogg.seek_time = time_pos;
if (fd < 0)
{
private_ogg.fd = -1;
return -1;
}
if (ov_open((void *) &private_ogg.fd, &private_ogg.vf, NULL, 0) < 0)
{
mem_close(private_ogg.fd); // mem_close() can too close files from devices
private_ogg.fd = -1;
ogg_thread_running = -1;
return -1;
}
if (LWP_CreateThread(&h_oggplayer, (void *) ogg_player_thread,
&private_ogg, oggplayer_stack, STACKSIZE, 80) == -1)
{
ogg_thread_running = -1;
ov_clear(&private_ogg.vf);
private_ogg.fd = -1;
return -1;
}
LWP_ThreadSignal(oggplayer_queue);
while (((volatile int) ogg_thread_running) == 0)
{
;;;
}
return 0;
}
void PauseOgg(int pause)
{
if (pause)
{
private_ogg.flag |= 128;
}
else
{
if (private_ogg.flag & 128)
{
private_ogg.flag |= 64;
private_ogg.flag &= ~128;
if (ogg_thread_running > 0)
{
LWP_ThreadSignal(oggplayer_queue);
// while(((volatile int )private_ogg.flag)!=1 && ((volatile int )ogg_thread_running)>0) {;;;}
}
}
}
}
int StatusOgg()
{
if (ogg_thread_running <= 0)
return -1; // Error
if (private_ogg.eof)
return 255; // EOF
if (private_ogg.flag & 128)
return 2; // paused
return 1; // running
}
void SetVolumeOgg(int volume)
{
private_ogg.volume = volume;
SND_ChangeVolumeVoice(0, volume, volume);
}
s32 GetTimeOgg()
{
int ret;
if (ogg_thread_running <= 0)
return 0;
if (private_ogg.fd < 0)
return 0;
ret = ((s32) ov_time_tell(&private_ogg.vf));
if (ret < 0)
ret = 0;
return ret;
}
void SetTimeOgg(s32 time_pos)
{
if (time_pos >= 0)
private_ogg.seek_time = time_pos;
}
#endif

174
source/gx/gui/oggplayer.h Normal file
View File

@ -0,0 +1,174 @@
/*
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
- The names of the contributors may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef NO_SOUND
#ifndef __OGGPLAYER_H__
#define __OGGPLAYER_H__
#include <asndlib.h>
#include "tremor/ivorbiscodec.h"
#include "tremor/ivorbisfile.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define OGG_ONE_TIME 0
#define OGG_INFINITE_TIME 1
#define OGG_STATUS_RUNNING 1
#define OGG_STATUS_ERR -1
#define OGG_STATUS_PAUSED 2
#define OGG_STATUS_EOF 255
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* Player OGG functions */
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int PlayOgg(int fd, int time_pos, int mode);
Play an Ogg file. This file can be loaded from memory (mem_open(void *ogg, int size_ogg)) or from device with open("device:file.ogg",O_RDONLY,0);
NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail.
-- Params ---
fd: file descriptor from open() or mem_open()
time_pos: initial time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds
mode: Use OGG_ONE_TIME or OGG_INFINITE_TIME. When you use OGG_ONE_TIME the sound stops and StatusOgg() return OGG_STATUS_EOF
return: 0- Ok, -1 Error
*/
int PlayOgg(int fd, int time_pos, int mode);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void StopOgg();
Stop an Ogg file.
NOTE: The file is closed and the player thread is released
-- Params ---
*/
void StopOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void PauseOgg(int pause);
Pause an Ogg file.
-- Params ---
pause: 0 -> continue, 1-> pause
*/
void PauseOgg(int pause);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* int StatusOgg();
Return the Ogg status
-- Params ---
return: OGG_STATUS_RUNNING
OGG_STATUS_ERR -> not initialized?
OGG_STATUS_PAUSED
OGG_STATUS_EOF -> player stopped by End Of File
*/
int StatusOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void SetVolumeOgg(int volume);
Set the Ogg playing volume.
NOTE: it change the volume of voice 0 (used for the Ogg player)
-- Params ---
volume: 0 to 255 (max)
*/
void SetVolumeOgg(int volume);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* s32 GetTimeOgg();
Return the Ogg time from the starts of the file
-- Params ---
return: 0 -> Ok or error condition (you must ignore this value)
>0 -> time in milliseconds from the starts
*/
s32 GetTimeOgg();
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* void SetTimeOgg(s32 time_pos);
Set the time position
NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail.
-- Params ---
time_pos: time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds
*/
void SetTimeOgg(s32 time_pos);
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@ -22,8 +22,10 @@
***************************************************************************/ ***************************************************************************/
#include "shared.h" #include "shared.h"
//#include "Bg_music_ogg.h"
#include <asndlib.h> #include <asndlib.h>
#include <oggplayer.h>
/* DMA soundbuffers (required to be 32-bytes aligned) /* DMA soundbuffers (required to be 32-bytes aligned)
Length is dimensionned for one frame of emulation (see below) Length is dimensionned for one frame of emulation (see below)
@ -47,7 +49,7 @@ static int delta;
static u32 dma_sync; static u32 dma_sync;
/* audio DMA status */ /* audio DMA status */
static u8 audioStarted; static u8 audioStarted = 0;
/*** /***
AudioDmaCallback AudioDmaCallback
@ -126,6 +128,8 @@ void gx_audio_update(void)
void gx_audio_start(void) void gx_audio_start(void)
{ {
/* shutdown menu audio */ /* shutdown menu audio */
PauseOgg(1);
StopOgg();
ASND_Pause(1); ASND_Pause(1);
ASND_End(); ASND_End();
@ -163,11 +167,14 @@ void gx_audio_start(void)
***/ ***/
void gx_audio_stop(void) void gx_audio_stop(void)
{ {
/* shutdown sound emulation */ /* stop emulator audio */
AUDIO_StopDMA (); AUDIO_StopDMA ();
audioStarted = 0; audioStarted = 0;
/* start menu audio */ /* restart menu audio */
ASND_Init(); ASND_Init();
ASND_Pause(0); ASND_Pause(0);
PauseOgg(0);
// PlayOgg(mem_open((char *)Bg_music_ogg, Bg_music_ogg_size), 0, OGG_INFINITE_TIME);
//SetVolumeOgg(255);
} }

View File

@ -831,7 +831,7 @@ void gxDrawScreenshot(u8 alpha)
} }
} }
void gxDrawTexture(gx_texture *texture, int x, int y, int w, int h, u8 alpha) void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha)
{ {
if (!texture) return; if (!texture) return;
if (texture->data) if (texture->data)
@ -866,7 +866,7 @@ void gxDrawTexture(gx_texture *texture, int x, int y, int w, int h, u8 alpha)
} }
} }
void gxDrawRepeat(gx_texture *texture, int x, int y, int w, int h) void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha)
{ {
if (!texture) return; if (!texture) return;
if (texture->data) if (texture->data)
@ -888,16 +888,16 @@ void gxDrawRepeat(gx_texture *texture, int x, int y, int w, int h)
/* draw textured quad */ /* draw textured quad */
GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
GX_Position2s16(x,y+h); GX_Position2s16(x,y+h);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,alpha);
GX_TexCoord2f32(0.0, t); GX_TexCoord2f32(0.0, t);
GX_Position2s16(x+w,y+h); GX_Position2s16(x+w,y+h);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,alpha);
GX_TexCoord2f32(s, t); GX_TexCoord2f32(s, t);
GX_Position2s16(x+w,y); GX_Position2s16(x+w,y);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,alpha);
GX_TexCoord2f32(s, 0.0); GX_TexCoord2f32(s, 0.0);
GX_Position2s16(x,y); GX_Position2s16(x,y);
GX_Color4u8(0xff,0xff,0xff,0xff); GX_Color4u8(0xff,0xff,0xff,alpha);
GX_TexCoord2f32(0.0, 0.0); GX_TexCoord2f32(0.0, 0.0);
GX_End (); GX_End ();
GX_DrawDone(); GX_DrawDone();
@ -983,6 +983,7 @@ void gx_video_start(void)
/* Video Interrupt synchronization */ /* Video Interrupt synchronization */
VIDEO_SetPostRetraceCallback(NULL); VIDEO_SetPostRetraceCallback(NULL);
if (!gc_pal && !vdp_pal) VIDEO_SetPreRetraceCallback(updateFrameCount); if (!gc_pal && !vdp_pal) VIDEO_SetPreRetraceCallback(updateFrameCount);
VIDEO_Flush();
/* interlaced/progressive mode */ /* interlaced/progressive mode */
if (config.render == 2) if (config.render == 2)

View File

@ -56,8 +56,8 @@ extern void gx_video_update(void);
extern gx_texture *gxTextureOpenPNG(const u8 *buffer); extern gx_texture *gxTextureOpenPNG(const u8 *buffer);
extern void gxTextureClose(gx_texture **p_texture); extern void gxTextureClose(gx_texture **p_texture);
extern void gxDrawScreenshot(u8 alpha); extern void gxDrawScreenshot(u8 alpha);
extern void gxDrawTexture(gx_texture *texture, int x, int y, int w, int h, u8 alpha); extern void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha);
extern void gxDrawRepeat(gx_texture *texture, int x, int y, int w, int h); extern void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha);
extern void gxResetAngle(f32 angle); extern void gxResetAngle(f32 angle);
extern void gxClearScreen (GXColor color); extern void gxClearScreen (GXColor color);
extern void gxSetScreen (); extern void gxSetScreen ();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -23,6 +23,7 @@
#include "shared.h" #include "shared.h"
#include "font.h" #include "font.h"
#include "menu.h"
#include "history.h" #include "history.h"
#include "aram.h" #include "aram.h"
#include "dvd.h" #include "dvd.h"
@ -35,7 +36,7 @@
/* Power Button callback */ /* Power Button callback */
u8 Shutdown = 0; u8 Shutdown = 0;
void Power_Off(void) static void Power_Off(void)
{ {
Shutdown = 1; Shutdown = 1;
ConfigRequested = 1; ConfigRequested = 1;
@ -47,7 +48,7 @@ void Power_Off(void)
* Genesis Plus Virtual Machine * Genesis Plus Virtual Machine
* *
***************************************************************************/ ***************************************************************************/
static void load_bios() static void load_bios(void)
{ {
char pathname[MAXPATHLEN]; char pathname[MAXPATHLEN];
@ -74,7 +75,7 @@ static void load_bios()
} }
} }
static void init_machine (void) static void init_machine(void)
{ {
/* Allocate cart_rom here ( 10 MBytes ) */ /* Allocate cart_rom here ( 10 MBytes ) */
cart_rom = memalign(32, MAXROMSIZE); cart_rom = memalign(32, MAXROMSIZE);
@ -115,15 +116,36 @@ static void init_machine (void)
/************************************************** /**************************************************
Load a new rom and performs some initialization Load a new rom and performs some initialization
***************************************************/ ***************************************************/
void reloadrom () void reloadrom (int size, char *name)
{ {
load_rom(""); /* Load ROM */ genromsize = size;
load_rom(name); /* Load ROM */
system_init (); /* Initialize System */ system_init (); /* Initialize System */
audio_init(48000); /* Audio System initialization */ audio_init(48000); /* Audio System initialization */
ClearGGCodes (); /* Clear Game Genie patches */ ClearGGCodes (); /* Clear Game Genie patches */
system_reset (); /* System Power ON */ system_reset (); /* System Power ON */
} }
/**************************************************
Shutdown everything properly
***************************************************/
void shutdown(void)
{
/* system shutdown */
memfile_autosave(-1,config.state_auto);
system_shutdown();
audio_shutdown();
free(cart_rom);
free(texturemem);
FONT_Shutdown();
VIDEO_ClearFrameBuffer(vmode, xfb[whichfb], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
#ifdef HW_RVL
DI_Close();
#endif
}
/*************************************************************************** /***************************************************************************
* M A I N * M A I N
* *
@ -134,7 +156,7 @@ u32 frameticker = 0;
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
#ifdef HW_RVL #ifdef HW_RVL
/* initialize Wii DVD interface first */ /* initialize DVD Mode */
DI_Close(); DI_Close();
DI_Init(); DI_Init();
#endif #endif
@ -201,7 +223,7 @@ int main (int argc, char *argv[])
if (genromsize) if (genromsize)
{ {
ARAMFetch((char *)cart_rom, (void *)0x8000, genromsize); ARAMFetch((char *)cart_rom, (void *)0x8000, genromsize);
reloadrom (); reloadrom (genromsize,"INJECT.bin");
gx_video_start(); gx_video_start();
gx_audio_start(); gx_audio_start();
frameticker = 1; frameticker = 1;
@ -219,11 +241,11 @@ int main (int argc, char *argv[])
if (ConfigRequested) if (ConfigRequested)
{ {
/* stop audio & video */ /* stop audio & video */
gx_audio_stop();
gx_video_stop(); gx_video_stop();
gx_audio_stop();
/* go to menu */ /* go to menu */
MainMenu (FramesPerSecond); MainMenu ();
ConfigRequested = 0; ConfigRequested = 0;
/* reset framecounts */ /* reset framecounts */

View File

@ -27,16 +27,19 @@
extern void error(char *format, ...); extern void error(char *format, ...);
extern void ClearGGCodes(); extern void ClearGGCodes();
extern void GetGGEntries(); extern void GetGGEntries();
extern void reloadrom();
extern void legal(); extern void legal();
extern void MainMenu(u32 fps);
extern void reloadrom (int size, char *name);
extern void shutdown();
extern int ManageSRAM(u8 direction, u8 device); extern int ManageSRAM(u8 direction, u8 device);
extern int ManageState(u8 direction, u8 device); extern int ManageState(u8 direction, u8 device);
extern void memfile_autosave(); extern void memfile_autosave(s8 autosram, s8 autostate);
extern void memfile_autoload(); extern void memfile_autoload(s8 autosram, s8 autostate);
extern u8 fat_enabled; extern u8 fat_enabled;
extern u32 frameticker; extern u32 frameticker;
extern char rom_filename[256];
#ifdef HW_RVL #ifdef HW_RVL
extern u8 Shutdown; extern u8 Shutdown;

Binary file not shown.

BIN
source/gx/sounds/intro.pcm Normal file

Binary file not shown.

View File

@ -265,6 +265,8 @@ int load_rom(char *filename)
#ifdef NGC #ifdef NGC
size = genromsize; size = genromsize;
sprintf(rom_filename,"%s",filename);
rom_filename[strlen(rom_filename) - 4] = 0;
#else #else
uint8 *ptr; uint8 *ptr;
ptr = load_archive(filename, &size); ptr = load_archive(filename, &size);