Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Starting a new SMS emulator

Reply to topic
Author Message
Jason Starr
  • Guest
Reply with quote
Starting a new SMS emulator
Post Posted: Sun Jan 16, 2000 3:25 am
I am eager to write an emulator and I though what better system to emulate than my favourite Sega Master System. I can code in C but not too well. I want to write an emulator to increase my coding skills, even though I hear this is a bad idea to learn emu programming and general programming at the same time. Ive read a lot of the HOWTO create an emulator documents and stuff. What I plan on doing is documenting my way through the whole process of creating a SMS emu so other newbie coders like myself can learn from it. I dont really know why I'm telling everybody about this, I know most of you's who post on this board think I'm just some lamer newbie who doesnt know how to code and wants to know how to make his own emulator, but im serious about this. Any other people who are interested in what I will be doing or want to ask any questions you can feel free to email me or post on this board. Anyone who can help me with anything in regards to the emulation you are VERY welcome to email me with anything :). Thats all I have to say I think. Belated New Years to you all

-Jason Starr-
 
Jose Manuel Delgado Mendi
  • Guest
Reply with quote
Post Posted: Sun Jan 16, 2000 10:48 am
Hello :)

If you want to write and emulator, and you are a newie, first of all you have to rebuild all documentation of the systemn you want to emulate. If the system is SMS you are luck, because all goods docs about it are here, in SMS Power. Second, you can find all source codes related the emulator you want to write. You musn´t copy the source, but it can help you in certain things, which can stop you a lot of time without help. Master Gear is a good option, or Mess or DarkNes. Third, you need a good compiler and a good graphics library. I thing the best solution nowadays id DGJPP+Allegro. It´s portable and very fast, if you code it properly.

When all before is done, you have to planificate your work. Start with the Allegro library: how to set the resolution you need, how to paint characters on the screen, etc... Then is the momento of build the emulator code. Start with the CARTDRIGE LOADING CODE. The first you need to emulate is rom code!!!. All you need to emulate a system is the processor and the code, so if ou have the code, it´s now the moment of programming the Z80 emulation code.¡¡¡¡¡ I encouragely recomend you that uses a Z80 Engine available in the net!!!!!! If not, you spend lot of hours do the work others done in the past. If you want to create new processor emulation code, try the R3000, the SH1 or something, but if you want to emulate a old processor, not to use a Z80 engine by other is a stupid idea. Z80 by marat is easy, but not fast and doesn´t emulate multiprocessor. Z80 by Marcel the Koegel is a better solution. The best solution is RAZE. It have a nice interface and it is fast. The problem is that is´t written in assembler, so if you want to learn, the best solution is a C engine: Marat or Marcel de Koegel.

Once you have done the work, the processor may want to paint on the screen. It´s the moment of write the VDP emulation code and implement the I/O ports. Ports that you have not use, to return 0xFF, and ports you use implement it with functions or other mechanis you want. To emulate the VDP is better to first make a line-per-line engine, like Master Gear, that paints the tiles, without scroll. It´s very easy. When you obtain your first image, try to emulate more things: sprites, scroll, more registers, etc...

When you have a poor emuator, but a work emulator, is the moment of make sound emulation, speed adjust code (to run at the same speed on all computers), other things: you can view a lot in Calypso or Meka: a GUI, other pheripherals, save-state code, gamma correction, etc....

It´s the mode I make Calypso. I think this can help you.

Happy new 2000 year :)

Saludos,

Jose Manuel Delgado
 
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
Post Posted: Sun Jan 16, 2000 11:08 am
Creating an emulator is a hard process if you don't have the experience and knowledge. As soon as you get it, it's much easier and you can consider making improvment in your existing code, etc. So I think making such documentation *while* you are making your emulator isn't a good idea, as it's probable you'll have to give work on important points in the later stage. My suggestion is that you write a working emulator (and I believe we'll be all happy to help you if you actually get somewhere), and then document the second or third SMS emulator you'll make from stratch.

Quote
> I am eager to write an emulator and I though what better system to emulate than my favourite Sega Master System. I can code in C but not too well. I want to write an emulator to increase my coding skills, even though I hear this is a bad idea to learn emu programming and general programming at the same time. Ive read a lot of the HOWTO create an emulator documents and stuff. What I plan on doing is documenting my way through the whole process of creating a SMS emu so other newbie coders like myself can learn from it. I dont really know why I'm telling everybody about this, I know most of you's who post on this board think I'm just some lamer newbie who doesnt know how to code and wants to know how to make his own emulator, but im serious about this. Any other people who are interested in what I will be doing or want to ask any questions you can feel free to email me or post on this board. Anyone who can help me with anything in regards to the emulation you are VERY welcome to email me with anything :). Thats all I have to say I think. Belated New Years to you all
  View user's profile Send private message Visit poster's website
Chris
  • Guest
Reply with quote
Wow! So this is where it all begins...
Post Posted: Sun Jan 16, 2000 4:26 pm
I'm doing the exact same stages as you're saying! First, I got my emulator to check and validate
whether the rom was a .NES Rom file. If so, then I would calculate how large the program and
video binary was by the header information and then I would allocate memory for it and copy
the binary into the allocated memory. Now that everything is working correctly without any
annoying warning flags, I'm at the next stage as you say. I'm going to code the m6502
core myself. My reasons? To totally understand all the aspects of a processor and to show
my programming advisor, "Yes. I wrote this working CPU emulator and debugger."
After that, it's a matter of the NES' memory stuff and using variables to emulate registers.
I predict that it may be a bitch but I'll trudge my way through it. My main focus is the
sound and pallete stuff. Make it like instead of using this one's and that one's pallete
file, simply create a standard pallete file, STDNES.PAL (Standard NES Pallete file)
and allowing the user to press 1 of 2 keys on the keyboard to increase or decrease the
intensity of the colors. It seems that all the other pallete files are exactly the same except
some are brighter or duller. Hopefully, now that I have a real NES again with a bunch
of games and a digital sound connection for my speakers, I'll have some descent sound.

(Yes, I know this is a Sega site but the information here is universal and priceless.)

Chris :o)
 
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
About Raze
Post Posted: Sun Jan 16, 2000 7:20 pm
Quote
>Z80 by marat is easy, but not fast

Marat's core is the fastest C core available and unless you sacrify emulation in some way you won't get faster with RAZE.

Quote
>and doesn´t emulate multiprocessor.

It's easily modifiable.

Quote
>Z80 by Marcel the Koegel is a better solution.

Except that it's buggy.

Quote
>The best solution is RAZE.

Except that it's buggy.

Quote
>It have a nice interface and it is fast.

It have a painful interface. As soon as you'll emulate mappers and stuff, you'll see.
  View user's profile Send private message Visit poster's website
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
About the Other Things (should have answering in a single message, anyway :-)
Post Posted: Sun Jan 16, 2000 7:27 pm
Quote
> you can view a lot in Calypso or Meka: a GUI, other pheripherals, save-state code, gamma correction, etc....

I would add that having little "technical related" tools like in Meka and Calypso can help in some cases to figure things out.
Like VRAM or Palette viewer, etc..

Quote
> It´s the mode I make Calypso. I think this can help you.

"It's the way I make Calypso" should be said in English.
I hope you aren't offended by me reporting such mistakes - my english is far from being perfect, anyway, but I'm always glad when someone helps me to improve it ! :)
  View user's profile Send private message Visit poster's website
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
..answered..
Post Posted: Sun Jan 16, 2000 9:39 pm
Shouldn't give english lessons when I made a mistake in the message subject ^_^
  View user's profile Send private message Visit poster's website
Jose Manuel Delgado
  • Guest
Reply with quote
Re: About Raze
Post Posted: Mon Jan 17, 2000 4:59 pm
Hello :)

Raze is as accurate as Marat Z80, and the engine by marcel de Koegel is as acurrate as Marat, because it based on it, but usesfunctiones pointers rather than switch case.

The interface of Raze is easy to use. If you like to implement mappers, simply make one function that do that, and define a region covering all the memory. Simply as that. This is the way Calypso uses it, since old versions of Calypso used Marat and newer Raze, without change the mapper functions.

Saludos,

Jose Manuel Delgado
 
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
Re: About Raze
Post Posted: Tue Jan 18, 2000 5:32 am
Quote
> Raze is as accurate as Marat Z80, and the engine by marcel de Koegel is as acurrate as Marat, because it based on it, but usesfunctiones pointers rather than switch case.

