
Today, I will be coding an emulator for a fake minimalistic CPU I have made, called the Gypsy 15. Let's create a fake ad from 1975, introducing the Gypsy-15 to the world.
Behold! The new Gypsy-15 4-bit central processing unit, capable of storing and manipulating binary numbers from 0 to 15! With 4 data registers (R0, R1, R2, and R3), you can add values together with a number of instructions, including STOR, ADD, and SUB! Be the first kid on your block to own a home computer with the new Gypsy-15! Buy one today! (Only $55.75!)
There you have it. An extremely simple CPU that I just made up. Oh, and if you're wondering, the syntaxes for the instructions are:
STOR [REGISTER] [VALUE] (Places the binary [VALUE] into register [REGISTER].)
ADD [REGISTER] [VALUE] (Adds [VALUE] to register [REGISTER].)
SUB [REGISTER] [VALUE] (Subtracts [VALUE] from register [REGISTER].)
Sure, they are pretty basic functions, but they're fictional. Now, let's begin. Say a user has written this code for our 1975 4-bit CPU:
STOR R0 0011
ADD R0 0001
SUB R0 0010
This program stores the binary-equivalent of the number 3 into Register 0, adds 1 to the register, and subtracts two, leaving us with a final value of 2. Now, before these instructions are executed by the CPU, they are changed to binary instructions by an assembler. Their binary equivalent might be:
0000 0000 0011
0001 0000 0001
0010 0000 0010
When the CPU reads each binary value, it manipulates the registers based on what the user has specified. Now let's imagine I am a Gypsy-15 fanatic living in the present day, and I would like to write a Gypsy-15 emulator. This would be an extremely simple emulator to write. Now, let's begin.
First, I select C++ as my programming language to write the emulator in because of its versatility and wide range of functions. I declare some variables to emulate some of the CPU's internals, including four specific variables to emulate the contents of the CPU's registers (R0, R1, R2, R3).
I must now code the area of my program that executes when it loads. I insert code to show a dialog that allows a user to select a file, and when I have the full file name, I must open that file as a binary file, and not a text file. Why? Because it is not a text file. It is a data file. A simple way to do this in C++ is to use iostream.h, along with io::binary, to read a file and store its contents in a buffer. Once this section is coded, I must now move into the processing of the code.
My program now has the contents of the file stored in a variable, and can read from it and act accordingly. I would do this using string manipulation, and I would initiate a loop that analyzes every four digits it comes across in the file. This part basically defines an emulator. A good definition of an emulator would be a program that analyzes binary opcodes and reacts accordingly. In most cases, you will be using a loop to analyze these values.
Inside the loop, my program acts accordingly based upon what four digits it is processing. For example, if the current instruction being analyzed is 0000, my program would know it is going to store a value in a register. It would look to the binary value next to it (which in this case is also 0000), and would know that we are dealing with R0. Then, it would look right once more, and see it will store binary value 0011. So, my program knows to store 0011 in R0. This is how an emulator will process all of the instructions it is given.
Now, since my program knows exactly what to do, it will react. It takes the binary value 0011 and stores it in its variable that emulates register R0. After this, it would skip two values in the list of instructions (because these values were used as arguments in the instruction just processed), and the program will move onto the processing of the next instruction. This should occur until every instruction entered has been processed. Your emulator will have to be able to process (almost) every instruction a CPU can process, but luckily, your life might be a bit easier.
A lot of CPUs group similar process together using a particular digit of the instruction's binary counterpart. For example, all instructions that will perform mathematical processes on registers will begin with the digit 1. This means that on a CPU, addition might be identified as ?1000?, subtraction as ?1001?, and multiplication as ?1010?.
Since CPUs and their emulations deal with binary values, there will be a lot of mathematical functions that you might have never heard of before, including bitwise operations, which deal with changing individual bits of binary values based on another value, and bit shifting, which will change the position individual bits. C++ includes many functions that help to accomplish these processes.
Emulator programming is a complex subject. Just a little warning to you: although it is possible, programming an emulator using a simplistic programming language will make your life even harder. C and C++ can handle complex mathematic processes, so they are good to use. Visual Basic can handle programming simple emulators, like CHIP-8 and Game Boy, but I would not recommend it for creating next-gen emulators. And I would not recommend using Javascript to program an emulator at all. Basically, the more sophisticated the programming language, the easier it will be to program an emulator in (to a certain extent! I would not program an emulator in assembly language!).
Another thing: if you plan to emulate next-gen consoles (PS3, Xbox 360, and even the Wii), you may have an extremely hard time, even if you use a programming language like C++. Because these consoles handle such complex mathematical processes, it will be hard for a common computer to recreate all of the parts necessary to accomplish a decent emulation. Think about it: you don't see an average computer emulating a super computer!
(Just a little bit of information that may help some of you. The Zilog Z80 CPU is emulated all the time, and has been used in a variety of video game consoles and 8-bit computers of the past. A document can be found here that will help you along with decoding Z80 opcodes if you ever have to emulate this CPU.)
Many beginners like to code emulators for computers that processed CHIP-8. CHIP-8 was a programming language used to simplify the creation of video games, and includes only 35 opcodes. Technically, you would be writing a programming language interpreter if you created an emulator for CHIP-8, but the way CHIP-8 works is so close to the way a CPU processes instructions that it is a good experience to write one!
Now you know exactly how to code an emulator. Remember, all computers are different, so all emulators will be different. Some will be harder to code than others, but it will be worth it when you can relive the memory of playing that old Pong game on your black-and-white television.
I am debating whether or not to write a third part to this series. It would cover the emulation of specific parts of the computer, including memory, the call stack, and graphics. Please tell me if you would like to see a new addition!
Would you like to be a Community Voices blogger? If so, please send a letter of interest and a sample blog entry (what you would post here if you were already a blogger for us) to forums@pcworld.com. We'd love to hear your perspective.
Do you find yourself emailing the same people over and over? Here is a way to create pre-addressed emails and launch them with a single mouse click and no typing (because clicking and typing are entirely too much work).
First of all, to get the most out of this tech tip you'll need to read and configure your desktop using my Ultimate Desktop Layout tech tip (click here to read the tech tip). If you choose not to arrange your desktop as mentioned in the earlier tech tip, this tip will still work, it just will not have the same punch.
Step By Step
1. Find an MS Outlook shortcut on your Quick Launch bar OR on your Start Menu OR on your desktop and with your "right" mouse button drag and drop the icon somewhere on your desktop. When you release your right mouse button a context menu will appear asking if you want to copy or move the icon. Select copy. You should now have another MS Outlook shortcut on your desktop.
Click here to view an example image.
2. Right click on the new MS Outlook shortcut and click Properties on the context menu.
Click here to view an example image.
3. On the Properties window add the following characters to the end of the Target path which ends in "?outlook.exe". The characters are { /c ipm.note /m "your email addresses here" } WITHOUT the brackets {}. Where I have "your email addresses here" you can put the email addresses for which you want to pre-address this email shortcut. For multiple email addresses, you can separate each with a semicolon. You can also put a group name there after creating an email group in your address book if you choose to do it that way. Also, for an explanation of what the "ipm.note" is all about, read my previous tech tip on Time Saving Outlook Shortcuts by clicking here.
Click here to view an example image.
4. On the Properties window click on the Change Icon button to select a new meaningful icon for your new pre-addressed email shortcut. Once you have done this, click OK on the Change Icon window.
Click here to view an example image.
5. Click on the General tab of the shortcut Properties window and change the name of the shortcut to something more meaningful. I named mine "New Email to Friends".
Click here to view an example image.
6. Click the OK button on the shortcut Properties window. Now you should have a shortcut that resembles something like this on your Windows desktop.
Click here to view an example image.
When you click this shortcut you should get a new pre-addressed email like mine in the image below.
Click here to view an example image.
Now to get the greatest benefit from this tip you'll need to drag the shortcut down to your Quick Launch bar so that it is never more than one click away. With this single tip we have eliminated several mouse clicks and who knows how much typing. With all this extra time you're saving, you'll have more time for golf.
Happy teching,
Ryan Williams
Ask Me A Tech Question
http://www.techbetter.com/question.aspx
View & Subscribe To My Tech Tips
http://blog.techbetter.com
About Me & TechBetter
http://www.techbetter.com/aboutme.aspx
Is it just me, or do others also see the emerging parallels between Lawrence Lessig and Thomas Jefferson? Both are geeks in the finest sense of the word. Both take a strong interest in political philosophy. And both use the power of their minds and the depth of their convictions to structurally change society, remedying ills of the past.
Lawrence Lessig is known for inventing the Creative Commons. That's just one of his many accomplishments. Now he's launching the Change Congress movement, which officially launched last week.
Lessig thinks and speaks with focused thoughts. You can hear them in this presentation he gave explaining why he's launching Change Congress.
If Thomas Jefferson were to give a presentation today, what would he sound like? He would sound an awful lot like Lawrence Lessig.
What would Jefferson love most about Lessig's ideas? Increased transparency in governmental workings with a concommitant increase in public participation.
The founding fathers and mothers gave us a foundation on which to build on, but they in no way finished building our house. It's time to tear down parts of our house and rebuild it. I have great faith and trust in Lawrence Lessig. He is an architect. He knows how to build social and governmental structures that will last centuries. We ought to follow his lead.
The blogger has been working to bridge the digital divide for 20 years in the Washington DC-area. He loves Macs, adores Linux and likes Windows. Reader responses welcome in the comments below or at philshapiroblogger@gmail.com
Glad you are bringing attention to the Change Congress effort.
Combine this effort with a general call for more universal production of media/content and we will go far in healing the ills of the modern day,
Thanks for the post on Lessig. I watched his presentation at the Press Club, and thought it was great. He is bringing attention to, and proposing reasonable solutions to, a problem that more and more of us are becoming aware of -- the idea that legislators have grown far too close to large corporate interests with a clear financial interest in shaping policy, tech and otherwise.

