Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - How does SMSFIX know the correct length of a ROM? *nt*

Reply to topic
Author Message
Evan Clarke
  • Guest
Reply with quote
How does SMSFIX know the correct length of a ROM? *nt*
Post Posted: Tue Mar 28, 2000 1:29 am
I said *nt*
 
  • Site Admin
  • Joined: 25 Oct 1999
  • Posts: 2029
  • Location: Monterey, California
Reply with quote
Post Posted: Tue Mar 28, 2000 5:38 pm
I think either it checks for redundant copies of a the cart data within the file (a sega card incorrectly dumped as a 1 meg cart will simply be the same 32k of data repeated four times, a 1 meg cart dumped as a two meg cart will be the same 128k repeated twice), or maintains a small database of carts that are known to have been incorrectly dumped in the early dats of cart dumping (checking by CRC maybe), or both.
  View user's profile Send private message Visit poster's website
Eric
  • Guest
Reply with quote
Post Posted: Tue Mar 28, 2000 8:20 pm
The majority (I would say "ALL" but I can't confirm this) of SMS ROM's contain a header at addresses 0x7FF0 through 0x7FFF.

The first eight bytes of the header are "TMR SEGA". The next eight bytes contain the checksum, part number, and some other information. The part number is the point of interest here. For many SMS carts, the part number indicates the size of the ROM, as well as whether battery-backup RAM is present. I used the part number to determine the size of ROMS in my SMSARCH (cartridge copier) software, I suspect that this method (along with the others mentioned by Nyef) could be used by SMSFIX.

I will try to document this information and place it in the Technical Documents section of S8-Dev.

Eric Quinn
 
Eric
  • Guest
Reply with quote
Post Posted: Tue Mar 28, 2000 8:22 pm
Quote
> I suspect that this method (along with the others mentioned by Nyef) could be used by SMSFIX.

Oops, I don't know what I was thinking, I meant Heliophobe (not Nyef).

Eric Quinn
 
Evan Clarke
  • Guest
Reply with quote
Thanks *nt*
Post Posted: Wed Mar 29, 2000 8:44 am
Quote
> > I suspect that this method (along with the others mentioned by Nyef) could be used by SMSFIX.

> Oops, I don't know what I was thinking, I meant Heliophobe (not Nyef).

> Eric Quinn


Thanks.
 
Ricardo Bittencourt
  • Guest
Reply with quote
Post Posted: Wed Mar 29, 2000 12:50 pm
#include <stdio.h>
#include <malloc.h>
#include <io.h>

void fix (char *name, char *buffer, int size) {
  FILE *f;

  f=fopen (name,"wb");
  fwrite (buffer,1,size,f);
  fclose (f);
}

int main (int argc, char **argv) {
  FILE *f;
  int size,i=0,original;
  char *buffer;

  printf ("SMSFIX v1.0\n");
  printf ("Copyright (C) 1999 by Ricardo Bittencourt\n\n");

  if (argc<2) {
    printf ("Usage: SMSFIX game.sms\n");
    return 1;
  }

  f=fopen (argv[1],"rb");
  size=filelength (fileno (f));
  buffer=(char *) malloc (size);

  if (size&512)
    fread (buffer,512,1,f);

  original=size&=0xFFFFC000;
  fread (buffer,1,size,f);
  fclose (f);

  do {
    for (i=0; i<size/2; i++)
      if (buffer[i]!=buffer[i+size/2]) {
        printf ("[%s]    Original: %3dkb ",argv[1],original/1024);
        printf ("Real: %3dkb %c\n",size/1024,original!=size?'*':' ');
        if (original!=size)
          fix (argv[1],buffer,size);
        return 1;
      }
    size/=2;
  } while (1);
}
 
  • Site Admin
  • Joined: 25 Oct 1999
  • Posts: 2029
  • Location: Monterey, California
Reply with quote
(Read the message in the reply box to see the correct formatting)
Post Posted: Wed Mar 29, 2000 4:18 pm
Quote
> #include
> #include
> #include

> void fix (char *name, char *buffer, int size) {
> FILE *f;

> f=fopen (name,"wb");
> fwrite (buffer,1,size,f);
> fclose (f);
> }

> int main (int argc, char **argv) {
> FILE *f;
> int size,i=0,original;
> char *buffer;

> printf ("SMSFIX v1.0
");
> printf ("Copyright (C) 1999 by Ricardo Bittencourt

");

> if (argc<2) {
> printf ("Usage: SMSFIX game.sms
");
> return 1;
> }

> f=fopen (argv[1],"rb");
> size=filelength (fileno (f));
> buffer=(char *) malloc (size);

> if (size&512)
> fread (buffer,512,1,f);

> original=size&=0xFFFFC000;
> fread (buffer,1,size,f);
> fclose (f);

> do {
> for (i=0; i > if (buffer[i]!=buffer[i+size/2]) {
> printf ("[%s] Original: %3dkb ",argv[1],original/1024);
> printf ("Real: %3dkb %c
",size/1024,original!=size?'*':' ');
> if (original!=size)
> fix (argv[1],buffer,size);
> return 1;
> }
> size/=2;
> } while (1);
> }
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!