Author Topic: Return Isn't Saved Correctly - Why?  (Read 4110 times)

fxar99

  • Enlightened One (+200)
  • *
  • Posts: 232
  • Oh how I wish to dream again...
    • View Profile
Return Isn't Saved Correctly - Why?
« on: January 21, 2006, 07:44:58 am »
I have added an NPC in Millenial Fair. When he is activated, he shows a decision box.

I write and save this:


But when I reload, I see this:


In case you don't see any difference, the Return command changes its level. Instead of going to Activate, it goes to If. Why??

Agent 12

  • Zurvan Surfer (+2500)
  • *
  • Posts: 2572
    • View Profile
Return Isn't Saved Correctly - Why?
« Reply #1 on: January 21, 2006, 12:39:35 pm »
The second way doesn't hurt since after (if result ==3) the next line of code is the return anyways. Plus with the second way your game isn't going to freeze if the result is neither 0,1,2,3 (I know it's not possible but for debugging purposes you want it to return no matter what.

you could probably do this

if result ==3
----return
return


have two returns...

--jp

fxar99

  • Enlightened One (+200)
  • *
  • Posts: 232
  • Oh how I wish to dream again...
    • View Profile
Return Isn't Saved Correctly - Why?
« Reply #2 on: January 21, 2006, 02:55:14 pm »
Quote from: jsondag2

if result ==3
----return
return


have two returns...

--jp


I've tried it, it doesn't work. Actually, any command I put in the end of Activate goes to If Return == 3 instead.

Agent 12

  • Zurvan Surfer (+2500)
  • *
  • Posts: 2572
    • View Profile
Return Isn't Saved Correctly - Why?
« Reply #3 on: January 21, 2006, 09:45:01 pm »
have you tried putting two returns then highlighting one of them and clicking promote??

--jp

fxar99

  • Enlightened One (+200)
  • *
  • Posts: 232
  • Oh how I wish to dream again...
    • View Profile
Return Isn't Saved Correctly - Why?
« Reply #4 on: January 22, 2006, 05:45:40 am »
Quote from: jsondag2
have you tried putting two returns then highlighting one of them and clicking promote??

--jp



I've tried it. I make the code as shown in the first picture by any means possible, then Update, Write Memory, Save. And when I reload, the same.

I want so much to put Return to the first level, because I suspect that its wrong position is the cause of a bug that occurs when I test my NPC. The bug is as follows: When I talk to the NPC and select Yes in his first decision box, he shows a list with all the songs of the ROM. It can show only
Previous Page
Song 1
Song 2
Next Page

Every page can show up to two songs if I want to keep the previous page feature (and I'm not willing to rewrite the list all over, just to remove that). So, the code was too large and had too many If statements. Temporal Flux seemed not to like this and saved the code after a certain level back to the first level. The solution I thought to solve this problem was to put code in an Arbitrary function and link from Activate to that one and back. However, for some reason I don't understand, after Activate completes, that arbitrary is run. I suspect this is because Return isn't set properly so that's the reason I want to put it at the first level.

Geiger

  • Guru of Life Emeritus
  • Chronopolitan (+300)
  • *
  • Posts: 315
    • View Profile
    • Geiger's Crypt
Re: Return Isn't Saved Correctly - Why?
« Reply #5 on: January 23, 2006, 03:20:24 am »
In case you don't see any difference, the Return command changes its level. Instead of going to Activate, it goes to If. Why??

It should not.  Cannot explain why it would be, since if statement ranges are determined by what is actually in the tree, and not just random number crunching.  Can you post a Flux file please?

---T.Geiger

fxar99

  • Enlightened One (+200)
  • *
  • Posts: 232
  • Oh how I wish to dream again...
    • View Profile
Return Isn't Saved Correctly - Why?
« Reply #6 on: January 23, 2006, 09:14:07 am »
The files created by Flux are here.

The patch that modifies the original (unheadered) ROM to my add-on is here.

[TC:\_]

ZeaLitY

  • Entity
  • End of Timer (+10000)
  • *
  • Posts: 10797
  • Spring Breeze Dancin'
    • View Profile
    • My Compendium Staff Profile
Return Isn't Saved Correctly - Why?
« Reply #7 on: January 23, 2006, 11:00:58 am »
I think what he means is that you should export the actual event packet for the location you're editing. It'll come out as a .Flux file; just drop down from File and hit Export. Remember that the event packet uses its own set of digits apart from the Location number (like 001 Crono's Kitchen uses map 3C, etc.)

fxar99

  • Enlightened One (+200)
  • *
  • Posts: 232
  • Oh how I wish to dream again...
    • View Profile
Return Isn't Saved Correctly - Why?
« Reply #8 on: January 24, 2006, 12:50:18 pm »
Oh, I hadn't noticed that function, sorry. Obviously, this is the first time I'm using it, so I may have made a mistake. Anyway, it's here.

If I've made any mistakes with the .flux file, please use the IPS patch in my previous post to turn the ROM into what I have.

[TC:\_]

Geiger

  • Guru of Life Emeritus
  • Chronopolitan (+300)
  • *
  • Posts: 315
    • View Profile
    • Geiger's Crypt
Return Isn't Saved Correctly - Why?
« Reply #9 on: January 24, 2006, 10:10:04 pm »
I am adding this to the bugtracker now.  It may be awhile before I release another update.

In the meantime, have you tried putting the return in Arb0?

---T.Geiger

fxar99

  • Enlightened One (+200)
  • *
  • Posts: 232
  • Oh how I wish to dream again...
    • View Profile
Return Isn't Saved Correctly - Why?
« Reply #10 on: January 29, 2006, 04:08:28 am »
Quote from: Geiger
In the meantime, have you tried putting the return in Arb0?


I just tried it. Take a look at the following pictures:

Again, I have this then Update, Write Mem., Save


And when I reload, it has turned into this:


[TC:\_]

Geiger

  • Guru of Life Emeritus
  • Chronopolitan (+300)
  • *
  • Posts: 315
    • View Profile
    • Geiger's Crypt
Return Isn't Saved Correctly - Why?
« Reply #11 on: January 29, 2006, 06:46:43 am »
That one is not really a bug.  More of a "I-did-not-tell-you-something-was-wrong-with-your-code".

Gotos have a max range of 0xFF, or 255 bytes.  Your code between the goto and return is 0x106 and 0xFA bytes respectively.  The second one is in range and works.  The first one is out of range and is clipped 0x100 bytes.  There should probably be a warning when the code is processed like if you have a bad label.

For your specific example, since you are merely returning, and not doing anything else after the jump, I would strongly suggest replacing Goto with Return, even if this were working correctly (or rather, more correctly).  Goto is two bytes while return is only one.

Course, if you were wanting to do something different, like muting the music before exiting, this would not work very well.  For code this massive, you would probably have to use up an arbitrary pointer.  I cannot think of anything else that can do a jump larger than 0xFF bytes for Location Events.

---T.Geiger