PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

How to write a C64 Emulator ?

Vicente_cgn · 23 Jul 2002, 14:43 UTC
Hi there!

It may sound naive, but I would like to write a C64 Emulator for an IPaq-PPC (3870).

I can't understand why any of the "pros" already did this - it can't be too complicated for them and there are some facts that speak for such an emulator:

- there a lot's of great, free games for this machine (http://www.lemon64.com/)
- the screen resolution is the same
- it shouldn't run fine on an ARM-processor, shouldn't it?
- it doesn't need much memory, only 64k!
- it has a huge fan-community!
- I would even pay 30-50€ for a good emulator!!!

So, I ask myself if perhaps I should start such a project! I'm working as a software-delevoper with a little bit programming to do but I don't think that this will help me! I'm afraid I have to learn a new language, perhaps even to code object-oriented, or even some machinecode ...

But I don't know even the basics of writing emulators - and that's what I'm asking you: how to begin? How do emulators work? What developing-tools do I need? Would it be easier to port an existing open-source project? How do I do such "ports"?

Hm - it's really naive to think that I could learn all this in my free time, isn't it? Is there really no one of the "pros" out there who would like to give the C64 fans in the PocketPC-World what they desire so much? As I said, I would even gladly spend 50€ for such a emulator ... and I'm sure, others would do so, too!

Bye,
-Vic-
andys · 23 Jul 2002, 15:11 UTC — How to write a C64 Emulator ?
Vicente_cgn wrote:
But I don't know even the basics of writing emulators - and that's what I'm asking you: how to begin? How do emulators work? What developing-tools do I need? Would it be easier to port an existing open-source project? How do I do such "ports"?


An emulator is like a virtual machine. In basic terms you simply do something like

"if(instr == GOTO) ....... else if(instr == ADD) ....."

And implement each instruction like that.

In practise, of course, nothing is quite that simple and if you look at the relatively few emulators out there for each platform, you'll see that it can be harder than that.

Porting an open-source project is usually relatively straightforward. You pick the piece of the code that outputs to the screen (which is usually seperated), and you modify it to talk to teh pocketpc's screen. There are lots of examples of this around,


Hm - it's really naive to think that I could learn all this in my free time, isn't it? Is there really no one of the "pros" out there who would like to give the C64 fans in the PocketPC-World what they desire so much? As I said, I would even gladly spend 50€ for such a emulator ... and I'm sure, others would do so, too!


It'll happen at some point - somebody will probably port something like vice to the PocketPC, given that it already runs okay on PocketLinux.
C64 has a 6510 processor which is like a 6502 only with more opcodes. Loads of docs at 6502.org
Jadam · 24 Jul 2002, 02:45 UTC — How to write a C64 Emulator ?
Vicente_cgn wrote:
Hi there!

It may sound naive, but I would like to write a C64 Emulator for an IPaq-PPC (3870).

I can't understand why any of the "pros" already did this - it can't be too complicated for them and there are some facts that speak for such an emulator:

- there a lot's of great, free games for this machine (http://www.lemon64.com/)
- the screen resolution is the same
- it shouldn't run fine on an ARM-processor, shouldn't it?
- it doesn't need much memory, only 64k!
- it has a huge fan-community!
- I would even pay 30-50€ for a good emulator!!!

So, I ask myself if perhaps I should start such a project! I'm working as a software-delevoper with a little bit programming to do but I don't think that this will help me! I'm afraid I have to learn a new language, perhaps even to code object-oriented, or even some machinecode ...

But I don't know even the basics of writing emulators - and that's what I'm asking you: how to begin? How do emulators work? What developing-tools do I need? Would it be easier to port an existing open-source project? How do I do such "ports"?

Hm - it's really naive to think that I could learn all this in my free time, isn't it? Is there really no one of the "pros" out there who would like to give the C64 fans in the PocketPC-World what they desire so much? As I said, I would even gladly spend 50€ for such a emulator ... and I'm sure, others would do so, too!

Bye,
-Vic-


you DEFINETLY DONT want to use an object oriented programming language. Secondly, correct me if im wrong but isnt teh 6510 a CISC processor? if so that thats a bitch, but you CAN find open source interpreters on the net if you do a bit of searching. It wouldnt be THAT hard, nothing like a psx emu :-/
BadBazza · 24 Jul 2002, 08:29 UTC — How to write a C64 Emulator ?
jadam wrote:
you DEFINETLY DONT want to use an object oriented programming language.


Hi Jadam,

No offence meant but what have you got against object orientated programming languages? IMO, C++ makes code very easy to read and understand and within a game when there are lots of things going on simultaneously it is easy to find the bit you want.

Let me know
Bad
It wouldnt be THAT hard, nothing like a psx emu :-/


8O

Umm... there seems to be this general assumption going around that emulation of older machines is easier to implement - this isn't always the case. The C64 contains highly timing-dependent custom chips which run alongside the CPU, and these need to be sychronised with the CPU to provide a close/exact emulation of sound and graphics. Even the 1541 floppy drive has it's own general purpose CPU!

In contrast, the PSX has a relatively basic CPU, geometry processor and polygon blitting processor configuration - the latter two may be high-level emulated in today's hardware due to their similarity with the calls provided with API's such as OpenGL and DirectX (granted, these are not YET available on the Pocket PC).

To conclude - I would much rather rate a given person's chances of writing a PSX emulator than a C64 emulator from scratch.
Vicente_cgn · 24 Jul 2002, 12:09 UTC
@jont

Hm, that doesn't sound very encouraging! :(

Perhaps I should just try to compile an opensource Emu like Vice or Frodo with the PocketPC-development package - perhaps I can sort out some things or ask here for help!

If it doesn't work I'll have to wait till some genius will do it ... and then my dream of playing Paradroid on my IPaq finally comes true! :D

Bye,
-Vic-
hmm, isn't frodo already ported to PPC? at least I saw symbian version...:) anyway modified frodo will be a piece of cake comparing to writing a new emulator from zero...
>6510 a CISC processor? if so that thats a bitch, but you CAN find open source interpreters on the net if you do a bit of searching.

The 6502 is piece of piss to emulate. It's just about the simplest processor out there.

6510 only has a few extra opcodes.
Yeah, paradroid was cool. Anyone here remember Omega? Man, that's one of my favourite games, it was just kickass!
btw, people say one of the hardest, if not the hardest job for a coder is to write an emulator. so i guess you might want to try and port VICE (afair that's the best one with source code released, otherwise, sure CCS64..)
The most mindblowing thing i've seen on the C64 from a technical point of view (only ever seen it on an emulator unfortunately) is Smash Design's conversion of Future Crew's 1993 demo Second Reality - anyone else seen it?

It's stuff like this that makes you understand how far ahead of it's time the C64 was upon it's 1982 (?) release (and therefore how difficult it is to emulate well :? ).
fzammetti · 25 Jul 2002, 14:52 UTC — CB64
I've looked into this quite a bit...

(1) If anyone can get or has the source for CB64 (ComeBack64), that already is ported to PocketPC (it's still floating around the web). It shouldn't be any problem at all to polish and finish it (it worked when I last played with it, but had some problems). I attempted to contact the original author, but I suspect he's long gone.

(2) I've looked at the source for both Frodo and Vice. I'd suggest going with Frodo simply because, to me anyway, the source looked easier to follow. Besides, Vice emulators a number of different CBM machines, I believe Frodo only does the C64, so there's less extraneous code to wade through.

I don't know how much time I could contribute (or what expertise I could offer), but I'd be willing to do what I can for such an effort (I started a similar thread a couple of weeks ago, search for it if your intersted).

By the way, I agree with the poster who said it won't be as easy as you might suspect, the C64 was really a unique piece of engineering as compared to many other systems that are emulated. Even the best C64 emulators out there now have trouble with many programs (I have two demos I wrote in the 80's that won't run on any emulator I'm aware of, but of course work perfectly on my real C64).

Oh, but to be able to play Impossible Mission, Beach Head, Hoover Boover, Tapper, Hardball and Spelunker again while in the can at work, whatever I can do to make it happen, I'll do! (more information than you wanted?!?)
Vicente_cgn · 25 Jul 2002, 21:07 UTC
@fzammetti

Hey, that's a great offer! :-)

At least you seem to have a lot more knowledge about these things than me - I've looked through some sourcecodes and I lost hope immediately.

I'm afraid, all I can do is searching for the CB64 sourcecode or do some "timeconsuming" simple tasks like "replace this expression with this one" or "these coordinates must be transfrerred to this" or betatesting or such things ...!

Of course not every program will run - but as far as I've tested, the most work perfectly! I haven't got the Isepic-loader to work on any emulator for example.

May I ask, how "good" you are in coding? I mean, could you get Frodo ported when time wouldn't play any role? I would gladly wait a year or longer! :-)

Bye,
-Vic-
fzammetti · 25 Jul 2002, 21:16 UTC — Well...
Well, my "coding" skill are fantastic, what else would you expect me to say?!? ;)

