Anyone interested in converting AGD to the Dragon/CoCo?

A place to discuss everything Dragon related that doesn't fall into the other categories.
oss003
Posts: 25
Joined: Sat Jun 23, 2018 12:01 pm

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by oss003 »

Hi Pere,

just had a look at your Hobbit conversion, pretty impressive ....
This means that you're familiar with Z80 assembler ..

Greetings
Kees
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by pser1 »

oss003 wrote:Hi Pere,
just had a look at your Hobbit conversion, pretty impressive ....
This means that you're familiar with Z80 assembler ..
Greetings
Kees
Hi, Kees
Thanks a lot for the explanation in previous message.
In fact I joined a team of spanish friends that had just begun to analayze how to convert it to 6809.
Someone had a binary that we unassembled and then 'slowly' we begun to split it into subroutines and
documenting what they were used for (reverse engineering :-( )
The final part was really a brute force conversion code line by code line from Z-80 to 6809 trying to
optimize a bit using the powerfull indexed addressing of the 6809 and a few more tricks.
Again, thanks a lot for you info and help!
cheers
pere
oss003
Posts: 25
Joined: Sat Jun 23, 2018 12:01 pm

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by oss003 »

Well I did almost the same.
I had the Z80 source code of the AGD engine, luckily well documented by Jonathan Cauldwell, and wrote a kind of script file which replaced the Z80 code with 6502 code.
This wasn't optimal but in theory it should work, the converted code looked like this:

Code: Select all

; 29.03.05 ld l, 0 	
	lda #0
	sta z80_l

; 29.03.05 ld b, 64 	
	lda #64
	sta z80_b

; 29.03.05 ld c, 6 	
	lda #6
	sta z80_c

; 29.04.00 ld ix, spritemenu 	
	lda #<(spritemenu)
	sta z80_x
	lda #>(spritemenu)
	sta z80_i

; 04.00.xx call largeSprite 	
	jsr largeSprite
The next step was, like you did, step the code line by line check and try to optimize it.
When that was done, the AGD compiler had to be upgraded because it was Z80 code based.
This was relative easy because the AGD compiler reads a command from the AGD file and outputs assembler code.
All you have to do is replace a few lines of Z80 code with 6502 code per command.
And then ....... the debugging starts.
This takes a long time but it's nice to see the progress until .... a game starts running.
That's a very nice feeling.

I don't have any knowledge of the 6809 assembler but hopefully there's someone willing to take the above steps to get AGD ported to the Dragon.
I'm willing to help where I can.
As I said, there are 150 games written for AGD and the number is growing so a lot of games will become available.

Greetings
Kees
jmk
Posts: 65
Joined: Fri Mar 20, 2009 1:12 am

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by jmk »

It's amazing how many more AGD games have been developed since I started this thread! Some of them would be great to have on the Dragon/CoCo.
oss003
Posts: 25
Joined: Sat Jun 23, 2018 12:01 pm

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by oss003 »

jmk wrote:It's amazing how many more AGD games have been developed since I started this thread! Some of them would be great to have on the Dragon/CoCo.
Yes, I noticed your post, it was 6 years old but it's an interesting project.

I think it all started when Jonathan Cauldwell wrote an editorless version of AGD.
The goal was to create a general game programming language which could be compiled to many systems.
He started with a Spectrum version and later a CPC version.
Then I added the Acorn Atom version and the same AGD game can be ported to 3 systems now.
This is great because the AGD community is very active.

Here's an example of one AGD game Moritz ported to 3 systems:

ZX Spectrum version: https://www.youtube.com/watch?v=AZ0kSVGLnAI
CPC version: https://www.facebook.com/sabe.baba/vide ... 665739200/
Acorn Atom version: https://www.youtube.com/watch?v=aEYfZQbPVjE

Maybe, for a start, I should write a script file to convert the Z80 code to 6809 code which can be assembled......... :roll:

Greetings
Kees
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by pser1 »

Hi Kees,
I have used your suite to compile FOGGY, previously I have commented the lines that delete intermediate files
so that I could have a peek at them.
It works perfectly! thanks a lot for sharing!
The first step of build, that converts the .agd file into .asm shows a few 'warning' messages
Here are all the messages from both steps: convert and build

Code: Select all

AGD extractor tool V0.5
(C) Jonathan Cauldwell May 2018
Assuming version 4.6
Sprite frames list 36924
Sprite data 36946
Block image data 46162
Block attribute data 46794
Block properties data 46873
Screen layouts 46952
Enemy positions 55804
AY sound effects 56280
Text 56485
Objects 57554
Events code 58315

AGD Compiler for ZX Spectrum Version 0.7
(C) Jonathan Cauldwell June 2018
Sourcename: FOGGY.agd
ENDIF without IF on line 1822: (in fact 1893)
; warning - ENDIF without IF?
ENDIF without IF on line 1824: (in fact 1895)
; warning - ENDIF without IF?
ENDIF without IF on line 1886: (in fact 1957)
; warning - ENDIF without IF?
ENDIF without IF on line 1996: (in fact 2067)
; warning - ENDIF without IF?
Not a number or variable on line 2133: (might it be 2205?)
BEEP 50
Output: FOGGY.asm

leader.txt
FOGGY.asm
trailer.txt
SjASMPlus Z80 Cross-Assembler v1.07 RC8 (build 06-11-2008)
Pass 1 complete (0 errors)
Pass 2 complete (0 errors)
Pass 3 complete
Errors: 0, warnings: 0, compiled: 6442 lines, work time: 0.188 seconds
Looking at the .agd code, the warning messages already exist there and it seems that they have been generated by the very first step (convert).
I assume that this is not to be taken into account because they have no effect on the final result.

So, we have a very solid beginning point!
Comparing the final .asm file against the engine you had uploaded, it is clear that the final one is made by adding the "data and events code"
at the end of the engine.
This seems to imply that we need to convert the engine module only 'once' and then every "data and event blocks" for every game we want to port

In any case, the first step to do will be analyze the code devoted to sound and graphics because these are the parts that will need to be
'converted' to match the hardware possibilities on the CoCo-Dragon

cheers
pere
oss003
Posts: 25
Joined: Sat Jun 23, 2018 12:01 pm

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by oss003 »

pser1 wrote:Here are all the messages from both steps: convert and build

Code: Select all

AGD Compiler for ZX Spectrum Version 0.7
(C) Jonathan Cauldwell June 2018
Sourcename: FOGGY.agd
ENDIF without IF on line 1822: (in fact 1893)
; warning - ENDIF without IF?
ENDIF without IF on line 1824: (in fact 1895)
; warning - ENDIF without IF?
ENDIF without IF on line 1886: (in fact 1957)
; warning - ENDIF without IF?
ENDIF without IF on line 1996: (in fact 2067)
; warning - ENDIF without IF?
Not a number or variable on line 2133: (might it be 2205?)
BEEP 50
Output: FOGGY.asm
These extra ENDIF commands are added by AGD4.7 where the game was created with.
You can remove the ENDIF commands with warning without any problem.
The error on line 2133 is the DELAY command without parameter. Enter DELAY 20 in de AGD file and it's working.
I'm not sure if this is a CONVERT error or if the errors are already in the snapshot but they are easy to fix.
pser1 wrote:Comparing the final .asm file against the engine you had uploaded, it is clear that the final one is made by adding the "data and events code"
at the end of the engine.
What I did was adding the missing labels without code to be sure the engine could be assembled.
You have to test every subroutine seperately with the right parameters.
pser1 wrote:This seems to imply that we need to convert the engine module only 'once' and then every "data and event blocks" for every game we want to port
In any case, the first step to do will be analyze the code devoted to sound and graphics because these are the parts that will need to be
'converted' to match the hardware possibilities on the CoCo-Dragon
Yes, you're right but you don't have to convert the data and event blocks because that's what the AGD compiler does.
The Atom also has a 6847 so you could take the Atom graphic routines.

I think the next step is to create a 6809 engine which can be assembled, it doesn't have to work yet but first it must to assembled without errors.
This can be done like I showed in the previous message, replace every Z80 command with 6809 commands.

Greetings
Kees
Last edited by oss003 on Tue Jun 26, 2018 3:14 pm, edited 1 time in total.
oss003
Posts: 25
Joined: Sat Jun 23, 2018 12:01 pm

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by oss003 »

I think we have to follow these steps:

- Convert engine to 6809 code
- Add dummy missing labels
- Assemble engine
- Start with debugging main loop (game)
- Debug every called subroutine by calling subroutines with right data
- Check output subroutine

I didn't use colourmode or sound and added that later.
It is very easy to use colourmode because the sprites move in steps of 2 pixels so you only have to redefine the graphics data, the game is for mono and colourmode the same.
You'll have to add parameters to the BUILD command because the Atom suite uses conditional assembly, this is done to save space.
BUILD FOGGY m builds FOGGY with the menu routines.

The syntax is BUILD FOGGY m p s i (lower capitals), conditional compiles the AGD file, assembles it and runs it in an Atom emulator
(m = add code for Menu/Inventory)
(p = add code for Particles)
(s = add code for Scrollytext)
(i = invert game)

https://www.youtube.com/watch?v=HTGFHAPp5eU

Parallel you can think about how to use the memory map.

I've added the Atom suite and if you unpack it in the same directory as the ZX suite and the snapshots, it will work.
The Atom suite uses the same snapshots as the ZX suite.
https://drive.google.com/open?id=1uwtQY ... QKfqXDLRTi

Greetings
Kees
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by pser1 »

Hello Kees,
thanks a lot for these two last messages.
I need some time to study and try what you explain here.
I thought that the AGD compiler was generating something like 'macros' that are later
converted to assembler by the 'sjasmplus' but have not seen a way to get 6809 or 6502 code out of this toolchain
But don't worry, as I said, I need to read this more thoroughly and right now I have very little time
I have created a thread on that subject in the Retrowiki web, for maybe someone 6809 or 6502 user
might want to work on the port. This is the link
http://www.retrowiki.es/viewtopic.php?f=62&t=200034092
This web is from Spain, so text is basically entered in spanish
Will keep in touch to let you know how this goes.
Thanks a bunch
cheers
pere
oss003
Posts: 25
Joined: Sat Jun 23, 2018 12:01 pm

Re: Anyone interested in converting AGD to the Dragon/CoCo?

Post by oss003 »

Thank you for having a look.....
Hopefully you will finish your projects soon to join me ...... 8-)

I'll start with tweaking my Z80-to-6502 conversion program to make it a Z80-to-6809 conversion program as a start.
It would be nice if you want to watch this topic now and then because I will have questions ......

Can you recomment a good assembler?
I also need a good emulator with debugging options, Xroar maybe?
Thanks.

Greetings
Kees
Post Reply