News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

Help with Game Percentage ASM

Started by GUZROCK, March 18, 2023, 07:36:42 AM

Previous topic - Next topic

GUZROCK

Does someone could gently tell me which line below I need to change to remove the decimal place?
e.g. 100% instead of 100.0% [in the SAMUS menu]

I applied the two ASMs below (the second asm fix the item % for vanilla), but I didn't know how to mix them, so I used both.

link showing the issue
https://ibb.co/hF0gvHB


;Changes how the end percentage in calculated. Made by Sadiztyk Fish   :P

;Allows tanks with multiple values (eg. missile tanks worth either 3 or 5)
;Allows an uneven or random number of items (up to 255 separate item pickups)
;Adds a single decimal point value, to give more accurate results to random item ammounts

!CollectedItems = $7ED86E

!TotalItems = #$64 ;TOTAL number if items in the game. This includes ALL items: missiles, upgrades, etc

LOROM

org $828F6B
JSR ItemPercent

;//[Free space ($C7 bytes)]
org $82FA6A
ItemPercent:
PHP
PHB
REP #$30
PHX
PHY
SEP #$20
STZ $12
LDA !CollectedItems ;Load number of collected items in the game
STA $4202
LDA #$64 ;Load #100 decimal
STA $4203
NOP : NOP : NOP : NOP : NOP : NOP : NOP
REP #$20
LDA $4216 ;Load number of (collected items * 100)
STA $4204 ;Store to devisor A
SEP #$20
LDA !TotalItems ;Load total number of game items
STA $4206 ;Store to devisor B
NOP : NOP : NOP : NOP : NOP : NOP : NOP
REP #$20
LDA $4214 ;Load ((collected items * 100)/Total items) ie Item percent
STA $4204
LDA $4216 ;Load remainder
PHA
SEP #$20
LDA #$0A
STA $4206
NOP : NOP : NOP : NOP : NOP : NOP : NOP ;Calculate percentage / 10
REP #$20
LDA $4214 ;Load tenths of percentage / 10 (eg, if 78, load 7, if 53, load 5)
STA $4204 ;Store value to devisor A
LDA $4216 ;Load remainder of percentage / 10 (eg, if 78, load 8, if 53, load 3)
STA $16 ;Store to $16. oneths of percentage. if 78, = 8, if 100, = 0
SEP #$20
LDA #$0A
STA $4206
NOP : NOP : NOP : NOP : NOP : NOP : NOP ;Divide percentage by 10 again
REP #$20
LDA $4214 ;If 100%, this will be 1
STA $12 ;Store to $12. Contains 100th of percentage. WIll only be 1 if 100% achieved
LDA $4216 ;Load remainder, which will be 0 if 100% achieved
STA $14 ;Store to $14
PLA
SEP #$20
STA $4204
LDA #$0A
STA $4206
NOP : NOP : NOP : NOP : NOP : NOP : NOP ;Divide remainder by 10
REP #$20
LDA $4214 ;load value
STA $18


;//[basic drawing]
LDX #$0000
LDA #$0C4A ;//decimal icon
STA $7E39CE
LDA #$0C02 ;//percent icon
STA $7E39D2
LDA $12 : JSR DrawDigit
LDA $14 : JSR DrawDigit
LDA $16 : JSR DrawDigit
INX : INX
LDA $18 : JSR DrawDigit
PLY
PLX
PLB
PLP
JSR $8F70 ;//vanilla
RTS
DrawDigit:
CLC : ADC #$0804
STA $7E39C8,x
INX : INX
RTS

;//[just the 'items' box]
org $B6E980
dw $0000,$1D5C,$3941,$3942,$3943,$0C9E,$0C9F,$0CAF,$7943,$3942,$3942,$7941
org $B6E9C0
dw $0000,$1D5C,$3940,$2801,$2801,$2801,$2801,$2801,$2801,$2801,$2801,$7940
org $B6EA00
dw $0000,$1D5C,$B941,$B942,$B942,$B942,$B942,$B942,$B942,$B942,$B942,$F941



---------------------------- VANILLA % FIX ----------------------------

LOROM

!CollectedItems = $7ED86E

org $84889F
JSL COLLECTTANK
org $84F000
COLLECTTANK:
PHA
LDA !CollectedItems
INC A
STA !CollectedItems
PLA
JSL $80818E
RTL


THANKS!

TobiMikami

Because I don't really have the time to convert all the values I only read the comments and my suggestion would be to patch it to a new ROM for troubleshooting purposes, I'd try and maybe remove just the line that specifically says "draw item percentage" because then it may calculate but not display. Otherwise if you remove the reference to the #100 decimal you'd have to remove that too obviously. But that's what I would try first. Use the scientific method, control your variables by only removing one line at a time, try, fail, learn, record your data, try again. Don't do the same thing twice and expect a different result, and whatever you do, USE A VANILLA ROM, don't risk your hack until you know FOR SURE it didn't have some obscure adverse effect not immediately foreseeable.

GUZROCK


nodever2

Try commenting out or deleting the following lines:

  • See the four DrawDigit calls? Comment out the last one, the line that says LDA $18 : JSR DrawDigit.
  • Also try commenting out two lines under ;//[basic drawing], one LDA #$0C4A and the other being STA $7E39CE
I haven't tested this myself, but that'd be my best guess reading the code.
Need help? Just ask.
My Hacks | My Resources

GUZROCK