Well, having implemented the three Z80 cores in Meka, I can say the two others have bugs in various games.

Quote
> The interface of Raze is easy to use. If you like to implement mappers, simply make one function that do that, and define a region covering all the memory. Simply as that. This is the way Calypso uses it, since old versions of Calypso used Marat and newer Raze, without change the mapper functions.

Alright, it works but if you use Raze this way you are not getting *any* speed improvement over Marat's core!
  View user's profile Send private message Visit poster's website
Nyef
  • Guest
Reply with quote
Re: About Raze
Post Posted: Tue Jan 18, 2000 1:56 pm
Quote
> > Raze is as accurate as Marat Z80, and the engine by marcel de Koegel is as acurrate as Marat, because it based on it, but usesfunctiones pointers rather than switch case.

> Well, having implemented the three Z80 cores in Meka, I can say the two others have bugs in various games.

Indeed. Just because they are based off the same code doesn't mean that they are all equally bug free (and if they were, the bugs are probably in different places). And didn't you say earlier that you had to bugfix even the one you ended up using?

Quote
> > The interface of Raze is easy to use. If you like to implement mappers, simply make one function that do that, and define a region covering all the memory. Simply as that. This is the way Calypso uses it, since old versions of Calypso used Marat and newer Raze, without change the mapper functions.

> Alright, it works but if you use Raze this way you are not getting *any* speed improvement over Marat's core!

This depends. If memory serves, Marat's core, as distributed, is multiprocessor capable, and stores flags in cannonical form. There are a number of things you can do to it to speed it up (of course, this requires much damage to the macrology, and can cost you the multiprocessorness, but it can be done).

Of course, real speedups to Marat's core are a pain to do, because he didn't anticipate that anyone would do them (stuff like using a pointer to memory do opcode fetches, that was a pain).

--Nyef (I'm looking forward to getting rid of M6502, MZ80, and the hack of M6502 that I'm using as a 6280 core)
 
ATani
  • Guest
Reply with quote
Re: About Raze
Post Posted: Tue Jan 18, 2000 4:22 pm
Quote
> >Z80 by marat is easy, but not fast

> Marat's core is the fastest C core available and unless you sacrify emulation in some way you won't get faster with RAZE.

> >and doesn´t emulate multiprocessor.

> It's easily modifiable.

> >Z80 by Marcel the Koegel is a better solution.

> Except that it's buggy.

> >The best solution is RAZE.

> Except that it's buggy.

> >It have a nice interface and it is fast.

> It have a painful interface. As soon as you'll emulate mappers and stuff, you'll see.

If you want FAST and Accurate try MZ80, it is done in C and ASM (two cores). I use it in my EMU as the ASM version. Take a look at this one as another Z80 core that so far has not had any problems with any games i have tossed at it :)

ATani
 
  • Joined: 28 Sep 1999
  • Posts: 1197
Reply with quote
Re: About Raze
Post Posted: Tue Jan 18, 2000 5:09 pm

Quote
> > The interface of Raze is easy to use. If you like to implement mappers, simply make one function that do that, and define a region covering all the memory. Simply as that. This is the way Calypso uses it, since old versions of Calypso used Marat and newer Raze, without change the mapper functions.

> Alright, it works but if you use Raze this way you are not getting *any* speed improvement over Marat's core!

This depends on your implementation.

If you set up RAZE so it has direct access to the ROM and RAM,
and you only have (you only need) one handler for accesses
to FFFC-FFFF, it's very fast, faster than any of the "C" cores.

On the other hand, if you pass everything through a handler,
you'll lose a lot of speed. There's a big difference between
retrieving a byte of data versus calling a function to do
some memory range checks then retrieving the byte.


  View user's profile Send private message Visit poster's website
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
Re: About Raze
Post Posted: Tue Jan 18, 2000 5:42 pm
Quote
> If you set up RAZE so it has direct access to the ROM and RAM,
> and you only have (you only need) one handler for accesses
> to FFFC-FFFF, it's very fast, faster than any of the "C" cores.

It'll be a pain to implement all kind of mappers.
  View user's profile Send private message Visit poster's website
