Advertisement
Guest User

BIOSerin v9.4.2 (EEPROM w/ Fancy Graphics)

a guest
Apr 26th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. local component_invoke = component.invoke
  2. local component = component
  3. local computer = computer
  4. local unicode = unicode
  5. function boot_invoke(address, method, ...)
  6. local result = table.pack(pcall(component_invoke, address, method, ...))
  7. if not result[1] then
  8. return nil, result[2]
  9. else
  10. return table.unpack(result, 2, result.n)
  11. end
  12. end
  13.  
  14. -- backwards compatibility, may remove later
  15. local eeprom = component.list("eeprom")()
  16. computer.getBootAddress = function()
  17. return boot_invoke(eeprom, "getData")
  18. end
  19. computer.setBootAddress = function(address)
  20. return boot_invoke(eeprom, "setData", address)
  21. end
  22.  
  23. do
  24. local gpu = component.list("gpu", true)()
  25. local w, h
  26. if gpu and screen then
  27. component.invoke(gpu, "bind", screen)
  28. w, h = component.invoke(gpu, "getResolution")
  29. component.invoke(gpu, "setResolution", w, h)
  30. component.invoke(gpu, "setBackground", 0x000000)
  31. component.invoke(gpu, "setForeground", 0xCC0C0C)
  32. component.invoke(gpu, "fill", 1, 1, w, h, " ")
  33. end
  34. local y = 1
  35. local function status(msg)
  36. if gpu and screen then
  37. component.invoke(gpu, "set", 1, y, msg)
  38. if y == h then
  39. component.invoke(gpu, "copy", 1, 2, w, h - 1, 0, -1)
  40. component.invoke(gpu, "fill", 1, h, w, 1, " ")
  41. else
  42. y = y + 1
  43. end
  44. end
  45. end
  46. component.invoke(gpu, "set", 1, 1, "███ █ █ ███ ██ ███ ███ █ ██ ")
  47. component.invoke(gpu, "set", 1, 2, "██ ██ █ █ █ ██ ██ █ █ █")
  48. component.invoke(gpu, "set", 1, 3, "███ █ █ ███ ██ ███ █ █ █ █ █")
  49. computer.beep(20, 3.5)
  50. component.invoke(gpu, "set", 1, 5, "Booting in 3,")
  51. computer.beep(20, 1)
  52. component.invoke(gpu, "set", 1, 5, "Booting in 2,")
  53. computer.beep(20, 1)
  54. component.invoke(gpu, "set", 1, 5, "Booting in 1,")
  55. computer.beep(20, 1)
  56. component.invoke(gpu, "set", 1, 5, "Booting in 0,")
  57. end
  58.  
  59. local function tryLoadFrom(address)
  60. local handle, reason = boot_invoke(address, "open", "/init.lua")
  61. if not handle then
  62. return nil, reason
  63. end
  64. local buffer = ""
  65. repeat
  66. local data, reason = boot_invoke(address, "read", handle, math.huge)
  67. if not data and reason then
  68. return nil, reason
  69. end
  70. buffer = buffer .. (data or "")
  71. until not data
  72. boot_invoke(address, "close", handle)
  73. return load(buffer, "=init")
  74. end
  75. local init, reason
  76. if computer.getBootAddress() then
  77. init, reason = tryLoadFrom(computer.getBootAddress())
  78. end
  79. if not init then
  80. computer.setBootAddress()
  81. for address in component.list("filesystem") do
  82. init, reason = tryLoadFrom(address)
  83. if init then
  84. computer.setBootAddress(address)
  85. break
  86. end
  87. end
  88. end
  89. if not init then
  90. error("FATAL: No bootable medium found." .. (reason and (": " .. tostring(reason)) or ""), 0)
  91. end
  92. computer.beep(1000, 0.2)
  93. init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement