Browse Source

bugfixes in timer emulation, still wonky

tags/0.1.1
asie 1 year ago
parent
commit
587c387aa0
8 changed files with 25 additions and 2 deletions
  1. 4
    0
      comms.lua
  2. 1
    0
      disks.lua
  3. 4
    1
      emu_core.lua
  4. 4
    1
      emu_core_pre.lua
  5. 2
    0
      keyboard.lua
  6. 7
    0
      pit.lua
  7. 2
    0
      timer.lua
  8. 1
    0
      video.lua

+ 4
- 0
comms.lua View File

@@ -4,6 +4,8 @@ cpu_register_interrupt_handler(0x14, function(ax,ah,al)
CPU["regs"][1] = 0x0000
emu_debug(0, "serial: get port status/init\n")
return true
else
cpu_set_flag(0)
end
end)

@@ -13,5 +15,7 @@ cpu_register_interrupt_handler(0x17, function(ax,ah,al)
CPU["regs"][1] = CPU["regs"][1] & 0xFF
emu_debug(0, "printer: get port status/init\n")
return true
else
cpu_set_flag(0)
end
end)

+ 1
- 0
disks.lua View File

@@ -281,6 +281,7 @@ cpu_register_interrupt_handler(0x13, function(ax,ah,al)
ret_status(1)
return true
else
cpu_set_flag(0)
return false
end
end)

+ 4
- 1
emu_core.lua View File

@@ -2034,6 +2034,8 @@ end

local oc_tick_i = 0

local last_pit_clock = clock

local function upd_tick(cv)
local last_clock = clock
clock = cv
@@ -2051,7 +2053,8 @@ local function upd_tick(cv)
-- handle video
video_update()
keyboard_update()
--pit_tick(clock, last_clock)
pit_tick(last_pit_clock, clock)
last_pit_clock = clock
-- handle OC waits
cv = os.clock()
if (cv - clock) < 0.05 then

+ 4
- 1
emu_core_pre.lua View File

@@ -2027,6 +2027,8 @@ end

local oc_tick_i = 0

local last_pit_clock = clock

local function upd_tick(cv)
local last_clock = clock
clock = cv
@@ -2044,7 +2046,8 @@ local function upd_tick(cv)
-- handle video
video_update()
keyboard_update()
--pit_tick(clock, last_clock)
pit_tick(last_pit_clock, clock)
last_pit_clock = clock
-- handle OC waits
cv = os.clock()
if (cv - clock) < 0.05 then

+ 2
- 0
keyboard.lua View File

@@ -155,6 +155,8 @@ cpu_register_interrupt_handler(0x16, function(ax,ah,al)
al = RAM[0x417]
CPU["regs"][1] = (ah << 8) | al
return true
else
cpu_set_flag(0)
end
end)


+ 7
- 0
pit.lua View File

@@ -30,6 +30,12 @@ function pit_tick(last_t, curr_t)
local trig=0
local ch=channels[c]
local ch_ready=(not ch.paused) and ch.reload_set_lo and ch.reload_set_hi
if ch_ready then
emu_debug(2, "PIT tick " .. c .. " mode " .. ch.mode)
end
if ch.reload == 0 then
ch.reload = 0x10000
end
if (ch.mode == 0 or ch.mode == 4) and ch_ready then
if ch.count == 0 then ch.count = ch.reload end
ch.count = ch.count - osc_count
@@ -39,6 +45,7 @@ function pit_tick(last_t, curr_t)
ch.paused = true
end
elseif (ch.mode == 2 or ch.mode == 3) and ch_ready then
emu_debug(2, "PIT " .. ch.count .. " -> " .. (ch.count - osc_count))
ch.count = ch.count - osc_count
while ch.count < 0 do
ch.count = ch.count + ch.reload

+ 2
- 0
timer.lua View File

@@ -54,6 +54,8 @@ cpu_register_interrupt_handler(0x1A, function(ax,ah,al)
CPU["regs"][3] = 0x0000
emu_debug(0, "time: get RTC (dummy)\n")
return true
else
cpu_set_flag(0)
end
end)


+ 1
- 0
video.lua View File

@@ -509,6 +509,7 @@ cpu_register_interrupt_handler(0x10, function(ax,ah,al)
CPU["regs"][4] = 0x020A
return true
else
cpu_set_flag(0)
return false
end
end)

Loading…
Cancel
Save