Seriously though, I've been programming for close to 20 years now, I am actually a tremendously good coder if I do say so myself.

The problem likely would be that I'm not such a great *C* programmer. Ironically, in all my years of programming, I only started in C maybe three years ago, and it's only over the past year or so that I've gotten too far with it. I still find myself having to ask rather basic questions at times (but I've also managed some rather advanced things at times, so on balance I'm probably OK in C).

To answer your question, if time was not an issue I have virtually no doubt that I could port it. I'd be doing A LOT of learning along the way, but that's the way it usually is with any sufficiently complex programming project.

If we can get a couple of people interested I'm sure I could contribute, but as the "lead" programmer I think it WOULD take a year or so! :) (But it would get done I suspect)
Vicente_cgn · 26 Jul 2002, 06:45 UTC
Hi there!

I think, it would be great if you good start as lead-programmer - perhaps later people will join you! But I think it would be time consuming to find other people and to organize all the tasks and put them together in the end, no? I think it's easier for one person doing the programming as long as the project isn't too big - but only you can judge this!

And if there any tasks I could do with my little knowledge: just tell me!

So, what you think? Will you start tomorrow? :)

Bye,
-Vic-
Here's the deal with the Frodo source code. All platform dependent code is seperated into external source files, such as (using Amiga as an example) SID_Amiga.i, Display_Amiga.i, Prefs_Amiga.i and so on.

This means that, at least in theory, a specialist could be appointed for each area of coding (graphics, sound and so on), and the results could be brought together a couple of times a week for compilation.

I'd be willing to have a crack at the graphics side of things (ie Display_PocketPC.i) if anyone else could take of SID, Prefs etc.

fzam: are you serious when you think it could take as much as a year? there's not that much platform dependent code there! 8O
Right now I don't think I will have the time to lead, but that's because I'm extremely busy at work right now and coming home to another big project isn't foremost on my mind.

Later in August though it should lighten up a bit, maybe then I will look at Frodo a little more seriously.
Vicente_cgn · 26 Jul 2002, 15:44 UTC
Cool! :D

So you two will work together on this? That would be good news indeed! And perhaps when others read this, they'll get in, too! You could make a public announcement when you 're really ready to start and you could ask for assistance for certain parts.

@jont I'll have a look at the sourcecode! Not that I'll understand much of it but it sure sounds interesting enough!

I'm getting too enthusiastic here, I'm afraid ... but at least there is something to start with, right?

Bye,
-Vic-
Well jont, I was not aware of that organization structure. Knowing that now, I think it probably would take far less than a year. I made that estimate based on me being the only one doing the coding, and I know my schedule, so a year seemed reasonable (maybe a bit over-estimated to begin with, but I always do that).

It sounds much more palatable now though.

Watch for my next message (separate so less people potentially miss it)
fzammetti · 26 Jul 2002, 16:00 UTC — PROJECT ORGANIZATION
I'd like to see this get off the ground and eventually completed, so let's do this for now...

For the time being, I will serve as project organizer (until an accounting scandal forces me to resign :) )

Anyone reading this thread that is interested in working on this project, which we'll tentatively call, obviously enough, the Frodo PocketPC Porting Project, eMail me at fzammetti@omnytex.com. Let me know in what capacity you'd like to contribute.

I'll accept new members until next Saturday, 8/3. After that, by 8/4, I will throw together a quicky web site and most likely a mailing list for the project and list all the members.

