don't click here

CRam Converter

Discussion in 'Engineering & Reverse Engineering' started by fuzzbuzz, Dec 29, 2003.

Thread Status:
Not open for further replies.
  1. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    Xinux and I were having a conversation the other day, and he stated how tedious and boring it was to manually change Palettes pulled from a rom, or other CRam dumps into Tile Layer Pro format palettes (*.TPL files). So I volunteered and wrote a program that will do it for you.


    CRam Palette Converter


    It's a console program, as I am too lazy to make a gui for it. Syntax:

    CRamConv.exe Inputfile Outfile.tpl

    You should put the tpl extension on the outfile, just so you can open it right from Tile Layer Pro.

    ================================================
    Speaking of Tile Layer Pro, who else has to do this to get it to open Genesis Roms...

    In the Open dialog box, I have to type "*.bin" into the filename for it to show my Roms. Then, after that, I have to manually change the format to "Genesis" else it won't work. Anybody else have to do this?

    If anybody wants me to post the source for this, so they can do whatever with it, just mention it in here.



    Fuzzbuzz
     
  2. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    Code:

    Code (Text):
    1. #include "iostream.h"
    2. #include "fstream.h"
    3. #include "stdlib.h"
    4. #include <windows.h>
    5.  
    6. int main(int argc, char **argv)
    7. {
    8.     int sResult,I,j;
    9.     char read[256], temp[1], write[(256 * 3) + 4];
    10.     HANDLE fin;
    11.     HANDLE fout;
    12.     BY_HANDLE_FILE_INFORMATION File_Inf;
    13.     int Size;
    14.     unsigned long Bytes_Read, bw;
    15.  
    16.     if (argc != 3)
    17.     {
    18.  &nbsp;cout << "Usage:\n CRamConv.exe\tFilein\tFileout\n";
    19.  &nbsp;return 0;
    20.     }
    21.  
    22.     if ((fin = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
    23.     {
    24.  &nbsp;cout << "Cannot open input file.\n";
    25.  &nbsp;return 0;
    26.     }
    27.  
    28.     if ((fout = CreateFile(argv[2], GENERIC_WRITE, NULL, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
    29.     {
    30.  &nbsp;cout << "Output file already exists.\n";
    31.  &nbsp;return 0;
    32.     }
    33.  
    34.  
    35.     //Get File Size
    36.     if (GetFileInformationByHandle(fin, &File_Inf))
    37.  &nbsp;Size = (File_Inf.nFileSizeHigh << 16) + File_Inf.nFileSizeLow + 65536;
    38.  
    39.     //Read bytes into buffer
    40.     memset(read, 0, 256);
    41.     memset(write, 0, (256 * 3) + 4);
    42.     sResult = ReadFile(fin, read, (Size - 65536), &bw, NULL);
    43.  
    44.     write[0] = 'T';
    45.     write[1] = 'P';
    46.     write[2] = 'L';
    47.     write[3] = 0x00;
    48.  
    49.     //Convert array to TPL Array
    50.     for (I=4, j=0; I < sizeof(write); I+=3, j+=2) {
    51.  &nbsp;//Blue
    52.  &nbsp;temp[1] = read[j];
    53.  &nbsp;write[I+2] = temp[1] << 4;
    54.  &nbsp;//Green
    55.  &nbsp;temp[1] = read[j+1];
    56.  &nbsp;write[I+1] = (temp[1] >> 4) << 4;
    57.  &nbsp;//Red
    58.  &nbsp;temp[1] = read[j+1];
    59.  &nbsp;write[I] = temp[1] << 4;
    60.     }
    61.  
    62.     sResult = WriteFile(fout, write, sizeof(write), &Bytes_Read, NULL);
    63.  
    64.     cout << "Conversion Successfully Completed" << endl;
    65.  
    66.     CloseHandle(fin);
    67.     CloseHandle(fout);
    68.  
    69.     return 0;
    70. }

    Fuzzbuzz
     
  3. Rika Chou

    Rika Chou

    Tech Member
    5,276
    170
    43
    Hivebrain already wrote a program that takes TLP pallets out of screen shots.
     
  4. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    I know, but this converts palettes ripped straight from the rom, like palettes not used and stuff.


    Fuzzbuzz
     
  5. Rika Chou

    Rika Chou

    Tech Member
    5,276
    170
    43
    So does his tool, the screen shots made with Genecyst contain the exact pallet data.
     
  6. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    Oh, well here you don't have to make a screenshot, and if you can't run Genecyst...=P

    EDIT: AND if you didn't want to download my emulator, which can pretty much do it for you anyway... :P


    Fuzzbuzz
     
  7. Hivebrain

    Hivebrain

    Administrator
    3,068
    204
    43
    53.4N, 1.5W
    Github
    That's good, but you still have to dump the CRam with an emulator. It would be better if you could specify an offset in a file to extract the pallete from, so you could get palletes directly from the ROM.
     
  8. Rika Chou

    Rika Chou

    Tech Member
    5,276
    170
    43
    Another tool that would be useful is something searches the ROM for a particular pallet line.
     
  9. Quickman

    Quickman

    be attitude for gains Tech Member
    5,595
    18
    18
    :x
    omg porjcet
    If Magus' little compression/decompression tool could be expanded to a general utilities tool, he could incorporate that as part of it. He already has the code for the offset-type stuff.
     
  10. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    Hmm...That's something I could look into. Though, I'm focusing more of my attention on my gens replacement at the moment. Speaking of that, I need a name for it...


    Fuzzbuzz
     
  11. Guess Who

    Guess Who

    It's a miracle! Oldbie
    4,296
    63
    28
    Oregon
    lol
    Your Genecyst replacement? How about... Mega Drive Dump, or MDump for short?
     
  12. fuzzbuzz

    fuzzbuzz

    Tech Member
    625
    0
    0
    Here
    Many Many Programming/hacking tools...
    Well, it has to keep Gens in it, so it'd be like

    for example, Gens: MDump. Maybe. Gotta think of more names before I make a decision.


    Fuzzbuzz
     
  13. Icy Guy

    Icy Guy

    Hedgehog. Sonic the Hedgehog. Member
    776
    0
    0
    California
    GoldenEye 007 level hack
    MDumpGens?
     
  14. Guess Who

    Guess Who

    It's a miracle! Oldbie
    4,296
    63
    28
    Oregon
    lol
    Gens Deluxe: MDump Edition! YAY :) !
     
Thread Status:
Not open for further replies.