Jump to content


Photo

Creating a C64 emulator in GameMaker - Part 2


  • Please log in to reply
4 replies to this topic

#1 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 5277 posts
  • Version:GM:Studio

Posted 09 January 2015 - 11:02 AM

http://www.yoyogames.com/tech_blog/96

 


So my next post was going to be about tracking down my CPU bug and how the memory mapping was going to work, but then I suddenly realised I needed to do another first, on how I actually emulate the CPU - a bit more detailed at any rate. So I've moved all the others out by a week, and thrown this one in first....

 

Before you read this one, you should probably read my post on dealing with binary (An introduction to Binary) - it'll certainly help when dealing with the emulator world as a whole. In my first post, I talked a little about how the CPU works, how it gets a stream of bytes, and how it executes a specific instruction for each one - and I was even nice enough to provide a couple of examples. Now this is all well and good, but what about more complicated ones? Instructions that aren't just load/store or clear a flag? What do they look like, and how do we emulate everything required?


  • 6

#2 stainedofmind

stainedofmind

    GMC Member

  • GMC Member
  • 1775 posts
  • Version:GM:Studio

Posted 09 January 2015 - 05:25 PM

Thanks for doing these, Mike.  C64 was my first computer and how I learned to program, so this is really interesting for me and I'm thouroughly enjoying it!


  • 0

#3 NakedPaulToast

NakedPaulToast

    GM Studio/Mac/Win

  • GMC Member
  • 8808 posts
  • Version:GM:Studio

Posted 09 January 2015 - 07:59 PM

Boy does this bring back memories.

 

One of my first computers was a Commodore 64. I loved it.

 

I still remember using it to teach myself 6502 assembly. I really struggled with it.

 

While I was already a competent IBM S360 (mainframe) assembly programmer, moving to the 6502 was really to much of a culture shock.

 

In S360 Assembly I had 16 general purpose registers, each of which 32 bits and multiply and divide instructions. How the heck do people do things with one 8 bit accumulator and two index registers? Wheres the multiply and divide instructions? You  mean I have to multiply by looping and test for overflow? And WTF are all these addressing modes? Immediate, relative, zero page, absolute? 

 

I remember waiting for my monthly copy of Compute! for games, The Transactor for technical articles, Sheldon Leemon's Mapping the Commodore 64 and any article written by Jim Butterfield.

 

I would really love to see this released on the Market Place, in two versions:

  • An inexpensive version that is just the C64 emulator.
  • A more expensive C64 emulator, with source. Similar to the YYG RPG.

 

 

Oh, and here's a potential suggestion for you.

 

I see that you are using a Cycles variable. I assume that's for delay timing to help timing critical programs such as games. Consider an emulation configuration where the Cycles instruction delay is ignored. This could be turned on for non-game programs where timing isn't critical and the emulator would then run blazingly fast.


Edited by NakedPaulToast, 09 January 2015 - 08:13 PM.

  • 1

If the Bible truly is inspired by God, you would think that somebody as omnipotent and all-knowing would have known to get his message out using TCP instead of UDP.

 


#4 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 5277 posts
  • Version:GM:Studio

Posted 09 January 2015 - 08:54 PM

Cycles is always needed as you need to tie this to virtual scan lines etc. When you want to uncap the FPS (which I do now and then), you just set the room speed to 99999 like you would with any GM game.

 

Basically Cycles is the 6502 CPU "tick" counter, and that is used to do things like sound and rendering ticks at the correct time in the virtual machine space.


  • 0

#5 Oldschoolgamer69

Oldschoolgamer69

    GMC Member

  • New Member
  • 13 posts
  • Version:GM8

Posted 11 January 2015 - 09:40 PM

C64 was my second computer, my first was also a Commodore computer (The VIC20) Interesting


  • 0