Page 1 of 1

Stopping by to say Hi

PostPosted: 08 Mar 2016, 12:58
by wietze
I recently found your website from the atari-forum post that you made regarding Captain Blood.

Im especially interested in the possibilities of using results of the reverse engineering actions you did to port games to the Atari ST; so it tickled my interest to wonder what is next on your todolist.

Re: Stopping by to say Hi

PostPosted: 09 Mar 2016, 00:00
by Kroah
Welcome wietze,

I remember seeing you on the CosmosEx sub-forum on Atari-Forum.

May i ask you what you mean by "to port games to the Atari ST" ? Most of my reverse engineering works are done from Atari ST games using the Steem debugger and IDA. How can this help you to port games to the Atari ST ?
I must be missing something sorry.

I have so many thing i would like to do... short term goals are putting online my works on Little Computer People and a Legend of Faerghail dungeon viewer. Then Dragonriders of Pern, Sundog, Rescue on Fractalus, Legend (from Mindscape), La Hanse and anything (running on Atari ST) that gives me enough motivation to disassemble. But i know i won't have enough time to do everything.

Do you have something in mind ?

Re: Stopping by to say Hi

PostPosted: 09 Mar 2016, 00:18
by wietze
Thank you for the welcome!

I may have misunderstood your efforts, it seemed to me that you also disassembled some Amiga games. Following this (perhaps wrong) assumption, I had a glimpse of hope that Eye of the Beholder could be moved towards the ST :). As a big fan of the dungeon crawler genre it seemed like a missed opportunity that this was never released on the st.

I have very little experience using IDA myself, but I must also say that I havent spend a big effort to get into it yet. Currently I am still putting my efforts on coding for this years demos, but I can pretty much plan ahead and schedule porting efforts towards 2017 :).

Re: Stopping by to say Hi

PostPosted: 06 Jan 2017, 07:21
by witchspace
Came here to say hi and great work on the Captain Blood reverse engineering.

Kroah wrote:Sundog

That'd be awesome!

I spent some time reverse-engineering that game in the 90's, but got stuck as it was based on some kind of interpreter, which I couldn't find details on. In retrospect I discovered they did a custom port of the UCSD p-system interpreter to Atari ST to port their game. Wow.

Recently I've been looking at it a bit again, thinking about giving it a new try with new tools and experience. Also some UCSD p-system source has been released which may be helpful in figuring out the interpreter. Unfortunately I lost my notes from back then, though.

Re: Stopping by to say Hi

PostPosted: 10 Jan 2017, 13:28
by witchspace
Okay I made quite some progress on reverse-engineering SunDog, some the help of the Softech UCSD manuals and p-system implementations for other museumpieces. I've disassembled and cross-referenced all of the VM code, figured out some of the GEMBIND (graphics) routines, and how the game logic works. Did not look deeply at the space rendering (SHIPLIB) yet, which also includes custom m68k assembly code.
It's quite elegant. The VM reminds me of a Java interpreter that is not crufty and with super-special PASCAL features :-)

The p-code system in SunDog is version "IV.2.1 R3.4" which is newer than any of the open source tools (http://ucsd-psystem-xc.sourceforge.net/, http://ucsd-psystem-vm.sourceforge.net/) support (which are based on version II). Most notably the opcodes all changed numbers and there are quite a few new ones.

Anyhow if anyone is interested let me know and I'll share my info.

Re: Stopping by to say Hi

PostPosted: 21 Jan 2017, 11:17
by witchspace
SunDog's color image compression routine (GEMBIND procedure 7) is also quite interesting. Haven't quite got it nailed down yet.
It looks like a RLE compression with a few stock patterns added for common cases, as well as able to refer to the previous line.

Edit: okay that was much simpler then I thought. It just looked complicated because it generates the image directly into ST planar format, whereas the colors are represented as 4 bit palette indices. Eventually ended up with this

Code: Select all
/* Flip 4 bits to the opposite bit order */
static inline unsigned flip4(unsigned x)
{
    return (((x >> 3) & 1) << 0) | (((x >> 2) & 1) << 1) | (((x >> 1) & 1) << 2) | (((x >> 0) & 1) << 3);
}

/* Decompress color image from src in compressed format to dest in
 * one-byte-per-pixel format. Needs width*height bytes space
 * at dest.
 */
void gembind_decompress_image(uint8_t *dest, uint8_t *src, unsigned width, unsigned height)
{
    unsigned sptr = 0, dptr = 0;
    unsigned end = width * height;
    unsigned i, count, pixel;
    while (dptr < end) {
        uint8_t in1 = src[sptr++];
        if (in1 & 0x80) { /* Count follows */
            count = src[sptr++];
            if (in1 & 0x40) { /* Two-byte BE count */
                count = (count << 8) | src[sptr++];
            }
            count += 1;
            if (in1 & 0x10) {
                if (in1 & 0x20) { /* Pixels from previous line */
                    for (i = 0; i < count; ++i) {
                        dest[dptr] = dest[dptr - width];
                        dptr += 1;
                    }
                    dest[dptr++] = flip4(in1 & 15);
                } else { /* H4L4 encoded pixels */
                    if (count & 1) {
                        dest[dptr++] = flip4(in1 & 15);
                    }
                    count >>= 1;
                    for (i = 0; i < count; ++i) {
                        uint8_t hl   = src[sptr++];
                        dest[dptr++] = flip4(hl >> 4);
                        dest[dptr++] = flip4(hl & 15);
                    }
                }
            } else { /* RLE */
                pixel = flip4(in1 & 15);
                for (i = 0; i < count; ++i) {
                    dest[dptr++] = pixel;
                }
            }
        } else { /* RLE 0xxxyyyy */
            count = (in1 >> 4) + 1;
            pixel = flip4(in1 & 15);
            for (i = 0; i < count; ++i) {
                dest[dptr++] = pixel;
            }
        }
    }
    if (dptr != end) {
        psys_panic("gembind_decompress_image: overshot ending by %d pixels\n", (int)(dptr - end));
    }
}

Re: Stopping by to say Hi

PostPosted: 19 Apr 2017, 01:29
by Kroah
Hello witchspace,

Sorry for the late reply.

I'm not working anymore on Sundog (until i start again :wink:), because of the Pascal Interpreter.
I've coded my own Atari Pascal IV Decompiler in C# using various sources (manuals, Pascal Compiler, etc.), it works pretty well and generates pseudo-C code (but still WIP).

Unfortunately, not being able to annotate the decompiled code (variables, functions, etc.) like in IDA is really a shore.

Here is my work in progress of the Pascal decompiler: Pascal Decompiler IV for Sundog - WIP 1.00.7z
It's badly written and without any comments, but may help if anyone is interested.

Re: Stopping by to say Hi

PostPosted: 14 Nov 2017, 21:39
by war_doc
Greetings and thank you for all the old memories. Do you have instructions how to deconstruct an Atari ST game? I'm still wanting Roadwar 2000 since I always enjoyed the game for its simplicity but also its use of tactics.

Thank you,

Kevin