Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f22711c
comments
warmCabin Aug 10, 2025
ecfc998
comment out index_lookup (for now)
warmCabin Aug 10, 2025
b8fdec1
change scoring to basic distance squared
warmCabin Aug 10, 2025
61bd178
reenable index_lookup, for science
warmCabin Aug 11, 2025
dccb54f
do a 5-bit lookup table
warmCabin Aug 11, 2025
29aa686
add gui.clearcolorcache
warmCabin May 17, 2026
ca7f5e8
add gui.setcolormatchformula
warmCabin May 17, 2026
5fecb6e
rerun CI
warmCabin May 18, 2026
506795f
rerun CI
warmCabin May 19, 2026
2c0003c
rerun CI
warmCabin May 20, 2026
086a7c2
fix args not getting passed to Lua scripts when opened from recents menu
warmCabin May 21, 2026
1a43948
create luaconsole.h
warmCabin May 21, 2026
b6c06c9
print formatting fixes
warmCabin May 21, 2026
1b0d825
make APPENDPRINT into one macro
warmCabin May 21, 2026
17e3659
tokenize Lua arg string into table
warmCabin May 23, 2026
bc81ee0
tidy up lua console dialog proc a bit
warmCabin May 23, 2026
7d35d8c
extract string tokenizer function
warmCabin May 25, 2026
043dadc
Call GetLuaArgs everywhere it needs to be
warmCabin May 25, 2026
5ebfec0
make clear console into a button and add dummy old-style args checkbox
warmCabin May 25, 2026
2111e2c
actually pass argument compatibility mode to lua-engine.cpp
warmCabin May 25, 2026
5eeac36
add -luaargs command line arg
warmCabin May 25, 2026
97a9df6
more luaconsole.h stuff
warmCabin May 25, 2026
7c41759
attempt to get Qt build working
warmCabin May 25, 2026
caf77f0
further attempts to get the Qt build running
warmCabin May 26, 2026
fef295f
further attempts to fix the builds
warmCabin May 26, 2026
24977df
yet further attempts to fix the builds
warmCabin May 26, 2026
a29fd83
yet furtherer attempts to fix the builds
warmCabin May 26, 2026
5fc99fb
Let's get it working on Ubuntu!
warmCabin May 26, 2026
401a7b6
attempt to fix Mac builds
warmCabin May 27, 2026
1a72ee4
another Mac build fix attempt
warmCabin May 27, 2026
5ecd4c9
one more try
warmCabin May 27, 2026
439fa25
Revert Mac fix attempts
warmCabin May 27, 2026
130b44b
Revert Mac fix attempts
warmCabin May 27, 2026
b6af459
final cleanup
warmCabin May 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/drivers/Qt/LuaControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,8 @@ int LuaKillMessageBox(void)
return luaKillMsgBoxRetVal;
}
//----------------------------------------------------
bool LuaArgCompat = true;

// TODO: stub. scriptArgs->text().toLocal8Bit().constData() ?
bool GetLuaArgs(char *dst, int len) { dst[0] = 0; return true; }
//----------------------------------------------------
8 changes: 8 additions & 0 deletions src/drivers/Qt/LuaControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ private slots:
void stopLuaScript(void);
};

void WinLuaOnStart(intptr_t hDlgAsInt);

void WinLuaOnStop(intptr_t hDlgAsInt);

// Formatted print
int LuaPrintfToWindowConsole( __FCEU_PRINTF_FORMAT const char *format, ...) __FCEU_PRINTF_ATTRIBUTE( 1, 2 );

void PrintToWindowConsole(intptr_t hDlgAsInt, const char *str);

int LuaKillMessageBox(void);

bool GetLuaArgs(char *dst, int len);

extern bool LuaArgCompat;
2 changes: 2 additions & 0 deletions src/drivers/win/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ char* MovieToLoad = 0; //Loads a movie file on startup
char* StateToLoad = 0; //Loads a savestate on startup (after a movie is loaded, if any)
char* ConfigToLoad = 0; //Loads a specific .cfg file (loads before any other commandline options
char* LuaToLoad = 0; //Loads a specific lua file
char* LuaArgs = 0; //Arguments to the lua script
char* PaletteToLoad = 0; //Loads a specific palette file
char* AviToLoad = 0; //Starts an avi capture at startup
char* DumpInput = 0; //Dumps all polled input to a binary file. Probably only useful with -playmovie. This is a rickety system, only useful in limited cases.
Expand All @@ -53,6 +54,7 @@ char *ParseArgies(int argc, char *argv[])
{"-nothrottle", 0, &eoptions, 0x8000|EO_NOTHROTTLE},
{"-playmovie", 0, &MovieToLoad, 0x4001},
{"-lua", 0, &LuaToLoad, 0x4001},
{"-luaargs", 0, &LuaArgs, 0x4001},
{"-palette", 0, &PaletteToLoad, 0x4001},
{"-loadstate", 0, &StateToLoad, 0x4001},
{"-readonly", 0, &replayReadOnlySetting, 0},
Expand Down
1 change: 1 addition & 0 deletions src/drivers/win/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extern char* MovieToLoad; //Contains the filename of the savestate specified in
extern char* StateToLoad; //Contains the filename of the movie file specified in the command line arguments
extern char* ConfigToLoad; //Contains the filename of the config file specified in the command line arguments
extern char* LuaToLoad; //Contains the filename of the lua script specified in the command line arguments
extern char* LuaArgs; //Contains the argument string to be tokenized and passed to the lua script
extern char* PaletteToLoad; //Contains the filename of the palette file specified in the command line arguments
extern char* AviToLoad; //Contains the filename of the Avi to be captured specified in the command line arguments
extern char* DumpInput;
Expand Down
83 changes: 64 additions & 19 deletions src/drivers/win/luaconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
extern HWND hAppWnd;

