Post Reply 
Converting Rom Art
09-16-2020, 11:16 AM
Post: #1
Converting Rom Art
Hi everyone,

I have rom Art and want to convert back for pioneer emu.
FILETOOLS I'm aware of but I can't find any direct information in what state theses image's are in, packed or not and so on.

Could some help me with further information relating rom Art ?
Link to conversion tool would good.

Thanks in advance.




[font=Tahoma][size=small]
Find all posts by this user
Quote this message in a reply
09-16-2020, 10:34 PM
Post: #2
RE: Converting Rom Art
Unsophisticated way I converted nardo rom art:
Opened .png file in MS Paint and saved picture as 256 color .bmp file.
Opened .bmp file in my TSE text editor as binary file.
Deleted the first 1078 bytes from the beginning of file.
Saved the edited file as a .rom file.

The 1078 bytes is 14+40+1024 .bmp header. See wikipedia article on bmp file format.

Ross
Find all posts by this user
Quote this message in a reply
09-16-2020, 10:52 PM (This post was last modified: 09-16-2020 10:53 PM by ijabbott.)
Post: #3
RE: Converting Rom Art
This might help. It uses libpng.

png2rom.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <png.h>

int main(int argc, char **argv)
{
    png_image image;
    png_bytep buffer;
    void *colormap;
    unsigned int imgsize;
    unsigned int rowstride;
    unsigned int numrows;
    unsigned int written;
    unsigned int row;
    FILE *fp;
    int rc;

    if (argc != 3) {
        fprintf(stderr, "usage: %s PNGFILEIN ROMFILEOUT\n", argv[0]);
        return 2;
    }

    /* Initialize the 'png_image' structure. */
    memset(&image, 0, sizeof image);
    image.version = PNG_IMAGE_VERSION;

    /* Begin to read the PNG file named by argv[1]. */
    if (png_image_begin_read_from_file(&image, argv[1]) == 0) {
        fprintf(stderr, "%s: error: %s\n", argv[1], image.message);
        return 1;
    }

    /* We expect to read color-mapped images. */
    image.format = PNG_FORMAT_RGB_COLORMAP;

    /* Image size is the ROM size. */
    rowstride = PNG_IMAGE_ROW_STRIDE(image);
    imgsize = PNG_IMAGE_BUFFER_SIZE(image, rowstride);
    numrows = image.height;

    /* Allocate memory to hold the image in this format. */
    buffer = malloc(imgsize);
    colormap = malloc(PNG_IMAGE_COLORMAP_SIZE(image));
    if (!buffer || !colormap) {
        fprintf(stderr, "Memory allocation error\n");
        free(buffer);
        free(colormap);
        png_image_free(&image);
        return 1;
    }

    if (png_image_finish_read(&image, NULL, buffer, 0, colormap) == 0) {
        fprintf(stderr, "%s: error: %s\n", argv[1], image.message);
        png_image_free(&image);
        free(buffer);
        free(colormap);
        return 1;
    }

    /* Write the ROM image named by argv[2]. */
    fp = fopen(argv[2], "wb");
    if (!fp) {
        perror(argv[2]);
        png_image_free(&image);
        free(buffer);
        free(colormap);
        return 1;
    }
    for (row = 0; row < numrows; row++) {
        png_bytep rowbuf = buffer + rowstride * (numrows - row - 1);

        written = fwrite(rowbuf, 1, rowstride, fp);
        if (written < rowstride) {
            break;
        }
    }

    if (row < numrows) {
        fprintf(stderr, "%s: Write error!\n", argv[2]);
    }
    rc = fclose(fp);
    if (rc == EOF) {
        perror(argv[2]);
    }
    png_image_free(&image);
    free(buffer);
    free(colormap);
    if (row < numrows || rc != 0) {
        return 1;
    }
    return 0;
}

— Ian Abbott
Find all posts by this user
Quote this message in a reply
09-17-2020, 03:26 AM
Post: #4
RE: Converting Rom Art
(09-16-2020 10:52 PM)ijabbott Wrote:  This might help. It uses libpng.

png2rom.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <png.h>

