DarwinNE / aws2c

Adventure Writing System to C translator
GNU General Public License v3.0
10 stars 4 forks source link

Atari ST support #3

Closed ggnkua closed 3 years ago

ggnkua commented 3 years ago

Hello,

Let me first say that I found this repository by accident: The Polyplay store on the ST section (https://www.polyplay.xyz/ST/STE/TT) lists one of your text adventures as supported on ST. But after visiting your page I couldn't find a ST version! So after a bit more searching I found this repository.

Looking at the source code I did indeed verify that the code has no mention of the Atari ST, so I went and added support myself. The generated adventure code is now compilable for Atari ST and compatibles using gcc 10.2.0 (although pretty much any gcc should work) and the sample adventure (Dawn Patrol) has been verified to work start to end, as well as save/load and coloured text.

To make this work firstly I added all the necessary stubs in systemd.h. But I also had to modify some code due to newline handling in TOS, which expects CRLF instead of just LF. I made this into a macro that is specific only for the ST, and the rest of the platforms should get the default behaviour.

So, I can prepare a pull request or patch if you have no objections.

Looking forward to your reply, George

P.S. I finished "Two days to the race" on the Amiga, I'd really like to play the other parts of the trilogy on the ST!

DarwinNE commented 3 years ago

Hello @ggnkua

That's awesome!

I wrote to Sebastian at Poly.Play, indeed The Queen's Footsteps is not yet available for the Atari ST.

Feel free to open a pull request, I'd really like to see your code. AWS2C works sufficiently well for my needs, but its code is not very clean on some details. Concerning the macro, for example I use SHIFTPETSCII to operate on the characters while a message is being output. I used it for the Atari 8 bit, too, so maybe the name is not chosen properly.

Concerning the compiler, which one are you using, exactly? I don't have a gcc configured to output on the ST, can you please point me towards a reliable one that I can build on a MacOS system?

Cheers, D.

ggnkua commented 3 years ago

Hi @DarwinNE

If I didn't do anything bad, you should have the pull request in 6930042.

I think what you describe with SHIFTPETSCII is different to my use case, but perhaps I misread what you wrote. I guess you can tell me when you look at my changes :).

As for the compiler, I have made a build script (with the help of some friends I should add) that creates a cross compiler for Windows/Linux/Mac. This is a combination of 2 projects: The gcc build script itself and the tool that converts ELF binaries to TOS executables.

So my build script for Dawn patrol looks something like this:

#Compile
$GCC_PATH/bin/m68k-atariextrabrowner-elf-gcc -c dawn_patrol.c -I. -DATARI_ST -I$GCC_PATH/mintlib-0.60.1-bin/include -m68000 -Ofast -fomit-frame-pointer -fstrict-aliasing -fcaller-saves -flto -ffunction-sections -fdata-sections -fleading-underscore -D__ATARI__ -D__M68000__ -DELF_CONFIG_STACK=16384
$GCC_PATH/bin/m68k-atariextrabrowner-elf-gcc -c ../inout.c -I. -DATARI_ST -I$GCC_PATH/browncc10.2/mintlib-0.60.1-bin/include -m68000 -Ofast -fomit-frame-pointer -fstrict-aliasing -fcaller-saves -flto -ffunction-sections -fdata-sections -fleading-underscore -D__ATARI__ -D__M68000__ -DELF_CONFIG_STACK=16384
$GCC_PATH/browncc10.2/bin/m68k-atariextrabrowner-elf-gcc -c ../loadsave.c -I. -DATARI_ST -I$GCC_PATH/mintlib-0.60.1-bin/include -m68000 -Ofast -fomit-frame-pointer -fstrict-aliasing -fcaller-saves -flto -ffunction-sections -fdata-sections -fleading-underscore -D__ATARI__ -D__M68000__ -DELF_CONFIG_STACK=16384
#Link
$GCC_PATH/bin/m68k-atariextrabrowner-elf-gcc -L$GCC_PATH/lib/gcc/m68k-atariextrabrowner-elf/10.2.0/m68000 -L$GCC_PATH/mintlib-0.60.1-bin/lib -o st.elf $GCC_PATH/mintlib-0.60.1-bin/startup/crt0.o dawn_patrol.o inout.o loadsave.o -Wl,-Map,st.map -Wl,--emit-relocs -Wl,-e_start -Ttext=0 -m68000 -Ofast -fomit-frame-pointer -fstrict-aliasing -fcaller-saves -flto -ffunction-sections -fdata-sections -fleading-underscore
#Convert to ST executable
./brownout -p 0 -i st.elf -o st.tos

If building gcc from scratch looks intimidating for you I can take a shot at it on my mac mini here. It'll take some time but it's ok!

That's all for now. Let me know how you get on with everything. George

DarwinNE commented 3 years ago

Hello, I had a look at the pull request and it seems OK. I see what you mean for the newline. I think it can work like this.

I have already rebuilt gcc on my machine, I'll have a look and let you know. Is there an emulator you would suggest in particular (working on MacOS)?

Cheers and thanks!

D.

ggnkua commented 3 years ago

Try hatari: https://download.tuxfamily.org/hatari/ and you can grab TOS images from http://www.avtandil.narod.ru/tose.html (I'd recommend versions 1.02 and 1.62 for best compatibility)

DarwinNE commented 3 years ago

Hello, installing gcc went very smooth and it seems that I could convert the output file to .tos. I tried the compiler toolchain with Silk Dust and a makefile that is inspired by the script you built for Dawn Patrol (it was extremely useful). I put the result there:

