I’ve been trying to decrease the amount of data may Makecode program takes up and I thought it was good until i downloaded it as a file. Downloading a game with no code takes up 509 KB. so my game takes a little over 23KB. My computer is rounding up the data to 24. What is taking up 509 KB?
Also if anyone has suggestions if making variables with small integers take up less data is possible, that would be nice.
use buffers. idk if their accesseble in blocks (ask Richard is you dont use javascript), in Javascript you do hex`…` where … is whatever hex value. Fit example:
when you download your project in makecode, the UF2 file contains two things:
the source code, which is all the files in your project. that’s also what is in the PNG version of the file
the compiled binary, which is what runs on the hardware device when you flash it. this is not in the PNG file
the compiled binary is what’s taking up the majority of the space here. that binary is going to be about that size no matter how much code is in your project, there isn’t really an easy way for you to make it smaller from within your project. i can go more into detail on how our native compilation works but that’s the gist.
why are you trying to do this, if i may ask? i can give more concrete suggestions if i have an idea of what problem you’re trying to solve.
I’m trying to get my project to run as fast and smoothly as possible while also being small enough to be available too make code compatible consoles. The program I made in make code arcade is just a tiles system that anybody can add games on top of so it has to be as small as passable.
if you want an accurate picture of how big the program is on hardware, then you can find out by following these steps:
switch to javascript
click download and select your hardware
in the file explorer beneath the simulator, expand the “built” section at the bottom of the list
select “binary.asm”
at the top of that file, you’ll see a comment like this:
; Interface tables: 544/1748 (31%)
; Virtual methods: 37 / 250
; generated code sizes (bytes): 131920 (incl. 92322 user, 4546 helpers, 11788 vtables, 23264 lits); src size 668
; assembly: 81205 lines; density: 34.26 bytes/stmt; (2695 stmts)
; total bytes: 342508 (69.7% of 480.0k flash with 149012 free)
; peep hole pass: 1634 instructions removed and 2928 updated
; peep hole pass: 1341 instructions removed and 6 updated
; peep hole pass: 1 instructions removed and 1 updated
; peep hole pass: 0 instructions removed and 0 updated
that percentage there is the total amount of the available flash space on the board that is occupied by the compiled binary. the above example is for an empty project compiled for meowbit.
…but, i think you’re probably overoptimizing things here. if you want to make things smaller, then you would probably want to drop the dependency on the game extension, but seeing as how the games you’re loading probably will have that dependency anyways, it would just be added back in.
we do have a lighter version of the game package available, game--light, which you can add to your pxt.json dependencies like this:
it has some lighter versions of sprites that you can use instead of the Sprite class that compile to less code. but, again, as soon as someone else reference the regular Sprite class then it will be pulled back into the binary