CppCast - MAME Emulation Project
Episode Date: September 7, 2016Rob and Jason are joined by Miodrag Milanovic to discuss his work on the MAME emulation project, its history and moving the MAME codebase from C to C++. Born in 1978, living in Novi Sad, Serbi...a. Proud husband and father of two. Started professional programming career in year 2000 working in Java, C# and of course C and C++ for various international customers. From 2012 coordinator of MAME emulation project, pushing hard in modernization of two decade old code. News NativeJIT a C++ to x64 JIT used in Bing Coati Release 0.8 LearnCpp "The design of C++" lecture by Bjarne Stroustrup Miodrag Milanovic @micko_mame Links MAME - Multiple Arcade Machine Emulator MAME on GitHub Sponsor Incredibuild
Transcript
Discussion (0)
This episode of CppCast is sponsored by Incredibuild.
You won't believe how fast your build can run until you download your free developer version
at incredibuild.com slash cppoffer or just click the link on our website.
CppCast is also sponsored by CppCon, the annual week-long face-to-face gathering
for the entire C++ community.
Episode 69 of CppCast with guest Miodrog Milanovic recorded September 7th, 2016.
In this episode, we discussed Native JIT and CODI.
Then we talked to Mewdrog Milanovic, coordinator of the MAME emulation project.
Mewdrog tells us about MAME's history, the only podcast for C++ developers by C++ developers.
I'm your host, Rob Irving, joined by my co-host, Jason Turner.
Jason, how are you doing today?
All right, Rob.
Doing lots of preparation for the conference coming up.
Yes, I need to increase the amount of prep work I'm doing.
I had a busy week the last few days, so I need to start playing catch-up and get working
on our talk.
So I guess there's one week left to register.
If anyone is interested in still signing up,
it's kind of short notice,
but,
but yeah,
I think they will still let you register.
Oh,
I'm pretty sure John went and turn you away.
Yeah.
We'll be great to get out there.
Um,
we did just order a couple more,
a couple more t-shirts and more stickers.
We'll probably have those to give away during our talk, right?
Yes.
Yeah.
Okay.
Well, at the top of your episode, I'd like to read a piece of feedback.
Last week, we had our news episode, and we had this comment on the website from Christopher.
And he wrote, guys, I enjoy the news recap discussion.
I wish it was longer.
I don't think you should feel obligated to have a full or even partial guest spot in every episode i might definitely you know always prefer to have a guest but i'm glad that you enjoyed the
news episode christopher right jason yeah it's hard to you know talk for a real long time just
the two of us yeah enough news items yeah i i it's it's hard to go on and on for uh without having the i guess to
add to the discussion i feel the same way but i'm glad you enjoyed the episode um and we did uh
hear from the guest who unfortunately missed out and he uh had to have some surgery i think so
we're gonna get him on in october yes yeah So we'd love to hear your thoughts about the show.
You can always reach out to us on Facebook, Twitter, or email us at feedback at cppcast.com.
And don't forget to leave us reviews on iTunes as well.
Joining us today is Miodrag Milanovic.
He was born in 1978 and lives in Novi Sad, Serbia.
He's a proud husband and father of two and started a professional programming career in the year 2000, working in Java, C Sharp, and of course, C and C++ for various
international customers. From 2012, he's been the coordinator of the MAME emulation project
and has been pushing hard for the modernization of two decades old code. Welcome to the show,
Miodrag. Thanks. Thanks for having me in the show.
Glad to see you.
I've got to ask a question that I like to ask a lot of our guests, is how did you get started programming?
What did you first program on?
Well, first computer was Zake Spectrum.
Okay. It was, well, I was about six years old when I got one.
I didn't even know the letters, so it was a bit hard.
Initially, my parents didn't give me a computer.
I was just looking from the side, and it was really interesting for me.
The thing I did was I ordered a book and I start, you know, looking
how the code is looking and what I could, you know, do. And I watched, there was a few TV shows
in that time, you know, explaining some things about computers and so on. So there was also newspapers in that period that were just publishing the source code
so you could actually see how it's working and you could learn a lot of things from that.
So I started looking at that and I saw how it could be done.
So I started with small programs, you know, and experimenting.
So yeah, after that, it was just, you know, going more and more
and working on not just on BASIC on ZEGG Spectrum,
but on assembly language because BASIC was really limited.
But that was, you know ending of the of the elementary
school when I start doing that then I moved to do Amstrad CPC computer and
that one had a better basic and also it was easier to develop in assembler so I
was working on it and after that in the in the high school I was working on it and after that in the high school I started working on the
IBM PC
and that was
when I started working on
the PC computers
and mostly
after that it was just
I started
with the Turbo Basic
sorry
Turbo Pascal and after, Turbo Pascal in that time.
And after that, Turbo C++ also started.
Turbo C first and then Turbo C++.
I started experimenting there.
And then, you know, you just start learning things.
So after that, you know, at the the university mostly I did
we learned
basically Java
most of the lectures
were in Java but also
we have the good
OOP
class
in which we just
learned things that
are not so connected to the language but
just how the things work actually and that was really good because we also get knowledge from
the few different languages and basically professor just taught us, you know,
in this language you wrote like this,
and this language you wrote like that, and it was really easy then to catch
how do you actually write a software
in different languages for OOP.
Okay.
So basically that was it mostly,
and after that, you know,
I started professionally to program program so that's that's
another story yeah i'm always impressed when we have a guest on who started assembly in like
elementary school time frame yeah yeah well uh thing is that you didn't have any other you know
way of doing things so if you want more, you need to start learning assembly.
Yeah, I just got stuck in BASIC for 10 years or so myself.
I mean, it was years with, you know, you just, if you want to get something out of those machines,
you needed to start working on assembly language, basically. Other than that, it was
almost impossible to get anything useful.
Right.
Okay, well, we had a couple of news items to discuss before we are going to start asking you about the main project.
So feel free to chime in on any of those, me or Jorg.
Okay?
Okay.
So this first one is NativeJIT, which is a C++ to x64 just-in-time compiler and it was just
open-sourced from the Bing team.
Right, Jason? Yeah, although
it seems like the actual title
and description of this is perhaps a bit
incorrect
because it cannot take C++
and compile it at runtime.
It can take expressions
that are written in
a domain-specific language in C++ and compile those at runtime.
Right.
And how exactly is this being used by the Bing team?
I wasn't quite sure what the purpose of it is.
That I didn't find myself either.
Okay. I think they mentioned on one place that they are actually using that to resolve some things related to the search results.
So basically they're propagating a lot of data.
So they're basically building queries, basically.
So expressions. So they define expression and then run
a large number of data through that
expression by using
this JIT.
So yeah, basically that's it.
But the thing is that
for example, we have the similar
thing in MAME and we call it
DRC and it's basically
directory compiler.
The thing is that we are using it for emulation of the CPUs.
But the thing is that we are working on the x86, x64 and PowerPC.
So those were the CPUs we support.
And basically we can then, you know,
we are not using it that much,
but we would like to use it more
and to make one part for the ARM processors
because they are much more in use than PowerPC is now.
Now, don't modern CPUs and modern compilers
have things like execute...
What am I trying to say?
Don't they make it relatively difficult
to take a bunch of code
and just jump into it and execute it from like a security perspective?
Yes, but you can, it's basically related to the operating system.
It's not so much related to the CPU itself. have on Windows, you have the allocation, memory allocation, and you can say, okay,
I want to allocate this memory, and I want it to be read, write, and execute.
So you can then execute that part of RAM.
But if you just use it for read, write, then it's just the data.
So you can't execute that. And on iOS,
there is no way you can do execute.
They limited that on the operating system level. So basically
you can't do anything like JIT on iOS.
Not in this form, for sure.
Okay, interesting.
Okay, so this next article is from the Cody blog,
which is announcing the release of their 0.8 version,
which it's not too interesting what they're adding with this version.
The main thing is Java support,
but I haven't heard of this product before.
So I just thought it was nice to share it because it's primarily
a C++ tool that they just added the Java support for. It's not an IDE. It seems to have its own
kind of unique purpose of just exploring code easily. And it kind of generates these UML
diagrams of your code on the fly. I thought it looked pretty handy. What did you think, Jason?
Yeah, I've seen some news about it come and go,
and I agree, it looks like it'd be pretty cool.
Like maybe if you are trying to jump into a project for the first time,
picking up someone else's code or something,
as a way to start to explore it and get in there, yeah.
Yeah, so the tool, like I said, it's in version 0.8.
It does have support on Linux, Windows, and Mac.
And you can get a free trial,
although when I looked at the free trial,
it looks like it might limit you
to looking at their sample project.
So if you want to actually try it out,
you might need to get a license,
but I'm not positive on that.
Looks like it's $29.
Yeah, so definitely looks like something to try out. There is a video
on the website if you want to see the tool in action and see exactly
what it does, but it's definitely a cool new tool that kind of has
its own little niche. It's not like an IDE replacement by any means. I don't think it even
supports code editing. It's not like an IDE replacement by any means. I don't think it even supports code editing. It's just
code viewing and creating these
UML diagrams on the fly
and making everything very searchable.
The next
one is learncpp.com.
During our news episode last week, we brought
up, I think it was CPP
examples.
Examples, yeah. Right, and someone pointed
out this as a
good way of just learning C++
with lots of sample code
in response to that.
This one surprised me,
learnc++.com.
I'm pretty sure I've never seen that URL
before, but it looks like it's been around for
a long time, since 2007.
Yeah. So, there's a long time, since 2007. Yeah.
So there's a lot
of information on here.
There is. They have a lot of good
samples going into
everything a C++ developer
needs to know.
And they have it broken up into different
chapters, so like C++
basics, operators,
control flow.
So it's pretty in-depth, right?
Yeah, looks like it.
Yeah.
And the last thing we have here is,
and I think this just got published to YouTube recently,
but it's a video of Bjarne Stroustrup talking about the design of C++.
And it dates back to, I think, either 94 or 96.
Yeah, 94.
And he goes into the origin of C++ and talks about C and Simula.
And then talks about some of the key design features of C++
and what the state of the language was at 20 years ago.
But it's pretty interesting to watch and to hear it all from Bjarn himself.
So you did watch the entire thing?
I did. I did watch the whole thing.
I only got to speak him.
Yeah, it's worth a watch.
It's, I think, about an hour, 15 minutes in total.
Yeah.
Okay, so, MewDraw, can you start off by giving us an overview of the MAME project?
Yes.
Well, MAME started, as we said, 20 years ago.
It was started by Nicola Salmoria, an Italian developer.
And the basic idea was to create an arcade emulator.
That's where the name comes from.
And thing is that in that time,
there were really few arcade emulators.
And they were just emulating a few games you know each emulator
was for just one type of game and that was basically a bad thing because if you want to
do something you always wanted to to have it all in one place so what he did was that he tried to make an universal emulator and that is what MAME is and the first
release of MAME emulated about six games which was you know most of them are were using Z80 CPU
and also 6502 and that was basically it, you know, just a few games.
And then it was really a, you know, new thing that time.
And people start, you know, writing their own emulators based on the main core.
And basically it start growing up quite rapidly.
So those initial years were, you know,
so-called golden age of MAME because it was really, really a great start
and a lot of emulators were basically, and we had support for almost hundreds of games
that were really interesting in that time.
And the thing is that during that time also,
in the parallel, there was another project called MESS.
And MESS was uh also from the people uh that were some people
were working on maim as well uh but uh they started a other way uh so they used the same core
but start emulating computers and consoles and that was a difference then and during all that time basically those
two projects grew independently but sharing the majority of code you know and during you know
after some time we decided that it would be really good to join those two projects.
And I basically started working on the MESS project, not on the MAME.
So I started working on the emulators for the computers and then just jumped in to work on the arcade games as well.
So that's how it all started and basically now we are
seeing MAME as an universal emulation platform. It's not a name we kept because
it's a brand basically. You have a lot of people knowing what MAME is.
And we kept that name, but we are now also emulating.
So we are emulating arcades.
We are emulating pinball games.
Also some fruit games, computers, consoles, calculators and some variety of hardware
that is not even in this group
so basically it's now a universal emulator
we can call it like that
So I think we're all familiar with
computers can run a variety of different software
now if I understand correctly, arcade systems,
there were like a handful of arcade motherboards
that generally the ROMs were swapped in and out of.
Is that a correct understanding?
Well, yeah.
It's a bit different architecture
because most of the arcade games were multi-CPU games.
So you had, for example, one CPU that is just running the main software of the game.
You have a different one that is just driving audio,
and you have a separate one for the graphics and things like that.
So it was really, those were quite expensive in their time, and still they are, you know,
and if you take a look, for example, how the games in the middle of 80s looked on arcades and how in the same period how the computer games looked like
it's a quite big difference you know you can see that arcade games were much more advanced you know
and that's why most of the people are if you take a look, for example, who are the MAME devs
and who are the people that are using MAME,
those people are mostly from our same age,
you know, because, you know,
we all are born in the same time
when we were going to arcades
and spend time there and have fun.
And also, we are the people who had computers as kids,
you know, and developed something on them.
And it's a bit nostalgic, you know.
And we just want to remember old times and how it all looked
and to try to run that software.
And the basic thing is that a lot of things get lost during the time.
For example, there are some really rare arcades.
There are also rare computers.
You have some software is even, you know,
you can't find a lot of copies from some software. And during time, there is a decay of the, you know,
diskettes, hard drives, CD-ROMs, etc.
And all things get destroyed.
And one of our goals is basically preservation of software.
And that's the thing, that's the point in which
we had trouble at the beginning
because that one
is not so far from piracy,
you know.
Because a lot of people see
it like that.
But we tried to,
that's one of the reasons
why when we came out,
we started, first, there was no, you know,
licenses on the code and things like that.
But when those problems came,
people agreed that it would be good to have a license,
which strictly says, okay,
if you can't use this on a commercial product,
because there were a lot of people
creating arcades,
new arcades, with the
computer inside, and selling
MAME with it,
and with the ROMs of the various
games.
And that was making us
more trouble than good.
You know?
And that's making us more trouble than good, you know. And that's the thing that you can also now go to some sites and you can buy one of those, definitely.
And there are also some computers made, basically, with computer boards that you can put in a standard arcade which had a version of MAME inside them and you can play I don't know about a few hundreds of
games that are capable to run on that hardware but those are all all using quite old version. I think it's some
0.35
or something like that.
That was the version that was
marked before the
transition to the new license. That was
marked as a GPL.
But it's even
not properly licensed.
You know,
people were not asking.
It was just, you know,
so they think it's legal,
but not so much.
But worst thing is that, you know,
you have some inaccurate, you know,
emulator that is more used
than the latest version, is you know could be not so good for the project but thing is that during the last two years we
worked hard on changing the license so I was working for about 10 months trying to get all the people and to ask them their opinion.
And we gave them a list of licenses that were in that time that people agreed that it would be good to have code under.
And at the end, it is about 96 percent of the code is
bsd3 license so you can use it now fully free and you know use it even in commercial projects
uh there is part of code with which is under gpl or lg. And that's the thing that, you know, it's viral
because then the whole project is basically GPL.
But a good thing is that at least we managed to get that part licensed as well
and that we marked all the files like that.
So what is different than maybe other project is that you don't need all files, you know,
in order to build an emulator.
Thing is that we have a core,
which is definitely BSD3 only.
And we have an emulation of various devices and various uh
drivers or machines that we are emulating and the thing is that uh we have our own build system i
i will talk about that later and uh we are basically making uh you can select, for example,
you want just Commodore 64 emulator
and it will build all the parts
that are needed just for that.
So you don't need emulation of other things,
which makes compilation faster
and also makes it possible
to have
builds for the
new separate emulators.
You were
just mentioning there some of the different
systems that you support.
Can you maybe list some of them?
Is it just arcades or is it old consoles
as well? I think you said Commodore 64.
How about Nintendo?
We have
36,000
different machines
emulated.
It's a quite big number.
Just to give you a more
realistic
image,
there are over 2,000
files with different emulations we call that
driver but essentially it's it's a hardware type you know because on the
arcades you have for example Neo Geo which is a specific hardware but you
have about 200 games that are totally different
that are running on the same hardware.
It's more like on a computer,
you can run hundreds of different software.
But here you have a fixed hardware,
and hardware also, it's a board,
but it also have additional board with ROMs on it.
So you have a software as a part of that.
So you can't change it easily.
I mean, you just need to open and exchange that part,
and basically it becomes a different arcade.
And we have over 2,000 different hardware supported.
So, for example, we have PC emulation as well.
And that's on the level that we can install Windows 2000 and Windows Millennium.
It also crashes like the real one.
It's good emulation.
You can run, you know, and
for now we are getting there
Intel's 486
CPU. We have some work
on Pentium CPU, but
right now we are working on the PCI implementation to make it more robust and
easier to work with. So we can then, you know, just add a lot of motherboards from that period
of time. But we also have, yes, computers, consoles. For example, for consoles, we have the NAS, SNES.
We also have N64.
And I have to say just what is the basic difference, you know, between us and the other emulators.
It's the thing that we are trying to be more general, you know, and
also, biggest
point is that we have
accuracy over performance.
That
is a good and bad thing,
but we try to be
accurate as much as possible,
so
it needs to work
as much as real hardware.
And that's why all others are using that old software of ours,
because it was not that accurate, but it was fast.
But the latest is much more accurate,
but you have some speed reduction because of that.
For example, we have the, for the audio boards,
there are some hardware that do not have the audio chip,
but you have analog circuits. And when you have analog circuits,
you just...
What people do in that time,
they just recorded
how that sounds and
placed that as a Vav files
and then just played
during the game.
And that sounded like that.
But what we did is that
now we have something it's called
a netlist it's basically emulation of the analog circuits in which you can
define all the values of the resistors and capacitors and some digital and analog circuits.
And you can connect that
and then you hear the sound,
how it should be heard.
And that takes some CPU time, of course.
But it's a cost of the accuracy.
But we think that it should be different from the others, and we should
provide and save it for the future to be heard as it was originally.
I'm curious, like your PC emulation, it seems it's different than DOSBox, because DOSBox
is a very specific thing.
Right. And it seems different than VMware VirtualBox today,
which uses...
Virtualization, basically.
Yes.
Right.
So you're actually fully emulating a PC,
and you said you support up to 486 right now?
Yes.
So then what kind of hardware do you support?
Could I say I want a 386 with a CGA card in it,
and now I want to boot that virtual PC?
Right, right.
What I did about three or four years ago,
I can't remember really,
is I did a thing called slot devices.
It's basically what I have noticed is that
you have
in computers
you have devices
that you can exchange
on a computer.
For example, you have the bus
on
Commodore 64, you had that
connector
at the back side of computer on which you could put some additional hardware.
And when you connect that, you have some other software running on it or you had a floppy drive or something like that.
And same thing you have for the PC computer.
So we defined ESA bus as a device inside computer.
And we have those slots.
You have six slots, ESA slots.
And you can put any card that is by ISA standard.
So you can say, okay, for example, in slot one, I will put CGA graphics.
In slot two, I will put a hard drive controller.
On slot three, I will put even a different graphics card, you know,
because there were some combinations that were possible in that time.
And so you can combine and create a machine like you wish.
By default, you get some, you know, reasonable configuration,
but you can change it in an experiment.
And the thing is that we have, for example, now about seven or eight different uh uh graphics card vga graphics card we have aga
cga hercules mda and it becomes really uh interesting you know because uh you can then
try some things that you couldn't do in the past because you can put multiple monitors and start
some debuggers and so on.
And it's
good because you're not
limited with
the virtualization. You're limited
to run that software
on
Intel CPU, basically.
And you can only virtualize
for example like VMware or VirtualBox on the Intel.
But if you want to run it on ARM CPU, you couldn't do that that way.
Also, DOSBox is having quite different approach.
They are just basically catching
all the calls, system
calls to the DOS, and
they are executing
that, they are simulating DOS
basically. And
that gives
a different result, and that's why
you have the software compatibility
lists and things like that,
because you can't support all variants like that.
And I think that's basically a major difference between us and DOSBox.
Okay.
So it's interesting, but the speed right now that we are running at are, without any problem,
you can run those 100 MHz CPUs, you know, things like that.
So 100, 200 MHz, it's not a problem.
But I think for the higher speeds, we would need to do some JIT, basically,
to use DRC or JIT. And we have the DRC cores for some other CPUs,
but we don't have it for Intel,
so we don't support Intel on Intel.
It's strange, but yeah.
It was on arcades.
As I said, major things were done for the arcades
and that's why uh the for example we didn't support those uh you know you don't have
had those things like graphics cards and um serial uh input or things like that because that was not
present on the on the hardware like it's arcade,
but you have that on computers and that's a totally different story.
Okay.
I wanted to interrupt this discussion for just a moment
to bring you a word from our sponsors.
IncrediBuild dramatically reduces compilation and development times
for both small and big companies like EA, Microsoft Game Studios, and NVIDIA.
IncrediBuild's unique process virtualization technology will transform your computer network
into a virtual supercomputer and let each workstation use hundreds of idle cores across
the network.
Use IncrediBuild to accelerate more than just C++ compilations, speed up your unit tests,
run more development cycles, and scale your development to the cloud to unleash Unreal speeds.
Join more than 100,000 users to save hundreds of monthly developer hours using existing hardware.
Download your free developer version at incredibuild.com slash cppoffer, or just click on the link in our link section. So in your bio, you mentioned that when you took over the project, you've been
pushing hard for modernization and how the code is, you know, 20 years old. What types of changes
have you been pushing for? Well, initially, I mean, one of the things is that the C to C++ was started by Aaron Giles.
He was the team lead before me.
And what he did is that he did the most of the core,
but there were a lot of things
that were related to the implementation
in the drivers that were left.
So it took us a while
really to clean that up.
Problem is that we are all
working this in the spare time.
So it's just a few hours a week
and that's not much.
But we managed to get
fully conversion to, well, it was mostly a c-width classes i would
say it was not a really c plus plus because there were a lot of a lot of things that were relying on
the on the some c stuff and uh what i was first uh doing was i tried to get rid of some macros and also conditional compiling. I
think that conditional compiling was killing us because it's a when you have
a software that needs to run on the 3 OS is and you have software that you know
had differences between main and mass.
We had also conditional compiling of subcode
because something is used and not on the other.
And it took me a while just to make it,
to always get everything compiled
and to have things selected during the runtime.
So it was mostly everything needs to be compiled.
And if there is some condition, it should be resolved in the runtime.
Thing is also, when we us to use the old standards
because we were losing a lot of time, you know,
just maintaining things like our internal string implementation.
Of course, everyone had a string implementation.
And also there were some lists and such.
It really took you a while to understand what's really going on.
And the problem was also that since there is not many of us working on project
and we always need an external help,
there were not much people contributing to the project
because it was really hard to learn,
to understand what's going on in the code.
It was just too complicated.
And one of the things why we started moving on the C++
was just that, just to uh uh simpler for people to understand
because with the uh op you get some clearer picture you know you have um if you have a c code
you just you're just not sure you know uh how all is connected uh What are the, you know, you don't see those interfaces.
You don't see those devices.
You just, you know, see some optimized code because we tried, you know, basic structure of the core and start building those devices on it and start defining interfaces. creating some device that if you need some if you need it to be the sound
device you will you know extend the sound interface and if it's a video
device you will extend the video interface and you will get some that way. So, the thing is that we also, since code needs to be a document itself,
that's how we see it, you know, you need to be able to understand how the machine works
by looking at the source code. And in order to do that, we didn't want to create some external
files and to make a new language, you know. But what we did is that we used macros. And
that's not maybe not a good, you know, solution, but it really gives you ability to define,
you know, some structure. And for example you we just have some machine configs
we call it like that and you said okay uh i have add cpu z80 with a speed of four megahertz and
then you can you know alter uh some parameters like, add a screen, which is that size, and refresh rate is like that.
So, I mean, I know that macros are considered not good in C++ especially.
Sometimes necessary, though. But yeah, those were necessary, and we needed to make it easier for people to understand how actual hardware works.
And that was kind of the problem. since we tried to support multiple operating systems, we also had the trouble with implementation of mutexes, threads, etc.
That was totally different.
And our layer that is used for that part is now about 20% or 10% from the previous size
because we just used the standard C++ 11 and 14
code. That'd be huge. Yeah, so it's
totally different now and it's much more stable
and that's really a good thing.
And yeah, one of the reasons I said
we used our old own build system is that
we use make standard make files but thing is that it was you know quite
limited because we could only build on the windows on the the MinG, and on the Linux and OS X on GCC and CLang.
But the problem was that we couldn't support Visual Studio.
And I think the Visual Studio is really good
because of its debugging capabilities.
And what I did is that I had found a pre for pre make for as
pre-made fork software that was there is also variant it's a fork created by Branimir Karadzic. It's called Jany.
And what he did is that he just extended that because it was not supported.
Pre-make 4 is not supported.
And the latest development is on Pre-, 5 version and I
worked on that project trying
to, you know, make
all things that we are needing
work there
and now we are getting basically
the ability to
create Visual Studio
projects and Xcode projects
which help
us, you know us develop much better.
And the thing is that it's using Lua files
for definition of build files.
So you can basically put anything inside
and we can create some variations know variations of of of of our build so it's it's much better for us than to
to create it that way so yeah that that was one of the reasons why we decided i mean i i think that
you know cmake is really great and but the uh you know definition language for CMake is really hard to learn.
And it's too complex, you know.
And I'm not sure if everything that we need is possible to create, you know.
And we anyway lost a lot of time getting this one running.
So, yeah, it would take us a lot to move to something else
definitely. So you know
you were saying earlier
that with your macros or whatever you
can say I've got a Z80 that runs at
4 megahertz and it's got a screen that's
got a certain refresh rate. Is it
really like that modular and
that pluggable together? Could I
create for instance
a system that never existed? Like,
could I say I have a 6502 with a VGA adapter and it talks at this memory location or something like
that? Sure, sure. Yeah, you can do that. Yeah. Thing is that, for example, for all those well
known CPUs, it's really not a problem. We have about over 80 CPUs supported.
But the thing is, for example, you can...
What is the usual situation?
The usual situation is that you stumble upon some ROM from an old computer,
and you just have that ROM,
and you don't even have how the hardware looks like, you know.
And that's the problem, you know.
And then you just connect CPU and you said, okay, connect that to ROM memory.
You know where to put it.
If it's Z80, you will put it at the beginning.
If it's 6502, you will put it at the end of the other space.
And then you just see the...
We have the internal debugger,
so you can see internal logs
and see what it's trying to read
and where it's trying to write.
And depending on that, you can determine,
okay, I see that he is using just these two bytes,
so it could be that chip that existed in that time for that kind of architecture.
So you can even recognize some patterns.
For example, for initialization, there is a Z80 PIO and there is Z80 CTC and things like that,
that were used as additional chips on the motherboards.
So it's really easy to add a new emulation, especially if the hardware is quite simple.
Interesting.
Yeah.
You can even experiment with some things like that.
So you can put maybe not a VGA because it would require you to have a lot of hardware
for communication.
But for example, you can make it use some serial output
and you can connect the terminal on it
and you can see the output on the terminal
because you have the generic terminal emulation inside.
So it's quite handy for development,
even for some unexisting and also for existing hardware.
Yeah, maybe a more realistic question would be a VIC-II
on the ISA bus of an x86.
Yeah, I mean, it's possible because there are also some interesting stuff, you know, like on the ISA bus, you can put, you know, basically anything.
And there were really a lot of hardware made like that by community.
Right.
And also you have some things like Kovacs, for example, that was placed on the parallel port.
And we basically have one emulation on that.
And you can put that on the PC computer.
You can put that also on CPC, Amstrad CPC.
And you just need to find the proper software to use that.
And it will work.
Just depending on the speed of the processor, you will get a different result, of course. But it will work, you know. And just depending of the speed of the processor,
you will get a different result, of course.
But yeah, it will sound the same.
You know, you have one emulation of the one device.
And I think that's great, you know,
just to have all that supported.
But it's really many years of development in that.
So, and yeah, as you said,
if you need a just small change
it takes you sometimes a few days to change everything in the code because you you for
example you know if you do are doing some refactoring it takes you quite a large amount of time to do that. So it's not that easy.
We have about 150 megabytes of source code.
Wow.
I mean, the comments are included there, but it's still a lot.
It's still a lot, and it takes a while to compile.
That's a trouble, basically, when you do things like that.
But yeah, we are looking forward to the future, and each year computers become faster,
and compile times are dropping, so compilers get better,
so C++ gets better.
So you're going to be doing a talk at CppCon
going over the history of MAME.
Right.
Before we let you go, is there anything you want to highlight
that's going to be in your talk that you haven't already shared with us?
Well, I'm not sure, to be honest.
I didn't think about that, but yeah.
Yeah, basically, it will cover some things
that we found out and experienced.
What we need to know is that C++ is places, but not at all on all places.
We had a problem.
It's really a simple thing.
We just moved one structure to be a class.
But that class is on 200,000 places, you know, and it can't
compile, you know, because if it's, you know, class, it takes much more. And if on 32-bit
operating system, it just can't compile. And we needed to change that and to make a simple
structure that holds the data and to have a separate class that will
initialize everything and work with that
and be just in one place.
So it's really, you know,
you just need to
look things and use just
those that
gives you better results,
I would say, you know. Not just
use things because they are new and
cool.
Well, I would say. Not just use things because they are new and cool. Okay. Well, I look forward
to your talk. Hopefully, I'll
be able to make it. If not, I'll definitely be
watching it on YouTube afterwards.
Thank you so much for your time today,
Miodrag. Thank you both.
See you then.
Thanks.
Thanks so much for listening as we chat about C++.
I'd love to hear what you think of the podcast.
Please let me know if we're discussing the stuff you're interested in,
or if you have a suggestion for a topic, I'd love to hear that also.
You can email all your thoughts to feedback at cppcast.com.
I'd also appreciate if you can follow CppCast on Twitter and like CppCast on Facebook.
And of course, you can find all that info and the show notes on the podcast
website at cppcast.com. Theme music for this episode is provided by podcastthemes.com.