From 67d0762272ff82f6c11f7bb2af62b3b07d15b037 Mon Sep 17 00:00:00 2001
From: David Schmenk <dschmenk@gmail.com>
Date: Sat, 28 Apr 2018 08:00:10 -0700
Subject: [PATCH] Prepare for event manager

---
 src/libsrc/apple/mouse.pla     | 20 ++++++++++++++++++--
 src/libsrc/apple/uthernet2.pla |  8 ++++----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/src/libsrc/apple/mouse.pla b/src/libsrc/apple/mouse.pla
index 4eed81b..b2bedd9 100644
--- a/src/libsrc/apple/mouse.pla
+++ b/src/libsrc/apple/mouse.pla
@@ -18,7 +18,7 @@ const MOVE_INT_ENABLE  = $02
 // Mouse driver
 //
 word rom
-byte slot, index, page, vblInt, mouInt
+byte slot, index, page, vblDiv, vblInt, mouInt
 byte params[]
 word setMouseFW, serveMouseFW, readMouseFW, clearMouseFW, posMouseFW, clampMouseFW, homeMouseFW, initMouseFW
 word minClamp, maxClamp, xMouse, yMouse, statMouse, modeMouse
@@ -93,9 +93,25 @@ asm chkEvt(addr)
         STA     ESTKH,X
         RTS
 end
+//
+// Convert VBL interrupts into millisecond timer increment
+//
 def chkTimer
-    return chkEvt(@vblInt)
+    byte count
+    word msec
+    
+    msec  = 0
+    count = chkEvt(@vblInt)
+    while count
+        msec   = msec + (vblDiv & 2 ?? 16 :: 17)
+        vblDiv = (vblDiv + 1) % 3
+        count--
+    loop
+    return msec
 end
+//
+// Check for mouse interrupt events
+//
 def chkMouse
     return chkEvt(@mouInt)
 end
diff --git a/src/libsrc/apple/uthernet2.pla b/src/libsrc/apple/uthernet2.pla
index e18c983..fd0c48e 100644
--- a/src/libsrc/apple/uthernet2.pla
+++ b/src/libsrc/apple/uthernet2.pla
@@ -791,11 +791,11 @@ def wizServiceIP
             fin
             wiz = wiz + t_channel
         next
-    if ir & $80
+        if ir & $80
             //
-        // IP conflict
-        //
-        pokereg(WIZ_IR, $80)
+            // IP conflict
+            //
+            pokereg(WIZ_IR, $80)
         fin
         if ir & $40
             //