6502 emu help needed!

You need an actual VIC.

Moderator: Moderators

HarryP2
Vic 20 Dabbler
Posts: 85
Joined: Sat Sep 26, 2015 8:40 am
Location: New York, U.S.A.

6502 emu help needed!

Post by HarryP2 »

I'm looking for enough information on the 6502 chip to do a good emulation of it. Any urls?
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: 6502 emu help needed!

Post 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.
User avatar
pixel
Vic 20 Scientist
Posts: 1328
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: 6502 emu help needed!

Post 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?
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
HarryP2
Vic 20 Dabbler
Posts: 85
Joined: Sat Sep 26, 2015 8:40 am
Location: New York, U.S.A.

Re: 6502 emu help needed!

Post 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.
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: 6502 emu help needed!

Post by groepaz »

for something like that you definitely need a cycle-accurate cpu core then
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
HarryP2
Vic 20 Dabbler
Posts: 85
Joined: Sat Sep 26, 2015 8:40 am
Location: New York, U.S.A.

Re: 6502 emu help needed!

Post 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. :)
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: 6502 emu help needed!

Post by nippur72 »

I think a C/asm cycle-exact emulator should run fine even on a slow machine (e.g. 200Mhz pentiums).
User avatar
pixel
Vic 20 Scientist
Posts: 1328
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: 6502 emu help needed!

Post by pixel »

I hope yous two give shadowVIC a whirl. :mrgreen: Without scaling it occupies ~15% CPU time on my 2GHz Intel Celeron.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
HarryP2
Vic 20 Dabbler
Posts: 85
Joined: Sat Sep 26, 2015 8:40 am
Location: New York, U.S.A.

Re: 6502 emu help needed!

Post 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. ;)
HarryP2
Vic 20 Dabbler
Posts: 85
Joined: Sat Sep 26, 2015 8:40 am
Location: New York, U.S.A.

Re: 6502 emu help needed!

Post 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? :)
User avatar
pixel
Vic 20 Scientist
Posts: 1328
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: 6502 emu help needed!

Post 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.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1328
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: 6502 emu help needed!

Post by pixel »

Oh, dear. Forgot to push Pulse up. But now it's all there.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1328
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: 6502 emu help needed!

Post 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.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
HarryP2
Vic 20 Dabbler
Posts: 85
Joined: Sat Sep 26, 2015 8:40 am
Location: New York, U.S.A.

Re: 6502 emu help needed!

Post 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. :)
User avatar
pixel
Vic 20 Scientist
Posts: 1328
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: 6502 emu help needed!

Post 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.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Post Reply