Is Anyone Willing to Explain This C++ Code?
-
Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Is Anyone Willing to Explain This C++ Code?
Okay, I know what you're all thinking: Why don't you learn C++ yourself? Well, If you find a tutorial that isn't a thousand pages long and is not in book form, then I might consider. (I think koitsu might have showed me something on C? If he did, I don't know where it is.) Basically, this is an extension of the Irem M92 thread, but it's main focus is on translating this, which admittedly, doesn't look like any small task: https://github.com/OpenEmu/UME-Core/blo ... ideo/m92.c I would be offering money, but I'm 99% sure my mother won't let me...
Last edited by Drew Sebastino on Fri Apr 03, 2015 7:18 am, edited 2 times in total.
-
Dwedit
- Posts: 5257
- Joined: Fri Nov 19, 2004 7:35 pm
Re: Is Anyone Willing to Explain This C Code?
That's C++ code, not C code. Looks like it's filled with macros, so you could run it through a preprocessor to get the actual code.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
-
Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: Is Anyone Willing to Explain This C Code?
Oops...
I'll change the title... I've always wondered, is there such a thing as C+?
Edit: What the heck is a preprocessor? And are the macros just like they are in ASM, but instead they use C++, meaning they exist so you don't need to write the same or nearly the same code over and over again?
Edit: What the heck is a preprocessor? And are the macros just like they are in ASM, but instead they use C++, meaning they exist so you don't need to write the same or nearly the same code over and over again?
-
Dwedit
- Posts: 5257
- Joined: Fri Nov 19, 2004 7:35 pm
Re: Is Anyone Willing to Explain This C++ Code?
If you're building with GCC, you can run CPP (c preprocessor) on it and see the result of all Preprocessor directives. This will perform all the #includes and everything, so you might have to cut all that stuff out first before reading it. I think that will also remove the comments as well.
I think you invoke it by "cpp file.c > output.txt" or something like that. You need GCC (mingw or cygwin) installed.
I think you invoke it by "cpp file.c > output.txt" or something like that. You need GCC (mingw or cygwin) installed.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
-
Jarhmander
- Formerly ~J-@D!~
- Posts: 570
- Joined: Sun Mar 12, 2006 12:36 am
- Location: Rive nord de Montréal
Re: Is Anyone Willing to Explain This C++ Code?
Hmm, the paletteram_xBBBBBGGGGGRRRRR_word_w would score quite high as the longest function name. Hopefully it's used only once.
((λ (x) (x x)) (λ (x) (x x)))
-
Dwedit
- Posts: 5257
- Joined: Fri Nov 19, 2004 7:35 pm
Re: Is Anyone Willing to Explain This C++ Code?
C++ mangled function names make that look short.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
-
Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: Is Anyone Willing to Explain This C++ Code?
Well, at least we now it uses the same color setup as the SNES. 
Oh, you know, one thing I don't understand is how there was no real reference used in the making of this. Wouldn't it have been easier to make a sheet with all the hardware info before making this? Do you think that maybe I should email the author of the page to see if he made one as a reference?
Edit: Oh, a random observation: When System 16 said the Irem M107 had twice as many colors, it must have meant colors total instead of color palettes because it has the same number of color palettes as the M92. It would probably have been a lot easier to do that instead of increasing the color palettes, seeing that every color in CGRAM (or whatever it's called here) has an unused bit for every color. I wonder if it's like the Neo Geo in that it has a half brightness bit, or if it has an extra green. I personally like the half brightness better.
Edit: I emailed the author of the page. We'll see what happens...
Oh, you know, one thing I don't understand is how there was no real reference used in the making of this. Wouldn't it have been easier to make a sheet with all the hardware info before making this? Do you think that maybe I should email the author of the page to see if he made one as a reference?
Edit: Oh, a random observation: When System 16 said the Irem M107 had twice as many colors, it must have meant colors total instead of color palettes because it has the same number of color palettes as the M92. It would probably have been a lot easier to do that instead of increasing the color palettes, seeing that every color in CGRAM (or whatever it's called here) has an unused bit for every color. I wonder if it's like the Neo Geo in that it has a half brightness bit, or if it has an extra green. I personally like the half brightness better.
Edit: I emailed the author of the page. We'll see what happens...
-
Jarhmander
- Formerly ~J-@D!~
- Posts: 570
- Joined: Sun Mar 12, 2006 12:36 am
- Location: Rive nord de Montréal
Re: Is Anyone Willing to Explain This C++ Code?
Well yeah, when you look at nested templates, the result is quite surprising!Dwedit wrote:C++ mangled function names make that look short.
((λ (x) (x x)) (λ (x) (x x)))
-
Drag
- Posts: 1708
- Joined: Mon Sep 27, 2004 2:57 pm
Re: Is Anyone Willing to Explain This C++ Code?
Yep! So thank god we have the mangled names so we don't have to look at those really long names, huh?Jarhmander wrote:Well yeah, when you look at nested templates, the result is quite surprising!Dwedit wrote:C++ mangled function names make that look short.
-
Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: Is Anyone Willing to Explain This C++ Code?
Good news! I've contacted the person who made that code, so I'm at least one step closer to figuring this whole thing out. He showed me this: https://github.com/OpenEmu/UME-Core/blo ... vers/m92.c which helps explain things a ton. I've been looking at 80186 related stuff, and I found this which I think is what I'm looking for. It's supposed to be the instruction set for it.
If this is correct, it actually doesn't look that bad! It actually seems to share quite a bit of similarities (at least compared to ARM. I actually looked at the 68000 and it left my head spinning.) with the 65816 instruction set. Well, at least I don't have to deal with things like this anyway! (I now know why x86 is considered a mess.)
If this is correct, it actually doesn't look that bad! It actually seems to share quite a bit of similarities (at least compared to ARM. I actually looked at the 68000 and it left my head spinning.) with the 65816 instruction set. Well, at least I don't have to deal with things like this anyway! (I now know why x86 is considered a mess.)
One thing though, do I need to find a special 80186 assembler, or will any x86 assembler do as long as I don't use any instructions that come after? (By judging instruction earlier, I don't think I'd even want to.)Wikipedia wrote:Instruction: VFMADDSUBPD xmm0, xmm1, xmm2, xmm3
Opcode: C4E3 WvvvvL01 5D /r /is4
Meaning: Fused Multiply-Alternating Add/Subtract of Packed Double-Precision Floating-Point Values
You do not have the required permissions to view the files attached to this post.
-
Joe
- Posts: 773
- Joined: Mon Apr 01, 2013 11:17 pm
Re: Is Anyone Willing to Explain This C++ Code?
Why are you linking to the OpenEmu copy of MAME instead of... actual MAME?
(There probably aren't any significant differences between the two, but...)
That instruction set isn't very complete. It's missing a few instructions, like movsb and movsw, and it doesn't cover addressing modes or segmentation at all. If someone made the same chart for 68000, you'd think it looked like 65816 too.
As far as assemblers go, I recommend NASM or YASM. They can easily be configured to generate only valid 80186 opcodes.
That instruction set isn't very complete. It's missing a few instructions, like movsb and movsw, and it doesn't cover addressing modes or segmentation at all. If someone made the same chart for 68000, you'd think it looked like 65816 too.
As far as assemblers go, I recommend NASM or YASM. They can easily be configured to generate only valid 80186 opcodes.
-
lidnariq
- Site Admin
- Posts: 11803
- Joined: Sun Apr 13, 2008 11:12 am
Re: Is Anyone Willing to Explain This C++ Code?
I told you to ignore things newer than 8086 ;pEspozo wrote:Wikipedia wrote:Instruction: VFMADDSUBPD xmm0, xmm1, xmm2, xmm3
Opcode: C4E3 WvvvvL01 5D /r /is4
Meaning: Fused Multiply-Alternating Add/Subtract of Packed Double-Precision Floating-Point Values
MMX and SSE instructions are ... really an entirely different universe than the older ones.
Almost all assemblers have a directive that will specify the instruction set. (e.g. nasm has "CPU 80186"). One almost-unusable instruction present in the original 8088/8086 that they removed from later cores is POP CS.One thing though, do I need to find a special 80186 assembler, or will any x86 assembler do as long as I don't use any instructions that come after?
-
Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: Is Anyone Willing to Explain This C++ Code?
The guy who made it pointed me to it. I don't think a document like this is even on actual mame.Joe wrote:Why are you linking to the OpenEmu copy of MAME instead of... actual MAME? (There probably aren't any significant differences between the two, but...)
Ok. It looked rather small. (One can dream.Joe wrote:That instruction set isn't very complete. It's missing a few instructions, like movsb and movsw, and it doesn't cover addressing modes or segmentation at all. If someone made the same chart for 68000, you'd think it looked like 65816 too.
I'm going to take a look...Joe wrote:As far as assemblers go, I recommend NASM or YASM. They can easily be configured to generate only valid 80186 opcodes.
Oh yeah, and lidnariq, the thing is so preposterously large, I almost though someone put it in the webpage as a joke, until I saw other ones just like it... The instruction is so complex, that even when I read the description, I still understand what it does.
-
lidnariq
- Site Admin
- Posts: 11803
- Joined: Sun Apr 13, 2008 11:12 am
Re: Is Anyone Willing to Explain This C++ Code?
The wikipedia reference isn't very good for actually programming...
I'd try a few of the other search results for "8086 instruction set", such as
http://www.gabrielececchetti.it/Teachin ... on_set.pdf
http://www.ing.unlp.edu.ar/electrotecni ... on_set.pdf
http://mai.kvk.uni-obuda.hu/documents/t ... erview.pdf
I'd try a few of the other search results for "8086 instruction set", such as
http://www.gabrielececchetti.it/Teachin ... on_set.pdf
http://www.ing.unlp.edu.ar/electrotecni ... on_set.pdf
http://mai.kvk.uni-obuda.hu/documents/t ... erview.pdf
-
Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: Is Anyone Willing to Explain This C++ Code?
The one thing though is that I'm looking at the 80816, so there are a bit more instructions, but I could still probably use those. I looked at NASM, but after I opened the rar file, a billion files spewed out, and I couldn't even find the exe/bat file. I then got YASM, and it was only one file. I think you know which one I chose. 