Last active
May 12, 2024 12:26
-
-
Save elModo7/ef2f859a99650ae21636a582c3fec537 to your computer and use it in GitHub Desktop.
Fix save data over 32Kb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; https://discord.com/channels/731899222311567400/731900507844640858/1239045849900646450 | |
| ; Removes bloat bytes from a Pokemon Crystal save file, maybe containing RTC data. Leaves the file as a pure 32Kb sav file. | |
| ;@Ahk2Exe-SetName SAV Size Fix | |
| ;@Ahk2Exe-SetDescription Fix save data over 32Kb | |
| ;@Ahk2Exe-SetVersion 1.2 | |
| ;@Ahk2Exe-SetCopyright Copyright (c) 2024`, elModo7 | |
| ;@Ahk2Exe-SetOrigFilename SAV Fix.exe | |
| #NoEnv | |
| #SingleInstance Force | |
| SetBatchLines, -1 | |
| statLabel := "v1.2 elModo7 2024" | |
| Gui +E0x10 | |
| Gui Font, s20 c0x0080C0 | |
| Gui Add, Text, x8 y21 w485 h47 +Center, Drag here your SAV file | |
| Gui, Font | |
| Gui Add, StatusBar, vstatus, %statLabel% | |
| Gui, Show, w500 h100, SAV Size Fix | |
| return | |
| GuiDropFiles(GuiHwnd, FileArray, CtrlHwnd, X, Y) { | |
| global | |
| for i, file in FileArray | |
| { | |
| SetWorkingDir, %file% | |
| GuiControl,,status, Patching... | |
| fileObj := FileOpen(file, "r") ; Open the file for reading | |
| if(fileObj.Length > 32768) | |
| { | |
| size := fileObj.Length - (fileObj.Length - 32768) | |
| BytesRead := fileObj.RawRead(buffer, size) ; Read until EOF - 44 | |
| fileObj.Close() | |
| SplitPath, file, fileName | |
| fileObj2 := FileOpen("out_" fileName, "w") ; Open the file for reading and writing | |
| fileObj2.RawWrite(buffer, size) ; Write the cropped file | |
| fileObj2.Close() | |
| MsgBox,,Success!, % fileName "`n▼ ▼ ▼`nout_" fileName "`n`nYour SAV file was patched successfully." | |
| GuiControl,,status, %statLabel% | |
| } | |
| else | |
| { | |
| MsgBox,,Error!, % file "`n`nYour SAV file was already 32Kb or lower! (" fileObj.Length " bits)." | |
| fileObj.Close() | |
| } | |
| } | |
| } | |
| GuiClose: | |
| ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment