Commit d77e65a0 authored by John P. Willis's avatar John P. Willis

Got multithreaded console working

parent bc1deedd
......@@ -46,7 +46,7 @@ sub bus_start()
for i = 1 to dev_count
print "bus_start(): starting device "; devices(i)
bus(devices(i)).dev_thread = threadcreate(@bus(devices(i)).dev_cycle)
bus(devices(i)).dev_thread = threadcreate(bus(devices(i)).dev_cycle, @devices(i))
bus(devices(i)).dev_thread_started = 1
next i
......@@ -71,6 +71,13 @@ sub bus_stop()
end sub
sub bus_sig_stop(device_number as ushort)
bus(device_number).dev_thread_stop_flag = 1
end sub
function bus_get_stop_flag(device_number as ushort) as ubyte
return bus(device_number).dev_thread_stop_flag
end function
sub bus_attach(device_number as ushort, dev as dev_entry)
dim port as ushort
......
......@@ -14,7 +14,7 @@ type dev_entry
dev_init as sub()
dev_reset as sub()
dev_cycle as sub()
dev_cycle as sub(byval userdata as any ptr)
dev_input as function(port_number as ushort) as ushort
dev_output as sub(port_number as ushort, value as ushort)
......@@ -35,6 +35,8 @@ declare sub bus_clear()
declare sub bus_init()
declare sub bus_start()
declare sub bus_stop()
declare sub bus_sig_stop(device_number as ushort)
declare function bus_get_stop_flag(device_number as ushort) as ubyte
declare sub bus_attach(device_number as ushort, dev as dev_entry)
declare sub bus_output(port_number as ushort, value as ushort)
......
......@@ -6,18 +6,17 @@
#include "storage.bi"
#include "bus.bi"
sub console_attach()
dim dev as dev_entry
with dev
.dev_tag = "ILXIM System Console"
.dev_tag = "console"
.io_base = 0
.io_port_count = 4
.dev_init = @console_init
.dev_reset = @console_reset
.dev_cycle = @console_refresh
.dev_cycle = @console_cycle
.dev_input = @console_input
.dev_output = @console_output
end with
......@@ -42,24 +41,35 @@ sub console_output(port_number as ushort, value as ushort)
end sub
sub console_refresh()
sub console_cycle(byval userdata as any ptr)
dim i as integer
dim c as ubyte
dim col as ubyte = 1 'x
dim row as ubyte = 1 'y
for i = CONSOLE_OFFSET to CONSOLE_LIMIT - 1
c = st_read_byte(CONSOLE_PAGE, i)
locate row, col, 0: print chr(c);
if col >= CONSOLE_WIDTH then
row = row + 1
col = 1
else
col = col + 1
end if
next i
sleep 25
do
col = 1
row = 1
for i = CONSOLE_OFFSET to CONSOLE_LIMIT - 1
c = st_read_byte(CONSOLE_PAGE, i)
locate row, col, 0: print chr(c);
if col >= CONSOLE_WIDTH then
row = row + 1
col = 1
else
col = col + 1
end if
next i
sleep 25
if bus_get_stop_flag(0) = 1 then exit do
loop
locate 26,1
end sub
\ No newline at end of file
......@@ -10,4 +10,4 @@ declare sub console_init()
declare sub console_reset()
declare function console_input(port_number as ushort) as ushort
declare sub console_output(port_number as ushort, value as ushort)
declare sub console_refresh()
\ No newline at end of file
declare sub console_cycle(byval userdata as any ptr)
\ No newline at end of file
......@@ -59,8 +59,6 @@ end sub
sub cpu()
bus_start
dim clock_count as long = 0
dim opcode as ubyte
......@@ -76,14 +74,10 @@ sub cpu()
cpu_clear_flag FL_HALT
cls
bus_start
' main cpu loop
do
clock_count += 1
if clock_count = 100 then
console_refresh
clock_count = 0
end if
inst_pc = cpu_state.pc
......@@ -266,8 +260,6 @@ sub cpu()
if cpu_get_flag(FL_HALT) then
console_refresh
if cpu_state.es > 0 then
print ""
print "cpu(): trap "; trim(str(cpu_state.ec)); " at pc = "; trim(str(cpu_state.pc))
......
......@@ -47,8 +47,6 @@ sub cli()
cmd_name = get_lexer_entry(0).strval
select case cmd_name
case "redraw"
cls: console_refresh
case "loadpage", "lp"
dim img_file as string = get_lexer_entry(1).strval
dim page_index as integer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment