9 ms·
No, no, no. 1. Super Mario Bros. is 40KB (PRG ROM is 32KB, and CHR ROM is 8KB). That said, I suppose if you were to compress the ROM, you probably would end up
by GlitchMr 7y ago
No, no, no.
1. Super Mario Bros. is 40KB (PRG ROM is 32KB, and CHR ROM is 8KB). That said, I suppose if you were to compress the ROM, you probably would end up with value like 31KB.
2. Levels don't use RLE or LZ77, that would use too much space. Rather, the game uses commands like "from now on, use this ground fill pattern", "draw pipe here", "put a staircase", "put a goal". Super Mario Bros. uses two bytes per object, representing the following information: XXXXYYYY PSSSVVVV, where X is horizontal position within the page, Y is vertical position within the page, P moves to the next page, S is a command, and V is its parameter (length or number of an extended object). Y positions bigger than 0b1011 are used for special commands (as such parameters would be rendered out of bounds).
3. Graphics aren't compressed as they are stored in CHR ROM, and are directly accessed by the PPU (PPU cannot access RAM). However, as the graphics are 2bpp, they don't use as much space. Palettes are used to not restrict the entire game to 2bpp - note that 16x16 blocks have different color palettes. Some tricks are used to reduce the number of necessary tiles - for instance, clouds are the same thing as bushes, just with a different palette applied.
4. Demoscene is misleading. The way demoscene works is that most things are using procedural generation, meanwhile the levels in Super Mario Bros. are actually designed, and graphics were drawn by an artist, they aren't using some arbitrarily picked mathematical function chosen because it looked cool. The game has to be playable after all.
- coldpie 7y agoIndeed, nothing in this article has anything to do with how the NES worked. If you want a real introduction to the hardware, "I Am Error" by Nathan Altice is a great book about how the NES worked. It includes a chapter about how SMB1 in particular stored its level layouts.
- eutropia 7y agoI once did a project scripting AI for Mario on SMB1 on an emulator, and I watched the game's memory pages as I did so I could learn more. To my surprise, I saw the pages of arrays of hex bytes in the memory mirroring what I saw on the level, the layout was very literally transferred directly. When Mario moved, the current screen and the next one were clearly visible scrolling by in memory, which different hex bytes representing different tile types.
- conception 7y agoYou get used to it, though. Your brain does the translating. I don't even see the code. All I see is blonde, brunette, redhead.
- neurostimulant 7y agoThey used that tiling system all the way up to NDS IIRC. I remember tinkering with gameboy advance homebrew programming back then trying to implement infinite scrolling and it works just like you described.
- mschaef 7y agoThanks for the reference. Hadn't heard of this book and just now ordered it.
- cableshaft 7y ago"I Am Error" is not the best name for that book. I wouldn't have thought it was an in-depth technical book for the NES based on that name.
- ASalazarMX 7y agoThe whole "Platform Studies" series is a guarantee of in-dept technical work. While all have deep knowledge, "Racing the beam" (Atari 2600) is amazing in its simplicity, while "The future was here" (Amiga) is borderline snobbish. YMMV.
- dragontamer 7y ago> Rather, the game uses commands like "from now on, use this ground fill pattern" That's RLE, isn't it? https://en.wikipedia.org/wiki/Run-length_encoding https://en.wikipedia.org/wiki/Run-length_encoding Or are you saying that they didn't even include the "count" for the ground fill? ---------- I'm confused about the thesis of the article. It seems like the article's purpose isn't to describe NES graphics, but instead to talk about PNG vs JPG files? The article starts as "Great question Dion!", but it never actually says what the original question was. (Or if the question was "Where do all the pixels come from", then that's an inadequate question and doesn't seem to serve as a thesis for the article) EDIT 2: It seems like the HN title "Super Mario Bros. game was just 31 Kilobytes. How's that possible?" is misrepresentative.
- greggman2 7y agoIIRC Mario 1 works by drawing "sprites" of tiles. The level data says "pipe at 73,30" where pipe is a 2x3 array of the tile ids that make a pipe or "cloud at 34,3" where cloud is a 3x2 array of tile ids. I don't know what percentage of NES games used a technique like that. AFAIK the majority of NES games with scrolling levels used a simple 2D tile map but Mario 1 does not. I shipped a NES game, ours had an MMC3 chip which if I recall gave us +8k ram for a total of 10k. We decompressed the current level's tile map into a portion of that. https://en.wikipedia.org/wiki/Memory_management_controller https://en.wikipedia.org/wiki/Memory_management_controller
- coldpie 7y ago> I shipped a NES game One of my favorite games of all time. You signed a copy of it via mail for me around 2006/2007 ;) Cheers. > We decompressed the current level's tile map into a portion of that. I reverse engineered it to dump PNG format maps of both it and the leaked prototype. Pretty straightforward RLE but it was fun learning about 6502, NES programming, and bank switching. Level dumper source: https://gitlab.com/mcmapper/mcmapper/blob/master/main.c https://gitlab.com/mcmapper/mcmapper/blob/master/main.c Generated images: https://tcrf.net/Proto:M.C._Kids https://tcrf.net/Proto:M.C._Kids Very different from how SMB1's level construction works. Like the OP comment said, it basically has a modal command structure. Something like "start drawing the ground two tiles up from the bottom. At x=18, draw a pipe." etc. This is why the level scrolls infinitely after the flagpole, it's just running the default "draw ground" command forever. M.C. Kids on the other hand actually stored the whole level tile grid, using RLE for compression.
- brudgers 7y agothe game uses commands like "from now on, use this ground fill pattern" Code is often a good form of data compression.
- MrFoof 7y agoVery much agree with the parent. If you want a better idea on how you can cram everything into 40KB — using every trick in the book, including ones not considered 30+ years ago — take a look at a how a recently released NES game (Micro Mages) managed it. Their primary design constrain was that they restricted themselves to 40KB, despite wanting to do far more than the games that were done in 40KB back in the 80s. https://youtu.be/ZWQ0591PAxM https://youtu.be/ZWQ0591PAxM
- jpm_sd 7y agoThis video is so well done! @dang this would make a much better top link than the nonsensical article posted originally
- johnfactorial 7y agoThe first sentence of this post strikes me as needlessly combative and the post would be better without it.