Language…
6 users online:  Big Brawler, fanfan21, Gamet2004, Hinalyte, Shiki_Makiro, Zavok - Guests: 730 - Bots: 116
Users: 70,914 (2,293 active)
Latest user: foobuntu

Exit Percentage on File Select v1.1

SMW Patches → Exit Percentage on File Select v1.1

Submission Details

Name: Exit Percentage on File Select v1.1
Author: Kevin
Added:
Tool: Asar
Requires Free Space: Yes
Bug Fix: No
Featured: No
Description: This patch will make the title screen show the percentage of exits obtained in the save files, rather than the absolute number. You just need to set the total amount of exits your hack has in the asm file. Included is a slightly modified GFX29 file containing the % sign.

Requested by Ondore's Lies.

P.S.: the patch can display up to 199%, so you can in theory have post-game levels that increase the number over 100%. You just need to set the number of exits in the patch as the exits required for the "main game".

v1.1: added option to display a decimal digit to show more accurate percentages. Note that values greater or equal than 100% won't display the decimal part (due to limited number of tiles per row in the file select tilemap).
Tags: lorom sa-1 save tilemap
Comments: 13 (jump to comments)
Download 2.67 KiB | 618 downloads

Screenshots

Comments (13)

zsnesw Link
for me a star is appearing instead of the percentage.
what number do I put to replace for percentage?
 Kevin Author Link
You need to replace the original GFX29.bin file in the Graphics folder with the one provided in the zip, then insert the graphics in LM with the #lm{insgfx} button.
Galeth Link
It appears to be incompatible with the One File, One Player patch. Any way, solid work!
HammerBrother Link
On the next update, can you feature a round-half-up (but away from 100%?)? Like if it lands halfway between two representable values, rounds upwards.

Examples:
Display integer percentage: 0.5% -> 1%
Display tenths percentage: 1.25% -> 1.3%
MarkAlarm Link
Moderated with:
Lunar Magic 3.20
Asar 1.71
SA-1 Pack 1.32 (also tested without)
Snes9x 1.60

Surprised this wasn't an existing thing, but it definitely has some usage and it worked fine so it's accepted. Rounding and decimal options all seemed to work well when I messed around, so there should be no issue with its calculation for larger hacks.
HammerBrother Link
Originally posted by KevinM
Also, don't tell me how I should format my code.


Sorry about that. I was wondering about the user-friendlyness towards people editing patches for their hacks.
 Kevin Author Link
Originally posted by HammerBrother
Ooh, I think I found a potential bug-- if you make it display a decimal and have roundup being set, it may be possible that the decimal point gets incremented, from 9 to 10, which could increment the integer part from 99 to 100. An easy fix for that is simply check if both if the integer part is 99, and the remainder is attempted to increment past 9, to simply display 99.9%.

I know about this, I didn't care to handle it since it can only happen for hacks with 1000+ exits, which is not even possible when using the normal event counter. Even if it was, the percentage can only be computed properly with up to 655 exits (since you do *100, which for higher values would be higher than $FFFF), so this "bug" will never happen.
Also, don't tell me how I should format my code.
HammerBrother Link
Ooh, I think I found a potential bug-- if you make it display a decimal and have roundup being set, it may be possible that the decimal point gets incremented, from 9 to 10, which could increment the integer part from 99 to 100. An easy fix for that is simply check if both if the integer part is 99, and the remainder is attempted to increment past 9, to simply display 99.9%.

Code
else
    pha             ; Save percentage for later.
    lda $4216       ;\ If remainder is 0, decimal digit is 0.
    beq +           ;/
    sta $4202       ;\
    lda.b #10       ;|
    sta $4203       ;| DecimalUnit = Remainder * 10 / TotalExits.
    jsr .sub        ;|
    lda $4214       ;/
if !RoundUp
    ldy $4216       ;\ If the remainder is 0, don't round up.
    beq +           ;/
    cmp.b #9        ;\
    bne ++          ;|
    pla             ;| If we have to round up 9, increase the
    inc             ;| integer units by 1 and set decimal digit to 0.
    pha             ;|
    lda #$00        ;|
    bra +           ;/
++  inc             ; Otherwise, just increase the decimal unit by 1.
endif


Also, I would recommend indenting the if statement, so that the nested if statement is double-indented for anyone wanting to edit the patch for their hacks to understand it easier.

An easy way to deal with displaying percentages with decimals is by using fixed-point arithmetic. Where instead of dealing with x/100, you deal with x/1000. So instead of ExitsFound * 100 / TotalExits, you do ExitsFound * 1000 / TotalExits, and after the hexdec display, note this:
Code
FixedPointInteger -> Display
1s place -> 1/10s place
10s place -> 1s place
100s place -> 10s place
1000s place -> 100s place

And when rounding via that, will round upwards by 0.1% automatically.

Perhaps, I made my own percentage converter (CTRL+F “ConvertToPercentage”). This one rounds 1/2 up, and you can use the Y register to check for misleading displays.
 Kevin Author Link
Updated to v1.1: now you can also display a decimal digit for the percentage for more accurate values.
 Kevin Author Link
Small update: added a check so 99 isn't rounded to 100 when using the RoundUp option, added support for values between 101% and 199% and changed mode 7 multiplication regs to normal regs since the results were wrong when having more than 127 exits.
 Kevin Author Link
In that case just set !RoundUp to 0, problem solved
HammerBrother Link
Be careful that when you have more than 100 exits, and you have the round up setting, there is a potential that the game may misleadingly display 100% indicating you got all the exit despite you only got 99.99%. A way to avoid that is by checking after you divide by the number of exits, the modulo is usually in between 0 and the number of exits. During the rounding upwards, check if it went from 99 to 100, then simply display 99%.

mason Link
Very cool #smrpg{y}