Coding

 Reply to this postStart new topic

Jump to 0 offset

Deji
post Feb 22 2010, 11:15 PM
Post #1


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Jump To 0 Offset


The infamous "Jump to 0 offset" bug is usually noticed either by Sanny reporting it upon an attempt at compiling or when the game restarts from the beginning without ending the current:




Fix


This is caused by not naming a thread with:

SANNY
03A4: name_thread 'NAME'



However. Since every thread has to be named different and there is a chance of 2 CLEO threads ending up with the same name (and therefore crashing or bugging the game)... A workaround was found.


Instead of using 03A4... Use:

CODE
0000: NOP


At the beginning of your script... Before any other opcode.


Easy.


--------------------
Go to the top of the page
 
+Quote Post
Mora Hannover
post Nov 6 2014, 02:11 PM
Post #2


Ameteur Member

Posts: 42
Joined: 3-November 14



but that won't work in SCM scripts. I noticed that if like i made :NIKO at the first of the script and at the middle of the script i do jump @NIKO then this occurs. It happens to me because i do some errors while typing.


--------------------
Rest in Peace Yeardley Diamond (Dec. 21, 1985 - Aug. 20, 2014)
Rest in Peace Kitty0706 (1994 - Jan. 25, 2015)
Go to the top of the page
 
+Quote Post
Deji
post Nov 7 2014, 01:10 PM
Post #3


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



OLD topic. The real reason is simply because you're not allowed to jump to the very first (0th) byte of non-main scripts. The engine works out offsets based on whether they're above or below 0. If it's below 0, the offset will be negated and added to the base of the current script address. If it's 0 or above, the offset will be used relative to the MAIN segment (entire main.scm file), which of course means that if you jump to 0, you'll jump to the start of the main.scm. That's why naming the thread or adding any other code before the earliest point you jump to fixes the problem.


--------------------
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

5 User(s) are reading this topic (5 Guests and 0 Anonymous Users)
0 Members: