Corporation Megademo

All about ST/STE demos

Moderators: lotek_style, Mug UK, Moderator Team

User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Corporation Megademo

Postby Steven Seagal » Fri Sep 30, 2011 7:27 am

Hi, another question about a demo on a real STE (Corporation Megademo is an STE only demo).

There's a patch for it in Steem that says:

This demo turns on keyboard interrupts and then won't work if it gets keyboard interrupts, very odd.
ApplyWhen=The main screen appears.


When I try the demo without patch in Steem, sometimes it works (bashing spacebar launches first demo), sometimes it doesn't. Before I waste time trying to "fix" that, I would like to know how it behaves on real hardware. If it does the same, there's nothing to fix. Thanks in advance.
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

Dio
Captain Atari
Captain Atari
Posts: 451
Joined: Thu Feb 28, 2008 3:51 pm

Re: Corporation Megademo

Postby Dio » Fri Sep 30, 2011 9:50 am

I may have come across this behaviour in Emu on a different piece of software.

Does the demo poll the keyboard status reg in at tight loop waiting for a character, but simultaneously have an ACIA interrupt routine that reads the keyboard? The original of Leviathan runs into trouble with this scenario (but, oddly, not the Automation disk) unless you have a bit of fiddly-ness in the emulator.

I traced the problem to Emu only executing its timer callbacks (and, through them, receiving bytes from the keyboard) on instruction boundaries, which would immediately generate the interrupt and that would always be taken. However, if an app polls the keyboard, it can see the character is ready before the interrupt is taken, because the status bit can change in the gap between the instruction starting and the read being done at the ACIA. In addition, there can also be some MFP latency that provides a bit more of a window for it to be visible. (I fixed it by adding a method to execute a timer early in these sorts of cases; I need to add the MFP latency too at some point).

The symptom at the app level on a real ST (and on the emulator when you fix the problem) is that sometimes you bash a key and it's missed (because the interrupt catches it) but sometimes you bash it and it works (because the poll manages to see it first), which sounds like what you describe. Before fixing the problem, the thing just never sees a key and locks up.

It may be that STeem initially had the same problem Emu did (locking up) and later fixed it with either or both of adding MFP latency or cycle-granular receive, but it wasn't then realised that the patch was now no longer required?

So if you can verify with the debugger that it's polling in a tight loop I think there's probably nothing to fix, but as you say, can't hurt to check for the same behaviour on a real machine to be sure.

User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Corporation Megademo

Postby Steven Seagal » Sat Oct 01, 2011 8:38 am

It sounds horribly complicated. I've looked in the debugger, but I'm lost in M68K.
What I could see is this:
When it doesn't work, the program reads 0xfffc00, and if IRQ is set (bit 7), it's not good for it... it's probably polling on its side... odd, like Steem authors say.

I've looked in WinSTon/Hatari keyboard routines, and it seems that Steem doesn't handle the well-known (hem) ACIA latency.
To fix the issue with this menu, I've prevented the IRQ bit on address 0xfffc00 to be set before some cycles have passed since the player bashed a key. It seems to work and not break normal typing, but I'll test it some more.
The problem is that the minimal value I must use is 10760 cycles , and the demo will still miss some hits. In WinSTon/Hatari, they use 7200, but in a much more intricate way (intern interrupt?!). I'm also worried that it may slow mouse/joystick action, which would be a high price just for one demo fix, though I haven't noticed it (I passed Arkanoid level 1!).

By the way Dio forgive my ignorance but what is Emu?
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

Dio
Captain Atari
Captain Atari
Posts: 451
Joined: Thu Feb 28, 2008 3:51 pm

Re: Corporation Megademo

Postby Dio » Sat Oct 01, 2011 1:32 pm

I'm not sure what you mean by the timing, but it definitely sounds like a similar problem to the one I encountered.

Emu is my ST (and Jaguar, Spectrum, Megadrive and VCS emulator) that evolved from this Jaguar emulator. It hasn't escaped the house except for a test build the IPF guys used to help debug their FDC because a. I haven't got around to building a website and b. it doesn't have enough of a USP to be viable - every one of its systems is better emulated elsewhere.

User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Corporation Megademo

Postby Steven Seagal » Sat Oct 15, 2011 9:39 pm

