Skip to content

Commit

Permalink
clean up bios, settings, and 3ds host
Browse files Browse the repository at this point in the history
  • Loading branch information
DPS2004 committed Oct 16, 2023
1 parent b0f0f42 commit f5db8c9
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*.rpx

*.exe
*.dll

*.o

Expand Down
53 changes: 17 additions & 36 deletions platform/3ds/source/3dsHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void Host::oneTimeSetup(Audio* audio){
}

gfxInitDefault();
gfxSetWide(consoleModel != 3);
//gfxSetWide(consoleModel != 3);
//C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); default is 0x40000
C3D_Init(0x10000);
//C2D_Init(C2D_DEFAULT_MAX_OBJECTS); //4096
Expand Down Expand Up @@ -375,20 +375,9 @@ void Host::oneTimeSetup(Audio* audio){

loadSettingsIni();

setRenderParamsFromStretch(stretch);
forceStretch(stretch);


if (stretch == AltScreenPixelPerfect) {
mouseOffsetX = (__3ds_BottomScreenWidth - PicoScreenWidth) / 2;
mouseOffsetY = (__3ds_BottomScreenHeight - PicoScreenHeight) / 2;
scaleX = 1.0;
scaleY = 1.0;
}
else{
mouseOffsetX = (__3ds_BottomScreenWidth - __3ds_BottomScreenHeight) / 2;
mouseOffsetY = 0;
scaleX = 0.53;
scaleY = 0.53;
}
}

