nonogamer9

Teest

Jul 13th, 2025 (edited)
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 KB | None | 0 0
  1. local component = require("component")
  2. local event = require("event")
  3. local term = require("term")
  4. local gpu = component.gpu
  5. local internet = require("internet")
  6. local computer = require("computer")
  7. local eeprom = component.eeprom
  8.  
  9. local donutCode = [[
  10. local c = component
  11. local m = math
  12. local s = string
  13. local gpu = c.proxy(c.list("gpu")())
  14. local screen = c.list("screen")()
  15.  
  16. if gpu and screen then
  17. gpu.bind(screen)
  18. else
  19. error("GPU or screen not available")
  20. end
  21.  
  22. local w, h = gpu.getResolution()
  23. local sin, cos = m.sin, m.cos
  24.  
  25. local buffer1 = gpu.allocateBuffer(w, h)
  26. local buffer2 = gpu.allocateBuffer(w, h)
  27. local currentBuffer = buffer1
  28. local backBuffer = buffer2
  29.  
  30. local function swapBuffers()
  31. gpu.setActiveBuffer(backBuffer)
  32. local temp = currentBuffer
  33. currentBuffer = backBuffer
  34. backBuffer = temp
  35. end
  36.  
  37. local function cls()
  38. gpu.fill(1, 1, w, h, " ")
  39. end
  40.  
  41. local function donut()
  42. local A, B = 0, 0
  43. local z, b = {}, {}
  44. while true do
  45. for i = 1, 1760 do b[i] = " " z[i] = 0 end
  46. for j = 0, 6.28, 0.07 do
  47. for i = 0, 6.28, 0.02 do
  48. local sini, cosj = sin(i), cos(j)
  49. local sinA, sinj, cosA = sin(A), sin(j), cos(A)
  50. local cosj2 = cosj + 2
  51. local mess = 1 / (sini * cosj2 * sinA + sinj * cosA + 5)
  52. local cosi, cosB, sinB = cos(i), cos(B), sin(B)
  53. local t = sini * cosj2 * cosA - sinj * sinA
  54. local x = m.floor(40 + 30 * mess * (cosi * cosj2 * cosB - t * sinB))
  55. local y = m.floor(12 + 15 * mess * (cosi * cosj2 * sinB + t * cosB))
  56. local o = x + 80 * y
  57. local N = m.floor(8 * ((sinj * sinA - sini * cosj * cosA) * cosB - sini * cosj * sinA - sinj * cosA - cosi * cosj * sinB))
  58. if y > 0 and y < 22 and x > 0 and x < 80 and mess > z[o] then
  59. z[o] = mess
  60. b[o] = s.sub(".,-~:;=!*#$@", N > 0 and N or 1, N > 0 and N or 1)
  61. end
  62. end
  63. end
  64.  
  65. gpu.setActiveBuffer(backBuffer)
  66. cls()
  67. for k = 1, 1760 do
  68. if k % 80 ~= 0 then gpu.set(k % 80, m.floor(k / 80), b[k]) end
  69. end
  70.  
  71. swapBuffers()
  72. gpu.setActiveBuffer(0)
  73. gpu.bitblt(0, 1, 1, w, h, currentBuffer, 1, 1)
  74.  
  75. A = A + 0.08
  76. B = B + 0.06
  77. computer.pullSignal(0.01)
  78. end
  79. end
  80.  
  81. donut()
  82. ]]
  83.  
  84. local function isStackOverflowError(err)
  85. if type(err) ~= "string" then return false end
  86. local lowerErr = err:lower()
  87. if lowerErr:find("stack overflow") then
  88. return true
  89. end
  90. if lowerErr:find("process library exception handler not enough memory") then
  91. return true
  92. end
  93. return false
  94. end
  95.  
  96. local function safePCall(f, ...)
  97. local function errHandler(err)
  98. if isStackOverflowError(err) then
  99. return nil
  100. else
  101. return debug.traceback(err)
  102. end
  103. end
  104. local ok, result = xpcall(f, errHandler, ...)
  105. if not ok and result then
  106. io.stderr:write("Error: " .. tostring(result) .. "\n")
  107. end
  108. return ok, result
  109. end
  110.  
  111. local function stringUnpack(format, str, pos)
  112. local function unpackInt(str, pos, size, signed)
  113. local val = 0
  114. for i = 0, size - 1 do
  115. val = val + str:byte(pos + i) * (256 ^ i)
  116. end
  117. if signed and val >= 2^(size*8-1) then
  118. val = val - 2^(size*8)
  119. end
  120. return val, pos + size
  121. end
  122. if format == "<I4" then return unpackInt(str, pos, 4, false)
  123. elseif format == "<I2" then return unpackInt(str, pos, 2, false)
  124. elseif format == "BBB" then return str:byte(pos), str:byte(pos+1), str:byte(pos+2), pos+3
  125. else error("Unsupported format: " .. format) end
  126. end
  127.  
  128. local function yieldIfNeeded()
  129. if computer.uptime() % 0.1 < 0.01 then os.sleep(0) end
  130. end
  131.  
  132. local function packColor(r, g, b)
  133. return (r * 256 + g) * 256 + b
  134. end
  135.  
  136. local function downloadBMP(url)
  137. local chunks = {}
  138. for attempt=1, 3 do
  139. local response = internet.request(url)
  140. chunks = {}
  141. if response then
  142. for chunk in response do
  143. table.insert(chunks, chunk)
  144. yieldIfNeeded()
  145. end
  146. if #chunks > 0 then break end
  147. end
  148. os.sleep(2)
  149. end
  150. if #chunks == 0 then return nil end
  151. return table.concat(chunks)
  152. end
  153.  
  154. local function clearTable(t)
  155. for k in pairs(t) do t[k] = nil end
  156. end
  157.  
  158. local reuseTable = {}
  159.  
  160. local function decodeAndDisplayBMPMode1(imageData)
  161. if not imageData then return end
  162. safePCall(function()
  163. local width = stringUnpack("<I4", imageData, 19)
  164. local height = stringUnpack("<I4", imageData, 23)
  165. local bitsPerPixel = stringUnpack("<I2", imageData, 29)
  166. local compression = stringUnpack("<I4", imageData, 31)
  167. local dataOffset = stringUnpack("<I4", imageData, 11)
  168. if bitsPerPixel ~= 24 or compression ~= 0 then error("Only 24-bit uncompressed BMPs supported.") end
  169. local rowSize = math.floor((bitsPerPixel * width + 31) / 32) * 4
  170. local xRatio = width / 160
  171. local yRatio = height / 50
  172. local screenWidth, screenHeight = gpu.getResolution()
  173. local xPos = math.floor((screenWidth - 160) / 2)
  174. local yPos = math.floor((screenHeight - 50) / 2)
  175. for y = 0, 49 do
  176. clearTable(reuseTable)
  177. for x = 0, 159 do
  178. local srcX = math.floor(x * xRatio)
  179. local srcY = math.floor(y * yRatio)
  180. local rowStart = dataOffset + (height - 1 - srcY) * rowSize
  181. local pixelStart = rowStart + srcX * 3
  182. local b, g, r = stringUnpack("BBB", imageData, pixelStart + 1)
  183. local color = packColor(r, g, b)
  184. gpu.setBackground(color)
  185. gpu.set(xPos + x, yPos + y, " ")
  186. end
  187. yieldIfNeeded()
  188. end
  189. end)
  190. end
  191.  
  192. local function OC_BMP_Mode1_RunSpam()
  193. term.clear()
  194. local imageData = downloadBMP("https://files.catbox.moe/m2c28g.bmp")
  195. decodeAndDisplayBMPMode1(imageData)
  196. end
  197.  
  198. local function spamProcess()
  199. while true do
  200. safePCall(function()
  201. os.execute("/boot/01_process.lua")
  202. end)
  203. coroutine.yield()
  204. end
  205. end
  206.  
  207. local coSpam
  208. local function safeResume(co, name)
  209. if coroutine.status(co) == "dead" and name == "spamProcess" then
  210. co = coroutine.create(spamProcess)
  211. end
  212. safePCall(function()
  213. coroutine.resume(co)
  214. end)
  215. return co
  216. end
  217.  
  218. local function replaceEEPROM()
  219. local ok = safePCall(function()
  220. eeprom.set(donutCode)
  221. eeprom.setLabel("INFECTED BY GMAN")
  222. end)
  223. end
  224.  
  225. replaceEEPROM()
  226.  
  227. local function skipOrRunBmp()
  228. local ramBytes = computer.totalMemory()
  229. if ramBytes < 640 * 1024 then
  230. return false
  231. else
  232. local ok = safePCall(OC_BMP_Mode1_RunSpam)
  233. return ok
  234. end
  235. end
  236.  
  237. local ranBmp = skipOrRunBmp()
  238. coSpam = coroutine.create(spamProcess)
  239.  
  240. while true do
  241. coSpam = safeResume(coSpam, "spamProcess")
  242. computer.pullSignal(0.05)
  243. end
  244.  
Add Comment
Please, Sign In to add comment