5 ms·
I think I’m pretty good at writing software, and then I see stuff like this, and the impostor syndrome kicks in hard. A fully working chess game in 4K of ROM, u
by kstrauser 3y ago
I think I’m pretty good at writing software, and then I see stuff like this, and the impostor syndrome kicks in hard. A fully working chess game in 4K of ROM, using each of the 128 bytes of RAM for several purposes? That’s some genius.
Bravo to OP for the disassembly and explanation, too!
- jgrahamc 3y agoIf you only had 4K of ROM and 128 bytes of RAM you’d find a way. That’s what we all did back then. This isn’t to diminish Atari’s achievement (this stuff was super hard and also super satisfying), it’s just to say that doing these kinds of tricks was what you did when you wanted to create something state of the art with few resources. Here’s a silly example: https://blog.jgc.org/2022/11/primality-testing-on-commodore-p50.html https://blog.jgc.org/2022/11/primality-testing-on-commodore-...
- falcor84 3y ago> That's what we all did back then. I think you might be "suffering" from the Dunning-Kruger Effect. Even if I accept that "all" the coders at that time were able to do this, that would just mean that the pool of people who were capable coders then is vastly more skilled than the typical coder these days.
- jgrahamc 3y agoAnyone who wanted to push the limits of hardware at that time had to do tricks like this. There just wasn't any other choice. Sure, there were plenty of programmers back then who weren't capable. But it's not magic, it's careful thinking and hard work.
- ddingus 3y agoWell, for some perspective tricks of the kind being discussed here were frequently published in magazines found in the local grocery store! Getting an extra sprite on a horizontal line, or putting more colors on the screen, various math tricks, how to pack multiple flags into a byte, and many other discussions were common. When others say, "we had to", they are in part, communicating how thinking was done. The lower level details were often published down to the bits in registers and doing even simple things took one into tricks land more often than we may realize today. Now that said, the VCS (2600) is a difficult machine. But, it was not above an average programmer to be successful as much as it did demand one go through the careful steps and thinking as told today. In fact, just doing what the machine was designed for; namely, "Combat" required that thinking. I think you may be getting hung up on scope and scale. What I mean is the field was not as broad in some ways, and most everyone was a lot closer to the hardware than we mostly are today too. Kids were jumping onto micros and literally figuring it out with the info they could glean from one another, manuals shipped with the machines (maybe), magazines and the like were the basic communications happening daily. I was one of those kids and in my peer group it was expected to understand the hardware well enough to follow code. So yeah, overall it was just different in ways that may well prove confusing today, depending on what any of us may have chosen as our start point.
- kstrauser 3y agoThat's perpetually true. "You're trying to do machine learning on a desktop PC?" "Hmmm, I wonder if we could use the GPU as a math engine?" But holy cow, that chess game really pushed the limits! (A side note I like to bring up occasionally: my first "computer" was "Atari BASIC" on my 2600. It had 63 bytes of RAM, I think. That didn't last long until my parents brought home a TS1000 with a luxurious 1KB of RAM.)
- jgrahamc 3y agoYes. I was thinking about that after my comment. All the folks doing machine learning optimizations, weird stuff with AVX2, etc. are the same folks who would have been stuffing chess in 4K of ROM and 128 bytes of RAM. In 1985, me and another boy from school wrote a whole reliable network transport and stuffed it into unused memory on a Research Machines 480Z. We had 128 bytes for the receive buffer so in order to do anything we'd literally ship a packet across the network containing machine code and the stub code would CALL the receive buffer to perform tasks. Executable packets!
- kstrauser 3y agoI could listen to stories like this all day long.
- jgrahamc 3y agoEnjoy: https://blog.jgc.org/2013/05/from-ground-up.html https://blog.jgc.org/2013/05/from-ground-up.html
- kstrauser 3y agoHow could you do this to me on a work day?
- kirubakaran 3y agoCall in sick. I faked a stomach ache when my parents got me Apple //c
- kgwxd 3y agoI've worked through all the 2600 programming books, including the authors. I've yet to start on anything of my own worth while. At one point I thought maybe I could start reverse engineering some games for some inspiration. Didn't get more than a few hours into it before I decided I'd just rather watch other people do great things with the 2600.
- toast0 3y agoI've considered doing something in this vein, and my thought is don't try to learn two things at once. Game design and game implementation are two different things; better to clone a game for your first several implementations, IMHO. OTOH, I'm not motivated enough to do that, either. :D
- ddingus 3y agoYou may want to give Batari Basic a look. In the early 00's one enthusiast had the idea to make a simple BASIC compiler for the 2600. I was one of the early testers and the first thing I did was make a functional "BREAKOUT", bounce the ball off the bat to eliminate bricks in a wall game. It took a couple hours and was, I think, the first (and buggy) playable program authored by someone other than the language author. And it was fun! What the author did was kind of brilliant in that he packaged up several of the common tricks used to make games and presented them along with a simple BASIC. Variables, for example, were just bytes and or individual bits, essentially addressing bits in a byte like an array. J = %01101101 If J[2] = 0 then X = X +1 Here is a sample program to move a sprite around on the screen: x=50 y=50 main2 COLUP0=28 COLUBK=02 player0: %00011100 %00011000 %00011000 %00100000 %01011010 %01111100 %00100100 %00010000 %00011000 %00111100 %00011000 end player0x=x player0y=y drawscreen if joy0right then x=x+1 if joy0left then x=x-1 if joy0up then y=y-1 if joy0down then y=y+1 goto main2 On the VCS, a game is a loop that renders the display and in-between display frames, during VBLANK, one computes the next game state to be displayed, and it all runs at 50 or 60Hz, locked to the display refresh rate. The BASIC exposes the little bit of hardware to a programmer in a simple way that I found to be a lot of fun because the really hard parts of assembly language are not necessary, but can be written in-line just as easily as defining a sprite is: asm LDA J ASL ASL . . . end Any hoo, it was fun and surprisingly productive. I found I could knock out simple concepts in an hour or two.
- chinaman425 3y ago[dead]
- Traubenfuchs 3y ago99% of people "writing software" could not write anything worth calling a chess engine by themselves.
- giantrobot 3y agoKeep in mind is these kind of things have a flat memory space between RAM and ROM. It's not like today where disk is some thing way over there that you need to buffer in RAM. All of your code and resources are in ROM which means they're just an address away. Your RAM is scratch space for dynamic values but you can pull everything else from ROM. For instance your bitmaps for pieces/spaces are stored in ROM, the code called when a scanline is drawn goes and accessed the values in ROM (it's just a memory address) without needing it to ever living in RAM. The only part that needs to live in RAM is the board state that the drawing code uses to find the bitmaps to draw. There's no need to draw to an off-screen buffer in RAM that then needs to be drawn to the screen. None of that is to say 128 bytes of RAM is somehow easy but the code and data in ROM can do a lot of heavy lifting without taking much RAM.
- toast0 3y ago> All of your code and resources are in ROM which means they're just an address away. Only until you need more rom than address space available to the cartridge slot, and you need to add bank switching. Then you've got to keep track of what bank resources are in.
- JohnBooty 3y agoKeep in mind is these kind of things have a flat memory space between RAM and ROM This is true and is very central to how these miracles were pulled off. While you know this, for the benefit of those reading: you could also use ROM for time/space tradeoff purposes -- for example instead of doing a bunch of trig calculations in real time for character movement purposes you could just have lookup tables in ROM. the code called when a scanline is drawn goes and accessed the values in ROM (it's just a memory address) without needing it to ever living in RAM This went away at some point in console history, and I'm not sure exactly when. For example the Sega Genesis/Megadrive has a scanline based video chip. No framebuffer, etc. But you've got to copy graphics data from ROM into the 64KB of video RAM before it can be drawn onscreen -- no rendering directly from ROM. You can do this during the VBLANK interval (the time between frames) but there is not enough time to rewrite all 64KB so you've got to be crafty. Typical procedure was to stream animation data for the main character into VBLANK because you would like your main character to be animated as smoothly as possible. [1] Contemporary systems like the Neo-Geo did not have that restriction and could render ROM data directly,[2] although it was several times more expensive than the Genesis and had many more address lines physically exposed on the ROM cartridge connector. May have used faster ROM chips too; dunno. [1] https://rasterscroll.com/mdgraphics/graphical-effects/animation/ https://rasterscroll.com/mdgraphics/graphical-effects/animat... [2] https://wiki.neogeodev.org/index.php?title=VRAM https://wiki.neogeodev.org/index.php?title=VRAM
- reaperducer 3y agoA fully working chess game in 4K of ROM, using each of the 128 bytes of RAM MicroChess says hold my 924 byte beer: http://www.benlo.com/microchess/index.html http://www.benlo.com/microchess/index.html MicroChess is also believed to be the first home computer software that was available for sale to the public. I have this on my KIM-1, and I find watching it play itself kind of soothing.
- billforsternz 3y agoI'm featured on that page, for porting it to C for running on modern PCs. But by far my favourite retro chess software project is Sargon 1978 https://github.com/billforsternz/retro-sargon https://github.com/billforsternz/retro-sargon