 Hello everybody and welcome to the first talk here in hall 3. Our speaker is Swally and in his talk he will address the history, the programming details and the hardware internals of one of the first game consoles on the market, the Atari 2600. Give him a huge round of applause, he is Swally. Hello, hello. So this is what I want to talk about today, the Atari 2600 video computer system. Yes, it's really called that way. So I'm going to talk to you about the history, the hardware and how you can write programs. Some first steps on how to get there. So why do I want this talk? Well, the idea came from two different aspects. One was Michael Stahl who inspired me to do a talk about retro computing when he did his talk about the C64. And the other one is why did I choose really the Atari? Because it is very well documented, the CPU and the video chip is as well. And the video chip differs from anything else that you've got in any other hardware or any other gaming console. And this is the main course. So first of all I got to thank you to all these guys. They did the pioneering. I just took on their work and did the talk. There are a lot of sites concerned about the varying aspects of video gaming in general and specifically on programming on the 2600. So let's start with the history. Short about the Atari history. Atari was founded by Nolan Bushnell and Ted Stephanie in 1972. It was founded because they wanted to produce what is known as Pong. This is recognized as the first worldwide video game. And though it's not the first at all. The same goes for the Atari. It was also thought of as the first gaming console for home. But this isn't. There was the Fairchild Journal F was further. But this was the one that really got the huge success. Between 1972 and 2001 Atari had an arcade game division which was the basic. One of the main fields of industry where they worked in. Most of the some of the games were also implemented for the Atari 2600. So let's start with the design history. Well their first release was a home version of the Pong game which was a success and a failure both. It was a success because it was the first game that really got into first video game that got into people's homes. But it was more a failure for Atari because it was cloned very fast and they couldn't get much money out of it. So in 1975 they decided to produce a home game console based on a programmable design using a CPU. They co-named it Zella after the bicycle of one of the engineers. And when they started designing three processor designs were considered. The Intel 8080, the Motorola 6800. And the MOS 6502 which was an independent company once the design started. But between that and the release of the Atari the whole MOS company got bought by Commodore. So they could produce the the pet computer and later the C64, big 20, something like that. And one of the key issues what they wanted was it should be really cheap. So that a lot of people not into video gaming would also consider buying one. So the basic design was set up in two days with the core team of the engineers together with Chuck Petal of MOS. He was the man who designed the 6502. And both the CPU and the ship set were off the shelf components. If you take a look at nowadays consoles like Wii, Xbox or the P3 all are custom designs. So this is back then it was off the shelf components. But the main thing MOS got the deals because they were significantly cheaper than the others. The first offer was about $15, Atari sang the prize to $12. Whereas the competition got them to or wanted to have $150 to $200. The guys at Motorola were sure that they want to get the deal because they were a bit cheaper than Intel. And they didn't know about MOS so a week after they learned that they didn't get the deal they sued MOS for patent infringements. But what was still needed was the chip responsible for video and audio. There were no off the shelf components available at this time. So Jmina designed one. Jmina is also known or better known as the father of Yamiga. And he did it using breadboard technology. We'll have a picture of that later. And it was a rather expensive design phase because it was very tedious work to do. And it took quite a lot of time. But when the finished design was transferred into a chip, this resulting chip was easy to produce. And it was named TIA short for television interface adapter. So this is what a breadboard looks like. And this is just a binary counter. So imagine if you want to put a whole video chip on this one that you really got to need a huge size of it. This is what the finished die looks like. And Atari is a part of pop culture. They were not the first on the market. This was the Fairchild Channel F. But they were the first that achieved really broad distribution. And it was released in 1977. And after the first release, the PCB design and also the casing was constantly redesigned. But the last version is still 100% compatible to the first version. And I knew back in the 80s, Atari was the new for home gaming. I knew back in the playground, when I was a kid, there wasn't a do you have a home game console? No, it was do you have an Atari? And it was discontinued at the end of 1991. So it was in production for more than 14 years. And this is the longest, this is the console that remains the longest in production. There are about 500 games that were programmed. If you're going to count in bootlegs, NTSC, Parcon versions, stuff like that, you can get estimated to over 10,000 different modules. About 7,000 have been counted by one website. So this is what the first Atari looked like. There you see the module you're going to plug it in there. And this is called the six switch model. Because there are still some difficulty switches on the front. In the next revision, they did not get moved away because it is still 100% compatible. But they have been moved to the back, which is better to see by the next revision which is just another different color. So you're going to see there and there the difficulty switches. This was the last one of the original Atari that was produced. If you want to go and code on real Atari hardware, I suppose that this is the console that you're going to use. Because it is technically the most advanced and it's really easy to modify for an AV output. The others still need some more. But this is for about parts two to three of you you can build your own AV output. This is the Atari flashback. So when Retro really got on the way, Atari also wanted to make some money of it and they put a whole series of flashback consoles. This is the flashback two plus, which differs from the original two just by a different game selection. The flashback one was not really an original Atari 2600. It was a NES system on a chip design where the games has been ported to. The flashback two is an ASIC design of the original hardware and the flashback three which has gone on the market this year is an ARM based computer which just runs an emulator. So back in the days, there was this green meadow where they're going to put on new games. So where did they get the inspirations from? Well, first of all was to port some analog games or content, something like chess or checkers. Also, there was an attempt to port the video pinball. So this is what these games looked like. Sports were a very nice thing where they got their ideas from and most of the sports have been implemented more than once. So there's boxing and real sports boxing, real sports soccer and pilet soccer. And so it's nice to compare them. We'll have that on the next slide. And probably the biggest selling title there was Decaflin, the real Georgia killer. So here we have basketball and soccer in the different year. So this was really from the early days. The double dunk is more sophisticated, but the most interesting part is to compare the soccer. On the pilet soccer, you have four players, three pilers and goalie. And the field players are always there in this formation. So you move over them at once. Six years later, they got more sophisticated. The other players were controlled by the computer. You just controlled one player, and there were six field player and one goalie. So another huge origin of games was to French eyes. Other titles like movies or cartoons like Spider-Man and even something like the Muppets. And the first Star Wars video game was for the Atari 2600. But there's no roundhouse kick. I tried it, I couldn't get it. So this is what the games looked like. This is the first Star Wars title. So you're going to play your fighter against the 88, Spider-Man, Smurf, and this one is Rails of the Lost Ark. Though it doesn't really look like much, it's one of the best adventures program for the Atari and it's still a fun title to play today. But the biggest section was to port arcade games. But it was not really porting, but it was just a re-implementation of the original game idea. So let's just compare two games. I can say one of this conversion sucks, in my opinion, and the other one has really gotten very well. As I put on the slides, I say from the view of the games you really couldn't tell which is which, but Donkey Kong, in my opinion, sucked because the original has four levels and the Atari clone only has two, the first and the last, and Popeye includes all three levels and they are also very fun to play. But this is the part you really want to get an Atari for today. These are the original titles. They are really evented for the Atari. The most important part there is the most original titles were just another space shooter or something like that, but there were really some really nice pearls in there. Haunted Horse is a nice adventure survival horror game, it's also called Pitfall is a classic, and Adventure is the one I'm going to introduce you in depth to. So this is what these games look like. About Yachter Revenge, there's a nice thing to know, that this energy barrier here, which blocks your shot, the developer wanted to have some random data, but space in the cartridge was really short, so what he used as random data is what you see there is program code used as a table. So let's take a look at Adventure. Why did I choose Adventure as an example? Because it's the ancestor of all action adventures. So when you play Zelda, the original one was for the Atari. It is still a fine game to play. It will not take you as long as Zelda to come through. A skilled player can do the easy version in less than a minute and the more complex... But this is just an introduction. The real game setting can be done in about five minutes, something like that. But till you get to that point, where you can do it in five minutes, you have still some things to learn, so it will... For the first time you get it through and think you've done it is about an hour. The original author of this game had put on a small website about this game where he also includes slides for a lecture he gave about this game and the Atari development in general. So how do you play it? This is you. So you start as an adventurer in front of a castle and your job is to bring the enchanted chalice back to that castle. For this you have a world consisting of 29 screens like the first one we saw. There are three castles, three mazes, consisting of several non-linear screens. So when you move out to one level, you can get into the same level as you can get... If you enter to the right. So it's really... You've got to learn your way by this turn, that turn, and not by just thinking as just as a plain area. There are several connecting rooms like forks where you can get either to the maze or to the castle. There are some dead ends. Some of them might contain objects that you need to solve your quest. So let's take a look at these objects. All objects interact by overlapping, so touching. This was something very new back then. We've got three dragons to chase you. This one is the real enemy because it moves your objects away. You can carry only one. So if you put it somewhere, it steals it from you. So maybe the sword is gone when you want to fight the dragon. You've got... For each of the three castles you've got a key, a very nice drawn sword to kill the dragons. This is something really cool. This is a wall where you can cross through... A bridge where you can cross through horizontal walls. The magnet to attract objects. This is also something very nice. This is a workaround for a problem you've got. You can drop some of your objects inside a wall so that you can't get them anymore or the bed can do this. So you've got to get it out there somehow and this is why Warren has implemented this magnet to attract the objects. And of course you've got the enchanted challenge. But the coolest thing about adventure is there's one more object. It's one pixel in size and it has the color of the background. So if you drop it, it's very hard to find. It's hidden in a room that's only accessible using the bridge. So in normal gameplay you wouldn't even come to this room. When you take this dot to a certain room and add another object to this room, the wall is gone. Maybe not on the first time. Maybe you've got to leave the room and enter it again but then the wall is definitely gone. And if you go to this wall that is no gone you can witness the first Easter egg of video gaming. The revenge of a disgruntled video game programmer. When Atari released their games the program of video games got a salary of about 20 to 25k a year. And they didn't get their name. Not in the manual, not in the game, not anywhere. It was an Atari game, it was another game of a programmer. So Warren choose to hide this one very deep in there. And after that quit. So let's take a look on how you're going to program it. Back in 77 you've got code assembled on a computer running a proprietary OS. My guess was that it was CPM but it wasn't back then. It's connected to a special cartridge which simulates the ROM inside the Atari. And when the software crashed you would just see stripes top down. Why are we going to learn later on? For debugging a logic analyzer was used. So something leading to a special condition could be displayed. It does not need the crash but something else could be also done. Nowadays it's much more simple. You've got your code assembled on almost any operating system you're going to choose like. You can run your code inside a very sophisticated installer with an emulator with very sophisticated debugging options. And once it works like expected you can transfer it on a special cartridge which simulates the ROM for you. Supercharger was the first was able to do this and how many cards is the current one that you can buy. In between there have been about four other cartridges but they are not available anymore. So this is what the Supercharger looks like. The data is transferred very much like it was done on the home computer back in the 80s. So with an audio coded signal. The game developers mostly used this to plug in the audio signal into the sound card so they could create the data direct from there. This is what the debugger looks like. So you've got your object code. You've got all the RAM in one view and you've got the display of the game. It turns black and white once the new screen will be drawn so that you can see where you are going to draw your data right now. Piracy. It was even back then an issue. In the design phase nobody thought about it because they thought this hardware is so sophisticated no one ever will be able to hack it. But suddenly there was competition in the name of Activision. Activision was founded by four Atari programmers who decided that they wanted to have their name on the cartridge so they had to go independent and there was a nice talk before they did that and this sentence was the one that really got them going. Well, Atari and otherwise. They filed a lawsuit to prohibit a third-party game development and they lost that suit. And other companies know that the juristic stuff was clear jumped into that and really lead to a flood of game card which is by other programmers. Some of them were really nice but most of them were not really worth mentioning today anymore. But when you have the option to program for it you have also the option just to modify the game so this is the cause of all the bootlegs. You just pick out the original game maybe change some sprites or some colors and then you have a new game that you really want to sell as new but you could also copy your games at home. There was some kind called the duplicator. You have got cartridges. They are fit with an eProm and this is just an ePromer with very special connectors. Atari filed a lawsuit and this time they won. It was a bit too obvious that this is not really good. So, home brewing. The Atari has been out of production for 20 years now, even more. And there is a big home brewing community that still develops new title. This year, Boulder Dash has been ported as a licensed game from First Star Software. Atari H and other real cartridges that you can buy and plug in an original Atari more than 100 titles compared to the 500 titles that were available when the Atari was taken from the market and most of the home brewing games are even better programmed. So, if you want to do it yourself, I can recommend two different assemblers. There is the Desim assembler and this is the defective standard of the home brewing community. And there is the CC65, which comes from another aspect, more for programming for Atari, the commuter computers, the 8-biters, all what runs on a 6502 processor. And if you just want to give it a hack, there even is a Atari basic. This is a basic-like language which compiles your code to an assembler source code that you can put on through there. You don't want to write a new game from scratch. You can go hack and modify other games. You can just change the graphics as the bootlegers did. There are even a few games with editors, so adventure can be modified to your own adventure. And you can disassemble and game and modify it. Therefore, I've got a fine example. Pac-Man. This is what Pac-Man looks like in the arcade. And this is what Pac-Man looked like at home. So the home brewing community thought, we're going to do this better. Let's put it in this way so that the colors match, the sprites look a bit nicer. But they even took another step. This is the ROM image of Miss Pac-Man, the successor, and they put back in the original image and even put in intermediate movies and stuff like that. It's really close to the original arcade version. So let's take a look at the hardware. This is the block diagram. So we've got the Atari. We've got the ROM module that contains all the code. There's no firmware or something like that in the Atari. The Atari in itself is dumb. You've got your input devices like joysticks and paddles. And you've got your output device, the television. Inside the Atari, we've got the 6507, the CPU. We've got the chip that contains ROM, IOD ports and a timer. And you've got the television interface adapter. These are all connected through a CPU bus. And the input devices are connected to the riot and also to the tier for analog inputs, something like that. And the tier outputs what you've got to the television. So let's take a look at the CPU. The CPU is a stripped-down version of the 6502. This has been described in depth by Michael Steyer last year. And if you want to go into that, I really recommend that you're going to see that talk. So here's just a brief overview first of the 6502. It was designed by Chuck Paddle, who also did some work on the Motorola 6800. So that was one of the course for the lawsuit. I mentioned earlier. It is an 8-bit architecture, a little engine. Your instructions take up one up to three bytes and take two up to seven clock cycles to execute. In this case, it is clocked at about 1.2 MHz. And it's cheap in production, even the 6502, and it was competitive in speed. So you've got in the CPU six registers, the multipurpose accumulator, two index registers, the program counter, so where the next instruction will be fetched from, the stack pointer. And there are some discussions if it's a 16-bit registered or not. It is a 16-bit address register where the next address for stack will be used. And it is an offset from 100. But if you transfer the stack register, you can transfer it to the X register, and then you have got 8-bit, so I chose to say it's an 8-bit register. And you have also the processor status for the zero flag, negative flag, stuff like that. So what's different about the 6502? It has a smaller chip package. What's missing? Three address lines. So instead of the 64K, you've got only 8K where you can address all the others on mirrors. The both interrupt lines have been completely disabled. There are four other pins missing where not essential and three non-connected pins have been used. And this one is even because of the smaller chip design or the chip package, this was one of the main cost factors you've got back then. So it was even cheaper to produce than the 6502, and it was very popular for embedded applications like washing machines, something like that. So we've got the riot. It was a very, very common companionship to the 6502 family. It features the whole 128 bytes of RAM. That's all you ever get there. You've got two IO ports. One port is used for the five console switches, the one you saw on the first minus the power switch. You've got one IO port for both joystick ports. There are only the directions. The fire buttons are routed through the tier. And a timer that is capable of sending interrupts. But as we have learned, the 6507 is not capable of receiving. So the external address space is 8K. This means we've got eight mirrors. The remaining address space is split in half. The lower half is used for IO like the tier, the riot, timer, RAM. And the other half is used for the ROM module. They are typically used in two ways. Either you put them all in one, but the most common one was to use the lower bank with the address of zero and the ROM with the address of f. So this is what the mapping of the chip looks like. It's a bit weird. So it's usually addressed at the first part of the zero page. There are different shadows available. It's got space for 64 registers. There are 14 read-only registers. They are mirrored four times inside that 64 byte address space. So we've got 45 write-only registers. They are really write-only because if you read from the same address, you get the read-only registers. So you use the address for both of them. So this is what the except-making of the riot looks like. The real interesting part is that there are the mode registers, either RAM or IO. So it means it's mapped to two different addresses. The RAM is usually addressed at the second half of the zero page, and the IO is at 280. So this is the mapping, which looks a bit weird, but they're alternating like this, that you get the first two mirrors for the RAM, the second two for the IO, and then switch back and something like that. This was necessary to get this mirror here. We'll learn the short why. So this is the IO ports and the time-up addresses. This is the RAM, 128 bytes, as I mentioned. It's needed two locations for your game status, the variables, and for the stack, which is at 180. So what you've got there is pretty less time. In the menu, it is stated that the stack will be used from top FF down. So keep in mind that you're using mirrors, so that you don't have the 128 bytes twice, but only once. And my favorite quote from the developers manual is this one. So what's still missing is the ROM. The ROM resembles, this is 24 pins that are on the connector, resembles an eProm or a ROM of 32 kilobits, so 4 kilobyte. It has three power lines, two ground and one voltage, eight data lines, and 13 address lines. So it just resembles what's the difference, what's missing. What's missing is the ship select signal. So what Atari did, they just defined that the ship select is not low active, but high active, and it's used at the highest address line for this use. So they needed no logic inside the Atari to generate a ship select. And what's also missing is the read-write line, which is in my opinion a bit of a design failure, because they have two grounds, one would have been enough, and they could have used the read-write so that you could put RAM on a cartridge. But this was, when they designed it, they just thought of it, ah, 4K ROM would be enough for everyone. So we're going to need to now learn about how to work around these barriers. At the start, there were only two or 4K ROM modules, at 81, the first 8K ROM modules were available. How are we going to fit it in there? Bank switching. Let's assume you've got your ROM, which is an addressable space of 4K, you put in two banks, and by reading just from a special address, you switch from one bank to another, and by reading from another address, you switch back. This is called the F8 type of cartridge because of the low byte value that's been used for switching. So if you need more ROM than 8K, you can simply add more banks. You use four banks, and again, four hotspots. This is called F6 because the first one was F6 to use. Now we have enough ROM, but what about RAM? We have no read-write line on the module, but we can use or misuse the address lines for the read-write configuration. So we have a write port and a read port. The write port starts from 1,000, and the read port starts from 1080. So what we're going to write to 1,000 can be written from 1080. And these are variations of the cartridges that I just introduced, and they have added a C for, as far as I know, super cartridge. But you can push the bank switching a lot more further. You can first split up your address space so that you don't need to bank all of it at once, but just one half. For this, you can address up to 256 banks, and these are not addressed by accessing hotspots because a whole page would be just lost for hotspots. You write the ROM bank number to 3F. This is IO space. But since you've got the whole CPU bus, you can use it. You can also add 32 banks of RAM. Change it to a different IO address you're going to use, and then you've got a really super cartridge, which is capable of addressing 512K of ROM and 32K of RAM. They are the different ports. And this is called Type 3E because of the RAM address, and it was used by a company called TigerVision. Though they didn't push it this far, as far as I could research, they only used up to four ROM banks. But one of the homebrew cartridges was capable, they have extended this logic to use it up really to this maximum. So short conclusion. There are many ways you can get more ROM or RAM into the cartridge. They also include some kind of bank switching scene, and you've got, you've learned about five real-life configurations. The Amulet Astella allows about 25. So it's even fun just to poke through the source code and see how they implemented the bank switching. There are some really weird things there. So nowadays you can use it using microcontrollers in cartridges, which also include the ROM data as well, which is used in the Harmony cartridge, for example. So part three, how to write programs. Now you're going to learn how to write on the registers. First of all, we need to look at what a television frame looks like. The ray crosses, the beam crosses the frame from left to right, and while it's crossing it's selected which color should be displayed. And this is done line by line, every frame. For these scan lines that they are called, you've got on NTSC 262 and on PAL 312. Across, as the beam travels you've got 228 color clock cycles. The Atari has no frame buffer as most of the other consoles. This is one of the main differences. So you cannot call them pixels or something like that. So you've got your vertical sync from the television, which is not displayed on the screen, as well as the overscan area, where the beam already has gone out of the picture. And you've got your horizontal blank, which you can use to prepare something for display. So this leaves you with an drawable area of 160 color clock cycles. So this is the closest one that you can get to a picture, so this is the resolution you've got there. Your games logic will always happen in the vertical sync, vertical blank, and in the overscan area. During this phase, you have to draw the display yourself. And the CPU clock, when you program the TIA, you have only 76 color clock cycles, exactly a third, because the TIA generates the CPU clock as one third. So since we've got no frame buffer, why we have no frame buffer? RAM was in 75, very expensive. My rough guess is that a kilobyte of RAM back then cost more than it would cost a gigabyte today. To convert, if you think of it as a frame buffer, there are 160 times 192. You will need 30K of 7-bit words. This would be a huge amount of RAM. It would be very expensive and wouldn't even be addressable by the CPU. So something, a completely different approach has been taken. You program the chip while it is traveling the beam. The advantage is it was very cheap to produce and it is very flexible. So over the years, the program has really learned to master this technique. And the disadvantage is, as I stated, the CPU is occupied doing this play so you can't do any game logic in there, except you put in a blank or something like that. So instead of running the graphics frame by frame, the image is drawn really line by line and you draw it line by line. But nothing changed. The next line is drawn as the one before. So if it crashes, you have just one set of lines going from top to down. There are no registers for Y components. That was something that was really odd to me when I started reading the manual. I thought, yeah, the sprite position X and X and Y. Y as you draw. So when you draw a sprite, it is 8-bit wide and you can put it as high as the screen. So what you do is you tell the tier to paint while it is painting. And this really needed some exact timing and this is officially called racing the beam. So let's take a look at the wide registers. There are four for syncing. So you even do your own syncing on hardware. A lot of graphics registers. A bit audio and this is to reset collision. So let's take a look at the graphic capabilities. You've got a background color. You've got two different colors for the sprites. You've got play field with its own color. You've got two missile sprites that are reusing the player colors. You've got one ball sprite. So if you take a look at this, a ball to missiles, it really comes from the requirement that you needed to run combat and pong as games. So let's take a look at the colors. We have got four color registers. Background, the play field and the two players. All other colors are taken from these for missiles and the ball are taken from these registers as well. And the color can be picked of a palette of 128. As a C64 programmer, I was really envious of this. This is what the palette looks like on NTSC. This is what it looks like on PAL. Because PAL color generation is more complicated, some of the space needed to be used for this logic. So it was completely rewritten at this point. When you port a game between NTSC and PAL, this is one of the two things that you've got to take care of so that you use another color palette. The other is the 60Hz versus 50Hz timing problem. But this really isn't a problem as you have seen. You do the timing all in software. You really program the video blank yourself so you've got no problem in running an NTSC game in a PAL console. You just get a 60Hz version of the game and you get some really strange colors. But really screwed with the one who got a Ccamp system. What has happened there? Well, the Atari has a switch in which you can put each game into black and white mode. So on the Ccamp system, this switch is always set to black and white and instead of displaying different gray colors, it's just really a different color that's been used. So let's take a look at the play field graphics. The resolution is 40 bits. So we've got four color clock cycles per bit that have been displayed. The registers responsible is the play field color, three data registers, but how are we going to squeeze 40 bits into three bytes? There's one more register that's just involved. It's a control play field register. And there you've got the option to reflect the play field or repeat the play field. This we're going to get in depth on the next one. You also can choose that you can use the player colors instead of the play field color, which is often used to display the score of a game. So the number displayed on the left gets the color of the left player and on the right gets the color of the right player. And you can also choose the priority if the play field should overlap sprites or if the sprites should overlap the play field. So this is the data register in depth. We've got our 20 bits there. This ordered in this way. So these 20 bits can be either mirrored and yes, this is not a mistake. The bit you specify there is really displayed somewhere in the middle. And this is one thing that's also, it's a cause for a lot of bugs if you're going to try coding. At least that's been for me. What you can also do is repeat the same color, still unordered or sometimes reversed, sometimes normal and backer to reverse. But what you can also do is you can change it during display. So while the beam travels over the first data, you can change that data to something completely different and then use this data again on the right half. And this ordering really isn't anything but straightforward. So let's take a look at some examples for our play fields. This is a classic combat, which has been one of the launch titles. You've got the play field slightly mirrored. You've got two different colors for the players and the players. Defender is a nice example on how the repeat has been used to draw the screen. And one of the nice examples I could use for play field was a game called to tank him. There they're going to use the alternating between mirrored and repeating to really to design the game level. So you come back from up there. You've got here a place where it is switched. This is a tunnel. So you can't go back down there. You go through the tunnel, go around there. And yes, here is mirrored. Here it is repeated. And this is something, which I think is a very clever design back then. We've got the play field and the other big graphic elements, the sprites. The TI has five sprites. Two player sprites, eight bit. Two missile sprites, they are on or off. And one ball sprite, also just on or off. So the missile sprite positions can be locked to the player position so that you don't have to use the registers for the missile sprites, but can position them on the same exact position as the player. And keep in mind that the hardware was constructed for using combat and pong. So you're going to see the player, the missile sprite, the missile sprite, the player, and the ball sprite. And these are also player sprites. Sprite placement. This is a real interesting topic. The Y is how it reaches, when it's enabled before it reaches the beam position. And X is a bit more complicated. You have registers that are called reset player zero, reset player one, reset missile zero, reset missile one. But these are just registers you trigger. They don't take any value. They just reset the sprite position. And reset has also different interpretation in here. You do not reset it to position zero to the left, but to the current X position of the beam. So what you're going to do is you wait until it reaches a special position, then trigger the reset register, and in the next line you enable so that it is displayed. But we have learned that the tier is three times as fast as the CPU, so you cannot do it pixel or color clock cycle exact. For this, you've got fine tuning registers. These are motion registers that can be used to move the sprite minus eight to plus seven. Very intuitive, negative move to the right, positive to the left. And you just store a value in there. It is not triggered while storing. It is triggered by storing the move register. And you can clear all these values at once. So how are you going to keep your code in sync? This is something that is really essential as we learned on the previous slides. To accomplish it, there are three rules you're going to use. First of all, you count the cycles. You know of every instruction, what it takes to execute. The second one, this is the core. This is really the core of Atari programming. You've got the W sync register to stop the CPU until the start of the next scan line is reached. So you can always delay your code to the next line about to display. And this is something, this is the key that obsoles but makes it possible to work without interrupts. And if you cannot predict, well, don't want to predict because it is some more complicated game logic, you start up a timer, run through your code and wait for it to time out afterwards. So let's take a look at some real life sprite examples. So the question is, two player sprite is a bit, really a bit, not much. So we can get more sprites. This can be done in software. Just by changing the sprite registers, once a sprite has been displayed. But you can also get a bit of help from the hardware. This is another game variation of combat. And once you have three planes there, again one large one. And this is done by hardware registers. The player sprites, or for the player's workouts, these seven options, the normal sprites are mostly used. You can then position them or enlarge them. So mirroring is also possible that you don't waste your ROM on mirror data. And the ball and missile sprites can be enlarged. So let's take a look at some game examples. Outlaw is one of the, not a launch shuttle, but came really short afterwards. Two player sprites and missile sprites have been used. Circus Atari is quite nice. The player sprites are used for the two clowns. And the seesaw you can see there is a missile sprite that's been moved four pixels, or the two-color-cluck cycles, sorry, every line. So you've got Berserk and Vanguard. They use the same technique. They make sure in gameplay that two enemies are on the same scan line. If this robot moves up, you're going to get there, it will stop about here because it would then reach the area of the next enemy. Pegman uses another different technique. This is a bit bad to see here. Pegman is always drawn every frame, but the ghosts, one there, one there, one there, and one there are also drawn, they take turns in being drawn. So they are interlaced. Space invaders use another neat trick. It uses triplication. So this, this, and this is the same sprite, and this, this, and this is the same sprite. And what you're going to do is, when someone gets shot, you don't turn it off, but you set the data to zero. DigDuck. DigDuck is a really fine-coded game. It just uses interlaced when two sprites are on the same scan lines. Videochess uses another trick. It just displays only every other line. So, and this is really still the best technique to use if you want to generate some kind of menu or something like that to display your data. So, let's go to detecting collisions. This is essential, and the hardware is full-featured here. We've got all combinations that are possible for collisions. There are registers in there. They will keep their data until it is triggered. What is a collision? If you code it in software, you could, you would do it in other, would not, if the pixel is touched, but you would take the drawing area and just see if something matches there. And it's really good there. So, this is not a collision. We've got two voices. A little bit of a rush because time is running out. The audio, we've got two voices, each having three registers. Volume, the frequency, this is a divider for the base frequency, and the control. The control has 11 unique settings and the control is the basic pattern you're going to get there. You're going to see it a bit afterwards. Most of the settings are not used for music, but just for motor noise, shots and something like that. So, the sound generation can be looked at at two steps. The basic signal is generated by setting the audio high or low. So, what the output got in there is just a rack angle. These are the base frequencies that are used. The control registers define the pattern and the sound is generated by shifting these patterns out one by one. So, let's take a look on a piano keyboard on what tones you've got if you're going to use the settings that are used for generating just a pure rack angle and that are useful for generating a melody. So, what you've got there is a bit more than three or four octaves, something like that. Some game developers really took some guys, say, write me some simple music instead of taking something that has been already known because there are some keys sometimes missing. So, let's take a look at the waveform that can be generated. So, this is the pure rack angle you get for the high notes and this is the one that get for the low notes and some others are really weird looking so they get some kind of distortion that can be used for motor noise and something like that. So, and the step two is that this signal is multiplied with the corresponding volume register and this can be used also to play four-bit digital data. This is quite impressive. There is one game which is really worth looking at. It's called the Berserk Voice Enhanced Edition. This is a hack of the game I introduced during the sprites part and this features the voice of the arcade version and if you compare it, it's really impressive because of the really different hardware and the capabilities. The hardware of the arcade version is way more sophisticated. So, going from here what you're going to do next I invite you to play a game. Back then, you couldn't hide a shitty game behind beautiful graphics and a beautiful soundtrack. When a game sucks, you see it and if it doesn't suck, if it really gets you playing then it gets it for a good cause because the game is good. I have not covered the homebrew games because I'm already out of time and take a look there. It really is impressive of what the homebrew community has squeezed out of the hardware and what's also nice. What you've learned here, try to figure out how they do it. I still have seen some games. I don't know how they did it. So, if you're not into playing games play with the system, code something for free. All tools are available. The emulator is available with very nice debugging support. You've got two assemblers you can use. And from the intro I've displayed the scroll routine without the coloring. Just drawing some text has taken me an afternoon to code. So, it's some time you can spend. If you think the Atari is shit do a talk about another console. I would like to learn. Show me something. So, have you taken time for questions? No time for questions. I'm sorry, but I wanted to squeeze as much information as in the talk. I'll be here around. I'll wait outside the room. If you have questions to me, address them. I'll be waiting there for you for about the next half an hour. Thank you.