forum.defence-force.org

Questions, bug reports, features requests, ... about the Oric Software Development Kit. Please indicate clearly in the title the related element (OSDK for generic questions, PictConv, FilePack, XA, Euphoric, etc...) to make it easy to locate messages.

In the above code (present in main.c on SVN, the "if" is on line 824) I want to make the "target" be the value of the global variable "canbetakenweight" (which is 4)
This does not work unless I EXPLICITLY assign it the value "4" (in the commented line).

Initially, I thought is was to do with mismatched char types (target is UNSIGNED and canbetakenweight is SIGNED but making them the same (unsigned) makes no difference.

By printing out the values of particular target locations (straight after being assigned the value of "canbetakenweight" which should be 4) we get different figures (e.g. 72). This drastically alters the behaviour of the program as "proper" higher value targets sometimes get ignored in favour of these spurious ones.

Anyone got any thoughts? (perhaps it's my coding and NOT the OSDK) but I just can't spot it and it's really slowing me down.

I can try to reproduce the problem when I am back home.
Could you try one thing: Declare the variable as a GLOBAL and check if it still misbehave. If it works then it probably means that there is a another bug in the stack frame handling (do you remember the bug with the function calls corrupting paramters when using printf?)

Conformity wise, lcc65 is pretty good, it behave pretty much like most other compilers used in the real world, so I would not really assume the bug is there.

Another possible candidate would be the macro expansion file that possibly does not generate correct 6502 code for this particular statement.

The variable is already defined as global but cannot be a constant as I intend to change it's value dynamically based on the game state. Other global variables seem to work OK and I can see nothing obviously wrong here.

@dbug
Yes, I remember the bug you mention and this is where I've got my money on at the moment. There are other puzzling aspects relating to game behaviour which I suspect may be related to this issue. Exhaustive dry running (using LOTS of paper and pencil) suggests to me that the logic is OK and is doing what I want it to but the reality is different...sometimes...