YTread Logo
YTread Logo

The Ultimate Game Boy Talk (33c3)

Jun 06, 2021
So I'm really looking forward to the next

talk

and I know why most of you are here because I'm excited about this too. I have a Gameboy and I'm very proud of it and I have it in my apartment. and on special occasions I get it out of good nowadays I use a safe emulator and I only have cartridge roms that I actually have good that's how it's supposed to work well yeah and I'm looking forward to this but the way it I am my favorite

game

s on a

game

boy the first to make that clear our Megaman 2 Mario Land and mystic quest and and whoever disagrees with this well you don't know me that well then so let's get to the

talk

of the definitive talk about Gameboy.
the ultimate game boy talk 33c3
I'm really looking forward to this, yeah, we have a Michael style speaker and he gave a really great talk at 25 C 3, the

ultimate

Commodore 64 talk and now with the

ultimate

Gameboy talk, I'm really looking forward to it. in this style michael by day he works in operating system technology by night he hacks obsolete systems in a previous life he hacked game consoles please a big round of applause michael the stage is yours hello hello everyone again my name is michael steele and this is The Best Game Boy Talk The idea of ​​the talk is to talk as much as possible about all the different details of the hardware.
the ultimate game boy talk 33c3

More Interesting Facts About,

the ultimate game boy talk 33c3...

