Lua 5.3 didn't need an x86 emulator. But now, it has one regardless.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pic.lua 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. -- 8259 PIC
  2. -- TODO: Not actually emulated.
  3. PIC_INTERRUPT_PRINTER = 7
  4. PIC_INTERRUPT_FDD = 6
  5. PIC_INTERRUPT_HDD = 5
  6. PIC_INTERRUPT_COM1 = 4
  7. PIC_INTERRUPT_COM2 = 3
  8. PIC_INTERRUPT_VIDEO = 2
  9. PIC_INTERRUPT_KEYBOARD = 1
  10. PIC_INTERRUPT_MOUSE = 1
  11. PIC_INTERRUPT_RTC = 1
  12. PIC_INTERRUPT_TIMER = 0
  13. local int_mask = 0x00
  14. local pic_irr = 0x00
  15. local pic_isr = 0x00
  16. function pic_interrupt_enabled(i)
  17. return true
  18. -- return (int_mask & (1 << i)) == 0
  19. end
  20. --function pic_interrupt_sent(i)
  21. -- pic_isr = pic_isr | (1 << i)
  22. --end
  23. local next_20 = 0x00
  24. pic_isr = 0xFF
  25. cpu_port_set(0x20, function(cond, val)
  26. if val then next_20 = val else
  27. if next_20 == 0x0A then
  28. return pic_irr
  29. elseif next_20 == 0x0B then
  30. pic_isr = pic_isr ~ 0xFF
  31. return pic_isr
  32. elseif next_20 == 0x20 then
  33. -- TODO
  34. return 0
  35. else
  36. -- unknown
  37. return 0xFF
  38. end
  39. end
  40. end)
  41. local int_22 = 0
  42. local int_23 = 0
  43. cpu_port_set(0x21, function(cond, val)
  44. if not val then return int_mask else int_mask = val end
  45. end)
  46. cpu_port_set(0x22, function(cond, val)
  47. if not val then return int_22 else int_22 = val end
  48. end)
  49. cpu_port_set(0x23, function(cond, val)
  50. if not val then return int_23 else int_23 = val end
  51. end)