mercoledì 20 aprile 2011

Why the translation of KH2 Final Mix sometimes freeze? There is a solution?

As a lot of people knows, the game freeze sometimes when you open a big chest, own a new keyblade or get void gold crowns for the puzzle. In this post I'll describe the cause of the problem.
Every OS, software or game, handle a lot of data that are managed by some functions like malloc, realloc and free (C/C++ is our best friend :P); this management is called DMA (Dynamic Memory Allocation). When you load a file with DMA, the system allocate spaces on RAM to hold the file that may be of any size and refresh a table that says to the system that at this address is loaded the file and tell the size of it. Kingdom Hearts game have DMA too and it handle a simple table but seems that the game have a bug; the game has some files compressed and the text files aren't an exception and currently there isn't a way to re-compress the files extracted, so I inserted the files unpacked on the translation Beta1, exceeding in size from the original ISO (but this isn't a problem). When the game load some texts uncompressed, they are placed over the table, so the game didn't find DMA anymore and it crashes. However when it load the text files compressed, the game insert them far away from the table, and decompress the content in a different location preserving the table. I can say this for sure because I tried to load the original Japanese text compressed, uncompressed and in different locations on ISO file, watch the table and the texts loaded in a RAM Viewer. So, currently the only way is to crack the decompression system to make an KH1/2 file compressor. It isn't impossible to do and today I'll focus on it :).

Ogni sistema operativo, software o gioco, gestisce un sacco di dati che sono pilotati da alcune funzioni come malloc, realloc e free; questa gestione viene chiamata DMA (Dynamic Memory Allocation). Quando carichi un file col DMA, il sistema alloca spazio nella ram per accogliere file di qualsiasi grandezza e aggiorna una tabella che dice al sistema che in quell'indirizzo è collocato il file e informa la sua grandezza. Anche il gioco di Kingdom Hearts ha il DMA e gestisce una semplice tabella che però, sembra esserci un bug nel gioco; Esso ha alcuni file compressi e i file di testo non sono da meno e correntemente non esiste un modo per ricomprimere i file di testo estratti, quindi ho inserito i file decompressi nella traduzione Beta1, eccedendo di grandezza dall'ISO originale (ma questo non è il vero problema). Quando il gioco carica alcuni testi decompressi, questi vengono caricati sopra la tabella, quindi il gioco non trova più la DMA e crasha. Però, quando il gioco carica i file di testo compressi, li inserisce lontani dalla tabella e il contenuto decompresso verrà piazzato in una locazione differente preservando la tabella. Posso dire questo con certezza perché ho provato a giocare col testo originale giapponese compresso, decompresso e in differenti locazioni nella ISO, vedendo la tabella e il testo caricato in un RAM Viewer. Quindi correntemente l'unico modo è crackare il sistema di decompressione per creare un compressore per KH1/2. Non è impossibile da fare e oggi mi concentrerò su quello :).

UPDATE: Cracked! But the compression system needs to be optimized:
SquareEnix compression system: 38,578 byte (472.82%)
Xeeynamo compression system: 83,673 byte (218.00%)
Original file size: 182,408 byte

UPDATE2: Full cracked the compression/decompression :D, now the files compressed are equal to Square's compression system.

UPDATE3: Compression improved:
SquareEnix compression system: 38,578 byte (472.82%)
Xeeynamo compression system: 38,318 byte (476.03%)
Original file size: 182,408 byte

