massive source code cleanup/renaming, fixed some (potential) memory leaks
@ -176,6 +176,7 @@ void gen_reset (uint32 hard_reset)
|
|||||||
|
|
||||||
void gen_shutdown (void)
|
void gen_shutdown (void)
|
||||||
{
|
{
|
||||||
|
z80_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* gcaram.c
|
* aram.c
|
||||||
*
|
*
|
||||||
* ARAM wrapper for libogc
|
* ARAM wrapper for libogc
|
||||||
*
|
*
|
||||||
@ -21,7 +21,6 @@
|
|||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
|
||||||
#define ARAMSTART 0x8000
|
#define ARAMSTART 0x8000
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* gcaram.c
|
* aram.c
|
||||||
*
|
*
|
||||||
* ARAM wrapper for libogc
|
* ARAM wrapper for libogc
|
||||||
*
|
*
|
@ -72,11 +72,11 @@ void config_load()
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_config_defaults(void)
|
void config_setDefault(void)
|
||||||
{
|
{
|
||||||
/* version TAG */
|
/* version TAG */
|
||||||
strncpy(config.version,CONFIG_VERSION,15);
|
strncpy(config.version,CONFIG_VERSION,15);
|
||||||
|
|
||||||
/* sound options */
|
/* sound options */
|
||||||
config.psg_preamp = 150;
|
config.psg_preamp = 150;
|
||||||
config.fm_preamp = 100;
|
config.fm_preamp = 100;
|
||||||
@ -107,7 +107,7 @@ void set_config_defaults(void)
|
|||||||
config.bilinear = 1;
|
config.bilinear = 1;
|
||||||
|
|
||||||
/* controllers options */
|
/* controllers options */
|
||||||
ogc_input_default();
|
gx_input_setDefault();
|
||||||
config.gun_cursor = 1;
|
config.gun_cursor = 1;
|
||||||
config.invert_mouse = 0;
|
config.invert_mouse = 0;
|
||||||
}
|
}
|
@ -64,7 +64,7 @@ t_config config;
|
|||||||
|
|
||||||
extern void config_save();
|
extern void config_save();
|
||||||
extern void config_load();
|
extern void config_load();
|
||||||
extern void set_config_defaults(void);
|
extern void config_setDefault(void);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CONFIG_H_ */
|
#endif /* _CONFIG_H_ */
|
@ -24,10 +24,6 @@
|
|||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
#ifdef HW_RVL
|
|
||||||
#include "di/di.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HW_RVL
|
#ifndef HW_RVL
|
||||||
static u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. by default */
|
static u64 DvdMaxOffset = 0x57057C00; /* 1.4 GB max. by default */
|
||||||
static vu32* const dvd = (u32*)0xCC006000; /* DVD I/O Address base */
|
static vu32* const dvd = (u32*)0xCC006000; /* DVD I/O Address base */
|
@ -27,10 +27,6 @@
|
|||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "filesel.h"
|
#include "filesel.h"
|
||||||
|
|
||||||
#ifdef HW_RVL
|
|
||||||
#include "di/di.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Minimal ISO Directory Definition **/
|
/** Minimal ISO Directory Definition **/
|
||||||
#define RECLEN 0 /* Record length */
|
#define RECLEN 0 /* Record length */
|
||||||
#define EXTENT 6 /* Extent */
|
#define EXTENT 6 /* Extent */
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* filemem.c
|
* file_mem.c
|
||||||
*
|
*
|
||||||
* FAT and Memory Card SRAM/Savestate files managment
|
* FAT and Memory Card SRAM/Savestate files managment
|
||||||
*
|
*
|
||||||
@ -23,12 +23,10 @@
|
|||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "saveicon.h"
|
#include "menu.h"
|
||||||
#include "filesel.h"
|
#include "filesel.h"
|
||||||
|
#include "saveicon.h"
|
||||||
#ifndef HW_RVL
|
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Support for MemCards */
|
/* Support for MemCards */
|
||||||
/**
|
/**
|
@ -110,7 +110,7 @@ void history_load()
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_history_defaults(void)
|
void history_setDefault(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i < NUM_HISTORY_ENTRIES; i++)
|
for(i=0; i < NUM_HISTORY_ENTRIES; i++)
|
@ -46,6 +46,6 @@ typedef struct
|
|||||||
extern t_history history;
|
extern t_history history;
|
||||||
extern void history_add_file(char *filepath, char *filename);
|
extern void history_add_file(char *filepath, char *filename);
|
||||||
extern void history_load();
|
extern void history_load();
|
||||||
extern void set_history_defaults();
|
extern void history_setDefault();
|
||||||
|
|
||||||
#endif
|
#endif
|
406
source/gx/gui/filesel.c
Normal file
@ -0,0 +1,406 @@
|
|||||||
|
/*
|
||||||
|
* filesel.c
|
||||||
|
*
|
||||||
|
* File Selection menu
|
||||||
|
*
|
||||||
|
* code by Softdev (2006), Eke-Eke (2007,2008)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "shared.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "font.h"
|
||||||
|
#include "file_dvd.h"
|
||||||
|
#include "file_fat.h"
|
||||||
|
#include "filesel.h"
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
#include <wiiuse/wpad.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* this is emulator specific ! */
|
||||||
|
#define PAGESIZE 14
|
||||||
|
//#define PAGEOFFSET 120
|
||||||
|
|
||||||
|
|
||||||
|
/* Global Variables */
|
||||||
|
int maxfiles = 0;
|
||||||
|
int offset = 0;
|
||||||
|
int selection = 0;
|
||||||
|
int old_selection = 0;
|
||||||
|
int old_offset = 0;
|
||||||
|
int useFAT = 0;
|
||||||
|
int useHistory = 0;
|
||||||
|
int haveDVDdir = 0;
|
||||||
|
int haveFATdir = 0;
|
||||||
|
|
||||||
|
FILEENTRIES filelist[MAXFILES];
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* ShowFiles
|
||||||
|
*
|
||||||
|
* Show filenames list in current directory
|
||||||
|
***************************************************************************/
|
||||||
|
/*static void ShowFiles (int offset, int selection)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
char text[MAXJOLIET+2];
|
||||||
|
|
||||||
|
gxClearScreen ((GXColor)BLACK);
|
||||||
|
j = 0;
|
||||||
|
|
||||||
|
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
|
||||||
|
{
|
||||||
|
memset(text,0,MAXJOLIET+2);
|
||||||
|
if (filelist[i].flags) sprintf(text, "[%s]", filelist[i].filename + filelist[i].filename_offset);
|
||||||
|
else sprintf (text, "%s", filelist[i].filename + filelist[i].filename_offset);
|
||||||
|
if (j == (selection - offset)) WriteCentre_HL ((j * fheight) + PAGEOFFSET, text);
|
||||||
|
else WriteCentre ((j * fheight) + PAGEOFFSET, text);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
gxSetScreen ();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* FileSortCallback (Marty Disibio)
|
||||||
|
*
|
||||||
|
* Quick sort callback to sort file entries with the following order:
|
||||||
|
* .
|
||||||
|
* ..
|
||||||
|
* <dirs>
|
||||||
|
* <files>
|
||||||
|
***************************************************************************/
|
||||||
|
int FileSortCallback(const void *f1, const void *f2)
|
||||||
|
{
|
||||||
|
/* Special case for implicit directories */
|
||||||
|
if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.')
|
||||||
|
{
|
||||||
|
if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; }
|
||||||
|
if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; }
|
||||||
|
if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; }
|
||||||
|
if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If one is a file and one is a directory the directory is first. */
|
||||||
|
if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1;
|
||||||
|
if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1;
|
||||||
|
|
||||||
|
return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* FileSelector
|
||||||
|
*
|
||||||
|
* Let user select a file from the File listing
|
||||||
|
..* ROM file buffer is provided as input
|
||||||
|
* ROM size is returned
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int FileSelector(unsigned char *buffer)
|
||||||
|
{
|
||||||
|
short p;
|
||||||
|
// int redraw = 1;
|
||||||
|
int go_up = 0;
|
||||||
|
int quit =0;
|
||||||
|
int ret;
|
||||||
|
int i,size;
|
||||||
|
int yoffset = 86;
|
||||||
|
|
||||||
|
char comment[2][30] = {"Back","Load ROM File"};
|
||||||
|
char fname[MAXPATHLEN];
|
||||||
|
FILE *xml;
|
||||||
|
FILE *snap;
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
/* allocate wiimote pointer data (only done once) */
|
||||||
|
gx_texture *pointer = gxTextureOpenPNG(generic_point);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* allocate background overlay texture */
|
||||||
|
gui_image *overlay = &bg_overlay_line;
|
||||||
|
if (!overlay->texture) overlay->texture = gxTextureOpenPNG(overlay->data);
|
||||||
|
|
||||||
|
/* allocate background image texture */
|
||||||
|
gui_image *bg = &bg_right;
|
||||||
|
if (!bg->texture) bg->texture = gxTextureOpenPNG(bg->data);
|
||||||
|
|
||||||
|
/* allocate logo texture */
|
||||||
|
gui_image *logo = &logo_small;
|
||||||
|
if (!logo->texture) logo->texture = gxTextureOpenPNG(logo->data);
|
||||||
|
|
||||||
|
/* allocate background elements textures */
|
||||||
|
gui_image *banners[2] = {&top_banner,&bottom_banner};
|
||||||
|
gui_item *helpers[2] = {&action_cancel, &action_select};
|
||||||
|
for (i=0; i<2; i++)
|
||||||
|
{
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* frames */
|
||||||
|
gx_texture *frame_left = gxTextureOpenPNG(Frame_s1);
|
||||||
|
gx_texture *frame_right = gxTextureOpenPNG(Frame_s2);
|
||||||
|
|
||||||
|
/* arrows */
|
||||||
|
gx_texture *arrow_up = gxTextureOpenPNG(Button_up);
|
||||||
|
gx_texture *arrow_up_over = gxTextureOpenPNG(Button_up_over);
|
||||||
|
gx_texture *arrow_down = gxTextureOpenPNG(Button_down);
|
||||||
|
gx_texture *arrow_down_over = gxTextureOpenPNG(Button_down_over);
|
||||||
|
|
||||||
|
/* selection bar */
|
||||||
|
gx_texture *bar_over = gxTextureOpenPNG(Overlay_bar);
|
||||||
|
|
||||||
|
/* directory icon */
|
||||||
|
gx_texture *dir_icon = gxTextureOpenPNG(Browser_dir);
|
||||||
|
|
||||||
|
/* stars */
|
||||||
|
gx_texture *star_full = gxTextureOpenPNG(Star_full);
|
||||||
|
gx_texture *star_empty = gxTextureOpenPNG(Star_empty);
|
||||||
|
|
||||||
|
/* snapshots */
|
||||||
|
gx_texture *snap_frame = gxTextureOpenPNG(Snap_frame);
|
||||||
|
gx_texture *snap_empty = gxTextureOpenPNG(Snap_empty);
|
||||||
|
|
||||||
|
while (!quit)
|
||||||
|
{
|
||||||
|
/* Draw menu*/
|
||||||
|
gxClearScreen ((GXColor)BACKGROUND);
|
||||||
|
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 Files Selection", 22,10,56, (GXColor)WHITE);
|
||||||
|
FONT_alignLeft(comment[0], 16, helpers[0]->x+helpers[0]->w+6,helpers[0]->y+(helpers[0]->h-16)/2 + 16, (GXColor)WHITE);
|
||||||
|
FONT_alignRight(comment[1], 16, helpers[1]->x - 6, helpers[1]->y+(helpers[1]->h-16)/2 + 16, (GXColor)WHITE);
|
||||||
|
|
||||||
|
/* ROM database informations */
|
||||||
|
strncpy(fname, filelist[selection].filename, strlen(filelist[selection].filename) - 4);
|
||||||
|
sprintf(fname, "%s%s.xml","/genplus/db/",fname);
|
||||||
|
xml = fopen(fname, "rb");
|
||||||
|
if (xml)
|
||||||
|
{
|
||||||
|
gxDrawTexture(frame_right,384,264,frame_right->width,frame_right->height,204);
|
||||||
|
fclose(xml); /* TODO */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ROM snapshot */
|
||||||
|
strncpy(fname, filelist[selection].filename, strlen(filelist[selection].filename) - 4);
|
||||||
|
sprintf(fname, "%s%s.png","/genplus/snap/",fname);
|
||||||
|
snap = fopen(fname, "rb");
|
||||||
|
if (snap)
|
||||||
|
{
|
||||||
|
fclose(snap); /* TODO */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gxDrawTexture(snap_empty,422,114,snap_empty->width,snap_empty->height,255);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cartridge picture */
|
||||||
|
gxDrawTexture(snap_frame,388,112,snap_frame->width,snap_frame->height,255);
|
||||||
|
|
||||||
|
/* File list */
|
||||||
|
gxDrawTexture(frame_left,14,76,frame_left->width,frame_left->height,204);
|
||||||
|
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
|
||||||
|
{
|
||||||
|
if (i == selection)
|
||||||
|
{
|
||||||
|
gxDrawTexture(bar_over,22,yoffset - ((bar_over->height - dir_icon->height)/2), bar_over->width,bar_over->height,255);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filelist[i].flags)
|
||||||
|
{
|
||||||
|
/* directory icon */
|
||||||
|
gxDrawTexture(dir_icon,26,yoffset,dir_icon->width,dir_icon->height,255);
|
||||||
|
FONT_alignLeft(filelist[i].filename + filelist[i].filename_offset, 12,26+dir_icon->width+6,yoffset+(dir_icon->height-12)/2 + 12, (GXColor)WHITE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FONT_alignLeft(filelist[i].filename + filelist[i].filename_offset, 12,26,yoffset+(dir_icon->height-12)/2 + 12, (GXColor)WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
yoffset += 22;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy EFB to XFB */
|
||||||
|
gxSetScreen ();
|
||||||
|
|
||||||
|
/* if (redraw) ShowFiles (offset, selection);
|
||||||
|
redraw = 0;*/
|
||||||
|
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 */
|
||||||
|
else if (p & PAD_BUTTON_DOWN)
|
||||||
|
{
|
||||||
|
filelist[selection].filename_offset = 0;
|
||||||
|
selection++;
|
||||||
|
if (selection == maxfiles) selection = offset = 0;
|
||||||
|
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
||||||
|
//redraw = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* highlight previous item */
|
||||||
|
else if (p & PAD_BUTTON_UP)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
//redraw = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* go back one page */
|
||||||
|
else if (p & PAD_TRIGGER_L)
|
||||||
|
{
|
||||||
|
filelist[selection].filename_offset = 0;
|
||||||
|
selection -= PAGESIZE;
|
||||||
|
if (selection < 0)
|
||||||
|
{
|
||||||
|
selection = maxfiles - 1;
|
||||||
|
offset = selection - PAGESIZE + 1;
|
||||||
|
}
|
||||||
|
if (selection < offset) offset -= PAGESIZE;
|
||||||
|
if (offset < 0) offset = 0;
|
||||||
|
//redraw = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* go forward one page */
|
||||||
|
else if (p & PAD_TRIGGER_R)
|
||||||
|
{
|
||||||
|
filelist[selection].filename_offset = 0;
|
||||||
|
selection += PAGESIZE;
|
||||||
|
if (selection > maxfiles - 1) selection = offset = 0;
|
||||||
|
if ((selection - offset) >= PAGESIZE) offset += PAGESIZE;
|
||||||
|
//redraw = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* quit */
|
||||||
|
if (p & PAD_TRIGGER_Z)
|
||||||
|
{
|
||||||
|
filelist[selection].filename_offset = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* open selected file or directory */
|
||||||
|
if ((p & PAD_BUTTON_A) || (p & PAD_BUTTON_B))
|
||||||
|
{
|
||||||
|
filelist[selection].filename_offset = 0;
|
||||||
|
go_up = 0;
|
||||||
|
|
||||||
|
if (p & PAD_BUTTON_B)
|
||||||
|
{
|
||||||
|
/* go up one directory or quit */
|
||||||
|
go_up = 1;
|
||||||
|
selection = useFAT ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** 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
|
||||||
|
/* allocate wiimote pointer data (only done once) */
|
||||||
|
gxTextureClose(&pointer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
gxTextureClose(&overlay->texture);
|
||||||
|
gxTextureClose(&bg->texture);
|
||||||
|
gxTextureClose(&logo->texture);
|
||||||
|
for (i=0; i<2; i++)
|
||||||
|
{
|
||||||
|
gxTextureClose(&banners[i]->texture);
|
||||||
|
gxTextureClose(&helpers[i]->texture);
|
||||||
|
}
|
||||||
|
gxTextureClose(&frame_left);
|
||||||
|
gxTextureClose(&frame_right);
|
||||||
|
gxTextureClose(&arrow_up);
|
||||||
|
gxTextureClose(&arrow_up_over);
|
||||||
|
gxTextureClose(&arrow_down);
|
||||||
|
gxTextureClose(&arrow_down_over);
|
||||||
|
gxTextureClose(&bar_over);
|
||||||
|
gxTextureClose(&dir_icon);
|
||||||
|
gxTextureClose(&star_full);
|
||||||
|
gxTextureClose(&star_empty);
|
||||||
|
gxTextureClose(&snap_frame);
|
||||||
|
gxTextureClose(&snap_empty);
|
||||||
|
|
||||||
|
if (quit == 2) return 0;
|
||||||
|
else if (useFAT) return FAT_LoadFile(buffer);
|
||||||
|
else return DVD_LoadFile(buffer);
|
||||||
|
}
|
@ -27,11 +27,6 @@
|
|||||||
#define MAXJOLIET 256
|
#define MAXJOLIET 256
|
||||||
#define MAXFILES 1000
|
#define MAXFILES 1000
|
||||||
|
|
||||||
/* this is emulator specific ! */
|
|
||||||
#define PAGESIZE 12
|
|
||||||
#define PAGEOFFSET 120
|
|
||||||
|
|
||||||
|
|
||||||
/* Filelist structure */
|
/* Filelist structure */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
278
source/gx/gui/font.c
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* font.c
|
||||||
|
*
|
||||||
|
* IPL FONT Engine, based on Qoob MP3 Player Font
|
||||||
|
*
|
||||||
|
* code by Softdev (2006), Eke-Eke(2007-2008)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "shared.h"
|
||||||
|
#include "font.h"
|
||||||
|
#include "menu.h"
|
||||||
|
|
||||||
|
/* Backdrop Frame Width (to avoid writing outside of the background frame) */
|
||||||
|
u16 back_framewidth = 640;
|
||||||
|
int font_size[256], fheight;
|
||||||
|
|
||||||
|
#ifndef HW_RVL
|
||||||
|
/* disable Qoob Modchip before IPL access (emukiddid) */
|
||||||
|
static void ipl_set_config(unsigned char c)
|
||||||
|
{
|
||||||
|
volatile unsigned long* exi = (volatile unsigned long*)0xCC006800;
|
||||||
|
unsigned long val,addr;
|
||||||
|
addr=0xc0000000;
|
||||||
|
val = c << 24;
|
||||||
|
exi[0] = ((((exi[0]) & 0x405) | 256) | 48); //select IPL
|
||||||
|
//write addr of IPL
|
||||||
|
exi[0 * 5 + 4] = addr;
|
||||||
|
exi[0 * 5 + 3] = ((4 - 1) << 4) | (1 << 2) | 1;
|
||||||
|
while (exi[0 * 5 + 3] & 1);
|
||||||
|
//write the ipl we want to send
|
||||||
|
exi[0 * 5 + 4] = val;
|
||||||
|
exi[0 * 5 + 3] = ((4 - 1) << 4) | (1 << 2) | 1;
|
||||||
|
while (exi[0 * 5 + 3] & 1);
|
||||||
|
exi[0] &= 0x405; //deselect IPL
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static sys_fontheader *fontHeader;
|
||||||
|
static u8 *fontTexture;
|
||||||
|
|
||||||
|
int FONT_Init(void)
|
||||||
|
{
|
||||||
|
#ifndef HW_RVL
|
||||||
|
/* disable Qoob before accessing IPL */
|
||||||
|
ipl_set_config(6);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* initialize IPL font */
|
||||||
|
fontHeader = memalign(32,sizeof(sys_fontheader));
|
||||||
|
if (!fontHeader) return 0;
|
||||||
|
SYS_InitFont(&fontHeader);
|
||||||
|
|
||||||
|
/* character width table */
|
||||||
|
int i,c;
|
||||||
|
for (i=0; i<256; ++i)
|
||||||
|
{
|
||||||
|
if ((i < fontHeader->first_char) || (i > fontHeader->last_char)) c = fontHeader->inval_char;
|
||||||
|
else c = i - fontHeader->first_char;
|
||||||
|
font_size[i] = ((unsigned char*)fontHeader)[fontHeader->width_table + c];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* default font height */
|
||||||
|
fheight = fontHeader->cell_height;
|
||||||
|
|
||||||
|
/* initialize texture data */
|
||||||
|
fontTexture = memalign(32, fontHeader->cell_width * fontHeader->cell_height / 2);
|
||||||
|
if (!fontTexture)
|
||||||
|
{
|
||||||
|
free(fontHeader);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FONT_Shutdown(void)
|
||||||
|
{
|
||||||
|
if (fontHeader) free(fontHeader);
|
||||||
|
if (fontTexture) free(fontTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor color)
|
||||||
|
{
|
||||||
|
s32 width;
|
||||||
|
|
||||||
|
/* reintialize texture object */
|
||||||
|
GXTexObj texobj;
|
||||||
|
GX_InitTexObj(&texobj, fontTexture, fontHeader->cell_width, fontHeader->cell_height, GX_TF_I4, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||||
|
GX_LoadTexObj(&texobj, GX_TEXMAP0);
|
||||||
|
|
||||||
|
/* reinitialize font texture data */
|
||||||
|
memset(fontTexture,0,fontHeader->cell_width * fontHeader->cell_height / 2);
|
||||||
|
SYS_GetFontTexel(c,fontTexture,0,fontHeader->cell_width/2,&width);
|
||||||
|
DCFlushRange(fontTexture, fontHeader->cell_width * fontHeader->cell_height / 2);
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
/* adjust texture width */
|
||||||
|
width = (fontHeader->cell_width * size) / fontHeader->cell_height;
|
||||||
|
|
||||||
|
/* GX rendering */
|
||||||
|
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
|
||||||
|
GX_Position2s16(xpos, ypos - size);
|
||||||
|
GX_Color4u8(color.r, color.g, color.b, 0xff);
|
||||||
|
GX_TexCoord2f32(0.0, 0.0);
|
||||||
|
GX_Position2s16(xpos + width, ypos - size);
|
||||||
|
GX_Color4u8(color.r, color.g, color.b, 0xff);
|
||||||
|
GX_TexCoord2f32(1.0, 0.0);
|
||||||
|
GX_Position2s16(xpos + width, ypos);
|
||||||
|
GX_Color4u8(color.r, color.g, color.b, 0xff);
|
||||||
|
GX_TexCoord2f32(1.0, 1.0);
|
||||||
|
GX_Position2s16(xpos, ypos);
|
||||||
|
GX_Color4u8(color.r, color.g, color.b, 0xff);
|
||||||
|
GX_TexCoord2f32(0.0, 1.0);
|
||||||
|
GX_End ();
|
||||||
|
GX_DrawDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void write_font(int x, int y, char *string)
|
||||||
|
{
|
||||||
|
int ox = x;
|
||||||
|
while (*string && (x < (ox + back_framewidth)))
|
||||||
|
{
|
||||||
|
DrawChar(*string, x -(vmode->fbWidth/2), y-(vmode->efbHeight/2),fontHeader->cell_height,(GXColor)WHITE);
|
||||||
|
x += font_size[(u8)*string];
|
||||||
|
string++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteCentre( int y, char *string)
|
||||||
|
{
|
||||||
|
int x, t;
|
||||||
|
for (x=t=0; t<strlen(string); t++) x += font_size[(u8)string[t]];
|
||||||
|
if (x>back_framewidth) x=back_framewidth;
|
||||||
|
x = (640 - x) >> 1;
|
||||||
|
write_font(x, y, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteCentre_HL( int y, char *string)
|
||||||
|
{
|
||||||
|
gx_texture *texture = gxTextureOpenPNG(Overlay_bar);
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
gxDrawTexture(texture, 0, y-fheight, 640, fheight,240);
|
||||||
|
if (texture->data) free(texture->data);
|
||||||
|
free(texture);
|
||||||
|
}
|
||||||
|
WriteCentre(y, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FONT_alignLeft(char *string, int size, int x, int y, GXColor color)
|
||||||
|
{
|
||||||
|
x -= (vmode->fbWidth / 2);
|
||||||
|
y -= (vmode->efbHeight / 2);
|
||||||
|
|
||||||
|
while (*string)
|
||||||
|
{
|
||||||
|
DrawChar(*string, x, y, size,color);
|
||||||
|
x += (font_size[(u8)*string++] * size) / fheight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FONT_alignRight(char *string, int size, int x, int y, GXColor color)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
u16 width = 0;
|
||||||
|
|
||||||
|
for (i=0; i<strlen(string); i++)
|
||||||
|
width += (font_size[(u8)string[i]] * size) / fheight;
|
||||||
|
|
||||||
|
x -= (vmode->fbWidth / 2) + width;
|
||||||
|
y -= (vmode->efbHeight / 2);
|
||||||
|
|
||||||
|
while (*string)
|
||||||
|
{
|
||||||
|
DrawChar(*string, x, y, size,color);
|
||||||
|
x += (font_size[(u8)*string++] * size) / fheight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
void fntDrawHLine (int x1, int x2, int y, int color)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
y = 320 * y;
|
||||||
|
x1 >>= 1;
|
||||||
|
x2 >>= 1;
|
||||||
|
for (i = x1; i <= x2; i++) xfb[whichfb][y + i] = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fntDrawVLine (int x, int y1, int y2, int color)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
x >>= 1;
|
||||||
|
for (i = y1; i <= y2; i++) xfb[whichfb][x + (640 * i) / 2] = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fntDrawBox (int x1, int y1, int x2, int y2, int color)
|
||||||
|
{
|
||||||
|
fntDrawHLine (x1, x2, y1, color);
|
||||||
|
fntDrawHLine (x1, x2, y2, color);
|
||||||
|
fntDrawVLine (x1, y1, y2, color);
|
||||||
|
fntDrawVLine (x2, y1, y2, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fntDrawBoxFilled (int x1, int y1, int x2, int y2, int color)
|
||||||
|
{
|
||||||
|
int h;
|
||||||
|
for (h = y1; h <= y2; h++) fntDrawHLine (x1, x2, h, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Generic GUI functions (deprecated)
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
u8 SILENT = 0;
|
||||||
|
|
||||||
|
void WaitButtonA ()
|
||||||
|
{
|
||||||
|
while (m_input.keys & PAD_BUTTON_A) VIDEO_WaitVSync();
|
||||||
|
while (!(m_input.keys & PAD_BUTTON_A)) VIDEO_WaitVSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaitPrompt (char *msg)
|
||||||
|
{
|
||||||
|
if (SILENT) return;
|
||||||
|
gxClearScreen((GXColor)BLACK);
|
||||||
|
WriteCentre(254, msg);
|
||||||
|
WriteCentre(254 + fheight, "Press A to Continue");
|
||||||
|
gxSetScreen();
|
||||||
|
WaitButtonA ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShowAction (char *msg)
|
||||||
|
{
|
||||||
|
if (SILENT) return;
|
||||||
|
|
||||||
|
gxClearScreen((GXColor)BLACK);
|
||||||
|
WriteCentre(254, msg);
|
||||||
|
gxSetScreen();
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* font.c
|
* font.c
|
||||||
*
|
*
|
||||||
* IPL FONT Engine, based on Qoob MP3 Player Font
|
* IPL Font Engine, powered by GX hardware
|
||||||
*
|
*
|
||||||
* code by Softdev (2006), Eke-Eke(2007-2008)
|
* code Eke-Eke(2009)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -25,46 +25,25 @@
|
|||||||
#ifndef _FONT_H
|
#ifndef _FONT_H
|
||||||
#define _FONT_H
|
#define _FONT_H
|
||||||
|
|
||||||
#define BLACK {0,0,0,0xff}
|
|
||||||
#define DARK_GREY {0x22,0x22,0x22,0xff}
|
|
||||||
#define WHITE {0xff,0xff,0xff,0xff}
|
|
||||||
|
|
||||||
|
|
||||||
extern GXColor BACKGROUND;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u8 *data;
|
|
||||||
u16 width;
|
|
||||||
u16 height;
|
|
||||||
u8 format;
|
|
||||||
} png_texture;
|
|
||||||
|
|
||||||
extern void CloseTexturePNG(png_texture **p_texture);
|
|
||||||
extern png_texture *OpenTexturePNG(const u8 *buffer);
|
|
||||||
extern void DrawTexture(png_texture *texture, int x, int y, int w, int h);
|
|
||||||
extern void DrawTextureRepeat(png_texture *texture, int x, int y, int w, int h);
|
|
||||||
extern void DrawTextureAlpha(png_texture *texture, int x, int y, int w, int h, u8 alpha);
|
|
||||||
|
|
||||||
extern int FONT_Init(void);
|
extern int FONT_Init(void);
|
||||||
|
extern void FONT_Shutdown(void);
|
||||||
extern void FONT_alignLeft(char *string, int size, int x, int y, GXColor color);
|
extern void FONT_alignLeft(char *string, int size, int x, int y, GXColor color);
|
||||||
extern void FONT_alignRight(char *string, int size, int x, int y, 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 WaitButtonA ();
|
||||||
|
extern void WaitPrompt (char *msg);
|
||||||
|
extern void ShowAction (char *msg);
|
||||||
|
|
||||||
|
|
||||||
extern void WriteCentre_HL( int y, char *string);
|
extern void WriteCentre_HL( int y, char *string);
|
||||||
extern void WriteCentre (int y, char *string);
|
extern void WriteCentre (int y, char *string);
|
||||||
extern void write_font (int x, int y, char *string);
|
extern void write_font (int x, int y, char *string);
|
||||||
extern void WriteText(char *text, int size, int x, int y);
|
extern void WriteText(char *text, int size, int x, int y);
|
||||||
extern void WaitPrompt (char *msg);
|
|
||||||
extern void ShowAction (char *msg);
|
|
||||||
extern void WaitButtonA ();
|
|
||||||
extern void ClearScreen (GXColor color);
|
|
||||||
extern void SetScreen ();
|
|
||||||
extern void fntDrawBoxFilled (int x1, int y1, int x2, int y2, int color);
|
extern void fntDrawBoxFilled (int x1, int y1, int x2, int y2, int color);
|
||||||
extern int fheight;
|
extern int fheight;
|
||||||
extern int font_size[256];
|
extern int font_size[256];
|
||||||
extern u16 back_framewidth;
|
extern u16 back_framewidth;
|
||||||
extern u8 SILENT;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -23,11 +23,11 @@
|
|||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
#include "menu.h"
|
||||||
|
|
||||||
#define MAXCODES 8
|
#define MAXCODES 8
|
||||||
|
|
||||||
extern char menutitle[60];
|
extern char menutitle[60];
|
||||||
extern s16 ogc_input__getMenuButtons(u32 cnt);
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -166,7 +166,7 @@ void DrawGGCodes ()
|
|||||||
int i,j;
|
int i,j;
|
||||||
unsigned char c[2] = { 0, 0 };
|
unsigned char c[2] = { 0, 0 };
|
||||||
|
|
||||||
ClearScreen ((GXColor)BACKGROUND);
|
gxClearScreen ((GXColor)BLACK);
|
||||||
WriteCentre (134, menutitle);
|
WriteCentre (134, menutitle);
|
||||||
|
|
||||||
for (i = 0; i < MAXCODES; i++)
|
for (i = 0; i < MAXCODES; i++)
|
||||||
@ -193,7 +193,7 @@ void DrawGGCodes ()
|
|||||||
}
|
}
|
||||||
else WriteCentre ((i * fheight) + 190, (char *)ggcodes[i]);
|
else WriteCentre ((i * fheight) + 190, (char *)ggcodes[i]);
|
||||||
}
|
}
|
||||||
SetScreen ();
|
gxSetScreen ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -221,7 +221,7 @@ void GGEditLine ()
|
|||||||
redraw = 0;
|
redraw = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ogc_input__getMenuButtons(0);
|
p = m_input.keys;
|
||||||
|
|
||||||
if (p & PAD_BUTTON_UP)
|
if (p & PAD_BUTTON_UP)
|
||||||
{
|
{
|
||||||
@ -294,7 +294,7 @@ void GGSelectLine ()
|
|||||||
redraw = 0;
|
redraw = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
j = ogc_input__getMenuButtons(0);
|
j = m_input.keys;
|
||||||
|
|
||||||
if (j & PAD_BUTTON_UP)
|
if (j & PAD_BUTTON_UP)
|
||||||
{
|
{
|
@ -24,12 +24,7 @@
|
|||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "Background_intro_c1.h"
|
#include "menu.h"
|
||||||
#include "Background_intro_c2.h"
|
|
||||||
#include "Background_intro_c3.h"
|
|
||||||
#include "Background_intro_c4.h"
|
|
||||||
|
|
||||||
extern s16 ogc_input__getMenuButtons(u32 cnt);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the legal stuff - which must be shown at program startup
|
* This is the legal stuff - which must be shown at program startup
|
||||||
@ -40,9 +35,9 @@ extern s16 ogc_input__getMenuButtons(u32 cnt);
|
|||||||
void legal ()
|
void legal ()
|
||||||
{
|
{
|
||||||
int ypos = 64;
|
int ypos = 64;
|
||||||
png_texture *texture;
|
gx_texture *texture;
|
||||||
|
|
||||||
ClearScreen((GXColor)BLACK);
|
gxClearScreen((GXColor)BLACK);
|
||||||
|
|
||||||
WriteCentre (ypos, "Genesis Plus Sega Mega Drive Emulator (v1.2a)");
|
WriteCentre (ypos, "Genesis Plus Sega Mega Drive Emulator (v1.2a)");
|
||||||
ypos += fheight;
|
ypos += fheight;
|
||||||
@ -63,60 +58,60 @@ void legal ()
|
|||||||
WriteCentre (ypos, "You are free to use it as you wish.");
|
WriteCentre (ypos, "You are free to use it as you wish.");
|
||||||
ypos += 2*fheight;
|
ypos += 2*fheight;
|
||||||
|
|
||||||
texture= OpenTexturePNG(Background_intro_c4);
|
texture= gxTextureOpenPNG(Background_intro_c4);
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
DrawTexture(texture, (640-texture->width)/2, ypos, texture->width, texture->height);
|
gxDrawTexture(texture, (640-texture->width)/2, ypos, texture->width, texture->height,255);
|
||||||
ypos += texture->height + 2 * fheight;
|
ypos += texture->height + 2 * fheight;
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetScreen ();
|
gxSetScreen ();
|
||||||
sleep (1);
|
sleep (1);
|
||||||
WriteCentre (ypos, "Press any button to skip intro");
|
WriteCentre (ypos, "Press any button to skip intro");
|
||||||
SetScreen ();
|
gxSetScreen ();
|
||||||
int count = 100;
|
int count = 100;
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
count--;
|
count--;
|
||||||
VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
if (ogc_input__getMenuButtons(0)) return;
|
if (m_input.keys) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearScreen((GXColor)BLACK);
|
gxClearScreen((GXColor)BLACK);
|
||||||
texture = OpenTexturePNG(Background_intro_c1);
|
texture = gxTextureOpenPNG(Background_intro_c1);
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
DrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height);
|
gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255);
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetScreen ();
|
gxSetScreen ();
|
||||||
sleep (1);
|
sleep (1);
|
||||||
|
|
||||||
ClearScreen((GXColor)WHITE);
|
gxClearScreen((GXColor)WHITE);
|
||||||
texture = OpenTexturePNG(Background_intro_c2);
|
texture = gxTextureOpenPNG(Background_intro_c2);
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
DrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height);
|
gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255);
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetScreen ();
|
gxSetScreen ();
|
||||||
sleep (1);
|
sleep (1);
|
||||||
|
|
||||||
ClearScreen((GXColor)BLACK);
|
gxClearScreen((GXColor)BLACK);
|
||||||
texture = OpenTexturePNG(Background_intro_c3);
|
texture = gxTextureOpenPNG(Background_intro_c3);
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
DrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height);
|
gxDrawTexture(texture, (640-texture->width)/2, (480-texture->height)/2, texture->width, texture->height,255);
|
||||||
if (texture->data) free(texture->data);
|
if (texture->data) free(texture->data);
|
||||||
free(texture);
|
free(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetScreen ();
|
gxSetScreen ();
|
||||||
sleep (2);
|
sleep (2);
|
||||||
}
|
}
|
209
source/gx/gui/menu.h
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* menu.c
|
||||||
|
*
|
||||||
|
* Genesis Plus GX menu
|
||||||
|
*
|
||||||
|
* code by Eke-Eke (march 2009)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _MENU_H
|
||||||
|
#define _MENU_H
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
#include <wiiuse/wpad.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "Background_intro_c1.h"
|
||||||
|
#include "Background_intro_c2.h"
|
||||||
|
#include "Background_intro_c3.h"
|
||||||
|
#include "Background_intro_c4.h"
|
||||||
|
|
||||||
|
#include "Banner_main.h"
|
||||||
|
#include "Banner_bottom.h"
|
||||||
|
#include "Banner_top.h"
|
||||||
|
|
||||||
|
#include "Background_main.h"
|
||||||
|
#include "Background_overlay.h"
|
||||||
|
|
||||||
|
#include "Frame_s1.h"
|
||||||
|
#include "Frame_s2.h"
|
||||||
|
#include "Frame_title.h"
|
||||||
|
|
||||||
|
#include "Overlay_bar.h"
|
||||||
|
|
||||||
|
#include "Browser_dir.h"
|
||||||
|
|
||||||
|
#include "Star_full.h"
|
||||||
|
#include "Star_empty.h"
|
||||||
|
|
||||||
|
#include "Snap_empty.h"
|
||||||
|
#include "Snap_frame.h"
|
||||||
|
|
||||||
|
#include "Main_logo.h"
|
||||||
|
#include "Main_play.h"
|
||||||
|
#include "Main_load.h"
|
||||||
|
#include "Main_options.h"
|
||||||
|
#include "Main_file.h"
|
||||||
|
#include "Main_reset.h"
|
||||||
|
#include "Main_info.h"
|
||||||
|
|
||||||
|
#include "Option_ctrl.h"
|
||||||
|
#include "Option_ggenie.h"
|
||||||
|
#include "Option_sound.h"
|
||||||
|
#include "Option_video.h"
|
||||||
|
#include "Option_system.h"
|
||||||
|
|
||||||
|
#include "Load_recent.h"
|
||||||
|
#include "Load_sd.h"
|
||||||
|
#include "Load_dvd.h"
|
||||||
|
|
||||||
|
#include "Button_text.h"
|
||||||
|
#include "Button_text_over.h"
|
||||||
|
#include "Button_icon.h"
|
||||||
|
#include "Button_icon_over.h"
|
||||||
|
#include "Button_up.h"
|
||||||
|
#include "Button_down.h"
|
||||||
|
#include "Button_up_over.h"
|
||||||
|
#include "Button_down_over.h"
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
#include "Load_usb.h"
|
||||||
|
#include "Key_A_wii.h"
|
||||||
|
#include "Key_B_wii.h"
|
||||||
|
#include "Key_home.h"
|
||||||
|
#include "generic_point.h"
|
||||||
|
#include "generic_openhand.h"
|
||||||
|
#else
|
||||||
|
#include "Key_A_gcn.h"
|
||||||
|
#include "Key_B_gcn.h"
|
||||||
|
#include "Key_trigger_Z.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "button_select.h"
|
||||||
|
#include "button_over.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Generic GUI structures */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/* Menu Inputs */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u16 keys;
|
||||||
|
#ifdef HW_RVL
|
||||||
|
struct ir_t ir;
|
||||||
|
#endif
|
||||||
|
} t_input_menu;
|
||||||
|
|
||||||
|
/* Item descriptor*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gx_texture *texture; /* temporary texture data */
|
||||||
|
const u8 *data; /* pointer to png image data (items icon only) */
|
||||||
|
char text[64]; /* item string (items list only) */
|
||||||
|
char comment[64]; /* item comment */
|
||||||
|
u16 x; /* button image or text X position (upper left corner) */
|
||||||
|
u16 y; /* button image or text Y position (upper left corner) */
|
||||||
|
u16 w; /* button image or text width */
|
||||||
|
u16 h; /* button image or text height */
|
||||||
|
} gui_item;
|
||||||
|
|
||||||
|
/* Button descriptor */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gx_texture *texture[2]; /* temporary texture datas */
|
||||||
|
const u8 *image[2]; /* pointer to png image datas (default) */
|
||||||
|
} butn_data;
|
||||||
|
|
||||||
|
/* Button descriptor */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
butn_data *data; /* pointer to button image/texture data */
|
||||||
|
u16 x; /* button image X position (upper left corner) */
|
||||||
|
u16 y; /* button image Y position (upper left corner) */
|
||||||
|
u16 w; /* button image pixels width */
|
||||||
|
u16 h; /* button image pixels height */
|
||||||
|
} gui_butn;
|
||||||
|
|
||||||
|
/* Image descriptor */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
gx_texture *texture; /* temporary texture data */
|
||||||
|
const u8 *data; /* pointer to png image data */
|
||||||
|
u16 x; /* button image or text X position (upper left corner) */
|
||||||
|
u16 y; /* button image or text Y position (upper left corner) */
|
||||||
|
u16 w; /* button image or text width */
|
||||||
|
u16 h; /* button image or text height */
|
||||||
|
} gui_image;
|
||||||
|
|
||||||
|
/* Menu descriptor */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char title[64]; /* menu title */
|
||||||
|
s8 selected; /* index of selected item */
|
||||||
|
u8 offset; /* items list offset */
|
||||||
|
u8 max_items; /* total number of items */
|
||||||
|
u8 max_buttons; /* total number of buttons (not necessary identical) */
|
||||||
|
u8 shift; /* number of items by line */
|
||||||
|
gui_item *items; /* menu items table */
|
||||||
|
gui_butn *buttons; /* menu buttons table */
|
||||||
|
gui_image *overlay; /* overlay image */
|
||||||
|
gui_image *background; /* background image */
|
||||||
|
gui_image *logo; /* logo image */
|
||||||
|
gui_image *frames[2]; /* windows (max. 2) */
|
||||||
|
gui_image *banners[2]; /* bottom & top banners */
|
||||||
|
gui_item *helpers[2]; /* left & right key comments */
|
||||||
|
gui_butn *arrows[2]; /* items list up & down arrows */
|
||||||
|
} gui_menu;
|
||||||
|
|
||||||
|
|
||||||
|
/* Global data */
|
||||||
|
extern u8 SILENT;
|
||||||
|
extern t_input_menu m_input;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Common GUI images */
|
||||||
|
/*****************************************************************************/
|
||||||
|
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 buttons data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern butn_data arrow_up_data;
|
||||||
|
extern butn_data arrow_down_data;
|
||||||
|
extern butn_data button_text_data;
|
||||||
|
extern butn_data button_icon_data;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Common GUI items */
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern gui_item action_cancel;
|
||||||
|
extern gui_item action_select;
|
||||||
|
extern gui_item action_exit;
|
||||||
|
|
||||||
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ogc_audio.c
|
* gx_audio.c
|
||||||
*
|
*
|
||||||
* Genesis Plus GX audio support
|
* Genesis Plus GX audio support
|
||||||
*
|
*
|
||||||
@ -65,12 +65,12 @@ static void AudioDmaCallback(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
ogc_audio__init
|
gx_audio__init
|
||||||
|
|
||||||
This function initializes the Audio Interface
|
This function initializes the Audio Interface
|
||||||
Default samplerate is set to 48khZ
|
Default samplerate is set to 48khZ
|
||||||
***/
|
***/
|
||||||
void ogc_audio_init(void)
|
void gx_audio_init(void)
|
||||||
{
|
{
|
||||||
AUDIO_Init (NULL);
|
AUDIO_Init (NULL);
|
||||||
AUDIO_SetDSPSampleRate (AI_SAMPLERATE_48KHZ);
|
AUDIO_SetDSPSampleRate (AI_SAMPLERATE_48KHZ);
|
||||||
@ -92,7 +92,7 @@ void ogc_audio_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
ogc_audio__update
|
gx_audio__update
|
||||||
|
|
||||||
This function is called at the end of each frame
|
This function is called at the end of each frame
|
||||||
Genesis Plus only provides sound data on completion of each frame.
|
Genesis Plus only provides sound data on completion of each frame.
|
||||||
@ -100,7 +100,7 @@ void ogc_audio_init(void)
|
|||||||
This function retrieves samples for the frame then set the next DMA parameters
|
This function retrieves samples for the frame then set the next DMA parameters
|
||||||
Parameters will be taken in account only when current DMA operation is over
|
Parameters will be taken in account only when current DMA operation is over
|
||||||
***/
|
***/
|
||||||
void ogc_audio_update(void)
|
void gx_audio_update(void)
|
||||||
{
|
{
|
||||||
u32 size = dma_len;
|
u32 size = dma_len;
|
||||||
|
|
||||||
@ -135,12 +135,12 @@ void ogc_audio_update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
ogc_audio__start
|
gx_audio__start
|
||||||
|
|
||||||
This function resets the audio engine
|
This function resets the audio engine
|
||||||
This is called when coming back from Main Menu
|
This is called when coming back from Main Menu
|
||||||
***/
|
***/
|
||||||
void ogc_audio_start(void)
|
void gx_audio_start(void)
|
||||||
{
|
{
|
||||||
/* shutdown menu audio */
|
/* shutdown menu audio */
|
||||||
ASND_Pause(1);
|
ASND_Pause(1);
|
||||||
@ -172,13 +172,13 @@ void ogc_audio_start(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
ogc_audio__stop
|
gx_audio__stop
|
||||||
|
|
||||||
This function stops current Audio DMA process
|
This function stops current Audio DMA process
|
||||||
This is called when going back to Main Menu
|
This is called when going back to Main Menu
|
||||||
DMA need to be restarted when going back to the game (see above)
|
DMA need to be restarted when going back to the game (see above)
|
||||||
***/
|
***/
|
||||||
void ogc_audio_stop(void)
|
void gx_audio_stop(void)
|
||||||
{
|
{
|
||||||
/* shutdown sound emulation */
|
/* shutdown sound emulation */
|
||||||
AUDIO_StopDMA ();
|
AUDIO_StopDMA ();
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ogc_audio.c
|
* gx_audio.c
|
||||||
*
|
*
|
||||||
* Genesis Plus GX audio support
|
* Genesis Plus GX audio support
|
||||||
*
|
*
|
||||||
@ -27,9 +27,9 @@
|
|||||||
extern u8 soundbuffer[2][3840];
|
extern u8 soundbuffer[2][3840];
|
||||||
extern u8 mixbuffer;
|
extern u8 mixbuffer;
|
||||||
|
|
||||||
extern void ogc_audio_init(void);
|
extern void gx_audio_init(void);
|
||||||
extern void ogc_audio_start(void);
|
extern void gx_audio_start(void);
|
||||||
extern void ogc_audio_stop(void);
|
extern void gx_audio_stop(void);
|
||||||
extern void ogc_audio_update(void);
|
extern void gx_audio_update(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ogc_input.c
|
* gx_input.c
|
||||||
*
|
*
|
||||||
* Genesis Plus GX input support
|
* Genesis Plus GX input support
|
||||||
*
|
*
|
||||||
@ -23,11 +23,7 @@
|
|||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
#include "menu.h"
|
||||||
#ifdef HW_RVL
|
|
||||||
#include <wiiuse/wpad.h>
|
|
||||||
#include <di/di.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* configurable keys */
|
/* configurable keys */
|
||||||
#define KEY_BUTTONA 0
|
#define KEY_BUTTONA 0
|
||||||
@ -137,10 +133,10 @@ static void pad_config(int num, int padtype)
|
|||||||
PAD_ScanPads();
|
PAD_ScanPads();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearScreen((GXColor)BLACK);
|
gxClearScreen((GXColor)BLACK);
|
||||||
sprintf(msg,"Press key for %s",keys_name[i]);
|
sprintf(msg,"Press key for %s",keys_name[i]);
|
||||||
WriteCentre(254, msg);
|
WriteCentre(254, msg);
|
||||||
SetScreen();
|
gxSetScreen();
|
||||||
|
|
||||||
/* check buttons state */
|
/* check buttons state */
|
||||||
quit = 0;
|
quit = 0;
|
||||||
@ -364,10 +360,10 @@ static void wpad_config(u8 num, u8 exp, u8 padtype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* user information */
|
/* user information */
|
||||||
ClearScreen((GXColor)BLACK);
|
gxClearScreen((GXColor)BLACK);
|
||||||
sprintf(msg,"Press key for %s",keys_name[i]);
|
sprintf(msg,"Press key for %s",keys_name[i]);
|
||||||
WriteCentre(254, msg);
|
WriteCentre(254, msg);
|
||||||
SetScreen();
|
gxSetScreen();
|
||||||
|
|
||||||
/* wait for input */
|
/* wait for input */
|
||||||
quit = 0;
|
quit = 0;
|
||||||
@ -574,7 +570,7 @@ static void wpad_update(s8 num, u8 i, u32 exp)
|
|||||||
Generic input handlers
|
Generic input handlers
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
|
|
||||||
void ogc_input_init(void)
|
void gx_input_init(void)
|
||||||
{
|
{
|
||||||
PAD_Init ();
|
PAD_Init ();
|
||||||
|
|
||||||
@ -584,11 +580,11 @@ void ogc_input_init(void)
|
|||||||
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
||||||
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
||||||
#endif
|
#endif
|
||||||
VIDEO_SetPostRetraceCallback(menu_updateInputs);
|
VIDEO_SetPostRetraceCallback(gx_input_updateMenu);
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ogc_input_default(void)
|
void gx_input_setDefault(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -687,7 +683,23 @@ void ogc_input_default(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ogc_input_update(void)
|
void gx_input_config(u8 num, u8 type, u8 padtype)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
pad_config(num, padtype);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
#ifdef HW_RVL
|
||||||
|
wpad_config(num,type-1, padtype);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gx_input_updateEmu(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
@ -723,18 +735,74 @@ void ogc_input_update(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ogc_input_config(u8 num, u8 type, u8 padtype)
|
/* Menu inputs update function (done by Video Interrupt callback) */
|
||||||
|
void gx_input_updateMenu(u32 cnt)
|
||||||
{
|
{
|
||||||
switch (type)
|
/* get gamepad inputs */
|
||||||
{
|
PAD_ScanPads();
|
||||||
case 0:
|
s16 p = PAD_ButtonsDown(0);
|
||||||
pad_config(num, padtype);
|
s8 x = PAD_StickX(0);
|
||||||
break;
|
s8 y = PAD_StickY(0);
|
||||||
|
if (x > 70) p |= PAD_BUTTON_RIGHT;
|
||||||
default:
|
else if (x < -70) p |= PAD_BUTTON_LEFT;
|
||||||
|
if (y > 60) p |= PAD_BUTTON_UP;
|
||||||
|
else if (y < -60) p |= PAD_BUTTON_DOWN;
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
wpad_config(num,type-1, padtype);
|
/* get wiimote + expansions inputs */
|
||||||
#endif
|
WPAD_ScanPads();
|
||||||
break;
|
u32 q = WPAD_ButtonsDown(0);
|
||||||
|
/*u32 h = WPAD_ButtonsHeld(0);*/
|
||||||
|
x = WPAD_StickX(0, 0);
|
||||||
|
y = WPAD_StickY(0, 0);
|
||||||
|
|
||||||
|
/* Wiimote orientation */
|
||||||
|
WPAD_IR(0, &m_input.ir);
|
||||||
|
|
||||||
|
/* wiimote directions */
|
||||||
|
if (m_input.ir.valid)
|
||||||
|
{
|
||||||
|
if (q & WPAD_BUTTON_UP) p |= PAD_BUTTON_UP;
|
||||||
|
else if (q & WPAD_BUTTON_DOWN) p |= PAD_BUTTON_DOWN;
|
||||||
|
else if (q & WPAD_BUTTON_LEFT) p |= PAD_BUTTON_LEFT;
|
||||||
|
else if (q & WPAD_BUTTON_RIGHT) p |= PAD_BUTTON_RIGHT;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (q & WPAD_BUTTON_UP) p |= PAD_BUTTON_LEFT;
|
||||||
|
else if (q & WPAD_BUTTON_DOWN) p |= PAD_BUTTON_RIGHT;
|
||||||
|
else if (q & WPAD_BUTTON_LEFT) p |= PAD_BUTTON_DOWN;
|
||||||
|
else if (q & WPAD_BUTTON_RIGHT) p |= PAD_BUTTON_UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* analog sticks */
|
||||||
|
if (y > 70) p |= PAD_BUTTON_UP;
|
||||||
|
else if (y < -70) p |= PAD_BUTTON_DOWN;
|
||||||
|
if (x < -60) p |= PAD_BUTTON_LEFT;
|
||||||
|
else if (x > 60) p |= PAD_BUTTON_RIGHT;
|
||||||
|
|
||||||
|
/* classic controller directions */
|
||||||
|
if (q & WPAD_CLASSIC_BUTTON_UP) p |= PAD_BUTTON_UP;
|
||||||
|
else if (q & WPAD_CLASSIC_BUTTON_DOWN) p |= PAD_BUTTON_DOWN;
|
||||||
|
if (q & WPAD_CLASSIC_BUTTON_LEFT) p |= PAD_BUTTON_LEFT;
|
||||||
|
else if (q & WPAD_CLASSIC_BUTTON_RIGHT) p |= PAD_BUTTON_RIGHT;
|
||||||
|
|
||||||
|
/* wiimote keys */
|
||||||
|
if (q & WPAD_BUTTON_MINUS) p |= PAD_TRIGGER_L;
|
||||||
|
if (q & WPAD_BUTTON_PLUS) p |= PAD_TRIGGER_R;
|
||||||
|
if (q & WPAD_BUTTON_A) p |= PAD_BUTTON_A;
|
||||||
|
if (q & WPAD_BUTTON_B) p |= PAD_BUTTON_B;
|
||||||
|
if (q & WPAD_BUTTON_2) p |= PAD_BUTTON_A;
|
||||||
|
if (q & WPAD_BUTTON_1) p |= PAD_BUTTON_B;
|
||||||
|
if (q & WPAD_BUTTON_HOME) p |= PAD_TRIGGER_Z;
|
||||||
|
|
||||||
|
/* classic controller keys */
|
||||||
|
if (q & WPAD_CLASSIC_BUTTON_FULL_L) p |= PAD_TRIGGER_L;
|
||||||
|
if (q & WPAD_CLASSIC_BUTTON_FULL_R) p |= PAD_TRIGGER_R;
|
||||||
|
if (q & WPAD_CLASSIC_BUTTON_A) p |= PAD_BUTTON_A;
|
||||||
|
if (q & WPAD_CLASSIC_BUTTON_B) p |= PAD_BUTTON_B;
|
||||||
|
if (q & WPAD_CLASSIC_BUTTON_HOME) p |= PAD_TRIGGER_Z;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_input.keys = p;
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ogc_input.c
|
* gx_input.c
|
||||||
*
|
*
|
||||||
* Genesis Plus GX input support
|
* Genesis Plus GX input support
|
||||||
*
|
*
|
||||||
@ -21,7 +21,6 @@
|
|||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _GC_INPUT_H_
|
#ifndef _GC_INPUT_H_
|
||||||
#define _GC_INPUT_H_
|
#define _GC_INPUT_H_
|
||||||
|
|
||||||
@ -35,8 +34,10 @@
|
|||||||
/* number of configurable keys */
|
/* number of configurable keys */
|
||||||
#define MAX_KEYS 8
|
#define MAX_KEYS 8
|
||||||
|
|
||||||
#define update_input() ogc_input_update()
|
/* wrapper for genesis plus */
|
||||||
|
#define update_input() gx_input_updateEmu()
|
||||||
|
|
||||||
|
/* key configuration structure */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
s8 device;
|
s8 device;
|
||||||
@ -45,10 +46,11 @@ typedef struct
|
|||||||
|
|
||||||
extern u8 ConfigRequested;
|
extern u8 ConfigRequested;
|
||||||
|
|
||||||
extern void ogc_input_init(void);
|
extern void gx_input_init(void);
|
||||||
extern void ogc_input_default(void);
|
extern void gx_input_setDefault(void);
|
||||||
extern void ogc_input_update(void);
|
extern void gx_input_config(u8 num, u8 type, u8 padtype);
|
||||||
extern void ogc_input_config(u8 num, u8 type, u8 padtype);
|
extern void gx_input_updateEmu(void);
|
||||||
|
extern void gx_input_updateMenu(u32 cnt);
|
||||||
|
|
||||||
extern s8 WPAD_StickX(u8 chan,u8 right);
|
extern s8 WPAD_StickX(u8 chan,u8 right);
|
||||||
extern s8 WPAD_StickY(u8 chan,u8 right);
|
extern s8 WPAD_StickY(u8 chan,u8 right);
|
@ -1,9 +1,9 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ogc_video.c
|
* gx_video.c
|
||||||
*
|
*
|
||||||
* Genesis Plus GX video support
|
* Genesis Plus GX video & rendering support
|
||||||
*
|
*
|
||||||
* code by Softdev (2006), Eke-Eke (2007,2008)
|
* code by Softdev (2006), Eke-Eke (2007,2009)
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -23,13 +23,16 @@
|
|||||||
|
|
||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "gcaram.h"
|
#include "sms_ntsc.h"
|
||||||
|
#include "aram.h"
|
||||||
#include "md_ntsc.h"
|
#include "md_ntsc.h"
|
||||||
#include "sms_ntsc.h"
|
#include "sms_ntsc.h"
|
||||||
|
|
||||||
#include "Crosshair_p1.h"
|
#include "Crosshair_p1.h"
|
||||||
#include "Crosshair_p2.h"
|
#include "Crosshair_p2.h"
|
||||||
|
|
||||||
|
#include <png.h>
|
||||||
|
|
||||||
#define TEX_WIDTH 720
|
#define TEX_WIDTH 720
|
||||||
#define TEX_HEIGHT 576
|
#define TEX_HEIGHT 576
|
||||||
#define TEX_SIZE (TEX_WIDTH * TEX_HEIGHT * 2)
|
#define TEX_SIZE (TEX_WIDTH * TEX_HEIGHT * 2)
|
||||||
@ -37,6 +40,13 @@
|
|||||||
#define HASPECT 320
|
#define HASPECT 320
|
||||||
#define VASPECT 240
|
#define VASPECT 240
|
||||||
|
|
||||||
|
/* libpng wrapper */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u8 *buffer;
|
||||||
|
u32 offset;
|
||||||
|
} png_file;
|
||||||
|
|
||||||
/*** VI ***/
|
/*** VI ***/
|
||||||
unsigned int *xfb[2]; /* External Framebuffers */
|
unsigned int *xfb[2]; /* External Framebuffers */
|
||||||
int whichfb = 0; /* Current Framebuffer */
|
int whichfb = 0; /* Current Framebuffer */
|
||||||
@ -60,7 +70,7 @@ static GXRModeObj *rmode;
|
|||||||
|
|
||||||
/*** GX Textures ***/
|
/*** GX Textures ***/
|
||||||
static u32 vwidth,vheight;
|
static u32 vwidth,vheight;
|
||||||
static png_texture *crosshair[2];
|
static gx_texture *crosshair[2];
|
||||||
|
|
||||||
/* 288 lines progressive (PAL 50Hz) */
|
/* 288 lines progressive (PAL 50Hz) */
|
||||||
static GXRModeObj TV50hz_288p =
|
static GXRModeObj TV50hz_288p =
|
||||||
@ -359,10 +369,6 @@ static void gxStart(void)
|
|||||||
guLookAt(view, &cam.pos, &cam.up, &cam.view);
|
guLookAt(view, &cam.pos, &cam.up, &cam.view);
|
||||||
GX_LoadPosMtxImm(view, GX_PNMTX0);
|
GX_LoadPosMtxImm(view, GX_PNMTX0);
|
||||||
GX_Flush();
|
GX_Flush();
|
||||||
|
|
||||||
/*** Initialize texture data ***/
|
|
||||||
texturemem = memalign(32, TEX_SIZE);
|
|
||||||
memset (texturemem, 0, TEX_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset GX rendering */
|
/* Reset GX rendering */
|
||||||
@ -534,7 +540,7 @@ static void gxResetScale(u32 width, u32 height)
|
|||||||
GX_InvVtxCache();
|
GX_InvVtxCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gxDrawCrosshair(png_texture *texture, int x, int y)
|
static void gxDrawCrosshair(gx_texture *texture, int x, int y)
|
||||||
{
|
{
|
||||||
if (texture->data)
|
if (texture->data)
|
||||||
{
|
{
|
||||||
@ -583,6 +589,205 @@ static void gxDrawCrosshair(png_texture *texture, int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* libpng read callback function */
|
||||||
|
static void png_read_from_mem (png_structp png_ptr, png_bytep data, png_size_t length)
|
||||||
|
{
|
||||||
|
png_file *file = (png_file *)png_get_io_ptr (png_ptr);
|
||||||
|
|
||||||
|
/* copy data from image buffer */
|
||||||
|
memcpy (data, file->buffer + file->offset, length);
|
||||||
|
|
||||||
|
/* advance in the file */
|
||||||
|
file->offset += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* convert a png file into RGBA8 texture */
|
||||||
|
gx_texture *gxTextureOpenPNG(const u8 *buffer)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
png_file file;
|
||||||
|
|
||||||
|
/* init PNG file structure */
|
||||||
|
file.buffer = (u8 *) buffer;
|
||||||
|
file.offset = 0;
|
||||||
|
|
||||||
|
/* check for valid magic number */
|
||||||
|
/*if (!png_check_sig (file.buffer, 8)) return;*/
|
||||||
|
|
||||||
|
/* create a png read struct */
|
||||||
|
png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
|
if (!png_ptr) return NULL;
|
||||||
|
|
||||||
|
/* create a png info struct */
|
||||||
|
png_infop info_ptr = png_create_info_struct (png_ptr);
|
||||||
|
if (!info_ptr)
|
||||||
|
{
|
||||||
|
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set callback for the read function */
|
||||||
|
png_set_read_fn (png_ptr, (png_voidp *)(&file), png_read_from_mem);
|
||||||
|
|
||||||
|
/* read png info */
|
||||||
|
png_read_info (png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* retrieve image information */
|
||||||
|
u32 width = png_get_image_width(png_ptr, info_ptr);
|
||||||
|
u32 height = png_get_image_height(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* ensure PNG images are in the supported format */
|
||||||
|
u32 bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||||
|
u32 color_type = png_get_color_type(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* support for RGBA8 textures ONLY !*/
|
||||||
|
if ((color_type != PNG_COLOR_TYPE_RGB_ALPHA) || (bit_depth != 8))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 4x4 tiles are required */
|
||||||
|
if ((width%4) || (height%4))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* allocate memory to store raw image data */
|
||||||
|
u32 stride = width << 2;
|
||||||
|
u8 *img_data = memalign (32, stride * height);
|
||||||
|
if (!img_data)
|
||||||
|
{
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate row pointer data */
|
||||||
|
png_bytep *row_pointers = (png_bytep *)memalign (32, sizeof (png_bytep) * height);
|
||||||
|
if (!row_pointers)
|
||||||
|
{
|
||||||
|
free (img_data);
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* store raw image data */
|
||||||
|
for (i = 0; i < height; i++)
|
||||||
|
{
|
||||||
|
row_pointers[i] = img_data + (i * stride);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* decode image */
|
||||||
|
png_read_image (png_ptr, row_pointers);
|
||||||
|
|
||||||
|
/* finish decompression and release memory */
|
||||||
|
png_read_end (png_ptr, NULL);
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
free(row_pointers);
|
||||||
|
|
||||||
|
/* initialize texture */
|
||||||
|
gx_texture *texture = (gx_texture *)memalign(32, sizeof(gx_texture));
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
free (img_data);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize texture data */
|
||||||
|
texture->data = memalign(32, stride * height);
|
||||||
|
if (!texture->data)
|
||||||
|
{
|
||||||
|
free (img_data);
|
||||||
|
free(texture);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(texture->data, 0, stride * height);
|
||||||
|
texture->width = width;
|
||||||
|
texture->height = height;
|
||||||
|
texture->format = GX_TF_RGBA8;
|
||||||
|
|
||||||
|
/* encode to GX_TF_RGBA8 format (4x4 pixels paired titles) */
|
||||||
|
u16 *dst_ar = (u16 *)(texture->data);
|
||||||
|
u16 *dst_gb = (u16 *)(texture->data + 32);
|
||||||
|
u32 *src1 = (u32 *)(img_data);
|
||||||
|
u32 *src2 = (u32 *)(img_data + stride);
|
||||||
|
u32 *src3 = (u32 *)(img_data + 2*stride);
|
||||||
|
u32 *src4 = (u32 *)(img_data + 3*stride);
|
||||||
|
u32 pixel,h,w;
|
||||||
|
|
||||||
|
for (h=0; h<height; h+=4)
|
||||||
|
{
|
||||||
|
for (w=0; w<width; w+=4)
|
||||||
|
{
|
||||||
|
/* line N (4 pixels) */
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
pixel = *src1++;
|
||||||
|
*dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff);
|
||||||
|
*dst_gb++= (pixel >> 8) & 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* line N + 1 (4 pixels) */
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
pixel = *src2++;
|
||||||
|
*dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff);
|
||||||
|
*dst_gb++= (pixel >> 8) & 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* line N + 2 (4 pixels) */
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
pixel = *src3++;
|
||||||
|
*dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff);
|
||||||
|
*dst_gb++= (pixel >> 8) & 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* line N + 3 (4 pixels) */
|
||||||
|
for (i=0; i<4; i++)
|
||||||
|
{
|
||||||
|
pixel = *src4++;
|
||||||
|
*dst_ar++= ((pixel << 8) & 0xff00) | ((pixel >> 24) & 0x00ff);
|
||||||
|
*dst_gb++= (pixel >> 8) & 0xffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* next paired tiles */
|
||||||
|
dst_ar += 16;
|
||||||
|
dst_gb += 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* next 4 lines */
|
||||||
|
src1 = src4;
|
||||||
|
src2 = src1 + width;
|
||||||
|
src3 = src2 + width;
|
||||||
|
src4 = src3 + width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* release memory */
|
||||||
|
free(img_data);
|
||||||
|
|
||||||
|
/* flush texture data from cache */
|
||||||
|
DCFlushRange(texture->data, height * stride);
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gxTextureClose(gx_texture **p_texture)
|
||||||
|
{
|
||||||
|
gx_texture *texture = *p_texture;
|
||||||
|
|
||||||
|
if (texture)
|
||||||
|
{
|
||||||
|
if (texture->data) free(texture->data);
|
||||||
|
free(texture);
|
||||||
|
*p_texture = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void gxDrawScreenshot(u8 alpha)
|
void gxDrawScreenshot(u8 alpha)
|
||||||
{
|
{
|
||||||
if (rmode)
|
if (rmode)
|
||||||
@ -626,7 +831,78 @@ void gxDrawScreenshot(u8 alpha)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gxResetCamera(f32 angle)
|
void gxDrawTexture(gx_texture *texture, int x, int y, int w, int h, u8 alpha)
|
||||||
|
{
|
||||||
|
if (texture->data)
|
||||||
|
{
|
||||||
|
/* load texture object */
|
||||||
|
GXTexObj texObj;
|
||||||
|
GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||||
|
GX_InitTexObjLOD(&texObj,GX_LINEAR,GX_LIN_MIP_LIN,0.0,10.0,0.0,GX_FALSE,GX_TRUE,GX_ANISO_4); /* does this really change anything ? */
|
||||||
|
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
/* vertex coordinate */
|
||||||
|
x -= (vmode->fbWidth/2);
|
||||||
|
y -= (vmode->efbHeight/2);
|
||||||
|
|
||||||
|
/* draw textured quad */
|
||||||
|
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
|
||||||
|
GX_Position2s16(x,y+h);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,alpha);
|
||||||
|
GX_TexCoord2f32(0.0, 1.0);
|
||||||
|
GX_Position2s16(x+w,y+h);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,alpha);
|
||||||
|
GX_TexCoord2f32(1.0, 1.0);
|
||||||
|
GX_Position2s16(x+w,y);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,alpha);
|
||||||
|
GX_TexCoord2f32(1.0, 0.0);
|
||||||
|
GX_Position2s16(x,y);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,alpha);
|
||||||
|
GX_TexCoord2f32(0.0, 0.0);
|
||||||
|
GX_End ();
|
||||||
|
GX_DrawDone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gxDrawRepeat(gx_texture *texture, int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
if (texture->data)
|
||||||
|
{
|
||||||
|
/* load texture object */
|
||||||
|
GXTexObj texObj;
|
||||||
|
GX_InitTexObj(&texObj, texture->data, texture->width, texture->height, GX_TF_RGBA8, GX_MIRROR, GX_MIRROR, GX_FALSE);
|
||||||
|
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
/* vertex coordinate */
|
||||||
|
x -= (vmode->fbWidth/2);
|
||||||
|
y -= (vmode->efbHeight/2);
|
||||||
|
|
||||||
|
/* texture coordinates */
|
||||||
|
f32 s = (f32)w / (f32)texture->width;
|
||||||
|
f32 t = (f32)h / (f32)texture->height;
|
||||||
|
|
||||||
|
/* draw textured quad */
|
||||||
|
GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
|
||||||
|
GX_Position2s16(x,y+h);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,0xff);
|
||||||
|
GX_TexCoord2f32(0.0, t);
|
||||||
|
GX_Position2s16(x+w,y+h);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,0xff);
|
||||||
|
GX_TexCoord2f32(s, t);
|
||||||
|
GX_Position2s16(x+w,y);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,0xff);
|
||||||
|
GX_TexCoord2f32(s, 0.0);
|
||||||
|
GX_Position2s16(x,y);
|
||||||
|
GX_Color4u8(0xff,0xff,0xff,0xff);
|
||||||
|
GX_TexCoord2f32(0.0, 0.0);
|
||||||
|
GX_End ();
|
||||||
|
GX_DrawDone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gxResetAngle(f32 angle)
|
||||||
{
|
{
|
||||||
Mtx view;
|
Mtx view;
|
||||||
|
|
||||||
@ -647,9 +923,27 @@ void gxResetCamera(f32 angle)
|
|||||||
GX_Flush();
|
GX_Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GXColor BACKGROUND = {0xd4,0xd0,0xc8,0xff};
|
||||||
|
|
||||||
|
void gxSetScreen ()
|
||||||
|
{
|
||||||
|
GX_CopyDisp(xfb[whichfb], GX_FALSE);
|
||||||
|
GX_Flush();
|
||||||
|
VIDEO_SetNextFramebuffer (xfb[whichfb]);
|
||||||
|
VIDEO_Flush ();
|
||||||
|
VIDEO_WaitVSync ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void gxClearScreen (GXColor color)
|
||||||
|
{
|
||||||
|
whichfb ^= 1;
|
||||||
|
GX_SetCopyClear(color,0x00ffffff);
|
||||||
|
GX_CopyDisp(xfb[whichfb], GX_TRUE);
|
||||||
|
GX_Flush();
|
||||||
|
}
|
||||||
|
|
||||||
/* Restore Menu Video mode */
|
/* Restore Menu Video mode */
|
||||||
void ogc_video_stop(void)
|
void gx_video_stop(void)
|
||||||
{
|
{
|
||||||
/* lightgun textures */
|
/* lightgun textures */
|
||||||
if (crosshair[0])
|
if (crosshair[0])
|
||||||
@ -673,12 +967,12 @@ void ogc_video_stop(void)
|
|||||||
gxDrawScreenshot(0xff);
|
gxDrawScreenshot(0xff);
|
||||||
VIDEO_Configure(vmode);
|
VIDEO_Configure(vmode);
|
||||||
VIDEO_SetPreRetraceCallback(NULL);
|
VIDEO_SetPreRetraceCallback(NULL);
|
||||||
VIDEO_SetPostRetraceCallback(menu_updateInputs);
|
VIDEO_SetPostRetraceCallback(gx_input_updateMenu);
|
||||||
SetScreen ();
|
gxSetScreen ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update Video settings */
|
/* Update Video settings */
|
||||||
void ogc_video_start(void)
|
void gx_video_start(void)
|
||||||
{
|
{
|
||||||
/* 50Hz/60Hz mode */
|
/* 50Hz/60Hz mode */
|
||||||
if ((config.tv_mode == 1) || ((config.tv_mode == 2) && vdp_pal)) gc_pal = 1;
|
if ((config.tv_mode == 1) || ((config.tv_mode == 2) && vdp_pal)) gc_pal = 1;
|
||||||
@ -728,8 +1022,8 @@ void ogc_video_start(void)
|
|||||||
{
|
{
|
||||||
if (config.gun_cursor)
|
if (config.gun_cursor)
|
||||||
{
|
{
|
||||||
if (input.dev[4] == DEVICE_LIGHTGUN) crosshair[0] = OpenTexturePNG(Crosshair_p1);
|
if (input.dev[4] == DEVICE_LIGHTGUN) crosshair[0] = gxTextureOpenPNG(Crosshair_p1);
|
||||||
if (input.dev[5] == DEVICE_LIGHTGUN) crosshair[1] = OpenTexturePNG(Crosshair_p2);
|
if (input.dev[5] == DEVICE_LIGHTGUN) crosshair[1] = gxTextureOpenPNG(Crosshair_p2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,7 +1037,7 @@ void ogc_video_start(void)
|
|||||||
|
|
||||||
|
|
||||||
/* GX render update */
|
/* GX render update */
|
||||||
void ogc_video_update(void)
|
void gx_video_update(void)
|
||||||
{
|
{
|
||||||
/* check if display has changed */
|
/* check if display has changed */
|
||||||
if (bitmap.viewport.changed)
|
if (bitmap.viewport.changed)
|
||||||
@ -833,7 +1127,7 @@ void ogc_video_update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize VIDEO subsystem */
|
/* Initialize VIDEO subsystem */
|
||||||
void ogc_video_init(void)
|
void gx_video_init(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Before doing anything else under libogc,
|
* Before doing anything else under libogc,
|
||||||
@ -937,6 +1231,17 @@ void ogc_video_init(void)
|
|||||||
gxResetRendering(1);
|
gxResetRendering(1);
|
||||||
gxResetView(vmode);
|
gxResetView(vmode);
|
||||||
|
|
||||||
/* Initialize Font */
|
/* Initialize texture data */
|
||||||
FONT_Init();
|
texturemem = memalign(32, TEX_SIZE);
|
||||||
|
if (!texturemem)
|
||||||
|
{
|
||||||
|
WaitPrompt("Failed to allocate texture buffer... Rebooting");
|
||||||
|
#ifdef HW_RVL
|
||||||
|
DI_Close();
|
||||||
|
SYS_ResetSystem(SYS_RESTART,0,0);
|
||||||
|
#else
|
||||||
|
SYS_ResetSystem(SYS_HOTRESET,0,0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
memset (texturemem, 0, TEX_SIZE);
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ogc_video.c
|
* gx_video.c
|
||||||
*
|
*
|
||||||
* Genesis Plus GX video support
|
* Genesis Plus GX video support
|
||||||
*
|
*
|
||||||
@ -24,6 +24,12 @@
|
|||||||
#ifndef _GC_VIDEO_H_
|
#ifndef _GC_VIDEO_H_
|
||||||
#define _GC_VIDEO_H_
|
#define _GC_VIDEO_H_
|
||||||
|
|
||||||
|
/* EFB colors */
|
||||||
|
#define BLACK {0,0,0,0xff}
|
||||||
|
#define DARK_GREY {0x22,0x22,0x22,0xff}
|
||||||
|
#define WHITE {0xff,0xff,0xff,0xff}
|
||||||
|
|
||||||
|
/* image texture */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
u8 *data;
|
u8 *data;
|
||||||
@ -32,20 +38,28 @@ typedef struct
|
|||||||
u8 format;
|
u8 format;
|
||||||
} gx_texture;
|
} gx_texture;
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
extern unsigned int *xfb[2];
|
extern unsigned int *xfb[2];
|
||||||
extern int whichfb;
|
extern int whichfb;
|
||||||
extern GXRModeObj *vmode;
|
extern GXRModeObj *vmode;
|
||||||
extern u8 *texturemem;
|
extern u8 *texturemem;
|
||||||
extern u8 gc_pal;
|
extern u8 gc_pal;
|
||||||
|
extern GXColor BACKGROUND;
|
||||||
|
|
||||||
extern void ogc_video_init(void);
|
/* GX video emulation functions */
|
||||||
extern void ogc_video_start(void);
|
extern void gx_video_init(void);
|
||||||
extern void ogc_video_stop(void);
|
extern void gx_video_start(void);
|
||||||
extern void ogc_video_update(void);
|
extern void gx_video_stop(void);
|
||||||
|
extern void gx_video_update(void);
|
||||||
|
|
||||||
extern void gxResetCamera(f32 angle);
|
/* GX draw functions */
|
||||||
|
extern gx_texture *gxTextureOpenPNG(const u8 *buffer);
|
||||||
|
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 gxDrawRepeat(gx_texture *texture, int x, int y, int w, int h);
|
||||||
|
extern void gxResetAngle(f32 angle);
|
||||||
|
extern void gxClearScreen (GXColor color);
|
||||||
|
extern void gxSetScreen ();
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* ngc.c
|
* main.c
|
||||||
*
|
*
|
||||||
* Genesis Plus GX main
|
* Genesis Plus GX main
|
||||||
*
|
*
|
||||||
@ -24,18 +24,15 @@
|
|||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "gcaram.h"
|
#include "aram.h"
|
||||||
|
|
||||||
#ifdef HW_DOL
|
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#else
|
|
||||||
#include <di/di.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
|
#include <wiiuse/wpad.h>
|
||||||
|
#include <di/di.h>
|
||||||
|
|
||||||
/* Power Button callback */
|
/* Power Button callback */
|
||||||
u8 Shutdown = 0;
|
u8 Shutdown = 0;
|
||||||
void Power_Off(void)
|
void Power_Off(void)
|
||||||
@ -80,7 +77,19 @@ 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, 10 * 1024 * 1024);
|
cart_rom = memalign(32, MAXROMSIZE);
|
||||||
|
if (!cart_rom)
|
||||||
|
{
|
||||||
|
WaitPrompt("Failed to allocate ROM buffer... Rebooting");
|
||||||
|
free(texturemem);
|
||||||
|
FONT_Shutdown();
|
||||||
|
#ifdef HW_RVL
|
||||||
|
DI_Close();
|
||||||
|
SYS_ResetSystem(SYS_RESTART,0,0);
|
||||||
|
#else
|
||||||
|
SYS_ResetSystem(SYS_HOTRESET,0,0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* BIOS support */
|
/* BIOS support */
|
||||||
load_bios();
|
load_bios();
|
||||||
@ -134,10 +143,23 @@ int main (int argc, char *argv[])
|
|||||||
uint32 TotalFrames = 0;
|
uint32 TotalFrames = 0;
|
||||||
uint32 FramesPerSecond = 0;
|
uint32 FramesPerSecond = 0;
|
||||||
|
|
||||||
/* initialize OGC subsystems */
|
/* initialize harwdare */
|
||||||
ogc_video_init();
|
gx_video_init();
|
||||||
ogc_input_init();
|
gx_input_init();
|
||||||
ogc_audio_init();
|
gx_audio_init();
|
||||||
|
|
||||||
|
/* initialize font */
|
||||||
|
if (!FONT_Init())
|
||||||
|
{
|
||||||
|
WaitPrompt("Failed to allocate ROM buffer... Rebooting");
|
||||||
|
free(texturemem);
|
||||||
|
#ifdef HW_RVL
|
||||||
|
DI_Close();
|
||||||
|
SYS_ResetSystem(SYS_RESTART,0,0);
|
||||||
|
#else
|
||||||
|
SYS_ResetSystem(SYS_HOTRESET,0,0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
/* initialize GC DVD interface */
|
/* initialize GC DVD interface */
|
||||||
@ -165,11 +187,11 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* default config */
|
/* default config */
|
||||||
legal();
|
legal();
|
||||||
set_config_defaults();
|
config_setDefault();
|
||||||
config_load();
|
config_load();
|
||||||
|
|
||||||
/* restore recent files list */
|
/* restore recent files list */
|
||||||
set_history_defaults();
|
history_setDefault();
|
||||||
history_load();
|
history_load();
|
||||||
|
|
||||||
/* initialize Virtual Machine */
|
/* initialize Virtual Machine */
|
||||||
@ -180,8 +202,8 @@ int main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ARAMFetch((char *)cart_rom, (void *)0x8000, genromsize);
|
ARAMFetch((char *)cart_rom, (void *)0x8000, genromsize);
|
||||||
reloadrom ();
|
reloadrom ();
|
||||||
ogc_video_start();
|
gx_video_start();
|
||||||
ogc_audio_start();
|
gx_audio_start();
|
||||||
frameticker = 1;
|
frameticker = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -197,8 +219,8 @@ int main (int argc, char *argv[])
|
|||||||
if (ConfigRequested)
|
if (ConfigRequested)
|
||||||
{
|
{
|
||||||
/* stop audio & video */
|
/* stop audio & video */
|
||||||
ogc_audio_stop();
|
gx_audio_stop();
|
||||||
ogc_video_stop();
|
gx_video_stop();
|
||||||
|
|
||||||
/* go to menu */
|
/* go to menu */
|
||||||
MainMenu (FramesPerSecond);
|
MainMenu (FramesPerSecond);
|
||||||
@ -210,8 +232,8 @@ int main (int argc, char *argv[])
|
|||||||
FramesPerSecond = vdp_rate;
|
FramesPerSecond = vdp_rate;
|
||||||
|
|
||||||
/* start audio & video */
|
/* start audio & video */
|
||||||
ogc_video_start();
|
gx_video_start();
|
||||||
ogc_audio_start();
|
gx_audio_start();
|
||||||
|
|
||||||
/* reset framesync */
|
/* reset framesync */
|
||||||
frameticker = 1;
|
frameticker = 1;
|
||||||
@ -224,7 +246,7 @@ int main (int argc, char *argv[])
|
|||||||
system_frame (1);
|
system_frame (1);
|
||||||
|
|
||||||
/* update audio only */
|
/* update audio only */
|
||||||
ogc_audio_update();
|
gx_audio_update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -236,8 +258,8 @@ int main (int argc, char *argv[])
|
|||||||
system_frame (0);
|
system_frame (0);
|
||||||
|
|
||||||
/* update video & audio */
|
/* update video & audio */
|
||||||
ogc_video_update();
|
gx_video_update();
|
||||||
ogc_audio_update();
|
gx_audio_update();
|
||||||
RenderedFrames++;
|
RenderedFrames++;
|
||||||
}
|
}
|
||||||
|
|
@ -12,9 +12,13 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
|
|
||||||
#include "ogc_input.h"
|
#ifdef HW_RVL
|
||||||
#include "ogc_audio.h"
|
#include <di/di.h>
|
||||||
#include "ogc_video.h"
|
#endif
|
||||||
|
|
||||||
|
#include "gx_input.h"
|
||||||
|
#include "gx_audio.h"
|
||||||
|
#include "gx_video.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define DEFAULT_PATH "/genplus"
|
#define DEFAULT_PATH "/genplus"
|
||||||
@ -30,7 +34,6 @@ 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();
|
||||||
extern void memfile_autoload();
|
extern void memfile_autoload();
|
||||||
extern void menu_updateInputs(u32 cnt);
|
|
||||||
|
|
||||||
extern u8 fat_enabled;
|
extern u8 fat_enabled;
|
||||||
extern u32 frameticker;
|
extern u32 frameticker;
|
Before Width: | Height: | Size: 341 KiB After Width: | Height: | Size: 341 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 450 B |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |