ROM Hack Recreate a CTPK File - Have some problems

xXDungeon_CrawlerXx

Well-Known Member
OP
Member
Joined
Jul 29, 2015
Messages
2,092
Trophies
1
Age
28
Location
Liverpool
XP
3,720
Country
Hey Guys,

I want to edit a CTPK File (a Texture) but I've a problem now.
I found out that the original File uses RGBA4-Format but no CTPK-Tool is able to create a file in this format.
Now I know that I can create a BCLIM in this format and copy the CTPK-Header (0x00 - 0x7F) to this bclim file + removing the last few bytes of the bclim file.
Now I ran into a other problem:
The CTPK-Files of this rom are a bit different. Do you find the difference between the original File and the recreated file?
ctpktestlwp3h.png
exactly!
Every single bit of the original file (excluding the header) is -1 of the recreated file.

So my question:
Someone who can help me by creating a tool which ADD "1" of every single bit of a file?

I tried to use the recreated file but the game crashes when It tries to load it.
 
Last edited by xXDungeon_CrawlerXx,

xXDungeon_CrawlerXx

Well-Known Member
OP
Member
Joined
Jul 29, 2015
Messages
2,092
Trophies
1
Age
28
Location
Liverpool
XP
3,720
Country
Anyways, I got it!
I wrote my own tool to add 0x11 to every byte of the file.
It isn't the best solution but it works:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    unsigned char onebyte;
    FILE * OldImage;
    FILE * NewImage;
    char charfilename[80];
    char charfilename2[80];
    int filelength;
    printf( "Enter the filename\n");
    gets(charfilename);
    printf( "Enter the new Filename\n");
    gets(charfilename2);
    if (strcmp(charfilename2,charfilename) == 0)
    {
        return 1;
    }
    OldImage = fopen(charfilename,"rb");
    fseek (OldImage,0,SEEK_END);
    filelength = ftell(OldImage);
    fseek (OldImage,0,SEEK_SET);
    NewImage = fopen(charfilename2,"wb+");
    while(filelength > ftell(NewImage))
    {
        fread (&onebyte,1,1,OldImage);
        onebyte = onebyte+0x11;
        fwrite (&onebyte,1,1,NewImage);
    }
    printf( "Done.\n");
   return 0;
}
 

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,287
Trophies
4
Location
Space
XP
13,845
Country
Norway
Anyways, I got it!
I wrote my own tool to add 0x11 to every byte of the file.
It isn't the best solution but it works:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    unsigned char onebyte;
    FILE * OldImage;
    FILE * NewImage;
    char charfilename[80];
    char charfilename2[80];
    int filelength;
    printf( "Enter the filename\n");
    gets(charfilename);
    printf( "Enter the new Filename\n");
    gets(charfilename2);
    if (strcmp(charfilename2,charfilename) == 0)
    {
        return 1;
    }
    OldImage = fopen(charfilename,"rb");
    fseek (OldImage,0,SEEK_END);
    filelength = ftell(OldImage);
    fseek (OldImage,0,SEEK_SET);
    NewImage = fopen(charfilename2,"wb+");
    while(filelength > ftell(NewImage))
    {
        fread (&onebyte,1,1,OldImage);
        onebyte = onebyte+0x11;
        fwrite (&onebyte,1,1,NewImage);
    }
    printf( "Done.\n");
   return 0;
}
Have you checked what happens if a byte is F0 or larger before adding? Does it roll around to 00? Or does that never occur?
 

xXDungeon_CrawlerXx

Well-Known Member
OP
Member
Joined
Jul 29, 2015
Messages
2,092
Trophies
1
Age
28
Location
Liverpool
XP
3,720
Country
Have you checked what happens if a byte is F0 or larger before adding? Does it roll around to 00? Or does that never occur?
In the recreated file (RGBA4 Format) the highest byte is "EE".
So F0 never appears, no need to check it ;D

Tested it: FF will change to 10 but all my recreated files doesn't contain bytes Higher than EE
 
Last edited by xXDungeon_CrawlerXx,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Sicklyboy @ Sicklyboy: I finally modeled and 3d printed the new HDD cages I need in order to build my 2nd NAS. Original...