6502 emulator in FB
-
- Posts: 284
- Joined: Dec 21, 2008 15:08
- Contact:
6502 emulator in FB
My new project. My head is spinning already. First of all I don't want to hear anyone give me the business for writing an emulator in a language other than C. C is great. Maybe for you. Maybe not for me. I know it, I took two courses in it and I just don't like it. Moving on.
Why? Fun, of course! To learn!
How? I've been studying the heck out of the 6502 architecture and emulator writing tutorials.
Previous knowledge? Well I've USED emulators all my life. I did just a tiny bit of work on a couple of patches for PCSX2 but those were more hacks than anything else. So my starting knowledge is probably 3/10.
Where? Here of course!
When? Uhm... no idea. Working on it now. All depends on what craziness happens in my life.
Hope to show you something within a few days!
Why? Fun, of course! To learn!
How? I've been studying the heck out of the 6502 architecture and emulator writing tutorials.
Previous knowledge? Well I've USED emulators all my life. I did just a tiny bit of work on a couple of patches for PCSX2 but those were more hacks than anything else. So my starting knowledge is probably 3/10.
Where? Here of course!
When? Uhm... no idea. Working on it now. All depends on what craziness happens in my life.
Hope to show you something within a few days!
-
- Posts: 649
- Joined: Jun 09, 2005 0:08
Re: 6502 emulator in FB
Cool, emulation of any particular machine?
I occasionally mess around with some asm on an electron emulator.
I occasionally mess around with some asm on an electron emulator.
-
- Posts: 284
- Joined: Dec 21, 2008 15:08
- Contact:
Re: 6502 emulator in FB
IF and that's an if as big as this page, I can get the core 6502 to be nice then maybe... NES... maybe... lol. confidence=0 but then again I never had any confidence to do my other projects. And I did them. It's been a while since I wrote real code so getting back into it with this project is a big leap. I've always wanted to though. Enough time... and patience... and maybe it will explode. Lol.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
-
- Posts: 284
- Joined: Dec 21, 2008 15:08
- Contact:
Re: 6502 emulator in FB
Thank you very much! I was wishing for a reference like that~
-
- Posts: 649
- Joined: Jun 09, 2005 0:08
Re: 6502 emulator in FB
Nice Joshy, have you run any games on it?
Re: 6502 emulator in FB
These 6502 emulators may be useful:
http://skilldrick.github.com/easy6502/
http://e-tradition.net/bytes/6502/
http://6502.org/tools/emu/
The best online emulator I used was http://6502asm.com, but unfortunately the domain seems expired.
Wayback confirms this: http://wayback.archive.org/web/*/6502asm.com
At least some of the source code is available through Wayback.
http://skilldrick.github.com/easy6502/
http://e-tradition.net/bytes/6502/
http://6502.org/tools/emu/
The best online emulator I used was http://6502asm.com, but unfortunately the domain seems expired.
Wayback confirms this: http://wayback.archive.org/web/*/6502asm.com
At least some of the source code is available through Wayback.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: 6502 emulator in FB
@tinram
you are right the FreeBASIC version is too clever for you.. :lol:
Joshy
you are right the FreeBASIC version is too clever for you.. :lol:
Joshy
Last edited by D.J.Peters on Jan 09, 2013 17:44, edited 1 time in total.
Re: 6502 emulator in FB
@Joshy
Yes, the brain I was given falls far short of yours (I've seen lots of your code, and respect it).
I know almost nothing about the Commodore 64, except the 'general view' that BASIC on it was bad enough that assembler was often preferred - hence, I guess why you might be suggesting your C64 emulator for learning 6502.
The 6502 links were reference suggestions, simpler, but perhaps a bit purer than going through a C64 emulator.
Yes, the brain I was given falls far short of yours (I've seen lots of your code, and respect it).
I know almost nothing about the Commodore 64, except the 'general view' that BASIC on it was bad enough that assembler was often preferred - hence, I guess why you might be suggesting your C64 emulator for learning 6502.
The 6502 links were reference suggestions, simpler, but perhaps a bit purer than going through a C64 emulator.
Re: 6502 emulator in FB
'To give someone the business'. Never heard that expression before (I am not from the US of A, GB etc...).squall4226 wrote:My new project. My head is spinning already. First of all I don't want to hear anyone give me the business for writing an emulator in a language other than C. C is great. Maybe for you. Maybe not for me. I know it, I took two courses in it and I just don't like it. Moving on.
Anyway, great to see another interpreter/compiler related project. There can never be enough of those
kind of projects. Hope you come up with some beautiful code.
Aside: I preferred programming in assembler on the C64. BASIC was great but the raw speed I got by
using assembler was better (favourite instruction: NOP :) ).
-
- Posts: 284
- Joined: Dec 21, 2008 15:08
- Contact:
Re: 6502 emulator in FB
To "give someone the business" basically means to criticize them. I.e. in the case above it would be saying "It's stupid to write an emulator in any language but C. BASIC is useless for..." blah blah blah.
On topic, a lot has been going on in my life. I haven't gotten much done on this project except studying D.J. Peters' code. I've written the basic skeleton for all the instructions (LDA, LSR, etc) and some memory related code.
On topic, a lot has been going on in my life. I haven't gotten much done on this project except studying D.J. Peters' code. I've written the basic skeleton for all the instructions (LDA, LSR, etc) and some memory related code.
Beauty is in the eye of the beholder... hehe. Honestly I had gotten to where I was writing some pretty elegant stuff a couple of years ago. Especially after I took a college course called "Logic and Design in Programming" which taught me a lot about writing better, more organized, more readable code. Like in my RPG engine, it says in the source code itself that the code within ranges from hackish beginner stuff to very well written advanced stuff. The reason is that was my first major project and I started pretty much as a newbie, but worked on it for two years and got better and better. I don't expect my code to go back to the "hackish" level, but I do expect it will take me a bit to get back in the game.Hope you come up with some beautiful code.
-
- Posts: 284
- Joined: Dec 21, 2008 15:08
- Contact:
Re: 6502 emulator in FB
Yeah it's been over a year but I recently picked up the project again and it's actually going somewhere this time! I've even emulated a small program correctly. I've gotten really interested in emulation again since becoming a moderator on the PCSX2 forums. My thread about this project there is:
http://forums.pcsx2.net/Thread-My-6502- ... an-NES-emu
My most recent update I posted was:
So yeah, this may just happen after all. I'm excited. Stay tuned!
http://forums.pcsx2.net/Thread-My-6502- ... an-NES-emu
My most recent update I posted was:
Well despite the flu I have I finished all the opcodes that only operate in implied mode today. So:
BRK, CLC, CLD, CLI, CLV, DEX, DEY, INX, INY, NOP, PHA, PHP, PLA, PLP, RTI, RTS, SEC, SED, SEI, TAX, TAY, TXA, TYA
In addition, AND, ADC, STA, LDA are done for certain address modes.
I find myself actually scared. Normally when I write a program I can check its progress rather often to make sure I'm not screwing it up, but a lot of this is "hope I did it right." I'm sure I made some errors here and there, I'm just afraid I will get to the end and have something completely unworkable or wacky that can't be fixed. I will seriously be crushed if that happens, and probably give up programming for good. I know that seems a bit extreme, but I really don't have any confidence in my code, despite some of the things I've written(media player, RPG engine, etc). Anyway I'm feeling wicked sick from the flu now so I'm going back to bed.
Edit: oh I also implemented the stack today.
So yeah, this may just happen after all. I'm excited. Stay tuned!
Re: 6502 emulator in FB
The BASIC itself was not that bad (maybe a tad slow and memoryhungry), the problem was more that it never was extended for any form of graphics or sound. Not even changing the colour of the PRINTed text or a BEEP command, let alone graphics mode and 3 voice polyphonic music. Only POKE and PEEK to write/read memory addresses.tinram wrote:
I know almost nothing about the Commodore 64, except the 'general view' that BASIC on it was bad enough that assembler was often preferred - hence, I guess why you might be suggesting your C64 emulator for learning 6502.
That being said, I rarely made purely assembler programs, other that for demo compo's. To just _do_ things it was often more constructive to use the basic to script the asm together.
-
- Posts: 284
- Joined: Dec 21, 2008 15:08
- Contact:
Re: 6502 emulator in FB
Well, despite being even sicker I made some progress. I did some modularization, wrote some code to allow me to step through the program and view the processor status after each opcode, wrote some of the addressing modes, wrote a few small homebrews to test that things were working right, and I mean really small, stuff like:
LDA #$FA
AND #$44
Just to check each opcode I've finished so far produces correct output. So far so good. I was hoping to finish all the addressing mode stuff tonight, but my fever is 103F and my brain is no longer thinking well, so I had to stop. Sucks being sick. Still, this time I am chest deep in this project and it's gonna happen come hell or high water!
I need to think of a name for it!
LDA #$FA
AND #$44
Just to check each opcode I've finished so far produces correct output. So far so good. I was hoping to finish all the addressing mode stuff tonight, but my fever is 103F and my brain is no longer thinking well, so I had to stop. Sucks being sick. Still, this time I am chest deep in this project and it's gonna happen come hell or high water!
I need to think of a name for it!
Re: 6502 emulator in FB
@marcov
Thanks, that's good clarification on the C64.
And is starting to refresh my memory.
@squall4226
Hope you get better soon.
Your project sounds promising.
Thanks, that's good clarification on the C64.
And is starting to refresh my memory.
@squall4226
Hope you get better soon.
Your project sounds promising.