Page 1 of 1

Compiling Stone Raider II

Posted: Tue Sep 29, 2015 9:49 pm
by kan
Hi there,
Most of you know that Rolf put the source code of his game, Stone Raider II, available to everyone in Github: https://github.com/rolfmichelsen/StoneRaiderII
The source code was written to be compiled using the software AllDream in Dragon 32. But, I've updated it in order to be compiled using "lwtools". Meanwhile Rolf approves the pull request, I attach the new source code if you want to try.
The good news is that I could find a way to compile and execute in a PC-environment, so I hope I could be useful to others. The steps are:
1) Compiling the source code using "lwasm":
lwasm -9 -b -o STONRAID.bin -d stonraid.asm

2) Using the script "bin2cas.pl", we can build a CASSETTE based on a binary:
perl -T bin2cas.pl -o stonraid.cas -e 0x2657 -l 0x2400 -n STONRAID --autorun -C STONRAID.bin

The value of 0x2400 is the same address that we set in the source code under "ORG" (line 9 of stonraid.asm), so it means the address where the program should be dumped. The value of 0x2657 is the address to be started after the cassette is loaded by the Dragon. As we executed "lwasm" in debug mode, we can find the line that looks like:
DEBUG 050 (1441383186): Register symbol @START: 0x2657

@START is the tag in our source code (line 158 of stonraid.asm) that set where our program starts its execution.

This is a little tedius, but the values are always the same if we compile it again. So, one we got it, we can reuse it directly.

3) Using XRoar, only load the file stonraid.cas and execute "CLOADM"

Don't hesitate to ask me any question if you've had any problem.

Re: Compiling Stone Raider II

Posted: Wed Sep 30, 2015 4:29 pm
by tormod
Welcome to the forum, Kan! Cool stuff. Thanks also to Rolf for sharing this in the first place! I have a couple of suggestions:

1. bin2cas.pl can read the load and exec address directly from the DECB binary, so you don't have to enter them on the command line. But for lwasm to embed the exec address you need the give the exec address (or label) as the optional argument to the "end" directive. That is, the last line in your .asm file should have:

Code: Select all

      end START
You must change the @START label to START in the code, because lwasm considers labels starting with @ as a local label.

2. Instead of rewriting /string/,0 to two lines of /string/ and FCB 0, I'd suggest you ask William to add this syntax to lwasm, so that fewer changes have to be made to this and other code. Although lwasm has its own FCN directive, it is nice to have a compact syntax that works in both lwasm and other assemblers.

Tormod

Re: Compiling Stone Raider II

Posted: Wed Sep 30, 2015 8:41 pm
by rolfmichelsen
Very cool to see you take the Stone Raider II code into the modern age, Kan. I have seen your merge request to the repository, but I'll let you consider Tormod's suggestions before doing the actual merge.

-- Rolf

Re: Compiling Stone Raider II

Posted: Wed Sep 30, 2015 11:15 pm
by tormod
It actually looks like William recently added this to the development version: http://lwtools.projects.l-w.ca/hg/index ... f4aaa2a4e8
m80ext
This pragma (along with pragma qrts) enables some uncommon behaviors to accomodate The
Micro Works MACRO-80c assembler from 1982. This assembler was used by a number of notable
TRS-80 Color Computer applications and the goal of this pragma is to allow them to build identical
binaries from unmodified, vintage source code.
In m80ext mode, the handling of the "END" pseudo-op changes when used inside an include file.
Instead of terminating all assembly, it merely stops processing of the current include file (this
behavior matches the original Motorola 6809 assembler). In addition, loading an ASCII value with
a single quote (e.g., LDA #’N) is extended to 16-bit registers (e.g., LDD #’NO). LWASM normally
supports this via double quote and that is the proper use in modern code. Finally, the FCC
pseudo-op is extended to handle FCB-like behavior after the closing delimiter:
FCC "Greetings from 1982",13,0

Re: Compiling Stone Raider II

Posted: Thu Oct 01, 2015 1:12 pm
by kan
tormod wrote:Welcome to the forum, Kan! Cool stuff. Thanks also to Rolf for sharing this in the first place! I have a couple of suggestions:

1. bin2cas.pl can read the load and exec address directly from the DECB binary, so you don't have to enter them on the command line. But for lwasm to embed the exec address you need the give the exec address (or label) as the optional argument to the "end" directive. That is, the last line in your .asm file should have:

Code: Select all

      end START
You must change the @START label to START in the code, because lwasm considers labels starting with @ as a local label.

2. Instead of rewriting /string/,0 to two lines of /string/ and FCB 0, I'd suggest you ask William to add this syntax to lwasm, so that fewer changes have to be made to this and other code. Although lwasm has its own FCN directive, it is nice to have a compact syntax that works in both lwasm and other assemblers.

Tormod
I used the last devel version of lwtools and you're right, I can use /string/,0 (although it's not possible 0,/string/). So, I applied those both suggestions (thanks btw!) and the result is simpler and less different than the original source code: https://github.com/rolfmichelsen/StoneR ... ll/1/files

I attach the new version, and the updated instructions for compiling are:

Code: Select all

 lwasm -9 -b --pragma=m80ext -o stonraid.bin stonraid.asm
 bin2cas.pl -o stonraid.cas -n STONRAID --autorun -C stonraid.bin

Re: Compiling Stone Raider II

Posted: Fri Oct 16, 2015 10:47 pm
by rolfmichelsen
I have merged Kan's changes into the Stone Raider II git repo. Thanks for the contribution.

-- Rolf

Re: Compiling Stone Raider II

Posted: Mon Oct 19, 2015 12:33 pm
by kan
Thanks to you for uploading your source code to Github. It's a pity there aren't lots of source code of games published openly