Jump to content
Sign in to follow this  
Nukey Shay

Demon Attack crash

Recommended Posts

While looking though the disassembly of this, I was surprised to find an endless loop coded into the game. It's a branch that loops to itself at $x482 when the game level reaches a value of $54 (level 85). Since the routines that deal with the game level seem to be able to handle any value, I'd imagine that these 2 bytes could just be NOP'ed over...but I dunno about any other glitches that might happen as a result of values greater than $83 being used...I'm not at all good at this game to find out ;)

Instead, I just found other bytes that could be cut out to provide space for a patch. Here's the original routine:

 

L147C: INC  $BE     ;increase the game level
L147E: LDA  $BE     ;...and give to the accumulator
       CMP  #$54    ;did it go past level 84?
L1482: BEQ  L1482    ;branch if so (endlesss loop)

 

 

...and a possible correction:

L147C: INC  $BE     ;increase the game level
L147E: LDA  $BE     ;...and give to the accumulator
       CMP  #$54    ;did it go past level 84?
       BNE  L1482    ;branch if not
       LDA  $#00    ;clear the counter
       STA  $BE     ;...and save
L1482:
;program continues...

 

Any theories as to why this endless loop had been put in by Imagic? :?

 

This binary is also Supercharger-compatable.

DemonAttack_fixed_.zip

Share this post


Link to post
Share on other sites

The game becomes much easier if you use guided shots.

 

The infinite loop may have been intentional, the simplest way of telling the player that the game was beaten, not unlike hitting level 255 in Pac-Man.

 

I can't remember if it was level 85 (I wasn't exactly keeping count), but I do recall that deep into the game, the colors of the aliens looked like they were getting ready to recycle themselves. Then, when I thought I was about to see the level-1 aliens in their original, level-1 colors, the game blanked. I assumed that was supposed to be the "end" of the game.

Edited by skunkworx

Share this post


Link to post
Share on other sites
The game becomes much easier if you use guided shots.

 

The infinite loop may have been intentional, the simplest way of telling the player that the game was beaten, not unlike hitting level 255 in Pac-Man.

 

I can't remember if it was level 85 (I wasn't exactly keeping count), but I do recall that deep into the game, the colors of the aliens looked like they were getting ready to recycle themselves.  Then, when I thought I was about to see the level-1 aliens in their original, level-1 colors, the game blanked.  I assumed that was supposed to be the "end" of the game.

890506[/snapback]

 

That's the big problem with this branch. If it was to be intentional (which I'm not sure about), it would have been better to have the game flip the game over status on (that way, the game screen wouldn't disappear and you could still read the score). Shouldn't take any additional romspace to accomplish that way rather than the original routine. My theory is that the branch was to jump to a routine that already included this function...but it was perhaps moved out of range during development (so it was altered to be an endless loop so that the WIP game would at least assemble)...but then forgotten about instead of being corrected when it was put into production.

 

Current hack assembly:

By rewriting the sound routine jumps a bit, I eliminated the 2 tables holding those indirect address tables (in addition to those PHA/RTS routines the place them into the stack). This saved a fair share of space, so I added pause routines. Ram hasn't been sorted out yet, so it can't keep track of "flip status" on the 7800 (so the pause function currently only works while B&W is selected). In the assembly, each of the sound routines is indicated, as well as the values that each uses. So by playing around with the instructions in them, different sounds can be created (the 3 added pause routines are indicated...just in case more space is needed just comment them out). Still working at freeing more space so that the function works with a 7800 as well ;)

Edited by Nukey Shay

Share this post


Link to post
Share on other sites

Ron Fulop Interview

DP: The manual mentions that after 84 waves, the game stops.

 

Fulop: That's an interesting story. I thought no one would ever "wrap" the game. I actually programmed it so, at the end of the game, if you beat the demons, they would just turn off. Two days after the game was released, some kid wrapped it. After the initial run of carts, I went back and took the "bug" out. I changed one line of code. I made it so you can play the game forever, but it never gets harder past the 84th wave.

Share this post


Link to post
Share on other sites

Hm...didn't know that. IMO it's pretty sloppy programming to intentionally let the game freeze up where you can't even see what your score was :(

 

Corrupted zipfile above...repost:

DemonAttack_fixed_.zip

Edited by Nukey Shay

Share this post


Link to post
Share on other sites

BTW as an example of changing the game sounds, here's how to make the hit demons produce an explosion-sound. The original routine is here:

L134F:
      LDX    #$08                   ;2 set volume
      LDY    $D0                    ;3 fetch current index
      INC    $D0                    ;5 ...and bump for next time
      LDA    L1E00,Y                ;4 get pitch value using that index
      AND    #$07                   ;2 (keep only the last 3 bits)
      BPL    L137F                  ;2 and branch to set the distortion & play the sound

 

 

The player explosion sound is here:

L12A7:
      LSR                           ;2
      LSR                           ;2
      TAX                           ;2 set the volume = A/4
      LDA    $99                    ;3 get current pitch
      AND    #$1F                   ;2 keep only the last 5 bits
      LDY    #$08                   ;2 white noise distortion
      BNE    L12D2                  ;2 branch to play the sound

 

 

By copying that routine a bit, you can make better-sounding explosion effects when enemies are shot:

 

L134F:
      LDA    $D0                    ;3 get current pitch
      TAX                           ;2 set the volume
      INC    $D0                    ;5 ...and bump for next time
      EOR    #$0A                   ;2 mix it up a bit
      LDY    #$08                   ;2 set white noise distortion
      BPL    L1388                  ;2 and branch to play the sound
      NOP                           ;2 unused
      NOP                           ;2 unused

 

 

 

Small gainers:

At L1383, the falling bird sound routine can be altered a bit by changing that LDA L1F96,X instruction into EOR #$0F. That instruction takes 1 byte less space...and also saves an additional 12 bytes (table L1F96). It -almost- sounds the same.

 

 

The player ship GFX table can be shared with the color data in the last page. The 12 bytes -almost- match...that saves an additional 12 bytes:

 

       .byte $C6; |XX   XX | $1FC6
      .byte $C6; |XX   XX | $1FC7
      .byte $C6; |XX   XX | $1FC8
      .byte $C6; |XX   XX | $1FC9
      .byte $EE; |XXX XXX | $1FCA
      .byte $EE; |XXX XXX | $1FCB
      .byte $6C; | XX XX  | $1FCC
      .byte $6C; | XX XX  | $1FCD

;changed these:
;       .byte $46; | X   XX | $1FCE
;       .byte $46; | X   XX | $1FCF
;       .byte $46; | X   XX | $1FD0
;       .byte $46; | X   XX | $1FD1

;...to these
      .byte $28; |  X X   | $1FCE
      .byte $28; |  X X   | $1FCF
      .byte $28; |  X X   | $1FD0
      .byte $28; |  X X   | $1FD1

 

Then you can paste label L1D88 to be there instead.

Share this post


Link to post
Share on other sites

The game now pauses on a 7800 as well. By moving a few instructions, I was able to reuse the temp ram pointers devoted to displaying the score digits for the rest of the display as well (i.e. demon GFX and missile pointers/colors). This saved 8 bytes of ram. One of them I set to be a copy of SWCHB (in order to perform a previous frame compare), and 2 bits of another was used to hold the B&W/Color flip status and the console type. 46 bytes of rom remain free (at the end of the binary), as well as ram locations $C0, $C1, $C2, $C3, $CD, $CE, and the lower 6 bits of $D4.

DemonAttack_fixed_.zip

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