- removed some unused files.

This commit is contained in:
Christoph Oelckers 2019-09-20 22:55:44 +02:00
parent 3b8b2b1fe0
commit b34c48962a
6 changed files with 0 additions and 2172 deletions

View file

@ -269,12 +269,6 @@
<ClCompile Include="..\..\source\build\src\screenshot.cpp" />
<ClCompile Include="..\..\source\build\src\scriptfile.cpp" />
<ClCompile Include="..\..\source\build\src\sdlayer.cpp" />
<ClCompile Include="..\..\source\build\src\sdlayer12.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\source\build\src\sdlkeytrans.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@ -288,12 +282,6 @@
<ClCompile Include="..\..\source\build\src\tiles.cpp" />
<ClCompile Include="..\..\source\build\src\timer.cpp" />
<ClCompile Include="..\..\source\build\src\voxmodel.cpp" />
<ClCompile Include="..\..\source\build\src\wiibits.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\source\build\src\winbits.cpp" />
<ClCompile Include="..\..\source\thirdparty\src\xxhash.c" />
<ClCompile Include="..\..\source\glbackend\glbackend.cpp" />

View file

@ -43,7 +43,6 @@
<ClCompile Include="..\..\source\build\src\screenshot.cpp" />
<ClCompile Include="..\..\source\build\src\scriptfile.cpp" />
<ClCompile Include="..\..\source\build\src\sdlayer.cpp" />
<ClCompile Include="..\..\source\build\src\sdlayer12.cpp" />
<ClCompile Include="..\..\source\build\src\sdlkeytrans.cpp" />
<ClCompile Include="..\..\source\build\src\smalltextfont.cpp" />
<ClCompile Include="..\..\source\build\src\softsurface.cpp" />
@ -52,7 +51,6 @@
<ClCompile Include="..\..\source\build\src\tiles.cpp" />
<ClCompile Include="..\..\source\build\src\timer.cpp" />
<ClCompile Include="..\..\source\build\src\voxmodel.cpp" />
<ClCompile Include="..\..\source\build\src\wiibits.cpp" />
<ClCompile Include="..\..\source\build\src\winbits.cpp" />
<ClCompile Include="..\..\source\thirdparty\src\xxhash.c" />
<ClCompile Include="..\..\source\glbackend\glbackend.cpp" />

View file

