Jump to content
IGNORED

Crystal Castles Source Code


DanBoris

Recommended Posts

 

I recently ran across a bunch of Atari arcade source code that was added to the Historical Source Github site, including source for one of my favorite games, Crystal Castles.

 

https://github.com/historicalsource/crystal-castles

 

I thought it would be cool to be able to re-assemble this back into the original ROMs. I started by trying to find an existing assembler that could do this, but the assembler used for this source had a lot of syntactical differences and features I couldn't find in any other 6502 assembler. I assume Atari used a VAX based assembler and I did even find documentation for a VAX assembler with similar features, but still not an exact match. 

 

I then thought about manually modifying the source to work with an existing assembler. I quickly realized that this wasn't feasible due to some of the odd syntax in this assembler. For example the Atari assembler has an different syntax for addressing modes. You can write Zero Page X like this: "LDA ZX,$PSTSL", you couldn't fix this with a simple search and replace. This would also have to be done for every game I wanted to re-assemble. 

 

So I decided the best option was to build my own assembler that could handle these files with little changes to the original source. The assembler I build is now able to reassemble the main source from the historical source repository and reproduce the MAME ccastles1 ROM set. 

 

I have setup a GitHub repository to hold the C# source code for my assembler as well as tool to split the output into separate ROMs and handle the checksum process. There is also a folder there with the files and instructions needed to rebuild the source. There are some small changes needed to the source which I have documented in the instructions, and there was one file missing from the Historical Source archive which I re-created from the original ROMs. 

 

https://github.com/danlb2000/AT6502

Edited by DanBoris
  • Like 6
Link to comment
Share on other sites

While digging through the source code I noticed a reference to a game state called "flashy display". It looks like this is activated if you have a high enough score at the end of the game. It fills the display with random cubes. I am not sure exactly what the score is, I modified the code so it always showed up. I played this game a lot in the arcades and don't know if I ever saw this.

 

FlashState.thumb.jpg.d62c358dd4f89b680fb0fa19f95d8419.jpg

Edited by DanBoris
  • Like 5
Link to comment
Share on other sites

  • 4 months later...

I have been writing some blog posts about the Crystal Castles source code. First post is here:

 

https://dansdigitalarchaeology.blogspot.com/2022/03/crystal-castles-source-code.html

 

In this post: 

 

https://dansdigitalarchaeology.blogspot.com/2022/08/hll65fmac.html

 

I discuss the high level language macros that the code uses. This is a pretty cool macro library that lets you do run time nested if/then statements. 

 

I have figured out enough of the assembler to reproduce the binary ROMs, but there is some odd syntax in these macros that relate to the listing output. I wrote a post about this and would be interested if anyone has an ideas on this. 

 

https://dansdigitalarchaeology.blogspot.com/2022/08/hll65f-indenunden.html

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

  • 3 weeks later...
On 3/4/2022 at 6:18 PM, DanBoris said:

 

I recently ran across a bunch of Atari arcade source code that was added to the Historical Source Github site, including source for one of my favorite games, Crystal Castles.

 

https://github.com/historicalsource/crystal-castles

 

I thought it would be cool to be able to re-assemble this back into the original ROMs. I started by trying to find an existing assembler that could do this, but the assembler used for this source had a lot of syntactical differences and features I couldn't find in any other 6502 assembler. I assume Atari used a VAX based assembler and I did even find documentation for a VAX assembler with similar features, but still not an exact match. 

 

I then thought about manually modifying the source to work with an existing assembler. I quickly realized that this wasn't feasible due to some of the odd syntax in this assembler. For example the Atari assembler has an different syntax for addressing modes. You can write Zero Page X like this: "LDA ZX,$PSTSL", you couldn't fix this with a simple search and replace. This would also have to be done for every game I wanted to re-assemble. 

 

So I decided the best option was to build my own assembler that could handle these files with little changes to the original source. The assembler I build is now able to reassemble the main source from the historical source repository and reproduce the MAME ccastles1 ROM set. 

 

I have setup a GitHub repository to hold the C# source code for my assembler as well as tool to split the output into separate ROMs and handle the checksum process. There is also a folder there with the files and instructions needed to rebuild the source. There are some small changes needed to the source which I have documented in the instructions, and there was one file missing from the Historical Source archive which I re-created from the original ROMs. 

 

https://github.com/danlb2000/AT6502

You couldn't find an assembler so you wrote your own?!?!  Hardcore man....

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
On 8/11/2022 at 1:25 PM, DanBoris said:

I have been writing some blog posts about the Crystal Castles source code. First post is here:

 

https://dansdigitalarchaeology.blogspot.com/2022/03/crystal-castles-source-code.html

 

In this post: 

 

https://dansdigitalarchaeology.blogspot.com/2022/08/hll65fmac.html

 

I discuss the high level language macros that the code uses. This is a pretty cool macro library that lets you do run time nested if/then statements. 

 

I have figured out enough of the assembler to reproduce the binary ROMs, but there is some odd syntax in these macros that relate to the listing output. I wrote a post about this and would be interested if anyone has an ideas on this. 

 

https://dansdigitalarchaeology.blogspot.com/2022/08/hll65f-indenunden.html

 

Dan, Can the ROM you produced run in an emulator?
I'm looking through the Asteroids Deluxe code right now and to try to understand the sound Macros, and I'd like to test out some changes. 

  • Like 1
Link to comment
Share on other sites

On 9/9/2022 at 10:00 AM, fultonbot said:

Dan, Can the ROM you produced run in an emulator?
I'm looking through the Asteroids Deluxe code right now and to try to understand the sound Macros, and I'd like to test out some changes. 

Yes, I have built the tools necessary to re-create the ROMS that will run in an emulator. I haven't tried Asteroids Deluxe yet but I took a quick look at the source and it looks like it will work with this assembler.

Link to comment
Share on other sites

5 hours ago, DanBoris said:

Yes, I have built the tools necessary to re-create the ROMS that will run in an emulator. I haven't tried Asteroids Deluxe yet but I took a quick look at the source and it looks like it will work with this assembler.

From your example, do I just find all the code files and string them to together as a parameter to the assembler?  
Is there any order to it?

Link to comment
Share on other sites

39 minutes ago, fultonbot said:

From your example, do I just find all the code files and string them to together as a parameter to the assembler?  
Is there any order to it?

 

In Crystal Castles there was a single root source file that included all the others so you only need to point the assembler at one file. I downloaded the Asteroids Deluxe code and I think DSTRD0.MAC is the root file. I tried assembling from that file but there was a pseudo op that isn't implemented in my assembler. If I have some time I may dig into this and make the changes to the assembler to be able to assembler this code. 

  • Like 1
Link to comment
Share on other sites

19 hours ago, DanBoris said:

 

In Crystal Castles there was a single root source file that included all the others so you only need to point the assembler at one file. I downloaded the Asteroids Deluxe code and I think DSTRD0.MAC is the root file. I tried assembling from that file but there was a pseudo op that isn't implemented in my assembler. If I have some time I may dig into this and make the changes to the assembler to be able to assembler this code. 

Wow, cool, thanks!

Link to comment
Share on other sites

  • 2 months later...
  • 9 months later...
  • 5 months later...

Just hopping in here to say thank you so much for this.  I am currently porting Crystal Castles to the Playdate (https://twitter.com/dbokser91/status/1767699168749863145) and your assembler really helped me understand the source code. I even added a crude feature to it to generate da65 info files to generate a more familiar looking ca65 source file to help with readability.

 

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...