Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro parameters not handling any expressions #58

Open
Vuurniac opened this issue Jun 3, 2024 · 0 comments
Open

Macro parameters not handling any expressions #58

Vuurniac opened this issue Jun 3, 2024 · 0 comments

Comments

@Vuurniac
Copy link

Vuurniac commented Jun 3, 2024

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:

09F13                           		@thing = sfx_denied_thump|param_sfx_pulse
09F13 A2 81                     	ldx #@thing
09F15                           		sfx @thing
09F15                                      ; Start sfx ID 0-31 with attribute flags 2,N,P
09F15 A2 83                     	ldx #sfx_confirm|param_sfx_pulse
09F17 20 3B 9A                  	jsr InitSfx

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:

	                            .macro sfx input
	                            ; Start sfx ID 0-31 with attribute flags 2,N,P
	                            	ldx #input
	                            	jsr InitSfx
	                            .endm
	                            	param_sfx_pulse = %10000000
	                            	param_sfx_noise = %01000000
	                            	param_sfx_prio	= %00100000 
092DB                           .enum 0
00000                           	; sfx IDs
00000                           	sfx_text0			.dsb 1
00001                           	sfx_denied_thump	.dsb 1
00002                           	sfx_mvsel			.dsb 1
00003                           	sfx_confirm			.dsb 1
00004                           	sfx_numberofsounds	.dsb 1
00005                           
00005                           		.if sfx_numberofsounds >= 32
00005                           			.error More sound effects than supported.
00005                           		.endif	
00005                           .ende

So I don't know how to proceed with using macros for anything other than very simple things. Any help is appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant