Post by Deleted on Oct 11, 2017 14:59:00 GMT -5
This has been discussed in at least two topics in the far past. One is here: devster.proboards.com/thread/1134/word-branch-out-range-rolango
I'm at zero hour on a deadline and it's been popping up like crazy. I think I found some techniques to work around it until all my projects are moved over to SecondBASIC.
1. IMMEDIATELY after your options statements GOTO a "pre initialize" label. After that GOTO statement put your functions.
2. The "pre initialize" label should contain your DIM and CONST statements. After that GOTO your label for your init section.
3. After that GOTO statement skipping to your init section put your code that accesses functions.
It seems like the distance in lines between the actual function and the line that calls that function is critical. Too many lines of code between the function and calling the function %99.99 triggers the word of of range bug.
I hope this helps others tearing their hair out due to these issues.
Here is a partial snippet of the style I'm describing:
I'm at zero hour on a deadline and it's been popping up like crazy. I think I found some techniques to work around it until all my projects are moved over to SecondBASIC.
1. IMMEDIATELY after your options statements GOTO a "pre initialize" label. After that GOTO statement put your functions.
2. The "pre initialize" label should contain your DIM and CONST statements. After that GOTO your label for your init section.
3. After that GOTO statement skipping to your init section put your code that accesses functions.
It seems like the distance in lines between the actual function and the line that calls that function is critical. Too many lines of code between the function and calling the function %99.99 triggers the word of of range bug.
I hope this helps others tearing their hair out due to these issues.
Here is a partial snippet of the style I'm describing:
' OPTIONS
option TEXTSTART, 0, 0
option TEXTHEIGHT, 28
option TEXTWIDTH, 40
option TEXTPRIORITY, LOW
option FONTBACKENTRY, 0
option NoLoadFont
option TITLE, "Example"
vidmode VID40CELL
goto pre_init
' FUNCTIONS
declare function rectRect(x1 as integer, y1 as integer, x2 as integer, y2 as integer, x3 as integer, y3 as integer, x4 as integer, y4 as integer) as integer
if x1 > x4 then return 0
if x2 < x3 then return 0
if y1 > y4 then return 0
if y2 < y3 then return 0
return 1
end function
pre_init:
' load Z80 XGM driver
z80_loadDriver
dim rotate(16) as integer at table_rotate
dim collision_player1_enemy1 as integer
' CONSTANTS
const #PCMLongitude = 27000
goto init
colcheck:
collision_player1_enemy1 = rectRect(player1x,player1y,(player1x+32),(player1y+32),enemy1x,enemy1y,(enemy1x+32),(enemy1y+32))
goto after_colcheck
' INIT
init:
pcmid& = 64