void Host::oneTimeCleanup(){
Expand All @@ -415,47 +404,39 @@ void Host::changeStretch(){
if ((currKDown32 & KEY_SELECT) && resizekey == YesResize) {
if (stretch == PixelPerfect) {
stretch = StretchToFit;
mouseOffsetX = (__3ds_BottomScreenWidth - __3ds_BottomScreenHeight) / 2;
mouseOffsetY = 0;
scaleX = 0.53;
scaleY = 0.53;
}
else if (stretch == StretchToFit) {
stretch = StretchAndOverflow;
mouseOffsetX = (__3ds_BottomScreenWidth - __3ds_BottomScreenHeight) / 2;
mouseOffsetY = 0;
scaleX = 0.53;
scaleY = 0.53;
}
else if (stretch == StretchAndOverflow) {
stretch = AltScreenPixelPerfect;
mouseOffsetX = (__3ds_BottomScreenWidth - PicoScreenWidth) / 2;
mouseOffsetY = (__3ds_BottomScreenHeight - PicoScreenHeight) / 2;
scaleX = 1.0;
scaleY = 1.0;
}
else if (stretch == AltScreenPixelPerfect) {
stretch = AltScreenStretch;
mouseOffsetX = (__3ds_BottomScreenWidth - __3ds_BottomScreenHeight) / 2;
mouseOffsetY = 0;
scaleX = 0.53;
scaleY = 0.53;
}
else {
stretch = PixelPerfect;
mouseOffsetX = (__3ds_BottomScreenWidth - __3ds_BottomScreenHeight) / 2;
mouseOffsetY = 0;
scaleX = 0.53;
scaleY = 0.53;
}

setRenderParamsFromStretch(stretch);
forceStretch(stretch);

}
}

void Host::forceStretch(StretchOption newStretch) {
setRenderParamsFromStretch(stretch);
if (stretch == AltScreenPixelPerfect) {
mouseOffsetX = (__3ds_BottomScreenWidth - PicoScreenWidth) / 2;
mouseOffsetY = (__3ds_BottomScreenHeight - PicoScreenHeight) / 2;
scaleX = 1.0;
scaleY = 1.0;
}
else{
mouseOffsetX = (__3ds_BottomScreenWidth - __3ds_BottomScreenHeight) / 2;
mouseOffsetY = 0;
scaleX = 0.53;
scaleY = 0.53;
}
}

InputState_t Host::scanInput(){
Expand Down Expand Up @@ -743,7 +724,7 @@ const char* Host::logFilePrefix() {
}

std::string Host::customBiosLua() {
return "";
return "platform = '3ds'";
}

std::string Host::getCartDirectory() {
Expand Down
1 change: 1 addition & 0 deletions platform/wiiu/source/WiiUHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ const char* Host::logFilePrefix() {

std::string Host::customBiosLua() {
return "cartpath = \"sd:/p8carts/\"\n"
"platform = 'wiiu'\n"
"pausebtn = \"+\"";
}

Expand Down
1 change: 1 addition & 0 deletions platform/windows/source/WindowsHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ string _desktopSdl2customBiosLua = "cartpath = \"AppData\"\n"
"selectbtn = \"z\"\n"
"pausebtn = \"esc\"\n"
"exitbtn = \"close window\"\n"
"platform = 'windows'\n"
"sizebtn = \"\"";


Expand Down
10 changes: 5 additions & 5 deletions source/FakoBios.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ __lua__
--all themes
--start customizable per platform
cartpath = "sdmc:/p8carts/"
selectbtn = "a"
pausebtn = "start"
cartpath = cartpath or "sdmc:/p8carts/"
selectbtn = selectbtn or "a"
pausebtn = pausebtn or "start"
versionstr = ")#" VER_STR R"#("
exitbtn = "l + r"
sizebtn = "select to cycle screen sizes"
exitbtn = exitbtn or "l + r"
sizebtn = sizebtn or "select to cycle screen sizes"
--end customizable per platform
darkenpal = {0,0,1,1,5,5,13,5,5,13,13,13,1,13,13}
Expand Down
23 changes: 21 additions & 2 deletions source/FakoSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ function _init()
settings[v] = __getsetting(v) + 1
end
local screenmodes = {}
local screenenum = {}
if platform == '3ds' then
screenmodes = {'pixel perfect','stretch to fit','overflow stretch','alt screen pixel perfect','alt screen stretch'}
screenenum = {0, 2, 4, 5, 6}
elseif platform == 'wiiu' then
screenmodes = {'pixel perfect','pixel perfect stretch','stretch to fit','stretch to fill','overflow stretch','alt screen pixel perfect','alt screen stretch'}--dont have a wiiu to test so leaving it alone
screenenum = {0, 1, 2, 3, 4, 5, 6}
else
screenmodes = {'pixel perfect','pixel perfect stretch','stretch to fit','stretch to fill'}
screenenum = {0, 1, 2, 3}
end
list = {
{name='input',ops = {
{
Expand All @@ -65,7 +78,8 @@ function _init()
{
name = 'stretch mode',
vn = 'stretch',
ch ={'pixel perfect','pixel perfect stretch','stretch to fit','overflow stretch','alt screen pixel perfect','alt screen stretch'}
ch = screenmodes,
en = screenenum
}
}},
{name='menu',ops = {
Expand Down Expand Up @@ -137,6 +151,7 @@ function refreshinfo()
sectionname = cpath.name
cvariable = cpath.vn
cvalue = settings[cvariable]
cenum = cpath.en
if cpath.ops then
cpath = cpath.ops
inoption = false
Expand Down Expand Up @@ -179,7 +194,11 @@ function updatecursor()
else
if inoption then
settings[cvariable] = cursorpos
__setsetting(cvariable,cursorpos-1)
local finalvalue = cursorpos-1
if cenum then
finalvalue = cenum[cursorpos]
end
__setsetting(cvariable,finalvalue)
if cvariable == 'bgcolor' then
refreshcolors()
end
Expand Down
30 changes: 16 additions & 14 deletions source/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@ bool Vm::loadCart(Cart* cart) {

#endif

//customize bios per host's requirements
if (cart->FullCartPath == BiosCartName || cart->FullCartPath == SettingsCartName) {
std::string customBiosLua = _host->customBiosLua();

if (customBiosLua.length() > 0) {
int doStrRes = luaL_dostring(_luaState, customBiosLua.c_str());

if (doStrRes != LUA_OK){
//bad lua passed
Logger_Write("Error: %s\n", lua_tostring(_luaState, -1));
lua_pop(_luaState, 1);
}
}
}

// Push the _init function on the top of the lua stack (or nil if it doesn't exist)
lua_getglobal(_luaState, "_init");

Expand Down Expand Up @@ -360,20 +375,7 @@ bool Vm::loadCart(Cart* cart) {
lua_pop(_luaState, 0);


//customize bios per host's requirements
if (cart->FullCartPath == BiosCartName || cart->FullCartPath == SettingsCartName) {
std::string customBiosLua = _host->customBiosLua();

if (customBiosLua.length() > 0) {
int doStrRes = luaL_dostring(_luaState, customBiosLua.c_str());

if (doStrRes != LUA_OK){
//bad lua passed
Logger_Write("Error: %s\n", lua_tostring(_luaState, -1));
lua_pop(_luaState, 1);
}
}
}


if (_cartBreadcrumb.length() > 0) {
ExecuteLua("__addbreadcrumb(\"" + _cartBreadcrumb +"\", \"" + _prevCartKey +"\")", "");
Expand Down

0 comments on commit f5db8c9

Please sign in to comment.