0 00:00:00,000 --> 00:00:30,000 Dear viewer, these subtitles were generated by a machine via the service Trint and therefore are (very) buggy. If you are capable, please help us to create good quality subtitles: https://c3subtitles.de/talk/757 Thanks! 1 00:00:13,860 --> 00:00:16,139 So the next talk, 2 00:00:16,140 --> 00:00:18,269 I'm really looking forward to this, and I 3 00:00:18,270 --> 00:00:20,699 know why the most 4 00:00:20,700 --> 00:00:22,230 most of you are here. 5 00:00:24,210 --> 00:00:26,759 Because I'm excited about this, too. 6 00:00:26,760 --> 00:00:29,849 I own a Gameboy 7 00:00:29,850 --> 00:00:31,979 and I'm really proud of it and I 8 00:00:31,980 --> 00:00:34,139 have it in my flat 9 00:00:34,140 --> 00:00:36,299 and on special occasions I take it 10 00:00:36,300 --> 00:00:38,729 out. Well, nowadays, I use an emulator 11 00:00:38,730 --> 00:00:41,009 for sure, and I only have ROMs 12 00:00:41,010 --> 00:00:42,929 of cartridges I really own. 13 00:00:45,930 --> 00:00:46,930 Well, that is. 14 00:00:50,060 --> 00:00:52,409 That is how it's supposed to work, right? 15 00:00:53,760 --> 00:00:56,279 Yeah, and I'm 16 00:00:56,280 --> 00:00:57,899 looking forward to this. 17 00:00:57,900 --> 00:01:00,179 By the way, I'm my favorite 18 00:01:00,180 --> 00:01:02,639 games on a game boy, the the first 19 00:01:02,640 --> 00:01:04,400 one to make that clear, 20 00:01:05,640 --> 00:01:08,009 our Megaman two Vario 21 00:01:08,010 --> 00:01:10,639 Land and Mystic Quest. 22 00:01:10,640 --> 00:01:12,839 And and who 23 00:01:12,840 --> 00:01:14,279 does not agree with this? 24 00:01:14,280 --> 00:01:16,349 Well, you don't know me that 25 00:01:16,350 --> 00:01:17,350 good then. 26 00:01:18,450 --> 00:01:20,789 So we go to the 27 00:01:20,790 --> 00:01:22,919 talk of the ultimate 28 00:01:22,920 --> 00:01:24,719 game boy talk. 29 00:01:24,720 --> 00:01:26,669 I'm really looking forward to this. 30 00:01:26,670 --> 00:01:28,769 Uh, yeah. 31 00:01:28,770 --> 00:01:31,019 We have a speaker, Michael 32 00:01:31,020 --> 00:01:33,239 Style, and he held a 33 00:01:33,240 --> 00:01:35,589 really great talk at twenty five 34 00:01:35,590 --> 00:01:38,069 C three, the ultimate 35 00:01:38,070 --> 00:01:40,499 Commodore 64 talk. 36 00:01:40,500 --> 00:01:42,869 And now with the ultimate game boy 37 00:01:42,870 --> 00:01:45,059 talk. I'm really looking forward to this 38 00:01:45,060 --> 00:01:47,159 Michael style. By day, he works on 39 00:01:47,160 --> 00:01:49,049 operating system technology. 40 00:01:49,050 --> 00:01:51,629 By night, he hacks obsolete systems. 41 00:01:51,630 --> 00:01:53,849 In a previous life, he hacked 42 00:01:53,850 --> 00:01:56,279 game consoles, police, a big 43 00:01:56,280 --> 00:01:57,689 round of applause. 44 00:01:57,690 --> 00:01:59,489 Michael, the stage is yours. 45 00:02:07,500 --> 00:02:09,948 Hello, hello, everyone, 46 00:02:09,949 --> 00:02:11,409 again, my name is Michael Steele, and 47 00:02:11,410 --> 00:02:13,030 this is the ultimate game boy talk. 48 00:02:22,690 --> 00:02:24,699 The idea of the talk is to talk as much 49 00:02:24,700 --> 00:02:26,199 as possible about all the different 50 00:02:26,200 --> 00:02:27,669 hardware details, everything that I can 51 00:02:27,670 --> 00:02:29,439 fit into 60 Minutes, everything about the 52 00:02:29,440 --> 00:02:31,509 game, Gameboy, 60 Minutes, 53 00:02:31,510 --> 00:02:33,849 I have about 200 slides, over 54 00:02:33,850 --> 00:02:36,129 800 individual builds. 55 00:02:36,130 --> 00:02:37,749 So maybe the information density is a 56 00:02:37,750 --> 00:02:39,459 little higher than normal. 57 00:02:39,460 --> 00:02:41,859 So let's get started real quick. 58 00:02:41,860 --> 00:02:43,719 The Gameboy talk is in the context of a 59 00:02:43,720 --> 00:02:45,219 series of talks that I have started eight 60 00:02:45,220 --> 00:02:47,259 years ago with the ultimate Commodore 64 61 00:02:47,260 --> 00:02:49,359 talk and other people have picked that up 62 00:02:49,360 --> 00:02:50,889 and talked about the Atari twenty six 63 00:02:50,890 --> 00:02:53,109 hundred, the Galaxy and the Amiga 64 00:02:53,110 --> 00:02:53,619 five hundred. 65 00:02:53,620 --> 00:02:54,699 And so it's my turn now 66 00:02:55,930 --> 00:02:57,369 again. 67 00:02:57,370 --> 00:02:58,809 And I think the Gameboy. 68 00:02:58,810 --> 00:03:01,389 Why is the game boy so interesting? 69 00:03:01,390 --> 00:03:02,859 Because they solve lots and lots of 70 00:03:02,860 --> 00:03:04,689 systems. Game boy, game boy, color one 71 00:03:04,690 --> 00:03:06,429 hundred eighteen million alone. 72 00:03:06,430 --> 00:03:08,019 And if you count the Gameboy Advance 73 00:03:08,020 --> 00:03:10,569 models that are compatible, excluding 74 00:03:10,570 --> 00:03:12,589 the game boy micro in total it's almost 75 00:03:12,590 --> 00:03:14,709 two hundred million systems that have 76 00:03:14,710 --> 00:03:16,749 made sixteen hundred, about sixteen 77 00:03:16,750 --> 00:03:17,750 hundred official games 78 00:03:19,330 --> 00:03:20,859 and they produced it from nineteen eighty 79 00:03:20,860 --> 00:03:23,469 nine, just the models until 2003. 80 00:03:23,470 --> 00:03:25,419 And again if you count the compatable 81 00:03:25,420 --> 00:03:28,179 Gameboy Advance models, they made 82 00:03:28,180 --> 00:03:30,399 a compatible gaming systems until 83 00:03:30,400 --> 00:03:31,719 two thousand nine. So that's a twenty 84 00:03:31,720 --> 00:03:32,949 year run, which is pretty amazing. 85 00:03:34,720 --> 00:03:36,849 Let's look at the competition back then 86 00:03:36,850 --> 00:03:37,899 just after the game. 87 00:03:37,900 --> 00:03:40,209 Boy, the Atari really still links Sega 88 00:03:40,210 --> 00:03:42,879 the game gear and see the Turbo Express. 89 00:03:42,880 --> 00:03:44,439 All of these had one thing in common. 90 00:03:44,440 --> 00:03:46,539 They had a color screen, pretty 91 00:03:46,540 --> 00:03:48,519 good color screen, but they also had one 92 00:03:48,520 --> 00:03:49,989 thing in common, which was really bad 93 00:03:49,990 --> 00:03:51,639 battery life of maybe three to five hours 94 00:03:51,640 --> 00:03:53,469 while a Gameboy had fifteen to thirty 95 00:03:53,470 --> 00:03:54,459 hours. 96 00:03:54,460 --> 00:03:56,259 But the compromise was it had a screen 97 00:03:56,260 --> 00:03:57,789 that looked like this and you could 98 00:03:57,790 --> 00:03:59,349 hardly make out anything really as soon 99 00:03:59,350 --> 00:04:00,350 as it starts scrolling. 100 00:04:01,810 --> 00:04:03,909 This is not the case with all the models 101 00:04:03,910 --> 00:04:05,829 of the Gameboy of which there are many. 102 00:04:05,830 --> 00:04:07,299 The original Gameboy and the original 103 00:04:07,300 --> 00:04:08,589 design, which was produced for the 104 00:04:08,590 --> 00:04:10,639 longest time, is the DMG. 105 00:04:10,640 --> 00:04:12,729 DMG stands for DOT Matrix Game, which 106 00:04:12,730 --> 00:04:14,289 was the original codename. 107 00:04:14,290 --> 00:04:15,669 Then in ninety six they released their 108 00:04:15,670 --> 00:04:17,289 game by pocket, which had a much better 109 00:04:17,290 --> 00:04:19,449 screen, much smaller. 110 00:04:19,450 --> 00:04:21,549 The MGB Gameboy Light was only 111 00:04:21,550 --> 00:04:23,739 released in Japan. It had a backlight and 112 00:04:23,740 --> 00:04:25,859 then the Gameboy color with twice the 113 00:04:25,860 --> 00:04:27,939 speed and twice the ram and twice the 114 00:04:27,940 --> 00:04:29,259 video ram and support. 115 00:04:31,300 --> 00:04:32,829 Then the Gameboy Advance series. 116 00:04:32,830 --> 00:04:33,789 They were completely different 117 00:04:33,790 --> 00:04:35,599 architecture. They were based on an arm 118 00:04:35,600 --> 00:04:38,079 CPU, but still they were on one hundred 119 00:04:38,080 --> 00:04:39,369 percent backwards, compatible with 120 00:04:39,370 --> 00:04:41,169 Gameboy and Gameboy color games. 121 00:04:41,170 --> 00:04:43,239 The events as part of 122 00:04:43,240 --> 00:04:45,009 that one two models exist. 123 00:04:45,010 --> 00:04:46,179 If you want to get one, you really need 124 00:04:46,180 --> 00:04:48,579 to get the one on one, 125 00:04:48,580 --> 00:04:49,929 which is the one with a backlight instead 126 00:04:49,930 --> 00:04:50,930 of the front light. 127 00:04:51,880 --> 00:04:53,919 And as you can see, Nintendo has always 128 00:04:53,920 --> 00:04:55,239 been ahead of its time a little. 129 00:04:55,240 --> 00:04:56,499 That didn't only make a rose colored 130 00:04:56,500 --> 00:04:58,269 version, but also you need an adapter to 131 00:04:58,270 --> 00:04:59,320 plug in regular headphones. 132 00:05:05,740 --> 00:05:08,139 If you want to play a game, boy games on 133 00:05:08,140 --> 00:05:10,209 a regular TV set, the two options 134 00:05:10,210 --> 00:05:12,399 for that, either you use a Super Nintendo 135 00:05:12,400 --> 00:05:13,989 and plug in the super Gameboy, the two 136 00:05:13,990 --> 00:05:15,459 versions of that one only be released in 137 00:05:15,460 --> 00:05:17,019 Japan, which had the proper timing, 138 00:05:17,020 --> 00:05:19,089 didn't run three percent too fast as the 139 00:05:19,090 --> 00:05:21,129 original one and the Gameboy player 140 00:05:22,240 --> 00:05:24,339 for the Nintendo Game Cube and all 141 00:05:24,340 --> 00:05:26,109 of these had complete Gameboy hardware 142 00:05:26,110 --> 00:05:27,519 embedded inside, basically a normal 143 00:05:27,520 --> 00:05:29,109 Gameboy. And it just it puts its pixel 144 00:05:29,110 --> 00:05:30,459 into the whole system instead of on the 145 00:05:30,460 --> 00:05:31,460 screen. 146 00:05:32,380 --> 00:05:34,269 So what does a Gameboy like as a two 147 00:05:34,270 --> 00:05:36,349 point six inch screen department 148 00:05:36,350 --> 00:05:38,109 or speaker? You can get stereo over the 149 00:05:38,110 --> 00:05:39,309 headphones. 150 00:05:39,310 --> 00:05:40,839 There's a link connector serial port to 151 00:05:40,840 --> 00:05:42,879 connect to game boys together, contrast 152 00:05:42,880 --> 00:05:45,159 and volume. And on the back, 153 00:05:45,160 --> 00:05:47,199 this is where the game goes and this is 154 00:05:47,200 --> 00:05:48,250 where you put in your batteries 155 00:05:49,420 --> 00:05:50,799 and this is what the game looks like. 156 00:05:50,800 --> 00:05:52,119 And the basically most games are really 157 00:05:52,120 --> 00:05:53,799 just rom chips. There's nothing more to 158 00:05:53,800 --> 00:05:54,800 it 159 00:05:55,900 --> 00:05:57,159 specifications. 160 00:05:57,160 --> 00:05:58,459 What are the specifications of the game 161 00:05:58,460 --> 00:06:00,009 when let's compare the Gameboy to some 162 00:06:00,010 --> 00:06:01,539 other systems that may or may not be 163 00:06:01,540 --> 00:06:02,439 comparable. 164 00:06:02,440 --> 00:06:04,049 The CPU is a one megahertz eight, but 165 00:06:04,050 --> 00:06:05,769 suppose some people in the audience may 166 00:06:05,770 --> 00:06:07,209 complain at this point and say no, it's a 167 00:06:07,210 --> 00:06:09,009 four megahertz Tipu. But I'll explain 168 00:06:09,010 --> 00:06:10,799 later while I call it one megahertz CPU. 169 00:06:11,900 --> 00:06:13,629 That's a better friend, which is plenty 170 00:06:13,630 --> 00:06:15,339 for a gaming system of that type. 171 00:06:15,340 --> 00:06:17,539 VRM of kilobytes is a little tight. 172 00:06:17,540 --> 00:06:19,389 The resolution of one hundred and sixty, 173 00:06:19,390 --> 00:06:20,979 but one hundred and forty four is really 174 00:06:20,980 --> 00:06:23,079 poor. But at a screen this size you 175 00:06:23,080 --> 00:06:25,029 don't really notice that much. 176 00:06:25,030 --> 00:06:27,339 It can do four simultaneous colors, which 177 00:06:27,340 --> 00:06:29,589 is four four shades of gray, 178 00:06:29,590 --> 00:06:31,689 and it supports up to 10 sprites per 179 00:06:31,690 --> 00:06:32,769 line. 180 00:06:32,770 --> 00:06:34,599 So if you compare all this to these other 181 00:06:34,600 --> 00:06:36,699 systems here, it's clear that 182 00:06:36,700 --> 00:06:38,709 the Gameboy is way more advanced. 183 00:06:38,710 --> 00:06:40,479 For example, Ontari. Twenty six hundred. 184 00:06:40,480 --> 00:06:42,519 But it's not at all in the league of 185 00:06:42,520 --> 00:06:43,419 Super Nintendo. 186 00:06:43,420 --> 00:06:45,279 It's more like an Sunia and more like a 187 00:06:45,280 --> 00:06:47,229 standard Nintendo entertainment system or 188 00:06:47,230 --> 00:06:48,609 a Commodore 64. 189 00:06:48,610 --> 00:06:50,979 But the fun thing here is that while the 190 00:06:50,980 --> 00:06:52,959 S and the C 64 were released in the early 191 00:06:52,960 --> 00:06:55,329 80s, the Gameboy is from eighty nine. 192 00:06:55,330 --> 00:06:57,759 And as I said, Compatible Hardware was 193 00:06:57,760 --> 00:07:00,069 was supported and released until 194 00:07:00,070 --> 00:07:01,209 2009. 195 00:07:01,210 --> 00:07:02,379 So that's what makes it really 196 00:07:02,380 --> 00:07:03,429 interesting. 197 00:07:03,430 --> 00:07:04,719 It's an eight bit system, but it's really 198 00:07:04,720 --> 00:07:06,789 the latest, the last eight 199 00:07:06,790 --> 00:07:08,740 bit system that was in common use. 200 00:07:10,540 --> 00:07:12,759 Let's look inside 201 00:07:12,760 --> 00:07:13,809 on the right. The board on the right 202 00:07:13,810 --> 00:07:15,129 isn't very interesting. If you look at it 203 00:07:15,130 --> 00:07:16,899 from the front, this is where the LCD 204 00:07:16,900 --> 00:07:19,119 connected speaker and the buttons, 205 00:07:19,120 --> 00:07:21,339 the button, the board 206 00:07:21,340 --> 00:07:23,739 on the back is much more interesting. 207 00:07:23,740 --> 00:07:25,749 This is where you can see three chips. 208 00:07:25,750 --> 00:07:27,459 So this is the DMG, the original Gameboy 209 00:07:27,460 --> 00:07:29,619 board to ram chips, two identical RAM 210 00:07:29,620 --> 00:07:31,659 chips. One is for CPU ramp, one is for 211 00:07:31,660 --> 00:07:32,889 video RAM. 212 00:07:32,890 --> 00:07:34,899 And this one big chip here, it's called 213 00:07:34,900 --> 00:07:37,089 the DMG CPU, but it really is the 214 00:07:37,090 --> 00:07:39,039 see the system on a chip. 215 00:07:39,040 --> 00:07:41,589 So what you would regularly 216 00:07:41,590 --> 00:07:43,929 expect to be lots of chips in a computer 217 00:07:43,930 --> 00:07:45,519 system like that. Everything is 218 00:07:45,520 --> 00:07:47,259 integrated into just a single chip, which 219 00:07:47,260 --> 00:07:48,260 is the Gameboy chip. 220 00:07:49,510 --> 00:07:51,579 Let's compare some other boys to the 221 00:07:51,580 --> 00:07:52,839 super Gameboy. 222 00:07:52,840 --> 00:07:53,889 It has a very similar chip. 223 00:07:53,890 --> 00:07:55,209 It's actually really ninety nine point 224 00:07:55,210 --> 00:07:57,009 nine percent identical. 225 00:07:58,210 --> 00:08:00,579 The Gameboy Pocket is then 226 00:08:00,580 --> 00:08:03,039 is a slightly optimized model 227 00:08:03,040 --> 00:08:04,689 that comes only with one round trip for 228 00:08:04,690 --> 00:08:06,099 both the Gameboy like you might have 229 00:08:06,100 --> 00:08:08,409 seen. It's not actually any different. 230 00:08:08,410 --> 00:08:10,419 It's just another MGB from the MGB 231 00:08:10,420 --> 00:08:12,549 series, but it comes with a backlight. 232 00:08:12,550 --> 00:08:14,049 And then there's the super Gameboy, too, 233 00:08:14,050 --> 00:08:16,599 which is based on the Gameboy Pocket. 234 00:08:16,600 --> 00:08:18,369 And this is what the Gameboy color looks 235 00:08:18,370 --> 00:08:19,269 like on the inside. 236 00:08:19,270 --> 00:08:20,739 They all have this one gigantic chip that 237 00:08:20,740 --> 00:08:21,740 does everything. 238 00:08:22,420 --> 00:08:23,889 But what is this one? This is a special 239 00:08:23,890 --> 00:08:25,809 one. You may not recognize it from the 240 00:08:25,810 --> 00:08:26,979 markings. 241 00:08:26,980 --> 00:08:29,179 This thing is called the boy. 242 00:08:29,180 --> 00:08:30,699 There have been companies closing the 243 00:08:30,700 --> 00:08:32,408 game, but all the time. And what this 244 00:08:32,409 --> 00:08:34,749 particular model is, is it's a perfect 245 00:08:34,750 --> 00:08:37,089 clone from copying and photographing 246 00:08:37,090 --> 00:08:40,119 and redoing that mask of the original 247 00:08:40,120 --> 00:08:41,649 Soucy here. 248 00:08:41,650 --> 00:08:43,869 And it's a Chinese 249 00:08:43,870 --> 00:08:46,059 Gameboy that you can still buy today 250 00:08:46,060 --> 00:08:47,619 for like thirty, forty bucks or so on 251 00:08:47,620 --> 00:08:48,620 eBay. 252 00:08:49,120 --> 00:08:50,799 It's a shame that the courts are 30 253 00:08:50,800 --> 00:08:52,509 percent too fast, so none of the games 254 00:08:52,510 --> 00:08:53,510 are playable. 255 00:08:56,050 --> 00:08:58,299 Let's go back to the board. 256 00:08:58,300 --> 00:08:59,949 So the DMG CPU is the thing that we're 257 00:08:59,950 --> 00:09:01,839 really interested in that does everything 258 00:09:01,840 --> 00:09:03,669 on this system. What is included in the 259 00:09:03,670 --> 00:09:05,739 DMG CPU while the regular C.P.U 260 00:09:05,740 --> 00:09:07,299 core interrupt controller time and 261 00:09:07,300 --> 00:09:08,769 memory? But from what you would expect 262 00:09:08,770 --> 00:09:10,479 from something like that, and then all 263 00:09:10,480 --> 00:09:13,089 the peripheral devices like the IO 264 00:09:13,090 --> 00:09:15,189 iPad input, serial data transfer 265 00:09:15,190 --> 00:09:16,899 for the link cable, that sound controller 266 00:09:16,900 --> 00:09:18,129 and a video controller, the pixel 267 00:09:18,130 --> 00:09:19,130 processing unit. 268 00:09:20,080 --> 00:09:21,489 So let's talk about the CPU. 269 00:09:21,490 --> 00:09:23,619 Historically, the Gameboy 270 00:09:23,620 --> 00:09:25,689 from nineteen eighty nine was 271 00:09:25,690 --> 00:09:27,969 released between the US and 272 00:09:27,970 --> 00:09:29,659 the Supreme. 273 00:09:29,660 --> 00:09:31,809 The S and the 274 00:09:31,810 --> 00:09:33,399 S came with a sixty five vote to 275 00:09:33,400 --> 00:09:35,739 Supernus, came with a sixty five 276 00:09:35,740 --> 00:09:37,059 eight sixteen which is the sixteen bit 277 00:09:37,060 --> 00:09:38,350 version of that same CPU. 278 00:09:39,490 --> 00:09:40,989 So obviously the Gameboy comes with a 279 00:09:40,990 --> 00:09:42,789 sharp LR three five nine oh two. 280 00:09:44,290 --> 00:09:46,449 What is the sharp L are a three five 281 00:09:46,450 --> 00:09:47,889 nine oh two core. 282 00:09:47,890 --> 00:09:49,449 It's nothing like a sixty five or two, 283 00:09:49,450 --> 00:09:51,549 it's more like somewhere in between an 284 00:09:51,550 --> 00:09:53,799 intel. Eighty eighty and a dialog eighty. 285 00:09:53,800 --> 00:09:55,929 But it's neither and both these 286 00:09:55,930 --> 00:09:57,279 architectures are interesting because the 287 00:09:57,280 --> 00:09:59,349 eighty eighty was for example used 288 00:09:59,350 --> 00:10:00,909 in the Altair, which is the first 289 00:10:00,910 --> 00:10:02,379 computer that Bill Gates wrote software 290 00:10:02,380 --> 00:10:03,879 for and released it for. 291 00:10:03,880 --> 00:10:06,159 And the Zetas and pretty much every 292 00:10:06,160 --> 00:10:08,319 computer home computer system 293 00:10:08,320 --> 00:10:10,329 that did not contain a 65 or to very 294 00:10:10,330 --> 00:10:11,350 successful architecture. 295 00:10:12,700 --> 00:10:14,889 So if you imagine this is the 296 00:10:14,890 --> 00:10:17,199 feature set of the Intel 80 80, that's 297 00:10:17,200 --> 00:10:18,699 the feature set of the dialog. 298 00:10:18,700 --> 00:10:19,839 So it's a strict superset. 299 00:10:19,840 --> 00:10:21,370 It's perfectly backwards compatible. 300 00:10:25,120 --> 00:10:27,219 And that is the Gameboy, 301 00:10:27,220 --> 00:10:28,220 if you. 302 00:10:30,310 --> 00:10:32,499 They're the core architecture is the same 303 00:10:32,500 --> 00:10:34,479 as the one from the 80 80, so all the 304 00:10:34,480 --> 00:10:36,069 core features are the register set to the 305 00:10:36,070 --> 00:10:38,259 instruction, encoding everything. 306 00:10:38,260 --> 00:10:39,999 All that is the same. 307 00:10:40,000 --> 00:10:41,049 But there are some features that are not 308 00:10:41,050 --> 00:10:43,149 supported, but it does support 309 00:10:43,150 --> 00:10:45,249 some zaidee features, but it does 310 00:10:45,250 --> 00:10:47,439 not support most of the Zedi features. 311 00:10:47,440 --> 00:10:48,819 And then they added a few features on 312 00:10:48,820 --> 00:10:49,820 top. 313 00:10:50,590 --> 00:10:52,359 Let's walk through that. 314 00:10:52,360 --> 00:10:54,489 So let's talk about the core architecture 315 00:10:54,490 --> 00:10:56,019 of the first. 316 00:10:56,020 --> 00:10:58,269 It has these registers accumulator, 317 00:10:58,270 --> 00:10:59,499 which is special. It's the one that can 318 00:10:59,500 --> 00:11:00,699 do all the arithmetic and logic. 319 00:11:00,700 --> 00:11:01,749 You cannot do this with the other 320 00:11:01,750 --> 00:11:02,709 registers. 321 00:11:02,710 --> 00:11:03,759 Flags register. 322 00:11:03,760 --> 00:11:06,009 It only has two useful flaks, the zero 323 00:11:06,010 --> 00:11:08,919 and the Kerry flag in the Gameboy model. 324 00:11:08,920 --> 00:11:10,329 The other two are only used for decimal 325 00:11:10,330 --> 00:11:11,330 adjust. And then there's 326 00:11:12,520 --> 00:11:13,929 another and another set of eight 327 00:11:13,930 --> 00:11:15,099 registers. 328 00:11:15,100 --> 00:11:17,019 But the fun thing about those is that you 329 00:11:17,020 --> 00:11:19,209 can combine B and C into A, B, C 330 00:11:19,210 --> 00:11:21,069 and D, E and the same thing. 331 00:11:21,070 --> 00:11:23,469 So you actually have 16 better registers 332 00:11:23,470 --> 00:11:24,609 that you can use as pointers, for 333 00:11:24,610 --> 00:11:25,929 example. 334 00:11:25,930 --> 00:11:28,059 So in total there for 16, 335 00:11:28,060 --> 00:11:30,669 but registers that can do some things and 336 00:11:30,670 --> 00:11:32,799 seven, eight bed registers plus 337 00:11:32,800 --> 00:11:34,989 one special case here, which is the 338 00:11:34,990 --> 00:11:37,239 memory location pointed to or the 339 00:11:37,240 --> 00:11:39,399 value at the memory location pointed to 340 00:11:39,400 --> 00:11:41,379 by the register, which can be used in 341 00:11:41,380 --> 00:11:44,169 place of any register in any 342 00:11:44,170 --> 00:11:46,089 in any instruction, which is pretty nice. 343 00:11:47,350 --> 00:11:49,329 So these are the instructions. 344 00:11:49,330 --> 00:11:51,609 There's the load in stores by practically 345 00:11:51,610 --> 00:11:53,469 the same instruction you can in direct, 346 00:11:53,470 --> 00:11:55,749 immediate direct 347 00:11:55,750 --> 00:11:57,939 stack is 16 but can only 348 00:11:57,940 --> 00:12:00,119 push 16 registers. 349 00:12:00,120 --> 00:12:01,929 And these are the printing and logic 350 00:12:01,930 --> 00:12:03,909 ones. As I said, only the accumulator can 351 00:12:03,910 --> 00:12:05,589 do most of those except for incrementing 352 00:12:05,590 --> 00:12:06,789 and incrementing, which works in any 353 00:12:06,790 --> 00:12:09,849 register. And that one also works on 354 00:12:09,850 --> 00:12:11,829 16. But registers that rotate 355 00:12:11,830 --> 00:12:14,349 instructions, controls flow, just call 356 00:12:14,350 --> 00:12:16,539 and return conditional and 357 00:12:16,540 --> 00:12:18,309 indirect and then some miscellaneous 358 00:12:18,310 --> 00:12:20,139 functions, setting the carriage, clearing 359 00:12:20,140 --> 00:12:22,239 the carry, not polt and disabling 360 00:12:22,240 --> 00:12:24,399 it, enabling to interrupt. 361 00:12:24,400 --> 00:12:27,489 What is the interrupt model 362 00:12:27,490 --> 00:12:28,749 on most systems. 363 00:12:28,750 --> 00:12:29,979 And that time you would expect there's an 364 00:12:29,980 --> 00:12:32,169 interrupt vector for all the interrupts, 365 00:12:32,170 --> 00:12:34,239 but it's neither a veteran nor is it just 366 00:12:34,240 --> 00:12:35,499 one. 367 00:12:35,500 --> 00:12:37,149 Instead of jumping over a vector, it 368 00:12:37,150 --> 00:12:39,219 jumps to fixed locations in RAM at 369 00:12:39,220 --> 00:12:41,409 the beginning of RAM and for 370 00:12:41,410 --> 00:12:42,429 the different kinds of interrupts it 371 00:12:42,430 --> 00:12:43,839 jumps at different locations to hex, 372 00:12:43,840 --> 00:12:46,059 forty hex, forty eight and so on. 373 00:12:46,060 --> 00:12:48,009 And there's also a concept of software 374 00:12:48,010 --> 00:12:49,389 interrupts. You can jump to these 375 00:12:49,390 --> 00:12:51,519 locations with special instructions and 376 00:12:51,520 --> 00:12:53,709 Oreste zero is a special one because this 377 00:12:53,710 --> 00:12:54,909 is the same as a reset. 378 00:12:54,910 --> 00:12:57,129 When you turn on an eighty eight CPU, 379 00:12:57,130 --> 00:12:58,490 it starts at location zero. 380 00:13:00,790 --> 00:13:02,679 Let's talk about the few unsupported 381 00:13:02,680 --> 00:13:04,269 eighty eighty features. 382 00:13:04,270 --> 00:13:05,859 So these are the flags of the Gameboy. 383 00:13:05,860 --> 00:13:07,299 These are the actual flags of the eighty 384 00:13:07,300 --> 00:13:09,429 eighty. And it has to for two 385 00:13:09,430 --> 00:13:11,499 extra flags. One is the same flag which 386 00:13:11,500 --> 00:13:13,029 is kind of useful, and the Perati flag, 387 00:13:13,030 --> 00:13:14,679 which is not so nice. 388 00:13:14,680 --> 00:13:17,139 None of these instructions are supported 389 00:13:17,140 --> 00:13:18,639 and a few others for some reason they 390 00:13:18,640 --> 00:13:21,469 just decided not to include those 391 00:13:21,470 --> 00:13:22,599 IO. 392 00:13:22,600 --> 00:13:24,219 You may remember that from eighty from 393 00:13:24,220 --> 00:13:26,079 the eighty, eighty six it has the support 394 00:13:26,080 --> 00:13:27,999 space. That one is in the eighty eighty 395 00:13:28,000 --> 00:13:29,259 but it's not supported on the Gameboy 396 00:13:29,260 --> 00:13:30,969 because it uses memory map. 397 00:13:30,970 --> 00:13:34,299 Instead, the Zaydi 398 00:13:34,300 --> 00:13:36,519 has lots of extra rotate 399 00:13:36,520 --> 00:13:38,919 and shift and pretesting setting 400 00:13:38,920 --> 00:13:40,929 and resetting instructions. 401 00:13:40,930 --> 00:13:43,449 All of those are supported as are, 402 00:13:43,450 --> 00:13:45,519 as is the relative instruction which 403 00:13:45,520 --> 00:13:47,739 is a more optimized version of a jump 404 00:13:47,740 --> 00:13:48,879 and the return from Interop. 405 00:13:48,880 --> 00:13:50,679 That's all that is supported. 406 00:13:50,680 --> 00:13:52,329 Everything that is not supported is all 407 00:13:52,330 --> 00:13:54,129 the interesting stuff from the Zaidee, 408 00:13:54,130 --> 00:13:55,779 which is the second register said the 409 00:13:55,780 --> 00:13:57,999 extra two registers and lots and lots 410 00:13:58,000 --> 00:14:00,099 of features, including the order 411 00:14:00,100 --> 00:14:01,329 increment and decrement and loop 412 00:14:01,330 --> 00:14:03,129 instructions, which are nice for copying 413 00:14:03,130 --> 00:14:05,289 memory, but it has a few features 414 00:14:05,290 --> 00:14:08,079 of its own that to take their place. 415 00:14:08,080 --> 00:14:09,080 For example, 416 00:14:10,360 --> 00:14:11,519 there's a post increment. 417 00:14:11,520 --> 00:14:14,049 And so if you want to access memory 418 00:14:14,050 --> 00:14:16,119 that is pointed to by you 419 00:14:16,120 --> 00:14:18,949 can post increment or you can predicament 420 00:14:18,950 --> 00:14:19,950 HL. 421 00:14:21,040 --> 00:14:23,049 There's also the concept of a zero page 422 00:14:23,050 --> 00:14:24,549 and it's a little confusing because it's 423 00:14:24,550 --> 00:14:26,169 not actually page zero and it's the 424 00:14:26,170 --> 00:14:27,609 topmost page in RAM. 425 00:14:27,610 --> 00:14:29,019 And if you know the sixty five or two you 426 00:14:29,020 --> 00:14:30,909 can see this is a concept borrowed from 427 00:14:30,910 --> 00:14:32,139 the sixty five or two. 428 00:14:32,140 --> 00:14:33,849 It just means that there's an optimized 429 00:14:33,850 --> 00:14:35,649 instruction encoding for instructions 430 00:14:35,650 --> 00:14:37,779 that are in the four for memory 431 00:14:37,780 --> 00:14:39,699 accesses that are in the topmost page of 432 00:14:39,700 --> 00:14:41,949 RAM. So instead of doing this 433 00:14:41,950 --> 00:14:44,079 loading from forty, which takes three 434 00:14:44,080 --> 00:14:46,359 bytes and four cycles, you can encoded 435 00:14:46,360 --> 00:14:48,339 like this takes two bytes and three 436 00:14:48,340 --> 00:14:49,340 cycles. 437 00:14:50,260 --> 00:14:51,459 And obviously you have to put something 438 00:14:51,460 --> 00:14:52,959 useful up there in the topmost page, 439 00:14:52,960 --> 00:14:55,089 which is timing critical that if 440 00:14:55,090 --> 00:14:57,519 you stack instructions and other stories, 441 00:14:57,520 --> 00:14:59,499 instruction, you can swap the low and the 442 00:14:59,500 --> 00:15:01,839 high nable. They added eight instructions 443 00:15:01,840 --> 00:15:04,029 there and there's an extra 444 00:15:04,030 --> 00:15:05,709 power saving instruction. 445 00:15:05,710 --> 00:15:07,149 So this is what the code table looks 446 00:15:07,150 --> 00:15:09,279 like. Just to get an idea from the color 447 00:15:09,280 --> 00:15:11,469 coding, you can see this is quite 448 00:15:11,470 --> 00:15:13,929 orthogonal and there are few instructions 449 00:15:13,930 --> 00:15:15,759 that are or a few op codes that are not 450 00:15:15,760 --> 00:15:17,319 in use and they all crash, which is a 451 00:15:17,320 --> 00:15:18,609 nice design. 452 00:15:18,610 --> 00:15:20,679 And this one 453 00:15:20,680 --> 00:15:22,509 is special. The OP code KB is the same 454 00:15:22,510 --> 00:15:24,549 prefix which hosts another two hundred 455 00:15:24,550 --> 00:15:25,959 and fifty six of codes. 456 00:15:25,960 --> 00:15:28,289 This is the complete space for the. 457 00:15:28,290 --> 00:15:30,179 Rotate and shift instructions borrowed 458 00:15:30,180 --> 00:15:32,429 from the Zaydi, plus the additional swap 459 00:15:32,430 --> 00:15:34,019 instruction that was added on the game, 460 00:15:34,020 --> 00:15:35,309 both of you. 461 00:15:35,310 --> 00:15:37,049 Let's look at another instruction here. 462 00:15:37,050 --> 00:15:39,029 Just as an example. 463 00:15:39,030 --> 00:15:41,219 This is a low load from a fixed 464 00:15:41,220 --> 00:15:42,220 address. 465 00:15:42,750 --> 00:15:45,089 This means it takes three bytes, sixteen 466 00:15:45,090 --> 00:15:47,399 clocks, sixteen clocks at four megahertz. 467 00:15:47,400 --> 00:15:49,709 But the Internet disagrees whether 468 00:15:49,710 --> 00:15:51,449 it should be looked at at four megahertz 469 00:15:51,450 --> 00:15:53,279 or at one megahertz, because all the 470 00:15:53,280 --> 00:15:55,529 clock times are 471 00:15:55,530 --> 00:15:56,999 divisible by four. 472 00:15:57,000 --> 00:15:59,129 And this is because the whole system 473 00:15:59,130 --> 00:16:00,779 is memory bound. The whole CPU is memory 474 00:16:00,780 --> 00:16:01,169 bound. 475 00:16:01,170 --> 00:16:03,419 So it can only calculate as fast 476 00:16:03,420 --> 00:16:05,849 as memory is providing 477 00:16:05,850 --> 00:16:07,019 the data. 478 00:16:07,020 --> 00:16:09,419 So basically you could just as well say 479 00:16:09,420 --> 00:16:11,189 this is a few that is clocked at one 480 00:16:11,190 --> 00:16:13,439 megahertz and it takes four clocks 481 00:16:13,440 --> 00:16:14,939 for this. And these are much smaller 482 00:16:14,940 --> 00:16:16,289 numbers now because now the numbers are 483 00:16:16,290 --> 00:16:18,029 actually comparable with similar systems 484 00:16:18,030 --> 00:16:19,589 like sixty five or two based systems 485 00:16:21,330 --> 00:16:23,459 that also have one megahertz memory 486 00:16:23,460 --> 00:16:24,389 with one megahertz. 487 00:16:24,390 --> 00:16:27,239 If you. So in theory, yes, the CPU 488 00:16:27,240 --> 00:16:29,039 is clock with four megahertz, but the RAM 489 00:16:29,040 --> 00:16:31,109 Rams at one megahertz, the CPU 490 00:16:31,110 --> 00:16:33,059 draws its pixels, the pixel processing 491 00:16:33,060 --> 00:16:34,829 unit at four megahertz and it's connected 492 00:16:34,830 --> 00:16:36,749 to VRAM that is running a two megahertz. 493 00:16:36,750 --> 00:16:38,549 So it's a little complicated here in the 494 00:16:38,550 --> 00:16:40,709 system, but most of the time everything 495 00:16:40,710 --> 00:16:42,779 runs or most of the numbers 496 00:16:42,780 --> 00:16:44,939 can be expressed in terms of 497 00:16:44,940 --> 00:16:45,959 one megahertz. 498 00:16:45,960 --> 00:16:48,329 But to be exact, 499 00:16:48,330 --> 00:16:50,399 it's not exactly one megahertz, it's one 500 00:16:50,400 --> 00:16:52,589 maybe Hertz as in ten to twenty 501 00:16:52,590 --> 00:16:54,449 four times twenty four hertz. 502 00:16:54,450 --> 00:16:56,579 So they didn't base it on fact 503 00:16:56,580 --> 00:16:57,689 or on base 10. 504 00:16:57,690 --> 00:16:59,939 They based on these two, just 505 00:16:59,940 --> 00:17:00,940 pretty. 506 00:17:01,320 --> 00:17:02,909 And so from now on, if I speak about 507 00:17:02,910 --> 00:17:04,769 cycles, I mean machine cycles at one 508 00:17:04,770 --> 00:17:05,770 megahertz. 509 00:17:07,730 --> 00:17:09,799 So that's the issue, and it's a 510 00:17:09,800 --> 00:17:11,929 16 that's Dipu and it's Tipu that 511 00:17:11,930 --> 00:17:13,729 has a sixteen bit address space because 512 00:17:13,730 --> 00:17:16,039 of the 16 pointers, so 64 513 00:17:16,040 --> 00:17:18,108 kilobytes of address space 514 00:17:18,109 --> 00:17:19,459 is all it can see. 515 00:17:19,460 --> 00:17:21,618 It's 32 kilobytes of that is the 516 00:17:21,619 --> 00:17:23,328 rom space that comes from the cartridge. 517 00:17:23,329 --> 00:17:25,279 It's just mapped in from the cartridge 518 00:17:25,280 --> 00:17:27,409 and there's a buttram lying on top of 519 00:17:27,410 --> 00:17:29,689 that that we'll talk about later. 520 00:17:29,690 --> 00:17:31,729 Video Ram is mapped in external ram that 521 00:17:31,730 --> 00:17:32,959 can also come from the cartridge 522 00:17:32,960 --> 00:17:34,279 optionally. 523 00:17:34,280 --> 00:17:36,409 Then there's the internal ram and 524 00:17:36,410 --> 00:17:38,389 some empty space, which is unassigned or 525 00:17:38,390 --> 00:17:40,009 is mirroring just other things. 526 00:17:40,010 --> 00:17:42,079 And if we zoom into this, we can see 527 00:17:42,080 --> 00:17:44,389 at the top there is another 528 00:17:44,390 --> 00:17:46,579 page of OEM RAM, which is like a special 529 00:17:46,580 --> 00:17:48,739 purpose video ram that is distinct 530 00:17:48,740 --> 00:17:50,149 from the video RAM that we'll talk about 531 00:17:50,150 --> 00:17:51,169 later. 532 00:17:51,170 --> 00:17:53,299 And then the last page, which is the zero 533 00:17:53,300 --> 00:17:54,829 page, contains the area. 534 00:17:54,830 --> 00:17:56,539 So all the registers for the peripherals 535 00:17:56,540 --> 00:17:58,999 like sound and video, plus another 536 00:17:59,000 --> 00:18:01,249 hundred and twenty seven bytes of 537 00:18:01,250 --> 00:18:02,390 each ram, which is 538 00:18:03,440 --> 00:18:05,509 distinct from the other ram. 539 00:18:05,510 --> 00:18:06,859 So does this mean that games can only 540 00:18:06,860 --> 00:18:08,539 have 32 kilobytes? 541 00:18:08,540 --> 00:18:10,579 Well, some games only need 32 kilobytes. 542 00:18:10,580 --> 00:18:12,649 Tetris fits nicely into 32 kilobytes. 543 00:18:12,650 --> 00:18:15,229 There's a single chip. They're pretty 544 00:18:15,230 --> 00:18:16,759 simple to manufacture. 545 00:18:16,760 --> 00:18:19,429 Other games can have in practice. 546 00:18:19,430 --> 00:18:20,899 I mean, there's no theoretical limit, but 547 00:18:20,900 --> 00:18:22,429 in practice, games go up to, I think, two 548 00:18:22,430 --> 00:18:23,430 megabytes. 549 00:18:23,960 --> 00:18:25,709 This one is 128 kilobytes. 550 00:18:25,710 --> 00:18:27,649 The way it achieves that is by adding 551 00:18:27,650 --> 00:18:29,539 another memory bank control a special 552 00:18:29,540 --> 00:18:31,849 chip to the cartridge, which can switch 553 00:18:31,850 --> 00:18:33,209 banks. 554 00:18:33,210 --> 00:18:35,359 This is common on all kinds of system. 555 00:18:35,360 --> 00:18:37,129 So in practice, well, these memory bank 556 00:18:37,130 --> 00:18:39,139 controllers can be very different, but 557 00:18:39,140 --> 00:18:41,149 most of them work something like this. 558 00:18:41,150 --> 00:18:43,279 The lowest bank in 559 00:18:43,280 --> 00:18:45,619 memory always maps to banks of the room 560 00:18:45,620 --> 00:18:47,899 and the upper 16 K map 561 00:18:47,900 --> 00:18:50,029 to whatever they can map to bank one bank 562 00:18:50,030 --> 00:18:51,439 too, and so on. 563 00:18:51,440 --> 00:18:53,509 And all this is controlled 564 00:18:53,510 --> 00:18:55,759 by writing magic values into 565 00:18:55,760 --> 00:18:57,439 ROM locations, which then we'll go to the 566 00:18:57,440 --> 00:18:59,059 cartridge, be intercepted by the memory 567 00:18:59,060 --> 00:19:00,619 bank controller, which then can switch 568 00:19:00,620 --> 00:19:01,519 those banks. 569 00:19:01,520 --> 00:19:03,409 The same is true with the external RAM. 570 00:19:03,410 --> 00:19:06,379 If the cartridge wants to 571 00:19:06,380 --> 00:19:08,539 expose extra ram, for example, for safe 572 00:19:08,540 --> 00:19:10,519 games that are the battery backed, that's 573 00:19:10,520 --> 00:19:11,690 the only way to do safe games. 574 00:19:12,920 --> 00:19:14,839 It can map an external ram here. 575 00:19:14,840 --> 00:19:15,840 Same model. 576 00:19:16,550 --> 00:19:18,739 So what's up with this from 577 00:19:18,740 --> 00:19:21,049 the CPU starts running at 578 00:19:21,050 --> 00:19:23,209 location zero in memory and the Buderim 579 00:19:23,210 --> 00:19:25,639 is the thing that draws this 580 00:19:25,640 --> 00:19:26,640 and does the time. 581 00:19:27,500 --> 00:19:29,329 This spectrum is built into the Gameboy 582 00:19:29,330 --> 00:19:31,609 and took a while until this was 583 00:19:31,610 --> 00:19:34,099 extracted was a real pain, not 584 00:19:34,100 --> 00:19:35,239 me. 585 00:19:35,240 --> 00:19:36,859 And what it does is this is a complete 586 00:19:36,860 --> 00:19:38,899 goodrum initializes, ram, initializes 587 00:19:38,900 --> 00:19:41,029 sound setup and decodes the 588 00:19:41,030 --> 00:19:42,779 logo that it puts on the screen that it 589 00:19:42,780 --> 00:19:44,029 scrolls in the logo. 590 00:19:44,030 --> 00:19:45,889 It placed the time and then it gets 591 00:19:45,890 --> 00:19:48,319 interesting. It compares the logo 592 00:19:48,320 --> 00:19:50,569 because the game has to have a copy 593 00:19:50,570 --> 00:19:52,609 of that Nintendo logo inside. 594 00:19:52,610 --> 00:19:54,799 If that if it doesn't match, the game 595 00:19:54,800 --> 00:19:57,109 does not put this was meant so that 596 00:19:57,110 --> 00:19:59,209 Nintendo could control which games are 597 00:19:59,210 --> 00:20:00,529 released for the platform because all 598 00:20:00,530 --> 00:20:02,329 games had to contain the logo, which is 599 00:20:02,330 --> 00:20:03,829 not just a copyright violation, but also 600 00:20:03,830 --> 00:20:05,119 a trademark violation. 601 00:20:05,120 --> 00:20:07,129 If if you include that and you don't have 602 00:20:07,130 --> 00:20:08,130 Nintendo's permission 603 00:20:09,620 --> 00:20:11,899 after that, it also checks the header 604 00:20:11,900 --> 00:20:14,029 just to make sure that you don't have to 605 00:20:14,030 --> 00:20:16,249 blow into the pins and then 606 00:20:16,250 --> 00:20:17,839 it turns off the ROM and continuous 607 00:20:17,840 --> 00:20:19,249 execution in there. 608 00:20:19,250 --> 00:20:21,319 So then 609 00:20:21,320 --> 00:20:23,450 that logo, though, is actually 610 00:20:25,070 --> 00:20:26,449 presented from the cartridge. 611 00:20:26,450 --> 00:20:28,519 So if you put up a Gameboy without a 612 00:20:28,520 --> 00:20:30,349 cartridge, you will see this. 613 00:20:30,350 --> 00:20:31,789 So but that doesn't mean that an 614 00:20:31,790 --> 00:20:33,859 application or a game can put any logo in 615 00:20:33,860 --> 00:20:35,809 there, but because it does get compared 616 00:20:35,810 --> 00:20:37,279 and at that point it wouldn't put any 617 00:20:37,280 --> 00:20:38,280 further. 618 00:20:39,260 --> 00:20:41,329 And since that's there was no clean up 619 00:20:41,330 --> 00:20:42,769 code, it doesn't reset the system or 620 00:20:42,770 --> 00:20:43,909 anything or clear the screen. 621 00:20:43,910 --> 00:20:45,349 So some games to something like this, 622 00:20:45,350 --> 00:20:47,029 they played with what's on the screen. 623 00:20:47,030 --> 00:20:48,319 Let's just continue with that. 624 00:20:48,320 --> 00:20:50,329 And of course, Demo was also like to play 625 00:20:50,330 --> 00:20:51,979 with that, the Nintendo logos on the 626 00:20:51,980 --> 00:20:53,660 screen. Let's just do something with it. 627 00:20:59,060 --> 00:21:00,060 Which is pretty nice. 628 00:21:01,490 --> 00:21:03,169 So the Buderim runs and runs until the 629 00:21:03,170 --> 00:21:04,699 last instruction and the last instruction 630 00:21:04,700 --> 00:21:06,349 is the one that turns off the Buderim. 631 00:21:06,350 --> 00:21:08,419 So at this point, even the first 632 00:21:08,420 --> 00:21:10,489 pigeon rom is mapped to 633 00:21:10,490 --> 00:21:12,679 show game data and it continues 634 00:21:12,680 --> 00:21:14,389 running here. So it's just continuous 635 00:21:14,390 --> 00:21:16,069 running into the next instructions from 636 00:21:16,070 --> 00:21:18,049 the game. And usually there's a jump 637 00:21:18,050 --> 00:21:20,089 there because there's a header that that 638 00:21:20,090 --> 00:21:21,950 is specified to be there at this location 639 00:21:23,480 --> 00:21:24,889 that had a contender contains the 640 00:21:24,890 --> 00:21:26,899 Nintendo logo and the header check, some 641 00:21:26,900 --> 00:21:28,009 which are important. All the other 642 00:21:28,010 --> 00:21:29,359 metadata is not really important. 643 00:21:29,360 --> 00:21:31,189 It was important for the developers back 644 00:21:31,190 --> 00:21:33,109 then for their hardware, but the game 645 00:21:33,110 --> 00:21:34,429 does not actually check any of this. 646 00:21:34,430 --> 00:21:35,989 And after that, you can have the actual 647 00:21:37,400 --> 00:21:38,400 game data. 648 00:21:39,440 --> 00:21:40,579 So one of the things that we haven't 649 00:21:40,580 --> 00:21:42,949 looked at is the Iowa area and atrium, 650 00:21:42,950 --> 00:21:45,049 which is the topmost page 651 00:21:45,050 --> 00:21:47,179 in the 652 00:21:47,180 --> 00:21:48,829 in the system. It's the zero page, the 653 00:21:48,830 --> 00:21:50,899 one that you can access 654 00:21:50,900 --> 00:21:52,159 quite efficiently. 655 00:21:52,160 --> 00:21:54,289 So the top one twenty seven here 656 00:21:54,290 --> 00:21:56,659 are extra ram and all the rest 657 00:21:56,660 --> 00:21:58,069 you can sprinkled throughout here. 658 00:21:58,070 --> 00:22:00,469 You can see the different devices and 659 00:22:00,470 --> 00:22:02,059 these are all the registers total in the 660 00:22:02,060 --> 00:22:03,319 system. Interrupt control of sound 661 00:22:03,320 --> 00:22:05,479 controller, joy, serial timer and 662 00:22:05,480 --> 00:22:06,499 pixel processing unit. 663 00:22:06,500 --> 00:22:08,119 These are all the components that we'll 664 00:22:08,120 --> 00:22:10,429 talk about now. 665 00:22:10,430 --> 00:22:11,359 TripIt input. 666 00:22:11,360 --> 00:22:12,889 It's really simple. 667 00:22:12,890 --> 00:22:14,569 This is these are all the inputs. 668 00:22:14,570 --> 00:22:16,369 The game has its four buttons and four 669 00:22:16,370 --> 00:22:18,259 directions. So you would think, let's 670 00:22:18,260 --> 00:22:19,699 have eight. 671 00:22:19,700 --> 00:22:21,349 And with that, we can do this. 672 00:22:21,350 --> 00:22:23,869 But we can actually do it with Scorpio's 673 00:22:23,870 --> 00:22:26,419 because it's two columns with four rows. 674 00:22:26,420 --> 00:22:28,069 So you select the column that you want to 675 00:22:28,070 --> 00:22:30,349 test and then from the row you can read 676 00:22:30,350 --> 00:22:32,579 what the what button was pressed so 677 00:22:32,580 --> 00:22:35,029 they could do with six instead of eight. 678 00:22:35,030 --> 00:22:36,049 That's all about the buttons. 679 00:22:36,050 --> 00:22:38,269 Pretty simple serial data 680 00:22:38,270 --> 00:22:39,229 transfer. 681 00:22:39,230 --> 00:22:40,669 You can connect to getting both together 682 00:22:40,670 --> 00:22:41,719 with a link cable. 683 00:22:41,720 --> 00:22:43,279 Everything that can link cable consisted 684 00:22:43,280 --> 00:22:45,499 of was one wire of data 685 00:22:45,500 --> 00:22:46,909 in the one direction, one wire, four data 686 00:22:46,910 --> 00:22:48,799 in the other direction and a third wire 687 00:22:48,800 --> 00:22:50,149 for the clock. 688 00:22:50,150 --> 00:22:51,739 The two chambers had to decide which one 689 00:22:51,740 --> 00:22:53,509 is sending the clock and which one is 690 00:22:53,510 --> 00:22:54,799 receiving the clock. 691 00:22:54,800 --> 00:22:57,079 So these are the bits that control this 692 00:22:57,080 --> 00:22:58,699 one sets the clock and it's always eight 693 00:22:58,700 --> 00:23:00,889 kilohertz. The receding clock can 694 00:23:00,890 --> 00:23:02,569 really be anything. It can be go up to a 695 00:23:02,570 --> 00:23:04,099 half a megahertz and it will receive it. 696 00:23:04,100 --> 00:23:06,049 And as soon as the transfer started, it 697 00:23:06,050 --> 00:23:07,999 will clock the bytes through and it 698 00:23:08,000 --> 00:23:09,049 always goes both directions. 699 00:23:09,050 --> 00:23:10,050 At the same time, 700 00:23:11,810 --> 00:23:13,889 the timer is any system. 701 00:23:13,890 --> 00:23:16,369 It has a timer. There's only one timer 702 00:23:16,370 --> 00:23:18,079 them to register. 703 00:23:18,080 --> 00:23:20,239 The modular register is where you put in 704 00:23:20,240 --> 00:23:22,669 the start value and then you can 705 00:23:22,670 --> 00:23:25,159 select one of four different speeds. 706 00:23:25,160 --> 00:23:26,959 And then you started and then it counts 707 00:23:26,960 --> 00:23:28,639 up until it overflows. 708 00:23:28,640 --> 00:23:31,459 And at the overflow time it reloads 709 00:23:31,460 --> 00:23:33,589 the module number and 710 00:23:33,590 --> 00:23:35,989 can optionally generate and interrupt. 711 00:23:35,990 --> 00:23:37,699 Speaking of interrupts, the interrupt 712 00:23:37,700 --> 00:23:39,619 controller supports five different 713 00:23:39,620 --> 00:23:41,729 interrupts v blenkin the LCD 714 00:23:41,730 --> 00:23:43,879 stat deal with the pixel processing 715 00:23:43,880 --> 00:23:45,319 unit. We'll talk about those later. 716 00:23:45,320 --> 00:23:47,029 We've already seen the timer causing 717 00:23:47,030 --> 00:23:48,499 interrupt. Serial can cause an interrupt 718 00:23:48,500 --> 00:23:50,189 when a new byte has been received and 719 00:23:50,190 --> 00:23:52,519 dropped when a button has been pressed 720 00:23:52,520 --> 00:23:54,409 and this was interrupted navel register. 721 00:23:54,410 --> 00:23:56,689 And that's the interlocked flag register 722 00:23:56,690 --> 00:23:58,159 where you can see which interrupt is 723 00:23:58,160 --> 00:23:59,539 still pending. 724 00:23:59,540 --> 00:24:01,129 And these are the addresses where those 725 00:24:01,130 --> 00:24:02,239 different interrupts jumps. 726 00:24:02,240 --> 00:24:04,339 So there's you don't have to find out 727 00:24:04,340 --> 00:24:06,109 which interrupted was because the two 728 00:24:06,110 --> 00:24:07,220 jumps to different locations. 729 00:24:08,690 --> 00:24:10,729 So the sound controller, sound 730 00:24:10,730 --> 00:24:13,009 controller, nothing has as many 731 00:24:13,010 --> 00:24:15,439 registers as the sound controller 732 00:24:15,440 --> 00:24:17,119 because there's four voices and they all 733 00:24:17,120 --> 00:24:19,489 have their distinct registers. 734 00:24:19,490 --> 00:24:21,169 So this is a better way to look at them. 735 00:24:21,170 --> 00:24:23,299 Four voices and 736 00:24:23,300 --> 00:24:24,589 five registers each. 737 00:24:26,300 --> 00:24:29,359 And those registers have particular 738 00:24:29,360 --> 00:24:30,360 meanings, 739 00:24:31,610 --> 00:24:33,709 but the meanings are rough because 740 00:24:33,710 --> 00:24:35,809 the four voices are not exactly the same. 741 00:24:35,810 --> 00:24:37,849 There are two very similar ones that do a 742 00:24:37,850 --> 00:24:39,949 pulse and one that does that. 743 00:24:39,950 --> 00:24:41,149 That is called voice. And one of those is 744 00:24:41,150 --> 00:24:42,559 called noise. 745 00:24:42,560 --> 00:24:44,719 If you look at the bits here, 746 00:24:44,720 --> 00:24:46,159 they are similar, but they're not the 747 00:24:46,160 --> 00:24:47,359 same. So it depends on the voice. 748 00:24:47,360 --> 00:24:48,679 What exactly those bits in those 749 00:24:48,680 --> 00:24:50,119 registers mean. 750 00:24:50,120 --> 00:24:52,189 Let's look at the ones that are in 751 00:24:52,190 --> 00:24:53,239 common. 752 00:24:53,240 --> 00:24:55,189 All the voices have a trigger bit which 753 00:24:55,190 --> 00:24:57,289 turns on the voice and you 754 00:24:57,290 --> 00:24:58,729 could just turn it off again at some 755 00:24:58,730 --> 00:25:00,829 point. But there's a 756 00:25:00,830 --> 00:25:02,539 length, a bit and a length register. 757 00:25:02,540 --> 00:25:04,849 So you can just say it turned off after 758 00:25:04,850 --> 00:25:05,850 quarter second. 759 00:25:06,980 --> 00:25:08,689 And let's look at the wave register, 760 00:25:08,690 --> 00:25:10,819 which is the simplest one in addition. 761 00:25:10,820 --> 00:25:12,889 So the idea of the wave register is that 762 00:25:12,890 --> 00:25:14,929 you can play any sound wave. 763 00:25:14,930 --> 00:25:17,569 It has these extra sixteen 764 00:25:17,570 --> 00:25:19,759 bytes of register here, which is thirty 765 00:25:19,760 --> 00:25:21,499 two entries of four bits each. 766 00:25:21,500 --> 00:25:23,719 And these can describe any waveform 767 00:25:23,720 --> 00:25:25,699 that you like that fits into these twenty 768 00:25:25,700 --> 00:25:26,700 introduced thirty two 769 00:25:27,890 --> 00:25:29,649 slots. So here are some examples. 770 00:25:29,650 --> 00:25:30,889 So you could for example create a 771 00:25:30,890 --> 00:25:31,890 sawtooth. 772 00:25:36,140 --> 00:25:37,669 Which is a pretty simple waveform where 773 00:25:37,670 --> 00:25:39,049 you could have a sign. 774 00:25:43,870 --> 00:25:46,000 Or you could just do anything custom. 775 00:25:50,910 --> 00:25:53,099 So you're pretty flexible at that, and 776 00:25:53,100 --> 00:25:54,509 then there's the frequency which controls 777 00:25:54,510 --> 00:25:56,579 the pitch, just controls how fast that 778 00:25:56,580 --> 00:25:59,099 wave table is played 779 00:25:59,100 --> 00:26:00,779 and two extra bits of volume so you can 780 00:26:00,780 --> 00:26:01,979 play 100 percent, 50 percent. 781 00:26:01,980 --> 00:26:03,539 Twenty five percent, or you can mute it. 782 00:26:05,790 --> 00:26:07,709 The other two hear the two pulse 783 00:26:07,710 --> 00:26:09,359 registers, the two pulse voices that are 784 00:26:09,360 --> 00:26:10,949 very similar. 785 00:26:10,950 --> 00:26:12,449 All these bits are the same and behave 786 00:26:12,450 --> 00:26:13,450 the same. 787 00:26:13,950 --> 00:26:15,419 You cannot specify a waveform. 788 00:26:15,420 --> 00:26:17,069 Hear the waveform is kind of fixed. 789 00:26:17,070 --> 00:26:19,169 It's always a pulse, meaning low and 790 00:26:19,170 --> 00:26:21,239 high in different 791 00:26:21,240 --> 00:26:23,759 ratios. And these two bits 792 00:26:23,760 --> 00:26:25,530 determine the ratio between low and high. 793 00:26:27,780 --> 00:26:30,179 Twelve point five higher and 794 00:26:30,180 --> 00:26:31,180 the rest is low. 795 00:26:33,320 --> 00:26:34,320 Twenty five percent. 796 00:26:36,630 --> 00:26:38,609 Fifty and then seventy five should sound 797 00:26:38,610 --> 00:26:39,839 exactly like twenty five, it's just 798 00:26:39,840 --> 00:26:40,840 inverted. 799 00:26:44,360 --> 00:26:46,009 So you can do this with either of these 800 00:26:46,010 --> 00:26:48,139 registers and there's also the concept 801 00:26:48,140 --> 00:26:50,389 of volume sweep so the volume 802 00:26:50,390 --> 00:26:52,279 can go up or the volume can go down, 803 00:26:52,280 --> 00:26:54,859 volume going down is the common case for 804 00:26:54,860 --> 00:26:56,119 emulating standard instruments. 805 00:26:58,790 --> 00:27:00,589 Or the volume going up is an interesting 806 00:27:00,590 --> 00:27:01,590 effect. 807 00:27:04,510 --> 00:27:06,819 And only the first 808 00:27:06,820 --> 00:27:09,009 pulse voice also has the concept 809 00:27:09,010 --> 00:27:11,139 of a frequency sweep 810 00:27:11,140 --> 00:27:12,399 so you can go up. 811 00:27:14,890 --> 00:27:16,990 Or you can go down the. 812 00:27:18,690 --> 00:27:20,099 So you can see this is mostly meant for 813 00:27:20,100 --> 00:27:21,359 sound effects and these are some more 814 00:27:21,360 --> 00:27:22,380 examples of sound effects. 815 00:27:25,760 --> 00:27:27,979 That's what you can do with that, and 816 00:27:27,980 --> 00:27:29,839 there's a fourth voice that can only do 817 00:27:29,840 --> 00:27:31,999 noise, so this is a shift 818 00:27:32,000 --> 00:27:34,579 register that basically generates 819 00:27:34,580 --> 00:27:36,259 pseudo random numbers. 820 00:27:36,260 --> 00:27:38,419 And depending on whether you 821 00:27:38,420 --> 00:27:40,699 said it's to 15 bot mode or seven 822 00:27:40,700 --> 00:27:42,650 mode, it will do one. 823 00:27:43,740 --> 00:27:45,380 We'll do one of two different waveforms. 824 00:27:48,080 --> 00:27:49,219 That's 15. But most. 825 00:27:51,620 --> 00:27:52,669 And that seven bit mode, 826 00:27:54,110 --> 00:27:55,489 so these are all the registers, again, 827 00:27:56,720 --> 00:27:58,579 different voices and three 828 00:27:58,580 --> 00:28:00,979 general-purpose registers, this register 829 00:28:00,980 --> 00:28:02,719 has a Volume four left, volume four right 830 00:28:02,720 --> 00:28:05,059 channel. And interestingly, cartridges 831 00:28:05,060 --> 00:28:07,519 can have their own audio controller 832 00:28:07,520 --> 00:28:09,709 that outputs an analog signal that can 833 00:28:09,710 --> 00:28:10,639 be hooked up into this. 834 00:28:10,640 --> 00:28:12,799 But no game ever did this. 835 00:28:12,800 --> 00:28:14,989 And there is 836 00:28:14,990 --> 00:28:17,539 another register we can say, should a 837 00:28:17,540 --> 00:28:18,769 voice be on the left or the right? 838 00:28:18,770 --> 00:28:20,959 On the right, on both or neither. 839 00:28:20,960 --> 00:28:22,759 And then there's the power bit. 840 00:28:22,760 --> 00:28:25,189 If you turn off the power to audio, 841 00:28:25,190 --> 00:28:26,809 you will save like 13 percent or so of 842 00:28:26,810 --> 00:28:27,810 energy. 843 00:28:28,340 --> 00:28:30,589 So the game 844 00:28:30,590 --> 00:28:32,209 is not only used or is the game, but 845 00:28:32,210 --> 00:28:33,889 sound is not only used for games. 846 00:28:33,890 --> 00:28:36,049 People still compose music in tools 847 00:28:36,050 --> 00:28:38,569 like a little sound today on the Gameboy 848 00:28:38,570 --> 00:28:40,460 and also your short example of that. 849 00:29:14,690 --> 00:29:15,690 So much, 850 00:29:17,120 --> 00:29:18,120 so much for. 851 00:29:19,010 --> 00:29:20,509 Let's talk about the pixel processing 852 00:29:20,510 --> 00:29:22,609 unit, the pixel processing unit is the 853 00:29:22,610 --> 00:29:24,259 thing that makes graphics. 854 00:29:24,260 --> 00:29:25,999 It has 12 registers, which is not quite a 855 00:29:26,000 --> 00:29:27,000 lot. 856 00:29:27,380 --> 00:29:28,849 But let's look at the specifications 857 00:29:28,850 --> 00:29:29,999 first. We talked about it before. 858 00:29:30,000 --> 00:29:31,099 One hundred and sixty. One hundred and 859 00:29:31,100 --> 00:29:32,479 forty pixels, not that much. 860 00:29:32,480 --> 00:29:34,789 Four shades of gray, which is more like 861 00:29:34,790 --> 00:29:36,140 four bad shades of green 862 00:29:37,540 --> 00:29:39,229 little Gameboy that much better. 863 00:29:39,230 --> 00:29:41,479 Everything on the screen is tile based 864 00:29:41,480 --> 00:29:42,679 and there are a certain number of tiles 865 00:29:42,680 --> 00:29:44,389 on the screen, the sprites and all this 866 00:29:44,390 --> 00:29:45,769 has to deal with eight kilobytes of 867 00:29:45,770 --> 00:29:47,929 video. Ram, what do I mean when I say 868 00:29:47,930 --> 00:29:49,849 eight by eight pixel tiles? 869 00:29:49,850 --> 00:29:51,469 If we look at a game like Tetris, you can 870 00:29:51,470 --> 00:29:53,449 see everything's blocky, everything's 871 00:29:53,450 --> 00:29:55,189 based on these blocks. 872 00:29:55,190 --> 00:29:56,929 Same with Zelda. If we put the grid over 873 00:29:56,930 --> 00:29:58,999 it, you can see there repeating patterns 874 00:29:59,000 --> 00:30:00,949 and they're all aligned to a certain grid 875 00:30:00,950 --> 00:30:02,149 with Super Mario land. 876 00:30:02,150 --> 00:30:03,679 It's also pretty obvious here, especially 877 00:30:03,680 --> 00:30:05,539 because it doesn't have many different of 878 00:30:05,540 --> 00:30:06,540 these tiles. 879 00:30:07,250 --> 00:30:08,629 Even with something like Donkey Kong 880 00:30:08,630 --> 00:30:10,699 land, you can see it as 881 00:30:10,700 --> 00:30:12,409 soon as you put the grid over it, that 882 00:30:12,410 --> 00:30:13,579 there are some repetitions and 883 00:30:13,580 --> 00:30:14,989 everything's aligned to that, even though 884 00:30:14,990 --> 00:30:16,429 they did a very good job of hiding that. 885 00:30:17,450 --> 00:30:19,369 And in some games you can see it because 886 00:30:19,370 --> 00:30:20,839 it plays with that very concept. 887 00:30:20,840 --> 00:30:22,429 So here in a hurricane, you can see it 888 00:30:22,430 --> 00:30:24,259 fills the screen with tiles. 889 00:30:24,260 --> 00:30:26,149 Let's look at the tile and what a tile is 890 00:30:26,150 --> 00:30:28,429 like. Tile consists of eight times 891 00:30:28,430 --> 00:30:30,019 eight pixels and has four colors like 892 00:30:30,020 --> 00:30:31,020 everything in the system. 893 00:30:31,940 --> 00:30:33,969 And these colors are encoded zero zero 894 00:30:33,970 --> 00:30:35,959 zero one one zero one one. 895 00:30:35,960 --> 00:30:38,089 So let's add that to these pixels 896 00:30:38,090 --> 00:30:39,589 and let's look at how the encoding is 897 00:30:39,590 --> 00:30:41,539 done. If I look at the first line here 898 00:30:41,540 --> 00:30:43,909 and I read it as a binary number zero two 899 00:30:43,910 --> 00:30:46,099 and F, so for every line of pixels, 900 00:30:46,100 --> 00:30:48,169 I need two bytes and in 901 00:30:48,170 --> 00:30:50,269 total I need 60 votes to describe a whole 902 00:30:50,270 --> 00:30:51,270 tile. 903 00:30:52,250 --> 00:30:54,379 You may have noticed here that the 904 00:30:54,380 --> 00:30:55,429 ordering of the colors, it doesn't 905 00:30:55,430 --> 00:30:56,779 necessarily make sense. 906 00:30:56,780 --> 00:30:58,369 This is because I can choose my own 907 00:30:58,370 --> 00:31:00,079 palette. I can be any palette. 908 00:31:00,080 --> 00:31:02,089 There's a two bit to two bit mapping in 909 00:31:02,090 --> 00:31:04,339 the system for these background tiles. 910 00:31:05,540 --> 00:31:07,639 So the native colors are zero, 911 00:31:07,640 --> 00:31:10,549 zero means white and one one means black. 912 00:31:10,550 --> 00:31:12,739 So I can pick any palette like this. 913 00:31:12,740 --> 00:31:15,109 I can also reuse the same colors if I 914 00:31:15,110 --> 00:31:16,279 want that for some effect. 915 00:31:17,510 --> 00:31:18,949 There are two hundred fifty six tiles in 916 00:31:18,950 --> 00:31:21,289 the system. So this tile set do. 917 00:31:21,290 --> 00:31:22,290 That's what it is. 918 00:31:22,910 --> 00:31:24,109 It's Tetris. 919 00:31:24,110 --> 00:31:25,909 If you don't recognize those dancing 920 00:31:25,910 --> 00:31:27,109 people at the bottom then you have not 921 00:31:27,110 --> 00:31:28,130 finished Tetris. 922 00:31:31,490 --> 00:31:32,490 This is Zelda 923 00:31:33,590 --> 00:31:35,719 and that is a Super Mario land which 924 00:31:35,720 --> 00:31:37,579 only uses a hundred twenty eight tiles 925 00:31:37,580 --> 00:31:39,229 that can deal with that. 926 00:31:39,230 --> 00:31:40,430 Anyone recognize what this is? 927 00:31:42,610 --> 00:31:45,099 Let's just puzzle together something and 928 00:31:45,100 --> 00:31:47,979 we'll see it's a tennis game. 929 00:31:47,980 --> 00:31:49,029 It's all star tennis 930 00:31:50,080 --> 00:31:52,209 and this is the puzzle 931 00:31:52,210 --> 00:31:54,339 together from 20 tiles by 18 tiles which 932 00:31:54,340 --> 00:31:55,869 fill up the whole screen, which is not 933 00:31:55,870 --> 00:31:58,059 the whole truth, because actually 934 00:31:58,060 --> 00:32:00,159 in video room there are thirty two 935 00:32:00,160 --> 00:32:01,419 tiles by 30 tiles. 936 00:32:01,420 --> 00:32:02,949 This is the complete background map. 937 00:32:02,950 --> 00:32:04,749 And what you see on the screen is just a 938 00:32:04,750 --> 00:32:05,859 viewport into that. 939 00:32:07,150 --> 00:32:09,219 And it's 256 940 00:32:09,220 --> 00:32:11,349 by 256 pixels, which is nice and 941 00:32:11,350 --> 00:32:13,419 convenient because this is how 942 00:32:13,420 --> 00:32:15,459 scrolling works by just moving that 943 00:32:15,460 --> 00:32:17,529 viewport around and 944 00:32:17,530 --> 00:32:18,759 we can see this in practice. 945 00:32:18,760 --> 00:32:20,199 There's a really nice emulator that lets 946 00:32:20,200 --> 00:32:22,419 you see what's going on in the background 947 00:32:22,420 --> 00:32:24,309 map and how the viewport is changing 948 00:32:24,310 --> 00:32:25,929 around. So this is basically really a 949 00:32:25,930 --> 00:32:27,879 camera that is moving around a bigger 32 950 00:32:27,880 --> 00:32:28,880 by thirty two map. 951 00:32:30,040 --> 00:32:31,749 But this only works with games that are 952 00:32:31,750 --> 00:32:33,339 maximum thirty two by thirty two. 953 00:32:33,340 --> 00:32:34,749 What about games that are, that are 954 00:32:34,750 --> 00:32:36,849 scrolling infinitely like Super Mario 955 00:32:36,850 --> 00:32:37,869 land? 956 00:32:37,870 --> 00:32:40,029 We can have this many extra columns 957 00:32:40,030 --> 00:32:42,429 and we can move the viewport over here. 958 00:32:42,430 --> 00:32:44,589 But what happens if we end up 959 00:32:44,590 --> 00:32:45,789 here at the end? 960 00:32:45,790 --> 00:32:47,319 Well, it will wrap around. 961 00:32:47,320 --> 00:32:49,389 And if we just to draw columns fast 962 00:32:49,390 --> 00:32:51,519 enough just before the viewport hits 963 00:32:51,520 --> 00:32:53,989 them, we can have an infinite world. 964 00:32:53,990 --> 00:32:55,479 So in the emulator, you can see this 965 00:32:55,480 --> 00:32:58,179 quite clearly in the off screen area 966 00:32:58,180 --> 00:33:00,339 of the viewport it keeps putting 967 00:33:00,340 --> 00:33:02,019 in those new columns. 968 00:33:02,020 --> 00:33:03,639 And this also works in two dimensions. 969 00:33:03,640 --> 00:33:05,499 This is Donkey Kong. And again, this 970 00:33:05,500 --> 00:33:06,409 looks pretty freaky. 971 00:33:06,410 --> 00:33:08,529 It just puts those extra columns 972 00:33:08,530 --> 00:33:10,779 and lines where it will 973 00:33:10,780 --> 00:33:11,780 go. 974 00:33:14,090 --> 00:33:15,679 So this is the one layer that we've 975 00:33:15,680 --> 00:33:16,680 talked about so far, 976 00:33:18,620 --> 00:33:20,209 it's the background and on top of the 977 00:33:20,210 --> 00:33:21,409 background, there's another layer that 978 00:33:21,410 --> 00:33:22,969 you can optionally put on top. 979 00:33:22,970 --> 00:33:23,899 It's the window. 980 00:33:23,900 --> 00:33:25,999 It can cover it fully or it can start at 981 00:33:26,000 --> 00:33:28,009 any location. There's an X and Y position 982 00:33:28,010 --> 00:33:29,689 for that and it will draw from there to 983 00:33:29,690 --> 00:33:31,609 the right and to the bottom. 984 00:33:31,610 --> 00:33:33,139 There's no translucency ever. 985 00:33:33,140 --> 00:33:35,059 So usually how this is used, as you put 986 00:33:35,060 --> 00:33:36,679 it, to the very right or you put it to 987 00:33:36,680 --> 00:33:38,299 the very bottom, it just always does and 988 00:33:38,300 --> 00:33:40,759 does not respond to the other scrolling 989 00:33:40,760 --> 00:33:41,449 settings. 990 00:33:41,450 --> 00:33:43,669 And you guessed it, this is necessary 991 00:33:43,670 --> 00:33:45,679 for something like a score that is shown 992 00:33:45,680 --> 00:33:46,699 at the bottom of the screen. 993 00:33:46,700 --> 00:33:48,499 This is very nice, easy and convenient 994 00:33:48,500 --> 00:33:49,879 for games. 995 00:33:49,880 --> 00:33:51,979 But you can also put it on the right. 996 00:33:51,980 --> 00:33:53,719 And these are games, but it wouldn't 997 00:33:53,720 --> 00:33:55,009 matter. It works on the game just as 998 00:33:55,010 --> 00:33:56,010 well. 999 00:33:57,050 --> 00:33:58,819 And then there's another layer on top of 1000 00:33:58,820 --> 00:34:00,709 the background. And the window, which is 1001 00:34:00,710 --> 00:34:03,019 a sprites, are objects on the screen 1002 00:34:03,020 --> 00:34:05,119 that are that don't fit into the eight by 1003 00:34:05,120 --> 00:34:06,709 eight Vasteras. You can position them 1004 00:34:06,710 --> 00:34:07,849 freely. 1005 00:34:07,850 --> 00:34:09,259 So we have three sprites here in the 1006 00:34:09,260 --> 00:34:12,169 system, Nintendo Custom Objects, LBJ, 1007 00:34:12,170 --> 00:34:13,669 but I keep calling them sprites because 1008 00:34:13,670 --> 00:34:15,138 everyone calls them aspirates. 1009 00:34:15,139 --> 00:34:17,238 Let's just look at this one here. 1010 00:34:17,239 --> 00:34:19,759 Every Sprite in the system has attributes 1011 00:34:19,760 --> 00:34:21,829 and there's the OEM, which 1012 00:34:21,830 --> 00:34:23,869 is the object attribute map, and this is 1013 00:34:23,870 --> 00:34:26,388 one entry and it has these values. 1014 00:34:26,389 --> 00:34:28,218 So one of them is the position. 1015 00:34:28,219 --> 00:34:29,749 So if we put the goombah to the very left 1016 00:34:29,750 --> 00:34:31,819 of the screen, you would expect us 1017 00:34:31,820 --> 00:34:33,919 to have a horizontal position of zero. 1018 00:34:33,920 --> 00:34:35,419 Right. But no, it's eight. 1019 00:34:35,420 --> 00:34:36,408 Why is that? 1020 00:34:36,409 --> 00:34:38,388 Because if you put it at four, it's here. 1021 00:34:38,389 --> 00:34:39,468 And if you put it, it's zero. 1022 00:34:39,469 --> 00:34:41,178 It's here because it's eight pixels wide. 1023 00:34:41,179 --> 00:34:43,279 You need a way to scroll it in. 1024 00:34:43,280 --> 00:34:44,928 And something similar is true at the top 1025 00:34:44,929 --> 00:34:47,599 of the screen. But the first 1026 00:34:47,600 --> 00:34:49,428 Y position where you see it fully is 16, 1027 00:34:49,429 --> 00:34:51,709 because sprites 1028 00:34:51,710 --> 00:34:53,988 can also be can can be up to 16 bits, 1029 00:34:53,989 --> 00:34:54,989 16, 1030 00:34:56,300 --> 00:34:58,039 16 pixels in height. 1031 00:34:59,210 --> 00:35:01,279 So let's put it at its natural 1032 00:35:01,280 --> 00:35:02,449 location here. 1033 00:35:02,450 --> 00:35:04,879 The next thing to look at is what 1034 00:35:04,880 --> 00:35:06,169 should it look like? 1035 00:35:06,170 --> 00:35:07,759 So first of all, you can see it's eight 1036 00:35:07,760 --> 00:35:09,349 by eight grid. It's the same encoding, 1037 00:35:09,350 --> 00:35:10,999 except that it also has translucent 1038 00:35:11,000 --> 00:35:11,339 pixels. 1039 00:35:11,340 --> 00:35:12,709 So the code zero zero stands for 1040 00:35:12,710 --> 00:35:14,209 translucency. 1041 00:35:14,210 --> 00:35:15,469 And since it's the same encoding, it's 1042 00:35:15,470 --> 00:35:16,759 the same kind of tiles. 1043 00:35:16,760 --> 00:35:18,349 And there's also two hundred fifty six 1044 00:35:18,350 --> 00:35:20,959 tiles in the system, which is a bit and 1045 00:35:20,960 --> 00:35:22,770 we can see it here, it's Hilex 90. 1046 00:35:24,680 --> 00:35:26,219 The next thing is the flip. 1047 00:35:26,220 --> 00:35:28,669 So in so you don't have to 1048 00:35:28,670 --> 00:35:30,679 save to goombahs here, one that works to 1049 00:35:30,680 --> 00:35:32,329 the left and one works to the right. 1050 00:35:32,330 --> 00:35:33,829 You just flip it horizontally and you 1051 00:35:33,830 --> 00:35:35,479 have one that walks to the right. 1052 00:35:35,480 --> 00:35:36,949 You flip it vertically and you have a 1053 00:35:36,950 --> 00:35:38,959 dead gumba, you flip it horizontally and 1054 00:35:38,960 --> 00:35:40,099 vertically and you have a dead woman 1055 00:35:40,100 --> 00:35:41,100 walking the other direction. 1056 00:35:42,620 --> 00:35:45,499 So let's put it right side up again. 1057 00:35:45,500 --> 00:35:48,229 The next bit is the pallet, because 1058 00:35:48,230 --> 00:35:50,179 one pixel combination, one bit 1059 00:35:50,180 --> 00:35:52,429 combination means translucency. 1060 00:35:52,430 --> 00:35:54,559 You only have three more colors for 1061 00:35:54,560 --> 00:35:56,269 sprites, which is a shame. 1062 00:35:56,270 --> 00:35:58,339 So they didn't want to impose 1063 00:35:58,340 --> 00:36:00,709 three specific colors for this. 1064 00:36:00,710 --> 00:36:02,869 So four for the sprites you can pick 1065 00:36:02,870 --> 00:36:04,639 which three colors out of the four you 1066 00:36:04,640 --> 00:36:06,619 want and all the sprites don't have to 1067 00:36:06,620 --> 00:36:08,779 share the same three colors because there 1068 00:36:08,780 --> 00:36:10,609 are two palettes in the system, which is 1069 00:36:10,610 --> 00:36:12,679 why the Sprite also has another flag. 1070 00:36:12,680 --> 00:36:14,299 Does it take Pallot zero one? 1071 00:36:14,300 --> 00:36:16,279 If it takes one, it would like this would 1072 00:36:16,280 --> 00:36:17,509 look like this with Pallot zero. 1073 00:36:17,510 --> 00:36:19,699 It looks like this and 1074 00:36:19,700 --> 00:36:21,259 one more bit is priority. 1075 00:36:21,260 --> 00:36:23,359 So how does the Sprite draw in 1076 00:36:23,360 --> 00:36:24,889 comparison with the background 1077 00:36:26,030 --> 00:36:26,929 if that priority is one? 1078 00:36:26,930 --> 00:36:28,099 This is the interesting case. 1079 00:36:28,100 --> 00:36:29,659 It will draw on top of all those white 1080 00:36:29,660 --> 00:36:31,729 pixels here, but it will draw at the 1081 00:36:31,730 --> 00:36:34,399 back of all the non white pixels. 1082 00:36:34,400 --> 00:36:35,659 But there's nothing special about white 1083 00:36:35,660 --> 00:36:36,979 here. This is why there exists a 1084 00:36:36,980 --> 00:36:38,149 background palette. 1085 00:36:38,150 --> 00:36:40,099 It's about pixels that have the value of 1086 00:36:40,100 --> 00:36:41,179 zero in the background. 1087 00:36:41,180 --> 00:36:43,069 So if you pick another palette and the 1088 00:36:43,070 --> 00:36:45,139 Goolma could very well be drawn 1089 00:36:45,140 --> 00:36:46,249 on top of any other color, 1090 00:36:47,630 --> 00:36:49,039 if we set the property to zero, it will 1091 00:36:49,040 --> 00:36:50,899 draw on top of everything except for the 1092 00:36:50,900 --> 00:36:52,130 translucent pixels, of course, 1093 00:36:53,510 --> 00:36:55,339 Sprite and Sprite priority. 1094 00:36:55,340 --> 00:36:56,749 There's nothing you can do about this. 1095 00:36:56,750 --> 00:36:58,759 This is always fixed with this rectangle 1096 00:36:58,760 --> 00:37:00,469 here and the base on top of the 1097 00:37:00,470 --> 00:37:02,179 rectangle, which is because the goombahs 1098 00:37:02,180 --> 00:37:03,859 horizontal position is smaller than the 1099 00:37:03,860 --> 00:37:05,539 rectangles. As soon as they're at the 1100 00:37:05,540 --> 00:37:07,819 same horizontal position, the sprites 1101 00:37:07,820 --> 00:37:09,409 with a lower number wins because the 1102 00:37:09,410 --> 00:37:10,969 sprites are an array and memory. 1103 00:37:10,970 --> 00:37:12,949 The one that comes earlier draws over, 1104 00:37:12,950 --> 00:37:14,119 the one that comes later. 1105 00:37:14,120 --> 00:37:16,249 As soon as the white rectangle 1106 00:37:16,250 --> 00:37:18,199 it has a small exposition, then the 1107 00:37:18,200 --> 00:37:20,269 gumba, it will draw on top of it. 1108 00:37:20,270 --> 00:37:21,559 And you can see this as flickering 1109 00:37:21,560 --> 00:37:23,419 effects in some games when you walk 1110 00:37:23,420 --> 00:37:24,420 through other things. 1111 00:37:26,120 --> 00:37:27,559 There are 40 sprites in the system, you 1112 00:37:27,560 --> 00:37:29,329 can have 40 sprites on the screen at the 1113 00:37:29,330 --> 00:37:31,849 same time, but there's another limitation 1114 00:37:31,850 --> 00:37:33,589 per line. You can only have 10 sprites. 1115 00:37:33,590 --> 00:37:35,359 So I have an 11th Sprite here and it only 1116 00:37:35,360 --> 00:37:36,949 counts per pixel line. 1117 00:37:36,950 --> 00:37:39,709 So here, these pixels would not be drawn 1118 00:37:39,710 --> 00:37:41,809 or the next line or 1119 00:37:41,810 --> 00:37:43,639 the next line. And this is not about the 1120 00:37:43,640 --> 00:37:45,169 11th one from the left. 1121 00:37:45,170 --> 00:37:47,419 It's the 11th visible one in 1122 00:37:47,420 --> 00:37:49,159 the list of sprites in the ordering that 1123 00:37:49,160 --> 00:37:50,540 the program decides. 1124 00:37:52,640 --> 00:37:54,289 So this is the complete entry. 1125 00:37:54,290 --> 00:37:55,729 It fits neatly into four bytes. 1126 00:37:55,730 --> 00:37:57,830 So this is one entry in memory. 1127 00:37:58,880 --> 00:38:00,889 Zero zero is where these entries are 1128 00:38:00,890 --> 00:38:03,139 stored. There are 40 of them for the 40 1129 00:38:03,140 --> 00:38:04,339 sprites. And the whole thing is called 1130 00:38:04,340 --> 00:38:06,589 the RAM, which is a special purpose 1131 00:38:06,590 --> 00:38:09,049 room at this location in memory, 1132 00:38:09,050 --> 00:38:10,489 which is not part of video RAM. 1133 00:38:12,050 --> 00:38:13,429 One more thing I should say about sprites 1134 00:38:13,430 --> 00:38:15,619 is even the small Mario this is the small 1135 00:38:15,620 --> 00:38:18,439 one is too big for it, but it's bright. 1136 00:38:18,440 --> 00:38:20,239 So you could do it as force bright. 1137 00:38:20,240 --> 00:38:21,799 And this is what the game actually does. 1138 00:38:21,800 --> 00:38:23,329 But there's another mode where you can 1139 00:38:23,330 --> 00:38:26,089 have surprise that a 16 pixels high, 1140 00:38:26,090 --> 00:38:27,169 but this is global. 1141 00:38:27,170 --> 00:38:28,309 The whole game would have to deal with a 1142 00:38:28,310 --> 00:38:30,919 16 pixel sprites then. 1143 00:38:30,920 --> 00:38:32,810 So we've seen the three different layers. 1144 00:38:34,070 --> 00:38:35,059 There is one more thing. 1145 00:38:35,060 --> 00:38:37,069 You can actually completely turn off the 1146 00:38:37,070 --> 00:38:40,039 display, which is a fifth color, 1147 00:38:40,040 --> 00:38:42,979 which is a little lighter than white, 1148 00:38:42,980 --> 00:38:44,899 not very useful because you have to turn 1149 00:38:44,900 --> 00:38:46,039 off the complete LCD. 1150 00:38:46,040 --> 00:38:48,049 So as soon as you turn on the LCD but 1151 00:38:48,050 --> 00:38:49,979 don't do a background, you could wait. 1152 00:38:49,980 --> 00:38:51,709 If you draw the background and say you 1153 00:38:51,710 --> 00:38:53,839 want to draw it and light gray, 1154 00:38:53,840 --> 00:38:55,669 it's completely replaces that color. 1155 00:38:55,670 --> 00:38:57,199 You can draw a window on top. 1156 00:38:57,200 --> 00:38:59,389 Again, no translucency here and 1157 00:38:59,390 --> 00:39:01,549 you can draw sprites on top and 1158 00:39:01,550 --> 00:39:02,869 notice that sprites don't distinguish 1159 00:39:02,870 --> 00:39:04,309 between whether pixel is background or 1160 00:39:04,310 --> 00:39:05,929 window. So there's no clipping going on 1161 00:39:05,930 --> 00:39:06,930 with the window. 1162 00:39:08,480 --> 00:39:10,879 So how does all this work with 1163 00:39:10,880 --> 00:39:12,769 the memory map for kilobytes of sprite 1164 00:39:12,770 --> 00:39:15,079 tiles and four kilobytes 1165 00:39:15,080 --> 00:39:17,419 of background tiles and 1166 00:39:17,420 --> 00:39:19,549 one kilobyte of the background map, the 1167 00:39:19,550 --> 00:39:20,599 32 by thirty two. 1168 00:39:20,600 --> 00:39:22,549 And we also have a kilobyte of the window 1169 00:39:22,550 --> 00:39:23,749 map. It's not the most efficient 1170 00:39:23,750 --> 00:39:25,190 representation, but they did it for 1171 00:39:26,210 --> 00:39:27,769 because it was easier. 1172 00:39:27,770 --> 00:39:30,079 And we only have eight kilobytes of video 1173 00:39:30,080 --> 00:39:31,609 ram. So if we put this brutality of the 1174 00:39:31,610 --> 00:39:33,049 background tiles here, we have already 1175 00:39:33,050 --> 00:39:35,209 run out of video. Ram, let's 1176 00:39:35,210 --> 00:39:36,829 try it differently. Let's put the sprites 1177 00:39:36,830 --> 00:39:39,139 here. Let's put the background in the 1178 00:39:39,140 --> 00:39:40,369 window map here. And what do we do with 1179 00:39:40,370 --> 00:39:41,359 the background tiles? 1180 00:39:41,360 --> 00:39:43,429 Let's have them overlap 1181 00:39:43,430 --> 00:39:45,859 and the different configurations here, 1182 00:39:45,860 --> 00:39:46,459 three bits. 1183 00:39:46,460 --> 00:39:48,409 We can have them completely overlap or 1184 00:39:48,410 --> 00:39:50,599 just partially and we can swap around 1185 00:39:50,600 --> 00:39:53,149 these or have them at the same location. 1186 00:39:53,150 --> 00:39:54,529 What does this overlap mean? 1187 00:39:54,530 --> 00:39:55,789 So this is one configuration, the 1188 00:39:55,790 --> 00:39:57,409 background tiles and the tiles there in 1189 00:39:57,410 --> 00:39:59,869 the same format, eight eight, two bits 1190 00:39:59,870 --> 00:40:02,269 per pixel, so they could share exactly 1191 00:40:02,270 --> 00:40:03,349 the same tiles. 1192 00:40:03,350 --> 00:40:04,789 But you can also put them this way. 1193 00:40:04,790 --> 00:40:06,229 So the first third of the first one, 1194 00:40:06,230 --> 00:40:08,149 twenty eight would be Sprite Taza 1195 00:40:08,150 --> 00:40:09,829 collusively. The last one twenty eight 1196 00:40:09,830 --> 00:40:11,569 would be background tiles exclusively and 1197 00:40:11,570 --> 00:40:12,979 the ones in the middle would be shared by 1198 00:40:12,980 --> 00:40:14,689 both or useable by both. 1199 00:40:14,690 --> 00:40:16,399 And in the case of Super Mario land here 1200 00:40:16,400 --> 00:40:19,219 you can see that the first two thirds 1201 00:40:19,220 --> 00:40:20,779 are used for sprites and the last third 1202 00:40:20,780 --> 00:40:21,780 is used for the background. 1203 00:40:24,320 --> 00:40:26,600 The next step is vertical timing, 1204 00:40:30,260 --> 00:40:32,509 as in CRT based systems. 1205 00:40:32,510 --> 00:40:34,729 So this is how a normal old CRT system 1206 00:40:34,730 --> 00:40:36,979 draws its picture very in 1207 00:40:36,980 --> 00:40:38,959 a very slow motion version. 1208 00:40:38,960 --> 00:40:40,549 It draws it from the top to the bottom, 1209 00:40:40,550 --> 00:40:42,349 from the left to the right. 1210 00:40:42,350 --> 00:40:44,509 And the same is true on a Gameboy. 1211 00:40:44,510 --> 00:40:46,669 It keeps drawing the picture 60 times 1212 00:40:46,670 --> 00:40:48,439 a second from top to bottom, line by 1213 00:40:48,440 --> 00:40:49,519 line, left to right. 1214 00:40:49,520 --> 00:40:51,439 This was not done because they were using 1215 00:40:51,440 --> 00:40:52,999 some old components. 1216 00:40:53,000 --> 00:40:55,489 They completely redid the 1217 00:40:55,490 --> 00:40:57,739 very idea how this was done, but still 1218 00:40:57,740 --> 00:40:59,209 nails, if you want to be refreshed 60 1219 00:40:59,210 --> 00:41:01,549 times a second and they dried like that. 1220 00:41:01,550 --> 00:41:02,809 And this is important to note, if you 1221 00:41:02,810 --> 00:41:04,759 wanted to do certain effects that you 1222 00:41:04,760 --> 00:41:06,739 cannot otherwise do in this game, for 1223 00:41:06,740 --> 00:41:08,179 example, you can see that different parts 1224 00:41:08,180 --> 00:41:09,769 of the screen behave differently. 1225 00:41:09,770 --> 00:41:11,959 And let's just look at the 1226 00:41:11,960 --> 00:41:14,809 scrolling city line here. 1227 00:41:14,810 --> 00:41:16,759 It would be easy to just have that scroll 1228 00:41:16,760 --> 00:41:18,859 by itself on the full screen, but we only 1229 00:41:18,860 --> 00:41:20,539 want to scroll a part of the screen. 1230 00:41:20,540 --> 00:41:21,919 And the way this is done is with these 1231 00:41:21,920 --> 00:41:24,019 extra registers. So if you've seen a bit 1232 00:41:24,020 --> 00:41:25,969 programing on something like AC 64 before 1233 00:41:25,970 --> 00:41:28,519 you've seen all this, you can see 1234 00:41:28,520 --> 00:41:30,709 you can read which line is currently 1235 00:41:30,710 --> 00:41:33,049 being drawn or which will be drawn in 1236 00:41:33,050 --> 00:41:33,949 just a moment. 1237 00:41:33,950 --> 00:41:36,179 And instead of just busy waiting there, 1238 00:41:36,180 --> 00:41:37,429 you can also set and interrupt. 1239 00:41:37,430 --> 00:41:39,019 It will wake you up as soon as a certain 1240 00:41:39,020 --> 00:41:40,020 line is reached. 1241 00:41:41,000 --> 00:41:43,309 So let's set the scroll X register 1242 00:41:43,310 --> 00:41:45,499 to zero and let's trigger here at line 1243 00:41:45,500 --> 00:41:47,149 eight. So it will draw all of this with a 1244 00:41:47,150 --> 00:41:48,319 scroll offset of zero. 1245 00:41:48,320 --> 00:41:50,389 At this point, our program will set 1246 00:41:50,390 --> 00:41:52,579 the scroll, offset the horizontal scroll 1247 00:41:52,580 --> 00:41:54,379 of the two, let's say twenty three in the 1248 00:41:54,380 --> 00:41:55,849 next room. We'll set it to twenty four. 1249 00:41:55,850 --> 00:41:58,129 So we'll scroll and we'll 1250 00:41:58,130 --> 00:42:00,289 compare it just to forty two and it will 1251 00:42:00,290 --> 00:42:01,849 continue drawing here with a certain 1252 00:42:01,850 --> 00:42:03,529 offset and then we set it to something 1253 00:42:03,530 --> 00:42:04,549 else, said another. 1254 00:42:04,550 --> 00:42:06,529 I see it keeps drawing like that. 1255 00:42:06,530 --> 00:42:08,599 How exactly draws the road here. 1256 00:42:08,600 --> 00:42:09,589 We'll talk about that later. 1257 00:42:09,590 --> 00:42:10,789 That's a fun trick as well. 1258 00:42:10,790 --> 00:42:12,559 And then we set it to zero again because 1259 00:42:12,560 --> 00:42:13,759 the dashboard doesn't do any kind of 1260 00:42:13,760 --> 00:42:15,709 scrolling and we do the same thing on the 1261 00:42:15,710 --> 00:42:16,710 next screen, again 1262 00:42:17,840 --> 00:42:18,919 in this example. 1263 00:42:18,920 --> 00:42:20,779 So it doesn't have to only have to do 1264 00:42:20,780 --> 00:42:22,729 with the scrolling register. 1265 00:42:22,730 --> 00:42:24,709 Here's a different example where the 1266 00:42:24,710 --> 00:42:26,149 Murray on the top right is actually a 1267 00:42:26,150 --> 00:42:27,289 window. 1268 00:42:27,290 --> 00:42:29,359 And we talked about this 1269 00:42:29,360 --> 00:42:30,949 before. The window will draw from a 1270 00:42:30,950 --> 00:42:32,329 certain position to the right and to the 1271 00:42:32,330 --> 00:42:33,259 bottom of the screen. 1272 00:42:33,260 --> 00:42:35,449 You cannot just have a draw halfway. 1273 00:42:35,450 --> 00:42:37,249 But yes, you can. 1274 00:42:37,250 --> 00:42:39,319 You trigger a line zero and turn on 1275 00:42:39,320 --> 00:42:40,939 the window and the trigger again at line 1276 00:42:40,940 --> 00:42:42,679 forty and turn off the window. 1277 00:42:42,680 --> 00:42:44,899 So when it draws a line forty, 1278 00:42:44,900 --> 00:42:46,309 the people will think a window. 1279 00:42:46,310 --> 00:42:47,299 What window? 1280 00:42:47,300 --> 00:42:49,459 Don't know about any window, so 1281 00:42:49,460 --> 00:42:51,379 it won't draw any further and. 1282 00:42:51,380 --> 00:42:52,969 You can see this in all kinds of games, 1283 00:42:52,970 --> 00:42:54,259 some of these tricks can be done with a 1284 00:42:54,260 --> 00:42:56,299 window. They have to be done with 1285 00:42:56,300 --> 00:42:57,440 screens, splitting techniques. 1286 00:42:59,330 --> 00:43:01,519 If you don't just trigger on 1287 00:43:01,520 --> 00:43:03,289 certain lines, but do something fun on 1288 00:43:03,290 --> 00:43:05,299 every line, you can do a trick like this. 1289 00:43:05,300 --> 00:43:06,379 So on the left, you can see what's on the 1290 00:43:06,380 --> 00:43:07,639 screen. On the right can see what's 1291 00:43:07,640 --> 00:43:09,859 actually happening or what's stored 1292 00:43:09,860 --> 00:43:11,929 inside the video room if 1293 00:43:11,930 --> 00:43:13,909 you change in every line. 1294 00:43:13,910 --> 00:43:16,129 This is the curve 1295 00:43:16,130 --> 00:43:18,409 that is just used as a transform for 1296 00:43:18,410 --> 00:43:19,939 that picture. And that curve changes on 1297 00:43:19,940 --> 00:43:21,889 every frame. And all the program has to 1298 00:43:21,890 --> 00:43:23,419 do is on every single line. 1299 00:43:23,420 --> 00:43:25,549 It has to to 1300 00:43:25,550 --> 00:43:28,099 write a different value into the 1301 00:43:28,100 --> 00:43:29,029 register. 1302 00:43:29,030 --> 00:43:30,469 And of course, it has to be done in every 1303 00:43:30,470 --> 00:43:32,119 line. The picture here doesn't show it in 1304 00:43:32,120 --> 00:43:33,120 every line. 1305 00:43:33,680 --> 00:43:36,079 And the racing game effect is 1306 00:43:36,080 --> 00:43:37,669 pretty much the same thing here. 1307 00:43:37,670 --> 00:43:39,139 This is what you can see in the video. 1308 00:43:39,140 --> 00:43:41,269 It's just a straight road, but it 1309 00:43:41,270 --> 00:43:43,339 gets distorted at runtime while the 1310 00:43:43,340 --> 00:43:45,019 picture is being drawn. 1311 00:43:45,020 --> 00:43:46,099 So let's zoom into this. 1312 00:43:46,100 --> 00:43:47,629 This is the source and this is what we 1313 00:43:47,630 --> 00:43:48,649 can see on the screen. 1314 00:43:48,650 --> 00:43:51,169 So if you ignore the sprites here, 1315 00:43:51,170 --> 00:43:53,059 this is the curve that it has to use to 1316 00:43:53,060 --> 00:43:54,079 distort it. 1317 00:43:54,080 --> 00:43:56,659 And these are all the offsets of X. 1318 00:43:56,660 --> 00:43:58,819 So if you keep updating in every 1319 00:43:58,820 --> 00:44:01,039 single line, you can warp it like that. 1320 00:44:01,040 --> 00:44:02,599 And another thing you can see here is 1321 00:44:02,600 --> 00:44:04,969 that the line in the middle is patterned 1322 00:44:04,970 --> 00:44:07,129 as well as the part 1323 00:44:07,130 --> 00:44:08,269 outside of the road. 1324 00:44:08,270 --> 00:44:10,219 And this is done by changing the pallet 1325 00:44:10,220 --> 00:44:12,440 every few lines in the circuit. 1326 00:44:14,480 --> 00:44:16,399 And you can even go one step further. 1327 00:44:16,400 --> 00:44:18,559 This rally game here can also do bumps in 1328 00:44:18,560 --> 00:44:20,689 the road, which is done by picking 1329 00:44:20,690 --> 00:44:22,249 not just the horizontal scroll register, 1330 00:44:22,250 --> 00:44:23,959 but also the vertical scroll register in 1331 00:44:23,960 --> 00:44:26,059 every line. So you can 1332 00:44:26,060 --> 00:44:27,829 you can duplicate lines and you can skip 1333 00:44:27,830 --> 00:44:29,899 lines. And with some good math, 1334 00:44:29,900 --> 00:44:31,489 you'll get to that. 1335 00:44:31,490 --> 00:44:34,099 And if you update your vertical scroll 1336 00:44:34,100 --> 00:44:36,109 register in the middle of a line, you can 1337 00:44:36,110 --> 00:44:37,729 do this wobble effect, which is two 1338 00:44:37,730 --> 00:44:38,899 dimensional. 1339 00:44:38,900 --> 00:44:40,879 But for that, we have to go a little 1340 00:44:40,880 --> 00:44:43,039 deeper and go into horizontal 1341 00:44:43,040 --> 00:44:44,040 timing. 1342 00:44:46,670 --> 00:44:49,669 What happens while a line is being drawn? 1343 00:44:49,670 --> 00:44:52,129 So this is the pixel transfer mode 1344 00:44:52,130 --> 00:44:54,229 of the people and it usually takes 1345 00:44:54,230 --> 00:44:56,299 forty three clocks and this is 1346 00:44:56,300 --> 00:44:57,349 done for one hundred and forty four 1347 00:44:57,350 --> 00:44:59,449 lines. But you cannot 1348 00:44:59,450 --> 00:45:01,399 just imagine that at the end of the first 1349 00:45:01,400 --> 00:45:03,499 line it will immediately draw 1350 00:45:03,500 --> 00:45:05,209 the first pixel of the next line. 1351 00:45:05,210 --> 00:45:06,979 That's not what what's happening because 1352 00:45:06,980 --> 00:45:09,079 there's an extra OEM's search at 1353 00:45:09,080 --> 00:45:10,279 the beginning of each line, which is 1354 00:45:10,280 --> 00:45:11,899 twenty clocks. I'll talk about that in a 1355 00:45:11,900 --> 00:45:14,029 minute. And an blank area of 1356 00:45:14,030 --> 00:45:16,189 fifty one clocks at the end of every line 1357 00:45:16,190 --> 00:45:18,499 in each blank about the people is idling. 1358 00:45:18,500 --> 00:45:19,729 It doesn't do anything. 1359 00:45:19,730 --> 00:45:21,439 And there's also a blank mode when the 1360 00:45:21,440 --> 00:45:22,879 people doesn't do anything between 1361 00:45:22,880 --> 00:45:23,880 screens. 1362 00:45:24,410 --> 00:45:26,289 So let's do the math aligned. 1363 00:45:26,290 --> 00:45:27,919 One hundred and fourteen clocks at one 1364 00:45:27,920 --> 00:45:29,269 megahertz. 1365 00:45:29,270 --> 00:45:30,439 Fifty four lines. 1366 00:45:30,440 --> 00:45:32,539 So this is this many clocks screen. 1367 00:45:32,540 --> 00:45:34,729 If you divide the clock by 1368 00:45:34,730 --> 00:45:36,739 this, you'll get a refresh rate of fifty 1369 00:45:36,740 --> 00:45:37,740 nine point seven hertz. 1370 00:45:41,770 --> 00:45:42,969 These four different modes that the 1371 00:45:42,970 --> 00:45:44,019 people can be in. 1372 00:45:44,020 --> 00:45:46,029 You can read that out and see if you can 1373 00:45:46,030 --> 00:45:47,499 know about that and you can also trigger 1374 00:45:47,500 --> 00:45:49,629 interrupts based on this. 1375 00:45:49,630 --> 00:45:52,689 But why would the CPU have to know? 1376 00:45:52,690 --> 00:45:54,309 Let's look at what's going on in these 1377 00:45:54,310 --> 00:45:56,199 different modes. First, what is this OEM 1378 00:45:56,200 --> 00:45:57,819 surge of twenty cycles at the beginning 1379 00:45:57,820 --> 00:46:00,099 of each line for every line, the CPU 1380 00:46:00,100 --> 00:46:02,649 has to decide which sprites 1381 00:46:02,650 --> 00:46:04,269 are visible in that line. 1382 00:46:04,270 --> 00:46:05,799 So there are 40 sprites total in the 1383 00:46:05,800 --> 00:46:07,959 system and it has 1384 00:46:07,960 --> 00:46:09,579 to filter those sprites. 1385 00:46:09,580 --> 00:46:11,649 It has to find the price that are visible 1386 00:46:11,650 --> 00:46:13,749 in that line and put them into 1387 00:46:13,750 --> 00:46:15,549 an array of up to 10 sprites that are 1388 00:46:15,550 --> 00:46:16,929 visible there. 1389 00:46:16,930 --> 00:46:18,909 And the logic for that is the exposition 1390 00:46:18,910 --> 00:46:20,499 cannot be zero because then it would be 1391 00:46:20,500 --> 00:46:22,929 invisible. And the 1392 00:46:22,930 --> 00:46:24,429 current line that we're drawing must be 1393 00:46:24,430 --> 00:46:26,019 between the first line of the Sprite and 1394 00:46:26,020 --> 00:46:27,309 the last line of the Sprite. 1395 00:46:27,310 --> 00:46:28,869 So it gets added to the visible sprite 1396 00:46:28,870 --> 00:46:29,870 array. 1397 00:46:30,220 --> 00:46:31,749 And this takes 20 cycles, 1398 00:46:32,860 --> 00:46:34,139 by the way, in the original game. 1399 00:46:34,140 --> 00:46:35,889 There was a fun bug here. 1400 00:46:35,890 --> 00:46:38,109 If you do 1401 00:46:38,110 --> 00:46:40,629 any calculations, any 16 bit calculations 1402 00:46:40,630 --> 00:46:42,729 with numbers between four 00 1403 00:46:42,730 --> 00:46:45,079 and four, which is the pointer to the OEM 1404 00:46:45,080 --> 00:46:47,199 rim, even if you're not accessing RAM at 1405 00:46:47,200 --> 00:46:49,359 all, it will destroy 1406 00:46:49,360 --> 00:46:51,789 the rim wire during open-mouthed. 1407 00:46:54,610 --> 00:46:56,889 So why else 1408 00:46:56,890 --> 00:46:59,169 would you have to care about what's going 1409 00:46:59,170 --> 00:47:00,159 on? 1410 00:47:00,160 --> 00:47:01,419 As if he was connected to RAM. 1411 00:47:02,500 --> 00:47:04,769 CPU is connected to video RAM and 1412 00:47:04,770 --> 00:47:06,729 a special Pipas also connected directly 1413 00:47:06,730 --> 00:47:09,229 to RAM CPU could be connected 1414 00:47:09,230 --> 00:47:10,569 to the video RAM as well. 1415 00:47:10,570 --> 00:47:12,309 So can write to a video ram. 1416 00:47:12,310 --> 00:47:13,959 But this is not how it's done. 1417 00:47:13,960 --> 00:47:15,699 You wouldn't need a double speed video 1418 00:47:15,700 --> 00:47:17,559 ram here. See 64 does it like that. 1419 00:47:17,560 --> 00:47:19,509 But on the Gameboy it has to go through 1420 00:47:19,510 --> 00:47:21,789 the CPU and this, this one big switch 1421 00:47:21,790 --> 00:47:23,259 where the people can say you cannot 1422 00:47:23,260 --> 00:47:24,789 access it right now if you want. 1423 00:47:24,790 --> 00:47:26,889 If the if this, if you want to write, 1424 00:47:26,890 --> 00:47:28,569 nothing happens. If it reads, it gets all 1425 00:47:28,570 --> 00:47:30,669 FNF at least nothing that can 1426 00:47:30,670 --> 00:47:32,199 happen. But it's also not very useful. 1427 00:47:32,200 --> 00:47:34,389 So the CPU has to make sure that the 1428 00:47:34,390 --> 00:47:35,709 people is in the right mode so that it 1429 00:47:35,710 --> 00:47:37,359 can access all this 1430 00:47:38,920 --> 00:47:40,179 during pixel transfer. 1431 00:47:40,180 --> 00:47:42,369 You cannot access video ram, but 1432 00:47:42,370 --> 00:47:45,189 you can. But during OEM search 1433 00:47:45,190 --> 00:47:47,529 and video and violent video ram access 1434 00:47:47,530 --> 00:47:48,669 is OK. 1435 00:47:48,670 --> 00:47:50,949 If you want to access OEM RAM, 1436 00:47:50,950 --> 00:47:53,079 you cannot do it in either OEM search or 1437 00:47:53,080 --> 00:47:54,579 doing pixel transfer because that's when 1438 00:47:54,580 --> 00:47:55,659 the sprays are drawn. 1439 00:47:55,660 --> 00:47:57,219 The CPU needs that. 1440 00:47:57,220 --> 00:47:59,589 You can only access it in those times. 1441 00:47:59,590 --> 00:48:01,149 So you have to be very careful in those 1442 00:48:01,150 --> 00:48:02,739 times while the screen is being drawn. 1443 00:48:03,820 --> 00:48:06,069 So basically all this is bad area 1444 00:48:06,070 --> 00:48:07,659 for the CPU. It shouldn't do anything 1445 00:48:07,660 --> 00:48:08,949 important at that time. 1446 00:48:08,950 --> 00:48:10,749 So, for example, if you want to move in 1447 00:48:10,750 --> 00:48:12,159 new columns into the background map, you 1448 00:48:12,160 --> 00:48:14,049 should do this in the blank where you 1449 00:48:14,050 --> 00:48:16,539 have the most uninterrupted time 1450 00:48:16,540 --> 00:48:18,369 and all the game logic of the game. 1451 00:48:18,370 --> 00:48:20,469 I can be done while the screen 1452 00:48:20,470 --> 00:48:21,549 is being drawn. 1453 00:48:21,550 --> 00:48:23,169 But there's a caveat here. 1454 00:48:23,170 --> 00:48:25,359 You cannot write the new Sprite 1455 00:48:25,360 --> 00:48:27,429 positions at this point because OEM 1456 00:48:27,430 --> 00:48:28,599 is going on. 1457 00:48:28,600 --> 00:48:30,729 So what games usually do is they 1458 00:48:30,730 --> 00:48:33,159 write the new updated Sprite information 1459 00:48:33,160 --> 00:48:35,259 into a shadow OEM, which is just a copy 1460 00:48:35,260 --> 00:48:36,279 of the OEM. 1461 00:48:36,280 --> 00:48:38,709 And then during the blank they copy that 1462 00:48:38,710 --> 00:48:40,449 into the real OEM. 1463 00:48:40,450 --> 00:48:42,729 So they copy a block from here from 1464 00:48:42,730 --> 00:48:44,889 any of those sources into the OEM 1465 00:48:44,890 --> 00:48:46,479 as a location. This is not to scale. 1466 00:48:47,830 --> 00:48:49,989 It doesn't have to do that 1467 00:48:49,990 --> 00:48:52,059 by itself because there's a DMA 1468 00:48:52,060 --> 00:48:54,219 function. You just write the block that 1469 00:48:54,220 --> 00:48:56,559 you want to be copied into. 1470 00:48:56,560 --> 00:48:58,309 This location takes a hundred and sixty 1471 00:48:58,310 --> 00:48:59,439 clocks. 1472 00:48:59,440 --> 00:49:01,599 And while it's doing that, the 1473 00:49:01,600 --> 00:49:03,699 CPU keeps running, but it cannot access 1474 00:49:03,700 --> 00:49:06,009 any of the source of 1475 00:49:06,010 --> 00:49:07,089 the source address base. 1476 00:49:07,090 --> 00:49:08,589 So it has to wait. 1477 00:49:08,590 --> 00:49:10,749 But since that code has to come from 1478 00:49:10,750 --> 00:49:12,849 somewhere as well, the only place you 1479 00:49:12,850 --> 00:49:14,469 can put it is into atrium, which is a 1480 00:49:14,470 --> 00:49:15,470 nice use of that as well. 1481 00:49:17,340 --> 00:49:19,619 So pixelate pipeline, let's dig in as 1482 00:49:19,620 --> 00:49:21,659 deep as it gets into the pipeline, and 1483 00:49:21,660 --> 00:49:23,879 this is cutting edge research and some 1484 00:49:23,880 --> 00:49:25,709 of these things have been previously 1485 00:49:27,090 --> 00:49:28,590 not known to the public. 1486 00:49:30,060 --> 00:49:32,159 The pixel is the central 1487 00:49:32,160 --> 00:49:34,589 concept of how the Gameboy draws 1488 00:49:34,590 --> 00:49:35,759 its picture. 1489 00:49:35,760 --> 00:49:36,989 So let's jump somewhere in the middle. 1490 00:49:36,990 --> 00:49:38,849 We have some pixels on the LCD already. 1491 00:49:38,850 --> 00:49:40,829 So that's five pixels already shifted 1492 00:49:40,830 --> 00:49:42,989 out, sent to the LCD 1493 00:49:42,990 --> 00:49:44,519 and the pixel five. Let's say there are a 1494 00:49:44,520 --> 00:49:46,259 few pixels in there now. 1495 00:49:46,260 --> 00:49:48,479 In every step, in every four megahertz 1496 00:49:48,480 --> 00:49:50,549 step, it shifts out one pixel and 1497 00:49:50,550 --> 00:49:51,689 sends it to the LCD. 1498 00:49:51,690 --> 00:49:53,489 It shifts all the pixel, sends it to the 1499 00:49:53,490 --> 00:49:55,259 LCD shifts at the next one, sends it to 1500 00:49:55,260 --> 00:49:57,569 the LCD. You may have noticed here that a 1501 00:49:57,570 --> 00:49:59,669 green button just became red 1502 00:49:59,670 --> 00:50:01,619 because the pixel pfeifle has to contain 1503 00:50:01,620 --> 00:50:03,269 more than eight pixels to be able to 1504 00:50:03,270 --> 00:50:04,889 shift something out. Why that is. 1505 00:50:04,890 --> 00:50:06,599 We'll get to that now. 1506 00:50:06,600 --> 00:50:08,759 We should get new data and fill 1507 00:50:08,760 --> 00:50:10,979 the FIFO and that's what 1508 00:50:10,980 --> 00:50:11,969 the future is for. 1509 00:50:11,970 --> 00:50:14,399 The future fetches background tiles 1510 00:50:14,400 --> 00:50:16,739 and nine eight oh two is right now the 1511 00:50:16,740 --> 00:50:18,269 position of the map that it fetches it 1512 00:50:18,270 --> 00:50:20,309 from. So it reads the tag number from the 1513 00:50:20,310 --> 00:50:22,379 background map takes one cycle in the 1514 00:50:22,380 --> 00:50:24,719 next cycle. It reads the first 1515 00:50:24,720 --> 00:50:26,609 part of the data and the second part of 1516 00:50:26,610 --> 00:50:28,109 the data from the tile rim. 1517 00:50:28,110 --> 00:50:30,389 Because every line of a tile 1518 00:50:30,390 --> 00:50:32,549 is sixteen bits and from that it 1519 00:50:32,550 --> 00:50:34,739 can construct eight new pixels. 1520 00:50:36,150 --> 00:50:38,129 It starts over again, goes to the next 1521 00:50:38,130 --> 00:50:40,199 location, and it can put those eight 1522 00:50:40,200 --> 00:50:42,269 pixels into the upper half of the 1523 00:50:42,270 --> 00:50:44,369 FIFA and then it can just continue 1524 00:50:44,370 --> 00:50:45,479 pushing those pixels out. 1525 00:50:45,480 --> 00:50:47,819 But what is not happening is that 1526 00:50:47,820 --> 00:50:49,349 it keeps pushing pixels and when it's 1527 00:50:49,350 --> 00:50:51,089 done it has to fetch some again. 1528 00:50:51,090 --> 00:50:52,619 Of course, this is all interleaved and 1529 00:50:52,620 --> 00:50:54,059 running at the same time. So let's work 1530 00:50:54,060 --> 00:50:55,060 through this real quick. 1531 00:50:56,110 --> 00:50:58,109 The FIFA is running at twice the speed, 1532 00:50:58,110 --> 00:51:00,479 so it does two pushes until 1533 00:51:00,480 --> 00:51:02,009 the Fed can do one step. 1534 00:51:02,010 --> 00:51:04,769 So push, push. 1535 00:51:04,770 --> 00:51:07,109 And we read the first bit of data, 1536 00:51:07,110 --> 00:51:09,329 push, push, and 1537 00:51:09,330 --> 00:51:11,159 the second part of the data. 1538 00:51:11,160 --> 00:51:12,160 And at that point, 1539 00:51:13,440 --> 00:51:15,539 it cannot put the data 1540 00:51:15,540 --> 00:51:17,129 into the FIFA yet because the FIFA isn't 1541 00:51:17,130 --> 00:51:19,229 empty yet. So Fichus, which is 1542 00:51:19,230 --> 00:51:21,359 to read, has to wait for two more 1543 00:51:21,360 --> 00:51:23,369 cycles here and then. 1544 00:51:23,370 --> 00:51:25,499 So it's idle for a while and then it puts 1545 00:51:25,500 --> 00:51:27,749 the data in. So if you look at the 1546 00:51:27,750 --> 00:51:29,489 memory access patterns, you can see three 1547 00:51:29,490 --> 00:51:31,559 reads and and an idle 1548 00:51:31,560 --> 00:51:32,560 three reads in an idle. 1549 00:51:35,160 --> 00:51:37,019 So again, the FIFA put just pushes one 1550 00:51:37,020 --> 00:51:38,759 picks up the clock at four megahertz 1551 00:51:38,760 --> 00:51:40,379 pauses unless it contains more than eight 1552 00:51:40,380 --> 00:51:41,849 pixels and the fetch runs at two 1553 00:51:41,850 --> 00:51:43,679 megahertz, three clocks to fetch those 1554 00:51:43,680 --> 00:51:44,699 new eight pixels. 1555 00:51:44,700 --> 00:51:47,039 And it pauses in the fourth clock unless 1556 00:51:47,040 --> 00:51:49,649 there's space in the available scrolling 1557 00:51:49,650 --> 00:51:50,969 is done very simply. 1558 00:51:50,970 --> 00:51:52,619 Let's say we scroll by three pixel so 1559 00:51:52,620 --> 00:51:54,179 everything is moved to the left by three 1560 00:51:54,180 --> 00:51:55,349 pixels. 1561 00:51:55,350 --> 00:51:58,019 The first three pixels are just discarded 1562 00:51:58,020 --> 00:51:59,699 and then the next pixel goes here on the 1563 00:51:59,700 --> 00:52:01,619 LCD. So at the end of the line this 1564 00:52:01,620 --> 00:52:03,749 becomes interesting because when we 1565 00:52:03,750 --> 00:52:05,879 want to trigger on one hundred and sixty, 1566 00:52:05,880 --> 00:52:07,439 the faithful may contain the next few 1567 00:52:07,440 --> 00:52:09,059 pixels that we want to actually draw. 1568 00:52:09,060 --> 00:52:11,189 And the fetch is already in the middle 1569 00:52:11,190 --> 00:52:13,229 of fetching the next tile that we also 1570 00:52:13,230 --> 00:52:14,309 don't care about. 1571 00:52:14,310 --> 00:52:16,439 So at this point, it'll just stop all 1572 00:52:16,440 --> 00:52:18,209 this and it has done too much work and 1573 00:52:18,210 --> 00:52:19,559 will be in blank mode, which is the 1574 00:52:19,560 --> 00:52:21,809 reason why a line takes forty, 1575 00:52:21,810 --> 00:52:23,999 forty, forty three clocks instead of 1576 00:52:24,000 --> 00:52:25,590 more logical forty clocks. 1577 00:52:26,700 --> 00:52:28,859 If we have a window, let's say 1578 00:52:28,860 --> 00:52:30,329 the window triggers at position twenty 1579 00:52:30,330 --> 00:52:31,799 six and we're here at twenty six. 1580 00:52:31,800 --> 00:52:33,449 The Pfeifle has some data in the fetcher 1581 00:52:33,450 --> 00:52:35,129 somewhere in the middle it will 1582 00:52:35,130 --> 00:52:37,139 completely clear the FIFA and then the 1583 00:52:37,140 --> 00:52:38,519 FIFA will be stopped because we don't 1584 00:52:38,520 --> 00:52:39,929 want those pixels anymore that are 1585 00:52:39,930 --> 00:52:42,119 already lined up and the fetch will 1586 00:52:42,120 --> 00:52:44,399 switch over to the map off 1587 00:52:44,400 --> 00:52:45,989 the window and the fetch will be 1588 00:52:45,990 --> 00:52:47,819 restarted and then we'll do the tower, 1589 00:52:47,820 --> 00:52:49,229 fetch the data, fetch the data, fetch and 1590 00:52:49,230 --> 00:52:51,059 we'll get the data from the window. 1591 00:52:51,060 --> 00:52:52,769 We can put it into the pixel FIFA. 1592 00:52:52,770 --> 00:52:55,289 So as soon as those are shifting out, 1593 00:52:55,290 --> 00:52:57,479 window pixels will be drawing 1594 00:52:57,480 --> 00:52:59,579 with sprites. There are ten competitors 1595 00:52:59,580 --> 00:53:02,129 that are triggering on the position. 1596 00:53:02,130 --> 00:53:03,569 And let's say here at position twenty 1597 00:53:03,570 --> 00:53:05,819 six, we have a Sprite at that location 1598 00:53:05,820 --> 00:53:07,229 and again the pixel FIFA has lots of 1599 00:53:07,230 --> 00:53:09,779 pixels and fetch somewhere in the middle. 1600 00:53:09,780 --> 00:53:11,999 First we temporarily suspend the pixel 1601 00:53:12,000 --> 00:53:15,029 FIFA. It cannot push out any more pixels. 1602 00:53:15,030 --> 00:53:17,099 We switch temporarily the fetch to 1603 00:53:17,100 --> 00:53:19,229 doing a sprite fetch and 1604 00:53:19,230 --> 00:53:20,339 restarting the fetch. 1605 00:53:20,340 --> 00:53:22,919 So we're getting the sprite information 1606 00:53:22,920 --> 00:53:25,049 and instead of putting it at the end, 1607 00:53:25,050 --> 00:53:26,909 we overlaid with the first eight pixels 1608 00:53:26,910 --> 00:53:29,129 and we mix them onto the pixels. 1609 00:53:29,130 --> 00:53:31,169 And this explains why the FIFA always has 1610 00:53:31,170 --> 00:53:32,879 to have eight pixels in there, because 1611 00:53:32,880 --> 00:53:34,739 that's how it mixes in the sprites. 1612 00:53:37,380 --> 00:53:39,689 This is in stark contrast 1613 00:53:39,690 --> 00:53:40,949 to two other systems. 1614 00:53:40,950 --> 00:53:42,959 So when we just push out pixels at a 1615 00:53:42,960 --> 00:53:45,399 constant rate until the window 1616 00:53:45,400 --> 00:53:47,519 starts, when the window starts, 1617 00:53:47,520 --> 00:53:48,839 the pfeifle gets cleared. 1618 00:53:48,840 --> 00:53:51,029 We are not pushing out pixels for quite 1619 00:53:51,030 --> 00:53:53,249 a while until the FIFA has 1620 00:53:53,250 --> 00:53:54,539 the window data again. 1621 00:53:54,540 --> 00:53:56,789 And which time? At which point it is 1622 00:53:56,790 --> 00:53:59,129 resumed. So it takes forty three clocks 1623 00:53:59,130 --> 00:54:01,229 or more depending on what's going on the 1624 00:54:01,230 --> 00:54:03,059 screen with sprites, it can take even 1625 00:54:03,060 --> 00:54:03,959 more. 1626 00:54:03,960 --> 00:54:05,609 This is on an LCD based system. 1627 00:54:05,610 --> 00:54:07,469 You can do that. You can suspend sending 1628 00:54:07,470 --> 00:54:08,999 pixels on a CRT based system. 1629 00:54:09,000 --> 00:54:11,339 You cannot see, for example, on a C sixty 1630 00:54:11,340 --> 00:54:13,529 four, a line always has to have exactly 1631 00:54:13,530 --> 00:54:15,509 forty clocks because any pixel that 1632 00:54:15,510 --> 00:54:17,919 comes. Too late, will it be shifted 1633 00:54:17,920 --> 00:54:19,030 to the right visually 1634 00:54:20,650 --> 00:54:22,419 so it's not completely accurate that we 1635 00:54:22,420 --> 00:54:24,849 have 40 clocks for pixel transports, 1636 00:54:24,850 --> 00:54:27,579 more like forty three plus and 1637 00:54:27,580 --> 00:54:30,219 the blink area is just the remaining 1638 00:54:30,220 --> 00:54:31,359 line. 1639 00:54:31,360 --> 00:54:32,769 And in practice, this is more like what 1640 00:54:32,770 --> 00:54:35,079 it looks like, depending on what sprites 1641 00:54:35,080 --> 00:54:36,159 or backgrounds you have. 1642 00:54:37,210 --> 00:54:39,639 So I wasn't completely honest about 1643 00:54:39,640 --> 00:54:40,779 how the pixel FIFA works. 1644 00:54:40,780 --> 00:54:42,639 It does not actually store of pixel 1645 00:54:42,640 --> 00:54:44,649 colors. What it does store is the 1646 00:54:44,650 --> 00:54:46,749 information, the original information of 1647 00:54:46,750 --> 00:54:49,149 the bit combinations 1648 00:54:49,150 --> 00:54:51,399 and the source like here, it says 1649 00:54:51,400 --> 00:54:53,529 these are a nine background pixels 1650 00:54:53,530 --> 00:54:54,849 and the same is true with a fetch. 1651 00:54:54,850 --> 00:54:56,889 It does not create pixel colors. 1652 00:54:56,890 --> 00:54:57,890 It creates 1653 00:54:59,050 --> 00:55:01,849 those combinations, plus the information 1654 00:55:01,850 --> 00:55:03,999 which Sprite palliated was or what 1655 00:55:04,000 --> 00:55:05,589 the source was. 1656 00:55:05,590 --> 00:55:07,389 So let's mix these together. 1657 00:55:07,390 --> 00:55:09,009 The Sprite is probably zero, meaning 1658 00:55:09,010 --> 00:55:10,719 drawing on top of the background. 1659 00:55:10,720 --> 00:55:12,879 And let's go through these Sprite 1660 00:55:12,880 --> 00:55:14,949 one zero zero means this is the 1661 00:55:14,950 --> 00:55:17,019 translucent. So the background wins. 1662 00:55:17,020 --> 00:55:19,089 In this case, the Sprite wins because 1663 00:55:19,090 --> 00:55:20,499 it draws on top of the background. 1664 00:55:20,500 --> 00:55:22,179 And this is true for most of those 1665 00:55:22,180 --> 00:55:23,199 pixels. 1666 00:55:23,200 --> 00:55:25,209 And at the very last pixel we can see 1667 00:55:25,210 --> 00:55:27,369 this is a Sprite with palette one 1668 00:55:27,370 --> 00:55:28,809 and translucent again. 1669 00:55:28,810 --> 00:55:30,669 So here the background wins again. 1670 00:55:30,670 --> 00:55:31,899 Let's do this one more time with another 1671 00:55:31,900 --> 00:55:33,369 Sprite that is at the exact same 1672 00:55:33,370 --> 00:55:34,370 location. 1673 00:55:35,710 --> 00:55:38,349 In the first case here, Sprite 1674 00:55:38,350 --> 00:55:40,599 with a palette of zero draws 1675 00:55:40,600 --> 00:55:42,429 on top of the background. Sprite wins and 1676 00:55:42,430 --> 00:55:44,619 in this case, a new Sprite does not win 1677 00:55:44,620 --> 00:55:45,879 over the old Sprite. There's already a 1678 00:55:45,880 --> 00:55:46,899 Sprite at this pixel. 1679 00:55:46,900 --> 00:55:48,279 So the old Sprite wins. 1680 00:55:48,280 --> 00:55:49,599 And this is true for everything. 1681 00:55:49,600 --> 00:55:51,999 And this is how spritzed the draw farther 1682 00:55:52,000 --> 00:55:53,709 to the right. Don't draw on top of 1683 00:55:53,710 --> 00:55:55,479 existing sprites and sprites with higher 1684 00:55:55,480 --> 00:55:57,489 numbers. Don't draw on top of existing 1685 00:55:57,490 --> 00:55:58,479 sprites. 1686 00:55:58,480 --> 00:55:59,829 And this is the last one with the Sprite 1687 00:55:59,830 --> 00:56:01,089 wins again. 1688 00:56:01,090 --> 00:56:03,339 And the playing of the palette 1689 00:56:03,340 --> 00:56:04,989 is only done at the very end when the 1690 00:56:04,990 --> 00:56:06,399 pixel is shifted out. 1691 00:56:06,400 --> 00:56:07,719 So we look it up here in the palette. 1692 00:56:07,720 --> 00:56:09,489 We convert it to a color and we put it 1693 00:56:09,490 --> 00:56:10,989 onto LCD. 1694 00:56:10,990 --> 00:56:13,389 Look it up, converted, LCD, 1695 00:56:14,470 --> 00:56:16,239 another one black. 1696 00:56:17,650 --> 00:56:19,719 And this is how it's also 1697 00:56:19,720 --> 00:56:21,709 done on the color system. 1698 00:56:21,710 --> 00:56:24,219 So starting with the super Gameboy, 1699 00:56:24,220 --> 00:56:25,869 existing games that couldn't really deal 1700 00:56:25,870 --> 00:56:27,549 with this could be colorized. 1701 00:56:27,550 --> 00:56:28,810 And what's done there, there's 1702 00:56:29,890 --> 00:56:31,629 the existing three palettes can now be 1703 00:56:31,630 --> 00:56:32,559 RGB palettes. 1704 00:56:32,560 --> 00:56:33,939 Everything else in the system is the 1705 00:56:33,940 --> 00:56:34,940 same. 1706 00:56:35,770 --> 00:56:37,899 But as soon as we 1707 00:56:37,900 --> 00:56:39,369 shift this out, it looks up. 1708 00:56:40,420 --> 00:56:42,609 RGV color puts the pink pixel 1709 00:56:42,610 --> 00:56:43,719 on the screen. 1710 00:56:43,720 --> 00:56:46,869 Eleven is one that's here. 1711 00:56:46,870 --> 00:56:47,870 Black pixel. 1712 00:56:48,700 --> 00:56:50,979 One more example. There are one from S1 1713 00:56:50,980 --> 00:56:52,179 because that used to be a Sprite with 1714 00:56:52,180 --> 00:56:53,469 palette one. 1715 00:56:53,470 --> 00:56:55,149 Put it on the screen. 1716 00:56:55,150 --> 00:56:56,499 That's the end of the technical part. 1717 00:57:08,620 --> 00:57:09,620 We have five minutes. 1718 00:57:11,700 --> 00:57:13,919 Let's talk about development in case 1719 00:57:13,920 --> 00:57:15,629 you're now interested in doing Gambo 1720 00:57:15,630 --> 00:57:16,229 development. 1721 00:57:16,230 --> 00:57:17,969 There are some really nice tools. 1722 00:57:17,970 --> 00:57:19,919 The redneck's game boy development system 1723 00:57:19,920 --> 00:57:21,839 is a set of command line tools that work 1724 00:57:21,840 --> 00:57:23,549 really nice with make files and your 1725 00:57:23,550 --> 00:57:24,550 editor of Choice 1726 00:57:25,830 --> 00:57:28,769 when you want to debug your code. 1727 00:57:28,770 --> 00:57:30,419 The BGB emulator, which is meant for 1728 00:57:30,420 --> 00:57:32,699 Windows but works really nicely with 1729 00:57:32,700 --> 00:57:34,889 with wine on top of 10 or Linux as 1730 00:57:34,890 --> 00:57:36,839 well. It has a built in debugger, single 1731 00:57:36,840 --> 00:57:38,759 stepping breakpoints, and it has this 1732 00:57:38,760 --> 00:57:41,099 really nice video 1733 00:57:41,100 --> 00:57:42,569 viewer that shows you all the details 1734 00:57:42,570 --> 00:57:44,249 about what's going on. Also really nice 1735 00:57:44,250 --> 00:57:46,199 to run demos and that and see what's 1736 00:57:46,200 --> 00:57:47,200 going on inside. 1737 00:57:48,120 --> 00:57:49,829 And if you want to run it on real 1738 00:57:49,830 --> 00:57:51,749 hardware, there are devices like the EVA 1739 00:57:51,750 --> 00:57:53,909 Drive where you can put in an SD 1740 00:57:53,910 --> 00:57:54,910 card. 1741 00:57:55,890 --> 00:57:58,079 And since we have another four 1742 00:57:58,080 --> 00:58:00,269 minutes, let's talk 1743 00:58:00,270 --> 00:58:02,429 about my favorite peripheral of the 1744 00:58:02,430 --> 00:58:04,559 Gameboy, the Gameboy camera, but not from 1745 00:58:04,560 --> 00:58:06,959 a technical perspective, just how great 1746 00:58:06,960 --> 00:58:08,129 a device that is. 1747 00:58:08,130 --> 00:58:09,199 This is the Gameboy camera. 1748 00:58:10,440 --> 00:58:11,459 You put it in the back of the game. 1749 00:58:11,460 --> 00:58:13,289 Boy, she it's really nice pictures. 1750 00:58:13,290 --> 00:58:14,609 You can print them on the Gameboy 1751 00:58:14,610 --> 00:58:17,519 printer, on thermal paper. 1752 00:58:17,520 --> 00:58:18,749 If it can still get that paper 1753 00:58:20,280 --> 00:58:21,989 and you can get these that you make, you 1754 00:58:21,990 --> 00:58:24,539 can take awesome pictures like that. 1755 00:58:24,540 --> 00:58:25,540 Let's zoom in a little. 1756 00:58:30,600 --> 00:58:31,920 These are really nice pictures. 1757 00:58:33,060 --> 00:58:35,189 Every picture is based on 1758 00:58:35,190 --> 00:58:37,320 the CD that has 14 color pixels 1759 00:58:38,520 --> 00:58:40,889 at a depth of 1760 00:58:40,890 --> 00:58:41,890 two. 1761 00:58:52,250 --> 00:58:54,409 So next time you go on a trip, make 1762 00:58:54,410 --> 00:58:55,849 sure take a Gameboy, 1763 00:58:57,110 --> 00:58:58,110 take a Gameboy. 1764 00:59:09,440 --> 00:59:11,269 Don't forget your Gameboy camera and a PC 1765 00:59:11,270 --> 00:59:12,949 with a parallel port and that one link 1766 00:59:12,950 --> 00:59:15,079 cable that you cannot get on 1767 00:59:15,080 --> 00:59:16,080 eBay anymore. 1768 00:59:17,270 --> 00:59:20,269 So thanks to those people who helped 1769 00:59:20,270 --> 00:59:22,639 debug the Gameboy and 1770 00:59:22,640 --> 00:59:24,739 helped me with the presentation, and 1771 00:59:24,740 --> 00:59:26,899 those people helped me in 1772 00:59:26,900 --> 00:59:27,900 various other ways. 1773 00:59:29,480 --> 00:59:30,559 So in. 1774 00:59:39,710 --> 00:59:41,929 In the series of the ultimate talks, 1775 00:59:41,930 --> 00:59:44,209 this was now the fifth talk, what's 1776 00:59:44,210 --> 00:59:45,210 next? 1777 00:59:46,100 --> 00:59:48,070 There should be a talk next year, right? 1778 00:59:49,370 --> 00:59:51,169 I'm suggesting to talks. 1779 00:59:51,170 --> 00:59:53,359 I'm nominating four, four, three, 1780 00:59:53,360 --> 00:59:54,360 four, three. 1781 00:59:55,430 --> 00:59:57,559 Dominic Bogner to talk about 1782 00:59:57,560 --> 00:59:58,730 the Archimedes. 1783 01:00:04,150 --> 01:00:05,739 And I nominated Janice Hodor. 1784 01:00:14,710 --> 01:00:16,239 Well, that's super for Nintendo. 1785 01:00:16,240 --> 01:00:18,579 It's your choice, you can do these talks 1786 01:00:18,580 --> 01:00:20,409 or you can put a bucket of ice water on 1787 01:00:20,410 --> 01:00:21,410 top of your head. 1788 01:00:25,550 --> 01:00:26,779 Thank you for your attention and see you 1789 01:00:26,780 --> 01:00:27,780 next year.