@ -1,557 +0,0 @@
// SDL 1.2 compatibility.
#include <SDL/SDL_events.h>
#ifdef _WIN32
HWND win_gethwnd(void)
{
struct SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
if (SDL_GetWMInfo(&wmInfo) != 1)
{
initprintf("win_gethwnd: SDL_GetWindowWMInfo() failed: %s\n", SDL_GetError());
return 0;
}
return wmInfo.window;
}
#endif
int32_t videoSetVsync(int32_t newSync)
{
if (vsync_renderlayer == newSync)
return newSync;
vsync_renderlayer = newSync;
videoResetMode();
if (videoSetGameMode(fullscreen, xres, yres, bpp, upscalefactor))
OSD_Printf("restartvid: Reset failed...\n");
return newSync;
}
int32_t sdlayer_checkversion(void)
{
const SDL_version *linked = SDL_Linked_Version();
SDL_version compiled;
SDL_VERSION(&compiled);
initprintf("Initializing SDL system interface "
"(compiled against SDL version %d.%d.%d, found version %d.%d.%d)\n",
compiled.major, compiled.minor, compiled.patch, linked->major, linked->minor, linked->patch);
if (SDL_VERSIONNUM(linked->major, linked->minor, linked->patch) < SDL_REQUIREDVERSION)
{
/*reject running under SDL versions older than what is stated in sdl_inc.h */
initprintf("You need at least v%d.%d.%d of SDL to run this game\n", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z);
return -1;
}
return 0;
}
//
// initsystem() -- init SDL systems
//
int32_t initsystem(void)
{
#if defined NOSDLPARACHUTE
const int sdlinitflags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
#else
const int sdlinitflags = SDL_INIT_VIDEO;
#endif
mutex_init(&m_initprintf);
#ifdef _WIN32
win_init();
#endif
if (sdlayer_checkversion())
return -1;
if (SDL_Init(sdlinitflags))
{
initprintf("Initialization failed! (%s)\nNon-interactive mode enabled\n", SDL_GetError());
novideo = 1;
#ifdef USE_OPENGL
nogl = 1;
#endif
}
atexit(uninitsystem);
frameplace = 0;
lockcount = 0;
if (!novideo)
{
char drvname[32];
#ifdef USE_OPENGL
if (SDL_GL_LoadLibrary(0))
{
initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n");
nogl = 1;
}
#ifdef POLYMER
if (loadglulibrary(getenv("BUILD_GLULIB")))
{
initprintf("Failed loading GLU. GL modes will be unavailable.\n");
nogl = 1;
}
#endif
#endif
if (SDL_VideoDriverName(drvname, 32))
initprintf("Using \"%s\" video driver\n", drvname);
wm_setapptitle(apptitle);
}
#if defined GEKKO
SDL_ShowCursor(SDL_DISABLE);
#endif
return 0;
}
#ifdef GEKKO
static const char *joynames[3][15] = {
{
"Left Stick X", "Left Stick Y", "Right Stick X", "Right Stick Y", "Axis 5", "Axis 6", "Axis 7", "Axis 8",
"Axis 9", "Axis 10", "Axis 11", "Axis 12", "Axis 13", "Axis 14", "Axis 15",
},
{
"Button A", "Button B", "Button 1", "Button 2", "Button -", "Button +", "Button HOME", "Button Z", "Button C",
"Button X", "Button Y", "Trigger L", "Trigger R", "Trigger ZL", "Trigger ZR",
},
{
"D-Pad Up", "D-Pad Right", "D-Pad Down", "D-Pad Left", "Hat 5", "Hat 6", "Hat 7", "Hat 8", "Hat 9", "Hat 10",
"Hat 11", "Hat 12", "Hat 13", "Hat 14", "Hat 15",
}
};
const char *joyGetName(int32_t what, int32_t num)
{
switch (what)
{
case 0: // axis
if ((unsigned)num > (unsigned)joystick.numAxes) return NULL;
return joynames[0][num];
case 1: // button
if ((unsigned)num > (unsigned)joystick.numButtons) return NULL;
return joynames[1][num];
case 2: // hat
if ((unsigned)num > (unsigned)joystick.numHats) return NULL;
return joynames[2][num];
default:
return NULL;
}
}
#endif
//
// grabmouse_low() -- show/hide mouse cursor, lower level (doesn't check state).
// furthermore return 0 if successful.
//
static inline char grabmouse_low(char a)
{
#if !defined GEKKO
SDL_ShowCursor(a ? SDL_DISABLE : SDL_ENABLE);
return (SDL_WM_GrabInput(a ? SDL_GRAB_ON : SDL_GRAB_OFF) != (a ? SDL_GRAB_ON : SDL_GRAB_OFF));
#else
UNREFERENCED_PARAMETER(a);
return 0;
#endif
}
void videoGetModes(void)
{
int32_t i, maxx = 0, maxy = 0;
int32_t j;
static int32_t cdepths[] = { 8,
#ifdef USE_OPENGL
16, 24, 32,
#endif
0 };
SDL_Rect **modes;
SDL_PixelFormat pf;
pf.palette = NULL;
pf.BitsPerPixel = 8;
pf.BytesPerPixel = 1;
if (modeschecked || novideo)
return;
validmodecnt = 0;
// initprintf("Detecting video modes:\n");
// do fullscreen modes first
for (j = 0; cdepths[j]; j++)
{
#ifdef USE_OPENGL
if (nogl && cdepths[j] > 8)
continue;
#endif
pf.BitsPerPixel = cdepths[j];
pf.BytesPerPixel = cdepths[j] >> 3;
// We convert paletted contents to non-paletted
modes = SDL_ListModes((cdepths[j] == 8) ? NULL : &pf, SURFACE_FLAGS | SDL_FULLSCREEN);
if (modes == (SDL_Rect **)0)
{
if (cdepths[j] > 8)
cdepths[j] = -1;
continue;
}
if (modes == (SDL_Rect **)-1)
{
for (i = 0; g_defaultVideoModes[i].x; i++)
SDL_ADDMODE(g_defaultVideoModes[i].x, g_defaultVideoModes[i].y, cdepths[j], 1);
}
else
{
for (i = 0; modes[i]; i++)
{
if (!SDL_CHECKMODE(modes[i]->w, modes[i]->h))
continue;
SDL_ADDMODE(modes[i]->w, modes[i]->h, cdepths[j], 1);
if ((modes[i]->w > maxx) || (modes[i]->h > maxy))
{
maxx = modes[i]->w;
maxy = modes[i]->h;
}
}
}
}
SDL_CHECKFSMODES(maxx, maxy);
// add windowed modes next
for (j = 0; cdepths[j]; j++)
{
#ifdef USE_OPENGL
if (nogl && cdepths[j] > 8)
continue;
#endif
if (cdepths[j] < 0)
continue;
for (i = 0; g_defaultVideoModes[i].x; i++)
{
auto &mode = g_defaultVideoModes[i];
if (mode.x > maxx || mode.y > maxy || !SDL_CHECKMODE(mode.x, mode.y))
continue;
SDL_ADDMODE(mode.x, mode.y, cdepths[j], 0);
}
}
qsort((void *)validmode, validmodecnt, sizeof(struct validmode_t), &sortmodes);
modeschecked = 1;
}
//
// setvideomode() -- set SDL video mode
//
int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs)
{
int32_t regrab = 0, ret;
#ifdef USE_OPENGL
static int32_t ovsync = 1;
#endif
ret = setvideomode_sdlcommon(&x, &y, c, fs, &regrab);
if (ret != 1)
{
if (ret == 0)
{
setvideomode_sdlcommonpost(x, y, c, fs, regrab);
}
return ret;
}
// restore gamma before we change video modes if it was changed
if (sdl_surface && gammabrightness)
{
SDL_SetGammaRamp(sysgamma[0], sysgamma[1], sysgamma[2]);
gammabrightness = 0; // redetect on next mode switch
}
// deinit
destroy_window_resources();
initprintf("Setting video mode %dx%d (%d-bpp %s)\n", x, y, c, ((fs & 1) ? "fullscreen" : "windowed"));
#ifdef USE_OPENGL
if (c > 8 || !nogl)
{
int32_t i, j, multisamplecheck = (glmultisample > 0);
if (nogl)
return -1;
# ifdef _WIN32
win_setvideomode(c);
# endif
struct glattribs
{
SDL_GLattr attr;
int32_t value;
} sdlayer_gl_attributes [] =
{
{ SDL_GL_DOUBLEBUFFER, 1 },
{ SDL_GL_MULTISAMPLEBUFFERS, glmultisample > 0 },
{ SDL_GL_MULTISAMPLESAMPLES, glmultisample },
{ SDL_GL_STENCIL_SIZE, 8 },
{ SDL_GL_ACCELERATED_VISUAL, 1 },
{ SDL_GL_SWAP_CONTROL, vsync_renderlayer },
};
do
{
SDL_GL_ATTRIBUTES(i, sdlayer_gl_attributes);
/* HACK: changing SDL GL attribs only works before surface creation,
so we have to create a new surface in a different format first
to force the surface we WANT to be recreated instead of reused. */
if (vsync_renderlayer != ovsync)
{
if (sdl_surface)
{
SDL_FreeSurface(sdl_surface);
sdl_surface =
SDL_SetVideoMode(1, 1, 8, SDL_NOFRAME | SURFACE_FLAGS | ((fs & 1) ? SDL_FULLSCREEN : 0));
SDL_FreeSurface(sdl_surface);
}
ovsync = vsync_renderlayer;
}
sdl_surface = SDL_SetVideoMode(x, y, c, SDL_OPENGL | ((fs & 1) ? SDL_FULLSCREEN : 0));
if (!sdl_surface)
{
if (multisamplecheck)
{
initprintf("Multisample mode not possible. Retrying without multisampling.\n");
glmultisample = 0;
continue;
}
initprintf("Unable to set video mode!\n");
return -1;
}
} while (multisamplecheck--);
gladLoadGLLoader(SDL_GL_GetProcAddress);
}
else
#endif // defined USE_OPENGL
{
// We convert paletted contents to non-paletted
sdl_surface = SDL_SetVideoMode(x, y, 0, SURFACE_FLAGS | ((fs & 1) ? SDL_FULLSCREEN : 0));
if (!sdl_surface)
{
initprintf("Unable to set video mode!\n");
return -1;
}
}
setvideomode_sdlcommonpost(x, y, c, fs, regrab);
return 0;
}
//
// showframe() -- update the display
//
void videoShowFrame(int32_t w)
{
UNREFERENCED_PARAMETER(w);
#ifdef USE_OPENGL
if (!nogl)
{
if (bpp > 8)
{
if (palfadedelta)
fullscreen_tint_gl(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta);
}
else
{
glsurface_blitBuffer();
}
SDL_GL_SwapBuffers();
return;
}
#endif
if (offscreenrendering) return;
if (lockcount)
{
printf("Frame still locked %d times when showframe() called.\n", lockcount);
while (lockcount) videoEndDrawing();
}
if (SDL_MUSTLOCK(sdl_surface)) SDL_LockSurface(sdl_surface);
softsurface_blitBuffer((uint32_t*) sdl_surface->pixels, sdl_surface->format->BitsPerPixel);
if (SDL_MUSTLOCK(sdl_surface)) SDL_UnlockSurface(sdl_surface);
SDL_Flip(sdl_surface);
}
// SDL 1.2 specific event handling
int32_t handleevents_pollsdl(void)
{
int32_t code, rv = 0, j;
SDL_Event ev;
while (SDL_PollEvent(&ev))
{
switch (ev.type)
{
case SDL_KEYDOWN:
case SDL_KEYUP:
code = keytranslation[ev.key.keysym.sym];
#ifdef KEY_PRINT_DEBUG
printf("keytranslation[%d] = %s (%d) %s\n", ev.key.keysym.sym, g_keyNameTable[code], code,
ev.key.type == SDL_KEYDOWN ? "DOWN" : "UP");
#endif
if (code != OSD_OSDKey() && ev.key.keysym.unicode != 0 && ev.key.type == SDL_KEYDOWN &&
(ev.key.keysym.unicode & 0xff80) == 0 && !keyBufferFull())
{
if (OSD_HandleChar(ev.key.keysym.unicode & 0x7f))
keyBufferInsert(ev.key.keysym.unicode & 0x7f);
}
// hook in the osd
if ((j = OSD_HandleScanCode(code, (ev.key.type == SDL_KEYDOWN))) <= 0)
{
if (j == -1) // osdkey
{
for (j = 0; j < NUMKEYS; ++j)
{
if (keyGetState(j))
{
keySetState(j, 0);
if (keypresscallback)
keypresscallback(j, 0);
}
}
}
break;
}
if (ev.key.type == SDL_KEYDOWN)
{
if (!keyGetState(code))
{
keySetState(code, 1);
if (keypresscallback)
keypresscallback(code, 1);
}
}
else
{
#ifdef __linux
if (code == 0x59) // pause
break;
#endif
keySetState(code, 0);
if (keypresscallback)
keypresscallback(code, 0);
}
break;
case SDL_ACTIVEEVENT:
if (ev.active.state & SDL_APPINPUTFOCUS)
{
appactive = ev.active.gain;
if (g_mouseGrabbed && g_mouseEnabled)
grabmouse_low(!!appactive);
# ifdef _WIN32
// Win_SetKeyboardLayoutUS(appactive);
if (backgroundidle)
SetPriorityClass(GetCurrentProcess(),
appactive ? NORMAL_PRIORITY_CLASS : IDLE_PRIORITY_CLASS);
# endif
rv = -1;
if (ev.active.state & SDL_APPMOUSEFOCUS)
g_mouseInsideWindow = ev.active.gain;
}
break;
// SDL_MOUSEMOTION needs to fall through to default... this is just GEKKO processing!
case SDL_MOUSEMOTION:
#ifdef GEKKO
// check if it's a wiimote pointer pretending to be a mouse
if (ev.motion.state & SDL_BUTTON_X2MASK)
{
// the absolute values are used to draw the crosshair
g_mouseAbs.x = ev.motion.x;
g_mouseAbs.y = ev.motion.y;
// hack: reduce the scale of the "relative" motions
// to make it act more like a real mouse
ev.motion.xrel /= 16;
ev.motion.yrel /= 12;
}
#endif
fallthrough__;
default: // OSD_Printf("Got event (%d)\n", ev.type); break;
rv = handleevents_sdlcommon(&ev);
break;
}
}
return rv;
}
// from SDL HG, modified
int32_t SDL_WaitEventTimeout(SDL_Event *event, int32_t timeout)
{
uint32_t expiration = 0;
if (timeout > 0)
expiration = SDL_GetTicks() + timeout;
for (;;)
{
SDL_PumpEvents();
switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, ~0)) // SDL_FIRSTEVENT, SDL_LASTEVENT)) {
{
case -1: return 0;
case 1: return 1;
case 0:
if (timeout == 0)
{
/* Polling and no events, just return */
return 0;
}
if (timeout > 0 && ((int32_t)(SDL_GetTicks() - expiration) >= 0))
{
/* Timeout expired and no events */
return 0;
}
SDL_Delay(10);
break;
}
}
}