http://davbucci.chez-alice.fr/index.php?argument=varie/silk/silk.inc&language=English

If it works, I can easily prepare a version of The Queen's Footsteps for the Atari ST using the same tools. I haven't yet installed an emulator (I'll try to have a loot at Hatari now), so I haven't tested anything. Just the compiling went OK :)

Cheers, D.

DarwinNE commented 3 years ago

I tried Hatari, for the moment with the EmuTOS and I could run correctly the version of Silk Dust! I just had to switch to the high resolution mode so to read 80 columns for the text.

That's awesome!!!

ggnkua commented 3 years ago

You can also switch to medium resolution for colour :).

Also, for low resolution it should be possible to make a second version with 40 columns limit, or send a "ESC v" code during init to turn wrapping on (http://toshyp.atari.org/en/VT_52_terminal.html#VT-52%20terminal).

Good news in general though!

DarwinNE commented 3 years ago

I prepared two versions. One with an 80-column wrapping of the text and less colours that works well in a medium resolution display and one with a 40-column wrapping and more colours. The second mode is activated by defining the LOWRES macro while compiling the inout.c file.

ggnkua commented 3 years ago

Cool, I'll test them tomorrow.

By the way, if you like I can help with displaying a title picture. On the ST there are a few methods in which one can show a picture consisting of several thousands of colours. Just let me know and I can cobble a small program together for this.

DarwinNE commented 3 years ago

It would be very interesting to show a splash picture! Which is a reasonable size/number of colours?

By the way, I just ported The Queen's Footsteps to the Atari ST, too:

http://davbucci.chez-alice.fr/index.php?argument=varie/queen/queen.inc&language=English

ggnkua commented 3 years ago

Here's an example of what can be achieved. It is far from optimal as I used a scaled copy of the box cover:

image

The converted pic is around 1900 colours.

DarwinNE commented 3 years ago

That's really impressive! I think I would probably use simpler pics, though, as that wonderful Ralph Niese's picture belongs to my editor.

For TQF, the best splash screen I have is the one I drew for the C64: the_queens_footsteps_C64

For SD, I drew one on the Amiga that can be used on the ST, too: amiga_splash11

Concerning colour rendering, the Amiga ones tend to appear quite "flashy" when I convert the image on modern computers. I think there is a red dominant that is not present in the original palette.

Here is a picture of what I see on a CRT monitor: SilkDust_screenshot_crt_thumbnail The colours appear more similar to what I see on my PVM monitor.

How can I convert them in a way that they can be displayed on the ST? The ideal way would be something that I can link to the game. Macro init_term() can be used to call a showsplash() functions that shows the image and then waits for a key press. I used this for the MSDOS versions of the game.

Cheers, D.

ggnkua commented 3 years ago

Hi @DarwinNE,

Sorry for the late reply on this, I'll explain why quickly:

Since the adventures will work on any Atari of the 16/32 line ((Mega) ST, (Mega) STE, TT, Falcon), I thought it would be nice if I could provide a solution to display the title pic in all machines.

Your C64 pic is no problem really, all the above machines can show that without any problems. For the other image, things get slightly complicated. ST/STE machines need specialised code to display that pic, while the TT and Falcon both have 256 colour modes, so there there's not many problems.

The real problem is that there's no straightforward way to convert the source picture to the formats required for each machine, so I had to make some sort of streamlined process for this. So I used the Photochrome line of programs (http://www.leonik.net/dml/sec_pcs.py) to convert the image to the special format for the ST/STE and once again for the TT/Falcon. Then I wrote some small programs (that can be combined into one) that load and display the pictures. Here are some results:

image

From left to right: TT, PC, Falcon, Mega STE. Some close ups:

TT, on TFT VGA monitor

image

Falcon, on a TFT VGA monitor:

image

Mega STE, on a Philips CM8833 CRT monitor (or something close to that)

image

Now, how to integrate all these things with your program. You mention that you would like something to link to your game. Does this mean that you also want to link the binary data of the pictures? I suppose I can write a small routine that detects the machine and then displays the appropriate picture for user configurable seconds and returns. The two different pictures are about 100k in size.

Let me know if you're ok with the results and what you'd like to do and I'll get on it.

Looking forward to your reply! (and sorry if I rambled for too long)

DarwinNE commented 3 years ago

Dear @ggnkua, the results are awesome!

I would be glad to include them in SD and TQF, with due credits, of course. I don't know how it would be simpler to include them in the game. In the MSDOS version, I put the splash screen as as binary data. On the other hand, the pictures can be present as a separate files on a disk image if it is simpler. I did that with the splash screen of the C128 and M20 of TQF (RLE encoded).

Cheers and thanks, D.

ggnkua commented 3 years ago

Hi @DarwinNE,

Sure, I'll fix up something for you in the coming days. Can I reach you by email when I'm done or would you like me to attach the files here?

Regards, George

DarwinNE commented 3 years ago

Sure, write me on the email you find on my blog (without attachments). I'll answer you back from an address where we can exchange files more easily.

Cheers, D.

ggnkua commented 3 years ago

Hi @DarwinNE, just wanted to check if you got my email from a couple of days ago. If not, I'll resend.

DarwinNE commented 3 years ago

Hello @ggnkua! No, I did not receive it. Can you please try to send it again?

Cheers, D.

ggnkua commented 3 years ago

Hi @DarwinNE, done!