• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
March 28, 2024, 05:28:12 pm

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - endrift

1
FFTA/FFTA2 Hacking / FFTA busy loop removal
February 03, 2015, 12:44:31 am
This patch will basically just make FFTA use less CPU in emulators (up to maybe 35%, but it practice probably more like 15%). That's about it. But it's great if you hold down fast forward all the time! I've only tested it against the US release (AGB-AFXE-USA, MD5: cd99cdde3d45554c1b36fbeb8863b7bd), but it might work against other regions as well.

Background: Final Fantasy Tactics Advance is not particularly well coded. That's no surprise, because most GBA games have tons of errors. However, one specific grievance that FFTA has is that, while waiting for the current frame to end, it performs a busy loop, perpetually checking if the frame has ended. This patch replaces three instructions to call the Halt syscall, which causes the CPU to stop until something happens. This saves battery on real GBAs, and lets emulators not do as much work, so as a result, emulated games use less CPU time.
2
Completed Mods / WotL Slowdown Removal Patch
February 22, 2012, 02:21:59 pm
Having almost completed my research, I have put together two patches for WotL, for unstretching the screen and speeding up the game. Although I did not personally test on the PSN version or any regions other than US, I've gotten reports that it works on the PSN release as well as the EU versions. A separate JP version is included, as well. As these are only preliminary patches, you might expect some bugs. However, I've found that in general, they work pretty well. The patching utility will require a PSP with custom firmware, and additional instructions are included. However, you won't need ISOs or any messy patching utilities on your computer. Everything is done when the game is run on the PSP!

An early version of the patching utility as well as the patches are attached. Please post feedback and bugs you find! You probably will not need the debug version of the utility (the only noticeable difference to a user is that it dumps a log), so download the regular version unless I ask you for a log.
3
Slowdown patches can be found here: http://ffhacktics.com/smf/index.php?topic=8490.0

Old post:

For the past week or so, I've had my PSP strapped into a debugger and have been slowly picking apart the assembly of War of the Lions and documenting it by transforming it into semi-readable C code. In order to stave off potential copyright concerns, I will NOT be posting straight dumps or disassemblies, although I can provide instructions for obtaining these manually from your own copies of WotL. (It's pretty easy, assuming you have custom firmware. Without custom firmware, it's a bit more difficult.) While this will complicate visualizing the mapping of C to and from assembly, as I won't be able to post my annotated disassemblies, I hope that that won't impede progress too much, and I do encourage people to try and do some of this work in parallel to make sure that I don't make too many mistakes while sorting through the myriad lines of disassembled code.

I will be keeping a git repository containing all of the progress (that I can post, as discussed above) on BitBucket: https://bitbucket.org/Archaemic/wotl

There is a central notes file called wotlnotes.txt, while most of the code I will be tossing into src/wotl.c. If any of these grows too large, I will split it up. I will also try to keep an up-to-date version of wotlnotes.txt in the following post. (I'm making it a separate post because it will be BIG.)

Here is a (hopefully) up to date list of what's going on:

What this means:

  • I will be making an effort to fix the slowdown and, if possible, sound desync issues.

  • It's not going to be easy; it will take me a while to get anywhere significant.

  • I can't guarantee I will actually get anywhere significant!

  • I'm posting almost everything online, so other people can help if they want.

  • Until then, I'm basically working alone. If you have experience and want to step up to the plate, you are welcome to!



What I have done so far:

  • Created a framework for attaching hooks into system calls, allowing me to trace where things get called.

  • Found out where things hook into the PSP's graphics engine.

  • Reverse engineered some parts of War of the Lion's graphics engine.

  • Unstretched the screen (in most places).

  • Figured out the general structure of a single redraw.

  • Found what is causing the slowdown.

  • Nullified the slowdown.



What I am working on right now:

  • Seeing if nullifying the slowdown has ill effects, and if so, what the best way to manage this is.

  • Discerning why the slowdown exists.

  • Locating where instructions are written from each frame.

  • Testing a screen unstretching patch.

  • Finding more places where the screen gets stretched.

  • Figuring out why there are PS1 GPU calls in a PSP game.

  • Figuring out where the halving and thirding are occurring.



What I have NOT done so far:

  • Figured out why the results of the timing function are having the affect they are.

  • Figured out the best way to remove the slowdown.

  • Found out where the GE lists are initialized.

  • Found out where the PS1 GPU calls are going.

  • Found out if the graphics engine is actually PS1 GPU emulation.

  • Found out what's causing any of the slowdown.

  • Fixed any of the slowdown.



Some miscellaneous observations:

  • The entirety of the main executable from the JP PS1 version of FFT is present in the file fftpack.bin. I can't find any traces of this file in the game when it's running, though.

  • The main thread for the game is called "psx_main", entailing that there is emulation going on. Given that the PS-X EXE doesn't appear to be in memory, though, this implies that there either isn't actually emulation, or they're doing JITing/dynarec for some reason. (I'd imagine all you'd need to fix is the memory accesses and offsets, and hardware I/O, but I might be wrong. That can be done easily with dynarec though.)

  • Very few GPU/ge calls are made per frame, seemingly always 0 (when the screen is blank) to 6. 2-4 seems typical. This implies that most of the rendering is either done all at once by sending a ton of commands to the GPU (which seems to be the case, given the mass of kilobytes of GPU instructions floating around at around 0x90f3c80), or done in CPU (would explain some of the slowdown!).

  • GPU calls seem to only have about 16 instructions at once (although I haven't confirmed this), meaning that doing all the rendering on the GPU in spurts is even more unlikely. This was a mistake. There are actually tons of instructions passed at a time. The 16 referred to the size of something else.

  • Frames are usually only drawn once every 1 or 2 vblanks, depending on factors that I am not sure of. For example, the load from memory stick screen is usually 1 redraw every two vblanks, but a lot of other stuff is every vblank.

  • During casting, the game only redraws every third vblank. I'm still looking into why.

  • I've found code that talks to the GPU, but modifying it doesn't seem to make the GPU do anything differently. Hurm.... Must investigate further.

  • There are PS1 GPU calls in the game that actually have an effect. It looks like there might be PS1 GPU emulation here.

  • The game rewrites all of its graphics instructions (up to 512kB) every frame. This might be related to the slowdown--it might try to do one (or two) frame(s) to write the instructions, one frame to run the instructions.

  • The slowdown is caused by something going funky in the function that detects timing between frames. Setting a fixed value for the time it tells us removes the slowdown, but I'm not sure why yet.

4
The Lounge / Checking in
February 12, 2012, 07:08:55 pm
Hello! I've been active in the IRC channel for a few weeks now, but I hadn't gotten around to making a forum account until just now.

A few years ago, I decided to see if I could do ROM hacking on a game that hadn't been hacked before, and if so, how far I could get. As such, I'm the first person to make any real progress at hacking FFTA. I haven't looked at it in a while, but I basically wrote the Data Crystal articles on FFTA. Darthatron seems to have picked up where I left off.

More recently, I got the bright idea in my head that I might have enough expertise to take a hammer disassembler to FFT: War of the Lions and see if I could flatten out any of those sound sync or slowdown issues. As of yet, I've not done anything other than reverse engineer bits and pieces of the graphics engine. I'll be posting a thread soon on my progress.

So how are things going on this message board? I read the rules, anything else I should know?

And before you ask, I've had this username for more than 5 years and I am not affiliated in any way with someone who might have a similar username.