Bare Metal Emulation on the Raspberry Pi - Commodore 64

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
want to get a bit closer to that authentic retro computer feel let's have a look at bare metal emulators on the Raspberry [Music] Pi hi and welcome to bites and bits if you're into Retro Gaming you've no doubt already set up emulators for your favorite computers on either your PC or maybe in retray and you've been able to play all your games and and have all that fun reliving all of those memories but sometimes it's quite nice to get a little bit closer to the actual original feel of using that computer now obviously you can you can go out and you can still buy a lot of the sort of 1980s 8bit computers and get those set up at home and so on but that does involve a lot of hassle and obviously there's a lot of Maintenance the these machines are now hitting 40 years old and the electronics are are starting to fade a bit so you will need to maintain those and obviously then interfacing them into modern monitors and TVs um does does involve a whole lot of of of effort um and again that that is a hobby in itself so in this tutorial uh I'm going to look at a a halfway house solution where we can get a lot closer to the original fa and indeed we can actually build some replica machines using this technique um but it does then allow us to use Modern Hardware so that we can easily interface then with our our modern game pads and our modern monitors so we're going to be looking at what's known as bare metal emulation so let's first of all have a look and see what that actually is so for this video I'm going to be using a Raspberry Pi as my base um processor so if we think about how a Raspberry Pi is normally organized we have the um Hardware itself and when you first turn that on there is a bios layer that needs to be loaded and that's usually sort of in raw mow or at least in sort of firmware and that loads in pretty quickly on top of that then once it's up and running and the system has access to all of the hardware devices it can then load in the operating system which of course in our Raspberry Pi is usually some version of Linux and then once that loads in we then get into our application and we can load in things like our actual emulators and start playing our games but if we think about this sort of load sequence so when we first turn on the BIOS is is almost instantly um loaded in um that is coming out of some sort of memory device after that then of course our Linux boots up and that does take maybe sort of 10 15 seconds to to go through load that in off the SD card and boot up and then we drop into either our Linux desktop um or or we might have it set up to automatically go straight into our emulator but that's there'll be some sort of messing around get then of course getting our emulator up and running out to our actual computer screen and from there we can start playing our games or or doing whatever we want to do with our system so for our bare metal emulation really what we're doing is we're trying to put our emulator code as far down the sequence as possible so obviously we need to have our bios layer um cuz that gives our code access to the hardware devices but then we don't need to have any operating system layer we can simply go straight into the code that runs our emulator and this really means then that um once we turn our computer on we're really going bypassing all of that sort of modern operating system level and going straight to the code that emulates our our retro computer and and that really just means then that we almost get down to the same sort of instant on that we would have if we had the original hardware and as these um bare metal emulators tend to not have a sort of graphic gaming front end we will also drop into the standard prompt that you would get on the original machine so to put one of these systems together you're going to need some Hardware so we've got our Raspberry Pi as our BAS processor but after that you can be really as original as you want the bare metal emulators tend to allow you to connect the original Hardware up to the gpio pins on the Raspberry Pi so you could if you want just buy an old nonworking computer and then just strip out the insides of that and put in your Raspberry Pi instead and indeed there are some companies who allow you to do this very simply where they will supply you with a readymade original computer all cleaned up and refurbished ready for you to fit with your Raspberry Pi now for me I'm going to use a slightly different approach I'm going to use modern keyboards and so on and really what I'm doing here is I'm I'm going to use um a a little 10-in screen HDMI screen and I can bolt a Raspberry Pi on the back of that so I have a nice little unit there and then I'm just going to use a wireless keyboard to connect to that and I'm really going this route here so that I can really create a number of bare metal um emulators and I can just simply switch them in and out by changing the SD card in the act in the Raspberry Pi and this then using the standard keyboard allows me to emulate a range of these machines using this bare metal technique and again um the downside here of course is that I won't be using an original keyboard so I will have to be careful with the um keyboard mapping um to be able to use the the interfaces on on the actual real machines so that's the basic idea of what we're doing so let's get set up with a Commodore 64 The emulator we're going to use for this is called BMC 64 so if you go to the website for that which is um here and again I'll I'll put the link to this in the description down below and don't forget to also have a look at the main project page on my bytes and bits. co.uk website um where again there's more information and you can follow through the instructions on there now one of the really nice things about this emulator is it also includes some bare metal versions for the other 8bit commodor computers so once we install this we will also have installed the bar metal emulators for the Commodore pet the Vic 20 the Commodore 128 and the plus4 now the actual emulator itself is based on the vice emulator code which is one one of the main commod or 64 emulators for sort of desktop PCS but of course it's been Rewritten and and optimized then for use on the r Raspberry Pi but again running on the Base Hardware of the Raspberry Pi rather than inside an operating system so if we go to this website if we scroll down a bit you'll see it here takes you through sort of various features uh and again one of the main features of this um emulator is that it is designed if if you are trying to build in effect a replica of the machine as we talked earlier on where we can actually hook up uh real keyboards you can put it inside a case in effect you can build a a modernized replica of the computer you want to run um using some um real Hardware but again we're not going to look at that in this particular tutorial so what we want to do is we want to get hold of the actual software to install that onto our um SD card so there are links off here the actual um source code is available if you want to have a look through that and see how it's all put together there are then two ways of installing the software one is where we will actually build up the SD card ourself and install the files on there ourselves but the much easier way then and what I'm going to take you through is using just the built-in SD card image which we can simply burn using any of our SD card burning um software so down here if we download that file that image file it comes down as a zip file so if I come out of that and really all we need to do now is to use something like the Raspberry Pi imager to burn that onto an SD card so we've now got our SD card burnt if we have a look at what's actually inside it so I've just plugged the SD card back into my computer we can see that we have our our drive now and there's a number of folders in here so if we have a look inside the c64 folder you can see that there's a number of files in here and these are number sort of files that help make the Raspberry Pi work but there's also this note then to put ROMs in here so so at the moment the actual emulator hasn't got the ROM files that needs to actually work and you can see that's sort of listed out here so it saying here um that you must obtain at least a minimum number of of these files and what it does underneath that then it actually takes you through and tells you what files you need to put into the system so to get hold of these files then it does give you an example here of two one area but the the actually the easiest way to um get them all in one go is to actually down load a copy of Vice so so Vice of course uses these ROM files as well so if you head across to this web address here again I'll put a link to that in the description if you scroll down you'll find the download files then for vice so you need to just go off and download one of these um again it doesn't really matter because we're not going to be using these as such um but if if you do want to have them play with Vice obviously download the one for for your computer so if if I was to download that it takes me off to the source Forge file um and again I will eventually get my download if we now go and have a look inside that downloaded um zip file for vice once we get down inside it you'll see that again we have we come to a set of folders and again these folders here are are sort of matching up with the ones in our BMC folder so we have a Commodore 64 folder here and inside that you'll see we have a number of ROM files well that's that's what these are these um files in here these the ones with bin at the end of them so we we need to get some of these files across into our our USB drive now we we need to make sure that we get the right files because you can see here um things like the charge in and so on there are a couple of variations on those so if we have a look on our um system over here so we'll need a kernel file a character generator file a basic file the the D1 1541 is a dis operating file just for the hard um floppy disc drive and that's really what we need then to get up and running so if we have a look at this example this actually lets us see which ones are which so if we go across to that if we have a scroll down here we can see that we have um two versions of basic here so we have this basic uh 901 22601 and that then of course is the actual common or 64 basic the one beneath that then is a commodore 65 which is is a computer that never really uh made out into the market so if we have a look in our folder here we should find that we have that basic file there sitting there so I'm going to need to use that so I'm going to copy across my basic file so I'm going to copy that I'm going to jump across onto my BMC file I'm going to paste my file in there okay so we now have that sitting in there if we do have a look back at what it's said to do with it it has to be called just basic no file extension so if I I come in here I'm going to come in to this and I'm going to edit that file name and I'm going to take it all the way down just to basic and yes I do want to change that and we now have our basic ROM installed we now need to get our um go back into our example here so we need a kernel file and you can see that there are a whole range of Kernel files sitting in here so the little descriptions are beside it here do tell you which one's which so um for me it looks like this um if I'm going to sort of use a sort of an original Commodore 64 style computer um then that revision two might be fine or or I might want to use my revision three to get the latest common or 64 version so let's go with this latest one here so kernel 901 22703 so if we go back into our vice um area so back into Vice so it was the kernel we come down here so it's the 03 version that we want so again we're going to copy that and then we're going to go across back to our 64 on our BMC version paste that in there and again we need to get it right down to just the word kernel as its file name and that is the kernel installed so again we need to go through this process then for our um other files um the the the only one which is going to be slightly different is this dis driver so if we come back across into our example we'll see that the drives are up here so we can of course um download it from here so you can see there's a 1541 Drive in there and there's a whole range of um ROMs that we can use but if we go into our vice area I'm going to go up folder I'm going to into my drives and we'll see that there actually is the um dos1 1541 um version two ROM sitting there so let let's let's use that one go back across to my BMC paste that in now again we do need to make sure that that file name matches exactly so let me go pack out here and the file name we need to use is d541 II so let's go back into my folder so again we need to rename this so we need to get rid of that bit at the end and we also need to get rid of the OS okay so I have my basic my kernel my dis Drive I simply need now my character generator file and that should be us ready to go so let's go back across into our um example here to work out what character generator we want so we come down here um we want our character generator file so there we have our characters and there only is one file in here so if we come back across to our oh yes we'll do that come back across to our drives we want to come up one folder into commodor 64 again our character generator here so it's saying here the character generator ROM is the 901 22501 so 901 2501 is that one there let's copy that stick that into our USB drive and then just rename that down to just car gen and that should be fine okay so let's have a look back in our BMC list here and then on our actual um USB drive itself so we've got our bootst we've got our RPI SYM we've got our kernel we've got our character generator we've got our basic and we've got our dis Drive ROM so we should now have everything we need to get that Commodore 64 up and running now you'll see as well there are some other um machines in here which we can emulate and again the process is going to be exactly the same so if we want to use the Vic 20 we will have to go in here to find out what files we need for the Vic 20 and again you can see them listed down here again if we go out to the example page we can see here the Vic 20 um files we can either download them individually from here or we can use our vice installation to pick those files out and just copy them across so again we should have enough information now to get all of these machines all of their ROMs installed so that we can use them but I I'll leave you to go through that I'm just going to concentrate now on the Commodore 64 so the last thing we need to get on on to our USB drive then are some actual programs to run so if we look back on the route of our USB drive you'll see that we have a couple of folders here for our cartridges our discs and our tips so it's really just a matter of getting hold of some of the game files and then putting them into the relevant folder so I've got a few of um d64 so these are Commodore 64 discs which I've I've downloaded again um you'll have to find the yourself they're they're not that hard to find um if you do have a look on my main project page um I I'm able to help you a bit more out there but but once you've got hold of those all we need to do is to put them into the correct folder so if I copy those go across onto my USB drive so in my diss folder there's a commodor 64 diss area and if I paste everything in there then when when I run BMC 64 to emulate my com 64 and ask it for a dis drive it will automatically look in this area for me so we've got all of our discs in place all of our ROMs in place let's see if everything boots up and works so I'm just putting the SD card into the Raspberry Pi which is actually mounted on the back of the screen and if I then turn that on we do have a slight delay with this screen as it sort of initializes itself and powers on but once we actually get through that we should drop into a Commodore 64 so let's have a look at that um just on the screen captur you can just see um the actual delay in getting the commodor 64 up and running so if I start from scratch and turn the power button on now we should get a delay for about sort of eight or so seconds and then we drop straight into our commodor 64 and we are now set as if we were at a real commodor 64 so it drops straight into basic so we can try typing in a little basic program so our usual sort of um little for next Loop so if we then do our print [Music] statement and then our last line is our next a and if we run that that then shows that all of our ROMs and our basic ROM and everything in our character generators are all working correctly now naturally you're going to want to play some games on this and for that we need to get a few things set up now I first off The BMC 64 does not allow you to hot plug USB devices into the system so anything you want to have available to you you need to plug that in before you power on the Raspberry Pi so I have a game controller plugged in and I had that plugged in before I turned on so we need to get that um set up so with this system it is based on fuse so we do need to use sort of the fuse key bindings and so on obviously I was getting a bit carried away here and I did mean to say Vice it is all based on the vice emulator and if if you're not familiar with what those are I'll put a PDF link um on the main project page where you can download and print out a a keyboard overlay but the the main ones you want to use here are are the F12 button takes us into the emulator menu and now we can use our cursor keys to navigate around this so first off we need to come down and we need to set up our um joysticks so we go to the Joy ports menu first of all we need to find out where our joystick is connected so if we go to our USB game pad 1 let's just check if it's in there so if we come in and we'll see there aren't very many options here so it doesn't look like this is going to be the one but if I go to monitor the usb1 data and click on that as I press buttons on my controller you can see that nothing is changing so that's not connected up to our actual controller so if I press escape to come back out here if I go into USB game pad 2 you can see we've got a lot more um options now and um at the top there does say that it has detected zero hats and five axes so so if we come down to monitor our raw data we need to find out which particular buttons and axes our system is using so um we can check which buttons we have so I'm going to press what I want to be the fire button on my controller and you can see that that is coming up as button number eight um the other buttons of course will give up different numbers but the one I want to use as fire is button number eight if I then press i' I've got a hat a hat key on my um controller so if I press left and right you can see there that Axis Three is the one that is changing for my left and right and up and down is Axis 4 so button 8 axis 3 is X1 is our X connection and four is our y connection so if I come back out of that screen there we just need to make sure we enter those in so um we need to use an analog um plus pot x y and buttons that seems to give us the best one so our x axis then if I use my left and right buttons so that's Axis Three my y AIS was axis 4 and my fire button was Button number eight so I want button8 to operate as my fire button but and and that now has set up this Joy Port so if I come out of here we now need to so our game pad 2 is what we're using and it's all set up so I'm going to want to connect that into port number one so if I go to Gamepad uh number two for that so we should now have our joystick all connected up so once we've set up the way we want it we do need to come down the bottom here and click on save settings so that will actually save any of the setting changes we have made to our system so that when we reboot our joysticks and whatever else we've set up will all be restored so let's go and get a game up and running so I can run my games through the auto start a program or dis option so if I go into that you can see that it comes out to my USB drive and we put our games into the diss folder and into commodor 64 and I come I could start up the game idium and I click on that and what it's doing now it's now attached that file as a floppy dis drive to our commodor 64 it's typed in our Command to load um from dis 8 and you can see it is now searching for that file now at the moment we have it set up in its basic settings so it will do everything at proper emulated speed including the very very very slow disc drives again not not quite as slow as tape drives obviously but we do need to go through this process there is an option in the settings to put it into turbo mode and basically what that does is when it's sitting there waiting for dis drives and so on to load and the actual loading of the data itself it just in effect sort of speeds through those because obviously we don't have to wait for any mechanical processes going on but as you can see eventually we do get to the actual data coming off the disk that's loading in then obviously at the standard speed um So eventually that that will actually get the program loaded in here um I I I do promise it will eventually get there so there we go um so this of course is a a hacked version of the um dis file to get us pass any sort of um Pary sort of protection so if we come into here this will then take us through some information screens and this is where we do need to be aware of what the keyboard bindings are so obviously space is is the space bar but the Run Stop Key was a special button on the Commodore 64 which of course doesn't appear on a standard keyboard so the the mapping for that is actually to the Escape key on our standard keyboard so I press Escape key that should head us towards the actual game itself and if we go through there and just get through these screens and then we should drop into the actual game idium and and there we go so we're up playing now with idium and hopefully our our keypad will now work so if I press the fire button that should start the game and we should be into it and there we go so I do warn you I'm not fantastically good at this game but um we can now go through and we can now start playing our our idium so everything is up and running and we have our games all ready for us to work [Music] with now that we've got our commodor 64 all set up and running we're going to want to do a little bit of housekeeping so we're going to want to put um more software onto our USB drive so that we can use that then in our emulators but if I have a look at the properties then of my USB drive at the moment if I pull it up here uh we can see that um because I've used the disk image to create the bootable drive it's come down as only a 300 megabyte hard drive so our SD card although it's a 16 GB card we're only using the first 300 megab off it now if you have created your USB card um using the file download option then obviously you'll have built yours to the full size but most of us I guess will have used the image and we're stuck with this 300 megabytes so let's have a look and see if we can actually make that bigger now the problem we have is um that there are some dis partitioning utilities built into windows so if I go into my windows here and go to the command prompt and startup an administrator prompt so inside here okay so I can use a program called disk part which will let me see what's going on and inside that if I then do a list volumes that will show me all the volumes I have on my on my computer so again my USB card is plugged in here as Drive K and it's saying here it's an fat partition of only 300 megab or 299 now the problem I have is if I try to select volume 12 and then try to extend it windows will give me up an error saying that the fat file system cannot be extended and then that's because the our windows can only extend NTFS and partitions so we're going to need to use a different bit of software to get around around this so there are a range of partition tools that you can use um if you're on Windows um like I am I'm I'm going to advise using this one called Partition Wizard which you which you'll get from this download um here this website here so I scroll down on the home user side there is a free version which has really all the tools that we're going to need for what we're doing here so we just need to go off then and install that so once we boot up this partition wizard you'll see all of your discs listed on on the system and the one we're interested in of course is this disc number five down here drive K and we can see there we have our 300 megabyte partition and then 14 GB of unallocated space so all I'm going to do is I'm just going to right click on that partition I'm going to say I want to resize that all I'm doing then is just going to drag this out and then going to say okay to that it should give me an idea here of what it's going to look like so I'm going to use the whole um USB stick for this drive K it hasn't yet applied that so I just need to apply that and that should then go through and resize my partition so now that's done we should now have our drive as it was before but now using our full our full um SD card so if we now check the information for our um USB drive coming in here you can see that it's now saying that we have a 14.4 GB drive with our um 14 GB now free so I should be able to come across here take my entire um commodor 64 library and then just simply drop that into my commodor 64 discs on the USB drive so really the last thing I want to sort of just show you with this emulator um we did at the start say that this does emulate a whole r range of the Commodore 8bit computers so so let's have a look at the Vic 20 um so again I have gone through the process of installing the ROM files for Vic 20 and I've also loaded a few cartridges into my system so if I go back into my settings here if I come up what I can do is I can go to the Machine menu and in here I can switch the machine that I want to be emulating so I'm going to go to a Vic 20 now it does come up with a number of options here and and sometimes you will have to go and play with which particular version of the Vic 20 you want to go with uh but I know my system that the HDMI Vice 720p um does seem to work quite well so we're going to reboot then back into a Vic 20 and there we go and again we're now sat at an in effect a a Vic 20 but again we can do exactly the same things as we did with the commodor 64 we can go into to our F12 to get to our U main menu we can come down here I can pick up a cartridge um actually actually before we do that we do need to set up obviously our our joysticks for for this one and again that's all done in exactly the same way so let's come down here and we'll configure our game pad 2 and I know that that is exactly the same as before so I need to just set up that and come on that then connect it up to my game pad and then go down and save that settings and then we're going to come up and I'm now going to attach a generic cartridge cuz I have them all as cartridge games uh and let's go down here and one that I like playing is something called Jupiter Lander and let's do that and there we have Jupiter Lander now on our Vic 20 so let's have to got that [Laughter] and you can see there that we have our our lunar lander game and we can play that on our Vic 20 so that's really uh the bare metal emulators for the Commodore series um covered um a really good way of producing a standalone Commodore 64 or or vict whatever you want um especially if you are going to be building a replica machine where you're perhaps putting a Raspberry Pi inside an old case and connecting up the the the original Hardware but want the modern Electronics inside that with the HDMI output and everything so hope you find that useful if you've liked that video please do click that like button and don't forget to subscribe to the channel I look forward to seeing you again in another video very soon and bye for now for more games programming Electronics projects and Retro Gaming please make sure you like this video subscribe to my YouTube channel and visit my [Music] website
Info
Channel: Bytes N Bits
Views: 31,188
Rating: undefined out of 5
Keywords: bare metal emulation#, commodore 64, VICE, BMC64
Id: 53wHr415LPU
Channel Id: undefined
Length: 33min 16sec (1996 seconds)
Published: Fri Oct 20 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.