ROM Hack Beginning to Mod an obscure game.

COR3Z

Member
OP
Newcomer
Joined
Apr 2, 2020
Messages
21
Trophies
0
Age
19
XP
51
Country
Indonesia
cookie-shop-ds.jpg

Hello.

I'm here to start modding a really obscure game called cookie shop. To know further details of the game, you can search Cookie Shop DS on google or other search engines.

My main goal is to create custom stories using the game, however in order to do so, I would have to modify the text files, and when I tried to do so, every time I continue from my previous game, The top shows a black screen and all my controls are locked. I don't know if it's a byte problem or a compilation problem, but hopefully someone can help me.

I am able to extract all the graphics of the file.
 
  • Like
Reactions: jeffyTheHomebrewer

jeffyTheHomebrewer

Neato Burrito!
Member
Joined
Aug 24, 2018
Messages
857
Trophies
1
Location
in ur orbit
XP
1,299
Country
United States
Seems like maybe it could be a byte problem? Try getting the vanilla rom, and a vanilla rom of cookie shop in a different language, and move a text file from the other version into the english version and test it that way. If it still gets a black screen and hangs like that, then it's probably a compiling problem, maybe.
 

COR3Z

Member
OP
Newcomer
Joined
Apr 2, 2020
Messages
21
Trophies
0
Age
19
XP
51
Country
Indonesia
I found out that by looking into the text files, if I were to look at the first 4 bytes, it will reveal the length of the text file in bytes. (including the first 4 bytes)

However, I realized that the language is stored in bin files. I have gathered the following

offset: VARIABLE // details
0x0-0x3: FILE_LENGTH // File length in bytes
0x4-0x7: SEPERATOR_AMOUNT // The amount of line seperators in the text.
0x8-0xB: SEPERATOR_START // where does the line seperators start
0xC-0xF: TEXT_START// where does the text start
SEPERATOR_START until TEXT_START: TEXT_SEPERATOR 0x## // the line seperators of the text. Each seperator is 4 bytes long. To find where length of the text # that will be inputed, add TEXT_START by the TEXT_SEPERATOR of the line number

example:
in auto_wakeup_eng.bin

FILE_LENGTH: 0xf0h
TEXT_START: 0x44h
SEPERATOR_AMOUNT: 0x1dh
TEXT_SEPERATOR 0x00: 0x00h
TEXT_SEPERATOR 0x01: 0x48h
... (continues until SEPERATOR_AMOUNT)
TEXT_SEPERATOR 0x0d: 0xa1h

The length of "Today is the day of the contest! I have to go to the department store!" is 48 bytes,excluding the quotation marks and including the 00 byte.

I almost forgot about the text stuff, Inside the text, the hex 0A means enter, 20 is space key, and 00 is null.

There the next line, using TEXT_SEPERATOR 0x01, would be programmed to be in 0x44h + 0x48h = 0x8c, and if you check, the next line "Today the announce... (continued)" starts at 0x8ch.

I am unable to program a tool however to generate these types of bin files. I need help and I since I couldn't program bytes properly.



upload_2021-6-25_15-3-27.png


I also found out that the uncompressed LZ bin the text contained shares the NARC format.
So theoretically, I would have to...
1. uncompress the lz77 translation file AND lz77 the original script file, then extract both of the uncompressed bins
2. Rename both bins from .bin to .narc.
3. unpack using crystal tile
4. edit the original script file.
5. get the new length of the script file in bytes and paste it on the first 4 characters before the script name
6. Use a tool of some sort to edit the translation file.
7. replace the files on the corresponding folders
8. repack the narc files and rename the file type back to bin.
 
Last edited by COR3Z,
  • Like
Reactions: jeffyTheHomebrewer

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
34,340
Trophies
2
Website
trastindustries.com
XP
23,444
Country
United Kingdom
Interesting format and nice job on getting this far as that is not the simplest format. No magic stamp but relative pointer setup and most of what I would normally expect out of a competent take on a text format. At least you don't have compression beyond that NARC file setup to cause problems. By the way depending upon the program you are using you might not have to decompress and rename -- NARC files were often seen to be compressed and gained the extension CARC instead which some programs will handle, though not sure about CT2.

I will note in your example text there then there are various accented and whatnot characters unique to French. Not all games will support such things. Simple test here (thanks to no compression) is just overwrite one of the normal characters with it -- don't change length or anything. If the game displays what you want, or indeed does not crash before them (some games will crash if they encounter unexpected text), then you have them. If not then you either deal without them or edit the font to include them (usually better to edit existing than add by the way, though if it is NTFR then adding is not the hardest thing).

