WIP: Attempts to minimize bytes, some token golf as well#1
Open
sparr wants to merge 1 commit intoFeneric:masterfrom
Open
WIP: Attempts to minimize bytes, some token golf as well#1sparr wants to merge 1 commit intoFeneric:masterfrom
sparr wants to merge 1 commit intoFeneric:masterfrom
Conversation
sparr
commented
Feb 17, 2020
| end | ||
|
|
||
| function not_over_32767(num) | ||
| return min(num,32767) |
sparr
commented
Feb 17, 2020
Comment on lines
1168
to
1172
| function delay(numofcycles) | ||
| for delaycount=0,numofcycles do | ||
| for delaycount=1,numofcycles do | ||
| flip() | ||
| end | ||
| end |
Author
There was a problem hiding this comment.
Was it intentional that the previous code would wait two frames for numofcycles==1, three frames for 2, etc?
sparr
commented
Feb 17, 2020
Comment on lines
+1190
to
+1215
| function print_r(str, x, ...) | ||
| print(str, x - 4 * #tostr(str), ...) | ||
| end | ||
|
|
||
| function draw_stats() | ||
| local linestart,midlinestart,longlinestart=106,110,119 | ||
| local linestart,lineend=106,127 | ||
| print("cond",linestart,0,5) | ||
| print(band(hero.st,1)==1 and 'p' or 'g',125,0,6) | ||
| print_r(band(hero.st,1)==1 and 'p' or 'g',lineend,0,6) | ||
| print("lvl",linestart,8,5) | ||
| print(hero.lvl,longlinestart,8,6) | ||
| print_r(hero. lvl,lineend,8,6) | ||
| print("hp",linestart,16,5) | ||
| print(hero.hp,linestart+8,16,6) | ||
| print_r(hero.hp,lineend,16,6) | ||
| print("ap",linestart,24,5) | ||
| print(hero.mp,linestart+8,24,6) | ||
| print_r(hero.mp,lineend,24,6) | ||
| print("$",linestart,32,5) | ||
| print(hero.gp,midlinestart,32,6) | ||
| print_r(hero.gp,lineend,32,6) | ||
| print("f",linestart,40,5) | ||
| print(hero.fd,midlinestart,40,6) | ||
| print_r(hero.fd,lineend,40,6) | ||
| print("exp",linestart,48,5) | ||
| print(hero.exp,linestart,55,6) | ||
| print_r(hero.exp,lineend,55,6) | ||
| print("dex",linestart,63,5) | ||
| print(hero.dex,longlinestart,63,6) | ||
| print_r(hero.dex,lineend,63,6) | ||
| print("int",linestart,71,5) | ||
| print(hero.int,longlinestart,71,6) | ||
| print_r(hero.int,lineend,71,6) | ||
| print("str",linestart,79,5) | ||
| print(hero.str,longlinestart,79,6) | ||
| print_r(hero.str,lineend,79,6) |
Author
There was a problem hiding this comment.
This is a functional change, both aesthetic and code-simplifying. I can easily undo the right aligning and approach the code reduction here another way.
sparr
commented
Feb 17, 2020
| print_r(hero.str,lineend,79,6) | ||
| for linenum=1,numoflines do | ||
| print(lines[(curline-linenum)%numoflines+1],0,128-linenum*8) | ||
| print(lines[(curline-linenum)%numoflines+1],0,129-linenum*8) |
Author
There was a problem hiding this comment.
This is purely an aesthetic change, moving the always-blank row from the bottom of the screen to the top of the lines output, so there will be a gap between the map and the lines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a work in progress. I have not been able to fully test all of the changes yet, as I haven't re-explored the whole story. I will do so, but wanted to submit this for feedback beforehand.
before (minified): 6475 tokens, 32610 chars, 99.38% compressed
after (minified): 6350 tokens, 30032 chars, 97% compressed
The biggest savings came from altering the "JSON" syntax to not require quotes around most strings. This makes them harder to edit in other json-aware programs, but still pretty much entirely human readable and hand-editable.
Other savings came from inlining functions and typical token golf optimizations. I suspect there's another 50 tokens, 500 chars, and 1% compressed size to be saved through further more complicated efforts of this sort. I'd be happy to attempt more in that direction if you're interested.
I will comment a few places in the PR that stand out as notable and possibly objectionable, some of which are aesthetic in nature.
If these changes are welcome here, I would also be happy to port the relevant ones over to Minima.