WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Source
  4. cubios.rs
Mission NodeSDK 6.3Rustcubios.rs

cubios.rs

SDK Source File: cubios.rs

Source / SDK 6.3 / Rust / Core

cubios.rs

cubios.rs
RUST
1#[allow(dead_code)]
2pub static mut CUBE_N: u32 = 0;
3
4
5#[allow(dead_code)]
6#[repr(C)]
7pub enum UartId {
8 Uart0 = 0,
9 Uart1,
10 Uart2
11}
12
13pub type SoundId = cty::uint32_t;
14pub type SpriteId = cty::uint32_t;
15
16#[allow(dead_code)]
17#[repr(C)]
18pub struct TopologyFaceletInfo {
19 pub module: cty::int32_t,
20 pub screen: cty::int32_t,
21 pub connected: cty::int32_t,
22}
23
24#[allow(dead_code)]
25#[repr(C)]
26pub struct TopologyPlace {
27 pub face: cty::int32_t,
28 pub position: cty::int32_t,
29}
30
31#[allow(dead_code)]
32#[repr(C)]
33#[derive(Debug, Clone, Copy)]
34pub enum TopologyNeighbour {
35 None = 0,
36 Left,
37 Diagonal,
38 Top,
39 Right,
40 Bottom,
41}
42
43#[allow(dead_code)]
44#[repr(C)]
45pub struct TopologyTwistInfo {
46 pub screen: cty::int32_t,
47 pub count: cty::int32_t,
48 pub direction: cty::int32_t,
49}
50
51#[allow(dead_code)]
52#[repr(C)]
53pub enum TopologyOrientation {
54 Menu = 0,
55 Gravity,
56 Splash,
57 Max,
58}
59
60#[allow(dead_code)]
61#[repr(C)]
62pub enum TextAlign{
63 Center = 0,
64 TopCenter,
65 BottomCenter,
66 LeftCorner,
67 LeftTopCorner,
68 LeftBottomCorner,
69 RightCorner,
70 RightTopCorner,
71 RightBottomCorner,
72}
73
74#[allow(dead_code)]
75#[repr(C)]
76#[derive(PartialEq)]
77pub enum TopologyLocation {
78 Up = 0,
79 Down,
80 Front,
81 Back,
82 Left,
83 Right,
84 Max,
85}
86
87#[allow(dead_code)]
88#[repr(C)]
89pub struct LbInfo {
90 pub board_count: cty::int32_t,
91 pub self_position: cty::int32_t,
92 pub self_achivement: cty::int32_t,
93 pub whole_user_list_count: cty::int32_t,
94}
95
96#[allow(dead_code)]
97#[repr(C)]
98pub struct GfxParticle {
99 pub ttl: cty::int32_t,
100 pub vx: cty::int32_t,
101 pub vy: cty::int32_t,
102 pub ax: cty::int32_t,
103 pub ay: cty::int32_t,
104 pub explosion: cty::int32_t,
105 pub velocity: cty::int32_t,
106 pub duration: cty::int32_t,
107 pub frequency: cty::int32_t,
108 pub max: cty::int32_t,
109 pub r#loop: cty::int32_t,
110 pub time: cty::int32_t,
111}
112
113#[allow(dead_code)]
114static NET_BROADCAST: u32 = 0xFF;
115
116#[allow(dead_code)]
117#[repr(C)]
118pub enum LogLevel {
119 Assert,
120 Error,
121 Warn,
122 Info,
123 Debug,
124 Verbose
125}
126
127extern "C" {
128 fn sendMessage(line: cty::uint32_t, dest: cty::uint32_t, pkt: *const cty::uint8_t, size: cty::uint32_t) -> cty::int32_t;
129 fn recvMessage(line: cty::uint32_t, size: cty::uint32_t, pktInfo: *mut cty::uint32_t, pkt: *mut u8, rxSize: *mut cty::uint32_t) -> cty::int32_t;
130 fn getTime() -> cty::int32_t;
131 fn getUserName(buffer: *mut cty::uint8_t, bufSize: cty::uint32_t) -> cty::int32_t;
132 fn toggleDebugInfo() -> cty::int32_t;
133 fn saveState(data: *const cty::uint8_t, size: cty::uint32_t) -> cty::int32_t;
134 fn loadState(data: *mut cty::uint8_t, size: cty::uint32_t) -> cty::int32_t;
135 fn random(min: cty::uint32_t, max: cty::uint32_t) -> cty::int32_t;
136 fn LOG(level: cty::uint8_t, text: *const cty::c_char) -> cty::int32_t;
137 fn getTap() -> cty::int32_t;
138
139 fn EVENT_getList() -> cty::int32_t;
140
141 fn GFX_getAssetId(spriteName: *const cty::c_char) -> cty::int32_t;
142 fn GFX_clear(color: cty::uint32_t) -> cty::int32_t;
143 fn GFX_drawText(x: cty::uint32_t, y: cty::uint32_t, scale: cty::uint32_t, angle: cty::uint32_t, align: cty::uint32_t, color: cty::uint32_t, text: *const cty::c_char) -> cty::int32_t;
144 fn GFX_drawPoint(x: cty::int32_t, y: cty::int32_t, color: cty::uint32_t) -> cty::int32_t;
145 fn GFX_drawCircle(x: cty::int32_t, y: cty::int32_t, radius: cty::uint32_t, width: cty::uint32_t, color: cty::uint32_t) -> cty::int32_t;
146 fn GFX_drawSolidCircle(x: cty::int32_t, y: cty::int32_t, radius: cty::uint32_t, color: cty::uint32_t) -> cty::int32_t;
147 fn GFX_drawArc(x: cty::int32_t, y: cty::int32_t, radius: cty::uint32_t, width: cty::uint32_t, angle0: cty::uint32_t , angle1: cty::uint32_t, color: cty::uint32_t) -> cty::int32_t;
148 fn GFX_drawSector(x: cty::int32_t, y: cty::int32_t, radius: cty::uint32_t, angle0: cty::uint32_t, angle1: cty::uint32_t, color: cty::uint32_t) -> cty::int32_t;
149 fn GFX_drawLine(x0: cty::int32_t, y0: cty::int32_t, x1: cty::int32_t, y1: cty::int32_t, thickness: cty::uint32_t, color: cty::uint32_t) -> cty::int32_t;
150 fn GFX_drawRectangle(x: cty::int32_t, y: cty::int32_t, w: cty::int32_t, h: cty::int32_t, color: cty::uint32_t) -> cty::int32_t;
151 fn GFX_bakeImage(id: SpriteId, width: cty::uint32_t , height: cty::uint32_t, replace: cty::uint32_t, overwrite: cty::uint32_t) -> cty::int32_t;
152 fn GFX_setRenderTarget(display: cty::uint32_t) -> cty::int32_t;
153 fn GFX_drawImage(id: SpriteId, x: cty::int32_t, y: cty::int32_t, alpha: cty::uint32_t, color: cty::uint32_t, scale_x: cty::uint32_t, scale_y: cty::uint32_t, angle: cty::uint32_t, mirror: cty::uint32_t) -> cty::int32_t;
154 fn GFX_drawBakedImage(x: cty::int32_t, y: cty::int32_t, color: cty::uint32_t, alpha: cty::uint32_t, scale_x: cty::uint32_t, scale_y: cty::uint32_t, angle: cty::uint32_t, mirror: cty::uint32_t, id: SpriteId) -> cty::int32_t;
155 fn GFX_render() -> cty::int32_t;
156 fn GFX_clearCache() -> cty::int32_t;
157 fn GFX_cacheImages(spriteIDs: *const SpriteId, count: cty::uint32_t) -> cty::int32_t;
158
159 fn TOPOLOGY_getAdjacentFacelet(module: cty::uint32_t, screen: cty::uint32_t, direction: TopologyNeighbour, result: *mut TopologyFaceletInfo) -> cty::int32_t;
160 fn TOPOLOGY_getFacelet(face: cty::uint32_t, position: cty::uint32_t, mode: TopologyOrientation, result: *mut TopologyFaceletInfo) -> cty::int32_t;
161 fn TOPOLOGY_getPlace(module: cty::uint32_t, screen: cty::uint32_t, mode: TopologyOrientation, result: *mut TopologyPlace) -> cty::int32_t;
162 fn TOPOLOGY_getOppositeFacelet(module: cty::uint32_t, screen: cty::uint32_t, result: *mut TopologyFaceletInfo) -> cty::int32_t;
163 fn TOPOLOGY_getAngle(module: cty::uint32_t, screen: cty::uint32_t, mode: TopologyOrientation) -> cty::int32_t;
164 fn TOPOLOGY_getFaceletOrientation(module: cty::uint32_t, screen: cty::uint32_t) -> cty::int32_t;
165 fn TOPOLOGY_getPlaceOrientation(face: cty::uint32_t, position: cty::uint32_t) -> cty::int32_t;
166 fn TOPOLOGY_getFace(orientation: cty::uint32_t) -> cty::int32_t;
167 fn TOPOLOGY_isAssembled() -> cty::int32_t;
168 fn TOPOLOGY_getTwist(twist: *mut TopologyTwistInfo) -> cty::int32_t;
169 fn TopologyDebugGetFace(module: cty::uint32_t, screen: cty::uint32_t) -> cty::int32_t;
170 fn TopologyDebugGetPosition(module: cty::uint32_t, screen: cty::uint32_t) -> cty::int32_t;
171 fn TopologyDebugGetHorizontal() -> cty::int32_t;
172
173 fn LB_getInfo(info: *mut LbInfo) -> cty::int32_t;
174 fn LB_getScore(leadTableBin: *mut cty::uint8_t, bufSize: cty::uint32_t) -> cty::int32_t;
175
176 fn MS_getFaceAccelX(display: cty::uint32_t) -> cty::int32_t;
177 fn MS_getFaceAccelY(display: cty::uint32_t) -> cty::int32_t;
178 fn MS_getFaceAccelZ(display: cty::uint32_t) -> cty::int32_t;
179 fn MS_getFaceGyroX(display: cty::uint32_t) -> cty::int32_t;
180 fn MS_getFaceGyroY(display: cty::uint32_t) -> cty::int32_t;
181 fn MS_getFaceGyroZ(display: cty::uint32_t) -> cty::int32_t;
182
183 fn SND_getAssetId(soundName: *const cty::c_char) -> cty::int32_t;
184 fn SND_play(soundID: SoundId, volume: cty::uint32_t) -> cty::int32_t;
185 fn SND_cacheSounds(soundIDs: *const SoundId, count: cty::uint32_t) -> cty::int32_t;
186}
187
188pub fn on_init(cid: u32) {
189 unsafe {
190 CUBE_N = cid;
191 }
192}
193
194#[allow(dead_code)]
195pub mod gfx {
196 use std::ffi::CString;
197
198 pub fn get_asset_id(sprite_name: &str) -> i32 {
199 let c_str = CString::new(sprite_name).unwrap();
200 return unsafe { super::GFX_getAssetId(c_str.as_ptr() as *const cty::c_char) };
201 }
202
203 pub fn clear(color: u32) -> i32 {
204 return unsafe { super::GFX_clear(color) };
205 }
206
207 pub fn draw_text(x: u32, y: u32, scale: u32, angle: u32, align: super::TextAlign, color: u32, text: &str) -> i32 {
208 let c_str = CString::new(text).unwrap();
209 return unsafe { super::GFX_drawText(x, y, scale, angle, align as u32, color, c_str.as_ptr() as *const cty::c_char) };
210 }
211
212 pub fn draw_point(x: i32, y: i32, color: u32) -> i32 {
213 return unsafe { super::GFX_drawPoint(x, y, color) };
214 }
215
216 pub fn draw_circle(x: i32, y: i32, radius: u32, width: u32, color: u32) -> i32 {
217 return unsafe { super::GFX_drawCircle(x, y, radius, width, color) };
218 }
219
220 pub fn draw_solid_circle(x: i32, y: i32, radius: u32, color: u32) -> i32 {
221 return unsafe { super::GFX_drawSolidCircle(x, y, radius, color) };
222 }
223
224 pub fn draw_arc(x: i32, y: i32, radius: u32, width: u32, angle0: u32, angle1: u32, color: u32) -> i32 {
225 return unsafe { super::GFX_drawArc(x, y, radius, width, angle0, angle1, color) };
226 }
227
228 pub fn draw_sector(x: i32, y: i32, radius: u32, angle0: u32, angle1: u32, color: u32) -> i32 {
229 return unsafe { super::GFX_drawSector(x, y, radius, angle0, angle1, color) };
230 }
231
232 pub fn draw_line(x0: i32, y0: i32, x1: i32, y1: i32, thickness: u32, color: u32) -> i32 {
233 return unsafe { super::GFX_drawLine(x0, y0, x1, y1, thickness, color) };
234 }
235
236 pub fn draw_rectangle(x: i32, y: i32, w: i32, h: i32, color: u32) -> i32 {
237 return unsafe { super::GFX_drawRectangle(x, y, w, h, color) };
238 }
239
240 pub fn bake_image(id: super::SpriteId, width: u32 , height: u32, replace: u32, overwrite: u32) -> i32 {
241 return unsafe { super::GFX_bakeImage(id, width, height, replace, overwrite) };
242 }
243
244 pub fn set_render_target(display: u8) -> i32 {
245 return unsafe { super::GFX_setRenderTarget(display as u32) };
246 }
247
248 pub fn draw_image(id: super::SpriteId, x: i32, y: i32, color: u32, alpha: u32, scale_x: u32, scale_y: u32, angle: u32, mirror: u32) -> i32 {
249 return unsafe { super::GFX_drawImage(id, x, y, alpha, color, scale_x, scale_y, angle, mirror) };
250 }
251
252 pub fn draw_baked_image(x: i32, y: i32, color: u32, alpha: u32, scale_x: u32, scale_y: u32, angle: u32, mirror: u32, id: super::SpriteId) -> i32 {
253 return unsafe { super::GFX_drawBakedImage(x, y, color, alpha, scale_x, scale_y, angle, mirror, id) };
254 }
255
256 pub fn render() -> i32 {
257 return unsafe { super::GFX_render() };
258 }
259
260 pub fn clear_cache() -> i32 {
261 return unsafe { super::GFX_clearCache() };
262 }
263
264 pub fn cache_images(sprite_ids: &[super::SpriteId]) -> i32 {
265 return unsafe { super::GFX_cacheImages(sprite_ids.as_ptr(), sprite_ids.len() as u32) };
266 }
267}
268
269#[allow(dead_code)]
270pub mod topology {
271 const REVERSED_FACES: [u32; 6] = [3, 5, 4, 0, 2, 1];
272
273 pub fn get_cuben() -> u32 {
274 unsafe {
275 super::CUBE_N
276 }
277 }
278
279 pub fn get_adjacent_facelet(module: u32, screen: u32, direction: super::TopologyNeighbour, result: *mut super::TopologyFaceletInfo) -> i32 {
280 return unsafe { super::TOPOLOGY_getAdjacentFacelet(module, screen, direction, result) };
281 }
282
283 pub fn get_reversed_face(face: u32) -> Option<u32> {
284 REVERSED_FACES.get(face as usize).cloned()
285 }
286
287 pub fn get_facelet(face: u32, position: u32, mode: super::TopologyOrientation, result: *mut super::TopologyFaceletInfo) -> i32 {
288 return unsafe { super::TOPOLOGY_getFacelet(face, position, mode, result) };
289 }
290
291 pub fn get_place(module: u32, screen: u32, mode: super::TopologyOrientation, result: *mut super::TopologyPlace) -> i32 {
292 return unsafe { super::TOPOLOGY_getPlace(module, screen, mode, result) };
293 }
294
295 pub fn get_opposite_facelet(module: u32, screen: u32, result: *mut super::TopologyFaceletInfo) -> i32 {
296 return unsafe { super::TOPOLOGY_getOppositeFacelet(module, screen, result) };
297 }
298
299 pub fn get_angle(module: u32, screen: u32, mode: super::TopologyOrientation) -> i32 {
300 return unsafe { super::TOPOLOGY_getAngle(module, screen, mode) };
301 }
302
303 pub fn get_facelet_orientation(module: u32, screen: u32) -> i32 {
304 return unsafe { super::TOPOLOGY_getFaceletOrientation(module, screen) };
305 }
306
307 pub fn get_place_orientation(face: u32, position: u32) -> i32 {
308 return unsafe { super::TOPOLOGY_getPlaceOrientation(face, position) };
309 }
310
311 pub fn get_face(orientation: u32) -> i32 {
312 return unsafe { super::TOPOLOGY_getFace(orientation) };
313 }
314
315 pub fn is_assembled() -> i32 {
316 return unsafe { super::TOPOLOGY_isAssembled() };
317 }
318
319 pub fn get_twist(twist: *mut super::TopologyTwistInfo) -> i32 {
320 return unsafe { super::TOPOLOGY_getTwist(twist) };
321 }
322
323 pub fn debug_get_face(module: u32, screen: u32) -> i32 {
324 return unsafe { super::TopologyDebugGetFace(module, screen) };
325 }
326
327 pub fn debug_get_position(module: u32, screen: u32) -> i32 {
328 return unsafe { super::TopologyDebugGetPosition(module, screen) };
329 }
330
331 fn debug_get_horizontal() -> i32 {
332 return unsafe { super::TopologyDebugGetHorizontal() };
333 }
334}
335
336#[allow(dead_code)]
337pub mod comm {
338 use std::ffi::CString;
339
340 pub fn send_message(line: u32, pkt: *const u8, size: u32) -> i32 {
341 return unsafe { super::sendMessage(line, super::NET_BROADCAST, pkt, size) };
342 }
343
344 pub fn recv_message(line: u32, size: u32, pkt_info: *mut u32, pkt: *mut u8, rx_size: *mut u32) -> i32 {
345 return unsafe { super::recvMessage(line, size, pkt_info, pkt, rx_size) };
346 }
347
348 pub fn get_time() -> i32 {
349 return unsafe { super::getTime() };
350 }
351
352 pub fn get_user_name(buffer: &mut [u8]) -> i32 {
353 return unsafe { super::getUserName(buffer.as_mut_ptr(), buffer.len() as u32) };
354 }
355
356 pub fn toggle_debug_info() -> i32 {
357 return unsafe { super::toggleDebugInfo() };
358 }
359
360 pub fn save_state(data: &[u8]) -> i32 {
361 return unsafe { super::saveState(data.as_ptr(), data.len() as u32) };
362 }
363
364 pub fn load_state(data: &mut [u8]) -> i32 {
365 return unsafe { super::loadState(data.as_mut_ptr(), data.len() as u32) };
366 }
367
368 pub fn random(min: u32, max: u32) -> i32 {
369 return unsafe { super::random(min, max) };
370 }
371
372 pub fn log_a( text: &str) -> i32 {
373 let c_str = CString::new(text).unwrap();
374 return unsafe { super::LOG(super::LogLevel::Assert as cty::uint8_t, c_str.as_ptr() as *const cty::uint8_t) };
375 }
376
377 pub fn log_e(text: &str) -> i32 {
378 let c_str = CString::new(text).unwrap();
379 return unsafe { super::LOG(super::LogLevel::Error as cty::uint8_t, c_str.as_ptr() as *const cty::uint8_t) };
380 }
381 pub fn log_w(text: &str) -> i32 {
382 let c_str = CString::new(text).unwrap();
383 return unsafe { super::LOG(super::LogLevel::Warn as cty::uint8_t, c_str.as_ptr() as *const cty::uint8_t) };
384 }
385
386 pub fn log_i(text: &str) -> i32 {
387 let c_str = CString::new(text).unwrap();
388 return unsafe { super::LOG(super::LogLevel::Info as cty::uint8_t, c_str.as_ptr() as *const cty::uint8_t) };
389 }
390
391 pub fn log_d(text: &str) -> i32 {
392 let c_str = CString::new(text).unwrap();
393 return unsafe { super::LOG(super::LogLevel::Debug as cty::uint8_t, c_str.as_ptr() as *const cty::uint8_t) };
394 }
395
396 pub fn log_v(text: &str) -> i32 {
397 let c_str = CString::new(text).unwrap();
398 return unsafe { super::LOG(super::LogLevel::Verbose as cty::uint8_t, c_str.as_ptr() as *const cty::uint8_t) };
399 }
400
401 pub fn get_tap() -> i32 {
402 return unsafe { super::getTap() };
403 }
404}
405
406#[allow(dead_code)]
407pub mod lb {
408 pub fn get_info(info: *mut super::LbInfo) -> i32 {
409 return unsafe { super::LB_getInfo(info) };
410 }
411
412 pub fn get_score(lead_table_bin: &mut [u8]) -> i32 {
413 return unsafe { super::LB_getScore(lead_table_bin.as_mut_ptr(), lead_table_bin.len() as u32) };
414 }
415}
416
417#[allow(dead_code)]
418pub mod ms {
419 pub fn get_face_accel_x(display: u32) -> i32 {
420 return unsafe { super::MS_getFaceAccelX(display) };
421 }
422
423 pub fn get_face_accel_y(display: u32) -> i32 {
424 return unsafe { super::MS_getFaceAccelY(display) };
425 }
426
427 pub fn get_face_accel_z(display: u32) -> i32 {
428 return unsafe { super::MS_getFaceAccelZ(display) };
429 }
430
431 pub fn get_face_gyro_x(display: u32) -> i32 {
432 return unsafe { super::MS_getFaceGyroX(display) };
433 }
434
435 pub fn get_face_gyro_y(display: u32) -> i32 {
436 return unsafe { super::MS_getFaceGyroY(display) };
437 }
438
439 pub fn get_face_gyro_z(display: u32) -> i32 {
440 return unsafe { super::MS_getFaceGyroZ(display) };
441 }
442}
443
444#[allow(dead_code)]
445pub mod snd {
446 use std::ffi::CString;
447
448 pub fn get_asset_id(sound_name: &str) -> i32 {
449 let c_str = CString::new(sound_name).unwrap();
450 return unsafe { super::SND_getAssetId(c_str.as_ptr() as *const cty::c_char) };
451 }
452
453 pub fn play(sound_id: super::SoundId, volume: u32) -> i32 {
454 return unsafe { super::SND_play(sound_id, volume) };
455 }
456
457 pub fn cache_sounds(sound_ids: &[super::SoundId]) -> i32 {
458 return unsafe { super::SND_cacheSounds(sound_ids.as_ptr(), sound_ids.len() as u32) };
459 }
460}
461
462#[allow(dead_code)]
463pub mod event {
464 #[allow(non_camel_case_types)]
465 pub enum Event {
466 ON_NET_UART0_RX = 1 << 0,
467 ON_NET_UART1_RX = 1 << 1,
468 ON_NET_UART2_RX = 1 << 2,
469 ON_PHYSICAL_TICK = 1 << 3,
470 ON_CLOSE = 1 << 4,
471 ON_TWIST = 1 << 5,
472 ON_PAT = 1 << 6,
473 ON_CFG_DATA = (1 << 7),
474 ON_UART_RX = (1 << 8),
475 }
476
477 pub fn get_list() -> cty::int32_t {
478 return unsafe { super::EVENT_getList() };
479 }
480}
481
482
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

application.rs
Source / SDK 6.3 / Rust / Core
lib.rs
Source / SDK 6.3 / Rust / Core
cubios.rs
Source / SDK 6.1 / Rust / Core
cubios.rs
Source / SDK 6.2 / Rust / Core
Previous Node
application.rs
Source / SDK 6.3 / Rust / Core
Next Node
lib.rs
Source / SDK 6.3 / Rust / Core