Language…
5 users online: Henrique98, Ice Man, Jamie, Lizard_433, Samantha - Guests: 1,351 - Bots: 105
Users: 67,694 (2,004 active)
Latest user: Sable Mage

Pass Coin Block by Nitrocell Inc.

File Name: Pass Coin Block
Submitted: by Nitrocell Inc.
Authors: Nitrocell Inc.
Act As: 025 or 130
Includes GFX: No
Description: This block lets you pass if you have enough coins (specified inside code). Also, you have one ready 50 coins block that requires no code editing (for mates who hate ASM). More clear guide how to change coin amount see inside readme.txt.
Tags: coin block, coin count, coin counter, coins, sa-1
Screenshots:
Tested with:
* Lunar Magic 3.31
* GPS 1.4.4
* SA-1 Pack 1.40
* Mesen-S 0.4.0

There's only a single issue that made me reject this... you set to the sound effect port every frame, which causes any other sound effect in that port to be cancelled out (for example yoshi's tongue and L/R camera scrolling) i think that's pretty significant.

But i want to talk about some stuff first;
Code
!ActAs130 = #$30
!ActAs25 = #$25
!HighByteY = #$01

!CoinsAmount = #$01			; Change this to amount you want (#$00 = 0 Coins)
!CoinsEqAmountSound = #$29		; Change this to desired sound if Mario has enough coins (See AddmusicK's sound list)
!CoinsNotEqMatchesSound = #$2A		; Change this to desired sound if Mario HASN'T enough coins (See AddmusicK's sound list)

these are your defines at the start of the file, three of which should not be modified. Usually you should put those last and specify that you shouldn't change them with a comment... (I assumed this because the readme doesn't specify that you can change the block's acts as)
But it's also weird because of how they're used in the code:
Code
ActAs130:
	LDY !HighByteY
	LDA !ActAs130
	STA $1693|!addr
	RTL

ActAs25:
	LDY #$00
	LDA !ActAs25
	STA $1693|!addr
	RTL

Why is there only a high byte define for 130 and not 25? The block will act weird assuming someone tries to mess with the acts as...
I think these defines should either be completely removed and you just use the values in the code, or do this instead
Code
!coinsEqual = #$0130
!coinsNotEqual = #$0025
.
.
.
ActAsEq:
	LDY !coinsEqual>>8
	LDA !coinsEqual&$FF
	STA $1693|!addr
	RTL

ActAsNotEq:
	LDY !coinsNotEqual>>8
	LDA !coinsNotEqual&$FF
	STA $1693|!addr
	RTL

This way, the user can easily mess with the acts as for the blocks when you have or don't have the required amount of coins.


Now for this...
Code
MarioBelow:
MarioAbove:
MarioSide:
TopCorner:
BodyInside:
HeadInside:
	JMP CheckCoins

CheckCoins:
	LDA $0DBF|!addr
	CMP !CoinsAmount
	BEQ +
	LDA !CoinsNotEqMatchesSound
	STA $1DFC|!addr
	JMP ActAs130
	+
	LDA !CoinsEqAmountSound
	STA $1DFC|!addr
	JMP ActAs25

First off, you should remove that JMP CheckCoins at the start, as the code will continue to that label either way.
Second, you could optimize the code in CheckCoins like so
Code
CheckCoins:
	LDA $0DBF|!addr
	CMP !CoinsAmount
	BEQ ActAs25

ActAs130:
	LDA !CoinsNotEqMatchesSound
	STA $1DFC|!addr

	LDY !HighByteY
	LDA !ActAs130
	STA $1693|!addr
	RTL

ActAs25:
	LDA !CoinsEqAmountSound
	STA $1DFC|!addr

	LDY #$00
	LDA !ActAs25
	STA $1693|!addr
	RTL

The sound effect code was included with the 'change acts as' code, and BEQ now jumps straight to the second label. If the coins aren't equal then the processor just continues to the 130 label since nothing is stopping it. Oh and one more thing, always use BRA for jumping instead of JMP if your code is really short, asar will notify you once your BRA jump is too long, only then do you use JMP.

Also not a complaint but i thought you should know
Code
print "Mario can pass through this block if has specified amount of coins."

Could be changed to
Code
print "Mario can pass through this block if has !CoinsAmount coin(s)."

It will print out !CoinsAmount as what you put in the define.

You can also change
Code
!CoinsAmount = #$32	
.
.
.
CMP !CoinsAmount

To
Code
!CoinsAmount = 50	; asar accepts decimal if you don't use $
.
.
.
CMP #!CoinsAmount


That's all. Feel free to re-submit if you feel like fixing that sound effect issue.

Benny Harvey RIP, miss you big man.