nwlink 0.0.7 → 0.0.10

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/README.md CHANGED
@@ -6,7 +6,7 @@ Simply install it with `npm install -g nwlink`, the run `nwlink --help` to get a
6
6
 
7
7
  ### About binutils
8
8
 
9
- The `ld.wasm` and `objcopy.wasm` files are distributed under the GNU GPL license, version 2. They are built from the unmodified sources of binutils version 2.38. To regenerate them, install emscripten 3.1.9-asserts and binutils 2.38, then run the following commands:
9
+ This modules contains two WebAssembly files, `ld.wasm` and `objcopy.wasm`. Those files (and only those files) are distributed under the GNU GPL license, version 2. They are built from the unmodified sources of binutils version 2.38. To regenerate them, install emscripten 3.1.9-asserts and binutils 2.38, then run the following commands:
10
10
 
11
11
  ```sh
12
12
  source emsdk/emsdk_env.sh
@@ -25,4 +25,4 @@ emconfigure ../configure \
25
25
  emmake make
26
26
  ```
27
27
 
28
- Note that these two web assembly modules can be re-used separately, and the rest of the code communicates with them using command-line arguments. They are therefore included here as a [mere aggregate](https://www.gnu.org/licenses/gpl-faq.html#MereAggregation) and the GNU GPL license subsequently does *not* apply to the rest of the provided files.
28
+ Note that these two WebAssembly files can be re-used separately, and the rest of the code communicates with them using command-line arguments. They are therefore included here as a [mere aggregate](https://www.gnu.org/licenses/gpl-faq.html#MereAggregation) and the GNU GPL license subsequently does *not* apply to the rest of the provided files.
@@ -0,0 +1,114 @@
1
+ #ifndef EADK_H
2
+ #define EADK_H
3
+
4
+ #include <stdbool.h>
5
+ #include <stdint.h>
6
+
7
+ // Types and constants
8
+ typedef uint16_t eadk_color_t;
9
+
10
+ static const eadk_color_t eadk_color_black = 0x0;
11
+ static const eadk_color_t eadk_color_white = 0xFFFF;
12
+ static const eadk_color_t eadk_color_red = 0xF800;
13
+ static const eadk_color_t eadk_color_green = 0x07E0;
14
+ static const eadk_color_t eadk_color_blue = 0x001F;
15
+
16
+ typedef struct {
17
+ uint16_t x;
18
+ uint16_t y;
19
+ } eadk_point_t;
20
+
21
+ typedef struct {
22
+ uint16_t x;
23
+ uint16_t y;
24
+ uint16_t width;
25
+ uint16_t height;
26
+ } eadk_rect_t;
27
+
28
+ static const eadk_rect_t eadk_screen_rect = {0, 0, 320, 240};
29
+
30
+ typedef uint64_t eadk_keyboard_state_t;
31
+ typedef enum {
32
+ eadk_key_left = 0,
33
+ eadk_key_up = 1,
34
+ eadk_key_down = 2,
35
+ eadk_key_right = 3,
36
+ eadk_key_ok = 4,
37
+ eadk_key_back = 5,
38
+ eadk_key_home = 6,
39
+ eadk_key_on_off = 8,
40
+ eadk_key_shift = 12,
41
+ eadk_key_alpha = 13,
42
+ eadk_key_xnt = 14,
43
+ eadk_key_var = 15,
44
+ eadk_key_toolbox = 16,
45
+ eadk_key_backspace = 17,
46
+ eadk_key_exp = 18,
47
+ eadk_key_ln = 19,
48
+ eadk_key_log = 20,
49
+ eadk_key_imaginary = 21,
50
+ eadk_key_comma = 22,
51
+ eadk_key_power = 23,
52
+ eadk_key_sine = 24,
53
+ eadk_key_cosine = 25,
54
+ eadk_key_tangent = 26,
55
+ eadk_key_pi = 27,
56
+ eadk_key_sqrt = 28,
57
+ eadk_key_square = 29,
58
+ eadk_key_seven = 30,
59
+ eadk_key_eight = 31,
60
+ eadk_key_nine = 32,
61
+ eadk_key_left_parenthesis = 33,
62
+ eadk_key_right_parenthesis = 34,
63
+ eadk_key_four = 36,
64
+ eadk_key_five = 37,
65
+ eadk_key_six = 38,
66
+ eadk_key_multiplication = 39,
67
+ eadk_key_division = 40,
68
+ eadk_key_one = 42,
69
+ eadk_key_two = 43,
70
+ eadk_key_three = 44,
71
+ eadk_key_plus = 45,
72
+ eadk_key_minus = 46,
73
+ eadk_key_zero = 48,
74
+ eadk_key_dot = 49,
75
+ eadk_key_ee = 50,
76
+ eadk_key_ans = 51,
77
+ eadk_key_exe = 52
78
+ } eadk_key_t;
79
+
80
+ static inline bool eadk_keyboard_key_down(eadk_keyboard_state_t state, eadk_key_t key) {
81
+ return (state>>(uint8_t)key) & 1;
82
+ }
83
+
84
+ // Backlight
85
+ void eadk_backlight_set_brightness(uint8_t brightness);
86
+ uint8_t eadk_backlight_brightness();
87
+
88
+ // Battery
89
+ bool eadk_battery_is_charging();
90
+ uint8_t eadk_battery_level();
91
+ float eadk_battery_voltage();
92
+
93
+ // Display
94
+ void eadk_display_push_rect(eadk_rect_t rect, const eadk_color_t * pixels);
95
+ void eadk_display_push_rect_uniform(eadk_rect_t rect, eadk_color_t color);
96
+ void eadk_display_pull_rect(eadk_rect_t rect, eadk_color_t * pixels);
97
+ bool eadk_display_wait_for_vblank();
98
+ void eadk_display_draw_string(const char * text, eadk_point_t point, bool large_font, eadk_color_t text_color, eadk_color_t background_color);
99
+
100
+ // Keyboard
101
+ eadk_keyboard_state_t eadk_keyboard_scan();
102
+
103
+ // Timing
104
+ void eadk_timing_usleep(uint32_t us);
105
+ void eadk_timing_msleep(uint32_t ms);
106
+ uint64_t eadk_timing_millis();
107
+
108
+ extern const unsigned char eadk_external_data[];
109
+
110
+ // Misc
111
+ bool eadk_usb_is_plugged();
112
+ uint32_t eadk_random();
113
+
114
+ #endif