Language…
18 users online: Adsila, Batata Douce, Blizzard Buffalo, David_Odie, Doopu,  Eden_, Ekimnoid, Hammerer, HD_DankBaron, LadiesMan217, LightAligns, LuigiTron, Maniek, masl, MorrieTheMagpie, ppp9q,  Ringo, sinseiga - Guests: 247 - Bots: 312
Users: 64,795 (2,375 active)
Latest user: mathew

Custom trigger and Custom manual is not work in higan/BSNES

I modified Mario vs. DK Switches and Blocks to be SA-1 compatible.
This code doesn't work on BSNES/Higan, it works fine on other emulators. Is there a way to get this to work in Higan/BSNES?
Code
;Act as $025

(skip)
	LDA !ManuelTrigger	;\if corresponding color not match, !ManuelTrigger = $7FC070
	CMP #$01		;|then return.
	BNE return		;/

	LDY #$01
if !ledge = 0
	LDA #$30
else
	LDA #$00
endif
	STA $1693|!addr
return:
RTL

if !ledge = 0
print "Solid if the corresponding switch is activated."
else
print "Ledge if the corresponding switch is activated."
endif


Also, LM 1.7+ Trigger Blocks has the same problem.
The issue is that the Lunar Magic Exanimation trigger addresses are in bank $7F, which can't be accessed by the SA-1 cpu, and blocks run on it by default. This means that you need to invoke the SNES cpu in order to access those addresses. You can find the code to do this in PIXI's sa1def.asm.
In this case you can change the code like this:
Code
macro invoke_snes(addr)
	LDA.b #<addr>
	STA $0183
	LDA.b #<addr>/256
	STA $0184
	LDA.b #<addr>/65536
	STA $0185
	LDA #$D0
	STA $2209
-	LDA $018A
	BEQ -
	STZ $018A
endmacro

(skip)

if !sa1
	%invoke_snes(stuff)
else
	JSL stuff
endif
	LDA $00
	CMP #$01		;|then return.
	BNE return		;/

	LDY #$01
if !ledge = 0
	LDA #$30
else
	LDA #$00
endif
	STA $1693|!addr
return:
	RTL

stuff:
	LDA !ManuelTrigger	;\if corresponding color not match, !ManuelTrigger = $7FC070
	STA $00
	RTL

Note that the code that uses the Exanimation address needs to be moved to a JSL subroutine in order for the SNES invoke to work. In this case the value is saved to scratch ram so it can be accessed from the SA-1 cpu when it returns. The SA-1 check at the start is needed just if you want the block to be SA-1 hybrid rather than SA-1 only (otherwise the macro will likely make the game crash if used on lorom).
Originally posted by Kevin
The issue is that the Lunar Magic Exanimation trigger addresses are in bank $7F, which can't be accessed by the SA-1 cpu, and blocks run on it by default. This means that you need to invoke the SNES cpu in order to access those addresses. You can find the code to do this in PIXI's sa1def.asm.
In this case you can change the code like this:
Code
macro invoke_snes(addr)
	LDA.b #<addr>
	STA $0183
.............
	RTL

Note that the code that uses the Exanimation address needs to be moved to a JSL subroutine in order for the SNES invoke to work. In this case the value is saved to scratch ram so it can be accessed from the SA-1 cpu when it returns. The SA-1 check at the start is needed just if you want the block to be SA-1 hybrid rather than SA-1 only (otherwise the macro will likely make the game crash if used on lorom).




Is it correct to put 'macro invoke_snes(addr)' above? or Routine folder?
This will result in an error.

And additional questions:

Code
	LDA #!Manuelflag	;\set flag.
	STA !ManuelTrigger	;/

How do I change this?

This is the code in 'ButtonSwitch_Red.asm'. Here, '#$02' is replaced with '#!Manuelflag', and '!Manuelflag = $02' is written at the top.
Originally posted by Hayashi Neru
Is it correct to put 'macro invoke_snes(addr)' above? or Routine folder?
This will result in an error.

