DIY LabVIEW Crew Blog

Community Browser
Showing results for 
Search instead for 
Did you mean: 

A Commodore 64 emulator written in LabVIEW

‎10-20-2009 07:24 AM
‎10-20-2009 07:24 AM

I wanted to share my C64 emulator I created in LabVIEW.

Why is somebody doing this?

That’s easy! For years I was wondering if it is complicated to emulate a processor or a whole computer platform.

So played around with the C64 roms I found on the web and a state machine in LabVIEW...

My goal was to make the C64 boot the Kernel and Rom so that I can write a little basic program like:

10 PRINT “HALLO”

20 GOTO 10

C64_FoorLoop.jpg

It took me a couple of weeks to get that far. I found many helpful resources on the web and got a copy of the Commodore 64 programmer’s reference manual from a friend (thanks Tapio!).

I got a few games working on the emulation, for example Lode Runner, Centipede etc.

C64_Game.jpg

This example code shows how an emulator can be written in LabVIEW, although is not a complete C64 emulator.

Overview

This program emulates most parts of the famous Commodore 64 home computer.

You can use the build in BASIC and some program files (PRG), for example games

- 6510 CPU with almost all OpCodes

- VIC with almost all Screen modes, sprites, collision detection and IRQs

- Keyboard and Joystick input

These parts of the C64 are not yet implemented:

VIC: Extended background color mode, fine scrolling

CIA: Timers, Serial port

SID: The is so far no sound at all!

Floppy and Datasette are not implemented.

I attached the emulator. Download and unzip it, look for original C64 ROMs on the web and place them in the folder named ROMs.

They must be named: kernal.rom, basic.rom, char.rom

Run the MAIN VI and have fun!

Christian

Comments
Member gene7135
Member

My first computer was a C64... this is awesome!

This sounds way cool!

Member jcz
Member

wow. great stuff !

Active Participant Thoric Active Participant
Active Participant

Very impressive! Well done to you for putting such an idea into practice - it would never have occured to me that this was possible in LabVIEW!

I like it very much

Member Rick K
Member

Genius!!!!..... This is an amazing feet. Thanks for contributing in such a big way to this group.

Member Bill_in_Detroit
Member

Cool.  Now I can throw out or give away the two Commodore 64 computers I have.  I look forward to trying out the code when I am away from my work place.  Have you considered building one that would emulate a Sinclair ZX-80?

Member Christian_Gindorf
Member

Thanks! But you better keep your C64! Tis emulator is not really finished ;-)

A very good emulator can be found here, unfortunately not in LV:  http://www.viceteam.org/

What processor does a ZX-80 use? I guess a Z80? Is that similar to the 6510 of the C64?

The Processor was a lot of work - it is a case structure with 256 cases...

The graphic is also complicated becuase of the many different modes which can be changed on every line etc.

I think I'll finish the graphics of the C64 first...;-)

Member Bill_in_Detroit
Member

The ZX-80 uses the Zilog Z80, an 8 bit processor and not at all like the 6502 based processor used in the C64.

But nostalgia aside (and the C64 definitely brings up memories for me), I look forward to seeing where you take the project.  I have said for years that LabVIEW is the most versatile programming environment that still retains the ability to be used by a single person for major projects and what you are doing is a perfect example of that.  Keep up the good work!

Member KBersch
Member

What version of LabVIEW is this written in?  I'm stuck at 8.6 for now.

Member jcz
Member

You say, you "stuck at 8.6" ? I still use 7.1.1 and I know people who use version 6.

Member Christian_Gindorf
Member

The C64 emulator was written in LV 8.6.1

Member Bill_in_Detroit
Member

Christian:

When you say "...original C64 ROMs..." do you mean ROMs for the original C64 as opposed to the SX64 or other variations on the theme, or do you mean only the ROMs from the first generation C64? (I think there were like 3 generations of ROMs over the life of the original C64)

Member KBersch
Member

That's why I asked what version it was writte in.  I actually have 8.6.1 but it occured to me that some one with an older version might try to open this and get frustrated.

This looks like a great project.  As soon as I can I'm going to see what I can do with it.  Ah, the memories of my first computer!

Active Participant RTSLVU
Active Participant

That's nothing my company's ATE system is still using LV 5.11 and our production test department is still developing with it.           

Worst part is, I am often called on to support it.

Proven Zealot
Proven Zealot

wow really awesome...

Member pRoFiT
Member

Nice, Almost makes me want to emulate a nes. but after running the slow c64 emu in labview...I don't think labview can handle the NES. Is anyone attempting to create the SID for this? The ground work is done. shouldn't be toooo hard to add sound. I did find a labview SID generator that talks to the SID chip through a serial port. All the registers and bits are already there. At least it would be useful to use to test the emulated SID. Maybe a QUE and outside loop for the SID and in the main loop pass address and data back to the audio loop through a que. It seems like the SID can play sounds as they come in indeterminate of the CPU loop. Well at least that's how the datasheet for it looks.

p.s. I'm running labview 2009 and it worked for me. And I pulled version 3 of the kernal. Well I pulled all 3 versions (minus jap ver), but only checked ver 3 named "kernal.901227-03.bin"

p.p.s good job, and why English and (German?) in the comments? Multiple people work on this?

Member Christian_Gindorf
Member

Hi, thanks for your thoughts on this!

The emulator runs fine (normalC64 speed) on LV 8.6. For LV 2009 you need the SP1. Without the SP1 the emulator is very slow!

The LabVIEW SID generator sounds interesting. Do you want to implement it? ;-)

I still would like to implement the SID and fix some bugs in the interrupt routine.

Some video line interrupts do not work perfectly.

I created the code on my own and started with german comments. But later I thought that maybe the

code is interesting for other people and since my colleagues at NI are mostly in Austin I switches to english.

Member Deirdre
Member

Super Cool!

Member pRoFiT
Member

Christian,

Have we met before? I work for PELCO. We talked with someone from NI called Christian on a project last year i think.

Anyways, i would love to build a SID emulator. I've done a little playing around with the audio out and sound waves. I just put a simple EQ together for a friend. So a cool audio project might make me learn more about wave files and such.

'I guess creating sounds to send to SID would be a little different. How do you plan on reading in the data for the SID? If you have a cluster design or what ever, then i can work around that. i think the timing parts will be the hardest for mixing the audio on your side of things

Member Christian_Gindorf
Member

Hi, I'm not sure if we met somewhere. I'm working in Germany.

It would be great if you build a SID for the emulator!

I thought about implementing the SID but have currently no time to do it.

My idea was to take the necessary registers from the main memory and register array and transfer the data to a loop running in parallel where the waveform generation is done.