pxt-common-packages 11.1.1 → 11.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/common-sim.d.ts +6 -0
- package/built/common-sim.js +62 -29
- package/libs/azureiot/built/debug/binary.js +461 -461
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +7986 -7953
- package/libs/controller---none/built/debug/binary.js +7965 -7932
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +462 -462
- package/libs/game/built/debug/binary.js +7878 -7845
- package/libs/game/sprite.ts +2 -0
- package/libs/game/sprites.ts +1 -0
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/microphone/sim/state.ts +2 -0
- package/libs/mixer/docs/reference/music/create-sound-effect.md +68 -0
- package/libs/mixer/docs/reference/music/play-sound-effect.md +59 -0
- package/libs/mixer/docs/reference/music/play.md +10 -2
- package/libs/mixer/docs/reference/music/randomize-sound.md +30 -0
- package/libs/mixer/docs/types/sound-effect.md +136 -0
- package/libs/mixer/playable.ts +19 -1
- package/libs/mixer/soundEffect.ts +1 -1
- package/libs/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +9666 -9633
- package/libs/palette/built/debug/binary.js +7877 -7844
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/_locales/screen-strings.json +1 -1
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/screen/fieldeditors.ts +5 -4
- package/libs/screen/sim/image.ts +32 -31
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/shader/pxt.json +14 -0
- package/libs/shader/shader.cpp +140 -0
- package/libs/shader/shader.ts +19 -0
- package/libs/shader/sim/shader.ts +37 -0
- package/libs/sprite-scaling/built/debug/binary.js +7877 -7844
- package/libs/storyboard/built/debug/binary.js +7877 -7844
- package/package.json +1 -1
|
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
|
|
|
56
56
|
const pxsim_numops = pxsim.numops;
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
function
|
|
59
|
+
function _main___P52862(s) {
|
|
60
60
|
let r0 = s.r0, step = s.pc;
|
|
61
61
|
s.pc = -1;
|
|
62
62
|
|
|
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
|
|
|
66
66
|
switch (step) {
|
|
67
67
|
case 0:
|
|
68
68
|
|
|
69
|
-
globals.
|
|
70
|
-
globals.
|
|
69
|
+
globals._intervals___53105 = (undefined);
|
|
70
|
+
globals._pollEventQueue___53118 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P52862.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"targetoverrides.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P52862.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P52862_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P52862, depth: s.depth + 1,
|
|
82
82
|
pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
|
|
83
83
|
} }
|
|
84
84
|
|
|
@@ -88,5 +88,5 @@ function _main___P52847_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P52862
|
|
92
92
|
})
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#include "pxt.h"
|
|
2
|
+
|
|
3
|
+
#define XX(v) (int)(((int16_t)(v)))
|
|
4
|
+
#define YY(v) (int)(((int16_t)(((int32_t)(v)) >> 16)))
|
|
5
|
+
|
|
6
|
+
namespace ShaderMethods {
|
|
7
|
+
|
|
8
|
+
void mapImage(Image_ toShade, Image_ shadeLevels, int x, int y, Buffer map) {
|
|
9
|
+
if (x >= toShade->width() || y >= toShade->height())
|
|
10
|
+
return;
|
|
11
|
+
|
|
12
|
+
if (toShade->bpp() != 4 || shadeLevels->bpp() != 4 || map->length < 16 || map->length % 16 != 0)
|
|
13
|
+
return;
|
|
14
|
+
|
|
15
|
+
int maxShadeLevel = map->length >> 4;
|
|
16
|
+
|
|
17
|
+
int x2 = x + shadeLevels->width() - 1;
|
|
18
|
+
int y2 = y + shadeLevels->height() - 1;
|
|
19
|
+
|
|
20
|
+
if (x2 < 0 || y2 < 0)
|
|
21
|
+
return;
|
|
22
|
+
|
|
23
|
+
int x0 = x;
|
|
24
|
+
int y0 = y;
|
|
25
|
+
|
|
26
|
+
toShade->clamp(&x2, &y2);
|
|
27
|
+
toShade->clamp(&x, &y);
|
|
28
|
+
int w = x2 - x + 1;
|
|
29
|
+
int h = y2 - y + 1;
|
|
30
|
+
|
|
31
|
+
toShade->makeWritable();
|
|
32
|
+
|
|
33
|
+
auto mapData = map->data;
|
|
34
|
+
|
|
35
|
+
auto toShadeByteHeight = toShade->byteHeight();
|
|
36
|
+
uint8_t *toShadeAddr = toShade->pix(x, y);
|
|
37
|
+
|
|
38
|
+
auto shadeLevelsByteHeight = shadeLevels->byteHeight();
|
|
39
|
+
uint8_t *shadeLevelsAddr = shadeLevels->pix(x - x0, y - y0);
|
|
40
|
+
|
|
41
|
+
while (w-- > 0) {
|
|
42
|
+
auto ptr1 = toShadeAddr;
|
|
43
|
+
auto ptr2 = shadeLevelsAddr;
|
|
44
|
+
unsigned shift1 = y & 1;
|
|
45
|
+
unsigned shift2 = (y - y0) & 1;
|
|
46
|
+
uint8_t shadeLevel = 0;
|
|
47
|
+
for (int i = 0; i < h; i++) {
|
|
48
|
+
if (shift2) {
|
|
49
|
+
shadeLevel = min(*ptr2 >> 4, maxShadeLevel);
|
|
50
|
+
ptr2++;
|
|
51
|
+
shift2 = 0;
|
|
52
|
+
} else {
|
|
53
|
+
shadeLevel = min(*ptr2 & 0x0f, maxShadeLevel);
|
|
54
|
+
shift2 = 1;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (shift1) {
|
|
58
|
+
*ptr1 = (mapData[(*ptr1 >> 4) + (shadeLevel << 4)] << 4) | (*ptr1 & 0x0f);
|
|
59
|
+
ptr1++;
|
|
60
|
+
shift1 = 0;
|
|
61
|
+
} else {
|
|
62
|
+
*ptr1 = (mapData[(*ptr1 & 0xf) + (shadeLevel << 4)] & 0xf) | (*ptr1 & 0xf0);
|
|
63
|
+
shift1 = 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
toShadeAddr += toShadeByteHeight;
|
|
67
|
+
shadeLevelsAddr += shadeLevelsByteHeight;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void mergeImage(Image_ dst, Image_ src, int x, int y) {
|
|
72
|
+
if (x >= dst->width() || y >= dst->height())
|
|
73
|
+
return;
|
|
74
|
+
|
|
75
|
+
if (dst->bpp() != 4 || src->bpp() != 4)
|
|
76
|
+
return;
|
|
77
|
+
|
|
78
|
+
int x2 = x + src->width() - 1;
|
|
79
|
+
int y2 = y + src->height() - 1;
|
|
80
|
+
|
|
81
|
+
if (x2 < 0 || y2 < 0)
|
|
82
|
+
return;
|
|
83
|
+
|
|
84
|
+
int x0 = x;
|
|
85
|
+
int y0 = y;
|
|
86
|
+
|
|
87
|
+
dst->clamp(&x2, &y2);
|
|
88
|
+
dst->clamp(&x, &y);
|
|
89
|
+
int w = x2 - x + 1;
|
|
90
|
+
int h = y2 - y + 1;
|
|
91
|
+
|
|
92
|
+
dst->makeWritable();
|
|
93
|
+
|
|
94
|
+
auto dstByteHeight = dst->byteHeight();
|
|
95
|
+
uint8_t *dstAddr = dst->pix(x, y);
|
|
96
|
+
|
|
97
|
+
auto srcByteHeight = src->byteHeight();
|
|
98
|
+
uint8_t *srcAddr = src->pix(x - x0, y - y0);
|
|
99
|
+
|
|
100
|
+
while (w-- > 0) {
|
|
101
|
+
auto ptr1 = dstAddr;
|
|
102
|
+
auto ptr2 = srcAddr;
|
|
103
|
+
unsigned shift1 = y & 1;
|
|
104
|
+
unsigned shift2 = (y - y0) & 1;
|
|
105
|
+
int srcValue = 0;
|
|
106
|
+
for (int i = 0; i < h; i++) {
|
|
107
|
+
if (shift2) {
|
|
108
|
+
srcValue = *ptr2 >> 4;
|
|
109
|
+
ptr2++;
|
|
110
|
+
shift2 = 0;
|
|
111
|
+
} else {
|
|
112
|
+
srcValue = *ptr2 & 0x0f;
|
|
113
|
+
shift2 = 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (shift1) {
|
|
117
|
+
*ptr1 = (min(*ptr1 >> 4, srcValue) << 4) | (*ptr1 & 0x0f);
|
|
118
|
+
ptr1++;
|
|
119
|
+
shift1 = 0;
|
|
120
|
+
} else {
|
|
121
|
+
*ptr1 = (min(*ptr1 & 0xf, srcValue) & 0xf) | (*ptr1 & 0xf0);
|
|
122
|
+
shift1 = 1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
dstAddr += dstByteHeight;
|
|
126
|
+
srcAddr += srcByteHeight;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//%
|
|
131
|
+
void _mapImage(Image_ toShade, Image_ shadeLevels, int xy, Buffer c) {
|
|
132
|
+
mapImage(toShade, shadeLevels, XX(xy), YY(xy), c);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//%
|
|
136
|
+
void _mergeImage(Image_ toShade, Image_ shadeLevels, int xy) {
|
|
137
|
+
mergeImage(toShade, shadeLevels, XX(xy), YY(xy));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
namespace helpers {
|
|
2
|
+
//% shim=ShaderMethods::_mapImage
|
|
3
|
+
function _mapImage(toShade: Image, shadeLevels: Image, xy: number, m: Buffer): void { }
|
|
4
|
+
|
|
5
|
+
export function mapImage(toShade: Image, shadeLevels: Image, x: number, y: number, m: Buffer) {
|
|
6
|
+
_mapImage(toShade, shadeLevels, pack(x, y), m);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//% shim=ShaderMethods::_mergeImage
|
|
10
|
+
function _mergeImage(dst: Image, src: Image, xy: number): void { }
|
|
11
|
+
|
|
12
|
+
export function mergeImage(dst: Image, src: Image, x: number, y: number) {
|
|
13
|
+
_mergeImage(dst, src, pack(x, y));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function pack(x: number, y: number) {
|
|
17
|
+
return (Math.clamp(-30000, 30000, x | 0) & 0xffff) | (Math.clamp(-30000, 30000, y | 0) << 16)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference path="../../screen/sim/image.ts" />
|
|
2
|
+
|
|
3
|
+
namespace pxsim.ShaderMethods {
|
|
4
|
+
export function _mergeImage(dst: RefImage, src: RefImage, xy: number) {
|
|
5
|
+
mergeImage(dst, src, pxsim.ImageMethods.XX(xy), pxsim.ImageMethods.YY(xy));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function mergeImage(dst: RefImage, src: RefImage, x0: number, y0: number) {
|
|
9
|
+
for (let x = 0; x < src._width; x++) {
|
|
10
|
+
for (let y = 0; y < src._height; y++) {
|
|
11
|
+
pxsim.ImageMethods.setPixel(
|
|
12
|
+
dst,
|
|
13
|
+
x0 + x,
|
|
14
|
+
y0 + y,
|
|
15
|
+
Math.min(pxsim.ImageMethods.getPixel(dst, x0 + x, y0 + y), pxsim.ImageMethods.getPixel(src, x, y))
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function _mapImage(dst: RefImage, src: RefImage, xy: number, buf: RefBuffer) {
|
|
22
|
+
mapImage(dst, src, pxsim.ImageMethods.XX(xy), pxsim.ImageMethods.YY(xy), buf);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function mapImage(dst: RefImage, src: RefImage, x0: number, y0: number, buf: RefBuffer) {
|
|
26
|
+
for (let x = 0; x < src._width; x++) {
|
|
27
|
+
for (let y = 0; y < src._height; y++) {
|
|
28
|
+
pxsim.ImageMethods.setPixel(
|
|
29
|
+
dst,
|
|
30
|
+
x0 + x,
|
|
31
|
+
y0 + y,
|
|
32
|
+
buf.data[pxsim.ImageMethods.getPixel(dst, x0 + x, y0 + y) + (pxsim.ImageMethods.getPixel(src, x, y) << 4)]
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|