From fb3951435f83eb39e6cecb93569c2f84da804c84 Mon Sep 17 00:00:00 2001 From: suchmememanyskill Date: Tue, 27 Jul 2021 14:16:01 +0200 Subject: [PATCH] add setpixels, printpos --- scripts/HelloWorld.te | 12 +++++------- source/script/standardLibrary.c | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/scripts/HelloWorld.te b/scripts/HelloWorld.te index 1d95158..9be5fc1 100644 --- a/scripts/HelloWorld.te +++ b/scripts/HelloWorld.te @@ -7,13 +7,9 @@ a.print() -mountsys("SYSTEM") -s = readsave("sd:/8000000000000120") -f = s.read("/meta/imkvdb.arc") -println(f.len()) -println(f.slice(1,1).project()[0]) -s.write("/meta/imkvdb.arc", ["BYTE[]", 1,2]).print() -s.commit().print() +printpos(20, 30) +setpixels(0, 0, 1279, 100, 0xFF0000) +println("sup") #a = s.readdir("/") pause() @@ -24,6 +20,8 @@ println(a.files.len()) println(a.folders.len()) println(a.fileSizes.len()) + + a.files.foreach("b") { println(b) } diff --git a/source/script/standardLibrary.c b/source/script/standardLibrary.c index c81d309..de0dde1 100644 --- a/source/script/standardLibrary.c +++ b/source/script/standardLibrary.c @@ -162,6 +162,18 @@ ClassFunction(stdSetPixel) { return &emptyClass; } +ClassFunction(stdSetPixels){ + gfx_box(getIntValue(args[0]), getIntValue(args[1]), getIntValue(args[2]), getIntValue(args[3]), (u32)getIntValue(args[4])); + return &emptyClass; +} + +ClassFunction(stdSetPrintPos){ + if (getIntValue(args[0]) > 0 && getIntValue(args[1]) > 0){ + gfx_con_setpos((getIntValue(args[0]) % 78) * 16, (getIntValue(args[1]) % 42) * 16); + } + return &emptyClass; +} + // Takes [str]. Returns empty. str: path to dir ClassFunction(stdReadDir){ Variable_t* resPtr = newIntVariablePtr(0); @@ -441,7 +453,7 @@ STUBBED(stdFileRead) u8 oneIntoneFunction[] = { IntClass, FunctionClass }; u8 doubleFunctionClass[] = { FunctionClass, FunctionClass }; u8 oneStringArgStd[] = {StringClass}; -u8 threeIntsStd[] = { IntClass, IntClass, IntClass }; +u8 threeIntsStd[] = { IntClass, IntClass, IntClass, IntClass, IntClass }; u8 twoStringArgStd[] = {StringClass, StringClass}; u8 oneIntStd[] = {IntClass}; u8 menuArgsStd[] = {StringArrayClass, IntClass, IntArrayClass}; @@ -461,7 +473,9 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = { // Utils {"print", stdPrint, VARARGCOUNT, 0}, {"println", stdPrintLn, VARARGCOUNT, 0}, - {"setpixel", stdSetPixel, 3, threeIntsStd}, // TODO: change for setblock + {"printpos", stdSetPrintPos, 2, threeIntsStd}, + {"setpixel", stdSetPixel, 3, threeIntsStd}, + {"setpixels", stdSetPixels, 5, threeIntsStd}, {"emu", stdHasEmu, 0, 0}, {"clear", stdClear, 0, 0}, {"timer", stdGetMs, 0, 0},