A Little Coding Problem that's Driving me Mad

gadgets

Resource contributor
#1
Question of the day. Why won't the counter "pclTimer" increment. It appears to remain at 1 after initialization and after the transponder code is changed to other than "0066". I've been looking at this code for two days now (and it hasn't helped). I guess I'm "too close to the forest to see the trees".

Don
db 'R','I','F','F' ; RIFF file identifier
dd bgl_data_end - $ - 4 ; size of RIFF data
db 'M','D','L','9' ; file identifier (FS9 model)
db 'M','D','L','H'
dd visual_model_header_end - $ - 4
dd visual_model_header_end - $ - 4
dd 0
dd 0
dd 10
dd 0
dd 0
dd 152
db 'F','S','8','0'
dd 2304
visual_model_header_end label dword
db 'I','S','F','T'
dd ver_end - $ - 4
db "Airfield Lights Toolkit 1.1.00(h)",0
ver_end label word
db 'B','B','O','X'
dd bounding_box_riff_end - $ - 4
real4 -0.5, 0.0, -0.5
real4 0.5, 1.0, 0.5
bounding_box_riff_end label word
db 'E','X','T','E'
dd exterior_riff_end - $ - 4
db 'B','G','L',' '
dd bgl_riff_end - $ - 4
JUMP startBGL_Lights
localVars label word
localVars_PCL label word
pclFlag label word
dw 0
pclTimer label word
dw 0
pclTable label word
dw 2
dw 0, 1, 999, 1000
startBGL_Lights label BGLCODE
VAR_BASE_32 VAR_BASE_GLOBAL
IFIN1 timeLights, trans_freq, 066h, 066h ; lights to be on when code "0066" selected
startTimer label BGLCODE
LOCAL_BASE_32 localVars_PCL
SETWRD offset pclTimer - localVars_PCL, 1 ; start the counter <----- INITIALIZATION
JUMP drawBGLLight
timeLights label BGLCODE
LOCAL_BASE_32 localVars_PCL
IFIN1 chkOperatingHours, offset pclTimer - localVars_PCL, 1, 540 ; 0-15 minutes
VAR_BASE_OVERRIDE VAR_BASE_GLOBAL
IFMSK skipCount, BGL_TICK18, 01h ; add one to the count every second tick
IFIN1 drawBGLLight, offset pclFlag - localVars_PCL, 0, 0 ; flag skips the counter until tick18 completes cycle
BGL_INTERPOLATE VAR_BASE_LOCAL, offset pclTimer - localVars_PCL, VAR_BASE_LOCAL, offset pclTimer - localVars_PCL, VAR_BASE_LOCAL, offset pclTable - localVars_PCL
SETWRD offset pclFlag - localVars_PCL, 1
JUMP drawBGLLight
skipCount label BGLCODE
VAR_BASE_32 VAR_BASE_LOCAL
SETWRD offset pclFlag - localVars_PCL, 0 ; reset the flag
JUMP drawBGLLight
chkOperatingHours label BGLCODE
insideOperatingHours label BGLCODE
VAR_BASE_32 VAR_BASE_GLOBAL
IFIN1 lightsOff, tod, 2, 4 ; if not daytime
drawBGLLight label word
VAR_BASE_32 VAR_BASE_GLOBAL
BGL_LIGHT BGL_LIGHT_TYPE_SMALL_HALO, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0C0C0C0h, 0.0, 0.0, 0.0
BGL_LIGHT BGL_LIGHT_TYPE_SMALL_HALO, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0C0C0C0h, 0.0, 0.0, 0.0
endLightsOn label word
lightsOff label word
end_BGL_LIGHTs label word
BGL_END
BGL_RETURN
bgl_riff_end label BGLCODE
exterior_riff_end label BGLCODE
bgl_data_end label BGLCODE
 
Last edited:

gadgets

Resource contributor
#2
And the answer is, it doesn't appear that the BGL_INTERPOLATE can be used to effect an up-counter simply by reversing the values in the "standard" count-down table. Once I restored count-down operation, all was well. Who knew???

Don
 
Top