Language…
17 users online: Carnalwillow, crocodileman94, DanMario24YT, Gamet2004, h4shcat, Hayashi Neru, Jaiden, LightAligns, MorrieTheMagpie, Rhubarb44230,  Segment1Zone2, ShadowMistressYuko, signature_steve, simon.caio,  Tahixham, TonyversoTV,  zuccha - Guests: 258 - Bots: 297
Users: 64,795 (2,378 active)
Latest user: mathew

Question about bonus stars => bonus room

I have this question :
bonus stars being added at the end of level make mario go to the bonus room lvl 0 if the bonus star count reaches 100 or over;;

I want to change in my hack that Mario gains 1 bonus star when he loses a life, and I am wondering if I can make it so that it triggers that he goes into bonus room (lvl 0) right after he dies if the bonus star count is at 100. Do you know how I can make that happen? Is it something that happens automatically, e.g. it is a bonus star count or flag check that happens before loading overworld that makes mario go to level 0 ? Or is there a routine name or something that I can call in the code when mario dies if bonus star count is at 100?
I made the hacks Tsunami Island and Super Mario Archipelago
Check them out !
I know the feeling where you have an ASM question and nobody is willing to answer it. I'm kinda stuck there, too. It hurts. With some help from #serioushax, here it is:

Code
header : lorom			; > Are these even necessary anymore?

org $00F60A			; \ Hijack
autoclean JML DeathHijack	; / 

freecode
DeathHijack:		PHX			; > Preserve X

			LDX $0DB3		; \ 
			LDA $0F48,x		; | Increase the current player's bonus stars
			INC A			; | 
			STA $0F48,x		; / 
			CMP #$64		; \ If greater than #100, branch
			BCS HasBonusStars	; / 

			LDA #$09		; \ 
			STA $1DFB		; |  Change music
			LDA #$FF		; | 
			STA $0DDA		; / 
			PLX			; > Pull X
			JML $00F614		; Continue the death

HasBonusStars:		LDX $95			; \ 
			LDA $5B			; | 
			LSR			; | 
			BCC +			; | Teleport
			LDX $97			; | 
+			STZ $19B8,x		; | 
			LDA #$06		; | 
			STA $71			; / 

			STZ $19			; > Remove power-up
			
			PLX			; \ Pull X and return
			RTL			; / 


By (almost) pure chance, the bonus game will function correctly when used!

