-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathffi.mbt
107 lines (84 loc) · 2.48 KB
/
ffi.mbt
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright 2024 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Addresses: https://wasm4.org/docs/reference/memory#memory-map
///|
let address_PALETTE = 0x4
///|
let address_DRAW_COLORS = 0x14
///|
let address_GAMEPADS = 0x16
///|
let address_MOUSE_X = 0x1a
///|
let address_MOUSE_Y = 0x1c
///|
let address_MOUSE_BUTTONS = 0x1e
///|
let address_SYSTEM_FLAGS = 0x1f
///|
let address_NETPLAY = 0x20
///|
let address_FRAMEBUFFER = 0xa0
///|
extern "wasm" fn load_byte(offset : Int) -> Byte =
#|(func (param i32) (result i32) (i32.load8_u (local.get 0)))
///|
extern "wasm" fn store_byte(offset : Int, byte : Byte) =
#|(func (param i32) (param i32) (i32.store8 (local.get 0) (local.get 1)))
///|
extern "wasm" fn load_s16(offset : Int) -> Int =
#|(func (param i32) (result i32) (i32.load16_s (local.get 0)))
///|
extern "wasm" fn load_u16(offset : Int) -> UInt =
#|(func (param i32) (result i32) (i32.load16_u (local.get 0)))
///|
extern "wasm" fn store_i16(offset : Int, value : Int) =
#|(func (param i32) (param i32) (i32.store16 (local.get 0) (local.get 1)))
///|
extern "wasm" fn load_s32(offset : Int) -> Int =
#|(func (param i32) (result i32) (i32.load (local.get 0)))
///|
extern "wasm" fn store_i32(offset : Int, value : Int) =
#|(func (param i32) (param i32) (i32.store (local.get 0) (local.get 1)))
///|
fn blit_ffi(
spritePtr : Int,
x : Int,
y : Int,
width : Int,
height : Int,
flags : Int
) = "env" "blit"
///|
fn blit_sub_ffi(
spritePtr : Int,
x : Int,
y : Int,
width : Int,
height : Int,
src_x : Int,
src_y : Int,
stride : Int,
flags : Int
) = "env" "blitSub"
///|
fn text_ffi(str : Int, x : Int, y : Int) = "env" "text"
///|
fn tone_ffi(frequency : UInt, duration : UInt, volume : UInt, flags : UInt) = "env" "tone"
///|
fn trace_ffi(offset : Int) = "env" "trace"
///|
fn diskr_ffi(ptr : Int, size : Int) -> Int = "env" "diskr"
///|
fn diskw_ffi(ptr : Int, size : Int) -> Int = "env" "diskw"