From 85b5fde272be6ab543aa866baebabddc24566bdb Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 23 May 2026 20:14:34 -0500 Subject: Add initial content --- c/menu/Makefile | 44 ++++++ c/menu/calculator.c | 95 +++++++++++++ c/menu/calculator.h | 6 + c/menu/calculator.o | Bin 0 -> 6432 bytes c/menu/digilines.c | 66 +++++++++ c/menu/digilines.h | 6 + c/menu/digilines.o | Bin 0 -> 3800 bytes c/menu/games.c | 121 ++++++++++++++++ c/menu/games.h | 6 + c/menu/games.o | Bin 0 -> 7412 bytes c/menu/menu.c | 74 ++++++++++ c/menu/menu.elf | Bin 0 -> 13056 bytes c/menu/menu.hex | 377 +++++++++++++++++++++++++++++++++++++++++++++++++ c/menu/menu.o | Bin 0 -> 4704 bytes c/menu/rvcontroller.ld | 45 ++++++ c/menu/screensaver.c | 137 ++++++++++++++++++ c/menu/screensaver.h | 6 + c/menu/screensaver.o | Bin 0 -> 7492 bytes 18 files changed, 983 insertions(+) create mode 100644 c/menu/Makefile create mode 100644 c/menu/calculator.c create mode 100644 c/menu/calculator.h create mode 100644 c/menu/calculator.o create mode 100644 c/menu/digilines.c create mode 100644 c/menu/digilines.h create mode 100644 c/menu/digilines.o create mode 100644 c/menu/games.c create mode 100644 c/menu/games.h create mode 100644 c/menu/games.o create mode 100644 c/menu/menu.c create mode 100755 c/menu/menu.elf create mode 100644 c/menu/menu.hex create mode 100644 c/menu/menu.o create mode 100644 c/menu/rvcontroller.ld create mode 100644 c/menu/screensaver.c create mode 100644 c/menu/screensaver.h create mode 100644 c/menu/screensaver.o (limited to 'c/menu') diff --git a/c/menu/Makefile b/c/menu/Makefile new file mode 100644 index 0000000..bd92e6a --- /dev/null +++ b/c/menu/Makefile @@ -0,0 +1,44 @@ +CC ?= clang +CFLAGS_MARCH ?= -march=rv32imacb_zicntr_zicond_zicsr_zifencei_zihintpause_zilsd_zclsd_zabha_zacas_zbkb_zbkx_zcb_zcmp_zcmt +CFLAGS_OPT ?= -O3 +CFLAGS ?= ${CFLAGS_MARCH} ${CFLAGS_OPT} + +ifeq (${CC}, clang) + CC := ${CC} -target riscv32-none-elf +endif + +.PHONY: all dump load clean + +all: menu.hex + +menu.o: menu.c calculator.h digilines.h games.h screensaver.h + ${CC} -I../rvcontroller-libraries ${CFLAGS} -ffreestanding -c -o menu.o menu.c + +calculator.o: calculator.c + ${CC} -I../rvcontroller-libraries ${CFLAGS} -ffreestanding -c -o calculator.o calculator.c + +digilines.o: digilines.c + ${CC} -I../rvcontroller-libraries ${CFLAGS} -ffreestanding -c -o digilines.o digilines.c + +games.o: games.c + ${CC} -I../rvcontroller-libraries ${CFLAGS} -ffreestanding -c -o games.o games.c + +screensaver.o: screensaver.c + ${CC} -I../rvcontroller-libraries ${CFLAGS} -ffreestanding -c -o screensaver.o screensaver.c + +menu.elf: ../rvcontroller-libraries/rvcontroller-init.o ../rvcontroller-libraries/rvcontroller-ecalls.o menu.o calculator.o digilines.o games.o screensaver.o +# riscv32-none-elf-ld -T rvcontroller.ld --no-warn-rwx-segments -o menu.elf ../rvcontroller-libraries/rvcontroller-init.o ../rvcontroller-libraries/rvcontroller-ecalls.o menu.o calculator.o digilines.o games.o + ${CC} -T rvcontroller.ld -nostdlib -nostartfiles -Xlinker --no-warn-rwx-segments -o menu.elf ../rvcontroller-libraries/rvcontroller-init.o ../rvcontroller-libraries/rvcontroller-ecalls.o menu.o calculator.o digilines.o games.o screensaver.o + +dump: menu.elf + riscv32-none-elf-objdump -d menu.elf + +menu.hex: menu.elf + riscv32-none-elf-objcopy -O ihex menu.elf menu.hex + +load: menu.hex + bash -c "wl-copy < menu.hex" + +clean: + rm -f menu.bin menu.elf menu.o init.o calculator.o digilines.o games.o screensaver.o + diff --git a/c/menu/calculator.c b/c/menu/calculator.c new file mode 100644 index 0000000..ff26f07 --- /dev/null +++ b/c/menu/calculator.c @@ -0,0 +1,95 @@ +/* Menu Thing for RVController - Calculator + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +#include +#include +#include "rvcontroller-ecalls.h" + +void runCalculator(void) { + char input[2] = {0}; + int32_t num1 = 0; + int32_t num2 = 0; + int32_t result = 0; + + printstr("\n\n\n\n\n\n"); + printstr("Enter number 1:\n> "); + num1 = readint(); + printint(num1); + printstr("\nEnter number 2:\n> "); + num2 = readint(); + printint(num2); + + bool opok = false; + while (!opok) { + printstr("\nSelect operation:\n[+-*/%&|^<<>>] > "); + readstr(input,2); + printstr(input); + + switch (input[0]) { + case '<': + case '>': + // Duplicate the character for these two to give the illusion that I bothered to store both + // Then fall through + printstr(input); + case '+': + case '-': + case '*': + case '/': + case '%': + case '&': + case '|': + case '^': + printchar('\n'); + opok = true; + break; + default: + printstr("\nInvalid operation\n"); + } + } + + switch (input[0]) { + case '+': + printint(num1+num2); + break; + case '-': + printint(num1-num2); + break; + case '*': + printint(num1*num2); + break; + case '/': + printint(num1/num2); + break; + case '%': + printint(num1%num2); + break; + case '&': + printint(num1&num2); + break; + case '|': + printint(num1|num2); + break; + case '^': + printint(num1^num2); + break; + case '<': + if (num2 < 0 || num2 > 31) { + printstr("Nice try."); + } else { + printint(num1<' : + if (num2 < 0 || num2 > 31) { + printstr("Nice try."); + } else { + printint(num1>>num2); + } + break; + } + + printstr("\nPress any key"); + readstr(input,1); +} diff --git a/c/menu/calculator.h b/c/menu/calculator.h new file mode 100644 index 0000000..4a70356 --- /dev/null +++ b/c/menu/calculator.h @@ -0,0 +1,6 @@ +/* Menu Thing for RVController - Calculator + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +void runCalculator(void); diff --git a/c/menu/calculator.o b/c/menu/calculator.o new file mode 100644 index 0000000..7247432 Binary files /dev/null and b/c/menu/calculator.o differ diff --git a/c/menu/digilines.c b/c/menu/digilines.c new file mode 100644 index 0000000..620d61f --- /dev/null +++ b/c/menu/digilines.c @@ -0,0 +1,66 @@ +/* Menu Thing for RVController - Digilines + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +#include +#include +#include "rvcontroller-ecalls.h" + +char dispbuf[] = "\nLast channel:\n(none) \nLast message:\n(none) \ns: Send\nq: Quit"; + +void dispWrite(char *text,int pos) { + int outpos; + for (int i=0;;i++) { + if (text[i] == 0) { break; } + outpos = pos + i; + dispbuf[outpos] = text[i]; + } +} + +void sendUI(void) { + char channeloutbuf[19]; + char msgoutbuf[19]; + printstr("\n\n\n\n\nEnter channel:\n> "); + readstr(channeloutbuf,19); + printstr(channeloutbuf); + printstr("\nEnter message:\n> "); + readstr(msgoutbuf,19); + printstr(msgoutbuf); + digiline_send(channeloutbuf,msgoutbuf); + printstr("\nSent!\nPress any key"); + readstr(channeloutbuf,1); +} + +void runDigilines(void) { + char channelinbuf[21]; + char msginbuf[21]; + char kbinput; + bool quit = false; + + console_clearbuffer(); + digiline_clearbuffer(); + dispWrite("(none) ",15); + dispWrite("(none) ",50); + + while (!quit) { + if (digiline_bufferlevel() > 0) { + digiline_receive(channelinbuf,21,msginbuf,21); + dispWrite(" ",15); + dispWrite(" ",50); + dispWrite(channelinbuf,15); + dispWrite(msginbuf,50); + } + printstr(dispbuf); + + kbinput = console_readchar(); + switch (kbinput) { + case 's': + sendUI(); + break; + case 'q': + quit = true; + break; + } + } +} diff --git a/c/menu/digilines.h b/c/menu/digilines.h new file mode 100644 index 0000000..480623a --- /dev/null +++ b/c/menu/digilines.h @@ -0,0 +1,6 @@ +/* Menu Thing for RVController - Digilines + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +void runDigilines(void); diff --git a/c/menu/digilines.o b/c/menu/digilines.o new file mode 100644 index 0000000..95a2ac8 Binary files /dev/null and b/c/menu/digilines.o differ diff --git a/c/menu/games.c b/c/menu/games.c new file mode 100644 index 0000000..574c6f0 --- /dev/null +++ b/c/menu/games.c @@ -0,0 +1,121 @@ +/* Menu Thing for RVController - Games + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +#include +#include +#include "rvcontroller-ecalls.h" + +void runCasino(void) { + int32_t input; + int32_t money = 10; + bool quit = false; + char strscratch[1]; + + printstr("\nCASINO\n"); + + while (!quit) { + printstr("You have:\n$"); + printint(money); + printstr("\nBet how much?\n(0 to quit)\n> "); + input = readint(); + printint(input); + printchar('\n'); + + if (input == 0) { + quit = true; + } else if (input < 0 || input > money) { + printstr("Nice try.\n"); + } else { + if (randomint(0,9) >= 6) { // Of course it's not a fair chance. This is a casino, gotta make money here! + printstr("You win!\n"); + money = money + input; + if (money >= 1000000000) { + printstr("You're a \nbillionaire!\nBest quit while\nyou're ahead...\n\nPress any key"); + readstr(strscratch,1); + quit = true; + } + } else { + printstr("You lose.\n"); + money = money - input; + if (money <= 0) { + printstr("You've gambled away\nyour life savings.\nTime to go home...\n\nPress any key"); + readstr(strscratch,1); + quit = true; + } + } + } + } +} + +void runGuessNum(void) { + int32_t answer = randomint(1,99); + int32_t entry; + int32_t guesses = 0; + uint32_t time = rdtime(); + bool quit = false; + char strscratch[1]; + + printstr("GUESS THE NUMBER\nThe computer will\npick a number from\n1 to 99 and you need\nto guess it.\n\nPress any key"); + readstr(strscratch,1); + printstr("\n\n\n\n"); + + while (!quit) { + printstr("Enter your guess:\n(0 to quit)\n> "); + entry = readint(); + if (entry == 0) { + quit = true; + } + printint(entry); + guesses = guesses + 1; + + if (entry == answer) { + printstr("\nCorrect!\n\nYou got it in:\n"); + printint(guesses); + printstr(" guess"); + if (guesses != 1) { printstr("es"); } + printchar('\n'); + time = rdtime() - time; + printint(time); + printstr(" second"); + if (time != 1) { printchar('s'); } + printstr("\nPress any key"); + readstr(strscratch,1); + quit = true; + } else if (entry > answer) { + printstr("\nToo high!\n\n"); + } else { + printstr("\nToo low!\n\n"); + } + } +} + +void runGames(void) { + char inputbuf[2]; + bool quit = false; + while (!quit) { + printstr("\nGAMES\n"); + printstr("1: Casino\n"); + printstr("2: Guess the Number\n"); + printstr("\n\n0: Back"); + readstr(inputbuf,2); + + switch (inputbuf[0]) { + case '0': + quit = true; + break; + case '1': + runCasino(); + quit = true; + break; + case '2': + runGuessNum(); + quit = true; + break; + default: + printstr("\nInvalid option\n\nPress any key\n\n\n"); + readstr(inputbuf,2); + } + } +} diff --git a/c/menu/games.h b/c/menu/games.h new file mode 100644 index 0000000..d2b67be --- /dev/null +++ b/c/menu/games.h @@ -0,0 +1,6 @@ +/* Menu Thing for RVController - Games + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +void runGames(void); diff --git a/c/menu/games.o b/c/menu/games.o new file mode 100644 index 0000000..749068a Binary files /dev/null and b/c/menu/games.o differ diff --git a/c/menu/menu.c b/c/menu/menu.c new file mode 100644 index 0000000..4d3aa14 --- /dev/null +++ b/c/menu/menu.c @@ -0,0 +1,74 @@ +/* Menu Thing for RVController - Main Menu + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +#include +#include +#include "rvcontroller-ecalls.h" +#include "calculator.h" +#include "digilines.h" +#include "games.h" +#include "screensaver.h" + +uint_fast8_t menupage = 0; + +void main(void) { + char inputbuf[32] = {0}; // Overkill for now but it's not like I'm short on RAM + while (true) { + switch (menupage) { + case 0: + printstr("\nMAIN MENU Page 1\n"); + printstr("< > to change page\n"); + printstr("1: Calculator\n"); + printstr("2: Calendar\n"); + printstr("3: Digilines\n"); + printstr("4: Games"); + break; + case 1: + printstr("\nMAIN MENU Page 2\n"); + printstr("< > to change page\n"); + printstr("5: Screensaver\n"); + printstr("6: Text Editor\n"); + printstr("More coming soon\n"); + printstr("(maybe)"); + break; + default: + printstr("\nInvalid menu page\n\n\n\n\n\n"); + } + + readstr(inputbuf,32); + + switch (inputbuf[0]) { + case '<': + if (menupage > 0) { + menupage--; + } else { + menupage = 1; + } + break; + case '>': + menupage = (menupage + 1) % 2; + break; + case '1': + runCalculator(); + break; + case '3': + runDigilines(); + break; + case '4': + runGames(); + break; + case '5': + runScreensaver(); + break; + default: + printstr("\nUnknown or\n"); + printstr("unimplemented\n"); + printstr("command\n"); + printstr("\n"); + printstr("Press any key\n"); + readstr(inputbuf,32); + } + } +} diff --git a/c/menu/menu.elf b/c/menu/menu.elf new file mode 100755 index 0000000..92b42fe Binary files /dev/null and b/c/menu/menu.elf differ diff --git a/c/menu/menu.hex b/c/menu/menu.hex new file mode 100644 index 0000000..2b96462 --- /dev/null +++ b/c/menu/menu.hex @@ -0,0 +1,377 @@ +:10000000370101006128A9487300000082808548FB +:100010007300000082809148730000008280AD4828 +:100020007300000082809308100873000000828033 +:1000300093085008730000008280930870087300D2 +:1000400000008280732510C08280732500C08280EA +:10005000930860087300000082800589F322008005 +:1000600093920248B3E2A200739002808280954886 +:1000700073000000828093080008730000008280F3 +:10008000A1487300000082809308300873000000CC +:100090008280930840087300000082804EB80111EE +:1000A000A2E4CAE052FC5AF862F46AF002C802CA3A +:1000B00002CC02CE02C002C202C402C6056D856D2A +:1000C000938D5DFF0569130979FE85699389A9FD03 +:1000D000056A130ABAFC856A938A4AFA354B856B1E +:1000E000938BCBF611A0712583456D77568552848D +:1000F000CE8C4A8CEE8495C585649384B404054502 +:10010000639CA50205651305E5FF0564130414014E +:10011000856C938C1C02056C130C1C038564938402 +:100120003404D53D0565130575FBF5352285E535A8 +:100130006685D5356285C5352685F13D0A859305E9 +:1001400000023D3F034501001305F5FC6360AB026F +:1001500033457521084102859D2079B703456D77A8 +:10016000854533F5A540230BAD76BDBF0565130569 +:1001700045065535056513051507713D05651305DC +:100180000508513D056513053536713505651305BF +:10019000950851350A8593050002DD35B1B74D222A +:1001A000A1B7EF00105089B703456D7709C57D15DC +:1001B000230BAD7615BF0545230BAD7635B74AB891 +:1001C00022EC4AE852E42313010005651305E535E6 +:1001D00099350565130585093D3D513D2A89053D44 +:1001E00005651305B50A053D5935AA890D35056420 +:1001F0001304F40B93047005056A130A4A0E856A0A +:10020000938A4A3A19A05285393522852935130532 +:1002100061008945B53513056100F53B0345610073 +:100220001305B5FDE3E1A4FE3345552108410285E0 +:100230002945F533034561001305B5FD93057005A8 +:1002400063E2A5088565938545503345B52008418F +:10025000028533653903B5A0130561006D3B29455F +:100260007D3B034561001305B5FD93057005E3FB78 +:10027000A5FC89A833852903A9A03345390391A09A +:1002800033F529013DA81305000263F9A9003315D0 +:10029000390105A81305000263E3A90205651305EA +:1002A000850F953B05A03385290121A833053941E8 +:1002B00009A833E5290131A033C5290119A0335517 +:1002C0003941B13305651305051CB13313056100D0 +:1002D00085457D3362644269226A4ABE108119CA2B +:1002E00085669386066AB695050590891081050591 +:1002F000850565FE82804EB8056513052510213BF6 +:100300001305D101CD45AD3B1305D1012933056559 +:100310001305951109331305A100CD459533130538 +:10032000A100D5391305D1019305A100ED3905656B +:100330001305C512CD311305D101854591334EBE4C +:100340004EB85D71A2FCCAF8D2F4DAF0E2ECEAE849 +:10035000253BFD3905641304046A930680021306E5 +:10036000E0061307F0061305500693059002930468 +:100370000002930A6101130B1100930B300705690A +:1003800013092910856993899911056A130ACA12FC +:10039000A307D4002308C400A308E4002309C40071 +:1003A0002309D402A309C402230AE402A30AC40253 +:1003B000130C1007A309A400230AB400A30A940095 +:1003C000230B9400A30B9400230C9400A30C940023 +:1003D000230D9400A30D9400230E9400A30E94000B +:1003E000230F9400A30F940023009402A30094020F +:1003F00023019402230BA402A30BB402230C940246 +:10040000A30C9402230D9402A30D9402230E9402D4 +:10041000A30E9402230F9402A30F940223009404CA +:10042000A300940423019404A301940423029404DC +:10043000A3029404930C2403130DF40035A84A85F9 +:10044000D93E1305D103CD4525391305D103E13636 +:100450004E85D1361305A102CD451D311305A102EC +:100460005D3E1305D1039305A102753E52856536A5 +:100470001305D10385452931653E79C9130551011D +:10048000D5450A86D546553EA30794002308940017 +:10049000A308940023099400A3099400230A94005C +:1004A000A30A9400230B9400A30B9400230C940044 +:1004B000A30C9400230D9400A30D9400230E94002C +:1004C000A30E9400230F9400A30F94002300940222 +:1004D000A30094022301940223099402A309940225 +:1004E000230A9402A30A9402230B9402A30B9402FE +:1004F000230C9402A30C9402230D9402A30D9402E6 +:10050000230E9402A30E9402230F9402A30F9402CD +:1005100023009404A300940403455101230194048F +:10052000A301940423029404A302940401C9EA855C +:100530005686888908820506850565FD0345010004 +:1005400001C9E6855A86888908820506850565FD04 +:100550002285D1343D3EE30475EFE31F85F16674D7 +:100560004679267A067B666C466D61614EBE4EB852 +:10057000411122FC4AF852F45AF062EC6AE805652F +:1005800013051514493C05651305A514693429455F +:10059000A944B53C056513056515B53CC93C2A84DD +:1005A000BD342945AD3C51C4056913094917856916 +:1005B0009389A914856B938B6B15194C856A938A63 +:1005C000FA17856C938C9C1837D59A3B056B130BE7 +:1005D000FB1C130DF59F056A130AAA1D39A84A854D +:1005E0001D3C4E850D3C26851D345E852D344134E1 +:1005F0002A84313C294525340DCCE34204FEE3C076 +:1006000084FEA5450145853C634885015685213416 +:10061000A294E3589DFC39A05A85F53A818CE342B7 +:1006200090FC11A0668A5285FD321305F1008545C4 +:10063000813C62744279227A027B626C426D410194 +:100640004EBEBAB822EC4AE852E40545930530069E +:10065000854415342A8BFD322A8905651305352218 +:100660005D3A130571008545213C05651305053686 +:100670005D3205651305A528793AD53A2A84413AB1 +:100680006318640505651305B52A713205454132C5 +:1006900005651305652C4132294551326532330415 +:1006A00025412285AD3205651305D52CAD32630594 +:1006B000940013053007A53205651305051CA13A02 +:1006C0001305710085456D3A62644269226ABABEBB +:1006D000635B8B0005651305552D353A11E862649F +:1006E0004269226ABABE05651305252E2D3265D8EA +:1006F00005651305A52805329D3AAA84093A0944DF +:10070000638C640385699389592D056A130AAA28A5 +:10071000856A938A2A2E63569B004E85ED3889E4BC +:100720007DBF5685CD38C5DC5285F5308932AA8427 +:10073000F9380504E39164FF05651305B52AE1382E +:100740002285F13005651305652CF130056513052B +:10075000B5FFD1302945E130F530330425412285FC +:100760007D3005651305D52C7D300545E313A4F4D4 +:10077000A1B74EB822F44AF052EC5AE805691309C1 +:10078000E92E85699389692F056A130A1A30056B6A +:10079000130B6B311304000393042003930B10031A +:1007A000856A938A0A324A85BD304E85AD305285BE +:1007B0009D305A858D301305E1008945D1300345C0 +:1007C000E100630E8500630195026309750156859A +:1007D00099301305E10089456530F1B7493B227432 +:1007E0000279626A426B4EBEA93D22740279626A46 +:1007F000426B4EBE81453306B5001082850565FE0D +:100800001385F5FF8280FD573307F5005883850770 +:1008100065FF63C405023387F500514893284701FB +:100820003307B8403377170FB3D7170FB368F70004 +:100830002E882A87634A1001A9A801483307B540CA +:10084000B388F50063571005B347C62033C6C720E9 +:1008500085C2429605651305756F32950505B30788 +:100860001501930500020C890505E31EF5FE15A090 +:10087000429685669386766F4698B305B5403305F4 +:10088000D6000505C2951083050710890505E31CF0 +:10089000B7FE82804AB822EC4AE852E45AE0954515 +:1008A0000145EFF04FFD2A84EFF00FFEEFF06FFEF1 +:1008B00005691309796FCD4419C105457DA04D5ACD +:1008C000856993892934930B1900D54A214B29A8AE +:1008D00095450145EFF02FFA2A84D1444A85EFF07F +:1008E0008FF3EFF00FFB2DE1E3549AFE1385F4FF35 +:1008F000635B900063C16403B3849A402A86CE850B +:10090000634E90001DA80146B38599408505B1044A +:10091000634690001DA0B544CE852A86B346842048 +:10092000DE94B3C68620B2963386DB00A696988105 +:10093000188A05068505E31CD6FEAA844A85EFF0D1 +:100940008FEDEFF00FF54DD163CA04001D4563ED47 +:10095000A4005145058D634AA00035A01385D4003D +:1009600081446344A00005A03545B3458420CA9462 +:10097000B3C58520A69585052E951306000290899E +:100980008505E39EA5FE62644269226A026B4ABE47 +:100990004EB822F44AF052EC5AE862E46AE0EFF012 +:1009A000AFEEEFF00FEF314985699389796F01C59B +:1009B0008144014501AA814A8144854C138A19006A +:1009C00013040002056B130B0B35D14B214C054D65 +:1009D0002DA813A514007D1D3375AD0E93A51A0027 +:1009E000FD1CB3F5BC0E13A674007D160505336D12 +:1009F000A60013A55A007D158505B36CB5004E857C +:100A0000EFF06FE1EFF0EFE851E963CA040063EE45 +:100A1000840133859B40A685634BA0003DA08145A2 +:100A20001385C4006345A0000DA03145A68533C6DB +:100A30005A21B306AA0033455621AA953305BA00B8 +:100A4000B69500890505E31EB5FEEA94E69A63CBE8 +:100A5000040063E18403B3859B4026865A85634E78 +:100A6000B00085BF014633059B409385C4006346B3 +:100A7000B00085B7B1455A852686B3C65A213307DB +:100A8000BA00B3C556212E96B305CA003A96148112 +:100A9000948985050505E39CC5FE25BF33C55A210C +:100AA0003345552163CB0400A14563EDB400D14526 +:100AB000338995406348200105A01389C40081440F +:100AC000635C200126954E9505052A999305000241 +:100AD0000C890505E31E25FF22740279626A426BC8 +:100AE000226C026D4EBE4EB83971A2F4CAF0D2EC3F +:100AF000DAE8E2E4EAE079556D58FD52F1566157C3 +:100B0000A547B1480944C94505469D442ADE194315 +:100B10003AD636D816DA42DC954B3ED4114532CC63 +:100B20002ECE22D046D28D4526CA930D00022EC26B +:100B30002AC45EC61AC82311B101EFF0EFD4EFF05A +:100B40004FD5056A130A7A6F630A051EA300BA011E +:100B50002301BA01A301BA012302BA01A302BA0117 +:100B60002303BA01A303BA012304BA01A304BA01FF +:100B70002305BA01A305BA012306BA01A306BA01E7 +:100B80002307BA01A307BA012308BA01A308BA01CF +:100B90002309BA01A309BA01230ABA01230BBA0136 +:100BA000A30BBA01230CBA01A30CBA01230DBA019D +:100BB000A30DBA01230EBA01A30EBA01230FBA0185 +:100BC000A30FBA012300BA03A300BA032301BA0397 +:100BD000A301BA032302BA03A302BA032303BA038D +:100BE000A303BA032304BA03A304BA03A305BA03F5 +:100BF0002306BA03A306BA032307BA03A307BA035B +:100C00002308BA03A308BA032309BA03A309BA0342 +:100C1000230ABA03A30ABA03230BBA03A30BBA032A +:100C2000230CBA03A30CBA03230DBA03A30DBA0312 +:100C3000230EBA03A30EBA03230FBA032300BA0587 +:100C4000A300BA052301BA05A301BA052302BA0518 +:100C5000A302BA052303BA05A303BA052304BA0500 +:100C6000A304BA052305BA05A305BA052306BA05E8 +:100C7000A306BA052307BA05A307BA052308BA05D0 +:100C8000A308BA052309BA05A309BA05A30ABA0538 +:100C9000230BBA05A30BBA05230CBA05A30CBA059E +:100CA000230DBA05A30DBA05230EBA05A30EBA0586 +:100CB000230FBA05A30FBA052300BA07A300BA078A +:100CC0002301BA07A301BA072302BA07A302BA078E +:100CD0002303BA07A303BA072304BA072305BA07F5 +:100CE000A305BA072306BA07A306BA072307BA075C +:100CF000A307BA072308BA07A308BA072309BA0744 +:100D0000A309BA07230ABA07A30ABA07230BBA072B +:100D1000A30BBA07230CBA07A30CBA07230DBA0713 +:100D2000A30DBA07230EBA07A30EBA0726740679D5 +:100D3000666A466B266C066D21614EBE014D6410DD +:100D4000130B810113042100130C6A0121A0050D6E +:100D5000630F7D05B3499D2003A90900930C190079 +:100D600023A09901130510029305A007EFF0AFB07F +:100D70002301A10063E99B0733456D210841FD551F +:100D80003306B4005082850565FE3306B50063481E +:100D9000050213264601D146898EB3F6C60E33D618 +:100DA000C50E558E930521006340C0022DA85285C3 +:100DB000EFF06FA6EFF0EFAD014D49DD41BBB3059C +:100DC000A44001456351C002B3462921B3C6262180 +:100DD000AA963305DC00E2963696948114890505BF +:100DE0008505E31CC5FE4800B34AAD2003A50A00F3 +:100DF000B385AC4063E7BB06B3456D218C417D569E +:100E0000B306C400D4820506E5FE93D6F501338708 +:100E1000C500D1478D8F93244701B3F7970E335602 +:100E2000960E5D8E3376D60EB356D70E558E641061 +:100E3000E35FC0F0B3E5050AB3462921B3C6262116 +:100E40003347A5203347A720B6953305EC402E95B0 +:100E5000998DE2952E962300B5010505E31DC5FE8B +:100E6000FDB51945E3C5A5EE85450145EFF0AFA0F9 +:100E70008545E31EB5EC05458D45EFF0CF9F330565 +:100E8000A04023A0A900CD450145EFF0CF9EB3457A +:100E90006D2188C10945A145EFF0EF9D23A0AA006F +:100EA0007DB54EB8411122FC4AF852F45AF062EC7A +:100EB0006AE805691309D935856993895936056A40 +:100EC000130A2A37856A938AEA37056B130B0B39A5 +:100ED000056C130C3C3605641304B43993041003F9 +:100EE000930C0003856B938B0B32130D2003930D32 +:100EF000300309A85E85EFF00F9213057100854558 +:100F0000EFF00F984A85EFF00F914E85EFF0AF901C +:100F10005285EFF04F905685EFF0EF8F5A85EFF046 +:100F20008F8F6285EFF02F8F2285EFF0CF8E130524 +:100F300071008945EFF0CF940345710063C7A400A9 +:100F4000630E9501E31895FA09A86306A501E3135A +:100F5000B5FB513E21A02D3C11A02D3A627442797F +:100F6000227A027B626C426D41014EBE5801000044 +:100F70006C0100009E010000E6000000A2010000DC +:100F80006C0100006C0100006C0100006C010000AD +:100F90006C0100006C010000A80100006C01000061 +:100FA0005C0100000A4D41494E204D454E552050F0 +:100FB00061676520310A003C203E20746F20636821 +:100FC000616E676520706167650A00313A20436190 +:100FD0006C63756C61746F720A00323A2043616C05 +:100FE000656E6461720A00333A20446967696C690E +:100FF0006E65730A00343A2047616D6573000A4DCF +:1010000041494E204D454E55205061676520320ABA +:1010100000353A2053637265656E73617665720AB6 +:1010200000363A205465787420456469746F720AFA +:10103000004D6F726520636F6D696E6720736F6F0F +:101040006E0A00286D6179626529000A496E766131 +:101050006C6964206D656E7520706167650A0A0AA7 +:101060000A0A0A000A556E6B6E6F776E206F720A5D +:1010700000756E696D706C656D656E7465640A00EF +:10108000636F6D6D616E640A0050726573732061E9 +:101090006E79206B65790A00456E746572206E75F5 +:1010A0006D62657220313A0A3E20000A456E746511 +:1010B00072206E756D62657220323A0A3E20000A17 +:1010C00053656C656374206F7065726174696F6ECF +:1010D0003A0A5B2B2D2A2F25267C5E3C3C3E3E5D4A +:1010E000203E20000A496E76616C6964206F70654D +:1010F000726174696F6E0A004E696365207472795B +:101100002E000A0A0A0A0A456E7465722063686135 +:101110006E6E656C3A0A3E20000A456E7465722058 +:101120006D6573736167653A0A3E20000A53656E08 +:1011300074210A507265737320616E79206B657932 +:10114000000A434153494E4F0A00596F75206861A8 +:1011500076653A0A24000A42657420686F77206D2C +:101160007563683F0A283020746F2071756974298F +:101170000A3E20004E696365207472792E0A005978 +:101180006F752077696E210A00596F752772652087 +:1011900061200A62696C6C696F6E61697265210A0F +:1011A000426573742071756974207768696C650A8B +:1011B000796F752772652061686561642E2E2E0A2D +:1011C0000A507265737320616E79206B65790059DE +:1011D0006F75206C6F73652E0A00596F75277665E1 +:1011E0002067616D626C656420617761790A796F4F +:1011F0007572206C69666520736176696E67732EFF +:101200000A54696D6520746F20676F20686F6D6583 +:101210002E2E2E0A0A507265737320616E79206B30 +:10122000657900475545535320544845204E554D48 +:101230004245520A54686520636F6D70757465721B +:101240002077696C6C0A7069636B2061206E756D24 +:101250006265722066726F6D0A3120746F203939B1 +:1012600020616E6420796F75206E6565640A746F05 +:101270002067756573732069742E0A0A507265734E +:101280007320616E79206B657900456E74657220FC +:10129000796F75722067756573733A0A2830207408 +:1012A0006F2071756974290A3E20000A436F7272BB +:1012B000656374210A0A596F7520676F7420697419 +:1012C00020696E3A0A0020677565737300207365A4 +:1012D000636F6E64000A546F6F2068696768210A43 +:1012E0000A000A546F6F206C6F77210A0A000A47C0 +:1012F000414D45530A00313A20436173696E6F0ACC +:1013000000323A20477565737320746865204E7506 +:101310006D6265720A000A0A303A204261636B000E +:101320000A496E76616C6964206F7074696F6E0A29 +:101330000A507265737320616E79206B65790A0AB1 +:101340000A005256436F6E74726F6C6C65722000A7 +:101350005256436F6E74726F6C6C6572000A0A0AA3 +:101360000A0A0A0A0053435245454E534156455214 +:101370000A00313A204D6172717565650A00323A92 +:1013800020426F756E63696E6720546578740A0039 +:10139000333A204D61747269780A00303A204578FA +:1013A00069740000300200003002000006020000F4 +:1013B00006020000060200003002000030020000B9 +:1013C00006020000300200000602000030020000A9 +:1013D00006020000060200000602000006020000ED +:1013E00006020000060200000602000006020000DD +:1013F00006020000060200000602000006020000CD +:101400005802000006020000580200000602000018 +:1014100006020000060200000602000006020000AC +:10142000060200000602000006020000060200009C +:10143000060200000602000006020000060200008C +:10144000060200000602000006020000060200007C +:10145000060200000602000006020000060200006C +:10146000060200000602000006020000060200005C +:10147000060200000602000006020000060200004C +:101480000602000006020000300200000602000012 +:10149000060200000602000006020000060200002C +:1014A000060200000602000006020000060200001C +:1014B000060200000602000006020000060200000C +:1014C00006020000060200000602000006020000FC +:1014D00006020000060200000602000006020000EC +:1014E00006020000060200000602000006020000DC +:1014F00006020000060200000602000006020000CC +:10150000300200005202000080020000C40200000D +:10151000C4020000C402000074020000A602000021 +:10152000C4020000AC020000C40200007A02000005 +:10153000C4020000C4020000C4020000C402000093 +:10154000C4020000C4020000C4020000C402000083 +:10155000C4020000C4020000C4020000C402000073 +:1015600086020000C402000094020000C4020000D1 +:10157000C4020000C4020000C4020000C402000053 +:10158000C4020000C4020000C4020000C402000043 +:10159000C4020000C4020000C4020000C402000033 +:1015A000C4020000C4020000C4020000C402000023 +:1015B000C4020000C4020000C4020000C402000013 +:1015C000C4020000C4020000C4020000C402000003 +:1015D000C4020000C4020000C4020000C4020000F3 +:1015E000C4020000C4020000B8020000C4020000EF +:1015F000C4020000C4020000C4020000C4020000D3 +:10160000C4020000C4020000C4020000C4020000C2 +:10161000C4020000C4020000C4020000C4020000B2 +:10162000C4020000C4020000C4020000C4020000A2 +:10163000C4020000C4020000C4020000C402000092 +:10164000C4020000C4020000C4020000C402000082 +:10165000C4020000C4020000C4020000C402000072 +:10166000B2020000F8FFFFFFFCFFFFFFFFFFFFFFDC +:10167000FBFFFFFFFEFFFFFF010000001200000064 +:10168000020000000C000000090000000300000040 +:101690000400000005000000060000000700000034 +:1016A0000A4C617374206368616E6E656C3A0A2837 +:1016B0006E6F6E65292020202020202020202020F1 +:1016C0002020200A4C617374206D65737361676517 +:1016D0003A0A286E6F6E65292020202020202020C5 +:1016E0002020202020200A733A2053656E640A715E +:1016F0003A2051756974000A2020202020202020E3 +:101700002020202020202020202020200A202020EF +:1017100020202020202020202020202020202020C9 +:10172000200A2020202020202020202020202020CF +:101730002020202020200A202020202020202020BF +:1017400020202020202020202020200A20202020AF +:101750002020202020202020202020202020202089 +:101760000A2020202020202020202020202020208F +:0717700020202020200000D2 +:00000001FF diff --git a/c/menu/menu.o b/c/menu/menu.o new file mode 100644 index 0000000..43e4e58 Binary files /dev/null and b/c/menu/menu.o differ diff --git a/c/menu/rvcontroller.ld b/c/menu/rvcontroller.ld new file mode 100644 index 0000000..985892b --- /dev/null +++ b/c/menu/rvcontroller.ld @@ -0,0 +1,45 @@ +/* Thanks https://github.com/darklife/darkriscv */ + __heap_size = 0x200; /* required amount of heap */ + __stack_size = 0x800; /* required amount of stack */ + ENTRY(_start); + MEMORY + { + RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 0x10000 + } + SECTIONS + { + .text : + { + *(.text.startup) + *(.text) + *(.text) + *(.rodata*) + } > RAM + .data : + { + *(.sbss) + *(.data) + *(.bss) + *(.rela*) + *(COMMON) + } > RAM + + .heap : + { + . = ALIGN(4); + PROVIDE ( end = . ); + _sheap = .; + . = . + __heap_size; + . = ALIGN(4); + _eheap = .; + } >RAM + + .stack : + { + . = ALIGN(4); + _estack = .; + . = . + __stack_size; + . = ALIGN(4); + _sstack = .; + } >RAM + } diff --git a/c/menu/screensaver.c b/c/menu/screensaver.c new file mode 100644 index 0000000..70e1647 --- /dev/null +++ b/c/menu/screensaver.c @@ -0,0 +1,137 @@ +/* Menu Thing for RVController - Screensaver + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +#include +#include +#include "rvcontroller-ecalls.h" + +char screensaverbuf[] = "\n \n \n \n \n \n "; + +int strlen(char *string) { + int i; + for (i = 0;string[i] != 0;i++) {} + return i; +} + +void screensaverWriteText(char *text, int column, int row, bool erase) { + int textlen = strlen(text); + if (column < 0) { + // Cut the left side off of the text and change the start position to the left side of the screen + text = text + (0 - column); + textlen = textlen + column; + column = 0; + } else if (column + textlen > 19) { + // Cut the right side off of the text + textlen = 20 - column; + } + for (int i=0;i < textlen;i++) { + if (erase) { + screensaverbuf[(row*21)+column+i+1] = 0x20; + } else { + screensaverbuf[(row*21)+column+i+1] = text[i]; + } + } +} + +void doMarquee(void) { + char text[] = "RVController "; + int col = 19; + int row = randomint(0,5); + console_clearbuffer(); + while (console_readchar() == 0) { + col--; + if (col < (0 - strlen(text))) { + col = 20; + row = randomint(0,5); + } + screensaverWriteText(text,col,row,false); + printstr(screensaverbuf); + } + screensaverWriteText(text,col,row,true); +} + +void doBouncingText(void) { + char text[] = "RVController"; + int col = 0; + int row = 0; + int xdir = 1; + int ydir = 1; + console_clearbuffer(); + while (console_readchar() == 0) { + screensaverWriteText(text,col,row,true); + col = col + xdir; + row = row + ydir; + if (col <= 0) { xdir = 1; } + if (col >= (19 - strlen(text))) { xdir = -1; } + if (row <= 0) { ydir = 1; } + if (row >= 5) { ydir = -1; } + screensaverWriteText(text,col,row,false); + printstr(screensaverbuf); + } + screensaverWriteText(text,col,row,true); +} + +void doMatrix(void) { + int row[] = {-8,-4,-1,-5,-2}; // "Random" positions off the top of the screen to give "random" start delays + int col[] = {1,18,2,12,9}; + int len[] = {3,4,5,6,7}; + char textscratch[] = " "; + console_clearbuffer(); + while (console_readchar() == 0) { + for (int i=0;i<=4;i++) { + row[i]++; + textscratch[0] = randomint(0x21,0x7a); + if (row[i] <= 5 && row[i] >= 0) { + screensaverWriteText(textscratch,col[i],row[i],false); + } + if ((row[i] - len[i]) <= 5 && (row[i] - len[i]) >= 0) { + screensaverWriteText(textscratch,col[i],(row[i] - len[i]),true); + } else if ((row[i] - len[i]) > 5 && randomint(0,1) == 1) { + row[i] = 0 - randomint(1,3); + col[i] = randomint(0,19); + len[i] = randomint(2,8); + } + } + printstr(screensaverbuf); + } + for (int i=0;i <= 5;i++) { + screensaverWriteText(" ",0,i,true); + } +} + +void runScreensaver(void) { + char inputbuf[9]; + bool quit = false; + while (!quit) { + printstr("\n\n\n\n\n\n\n"); + printstr("SCREENSAVER\n"); + printstr("1: Marquee\n"); + printstr("2: Bouncing Text\n"); + printstr("3: Matrix\n"); + printstr("\n"); + printstr("0: Exit"); + readstr(inputbuf,2); + switch (inputbuf[0]) { + case '0': + quit = true; + break; + case '1': + doMarquee(); + quit = true; + break; + case '2': + doBouncingText(); + quit = true; + break; + case '3': + doMatrix(); + quit = true; + break; + default: + printstr("\nInvalid option\n\nPress any key\n\n\n"); + readstr(inputbuf,1); + } + } +} diff --git a/c/menu/screensaver.h b/c/menu/screensaver.h new file mode 100644 index 0000000..f56811a --- /dev/null +++ b/c/menu/screensaver.h @@ -0,0 +1,6 @@ +/* Menu Thing for RVController - Screensaver + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +void runScreensaver(void); diff --git a/c/menu/screensaver.o b/c/menu/screensaver.o new file mode 100644 index 0000000..1f725d3 Binary files /dev/null and b/c/menu/screensaver.o differ -- cgit v1.2.3