And this happened while I was making it: (it's fixed now)
Thank you so much Technius!! Did you just write this now for me or??
In any case this is much appreciated saves a lot of time because of course a lot of knowledge of some precise things go into hacking anything directly with ASM and it takes so long to find out about them sometimes, hard to make the intended system unless you get this kind of help!! Thank you thank you thank you
I made the hacks Tsunami Island and Super Mario Archipelago
Check them out !
Just for you. It took about an hour.

You're wlecome you're welcome you're welcome.
Funnily enough, I was working with K3fka to try to help you out with this too, but Technius got it done quicker and better.

I have one recommendation, and it's your move to disregard it or not. You might consider changing the amount of bonus stars that the player receives upon death from 1 bonus star to 5 bonus stars. Let's say that the player averages 20 bonus stars from the goal tape each level. For an increase of 1 bonus star each death, it would take 20 deaths to accumulate enough bonus stars for a meaningful amount that might save you a level to get the bonus game, but if you set the increase amount to 5 bonus stars upon death, then the player could potentially reach a bonus game one level earlier after 4 deaths. To me, it feels like the mechanic has more impact on the gameplay. Maybe a player plays a hack one world during a play session before saving and quitting and averages 5 deaths in a world. In that case, they would never encounter any benefits from your bonus star upon death system at an output of 1 star per death since it would take many more deaths. The player would play from the next world during a second play session, and the bonus stars would be reset.

If you're interested in increasing by 5 instead of 1 and have not applied his patch yet, make this change.

Go from this...
Code
LDA $0F48,x		; | Increase the current player's bonus stars
INC A			; | 
STA $0F48,x		; / 


...to this.
Code
LDA $0F48,X             ; /  
CLC                         ; \
ADC #$05                    ;  | Adds 5 bonus stars to the player's bonus stars
STA $0F48,X                 ; /


Don't feel forced to make the change if you don't like it. I just wanted to share my thoughts.
Hey Domiok, thanks for your suggestion and it is very nice to know you were trying to help as well!

The thing is that this change is part of a larger, simple system where I also will change the amount of bonus stars gained from ending a level.

Specifically, this is what I want to do (spoiler^^):
When you break goal tape, you only get 2 or 3 bonus stars (flat number). If I can, I will make it so that you gain also a number of coins depending on how high the tape is (doesn't seem hard to do) to maybe 1-20 or something like that.

In my hack, reaching 100bonus stars takes the player to the bonus room which is actually a ending level/screen, a "game over" screen, if you will. This mechanic acts like a "time limit" in the whole game so that you have a limited number of tries to find stuff in the world. (it symbolizes that the forecast tsunami has hit the archipelago and Mario has gone back to the safety of the bonus room)

This goes with a 4-digit coin counter. I want to make every coin that the player grabs meaningful. The number of total exits in the game is such that if you find them all, you reach approximately 100bonus stars or a little less (so 33-50 exits).

At the end, the priority factor in determining how well you did is the number of exits found. Then also, lives left are converted into coins, like 10 coins per lives. The total stash is your score, aside from the number of exits found.

So you can replay the game and try to achieve a better score by finding more coins, losing less lives, and finding more/all exits. I probably will let the player keep playing after the end room and just freeze the coin counter then somehow, so that on a first play through you can check/find everywhere and everything. Try to make losing lives not too punitive, too. I don't really want to leave a lot of room for losing lives and still finding all exits before "time" runs out, because then it would encourage a player who wants to maximize score, after he has found all exits and still hasn't reached 100 bonus stars for losing few enough lives, to repetitively play the level where there are the most coins to grab until he goes to 100 bonus stars. I might do something weird, is actually having more exits than you can find within the "time limit", so you can actually pick which levels/exits you want to uncover for getting the best score, eheh (because it is not linear, the path between levels, you can pick a direction sometimes and ofc find secret paths). Like 40-50 exits each giving 3 bonus stars. And for 3 bonus stars an exit, it means for every 3 lives you lose, that is one less exit. It makes me think of this, what you said. The proportion here is very important indeed. I think considering the difficulty in my hack (it is medium so far) and the length of levels (rather short, about 12 screens, decimal lol, with no midway points), 3 bonus stars for an exit and 1 for a life sounds good. Some hard levels or sections will definitely be included, I will make sure they are worth more coins :p
I made the hacks Tsunami Island and Super Mario Archipelago
Check them out !
I think this is what you might want?

Code
header : lorom

org $01C17A			; \ 
RTS				; | Disable big bonus star numbers
NOP #3				; / 

org $07F1AA
db $01,$02,$03,$04,$05,$06,$07,$08	; \ 
db $09,$10,$11,$12,$13,$14,$15,$16	; | Bonus star table
db $17,$18,$19,$20,$21,$22,$23,$24	; | 
db $25,$26,$27,$28,$29,$30,$40,$50	; / 

org $07F252
JML BonusHijack

freecode
BonusHijack:
	PHX
	LDA $1594,x
	LSR
	LSR
	TAX
	LDA $07F1AA,x
	STA $1900
	LDA.L CoinBonusTable,x
	CLC : ADC $0DBF
	;JSL $05B329
	STA $0DBF
	PLX
	CMP #$50
	BNE ReturnBonus
	LDA #$0A
	JSL $02ACE5
ReturnBonus:
	RTL

CoinBonusTable:
db $01,$01,$02,$02,$03,$03,$04,$04	; \ 
db $05,$05,$06,$06,$07,$07,$08,$08	; | Coin bonus table
db $09,$09,$0A,$0A,$0B,$0C,$0D,$0E	; | 
db $0F,$10,$11,$12,$13,$14,$19,$1E	; / 
Technius :3
Thanks a lot for this. I was going to add code into goal tape sprite dissasembly. But surely, this that you wrote for me will save me quite some time since I am little experienced with ASM. I will test this as soon as I can when I am back. Thank you again ><
I made the hacks Tsunami Island and Super Mario Archipelago
Check them out !
Hey, just want to say, it works perfect :) it is really great!
I have just a question though, when I patch with Asar the patch to modify goal point, I get a warning "this freespace appears to be leaked" at line 16 which is the "freecode" line. It says there are like 2 more warnings but I can patch anyway, so I hit yes and yeah all works. (ofc I have backup no problem). But what does this "freespace appears to be leaked" mean ? Could this cause any problem later ?
Mega cheers this is really really helpful
I made the hacks Tsunami Island and Super Mario Archipelago
Check them out !
Probably because Technius forgot an 'autoclean' before JML BonusHijack
Ok thanks I will add this! I am really happy, that the system I wanted is going to work. I believe I can make a really good game with this :] In the making!!
I made the hacks Tsunami Island and Super Mario Archipelago
Check them out !
Hey,
I am back here now that I finished working on all the levels of my hack. I only have some more playtesting and polishing to do.

I ran into a little issue with this patch due to my own wording probably, here is what's not working as intended :

#1 When ending a level, I want that 2 bonus stars are ALWAYS added to the player's bonus stars count whether they touched the goal tape or not. Currently, if the player avoids touching the goal tape, they will not gain any bonus stars, and it goes completely counter to what I want (the "limited number of attempts"). So, taking into account the code above by LDA/Technius which I used to patch 2 bonus stars being added on tape touch, how do I make it / change it so that if the player does not touch the tape (misses touching it), there will still be 2 bonus stars added? Resolved thanks to Thomas