19 commenti:

  1. @xeeynamo
    Well I´m not a programer, so I havent understood a lot of what you said. But good luck finding the fix for it ;)
    BTW, is because of that that the game wont work on a ps2? do you know why it is? is there already a fix for that? (Im using the english one)

    1. one question Xeeynamo can you make one last update for the patch just one i have the latest update and there are a few bugs is the game gets slow when changing rooms ..the other is when FMVs end they start normally as fast as they should but take a long time to end .balck screen for ten -15 seconds...

  2. OK. I´ve already seen Ophelia´s post about swap magic.
    I´ve allways burned dvd +R at max and never happened that.
    But maybe that´s because of that (I dont think that run in PAL mode changes something, it only lowers the screen size and display color on tv´s that dont support NTCS). For the [] I always use that one .
    So as I lack dvds (I want to spend one on a better version) do you know when the next beta will be released? Will the next be the final one?

  3. @b: Don't ruin more DVDs. It's strange that your PS2 won't accept the game... Do you use the swapmagic or modchip? What PS2 model is it? The original version of KH2FM works? However I don't recommend to anyone to burn this beta version, better if you play it with PCSX2

  4. First of all a great "Thank you" for all you did so far Xeeynamo, it's just looking fantastic !

    But unfortunatly there occurs an error everytime I want to open the menu the first time it's possible in the game - when roxas has to do some jobs to gain money for the train.

    PCSX2 says :

    Tlb Miss, addr=0x2000004 [load]
    PC : 0x002ac3bc Cycle: 0xd5da91d0

    Has this problem ever occured before, do I have some bad configuration or is it some known bug ?

  5. @Dennis: Thank you too for the interest :). However it isn't a wrong configuration of PCSX2 but a bug of the translation (exactly a bug of the game that I'm not able to avoid already. If you want to start the game for the first time I recommend you to wait another release of translation :) just be patient.

  6. Okay, thanks for the quick answer and I'll be patiently waiting for your next update :)!

  7. I´m using swap magic 3.6 on a PAL slim PS2.
    and yeah, the original KH2FM works with no prob (BTW I even use a beta patch for Tales of Destiny 2 and it works).
    I´ve already tryed to use pcsx2 but I dont seem to get the emu started (and I can play Wii on dolphin, so ps2 wouldn´t be a problem)(and I´ve tryed with Tales of Ayss too so the problem is not from KH2FM, its just me it seems :( )

  8. @b
    Try burning it at 2x... I couldn't download that patch yet, but both of Majik's patches work just fine. If Xeeynamo's don't work, try using Majik's latest:

  9. Questo commento è stato eliminato dall'autore.

  10. it might be a size issue, or a instruction gets corrupted/overwritten at some point thus failing when it gets called (one tiny error can affect many commands) So they might all be related.

    I'm just taking a guess though. I'm not really knowledgeable when it comes to the ps2.

    you might want to try physically replacing the table that holds the text strings.

  11. Ciao!!!
    Sto provando la beta è ho riscontrato lo stesso problema di Dennis di qualche post fa, e ho capito che stai già provvedendo...
    Comunque ho trovato un altro problema: la beta va molto lenta però se metto in pausa torna la velocità normale, gli altri giochi mi girano perfettamente su pcsx2... è un problema risolvibile con la versione completa ho devo mettere impostazioni migliori???

  12. Finalmente qualche progresso :)

  13. So, should I re-download before I continue my full-on play-through comparison? And where is the download?

  14. I think these days will post the download ....

  15. @xeeynamo
    so man i supose this time a patch will be made rather than an iso right ? :D just asking out of curiosity

  16. Xeeynamo è da un bel pò ke non ci aggiorni sugli sviluppi della patch di KHII FM.....=(.Quali sono i risultati fino ad ora? (Xeeynamo is quite a bit ke no update on developments in the patch of KHII FM .....=(. What are the results so far?)

  17. Xeeynamo giocando su pcsx2 la beta 1 con il bug delle corone,ho notato che non è che non accetta le corone per il puzzle,ma le devi prendere in un determinato ordine perchè il grillario le accetti.
    Questo perchè prima ho preso delle corone nel mondo che non esiste e non me le dava,ma dopo aver preso delle corone a port royal,sono ritornato e le prendeva!
    Quando prendevo le corone venivano fuori dei numeri tipo 20345 e non crashava.
    So che il Bug è ormai risolto ma volevo fartelo sapere.
    Grazie ancora per il grandioso lavoro che stai facendo!!

  18. yeah just one last patch xeeynamo and itll be flawless perfection master Xeynamo