Jump to content

Photo

Demon Attack (source code)


10 replies to this topic

#1 az_network OFFLINE  

az_network

    Combat Commando

  • 5 posts

Posted Mon Jan 31, 2011 3:47 AM

Hi, here enclosed you find the commented source code of Demon Attack
for Atari 2600.

I enclose also a version of the same game with infinite lives.

Regards,

A.

Attached Files


  • diogoandrei likes this

#2 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 21,636 posts
  • Location:The land of Gorch

Posted Mon Jan 31, 2011 4:11 AM

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

  • az_network likes this

#3 az_network OFFLINE  

az_network

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Mon Jan 31, 2011 5:16 AM

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.

#4 az_network OFFLINE  

az_network

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Mon Jan 31, 2011 5:48 AM

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.

Attached Files



#5 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 21,636 posts
  • Location:The land of Gorch

Posted Mon Jan 31, 2011 6:16 AM

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 :)

#6 az_network OFFLINE  

az_network

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Mon Jan 31, 2011 1:34 PM

Thank you for the very clear explanation !!! :)

A.

#7 ComputerSpaceFan OFFLINE  

ComputerSpaceFan

    River Patroller

  • 2,123 posts

Posted Mon Jan 31, 2011 7:02 PM

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)

#8 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 21,636 posts
  • Location:The land of Gorch

Posted Tue Feb 1, 2011 1:17 AM

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.

Attached Files


Edited by Nukey Shay, Tue Feb 1, 2011 1:21 AM.


#9 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 21,636 posts
  • Location:The land of Gorch

Posted Tue Feb 1, 2011 1:57 AM

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....e-that-crashes/

#10 az_network OFFLINE  

az_network

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Tue Feb 1, 2011 2:59 AM

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.

Attached Files



#11 ComputerSpaceFan OFFLINE  

ComputerSpaceFan

    River Patroller

  • 2,123 posts

Posted Tue Feb 1, 2011 7:11 PM

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....e-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!




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users