Jump to content
Sign in to follow this  
az_network

Demon Attack (source code)

Recommended Posts

Hi, here enclosed you find the commented source code of Demon Attack

for Atari 2600.

Close...but there are still vectors you missed. Such as L12EF, which holds destination addresses that are pushed onto the stack and then RTS'ed to (because RTS is handling them, the addresses are all -1 from the actual address).

 

ex:

L12EF: .word LF1388-1
      .word LF135C-1
      .word LF134F-1
      .word LF12F7-1

  • Like 1

Share this post


Link to post
Share on other sites
Hi, here enclosed you find the commented source code of Demon Attack

for Atari 2600.

Close...but there are still vectors you missed. Such as L12EF, which holds destination addresses that are pushed onto the stack and then RTS'ed to (because RTS is handling them, the addresses are all -1 from the actual address).

 

ex:

L12EF: .word LF1388-1
      .word LF135C-1
      .word LF134F-1
      .word LF12F7-1

 

 

Hi, thank you for your reply.

 

Indeed, few lines before you see an explanation of the addresses in table L12EF,

and the commented lines of subroutines (SUB1), (SUB2), etc. take in due account

the actual +1 address (i.e. SUB 7 starting line is at $12F7, but stack address is

$12F6).

 

Do you suggest to use ".word LF12F7-1" in table to express more clearly the

actual starting addresses of subroutins ?

 

 

      LDA    SoundIndex	;3		if SoundIndex = 0 0 0 0 x x x x ---> save $1387 on stack (SUB4)
      AND    #$F0    		;2
      LSR            		;2		if SoundIndex = 0 0 0 1 x x x x ---> save $135B on stack (SUB5)
      LSR           		;2
      LSR            		;2		if SoundIndex = 0 0 1 0 x x x x ---> save $134E on stack (SUB6)
      TAY            		;2
      LDA    L12F0,Y 		;4		if SoundIndex = 0 1 0 0 x x x x ---> save $12F6 on stack (SUB7)

 

 

Anyway, I learned a nice way to embed a "ON x GOSUB" instruction in assembler !!!

 

regards,

 

A.

Share this post


Link to post
Share on other sites

Somebody created a translation of the original Demon Attack

in java (from the website Meatfighter).

 

The enclosed file could be useful to better understand the

dynamics of game. There is still a lot of work to do...

 

A.

demon_java.zip

Share this post


Link to post
Share on other sites
Do you suggest to use ".word LF12F7-1" in table to express more clearly the

actual starting addresses of subroutins ?

Yes, because that is the easiest way to keep the table values correct should a user add or delete code...just have the assembler do it for you. Otherwise, it's just a collection of values that may or may not be correct (and inadvertantly cause the program to glitch or crash). Describing what something is used for is the basic purpose of any source code...whether it's a value, labelled destination, subroutine, etc.

 

As more of the code is reverse-engineered and understood...something like this:

 

       LDA    L12F0,Y         ;4
      PHA                    ;3
      LDA    L12EF,Y         ;4
      PHA                    ;3
      RTS                    ;6

L12EF: .byte $87 ; |X    XXX| $12EF
L12F0: .byte $13 ; |   X  XX| $12F0
      .byte $5B ; | X XX XX| $12F1
      .byte $13 ; |   X  XX| $12F2
      .byte $4E ; | X  XXX | $12F3
      .byte $13 ; |   X  XX| $12F4
      .byte $F6 ; |XXXX XX | $12F5
      .byte $12 ; |   X  X | $12F6

 

 

...becomes this:

       LDA    L12EF+1,Y               ;4 MSB
      PHA                            ;3
      LDA    L12EF,Y                 ;4 LSB
      PHA                            ;3
      RTS                            ;6 Do sound effect for v1

L12EF:               ; SoundIndex bits 5-4 / effect
      .word L1388-1 ;                 0 0 / no sound
      .word L135C-1 ;                 0 1 / regular background noise
      .word L134F-1 ;                 1 0 / demon exploding
      .word L12F7-1 ;                 1 1 / end-of-game

 

 

The labels themselves can be search/replaced to describe what they are used for. In that case, the table would read something like this:

 

;jump table for voice1 sound effects...
v1_sound_tbl:                    ; SoundIndex bits 5-4
      .word v1_no_sound-1       ;                 0 0
      .word v1_reg_background-1 ;                 0 1
      .word v1_demon_explode-1  ;                 1 0
      .word v1_end_of_game-1    ;                 1 1

 

Much more easy to read than just a collection of generic labels that Distella assigned :)

Share this post


Link to post
Share on other sites

Can I ask, on behalf of those of us who don't speak the assembler language you are parlaying, does the "commented source code" version mean this is the original ROM that ends at Level 256?

 

(Sorry for my ignorance, I am trying desperately to get the original game-ends-at-256 version anywhere I can)

Share this post


Link to post
Share on other sites

The original ROM crashes after level 84...not 255. The code specifically checks for that level, and enters an infinite loop (it's not a bug).

 

; @ = $147C
.SinglePlayer: 
      INC    LEVEL       ;5 LEVEL = LEVEL +1
.ContinueOnTheSameLevel: 
      LDA    LEVEL       ;3
      CMP    #$54        ;2 LEVEL = 84 ?
.NeverEndingLoop: 
 IF NTSC
      BEQ    .NeverEndingLoop  ; after 84 levels game crashes (if NTSC)
 ELSE
      NOP
      NOP           
 ENDIF

 

"IF NTSC" above should read "IF ORIGINAL", actually ;) Both versions exist for PAL and NTSC. The game-crashing loop appears in the binaries that include "(Imagic w-Picture Label)" as part of the filenames in ROM's set.

Originals.zip

Edited by Nukey Shay

Share this post


Link to post
Share on other sites

I should mention that the description "w-picture label" used in the filenames is also misleading. Rob altered the game when the picture label cart variation was in production...so all of the text label carts (I think) should feature the infinite loop, but it's still present in some of the picture label carts.

 

Look here:

http://www.atariage.com/forums/topic/161476-how-long-to-test-if-demon-attack-is-the-one-that-crashes/

Share this post


Link to post
Share on other sites

I started to do some experiments.

 

The original Demon Attack is a 4K cartridge.

 

It is possible to use the bank switch in order to double

the number of demons waves in a 8k Demon Attack.

 

At some point of the game I just switch to a different

bank where different graphics is available.

Just by chance this happens when the player wins an

extra life, because the sound music access to the final

addresses of the 4k, and eventually access to the

switch registers.

 

Furthermore, using the option of multiple players

(NUSIZE0-1) it is possible to multiply the number of

moving demons on screen.

 

Here attached you see an example (Scorpion is my

chosen brand for the games).

 

Please, consider that is just an experiment to

extend existing games, not a real game. ;)

 

A.

demon8k.zip

Share this post


Link to post
Share on other sites

I should mention that the description "w-picture label" used in the filenames is also misleading. Rob altered the game when the picture label cart variation was in production...so all of the text label carts (I think) should feature the infinite loop, but it's still present in some of the picture label carts.

 

Look here:

http://www.atariage.com/forums/topic/161476-how-long-to-test-if-demon-attack-is-the-one-that-crashes/

 

Ooops I forgot it was actually 84 levels, not 255 AND I forgot I asked this before in that other thread! Oh well, it's been nearly a year since I posted that one.

Must be getting old.

 

Thanks Nukey for the info!

Share this post


Link to post
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.

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...