There are still more things planned. The simulation does not yet support paddle positioning or the ball, only the playfield and scores. I plan on making a few posts on how those circuits work, while improving the simulator. So its not fully complete (hence the asterisk in the title)
The source is available here. It's written in JavaScript, so it should run on any (modern) web browser. You can download the source and run it from your computer, or as the purpose of HTML is to make downloading unnecessary, you can use the version I hosted HERE.
Getting it running
To run the chip, "hit the step forward" in the upper right to advance the chip by half a clock pulse, hit the "run" button to make it step forward automatically. Each step will toggle the state of the clock pin (It will flash very fast) and update the circuitry. One of the circuits connected (almost) directly to the clock input is the horizontal position shift register. If you run the simulation you should be able see the bits inside shift from left to right.
The shift register |
Below the shift register is a binary decoder. The horizontal control lines going through it will light up when the shift register reaches the right combination.
The signal output
As said before, not everything is implemented yet. The simulated television will only show the outputs from the play-field and sync pins in this version. As the chip runs, the simulated electron gun moves across the screen and the value of the output pins determines the color drawn. Sync pulses appear as red, these trigger new lines (HSYNC) or new fields (VSYNC.) Usually, the chip runs at a ~2Mhz clock, but ours will run much slower, allowing you to see the image being created.
You probably don't want to wait around for it to slowly generate the screen. There's a box called "Animate during simulation" below the chip image, if you uncheck this, it will run much faster. To get it to go at even higher speeds, hit the "one line" or "one field" buttons at the upper right. It may freeze the window for a few seconds while it processes though.
Below the buttons is a speed indicator. Using Firefox 61, I get ~13Hz, 100Hz without updating the animation, and about 3000Hz at full speed using the "generate field" button. I'm curious as to how fast this performs on other browsers/computers.
Interacting with the Chip
You can turn the game select and reset pins (bottom left-bottom right) on and off with the checkboxes above the TV screen. Tennis (default) displays an I-shaped court, soccer adds walls to the back. Practice and Squash create a one-wall court, and the rifle games don't create any court. You see what happens when you try out any combination. Soccer and Tennis will trigger a soccer game, while Soccer and Squash are invalid and will lock the clock circuitry.
The score circuitry is on the right middle. The "Update Scores" button sets the internal counters to the values in the boxes. Its quite fun to mess with the inputs and states of a virtual chip. If you break it, you can just hit the reset button!
Under the hood
I made some changes to the original chip simulator code. I had to add in functions to "force" nodes into other states (e.g. when changing the scores) The original simulations never needed to edit internal registers directly, and thus only had functions to change the pull-up/pull-down of nodes. The simulation also saves the chip's state every step into a string, which is read when stepping back. This can grow fast very quickly (multiple megabytes per second), I had barely any RAM left after generating a few fields. That was modified to save only a limited number of steps (400)
A very helpful addition I made was to highlight all the transistors connected to the selected node. Yellow ones are nodes controlled by the node (gate-connected), while pink are ones that affect the node if powered. Now it only takes a click to find out what can ground a node, as well as what that node can ground.
It's definitely easier to analyse the chip with a simulation instead of plain die photo.
It took me a little while to understand the chip, and I left a lot of comments for anyone else who wants to understand how it works. Again, the source is here.
It took me a little while to understand the chip, and I left a lot of comments for anyone else who wants to understand how it works. Again, the source is here.
Original |
Simulation |
To be continued...
I promised a post on the workings of the control and sync circuitry last January. That's coming, just a few months later than I originally expected. I'll look into the gamefield and score circuitry after that, then improve the simulation so that it can make use of all functions of the chip. There is also another digital logic reverse-engineering project I might work on, one that's less than a decade old. Also, sometime I'll put the finishing touches on the image processor I wrote and put that online.
Until next time! |
Amazing!!!!!!!!!!!!!!!! Great work
ReplyDeleteIdeas for next version:
1:only game screen option
2:controls, like in the consoles that use this chip
3:Configurable controls
4:true colors or configure colors option
5:save state option
6:exe file
7:run with command line
8:fullscreen option
This is realy a great work!!!!!!
ReplyDeleteWe do not have simulators fo AY-3-8700 (tank battle) too, but i can not find any decaps. Some ideas for next version: simulator like emulators is easier for to use (win arcadia for sample)