pr 00.1 created bridges

This commit is contained in:
bQUARKz 2026-02-03 20:04:03 +00:00
parent 60384bf720
commit 0cacf4fed8
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
21 changed files with 940 additions and 87 deletions

2
Cargo.lock generated
View File

@ -2242,7 +2242,7 @@ dependencies = [
] ]
[[package]] [[package]]
name = "prometeu-hinfra" name = "prometeu-hardware-contract"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"serde", "serde",

View File

@ -8,7 +8,7 @@ members = [
"crates/prometeu-compiler", "crates/prometeu-compiler",
"crates/prometeu-analysis", "crates/prometeu-analysis",
"crates/prometeu-lsp", "crates/prometeu-lsp",
"crates/prometeu-hinfra" "crates/prometeu-hardware-contract"
] ]
resolver = "2" resolver = "2"

604
compilation_errors.txt Normal file
View File

@ -0,0 +1,604 @@
Checking prometeu-core v0.1.0 (/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/crates/prometeu-core)
error[E0615]: attempted to take value of method `start` on type `&dyn PadBridge`
--> crates/prometeu-core/src/firmware/firmware_step_hub_home.rs:20:29
|
20 | if ctx.hw.pad().start.down {
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
20 | if ctx.hw.pad().start().down {
| ++
error[E0615]: attempted to take value of method `start` on type `&dyn PadBridge`
--> crates/prometeu-core/src/firmware/firmware_step_crash_screen.rs:27:25
|
27 | if ctx.hw.pad().start.down {
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
27 | if ctx.hw.pad().start().down {
| ++
error[E0615]: attempted to take value of method `up` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:380:28
|
380 | 0 => Some(&pad.up),
| ^^ method, not a field
|
help: use parentheses to call the method
|
380 | 0 => Some(&pad.up()),
| ++
error[E0615]: attempted to take value of method `down` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:381:28
|
381 | 1 => Some(&pad.down),
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
381 | 1 => Some(&pad.down()),
| ++
error[E0615]: attempted to take value of method `left` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:382:28
|
382 | 2 => Some(&pad.left),
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
382 | 2 => Some(&pad.left()),
| ++
error[E0615]: attempted to take value of method `right` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:383:28
|
383 | 3 => Some(&pad.right),
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
383 | 3 => Some(&pad.right()),
| ++
error[E0615]: attempted to take value of method `a` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:384:28
|
384 | 4 => Some(&pad.a),
| ^ method, not a field
|
help: use parentheses to call the method
|
384 | 4 => Some(&pad.a()),
| ++
error[E0615]: attempted to take value of method `b` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:385:28
|
385 | 5 => Some(&pad.b),
| ^ method, not a field
|
help: use parentheses to call the method
|
385 | 5 => Some(&pad.b()),
| ++
error[E0615]: attempted to take value of method `x` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:386:28
|
386 | 6 => Some(&pad.x),
| ^ method, not a field
|
help: use parentheses to call the method
|
386 | 6 => Some(&pad.x()),
| ++
error[E0615]: attempted to take value of method `y` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:387:28
|
387 | 7 => Some(&pad.y),
| ^ method, not a field
|
help: use parentheses to call the method
|
387 | 7 => Some(&pad.y()),
| ++
error[E0615]: attempted to take value of method `l` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:388:28
|
388 | 8 => Some(&pad.l),
| ^ method, not a field
|
help: use parentheses to call the method
|
388 | 8 => Some(&pad.l()),
| ++
error[E0615]: attempted to take value of method `r` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:389:28
|
389 | 9 => Some(&pad.r),
| ^ method, not a field
|
help: use parentheses to call the method
|
389 | 9 => Some(&pad.r()),
| ++
error[E0615]: attempted to take value of method `start` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:390:29
|
390 | 10 => Some(&pad.start),
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
390 | 10 => Some(&pad.start()),
| ++
error[E0615]: attempted to take value of method `select` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:391:29
|
391 | 11 => Some(&pad.select),
| ^^^^^^ method, not a field
|
help: use parentheses to call the method
|
391 | 11 => Some(&pad.select()),
| ++
error[E0615]: attempted to take value of method `up` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:398:27
|
398 | 0 => hw.pad().up.down,
| ^^ method, not a field
|
help: use parentheses to call the method
|
398 | 0 => hw.pad().up().down,
| ++
error[E0615]: attempted to take value of method `down` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:399:27
|
399 | 1 => hw.pad().down.down,
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
399 | 1 => hw.pad().down().down,
| ++
error[E0615]: attempted to take value of method `left` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:400:27
|
400 | 2 => hw.pad().left.down,
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
400 | 2 => hw.pad().left().down,
| ++
error[E0615]: attempted to take value of method `right` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:401:27
|
401 | 3 => hw.pad().right.down,
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
401 | 3 => hw.pad().right().down,
| ++
error[E0615]: attempted to take value of method `a` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:402:27
|
402 | 4 => hw.pad().a.down,
| ^ method, not a field
|
help: use parentheses to call the method
|
402 | 4 => hw.pad().a().down,
| ++
error[E0615]: attempted to take value of method `b` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:403:27
|
403 | 5 => hw.pad().b.down,
| ^ method, not a field
|
help: use parentheses to call the method
|
403 | 5 => hw.pad().b().down,
| ++
error[E0615]: attempted to take value of method `x` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:404:27
|
404 | 6 => hw.pad().x.down,
| ^ method, not a field
|
help: use parentheses to call the method
|
404 | 6 => hw.pad().x().down,
| ++
error[E0615]: attempted to take value of method `y` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:405:27
|
405 | 7 => hw.pad().y.down,
| ^ method, not a field
|
help: use parentheses to call the method
|
405 | 7 => hw.pad().y().down,
| ++
error[E0615]: attempted to take value of method `l` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:406:27
|
406 | 8 => hw.pad().l.down,
| ^ method, not a field
|
help: use parentheses to call the method
|
406 | 8 => hw.pad().l().down,
| ++
error[E0615]: attempted to take value of method `r` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:407:27
|
407 | 9 => hw.pad().r.down,
| ^ method, not a field
|
help: use parentheses to call the method
|
407 | 9 => hw.pad().r().down,
| ++
error[E0615]: attempted to take value of method `start` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:408:28
|
408 | 10 => hw.pad().start.down,
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
408 | 10 => hw.pad().start().down,
| ++
error[E0615]: attempted to take value of method `select` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:409:28
|
409 | 11 => hw.pad().select.down,
| ^^^^^^ method, not a field
|
help: use parentheses to call the method
|
409 | 11 => hw.pad().select().down,
| ++
error[E0609]: no field `sprites` on type `&mut dyn GfxBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:963:34
|
963 | hw.gfx_mut().sprites[index] = crate::model::Sprite {
| ^^^^^^^ unknown field
error[E0615]: attempted to take value of method `x` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1031:41
|
1031 | ret.push_int(hw.touch().x as i64);
| ^ method, not a field
|
help: use parentheses to call the method
|
1031 | ret.push_int(hw.touch().x() as i64);
| ++
error[E0615]: attempted to take value of method `y` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1035:41
|
1035 | ret.push_int(hw.touch().y as i64);
| ^ method, not a field
|
help: use parentheses to call the method
|
1035 | ret.push_int(hw.touch().y() as i64);
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1039:42
|
1039 | ret.push_bool(hw.touch().f.down);
| ^ method, not a field
|
help: use parentheses to call the method
|
1039 | ret.push_bool(hw.touch().f().down);
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1043:42
|
1043 | ret.push_bool(hw.touch().f.pressed);
| ^ method, not a field
|
help: use parentheses to call the method
|
1043 | ret.push_bool(hw.touch().f().pressed);
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1047:42
|
1047 | ret.push_bool(hw.touch().f.released);
| ^ method, not a field
|
help: use parentheses to call the method
|
1047 | ret.push_bool(hw.touch().f().released);
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1051:41
|
1051 | ret.push_int(hw.touch().f.hold_frames as i64);
| ^ method, not a field
|
help: use parentheses to call the method
|
1051 | ret.push_int(hw.touch().f().hold_frames as i64);
| ++
error[E0615]: attempted to take value of method `up` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1057:26
|
1057 | &pad.up, &pad.down, &pad.left, &pad.right,
| ^^ method, not a field
|
help: use parentheses to call the method
|
1057 | &pad.up(), &pad.down, &pad.left, &pad.right,
| ++
error[E0615]: attempted to take value of method `down` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1057:35
|
1057 | &pad.up, &pad.down, &pad.left, &pad.right,
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
1057 | &pad.up, &pad.down(), &pad.left, &pad.right,
| ++
error[E0615]: attempted to take value of method `left` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1057:46
|
1057 | &pad.up, &pad.down, &pad.left, &pad.right,
| ^^^^ method, not a field
|
help: use parentheses to call the method
|
1057 | &pad.up, &pad.down, &pad.left(), &pad.right,
| ++
error[E0615]: attempted to take value of method `right` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1057:57
|
1057 | &pad.up, &pad.down, &pad.left, &pad.right,
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
1057 | &pad.up, &pad.down, &pad.left, &pad.right(),
| ++
error[E0615]: attempted to take value of method `a` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1058:26
|
1058 | &pad.a, &pad.b, &pad.x, &pad.y,
| ^ method, not a field
|
help: use parentheses to call the method
|
1058 | &pad.a(), &pad.b, &pad.x, &pad.y,
| ++
error[E0615]: attempted to take value of method `b` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1058:34
|
1058 | &pad.a, &pad.b, &pad.x, &pad.y,
| ^ method, not a field
|
help: use parentheses to call the method
|
1058 | &pad.a, &pad.b(), &pad.x, &pad.y,
| ++
error[E0615]: attempted to take value of method `x` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1058:42
|
1058 | &pad.a, &pad.b, &pad.x, &pad.y,
| ^ method, not a field
|
help: use parentheses to call the method
|
1058 | &pad.a, &pad.b, &pad.x(), &pad.y,
| ++
error[E0615]: attempted to take value of method `y` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1058:50
|
1058 | &pad.a, &pad.b, &pad.x, &pad.y,
| ^ method, not a field
|
help: use parentheses to call the method
|
1058 | &pad.a, &pad.b, &pad.x, &pad.y(),
| ++
error[E0615]: attempted to take value of method `l` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1059:26
|
1059 | &pad.l, &pad.r, &pad.start, &pad.select,
| ^ method, not a field
|
help: use parentheses to call the method
|
1059 | &pad.l(), &pad.r, &pad.start, &pad.select,
| ++
error[E0615]: attempted to take value of method `r` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1059:34
|
1059 | &pad.l, &pad.r, &pad.start, &pad.select,
| ^ method, not a field
|
help: use parentheses to call the method
|
1059 | &pad.l, &pad.r(), &pad.start, &pad.select,
| ++
error[E0615]: attempted to take value of method `start` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1059:42
|
1059 | &pad.l, &pad.r, &pad.start, &pad.select,
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
1059 | &pad.l, &pad.r, &pad.start(), &pad.select,
| ++
error[E0615]: attempted to take value of method `select` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1059:54
|
1059 | &pad.l, &pad.r, &pad.start, &pad.select,
| ^^^^^^ method, not a field
|
help: use parentheses to call the method
|
1059 | &pad.l, &pad.r, &pad.start, &pad.select(),
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1070:37
|
1070 | ret.push_bool(touch.f.pressed);
| ^ method, not a field
|
help: use parentheses to call the method
|
1070 | ret.push_bool(touch.f().pressed);
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1071:37
|
1071 | ret.push_bool(touch.f.released);
| ^ method, not a field
|
help: use parentheses to call the method
|
1071 | ret.push_bool(touch.f().released);
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1072:37
|
1072 | ret.push_bool(touch.f.down);
| ^ method, not a field
|
help: use parentheses to call the method
|
1072 | ret.push_bool(touch.f().down);
| ++
error[E0615]: attempted to take value of method `f` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1073:36
|
1073 | ret.push_int(touch.f.hold_frames as i64);
| ^ method, not a field
|
help: use parentheses to call the method
|
1073 | ret.push_int(touch.f().hold_frames as i64);
| ++
error[E0615]: attempted to take value of method `x` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1074:36
|
1074 | ret.push_int(touch.x as i64);
| ^ method, not a field
|
help: use parentheses to call the method
|
1074 | ret.push_int(touch.x() as i64);
| ++
error[E0615]: attempted to take value of method `y` on type `&dyn TouchBridge`
--> crates/prometeu-core/src/prometeu_os/prometeu_os.rs:1075:36
|
1075 | ret.push_int(touch.y as i64);
| ^ method, not a field
|
help: use parentheses to call the method
|
1075 | ret.push_int(touch.y() as i64);
| ++
error[E0615]: attempted to take value of method `a` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:28:21
|
28 | if hw.pad().a.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
28 | if hw.pad().a().pressed {
| ++
error[E0615]: attempted to take value of method `b` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:31:28
|
31 | } else if hw.pad().b.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
31 | } else if hw.pad().b().pressed {
| ++
error[E0615]: attempted to take value of method `x` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:34:28
|
34 | } else if hw.pad().x.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
34 | } else if hw.pad().x().pressed {
| ++
error[E0615]: attempted to take value of method `y` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:37:28
|
37 | } else if hw.pad().y.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
37 | } else if hw.pad().y().pressed {
| ++
Some errors have detailed explanations: E0609, E0615.
For more information about an error, try `rustc --explain E0609`.
error: could not compile `prometeu-core` (lib) due to 55 previous errors

69
compilation_errors_2.txt Normal file
View File

@ -0,0 +1,69 @@
Checking prometeu-core v0.1.0 (/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/crates/prometeu-core)
error[E0615]: attempted to take value of method `start` on type `&dyn PadBridge`
--> crates/prometeu-core/src/firmware/firmware_step_hub_home.rs:20:29
|
20 | if ctx.hw.pad().start.down {
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
20 | if ctx.hw.pad().start().down {
| ++
error[E0615]: attempted to take value of method `start` on type `&dyn PadBridge`
--> crates/prometeu-core/src/firmware/firmware_step_crash_screen.rs:27:25
|
27 | if ctx.hw.pad().start.down {
| ^^^^^ method, not a field
|
help: use parentheses to call the method
|
27 | if ctx.hw.pad().start().down {
| ++
error[E0615]: attempted to take value of method `a` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:28:21
|
28 | if hw.pad().a.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
28 | if hw.pad().a().pressed {
| ++
error[E0615]: attempted to take value of method `b` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:31:28
|
31 | } else if hw.pad().b.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
31 | } else if hw.pad().b().pressed {
| ++
error[E0615]: attempted to take value of method `x` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:34:28
|
34 | } else if hw.pad().x.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
34 | } else if hw.pad().x().pressed {
| ++
error[E0615]: attempted to take value of method `y` on type `&dyn PadBridge`
--> crates/prometeu-core/src/prometeu_hub/prometeu_hub.rs:37:28
|
37 | } else if hw.pad().y.pressed {
| ^ method, not a field
|
help: use parentheses to call the method
|
37 | } else if hw.pad().y().pressed {
| ++
For more information about this error, try `rustc --explain E0615`.
error: could not compile `prometeu-core` (lib) due to 6 previous errors

View File

@ -1,5 +1,5 @@
use prometeu_compiler::compiler::compile; use prometeu_compiler::compiler::compile;
use prometeu_core::hardware::{AssetManager, Audio, Gfx, HardwareBridge, MemoryBanks, Pad, Touch}; use prometeu_core::hardware::{AssetBridge, AssetManager, Audio, AudioBridge, Gfx, GfxBridge, HardwareBridge, MemoryBanks, Pad, PadBridge, Touch, TouchBridge};
use prometeu_core::virtual_machine::{HostContext, HostReturn, LogicalFrameEndingReason, NativeInterface, Value, VirtualMachine, VmFault}; use prometeu_core::virtual_machine::{HostContext, HostReturn, LogicalFrameEndingReason, NativeInterface, Value, VirtualMachine, VmFault};
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
@ -33,16 +33,16 @@ impl SimpleHardware {
} }
impl HardwareBridge for SimpleHardware { impl HardwareBridge for SimpleHardware {
fn gfx(&self) -> &Gfx { &self.gfx } fn gfx(&self) -> &dyn GfxBridge { &self.gfx }
fn gfx_mut(&mut self) -> &mut Gfx { &mut self.gfx } fn gfx_mut(&mut self) -> &mut dyn GfxBridge { &mut self.gfx }
fn audio(&self) -> &Audio { &self.audio } fn audio(&self) -> &dyn AudioBridge { &self.audio }
fn audio_mut(&mut self) -> &mut Audio { &mut self.audio } fn audio_mut(&mut self) -> &mut dyn AudioBridge { &mut self.audio }
fn pad(&self) -> &Pad { &self.pad } fn pad(&self) -> &dyn PadBridge { &self.pad }
fn pad_mut(&mut self) -> &mut Pad { &mut self.pad } fn pad_mut(&mut self) -> &mut dyn PadBridge { &mut self.pad }
fn touch(&self) -> &Touch { &self.touch } fn touch(&self) -> &dyn TouchBridge { &self.touch }
fn touch_mut(&mut self) -> &mut Touch { &mut self.touch } fn touch_mut(&mut self) -> &mut dyn TouchBridge { &mut self.touch }
fn assets(&self) -> &AssetManager { &self.assets } fn assets(&self) -> &dyn AssetBridge { &self.assets }
fn assets_mut(&mut self) -> &mut AssetManager { &mut self.assets } fn assets_mut(&mut self) -> &mut dyn AssetBridge { &mut self.assets }
} }
#[test] #[test]

View File

@ -24,7 +24,7 @@ impl AppCrashesStep {
ctx.hw.gfx_mut().present(); ctx.hw.gfx_mut().present();
// If START is pressed, return to the Hub // If START is pressed, return to the Hub
if ctx.hw.pad().start.down { if ctx.hw.pad().start().down {
return Some(FirmwareState::LaunchHub(LaunchHubStep)); return Some(FirmwareState::LaunchHub(LaunchHubStep));
} }

View File

@ -17,7 +17,7 @@ impl HubHomeStep {
ctx.hub.gui_update(ctx.os, ctx.hw); ctx.hub.gui_update(ctx.os, ctx.hw);
if let Some(focused_id) = ctx.hub.window_manager.focused { if let Some(focused_id) = ctx.hub.window_manager.focused {
if ctx.hw.pad().start.down { if ctx.hw.pad().start().down {
ctx.hub.window_manager.remove_window(focused_id); ctx.hub.window_manager.remove_window(focused_id);
} else { } else {
// System App runs here, drawing over the Hub background // System App runs here, drawing over the Hub background

View File

@ -93,6 +93,19 @@ impl<T> BankPolicy<T> {
} }
} }
pub trait AssetBridge {
fn initialize_for_cartridge(&self, assets: Vec<AssetEntry>, preload: Vec<PreloadEntry>, assets_data: Vec<u8>);
fn load(&self, asset_name: &str, slot: SlotRef) -> Result<HandleId, String>;
fn status(&self, handle: HandleId) -> LoadStatus;
fn commit(&self, handle: HandleId);
fn cancel(&self, handle: HandleId);
fn apply_commits(&self);
fn bank_info(&self, kind: BankType) -> BankStats;
fn slot_info(&self, slot: SlotRef) -> SlotStats;
fn find_slot_by_name(&self, asset_name: &str, kind: BankType) -> Option<u8>;
fn shutdown(&self);
}
pub struct AssetManager { pub struct AssetManager {
assets: Arc<RwLock<HashMap<u32, AssetEntry>>>, assets: Arc<RwLock<HashMap<u32, AssetEntry>>>,
name_to_id: Arc<RwLock<HashMap<String, u32>>>, name_to_id: Arc<RwLock<HashMap<String, u32>>>,
@ -123,6 +136,19 @@ struct LoadHandleInfo {
status: LoadStatus, status: LoadStatus,
} }
impl AssetBridge for AssetManager {
fn initialize_for_cartridge(&self, assets: Vec<AssetEntry>, preload: Vec<PreloadEntry>, assets_data: Vec<u8>) { self.initialize_for_cartridge(assets, preload, assets_data) }
fn load(&self, asset_name: &str, slot: SlotRef) -> Result<HandleId, String> { self.load(asset_name, slot) }
fn status(&self, handle: HandleId) -> LoadStatus { self.status(handle) }
fn commit(&self, handle: HandleId) { self.commit(handle) }
fn cancel(&self, handle: HandleId) { self.cancel(handle) }
fn apply_commits(&self) { self.apply_commits() }
fn bank_info(&self, kind: BankType) -> BankStats { self.bank_info(kind) }
fn slot_info(&self, slot: SlotRef) -> SlotStats { self.slot_info(slot) }
fn find_slot_by_name(&self, asset_name: &str, kind: BankType) -> Option<u8> { self.find_slot_by_name(asset_name, kind) }
fn shutdown(&self) { self.shutdown() }
}
impl AssetManager { impl AssetManager {
pub fn new( pub fn new(
assets: Vec<AssetEntry>, assets: Vec<AssetEntry>,

View File

@ -108,6 +108,17 @@ pub enum AudioCommand {
/// - **16 Simultaneous Voices**: Independent volume, pan, and pitch. /// - **16 Simultaneous Voices**: Independent volume, pan, and pitch.
/// - **Sample-based Synthesis**: Plays PCM data stored in SoundBanks. /// - **Sample-based Synthesis**: Plays PCM data stored in SoundBanks.
/// - **Stereo Output**: 48kHz output target. /// - **Stereo Output**: 48kHz output target.
pub trait AudioBridge {
fn play(&mut self, bank_id: u8, sample_id: u16, voice_id: usize, volume: u8, pan: u8, pitch: f64, priority: u8, loop_mode: LoopMode) -> ();
fn play_sample(&mut self, sample: Arc<Sample>, voice_id: usize, volume: u8, pan: u8, pitch: f64, priority: u8, loop_mode: LoopMode) -> ();
fn stop(&mut self, voice_id: usize) -> ();
fn set_volume(&mut self, voice_id: usize, volume: u8) -> ();
fn set_pan(&mut self, voice_id: usize, pan: u8) -> ();
fn set_pitch(&mut self, voice_id: usize, pitch: f64) -> ();
fn is_playing(&self, voice_id: usize) -> bool;
fn clear_commands(&mut self) -> ();
}
pub struct Audio { pub struct Audio {
/// Local state of the hardware voices. This state is used for logic /// Local state of the hardware voices. This state is used for logic
/// (e.g., checking if a sound is still playing) and is synchronized with the Host. /// (e.g., checking if a sound is still playing) and is synchronized with the Host.
@ -119,6 +130,17 @@ pub struct Audio {
pub sound_banks: Arc<dyn SoundBankPoolAccess>, pub sound_banks: Arc<dyn SoundBankPoolAccess>,
} }
impl AudioBridge for Audio {
fn play(&mut self, bank_id: u8, sample_id: u16, voice_id: usize, volume: u8, pan: u8, pitch: f64, priority: u8, loop_mode: LoopMode) { self.play(bank_id, sample_id, voice_id, volume, pan, pitch, priority, loop_mode) }
fn play_sample(&mut self, sample: Arc<Sample>, voice_id: usize, volume: u8, pan: u8, pitch: f64, priority: u8, loop_mode: LoopMode) { self.play_sample(sample, voice_id, volume, pan, pitch, priority, loop_mode) }
fn stop(&mut self, voice_id: usize) { self.stop(voice_id) }
fn set_volume(&mut self, voice_id: usize, volume: u8) { self.set_volume(voice_id, volume) }
fn set_pan(&mut self, voice_id: usize, pan: u8) { self.set_pan(voice_id, pan) }
fn set_pitch(&mut self, voice_id: usize, pitch: f64) { self.set_pitch(voice_id, pitch) }
fn is_playing(&self, voice_id: usize) -> bool { self.is_playing(voice_id) }
fn clear_commands(&mut self) { self.clear_commands() }
}
impl Audio { impl Audio {
/// Initializes the audio system with empty voices and sound bank access. /// Initializes the audio system with empty voices and sound bank access.
pub fn new(sound_banks: Arc<dyn SoundBankPoolAccess>) -> Self { pub fn new(sound_banks: Arc<dyn SoundBankPoolAccess>) -> Self {

View File

@ -41,6 +41,47 @@ pub enum BlendMode {
/// 6. **Scene Fade**: Global brightness/color filter. /// 6. **Scene Fade**: Global brightness/color filter.
/// 7. **HUD Layer**: Fixed UI elements (always on top). /// 7. **HUD Layer**: Fixed UI elements (always on top).
/// 8. **HUD Fade**: Independent fade for the UI. /// 8. **HUD Fade**: Independent fade for the UI.
pub trait GfxBridge {
fn size(&self) -> (usize, usize);
fn front_buffer(&self) -> &[u16];
fn clear(&mut self, color: Color) -> ();
fn fill_rect_blend(&mut self, x: i32, y: i32, w: i32, h: i32, color: Color, mode: BlendMode) -> ();
fn fill_rect(&mut self, x: i32, y: i32, w: i32, h: i32, color: Color) -> ();
fn draw_pixel(&mut self, x: i32, y: i32, color: Color) -> ();
fn draw_line(&mut self, x0: i32, y0: i32, x1: i32, y1: i32, color: Color) -> ();
fn draw_circle(&mut self, xc: i32, yc: i32, r: i32, color: Color) -> ();
fn draw_circle_points(&mut self, xc: i32, yc: i32, x: i32, y: i32, color: Color) -> ();
fn fill_circle(&mut self, xc: i32, yc: i32, r: i32, color: Color) -> ();
fn draw_circle_lines(&mut self, xc: i32, yc: i32, x: i32, y: i32, color: Color) -> ();
fn draw_disc(&mut self, x: i32, y: i32, r: i32, border_color: Color, fill_color: Color) -> ();
fn draw_rect(&mut self, x: i32, y: i32, w: i32, h: i32, color: Color) -> ();
fn draw_square(&mut self, x: i32, y: i32, w: i32, h: i32, border_color: Color, fill_color: Color) -> ();
fn draw_horizontal_line(&mut self, x0: i32, x1: i32, y: i32, color: Color) -> ();
fn draw_vertical_line(&mut self, x: i32, y0: i32, y1: i32, color: Color) -> ();
fn present(&mut self) -> ();
fn render_all(&mut self) -> ();
fn render_layer(&mut self, layer_idx: usize) -> ();
fn render_hud(&mut self) -> ();
fn draw_text(&mut self, x: i32, y: i32, text: &str, color: Color) -> ();
fn draw_char(&mut self, x: i32, y: i32, c: char, color: Color) -> ();
fn layer(&self, index: usize) -> &ScrollableTileLayer;
fn layer_mut(&mut self, index: usize) -> &mut ScrollableTileLayer;
fn hud(&self) -> &HudTileLayer;
fn hud_mut(&mut self) -> &mut HudTileLayer;
fn sprite(&self, index: usize) -> &Sprite;
fn sprite_mut(&mut self, index: usize) -> &mut Sprite;
fn scene_fade_level(&self) -> u8;
fn set_scene_fade_level(&mut self, level: u8);
fn scene_fade_color(&self) -> Color;
fn set_scene_fade_color(&mut self, color: Color);
fn hud_fade_level(&self) -> u8;
fn set_hud_fade_level(&mut self, level: u8);
fn hud_fade_color(&self) -> Color;
fn set_hud_fade_color(&mut self, color: Color);
}
pub struct Gfx { pub struct Gfx {
/// Width of the internal framebuffer in pixels. /// Width of the internal framebuffer in pixels.
w: usize, w: usize,
@ -73,6 +114,47 @@ pub struct Gfx {
priority_buckets: [Vec<usize>; 5], priority_buckets: [Vec<usize>; 5],
} }
impl GfxBridge for Gfx {
fn size(&self) -> (usize, usize) { self.size() }
fn front_buffer(&self) -> &[u16] { self.front_buffer() }
fn clear(&mut self, color: Color) { self.clear(color) }
fn fill_rect_blend(&mut self, x: i32, y: i32, w: i32, h: i32, color: Color, mode: BlendMode) { self.fill_rect_blend(x, y, w, h, color, mode) }
fn fill_rect(&mut self, x: i32, y: i32, w: i32, h: i32, color: Color) { self.fill_rect(x, y, w, h, color) }
fn draw_pixel(&mut self, x: i32, y: i32, color: Color) { self.draw_pixel(x, y, color) }
fn draw_line(&mut self, x0: i32, y0: i32, x1: i32, y1: i32, color: Color) { self.draw_line(x0, y0, x1, y1, color) }
fn draw_circle(&mut self, xc: i32, yc: i32, r: i32, color: Color) { self.draw_circle(xc, yc, r, color) }
fn draw_circle_points(&mut self, xc: i32, yc: i32, x: i32, y: i32, color: Color) { self.draw_circle_points(xc, yc, x, y, color) }
fn fill_circle(&mut self, xc: i32, yc: i32, r: i32, color: Color) { self.fill_circle(xc, yc, r, color) }
fn draw_circle_lines(&mut self, xc: i32, yc: i32, x: i32, y: i32, color: Color) { self.draw_circle_lines(xc, yc, x, y, color) }
fn draw_disc(&mut self, x: i32, y: i32, r: i32, border_color: Color, fill_color: Color) { self.draw_disc(x, y, r, border_color, fill_color) }
fn draw_rect(&mut self, x: i32, y: i32, w: i32, h: i32, color: Color) { self.draw_rect(x, y, w, h, color) }
fn draw_square(&mut self, x: i32, y: i32, w: i32, h: i32, border_color: Color, fill_color: Color) { self.draw_square(x, y, w, h, border_color, fill_color) }
fn draw_horizontal_line(&mut self, x0: i32, x1: i32, y: i32, color: Color) { self.draw_horizontal_line(x0, x1, y, color) }
fn draw_vertical_line(&mut self, x: i32, y0: i32, y1: i32, color: Color) { self.draw_vertical_line(x, y0, y1, color) }
fn present(&mut self) { self.present() }
fn render_all(&mut self) { self.render_all() }
fn render_layer(&mut self, layer_idx: usize) { self.render_layer(layer_idx) }
fn render_hud(&mut self) { self.render_hud() }
fn draw_text(&mut self, x: i32, y: i32, text: &str, color: Color) { self.draw_text(x, y, text, color) }
fn draw_char(&mut self, x: i32, y: i32, c: char, color: Color) { self.draw_char(x, y, c, color) }
fn layer(&self, index: usize) -> &ScrollableTileLayer { &self.layers[index] }
fn layer_mut(&mut self, index: usize) -> &mut ScrollableTileLayer { &mut self.layers[index] }
fn hud(&self) -> &HudTileLayer { &self.hud }
fn hud_mut(&mut self) -> &mut HudTileLayer { &mut self.hud }
fn sprite(&self, index: usize) -> &Sprite { &self.sprites[index] }
fn sprite_mut(&mut self, index: usize) -> &mut Sprite { &mut self.sprites[index] }
fn scene_fade_level(&self) -> u8 { self.scene_fade_level }
fn set_scene_fade_level(&mut self, level: u8) { self.scene_fade_level = level; }
fn scene_fade_color(&self) -> Color { self.scene_fade_color }
fn set_scene_fade_color(&mut self, color: Color) { self.scene_fade_color = color; }
fn hud_fade_level(&self) -> u8 { self.hud_fade_level }
fn set_hud_fade_level(&mut self, level: u8) { self.hud_fade_level = level; }
fn hud_fade_color(&self) -> Color { self.hud_fade_color }
fn set_hud_fade_color(&mut self, color: Color) { self.hud_fade_color = color; }
}
impl Gfx { impl Gfx {
/// Initializes the graphics system with a specific resolution and shared memory banks. /// Initializes the graphics system with a specific resolution and shared memory banks.
pub fn new(w: usize, h: usize, tile_banks: Arc<dyn TileBankPoolAccess>) -> Self { pub fn new(w: usize, h: usize, tile_banks: Arc<dyn TileBankPoolAccess>) -> Self {

View File

@ -1,5 +1,5 @@
use crate::hardware::memory_banks::{SoundBankPoolAccess, SoundBankPoolInstaller, TileBankPoolAccess, TileBankPoolInstaller}; use crate::hardware::memory_banks::{SoundBankPoolAccess, SoundBankPoolInstaller, TileBankPoolAccess, TileBankPoolInstaller};
use crate::hardware::{AssetManager, Audio, Gfx, HardwareBridge, MemoryBanks, Pad, Touch}; use crate::hardware::{AssetBridge, AssetManager, Audio, AudioBridge, Gfx, GfxBridge, HardwareBridge, MemoryBanks, Pad, PadBridge, Touch, TouchBridge};
use std::sync::Arc; use std::sync::Arc;
/// Aggregate structure for all virtual hardware peripherals. /// Aggregate structure for all virtual hardware peripherals.
@ -28,20 +28,20 @@ pub struct Hardware {
} }
impl HardwareBridge for Hardware { impl HardwareBridge for Hardware {
fn gfx(&self) -> &Gfx { &self.gfx } fn gfx(&self) -> &dyn GfxBridge { &self.gfx }
fn gfx_mut(&mut self) -> &mut Gfx { &mut self.gfx } fn gfx_mut(&mut self) -> &mut dyn GfxBridge { &mut self.gfx }
fn audio(&self) -> &Audio { &self.audio } fn audio(&self) -> &dyn AudioBridge { &self.audio }
fn audio_mut(&mut self) -> &mut Audio { &mut self.audio } fn audio_mut(&mut self) -> &mut dyn AudioBridge { &mut self.audio }
fn pad(&self) -> &Pad { &self.pad } fn pad(&self) -> &dyn PadBridge { &self.pad }
fn pad_mut(&mut self) -> &mut Pad { &mut self.pad } fn pad_mut(&mut self) -> &mut dyn PadBridge { &mut self.pad }
fn touch(&self) -> &Touch { &self.touch } fn touch(&self) -> &dyn TouchBridge { &self.touch }
fn touch_mut(&mut self) -> &mut Touch { &mut self.touch } fn touch_mut(&mut self) -> &mut dyn TouchBridge { &mut self.touch }
fn assets(&self) -> &AssetManager { &self.assets } fn assets(&self) -> &dyn AssetBridge { &self.assets }
fn assets_mut(&mut self) -> &mut AssetManager { &mut self.assets } fn assets_mut(&mut self) -> &mut dyn AssetBridge { &mut self.assets }
} }
impl Hardware { impl Hardware {

View File

@ -8,28 +8,28 @@ mod memory_banks;
pub mod hardware; pub mod hardware;
pub use crate::model::HandleId; pub use crate::model::HandleId;
pub use asset::AssetManager; pub use asset::{AssetBridge, AssetManager};
pub use audio::{Audio, AudioCommand, Channel, LoopMode, MAX_CHANNELS, OUTPUT_SAMPLE_RATE}; pub use audio::{Audio, AudioBridge, AudioCommand, Channel, LoopMode, MAX_CHANNELS, OUTPUT_SAMPLE_RATE};
pub use gfx::BlendMode; pub use gfx::BlendMode;
pub use gfx::Gfx; pub use gfx::{Gfx, GfxBridge};
pub use input_signal::InputSignals; pub use input_signal::InputSignals;
pub use memory_banks::MemoryBanks; pub use memory_banks::MemoryBanks;
pub use pad::Pad; pub use pad::{Pad, PadBridge};
pub use touch::Touch; pub use touch::{Touch, TouchBridge};
pub trait HardwareBridge { pub trait HardwareBridge {
fn gfx(&self) -> &Gfx; fn gfx(&self) -> &dyn GfxBridge;
fn gfx_mut(&mut self) -> &mut Gfx; fn gfx_mut(&mut self) -> &mut dyn GfxBridge;
fn audio(&self) -> &Audio; fn audio(&self) -> &dyn AudioBridge;
fn audio_mut(&mut self) -> &mut Audio; fn audio_mut(&mut self) -> &mut dyn AudioBridge;
fn pad(&self) -> &Pad; fn pad(&self) -> &dyn PadBridge;
fn pad_mut(&mut self) -> &mut Pad; fn pad_mut(&mut self) -> &mut dyn PadBridge;
fn touch(&self) -> &Touch; fn touch(&self) -> &dyn TouchBridge;
fn touch_mut(&mut self) -> &mut Touch; fn touch_mut(&mut self) -> &mut dyn TouchBridge;
fn assets(&self) -> &AssetManager; fn assets(&self) -> &dyn AssetBridge;
fn assets_mut(&mut self) -> &mut AssetManager; fn assets_mut(&mut self) -> &mut dyn AssetBridge;
} }

View File

@ -1,6 +1,24 @@
use crate::hardware::input_signal::InputSignals; use crate::hardware::input_signal::InputSignals;
use crate::model::Button; use crate::model::Button;
pub trait PadBridge {
fn begin_frame(&mut self, signals: &InputSignals);
fn any(&self) -> bool;
fn up(&self) -> &Button;
fn down(&self) -> &Button;
fn left(&self) -> &Button;
fn right(&self) -> &Button;
fn a(&self) -> &Button;
fn b(&self) -> &Button;
fn x(&self) -> &Button;
fn y(&self) -> &Button;
fn l(&self) -> &Button;
fn r(&self) -> &Button;
fn start(&self) -> &Button;
fn select(&self) -> &Button;
}
#[derive(Default, Clone, Copy, Debug)] #[derive(Default, Clone, Copy, Debug)]
pub struct Pad { pub struct Pad {
pub up: Button, pub up: Button,
@ -19,6 +37,24 @@ pub struct Pad {
pub select: Button, pub select: Button,
} }
impl PadBridge for Pad {
fn begin_frame(&mut self, signals: &InputSignals) { self.begin_frame(signals) }
fn any(&self) -> bool { self.any() }
fn up(&self) -> &Button { &self.up }
fn down(&self) -> &Button { &self.down }
fn left(&self) -> &Button { &self.left }
fn right(&self) -> &Button { &self.right }
fn a(&self) -> &Button { &self.a }
fn b(&self) -> &Button { &self.b }
fn x(&self) -> &Button { &self.x }
fn y(&self) -> &Button { &self.y }
fn l(&self) -> &Button { &self.l }
fn r(&self) -> &Button { &self.r }
fn start(&self) -> &Button { &self.start }
fn select(&self) -> &Button { &self.select }
}
impl Pad { impl Pad {
pub fn begin_frame(&mut self, signals: &InputSignals) { pub fn begin_frame(&mut self, signals: &InputSignals) {
self.up.begin_frame(signals.up_signal); self.up.begin_frame(signals.up_signal);

View File

@ -1,6 +1,13 @@
use crate::hardware::input_signal::InputSignals; use crate::hardware::input_signal::InputSignals;
use crate::model::Button; use crate::model::Button;
pub trait TouchBridge {
fn begin_frame(&mut self, signals: &InputSignals);
fn f(&self) -> &Button;
fn x(&self) -> i32;
fn y(&self) -> i32;
}
#[derive(Default, Clone, Copy, Debug)] #[derive(Default, Clone, Copy, Debug)]
pub struct Touch { pub struct Touch {
pub f: Button, pub f: Button,
@ -8,6 +15,13 @@ pub struct Touch {
pub y: i32, pub y: i32,
} }
impl TouchBridge for Touch {
fn begin_frame(&mut self, signals: &InputSignals) { self.begin_frame(signals) }
fn f(&self) -> &Button { &self.f }
fn x(&self) -> i32 { self.x }
fn y(&self) -> i32 { self.y }
}
impl Touch { impl Touch {
/// Transient flags should last only 1 frame. /// Transient flags should last only 1 frame.
pub fn begin_frame(&mut self, signals: &InputSignals) { pub fn begin_frame(&mut self, signals: &InputSignals) {

View File

@ -25,16 +25,16 @@ impl PrometeuHub {
let mut next_window = None; let mut next_window = None;
if hw.pad().a.pressed { if hw.pad().a().pressed {
os.log(LogLevel::Debug, LogSource::Hub, 0, "window A opened".to_string()); os.log(LogLevel::Debug, LogSource::Hub, 0, "window A opened".to_string());
next_window = Some(("Green Window".to_string(), Rect { x: 0, y: 0, w: 160, h: 90 }, Color::GREEN)); next_window = Some(("Green Window".to_string(), Rect { x: 0, y: 0, w: 160, h: 90 }, Color::GREEN));
} else if hw.pad().b.pressed { } else if hw.pad().b().pressed {
os.log(LogLevel::Debug, LogSource::Hub, 0, "window B opened".to_string()); os.log(LogLevel::Debug, LogSource::Hub, 0, "window B opened".to_string());
next_window = Some(("Indigo Window".to_string(), Rect { x: 160, y: 0, w: 160, h: 90 }, Color::INDIGO)); next_window = Some(("Indigo Window".to_string(), Rect { x: 160, y: 0, w: 160, h: 90 }, Color::INDIGO));
} else if hw.pad().x.pressed { } else if hw.pad().x().pressed {
os.log(LogLevel::Debug, LogSource::Hub, 0, "window X opened".to_string()); os.log(LogLevel::Debug, LogSource::Hub, 0, "window X opened".to_string());
next_window = Some(("Yellow Window".to_string(), Rect { x: 0, y: 90, w: 160, h: 90 }, Color::YELLOW)); next_window = Some(("Yellow Window".to_string(), Rect { x: 0, y: 90, w: 160, h: 90 }, Color::YELLOW));
} else if hw.pad().y.pressed { } else if hw.pad().y().pressed {
os.log(LogLevel::Debug, LogSource::Hub, 0, "window Y opened".to_string()); os.log(LogLevel::Debug, LogSource::Hub, 0, "window Y opened".to_string());
next_window = Some(("Red Window".to_string(), Rect { x: 160, y: 90, w: 160, h: 90 }, Color::RED)); next_window = Some(("Red Window".to_string(), Rect { x: 160, y: 90, w: 160, h: 90 }, Color::RED));
} }

View File

@ -377,36 +377,36 @@ impl PrometeuOS {
pub fn get_button<'a>(&self, id: u32, hw: &'a dyn HardwareBridge) -> Option<&'a crate::model::Button> { pub fn get_button<'a>(&self, id: u32, hw: &'a dyn HardwareBridge) -> Option<&'a crate::model::Button> {
let pad = hw.pad(); let pad = hw.pad();
match id { match id {
0 => Some(&pad.up), 0 => Some(pad.up()),
1 => Some(&pad.down), 1 => Some(pad.down()),
2 => Some(&pad.left), 2 => Some(pad.left()),
3 => Some(&pad.right), 3 => Some(pad.right()),
4 => Some(&pad.a), 4 => Some(pad.a()),
5 => Some(&pad.b), 5 => Some(pad.b()),
6 => Some(&pad.x), 6 => Some(pad.x()),
7 => Some(&pad.y), 7 => Some(pad.y()),
8 => Some(&pad.l), 8 => Some(pad.l()),
9 => Some(&pad.r), 9 => Some(pad.r()),
10 => Some(&pad.start), 10 => Some(pad.start()),
11 => Some(&pad.select), 11 => Some(pad.select()),
_ => None, _ => None,
} }
} }
pub fn is_button_down(&self, id: u32, hw: &mut dyn HardwareBridge) -> bool { pub fn is_button_down(&self, id: u32, hw: &mut dyn HardwareBridge) -> bool {
match id { match id {
0 => hw.pad().up.down, 0 => hw.pad().up().down,
1 => hw.pad().down.down, 1 => hw.pad().down().down,
2 => hw.pad().left.down, 2 => hw.pad().left().down,
3 => hw.pad().right.down, 3 => hw.pad().right().down,
4 => hw.pad().a.down, 4 => hw.pad().a().down,
5 => hw.pad().b.down, 5 => hw.pad().b().down,
6 => hw.pad().x.down, 6 => hw.pad().x().down,
7 => hw.pad().y.down, 7 => hw.pad().y().down,
8 => hw.pad().l.down, 8 => hw.pad().l().down,
9 => hw.pad().r.down, 9 => hw.pad().r().down,
10 => hw.pad().start.down, 10 => hw.pad().start().down,
11 => hw.pad().select.down, 11 => hw.pad().select().down,
_ => false, _ => false,
} }
} }
@ -960,7 +960,7 @@ impl NativeInterface for PrometeuOS {
let bank_id = hw.assets().find_slot_by_name(&asset_name, crate::model::BankType::TILES).unwrap_or(0); let bank_id = hw.assets().find_slot_by_name(&asset_name, crate::model::BankType::TILES).unwrap_or(0);
if index < 512 { if index < 512 {
hw.gfx_mut().sprites[index] = crate::model::Sprite { *hw.gfx_mut().sprite_mut(index) = crate::model::Sprite {
tile: crate::model::Tile { id: tile_id, flip_x: false, flip_y: false, palette_id }, tile: crate::model::Tile { id: tile_id, flip_x: false, flip_y: false, palette_id },
x, x,
y, y,
@ -1028,35 +1028,35 @@ impl NativeInterface for PrometeuOS {
} }
Syscall::TouchGetX => { Syscall::TouchGetX => {
ret.push_int(hw.touch().x as i64); ret.push_int(hw.touch().x() as i64);
Ok(()) Ok(())
} }
Syscall::TouchGetY => { Syscall::TouchGetY => {
ret.push_int(hw.touch().y as i64); ret.push_int(hw.touch().y() as i64);
Ok(()) Ok(())
} }
Syscall::TouchIsDown => { Syscall::TouchIsDown => {
ret.push_bool(hw.touch().f.down); ret.push_bool(hw.touch().f().down);
Ok(()) Ok(())
} }
Syscall::TouchIsPressed => { Syscall::TouchIsPressed => {
ret.push_bool(hw.touch().f.pressed); ret.push_bool(hw.touch().f().pressed);
Ok(()) Ok(())
} }
Syscall::TouchIsReleased => { Syscall::TouchIsReleased => {
ret.push_bool(hw.touch().f.released); ret.push_bool(hw.touch().f().released);
Ok(()) Ok(())
} }
Syscall::TouchGetHold => { Syscall::TouchGetHold => {
ret.push_int(hw.touch().f.hold_frames as i64); ret.push_int(hw.touch().f().hold_frames as i64);
Ok(()) Ok(())
} }
Syscall::InputPadSnapshot => { Syscall::InputPadSnapshot => {
let pad = hw.pad(); let pad = hw.pad();
for btn in [ for btn in [
&pad.up, &pad.down, &pad.left, &pad.right, pad.up(), pad.down(), pad.left(), pad.right(),
&pad.a, &pad.b, &pad.x, &pad.y, pad.a(), pad.b(), pad.x(), pad.y(),
&pad.l, &pad.r, &pad.start, &pad.select, pad.l(), pad.r(), pad.start(), pad.select(),
] { ] {
ret.push_bool(btn.pressed); ret.push_bool(btn.pressed);
ret.push_bool(btn.released); ret.push_bool(btn.released);
@ -1067,12 +1067,12 @@ impl NativeInterface for PrometeuOS {
} }
Syscall::InputTouchSnapshot => { Syscall::InputTouchSnapshot => {
let touch = hw.touch(); let touch = hw.touch();
ret.push_bool(touch.f.pressed); ret.push_bool(touch.f().pressed);
ret.push_bool(touch.f.released); ret.push_bool(touch.f().released);
ret.push_bool(touch.f.down); ret.push_bool(touch.f().down);
ret.push_int(touch.f.hold_frames as i64); ret.push_int(touch.f().hold_frames as i64);
ret.push_int(touch.x as i64); ret.push_int(touch.x() as i64);
ret.push_int(touch.y as i64); ret.push_int(touch.y() as i64);
Ok(()) Ok(())
} }

View File

@ -20,7 +20,7 @@ impl<'a> HostContext<'a> {
} }
pub trait HostContextProvider { pub trait HostContextProvider {
fn make_ctx(&mut self) -> HostContext; fn make_ctx(&'_ mut self) -> HostContext<'_>;
} }
impl<T: HardwareBridge> HostContextProvider for T { impl<T: HardwareBridge> HostContextProvider for T {

View File

@ -1,5 +1,5 @@
[package] [package]
name = "prometeu-hinfra" name = "prometeu-hardware-contract"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
license.workspace = true license.workspace = true