from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[2] with open(REPO_ROOT / 'poker.asm', 'r', encoding='cp1251') as f: text = f.read() # 1. Add defaultPlayerSave if 'defaultPlayerSave' not in text: target = 'saveFileName db 64 dup(0)' replacement = 'saveFileName db 64 dup(0)\r\ndefaultPlayerSave db "Player.dat",0' text = text.replace(target, replacement, 1) # 2. Remove include casino3d.inc from old position old_inc = 'include casino3d.inc' if old_inc in text: text = text.replace(old_inc, '; include casino3d.inc moved below', 1) # 3. Update run_casino_3d in MainMenu old_run_3d = """run_casino_3d: call StartCasino3D jmp menu_loop""" new_run_3d = """run_casino_3d: invoke ShowWindow, hCasinoConsole, SW_HIDE call StartCasino3D invoke ShowWindow, hCasinoConsole, SW_SHOW invoke SetForegroundWindow, hCasinoConsole jmp menu_loop""" if old_run_3d in text: text = text.replace(old_run_3d, new_run_3d, 1) else: print('Notice: old_run_3d pattern not exact, searching line-by-line') # 4. Insert include casino3d.inc after MainMenu ENDP and replace main PROC pos = text.find('exit_menu:') if pos != -1: end_main_pos = text.find('END main') if end_main_pos != -1: new_main_block = """exit_menu: ret MainMenu ENDP include casino3d.inc ; --- main: Unified Entry Point --- main PROC invoke SetConsoleOutputCP, 65001 invoke SetConsoleCP, 65001 invoke GetStdHandle, STD_OUTPUT_HANDLE mov hOut, eax call ConfigureConsoleSize call EnableAnsi invoke CreateDirectoryA, OFFSET runtimeDir, 0 invoke GetStdHandle, STD_INPUT_HANDLE mov hIn, eax invoke GetTickCount mov seed, eax call InitSounds call InitPaths3D call AutoLoadAccountFast cmp accountCount, 0 jne @F call ResetProfileDefaults invoke CopyCString, OFFSET saveFileName, OFFSET defaultPlayerSave call SaveGame call CollectAccounts @@: call ApplySoundVolume invoke GetConsoleWindow mov hCasinoConsole, eax invoke ShowWindow, hCasinoConsole, SW_HIDE call StartCasino3D cmp mutex3D, 0 je @F invoke CloseHandle, mutex3D @@: invoke ExitProcess, 0 main ENDP """ text = text[:pos] + new_main_block + '\r\nEND main\r\n' print('Successfully replaced main block!') else: print('Error: END main not found') else: print('Error: exit_menu: not found') with open(REPO_ROOT / 'poker.asm', 'wb') as f: f.write(text.encode('cp1251')) print('poker.asm updated in CP1251!')