Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
  You are not logged in - nap
Alter Ego   [2023]

Alter Ego Released by :
Grue

Release Date :
6 April 2023

Type :
IDE64 Release

AKA :
Male and Female versions

User rating:**********  9.8/10 (10 votes)   See votestatistics

Credits :
Code .... Grue of Beyond Force, Extend, Kasettilamerit
  TNT of Beyond Force, Kasettilamerit
Graphics .... Grue of Beyond Force, Extend, Kasettilamerit
Crack .... Grue of Beyond Force, Extend, Kasettilamerit
Original Supply .... John York of Yleisradio
Loader .... Grue of Beyond Force, Extend, Kasettilamerit
Test .... Trurl of Extend
Help .... TNT of Beyond Force, Kasettilamerit

Download :

Look for downloads on external sites:
 Pokefinder.org


Summary
Submitted by Grue on 6 April 2023
Alter Ego Male / Female For IDE64 fix by Grue

When I first got my IDE64, one of the first games I would have wanted to play from it was Alter Ego. But it didn't work, and there was no fix for it either. Many other multi-floppy games had been ported already, but no one had provided this title.

So after finishing several of my unfinished projects, I finally started to look into the code for Alter Ego Female version. I chose the female version, because back in the 80s I didn't have it, so why not take a peek now? The Male and Female versions ought to be the same anyway?

The first part of the quest was to find the floppy routines to understand how the game accessed those .rel files, as it seemed to use a custom loader instead of the kernal routines. Straight away I stumbled into some not-so-hacker-friendly code involving encryption. Too bad that those are not even a challenge when you have an emulator and breakpoints, so getting readable code was quite simple.
Next was the 1541 code. I spent quite some time reverse-engineering the code and figuring out how it worked. The drive gets the seek command from the c64, loads some tables and finds the wanted sector from the floppy. A pointer to the next sector is included in the accessed sector, so it keeps reading until everything has been read.
I also realized that I don't have a clue what a .rel file is, and how it's accessed. After some investigation, it's just a bunch of regular looking sectors with only $fd bytes of actual data in them.
I extracted those .rel files and combined them into an ide64 compatible format. All I had to do was just remove the header in front of each file and make notes about the index the next .rel file starts at, so I could write some loader code to jump into the correct index when side2 is needed and so on.

Alter Ego has its data spread across 6 floppy sides, and when I had combined all of the data, I had a whopping 823kbytes of female and 844k of male data.

The game asks for data via certain indexes which turned out to be the address for the data. The problem was that the loader asked for data from $01de00. There are only 16 bits of meaningful data. $1de is the number of sectors (sector $100 bytes), and if we lose 2 bytes/sector, that has to be subtracted from the original address somehow. So, in short, the index is $01de00 - 2*1de = 01da44
The index starts at zero when the floppy side is changed, so I needed my earlier notes to create a table of the addresses where the floppy side data is located. We need to add the disk side base address to our freshly calculated address to calculate the correct index. So, to get the actual address, let's say we are on floppy side 3, which starts at $044a5a. We need to add the earlier index to that, which was $01da44 = $06249e

A bit complicated, but there was enough room for the code after removing the original serial transfer routines.

After reverse engineering the game code, I was able to patch it to be mostly ide64 compatible. The game was playable from the beginning to the end. But one little thing was still missing, and that was save and restore functionality. Loading earlier saves proved to be quite simple to get working, but saving turned out to be a hell of a nightmare.

After examining the code for Alter Ego, it was quite apparent that it is compiled code and all the game logic is inside compiled bytecode which is a real pain in the butt to decipher. The only option was to go forward, and try to understand how the save process works. I was able to understand some of the bytecode structure by staring at it long enough. After voicing out my pain in our IRC channel, TNT had silently reverse-engineered the bytecode interpreter and provided me a script for the 010 editor which I could use to decipher the bytecode from hex strings into a half-readable format.

The problem with the save process was, that after scratching the old file, it checked if the drive returned error code 01, fair enough, but I had needed to patch these status messages earlier to always return 00 = OK. I was trying to find a condition in the bytecode where the 01 status was checked. Still, while I was on my quest to find the holy check, TNT found another way around this by supplying me with a patch that changed the byte code in a way that it forces the status to always be 01 after sending a scratch file command to the drive.

That took me several days, a puny file save feature. I was originally going to completely rewrite the save code, but Trurl pointed out that keeping the original save file format is important if you want to transfer your old saves from floppies. Fair enough, I think accomplishing this was worth all the pain.

The last finishing touch was to make the Quit option of the game return to ide basic since I have always hated it when I needed to perform an extra reset.

I wanted to include the original Activision intro in this release as I think it is very cool. Only one little detail was needed. I want to tag my releases somehow, so...

What a painful process. I learned that interpreted bytecode is a bitch to follow in an emulator...

But enjoy playing Alter Ego. I do now when I can use my ide64 and forget those floppies! <3

Traditional tools list:

010 editor - this has become a very important tool

ghidra
6502bench
64tass
vscode editor
irccloud
retrodebugger
vice
Search CSDb
Advanced
Navigate
Prev - Random - Next
Detailed Info
· Summaries (1)
· User Comments
· Production Notes
Fun Stuff
· Goofs
· Hidden Parts
· Trivia
Forum
· Discuss this release
Support CSDb
Help keep CSDb running:



Funding status:




About this site:
CSDb (Commodore 64 Scene Database) is a website which goal is to gather as much information and material about the scene around the commodore 64 computer - the worlds most popular home computer throughout time. Here you can find almost anything which was ever made for the commodore 64, and more is being added every day. As this website is scene related, you can mostly find demos, music and graphics made by the people who made the scene (the sceners), but you can also find a lot of the old classic games here. Try out the search box in the top right corner, or check out the CSDb main page for the latest additions.
Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.093 sec.