Sega Game Coding in Assembly - Computerphile
Skills:
ML Maths Basics60%
Key Takeaways
Sega game coding in Assembly Language using Sega Mega CD development kit and custom hardware, with a focus on debugging and development techniques
Full Transcript
this is a cross product Sega Mega CD development kit it's for making Mega CD games um it's dat stamped 1992 which will put it at the start of the mega CD life cycle the Genesis was probably released around '89 maybe a little earlier it was a standalone console before this came along and this was just an extra that fitted onto it it was to add a second processor to the machine an additional Graphics chip and some better audio capabilities as well as a CD ROM drive so you can store an entire CD's worth of game on there this is a special bit of Kit right yeah a special bits of kit for games developers to make the games with so what's your day job I'm a video games programmer I've worked at travelous tals krych and deep silver damster Studios uh I've worked on about 14 titles so far it kind of looks like a traditional Mega CD but it's not it's all molded together and screwed together so it's very much of a Spoke piece of Hardware inside it's got a snazm host board uh and on top it's got a mega CD daugh board and on top it's got the Genesis da board and it's all very custom wide inside so yeah not exactly a mega CD inside it's got two sets of switches one for the Sega Genesis side one for the Mega CD side it's got dip switches to configure things like Po or ntsc region settings it's got the SCSI ID for it to plug into the PC uh one for each side um it's got switches to enable the main CPU and the sub CPU so you can uh turn off the mega CD side and just run the Genesis it's also got this big emulator button here so that you can either emulate the CD drive through the PC with a big Isa card or you can set it to run from the CD drive itself so you can pop a burnt CD inside on the sides we' got uh a really big heat sink is a very hot component here it's also got the line out at the side rather than the front it's got an SCSI Port direct to PC through a snazm interface card it's also got an emulator port with a very special cable and that's for the CD ROM emulator the rest is pretty standard it's got a SC out and RF out and the usual audio outputs from the mega CD and again the bridge doesn't come open that's that's molded on so this thing can't be taken apart and a very annoying little whiny fan there which is quite loud that kind of looks a bit aftermarket that fan isn't it it does a little bit you can tell that they've used a real Sega Genesis shell and they've put some special Hardware inside it so there are some holes here where there used to be ports and they were no longer off what can you do with it then I mean tell us why you're showing it us today uh I'm going to show off uh a game that I've been developing on it for the past three years in raw 68,000 Assembly Language uh so I've got the snazm interface card to plug it in which is a big Zill linkx chip it's also got what looks like a battery here but it's actually the license key to use the software if you ever use qbase or something like that that comes with a dongle it's a similar thing got the nice snazm 2 logo on the back there so I'm quite happy I managed to find one of these I'm going to plug this in I'm going to fire up my game I'm going to show you how to use the debugger I put the iso card in the machine it's just booting Windows 95 now this is AMD k6 200 mahz machine um it was5 from a car boot sale it was the only one I could find that could get the ISA car to work cuz the bus had to have uh specific timings on it it also fails to boot one in three times so yeah it's a bit old and knackered but it does the job um and with this thing I've managed to make my entire game engine and game so um I won't argue with it as long as it keeps booting now and again I'm happy with it and why is it that you have to use an old machine for this is this just is it an interface thing or what's this it is yeah um before PCI we had Isa which was a big black slot and this is on the motherboard is it this is on the motherboard yeah of the PC the Sega card is a big heavy Isa card let's fire it up and I'll show you some code uh the driver is already loaded it's already in the the auto exact dobat uh so the snazm card's ready to go it's all plugged into the back of the uh development kit via looks like cable very oldfashioned uh kind of C yeah it's it's a it's a parallel cable but it serves a different purpose here so this is part of the Tanglewood code base Tanglewood is a game that I'm releasing next year on real cartridge for the Sega Mega Drive and it's coded in raw 68,000 Assembly Language so I'm going to go and show uh a couple of lines of assembly we've got here the entry point which is the first line of code that the uh debuger is going to run first we're going to jump to a connect debuger sub routine because it's a development kit it needs the register set up in a certain way it needs the the uh CPU Vector table set up in a certain way and because it's a mega CD based kit we have to restore the horizontal interrupt which is a special thing you have to do specifically for this kit so afterwards we're then ready to go and we can type arbitrary code I'm going to go ahead and do something mundane here uh so if we move a long words worth of data let's say literal 32 to register d0 then we move a long word literal 16 to register D1 and then we're going to add the two together with the adop code so add long words worth of data d0 and D1 together and we're going to save that so basically what you're doing here is you're going to use some very basic assembler language to to add a couple of numbers together but using the the but using the real dev kit yeah I'm going to show you how the debugger works and uh how to view the results of that as well um so I'm going to go ahead and build that I've got a batch file set up ready it's quite a long command line to do this uh and there we go that's built ready okay so if I click on the power first of all the ACT light comes on and the right protect goes off so it's written the ROM ready and then it's ready to go the screen's blank so if I open up the debugger here and this is an old MS DOS based debugger mostly done with keyboard shortcut so I can go to that CPU entry point function that we had there and there's the code we just wrote move 32 to d0 move 16 to D1 and then add d0 and D1 so the first thing we do is reset the CPU use of hit execution reset processor and then we can start setting break points so if I hit F5 that'll set a break point on that code and I can hit nine to go that's running the executable that's hit that break point I've got the register's window down here so we can see what's going on so our first command here is to move 32 to register d0 in HEX obviously so if I step once we can see that d0 changes to 32 and then move 16 to D1 so we can see that D1 changes to 16 in HEX and then add the two together so add d0 to D1 and that's going to store the result in D1 and there we go was that actually running on that dev kit then yeah uh this this executable is running on this dev kit uh with the debugger attached to it so that we can set break points and view real time values like the memory and the registers as it's running and for people who've not done much in the way of developing so a break point is where you can sort of pause the program is it yes it's where you can pause a program at a specified line so you can see what the state of the processor is in at that point in time figure so something's going wrong you can if something's going wrong you can break a specific line of code and view the memory and see what happened I've got a demo this is the main character from my game running around in Sonic land this is just a small demo I used to teach programming how to set break points how to watch values Etc how to monitor memory it was just a very small window here where you can push a thing around with the little physics engine I've got written I'm not a developer but it looks quite complicated and laborious is it is it difficult it it is but you can break it down to very simple steps and you can learn one thing at a time um it took me about 3 years to learn Assembly Language and how to code for the machine but it all broke down to very simple steps like I showed you moving one number to one register another number to another register and then adding two the together they're all three very simple steps and you can build on that from that you can learn to subtract uh multiply divide uh once you can do that you can code a very simple player system where you're adding velocity to a player position Etc uh add gravity you then can come clamp it to the uh uh the floor height Etc so using very simple op codes like that it doesn't take that long to get a very simple game system running the tricky bits working with the uh graphics and audio Hardware in here but even then all that can be broken into Sly simple steps and do you have to end up keeping a lot of this information in your head though uh yes and now um I I write a blog um so when I started learning 68k assembler um I made sure every line of code I wrote everything I found out I blogged on my website um so that I can come back to it when I forgotten bits or I'd messed up I need to backtrack you did that kind of like a diary but could anyone else have a look at that if they wanted to yeah sure I'll drop it in the uh description your game then where are you at with it now I finished the first level which is split into three acts and it's got most of the main mechanics running it's now on Kickstarter so I've used the demo to to try and generate some hype for the game there's a ROM you can download you can play using an emulator Windows Mac and Linux even some handheld consoles have some emulators so you can put the ROM in there and play it on there if you got something like an ever drive cart which is a flash cart that you can put inside your mega drive to put a ROM on you can actually play the game on your real console at home do you think there are a lot of people out there still working on this kind of equipment I know at least one other developer who is making a game on cartridge I know one other person with one of these machines in in Australia it's the other known working kit I know of um but other than that it's it's quite a rare quite a rare thing to do there is a small home R Community there's some forums you can look at for advice and stuff and I'm assuming the 6800 was in other machines as well other devices as well what yeah it was uh there were Taris and Amigas based on the 68k um lots of embedded microcontrollers were based on it it was a very widely used chip does that mean that a lot of the language that you're using for this is the same across those as well yeah it certainly applies elsewhere yeah so you could potentially Port things backwards and forwards yeah you could do yeah the only specialized Parts really the graphics and the sound Hardware those have to be redone uh but the core language itself is is usable across multiple machines we'd like to thank audible.com for supporting computer file and if you go to audible.com Compu file there's a chance to sign up for a 30-day free trial and download a free audio book now today I'd like to recommend the book that I first listened to as an audio book which is The Hobbit um back in the day I had a tape and book and it was very heavily Abridged and every time you got to the end of a page there was a ding sound and you had to turn the page well fear not go to audible.com you can listen to the whole unabridged version of The Hobbit it probably needs no introduction from me so check out The Hobbit on audible.com and thanks once again to them for supporting computer file he'll help you out by giving you his color n changes to Yellow so now that he's yellow he can glide so we can then get past gaps so there we go we can fly over that big gap there continue on but of course time isn't on your side so it's going to change
Original Description
Audible 30 day free trial: http://www.audible.com/computerphile
Coding an entire game in assembler. Matt Phillips is creating a brand new game for a 25 year old console.
EXTRA BITS: https://youtu.be/hUUYJ5_zbcc
More info on Matt's Project: http://www.tanglewoodgame.com/info
Thanks to The National Videogame Arcade: http://bit.ly/Computerphile_NVA
http://www.facebook.com/computerphile
https://twitter.com/computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: http://bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. More at http://www.bradyharan.com
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Computerphile · Computerphile · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Follow the Cookie Trail - Computerphile
Computerphile
EXTRA BITS - Follow the Cookie Trail - Computerphile
Computerphile
Musical Floppy Drives - Computerphile
Computerphile
The Hair Algorithm - Computerphile
Computerphile
Getting Sorted & Big O Notation - Computerphile
Computerphile
Quick Sort - Computerphile
Computerphile
Hyper History and Cyber War - Computerphile
Computerphile
Entropy in Compression - Computerphile
Computerphile
Original Elite on the BBC B - Computerphile
Computerphile
IP Addresses and the Internet - Computerphile
Computerphile
A Career in Video Games - Computerphile
Computerphile
Error Detection and Flipping the Bits - Computerphile
Computerphile
Programming BASIC and Sorting - Computerphile
Computerphile
Birthplace of the World Wide Web - Computerphile
Computerphile
Punch Card Programming - Computerphile
Computerphile
Programming Paradigms - Computerphile
Computerphile
CERN Computing Centre (and mouse farm) - Computerphile
Computerphile
Error Correction - Computerphile
Computerphile
Home-Made Code - Computerphile
Computerphile
Security of Data on Disk - Computerphile
Computerphile
Gesture Controls - Computerphile
Computerphile
How Intelligent is Artificial Intelligence? - Computerphile
Computerphile
Encryption and Security Agencies - Computerphile
Computerphile
Virtual Machines Power the Cloud - Computerphile
Computerphile
Hacking Websites with SQL Injection - Computerphile
Computerphile
How Huffman Trees Work - Computerphile
Computerphile
Cracking Websites with Cross Site Scripting - Computerphile
Computerphile
Cloud Computing (Cloudy with a Chance of Pizza) - Computerphile
Computerphile
Texting Cabbage with a Recorder - Computerphile
Computerphile
Hashing Algorithms and Security - Computerphile
Computerphile
How YouTube Works - Computerphile
Computerphile
How NOT to Store Passwords! - Computerphile
Computerphile
A New Golden Age of Video Games - Computerphile
Computerphile
A Universe of Triangles - Computerphile
Computerphile
Cross Site Request Forgery - Computerphile
Computerphile
The True Power of the Matrix (Transformations in Graphics) - Computerphile
Computerphile
The Great 202 Jailbreak - Computerphile
Computerphile
EXTRA BITS - Printing and Typesetting History - Computerphile
Computerphile
Triangles to Pixels - Computerphile
Computerphile
The Problem with Time & Timezones - Computerphile
Computerphile
The Visibility Problem - Computerphile
Computerphile
Lights and Shadows in Graphics - Computerphile
Computerphile
The Penguin Barcode - Computerphile
Computerphile
Typesetters in the '80s - Computerphile
Computerphile
The Font Magicians - Computerphile
Computerphile
The Little Mac with the Big Bite - Computerphile
Computerphile
EXTRA BITS - More on the Original Mac at 30 - Computerphile
Computerphile
XP to Ubuntu with an 8yr old Hacktop - Computerphile
Computerphile
EXTRA BITS - Hacktop Real-Time Boot Comparison - Computerphile
Computerphile
EXTRA BITS - Making a Bootable USB in Linux - Computerphile
Computerphile
EXTRA BITS - Installing Ubuntu Permanently - Computerphile
Computerphile
The Dawn of Desktop Publishing - Computerphile
Computerphile
What is Bootstrapping? - Computerphile
Computerphile
Reverse Polish Notation and The Stack - Computerphile
Computerphile
Home-Made Z80 Retro Computer - Computerphile
Computerphile
Should Everybody Learn to Code? - Computerphile
Computerphile
Programming in PostScript - Computerphile
Computerphile
Heartbleed, Running the Code - Computerphile
Computerphile
YouTube's Secret Algorithm - Computerphile
Computerphile
YouTube Search & Discovery - Computerphile
Computerphile
More on: ML Maths Basics
View skill →Related Reads
📰
📰
📰
📰
I'm a self-taught programmer who only learned programming to develop my own application (Wander). What should I do to gain a Computer Science (CS) perspective and scale the project more effectively?
Reddit r/learnprogramming
I graded my own ML option forecasts. Here's the Brier score.
Dev.to · connerlambden
Yes, another tree classifier. Here's what building one from scratch taught me.
Dev.to · new_char
Machine Learning for Beginners: A Simple Guide That Actually Makes Sense
Medium · Machine Learning
🎓
Tutor Explanation
DeepCamp AI