home page http://www.playoffline.com/others/junk/index.html
http://www.playoffline.com/others/junk/index.html to get a compiled#include <stdio.h>
#include <string.h>
#define FILENAME "fcemu.rom"
static char *gtFileName[] =
{
"donkey",
"donkeyjr",
"popeye",
};
static unsigned short gtDonkey[] =
{
#include "donkey.h"
};
static unsigned short gtDonkeyJr[] =
{
#include "donkeyjr.h"
};
static unsigned short gtPopeye[] =
{
#include "popeye.h"
};
static unsigned short *gtPatch[sizeof gtFileName / sizeof *gtFileName] =
{
gtDonkey,
gtDonkeyJr,
gtPopeye,
};
static int gtSize[sizeof gtFileName / sizeof *gtFileName] =
{
sizeof gtDonkey / sizeof *gtDonkey,
sizeof gtDonkeyJr / sizeof *gtDonkeyJr,
sizeof gtPopeye / sizeof *gtPopeye,
};
void main(int argc, char *argv[])
{
printf("FC-Emulator for SuperFamicom\n");
unsigned char buf[0x200 + 0x8000];
memset(buf, 0, sizeof buf);
//header
buf[0] = 0x04;
buf[8] = 0xaa;
buf[9] = 0xbb;
buf[10] = 0x04;
FILE *fp = fopen(FILENAME, "rb");
if (fp == NULL)
{
printf("error: can't open " FILENAME "\n");
return;
}
fread(&buf[0x200], 1, 0x800, fp);
fclose(fp);
for (int n = 0; n < (sizeof gtFileName / sizeof *gtFileName); n++)
{
char tmp[256];
sprintf(tmp, "%s.nes", gtFileName[n]);
fp = fopen(tmp, "rb");
if (fp == NULL)
{
printf("error: can't open %s\n", tmp);
continue;
}
unsigned char header[16];
fread(header, 1, sizeof header, fp);
if (header[0] != 'N'
|| header[1] != 'E'
|| header[2] != 'S'
|| header[4] != 1
|| header[5] != 1)
{
printf("error: not supported mapper %s\n", tmp);
fclose(fp);
continue;
}
fread(&buf[0x200 + 0x4000], 1, 0x4000, fp);
fread(&buf[0x200 + 0x2000], 1, 0x2000, fp);
fclose(fp);
//reset
buf[0x200 + 0x0297] = buf[0x200 + 0x7ffc];
buf[0x200 + 0x0298] = buf[0x200 + 0x7ffd];
//nmi
buf[0x200 + 0x02be] = buf[0x200 + 0x7ffa];
buf[0x200 + 0x02bf] = buf[0x200 + 0x7ffb];
//patch
for (int p = 0; p < gtSize[n] / 2; p++)
{
buf[0x200 + 0x4000 + gtPatch[n][p * 2 + 0]] = (unsigned char)gtPatch[n][p * 2 + 1];
}
sprintf(tmp, "%s.smc", gtFileName[n]);
fp = fopen(tmp, "wb");
if (fp == NULL)
{
printf("error: can't open %s\n", tmp);
continue;
}
fwrite(buf, 1, sizeof buf, fp);
fclose(fp);
}
}
version ......with some rewiting of the code it could convert all most any nes rom to work on a snes emulator go try it works
this is very neat code to change nes roms into snes roms with this code and a few bits of thinking you could do some think good with it
any ways just thought it was kool