pxt-common-packages 10.2.3 → 10.2.5
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 +5 -3
- package/built/common-sim.js +40 -17
- 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 +7386 -7294
- package/libs/controller---none/built/debug/binary.js +7365 -7273
- 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 +7278 -7186
- package/libs/game/multiplayer.cpp +1 -4
- package/libs/game/multiplayer.ts +13 -0
- package/libs/game/scene.ts +2 -0
- package/libs/game/sim/keymap.ts +1 -1
- package/libs/game/sim/multiplayer.ts +20 -14
- 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/mqtt/built/debug/binary.js +176 -176
- package/libs/net/built/debug/binary.js +176 -176
- package/libs/net-game/built/debug/binary.js +9066 -8974
- package/libs/palette/built/debug/binary.js +7277 -7185
- 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/built/debug/binary.js +50 -50
- package/libs/screen/sim/state.ts +27 -5
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/built/debug/binary.js +7277 -7185
- package/libs/storyboard/built/debug/binary.js +7277 -7185
- package/package.json +2 -2
|
@@ -2,18 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
namespace multiplayer {
|
|
4
4
|
//%
|
|
5
|
-
void postImage(Image_ im
|
|
6
|
-
// no support >:(
|
|
5
|
+
void postImage(Image_ im) {
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
//%
|
|
10
9
|
void setOrigin(String origin) {
|
|
11
|
-
// no
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
//%
|
|
15
13
|
Image_ getCurrentImage() {
|
|
16
|
-
// nah
|
|
17
14
|
return NULL;
|
|
18
15
|
}
|
|
19
16
|
|
package/libs/game/multiplayer.ts
CHANGED
|
@@ -2,6 +2,9 @@ namespace multiplayer {
|
|
|
2
2
|
//% shim=multiplayer::getCurrentImage
|
|
3
3
|
declare function getCurrentImage(): Image;
|
|
4
4
|
|
|
5
|
+
//% shim=multiplayer::postImage
|
|
6
|
+
declare function postImage(im: Image): void;
|
|
7
|
+
|
|
5
8
|
//% shim=multiplayer::setOrigin
|
|
6
9
|
declare function setOrigin(origin: string): void;
|
|
7
10
|
|
|
@@ -21,4 +24,14 @@ namespace multiplayer {
|
|
|
21
24
|
});
|
|
22
25
|
game.pushScene();
|
|
23
26
|
}
|
|
27
|
+
|
|
28
|
+
export function initServer() {
|
|
29
|
+
if (getOrigin() === "server") {
|
|
30
|
+
game.eventContext().registerFrameHandler(scene.MULTIPLAYER_POST_SCREEN_PRIORITY, () => {
|
|
31
|
+
if (getOrigin() === "server") {
|
|
32
|
+
postImage(screen);
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
24
37
|
}
|
package/libs/game/scene.ts
CHANGED
|
@@ -65,6 +65,7 @@ namespace scene {
|
|
|
65
65
|
export const RENDER_DIAGNOSTICS_PRIORITY = 150;
|
|
66
66
|
export const MULTIPLAYER_SCREEN_PRIORITY = 190;
|
|
67
67
|
export const UPDATE_SCREEN_PRIORITY = 200;
|
|
68
|
+
export const MULTIPLAYER_POST_SCREEN_PRIORITY = 210;
|
|
68
69
|
|
|
69
70
|
// default rendering z indices
|
|
70
71
|
export const ON_PAINT_Z = -20;
|
|
@@ -179,6 +180,7 @@ namespace scene {
|
|
|
179
180
|
});
|
|
180
181
|
// update screen
|
|
181
182
|
this.eventContext.registerFrameHandler(UPDATE_SCREEN_PRIORITY, control.__screen.update);
|
|
183
|
+
multiplayer.initServer();
|
|
182
184
|
// register additional components
|
|
183
185
|
Scene.initializers.forEach(f => f(this));
|
|
184
186
|
}
|
package/libs/game/sim/keymap.ts
CHANGED
|
@@ -160,7 +160,7 @@ namespace pxsim {
|
|
|
160
160
|
|
|
161
161
|
private clearMap(name: string) {
|
|
162
162
|
const keyCodes = this.mappings[name];
|
|
163
|
-
keyCodes
|
|
163
|
+
keyCodes && keyCodes.forEach(keyCode => delete this.keymap[keyCode]);
|
|
164
164
|
delete this.mappings[name];
|
|
165
165
|
}
|
|
166
166
|
}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
namespace pxsim.multiplayer {
|
|
2
|
-
|
|
2
|
+
const throttledImgPost = pxsim.U.throttle((msg: MultiplayerImageMessage) =>{
|
|
3
|
+
getMultiplayerState().send(msg);
|
|
4
|
+
}, 50, true);
|
|
5
|
+
|
|
6
|
+
export function postImage(im: pxsim.RefImage) {
|
|
7
|
+
if (getMultiplayerState().origin !== "server")
|
|
8
|
+
return;
|
|
3
9
|
const asBuf = pxsim.image.toBuffer(im);
|
|
4
|
-
|
|
10
|
+
const sb = board() as ScreenBoard;
|
|
11
|
+
throttledImgPost(<MultiplayerImageMessage>{
|
|
5
12
|
content: "Image",
|
|
6
13
|
image: asBuf,
|
|
7
|
-
|
|
14
|
+
palette: sb?.screenState?.paletteToUint8Array(),
|
|
8
15
|
});
|
|
9
16
|
}
|
|
10
17
|
|
|
18
|
+
|
|
11
19
|
export function getCurrentImage(): pxsim.RefImage {
|
|
12
20
|
return getMultiplayerState().backgroundImage;
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
export function setOrigin(origin: "client" | "server" | undefined) {
|
|
16
24
|
getMultiplayerState().origin = origin;
|
|
25
|
+
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
export function getOrigin(): string {
|
|
@@ -41,8 +50,9 @@ namespace pxsim {
|
|
|
41
50
|
|
|
42
51
|
export interface MultiplayerImageMessage extends SimulatorMultiplayerMessage {
|
|
43
52
|
content: "Image";
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
image: RefBuffer;
|
|
54
|
+
// 48bytes, [r0,g0,b0,r1,g1,b1,...]
|
|
55
|
+
palette: Uint8Array;
|
|
46
56
|
}
|
|
47
57
|
|
|
48
58
|
export interface MultiplayerButtonEvent extends SimulatorMultiplayerMessage {
|
|
@@ -74,14 +84,6 @@ namespace pxsim {
|
|
|
74
84
|
init(origin: string) {
|
|
75
85
|
this.origin = origin;
|
|
76
86
|
runtime.board.addMessageListener(msg => this.messageHandler(msg));
|
|
77
|
-
setInterval(() => {
|
|
78
|
-
if (this.origin === "server") {
|
|
79
|
-
const b = board() as ScreenBoard;
|
|
80
|
-
const screenState = b && b.screenState;
|
|
81
|
-
const lastImage = screenState && screenState.lastImage;
|
|
82
|
-
lastImage && pxsim.multiplayer.postImage(lastImage, "broadcast-screen");
|
|
83
|
-
}
|
|
84
|
-
}, 50);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
setButton(key: number, isPressed: boolean) {
|
|
@@ -106,10 +108,14 @@ namespace pxsim {
|
|
|
106
108
|
msg.image.data = new Uint8Array(msg.image.data);
|
|
107
109
|
}
|
|
108
110
|
this.backgroundImage = pxsim.image.ofBuffer(msg.image);
|
|
111
|
+
if (msg.palette?.length === 48) {
|
|
112
|
+
const palBuffer = new pxsim.RefBuffer(msg.palette)
|
|
113
|
+
pxsim.pxtcore.setPalette(palBuffer);
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
} else if (isButtonMessage(msg)) {
|
|
111
117
|
if (this.origin === "server") {
|
|
112
|
-
(board() as any).
|
|
118
|
+
(board() as any).handleKeyEvent(
|
|
113
119
|
msg.button + (7 * (msg.clientNumber || 1)), // + 7 to make it player 2 controls,
|
|
114
120
|
msg.state === "Pressed" || msg.state === "Held"
|
|
115
121
|
);
|
|
@@ -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___P48498(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___48741 = (undefined);
|
|
70
|
+
globals._pollEventQueue___48754 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P48498.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"characterlcd.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P48498.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P48498_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P48498, 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___P48480_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P48498
|
|
92
92
|
})
|
|
@@ -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___P97826(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___98069 = (undefined);
|
|
70
|
+
globals._pollEventQueue___98082 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P97826.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"tsl2591.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P97826.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P97826_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P97826, 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___P97772_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P97826
|
|
92
92
|
})
|
|
@@ -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___P59800(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___60043 = (undefined);
|
|
70
|
+
globals._pollEventQueue___60056 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P59800.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"lora.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P59800.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P59800_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P59800, 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___P59782_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P59800
|
|
92
92
|
})
|
|
@@ -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___P190006(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___190249 = (undefined);
|
|
70
|
+
globals._pollEventQueue___190262 = (undefined);
|
|
71
71
|
r0 = undefined;
|
|
72
72
|
return leave(s, r0)
|
|
73
73
|
default: oops()
|
|
74
74
|
} } }
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
_main___P190006.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
|
|
76
|
+
_main___P190006.continuations = [ ]
|
|
77
77
|
|
|
78
|
-
function
|
|
78
|
+
function _main___P190006_mk(s) {
|
|
79
79
|
checkStack(s.depth);
|
|
80
80
|
return {
|
|
81
|
-
parent: s, fn:
|
|
81
|
+
parent: s, fn: _main___P190006, 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___P189880_mk(s) {
|
|
|
88
88
|
|
|
89
89
|
const breakpoints = setupDebugger(1, [])
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return _main___P190006
|
|
92
92
|
})
|