I have been trying to simplify things by moving as many function calls inside macros as I can and move away from manually loading function inputs into registers before calling the function, etc. since these things don't cost any CPU time to do from a macro. It seems though that I'm getting incorrect results whenever the macro parameters are not just bare symbols. The example is from a list file where I am demonstrating the issue:
My macro sfx is supposed to load the X register with the immediate value and then call the function. Other than the sfx ID I can also specify which sound channels I want to use, so the channel flag constants need to be ORd with the sound ID. This produces incorrect results, and it does not matter if I put an extra layer by providing my input in a local symbol either (the local symbol takes on the correct value of 0x81). I initially tried sfx sfx_denied_thump|param_sfx_pulse but that does the same thing, resulting in 0x83 getting loaded into the X register. Even just putting sfx sfx_denied_thump without expressions resolves to ldx #sfx_confirm|param_sfx_pulse even though there was no OR with anything.
For clarity here are the definitions of the macro and the sound IDs:
I have been trying to simplify things by moving as many function calls inside macros as I can and move away from manually loading function inputs into registers before calling the function, etc. since these things don't cost any CPU time to do from a macro. It seems though that I'm getting incorrect results whenever the macro parameters are not just bare symbols. The example is from a list file where I am demonstrating the issue:
My macro
sfx
is supposed to load the X register with the immediate value and then call the function. Other than the sfx ID I can also specify which sound channels I want to use, so the channel flag constants need to be ORd with the sound ID. This produces incorrect results, and it does not matter if I put an extra layer by providing my input in a local symbol either (the local symbol takes on the correct value of 0x81). I initially triedsfx sfx_denied_thump|param_sfx_pulse
but that does the same thing, resulting in 0x83 getting loaded into the X register. Even just puttingsfx sfx_denied_thump
without expressions resolves toldx #sfx_confirm|param_sfx_pulse
even though there was no OR with anything.For clarity here are the definitions of the macro and the sound IDs:
So I don't know how to proceed with using macros for anything other than very simple things. Any help is appreciated!