more content into main.ts
This commit is contained in:
parent
b3cc7ee384
commit
ecda79bcc6
@ -295,18 +295,18 @@ impl Codegen {
|
||||
|
||||
if full_name.to_lowercase().starts_with("color.") {
|
||||
match full_name.to_lowercase().as_str() {
|
||||
"color.black" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::BLACK.hex())], member.span),
|
||||
"color.white" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::WHITE.hex())], member.span),
|
||||
"color.red" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::RED.hex())], member.span),
|
||||
"color.green" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::GREEN.hex())], member.span),
|
||||
"color.blue" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::BLUE.hex())], member.span),
|
||||
"color.yellow" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::YELLOW.hex())], member.span),
|
||||
"color.cyan" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::CYAN.hex())], member.span),
|
||||
"color.gray" | "color.grey" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::GRAY.hex())], member.span),
|
||||
"color.orange" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::ORANGE.hex())], member.span),
|
||||
"color.indigo" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::INDIGO.hex())], member.span),
|
||||
"color.magenta" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::MAGENTA.hex())], member.span),
|
||||
"color.colorKey" | "color.color_key" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::COLOR_KEY.hex())], member.span),
|
||||
"color.black" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::BLACK.raw() as i32)], member.span),
|
||||
"color.white" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::WHITE.raw() as i32)], member.span),
|
||||
"color.red" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::RED.raw() as i32)], member.span),
|
||||
"color.green" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::GREEN.raw() as i32)], member.span),
|
||||
"color.blue" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::BLUE.raw() as i32)], member.span),
|
||||
"color.yellow" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::YELLOW.raw() as i32)], member.span),
|
||||
"color.cyan" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::CYAN.raw() as i32)], member.span),
|
||||
"color.gray" | "color.grey" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::GRAY.raw() as i32)], member.span),
|
||||
"color.orange" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::ORANGE.raw() as i32)], member.span),
|
||||
"color.indigo" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::INDIGO.raw() as i32)], member.span),
|
||||
"color.magenta" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::MAGENTA.raw() as i32)], member.span),
|
||||
"color.colorKey" | "color.color_key" => self.emit_op(OpCode::PushI32, vec![Operand::I32(Color::COLOR_KEY.raw() as i32)], member.span),
|
||||
_ => return Err(anyhow!("Unsupported color constant: {} at {:?}", full_name, member.span)),
|
||||
}
|
||||
} else if full_name.to_lowercase().starts_with("pad.") {
|
||||
|
||||
@ -2,42 +2,42 @@
|
||||
0000000A Pop
|
||||
0000000C FrameSync
|
||||
0000000E Jmp U32(0)
|
||||
00000014 PushI32 U32(4849796) ; ./src/main.ts:2
|
||||
00000014 PushI32 U32(18448) ; ./src/main.ts:2
|
||||
0000001A Syscall U32(4097) ; ./src/main.ts:2
|
||||
00000020 Pop ; ./src/main.ts:2
|
||||
00000022 PushI32 U32(10) ; ./src/main.ts:4
|
||||
00000028 PushI32 U32(10) ; ./src/main.ts:4
|
||||
0000002E PushI32 U32(50) ; ./src/main.ts:4
|
||||
00000034 PushI32 U32(50) ; ./src/main.ts:4
|
||||
0000003A PushI32 U32(16711680) ; ./src/main.ts:4
|
||||
0000003A PushI32 U32(63488) ; ./src/main.ts:4
|
||||
00000040 Syscall U32(4098) ; ./src/main.ts:4
|
||||
00000046 Pop ; ./src/main.ts:4
|
||||
00000048 PushI32 U32(0) ; ./src/main.ts:5
|
||||
0000004E PushI32 U32(0) ; ./src/main.ts:5
|
||||
00000054 PushI32 U32(128) ; ./src/main.ts:5
|
||||
0000005A PushI32 U32(128) ; ./src/main.ts:5
|
||||
00000060 PushI32 U32(16777215) ; ./src/main.ts:5
|
||||
00000060 PushI32 U32(65535) ; ./src/main.ts:5
|
||||
00000066 Syscall U32(4099) ; ./src/main.ts:5
|
||||
0000006C Pop ; ./src/main.ts:5
|
||||
0000006E PushI32 U32(64) ; ./src/main.ts:6
|
||||
00000074 PushI32 U32(64) ; ./src/main.ts:6
|
||||
0000007A PushI32 U32(20) ; ./src/main.ts:6
|
||||
00000080 PushI32 U32(255) ; ./src/main.ts:6
|
||||
00000080 PushI32 U32(31) ; ./src/main.ts:6
|
||||
00000086 Syscall U32(4100) ; ./src/main.ts:6
|
||||
0000008C Pop ; ./src/main.ts:6
|
||||
0000008E PushI32 U32(100) ; ./src/main.ts:7
|
||||
00000094 PushI32 U32(100) ; ./src/main.ts:7
|
||||
0000009A PushI32 U32(10) ; ./src/main.ts:7
|
||||
000000A0 PushI32 U32(65280) ; ./src/main.ts:7
|
||||
000000A6 PushI32 U32(16776960) ; ./src/main.ts:7
|
||||
000000A0 PushI32 U32(2016) ; ./src/main.ts:7
|
||||
000000A6 PushI32 U32(65504) ; ./src/main.ts:7
|
||||
000000AC Syscall U32(4101) ; ./src/main.ts:7
|
||||
000000B2 Pop ; ./src/main.ts:7
|
||||
000000B4 PushI32 U32(20) ; ./src/main.ts:8
|
||||
000000BA PushI32 U32(100) ; ./src/main.ts:8
|
||||
000000C0 PushI32 U32(30) ; ./src/main.ts:8
|
||||
000000C6 PushI32 U32(30) ; ./src/main.ts:8
|
||||
000000CC PushI32 U32(65535) ; ./src/main.ts:8
|
||||
000000D2 PushI32 U32(16711935) ; ./src/main.ts:8
|
||||
000000CC PushI32 U32(2047) ; ./src/main.ts:8
|
||||
000000D2 PushI32 U32(63519) ; ./src/main.ts:8
|
||||
000000D8 Syscall U32(4102) ; ./src/main.ts:8
|
||||
000000DE Pop ; ./src/main.ts:8
|
||||
000000E0 PushI32 U32(0) ; ./src/main.ts:10
|
||||
@ -64,7 +64,7 @@
|
||||
00000156 Syscall U32(8449) ; ./src/main.ts:19
|
||||
0000015C Syscall U32(8450) ; ./src/main.ts:19
|
||||
00000162 PushI32 U32(5) ; ./src/main.ts:19
|
||||
00000168 PushI32 U32(16777215) ; ./src/main.ts:19
|
||||
00000168 PushI32 U32(65535) ; ./src/main.ts:19
|
||||
0000016E Syscall U32(4100) ; ./src/main.ts:19
|
||||
00000174 Pop ; ./src/main.ts:19
|
||||
00000176 Jmp U32(380)
|
||||
@ -111,8 +111,22 @@
|
||||
00000240 PushI32 U32(0) ; ./src/main.ts:31
|
||||
00000246 PushI32 U32(5) ; ./src/main.ts:31
|
||||
0000024C PushI32 U32(5) ; ./src/main.ts:31
|
||||
00000252 GetLocal U32(2) ; ./src/main.ts:31
|
||||
00000258 Syscall U32(4098) ; ./src/main.ts:31
|
||||
0000025E Pop ; ./src/main.ts:31
|
||||
00000260 PushConst U32(0)
|
||||
00000266 Ret
|
||||
00000252 PushI32 U32(255) ; ./src/main.ts:31
|
||||
00000258 PushI32 U32(3) ; ./src/main.ts:31
|
||||
0000025E Shr ; ./src/main.ts:31
|
||||
00000260 PushI32 U32(11) ; ./src/main.ts:31
|
||||
00000266 Shl ; ./src/main.ts:31
|
||||
00000268 PushI32 U32(128) ; ./src/main.ts:31
|
||||
0000026E PushI32 U32(2) ; ./src/main.ts:31
|
||||
00000274 Shr ; ./src/main.ts:31
|
||||
00000276 PushI32 U32(5) ; ./src/main.ts:31
|
||||
0000027C Shl ; ./src/main.ts:31
|
||||
0000027E BitOr ; ./src/main.ts:31
|
||||
00000280 PushI32 U32(0) ; ./src/main.ts:31
|
||||
00000286 PushI32 U32(3) ; ./src/main.ts:31
|
||||
0000028C Shr ; ./src/main.ts:31
|
||||
0000028E BitOr ; ./src/main.ts:31
|
||||
00000290 Syscall U32(4098) ; ./src/main.ts:31
|
||||
00000296 Pop ; ./src/main.ts:31
|
||||
00000298 PushConst U32(0)
|
||||
0000029E Ret
|
||||
|
||||
Binary file not shown.
@ -627,18 +627,102 @@
|
||||
"pc": 594,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
"col": 38
|
||||
},
|
||||
{
|
||||
"pc": 600,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 3
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 606,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 608,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 614,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 616,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 43
|
||||
},
|
||||
{
|
||||
"pc": 622,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 628,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 630,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 636,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 638,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 640,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 48
|
||||
},
|
||||
{
|
||||
"pc": 646,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 652,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 654,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 28
|
||||
},
|
||||
{
|
||||
"pc": 656,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 3
|
||||
},
|
||||
{
|
||||
"pc": 662,
|
||||
"file": "./src/main.ts",
|
||||
"line": 31,
|
||||
"col": 3
|
||||
}
|
||||
]
|
||||
Binary file not shown.
5
test-cartridges/color-square/run.sh
Executable file
5
test-cartridges/color-square/run.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
./prometeu-sdk/prometeu build .
|
||||
cp build/program.pbc cartridge
|
||||
./prometeu-sdk/prometeu run cartridge
|
||||
@ -1,32 +1,44 @@
|
||||
function do_init_gfx(): void {
|
||||
gfx.clear(color.indigo);
|
||||
gfx.fillRect(10, 10, 50, 50, color.red);
|
||||
gfx.drawLine(0, 0, 128, 128, color.white);
|
||||
gfx.drawCircle(64, 64, 20, color.blue);
|
||||
gfx.drawDisc(100, 100, 10, color.green, color.yellow);
|
||||
gfx.drawSquare(20, 100, 30, 30, color.cyan, color.color_key);
|
||||
}
|
||||
|
||||
function do_pad(): void {
|
||||
if (pad.up.down) {
|
||||
log.write(2, "Up is down");
|
||||
}
|
||||
|
||||
if (pad.a.pressed) {
|
||||
audio.playSample(1, 0, 255, 128, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
function do_touch(): void {
|
||||
if (touch.button.down) {
|
||||
gfx.drawCircle(touch.x, touch.y, 5, color.white);
|
||||
}
|
||||
}
|
||||
|
||||
function do_fs(): void {
|
||||
let h = fs.open("test.txt");
|
||||
if (h >= 0) {
|
||||
fs.write(h, "Hello Prometeu!");
|
||||
let content = fs.read(h);
|
||||
if (content) log.writeTag(2, 101, content);
|
||||
fs.close(h);
|
||||
}
|
||||
}
|
||||
|
||||
export function tick(): void {
|
||||
gfx.clear(color.indigo);
|
||||
do_init_gfx();
|
||||
do_pad();
|
||||
do_touch();
|
||||
do_fs();
|
||||
|
||||
gfx.fillRect(10, 10, 50, 50, color.red);
|
||||
gfx.drawLine(0, 0, 128, 128, color.white);
|
||||
gfx.drawCircle(64, 64, 20, color.blue);
|
||||
gfx.drawDisc(100, 100, 10, color.green, color.yellow);
|
||||
gfx.drawSquare(20, 100, 30, 30, color.cyan, color.color_key);
|
||||
|
||||
if (pad.up.down) {
|
||||
log.write(2, "Up is down");
|
||||
}
|
||||
|
||||
if (pad.a.pressed) {
|
||||
audio.playSample(1, 0, 255, 128, 1.0);
|
||||
}
|
||||
|
||||
if (touch.button.down) {
|
||||
gfx.drawCircle(touch.x, touch.y, 5, color.white);
|
||||
}
|
||||
|
||||
let h = fs.open("test.txt");
|
||||
if (h >= 0) {
|
||||
fs.write(h, "Hello Prometeu!");
|
||||
let content = fs.read(h);
|
||||
if (content) log.writeTag(2, 101, content);
|
||||
fs.close(h);
|
||||
}
|
||||
|
||||
let c = color.rgb(255, 128, 0);
|
||||
gfx.fillRect(0, 0, 5, 5, c);
|
||||
let c = color.rgb(255, 128, 0);
|
||||
gfx.fillRect(0, 0, 5, 5, c);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user