Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
66 changes: 66 additions & 0 deletions build-tiny.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@echo off
setlocal

set "INCDIR=C:\masm32\include"
if not exist "%INCDIR%\windows.inc" (
echo Missing MASM include dir: "%INCDIR%"
exit /b 1
)

set "MLCMD="
for /f "delims=" %%I in ('where ml 2^>nul') do (
set "MLCMD=%%I"
goto :found_ml
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "delims=" %%I in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find VC\Tools\MSVC\**\bin\Hostx64\x86\ml.exe 2^>nul') do (
set "MLCMD=%%I"
goto :found_ml
)
)
echo Could not find ml.exe
exit /b 1

:found_ml
set "CRINKLER="
for /f "delims=" %%I in ('where crinkler 2^>nul') do (
set "CRINKLER=%%I"
goto :found_crinkler
)
if exist "%LOCALAPPDATA%\Tools\Crinkler\crinkler30a\Win32\Crinkler.exe" (
set "CRINKLER=%LOCALAPPDATA%\Tools\Crinkler\crinkler30a\Win32\Crinkler.exe"
goto :found_crinkler
)
echo Could not find Crinkler.exe
exit /b 1

:found_crinkler
set "SDKLIB="
for /f "delims=" %%I in ('dir /b /ad /o-n "C:\Program Files (x86)\Windows Kits\10\Lib" 2^>nul') do (
if exist "C:\Program Files (x86)\Windows Kits\10\Lib\%%I\um\x86\kernel32.lib" (
set "SDKLIB=C:\Program Files (x86)\Windows Kits\10\Lib\%%I\um\x86"
goto :found_sdklib
)
)
echo Could not find Windows SDK x86 libs
exit /b 1

:found_sdklib
"%MLCMD%" /nologo /c /coff /Cp /I"%INCDIR%" /Fotrpad.obj trpad.asm
if errorlevel 1 exit /b 1

"%CRINKLER%" trpad.obj ^
/OUT:trpad-tiny.exe ^
/ENTRY:MainEntry ^
/SUBSYSTEM:WINDOWS ^
/NOINITIALIZERS ^
/TINYIMPORT ^
/TRANSFORM:CALLS ^
/HASHSIZE:32 ^
/ORDERTRIES:2000 ^
/LIBPATH:"%SDKLIB%" ^
kernel32.lib user32.lib shell32.lib comdlg32.lib gdi32.lib
if errorlevel 1 exit /b 1

del trpad.obj
endlocal
71 changes: 58 additions & 13 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,58 @@
ml /nologo /c /coff /Cp /IC:\masm32\include trpad.asm

crinkler trpad.obj ^
/OUT:trpad.exe ^
/ENTRY:MainEntry ^
/SUBSYSTEM:WINDOWS ^
/NOINITIALIZERS ^
/TINYIMPORT ^
/ORDERTRIES:2000 ^
/LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.20348.0\um\x86" ^
kernel32.lib user32.lib shell32.lib comdlg32.lib gdi32.lib

del trpad.obj
@echo off
setlocal

set "INCDIR=C:\masm32\include"
if not exist "%INCDIR%\windows.inc" (
echo Missing MASM include dir: "%INCDIR%"
exit /b 1
)

set "MLCMD="
for /f "delims=" %%I in ('where ml 2^>nul') do (
set "MLCMD=%%I"
goto :found_ml
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "delims=" %%I in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find VC\Tools\MSVC\**\bin\Hostx64\x86\ml.exe 2^>nul') do (
set "MLCMD=%%I"
goto :found_ml
)
)
echo Could not find ml.exe
exit /b 1

:found_ml
set "LINKCMD="
for /f "delims=" %%I in ('where link 2^>nul') do (
set "LINKCMD=%%I"
goto :found_link
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
for /f "delims=" %%I in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find VC\Tools\MSVC\**\bin\Hostx64\x86\link.exe 2^>nul') do (
set "LINKCMD=%%I"
goto :found_link
)
)
echo Could not find link.exe
exit /b 1

:found_link
set "SDKLIB="
for /f "delims=" %%I in ('dir /b /ad /o-n "C:\Program Files (x86)\Windows Kits\10\Lib" 2^>nul') do (
if exist "C:\Program Files (x86)\Windows Kits\10\Lib\%%I\um\x86\kernel32.lib" (
set "SDKLIB=C:\Program Files (x86)\Windows Kits\10\Lib\%%I\um\x86"
goto :found_sdklib
)
)
echo Could not find Windows SDK x86 libs
exit /b 1

