From 02a83be576a7ec744ad157b6fae8f3dc4247e686 Mon Sep 17 00:00:00 2001 From: wiimpathy Date: Fri, 1 Apr 2016 12:00:00 +0200 Subject: [PATCH] DosBox_Wii_R1 Wiimpathy https://gbatemp.net/threads/wiiflow-lite.422685/page-76#post-8580238 --- Makefile | 4 +- README_R1.txt | 11 ++ include/mapper.h | 5 +- include/programs.h | 2 +- include/video.h | 1 + src/cpu/cpu.cpp | 14 +- src/gui/render.cpp | 53 +++++- src/gui/sdl_mapper.cpp | 33 ++-- src/gui/sdlmain.cpp | 70 +++++++- src/misc/programs.cpp | 24 ++- src/platform/wii/filelist.h | 6 + src/platform/wii/images/tv.png | Bin 0 -> 995 bytes src/platform/wii/images/tv_over.png | Bin 0 -> 965 bytes src/platform/wii/input.cpp | 1 + src/platform/wii/menu.cpp | 248 +++++++++++++++++++++++++++- 15 files changed, 441 insertions(+), 31 deletions(-) create mode 100644 README_R1.txt create mode 100644 src/platform/wii/images/tv.png create mode 100644 src/platform/wii/images/tv_over.png diff --git a/Makefile b/Makefile index 904d0b6..8e3bd6b 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ include $(DEVKITPPC)/wii_rules # SOURCES is a list of directories containing source code # INCLUDES is a list of directories containing extra header files #--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) +TARGET := boot BUILD := build SOURCES := src src/cpu src/debug src/dos src/fpu src/gui \ src/hardware src/hardware/serialport src/ints src/libs \ @@ -105,7 +105,7 @@ export OUTPUT := $(CURDIR)/$(TARGET) #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile + @make --no-print-directory -j4 -C $(BUILD) -f $(CURDIR)/Makefile #--------------------------------------------------------------------------------- clean: diff --git a/README_R1.txt b/README_R1.txt new file mode 100644 index 0000000..d4a67bc --- /dev/null +++ b/README_R1.txt @@ -0,0 +1,11 @@ +/* DOSBox Wii Version 1.7 R1 (wiimpathy) */ + +R1 - April 1, 2016 +------------------ + +* GameCube pad support in-game : add joystick=fcs in Dosbox .conf file. +* Navigate menu with GC pad, open it with Start+Z. +* Mapper button to remap keyboard/controllers(same as CTRL-F1). +* New top menu buttons, from left to right: cycles, frameskip, scaler. + Push + or - to increase/decrease cycles/frameskip. Push the tv button to change the filter. +* Conf file saved automatically when exiting if values have been modified("config -wc"). diff --git a/include/mapper.h b/include/mapper.h index 6037d4c..ad65c59 100644 --- a/include/mapper.h +++ b/include/mapper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2002-2011 The DOSBox Team + * Copyright (C) 2002-2015 The DOSBox Team * * 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 @@ -30,10 +30,9 @@ void MAPPER_AddHandler(MAPPER_Handler * handler,MapKeys key,Bitu mods,char const void MAPPER_Init(void); void MAPPER_StartUp(Section * sec); void MAPPER_Run(bool pressed); -void MAPPER_RunInternal(); +extern void MAPPER_RunInternal(); void MAPPER_LosingFocus(void); - #define MMOD1 0x1 #define MMOD2 0x2 diff --git a/include/programs.h b/include/programs.h index 0b85a86..058f71e 100644 --- a/include/programs.h +++ b/include/programs.h @@ -83,7 +83,7 @@ public: void WriteOut(const char * format,...); /* Write to standard output */ void WriteOut_NoParsing(const char * format); /* Write to standard output, no parsing */ void ChangeToLongCmd(); - + void writez(); }; typedef void (PROGRAMS_Main)(Program * * make); diff --git a/include/video.h b/include/video.h index b78186b..3e979bc 100644 --- a/include/video.h +++ b/include/video.h @@ -82,3 +82,4 @@ void GFX_CaptureMouse(void); extern bool mouselocked; //true if mouse is confined to window #endif + diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index c867f40..970e744 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -37,6 +37,10 @@ Bitu DEBUG_EnableDebugger(void); extern void GFX_SetTitle(Bit32s cycles ,Bits frameskip,bool paused); +#ifdef HW_RVL +extern void CPU_CycleDecrease(bool pressed); +extern void CPU_CycleIncrease(bool pressed); +#endif #if 1 #undef LOG @@ -2101,8 +2105,11 @@ void CPU_ENTER(bool use32,Bitu bytes,Bitu level) { sp_index-=bytes; reg_esp=(reg_esp&cpu.stack.notmask)|((sp_index)&cpu.stack.mask); } - +#ifdef HW_RVL +void CPU_CycleIncrease(bool pressed) { +#else static void CPU_CycleIncrease(bool pressed) { +#endif if (!pressed) return; if (CPU_CycleAutoAdjust) { CPU_CyclePercUsed+=5; @@ -2126,8 +2133,11 @@ static void CPU_CycleIncrease(bool pressed) { GFX_SetTitle(CPU_CycleMax,-1,false); } } - +#ifdef HW_RVL +void CPU_CycleDecrease(bool pressed) { +#else static void CPU_CycleDecrease(bool pressed) { +#endif if (!pressed) return; if (CPU_CycleAutoAdjust) { CPU_CyclePercUsed-=5; diff --git a/src/gui/render.cpp b/src/gui/render.cpp index c20148f..d1e78de 100644 --- a/src/gui/render.cpp +++ b/src/gui/render.cpp @@ -36,8 +36,13 @@ Render_t render; ScalerLineHandler_t RENDER_DrawLine; +#ifdef HW_RVL +extern void IncreaseFrameSkip(bool pressed); +extern void DecreaseFrameSkip(bool pressed); +extern void ChangeScaler(bool pressed); static void RENDER_CallBack( GFX_CallBackFunctions_t function ); - +char filterTxt[15]; +#endif static void Check_Palette(void) { /* Clean up any previous changed palette data */ if (render.pal.changed) { @@ -281,14 +286,26 @@ static void RENDER_Reset( void ) { gfx_scalew = 1; gfx_scaleh = 1; } +#ifdef HW_RVL + if (render.scale.size == 3) + render.scale.size=1; +#endif + if ((dblh && dblw) || (render.scale.forced && !dblh && !dblw)) { /* Initialize always working defaults */ if (render.scale.size == 2) simpleBlock = &ScaleNormal2x; +#if !defined(HW_RVL) else if (render.scale.size == 3) simpleBlock = &ScaleNormal3x; + else simpleBlock = &ScaleNormal1x; +#else + else if (render.scale.size < 2) + simpleBlock = &ScaleNormal1x; +#endif + /* Maybe override them */ #if RENDER_USE_ADVANCED_SCALERS>0 switch (render.scale.op) { @@ -296,20 +313,26 @@ static void RENDER_Reset( void ) { case scalerOpAdvInterp: if (render.scale.size == 2) complexBlock = &ScaleAdvInterp2x; +#if !defined(HW_RVL) else if (render.scale.size == 3) complexBlock = &ScaleAdvInterp3x; +#endif break; case scalerOpAdvMame: if (render.scale.size == 2) complexBlock = &ScaleAdvMame2x; +#if !defined(HW_RVL) else if (render.scale.size == 3) complexBlock = &ScaleAdvMame3x; +#endif break; case scalerOpHQ: if (render.scale.size == 2) complexBlock = &ScaleHQ2x; +#if !defined(HW_RVL) else if (render.scale.size == 3) complexBlock = &ScaleHQ3x; +#endif break; case scalerOpSuperSaI: if (render.scale.size == 2) @@ -327,20 +350,26 @@ static void RENDER_Reset( void ) { case scalerOpTV: if (render.scale.size == 2) simpleBlock = &ScaleTV2x; +#if !defined(HW_RVL) else if (render.scale.size == 3) simpleBlock = &ScaleTV3x; +#endif break; case scalerOpRGB: if (render.scale.size == 2) simpleBlock = &ScaleRGB2x; +#if !defined(HW_RVL) else if (render.scale.size == 3) simpleBlock = &ScaleRGB3x; +#endif break; case scalerOpScan: if (render.scale.size == 2) simpleBlock = &ScaleScan2x; +#if !defined(HW_RVL) else if (render.scale.size == 3) simpleBlock = &ScaleScan3x; +#endif break; default: break; @@ -367,11 +396,17 @@ forcenormal: gfx_flags = complexBlock->gfxFlags; xscale = complexBlock->xscale; yscale = complexBlock->yscale; +#ifdef HW_RVL + sprintf(filterTxt, complexBlock->name); +#endif // LOG_MSG("Scaler:%s",complexBlock->name); } else { gfx_flags = simpleBlock->gfxFlags; xscale = simpleBlock->xscale; yscale = simpleBlock->yscale; +#ifdef HW_RVL + sprintf(filterTxt, simpleBlock->name); +#endif // LOG_MSG("Scaler:%s",simpleBlock->name); } switch (render.src.bpp) { @@ -535,23 +570,31 @@ void RENDER_SetSize(Bitu width,Bitu height,Bitu bpp,float fps,double ratio,bool } extern void GFX_SetTitle(Bit32s cycles, Bits frameskip,bool paused); +#ifdef HW_RVL +void IncreaseFrameSkip(bool pressed) { +#else static void IncreaseFrameSkip(bool pressed) { +#endif if (!pressed) return; if (render.frameskip.max<10) render.frameskip.max++; LOG_MSG("Frame Skip at %d",render.frameskip.max); GFX_SetTitle(-1,render.frameskip.max,false); } - +#ifdef HW_RVL +void DecreaseFrameSkip(bool pressed) { +#else static void DecreaseFrameSkip(bool pressed) { +#endif if (!pressed) return; if (render.frameskip.max>0) render.frameskip.max--; LOG_MSG("Frame Skip at %d",render.frameskip.max); GFX_SetTitle(-1,render.frameskip.max,false); } -/* Disabled as I don't want to waste a keybind for that. Might be used in the future (Qbix) -static void ChangeScaler(bool pressed) { + //Disabled as I don't want to waste a keybind for that. Might be used in the future (Qbix) +//static void ChangeScaler(bool pressed) { +void ChangeScaler(bool pressed) { if (!pressed) return; render.scale.op = (scalerOperation)((int)render.scale.op+1); @@ -561,7 +604,7 @@ static void ChangeScaler(bool pressed) { render.scale.size = 1; } RENDER_CallBack( GFX_CallBackReset ); -} */ +} void RENDER_Init(Section * sec) { Section_prop * section=static_cast(sec); diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 8e685bf..036bf47 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -392,7 +392,6 @@ static SDLKey sdlkey_map[MAX_SCANCODES]={SDLK_UNKNOWN,SDLK_ESCAPE, #undef Z - SDLKey MapSDLCode(Bitu skey) { if (usescancodes) { if (skeytype) { case SDL_JOYAXISMOTION: jaxis = &event->jaxis; @@ -1531,7 +1528,6 @@ protected: Bitu stick,hat,dir; }; - class CModEvent : public CTriggeredEvent { public: CModEvent(char const * const _entry,Bitu _wmod) : CTriggeredEvent(_entry) { @@ -1617,13 +1613,11 @@ static struct { CCheckButton * mod1,* mod2,* mod3,* hold; } bind_but; - static void change_action_text(const char* text,Bit8u col) { bind_but.action->Change(text,""); bind_but.action->SetColor(col); } - static void SetActiveBind(CBind * _bind) { mapper.abind=_bind; if (_bind) { @@ -1931,9 +1925,7 @@ static void CreateLayout(void) { new CTextButton(PX(XO+4),PY(YO-1),3*BW,20,"Disabled"); new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Disabled"); } - - - + /* The modifier buttons */ AddModButton(PX(0),PY(14),50,20,"Mod1",1); AddModButton(PX(2),PY(14),50,20,"Mod2",2); @@ -2206,7 +2198,11 @@ static void InitializeJoysticks(void) { SDL_JoystickClose(tmp_stick1); } bool second_usable=false; +#ifdef HW_RVL + SDL_Joystick* tmp_stick2=SDL_JoystickOpen(4); +#else SDL_Joystick* tmp_stick2=SDL_JoystickOpen(1); +#endif if (tmp_stick2) { if ((SDL_JoystickNumAxes(tmp_stick2)>1) || (SDL_JoystickNumButtons(tmp_stick2)>0)) { second_usable=true; @@ -2268,8 +2264,13 @@ static void CreateBindGroups(void) { new CStickBindGroup(joyno,joyno+1U,true); break; case JOY_FCS: +#ifdef HW_RVL + mapper.sticks.stick[mapper.sticks.num_groups++]=new CFCSBindGroup(0,joyno); + mapper.sticks.stick[mapper.sticks.num_groups++]=new CFCSBindGroup(4,joyno+1U); +#else mapper.sticks.stick[mapper.sticks.num_groups++]=new CFCSBindGroup(joyno,joyno); new CStickBindGroup(joyno+1U,joyno+1U,true); +#endif break; case JOY_CH: mapper.sticks.stick[mapper.sticks.num_groups++]=new CCHBindGroup(joyno,joyno); @@ -2278,11 +2279,22 @@ static void CreateBindGroups(void) { case JOY_2AXIS: default: mapper.sticks.stick[mapper.sticks.num_groups++]=new CStickBindGroup(joyno,joyno); +#ifdef HW_RVL + mapper.sticks.stick[mapper.sticks.num_groups++]=new CStickBindGroup(4,joyno); + if((joyno+1U) < mapper.sticks.num) { + mapper.sticks.stick[mapper.sticks.num_groups++]=new CStickBindGroup(1,joyno+1U); + mapper.sticks.stick[mapper.sticks.num_groups++]=new CStickBindGroup(5,joyno+1U); + } else { + new CStickBindGroup(1,joyno+1U,true); + new CStickBindGroup(5,joyno+1U,true); + } +#else if((joyno+1U) < mapper.sticks.num) { mapper.sticks.stick[mapper.sticks.num_groups++]=new CStickBindGroup(joyno+1U,joyno+1U); } else { new CStickBindGroup(joyno+1U,joyno+1U,true); } +#endif break; } } @@ -2380,6 +2392,7 @@ void MAPPER_Init(void) { } } } + //Somehow including them at the top conflicts with something in setup.h #ifdef C_X11_XKB #include "SDL_syswm.h" diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 82b8ed5..1cc8076 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -134,6 +134,16 @@ struct private_hwdata { #include #endif +#ifdef HW_RVL +#include "mapper.h" +extern int option; +extern bool savecfg; +int CyclesDisplay; +int FrameskipDisplay; +extern char filterTxt[15]; +void ChangeScaler(bool pressed); +#endif + enum SCREEN_TYPES { SCREEN_SURFACE, SCREEN_SURFACE_DDRAW, @@ -150,7 +160,6 @@ enum PRIORITY_LEVELS { PRIORITY_LEVEL_HIGHEST }; - struct SDL_Block { bool inited; bool active; //If this isn't set don't draw @@ -246,6 +255,9 @@ void GFX_SetTitle(Bit32s cycles,Bits frameskip,bool paused){ sprintf(title,"DOSBox %s, CPU speed: %8d cycles, Frameskip %2d, Program: %8s",VERSION,internal_cycles,internal_frameskip,RunningProgram); } + CyclesDisplay=internal_cycles; + FrameskipDisplay=internal_frameskip; + if(paused) strcat(title," PAUSED"); SDL_WM_SetCaption(title,VERSION); } @@ -578,6 +590,7 @@ dosurface: if (sdl.blit.surface) { SDL_FreeSurface(sdl.blit.surface); sdl.blit.surface=0; + } LOG_MSG("Failed to create ddraw surface, back to normal surface."); goto dosurface; @@ -848,6 +861,7 @@ bool GFX_StartUpdate(Bit8u * & pixels,Bitu & pitch) { pitch=sdl.blit.surface->pitch; sdl.updating=true; return true; + #endif case SCREEN_OVERLAY: if (SDL_LockYUVOverlay(sdl.overlay)) return false; @@ -1346,6 +1360,7 @@ static void GUI_StartUp(Section * sec) { } if (use_fadeout) { + SDL_FillRect(sdl.surface, NULL, SDL_MapRGB(sdl.surface->format, 0, 0, 0)); SDL_Flip(sdl.surface); } @@ -1438,15 +1453,63 @@ bool GFX_IsFullscreen(void) { return sdl.desktop.fullscreen; } +#ifdef HW_RVL +void HandleCfg(void) { + Section *sec = NULL; + char ScalerTxt[20]; + char CyclesTxt[15]; + char frameskipTxt[15]; + + sec = control->GetSection("render"); + + for(int i = 0; filterTxt[i]; i++) { + filterTxt[i] = tolower(filterTxt[i]); + } + + sprintf(ScalerTxt, "scaler=%s", filterTxt); + sec->HandleInputline(std::string(ScalerTxt)); + sprintf(frameskipTxt, "frameskip=%d", FrameskipDisplay); + sec->HandleInputline(std::string(frameskipTxt)); + + sec = control->GetSection("cpu"); + sprintf(CyclesTxt, "cycles=%d", CyclesDisplay); + sec->HandleInputline(std::string(CyclesTxt)); + + // Values have changed, save dosbox .cfg when exiting + savecfg=true; + option=0; +} +#endif + void GFX_Events() { #ifdef HW_RVL // check for home button u32 btns; + u16 btns_gc; for(int i=0; i<4; i++) { btns = WPAD_ButtonsHeld(i); - if((btns & WPAD_BUTTON_HOME) || (btns & WPAD_CLASSIC_BUTTON_HOME)) + btns_gc = PAD_ButtonsHeld(i); + if((btns & WPAD_BUTTON_HOME) || (btns & WPAD_CLASSIC_BUTTON_HOME) || ((btns_gc & PAD_BUTTON_START) && (btns_gc & PAD_TRIGGER_Z)) ) WiiMenu (); + + // Call the Mapper + if(option == 1) + { + MAPPER_RunInternal(); + option=0; + } + // Change cycles and frameskip + else if(option==2) + { + HandleCfg(); + } + // Change the scaler + else if(option==3) + { + ChangeScaler(true); + HandleCfg(); + } } #endif @@ -2057,7 +2120,6 @@ int main(int argc, char* argv[]) { GFX_SwitchFullScreen(); } } - /* Init the keyMapper */ MAPPER_Init(); if (control->cmdline->FindExist("-startmapper")) MAPPER_RunInternal(); @@ -2071,6 +2133,7 @@ int main(int argc, char* argv[]) { } catch (char * error) { #if defined (WIN32) sticky_keys(true); + #endif GFX_ShowMsg("Exit to error: %s",error); fflush(NULL); @@ -2108,6 +2171,7 @@ int main(int argc, char* argv[]) { WiiFinished(); #endif SDL_Quit();//Let's hope sdl will quit as well when it catches an exception + return 0; } diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index 0964755..73728c1 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -32,6 +32,10 @@ #include "control.h" #include "shell.h" +#ifdef HW_RVL +extern void SaveConfig(bool pressed); +#endif + Bitu call_program; /* This registers a file on the virtual drive and creates the correct structure for it*/ @@ -67,8 +71,6 @@ void PROGRAMS_MakeFile(char const * const name,PROGRAMS_Main * main) { VFILE_Register(name,comdata,size); } - - static Bitu PROGRAMS_Handler(void) { /* This sets up everything for a program start up call */ Bitu size=sizeof(Bit8u); @@ -250,6 +252,9 @@ void restart_program(std::vector & parameters); class CONFIG : public Program { public: void Run(void); +#ifdef HW_RVL + void Write(); +#endif private: void restart(const char* useconfig); @@ -276,6 +281,8 @@ private: } }; + + void CONFIG::Run(void) { static const char* const params[] = { "-r", "-wcp", "-wcd", "-wc", "-writeconf", "-l", "-rmconf", @@ -749,6 +756,19 @@ static void CONFIG_ProgramStart(Program * * make) { *make=new CONFIG; } +#ifdef HW_RVL +void CONFIG::Write(void) { + writeconf(control->configfiles[0], false); +} + +void SaveConfig(bool pressed) { + if (!pressed) + return; + + CONFIG config; + config.Write(); +} +#endif void PROGRAMS_Init(Section* /*sec*/) { /* Setup a special callback to start virtual programs */ diff --git a/src/platform/wii/filelist.h b/src/platform/wii/filelist.h index d62edde..d07ff7c 100644 --- a/src/platform/wii/filelist.h +++ b/src/platform/wii/filelist.h @@ -103,4 +103,10 @@ extern const u32 player3_point_png_size; extern const u8 player4_point_png[]; extern const u32 player4_point_png_size; +extern const u8 tv_png[]; +extern const u32 tv_png_size; + +extern const u8 tv_over_png[]; +extern const u32 tv_over_png_size; + #endif diff --git a/src/platform/wii/images/tv.png b/src/platform/wii/images/tv.png new file mode 100644 index 0000000000000000000000000000000000000000..67069c6fe09882b0b92309c59d8e6222fdb049d1 GIT binary patch literal 995 zcmV<9104K`P)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00T=&L_t(o!_8PrZrd;reRM=S z26TV`xkmQcWs@sp({73$sNELbWS2|i1X<<|*(I?^lM>ZUhZqe%lI;RD0m3pxk&kcQ z42M)tPftHX2;V~pIH$5&t)R93(I}<9+~40Lgn)4zF^*&GM9;Zj-j{##FN#tM0Py_$ z{IvmaskMeN23qSy1N>`15}b1mtJMnQIBpvNxVX5$%gYNMA0M$^uNSZIly^$0i6uy4 z#uz+2JmBW$1_01d=g-eigb;9bb(NS|R+7Uo4Dr8g8-^ja^Y?w<#~MON#^|~ZyWK9% z-|!W-Z42)`x~|Kzk<%X6E`R2eQYFw*yRwbX(eTNYQZUBgS*QGT3Bl_ z3_}qhEr3Afz(_M4QnGt7v0<&9Y&B$dF6LVDD%)ySsIkjS!!^})9p2yHBSW=}xdgNX z`dAhtKw}Kv-rmqO&1B+S!f+_K5^JS}CnnD2YfE%A2e6j(E@5!uB)NfV>3c0S%mF^i zi{+NK^x#wjb&NKPCN7zVXVp3F91E~^s7eC0G_hO}&j;sBoddN5+#(Z8{n3iZ>~m+6 z+M)i?kdp*zIYF!r1z6R@r65|1g>!c}r{3FS zO?=4R%Tm^AvGgDYhha#r9ZJEv#O|rADWzgImBhieZE<~ljqP^(U+)Dsn+@8wjlR$T zK;QScy}iZV-Q8JSUhen%ce zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00S*aL_t(o!_8PhZrd;r9LjX! zLJu(Vi=1-{kT2u`?WO30+H27V9 z<%(vv+x;4b;YUgd=Tw@efwlIhHO73sySqb53Bxd87>02WJ!`*m>}Qnye*et^*jQ`f zoWpv(u6pq^ff-}qy+_kD7>41C1%TCRg~!K7JUl#9fi%W^xX&0fu>?uXIfwiEdt6^% z0{|=yetUaEN(tNTc4lT-Ne=Jt?*M?5(xi?5QXlV+F(Sq|X{YC|>u@+6#`P`VVcWI{ zA)xCzl?|yq4wgUjKCMbk%Qn7-<%=6*;GDzj>nn^gS#xO&%gKpB$!d;mY6~HZ?K6PH zTGKR(0CO_XOiNYvNx%edL<*nljDwIYYG&5jVvJci^nI@bOew*8kM(*z z(kw%PlmcgCDXdWZlTN}JODW-SI3R>D*C3%MfST8GASI90yp@}kSPUV|g0^#R?!}zm zi;D}y7$Ln|o*1M}sUI3gpa`t@ega675)W+?fHcs1KkiJLmH(Hflg~7VWGI&fmT)TUL>}Rhu}Mh!TsGa^NI^t^NHMEHt3b@Y7t`00000NkvXXu0mjf^^3UG literal 0 HcmV?d00001 diff --git a/src/platform/wii/input.cpp b/src/platform/wii/input.cpp index 15355ff..d8f352a 100644 --- a/src/platform/wii/input.cpp +++ b/src/platform/wii/input.cpp @@ -109,3 +109,4 @@ bool MenuRequested() } return false; } + diff --git a/src/platform/wii/menu.cpp b/src/platform/wii/menu.cpp index 7a21399..020d3f6 100644 --- a/src/platform/wii/menu.cpp +++ b/src/platform/wii/menu.cpp @@ -19,12 +19,17 @@ #include "libwiigui/gui.h" #include "wiihardware.h" +#include "cpu.h" + #define THREAD_SLEEP 100 #define APPVERSION "1.7" static GuiImageData * pointer[4]; static GuiWindow * mainWindow = NULL; static GuiButton * logoBtn = NULL; +static GuiText * cycleText = NULL; +static GuiText * fskipText = NULL; +static GuiText * filterBtnTxt = NULL; static lwp_t guithread = LWP_THREAD_NULL; static lwp_t creditsthread = LWP_THREAD_NULL; @@ -32,6 +37,23 @@ static bool guiHalt = true; static bool ExitRequested = false; static bool creditsOpen = false; +int option=0; +bool savecfg=false; +extern int CyclesDisplay; +extern int FrameskipDisplay; +extern Bit32s CPU_CycleUp; +extern Bit32s CPU_CycleDown; +extern char filterTxt[15]; +int cyclez; +int fskip; + +void SaveConfig(bool pressed); +void CPU_CycleDecrease(bool pressed); +void CPU_CycleIncrease(bool pressed); +void IncreaseFrameSkip(bool pressed); +void DecreaseFrameSkip(bool pressed); +void ChangeScaler(bool pressed); + /**************************************************************************** * UpdateGUI * @@ -79,6 +101,11 @@ static void * UpdateGUI (void *arg) ShutoffRumble(); VIDEO_SetBlack(TRUE); VIDEO_Flush(); + + // Save dosbox .cfg file + if(savecfg) + SaveConfig(true); + throw(0); } usleep(THREAD_SLEEP); @@ -304,13 +331,107 @@ static void DisplayCredits(void * ptr) LWP_CreateThread (&creditsthread, WindowCredits, NULL, NULL, 0, 60); } +/**************************************************************************** + * CpuCycleUpdate + * + * Increase or decrease CPU cycles. + ***************************************************************************/ +static void CpuCycleUpdate(void * ptr, bool increase) +{ + GuiButton * b = (GuiButton *)ptr; + if(b->GetState() == STATE_CLICKED) + { + char cycleTxt[10]; + + if(increase) + { + if (CPU_CycleUp < 100) + { + cyclez = (Bit32s)(CyclesDisplay * (1 + (float)CPU_CycleUp / 100.0)); + } + else + { + cyclez = (Bit32s)(CyclesDisplay + CPU_CycleUp); + } + + sprintf(cycleTxt, "%d",cyclez); + cycleText->SetText(cycleTxt); + CPU_CycleIncrease(true); + } + else + { + if (CPU_CycleDown < 100) + { + cyclez = (Bit32s)(CyclesDisplay / (1 + (float)CPU_CycleDown / 100.0)); + } + else + { + cyclez = (Bit32s)(CyclesDisplay - CPU_CycleDown); + } + + sprintf(cycleTxt, "%d",cyclez); + cycleText->SetText(cycleTxt); + CPU_CycleDecrease(true); + } + CyclesDisplay=cyclez; + b->ResetState(); + option=2; + } +} + +/**************************************************************************** + * RenderFskipUpdate + * + * Increase or decrease frameskip. + ***************************************************************************/ +static void RenderFskipUpdate(void * ptr, bool increase) +{ + GuiButton * b = (GuiButton *)ptr; + if(b->GetState() == STATE_CLICKED) + { + char fskipTxt[10]; + + if(fskip < 0) + fskip=0; + + if(increase) + { + fskip=FrameskipDisplay; + fskip++; + sprintf(fskipTxt, "%d",fskip); + fskipText->SetText(fskipTxt); + IncreaseFrameSkip(true); + } + else + { + fskip=FrameskipDisplay; + fskip--; + if(fskip < 0) + fskip=0; + sprintf(fskipTxt, "%d",fskip); + fskipText->SetText(fskipTxt); + DecreaseFrameSkip(true); + } + + FrameskipDisplay=fskip; + b->ResetState(); + option=2; + } +} + +static void CpuCycleDecrease(void * ptr) { CpuCycleUpdate(ptr, false); } +static void CpuCycleIncrease(void * ptr) { CpuCycleUpdate(ptr, true); } + +static void RenderFskipDecrease(void * ptr) { RenderFskipUpdate(ptr, false); } +static void RenderFskipIncrease(void * ptr) { RenderFskipUpdate(ptr, true); } + /**************************************************************************** * HomeMenu ***************************************************************************/ void HomeMenu () { ResetVideo_Menu(); - + pointer[0] = new GuiImageData(player1_point_png); pointer[1] = new GuiImageData(player2_point_png); pointer[2] = new GuiImageData(player3_point_png); @@ -366,12 +487,110 @@ void HomeMenu () logoBtn->SetTrigger(&trigA); logoBtn->SetUpdateCallback(DisplayCredits); + char CyclesTxt[15]; + char FskipTxt[15]; + sprintf(CyclesTxt, "%d", CyclesDisplay); + sprintf(FskipTxt, "%d", FrameskipDisplay); + + cycleText = new GuiText(NULL, 20, (GXColor){255, 255, 255, 255}); + cycleText->SetText(CyclesTxt); + cycleText->SetPosition(-215, -180); + + fskipText = new GuiText(NULL, 20, (GXColor){255, 255, 255, 255}); + fskipText->SetText(FskipTxt); + fskipText->SetPosition(-45, -180); + + GuiText cycleDecBtnTxt("-", 24, (GXColor){0, 0, 0, 255}); + GuiImageData cycleDec(keyboard_key_png); + GuiImage cycleDecImg(&cycleDec); + GuiImageData cycleDecOver(keyboard_key_over_png); + GuiImage cycleDecOverImg(&cycleDecOver); + GuiButton cycleDecBtn(cycleDec.GetWidth(), cycleDec.GetHeight()); + cycleDecBtn.SetImage(&cycleDecImg); + cycleDecBtn.SetImageOver(&cycleDecOverImg); + cycleDecBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + cycleDecBtn.SetPosition(-270, -180); + cycleDecBtn.SetLabel(&cycleDecBtnTxt); + cycleDecBtn.SetTrigger(&trigA); + cycleDecBtn.SetUpdateCallback(CpuCycleDecrease); + + GuiText cycleIncBtnTxt("+", 24, (GXColor){0, 0, 0, 255}); + GuiImageData cycleInc(keyboard_key_png); + GuiImage cycleIncImg(&cycleInc); + GuiImageData cycleIncOver(keyboard_key_over_png); + GuiImage cycleIncOverImg(&cycleIncOver); + GuiButton cycleIncBtn(cycleInc.GetWidth(), cycleInc.GetHeight()); + cycleIncBtn.SetImage(&cycleIncImg); + cycleIncBtn.SetImageOver(&cycleIncOverImg); + cycleIncBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + cycleIncBtn.SetPosition(-160, -180); + cycleIncBtn.SetLabel(&cycleIncBtnTxt); + cycleIncBtn.SetTrigger(&trigA); + cycleIncBtn.SetUpdateCallback(CpuCycleIncrease); + + GuiText fskipDecBtnTxt("-", 24, (GXColor){0, 0, 0, 255}); + GuiImageData fskipDec(keyboard_key_png); + GuiImage fskipDecImg(&fskipDec); + GuiImageData fskipDecOver(keyboard_key_over_png); + GuiImage fskipDecOverImg(&fskipDecOver); + GuiButton fskipDecBtn(fskipDec.GetWidth(), fskipDec.GetHeight()); + fskipDecBtn.SetImage(&fskipDecImg); + fskipDecBtn.SetImageOver(&fskipDecOverImg); + fskipDecBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + fskipDecBtn.SetPosition(-80, -180); + fskipDecBtn.SetLabel(&fskipDecBtnTxt); + fskipDecBtn.SetTrigger(&trigA); + fskipDecBtn.SetUpdateCallback(RenderFskipDecrease); + + GuiText fskipIncBtnTxt("+", 24, (GXColor){0, 0, 0, 255}); + GuiImageData fskipInc(keyboard_key_png); + GuiImage fskipIncImg(&fskipInc); + GuiImageData fskipIncOver(keyboard_key_over_png); + GuiImage fskipIncOverImg(&fskipIncOver); + GuiButton fskipIncBtn(fskipInc.GetWidth(), fskipInc.GetHeight()); + fskipIncBtn.SetImage(&fskipIncImg); + fskipIncBtn.SetImageOver(&fskipIncOverImg); + fskipIncBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + fskipIncBtn.SetPosition(0, -180); + fskipIncBtn.SetLabel(&fskipIncBtnTxt); + fskipIncBtn.SetTrigger(&trigA); + fskipIncBtn.SetUpdateCallback(RenderFskipIncrease); + + filterBtnTxt = new GuiText(NULL, 20, (GXColor){255, 255, 255, 255}); + filterBtnTxt->SetText(filterTxt); + filterBtnTxt->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM); + GuiImageData filter(tv_png); + GuiImage filterImg(&filter); + GuiImageData filterOver(tv_over_png); + GuiImage filterOverImg(&filterOver); + GuiButton filterBtn(filter.GetWidth(), filter.GetHeight()); + filterBtn.SetImage(&filterImg); + filterBtn.SetImageOver(&filterOverImg); + filterBtn.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); + filterBtn.SetPosition(80, -180); + filterBtn.SetLabel(filterBtnTxt); + filterBtn.SetTrigger(&trigA); + + GuiText remapBtnTxt("Mapper", 24, (GXColor){0, 0, 0, 255}); + GuiImage remapBtnImg(&btnLargeOutline); + GuiImage remapBtnImgOver(&btnLargeOutlineOver); + GuiButton remapBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); + remapBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + remapBtn.SetPosition(125, 250); + remapBtn.SetLabel(&remapBtnTxt); + remapBtn.SetImage(&remapBtnImg); + remapBtn.SetImageOver(&remapBtnImgOver); + remapBtn.SetSoundOver(&btnSoundOver); + remapBtn.SetSoundClick(&btnSoundClick); + remapBtn.SetTrigger(&trigA); + remapBtn.SetEffectGrow(); + GuiText exitBtnTxt("Exit", 24, (GXColor){0, 0, 0, 255}); GuiImage exitBtnImg(&btnLargeOutline); GuiImage exitBtnImgOver(&btnLargeOutlineOver); GuiButton exitBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); exitBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - exitBtn.SetPosition(-125, 120); + exitBtn.SetPosition(-125, 110); exitBtn.SetLabel(&exitBtnTxt); exitBtn.SetImage(&exitBtnImg); exitBtn.SetImageOver(&exitBtnImgOver); @@ -385,7 +604,7 @@ void HomeMenu () GuiImage keyboardBtnImgOver(&btnLargeOutlineOver); GuiButton keyboardBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); keyboardBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - keyboardBtn.SetPosition(125, 120); + keyboardBtn.SetPosition(125, 110); keyboardBtn.SetLabel(&keyboardBtnTxt); keyboardBtn.SetImage(&keyboardBtnImg); keyboardBtn.SetImageOver(&keyboardBtnImgOver); @@ -463,6 +682,14 @@ void HomeMenu () w.Append(logoBtn); w.Append(&closeBtn); w.Append(&exitBtn); + w.Append(&remapBtn); + w.Append(cycleText); + w.Append(fskipText); + w.Append(&cycleDecBtn); + w.Append(&cycleIncBtn); + w.Append(&fskipDecBtn); + w.Append(&fskipIncBtn); + w.Append(&filterBtn); w.Append(&keyboardBtn); mainWindow->Append(&screenImg); @@ -554,6 +781,19 @@ void HomeMenu () if(dosboxCommand[0] != 0) break; } + else if(remapBtn.GetState() == STATE_CLICKED) + { + remapBtn.ResetState(); + option=1; + break; + } + else if(filterBtn.GetState() == STATE_CLICKED) + { + filterBtn.ResetState(); + option=3; + filterBtnTxt->SetText(filterTxt); + break; + } } ShutoffRumble(); @@ -580,6 +820,8 @@ void HomeMenu () delete pointer[1]; delete pointer[2]; delete pointer[3]; + delete(cycleText); + delete(fskipText); mainWindow = NULL;