diff --git a/examples/curlywas/control.cwa b/examples/curlywas/control.cwa new file mode 100644 index 0000000..0cdaffb --- /dev/null +++ b/examples/curlywas/control.cwa @@ -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) +} diff --git a/platform/bin/platform.uw8 b/platform/bin/platform.uw8 index fe2d3bc..d245d77 100644 Binary files a/platform/bin/platform.uw8 and b/platform/bin/platform.uw8 differ diff --git a/platform/src/platform.cwa b/platform/src/platform.cwa index 4a53486..53ca1d1 100644 --- a/platform/src/platform.cwa +++ b/platform/src/platform.cwa @@ -308,14 +308,30 @@ export fn printChar(char: i32) { } } +global mut controlCodeLength = 0; + fn printSingleChar(char: i32) { - if char == 4 | char == 5 { - graphicsText = char == 5; + controlCodeLength?0x12d20 = char; + controlCodeLength = controlCodeLength + 1; + char = 0x12d20?0; + if char < 32 & controlCodeLength < char?0x12d00 { + return; + } + controlCodeLength = 0; + + if char == 1 { + drawChar(0x12d20?1); return; } - if char == 10 | (!graphicsText & textCursorX >= 320) { - textCursorX = 0; + if char == 4 | char == 5 { + graphicsText = char == 5; + textCursorX = 0; + textCursorY = 0; + return; + } + + if char == 10 { textCursorY = textCursorY + 8; if !graphicsText & textCursorY >= 240 { textCursorY = 240 - 8; @@ -329,6 +345,47 @@ fn printSingleChar(char: i32) { 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; loop rows { let bits = (char * 8 + y)?0x13400;