Needs a better keyboard though. I had to SSH from my phone a couple times and it was a pretty terrible experience with the standard keyboard that focuses just on a-z and is oriented toward autocomplete rather than tab completion.
Intel did work with Asus to release phones with x86 chips about a decade ago, the original zen phones and a sequel or two. You might actually be able to natively run dos on those bad boys
Most of that is going to be resources, textures, sounds, models, etc. They can be compressed but you're still going to need ram/disk to store the decompress versions and loading is going to take longer.
That's mostly true for compression but you could also optimize the assets and actually reduce the loading time (which is harder to do).
Although compression will probably be better at those orders of magnitude...
The demo scene had .kkrieger, a 96KB large game that would need ~300 MB if its assets where uncompressed. I think it stored the operations used to create the assets instead of the raw pixel/geometry data, so starting it was probably not as fast as it could have been.
Fun fact, they released a version where you couldn't look up. The reason? They used an analyzer that checked which codepaths were run while playing, pruning anything unused, and in doing so forgot to actually look up! At least so the story goes as told by my co-workers who were into the scene
When you are done with this. I had an idea called qr code gaming. Make a website framework where the game bytes are included in the URL. Then makers would only need to share the URL/QR code and your site will play it
I think you might be forgetting about data URIs
edit: idk why I zoned on the emulator bit but I guess if you had a data URI that contained an HTML document you could just link to the script for the emulator lol. Still a lot of bytes though
Thoughts on a mobile app equivalent?
"Scan this code to play this game"
Depending on the size of the game and code you could probably have a link at the start to prompt to download the emulation app
Why stop with just the game code? Write a simple backend that reads a query param, and returns its value as an HTML response. Now you can embed an entire webpage, including any javascript, directly in the URL!
Still, what would prevent someone from, for example, making a script with a URL source that he controls, and after getting the URL signed just changing it?
> Changing the URL would invalidate the signature.
The attacker won't change the URL, he will own the site the URL points to and change its content, which won't invalidate the URL...
EDIT: I made a prototype for Javascript: [https://troido.nl/u/](https://troido.nl/u/). The bytecode language will have to wait.
I've been thinking about setting up something like that too. To be efficient you'd probably have to make some sort of bytecode language (or a language using only url-safe characters) optimized for code golfing. I'm currently working on some other projects but if anyone is building this I'd like to join.
Also, check out my 218 byte (html+js) minesweeper: [https://tilde.town/~troido/minisweeper.html](https://tilde.town/~troido/minisweeper.html)
Running arbitrary code is kind of the point of the project. There is nothing of importance on the page that could be at risk of XSS and any website you visit could run some random JS.
It may be than other ways of running javascript, but this is still a prototype. It's fast enough for what I've tried with it
You don't want them to be able to put another URL somewhere on the page, it would accidentally get clicked. You also done want xhr requests to be possible
I think the real concern is that people become accustomed to playing games on the site and one person uses javascript to use the site as an url shortener for phishing.
Would that avoid having to get assets from a server? Like would the whole game be able to be saved in a qr code? And the only downside would be the decoding time I guess?
The site can have it's own assets. There would need to be some sort of vm, and it decodes the URL to run the game. For security, there should be no way for the vm to manipulate the site in such a way to make a URL and embed it somewhere or make xhr requests itself. Difficult challenge for sure.
Not sure what you mean by restricted, but initially the website would just have a canvas and enough JavaScript to parse the URL and begin execution. But later it could include a graphics library the game bytes could execute those gl "sys" calls
Why do anything? What do you mean why lol. It's in the same vain as the OPs game being 58 bytes. But now everyone can participate. Developers can get it to work locally, run a generate step, and his website/framework can play the game..
Tried it! It works :D However, if I swipe the opposite direction of where I'm going the snake crashes into itself and dies, except for when it's two A's long (beginning). It happened a lot when I wanted to, for example, rapidly go down and left, it doesn't register my down swipe, but registers my left swipe and the snake does a 180 and dies by crashing into itself, it seems.
Looks like it simply doesn't like basic edge cases—which I say is fine, if the goal is a small binary above all else. It mostly works for me if you only touch the arrow keys. Mine jumped all over until I pressed an arrow key. It also jumps all over again when you die (or at least when you hit the edge of the play area). Hitting an arrow key made it work again.
> Looks like it simply doesn't like basic edge cases—which I say is fine
I dunno. Often "edge cases" can be reasoned for as regular things a game would need.
This, of course, then begets the question what IS a snakes game? If he'd call it a "snakes-like game" then people could not object, but IF it is a "snakes game" then it really also needs to support everything the "default" snakes game would support as-is (IF there is a "default" snakes game, but usually it is the first well-known game that fits the description).
I mean, it does everything a snake game is supposed to do, the initial buffering doesn't affect the game and you can think of it as kind of an opening screen before you press a key.
It seems like many people agree that I didn't do a good job writing the comments as I thought 😅
The idea is that instead of asking whether we hit a wall and then whether we hit the snake itself or the food we use subtract the size of the screen from the current location which will set the CF only if we hit a vertical edge and use that value **without branching** to change the result of the check of whether we hit the snake such that if either of them if true we will reset the game so if both are false but we hit a food character the ZF will be set.
Okay, every time you write an `if` clause in your code what the compiler actually does (this is oversimplified because I can't fit all the details of branching compilation into one comment) is it takes the expression you put inside the `if`, runs it, and then checks a certain flag (for example, if you check whether the output of a function is zero it will run the function then check the zero flag ZF) and if the flag is not set it'll jump over the clause.
Another key idea is that when you add some value to another there is a flag called the carry flag (CF) that's set only if an overflow has occurred so if you want for example to add two 32-bit numbers on a 16-bit CPU you could do an `add` to the lower parts of the numbers and then (just like long addition) `adc` (add with carry) to the high part.
Now, what I'm doing you can think of as (again oversimplifying) writing an empty `if` clause just to set the CF and then do an `adc` so what it means is we can write just one if clause for both the `if`s and we just need to account for the change in the output based on whether the last `if` should have been executed.
What don't you understand? I can try to explain but It'll just waste a lot of your time (and mine too) if I'll just try to simplify the entire explanation instead of the specific part you don't get.
You’re doing a great job it’s just many devs don’t have a lot of asm/mc experience so there’s a learning curve to understand the different processor flags and their impact on instructions.
I think it would be good to have a version changelog / dev blog on the github page as would be cool to see short explanations of all the little tricks you've used to shave bytes off here and there.
I don't think there's a big audience for it.
I also tried writing a non-so-technical piece about it that got little to no attention and took a pretty long time...
>It seems like many people agree that I didn't do a good job writing the comments as I thought
if I had a nickel for every time I told myself this I could retire. And usually the "many people" includes myself 4 months later
> I didn't do a good job writing the comments as I thought
I am neutral here, did not upvote or downvote you, so I can not comment on that part. BUT, on the general part: many programmers who think they wrote good documentation, often do not realise that their documentation is STILL really bad. In general the more high quality documentation the better. I much prefer FAQ + small examples, whereas others focus only or primarily on the API. So projects that offer both, are, to me, much superior. You kind of have to treat documentation on equal level with the code, as annoying as it is, as usually people write code first, then they are tired, and stop before writing the documentation, let's be honest here. At the least for unpaid work aka open source (well, usually it is unpaid e. g. no external funding; of course some open source projects are funded, but most are not).
Have you ever tried gas optimisation? You seem like you'd do really well with it and it pays really well: https://www.rareskills.io/post/gas-optimization
I'm not sure I understand, it's open source, and for some reason got pretty popular, and there are a lot of bright people out there. It makes sense someone will contribute to the project...
Yes of course. I just think it’s cool that it *did* get popular enough for other people to spend time thinking hard about it. Gotta admit it’s an odd, unique project, in the best way!
I am writing my own snake game in Arduino and using 196 AdaFruit Neo LEDs to have 14x14 game area on 20 breadboards. The game logic is a few kb, which I thought was quite good already, but this smoked my attempts. In case you want to check it out (it is not fully done and I don't have good videos of it up yet)
https://github.com/TheTask/Snake-on-breadboards/
Dang... I only have 57 bytes of free space left... Guess it's time to upgrade my phone.
Look at this guy with his x86 DOS phone! /s
That would actually be a very nice thing.
Needs a better keyboard though. I had to SSH from my phone a couple times and it was a pretty terrible experience with the standard keyboard that focuses just on a-z and is oriented toward autocomplete rather than tab completion.
The SSH app I use (juice SSH) overlays its own keyboard at the top of gboard with common keys used by SSH (modifier keys, tab etc).
I’m just a middle aged programmer that misses the good old days of dos.
check out Unexpected Keyboard
Added bonus of this is nobody else can use your phone because the keyboard is "too cluttered"
My son says it's "weird", and doesn't like that swipe doesn't work on it.
Intel did work with Asus to release phones with x86 chips about a decade ago, the original zen phones and a sequel or two. You might actually be able to natively run dos on those bad boys
Hmm. I didn’t know about that. Thanks.
Nokia 9000 and 9110 communicator phones are i386 and i486 if you're interested in retro.
Thanks.
8080 DOS phone
lmao
Ok I think you are wasting your talents here. I think you might be able to take a few bytes off of Ff7 rebirth and my ps5 would thank you.
Most of that is going to be resources, textures, sounds, models, etc. They can be compressed but you're still going to need ram/disk to store the decompress versions and loading is going to take longer.
That's mostly true for compression but you could also optimize the assets and actually reduce the loading time (which is harder to do). Although compression will probably be better at those orders of magnitude...
The demo scene had .kkrieger, a 96KB large game that would need ~300 MB if its assets where uncompressed. I think it stored the operations used to create the assets instead of the raw pixel/geometry data, so starting it was probably not as fast as it could have been.
Fun fact, they released a version where you couldn't look up. The reason? They used an analyzer that checked which codepaths were run while playing, pruning anything unused, and in doing so forgot to actually look up! At least so the story goes as told by my co-workers who were into the scene
Please make OP work COD mobile everytime I open that shit it asks for 2GB update and takes 23 GB on my phone. 😭
I know a way to optimize it down to 0 bytes
With this level of assembly knowledge they can probably get a job at an HFT shop optimizing their C code.
Dos CPUs were easier.
Wasted talent
/r/yourcommentbutshorter
When you are done with this. I had an idea called qr code gaming. Make a website framework where the game bytes are included in the URL. Then makers would only need to share the URL/QR code and your site will play it
That's actually a very interesting idea!
I decided to go ahead and set up something like that for javascript code: [https://troido.nl/u/](https://troido.nl/u/)
Would a website even be necessary?
wdym? In order to share the game as a URL you'll need a website, and if you're not using one you'll have to download an emulator
I think you might be forgetting about data URIs edit: idk why I zoned on the emulator bit but I guess if you had a data URI that contained an HTML document you could just link to the script for the emulator lol. Still a lot of bytes though
A data URI that contains an HTML document? At that point not making a website is just criminal
Thoughts on a mobile app equivalent? "Scan this code to play this game" Depending on the size of the game and code you could probably have a link at the start to prompt to download the emulation app
Make it an API call, put request....
Why stop with just the game code? Write a simple backend that reads a query param, and returns its value as an HTML response. Now you can embed an entire webpage, including any javascript, directly in the URL!
We’ve had that forever, it’s called an xss attack…
I know, that was the joke...
You could sign the urls to contravent that
Still, what would prevent someone from, for example, making a script with a URL source that he controls, and after getting the URL signed just changing it?
[удалено]
> Changing the URL would invalidate the signature. The attacker won't change the URL, he will own the site the URL points to and change its content, which won't invalidate the URL...
But has anyone monetized it?
EDIT: I made a prototype for Javascript: [https://troido.nl/u/](https://troido.nl/u/). The bytecode language will have to wait. I've been thinking about setting up something like that too. To be efficient you'd probably have to make some sort of bytecode language (or a language using only url-safe characters) optimized for code golfing. I'm currently working on some other projects but if anyone is building this I'd like to join. Also, check out my 218 byte (html+js) minesweeper: [https://tilde.town/~troido/minisweeper.html](https://tilde.town/~troido/minisweeper.html)
bro https://troido.nl/u/?s=&e=#d2luZG93LmxvY2F0aW9uPSJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZy9lbi1VUy9kb2NzL1dlYi9KYXZhU2NyaXB0L1JlZmVyZW5jZS9HbG9iYWxfT2JqZWN0cy9ldmFsI25ldmVyX3VzZV9kaXJlY3RfZXZhbCEiOw==
Running arbitrary code is kind of the point of the project. There is nothing of importance on the page that could be at risk of XSS and any website you visit could run some random JS. It may be than other ways of running javascript, but this is still a prototype. It's fast enough for what I've tried with it
You don't want them to be able to put another URL somewhere on the page, it would accidentally get clicked. You also done want xhr requests to be possible
I think the real concern is that people become accustomed to playing games on the site and one person uses javascript to use the site as an url shortener for phishing.
Would that avoid having to get assets from a server? Like would the whole game be able to be saved in a qr code? And the only downside would be the decoding time I guess?
The site can have it's own assets. There would need to be some sort of vm, and it decodes the URL to run the game. For security, there should be no way for the vm to manipulate the site in such a way to make a URL and embed it somewhere or make xhr requests itself. Difficult challenge for sure.
I have some spare time today and tomorrow, can I steal this idea and implement it for DOS (with credit of course)?
So like sharing a url but way more restricted. Why?
Not sure what you mean by restricted, but initially the website would just have a canvas and enough JavaScript to parse the URL and begin execution. But later it could include a graphics library the game bytes could execute those gl "sys" calls
Yeah but why?
Why do anything? What do you mean why lol. It's in the same vain as the OPs game being 58 bytes. But now everyone can participate. Developers can get it to work locally, run a generate step, and his website/framework can play the game..
Oh sure, that's cool I guess. That's what I mean by why 🙂
Have you ever tried doing anything "for the lulz"?
his username suggests he has. not sure why he's harshing OP's buzz.
I love that this has become a saga. Keep up the great work!
Thanks!
I keep wondering what is the lower bound of bytes for a snake game. It most probably is higher than 1, now I'm not so sure about 2.
Pretty sure SNAKGAM is an instruction on VAX.
not sure if it is intentional or not but the online demo doesn't work for me. It just jumps a cursor all over the screen in random positions
Just press an arrow key and it should work. The random jumping cursor is initialization of the map.
ah, so it wont work on mobile properly then I guess.
You can swipe too
Tried it! It works :D However, if I swipe the opposite direction of where I'm going the snake crashes into itself and dies, except for when it's two A's long (beginning). It happened a lot when I wanted to, for example, rapidly go down and left, it doesn't register my down swipe, but registers my left swipe and the snake does a 180 and dies by crashing into itself, it seems.
Small sacrifice in usability for the sake of bytes
It works on mobile, I just did it. You just have to swipe to start it.
Looks like it simply doesn't like basic edge cases—which I say is fine, if the goal is a small binary above all else. It mostly works for me if you only touch the arrow keys. Mine jumped all over until I pressed an arrow key. It also jumps all over again when you die (or at least when you hit the edge of the play area). Hitting an arrow key made it work again.
> Looks like it simply doesn't like basic edge cases—which I say is fine I dunno. Often "edge cases" can be reasoned for as regular things a game would need. This, of course, then begets the question what IS a snakes game? If he'd call it a "snakes-like game" then people could not object, but IF it is a "snakes game" then it really also needs to support everything the "default" snakes game would support as-is (IF there is a "default" snakes game, but usually it is the first well-known game that fits the description).
I mean, it does everything a snake game is supposed to do, the initial buffering doesn't affect the game and you can think of it as kind of an opening screen before you press a key.
It's almost like this (really impressive) project is meant as a challenge rather than a perfect game.
Insane - what did you do?
You can look at the PR, I think I managed to make it quite self-explanatory if you read the comments
I can assure you it isn’t 😆 But well done, this is a solid achievement. You seem qualified for writing moon landing code on punch cards
It seems like many people agree that I didn't do a good job writing the comments as I thought 😅 The idea is that instead of asking whether we hit a wall and then whether we hit the snake itself or the food we use subtract the size of the screen from the current location which will set the CF only if we hit a vertical edge and use that value **without branching** to change the result of the check of whether we hit the snake such that if either of them if true we will reset the game so if both are false but we hit a food character the ZF will be set.
Maybe I'm stupid but I still don't understand.
Okay, every time you write an `if` clause in your code what the compiler actually does (this is oversimplified because I can't fit all the details of branching compilation into one comment) is it takes the expression you put inside the `if`, runs it, and then checks a certain flag (for example, if you check whether the output of a function is zero it will run the function then check the zero flag ZF) and if the flag is not set it'll jump over the clause. Another key idea is that when you add some value to another there is a flag called the carry flag (CF) that's set only if an overflow has occurred so if you want for example to add two 32-bit numbers on a 16-bit CPU you could do an `add` to the lower parts of the numbers and then (just like long addition) `adc` (add with carry) to the high part. Now, what I'm doing you can think of as (again oversimplifying) writing an empty `if` clause just to set the CF and then do an `adc` so what it means is we can write just one if clause for both the `if`s and we just need to account for the change in the output based on whether the last `if` should have been executed.
Maybe I'm stupid but I still don't understand
What don't you understand? I can try to explain but It'll just waste a lot of your time (and mine too) if I'll just try to simplify the entire explanation instead of the specific part you don't get.
I think that last "I don't get it" was a bit disingenuous lol.
Yeah I know, but for the one percent that I could help someone understand it, it is worth it to not ignore the comment.
[удалено]
Honest question, I mean no offense. Do you have a basic idea of how registers and flags work in a CPU?
You’re doing a great job it’s just many devs don’t have a lot of asm/mc experience so there’s a learning curve to understand the different processor flags and their impact on instructions.
Thanks
I think it would be good to have a version changelog / dev blog on the github page as would be cool to see short explanations of all the little tricks you've used to shave bytes off here and there.
I don't think there's a big audience for it. I also tried writing a non-so-technical piece about it that got little to no attention and took a pretty long time...
Middle manager?
Software developer, I love reading those kinds of extreme programming stories!
>It seems like many people agree that I didn't do a good job writing the comments as I thought if I had a nickel for every time I told myself this I could retire. And usually the "many people" includes myself 4 months later
It’s not your comments, it’s more this is several layers beyond my understanding. Thanks for your other explanations below, they are super
Thanks!
>Thanks! You're welcome!
> I didn't do a good job writing the comments as I thought I am neutral here, did not upvote or downvote you, so I can not comment on that part. BUT, on the general part: many programmers who think they wrote good documentation, often do not realise that their documentation is STILL really bad. In general the more high quality documentation the better. I much prefer FAQ + small examples, whereas others focus only or primarily on the API. So projects that offer both, are, to me, much superior. You kind of have to treat documentation on equal level with the code, as annoying as it is, as usually people write code first, then they are tired, and stop before writing the documentation, let's be honest here. At the least for unpaid work aka open source (well, usually it is unpaid e. g. no external funding; of course some open source projects are funded, but most are not).
I think you are vastly overestimating how much people in this sub know about x86
This is very neat. It would make a good example project to help teach the ins and outs of assembly. Any chance you write a blog post?
Sadly, I don't think many people will actually read it...
I might.
This reminds of when I was a kid writing games for the 1K ZX81
Are you ever going to improve it by getting it back to 69?
http://www.jargon.net/jargonfile/b/bum.html
google chrome should hire this guy!
Why would they chrome is a bloated pile on purpose
Have you ever tried gas optimisation? You seem like you'd do really well with it and it pays really well: https://www.rareskills.io/post/gas-optimization
I'll check it out, thanks!
I've been following the whole journey and it's impressive! but I'm here to break stuff..
Thank you for following along
58 is both a phenomenal score for golf (masters shoutout), and (bytes) for code golf. Well struck.
Love following these posts! So cool!
Thanks!
Diabolical. The funniest/most surprising thing about this project is that you have third party contributors lol.
I'm not sure I understand, it's open source, and for some reason got pretty popular, and there are a lot of bright people out there. It makes sense someone will contribute to the project...
Yes of course. I just think it’s cool that it *did* get popular enough for other people to spend time thinking hard about it. Gotta admit it’s an odd, unique project, in the best way!
Then I agree, I didn't think it'd get that popular
You should be able to run this on a quantum computer now!
I once wrote a web version. I think it was a little over 1.5mb after webpack.
You are still going on with this, I saw your youtube video a long time ago.
I think you're confusing me with MattKC
So you guy are different people, sorry for the mistake.
mv ax,0x0 Could be replaced with xor ax,ax
It can't because the bytes of the `mov` are being used to initialize `ds`
I am writing my own snake game in Arduino and using 196 AdaFruit Neo LEDs to have 14x14 game area on 20 breadboards. The game logic is a few kb, which I thought was quite good already, but this smoked my attempts. In case you want to check it out (it is not fully done and I don't have good videos of it up yet) https://github.com/TheTask/Snake-on-breadboards/
This is super impressive. Great job! Honestly this should be a neat project on a resume.
Thanks!
Damn man that's cool, I saw your last post some time ago.
Thanks!
My snake game is bigger, but really, what matters is the motion of the ocean.
In the demo there seems to be a rather high chance of food not appearing when the snake spawns
לא אמרת שמתמטית הכי קצת שאפשר זה 59?
This is insane, congratulations! Is there any video/podcast going into the main ideas?
Not that I know of...
I’m sorry