Hi guys,
I was looking at the free open source VICE Commodore emulator page (www.viceteam.org) and stumbled across this link:

http://ed64.eldendo.be/

It has a number of chapters on how to make a C64 emulator (not optimized) using Freepascal

I'm going to have a look as it will be fun to play with and look at the code :-)
cheers,
Paul