You are browsing as a guest. Sign up (or log in) to start making projects!

3h 47m 11s logged

programming update: implemented most of the flash memory into my program, as well as some (SOME) lua.

flash memory took the longest. reading through documentation is boring but informative. i got a better understanding of how SPI works, and if not that, how the chip itself works. they have these diagrams of the MISO, MOSI, CS, and SCK lines which shows how data gets transferred. i attached a picture of one of those diagrams below.

regarding lua: it didn’t take that long because i’ve experimented with it before in mallow revision 1.4. lua is interesting since, using the lua VM in C at least, it’s stack-based, using pop and push functions. it reminds me of the time i tried learning assembly.

i need to try to push an actual file so i dont need to write down files like this…

// i'll probably need to store the length of the script somewhere.
// a script struct is probably going to be used for organization 
const char *script = "local counter = 0\n"
                     "function update() end\n"
                     "function render()\n"
                     "if counter >= 0.5 then\n"
                     "draw_rect_filled(5, 5, 310, 230, 0xf81f)\n"
                     "display_fb()\n"
                     "counter = 0\n"
                     "end\n"
                     "counter = counter + delta_time\n"
                     "end\n";

…it works for now, but it’s gonna get messy if i were to push an actual game file. i need to also figure out how to push image data to flash.

here’s an example of popping stuff in lua (from my program on 8/19/26:

    // get and call update
    lua_getglobal(L, "update");
    if (lua_isfunction(L, -1)){
      if (lua_pcall(L, 0, 0, 0) != LUA_OK){
        printf("ERR CALLING UPDATE: %s\n", lua_tostring(L, -1));
        lua_pop(L, 1);
      }
    }
    else {
      lua_pop(L, 1);
    }

when you get the function, it pushes it to the top of the stack. then it checks if what you got was a function, as well as actually calling the code inside the function. if something goes wrong, it print’s the error. either way, it pops the function from the stack since we dont need it any more for that while loop cycle. this is the same process for render.

if anyone actually decided to read through all of this, tell me about your own project. idk if im yapping into the void or not.

i cant wait for my pcbs to come in, programming gets boring sometimes 🥹

0
13

Comments 0

No comments yet. Be the first!