Some more dumb fun seeing if I can read midi data from the 6850 ACIA with lua. (with a midi card in slot 2 -sl2 midi)

If I keep polling 0xc0a8 every 1/31250*10 seconds (1 second divided by the midi clock times 10 bits) I should be able to see all of the data bytes since one byte will arrive at this interval.

It's useful to me to see just exactly how the device behaves.

We'll just read 18 bytes and then exit the coroutine.

Code

mem=manager:machine().devices[":maincpu"].spaces["program"]
mem:write_u8(0xc0a8,19)  -- acia master reset CR0=1, CR1=1
mem:write_u8(0xc0a8,17)  -- set divider to 16 CR0=1, CR1=0
co1 = function() for i=1,18 do 
  status=mem:read_u8(0xc0a8)
  while (status&1)==0 do 
     emu.wait(1/31250*10) 
     status=mem:read_u8(0xc0a8) 
  end 
  data=mem:read_u8(0xc0a9) 
  if (status&0x20)~=0 then print ("OVERRUN ") end 
  print(string.format("status=%x  data=%x",status,data)) 
  emu.wait(1/31250*10) 
end end
myco1=coroutine.create(co1) ok,errormsg=coroutine.resume(myco1)


and you get something like this as output:

Code
[MAME]> myco1=coroutine.create(co1) ok,errormsg=coroutine.resume(myco1)
status=3  data=45
OVERRUN 
status=23  data=45
[MAME]> status=3  data=90
status=3  data=49
status=3  data=44
status=3  data=90
status=3  data=49
status=3  data=0