6 ms·
SnakeOS: Bootable x86 snake game in Rust
- fspacef 5y agoI love rust and it’s fascinating to see what people can do with it. Exciting game and great find.
- dmitrygr 5y ago> 212kB Rust'll be ready for embedded when it is 512 bytes: https://gitlab.com/pmikkelsen/asm_snake https://gitlab.com/pmikkelsen/asm_snake
- alfiedotwtf 5y agoArduino UNO has 32kb of RAM, which Rust can target... so maybe good enough for some people
- Measter 5y agoThe Atmega 328P that the Uno uses has 2kb of RAM, and 32kb of ROM (technically, writable on boot, but not after you leave the bootloader).
- gchamonlive 5y agoI could be dead wrong, but isn't x86 not an architecture suited for embedded systems?
- dmitrygr 5y agoMost embedded systems running most factories would disagree with you. Embedded x86 is pretty big
- detaro 5y agobut just to be clear, nobody cares about kilobytes there.
- usr1106 5y agoEmbedded is not a clearly defined concept when it comes to size. When I worked with embedded Linux with a Gigabyte or two of RAM, we used to make the difference to the microcontroller world by calling them embedded embedded.
- detaro 5y agoEmbedded systems are a very large range, depending on what kind of performance needs to be embedded. From tiny microcontrollers on one end to what's equivalent to high-end workstations with custom hardware interfaces on the other (and probably talking to smaller controllers). x86 hasn't been successful in the microcontroller half of things (even though fast microcontrollers beat some x86 options, so it's not a size thing, but there hasn't been a compelling offering), but on the microprocessor side of things it has its uses, primarily but not exclusively towards the high-end nowadays (due to competition by ARM). To add another line to differentiate, x86 without an OS is going to be quite rare nowadays.
- wyldfire 5y agoDoesn't seem fair to hold a code size contest and not measure the code executed in BIOS calls. Anyone can get ever-smaller code sizes if you just move the code to somewhere outside the region gauged by the test.
- userbinator 5y agoFor comparison, 212k is roughly the size of DOS 2.x.
- hulitu 5y agoThe world has evolved. Everybody knows that Rust is better than C or ASM. So a little increase in binary size is good for security.
- jneumann004 5y agoCouldn't the binary be made smaller with additional compiler options? From what I read in the repository, they weren't going for the smallest size.
- detaro 5y agoEmbedded is not just small microcontrollers (re 512 byte being a target), and this is likely not a size-optimized build.
- MStrehovsky 5y ago> 212kB Here's a 11 kB bootable x86-64 version of the game written in C# https://github.com/kant2002/SeeSharpSnake/tree/kant/uefi#run-on-uefi https://github.com/kant2002/SeeSharpSnake/tree/kant/uefi#run.... There's an accompanying article with a video at the bottom https://codevision.medium.com/running-c-snake-inside-uefi-df193b6213e2 https://codevision.medium.com/running-c-snake-inside-uefi-df....
- elromulous 5y agoSo I admittedly only skimmed that link very briefly. But... how? I would think the c# runtime alone would balloon this to some astronomical size. Edit: Got my answer. /p:Mode=CoreRT-NoRuntime, /nostdlib, and a bunch of others.
- option_greek 5y agoSo how does it work. Where do the standard library functions come from? Where do all the garbage collecting functionality gets loaded from?. Or is it more like pinvoking a reduced external library in C for all needed functionality.
- hahamrfunnyguy 5y agoHe used a few different techniques. 1. Used CoreRT instead of the standard .NET libraries 2. He avoided using functionality that would use GC in the first place 3. Created his own alternative runtime library w/out GC and exception handling 4. Created a base type library for some of the System functions 5. Re-directed certain functions like Thread.Sleep to smaller implementations in specific libraries. The blog posting is well worth reading: https://medium.com/@MStrehovsky/building-a-self-contained-game-in-c-under-8-kilobytes-74c3cf60ea04 https://medium.com/@MStrehovsky/building-a-self-contained-ga...
- pjmlp 5y agoThis is also a very good example that not all languages with GC are created equal, some do provide the mechanisms to do alternative ways of managing resources.
- Tehdasi 5y agoObligatory comment about how an operating system is "system software that manages computer hardware, software resources, and provides common services for computer programs" and not just a program that executes at startup.
- pedrogpimenta 5y agoObligatory comment about how you must be great at parties.
- trusch 5y agoObligatory comment about that this software abstracts away display, memory and interrupt management and provides services for the snake module. Also I like the name snakeos, since it doesn't promise more than it can deliver
- vuldin 5y agoI didn't take this comment as derogatory. Instead I see it as a good comment explaining that this example is much more than just "a program that executes at startup"... as it seems some people may have initially thought when glancing at only the start of the github readme page.
- pjmlp 5y ago"An operating system is a collection of things that don't fit into a language. There shouldn't be one." – Dan Ingalls, in an article in Byte Magazine, 1981
- netgusto 5y agoNice :) I love seeing Rust used for games. Also; similar project, but in ASM: https://github.com/gabi-250/slug https://github.com/gabi-250/slug
- usr1106 5y agoBootable? Does that mean BIOS legacy? Modern PCs can only boot UEFI binaries. (Just wondering. Of course nobody would seriosly want to use a modern PC to run that game.)
- OJFord 5y agoDo they not still have both modes? I haven't bought a motherboard for a couple of years, but the last few that I have have been both. (And basically I've not known or cared which I used!) Seems an unfortunate backwards compatibility loss if so.
- usr1106 5y agoI don't know the details. But legacy boot mode support was supposed to be phased out between 2019 and 2021. Couldn't quickly find a good reference, here is at least some: https://www.dell.com/support/kbdoc/fi-fi/000151899/no-boot-device-found-when-you-change-the-boot-sequence-to-legacy-mode?lang=en https://www.dell.com/support/kbdoc/fi-fi/000151899/no-boot-d... Edit: UEFI class 3 is the keyword https://en.m.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface https://en.m.wikipedia.org/wiki/Unified_Extensible_Firmware_...
- fuzzfactor 5y agoClass 3 is the progressively lower class which is designed to get users to accept lesser functionality as more "modern" so therefore it must be "better" or something.
- amelius 5y ago> Of course nobody would seriosly want to use a modern PC to run that game. It's a technology demonstrator. And people run all sorts of tools from USB drives. For example, I recently ran a memory tester from USB.
- usr1106 5y agoIs there any memory tester that runs from UEFI?