View file

@ -1,548 +0,0 @@
#include "gtkpixdata.h"
#include "dynamicgtk.h"
#include "build.h"
#include "editor.h"
#include "baselayer.h"
enum
{
TAB_CONFIG,
TAB_MESSAGES,
};
static struct
{
GtkWidget *startwin;
GtkWidget *hlayout;
GtkWidget *banner;
GtkWidget *vlayout;
GtkWidget *tabs;
GtkWidget *configtlayout;
GtkWidget *vmode2dlabel;
GtkWidget *vmode3dlabel;
GtkWidget *vmode2dcombo;
GtkWidget *vmode3dcombo;
GtkWidget *fullscreencheck;
GtkWidget *emptyhlayout;
GtkWidget *alwaysshowcheck;
GtkWidget *configtab;
GtkWidget *messagesscroll;
GtkWidget *messagestext;
GtkWidget *messagestab;
GtkWidget *buttons;
GtkWidget *cancelbutton;
GtkWidget *cancelbuttonalign;
GtkWidget *cancelbuttonlayout;
GtkWidget *cancelbuttonicon;
GtkWidget *cancelbuttonlabel;
GtkWidget *startbutton;
GtkWidget *startbuttonalign;
GtkWidget *startbuttonlayout;
GtkWidget *startbuttonicon;
GtkWidget *startbuttonlabel;
GtkAccelGroup *accel_group;
} stwidgets;
static struct
{
int32_t fullscreen;
int32_t xdim2d, ydim2d;
int32_t xdim3d, ydim3d, bpp3d;
int32_t forcesetup;
} settings;
static int32_t retval = -1, mode = TAB_MESSAGES;
extern int32_t gtkenabled;
static void PopulateForm(void);
// -- EVENT CALLBACKS AND CREATION STUFF --------------------------------------
static void on_vmode2dcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
GtkTreeModel *data;
GtkTreeIter iter;
int32_t val;
UNREFERENCED_PARAMETER(user_data);
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
if (!(data = gtk_combo_box_get_model(combobox))) return;
gtk_tree_model_get(data, &iter, 1, &val, -1);
settings.xdim2d = validmode[val].xdim;
settings.ydim2d = validmode[val].ydim;
}
static void on_vmode3dcombo_changed(GtkComboBox *combobox, gpointer user_data)
{
GtkTreeModel *data;
GtkTreeIter iter;
int32_t val;
UNREFERENCED_PARAMETER(user_data);
if (!gtk_combo_box_get_active_iter(combobox, &iter)) return;
if (!(data = gtk_combo_box_get_model(combobox))) return;
gtk_tree_model_get(data, &iter, 1, &val, -1);
settings.xdim3d = validmode[val].xdim;
settings.ydim3d = validmode[val].ydim;
settings.bpp3d = validmode[val].bpp;
}
static void on_fullscreencheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
UNREFERENCED_PARAMETER(user_data);
settings.fullscreen = (gtk_toggle_button_get_active(togglebutton) == TRUE);
PopulateForm();
}
static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
UNREFERENCED_PARAMETER(user_data);
settings.forcesetup = (gtk_toggle_button_get_active(togglebutton) == TRUE);
}
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
{
UNREFERENCED_PARAMETER(button);
UNREFERENCED_PARAMETER(user_data);
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
else quitevent++;
}
static void on_startbutton_clicked(GtkButton *button, gpointer user_data)
{
UNREFERENCED_PARAMETER(button);
UNREFERENCED_PARAMETER(user_data);
retval = 1;
gtk_main_quit();
}
static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
UNREFERENCED_PARAMETER(widget);
UNREFERENCED_PARAMETER(event);
UNREFERENCED_PARAMETER(user_data);
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
else quitevent++;
return TRUE; // FALSE would let the event go through. we want the game to decide when to close
}
// -- SUPPORT FUNCTIONS -------------------------------------------------------
static GdkPixbuf *load_banner(void)
{
return gdk_pixbuf_from_pixdata((GdkPixdata const *)&startbanner_pixdata, FALSE, NULL);
}
static void SetPage(int32_t n)
{
if (!gtkenabled || !stwidgets.startwin) return;
mode = n;
gtk_notebook_set_current_page(GTK_NOTEBOOK(stwidgets.tabs), n);
// each control in the config page vertical layout plus the start button should be made (in)sensitive
if (n == TAB_CONFIG) n = TRUE; else n = FALSE;
gtk_widget_set_sensitive(stwidgets.startbutton, n);
gtk_container_foreach(GTK_CONTAINER(stwidgets.configtlayout),
(GtkCallback)gtk_widget_set_sensitive,
(gpointer)&n);
}
static void PopulateForm(void)
{
int32_t mode2d, mode3d, i;
GtkListStore *modes2d, *modes3d;
GtkTreeIter iter;
GtkComboBox *box2d, *box3d;
char buf[64];
mode2d = videoCheckMode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1);
mode3d = videoCheckMode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode2d < 0) mode2d = 0;
if (mode3d < 0)
{
int32_t i, cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; }
for (; cd[i]; i++)
{
mode3d = videoCheckMode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
break;
}
}
box2d = GTK_COMBO_BOX(stwidgets.vmode2dcombo);
box3d = GTK_COMBO_BOX(stwidgets.vmode3dcombo);
modes2d = GTK_LIST_STORE(gtk_combo_box_get_model(box2d));
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes2d);
gtk_list_store_clear(modes3d);
for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list
Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL");
gtk_list_store_append(modes3d, &iter);
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
if (i == mode3d)
{
g_signal_handlers_block_by_func(box3d, (gpointer)on_vmode3dcombo_changed, NULL);
gtk_combo_box_set_active_iter(box3d, &iter);
g_signal_handlers_unblock_by_func(box3d, (gpointer)on_vmode3dcombo_changed, NULL);
}
// only 8-bit modes get used for 2D
if (validmode[i].bpp != 8 || validmode[i].xdim < 640 || validmode[i].ydim < 480) continue;
Bsprintf(buf, "%d x %d", validmode[i].xdim, validmode[i].ydim);
gtk_list_store_append(modes2d, &iter);
gtk_list_store_set(modes2d, &iter, 0,buf, 1,i, -1);
if (i == mode2d)
{
g_signal_handlers_block_by_func(box2d, (gpointer)on_vmode2dcombo_changed, NULL);
gtk_combo_box_set_active_iter(box2d, &iter);
g_signal_handlers_unblock_by_func(box2d, (gpointer)on_vmode2dcombo_changed, NULL);
}
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.fullscreencheck), settings.fullscreen);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stwidgets.alwaysshowcheck), settings.forcesetup);
}
static GtkWidget *create_window(void)
{
stwidgets.accel_group = gtk_accel_group_new();
// Basic window
stwidgets.startwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(stwidgets.startwin), apptitle); // NOTE: use global app title
gtk_window_set_position(GTK_WINDOW(stwidgets.startwin), GTK_WIN_POS_CENTER);
gtk_window_set_resizable(GTK_WINDOW(stwidgets.startwin), FALSE);
gtk_window_set_type_hint(GTK_WINDOW(stwidgets.startwin), GDK_WINDOW_TYPE_HINT_DIALOG);
// Horizontal layout of banner and controls
stwidgets.hlayout = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(stwidgets.startwin), stwidgets.hlayout);
// banner
{
GdkPixbuf *pixbuf = load_banner();
stwidgets.banner = gtk_image_new_from_pixbuf(pixbuf);
g_object_unref((gpointer)pixbuf);
}
gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.banner, FALSE, FALSE, 0);
gtk_misc_set_alignment(GTK_MISC(stwidgets.banner), 0.5, 0);
// Vertical layout of tab control and start+cancel buttons
stwidgets.vlayout = gtk_vbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(stwidgets.hlayout), stwidgets.vlayout, TRUE, TRUE, 0);
// Tab control
stwidgets.tabs = gtk_notebook_new();
gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.tabs, TRUE, TRUE, 0);
gtk_container_set_border_width(GTK_CONTAINER(stwidgets.tabs), 4);
// layout table of config page
stwidgets.configtlayout = gtk_table_new(4, 3, FALSE);
gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.configtlayout);
// 2D video mode label
stwidgets.vmode2dlabel = gtk_label_new_with_mnemonic("_2D Video mode:");
gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode2dlabel), 0.3, 0);
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dlabel, 0,1, 0,1, GTK_FILL, (GtkAttachOptions)0, 4, 6);
// 2D video mode combo
{
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
GtkCellRenderer *cell;
stwidgets.vmode2dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
g_object_unref(G_OBJECT(list));
cell = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode2dcombo), cell, "text", 0, NULL);
}
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode2dcombo, 1,2, 0,1,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 6);
gtk_widget_add_accelerator(stwidgets.vmode2dcombo, "grab_focus", stwidgets.accel_group,
GDK_2, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Fullscreen checkbox
stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.fullscreencheck, 2,3, 0,1, GTK_FILL, (GtkAttachOptions)0, 4, 6);
gtk_widget_add_accelerator(stwidgets.fullscreencheck, "grab_focus", stwidgets.accel_group,
GDK_F, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// 3D video mode label
stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_3D Video mode:");
gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0);
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 1,2, GTK_FILL, (GtkAttachOptions)0, 4, 6);
// 3D video mode combo
{
GtkListStore *list = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
GtkCellRenderer *cell;
stwidgets.vmode3dcombo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(list));
g_object_unref(G_OBJECT(list));
cell = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL);
}
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 1,2,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)0, 4, 0);
gtk_widget_add_accelerator(stwidgets.vmode3dcombo, "grab_focus", stwidgets.accel_group,
GDK_3, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Empty horizontal layout
stwidgets.emptyhlayout = gtk_hbox_new(TRUE, 0);
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.emptyhlayout, 0,1, 2,3, (GtkAttachOptions)0,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0);
// Always show config checkbox
stwidgets.alwaysshowcheck = gtk_check_button_new_with_mnemonic("_Always show configuration on start");
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.alwaysshowcheck, 0,2, 3,4, GTK_FILL, (GtkAttachOptions)0, 4, 6);
gtk_widget_add_accelerator(stwidgets.alwaysshowcheck, "grab_focus", stwidgets.accel_group,
GDK_A, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
// Configuration tab
stwidgets.configtab = gtk_label_new("Configuration");
gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 0), stwidgets.configtab);
// Messages scrollable area
stwidgets.messagesscroll = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(stwidgets.tabs), stwidgets.messagesscroll);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(stwidgets.messagesscroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
// Messages text area
stwidgets.messagestext = gtk_text_view_new();
gtk_container_add(GTK_CONTAINER(stwidgets.messagesscroll), stwidgets.messagestext);
gtk_text_view_set_editable(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(stwidgets.messagestext), GTK_WRAP_WORD);
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(stwidgets.messagestext), FALSE);
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2);
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(stwidgets.messagestext), 2);
// Messages tab
stwidgets.messagestab = gtk_label_new("Messages");
gtk_notebook_set_tab_label(GTK_NOTEBOOK(stwidgets.tabs), gtk_notebook_get_nth_page(GTK_NOTEBOOK(stwidgets.tabs), 1), stwidgets.messagestab);
// Dialogue box buttons layout
stwidgets.buttons = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(stwidgets.vlayout), stwidgets.buttons, FALSE, TRUE, 0);
gtk_container_set_border_width(GTK_CONTAINER(stwidgets.buttons), 3);
gtk_button_box_set_layout(GTK_BUTTON_BOX(stwidgets.buttons), GTK_BUTTONBOX_END);
// Cancel button
stwidgets.cancelbutton = gtk_button_new();
gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.cancelbutton);
GTK_WIDGET_SET_FLAGS(stwidgets.cancelbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator(stwidgets.cancelbutton, "grab_focus", stwidgets.accel_group,
GDK_C, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator(stwidgets.cancelbutton, "clicked", stwidgets.accel_group,
GDK_Escape, (GdkModifierType)0,
GTK_ACCEL_VISIBLE);
stwidgets.cancelbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_container_add(GTK_CONTAINER(stwidgets.cancelbutton), stwidgets.cancelbuttonalign);
stwidgets.cancelbuttonlayout = gtk_hbox_new(FALSE, 2);
gtk_container_add(GTK_CONTAINER(stwidgets.cancelbuttonalign), stwidgets.cancelbuttonlayout);
stwidgets.cancelbuttonicon = gtk_image_new_from_stock("gtk-cancel", GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonicon, FALSE, FALSE, 0);
stwidgets.cancelbuttonlabel = gtk_label_new_with_mnemonic("_Cancel");
gtk_box_pack_start(GTK_BOX(stwidgets.cancelbuttonlayout), stwidgets.cancelbuttonlabel, FALSE, FALSE, 0);
// Start button
stwidgets.startbutton = gtk_button_new();
gtk_container_add(GTK_CONTAINER(stwidgets.buttons), stwidgets.startbutton);
GTK_WIDGET_SET_FLAGS(stwidgets.startbutton, GTK_CAN_DEFAULT);
gtk_widget_add_accelerator(stwidgets.startbutton, "grab_focus", stwidgets.accel_group,
GDK_S, GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
gtk_widget_add_accelerator(stwidgets.startbutton, "clicked", stwidgets.accel_group,
GDK_Return, (GdkModifierType)0,
GTK_ACCEL_VISIBLE);
stwidgets.startbuttonalign = gtk_alignment_new(0.5, 0.5, 0, 0);
gtk_container_add(GTK_CONTAINER(stwidgets.startbutton), stwidgets.startbuttonalign);
stwidgets.startbuttonlayout = gtk_hbox_new(FALSE, 2);
gtk_container_add(GTK_CONTAINER(stwidgets.startbuttonalign), stwidgets.startbuttonlayout);
stwidgets.startbuttonicon = gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonicon, FALSE, FALSE, 0);
stwidgets.startbuttonlabel = gtk_label_new_with_mnemonic("_Start");
gtk_box_pack_start(GTK_BOX(stwidgets.startbuttonlayout), stwidgets.startbuttonlabel, FALSE, FALSE, 0);
// Wire up the signals
g_signal_connect((gpointer) stwidgets.startwin, "delete_event",
G_CALLBACK(on_startwin_delete_event),
NULL);
g_signal_connect((gpointer) stwidgets.vmode2dcombo, "changed",
G_CALLBACK(on_vmode2dcombo_changed),
NULL);
g_signal_connect((gpointer) stwidgets.vmode3dcombo, "changed",
G_CALLBACK(on_vmode3dcombo_changed),
NULL);
g_signal_connect((gpointer) stwidgets.fullscreencheck, "toggled",
G_CALLBACK(on_fullscreencheck_toggled),
NULL);
g_signal_connect((gpointer) stwidgets.alwaysshowcheck, "toggled",
G_CALLBACK(on_alwaysshowcheck_toggled),
NULL);
g_signal_connect((gpointer) stwidgets.cancelbutton, "clicked",
G_CALLBACK(on_cancelbutton_clicked),
NULL);
g_signal_connect((gpointer) stwidgets.startbutton, "clicked",
G_CALLBACK(on_startbutton_clicked),
NULL);
// Associate labels with their controls
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode2dlabel), stwidgets.vmode2dcombo);
gtk_label_set_mnemonic_widget(GTK_LABEL(stwidgets.vmode3dlabel), stwidgets.vmode3dcombo);
gtk_window_add_accel_group(GTK_WINDOW(stwidgets.startwin), stwidgets.accel_group);
return stwidgets.startwin;
}
// -- BUILD ENTRY POINTS ------------------------------------------------------
int32_t startwin_open(void)
{
if (!gtkenabled) return 0;
if (stwidgets.startwin) return 1;
stwidgets.startwin = create_window();
if (stwidgets.startwin)
{
SetPage(TAB_MESSAGES);
gtk_widget_show_all(stwidgets.startwin);
gtk_main_iteration_do(FALSE);
return 0;
}
return -1;
}
int32_t startwin_close(void)
{
if (!gtkenabled) return 0;
if (!stwidgets.startwin) return 1;
gtk_widget_destroy(stwidgets.startwin);
stwidgets.startwin = NULL;
return 0;
}
int32_t startwin_puts(const char *str)
{
GtkWidget *textview;
GtkTextBuffer *textbuffer;
GtkTextIter enditer;
GtkTextMark *mark;
const char *aptr, *bptr;
if (!gtkenabled || !str) return 0;
if (!stwidgets.startwin) return 1;
if (!(textview = stwidgets.messagestext)) return -1;
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_buffer_get_end_iter(textbuffer, &enditer);
for (aptr = bptr = str; *aptr != 0;)
{
switch (*bptr)
{
case '\b':
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
#if GTK_CHECK_VERSION(2,6,0)
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
#else
{
GtkTextIter iter2 = enditer;
gtk_text_iter_backward_cursor_position(&iter2);
//FIXME: this seems be deleting one too many chars somewhere!
if (!gtk_text_iter_equal(&iter2, &enditer))
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
}
#endif
aptr = ++bptr;
break;
case 0:
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
aptr = bptr;
break;
case '\r': // FIXME
default:
bptr++;
break;
}
}
mark = gtk_text_buffer_create_mark(textbuffer, NULL, &enditer, 1);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(textview), mark, 0.0, FALSE, 0.0, 1.0);
gtk_text_buffer_delete_mark(textbuffer, mark);
return 0;
}
int32_t startwin_settitle(const char *title)
{
if (!gtkenabled) return 0;
if (!stwidgets.startwin) return 1;
gtk_window_set_title(GTK_WINDOW(stwidgets.startwin), title);
return 0;
}
int32_t startwin_idle(void *s)
{
UNREFERENCED_PARAMETER(s);
if (!gtkenabled) return 0;
//if (!stwidgets.startwin) return 1;
gtk_main_iteration_do(FALSE);
return 0;
}
int32_t startwin_run(void)
{
if (!gtkenabled) return 1;
if (!stwidgets.startwin) return 1;
SetPage(TAB_CONFIG);
settings.fullscreen = fullscreen;
settings.xdim2d = xdim2d;
settings.ydim2d = ydim2d;
settings.xdim3d = xdimgame;
settings.ydim3d = ydimgame;
settings.bpp3d = bppgame;
settings.forcesetup = forcesetup;
PopulateForm();
gtk_main();
SetPage(TAB_MESSAGES);
if (retval)
{
fullscreen = settings.fullscreen;
xdim2d = settings.xdim2d;
ydim2d = settings.ydim2d;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;
bppgame = settings.bpp3d;
forcesetup = settings.forcesetup;
}
return retval;
}

