HP Forums
Converting Rom Art - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Converting Rom Art (/thread-15593.html)



Converting Rom Art - RPLman - 09-16-2020 11:16 AM

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]


RE: Converting Rom Art - Ross Barnes - 09-16-2020 10:34 PM

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


RE: Converting Rom Art - ijabbott - 09-16-2020 10:52 PM

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;
}



RE: Converting Rom Art - RPLman - 09-17-2020 03:26 AM

(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


RE: Converting Rom Art - Eric Rechlin - 09-17-2020 03:07 PM

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.


RE: Converting Rom Art - Massimo Gnerucci - 09-17-2020 04:36 PM

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à!



RE: Converting Rom Art - Didier Lachieze - 09-17-2020 06:10 PM

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.


RE: Converting Rom Art - Ross Barnes - 09-17-2020 06:18 PM

I used MS Paint in Win XP Home Edition SP1.

Ross


RE: Converting Rom Art - kwarda - 09-17-2020 07:50 PM

I have done it this way:

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


RE: Converting Rom Art - Eric Rechlin - 09-18-2020 01:20 AM

Looks like Windows 10 Paint is the culprit. I downloaded Windows XP Paint from archive.org and that worked perfectly.


RE: Converting Rom Art - aamiel - 09-21-2020 07:54 AM

(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.


RE: Converting Rom Art - Christoph Giesselink - 09-21-2020 04:51 PM

The original idea was doing the 1st step with the Internet Explorer 7 using the "Save Picture As.." dialog choosing the Bitmap (*.bmp) format.


RE: Converting Rom Art - RPLman - 09-25-2020 02:29 PM

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!


RE: Converting Rom Art - Christoph Giesselink - 09-25-2020 08:24 PM

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!


RE: Converting Rom Art - RPLman - 09-26-2020 12:56 AM

(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.


RE: Converting Rom Art - RPLman - 09-26-2020 10:17 AM

(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'


RE: Converting Rom Art - JanS - 10-24-2024 09:32 PM

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 !