As far as compilation (rebuilding the ROM) then simple test there is unbuild using whatever you are using and rebuild accordingly. Some games are a bit fussy here about what they need, though for that there are tools like nitro explorer (originally made for New Super Mario Brothers which is one of the tricky ones for older approaches like ndstool).
 
  • Like
Reactions: jeffyTheHomebrewer

COR3Z

Member
OP
Newcomer
Joined
Apr 2, 2020
Messages
21
Trophies
0
Age
19
XP
51
Country
Indonesia
Code:
package;

import haxe.io.Bytes;
import flash.utils.ByteArray;
import flixel.FlxState;
import flixel.FlxG;
import flixel.addons.ui.FlxUINumericStepper;
import flixel.addons.ui.FlxInputText;
import openfl.net.FileReference;
import openfl.events.Event;
import openfl.events.IOErrorEvent;

class PlayState extends FlxState
{
    var inputFile:FileReference;
    inputFile = new FileReference();

    inputFile.addEventListener(Event.COMPLETE, coolLoad);
    inputFile.addEventListener(Event.CANCEL, cancelLoad);
    inputFile.addEventListener(IOErrorEvent.IO_ERROR, errorLoad);
    inputFile.load();

    var inputArray:ByteArray;
    var inputBytes:Bytes = inputFile.ofData();


    var textNumber = new FlxUINumericStepper(10, 10, 1, 1, 1, 100);
    var curNumber = new FlxUINumericStepper(65, 10, 1, 1, 1, textNumber.value);

    var fileLength:Int = inputBytes.getInt32(0);
    var dialogueLength:Int = inputBytes.getInt32(4);
    var tableStart:Int = inputBytes.getInt32(8);
    var scriptStart:Int = inputBytes.getInt32(12);

    var lineLengths:Array<Int> = [];
    var lines:Array<String> = [];
    var startLengths:Array<Int> = [];

    for (i in 0...dialogueLength-1)
        {
            startLengths.push(inputBytes.getInt32(16 + 4*i));
            if (i < dialogueLength-1) lineLengths.push(inputBytes.getInt32(16 + 4*(i+1))-inputBytes.getInt32(16 + 4*i));
            else lineLengths.push(lines[dialogueLength-1].length-inputBytes.getInt32(16 + 4*i));
        }

    for (i in 0...dialogueLength-1)
        {
            var text:String = inputBytes.getString(scriptStart + startLengths[i], lineLengths[i], UTF8);
            lines.push(text);
        }
   
    var line = new FlxInputText(10, 65, 300, lines[curNumber-1]);

    private function coolLoad()
        {
            inputFile.removeEventListener(Event.COMPLETE, coolLoad);
            inputFile.removeEventListener(Event.CANCEL, cancelLoad);
            inputFile.removeEventListener(IOErrorEvent.IO_ERROR, errorLoad);
            inputFile = null;
            FlxG.log.notice("Loaded translation file!");
        }

    private function cancelLoad()
        {
            inputFile.removeEventListener(Event.COMPLETE, coolLoad);
            inputFile.removeEventListener(Event.CANCEL, cancelLoad);
            inputFile.removeEventListener(IOErrorEvent.IO_ERROR, errorLoad);
            inputFile = null;
        }

    private function errorLoad()
        {
            inputFile.removeEventListener(Event.COMPLETE, coolLoad);
            inputFile.removeEventListener(Event.CANCEL, cancelLoad);
            inputFile.removeEventListener(IOErrorEvent.IO_ERROR, errorLoad);
            inputFile = null;
            FlxG.log.notice("Something wrong here. Please recheck.");
        }
   
   
}

I attempted to use HaxeFlixel and I want someone to test it out, I couldn't compile it for some reason on my end so I need your help.

Currently it is being used as a viewer and not an actual creator.
 
Last edited by COR3Z,
  • Like
Reactions: jeffyTheHomebrewer

COR3Z

Member
OP
Newcomer
Joined
Apr 2, 2020
Messages
21
Trophies
0
Age
19
XP
51
Country
Indonesia
Looking into the rom, specifically the arm9.bin, I can see a lot of commands that are going to be used in the script. Expressions include "sad", "shy", "talk", then special methods were written into the code such as, *set, *add, *sub, (any string that starts with *).

upload_2021-6-27_16-49-8.png

Unpacking the script files, multiple .txt files were found. These contain the variables the text has shown.

Many variables such as "day", "month", "year", and character names were found inside the list. The ones that I did not find is how they are called in.

upload_2021-6-27_16-55-55.png


Due to my lacking coding skills I'm finding someone who could create a tool that can create variables in the arm9.bin, generator for the script text file, and english translation, I will send you the rom in the pms if necessary.
 
General chit-chat
Help Users
    KennieDaMeanie @ KennieDaMeanie: Dick piercing is a manly statement