#2 The second part in the tape touched hack here gives a number of coins depending on the height of the tape. It worked when I tested it before, but now that I applied the 4-5 digits coin counter, it won't work with that anymore. Normal coins add coins to my 5 digit counters, but this particular hack for the bonus tape does not add coins to it for unknown reason to me. Is this because the 5 digits coin counter hack changes the "command" for adding coins?? The patch does work with a default SMW rom, it just won't add coins to the hacked 4 digits coin counter on my hack.

I think it is probably not very hard or time consuming to do, but it's hard for me to figure out and exhausting because I spend so much time working on level design. I want to finish this hack, it's almost done, just gotta change this and do a bit more of polish/testing of levels and then it's ready to release ><! Would really appreciate being helped out by somebody who is more experienced with SMW coding.

Here is the code for the 4-5 digits coin counter hack :

Code
!base1 = $0000
!base2 = $0000
!sa1 = 0

if read1($00FFD5) == $23
sa1rom
!sa1 = 1
!base1 = $3000
!base2 = $6000
endif

!RAM_DecCoins = $7F969E	;
!ShowZeroes = 0			; 0 - don't show leading zeroes, anything else - show them

org $008CB2
db     $3C		; \
db $FC,$38		;  |
db $FC,$38		;  |
db $FC,$20		;  | Tilemap in status bar.
db $FC,$20		;  |
db $FC,$38		;  |
db $FC,$38		;  |
db $FC,$20		; /

org $008CE7
db $FC,$3C		; \  Change $FC to $2E if you want the coin sign in front.
db $00,$38		;  |
db $00,$38		;  | More tilemap data.
db $00,$38		;  |
db $00,$38		;  |
db $00,$38		;  |
db $00,$38		;  |
db $2E,$3C		; /

org $008EE5
autoclean JSL ZeroCoins
NOP

org $00802A
autoclean JSL ZeroDec
;STZ $0F29|!base2,x       ; <--

org $008F1D
autoclean JML RoutineStart
LDA $00
BRA CycleSkip  ;\ Skip for reducing cycles
NOP            ; |
NOP            ; | Useless
NOP            ; |
NOP            ;/

CycleSkip:


org $008F7E
BRA Skip 		; \ Skip to save cycles.
NOP      		;  |
NOP      		;  | 
NOP      		;  |
NOP      		; / There isn't written to coin total.
Skip:

org $009BCC
autoclean JSL SaveSRAMRoutine   ; Save data to SRAM!
NOP
NOP

org $009D14
autoclean JSL LoadSRAMRoutine   ; Load data from SRAM!

org $009E4E
NOP    ; Remove the first ; if you...
NOP    ; want to disable the score being...
NOP    ; deleted when getting to the Game Over screen.

org $009E56
NOP    ; Remove the first ; if you...
NOP    ; want to disable the score being...
NOP    ; deleted when getting to the Game Over screen.

org $00D0DD
autoclean JSL STZSRAMWhenGameOver
NOP

org $028766
BRA $01
NOP

org $028770
BRA $01
NOP

org $02AE21
BRA SkipUseless		; \ Skip to save cycles.
NOP					;  |
NOP					;  |
NOP					;  |
NOP					;  | Disable score
NOP					;  |
NOP					;  |
NOP					;  |
NOP					;  |
NOP					;  |
NOP					; /
NOP
NOP
NOP
NOP                 ; \ Yeah more semi-colons and comments...
NOP                 ; / Etc.
NOP
NOP
NOP
SkipUseless:

org $05CEF9
BRA +
NOP					; \
NOP					;  |
NOP					;  |
NOP					;  |
NOP					;  | Disable score being added at level end.
NOP					;  |
NOP					;  |
NOP					;  |
NOP					;  |
NOP					; /
+

freedata ; this one doesn't change the data bank register, so it uses the RAM mirrors from another bank, so I might as well toss it into banks 40+

RoutineStart:        ; Don't remove label
LDA !RAM_DecCoins
BEQ EndDec
LDA $0F34|!base2
ORA $0F35|!base2
ORA $0F36|!base2
BEQ EndDec
REP #$20
LDA !RAM_DecCoins
DEC A
STA !RAM_DecCoins
SEP #$20
LDA #$FF
DEC $0F34|!base2
CMP $0F34|!base2
BNE EndDec
DEC $0F35|!base2
CMP $0F35|!base2
BNE EndDec
DEC $0F36|!base2
EndDec:

LDA $13CC|!base2
BEQ NoInc

IncCoins:
DEC $13CC|!base2

LDA $7E0DB3
CMP #$01
BEQ Luigi					;If Luigi active go Luigi routine

