mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 19:26:43 +01:00
implement framework for control codes
This commit is contained in:
12
examples/curlywas/control.cwa
Normal file
12
examples/curlywas/control.cwa
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import "env.printChar" fn printChar(i32);
|
||||||
|
import "env.printString" fn printString(i32);
|
||||||
|
|
||||||
|
export fn upd() {
|
||||||
|
printString(0x20000);
|
||||||
|
}
|
||||||
|
|
||||||
|
data 0x20000 {
|
||||||
|
i8(14, 0xfd, 12) // clear screen to color 0xfd
|
||||||
|
"Top left"
|
||||||
|
i8(0)
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -308,14 +308,30 @@ export fn printChar(char: i32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global mut controlCodeLength = 0;
|
||||||
|
|
||||||
fn printSingleChar(char: i32) {
|
fn printSingleChar(char: i32) {
|
||||||
if char == 4 | char == 5 {
|
controlCodeLength?0x12d20 = char;
|
||||||
graphicsText = char == 5;
|
controlCodeLength = controlCodeLength + 1;
|
||||||
|
char = 0x12d20?0;
|
||||||
|
if char < 32 & controlCodeLength < char?0x12d00 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
controlCodeLength = 0;
|
||||||
|
|
||||||
|
if char == 1 {
|
||||||
|
drawChar(0x12d20?1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if char == 10 | (!graphicsText & textCursorX >= 320) {
|
if char == 4 | char == 5 {
|
||||||
textCursorX = 0;
|
graphicsText = char == 5;
|
||||||
|
textCursorX = 0;
|
||||||
|
textCursorY = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if char == 10 {
|
||||||
textCursorY = textCursorY + 8;
|
textCursorY = textCursorY + 8;
|
||||||
if !graphicsText & textCursorY >= 240 {
|
if !graphicsText & textCursorY >= 240 {
|
||||||
textCursorY = 240 - 8;
|
textCursorY = 240 - 8;
|
||||||
@@ -329,6 +345,47 @@ fn printSingleChar(char: i32) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if char == 12 {
|
||||||
|
cls(bgColor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if char == 13 {
|
||||||
|
textCursorX = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if char == 14 {
|
||||||
|
bgColor = 0x12d20?1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if char == 15 {
|
||||||
|
textColor = 0x12d20?1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawChar(char);
|
||||||
|
}
|
||||||
|
|
||||||
|
data(0x12d00) {
|
||||||
|
i8(
|
||||||
|
1, 2, 1, 1, // 0-3
|
||||||
|
1, 1, 1, 1, // 4-7
|
||||||
|
1, 1, 1, 1, // 8-11
|
||||||
|
1, 1, 2, 1, // 12-15,
|
||||||
|
1, 1, 1, 1, // 16-19,
|
||||||
|
1, 1, 1, 1, // 20-23,
|
||||||
|
1, 1, 1, 1, // 24-27,
|
||||||
|
1, 1, 1, 1 // 28-31
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn drawChar(char: i32) {
|
||||||
|
if !graphicsText & textCursorX >= 320 {
|
||||||
|
printChar(0xd0a);
|
||||||
|
}
|
||||||
|
|
||||||
let y: i32;
|
let y: i32;
|
||||||
loop rows {
|
loop rows {
|
||||||
let bits = (char * 8 + y)?0x13400;
|
let bits = (char * 8 + y)?0x13400;
|
||||||
|
|||||||
Reference in New Issue
Block a user