Welcome!

Final Burn Neo => FBN Development => Topic started by: ggaclassics on July 03, 2016, 03:16:36 AM

Title: Load a savestate through a cheat file
Post by: ggaclassics on July 03, 2016, 03:16:36 AM
Hi,

I have managed to decompress a kof98 savestate into its raw form, meaning the bin data of driver before saving. Now, I want to know how can I load this raw data using a cheat file!

Is there any structure to this data specific to FBA or is it the same structure as that of NeoGeo's VRAM, REGs, ... ?
Title: Re: Load a savestate through a cheat file
Post by: dink on July 03, 2016, 08:29:42 AM
The only way to load it after unpacking it and modifying it is to repack it and use the load savestate function.
The savestate format is quite involved, it contains all the system variables, memory, cpu/soundcore internal data etc.
One would have to trace through NeoScan() and log the sizes of every variable/chunk of memory being scanned (SCAN_VAR) or BurnAcb'd (scan block) AND SCAN_OFF'd (scan a pointers' offset from a predetermined value) to get the actual format.  It might be helpfull to put a markers around the data you want to modify in the source code, then compile / run kof98 and take a savestate.  Something like INT32 marker = 0xf1f2f3f4; SCAN_VAR(marker); might be helpful.

best regards,
- dink
Title: Re: Load a savestate through a cheat file
Post by: ggaclassics on December 30, 2016, 01:00:31 AM
Well, I went to check RAMIndex(), ROMIndex(), and NeoScan() of both old and recent version of FBA. There is no difference in the index/size of memory chunks. I guess I'll have to look at the other functions as well.

Here is what I got from src:

Code: [Select]
RAMIndex()
offset size description
NeoPalSrc[0] 0x000000 0x002000 Palette RAM Bank 0
NeoPalSrc[1] 0x002000 0x002000 Palette RAM Bank 1
NeoGraphicsRAM 0x004000 0x020000 Graphics controller RAM (2 64KB banks)
Neo68KRAM 0x024000 0x010000 68K work RAM
NeoZ80RAM 0x034000 0x000800 Z80 RAM
NeoNVRAM 0x034800 0x010000 Battery backed SRAM
NeoMemoryCard 0x044800 0x020000 Memory card
CartRAM 0x064800 0x002000 PVC RAM
RAMEnd 0x066800 n/a n/a



ROMIndex()
offset size description
Neo68KBIOS 0x000000 0x080000 68K boardROM
Neo68KROM 0x080000 nCodeSize n/a
Neo68KVectors +nCodeSize 0x000400 Copy of 68K cartridge ROM with boardROM vector table
NeoZ80BIOS +0x000400 0x020000 Z80 boardROM
NeoZ80ROM +0x020000 0x080000 n/a
NeoZoomROM +0x080000 0x010000 Y Zoom table
ROMEnd +0x010000 n/a n/a



NeoScan()
data size
68K BIOS Neo68KBIOS 0x00020000 131072
68K ROM Neo68KROM nCodeSize n/a
Z80 BIOS NeoZ80BIOS 0x00020000 131072
Z80 ROM NeoZ80ROM 0x00080000 524288
Memory card NeoMemoryCard 0x00020000 131072
NVRAM NeoNVRAM 0x00010000 065536
Extra NVRAM NeoNVRAM2 0x00002000 008192
PVC RAM CartRAM 0x00002000 008192
68K RAM Neo68KRAM 0x00010000 065536
Z80 RAM NeoZ80RAM 0x00000800 002048
Palette 0 NeoPalSrc[0] 0x00002000 008192
Palette 1 NeoPalSrc[1] 0x00002000 008192
Graphics RAM NeoGraphicsRAM 0x00020000 131072

I've got to add that I've made two savestates with two different versions of FBA and exactly the same game variables. Then I decompressed the zlib chunks into raw data, and conducted many comparisons using a hex editor.
There's just too many occurrences of insertion, deletion, change, and matches for me to figure any pattern.
Title: Re: Load a savestate through a cheat file
Post by: ggaclassics on July 05, 2017, 03:20:57 AM
UPDATE
So I grabbed an unofficial FBA with RAM search and kept myself busy looking for a way to get those RAM values saved into a file.
My first attempt revolved around RAM search which had unsatisfying UI; selecting and adding rows to the watch was tedious, moreover, the save function could only output 256 addresses without their actual value (can you believe it?).
Realizing I'm wasting time I opted to OCR the whole table from RAM search with ffmpeg/screencapture, tesseract, and macros. It took me a while to set everything up and my test tries were a success... or so I though. There's 16MB of address that I have to scan, let's assume I'm able to scan 60 addresses each second, it would take more than 3 days to complete the process. IMPRACTICAL!

I was left with no choice but to try a memory dump. What I feared was facing some cryptic, hard-to-figure data structures that will take me back to square zero. Luckily, I was able to get the correct RAM values from it and save them separately into a file. I then proceeded to make a cheat file:

(http://i.imgur.com/hcoILBx.png)

I open FBA and I run the ROM... only to meet with this error:
Quote
Cheat file cheats\kof98.ini is malformed.
Please remove or repair the file.

Parse error at line 4, in cheat "Custom Load".
Problem:   value omitted.

I'm doing all of this to avoid dealing with the decompressed savestate file structure. Now my last bet is to write directly to memory the values I dumped.
Title: Re: Load a savestate through a cheat file
Post by: ggaclassics on October 31, 2017, 12:29:27 AM
It's a failure and a success. I think I have a clue now. If someone is well versed in 68000 assembly I'll be glad to hear some advise
Title: Re: Load a savestate through a cheat file
Post by: Surachaiy on November 02, 2017, 04:15:34 AM
Load savestate through cheat file, it can do it offline