View file

@ -1,493 +0,0 @@
#ifndef _WIN32
#error Only for Windows
#endif
#include "compat.h"
#define NEED_WINDOWSX_H
#define NEED_COMMCTRL_H
#include "windows_inc.h"
#include "renderlayer.h"
#ifdef STARTUP_SETUP_WINDOW
#include "build.h"
#include "editor.h"
#include "winlayer.h"
#include "startwin.editor.h"
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct
{
int32_t fullscreen;
int32_t xdim2d, ydim2d;
int32_t xdim3d, ydim3d, bpp3d;
int32_t forcesetup;
} settings;
static HWND startupdlg = NULL;
static HWND pages[2] = { NULL, NULL};
static int32_t done = -1, mode = TAB_CONFIG;
static void PopulateForm(void)
{
int32_t i,j;
char buf[64];
int32_t mode2d, mode3d;
HWND hwnd2d, hwnd3d;
hwnd2d = GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE);
hwnd3d = GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE);
mode2d = videoCheckMode(&settings.xdim2d, &settings.ydim2d, 8, settings.fullscreen, 1);
mode3d = videoCheckMode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode2d < 0) mode2d = 0;
if (mode3d < 0)
{
int32_t cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; }
for (; cd[i]; i++)
{
mode3d = videoCheckMode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
break;
}
}
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCALWAYSSHOW), (settings.forcesetup ? BST_CHECKED : BST_UNCHECKED));
(void)ComboBox_ResetContent(hwnd2d);
(void)ComboBox_ResetContent(hwnd3d);
for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list
Bsprintf(buf, "%dx%d %s", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp == 8 ? "software" : "OpenGL");
j = ComboBox_AddString(hwnd3d, buf);
(void)ComboBox_SetItemData(hwnd3d, j, i);
if (i == mode3d)(void)ComboBox_SetCurSel(hwnd3d, j);
// only 8-bit modes get used for 2D
if (validmode[i].bpp != 8 || validmode[i].xdim < 640 || validmode[i].ydim < 480) continue;
Bsprintf(buf, "%d x %d", validmode[i].xdim, validmode[i].ydim);
j = ComboBox_AddString(hwnd2d, buf);
(void)ComboBox_SetItemData(hwnd2d, j, i);
if (i == mode2d)(void)ComboBox_SetCurSel(hwnd2d, j);
}
}
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen;
PopulateForm();
return TRUE;
case IDC2DVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
int32_t i;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR)
{
settings.xdim2d = validmode[i].xdim;
settings.ydim2d = validmode[i].ydim;
}
}
return TRUE;
case IDC3DVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
int32_t i;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR)
{
settings.xdim3d = validmode[i].xdim;
settings.ydim3d = validmode[i].ydim;
settings.bpp3d = validmode[i].bpp;
}
}
return TRUE;
case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE;
default:
break;
}
break;
default:
break;
}
return FALSE;
}
static void SetPage(int32_t n)
{
HWND tab;
int32_t cur;
tab = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
cur = (int32_t)SendMessage(tab, TCM_GETCURSEL,0,0);
ShowWindow(pages[cur],SW_HIDE);
SendMessage(tab, TCM_SETCURSEL, n, 0);
ShowWindow(pages[n],SW_SHOW);
mode = n;
SetFocus(GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL));
}
static void EnableConfig(int32_t n)
{
//EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_CANCEL), n);
EnableWindow(GetDlgItem(startupdlg, WIN_STARTWIN_START), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC2DVMODE), n);
EnableWindow(GetDlgItem(pages[TAB_CONFIG], IDC3DVMODE), n);
}
static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HBITMAP hbmp = NULL;
HDC hdc;
switch (uMsg)
{
case WM_INITDIALOG:
{
HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int32_t xoffset = 0, yoffset = 0;
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
ZeroMemory(&chrome, sizeof(chrome));
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// Knock off the non-client area of the main dialogue to give just the client area
rdlg.left -= chrome.left; rdlg.top -= chrome.top;
rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom;
// Translate them to client-relative coordinates wrt the main dialogue window
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left; rtab.top -= rdlg.top;
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left; rstart.top -= rdlg.top;
// And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0; rdlg.top = 0;
// Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
GetClientRect(hwnd, &r);
xoffset = r.right;
yoffset = r.bottom - rdlg.bottom;
// Shift and resize the controls that require it
rtab.left += xoffset; rtab.bottom += yoffset;
rcancel.left += xoffset; rcancel.top += yoffset;
rstart.left += xoffset; rstart.top += yoffset;
rdlg.right += xoffset;
rdlg.bottom += yoffset;
// Move the controls to their new positions
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
// Move the main dialogue to the centre of the screen
hdc = GetDC(NULL);
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc);
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
// Add tabs to the tab control
{
TCITEM tab;
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
ZeroMemory(&tab, sizeof(tab));
tab.mask = TCIF_TEXT;
static char textSetup[] = TEXT("Setup");
tab.pszText = textSetup;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
static char textMessageLog[] = TEXT("Message Log");
tab.pszText = textMessageLog;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r));
GetClientRect(hwnd, &r);
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
r.right -= r.left-1;
r.bottom -= r.top-1;
r.top += rtab.top;
r.left += rtab.left;
// Create the pages and position them in the tab control, but hide them
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
// Tell the editfield acting as the console to exclude the width of the scrollbar
GetClientRect(pages[TAB_MESSAGES],&r);
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
r.left = r.top = 0;
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
}
return FALSE;
}
case WM_NOTIFY:
{
LPNMHDR nmhdr = (LPNMHDR)lParam;
int32_t cur;
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
cur = (int32_t)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code)
{
case TCN_SELCHANGING:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
}
break;
}
case WM_CLOSE:
if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
case WM_DESTROY:
if (hbmp)
{
DeleteObject(hbmp);
hbmp = NULL;
}
if (pages[TAB_CONFIG])
{
DestroyWindow(pages[TAB_CONFIG]);
pages[TAB_CONFIG] = NULL;
}
startupdlg = NULL;
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case WIN_STARTWIN_CANCEL:
if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
case WIN_STARTWIN_START:
done = 1; return TRUE;
}
return FALSE;
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == pages[TAB_MESSAGES])
return (BOOL)(intptr_t)GetSysColorBrush(COLOR_WINDOW);
break;
default:
break;
}
return FALSE;
}
int32_t startwin_open(void)
{
INITCOMMONCONTROLSEX icc;
if (startupdlg) return 1;
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg)
{
SetPage(TAB_MESSAGES);
EnableConfig(0);
return 0;
}
return -1;
}
int32_t startwin_close(void)
{
if (!startupdlg) return 1;
DestroyWindow(startupdlg);
startupdlg = NULL;
return 0;
}
int32_t startwin_puts(const char *buf)
{
const char *p = NULL, *q = NULL;
static char workbuf[1024];
static int32_t newline = 0;
int32_t curlen, linesbefore, linesafter;
HWND edctl;
int32_t vis;
static HWND dactrl = NULL;
if (!startupdlg) return 1;
edctl = pages[TAB_MESSAGES];
if (!edctl) return -1;
if (!dactrl) dactrl = GetDlgItem(startupdlg, WIN_STARTWIN_TABCTL);
vis = ((int32_t)SendMessage(dactrl, TCM_GETCURSEL,0,0) == TAB_MESSAGES);
if (vis) SendMessage(edctl, WM_SETREDRAW, FALSE,0);
curlen = SendMessage(edctl, WM_GETTEXTLENGTH, 0,0);
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
while (*p)
{
if (newline)
{
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
newline = 0;
}
q = p;
while (*q && *q != '\n') q++;
Bmemcpy(workbuf, p, q-p);
if (*q == '\n')
{
if (!q[1])
{
newline = 1;
workbuf[q-p] = 0;
}
else
{
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
}
else
{
workbuf[q-p] = 0;
p = q;
}
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)workbuf);
}
linesafter = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
SendMessage(edctl, EM_LINESCROLL, 0, linesafter-linesbefore);
if (vis) SendMessage(edctl, WM_SETREDRAW, TRUE,0);
return 0;
}
int32_t startwin_settitle(const char *str)
{
if (!startupdlg) return 1;
SetWindowText(startupdlg, str);
return 0;
}
int32_t startwin_idle(void *v)
{
if (!startupdlg || !IsWindow(startupdlg)) return 0;
if (IsDialogMessage(startupdlg, (MSG *)v)) return 1;
return 0;
}
int32_t startwin_run(void)
{
MSG msg;
if (!startupdlg) return 1;
done = -1;
SetPage(TAB_CONFIG);
EnableConfig(1);
settings.fullscreen = fullscreen;
settings.xdim2d = xdim2d;
settings.ydim2d = ydim2d;
settings.xdim3d = xdimgame;
settings.ydim3d = ydimgame;
settings.bpp3d = bppgame;
settings.forcesetup = forcesetup;
PopulateForm();
while (done < 0)
{
switch (GetMessage(&msg, NULL, 0,0))
{
case 0:
done = 1; break;
case -1:
return -1;
default:
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
}
}
SetPage(TAB_MESSAGES);
EnableConfig(0);
if (done)
{
fullscreen = settings.fullscreen;
xdim2d = settings.xdim2d;
ydim2d = settings.ydim2d;
xdimgame = settings.xdim3d;
ydimgame = settings.ydim3d;
bppgame = settings.bpp3d;
forcesetup = settings.forcesetup;
}
return done;
}
#endif // STARTUP_SETUP_WINDOW

