-
Notifications
You must be signed in to change notification settings - Fork 2
/
imageloader-loadshare.txt
56 lines (46 loc) · 1.69 KB
/
imageloader-loadshare.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@name imageloader-loadshare
#Source https://github.com/Divran/e2imageloader
@persist ImageData:string
@persist LoadShare_Start LoadShare_Stop Step NumScreenSqrt
@persist LinkedDigis:array ImageSize:vector2 MaxRes:vector2
@persist G:gtable DataSize ScreenSize:vector2
if (first()) {
G = gTable("imageloader",0)
dsSetScope(0)
dsJoinGroup("imageloader")
dsSend("register","imageloader-main","derp")
DataSize = 6
} elseif (dsClk("stop")) {
stoptimer("step")
} elseif (dsClk("load")) {
local Data = dsGetTable()
LinkedDigis = Data["wirelink",array]
NumScreenSqrt = sqrt(LinkedDigis:count())
ImageData = Data["imagedata",string]
ImageSize = Data["imagesize",vector2]
MaxRes = Data["maxres",vector2]
LoadShare_Start = Data["start",number]
LoadShare_Stop = Data["stop",number]
ScreenSize = Data["screensize",vector2]
Step = LoadShare_Start
timer("step",1)
} elseif (clk("step")) {
while(perf()) {
local Color = ImageData:sub(Step*DataSize+1,Step*DataSize+DataSize):toNumber(16)
if (Color != 0) {
if (NumScreenSqrt == 1) {
LinkedDigis[1,wirelink][Step] = Color
} else {
local X = Step % ImageSize:x()
local Y = floor(Step / ImageSize:y())
local DigiX = floor(X / ScreenSize:x())
local DigiY = floor(Y / ScreenSize:y()) * NumScreenSqrt
LinkedDigis[DigiX+DigiY+1,wirelink][X % ScreenSize:x() + ScreenSize:x() * (Y % ScreenSize:y())] = Color
}
}
Step++
}
if (G["stop",number] == 0 & Step < LoadShare_Stop) {
timer("step",10)
}
}