!CollectedItems = $7ED86E !TotalItems = #$60 ;//TOTAL number if items in the game. This includes ALL items: missiles, upgrades, etc LOROM org $828F6B JSR ItemPercent ;//[Free space ($BD bytes)] org $82F74C ItemPercent: PHP PHB REP #$30 PHX PHY SEP #$20 STZ $12 : STZ $14 : STZ $16 LDA !CollectedItems ;Load number of collected items in the game STA $4202 LDA #$64 ;Load #100 decimal STA $4203 PHA : PLA : PHA : PLA 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 PHA : PLA : PHA : PLA REP #$20 LDA $4214 ;Load ((collected items * 100)/Total items) ie Item percent STA $4204 LDA $4216 : STA $1C ;Load remainder SEP #$20 LDA #$0A STA $4206 PHA : PLA : PHA : PLA ;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 PHA : PLA : PHA : PLA ;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 SEP #$20 : LDA $1C : STA $4204 LDA #$0A : STA $4206 PHA : PLA : PHA : PLA ;Divide remainder by 10 REP #$20 : LDA $4216 CLC : ADC #$0804 : STA $7E39D0 ;//[basic drawing] LDX #$0000 LDA #$0C4A : STA $7E39CE ;//decimal icon LDA #$0C02 : STA $7E39D2 ;//percent icon LDA $12 : JSR DrawDigit LDA $14 : JSR DrawDigit LDA $16 : 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 org $B6EA40 dw $0000,$1D5C,$3941,$3942,$3943,$0D07,$0D08,$0D09,$7943,$3942,$3942,$7941