LDA #$FF
CMP $0F34|!base2
BNE NotMaxedOut
CMP $0F35|!base2
BNE NotMaxedOut
CMP $0F36|!base2

BNE NotMaxedOut

STZ $13CC|!base2

BRA EndInc

NotMaxedOut:
INC $0F34|!base2			; $0F34 = Lowest 256 values.
BNE EndInc
INC $0F35|!base2			; $0F35 = Lowest 65536 values.
BNE EndInc
INC $0F36|!base2			; $0F36 = All 1000000 values
BRA EndInc


Luigi:						;Here we go, with Luigi addresses

LDA #$FF
CMP $0F37|!base2
BNE NotLaxedOut
CMP $0F38|!base2
BNE NotLaxedOut
CMP $0F39|!base2
BNE NotLaxedOut

STZ $13CC|!base2

BRA EndInc

NotLaxedOut:
INC $0F37|!base2			; $0F37 = Lowest 256 values.
BNE EndInc
INC $0F38|!base2			; $0F38 = Lowest 65536 values.
BNE EndInc
INC $0F39|!base2			; $0F39 = All 1000000 values


EndInc:
LDA $00
JML $008F32

NoInc:
JML $008F3B

ZeroDec:
STA $7F8000
LDA #$0000
STA !RAM_DecCoins
RTL

SaveSRAMRoutine:
JSR GetSaveFile

LoadScoreData:
LDA $0F34|!base2,y			; Transfer coin counter data over...

if !sa1 == 0
STA $70079F,x				; to SRAM data. ($7007FD - $7007FF)
else
STA $41C79F,x				; to SRAM data. ($41C7FD - $41C7FF)
endif

INX
INY
CPY #32
BCC LoadScoreData
LDX $010A|!base2
LDA $009CCB,x
RTL

LoadSRAMRoutine:
PHX
PHY
SEP #$10
JSR GetSaveFile

LoadSRAMData:

if !sa1 == 0
LDA $70079F,x			; Transfer SRAM data...
else
LDA $41C79F,x			; Transfer SRAM data...
endif

STA $0F34|!base2,y		; over to coin counter data.
INX
INY
CPY #32
BCC LoadSRAMData
REP #$10
PLY
PLX

if !sa1 == 0
LDA $700000,x
else
LDA $41C000,x
endif

RTL

STZSRAMWhenGameOver:
JSR GetSaveFile

StoreZeroIntoSRAM:
LDA #$00
STA $0F34|!base2,y			; Set coins to zero.

if !sa1 == 0
STA $70079F,x				; Set coins in SRAM to zero.
else
STA $41C79F,x				; Set coins in SRAM to zero.
endif

INX
INY
CPY #32
BCC StoreZeroIntoSRAM
LDA #$0A
STA $1DFB|!base2
RTL 

GetSaveFile:
LDA $010A|!base2
ASL
ASL
ASL
ASL
ASL
TAX
LDY #0
RTS

ZeroCoins:

if !ShowZeroes
STZ $0F29|!base2,x
RTL
else

LDA #$FC			; hijacked routine
STA $0F29|!base2,x
LDA $0F34|!base2
ORA $0F35|!base2
ORA $0F36|!base2	; if you have 0 coins...
BNE DontStoreZero	; put "0" on the status bar

STZ $0F2E|!base2	; 0 for the first digit

DontStoreZero:
RTL

endif


Here is a copy of the code of TechnisCoinsGoal which hijacks code on goal tape break to give always 2 bonus stars and a number of coins :

Code
header : lorom

org $01C17A			; \ 
RTS				; | Disable big bonus star numbers
NOP #3				; / 

org $07F1AA
db $02,$02,$02,$02,$02,$02,$02,$02	; \ 
db $02,$02,$02,$02,$02,$02,$02,$02	; | Bonus star table
db $02,$02,$02,$02,$02,$02,$02,$02	; | 
db $02,$02,$02,$02,$02,$02,$02,$02	; / 

org $07F252
autoclean JML BonusHijack

freecode
BonusHijack:
	PHX
	LDA $1594,x
	LSR
	LSR
	TAX
	LDA $07F1AA,x
	STA $1900
	LDA.L CoinBonusTable,x
	CLC : ADC $0DBF
	;JSL $05B329
	STA $0DBF
	PLX
	CMP #$50
	BNE ReturnBonus
	LDA #$0A
	JSL $02ACE5
ReturnBonus:
	RTL

CoinBonusTable:
db $01,$01,$01,$01,$02,$02,$02,$02	; \ 
db $03,$03,$03,$03,$04,$04,$04,$04	; | Coin bonus table ~
db $05,$05,$05,$05,$06,$06,$06,$06	; | three last values originally
db $07,$07,$07,$07,$08,$08,$08,$08	; / give big increments

I made the hacks Tsunami Island and Super Mario Archipelago
Check them out !