Jose Manuel Delgado
  • Guest
Reply with quote
Re: About Raze
Post Posted: Wed Jan 19, 2000 1:38 pm
Hello :)

Quote
> Well, having implemented the three Z80 cores in Meka, I can say the two others have bugs in various games.

It could be..... I can Calypso to do it. And, what games are...?

Quote
> Alright, it works but if you use Raze this way you are not getting *any* speed improvement over Marat's core!

This is formely false. The same version of Calypso (Build 006), one with Raze engine and other withs Marat´s, same memory handler, and the Raze version make eight frames per second plus the version compiled with Marat. The reason is that true, you can spend a lot of time with the handler, but the emulation itself is faster, because it´s written in pure assembly. Try to make an ASM version of Marat with the Gcc option -E (i don´t remember, but i think it´s -E). The ASM code it´s bigger and slower that a well optimized ASM version like Raze.


Saludos,

Jose Manuel Delgado
 
  • Joined: 24 Jun 1999
  • Posts: 1732
  • Location: Paris, France
Reply with quote
Re: About Raze
Post Posted: Thu Jan 20, 2000 7:28 pm
Quote
> > Well, having implemented the three Z80 cores in Meka, I can say the two others have bugs in various games.
> It could be..... I can Calypso to do it. And, what games are...?

I don't remember of all problems in Raze.
Characters in Y's' Town did hang on wall if I remember correctly.

Quote
> > Alright, it works but if you use Raze this way you are not getting *any* speed improvement over Marat's core!
> This is formely false. The same version of Calypso (Build 006), one with Raze engine and other withs Marat´s, same memory handler, and the Raze version make eight frames per second plus the version compiled with Marat. The reason is that true, you can spend a lot of time with the handler, but the emulation itself is faster, because it´s written in pure assembly. Try to make an ASM version of Marat with the Gcc option -E (i don´t remember, but i think it´s -E). The ASM code it´s bigger and slower that a well optimized ASM version like Raze.

I didn't got any speed improvment when switching from one core to another. I'll try to recompile and see what's going on.
The more I think about it, the more I believe there is a stupid bug in Meka that make it very slow. Because the CPU core and the Graphics renderers seems to use only a very few of the few CPU power!
  View user's profile Send private message Visit poster's website
Johannes Holmberg
  • Guest
Reply with quote
Re: Wow! So this is where it all begins...
Post Posted: Fri Jan 21, 2000 1:26 pm
Quote
> I'm going to code the m6502 core myself.

Too late. It's already been done... It's written by some guy called Marat Fayzullin.
 
AltCtrlDel
  • Guest
Reply with quote
Post Posted: Sat Feb 12, 2000 8:47 am
Quote
> I am eager to write an emulator and I though what better system to emulate than my favourite Sega Master System. I can code in C but not too well. I want to write an emulator to increase my coding skills, even though I hear this is a bad idea to learn emu programming and general programming at the same time. Ive read a lot of the HOWTO create an emulator documents and stuff. What I plan on doing is documenting my way through the whole process of creating a SMS emu so other newbie coders like myself can learn from it. I dont really know why I'm telling everybody about this, I know most of you's who post on this board think I'm just some lamer newbie who doesnt know how to code and wants to know how to make his own emulator, but im serious about this. Any other people who are interested in what I will be doing or want to ask any questions you can feel free to email me or post on this board. Anyone who can help me with anything in regards to the emulation you are VERY welcome to email me with anything :). Thats all I have to say I think. Belated New Years to you all

> -Jason Starr-

Why make an emulator for SMS in C. That has been done at least 4 times. Try making an SMS emulator for assembler, for Linux or something different than what has already been done.
 
Richard Mitton
  • Guest
Reply with quote
Re: About Raze
Post Posted: Wed Feb 16, 2000 3:16 am
Quote
> >The best solution is RAZE.
> Except that it's buggy.

OK, just to clear a bit up here.

1) RAZE *isn't* based off Marcel's or Marat's core, it's written from scratch in assembler.

2) It has no bugs in AFAIK, although there are a coupla features not done yet (R register etc). Should be in the next release.

There are at least 2 SMS emulators using it, both with no problems at all from what I have heard.

 
Reply to topic



Back to the top of this page

Back to SMS Power!