:found_sdklib
"%MLCMD%" /nologo /c /coff /Cp /I"%INCDIR%" /Fotrpad.obj trpad.asm
if errorlevel 1 exit /b 1

"%LINKCMD%" /NOLOGO /SUBSYSTEM:WINDOWS /ENTRY:MainEntry@0 /OUT:trpad.exe trpad.obj /LIBPATH:"%SDKLIB%" kernel32.lib user32.lib shell32.lib comdlg32.lib gdi32.lib
if errorlevel 1 exit /b 1

del trpad.obj
endlocal
18 changes: 6 additions & 12 deletions trpad.asm
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ ENDIF
ClassName db ".",0 ; save bytes here (seems to work)
RichDll db "Msftedit",0 ; Rich Edit DLL (no ext saves those bytes)
EditClass db "RICHEDIT50W",0 ; modern Rich Edit control from WinAPI
SaveText db "Save",0 ; button added to system menu
EmptyText db 0

hMain dd 0 ; main window handle
Expand Down Expand Up @@ -271,9 +270,7 @@ MStatusBar db "&Status Bar",0

MViewHelp db "&View Help",0
MAbout db "&About TinyRetroPad",0
AboutCap db "TinyRetroPad",0
AboutText db "TinyRetroPad - tiny notepad-style editor",0
SaveCap db "TinyRetroPad",0
SaveAskText db "Save changes?",0
SpaceText db " ",0
DateBuf db 32 dup (0)
Expand All @@ -287,8 +284,6 @@ fr FINDREPLACEA <> ; shared find/replace request
hFindDlg dd 0 ; modeless find/replace dialog HWND
uFindMsg dd 0 ; registered FINDMSGSTRING message

StaticClass db "STATIC",0 ; built-in class for status bar pane
DocName db "TinyRetroPad",0 ; print job document name
LnColFmt db " Ln %d, Col %d",0 ; status bar Ln/Col format
StatusBuf db 48 dup (0) ; formatted Ln/Col text
hStatus dd 0 ; status bar window handle
Expand All @@ -306,7 +301,6 @@ MDarkMode db "Dark &Mode",0 ; View menu label
ENDIF

hInst dd 0 ; module handle (for dialogs)
OpenVerb db "open",0 ; ShellExecute verb
HelpUrl db "https://github.com/davepl",0

; in-memory Go To dialog template (no font block to stay compact)
Expand Down Expand Up @@ -625,7 +619,7 @@ MaybeSaveChanges proc NEAR

AskSave:
push MB_YESNOCANCEL or MB_ICONQUESTION
push OFFSET SaveCap
push OFFSET MAbout+7
push OFFSET SaveAskText
mov eax, hMain
push eax
Expand Down Expand Up @@ -1012,7 +1006,7 @@ PrintDoc proc NEAR
mov ecx, SIZEOF DOCINFOA
rep stosb
mov docInf.cbSize, SIZEOF DOCINFOA
mov docInf.lpszDocName, OFFSET DocName
mov docInf.lpszDocName, OFFSET MAbout+7
lea eax, docInf
push eax
push hPrnDC
Expand Down Expand Up @@ -2059,7 +2053,7 @@ ENDIF
push FALSE
push hWnd
call [_imp__GetSystemMenu@8]
push OFFSET SaveText
push OFFSET MSaveMenu+1
push IDM_SAVE
push MF_STRING
push eax
Expand All @@ -2080,7 +2074,7 @@ ENDIF
push 0
push WS_CHILD or WS_VISIBLE
push OFFSET StatusBuf
push OFFSET StaticClass
push 0082h
push WS_EX_STATICEDGE
call [_imp__CreateWindowExA@48]
mov hStatus, eax
Expand Down Expand Up @@ -2542,7 +2536,7 @@ ENDIF

CmdHelpAbout:
push MB_OK or MB_ICONINFORMATION
push OFFSET AboutCap
push OFFSET MAbout+7
push OFFSET AboutText
push hWnd
call [_imp__MessageBoxA@16]
Expand All @@ -2554,7 +2548,7 @@ ENDIF
push 0
push 0
push OFFSET HelpUrl
push OFFSET OpenVerb
push 0
push 0
call [_imp__ShellExecuteA@24]
xor eax, eax
Expand Down