diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/irc.c | 13 | ||||
| -rw-r--r-- | src/jifsec.s | 24 |
2 files changed, 26 insertions, 11 deletions
@@ -107,7 +107,7 @@ static void do_priv_nick(void) { } } -/* this ping calculation relies on the assumption that +/* the ping calculation in jifsec.s relies on the assumption that nobody's ping time will ever be more than 9 minutes. anyone that lagged will have been disconnected from the server already. if this assumption turns out to be false, the ping time displayed @@ -119,19 +119,12 @@ static void do_priv_nick(void) { the compiled code smaller, but it grew by ~50 bytes. avoid. */ static void print_ping_time(char *p) { - extern void print_jif_sec(unsigned int j); - static unsigned int now, pingtime; - - now = read_rtclok(); - pingtime = (unsigned int)a2uint(p); - - /* correct for rtclock rollover (every ~9 mins) */ - if(now < pingtime) now |= 0x8000; + extern void calc_ping_time(unsigned int j); scr_print_active("*** "); scr_print_active(msg_src); scr_print_active(" lag: "); - print_jif_sec(now - pingtime); + calc_ping_time(p); scr_putc_active('s'); } diff --git a/src/jifsec.s b/src/jifsec.s index 4f3d3c8..15ae972 100644 --- a/src/jifsec.s +++ b/src/jifsec.s @@ -15,10 +15,32 @@ _hz = $f0 ; must agree with timers.h! .import _scr_act_printnum, _scr_putc_active + .import _read_rtclok, _a2uint .import mulax10 ; extern void print_jif_sec(unsigned int jiffies); - .export _print_jif_sec + .export _print_jif_sec, _calc_ping_time + +_calc_ping_time: + jsr _a2uint + sta acc16 + stx acc16+1 ; acc16 = timestamp in ping response + jsr _read_rtclok ; A/X = low 15 bits of RTCLOK + cpx acc16+1 ; has RTCLOK rolled over? + bcs @clok_ok + pha + txa + ora #$80 + tax + pla +@clok_ok: + sec + sbc acc16 + pha + txa + sbc acc16+1 + tax + pla ; A/X now holds "now" minus timestamp _print_jif_sec: jsr divbyhz |