int main(int argc, char **argv)
{
    png_image image;
    png_bytep buffer;
    void *colormap;
    unsigned int imgsize;
    unsigned int rowstride;
    unsigned int numrows;
    unsigned int written;
    unsigned int row;
    FILE *fp;
    int rc;

    if (argc != 3) {
        fprintf(stderr, "usage: %s PNGFILEIN ROMFILEOUT\n", argv[0]);
        return 2;
    }

    /* Initialize the 'png_image' structure. */
    memset(&image, 0, sizeof image);
    image.version = PNG_IMAGE_VERSION;

    /* Begin to read the PNG file named by argv[1]. */
    if (png_image_begin_read_from_file(&image, argv[1]) == 0) {
        fprintf(stderr, "%s: error: %s\n", argv[1], image.message);
        return 1;
    }

    /* We expect to read color-mapped images. */
    image.format = PNG_FORMAT_RGB_COLORMAP;

    /* Image size is the ROM size. */
    rowstride = PNG_IMAGE_ROW_STRIDE(image);
    imgsize = PNG_IMAGE_BUFFER_SIZE(image, rowstride);
    numrows = image.height;

    /* Allocate memory to hold the image in this format. */
    buffer = malloc(imgsize);
    colormap = malloc(PNG_IMAGE_COLORMAP_SIZE(image));
    if (!buffer || !colormap) {
        fprintf(stderr, "Memory allocation error\n");
        free(buffer);
        free(colormap);
        png_image_free(&image);
        return 1;
    }

    if (png_image_finish_read(&image, NULL, buffer, 0, colormap) == 0) {
        fprintf(stderr, "%s: error: %s\n", argv[1], image.message);
        png_image_free(&image);
        free(buffer);
        free(colormap);
        return 1;
    }

    /* Write the ROM image named by argv[2]. */
    fp = fopen(argv[2], "wb");
    if (!fp) {
        perror(argv[2]);
        png_image_free(&image);
        free(buffer);
        free(colormap);
        return 1;
    }
    for (row = 0; row < numrows; row++) {
        png_bytep rowbuf = buffer + rowstride * (numrows - row - 1);

        written = fwrite(rowbuf, 1, rowstride, fp);
        if (written < rowstride) {
            break;
        }
    }

    if (row < numrows) {
        fprintf(stderr, "%s: Write error!\n", argv[2]);
    }
    rc = fclose(fp);
    if (rc == EOF) {
        perror(argv[2]);
    }
    png_image_free(&image);
    free(buffer);
    free(colormap);
    if (row < numrows || rc != 0) {
        return 1;
    }
    return 0;
}

I'm not familiar with programming is there an easy way to implement the script/code.
Thanks
Find all posts by this user
Quote this message in a reply
09-17-2020, 03:07 PM (This post was last modified: 09-18-2020 01:21 AM by Eric Rechlin.)
Post: #5
RE: Converting Rom Art
I'll be honest, I never could get it even close to working with the Paint approach. With Paint (at least on Windows 10), if you save it as an 8-bit BMP it changes the colors to match a more restricted palette and loses most of the data.

With Paint.NET it doesn't do that and keeps the image data just fine, but even after stripping the 1078 byte BMP header it still doesn't work. It's close though -- it seems to just have the color palette ordered differently so each pixel is pointing at a different index to the palette and therefore the 0-255 values are mixed up in a theoretically decodeable order (for example, it saves 07 instead of 41, 1A instead of 42, 05 instead of 43, 17 instead of 44, 25 instead of 45, 31 instead of 46, 1B instead of 47, 1D instead of 48, 2B instead of 49, and so on). So either there is something I am missing or we need to find the right graphics software that orders the colors in the palette in the same order as the original "artist" intended.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-17-2020, 04:36 PM
Post: #6
RE: Converting Rom Art
My original recipe from two years ago:

