Skip to content

Commit 67ecb69

Browse files
committed
UI: update IMAGE handling
1 parent 601eefb commit 67ecb69

File tree

7 files changed

+229
-95
lines changed

7 files changed

+229
-95
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Added file manager to main shell program
2626
Fixed issues with TRY/CATCH
2727
Fixed using POINT to retrieve IMAGE data
28+
The IMAGE argument can now be PNG data stored in an INT array
2829

2930
2016-02-11
3031
Added export to mobile command (SDL)

samples/distro-examples/libs/base64.bas

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ func decode(message)
7575
decode = result
7676
end
7777

78+
func decodeBin(message)
79+
dim result
80+
local in_len = len(message)
81+
local i, b_a, b_b, b_c, b_d
82+
83+
if (in_len % 4 != 0) then
84+
throw "Invalid base64 message length"
85+
endif
86+
87+
for i = 1 to in_len step 4
88+
b_a = index(asc(mid(message, i, 1)))
89+
b_b = index(asc(mid(message, i + 1, 1)))
90+
b_c = index(asc(mid(message, i + 2, 1)))
91+
b_d = index(asc(mid(message, i + 3, 1)))
92+
result << (((b_a lshift 2) + (b_b rshift 4)))
93+
result << (((b_b band 0xf) lshift 4) + (b_c rshift 2))
94+
result << (((b_c band 0x3) lshift 6) + b_d)
95+
next offset
96+
decode = result
97+
end
98+
99+
78100
sub test
79101
if (len(alphabet) != 64) then
80102
throw "Invalid alphaet length"

samples/distro-examples/tests/chain.bas

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,52 @@ ar_code << " print i"
77
ar_code << "next i"
88
chain ar_code
99

10+
Const FILENAME = "chain.tmp"
11+
12+
Sub open_1
13+
Open FILENAME For Output As #1
14+
End Sub
15+
16+
' ERROR: Missing ')' (does not read last character):
17+
open_1
18+
? #1, "Print Pow(2, 1)";
19+
Close #1
20+
Chain FILENAME
21+
22+
' OK: prints 4 (last character is ":"):
23+
open_1
24+
? #1, "Print Pow(2, 2):";
25+
Close #1
26+
Chain FILENAME
27+
28+
' OK: prints 8 (last character is \n):
29+
open_1
30+
? #1, "Print Pow(2, 3)"
31+
Close #1
32+
Chain FILENAME
33+
34+
' BUG?: prints 16 (reads ONLY the first line,
35+
' should read file as Array - not as String...):
36+
open_1
37+
? #1, "Print Pow(2, 4)"
38+
? #1, "Print Pow(2, 5)"
39+
Close #1
40+
Chain FILENAME
41+
42+
' OK: prints 64 128 (but as a String - not as an Array...):
43+
?
44+
open_1
45+
? #1, "Print Pow(2, 6):";
46+
? #1, "Print Pow(2, 7):";
47+
Close #1
48+
Chain FILENAME
49+
50+
' OK: causes an ERROR: Variable is NOT an Array (use DIM)
51+
open_1
52+
? #1, "Print Power(2, 1)" ' (Power instead of Pow)
53+
Close #1
54+
Chain FILENAME
55+
56+
' BUG?: does not report an ERROR (entering endless/long loop - ONLY IF previous "Chain FILENAME" is uncommented):
57+
Chain "Print Power(2, 1)" ' using a "string" instead of filename.
1058

src/common/blib.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2767,7 +2767,15 @@ void cmd_call_vfunc() {
27672767
if (v_func == NULL || v_func->type != V_FUNC) {
27682768
rt_raise(ERR_NO_FUNC);
27692769
} else {
2770-
v_func->v.fn.cb(v_func->v.fn.self);
2770+
if (code_peek() != kwTYPE_LEVEL_BEGIN) {
2771+
err_missing_lp();
2772+
} else {
2773+
code_skipnext();
2774+
v_func->v.fn.cb(v_func->v.fn.self);
2775+
if (!prog_error && code_peek() != kwTYPE_LEVEL_END) {
2776+
err_missing_rp();
2777+
}
2778+
}
27712779
}
27722780
}
27732781

0 commit comments

Comments
 (0)