AES Atlas: Earth's Last Hope (AKA weird twin-stick-shooter-ish game)

User avatar
Mihoshi20
Posts: 273
Joined: Tue Mar 06, 2018 11:47 pm

Re: AES Atlas: Earth's Last Hope (AKA weird twin-stick-shooter-ish game)

Post by Mihoshi20 » Tue Jun 05, 2018 7:46 am

I see what's going on now, which is even more interesting as you've worked around either a limitation in the tool which treats a press of Down Left as a Down or Left press which is a little annoying. But I did manage to get the movement and idle animation toggle to work.

In DumbDirectionChange.asm under DumbDirectionChange: near the very top of the file simply type ChangeObjectState #$01 right before the commented out section talking about Object_movement.

Same goes for releaseupdate.asm place ChangeObjectState #$00 directly under ReleaseUpdate:

This should re-enable the switching between idle animations and movement animations.
User avatar
TheNew8bitHeroes
Posts: 251
Joined: Fri Feb 16, 2018 9:24 pm
Location: Sarasota, FL
Contact:

Re: AES Atlas: Earth's Last Hope (AKA weird twin-stick-shooter-ish game)

Post by TheNew8bitHeroes » Tue Jun 05, 2018 2:17 pm

This is all amazing! :-)

Just also wanted to give you at least one branch out of range fix! (there are multiple ways to fix this)

Ok, so let's say you have a code, and it looks like this:

Code: Select all


      LDA someVariable ;; check the state of some variable
      CMP temp ;;; compare the value to some variable.
      BEQ skipAllTheCode ;;; if it equals the variable, skip all the code
      ;;;;;; if you're here, it means you DIDN'T skip the code.
      ;;;; do a bunch of things.
      LDA #$00
      STA something
      JSR doAlotOfThings
      RTS
skipAllTheCode:
      ;; bypassed all of those a lot of things
      RTS  


That will work fine. BUT, the position counter can't branch across a page (256 values beyond its current position in the code) using this method. So, for instance, this might be a problem...

Code: Select all


      LDA someVariable ;; check the state of some variable
      CMP temp ;;; compare the value to some variable.
      BEQ skipAllTheCode ;;; if it equals the variable, skip all the code
      ;;;;;; if you're here, it means you DIDN'T skip the code.
      ;;;; do a bunch of things.
      LDA #$00
      STA something
      JSR doAlotOfThings
      ;;;; a hundred other lines of code
      ;;;; two hundred lines of code...
      ;; now skipAllTheCode is FURTHER than the above BEQ can jump....thus, you get a branch out of range issue....
      RTS
skipAllTheCode:
      ;; bypassed all of those a lot of things
      RTS  


If something like this is the culprit and you need to fix it, here's an easy fix! Since the JMP command CAN jump beyond a page, you can INVERT the branch...like this:

Code: Select all


      LDA someVariable ;; check the state of some variable
      CMP temp ;;; compare the value to some variable.
 ;;;;===================================
      ;;;; INVERT THE BRANCH HERE...instead of checking if it's equal, check if it's NOT equal...
      BNE DONTskipAllTheCode ;; if it's NOT equal, you DO want to do the code...so we'll make a label where that code starts....
      JMP skipAllTheCode ;;; so now this means if it IS equal, in which case we want to JUMP to that label, which doesn't have the single code page limit.
 DONTskipAllTheCode: ;; this label now represents what happens if that variable was NOT zero.
 ;;;;==================================
      ;;;;;; if you're here, it means you DIDN'T skip the code.
      ;;;; do a bunch of things.
      LDA #$00
      STA something
      JSR doAlotOfThings
      ;;;; a hundred other lines of code
      ;;;; two hundred lines of code...
      ;; now skipAllTheCode is FURTHER than the above BEQ can jump....thus, you get a branch out of range issue....
      RTS
skipAllTheCode:
      ;; bypassed all of those a lot of things
      RTS  


That may fix the problem. As you add code to the middle of existing code, this tends to happen often. Does this make sense?
User avatar
Mihoshi20
Posts: 273
Joined: Tue Mar 06, 2018 11:47 pm

Re: AES Atlas: Earth's Last Hope (AKA weird twin-stick-shooter-ish game)

Post by Mihoshi20 » Tue Jun 05, 2018 4:07 pm

TheNew8bitHeroes wrote:
Tue Jun 05, 2018 2:17 pm
This is all amazing! :-)

Just also wanted to give you at least one branch out of range fix! (there are multiple ways to fix this)

Ok, so let's say you have a code, and it looks like this:

Code: Select all


      LDA someVariable ;; check the state of some variable
      CMP temp ;;; compare the value to some variable.
      BEQ skipAllTheCode ;;; if it equals the variable, skip all the code
      ;;;;;; if you're here, it means you DIDN'T skip the code.
      ;;;; do a bunch of things.
      LDA #$00
      STA something
      JSR doAlotOfThings
      RTS
skipAllTheCode:
      ;; bypassed all of those a lot of things
      RTS  


That will work fine. BUT, the position counter can't branch across a page (256 values beyond its current position in the code) using this method. So, for instance, this might be a problem...

Code: Select all


      LDA someVariable ;; check the state of some variable
      CMP temp ;;; compare the value to some variable.
      BEQ skipAllTheCode ;;; if it equals the variable, skip all the code
      ;;;;;; if you're here, it means you DIDN'T skip the code.
      ;;;; do a bunch of things.
      LDA #$00
      STA something
      JSR doAlotOfThings
      ;;;; a hundred other lines of code
      ;;;; two hundred lines of code...
      ;; now skipAllTheCode is FURTHER than the above BEQ can jump....thus, you get a branch out of range issue....
      RTS
skipAllTheCode:
      ;; bypassed all of those a lot of things
      RTS  


If something like this is the culprit and you need to fix it, here's an easy fix! Since the JMP command CAN jump beyond a page, you can INVERT the branch...like this:

Code: Select all


      LDA someVariable ;; check the state of some variable
      CMP temp ;;; compare the value to some variable.
 ;;;;===================================
      ;;;; INVERT THE BRANCH HERE...instead of checking if it's equal, check if it's NOT equal...
      BNE DONTskipAllTheCode ;; if it's NOT equal, you DO want to do the code...so we'll make a label where that code starts....
      JMP skipAllTheCode ;;; so now this means if it IS equal, in which case we want to JUMP to that label, which doesn't have the single code page limit.
 DONTskipAllTheCode: ;; this label now represents what happens if that variable was NOT zero.
 ;;;;==================================
      ;;;;;; if you're here, it means you DIDN'T skip the code.
      ;;;; do a bunch of things.
      LDA #$00
      STA something
      JSR doAlotOfThings
      ;;;; a hundred other lines of code
      ;;;; two hundred lines of code...
      ;; now skipAllTheCode is FURTHER than the above BEQ can jump....thus, you get a branch out of range issue....
      RTS
skipAllTheCode:
      ;; bypassed all of those a lot of things
      RTS  


That may fix the problem. As you add code to the middle of existing code, this tends to happen often. Does this make sense?
Hmm, interesting and really good to know and to keep in mind when diving into the code. I can't recall the exact terminology for the CPU time it takes to execute a line of asm code but I imagine when you say the countercan't go over 256 you're meaning that. Luckily though an easy implementation could be found that worked as before I was trying to add it to each direction check which I'm glad didn't work as it would have massively bloated the code and CPU cycles. But it's still good to get familiar with the NES' quirks as I'm really not used to at all working this close to the hardware and without an OS middleman. It's been a really fun exercise all around.
Post Reply