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
Comments (13)
what number do I put to replace for percentage?
Examples:
Display integer percentage: 0.5% -> 1%
Display tenths percentage: 1.25% -> 1.3%
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.
Sorry about that. I was wondering about the user-friendlyness towards people editing patches for their hacks.
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.
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:
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.