View file

@ -1,560 +0,0 @@
#include "wiibits.h"
#include "baselayer.h"
#include "common.h"
#include <ogc/system.h>
#include <ogc/video.h>
#include <ogc/video_types.h>
#include <ogc/gx.h>
#include <ogc/pad.h>
#include <ogc/consol.h>
#include <ogc/lwp.h>
#include <ogc/lwp_watchdog.h>
#include <ogc/lwp_threads.h>
#include <ogc/ios.h>
#include <ogc/color.h>
#include <gctypes.h> // for bool
#include "vfs.h"
#ifdef __cplusplus
extern "C" {
#endif
extern buildvfs_FILE osdlog;
extern void L2Enhance();
extern void CON_EnableGecko(int channel,int safe);
extern bool fatInit(uint32_t cacheSize, bool setAsDefaultDevice);
extern void WII_InitVideoSystem(void);
extern unsigned char *xfb;
extern GXRModeObj *vmode;
#ifdef __cplusplus
}
#endif
enum
{
Black = 0,
Red = 1,
Green = 2,
Yellow = 3,
Blue = 4,
Magenta = 5,
Cyan = 6,
White = 7
};
static void ConsoleColor(uint8_t bgcolor, uint8_t bgbold, uint8_t fgcolor, uint8_t fgbold)
{
Bprintf("\x1b[%u;%dm\x1b[%u;%dm", fgcolor + 30, fgbold, bgcolor + 40, bgbold);
}
static void print_centered(const int32_t width, const char *part1, const char *part2)
{
const int32_t length = Bstrlen(part1) + Bstrlen(part2) + 1;
const int32_t leftbuf = (width-1 - length) / 2;
const int32_t rightbuf = width-1 - leftbuf - length;
Bprintf("%*s%s %s%*s\n", leftbuf, " ", part1, part2, rightbuf, " ");
}
void wii_open(void)
{
struct { int x, y; } ConsoleExtent;
L2Enhance();
CON_EnableGecko(1, 1);
Bprintf("Console started\n");
fatInit(28, true);
// init the console for the title bar
CON_InitEx(vmode, 0, 12, vmode->viWidth, 68);
ConsoleColor(Blue, 0, White, 0);
CON_GetMetrics(&ConsoleExtent.x, &ConsoleExtent.y);
print_centered(ConsoleExtent.x, AppProperName, s_buildRev);
print_centered(ConsoleExtent.x, "Built", s_buildTimestamp);
VIDEO_WaitVSync();
if (vmode->viTVMode&VI_NON_INTERLACE)
VIDEO_WaitVSync();
// reinit console below the title bar
CON_InitEx(vmode, 8, 50, vmode->viWidth - 16, vmode->viHeight - 62);
ConsoleColor(Black, 0, White, 0);
}
// Reset the video system to remove the startup console.
void wii_initgamevideo(void)
{
WII_InitVideoSystem();
}
/*
* linux/lib/vsprintf.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/
/* we use this so that we can do without the ctype library */
#define is_digit(c) ((c) >= '0' && (c) <= '9')
static int skip_atoi(const char **s)
{
int i=0;
while (is_digit(**s))
i = i*10 + *((*s)++) - '0';
return i;
}
#define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */
#define PLUS 4 /* show plus */
#define SPACE 8 /* space if plus */
#define LEFT 16 /* left justified */
#define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#define do_div(n,base) ({ \
int __res; \
__res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \
__res; })
static char * number(char * str, long num, int base, int size, int precision
,int type)
{
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN) {
if (num < 0) {
sign = '-';
num = -num;
size--;
} else if (type & PLUS) {
sign = '+';
size--;
} else if (type & SPACE) {
sign = ' ';
size--;
}
}
if (type & SPECIAL) {
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[do_div(num,base)];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(ZEROPAD+LEFT)))
while(size-->0)
*str++ = ' ';
if (sign)
*str++ = sign;
if (type & SPECIAL) {
if (base==8)
*str++ = '0';
else if (base==16) {
*str++ = '0';
*str++ = digits[33];
}
}
if (!(type & LEFT))
while (size-- > 0)
*str++ = c;
while (i < precision--)
*str++ = '0';
while (i-- > 0)
*str++ = tmp[i];
while (size-- > 0)
*str++ = ' ';
return str;
}
static int exception_vsprintf(char *buf, const char *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
char * str;
const char *s;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (is_digit(*fmt))
field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
if (precision < 0)
precision = 0;
}
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}
/* default base */
base = 10;
switch (*fmt) {
case 'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
*str++ = (unsigned char) va_arg(args, int);
while (--field_width > 0)
*str++ = ' ';
continue;
case 's':
s = va_arg(args, char *);
if (!s)
s = "<NULL>";
len = strnlen(s, precision);
if (!(flags & LEFT))
while (len < field_width--)
*str++ = ' ';
for (i = 0; i < len; ++i)
*str++ = *s++;
while (len < field_width--)
*str++ = ' ';
continue;
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
flags |= ZEROPAD;
}
str = number(str,
(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
case 'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (str - buf);
} else {
int * ip = va_arg(args, int *);
*ip = (str - buf);
}
continue;
case '%':
*str++ = '%';
continue;
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
default:
*str++ = '%';
if (*fmt)
*str++ = *fmt;
else
--fmt;
continue;
}
if (qualifier == 'l')
num = va_arg(args, unsigned long);
else if (qualifier == 'h') {
num = (unsigned short) va_arg(args, int);
if (flags & SIGN)
num = (short) num;
} else if (flags & SIGN)
num = va_arg(args, int);
else
num = va_arg(args, unsigned int);
str = number(str, num, base, field_width, precision, flags);
}
*str = '\0';
return str-buf;
}
#define DOUTBUFSIZE 256
static int exception_output;
static void exception_printf(const char *str, ...)
{
char outstr[DOUTBUFSIZE];
int len;
va_list args;
va_start(args, str);
len = exception_vsprintf(outstr, str, args);
va_end(args);
if (exception_output)
Bfputs(outstr, osdlog);
else
Bwrite(2, outstr, len);
}
/*-------------------------------------------------------------
exception.c -- PPC exception handling support
Copyright (C) 2004
Michael Wiedenbauer (shagkur)
Dave Murphy (WinterMute)
Copyright (C) 2014
Modified for EDuke32
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
-------------------------------------------------------------*/
//#define _EXC_DEBUG
#define CPU_STACK_TRACE_DEPTH 10
typedef struct _framerec {
struct _framerec *up;
void *lr;
} frame_rec, *frame_rec_t;
static void *exception_xfb = (void*)0xC1700000; //we use a static address above ArenaHi.
#ifdef __cplusplus
extern "C" {
#endif
extern void udelay(int us);
extern void __reload();
extern void VIDEO_SetFramebuffer(void *);
extern void __console_init(void *framebuffer,int xstart,int ystart,int xres,int yres,int stride);
extern void __wrap_c_default_exceptionhandler(frame_context *pCtx);
#ifdef __cplusplus
}
#endif
static const char *exception_name[NUM_EXCEPTIONS] = {
"System Reset", "Machine Check", "DSI", "ISI",
"Interrupt", "Alignment", "Program", "Floating Point",
"Decrementer", "System Call", "Trace", "Performance",
"IABR", "Reserved", "Thermal"};
extern void __wrap_c_default_exceptionhandler(frame_context *pCtx);
static void _cpu_print_stack(void *pc,void *lr,void *r1)
{
u32 i = 0;
frame_rec_t l,p = (frame_rec_t)lr;
l = p;
p = (frame_rec_t)r1;
if(!p) __asm__ __volatile__("mr %0,%%r1" : "=r"(p));
exception_printf("\n\tSTACK DUMP:");
for(i=0;i<CPU_STACK_TRACE_DEPTH-1 && p->up;p=p->up,i++) {
if(i%4) exception_printf(" --> ");
else {
if(i>0) exception_printf(" -->\n\t");
else exception_printf("\n\t");
}
switch(i) {
case 0:
if(pc) exception_printf("%p",pc);
break;
case 1:
if(!l) l = (frame_rec_t)mfspr(8);
exception_printf("%p",(void*)l);
break;
default:
exception_printf("%p",(void*)(p->up->lr));
break;
}
}
}
static void waitForReload(void)
{
u32 level;
exception_printf("\tPress the Reset button to return to loader.\n\n");
while ( 1 )
{
if( SYS_ResetButtonDown() )
{
exception_printf("\tReturning to loader...\n");
_CPU_ISR_Disable(level);
__reload ();
}
udelay(20000);
}
}
void __wrap_c_default_exceptionhandler(frame_context *pCtx)
{
GX_AbortFrame();
VIDEO_SetFramebuffer(exception_xfb);
__console_init(exception_xfb,20,20,640,574,1280);
CON_EnableGecko(1, true);
exception_printf("\n\n\n");
if (osdlog && osdlogfn)
{
exception_printf("\tAn unrecoverable error has occurred.\n\tPlease submit \"%s\" to the %s developers.\n\n", osdlogfn, AppProperName);
exception_output = 1;
}
exception_printf("\tException: %s\n\n", exception_name[pCtx->EXCPT_Number]);
exception_printf("\tGPR00 %08X GPR08 %08X GPR16 %08X GPR24 %08X\n",pCtx->GPR[0], pCtx->GPR[8], pCtx->GPR[16], pCtx->GPR[24]);
exception_printf("\tGPR01 %08X GPR09 %08X GPR17 %08X GPR25 %08X\n",pCtx->GPR[1], pCtx->GPR[9], pCtx->GPR[17], pCtx->GPR[25]);
exception_printf("\tGPR02 %08X GPR10 %08X GPR18 %08X GPR26 %08X\n",pCtx->GPR[2], pCtx->GPR[10], pCtx->GPR[18], pCtx->GPR[26]);
exception_printf("\tGPR03 %08X GPR11 %08X GPR19 %08X GPR27 %08X\n",pCtx->GPR[3], pCtx->GPR[11], pCtx->GPR[19], pCtx->GPR[27]);
exception_printf("\tGPR04 %08X GPR12 %08X GPR20 %08X GPR28 %08X\n",pCtx->GPR[4], pCtx->GPR[12], pCtx->GPR[20], pCtx->GPR[28]);
exception_printf("\tGPR05 %08X GPR13 %08X GPR21 %08X GPR29 %08X\n",pCtx->GPR[5], pCtx->GPR[13], pCtx->GPR[21], pCtx->GPR[29]);
exception_printf("\tGPR06 %08X GPR14 %08X GPR22 %08X GPR30 %08X\n",pCtx->GPR[6], pCtx->GPR[14], pCtx->GPR[22], pCtx->GPR[30]);
exception_printf("\tGPR07 %08X GPR15 %08X GPR23 %08X GPR31 %08X\n",pCtx->GPR[7], pCtx->GPR[15], pCtx->GPR[23], pCtx->GPR[31]);
exception_printf("\tLR %08X SRR0 %08x SRR1 %08x MSR %08x\n", pCtx->LR, pCtx->SRR0, pCtx->SRR1,pCtx->MSR);
exception_printf("\tDAR %08X DSISR %08X\n", mfspr(19), mfspr(18));
_cpu_print_stack((void*)pCtx->SRR0,(void*)pCtx->LR,(void*)pCtx->GPR[1]);
if((pCtx->EXCPT_Number==EX_DSI) || (pCtx->EXCPT_Number==EX_FP)) {
u32 i;
u32 *pAdd = (u32*)pCtx->SRR0;
exception_printf("\n\n\tCODE DUMP:\n");
for (i=0; i<12; i+=4)
exception_printf("\t%p: %08X %08X %08X %08X\n",
&(pAdd[i]),pAdd[i], pAdd[i+1], pAdd[i+2], pAdd[i+3]);
}
if (exception_output)
{
exception_output = 0;
MAYBE_FCLOSE_AND_NULL(osdlog);
}
else
{
exception_printf("\n");
}
waitForReload();
return;
}