Long winded explanation:
UPDATE 0.2:
- A bit more content to show possible use cases
- Implemented scrolling with mouse wheel with @Einstein2's tips
- Now shows mouse
Very nice! I once had a similar idea for a pico-8 operating system, where that region of memory could be used to download "packages" then write them (using printh) to a "disk" (a text file that would be #include-d each time the cart restarted).
A few things I'd like to say:
-
There are two general use regions: 0x4300..0x55ff and 0x5600..0x5dff. The first one is 4864 bytes (bytes, not 32-bit numbers: that's only 4864 characters, not 19456) long, and is the one that is not cleared upon load()ing. The second one is 2048 bytes long, can be used for the second font, and does get emptied upon load()ing just like any other section of memory.
-
The third parameter of load() is a (maximum 1024 characters long) string that will get passed to the cart you're loading. This increases the max transferable amount of chars/bytes to 5888.
-
With stat(36) you can detect mouse scroll events; it'd be quite simple to hook it up to your existing scrolling system.
- poke(0x5f34,1) lets you include fill patterns inside the color value. This means you can have simple two-color patterns for a background without having to change much. From the manual:
@Einstein2 (sorry for being late) Thanks for the tips! Also, your operating system idea is very interesting! Maybe I should try implementing that package system sometime.
@wallgraffiti
No worries!
I tried to make the package system with the general-use memory section... it wasn't working at all, I have no clue why. So instead I resorted to only using the third load parameter:
[cart1.p8]
h=split(stat(6),"•",false) --the string returned from cart2 is [package content]•[index of next package] printh(h[1],"disk.txt",false) --print contents to file if(h[2]!="0")load("cart2.p8",nil,"package•cart1.p8"..(h[2]and "•"..h[2]or "")) --[packagename]•[cart to load]•[index] ; don't download anymore if the index is equal to 0 #include disk.txt --disk.txt (or whatever you name it) does need to exist before this cart is run |
[cart2.p8]
pckgs={} pckgs.package=2 --number of loads needed to download the complete package pckgs.package1="a=5" pckgs.package2="b=5" --package number starts from the highest and counts down (i.e. package2 is downloaded first, then package1) h=split(stat(6),"•") --[packagename]•[cart to load]•[index of package to download] b=tonum(h[3])or(pckgs[h[1]]) --the first load, [index] will be nil, so it fetches the load number (in this case, 2) load(h[2],nil,pckgs[h[1]..b].."•"..b-1) --load [cart to load], passing [package content]•[index-1] |
This works fairly well, although it's a bit slow. Feel free to ask how specific parts work if the comments are not thorough enough.
[Please log in to post a comment]