Banner
The Overworld Design Contest ends in
11 DAYS, 3 HOURS, 54 MINUTES AND 26 SECONDS
Views: 904,604,610
Time:
12 users online:  Anorakun, AppleBoy54321, Bench-kun, chickaDEE Magazine, Green Jerry, Isikoro,  Lazy, Murphmario, Nouie, SolveForX, Teaser, TheMorganah - Guests: 65 - Bots: 73 Users: 50,715 (2,107 active)
Latest: Kharjacker
Tip: Unless you're making a Kaizo hack, don't make Mario die after cutting the goal tape.
Not logged in.
shop block problem
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - shop block problem
Pages: « 1 » Link
I found a shop block (mushroom)in an old thread which works with the
6-digit-counter I added to my rom. the problem is there is something
wrong with the amount of coins spend for the mushroom - it chances
(sometimes 20, 30, 10).


could someone help me please? (I don't know much about ASM)
is it possible to change the sold item (flower, 1-up)?

Code
;6 coin shop block - Spigmike
;Standard Shop Block
;Mushroom

JMP HitBottom : JMP Return : JMP Return : JMP Return : JMP Return : JMP Return : JMP Return

HitBottom:

REP #$20 ;Set accumulator to 16-bit
LDA $0F34 ;Load Coins
CMP #$0009 ;Compare to cost-1
BCS Enough ;Branch if the player has enough coins
SEP #$20 ;\
LDY #$01
LDA #$30
STA $1693
RTL ;/If they don't, exit block and set accumulator back to 8-bit

Enough:

SEP #$20 ;set accumulator to 8-bit
LDA $0DBC ;\See if there's already a mushroom in the item box
CMP #$01 ;/
BEQ Return
REP #$20 ;set accumulator to 16-bit again
LDA $0F34 ;Load Coins
SEC ;\
SBC #$000A ;| Subtract 10 coins and store
STA $0F34 ;/
SEP #$20 ;set accumulator back to 8-bit

LDA #$01 ;Load mushroom sprite number
STA $0DC2 ;Store it in mario's item box

Return:
LDY #$01
LDA #$30
STA $1693
RTL


--------------------

if you were me, you would not prefer being you
Originally posted by DonGeilo

is it possible to change the sold item (flower, 1-up)?


Yes.

Code
LDA #$01 ;Load mushroom sprite number
STA $0DC2 ;Store it in mario's item box


Change the #$01 to something else. Here are the possible values (from RAM map):

#$00 = Nothing
#$01 = Mushroom
#$02 = Fire Flower
#$03 = Star
#$04 = Feather

EDIT: If you want it to sell an 1-up, you must replace those two rows with this:

Code
INC $18E4
The only possible reason I can think of is the code getting executed more than once when Mario hits it. Try sticking this right after the "HitBottom:" label:

Code
LDA #$20
STA $7D
thank you very much for the advice - it's working now but another error occurs:

when I don't have enough coins and try to buy something the counter
jumps to about 65000 coins - I can buy unlimited items (a nice
gimmick in real-life but not in smw :P)

--------------------

if you were me, you would not prefer being you
Haha, yes. :P

Anyway, that error must have already been there. I think you can fix it by changing only the 9 in line 13:

CMP #$0009 ;Compare to cost-1

to "A", so it's CMP #$000A.
hmmm.. nothing changed - error still existing

--------------------

if you were me, you would not prefer being you
Huh, I don't see why it would do that. Can you post your entire new code?

And did you reinsert the block?
yes I did, several times :)

Code
;6 coin shop block - Spigmike
;Standard Shop Block
;Mushroom

JMP HitBottom : JMP Return : JMP Return : JMP Return : JMP Return : JMP Return : JMP Return

HitBottom:

LDA #$20 
STA $7D

REP #$20 ;Set accumulator to 16-bit
LDA $0F34 ;Load Coins
CMP #$000A ;Compare to cost-1
BCS Enough ;Branch if the player has enough coins
SEP #$20 ;\
LDY #$01
LDA #$30
STA $1693
RTL ;/If they don't, exit block and set accumulator back to 8-bit

Enough:

SEP #$20 ;set accumulator to 8-bit
LDA $0DBC ;\See if there's already a mushroom in the item box
CMP #$01 ;/
BEQ Return
REP #$20 ;set accumulator to 16-bit again
LDA $0F34 ;Load Coins
SEC ;\
SBC #$0032 ;| Subtract 50 coins and store
STA $0F34 ;/
SEP #$20 ;set accumulator back to 8-bit

LDA #$01 ;Load mushroom sprite number
STA $0DC2 ;Store it in mario's item box

Return:
LDY #$01
LDA #$30
STA $1693
RTL


--------------------

if you were me, you would not prefer being you
Figured it out with some help from Alcaro, at first it wasn't very obvious but now it is:

LDA $0F34 ;Load Coins
SEC ;\
SBC #$0032 ;| Subtract 50 coins and store
STA $0F34 ;/

You're taking away 50 coins from the player when they're buying something for only 10 coins. Change that 0032 to 000A.

In fact, you may want to add a define at the very top of the file and use that for the price.
thank you very much. it's working now. I changed the cost (000A) to 0032 (otherwise it would be too cheap).

thx a lot again - now I can focus on editing some stages again.

--------------------

if you were me, you would not prefer being you
Pages: « 1 » Link
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - shop block problem

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2021 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy
  • sm64romhacks