All I can fit into sixty minutes. All about Gameboy. sixty minutes. I have about two hundred slides in over 800 individual builds, so maybe the information. The density is a little higher than normal, so let's start real quick. The Gameboy talk is in the context of a series of talks that I started eight years ago with the ultimate Commodore 64 talk and other people picked up on that and talked about Atari. 2600, Galaxia and Amiga 500, so now it's my turn and I choose Game Boy, why is the game so interesting because they solve so many systems? Game Boy, Game Boy Color, only 118 million, and if you count the game. advanced models that are compatible excluding Gameboy micro in total are almost 200 million systems, they have created 1600 around 1600 official games and produced it since 1989 only the 8-bit models until 2003 and again if you count the advanced compatible Gameboy models that they manufactured Gaming systems supported 8-bit until 2009, so that's 20 years, which is pretty amazing.
the ultimate game boy talk 33c3
Let's look at the competition back then, right after the Gameboy you knew relaunched Lynx, Sega, Game Gear and NEC, turbo Express, they all had them. One thing in common: they had a color screen, a pretty good color screen, but they also had one thing in common: really bad battery life, maybe three to five hours, whereas a Gameboy had fifteen to thirty hours, but the compromise was that you had a screen that looked like this and you could barely make out anything as soon as you start scrolling, this is not the case with all Game Boy models, of which there are many, the original Gameboy in the original design that was produced the longest is the DM G DM G stands for dot matrix game which was the original code name, then in '96 they released their pocket game which had a much better, much smaller screen , the MGB Game Boy light was only released in Japan, it had a backlight and then the gameboy. color with double the CPU space and double the RAM and double the video RAM and color support, then the Game Boy Advance series had a completely different architecture, they were based on an arm CPU, but they were still 100% compatible with Game Boy and Game Boy Color games, the Advance SP of that, there are two models, if you want to get one, you really need to get the AG s101, which is the one with the backlight instead of the front light and, like You can see, there has always been an antenna.
the ultimate game boy talk 33c3
They were a little ahead of their time, not only did they make a rose gold version, but you also need an adapter to connect regular headphones. If you want to play Gameboy games on a regular TV, set both options for that, or use an M Super. Nintendo and plug in a Super Gameboy, the two versions of that that were only released in Japan and given the right time didn't run 3% as fast as the original and the Gameboy player for the Nintendo GameCube and all of these had full Gameboy hardware. Built inside, basically, a regular, tight-fitting Game Boy, it places its pixel on the host system instead of on the screen, so what is a Game Boy?
There is a mono joypad speaker with a two-point-eight and six-inch screen. You can get stereo through headphones. There is a link connector. serial port to connect to the game boards together contrast and volume and on the back this is where the game goes and this is where you put the batteries and this is what the game looks like and basically most of the games are just ROM chips, no There are nothing more than specifications. What are the specifications of the game? When comparing Game Boy to other systems that may or may not be comparable. The CPU is a 1 megahertz 8-bit CPU.
Some people in the audience may complain at this point. I know it is a 4 megahertz CPU, but I will explain later, although I will call it a 1 megahertz CPU, there is a large amount of RAM, which is enough for such a gaming system. VRML 5 kilobytes is a bit tight, the 160 by 144 resolution is really poor, but on a screen this size it's not very noticeable, it can do four simultaneous colors, allowing four shades of gray to be skipped, and supports up to ten sprites per line, so if you compare all this with these other systems here it is clear that the Gameboy is much more advanced than, for example, the Atari 2600, but it is not at all in the league of a Super Nintendo, it is more like a senior S and more like a standard Nintendo Entertainment System or a Commodore 64, but the fun thing here is that while the NES and c64 were released in the early '80s, the gameboy is from '89 and, like I said, the compatible hardware was compatible and released until 2009, that's what makes it really interesting: it's an 8-bit system, but it's actually the latest. the last 8-bit system and which was in common use, let's look inside on the right, the dashboard on the right is not very interesting if you look at it from the front, this is where the LCD screen is connected, the speaker on the buttons, the button or plate on the back is much more interesting this is where you can see three chips so this is the dmg of the original Gameboy board two RAM chips two identical RAM chips one is for CPU Ram another is for RAM video and that's what there's a big chip here it's called a dmg CPU but it's actually the SOC, the system on a chip, so you would normally expect there to be a lot of chips in a computer system like that, it's all integrated on a single chip, which is the gameboy chip. compare some other boards here, the super Gameboy, it has a very similar chip, it is actually 99.9% identical, the Gameboy Pocket is not, it is a slightly optimized model that comes only with a Ram chip for Gameboy Light, it is possible that you have seen that in reality it is not. different, it's just another MGB from the MGB series, but it comes with backlight, then there are two Super Gameboy two which are based on the Game Boy pocket and this is what the color of the Gameboy looks like on the inside.
Everyone has this giant chip that does everything, but what is this? This one is special. You may not recognize it from the markings. This thing is called GB boy. There have been companies that clone the game, but all the time, and what this particular model is is a perfect clone of. Decapitating, photographing, and remaking the original SOC skin here and it's a Chinese Game Boy that you can still buy today for about $3,040 or so on eBay. It's a shame that Quartz is 30% faster, so none of the games are playable. Let's go back to the board, so the dmg cpu is what we're really interested in and it does everything in the system that is included in the dmg cpu, while a normal cpu core interrupt controller boots with time and memory from what would be expected of something. well and then all the peripheral devices like the i/o joy job had input serial data transfer for the link cable, a sound controller and a video controller, the pixel processing unit, so let's talk about the CPU historically, the 1989 gameboy was released between the NES and Super NES and NES came with a 6502 soup.
Aeneas came with a 65 eight 16 which is the 16 bit version of that same CPU, so obviously the again for tens with a sharpened L r35 902, what is the sharpened lr3 5902 core? It's nothing like a 65 or two, it's more like someone between an Intel 8080 and a Zilog z80, but neither of these two architectures is interesting because the 8080 was used, for example, in Altair, which is the first computer for the one that Bill Gates wrote software and released. and CID is on almost all 8-bit home computer systems that don't contain a very successful 6502 architecture, so if you imagine this is the feature set of the Intel 8080, that's the feature set of the zilog z80, so which is a strict superset is perfectly backwards compatible and that's the game guys with you, the core architecture is the same as the 8080, so all the main features are the register configured for the instructions that code everything, everything is the same, but there are some features. which are not supported, but it does support some GID functions, but it does not support most of the CID functions and then they added some functions on top, let's discuss that, so let's first talk about the core architecture of the 8080, it has these registers . the accumulator that is special is the one that can do all the arithmetic and logic you cannot do this with the other registers a Flags register only has two useful flags the 0 and the carry flag in the gameboy model the other two are only they use for decimal setting and then there's PC teh L, another set of 8-bit registers, but the fun thing about this is that you can combine B and C into BC and de and HL the same, so you actually have 16 registers better than you can use as pointers. for example, in total there are four 16-bit registers that can do some things and seven 8-bit registers plus a special case here, which is the pointed memory location or the value in the memory location pointed to by the HL register that can can be used in place of any register in any instruction, which is pretty cool, so these are the instructions, they are loaded and stored with pretty much the same instruction.
You can indirect, immediate, direct, the stack is 16 bits, you can only send 16 bit registers and these. they are reference and logical, like I said only the accumulator can do most of them except increment and decrement which works on any register and that one also works on 16 bit registers, the rotate instructions control the jump stream call and conditional and indirect return and then some miscellaneous functions are setting the carry, clearing the carry, not stopping it, disabling and allowing interrupt. What is the interrupt model in most systems? At that point you would expect there to be an interrupt vector for all interrupts, but it's not even vector noise, it just one, instead of jumping over a vector, jumps to fixed locations in RAM at the beginning of RAM and to the different types of interrupts jumps at different locations so hex 40 hex 48 and so on and there is also a concept of software interrupts that you can jump to these locations with special instructions and RS t0 is special because it is the same as a reset when you power on an 8080 CPU, it starts at location 0, let's talk about the few features not supported by the 8080, so these are the Game Boy flags. these are the actual flags of the 8080 and it has two by two additional flags, one is the sign flag which is somewhat useful and the parity flag which is not, so none of these instructions are supported and some others for some reason, they simply decided not to include those I/O ports, you may remember that the 8086 has the port space and that is on the 8080, but it is not compatible with Gameboy because it uses memory-mapped I/O, On the other hand, the z80 has many. of set and reset instructions rotation and additional bit flipping and bit testing, all of them are supported as is relative jump instructions which is a more optimized version of a jump and return from interrupts, that's all what is supported, everything that is not supported is all the cool stuff about the z80, which is the second register, sets the two extra registers and many, many features including the auto increment and decrement and loop instructions which are Good for copying memory, but it has some features of its own that take its place, for example, there is a later appearance of increment and decrement, so if you want to access the memory that HL points to, you can post an increment or you can pre -decrease HL.
There is also the concept of a zero page and it is a bit confusing because it is not actually the zero page in RAM, it is the top page in RAM and if you know the 6502, you can see that this is a concept taken from the 6502, it just means that there is optimized instruction encoding for the instructions that are in the four or four memory accesses that are in the top page of RAM, so instead of doing this load from ff4 T, which requires threebytes and four cycles, you can code it like this, it requires two bytes and three cycles and obviously you have to put something useful on the top page. which is time critical, they add some stack instructions, another storage SP instruction, you can swap the low and high bite, they added eight instructions in there and there is an extra power saving instruction, so this is what the opcode table just to get an idea. the color code that you can see is quite orthogonal and there are some instructions that are or some opcodes that are not in use and they all fail, which is a nice design and this one is special, the CB opcode is this prefix that houses another 256 opcode and this is the complete opposite slot for the rotate and shift instructions taken from the z80 plus the extra swap instruction that was added in the game ifLet's look at another instruction here just as an example.
This is a low load from a fixed direction. This means you need three bytes, sixteen clocks, sixteen clocks at four megahertz, but the Internet disagrees whether you should look at four megahertz or one megahertz. because all clock times are divisible by four and this is because in the entire system it is memory limited, the entire CPU is memory limited, so it can only calculate as fast as the memory provides the data, so basically you could say this is a CPU that has a frequency of one megahertz and it takes four clocks with four this and these are much more sensible numbers now because now the numbers are actually comparable to similar systems like based systems ​​​in sixty-five or two that also have a one megahertz memory with a one megahertz CPU.
So in theory, yes, the CPU is clocked at four megahertz, the RAM runs at one megahertz, the PPU draws its pixels, the pixel processing unit at four megahertz and is connected to V RAM which runs at two megahertz, so it's a little complicated here in the system. but most of the time everything works or most numbers can be expressed in terms of a megahertz, but to be exact, it's not exactly a megahertz, maybe it's a hertz as in 1024 times 24 hertz, so no they based it on the factor of ten in base ten, they based it in base two, just nice, and from now on, and if I talk about cycles, I mean machine cycles at one megahertz, so that's the CPU and it's a CPU 16 bits and... but a CPU that has 16 bits. address space because of the 16 bit pointers, so 64 kilobytes of address space is all you can see, that's 32 kilobytes of that is the ROM space that comes from the cartridge, it was just allocated from the cartridge and there is a boot ROM placed on top of that, we will talk later that the video RAM is allocated in the external RAM which can also come from the cartridge optionally, then there is the internal RAM and some empty space that is either unallocated or mirroring just other stuff and if we zoom in on this, You can see at the top there's another OAM RAM page which is like a special purpose video RAM which is different from the video RAM we're going to talk about later and then the last page , which is page zero, contains the I/O. areas or all the registers for peripherals like sound and video plus another 127 bytes of each ram that is different from the other Ram, does this mean that games can only have 32 kilobytes?
Well, some games only need 32 kilobytes. Tetris fits very well into 32 kilobytes. a single chip there and quite simple to manufacture other games can have in practice, I mean, there is no theoretical limit, but in practice the games go up to I think 2 megabytes and this one is 128 kilobytes. The way you achieve this is by adding another memory bank controller. special chip for the cartridge that can change banks and this is common in all types of systems, so in practice these memory bank controllers can be very different, but most of them work this way, the bank most low in memory is always mapped to bank zero of the ROM and the top 16k are mapped to whatever they can map to bank 1, bank 2 and so on, and this is all controlled by writing magic values ​​into ROM locations that will then go to the cartridge and will be intercepted by the memory bank controller, which can then change them.
In banks, the same goes for external RAM if the cartridge wants to expose additional RAM, for example for safe games that have a bad battery. That's the only way to do safe gaming, you can map to external RAM here, same model, so what's up with this? Boot ROM, the CPU starts running at location 0 in memory and the Boot ROM is what draws this and does the ringing. The spud ROM is built into the Game Boy and took a while to remove, it was a real pain that I didn't do it myself. and what it does is this is the full boot ROM, it initializes the RAM, it initializes the sound, it sets up the entity codes, the logo it puts on the screen, it scrolls on the logo, it plays the ringtone and then it It gets interesting, compare the logo because the game has to have a copy of the Nintendo logo inside, if it doesn't match, the game won't start.
This was intended so that Nintendo could control which games are released for the platform because all games had to contain the logo, which is not only a copyright violation but also a trademark violation if you include that and don't have permission. Nintendo after that also checks part of the header just to make sure you don't have to blow on the pins and then it turns off the ROM and continues running there so that Nutella and then that logo is presented from the cartridge so that if you boot up a Game Boy without a cartridge you will see this, but that doesn't mean that an app or a game can put any logo there, but because it compares and at that time it wouldn't put any more and because there was no clearing code, it doesn't reboot the system or anything or clear the screen, which is why some games do something like this. they played with what's on the screen, let's continue with that and of course it's also possible to play with the demo with the Nintendo logo on the screen, let's do something with it, which is pretty good for the boot ROM to be run until last The instruction in the last instructions is the one that turns off the boot ROM, so at this point even the first page of the ROM is mapped to display game data and it continues to run here, so it continues to run on the following game instructions and usually there is a skip there because there is a header that was specified to be there at this location.
I mean, the header contains the Nintendo logo and the header checksum which are important or the other metadata is not really important, it was important to developers back then. for your hardware, but the player doesn't actually check any of this and then you can have the actual game data, so another thing we haven't seen is the I/O and HRM area, which is the top page in the system is page zero which you can access pretty efficiently so the top 127 here are extra RAM and all the others can be distributed here you can see the different devices and these are all the registers in total in the controller of system interruptions. sound controller joypad serial timer and pixel processing unit these are all the components we will talk about now enjoy the paid input it is really very simple these are all the inputs that the Game Boy has its four buttons and four directions so you would think we have 8 GP iOS and with that we can do this but actually we can do it with 6 GP iOS because it is two columns with four rows so you select the column you want to test and then from the row you can read which button was pressed to that they could use 6 instead of 8, that's about the buttons.
Pretty simple serial data transfer. You can connect it to game boards along with a link cable. All the link cable consisted of was a data cable in One Direction. One wire for data in the other direction and a third wire for the clock, the two games had to decide which one sends the clock and which receives the clock, so these are the bits that control this, one sets the clock and so therefore, eight kilohertz the recoil. The clock can really be anything, it can go up to half a megahertz and it will receive it and as soon as the transfers start it will record the bytes and it always goes in both directions at the same time, the timer is whatever system you have. a timer there is only one timer the TM a register the modular register is where you enter the initial value and then you can select one of four different speeds and then you start it and then it counts until it overflows and at the time of overflow it reloads the module number and you can optionally generate an interrupt by talking about interrupts the interrupt controller supports five different interrupts a blank V and an LCD stat drive a pixel processing unit which we will talk about later we have already seen the timer that causes zero interrupts can cause an interrupt when a new byte was received on the joypad when a button was pressed and this was the interrupt enable register and there is the interrupt flag register where you can see which interrupt is still pending and these are the addresses where those different ones jump interruptions So you don't have to figure out what interruption it was because there are some jumps to different locations, so this sound controller doesn't have as many registers as the sound controller because there are four voices and they all have their own distinct register.
This is a better way to look at them four voices and five registers each and those registers have particular meanings about the meanings are approximate because the four voices are not exactly the same they are two very similar that make a pulse and one that does not That is called voice and another is called noise. If you look at the bits here, they are similar but they are not the same, so it depends on the voice what exactly those bits in those registers mean. Let's see what they have in common. and all voices have an activation bit that turns the voice on and you can turn it off again at some point, but there is a length bit and a length register, so you can say off after a quarter of a second, let's look at the wave register . which is the simplest plus, so the idea of ​​wave logs is that you can play any sound wave.
You have these extra 16 bytes of register here, which are 32 entries of 4 bits each and can describe any waveform you want that fits. These twenty in these 32 slots, so here are some examples. You could, for example, create a sawtooth, which is a pretty simple waveform, where you could have a signal or you could just do anything custom, so you're pretty flexible on that and then there's a frequency. which controls the pitch, it simply controls the speed at which the wavetable plays and two additional bits of volume so you can play at 100%, 50%, 25% or you can mute it. The other tool here the two pulse registers the two pulse voices are very similar all these bits are the same and behave the same and you cannot specify a waveform here, the waveform is somewhat fixed, it is always a pulse, which means low and high in different ratios and these two bits determine the relationship between low and high, 12.5 high and the rest. it's bass twenty five percent fifty and then 75 should sound exactly like 25 it's just inverted so you can do this with any of these records and there's also the concept of volume sweep so the volume can go up or down. lowering is the common case to emulate standard instruments or turning up the volume is an interesting effect and only the first pulse voice also has the concept of frequency sweep so you can turn it up or down so you can see this is mainly intended for sound effects and these are some more examples of sound effects that's what you can do with that and there's a fourth voice that can just make noise so this is a shift register that basically generates pseudorandom numbers and depending on if you set to 15-bit mode or seven-bit mode, it will do one of two different waveforms, which is 15-bit mode and 7-bit mode, so these are all the registers again, different voices and three general purpose registers.
This register has a volume for the left volume for the right channel and interestingly cartridges can have their own audio controller which outputs an analog signal which can be connected to this but no game did this and there is another register where you can say if there is a voice on the left. or right on both or neither and then there's the power bit, if you turn off the audio, you'll save about 13 percent power, so not only is the game used or the game, but the sound is not only is. used for games, people still compose music in tools like little sound DJ today on the Game Boy and I'll show you a quick example of that, both for the sound, let's talk about thepixel processing unit, pixel processing, you need something that does graphics, it has twelve registers, which is not a lot, but first let's look at the specifications.
We talked about it before. 160,540 pixels, not so much for shades of gray, which are more like four bad shades of green. Then the Game Boys are much better at everything. on the screen is based on 8x8 tiles and there are a certain amount of tiles on the screen, there are sprites and this all has to do with 8 kilobytes of video RAM. What do I mean when I say 8x8 pixel wheels if we look at a game like Tetris? You can see that everything is in blocks, everything is based on these blocks. Same with Zelda, if we put the grid over it, you can see that there are repeating patterns and they are all aligned with a certain grid.
In Super Mario Land, it's also pretty obvious here, especially since I don't have a lot of these different tiles, even with something like Donkey Kong Land, you can see it as soon as you place the grid on it and there are some repeats and everything is aligned with that although they did a really good job of hiding it and in some games you can see because it plays with that same concept so here in turrican you can see it fills the screen with tiles let's look at the tile and the water tile is like a tile which consists of 8 x 8 pixels and has 4 colors like everything in the system and these colors are encoded 0 0 0 1 1 0 1 1 so let's add that to these pixels and see how the encoding is done if I look at the first line here and I read it as a binary number 0 2 & FF, so for each line of pixels I need 2 bytes and in total I need 16 bytes to describe a complete mosaic.
You may have noticed here that the order of the Colosseum scents makes sense, this is because I can choose my own palette. Be it any palette, there is a two bit - 2 bit mapping in the system for these background tiles, so the native colors are 0 0 means white and 1 1 means black, so I can choose any palette like this. I can also reuse the same colors if I want. that for some purpose there are 256 tiles in the system, so this set of tiles, do you recognize what it is? It's tetris, if you don't recognize those people dancing at the bottom then you haven't finished Tetris, this is Zelda and that is Super Mario Land which is only used under 28 tiles that you can deal with so that anyone recognizes what is this, let's just put something together and we'll see that it's a tennis game, its star tennis and this is the 20 tile by 18 tile puzzle that fills the entire screen. it's not the whole truth because actually in the video RAM there are 32 tiles by 32 towers, this is the full background map and what you see on the screen is just a viewport and it measures 256 by 256 pixels which is nice and convenient because it's how scrolling works by just moving that viewport and we can see that in practice there is a really good emulator that allows you to see what's happening on the background map and how the viewport changes, so basically it's about of a camera that moves a map larger than 32 by 32, but this only works with games that max out at 32 by 32.
What about games that scroll infinitely like Super Mario Land? We can have so many extra columns and we can move the viewport here, but what if we're done? Here at the end, well, it will snap and if we draw columns fast enough just before the viewport reaches them, we can have an infinite world, so in the emulator you can see this quite clearly in the off-screen area of the graphics window. putting in those new columns this also works in two dimensions this is Donkey Kong Land again this looks pretty strange just put those extra columns and lines where they will go so this is a layer we've talked about so far is the background and on top of the background there is another layer that you can optionally put on top of it, it is the window, it can cover it completely or it can start at any location, there is an usually how you use this when you put it too far to the right or you put it too low, it just overlaps this and doesn't respond to the other scroll settings and you guess this is needed for something. like a score displayed at the bottom of the screen this is very nice easy and convenient for games but you can also put it on the right and these are games about color games but it wouldn't matter it works in the game with just also and then there is another layer on top of the background and the window which is a sprite.
Sprites are objects on the screen that do not fit into 8x8 rasters. You can place them freely, so we have three sprites here in the system and I intend to call some objects obj, but I will continue to call them sprites because they all call some sprites. Let's look at this boom bar here and every sprite in the system has attributes and there's the OAM, which is the attribute map of the object and this is an M distance input and it has these values, so one of them is the exposure, so if we placed the Goomba on the far left of the screen, I would expect it to have a horizontal position of zero to the right, but now it's eight, why?
Because if you set it to four, it's here and if you set it to zero, it's here because it's eight pixels wide, you need a way to scroll it and something similar happens at the top of the screen, but in the first wide position where it you see completely. is 16 because sprites can also be up to 16 bits 16 16 pixels tall, so let's put it in its natural location here. The next thing we need to look at is what it should look like, so first of all you can see that it's an 8x8. grid is the same encoding except it also has translucent pixels so code zero zero means translucency and since it is the same encoding it is the same type of tiles and also there are 256 tiles in the system which is one byte and we can see it here. it's the hex 90 tile, next up is the flip expert so you don't have to save it to goombazz.
Here's one that works, the one on the left works clockwise, just flip it horizontally and you have one that works clockwise. flip it vertically and you'll have a dead Goomba, flip it horizontally and vertically and you'll have a dead Goomer walking in the other action, so let's turn it face up again. The next bit is the palette because a combination of pixels, a combination of one bit, means translucency. I only have three more colors for the sprites, which is a shame, so they didn't want to impose three specific colors for this, so for four of the sprites you can choose which three colors of the four you want and all the sprites don't.
I have to share the same three colors because there are two palettes in the system, that's why the sprite also has another flag, do you take palette zero?, palette one, if you take palette one, would you like it to look like this with palette zero? , it looks like this. this and one more bit is priority, so how is the sprite drawn compared to the background? If the priority is one, this is the interesting case: it will draw on top of all those white pixels here, but it will draw on the back of all the non-white ones. -White pixels, but white is nothing special here, that's why there is a background palette.
These are pixels that have a value of zero in the background, so if you choose another palette, the goombah could very well be drawn on top of any other color. if we set the priority to zero it will draw on top of everything except the translucent pixels of course the sprites and the sprite priority there is nothing you can do about it this is always fixed we have this rectangle here and the goombah is on top of the rectangle. which is because the horizontal position of the goombahs is smaller than the rectangles, as soon as there is the same horizontal position, the sprite with a smaller number wins because the sprites are an array in memory, the one that comes before is draw on the one that comes after.
As the white sort angle has a smaller x position than the Goomba, it will be drawn on top of it and you can see this as flickering effects in some games when you walk by other things. There are 40 sprites in the system. You can have 40 sprites. on the screen at the same time, but there is another limitation per line: you can only have 10 sprites, so I have an eleventh sprite here and it only counts per pixel line, so here these pixels will not be drawn on either the next line or on the next line and It's not the eleventh from the left, it's the eleventh visible in the sprite list in the order decided by the program, so this is the full entry for om, it fits perfectly in four bits, so that this is an om entry in memory fe 0 0 is where these entries are stored, there are 40 of them for the 40 sprites and the whole thing is called OAM RAM, which is a special purpose RAM in this memory location that does not It is part of the video RAM.
One more thing I should say about sprites is even a small Mario this is the small one and it's too big for 8x8 sprites so you can make it like 4 sprites and this is what the game really does but there is another way in the that you can have 16 pixel high sprites, but this is global, the whole game would have to deal with 16 pixel high sprites, so we have seen the three different layers, there is one more thing that you can completely turn off the screen, which It is a fifth color that is a little lighter than white. very useful because you have to turn off the entire LCD, so as soon as you turn on the LCD but don't draw a background, you get white if you draw the background and say you want to draw it in light gray and it replaces it completely. color, you can draw a window on top again, there is no translucency here and you can draw sprites on top and notice that the sprites don't distinguish if the pixel is at the bottom of the windows, so there is no clipping in the window, so how does all this work? the memory map four kilobytes of sprite tiles and four kilobytes of background tiles and one kilobyte of the background map the 32 by 32 and we also have a kilobyte of the window map is not the most efficient representation but they did it because it was easier and we only have eight kilobytes of video RAM, so if your purpose is bright tiles here, background tiles here, we've already run out of video RAM, let's try a different way, let's place the sprites here, let's make the background on the map of the window here and what do we do? what we do with the background tiles, we are going to overlap them and that difference comes in figurations here three bits, we can overlap them completely or only partially and we can swap them or have them in the same location, what does this overlap mean?
So this is one set the background tiles to the sprite tiles, they are in the same 8x8 format, two bits per pixel, so they could share the exact same tiles, but you can also place them this way so that the first third of the first 128 are sprite mosaics exclusively. The last 128 would be the background house exclusively and the middle ones would be shared by both and both could use them and in the case of Super Mario Land here you can see that the first two thirds are used for sprites and the last third is used for the background , the next step is vertical sync as in the CRT based system, this is how a normal old CRT system draws its image in a very slow motion version that draws it from top to bottom, left to right and the same. it's true on a gameboy it still draws the image sixty times a second from top to bottom line by line from left to right this wasn't done because they were reusing some old components they completely redid the idea of ​​how this was done but it's still a nail 2d wants be updated 60 times a second and they draw it like this and it's important to know if you want to do certain effects that you can't otherwise do in this game, for example you can see that different parts of the screen behave differently and let's just look at the city scroll line here, it would be easy to have that scroll only on the full screen, but we only want to scroll a portion of the screen and the way this is done is with these additional registers, so if you have seen programming 8 bit on something like a c64 before having seen all this there you can see you can read which line is currently being drawn or which will be drawn in a moment and instead of being busy waiting there you can also set an interrupt to wake it up as soon as a certain line is reached, so let's set the shift register of let's say 23 in the next frame will set it to 24, so we'll scroll and set the comparators to 242 and it will continue to draw here with a certain offset and then we set it. to something else said another LIC, keep drawing like this how exactly the road is drawn here, we'll talk about that later, it's also a fun trick and then we set it to 0 again, but because the board doesn't do any kind ofscroll and we do the same thing on the next screen again in this example, so it's not just about shift register . before the window is drawn from a certain position to the right and to the bottom of the screen, you can't just make it draw halfway, but yes, you can fire on the zero line and turn on the window and they fire again on line 40 and shut down. the window so when you draw a line 40 the PPU will think window which window doesn't know any window so it won't draw any more and you can see this in all types of games.
Some of these tricks can be done with the window, others must be done with screen splitting techniques, if you not only activate certain lines but do something fun on each line, you can do a trick like this so that on the left you can see what that is on the screen on the right. see what is actually happening or what is stored inside the video Ram if you change SC What to do is on each single line you have to write a different SC x value to the SD x register and of course it has to be done on each line.
This image here doesn't show it on every line and the racing game effect is pretty much the same here. this is what you can see in the Ram video, it's just a straight path but it gets distorted at runtime while the image is being drawn, so let's zoom in on this. This is the source and this is what we can see on the screen, so if you ignore it. the sprites here this is the curve you have to use to distort it and these are all the offsets of SC a pattern just like the off road part and this is done by changing the paddle every few lines in a circle and you may even want to go a step further, this rally game here can also overcome the bumps on the road. which is done by choosing not only the horizontal shift register but also the vertical shift register on each line so you can duplicate lines and skip lines and some good calculations will come to that and if you update your vertical shift register in the middle of a line you can do this wobble effect that is two-dimensional, but for that we have to go a little deeper and go into horizontal sync, which happens while drawing a line, so this is the pixel transfer mode of the line.
PPU and it usually takes 43 clocks and this is done for 144 lines, but you can't imagine that at the end of the first line it will immediately draw the first pixel of the next line, that's not what is happening because there is an extra fetch at the beginning of each line which are 20 watches. I'll talk about that in a minute and a 51 clock H blank area. at the end of each line in H blank mode the PPU is idle, it does nothing and there is also a V blank mode when the PPU does nothing between screens, so let's do the math, one line has 114 clocks at one megahertz. 54 lines, so that's that many clocks per screen.
If you divide the base clock by this, you get a refresh rate of fifty-nine point seven Hertz. These four different modes that the PPU can be in, you can read that and the CPU can know that. about that and you can also trigger interrupts based on this, but why would the CPU know? Let's first look at what is happening in these different modes, what is this 20 cycle search at the beginning of each line for each line that the PPU has? to decide which sprites are visible on that line, so that there are 40 total sprites in the system and you have to filter those sprites, you have to find the sprites that are visible on that line and place them in an array of up to ten sprites that are visible there and the logic for that is that the x position cannot be 0 because then it would be invisible and the current line we are drawing must be between the first line of the sprite and the last line of the sprite for it to be added to the sprite array visible and this takes 20 cycles btw in the original game where there was a funny bug here if you do any calculations, any 16 bit calculations with numbers between Fe 0 0 and fe f f which is the pointer to the RAM OM Even if you don't you're accessing RAM, it will destroy it during REM mode, so why else would you need to worry about what happens if you're connected to RAM?
The PPU is connected to the video RAM and our M RAM is special. PP is also connected directly to the om RAM. The CPU can also be connected to the video RAM in order to write to the video RAM, but that is not how it is done. You would need double speed video RAM. Here c64 does it like that, but in the game. boy it has to go through the PPU and there is a big switch for the pp you can say you can't access it right now if you want if the pvp wants to fix it's okay if it reads it gets all the FF at least no nothing bad can happen. but it's also not very useful, so the CPU has to make sure the PPU is in the right mode so it can access all of this during pixel transfer.
You can't access video RAM but you can act but during om search every blank and video and v. blank video ram accesses, ok, if you want to access am ram, you can't do it either in search or during pixel transfer because that's when the sprites are drawn, the PPU needs it to only be able to access at those times, so you have to be very careful at those times while drawing the screen, so basically all this is a bad area for the CPU, you shouldn't do anything important at that time, so for example if you want to move into new columns to the background map, you should do it in blank v where you have the most uninterrupted time and all the game logic, all the game AI can be done while the screen is drawn, but there is a warning here and you can't write the new ones positions of the sprites at this point because an M shape is happening.
So what games usually do is write the new updated sprite information into a shadow om which is just a copy of the OM and then during blank v they copy it to the real om so they copy a block from here from any of those sources to the OEM as a location, this is not to scale, you don't have to do it yourself because there is a DMA function, you just write the block you want to copy to this location, it takes 160 clocks and while it's doing it, the CPU is still running. but you can't access any source in the source address space, so you have to wait, but since that code also has to come from somewhere, the only place you can put it is in H RAM, which is also a good use. pixel pipeline, let's go as deep as it goes to the pigs and the pipeline and this is a cut in the research and some of these things were not known to the public previously.
The FIFO pixel is the core concept of how Gameboy draws its image, so jump somewhere in the middle, we already have some pixels on the LCD, so there are already five offset pixels sent to the LCD and the FIFO pixel , let's say there are few pixels there now in each step, in each four megahertz step, you shift one pixel and send it to the LCD, you shift one pixel, you send it to the LCD, you shift the next one, send it to the LCD screen. You may have noticed here that a green button just turned red because the FIFO pixel has to contain more than eight pixels to be able to change something why we'll get to that now we should get new data and fill the FIFO and that's what is the finder for the finder searches for background tiles and nine 802 is now the position of the map that retrieves it so that it reads the tile number of the background map takes a cycle in the next cycle reads the first part of the data in the second part of the data from the Ram tile because each line of a tile is 16 bits and from there you can build eight new pixels, you start again, you go to the next location and you can place those eight pixels in the top half of the FIFO and then you can keep pushing out those pixels but what doesn't happen is you keep pushing pixels and when you're done you have to fetch some back again of course this is all interleaved and running at the same time so let's look at this real quick the FIFO is running at the same time double speed, so it does two pushes until the search can do one. step, so press, press and we read the first byte of data, press, press and the second part of the data, and at that point you still can't put the data into the FIFO because the FIFO is not empty yet, so you must look for the switches to read. wait two more cycles here and then it will be idle for a while and then it will put the data so if you look at the memory access patterns you can see three reads and one idle three reads and one idle so again the images FIFO. pushes a pixel plug clock to pauses at four megahertz unless it contains more than eight pixels and the search runs at two megahertz three clocks to search for those new eight pixels and stops at the fourth clock unless they are spaced between the five available the scrolling is done very simply let's say we shift three pixels so that everything moves three pixels to the left, the first three pixels are simply discarded and then the next pixel goes here on the LCD screen, so at the end of line this gets interesting because when we want to trigger at 160 the FIFO may contain the next pixels which we won't actually draw and the search is already in the middle of looking for the next tile which we also don't care about so at this point it will just stop all of this. and you've done too much work and we'll be in blank h mode, which is why a line takes 40 40 clocks forty-three clocks instead of 40 clocks more logically if we have a window, let's say the window activates on the position 26 and we are here at 26, the 5-4 has some data, the fetch is somewhere in the middle, it will completely clear the FIFO and then the FIFO will stop because we no longer want those pixels that are already aligned and the fetch will change to the map outside the window and the fetch will restart and then we will do the tiling, we will fetch the data, we will fetch the data and we will get the data from the window, we can put it in the FIFO pixel.
So as soon as those pixels move out of the window, the pixels will be drawn with sprites, there are 10 comparators that fire at position x and let's say here at position 26 we have a sprite at that location and again the pixel FIFO has a lot of pixels and search somewhere in the middle we first temporarily suspend pixel five because it can't take out more pixels, we temporarily change the search to do a sprite search and restart the search to get the sprite information and instead of putting it to the final. we overlay it with the first eight pixels and mix them with the pixels and this explains why the FIFO always has to have eight pixels there because that's how it is mixed in the sprites, this is a stark contrast to other systems, so when you just we press remove pixels at a constant rate until Windows starts, when the window starts the FIFO is cleared, we won't eject pixels for quite some time until the FIFO has the window data again and at what time and at what point it is resumes, so it takes 43 clocks or more depending on what is happening on the sprite screen, it may take even longer.
This is on an LCD based system. You can suspend sending pixels on a CRT-based system. You can't, for example, on a c64, one line always has. have exactly 40 clocks because any pixel that arrives too late will be visually shifted to the right, so it's not completely accurate that we have 40 clocks for pixel transfer, it's more like 43 more and the blank area H is just the line remaining and in practice this is more like it sounds depending on what sprites or background you have, so I wasn't completely honest about how pixel pfeiffer works. It doesn't actually store pixel colors.
What it does store is the information, the original information of the combinations of bits and the font as here it says that there are 9 background pixels and the same thing happens with a search, it does not create pixel colors, it creates those combinations of bits plus the information with what sprite palette was or what was the source, so let's mix These together, the sprite is probably zero, which means draw over the background and let's go over this. There sprite one zero zero means this is translucent, so the background wins. In this case, the sprite wins because it is drawn over the background and this is it.
This is true for most of those pixels and in the last pixel we can see that this is an object with palette 1 + translucent again, so here the background wins again. Let's do this one more time with another object that is in the exact same location on the first one. In this case, the sprite with a zero palette is drawn on top of the background spritewins and in this case a new sprite doesn't beat the old sprite, there is already a sprite at this pixel so the old sprite wins and this is true for everything and this.
This is how sprites that are drawn further to the right are not drawn on top of existing sprites and sprites with higher numbers are not drawn too much on top of existing sprites and this is the last one with a sprite wins again and the handling of the palette is only done at the end when the pixel moves out, so we look for it here in the palette, convert it to a color and put it in TLS LCD, lock it, convert it in LCD another black and that's how also done in the color system, so starting with the super Gameboy, existing games that couldn't really handle this could be colored and what was done there, the three existing palettes can now be RGB palettes, everything else in the system is the same, but as soon as we change this it looks for RGB color it puts a pink pixel on the screen 11s one that is here black pixel one more example 0 1 of s 1 because it used to be an object with palette 1 put it on the screen that It's the end of the technical part we have five more minutes, let's talk about development in case you are now interested in developing Game Boy, there are some really good tools, the Rednex Game Boy development system is a set of command line tools that work great with makefiles and your editor of choice when you want to debug your code, the bgb emulator, which is designed for Windows, but works great with Wine on OS 10 or Linux, plus it has a built-in debugger with one-step breakpoints and it has this very very nice REM video viewer that shows all the details about what's happening.
It's also great to run demos and see what's going on inside. If you want to run it on real hardware, there are devices like Everdrive where you can install it. an SD card and since we have another four minutes, let's talk about my favorite Game Boy peripheral, the Game Boy camera, but not from the point of view of how cool this device is, the Game Boy camera, you put it on the back part. of Game Boy takes really nice pictures you can print them on the Game Boy printer on thermal paper if you can still get that paper and you can get these ones you make you can take amazing pictures like that let's zoom in a little these are really nice pictures every picture is based on the CCD that has 14 kilopixels at a depth of 2 bits, so next time you go on a trip, make sure you bring a Gameboy, a game book, don't forget your Game Boy camera and a PC with a parallel port and that link cable you can't get on eBay anymore, so thanks to the people who helped debug the Game Boy and helped me with a presentation and to the people who helped me in other ways on the Ultimate series. talks this was now the fifth talk what's next there should be a talk next year right I'm suggesting two talks I'm nominating 43230 for c3 Dominic vogner to talk about Acorn Archimedes and I nominate Yanni more difficult well Super Nintendo is your choice you can do these talks or you can put a bucket of ice water on top of your head, thank you for your attention and see you next year so that

If you have any copyright issue, please Contact