void UpdateLuaConsole(const char* fname);
bool GetLuaArgs(char *dst, int len);

HWND LuaConsoleHWnd = NULL;
HFONT hFont = NULL;
Expand Down Expand Up @@ -39,14 +40,18 @@ static ControlLayoutInfo controlLayoutInfos [] = {
{IDC_EDIT_LUAARGS, ControlLayoutInfo::RESIZE_END, ControlLayoutInfo::NONE},
{IDC_BUTTON_LUARUN, ControlLayoutInfo::MOVE_START, ControlLayoutInfo::NONE},
{IDC_BUTTON_LUASTOP, ControlLayoutInfo::MOVE_START, ControlLayoutInfo::NONE},
{IDC_LUACONSOLE_CLEAR, ControlLayoutInfo::MOVE_START, ControlLayoutInfo::NONE},
};
static const int numControlLayoutInfos = sizeof(controlLayoutInfos)/sizeof(*controlLayoutInfos);

struct {
int width; int height;
int minTrackWidth; int minTrackHeight;
ControlLayoutState layoutState [numControlLayoutInfos];
} windowInfo;

bool LuaArgCompat = false;

void PrintToWindowConsole(intptr_t hDlgAsInt, const char* str)
{
HWND hDlg = (HWND)hDlgAsInt;
Expand Down Expand Up @@ -121,6 +126,9 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
GetClientRect(hDlg, &r3);
windowInfo.width = r3.right - r3.left;
windowInfo.height = r3.bottom - r3.top;
GetWindowRect(hDlg, &r3); // consider the initial size to be the minimum size
windowInfo.minTrackWidth = r3.right - r3.left;
windowInfo.minTrackHeight = r3.bottom - r3.top;
for(int i = 0; i < numControlLayoutInfos; i++) {
ControlLayoutState& layoutState = windowInfo.layoutState[i];
layoutState.valid = false;
Expand All @@ -130,8 +138,19 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
SetDlgItemText(hDlg, IDC_EDIT_LUAPATH, FCEU_GetLuaScriptName());

SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &LuaConsoleLogFont, 0); // reset with an acceptable font

HMENU hmenu = GetMenu(hDlg);
CheckMenuItem(hmenu, IDC_LUACONSOLE_ARGCOMPAT, LuaArgCompat ? MF_CHECKED : MF_UNCHECKED);
return true;
}

case WM_GETMINMAXINFO:
{
auto info = (MINMAXINFO*)lParam;
info->ptMinTrackSize.x = windowInfo.minTrackWidth;
info->ptMinTrackSize.y = windowInfo.minTrackHeight;
return true;
} break;
}

case WM_SIZE:
{
Expand Down Expand Up @@ -187,7 +206,7 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
default: break;
}

SetWindowPos(hCtrl, 0, x,y, width,height, 0);
SetWindowPos(hCtrl, HWND_TOP, x,y, width,height, SWP_NOREDRAW);

layoutState.x = x;
layoutState.y = y;
Expand All @@ -199,29 +218,33 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
windowInfo.width = dlgWidth;
windowInfo.height = dlgHeight;

RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE);
} break;
RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE);
return true;
}

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL: {
EndDialog(hDlg, true); // goto case WM_CLOSE;
} break;
case IDCANCEL:
{
goto close;
}

case IDC_BUTTON_LUARUN:
case IDOK:
{
char filename[MAX_PATH];
char args[MAX_PATH];
GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
GetDlgItemText(hDlg, IDC_EDIT_LUAARGS, args, MAX_PATH);
FCEU_LoadLuaCode(filename, args);
} break;
return true;
}

case IDC_BUTTON_LUASTOP:
{
FCEU_LuaStop();
} break;
return true;
}

case IDC_BUTTON_LUAEDIT:
{
Expand All @@ -232,7 +255,8 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
if((intptr_t)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
if((intptr_t)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL);
} break;
return true;
}

case IDC_BUTTON_LUABROWSE:
{
Expand All @@ -254,7 +278,7 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), szFileName);
}
return true;
} break;
}

case IDC_EDIT_LUAPATH:
{
Expand All @@ -264,7 +288,8 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
EnableWindow(GetDlgItem(hDlg, IDOK), file != NULL);
if(file)
fclose(file);
} break;
return true;
}