Sorry it's a bit technical but I wasted some time on this mystery and I place it here in the forum in case someone made a search on the subject.

I looked further into this one, and also in V8 Music System. Both demos required a patch in Steem 3.2. No more. V8 didn't work because the ACIA (keyboard) IRQ was triggered at off times, quite too late if we take the 7200 + 18 cycles reference (WinSTon/Hatari, my main doc for keyboard problems). The way I understand it, the IRQ was triggered at the end of 20 scanlines after key press (10K+ cycles). So there was a delay IKBD/ACIA, but it wasn't accurate. It couldn't work that way! Corporation didn't work because indeed there's polling, and the program wants the 'data in' register bit to be set but not the 'irq' bit. But then the 'megaballs' demo has a strange behaviour too, I was always having keyboard 'overrun' errors... It's hard to make both V8 and Corporation work because one is in TOS 1.06 and it seems the keyboard handler of that TOS takes more cycles than TOS 1.02.

Edit: I finally found the trick that makes both demos work the same way. It's essential to set the ''data in' bit, then let some cycles pass for eventual polling programs, then set the 'irq' bit.
Edit2: in fact the Corporation keyboard problem still requires a hack.
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Corporation Megademo

Postby Steven Seagal » Thu Dec 15, 2011 6:25 pm

While testing & debugging Steem, I found that the last screen of Corporation never comes up. There's that problem in Hatari too. In Steem, the ST seems to endlessly loop in exceptions (bombs, but ther screen just hangs).
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

User avatar
npomarede
Atari God
Atari God
Posts: 1328
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Corporation Megademo

Postby npomarede » Thu Dec 15, 2011 11:00 pm

Steven Seagal wrote:While testing & debugging Steem, I found that the last screen of Corporation never comes up. There's that problem in Hatari too. In Steem, the ST seems to endlessly loop in exceptions (bombs, but ther screen just hangs).


It works fine under Hatari (at least next 1.6 version), last screen is a vertical scrolling with credits.

User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Corporation Megademo

Postby Steven Seagal » Wed Feb 08, 2012 6:40 pm

npomarede wrote:
It works fine under Hatari (at least next 1.6 version), last screen is a vertical scrolling with credits.


After further tests, it turns out it was a bad disk image. Probably the Chaos Engine version. The version at pouet.net is OK.
Last edited by Steven Seagal on Wed Feb 08, 2012 7:00 pm, edited 1 time in total.
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

User avatar
npomarede
Atari God
Atari God
Posts: 1328
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Corporation Megademo

Postby npomarede » Wed Feb 08, 2012 6:45 pm

That's my rule for testing games : if it doesn't load/crash under Steem, Hatari and Saint, then it's quite likely the image is altered :) (well, this rule is only valid because I know each emulator now has a fairly high level of accuracy !)

User avatar
Steven Seagal
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2018
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Corporation Megademo

Postby Steven Seagal » Fri Mar 02, 2012 9:10 pm

I come back once again on this "mega" demo to rectify what I previsouly stated. My understanding now is that it's a different problem from V8MS. For the latter, indeed, a delay is needed between 'RX' and 'IRQ' (as stated in Hatari source).
For Corporation, the problem is that the program is alawys lost in the VBL routine when ACIA interrupt triggers, and it's just because Steem takes Windows messages only at... VBL time!, which is only natural for an emulator, but it didn't strike me until now. If you make it "peek" messages before the end of the frame (at middle, for example), it works.
But probably in a few weeks or months, I must backtrack again...
In the CIA we learned that ST ruled
Steem SSE: http://sourceforge.net/projects/steemsse

User avatar
npomarede
Atari God
Atari God
Posts: 1328
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Corporation Megademo

Postby npomarede » Fri Mar 02, 2012 10:16 pm

In Hatari, mouse/keys events are not reported during the VBL but in a more random way. Testing for external events always at the same spot will often either hide bugs, or create "holes" you can't escape, there should be some pseudo randomness added to the processing of these events if you want to emulate the physical behaviour of a real keyboard/mouse (many (badly coded) programs are often only working because of this randomness, even on a real ST)

Nicolas


Social Media

     

Return to “Demos - General”

Who is online

Users browsing this forum: No registered users and 8 guests