Spocks-cuddly-tribble wrote: ↑Sat Oct 07, 2023 5:44 pm
438655 jump loc_relocation
@ loc relocation
call 51D886 copy_file_EAX_to_name_EDX auto.sav -> last.sav // EDIT if sub_51D886 is rename and not copy then just leave this out
compose your new/extra file name string and mov start position pointer to edx
mov edx, start location new composed file name string
mov eax, offset aAuto_sav
call 51D886 copy_file_EAX_to_name_EDX auto.sav -> your new file name/location
jmp 43865A
great idea, but once auto.sav -> last.sav there is no auto.sav -> your new file name/location.
so instead I went with;
last.sav -> new.sav
auto -> last
write new auto
I need to do more testing but so far working as expected with using "race name"_"turn#.sav format (Romulans_9.sav)
if file present in saves folder it is deleted before new file is moved
checks turn 1 and 2 (turn 1 vanilla last.sav bug)
if turn 1 jump to 0043865A (create auto.sav, on turn 1 last.sav would be from different game)
if turn 2 jump to 0068C48A (auto.sav -> last.sav, create auto.sav)
else (last.sav -> new.sav, auto.sav -> last.sav, create auto.sav)
here is code (current but may still change)
00438641 E9 0A 3E 25 00 jmp loc_68C450 //jump point to new code
0068C450 loc_68C450: ; CODE XREF: sub_438630+11j
0068C450 A1 18 29 5A 00 mov eax, ds:dword_5A2918 //get current turn
0068C455 83 F8 01 cmp eax, 1 //if turn 1 jmp 43865A
0068C458 0F 84 FC C1 DA FF jz loc_43865A
0068C45E 83 F8 02 cmp eax, 2 //if turn 2 jmp 68C4A1
0068C461 74 3E jz short loc_68C4A1
0068C463 48 dec eax //decrease turn by 1 to match in-game display
0068C464 50 push eax
0068C465 36 A0 2A 2B 5A 00 mov al, ss:byte_5A2B2A // get player race id
0068C46B E8 00 E9 DA FF call sub_43AD70 // call jump_lex_monster_majors
0068C470 50 push eax
0068C471 68 A0 A3 68 00 push offset aSavesS_D_sav ; "Saves/%s_%d.sav"
0068C476 8D 44 24 0C lea eax, [esp+9Ch+var_90]
0068C47A 50 push eax
0068C47B E8 19 79 E8 FF call sprintf_ //call sprintf__compose_string
0068C480 83 C4 10 add esp, 10h //align esp to string start
0068C483 8B F4 mov esi, esp //move string to ESI
0068C485 56 push esi
0068C486 8B C6 mov eax, esi //move (esi) string to EAX
0068C488 8B D6 mov edx, esi //move (esi) string to EDX
0068C48A E8 DC 13 E9 FF call sub_51D86B //call delete_file_eax__last_sav
0068C48F B8 00 83 57 00 mov eax, offset aLast_sav ; "last.sav"
0068C494 90 nop
0068C495 E8 EC 13 E9 FF call sub_51D886 //call move_file_eax__last_sav
0068C49A BA 02 01 00 00 mov edx, 102h //reset edx
0068C49F 8B E6 mov esp, esi //reset esp
0068C4A1
0068C4A1 loc_68C4A1: ; CODE XREF: sub_438630+253E31j
0068C4A1 B8 00 83 57 00 mov eax, offset aLast_sav ; "last.sav" //over written jump code
0068C4A6 E9 9B C1 DA FF jmp loc_438646 //return to start point 438646
0068A3A0 53 61 76 65 73 2F 25 73 5F 25 64 2E 73 61 76 00 aSavesS_D_sav db 'Saves/%s_%d.sav',0 //new string offset