case IDC_LUACONSOLE_CHOOSEFONT:
{
Expand All @@ -284,28 +309,40 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
if (hFont)
SendDlgItemMessage(hDlg, IDC_LUACONSOLE, WM_SETFONT, (WPARAM)hFont, 0);
}
} break;
return true;
}

case IDC_LUACONSOLE_CLEAR:
{
SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), "");
} break;
return true;
}

case IDC_LUACONSOLE_ARGCOMPAT:
{
HMENU hmenu = GetMenu(hDlg);
CheckMenuItem(hmenu, IDC_LUACONSOLE_ARGCOMPAT, (LuaArgCompat = !LuaArgCompat) ? MF_CHECKED : MF_UNCHECKED);
return true;
}
}
break;


close:
case WM_CLOSE: {
FCEU_LuaStop();
DragAcceptFiles(hDlg, FALSE);
if (hFont) {
DeleteObject(hFont);
hFont = NULL;
}
EndDialog(hDlg, true);
LuaConsoleHWnd = NULL;
} break;
return true;
}

case WM_DROPFILES: {
HDROP hDrop;
//UINT fileNo;
UINT fileCount;
char filename[MAX_PATH];

Expand All @@ -317,7 +354,7 @@ INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
}
DragFinish(hDrop);
return true;
} break;
}

}

Expand All @@ -330,4 +367,12 @@ void UpdateLuaConsole(const char* fname)
if (!LuaConsoleHWnd) return;

SetWindowText(GetDlgItem(LuaConsoleHWnd, IDC_EDIT_LUAPATH), fname);
}
}

bool GetLuaArgs(char *dst, int len)
{
if (!LuaConsoleHWnd)
return dst[0] = 0;

return GetDlgItemText(LuaConsoleHWnd, IDC_EDIT_LUAARGS, dst, len) || !GetLastError();
}
14 changes: 14 additions & 0 deletions src/drivers/win/luaconsole.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef LUACONSOLE_H
#define LUACONSOLE_H

extern HWND LuaConsoleHWnd;
extern bool LuaArgCompat;

void PrintToWindowConsole(intptr_t hDlgAsInt, const char* str);
void WinLuaOnStart(intptr_t hDlgAsInt);
void WinLuaOnStop(intptr_t hDlgAsInt);
INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
void UpdateLuaConsole(const char* fname);
bool GetLuaArgs(char *args, int len);

#endif
4 changes: 3 additions & 1 deletion src/drivers/win/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,11 @@ int main(int argc,char *argv[])
}
if(GameInfo && LuaToLoad)
{
FCEU_LoadLuaCode(LuaToLoad);
FCEU_LoadLuaCode(LuaToLoad, LuaArgs); // TODO: Would be cool to send these args to the textbox
free(LuaToLoad);
free(LuaArgs);
LuaToLoad = NULL;
LuaArgs = NULL;
}

//Initiates AVI capture mode, will set up proper settings, and close FCUEX once capturing is finished
Expand Down
10 changes: 7 additions & 3 deletions src/drivers/win/res.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@ BEGIN
EDITTEXT IDC_LUACONSOLE,7,80,256,60,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL
LTEXT "Arguments:",IDC_STATIC,7,52,40,8
EDITTEXT IDC_EDIT_LUAARGS,47,50,216,14,ES_AUTOHSCROLL
PUSHBUTTON "&Clear",IDC_LUACONSOLE_CLEAR,213,66,50,13
END

VIDEOCONFIG DIALOGEX 65520, 76, 511, 170
Expand Down Expand Up @@ -3006,10 +3007,13 @@ END

LUAWINDOW_MENU MENU
BEGIN
POPUP "Console"
POPUP "Options"
BEGIN
MENUITEM "&Font...", IDC_LUACONSOLE_CHOOSEFONT
MENUITEM "Clear", IDC_LUACONSOLE_CLEAR
POPUP "Console"
BEGIN
MENUITEM "&Font...", IDC_LUACONSOLE_CHOOSEFONT
END
MENUITEM "Old-Style Args", IDC_LUACONSOLE_ARGCOMPAT
END
END

Expand Down
5 changes: 3 additions & 2 deletions src/drivers/win/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@
#define MENU_INSERT_COIN2 40013
#define MENU_SERVICE 40014
#define MENU_SERVICE_BUTTON 40015
#define IDC_LUACONSOLE_ARGCOMPAT 40017
#define MENU_NETWORK 40040
#define MENU_PALETTE 40041
#define MENU_SOUND 40042
Expand Down Expand Up @@ -1229,8 +1230,8 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 313
#define _APS_NEXT_COMMAND_VALUE 40016
#define _APS_NEXT_RESOURCE_VALUE 314
#define _APS_NEXT_COMMAND_VALUE 40018
#define _APS_NEXT_CONTROL_VALUE 1050
#define _APS_NEXT_SYMED_VALUE 101
#endif
Expand Down
Loading