pr9.4
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
# PROMETEU Test Cartridges
|
||||
|
||||
This directory contains example cartridges and test suites to validate the behavior of the PROMETEU runtime and development tools.
|
||||
|
||||
## Available Cartridges
|
||||
|
||||
### 🟩 [color-square-ts](color-square-ts)
|
||||
A simple cartridge that demonstrates:
|
||||
- System initialization.
|
||||
- Rendering a colored square in the framebuffer.
|
||||
- Basic execution loop.
|
||||
|
||||
## Cartridge Structure
|
||||
|
||||
A PROMETEU cartridge (in its unpacked form) generally consists of:
|
||||
- `manifest.json`: Application metadata (ID, title, version, mode).
|
||||
- `program.pbc`: Compiled bytecode for the PROMETEU VM.
|
||||
- `assets/`: Resources such as tiles, sprites, and audio samples.
|
||||
|
||||
## How to use
|
||||
|
||||
You can run any of these cartridges using the main CLI:
|
||||
|
||||
```bash
|
||||
prometeu run test-cartridges/<cartridge_name>
|
||||
```
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"kind": "File",
|
||||
"imports": [],
|
||||
"decls": [
|
||||
30,
|
||||
40
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
0000 PushConst U32(1)
|
||||
0006 SetLocal U32(0)
|
||||
000C GetLocal U32(0)
|
||||
0012 GetLocal U32(0)
|
||||
0018 SetLocal U32(1)
|
||||
001E SetLocal U32(0)
|
||||
0024 GetLocal U32(0)
|
||||
002A GetLocal U32(1)
|
||||
0030 Call U32(1)
|
||||
0036 SetLocal U32(2)
|
||||
003C FrameSync
|
||||
003E Ret
|
||||
0040 GetLocal U32(0)
|
||||
0046 GetLocal U32(0)
|
||||
004C GetLocal U32(1)
|
||||
0052 Add
|
||||
0054 Mul
|
||||
0056 GetLocal U32(1)
|
||||
005C Mul
|
||||
005E Ret
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "canonical",
|
||||
"version": "0.1.0",
|
||||
"script_fe": "pbs",
|
||||
"entry": "src/main/modules/main.pbs"
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
declare struct Vec2(x: int, y: int)
|
||||
[
|
||||
(x: int, y: int): (x, y) as default
|
||||
(s: int): (s, s) as square
|
||||
]
|
||||
[[
|
||||
ZERO: square(0)
|
||||
]]
|
||||
{
|
||||
pub fn len(self: this): int {
|
||||
return x * x + y * y;
|
||||
}
|
||||
}
|
||||
|
||||
fn frame(): void {
|
||||
let zero = Vec2.ZERO;
|
||||
let zz = zero.len();
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "sdk",
|
||||
"version": "0.1.0",
|
||||
"script_fe": "pbs",
|
||||
"kind": "lib"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
pub declare struct Color(raw: bounded)
|
||||
[[
|
||||
BLACK: Color(0b),
|
||||
WHITE: Color(65535b),
|
||||
RED: Color(63488b),
|
||||
GREEN: Color(2016b),
|
||||
BLUE: Color(31b)
|
||||
]]
|
||||
@@ -1,3 +0,0 @@
|
||||
pub declare contract Gfx host {
|
||||
fn clear(color: Color): void;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
pub declare struct Button(
|
||||
pressed: bool,
|
||||
released: bool,
|
||||
down: bool,
|
||||
hold_frames: bounded
|
||||
)
|
||||
@@ -1,20 +0,0 @@
|
||||
pub declare contract Pad host {
|
||||
fn up(): Button;
|
||||
fn down(): Button;
|
||||
fn left(): Button;
|
||||
fn right(): Button;
|
||||
fn a(): Button;
|
||||
fn b(): Button;
|
||||
fn x(): Button;
|
||||
fn y(): Button;
|
||||
fn l(): Button;
|
||||
fn r(): Button;
|
||||
fn start(): Button;
|
||||
fn select(): Button;
|
||||
}
|
||||
|
||||
pub declare contract Touch host {
|
||||
fn screen_x(): int;
|
||||
fn screen_y(): int;
|
||||
fn finger(): Button;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
// Injeção pelo hardware
|
||||
declare contract LogHost host {
|
||||
fn write(level: int, msg: string): void;
|
||||
fn writeTag(level: int, tag: int, msg: string): void;
|
||||
}
|
||||
|
||||
// exposicao do modulo, com sugar sintatico, nada injetado aqui
|
||||
pub service Log {
|
||||
fn trace(msg: string): void {
|
||||
LogHost.write(0, msg);
|
||||
}
|
||||
|
||||
fn trace(tag: int, msg: string): void {
|
||||
LogHost.writeTag(0, tag, msg);
|
||||
}
|
||||
|
||||
fn debug(msg: string): void {
|
||||
LogHost.write(1, msg);
|
||||
}
|
||||
|
||||
fn debug(tag: int, msg: string): void {
|
||||
LogHost.writeTag(1, tag, msg);
|
||||
}
|
||||
|
||||
fn info(msg: string): void {
|
||||
LogHost.write(2, msg);
|
||||
}
|
||||
|
||||
fn info(tag: int, msg: string): void {
|
||||
LogHost.writeTag(2, tag, msg);
|
||||
}
|
||||
|
||||
fn warn(msg: string): void {
|
||||
LogHost.write(3, msg);
|
||||
}
|
||||
|
||||
fn warn(tag: int, msg: string): void {
|
||||
LogHost.writeTag(3, tag, msg);
|
||||
}
|
||||
|
||||
fn err(msg: string): void {
|
||||
LogHost.write(4, msg);
|
||||
}
|
||||
|
||||
fn err(tag: int, msg: string): void {
|
||||
LogHost.writeTag(4, tag, msg);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"magic": "PMTU",
|
||||
"cartridge_version": 1,
|
||||
"app_id": 1,
|
||||
"title": "Test 1",
|
||||
"app_version": "0.1.0",
|
||||
"app_mode": "Game",
|
||||
"entrypoint": "frame",
|
||||
"asset_table": [
|
||||
{
|
||||
"asset_id": 0,
|
||||
"asset_name": "bgm_music",
|
||||
"bank_type": "SOUNDS",
|
||||
"offset": 0,
|
||||
"size": 88200,
|
||||
"decoded_size": 88200,
|
||||
"codec": "RAW",
|
||||
"metadata": {
|
||||
"sample_rate": 44100
|
||||
}
|
||||
},
|
||||
{
|
||||
"asset_id": 1,
|
||||
"asset_name": "mouse_cursor",
|
||||
"bank_type": "TILES",
|
||||
"offset": 88200,
|
||||
"size": 2304,
|
||||
"decoded_size": 2304,
|
||||
"codec": "RAW",
|
||||
"metadata": {
|
||||
"tile_size": 16,
|
||||
"width": 16,
|
||||
"height": 16
|
||||
}
|
||||
}
|
||||
],
|
||||
"preload": [
|
||||
{ "asset_name": "bgm_music", "slot": 0 },
|
||||
{ "asset_name": "mouse_cursor", "slot": 1 }
|
||||
]
|
||||
}
|
||||
Binary file not shown.
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "test01",
|
||||
"version": "0.1.0",
|
||||
"script_fe": "pbs",
|
||||
"kind": "app",
|
||||
"entry": "src/main/modules/main.pbs",
|
||||
"out": "build/program.pbc",
|
||||
"dependencies": {
|
||||
"sdk": "../sdk"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
set -e
|
||||
|
||||
sdk/prometeu build .
|
||||
cp build/program.pbc cartridge/program.pbc
|
||||
sdk/prometeu run cartridge
|
||||
@@ -1 +0,0 @@
|
||||
../../dist-staging/stable/prometeu-aarch64-apple-darwin
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"prometeuPbs.serverPath": "/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/target/debug/prometeu-lsp --studio"
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
import { Color, Gfx } from "@sdk:gfx";
|
||||
import { Pad, Touch } from "@sdk:input";
|
||||
import { Log } from "@sdk:log";
|
||||
|
||||
declare struct Vec2(x: int, y: int)
|
||||
[
|
||||
(x: int, y: int): (x, y) as default { }
|
||||
(s: int): (s, s) as square { }
|
||||
]
|
||||
[[
|
||||
ZERO: square(0)
|
||||
]]
|
||||
{
|
||||
fn getX(self: this): int {
|
||||
return x;
|
||||
}
|
||||
|
||||
fn getY(self: this): int {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
fn add(a: int, b: int): int {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
fn is_higher(a: int, b: int): bool {
|
||||
let c: int = a + b;
|
||||
return c >= 30;
|
||||
}
|
||||
|
||||
fn add2(a: int, b: int): int {
|
||||
let c = add(a, b);
|
||||
return c;
|
||||
}
|
||||
|
||||
fn frame(): void {
|
||||
let zero = Vec2.ZERO;
|
||||
let zz = add2(zero.getX(), zero.getY());
|
||||
|
||||
// 1. Locals & Arithmetic
|
||||
let x = 10;
|
||||
let y = 20;
|
||||
let z = add(x, y);
|
||||
|
||||
// 2. Control Flow (if)
|
||||
if z == 30 {
|
||||
// 3. Syscall Clear
|
||||
Gfx.clear(Color.GREEN);
|
||||
} else {
|
||||
Gfx.clear(Color.RED);
|
||||
}
|
||||
|
||||
// 4. Input Snapshot & Nested Member Access
|
||||
let pad_a = Pad.a();
|
||||
let touch_f = Touch.finger();
|
||||
let is_pressed = pad_a.down || touch_f.down;
|
||||
if is_pressed {
|
||||
Gfx.clear(Color.BLUE);
|
||||
}
|
||||
|
||||
if Pad.b().pressed {
|
||||
Log.debug("B Pressed");
|
||||
Gfx.clear(Color.RED);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user