Sonic and Sega Retro Message Board: CRam Converter - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

CRam Converter A little converter, duh!

#1 User is offline fuzzbuzz 

Posted 29 December 2003 - 02:53 PM

  • Posts: 625
  • Joined: 13-November 03
  • Gender:Male
  • Location:Here
  • Project: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 User is offline fuzzbuzz 

Posted 29 December 2003 - 03:57 PM

  • Posts: 625
  • Joined: 13-November 03
  • Gender:Male
  • Location:Here
  • Project:Many Many Programming/hacking tools...
Code:

#include "iostream.h"
#include "fstream.h"
#include "stdlib.h"
#include <windows.h>

int main(int argc, char **argv)
{
	int sResult,I,j;
	char read[256], temp[1], write[(256 * 3) + 4];
	HANDLE fin;
	HANDLE fout;
	BY_HANDLE_FILE_INFORMATION File_Inf;
	int Size;
	unsigned long Bytes_Read, bw;

	if (argc != 3)
	{
  cout << "Usage:\n CRamConv.exe\tFilein\tFileout\n";
  return 0;
	}

	if ((fin = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
	{
  cout << "Cannot open input file.\n";
  return 0;
	}

	if ((fout = CreateFile(argv[2], GENERIC_WRITE, NULL, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
	{
  cout << "Output file already exists.\n";
  return 0;
	}


	//Get File Size
	if (GetFileInformationByHandle(fin, &File_Inf))
  Size = (File_Inf.nFileSizeHigh << 16) + File_Inf.nFileSizeLow + 65536;

	//Read bytes into buffer
	memset(read, 0, 256);
	memset(write, 0, (256 * 3) + 4);
	sResult = ReadFile(fin, read, (Size - 65536), &bw, NULL);

	write[0] = 'T';
	write[1] = 'P';
	write[2] = 'L';
	write[3] = 0x00;

	//Convert array to TPL Array
	for (I=4, j=0; I < sizeof(write); I+=3, j+=2) {
  //Blue
  temp[1] = read[j];
  write[I+2] = temp[1] << 4;
  //Green
  temp[1] = read[j+1];
  write[I+1] = (temp[1] >> 4) << 4;
  //Red
  temp[1] = read[j+1];
  write[I] = temp[1] << 4;
	}

	sResult = WriteFile(fout, write, sizeof(write), &Bytes_Read, NULL);

	cout << "Conversion Successfully Completed" << endl;

	CloseHandle(fin);
	CloseHandle(fout);

	return 0;
}



Fuzzbuzz

#3 User is offline Rika Chou 

Posted 29 December 2003 - 04:56 PM

  • Adopt
  • Posts: 5093
  • Joined: 11-January 03
  • Gender:Not Telling
  • Location:CA US
  • Wiki edits:4
Hivebrain already wrote a program that takes TLP pallets out of screen shots.

#4 User is offline fuzzbuzz 

Posted 29 December 2003 - 06:34 PM

  • Posts: 625
  • Joined: 13-November 03
  • Gender:Male
  • Location:Here
  • Project:Many Many Programming/hacking tools...
I know, but this converts palettes ripped straight from the rom, like palettes not used and stuff.


Fuzzbuzz

#5 User is offline Rika Chou 

Posted 29 December 2003 - 06:37 PM

  • Adopt
  • Posts: 5093
  • Joined: 11-January 03
  • Gender:Not Telling
  • Location:CA US
  • Wiki edits:4

fuzzbuzz, on Dec 29 2003, 09:34 PM, said:

I know, but this converts palettes ripped straight from the rom, like palettes not used and stuff.


Fuzzbuzz

So does his tool, the screen shots made with Genecyst contain the exact pallet data.

#6 User is offline fuzzbuzz 

Posted 29 December 2003 - 06:42 PM

  • Posts: 625
  • Joined: 13-November 03
  • Gender:Male
  • Location:Here
  • Project: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
This post has been edited by fuzzbuzz: 29 December 2003 - 06:46 PM

#7 User is offline Hivebrain 

Posted 29 December 2003 - 10:10 PM

  • Posts: 2508
  • Joined: 15-January 03
  • Gender:Male
  • Location:53.4N, 1.5W
  • Project:HivePal 2.0
  • Wiki edits:6,176

fuzzbuzz, on Dec 29 2003, 11:42 PM, said:

Oh, well here you don't have to make a screenshot, and if you can't run Genecyst...=P

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 User is offline Rika Chou 

Posted 29 December 2003 - 10:36 PM

  • Adopt
  • Posts: 5093
  • Joined: 11-January 03
  • Gender:Not Telling
  • Location:CA US
  • Wiki edits:4
Another tool that would be useful is something searches the ROM for a particular pallet line.

#9 User is offline Quickman 

Posted 29 December 2003 - 10:50 PM

  • Posts: 5584
  • Joined: 03-December 03
  • Gender:Male
  • Location::x
  • Project:omg porjcet
  • Wiki edits:10
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 User is offline fuzzbuzz 

Posted 30 December 2003 - 12:24 AM

  • Posts: 625
  • Joined: 13-November 03
  • Gender:Male
  • Location:Here
  • Project: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 User is offline Guess Who 

Posted 31 December 2003 - 04:28 PM

  • It's a miracle!
  • Posts: 4257
  • Joined: 22-December 03
  • Gender:Male
  • Location:New Mexico
  • Project:lol
  • Wiki edits:2
Your Genecyst replacement? How about... Mega Drive Dump, or MDump for short?

#12 User is offline fuzzbuzz 

Posted 31 December 2003 - 04:34 PM

  • Posts: 625
  • Joined: 13-November 03
  • Gender:Male
  • Location:Here
  • Project: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 User is offline Icy Guy 

Posted 31 December 2003 - 04:51 PM

  • Hedgehog. Sonic the Hedgehog.
  • Posts: 777
  • Joined: 23-November 03
  • Gender:Male
  • Location:California
  • Project:GoldenEye 007 level hack
  • Wiki edits:2
MDumpGens?

#14 User is offline Guess Who 

Posted 31 December 2003 - 09:22 PM

  • It's a miracle!
  • Posts: 4257
  • Joined: 22-December 03
  • Gender:Male
  • Location:New Mexico
  • Project:lol
  • Wiki edits:2
Gens Deluxe: MDump Edition! YAY :) !

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users