Think back to a time when computers were simpler. Your eyes ache as you look straight into the green light emitting from your monochrome monitor. You load up your Multi User Dungeon program, and after gaining a level, you post on the alt.hacker Usenet group about your dream of having a computer in every household. These were the times of DOS, Apple II, a minimal form of Unix, and even more tiny (sometimes even homemade) computers. Something was magical about these minimal machines. Something was different.
These computer users have now grown, and so has the technology industry. No longer can you post on a Usenet group without facing loads of spam, no longer can the word ?hacker? be used without striking fear into the hearts of non-technical-savvy people, and no longer can you war-dial. But there are a few select people out there who miss these times, and who long to bring back the glory of these simple silicon devices to the present day. These retrocomputing fans may restore the deteriorating hardware of an old computer, but many encourage the development of emulators, which can run the software of the past on today's high-speed computers.
I have long wondered how emulators work, and how to program one myself. Let me tell you, it is no easy task. It will take a long time, and a lot of patience in order to relive the memories of past electronics. But even those who are ready for the challenge will have a hard time finding documentation on how to begin. Information on emulator structure alone is hard enough to find!
This document will discuss the creation of an interpreting emulator. There are several different types of emulators, but this type is probably the easiest to write, as it doesn't require the recompiling of code.
Before I discuss how to program an emulator, one must know the design of a computer like the back of their hand, and in particular, the computer or video game console that they plan to emulate. This is the only way you will be able to create what you long for. The following is a brief (and I mean brief) description of how a typical computer works. The actual process is much more complicated, but a basic computer will include these elements.
Computers read instructions coded in the form of binary to tell them what to do. The parts of the computer then react to a specified command, and often store a number or value in the memory of the computer, for use in a later process or manipulation. CPUs can store numeric values in what are called registers, and values from the memory can be loaded into these registers. When in a register, a value can undergo a variety of mathematic processes, including addition and subtraction. These registers are what define a computer.
There are limits to how large a number a computer can process. It all depends on the bit type of a CPU. 8-bit CPUs can store numbers up to 255, 16-bit can store up to 65535, and 32-bit stores up to 1, 677, 721. The most commonly emulated computers are 8-bit, as the small numeric limits are easier to code with.
The binary counterparts of these computer instructions are stored in memory, and on the modern computer, a file. That's right, ?resume.txt? actually holds the ASCII binary values of each letter in that job resume. There's a lot more to it than just text.
Now that you know how a basic computer will work, we can begin the discussion of how to create an emulator for a certain computer. Keep in mind that creating an emulator will become more complex if you choose to emulate a complex computer. Computers often include many peripherals that you will have to emulate, too. If your computer includes memory, lights, and a keyboard, you will probably have to emulate them all.
Stay tuned for part two, where I give an example of how to code an emulator!
Would you like to be a Community Voices blogger? If so, please send a letter of interest and a sample blog entry (what you would post here if you were already a blogger for us) to forums@pcworld.com. We'd love to hear your perspective.
If you have ever wanted to keep better track of how you spend your time, this tech tip is for you. For just about everyone who provides a professional service, keeping track of billable time is a necessary evil. It is also A LOT harder than it sounds. Many professionals wait until the end of each week and try to document how they spent their time for the previous 5 days. As you can imagine, this is probably not the most accurate way of tracking time. Even trying to recall how a morning was spent at the end of a single day is often less accurate than you might think.
To combat this problem and make time tracking as easy as possible, I developed a very simple time tracking application which I am giving away for free to anyone who wants it. In order to utilize the time tracking application, you'll also need to become familiar with the Windows Task Scheduler. Therefore, we will cover both applications in this Tech Tip.
The way the time tracking application works is by asking you what you are doing every 10 minutes (you determine how often). The application remembers your responses from one prompt to the next so if you are doing the same thing several prompts in a row, all you have to do is press the enter key to make the prompt go away and log an entry.
First, you can download the time tracking application using the link below. After downloading the zip file, I suggest creating a folder on the C drive named "TimePrompt" (C:\TimePrompt). Then, extract the TimePrompt.exe executable into this folder. You can put the executable anywhere you choose, this is just my suggestion.
Click here to download TimePrompt.
You'll also need to download and install the Microsoft .Net Framework 2.0 if it is not already installed on your computer.
Click here to download the Framework.
Double click on the TimePrompt.exe executable to see what it looks like. As I said earlier, it is a pretty simple application. There are two big textboxes, one for reminders and one for keeping track of how you are spending your time. The application will remember the text in each field each time the application is launched. The first time the application runs it will create three text files, one to store your reminders, one to store your last time entry and one which is a log of all your time entries with dates and times. You can test this now if you choose.
The engine that makes the TimePrompt application do its thing is the Windows Task Scheduler. The Microsoft Windows Task Scheduler looks quite different depending of whether you are running Windows Vista or Windows XP. Therefore, I have provided step by step instructions for both operating systems. Choose whichever instructions apply to you.
Windows Vista Task Scheduler Instructions
1. Click on the Open Task Scheduler button on the Time Prompt screen.
Click here for an example image.
2. Click on the Action menu and then Create Task.
Click here for an example image.
3. On the Create Task window enter a description for the scheduled task and make sure it is set to run only when you are logged in.
Click here for an example image.
4. On the Triggers tab click on the New button to create a new trigger.
Click here for an example image.
5. Fill out the New Trigger window as I have in this example picture.
Click here for an example image.
6. Next click on the Action tab and then click on the New button to create a new action.
Click here for an example image.
7. On the New Action windows enter the path to wherever you saved TimePrompt.exe when you extracted the zip file. Then click the OK button.
Click here for an example image.
8. Click on the Conditions tab and complete the form as I have in this example image.
Click here for an example image.
9. Click on the Settings tab and complete the screen as I have in this example image.
Click here for an example image.
10. Now click OK on the Create Task window. Your time prompt is now scheduled to prompt you to capture your time every few minutes.
Windows XP Task Scheduler Instructions
1. Click on the Open Task Scheduler button on the Time Prompt screen.
Click here for an example image.
2. In the Tasks window click on Add Scheduled Task. This will open the Scheduled Task Wizard. Click the Next button.
Click here for an example image.
3. On the next screen click the Browse button.
Click here for an example image.
4. In the Select Program to Schedule window browse to the directory to which you saved TimePrompt.exe. My suggested location was c:\timeprompt\. Click Open after you find and select TimePrompt.exe.
Click here for an example image.
5. You should now be looking at a window where you select how frequently to run TimePrompt.exe. Select daily and click Next.
Click here for an example image.
6. The next screen is for selecting the start time of the scheduled task. Select 12:00 AM every day and click Next.
Click here for an example image.
7. The next screen asks for a username. Just leave everything the way it is and click Next.
Click here for an example image.
8. The next screen is the final screen of the Scheduled Task Wizard. Be sure to check the checkbox to open advanced properties and click finish. If you get a warning message, just click OK.
Click here for an example image.
9. You should now be looking at the TimePrompt scheduled task properties window. Check the box beside Run only if logged on.
Click here for an example image.
10. Next click on the Schedule tab and click the Advanced button.
Click here for an example image.
11. On the Advanced Schedule Options, check the checkbox beside Repeat task and configure the rest of the screen as I have in this example image. Click OK when finished.
Click here for an example image.
12. Next click on the Settings tab. Uncheck every box as I have in this example image. Then click OK. Your time prompt is now scheduled.
Click here for an example image.
Now, the time prompt application will prompt you every 10 minutes to ask what you are doing. Each time you enter your comments they will be saved with the current date and time in the timelog.txt file. You can refer to this file at any time to see a log of how you have been spending your time.
Another handy feature of the TimePrompt application is the reminder box. Instead of writing reminders on sticky notes, try entering them in the reminders box. Every 10 minutes you will be reminded of what you should be working on and it should help you stay on track.
Now, not only can you keep better track of how you are spending your time, but you have also been exposed to the Windows Task Scheduler. In later tech tips I will provide additional examples of how you can utilize the Windows Task Scheduler and also some other beneficial uses for the TimePrompt application. I hope you find this application useful. Until next time?
Happy Teching,
Ryan Williams
Ask Me A Tech Question
http://www.techbetter.com/question.aspx
View & Subscribe To My Tech Tips
http://blog.techbetter.com
About Me & TechBetter
http://www.techbetter.com/aboutme.aspx
In an article I wrote a while back, I mentioned that for electronic musicians using computer-based production software, like Cubase, FL Studio, or Ableton, VST plugins are the way to make your music sound better. VST plugins are like virtual synthesizers and effect units. There are tons of options (and tons of different VST plugins) available to make your song sound so different and unique. Here are just a few of the free ones that I have been using recently.
SupaTrigga - SupaTrigga would probably be more suited for live performances. When you forward your sound to the SupaTrigga VST effect, your sound is manipulated in a variety of ways. For example, you can slice the song into sections and loop those parts over independently, and you can reverse the different sections. There is also a function that allows the plugin to randomly determine when this will happen. There are more VST plugins on this website, but SupaTrigga is my absolute favorite.
TWEAKBENCH Plugins - There are a variety of different VST plugins (effects and instruments) on this website, but I just had to mention this website because of a select few. ?toad? is a NES-influenced drumkit that produces 8-bit style sounds, including the one and only coin sound from Super Mario Brothers. ?triforce? is an 8-bit syle 3-oscillator synthesizer, which includes an arpeggiator. Finally, ?peach? is a NES-style synthesizer with over thirty waveforms.
iZotope Vinyl - The majority of hip-hop is no longer produced with a DJ, a recording studio, and vinyl records. Many rap artists use computer based editors to create their tracks. Many people feel that since the sound quality is almost perfect, there is something missing. That's why iZotope Vinyl takes audio samples and emulates the dust, wear, scratches, and more elements of a vinyl record. You can now make your tracks sound like they used samples straight from the LPs!
Would you like to be a Community Voices blogger? If so, please send a letter of interest and a sample blog entry (what you would post here if you were already a blogger for us) to forums@pcworld.com. We'd love to hear your perspective.
I have a really horrible digital video camera. There's no denying that. It records video in the ASF video file format, which I've recently had some troubles with.
I recently went to see a talent show with one of my friends in it. My friend happens to be an incredible guitar player! He promised me that he had an awesome guitar solo during it, and he wanted me to tape it. So, after having no luck when searching for my analog video camera, I resorted to using my crummy $100 digital one. And I got extremely mad when I got home.
I sat two rows from the front. I had amazing seats, right next to his amplifier. This turned out to be a mistake (which I blame on my own stupidity), because the audio quality of my video was horrible, but I managed to fix that. But that's not the only problem I had.
So I recorded all of my video, which included videos of other contestants performing in the talent show. I got home, and it was just my luck to find that all of the videos were fine except my friend's guitar solo. For some reason, it was a corrupt file, and would not play.
I tried almost everything. I downloaded five different programs to try to fix the file, and none worked. They all promised to fix ASF files, but none did the job. Until I came across AsfTools.
AsfTools wound up being the only program that fixed my video. Don't be hesitant to download it because of the Geocities website, it works fine! However, AsfTools only runs on Windows, so if you are using Mac or Linux, you may have a bit of trouble finding another program to fix your home movies.
AsfTools allows you to create a list of ASF files, and can edit them together in many ways, as well as rip the audio, create AVI files, ASX files, and re-encode the ASF. But the best part of this particular piece of software has to be the repair features it has. There are two types of repair: basic repair and advanced repair. Advanced repair gives the user a few more options when AsfTools attempts to fix a broken ASF.
Neither of these functions worked on my particular file, but the one feature that did, ?Recover Lost Chunks?, managed to make my file good as new. For some reason, the chunks that make up the ASF file were lost, but still existed in digital form, so AsfTools produced a brand new, full-length ASF file of my movie.
AsfTools has many other features, too, but it really comes in handy when fixing corrupt or broken ASF files. Try using it if you ever have trouble watching any ASF videos! It may just save your home movies.
Would you like to be a Community Voices blogger? If so, please send a letter of interest and a sample blog entry (what you would post here if you were already a blogger for us) to forums@pcworld.com. We'd love to hear your perspective.
In this tech tip I am going to address two questions that were submitted recently. Sorry I cannot get to them all.
QUESTION #1: The first question comes from a reader in Texas. The question is ?Can cell phones with built in Wi-Fi use the Wi-Fi to connect to the internet?? The answer is definitely yes. However, phones with built in wireless still have to be configured just the same as a laptop with wireless. If the place where you are trying to access the internet has wireless security enabled, you will still need to configure your phone?s wireless settings to match. The process is slightly different on every phone so I cannot provide step by step instructions, however, having Wi-Fi on your phone is really handy, and it is definitely worth paying for when you are shopping for cell phones. Most cell phones now days allow for surfing the internet, however, the data connection is often slow and you often have to pay extra for internet usage. Having built-in Wi-Fi on your phone avoids having to pay your cell phone service provider for internet access. It is also especially nice for surfing the internet in your living room while the rest of your family is watching the Food Network.
QUESTION #2: Another reader says she accidentally removed the administrator privileges from her Windows Vista account. Now, she cannot install new software nor do other things that require administrator privileges. This person wants to know if there is another option besides formatting and reloading the entire computer to reestablish an account that has administrator privileges. The answer is thankfully yes. There is another option.
In Windows Vista there is a hidden administrator account that is disabled by default. The following steps will enable this hidden administrator account and allow you to reestablish your personal account with administrator privileges. I suggest that you disable this hidden administrator account after you fix your existing personal account.
Here are the steps for enabling the hidden Windows Vista administrator account.
1. Click on the start menu and type ?command? in the search bar. This will pull up the Command Prompt program in the search results above.
Click here for an example image.
2. Right-click on the Command Prompt program and select Run as Administrator.
Click here for an example image.
3. Next, type in the following command at the command prompt and press enter.
net users administrator /active:yes
This will activate the hidden administrator account.
Click here for an example image.
4. Now, log off or restart your computer. You should have the option to log in as the administrator. By default the administrator login does not have a password. I suggest that you disable the administrator login after using it. To do so, use this command at the same command prompt as in step 3 above.
net users administrator /active:no
This will deactivate the hidden administrator account.
That?s all there is to it.
If you would like to ask me a tech question, please click on the link below. I look forward to hearing from you.
Happy Teching,
Ryan Williams
Ask Me A Tech Question
http://www.techbetter.com/question.aspx
View & Subscribe To My Tech Tips
http://blog.techbetter.com
About Me & TechBetter
http://www.techbetter.com/aboutme.aspx