If you want the macro to be available in every block, you can copy it in the "defines.asm" file. Putting it in routines won't work, I think. What error are you talking about?

Originally posted by Hayashi Neru
And additional questions:

Code
	LDA #!Manuelflag	;\set flag.
	STA !ManuelTrigger	;/

How do I change this?

This is the code in 'ButtonSwitch_Red.asm'. Here, '#$02' is replaced with '#!Manuelflag', and '!Manuelflag = $02' is written at the top.

Same thing, you put that in a subroutine and call it in the block's code like this:
Code
%invoke_snes(SetFlag)
...other block code

SetFlag:
	LDA #!Manuelflag	;\set flag.
	STA !ManuelTrigger	;/
	RTL

Also note that you only need to do this in blocks and sprites, but not UberASM code, since UberASM runs on the SNES by default.
The error means that the block cannot be inserted into the rom with GPS.

For reference, this is what happens if put the macro code in define.asm.
Code
shared.asm:73: error: (E5095): Macro 'invoke_snes' redefined.


defines.asm
Code
; Feel free to add more if you want.

incsrc powerup_defs.asm		;this ROM using lx5's custom power ups.

namespace nested on

!sa1 = 0			; SA-1 flag
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
macro assert_lm_version(version, define)
	!lm_version #= ((read1($0FF0B4)-'0')*100)+((read1($0FF0B6)-'0')*10)+(read1($0FF0B7)-'0')
	if !lm_version >= <version>
		!<define> = 1
	else
		!<define> = 0
	endif
endmacro

macro invoke_snes(addr)
	LDA.b #<addr>
	STA $0183
	LDA.b #<addr>/256
	STA $0184
	LDA.b #<addr>/65536
	STA $0185
	LDA #$D0
	STA $2209
-	LDA $018A
	BEQ -
	STZ $018A
endmacro

%assert_lm_version(257, "EXLEVEL") ; Ex level support
...........
Originally posted by Hayashi Neru
The error means that the block cannot be inserted into the rom with GPS.

For reference, this is what happens if put the macro code in define.asm.
Code
shared.asm:73: error: (E5095): Macro 'invoke_snes' redefined.


defines.asm
Code
; Feel free to add more if you want.

incsrc powerup_defs.asm		;this ROM using lx5's custom power ups.

namespace nested on

!sa1 = 0			; SA-1 flag
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
macro assert_lm_version(version, define)
	!lm_version #= ((read1($0FF0B4)-'0')*100)+((read1($0FF0B6)-'0')*10)+(read1($0FF0B7)-'0')
	if !lm_version >= <version>
		!<define> = 1
	else
		!<define> = 0
	endif
endmacro

macro invoke_snes(addr)
	LDA.b #<addr>
	STA $0183
	LDA.b #<addr>/256
	STA $0184
	LDA.b #<addr>/65536
	STA $0185
	LDA #$D0
	STA $2209
-	LDA $018A
	BEQ -
	STZ $018A
endmacro

%assert_lm_version(257, "EXLEVEL") ; Ex level support
...........

Oh it looks like that macro was added to GPS recently, so yeah you dont need to add it again.
If remove that macro, getting this error:

Code
blocks/manualtrigger/blockred.asm:25 (called from blocks/manualtrigger/blockred.asm:25): error: (E5101): Wrong number of parameters to macro. [%invoke_snes(stuff)]


Ok I checked and GPS didn't actually add that macro recently so you probably have it from some other resource that I don't know, either way I guess copy the one I posted in defines.asm but change the name like "macro invoke_snes2(...)" and call it like "%invoke_snes2(label)".
Found why macro 'macro invoke_snes(...)' didn't work. It's because I made a silly mistake. The mistake was putting the macro in the 'routines' folder. If I delete the macro from that folder, it works. (Tested in Higan)
Thanks for your help.
Oh okay, I guess GPS inserts it anyway but it messes up... anyway I'm glad it works. The reason why this isn't a problem on Snes9x is that it's not very accurate with SA-1 especially, so accesses to ram in banks $7E-$7F on SA-1 is allowed.