Page 1 of 3

6502 emu help needed!

Posted: Mon Sep 28, 2015 8:20 am
by HarryP2
I'm looking for enough information on the 6502 chip to do a good emulation of it. Any urls?

Re: 6502 emu help needed!

Posted: Mon Sep 28, 2015 9:27 am
by nippur72
http://6502.org has a lot of good info, but most likely you already know of it.

I suggest you to grab the code from open source emulators (not only vic-20) and study them.

Start with a simple one (not VICE!) and look for an emulator that is written in your favourite language.

6502 emulators fall in two main categories:

- cycle exact emulators, where the emulator takes into account that each CPU instruction takes several clock cycles to execute. In that case the emulator is written as a big "state machine". It's the most difficult type of emulator to write but the most precise also.

- trivial emulators, emulation is done at CPU instruction level. Rather easy to write but not accurate, used only where speed is required or for demonstration purposes.

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 1:59 am
by pixel
Just for the déjà vu experience: https://github.com/SvenMichaelKlose/ben ... e/master/c – not emulating cycles but probably won't get much simpler.

May I ask what you're working on?

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 5:04 am
by HarryP2
pixel wrote:Just for the déjà vu experience: https://github.com/SvenMichaelKlose/ben ... e/master/c – not emulating cycles but probably won't get much simpler.

May I ask what you're working on?
I''m not working on t yet, but I plan on working on a Vic20 emulator then C64 and 128 emulators for DOS.

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 5:42 am
by groepaz
for something like that you definitely need a cycle-accurate cpu core then

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 8:54 am
by HarryP2
groepaz wrote:for something like that you definitely need a cycle-accurate cpu core then
Yes, but I did think about having a quick-emulation mode where the CPU core will make short-cuts, i.e. loading whole words at a time. This will only be an option, but I think it could help on slow computers. :)

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 9:56 am
by nippur72
I think a C/asm cycle-exact emulator should run fine even on a slow machine (e.g. 200Mhz pentiums).

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 10:08 am
by pixel
I hope yous two give shadowVIC a whirl. :mrgreen: Without scaling it occupies ~15% CPU time on my 2GHz Intel Celeron.

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 10:09 am
by HarryP2
nippur72 wrote:I think a C/asm cycle-exact emulator should run fine even on a slow machine (e.g. 200Mhz pentiums).
Well...I am planning to use 386 assembler for the emulation cores and C for the interface. BTW, I think PCVic runs well even on 33MHz. ;)

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 10:11 am
by HarryP2
pixel wrote:I hope yous two give shadowVIC a whirl. :mrgreen: Without scaling it occupies ~15% CPU time on my 2GHz Intel Celeron.
ShadowVIC is for what system, and where can I find it? :)

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 10:22 am
by pixel
HarryP2 wrote:
pixel wrote:I hope yous two give shadowVIC a whirl. :mrgreen: Without scaling it occupies ~15% CPU time on my 2GHz Intel Celeron.
ShadowVIC is for what system, and where can I find it? :)
It's been posted in this forum's emulation section about two hours ago. It runs on Linux but there should be no problem adapting video.c and joystick.c to DOS or any other operating system you can name.

EDIT: Forget video.c, it's fb.c that needs to be replaced.
EDIT: Oh, well, if you intend to not use packed pixel format, filling rectangles in video.c would need some tweaking as well.

Re: 6502 emu help needed!

Posted: Tue Sep 29, 2015 10:39 am
by pixel
Oh, dear. Forgot to push Pulse up. But now it's all there.

Re: 6502 emu help needed!

Posted: Thu Oct 01, 2015 5:41 am
by pixel
HarryP2 wrote:Well...I am planning to use 386 assembler for the emulation cores and C for the interface. BTW, I think PCVic runs well even on 33MHz. ;)
Hold your horses, young Jedi, if you crunsch it in one pass with gcc, there's no need for assembly.

Re: 6502 emu help needed!

Posted: Thu Oct 01, 2015 7:12 am
by HarryP2
pixel wrote:
HarryP2 wrote:Well...I am planning to use 386 assembler for the emulation cores and C for the interface. BTW, I think PCVic runs well even on 33MHz. ;)
Hold your horses, young Jedi, if you crunsch it in one pass with gcc, there's no need for assembly.
I think C can do it well, but I still think that assembler can do it better. Besides that, I'm targeting DOSBox and real DOS, and I would like to do full emulation of 40MHz or less. :)

Re: 6502 emu help needed!

Posted: Thu Oct 01, 2015 12:06 pm
by pixel
HarryP2 wrote: I think C can do it well, but I still think that assembler can do it better. Besides that, I'm targeting DOSBox and real DOS, and I would like to do full emulation of 40MHz or less. :)
An absolutely valid target in the retro world. Checked out https://github.com/svenmichaelklose/tma ? Not sure if it's still working, though. There's also a 6502 assembler in it. But I never used it myself.