Banner
Views: 864,172,425
Time:
13 users online: Abdu, Daizo Dee Von, Darkbloom, djEnby, Erik_The_Swift, GangsterJerby, Infinity, Jazzman287, Lunming Gaming, nnj, quietmason,  RussianMan, underway - Guests: 37 - Bots: 143 Users: 47,844 (2,085 active)
Latest: Tokarev
Tip: Create a thread for your hack in the Works in Progress once you have enough screenshots/videos to show.Not logged in.
Details for Exit Percentage on File Select v1.1
SMW Patches - Exit Percentage on File Select v1.1 Show random
File Name: Exit Percentage on File Select v1.1
Added:
Authors: KevinM
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
Download: Download - 2.67 KiB
85 downloads
Screenshots
Previous 
 Next
Galeth
It appears to be incompatible with the One File, One Player patch. Any way, solid work!
Posted by: Galeth - | Link
HammerBrother
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%
Posted by: HammerBrother - | Link
MiniMawile303
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.
Posted by:  MiniMawile303 - | Link
HammerBrother
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.
Posted by: HammerBrother - | Link
KevinM
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.
Posted by:  KevinM - | Link
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%.

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.
Posted by: HammerBrother - | Link
KevinM
Updated to v1.1: now you can also display a decimal digit for the percentage for more accurate values.
Posted by:  KevinM - | Link
KevinM
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.
Posted by:  KevinM - | Link
KevinM
In that case just set !RoundUp to 0, problem solved
Posted by:  KevinM - | Link
HammerBrother
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%.

Posted by: HammerBrother - | Link
quietmason
Very cool #smrpg{y}
Posted by: quietmason - | Link

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

Copyright © 2005 - 2020 - 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