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/drawercalc/Makefile | 20 +++++++ c/drawercalc/drawercalc.c | 129 +++++++++++++++++++++++++++++++++++++++++++ c/drawercalc/drawercalc.elf | Bin 0 -> 7028 bytes c/drawercalc/drawercalc.hex | 56 +++++++++++++++++++ c/drawercalc/drawercalc.o | Bin 0 -> 5512 bytes c/drawercalc/rvcontroller.ld | 45 +++++++++++++++ 6 files changed, 250 insertions(+) create mode 100644 c/drawercalc/Makefile create mode 100644 c/drawercalc/drawercalc.c create mode 100755 c/drawercalc/drawercalc.elf create mode 100644 c/drawercalc/drawercalc.hex create mode 100644 c/drawercalc/drawercalc.o create mode 100644 c/drawercalc/rvcontroller.ld (limited to 'c/drawercalc') diff --git a/c/drawercalc/Makefile b/c/drawercalc/Makefile new file mode 100644 index 0000000..52f47d1 --- /dev/null +++ b/c/drawercalc/Makefile @@ -0,0 +1,20 @@ +all: drawercalc.hex + +drawercalc.o: drawercalc.c + clang -target riscv32-none-elf -I../rvcontroller-libraries -march=rv32imacb_zicntr_zicond_zicsr_zifencei_zihintpause_zilsd_zclsd_zabha_zacas_zbkb_zbkx_zcb_zcmp_zcmt -ffreestanding -O3 -c -o drawercalc.o drawercalc.c + +drawercalc.elf: ../rvcontroller-libraries/rvcontroller-init.o ../rvcontroller-libraries/rvcontroller-ecalls.o drawercalc.o + riscv32-none-elf-ld -T rvcontroller.ld --no-warn-rwx-segments -o drawercalc.elf ../rvcontroller-libraries/rvcontroller-init.o drawercalc.o ../rvcontroller-libraries/rvcontroller-ecalls.o + +dump: drawercalc.elf + riscv32-none-elf-objdump -d drawercalc.elf + +drawercalc.hex: drawercalc.elf + riscv32-none-elf-objcopy -O ihex drawercalc.elf drawercalc.hex + +load: drawercalc.hex + bash -c "wl-copy < drawercalc.hex" + +clean: + rm -f drawercalc.bin drawercalc.elf drawercalc.o init.o + diff --git a/c/drawercalc/drawercalc.c b/c/drawercalc/drawercalc.c new file mode 100644 index 0000000..1d2de03 --- /dev/null +++ b/c/drawercalc/drawercalc.c @@ -0,0 +1,129 @@ +/* Drawer Capacity Calculator for RVController + * 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" + +#define BASE_SLOTS 32 +#define STACK_MAX 99 +#define STEEL_UPGRADE_MULT 1 +#define GOLD_UPGRADE_MULT 2 +#define OBSIDIAN_UPGRADE_MULT 3 +#define DIAMOND_UPGRADE_MULT 7 +#define MITHRIL_UPGRADE_MULT 12 + +bool checkUpgradeCount(int32_t count,int32_t maxcount) { + return (count >= 0 && count <= maxcount); +} + +void main(void) { + while (true) { + int32_t capacity = BASE_SLOTS * STACK_MAX; + uint8_t upgrades_used = 0; + printstr("\n\n\nSettings:\n"); + printstr("Base Stack Count: "); + printint(BASE_SLOTS); + printstr("\nMax Stack Size: "); + printint(STACK_MAX); + printchar('\n'); + + int32_t upgcount = 0; + while (true) { + printstr("\nSteel Upgrades?\n[0-5] > "); + upgcount = readint(); + printint(upgcount); + printchar('\n'); + if (checkUpgradeCount(upgcount,5)) { + break; + } else { + printstr("Invalid entry"); + } + } + upgrades_used += upgcount; + capacity += BASE_SLOTS * STACK_MAX * STEEL_UPGRADE_MULT * upgcount; + + if (upgrades_used < 5) { + while (true) { + printstr("\nGold Upgrades?\n[0-"); + printint(5-upgrades_used); + printstr("] > "); + upgcount = readint(); + printint(upgcount); + printchar('\n'); + if (checkUpgradeCount(upgcount,5-upgrades_used)) { + break; + } else { + printstr("Invalid entry"); + } + } + upgrades_used += upgcount; + capacity += BASE_SLOTS * STACK_MAX * GOLD_UPGRADE_MULT * upgcount; + } + + if (upgrades_used < 5) { + while (true) { + printstr("\nObsidian Upgrades?\n[0-"); + printint(5-upgrades_used); + printstr("] > "); + upgcount = readint(); + printint(upgcount); + printchar('\n'); + if (checkUpgradeCount(upgcount,5-upgrades_used)) { + break; + } else { + printstr("Invalid entry"); + } + } + upgrades_used += upgcount; + capacity += BASE_SLOTS * STACK_MAX * OBSIDIAN_UPGRADE_MULT * upgcount; + } + + if (upgrades_used < 5) { + while (true) { + printstr("\nDiamond Upgrades?\n[0-"); + printint(5-upgrades_used); + printstr("] > "); + upgcount = readint(); + printint(upgcount); + printchar('\n'); + if (checkUpgradeCount(upgcount,5-upgrades_used)) { + break; + } else { + printstr("Invalid entry"); + } + } + upgrades_used += upgcount; + capacity += BASE_SLOTS * STACK_MAX * DIAMOND_UPGRADE_MULT * upgcount; + } + + if (upgrades_used < 5) { + while (true) { + printstr("\nMithril Upgrades?\n[0-"); + printint(5-upgrades_used); + printstr("] > "); + upgcount = readint(); + printint(upgcount); + printchar('\n'); + if (checkUpgradeCount(upgcount,5-upgrades_used)) { + break; + } else { + printstr("Invalid entry"); + } + } + upgrades_used += upgcount; + capacity += BASE_SLOTS * STACK_MAX * MITHRIL_UPGRADE_MULT * upgcount; + } + + printstr("\n1 slot: "); + printint(capacity); + printstr("\n2 slots: "); + printint(capacity/2); + printstr("\n4 slots: "); + printint(capacity/4); + printstr("\nPress 0 to run again\n"); + upgcount = readint(); + } +} diff --git a/c/drawercalc/drawercalc.elf b/c/drawercalc/drawercalc.elf new file mode 100755 index 0000000..be34b55 Binary files /dev/null and b/c/drawercalc/drawercalc.elf differ diff --git a/c/drawercalc/drawercalc.hex b/c/drawercalc/drawercalc.hex new file mode 100644 index 0000000..b66fc63 --- /dev/null +++ b/c/drawercalc/drawercalc.hex @@ -0,0 +1,56 @@ +:10000000370101002928A948730000008280135697 +:10001000F50133A5A500518D1345150082804EB81A +:100020000111A2E4CAE052FC5AF862F46AF00565D4 +:100030001309C0279304A0281304D029930BF02A96 +:10004000194B9549930C702D130D402C130C902CCB +:100050008965930DB02E1566A566130505C62ACED3 +:100060001385058C2ACC138505522ACA1305066A06 +:100070002AC8138506482AC63DA83245419D2A9ABA +:100080005A899304A0281304D029194B130510335F +:100090009D225285A92A1305B033B12A13551A009F +:1000A000B92213056034812A13552A0089221305C9 +:1000B00010359122692A4A853D2A26852D2A130565 +:1000C000000235222285052A130530060D22294516 +:1000D0003D225E850D22A52AAA8A112A29450522DC +:1000E00063ED6A016285012A5E8531228D22AA8A2A +:1000F000FD2829452922E3E759FF7245338AAA02E0 +:100100002A9AE3853AF96685FD20338B59415A8551 +:10011000F9286A85CD20252AAA84D1282945C52019 +:1001200063779B006285C1286685F120CDB7A69ACA +:100130006245459D2A9A1145E36555F54A8B6E85C2 +:100140005D28B384594126855D206A856D20012292 +:100150002A847128294565201309303063F184020F +:10016000628551286E854128268551206A85612047 +:10017000F9282A84AD2829455920E3E384FEA29A70 +:100180005245419D2A9A1145E36C55EF4A85A520B9 +:10019000B38459412685A1286A85B1284D282A842F +:1001A000B9202945A92863F784006285A9204A85DA +:1001B0009920CDB7A29A4245419D2A9A1145E36103 +:1001C00055ED1309A0314A853D20B3845941268558 +:1001D00039286A850D20A5282A841128294505205B +:1001E000E3FD84E8628501284A853120CDB7854842 +:1001F0007300000082809148730000008280AD4847 +:100200007300000082809308100873000000828051 +:1002100093085008730000008280930870087300F0 +:1002200000008280732510C08280732500C0828008 +:10023000930860087300000082800589F322008023 +:1002400093920248B3E2A2007390028082809548A4 +:100250007300000082809308000873000000828011 +:10026000A1487300000082809308300873000000EA +:100270008280930840087300000082800A0A0A53B3 +:10028000657474696E67733A0A004261736520533E +:100290007461636B20436F756E743A20000A4D6180 +:1002A0007820537461636B2053697A653A20000AA1 +:1002B000537465656C2055706772616465733F0A9D +:1002C0005B302D355D203E2000496E76616C69649F +:1002D00020656E747279000A476F6C6420557067F0 +:1002E00072616465733F0A5B302D000A4F62736967 +:1002F0006469616E2055706772616465733F0A5B63 +:10030000302D000A4469616D6F6E6420557067720C +:10031000616465733F0A5B302D000A4D6974687231 +:10032000696C2055706772616465733F0A5B302D9C +:10033000000A3120736C6F743A20000A3220736C0B +:100340006F74733A20000A3420736C6F74733A2010 +:10035000000A5072657373203020746F2072756EBE +:0803600020616761696E0A006B +:00000001FF diff --git a/c/drawercalc/drawercalc.o b/c/drawercalc/drawercalc.o new file mode 100644 index 0000000..fac534a Binary files /dev/null and b/c/drawercalc/drawercalc.o differ diff --git a/c/drawercalc/rvcontroller.ld b/c/drawercalc/rvcontroller.ld new file mode 100644 index 0000000..985892b --- /dev/null +++ b/c/drawercalc/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 + } -- cgit v1.2.3