header lorom org $8F70 NOP ; \ NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | Stop the original counter. NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; | NOP ; / org $8FD8 JML Check_One ; Jump to the new code. NOP ; ------------------------------------------- org $3A8000 ; address to put code ; ------------------------------------------- db "STAR" ; Write RATS tag dw Endcodeblock-Startcodeblock dw Endcodeblock-Startcodeblock^#$FFFF ; ------------------------------------------- Startcodeblock: ; code starts here ; ------------------------------------------- Check_One: LDA $318000 ;\ CMP #$3A ; | If greater than a certain amount... BCS Set_Zero ;/ ...branch off. Check_Two: LDA $318001 ;\ CMP #$3A ; | If greater than a certain amount... BCS Set_Zero2 ;/ ...branch off. BRA CoinOne ; Branch off to setting the values shown in the status bar. Set_Zero: LDA #$00 ;\ STA $318000 ; | Set the address to zero. BRA Check_Two ;/ Set_Zero2: LDA #$00 ;\ STA $318001 ;/ Set the address to zero. CoinOne: LDA $308000 ;\ CMP #$0A ; | If less than #$0A... BCC CoinTwo ;/ ...go check the next digit. LDA $318000 ;\ CMP #$09 ; | If the tens digit is 9... BCC Increase ;/ ...check final digit. LDA $318001 ;\ CMP #$09 ; | If the hundreds digit is 9... BCC Increase ;/ ...draw digits. LDA #$09 ;\ Set the digit to 9. STA $308000 ;/ LDA #$09 ;\ Set the digit to 9. STA $318000 ;/ LDA #$09 ;\ Set the digit to 9. STA $318001 ;/ BRA DrawCoin Increase: LDA $318000 ;\ INC ; | Increase the value of the next digit. STA $318000 ;/ LDA $308000 ;\ SEC ; | SBC #$0A ; | Subtract #$0A from the digit... STA $308000 ;/ ...so we get the right value. CoinTwo: LDA $318000 ;\ CMP #$0A ; | If less than #$0A... BCC CoinThree ;/ ...go check the next digit. LDA $318001 ;\ CMP #$09 ; | If the hundreds digit is 9... BCC Increase2 ;/ ...draw digits. LDA #$09 ;\ Set the digit to 9. STA $308000 ;/ LDA #$09 ;\ Set the digit to 9. STA $318000 ;/ LDA #$09 ;\ Set the digit to 9. STA $318001 ;/ BRA DrawCoin Increase2: LDA $318001 ;\ INC ; | Increase the value of the next digit. STA $318001 ;/ LDA $318000 ;\ SEC ; | SBC #$0A ; | Subtract #$0A from the digit... STA $318000 ;/ ...so we get the right value. CoinThree: LDA $318001 ;\ CMP #$0A ; | If less than #$0A... BCC DrawCoin ;/ ...draw the values to the status bar. LDA #$09 ;\ Set the digit to 9. STA $308000 ;/ LDA #$09 ;\ Set the digit to 9. STA $318000 ;/ LDA #$09 ;\ Set the digit to 9. STA $318001 ;/ DrawCoin: LDA $308000 ;\ STA $7E0F14 ; | LDA $318000 ; | Write the values of the digits to the status bar... STA $7E0F13 ; | ...at the location of the original counter. LDA $318001 ; | STA $7E0F12 ;/ LDA $1422 ;\ CMP #$05 ; | We hooked into the original Yoshi Coin code, so we're restoring it here so we don't mess up anything! JML $008FDD ;/ ; ------------------------------------------- Endcodeblock: ; code ends here ; ------------------------------------------- ; ------------------------------------------- org $3C8008 ; address to put code ; ------------------------------------------- db "STAR" ; Write RATS tag dw Endcodeblock2-Startcodeblock2 dw Endcodeblock2-Startcodeblock2^#$FFFF ; ------------------------------------------- Startcodeblock2: ; code starts here ; ------------------------------------------- LDA $318002 ;\ CMP #$03 ; | If $C102 is higher than #$02... BCS Reset_Count ; | ...branch off... BRA Check1 ;/ ...else continue with the code. Reset_Count: LDA #$00 ;\ STA $318002 ;/ Zero out $C102 so things won't wig out when we try to pay for something. Check1: LDA $318001 ;\ CMP $318003 ; | If our hundreds digit is equal to the amount we need... BEQ Check2 ; | ...check the next digit... BCS Pay ; | ...or go ahead and pay if it's greater... BCC Midway2 ;/ ...or return that we don't have enough. Check2: LDA $318000 ;\ CMP $318004 ; | If our tens digit is equal to the amount we need... BEQ Check3 ; | ...check the next digit... BCS Pay ; | ...or go ahead and pay if it's greater... BCC Midway2 ;/ ...or return that we don't have enough. Check3: LDA $308000 ;\ CMP $318005 ; | If our ones digit is equal to or greater than the amount we need... BEQ Pay ; | ...we go pay the price... BCS Pay ; | BCC Midway2 ;/ ...else return that we don't have enough. Pay: LDA $318005 ;\ CMP #$00 ; | If the price is non-existant for this digit... BEQ Counter2 ;/ ...just ignore this section and check the next digit. LDA $308000 ;\ CMP $318005 ; | If the ones digit is less than the ones price... BCC Pull1 ;/ ...jump off to pulling from the next digit. Drain1: LDA $308000 ;\ SEC ; | SBC $318005 ; | Subtract the price from the digit. STA $308000 ; | BRA Counter2 ;/ Next digit... Pull1: LDA $318000 ;\ DEC ; | Decrease the next digit by one... STA $318000 ;/ LDA $308000 ;\ CLC ; | ADC #$0A ; | ...and add it to the current digit in the form of #$0A, 10 decimal. STA $308000 ; | BRA Drain1 ;/ Subtract from the digit. Midway2: BRA Midway3 ; Midway stop for the return, so we don't get an error. Counter2: LDA $318004 ;\ CMP #$00 ; | If the price is non-existant for this digit... BEQ Counter3 ;/ ...just ignore this section and check the next digit. LDA $318000 ;\ CMP $318004 ; | Checking the next digit against the price... BCC Pull2 ;/ Drain2: LDA $318000 ;\ SEC ; | SBC $318004 ; | Drain the price from the digit again. STA $318000 ; | BRA Counter3 ;/ Pull2: LDA $318001 ;\ DEC ; | Decreasing again. STA $318001 ;/ LDA $318000 ;\ CLC ; | ADC #$0A ; | Adding to give us a safe and accurate subtraction again. STA $318000 ; | BRA Drain2 ;/ Midway3: BRA CantPay ; Midway stop for the return, so we don't get an error. Counter3: LDA $318003 ;\ CMP #$00 ; | If the price is non-existant for this digit... BEQ CanPay ;/ ...just ignore this section and pay immediately. LDA $318001 ;\ SEC ; | SBC $318003 ; | Drain the price from the final digit. STA $318001 ; | BRA CanPay ;/ CanPay: LDA #$01 STA $318002 ; Return that we have enough coins to buy the effect. BRA Return CantPay: LDA #$02 STA $318002 ; Return that we don't have enough coins to buy. Return: RTL ; ------------------------------------------- Endcodeblock2: ; code ends here ; -------------------------------------------