>>>>> "RajW" == RajW <r
...@intelc64.net> writes:
RajW> Yuck! My brain is to tired right now to "fix/normalize" the raw
RajW> cartridge dump.
It's not that hard. Feel free to adapt the following C program I
wrote for shuffling the address and data lines of a 512kB Flash
cartridge for the VIC-20. The program reads the shuffled image from
stdin and outputs the unshuffled one on stdout. It probably doesn't
work on Microsoft operating systems, because they make an artificial
distinction between binary and text files, and interpret the CR and LF
characters on stdin and stdout as "text" by default.
BTW, in the 4 MB version of the cartridge, I only swapped A0 and A1,
because the chip has much nicer pinout (all address and data lines
nicely sorted in numerical order).
Marko
#include <stdio.h>
/** Move a bit to another position
* @param i the number being shuffled
* @param from original bit position
* @param to translated bit position
* @return the bit in the translated position
*/
#define MVBIT(i,from,to) (((i) & 1 << (from)) ? 1 << (to) : 0)
/** precomputed table for shuffling the data bus */
static unsigned char databus[256];
static unsigned char image[1 << 19];
int
main (int argc, char** argv)
{
unsigned i;
for (i = 256; i--; )
databus[i] =
MVBIT (i, 0, 5) |
MVBIT (i, 1, 6) |
MVBIT (i, 2, 7) |
MVBIT (i, 3, 4) |
MVBIT (i, 4, 3) |
MVBIT (i, 5, 2) |
MVBIT (i, 6, 0) |
MVBIT (i, 7, 1);
for (i = 0; i < sizeof image; i++) {
int c = getchar ();
if (c == EOF)
break;
else
image[MVBIT (i, 0, 17) |
MVBIT (i, 1, 18) |
MVBIT (i, 2, 16) |
MVBIT (i, 3, 15) |
MVBIT (i, 4, 12) |
MVBIT (i, 5, 7) |
MVBIT (i, 6, 6) |
MVBIT (i, 7, 5) |
MVBIT (i, 8, 4) |
MVBIT (i, 9, 3) |
MVBIT (i, 10, 2) |
MVBIT (i, 11, 1) |
MVBIT (i, 12, 0) |
MVBIT (i, 13, 13) |
MVBIT (i, 14, 14) |
MVBIT (i, 15, 11) |
MVBIT (i, 16, 8) |
MVBIT (i, 17, 9) |
MVBIT (i, 18, 10)] =
databus[(unsigned char) c];
}
return fwrite (image, 1, sizeof image, stdout);
}