Jump to content
IGNORED

XL/XE Compatible Demon Attack


dwhyte

Recommended Posts

I've never been a fan of translator software. I've always liked games to run without a translator disk or cart. So needless to say running Demon Attack has always been a thorn in my side when I had to boot up a translator disk to play it on a real system, or changing system modes on an emulator.

 

Well here's an XL/XE compatible Demon Attack that no longer requires OS translation. I've yet to see one out there other than the DemonAttack/Pitfall (which isn't file'ized) disk on Atarimania...

Demon_Attack__XL_XE_.zip

Edited by dwhyte
Link to comment
Share on other sites

For anyone interested, here's my own fixed version that works on 400/800 and XL/XE:

Edit: attachment removed, see below for "proper" fixed version

 

BTW, is there a "correct" way for code to determine whether it's running on a 400/800 or XL/XE? I just checked the high 4 bits of the 6502 RESET vector, and assume I'm on an XL/XE if it's $C (since on an 800, there's no ROM at $Cxxx, so the RESET vector can't point there). Does anyone know if any of the variant 800 OSes (Omnimon, etc) include ROM at $C000, and if so, do any of them actually point the RESET vector there?

 

I can think of several other ways to check, including the revision byte at $FFF7... this way seemed simplest (least likely to get confused by patched OS ROMs).

Edited by Urchlay
Link to comment
Share on other sites

SuperMon has ROM at $C000 and pretty sure OmniView and probably all others do too.

 

Given that the 10K on the 400/800 is pretty packed by default, you'd be hard pressed to fit much more into it.

I guess the revision byte check mightn't work on certain alternative OSes for the XL that give it extra legacy compatability, although in such cases the incompatability issues usually don't appear anyway.

 

Other ways to detect 800 vs XL:

 

Switch in the Self-Test ROM and test for it at $5000.

Switch out the OS and check if a range of memory changes within the OS address space.

Check the contents of $CC00-$CC0F (second character set), although that might fail with modded OSes which use that area for code.

Do a warmstart ($E474) then check if PORTB is in output mode.

Edited by Rybags
Link to comment
Share on other sites

SuperMon has ROM at $C000 and pretty sure OmniView and probably all others do too.

 

Given that the 10K on the 400/800 is pretty packed by default, you'd be hard pressed to fit much more into it.

I guess the revision byte check mightn't work on certain alternative OSes for the XL that give it extra legacy compatability, although in such cases the incompatability issues usually don't appear anyway.

 

Demon Attack jumps to SYSVBL, a documented entry point... so depending on how Omnimon/Supermon/etc works, my (admittedly simple) code might decide it's on an XL, and try to jump to the XL SYSVBL location. Anyone who uses one of these alternate OSes care to try it & let me know if it works?

 

Switch in the Self-Test ROM and test for it at $5000.

 

Thought of that, but then there are those 1 meg modded XEs that don't have the self-test ROM (or anyway they somehow use PORTB bit 7 for RAM banking).

 

Switch out the OS and check if a range of memory changes within the OS address space.

 

Thought of that too, but if they're running something like SpartaDOS 3.x, part of the OS ROM gets copied into RAM (I know the charset does at least, maybe some of the interrupt handlers too), so I'd have to know what I was doing there...

 

Check the contents of $CC00-$CC0F (second character set), although that might fail with modded OSes which use that area for code.

 

Yah, thought of that too :)

 

Actually I prefer not to mess with the $Cxxx area on an 800, since I don't know whether the undefined memory accesses are emulated correctly in atari800/atari++, and am too lazy to dig my real 800 out & set it up..

 

Do a warmstart ($E474) then check if PORTB is in output mode.

 

Hm, is a warmstart even necessary there? I suppose there might be some software out there that sets PORTB as outputs on the 800 (driver for the numeric keypad maybe?)...

 

Another thing I thought of: there are quite a few "spare" bytes on the 800 that are initialized to 0, but on an XL they're used for something and therefore not 0. CHSALT ($026B) is a good candidate (on an XL it should never be 0, on an 800 it should always be 0, unless someone's breaking the rules).

Link to comment
Share on other sites

What exactly is Demon Attack doing that makes it OS dependent?

 

Directly jumping to the OS immediate VBLANK handler, which is a no-no (various Atari manuals warned not to do stuff like this, from day one).

 

Actually, I'm guessing Demon Attack was originally developed on 400/800 OS revision A, because it contains JMP $E7D1... on rev A, $E7D1 is the start of the SYSVBL routine. On rev B, it's actually in the middle of the routine, and it's probably blind luck that the jump lands on a valid instruction and that the program still works. On the XL/XE OSes, the interrupt handlers all got moved to $Cxxx, so whatever's at $E7D1 is the wrong code to jump to (so the game crashes).

 

dwhyte's modified version replaces the 2 instances of JMP $E7D1 with JMP $C10F, which is probably the start of SYSVBL on the XL/XE (I haven't checked). The version I posted is dwhyte's version plus a few bytes of init code that run before the game runs, and undo the patch if it's running on an 800.

 

Now that I think of it, there's a better way to fix it... VVBKLI at $0222 is initialized to point to SYSVBL at boot, so it'd contain the correct address for the game to jump to. The game code changes the vector to point within itself, but it'd be easy to write a little init segment that loads before the game, grabs the contents of $0222/$0223, and saves them somewhere in memory the game doesn't use (maybe page 6, or the tape buffer, the usual suspects), then change the absolute JMPs in the game code to indirect JMPs, to vector through the saved SYSVBL. Doing it this way, it'd be less of a "dirty hack", and more likely to work with nonstandard/modified OSes like Omnimon.

Link to comment
Share on other sites

Easier still - the contents of those vectors are just the operands of the documented Jump Table addresses at $E45F/$E462.

Easiest - just JMP $E45F.

 

C10F seems to also be part way into Stage 1 VBlank, just after RTCLOCK is incremented and software Timer 1 is checked.

Link to comment
Share on other sites

What exactly is Demon Attack doing that makes it OS dependent?

 

Directly jumping to the OS immediate VBLANK handler, which is a no-no (various Atari manuals warned not to do stuff like this, from day one).

I figured it was something like that. I like the idea of fixing the call rather than patching the illegal jump. Nice to have these games finally fixed.

Link to comment
Share on other sites

Easier still - the contents of those vectors are just the operands of the documented Jump Table addresses at $E45F/$E462.

Easiest - just JMP $E45F.

 

Argh, I missed that. Wonder why the original programmer didn't just do that?

 

C10F seems to also be part way into Stage 1 VBlank, just after RTCLOCK is incremented and software Timer 1 is checked.

 

Yeah, but the game plays fine whether you jump to SYSVBL or that part of the routine (I suppose the game doesn't use RTCLOCK or sw timer 1).

Link to comment
Share on other sites

Will these 'little tricks' work on every A800 only game....or does it depend on how the game was programmed/coded

Most of the time it's something like this, where interrupts aren't handled properly and/or a jump is made directly into the OS. I think there was a game or two that did things like messing with PORTB.

Edited by Bryan
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...