Download the .PNG, open it in GIMP, export as Windows BMP (without RLE, no colorspace info).
Open the BMP with an hex editor, delete the same amount of bytes from every BMP (do you really want to know how many? Let me know... I wouldn't spoil all the fun), save as .ROM.

Voilà!

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
09-17-2020, 06:10 PM
Post: #7
RE: Converting Rom Art
I don't remember which graphic software I used to create the bmp files, possibly Paint Shop Pro.
For the second step I simply used dd.
Find all posts by this user
Quote this message in a reply
09-17-2020, 06:18 PM
Post: #8
RE: Converting Rom Art
I used MS Paint in Win XP Home Edition SP1.

Ross
Find all posts by this user
Quote this message in a reply
09-17-2020, 07:50 PM
Post: #9
RE: Converting Rom Art
I have done it this way:

- load png into gimp
- flip vertically
- export as raw (*.data)
- rename *.data to *.rom
Find all posts by this user
Quote this message in a reply
09-18-2020, 01:20 AM
Post: #10
RE: Converting Rom Art
Looks like Windows 10 Paint is the culprit. I downloaded Windows XP Paint from archive.org and that worked perfectly.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-21-2020, 07:54 AM
Post: #11
RE: Converting Rom Art
(09-17-2020 07:50 PM)kwarda Wrote:  I have done it this way:

- load png into gimp
- flip vertically
- export as raw (*.data)
- rename *.data to *.rom

It was a long time ago, and I used gimp too but I seem to remember I had to flip the picture before exporting.
Find all posts by this user
Quote this message in a reply
09-21-2020, 04:51 PM
Post: #12
RE: Converting Rom Art
The original idea was doing the 1st step with the Internet Explorer 7 using the "Save Picture As.." dialog choosing the Bitmap (*.bmp) format.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-25-2020, 02:29 PM
Post: #13
RE: Converting Rom Art
For those member who are interested.

I was able decode Rom Art by using the old Microsoft Paint program.

1. Convert each image to a 256 color BMP.
2. Use a Hex Editor and delete the first 1077 bits.
3. Save the rom file.
4. Check by using Windows File Explorer properties for ROM size
5. Check using LEWISCRC.exe (2019)


The Lewiscrc program accepts packed or unpacked binary images of 10, 16, 64, 96 and 128 KB ROM size.
by Christoph Gießelink.

Theses are my findings.

1. You may need to pad out the final image to the correct Kbs for Lewiscrc.
2. To check size use File Explorer it need to report both same "size and disc size" if done correctly. (16, 64, 96, and 128 kb)
3. Strangely 10kb roms only need to report "size" on File Explorer to work with Lewiscrc.
4. I first used an older copy of Lewiscrc that didn't work with 10 kb rom files, I use 2019 I think this version is 1.1.

Below are roms I tested, the only one I had trouble with was last Hp28c.ck.rom but I believe it's correct.

PS C:\roms> ./lewiscrc hp10b.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
Bert ROM = 4187 -> Ok
Checksum ok!

PS C:\roms> ./lewiscrc hp20s.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
Bert ROM = F687 -> Ok
Checksum ok!

PS C:\roms> ./lewiscrc hp21s.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
Bert ROM = E9A9 -> Ok
Checksum ok!

PS C:\roms> ./lewiscrc hp14b.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
Sacajawea CRC Pass 0 = FFFF
Sacajawea CRC Pass 1 = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp32sii.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
Sacajawea CRC Pass 0 = FFFF
Sacajawea CRC Pass 1 = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp27s.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
1st Lewis CRC Pass 0 = FFFF
1st Lewis CRC Pass 1 = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp42s.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
1st Lewis CRC Pass 0 = FFFF
1st Lewis CRC Pass 1 = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp17b.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
1st Lewis CRC Pass 0 = FFFF
1st Lewis CRC Pass 1 = FFFF
External ROM CRC = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp17bii.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
1st Lewis CRC Pass 0 = FFFF
1st Lewis CRC Pass 1 = FFFF
External ROM CRC = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp19bii.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
1st Lewis CRC Pass 0 = FFFF
1st Lewis CRC Pass 1 = FFFF
2nd Lewis CRC Pass 0 = FFFF
2nd Lewis CRC Pass 1 = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp28s.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
1st Lewis CRC Pass 0 = FFFF
1st Lewis CRC Pass 1 = FFFF
2nd Lewis CRC Pass 0 = FFFF
2nd Lewis CRC Pass 1 = FFFF
CRC ok!

PS C:\roms> ./lewiscrc hp28c.ck.rom
BERT/SACAJAWEA/LEWIS ROM Test V1.10
Unpacking data...
1st Lewis CRC Pass 0 = 321A
1st Lewis CRC Pass 1 = 7F0B
2nd Lewis CRC Pass 0 = F526
2nd Lewis CRC Pass 1 = BA1E
CRC Error!
Find all posts by this user
Quote this message in a reply
09-25-2020, 08:24 PM
Post: #14
RE: Converting Rom Art
The HP28C ROM image is for Emu28 and has no CRC's inside. Use the CHAMPCHK.EXE program from the Emu28 package to verify the internal checksums please.

C:\HP28>CHAMPCHK.EXE HP28C.ROM
CHAMPION ROM Test V1.01
Unpacking data...
1st ROM 1st Part = 01 -> Ok
1st ROM 2nd Part = 01 -> Ok
2nd ROM 1st Part = 01 -> Ok
2nd ROM 2nd Part = 01 -> Ok
Checksums ok!
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2020, 12:56 AM
Post: #15
RE: Converting Rom Art
(09-25-2020 08:24 PM)Christoph Giesselink Wrote:  The HP28C ROM image is for Emu28 and has no CRC's inside. Use the CHAMPCHK.EXE program from the Emu28 package to verify the internal checksums please.

C:\HP28>CHAMPCHK.EXE HP28C.ROM
CHAMPION ROM Test V1.01
Unpacking data...
1st ROM 1st Part = 01 -> Ok
1st ROM 2nd Part = 01 -> Ok
2nd ROM 1st Part = 01 -> Ok
2nd ROM 2nd Part = 01 -> Ok
Checksums ok!

Hi Christoph,

Cool, I knew something wasn't quite right
thanks for that I'll give it a go.
Find all posts by this user
Quote this message in a reply
09-26-2020, 10:17 AM
Post: #16
RE: Converting Rom Art
(09-26-2020 12:56 AM)RPLman Wrote:  [quote='Christoph Giesselink' pid='136759' dateline='1601065454']
The HP28C ROM image is for Emu28 and has no CRC's inside. Use the CHAMPCHK.EXE program from the Emu28 package to verify the internal checksums please.

C:\HP28>CHAMPCHK.EXE HP28C.ROM
CHAMPION ROM Test V1.01
Unpacking data...
1st ROM 1st Part = 01 -> Ok
1st ROM 2nd Part = 01 -> Ok
2nd ROM 1st Part = 01 -> Ok
2nd ROM 2nd Part = 01 -> Ok
Checksums ok!

Try to test the above rom again but CHAMPION.exe complained about a wrong size error at 128 kb's ?? This time I created a new file and it worked this time.

PS C:\roms> ./champchk hp28c.ck.rom
CHAMPION ROM Test V1.01
Unpacking data...
1st ROM 1st Part = 01 -> Ok
1st ROM 2nd Part = 01 -> Ok
2nd ROM 1st Part = 01 -> Ok
2nd ROM 2nd Part = 01 -> Ok
Checksums ok!

Now I have a full set, and some fun at that, Cool.

Thanks Guys'
Find all posts by this user
Quote this message in a reply
10-24-2024, 09:32 PM
Post: #17
RE: Converting Rom Art
I had this on my 2do list for quite a while and postponed it multiple times. Out of curiosity, I fired up Visual Studio and pasted Ian's code from above. Some dependencies and a little debugging later I have a valid x64 Wintendo binary. This was compiled with no dependencies, so should run anywhere WinX64. It's called Exhibitionist because it exposes the beauty in those pictures for more than just the naked eye (enough Innuendo already).

Usage:
Exhibitionist.exe InputImage.png Output.ROM

Enjoy Everyone !


Attached File(s)
.zip  Exhibitionist.zip (Size: 78.29 KB / Downloads: 13)

Stay healthy and keep calculating,
Jan
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)