Hi KFest it’s Tamas Rudnai speaking from California and today I am going to talk about Steve ][ a brand new emulator I am going to talk about why did I do that and how did I do that so let’s get to it I would like to dedicate this talk to my Father He was a mechanical engineer a plumbing engineer, designing water supply system and heating system for large buildings And he was a dedicated man He learned AppleSoft BASIC to be able to write software for himself to ease his work Part of his job was budget calculations which means you have to estimate the money you need to realize a project So for that you need to go through all the drawings and calculate every single components you need, like how many miles of pipes and how many screws you need and different components you need for the project And it was a tedious job. You needed three or four engineers to work on this for three weeks. Three weeks! And he was able to do this on the Apple ][ in just three days Two years ago he passed away and I traveled back to Hungary for a funeral When I went down to the basement look what I found The old Apple ][ computer he was using This was a Taiwanese clone we had to smuggle into Hungary Hungary was part of the Eastern Bloc countries so we were not allowed to buy any Western computers or any Western devices We had to have some friends to be able to bring the motherboard and all the components from Western Germany — that’s why you can see the keyboard is German My father was using this computer for his job as I mentioned and sometimes it took a long time to finish his calculations. I remember that he came to the kitchen for a very good lunch, you know, one that takes one and a half hours to eat everything and and then have a nice coffee and talk to the family and everything and then he went back and it was still running As far as I know sometimes it took three maybe four hours to do all the calculations That let me thinking: How long would that take to run that software on a modern computer. Actually not a modern computer I wanted to know how long would that take if this Apple ][ computer was built using modern technology You know the 6502 would be much faster and we had hard drives or SSD drives instead of floppy drives Many people are asking me why? Why do you want to create your own emulator? And you know what? This is a valid question There are thousands of emulators out there and I could just load my own software on it and measure the speed Every time they are asking this question, this is my answer to it: I just want to have fun But it is not only about having fun There are many other aspects of a project like that For example you have the benefit of controlling speed, rendering techniques and of course you learn a lot of other things You learn about Apple ][ hardware you learn about how AppleSoft BASIC works in a deep level you learn about 6502 in deeper level than ever before And maybe also about the host computer And hopefully you can explore something new Something new that hasn’t been explored before Like inventing some new techniques emulation techniques Sharing is caring so I really believe that information needs to be shared with the peers and of course the next generation Before we go any further on this journey we would like to know how long does it take to run this simple program It just counts from 1 to $FFFF and prints the results to the screen On the original Apple ][ it takes almost half an hour This is a significant amount of time so we have to fast forward this video You can see the stopwatch on the top of the screen and you can see that it is going crazy right now and it is almost over you can see that it is 31 minutes and it’s still counting
it is almost done just a couple of more… still running and it is done So it takes a lot of time I just wanted to measure in the early stage how fast my emulator is so I injected this very simple program into the memory to address zero and it does nothing else nothing fancy just jumps back to address zero so it executes itself again and again and again Same as this puppy As you can see even if you are catching your tail it is not very useful except you can see how fast it is going to happen So there’s the number I came up with The first number is the MIPS (Mega Instructions Per Second) so how many millions of instructions executed in one second. This number is also known as Meaningless Indicator of Processor Speed because we don not really know how fast it is But the second number is maybe more relevant to us because we know that the original Apple ][ is running at 1 MHz and compared to that, Steve ][ is almost 1 GHz so I think this was a significant speed increase. The next obvious thing to do was to emulate something meaningful For that I injected something else into the memory and that was the Apple ][ ROM. I obviously injected the Apple ROM into the appropriate memory location and also made some 6502 initialization in order to be able to run the ROM And the result is: Wow! What just happened? If you want to know why am I so excited just take a look at these guys It is printing out Apple logo and it is doing it in backwards The only question we have left is how are we going to display this logo on the screen? In order to be able to display the character on the screen, we need to pick up the character from the text memory and push that character into the character translator, which is a very simple routine it just picks up the Apple ][ ASCII code and translates it into Unicode Then we can build up a string from these characters and display it on the screen using a special font set and… finally! We have got the apple logo on the screen This was really a turning point because now I knew I can create my own emulator The emulator started to grow from here I had to work on the graphics emulation and graphic emulation is a big deal for me because this was one of the reason I fell in love with computers: The graphics, right? And of course had to work on the disk emuation, because without disk emuation you got nothing. You only can type some commands into the Apple, but nothing else You cannot load any programs play games etc. So this had to be done. And of course after I have finished disk emulation, I have got DOS loaded from the disk. I could get the catalog and load the software from it… I was so happy And of course I could play my favorite games on my emulator Hard Hat Mack one of my favorite and the one and only Q*bert Before we talk about speed of Steve ][ I would like to make a disclaimer I was comparing Steve ][ to other products of course I wanted to know how well it is doing and I really like those emulators I am going to compare to I really appreciate the efforts people put on those projects so for that reason I am not going to tell you the names and please don’t even ask not even personal emails, because this is not a war. It does not really matter which products I am talking about I am going to create a compression chart without telling you the names of these emulators. Emulator 1 is very popular and it is a high quality product and I really like it It was able to make 34 MHz on my computer Which is really good — 34 times faster than the original Apple ][ computer Emulator 2 was a little bit faster It is 120 MHz
Right? So it is 120 times faster than the original Apple ][ which is brilliant! I mean, come on! When i checked the speed (of Steve ][ ) I was expecting to have some degradation (to the initial measure) and I was right. It showed 352MHz which is very good. I mean it is two times faster than the competitor So i was happy. However, I was thinking why did the speed degraded that much? So I was tweaking the code until I have got 482 MHz And this was just a little reorganization of how do we access to the memory by different instructions But can we go higher? And the answer is Yes, of course we can! With a little more tweaking with the code I was able to do 521 MHz This was the point when I thought okay, no more That’s it! I am happy. But then in the middle of the night I woke up started to walk up and down thinking about this and I had new ideas. I have realized not all the instructions need to access to the memory in the same way And I was able to make 721 MHz with that technique And if you thought it is over sorry it is not. I was thinking further how do I do the memory management Completely rewritten the way memory pages and memory access handled and I was able to go up to 900 MHz. And of course I didn’t stop with that I started to work a little bit more and more on the technic and finally I got to 1.3 GHz This speed is so high that everything is affecting the results So if you are recording the screen or running some apps on the background that is affecting the speed. Also (speed is affected by) how you are compiling the code because how the host computer CPU works is that you have several level of caches and branch predictions and loads of other techniques in modern computers and if you are outside… the memory access is outside of this cache then you are out of luck. You are degrading the speed a lot So in one compilation I was able to reach the 1.3 GHz and the other compilation it went down by 200 MHz, so it was only 1.1 GHz To put the speed into retrospective, do you still remember my original code I was using to test the speed? Yes, here we go Just a reminder at original speed it took 31 minutes to run Let’s crank up the emulator all the way up and because I am recording the screen it won’t go up to 1.3 GHz. It is only 1.2 something Anyway so let’s run it and that’s it That was it. The 31 minute run only takes two seconds on the emulator Let’s just calculate how long that would take to run that software my Father was using. That software was running three to four hours each time We are going to count as four hours… and this is how many minutes this is how many seconds If you want to know how long does it take to run on Steve ][ we just have to divide it by the speed increase And it is going to be 11 seconds My Father would be really happy with this results All right, enough talking let’s do some action! Let’s power it on you can hear the disk activity It is because the disk sound emulation is on You can turn it off if you want but usually I leave it on just to hear that we are doing something with the disk, like catalog We also have a Quick Disk Mode Quick Disk Mode is great when you want to load something quicker Right now it is off and if we are loading Renumber you will see it takes a couple of seconds to load that program. Yes And now we can see that the Renumber program is in the memory but if we turn Quick Disk Mode on… clear everything so it is no longer in the memory
right… and we get the catalog It is really fast, right? If we are loading Renumber 3… 2… 1… Go! So it is fraction of a second. All right and also if we reload DOS it is less than a second and that is loading DOS 3.3 and Integer BASIC You can actually see that Integer BASIC is loaded All right, let’s see what we have got on the toolbar We have got a speed selector so you can select what speed do you want to use the emulator with You have got the monitor selector so you can turn on CRT mode, which is scan lines plus some other rendering techniques to look like as a CRT monitor and you can use Green phosphor, Amber or White mono monitor. We just leave it in a Color mode right now. And of course volume buttons in here On the left hand side we have got the CPU mode selector I am going to talk about it later And the Game Input selector And Copy / Paste functions And that is it I think that are the main functions. Oh, on the bottom of the screen you will see a real speed indicator which is measuring the actual MHz. You can see that right now it looks like it is just following the same number but actually it really measures the actual speed of the CPU All right It is time to play Donkey Kong All-time favorite! Let’s load the disk and make sure Quick Disk Mode is on because we do not want to wait and now we just need to power it on As you can see it loads really fast less than a second. I turn on CRT mode because it looks better in my opinion it is too loud you will here me better if it is not that loud, right? All right. You can play Donkey Kong or any games in Normal Mode as well but if you turn on Game Mode the screen refresh rate cranks up to 60 Hz 60 FPS, and also the input lag is going down from 33 ms to 1.5 ms it is much better in my opinion for games and… oh… I did not expect that one All right. Anyway Donkey Kong is great I am not And we have Hard Hat Mack now we can start playing too loud… Hard Hat Mack is really great with keyboard I think better than with joystick, so I am just playing with keyboard and I am still still not good at it All right Let’s Wavy Navy… Paddle is on and start the game. You can see that the little ship is following the mouse cursor It is because I am assigning the mouse cursor into certain joystick positions and Wavy Navy is almost one to one assigning joystick position to ship position We can actually exploit this behavior in our game It is kind of cheating but anyway I place the mouse cursor on top of the helicopter and just keep shooting It is really easy to defeat the enemy this way. I wanted to show Eco Mode. To understand what Eco Mode is, I am going to load Merlin assembler Let’s do the Quick Disk Mode and power it on As you can see Merlin works perfectly in Normal Mode and if I take a look at the Activity Monitor not this one but in here
actually this guy… so this is Steve ][ If we take a look at how much CPU cycles it takes from the host computer, it is around 4%, which is not that bad, right? But if I turn on the Eco Mode then it goes down to 0.5% and it goes down for good That is because Steve ][ recognizes that the software is only waiting for keyboard input and until we press any button Steve ][ is in Pause mode If i press a button and go back here we can see that CPU goes up a little bit and then goes back again because it is waiting for keyboard input again press another keyboard and we can see the activity This is really cool especially when we are using Merlin To show you what it means I am going to load Macro Library We can see that we have our software let’s just speed it up it is 300 lines of source code If we are going to do a compilation it takes quite a while to compile this code, right? Normally what would you do is to go here and then crank up the CPU speed manually, until the compilation finished but in Eco Mode you do not have to do that. We are in Eco Mode we are cranking up the speed up to max and we can still see that it does not take much CPU cycles from the host computer But if I say compile and number three… maybe bang! It is finished. So it is really fast So the advantage is that you can use the speed of the emulator while you can still save the the battery on your laptop So for example if you are working on on an airplane or go to McDonald’s to work on your project you can still do it That is Eco Mode If I turn back to Normal Mode again, guess what… it is 100% All right Oh… You are still here? That is great, because I have some good news for you In the last couple of months many people were asking me how can they test Steve ][ and when is it going to be available, how much does it cost Today I am going to announce that Steve ][ is going to be available for free No cost at all, no dollars it is just free and it’s going to be open source. You can download it, you can compile it for yourself, you can play with the code, you can modify it if you want It is under GPL v3 and I really hope that some of you guys will enjoy Steve ][ as much as I do I really hope that you are joining to Steve ][ team and make it even better Just follow the link and I will make this link available on KansasFest forum and also on Facebook, so bear with me and please let me know what you think Thanks for watching! Before you go away I would like to thank to these guys You may know Peter from Total Replay He was a dear colleague of mine, sitting just a couple of desks away from me Thanks Peter for helping me to understand how disk works! David, you may know him because of Booti device. Thanks Dave to help understanding how speaker works Also Costin who is my colleague and dear friend. Thanks Costin for helping me on understanding emulation technologies Also I would like to say thanks to Arpad Darvas, he is a very good friend of mine he had great ideas about how to improve the emulator Dumitru, you are awesome, you helped me a lot Mario, thanks for letting me know how your Commodore emulator works. It helped me a lot as well to understand
And of course the entire Apple II Enthusiasts group on Facebook, your guys are awesome! And last but not least thanks KansasFest! Great great stuff!