lorom macro divide(dvsr, quot, rmdr) ;divides a number in A by dvsr and stores the quotient and remainder where specified STA $4204 SEP #$20 : LDA #$ : STA $4206 : REP #$20 PHA : PLA : PHA : PLA LDA $4216 : STA $ LDA $4214 : STA $ endmacro macro multiply(mlp) SEP #$20 STA $4202 LDA #$ : STA $4203 PHA : PLA REP #$20 LDA $4216 endmacro macro get_num(start) JSR Calc LDX $12 : LDA Num,x : STA $ LDX $14 : LDA Num,x : STA $+2 endmacro macro get_digit(dgt, dst) LDA $ : ASL : TAX : LDA Num,x : STA $7FFA00+$ endmacro !Hours = $09E0 !Minutes = $09DE !Seconds = $09DC !total_items = 64 ;change this if you have more or fewer than 100 items (including upgrades) in the game org $84889F : JSL COLLECTTANK ;from scyzer's ending total's patch org $84EFE0 ;this just adds to a blank address for every upgrade you get, making percent calculation easier COLLECTTANK: PHA LDA $7ED86E ;there are better addresses for her to have used that don't require 3 byte pointers INC A STA $7ED86E PLA JSL $80818E RTL org $809B4E : JSR Game_timer org $80CDC0 Game_timer: JSR Calc_time JSR Transfer_time JSR Calc_percent JSR Transfer_percent LDA $09C0 RTS Calc_time: LDA #$08CB : STA $7FFA50 : STA $7FFA56 ;in case you want to use colon tile drawn after the blank tiles LDA !Hours : %get_num(7ffa4c) LDA !Minutes : %get_num(7ffa52) LDA !Seconds : %get_num(7ffa58) RTS Transfer_time: LDX $0330 LDA #$0010 : STA $D0,x LDA #$FA4C : STA $D2,x LDA #$007F : STA $D4,x LDA #$5805 : STA $D5,x TXA : CLC : ADC #$0007 : STA $0330 RTS Transfer_percent: LDX $0330 LDA #$000A : STA $D0,x LDA #$FA5C : STA $D2,x LDA #$007F : STA $D4,x LDA #$5814 : STA $D5,x TXA : CLC : ADC #$0007 : STA $0330 RTS Calc: %divide(64, 08, 10) ;divide by 100 (quotient in 08, remainder in 10) LDA $10 %divide(0A, 12, 14) ;divide results by 10 ASL A : STA $12 ;multiply for indexing LDA $14 : ASL A : STA $14 RTS Num: dw $0C09,$0C00,$0C01,$0C02,$0C03,$0C04,$0C05,$0C06,$0C07,$0C08 Calc_percent: ;the math here is modified version of scyzer's ending totals patch, but cleaned up to be easier to read LDA #$08CB : STA $7FFA62 LDA $7ED86E %multiply(64) %divide(!total_items, 08, 18) %divide(0A, 08, 16) %divide(0A, 12, 14) LDA $18 : %divide(0A, 18, 08) %get_digit(12, 5C) %get_digit(14, 5E) %get_digit(16, 60) %get_digit(18, 64) RTS org $80988B ;remove these lines if you don't want the 'TIME'/'ITEM %' text before the timer dw $1CF3, $1CE8, $1CEC, $1CE4, $1CCF ;TIME - rep 9 : dw $2C0F dw $1CE8, $1CF3, $1CE4, $1CEC, $1CF2, $1CCF ;ITEMS - rep 5 : dw $2C0F dw $0C0A ;% dw $2C1D, $2C1D, $2C1D, $2C1D, $2C1D, $2C1C ;the top edges of the map tiles