Shortly after that we'll get together and hash out who wants to do what. A week later, on 8/10, I will update the site with the "job assignments". From then on, actual development can begin and I'll organize things after that in terms of milestones and such.

We'll need, as jont said, one "master integrator" that will take all the sub-projects and come out with the current code base. We'll of course need a couple of people to handle each piece as jont also pointed out. I'm sure we'll also need researchers along the way, so not just coders can apply!

I'd like to limit the team to no more than 10 people though, just for efficiency's sake. If I get 500 applicants I suppose it'll be first-come-first-served, but I'm hoping I'm not faced with that anyway!

I hope I'm not coming across pushy, that's not my intent. I simply want to see a good C64 emulator for PocketPC in a few months, and I've seen too many project fail simply because they weren't well-organized, which means lead by someone, so I'm trying to avoid that pitfall right from the get-go.

Thanks everyone, I look forward to playing Mail Order Monsters and GI Joe in a few weeks or months!
fzammetti · 26 Jul 2002, 20:49 UTC — Permission!
Since we don't have a mailing list yet, and won't for a couple of days, I'll post this here...

I just corresponded with Christian Bauer, author of Frodo. He gave us complete permission to do a PocketPC port of Frodo, so we're good to go down that road. He gave me some inside information on the still developing v5 as well. I don't think anyone is going to be willing to wait for that, even though is sounds like it will be better, so we'll be starting with v4 and maybe do v5 down the road (supposed to be easier to port, that's what stuck out most in my mind).

So, aside from actually getting members on the team, we're good to go!
devniall · 26 Jul 2002, 22:21 UTC — CB64
fzammetti wrote:

Oh, but to be able to play Impossible Mission,


Stay awhile... stay... FOREVER!
I never finished Mission Impossible...

Great news though, finally someone heard my prayers for a C64 emulator. :D

fzammetti, what could a C64 fanatic with no programming skills (except a little BASIC and PHP) do to support the project? I've lots of time on my hands! :wink:
accolon wrote:while (!asleep()) sheep++;
HA! I get it! That's clever! Counting sheep ... tee hee.
That is clever!

My only problem with it is this... a function called asleep() one would logically assume returns true if asleep, so in that case, that code would mean I'm counting sheep while AWAKE?!?

On second thought, thinking about my job... yeah, I think THAT'S right!
You count sheep in order to go to sleep. So you're counting when you're awake. while you're awake you count sheep until your asleep.
fzammetti · 28 Jul 2002, 21:24 UTC — Duh
That's right, I didn't look at it right.

Probably because I prefer drugs to fall asleep, after which all I see is sheep.

Sheep that can talk and fly and turn fifty different colors and that can dance the Tango to Drowning Pool tunes.

Ah, aren't the sixties great?!?
BurningSheep · 28 Jul 2002, 21:40 UTC
*bleat*
accolon · 28 Jul 2002, 21:56 UTC — Duh
What's wrong with your avatar, fzammetti? Alpha transparency, eh?
BurningSheep · 28 Jul 2002, 22:08 UTC
looks like a Rorshach ink blot
BurningSheep wrote:
looks like a Rorshach ink blot


Oh, do you also see this naked young lady with long dark hair?
I see a Teenage Mutant Ninja turtle, YEAH DUDES!!!!!
fzammetti · 29 Jul 2002, 00:16 UTC — Avatar
Yeah, I gotta fix that... I've just been lazy today... It's a Shadow from B5 of course, but it's obviously not done right. Ah well, I'll just change it to a big black square, just avoid any other problems.
For anyone who's had the patience to trawl through the irrelevant mass of drivel that has overcome this topic 8O :roll: , the original "C64 emulator" topic is now continued at:

http://forums.pocketmatrix.com/viewtopic.php?t=6817
LOL, welcome to PocketMatrix ;)
Fzammetti:
It's a Shadow from B5 of course


It's a Vorlon, isn't it?
Well he changed it now
Yeah, I'd prefer a Shadow but I couldn't find a good enough image anywhere. Kosh is cool though.

Somehow I don't think he used a C64 Emulator though (my sarcastic comment on how OT this has gone).

I know, I know... welcome to PM...

Welcome to ANY message forum on the net you mean!