I don't know if it helps you, but here it is, a program to swap pins in a ROM image file (you can only swap address pins with address pins and data pins with data pins, and only 8-bit data is supported, and you must use a raw ROM image without a header):
Code:
/* pinswap - public domain */
#ifdef _WIN32
#include <fcntl.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned short address;
typedef unsigned char byte;
static int bits;
static address addrconv[65536];
static byte bitconv[256];
static byte*rom;
static unsigned int romsize;
static int make_bitconv(char*n) {
unsigned int i,j,k,x;
int b[16];
for(k=x=0;k<16 && *n;n++) {
if(*n=='-') {
x|=1<<k;
} else if(*n>='0' && *n<='9') {
b[k++]=*n&15;
} else if(*n>='A' && *n<='Z') {
b[k++]=*n+10-'A';
} else if(*n>='a' && *n<='z') {
b[k++]=*n+10-'a';
}
}
for(i=1<<k;i--;) {
addrconv[i]=x;
for(j=0;j<k;j++) if(i&(1<<j)) addrconv[i]^=1<<b[j];
}
return k;
}
int main(int argc,char**argv) {
unsigned int i;
#ifdef _WIN32
_setmode(_fileno(stdin),_O_BINARY);
_setmode(_fileno(stdout),_O_BINARY);
#endif
if(argc<3) return 1;
bits=strlen(argv[2]);
make_bitconv(argv[1]);
for(i=0;i<256;i++) bitconv[i]=addrconv[i];
bits=make_bitconv(argv[2]);
rom=malloc(romsize=1<<bits);
while(!feof(stdin)) {
if(!fread(rom,1,romsize,stdin)) return 0;
for(i=0;i<romsize;i++) putchar(bitconv[rom[addrconv[i]]]);
fflush(stdout);
}
return 0;
}