Building a game launch menu for the AUTO folder: What could possibly go wrong?!

News,announcements,programming,fixes,game patches & discussions.

Moderator: Petari

Post Reply
stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Tue May 29, 2018 9:28 pm

Well, over the weekend I had a lot of fun hacking together a game launcher menu system for my Atari TT.

Given that this was to be a quick system I leant on my UNIX knowledge and decided to use the curses library for the screen management. Usefully in the early 90s Eric Smith (of MiNT fame) wrote a basic TOS version based upon the early BSD UNIX sources. I had a full build environment under MiNT too, so it was logical to use that. (This comprised GCC 2.5.8pl1 and mintlibs pl 46.)

To cut a long story short, this part of the project, including reading in an INI file and parsing a simplified CSV format file, was quite simple.

The frustrating parts were controlling the sound system. Thankfully I found reasonable documentation for the STe/TT Microwire interface to control the volume of the DMA audio. The difficult bit was controlling the speaker on the TT. After numerous attempts to get it to work I got no-where until I discovered:
  • A 'feature' of the mintlibs <osbind.h> header combined with GCC meant that the value passed to Ongibit() and Offgibit() HAS to be unsigned short otherwise it doesn't work.
  • The game I was using to test (Bubble Bobble) cleared the PSG Port A, meaning that bit 6 got cleared, turning the speaker back on! This meant that even after I'd got it working I didn't know that I had. I only discovered this when I tried a different game.
I also had to learn how to write inline assembler to allow me to control the 68030 cache.

Anyway, by late yesterday I had a working program which would work on all Ataris as I'd made sure that I only controlled the DMA audio and other extras on the relevant machines. I even checked by running it under MiNT with memory protection turned on to make absolutely sure that there wasn't any erroneous memory access. All fine.

So, today at the asking of that nice Petari fellow I posted a binary... Well it crashed and burned on his STe... Oh dear!

He suggested that I try in an emulator, so I downloaded Hatari for my Mac, installed TOS 1.62 into it, recompiled the code giving the compiler the -m68000 options as I guessed that it was building 68030 binaries by default and copied the executable into the emulator's "hard disk"...

The result... it mostly worked. If run from the AUTO folder it ran and didn't crash anything on exit, most of the time. Run from the GEM desktop it would always crash with three bombs on exit and I have no idea why.

I haven't got my STe available at the moment (it's in the loft) so I can't try it on a real machine.

So I'm almost there.

If anyone would like to play I've attached a zip file containing the source and an executable. As mentioned about you'll need GCC, make, mintlibs and Eric Smith's curses library to build it.
Attachments
gamemenu.zip
(86.45 KiB) Downloaded 19 times
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Tue May 29, 2018 10:47 pm

I wonder if the crashes are due to the colour changing code reading/writing 16 colour values even when it's in ST-Medium mode, which only uses 4 colours...
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Tue May 29, 2018 10:58 pm

Nope! :(
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Wed May 30, 2018 6:47 pm

After running a "Hello World" test program successfully the compiler checked out so I decided to try commenting out all of the code and start enabling from the beginning of gamemenu.c

The first thing the code does is call the MiNTlib "uname()" function (a copy of which is attached). This extracts the machine type from the Cookie Jar and other information to get the OS name and version, making some defaults if it's not running under MiNT.

After calling this function and exiting without doing anything else the Hatari STe crashes, so I've found the location of the problem. I wonder why it doesn't crash on the TT.

Anyway, I only need to know what machine I'v running upon so I can write my own Cookie Jar reading code and replace 'uname'. That should fix it.
Attachments
uname.c
(1.78 KiB) Downloaded 17 times
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Wed May 30, 2018 8:47 pm

OK. This is strange. With my own code which merely reads the Cookie Jar causes the emulated Hatari STe to crash. Something's not right here.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Thu May 31, 2018 8:16 am

I still can't think of a reason that reading memory in supervisor mode could possibly cause a machine to crash after the process exits.

Any ideas?

Here's the code that causes the crash.
#include <osbind.h>

#define COOKIE_BASE ((unsigned long **) 0x5a0L)

unsigned long mch = 0L;

void read_cookie_jar()
{
unsigned long *cookie;

cookie = *COOKIE_BASE;

if (cookie)
{
while(*cookie)
{
if (*cookie == (unsigned long) 0x5f4d4348L)
{
mch = cookie[1];
break;
}

cookie += 2;
}
}
}
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Thu May 31, 2018 8:39 pm

And now, after re-writing the cookie code to only read the location of the Cookie Jar in supervisor mode and do everything else in user mode it still crashes with two or three bombs upon exit when run from the desktop.

It must be the emulator at this point as there's nothing else it can be.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Thu May 31, 2018 9:02 pm

Switched to EmuTOS from TOS 1.62(UK) and it works in Hatari. Strange.

So, if anyone else wants to try the program, I've attached a ZIP file containing the source and a binary for you to try.
Attachments
gamemenu.zip
(87.18 KiB) Downloaded 14 times
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 166
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by stephen_usher » Mon Jun 11, 2018 12:36 pm

The event for which I wrote the game launcher happened this weekend and everything went well.

The TT performed flawlessly for the whole two and a half days and many people had a lot of fun.

I'd like to thank Petari for all his work getting old games not only running off the hard disk but also running on the TT. Thank-you for all your hard work.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

JezC
Posts: 44
Joined: Mon Aug 28, 2017 11:44 pm

Re: Building a game launch menu for the AUTO folder: What could possibly go wrong?!

Post by JezC » Mon Jun 11, 2018 10:40 pm

+1

I'm really grateful to all the people still working hard to support these platforms - they don't get anywhere near enough credit for all their hard work IMO!

Jez

Post Reply