Page 2 of 5

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 2:34 pm
by lidnariq
NASM comes with a large pile of examples, which are probably good reference.

I'm still somewhat partial to the oooolld Turbo Assembler, but it's so much easier for me to use NASM nowadays...

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 2:44 pm
by Joe
Espozo wrote:The guy who made it pointed me to it. I don't think a document like this is even on actual mame.
What about this? :P

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 2:46 pm
by Drew Sebastino
That's odd... I wonder why he showed me the other thing...

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 3:35 pm
by Drew Sebastino
Well, I wrote "mov DS, AX" (kind of like "tax" in 65816 instruction set? what things, (I don't know what to call them) are there in the 80186? I mean like accumulator, x and y) in an otherwise blank .asm document and ran it through yasm and it gave me a file, so I at least know it's working. I tried looking up a good tutorial for yasm, but I only found a giant thing I don't feel like looking through (it doesn't really even seem that stubborn if it ran what I gave it) and all I really want to know right now is how to make it only use 80186 instructions. (Never mind. CPU 80186 seems to work on yasm also.) The main thing I wanted to ask though was I remember looking at Neo Geo Dev once, and instead of making everything from scratch, people just hijacked a rom of Super Side Kicks and only changed files that they needed to. (As in if you just want text to appear on the screen, you can just use the pre existing chr rom file.) The problem is, I have no clue what file is for. I opened up GunForce 2, and this is what I got: (I've never even heard of any of these file types before.)

a2_000.8a
a2_010.8b
a2_020.8c
a2_030.8d
a2_c0.1a
a2_c1.1b
a2_c2.3a
a2_c3.3b
a2_da.1l
a2_sh0.3l
a2_sl0.5l
a2_h0-a.6h
a2_h1-a.6f
a2_l0-a.8h
a2_l1-a.8f

How can there be so many files? The only file that I know what is for is "a2_da.1l", as it has all the pcm instruments. If it's anything like the Neo Geo, you just get your custom file, rename it, and replace it with the pre existing one. Mame acts like files are missing for some reason, so I remember someone made a .bat file that you run and it opens up some sort of debugging mode, where the game will actually run. Why it doesn't just run in the first place is beyond me, unless it looks and sees that the game isn't actually Super Side Kicks and stops you from attempting to run it.

Edit: Oh, apparently, yasm doesn't recognize "#". How does it tell what's a number and what's a register?

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 5:01 pm
by Joe
Espozo wrote:what things, (I don't know what to call them) are there in the 80186? I mean like accumulator, x and y
Those are called registers. The 80186 has the following 16-bit registers: AX, CX, DX, BX, SP, BP, SI, DI, ES, CS, SS, DS, FLAGS, IP. Additionally, AX, CX, DX, and BX can be accessed as pairs of 8-bit registers: AL, CL, DL, BL, AH, CH, DH, and BH.
Espozo wrote:I've never even heard of any of these file types before.
MAME names files based on the labels that would be visible to someone repairing their arcade system. The "extension" has nothing to do with the file contents; they're all just dumps of whatever was in the original ROM chips.
Espozo wrote:How can there be so many files?
There is one file per chip.
Espozo wrote:Mame acts like files are missing for some reason, so I remember someone made a .bat file that you run and it opens up some sort of debugging mode, where the game will actually run. Why it doesn't just run in the first place is beyond me, unless it looks and sees that the game isn't actually Super Side Kicks and stops you from attempting to run it.
MAME verifies files for accuracy, and will complain or refuse to run if the file doesn't match what it expects. You have to override this behavior to run a modified game.
Espozo wrote:Oh, apparently, yasm doesn't recognize "#". How does it tell what's a number and what's a register?
I'll assume by "number" you mean "immediate", and by "register" you mean "the equivalent to 6502's absolute", which is called "direct". In NASM syntax, immediate values have no prefix or suffix, and direct addresses are inside [] square brackets. (YASM uses NASM syntax by default.)

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 5:20 pm
by Drew Sebastino
Joe wrote:
Espozo wrote:what things, (I don't know what to call them) are there in the 80186? I mean like accumulator, x and y
Those are called registers. The 80186 has the following 16-bit registers: AX, CX, DX, BX, SP, BP, SI, DI, ES, CS, SS, DS, FLAGS, IP. Additionally, AX, CX, DX, and BX can be accessed as pairs of 8-bit registers: AL, CL, DL, BL, AH, CH, DH, and BH.
Well, that's a lot... (or do the 65816 and 6502 just have a very small amount of registers? I recall ARM having about the amount you showed.)
Joe wrote:Espozo wrote:How can there be so many files?There is one file per chip.
:shock: Is each ROM chip kind of like a ROM bank? Why not just have one giant ROM bank?
Joe wrote:MAME verifies files for accuracy, and will complain or refuse to run if the file doesn't match what it expects. You have to override this behavior to run a modified game.
That's a bit silly... Why not just give a warning message but let you continue anyway?
Joe wrote:
Espozo wrote:Oh, apparently, yasm doesn't recognize "#". How does it tell what's a number and what's a register?
I'll assume by "number" you mean "immediate", and by "register" you mean "the equivalent to 6502's absolute", which is called "direct". In NASM syntax, immediate values have no prefix or suffix, and direct addresses are inside [] square brackets. (YASM uses NASM syntax by default.)
Yeah, that's what I meant. I've been doing this stuff for almost a year now and I still don't know any of the terminology. :oops:

So, If I were to take an "immediate" and store it in a "direct", I'd do something like this?

Code: Select all

mov  [F8800], 1F
Oh yeah, one thing I noticed about the files for each game is that they aren't always (or ever, from what I've seen) the same file extension, but there are always 15 files. I wouldn't be surprised if there were files between the games that had the same purpose (like storing pcm samples) but just had different names. One last thing, I doubt it, but do you thing I could try to open one of the files with a chr rom editor? Aside from being 4bpp, I just don't know if the planar or packed pixel, or what. It shouldn't be too hard to figure out.

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 5:24 pm
by lidnariq
Espozo wrote:So, If I were to take an "immediate" and store it in a "direct", I'd do something like this?

Code: Select all

mov  [F8800], 1F
Except that you need to specify the size of the operand ... and I don't think you can specify a far address literally? But if you can, you'll have to specify it as a segmented pointer.

i.e. mov BYTE PTR [F000h:8800h], 1Fh or something like that.

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 5:32 pm
by Drew Sebastino
Do you think you could explain what the "BYTE PTR" means and also what "h" is? also shouldn't "[F000h:8800h]" be "[000Fh:8800h]" ? Why do you even need the ":"? Just because?

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 5:39 pm
by lidnariq
"BYTE" = you're writing an octet, as opposed to a "WORD" (16-bit value)
(or DWORD or QWORD on later machines, or TWORD if you have an 8087)
"PTR" = pointer, because you're doing a memory access without going through a register
"h" is how most some x86 assemblers mark hexadecimal arguments. eta: You can also use the C-like [0xF880:0].
And, no, the 8086 holds a 20-bit address in two 16-bit registers, by taking (SEGMENT<<4)+OFFSET, so the absolute address 0xF8800 is at the segmented address F880h:0h or F000h:8800h or F376h:50A0h

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 5:47 pm
by tepples
Joe wrote:Why are you linking to the OpenEmu copy of MAME instead of... actual MAME?
In my experience while building the citations for my list of arcade system boards' pixel clock rates, the web-based source code viewer at mamedev.org appeared to have some sort of throttling on how many source code files I could view in a day, after which point I started getting errors. I might be confused about the cause of this though, and the move to GitHub might have started to fix things.

On the other hand, since when is the MAME license (or any other noncommercial license) acceptable in a repository on GitHub's "open source" plan?
MAME verifies files for accuracy, and will complain or refuse to run if the file doesn't match what it expects. You have to override this behavior to run a modified game.
What's the preferred way to override this behavior?
Espozo wrote:Is each ROM chip kind of like a ROM bank? Why not just have one giant ROM bank?
For the same reason that several NES games have separate PRG ROM and CHR ROM chips: each one is connected to a separate bus. Also for the same reason that several Super NES games have several PRG ROM chips and very early NROM-128-class boards (RTROM and STROM) had two PRG ROM chips: sometimes two small chips are cheaper than one large chip.

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 5:55 pm
by Drew Sebastino
tepples wrote:MAME verifies files for accuracy, and will complain or refuse to run if the file doesn't match what it expects. You have to override this behavior to run a modified game.What's the preferred way to override this behavior?
Are you asking because you don't know how, or because you want to ask me how I think you should override it? I use a .bat file that contains the following:

Code: Select all

(name of mame exe file here) (game rar name here) -debug -nofilter -video d3d -waitvsync -window
pause
I actually kind of like it better than Mame normally, because you don't have that dumb filter that makes me feel like my vision is even worse than it is.

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 6:19 pm
by Drew Sebastino
Here's a cool little discovery I made: apparently, the graphics for the BG tiles (I haven't found sprites yet) are spread across 4 chips, one for each bit per pixel. It's at least nice to know that there are only 10 (as if that's small) files left to look at.
Irem M92 chr rom.png

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 6:21 pm
by lidnariq
Splitting bitplanes across multiple chips is an obvious way to improve performance.

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 6:25 pm
by tepples
Espozo wrote:Here's a cool little discovery I made: apparently, the graphics for the BG tiles (I haven't found sprites yet) are spread across 4 chips, one for each bit per pixel.
Which means it'd take about 15 minutes to make a tool to translate them in and out of Super NES 4-bit tile format by reinterleaving the bytes.

Re: Is Anyone Willing to Explain This C++ Code?

Posted: Sat Apr 04, 2015 6:26 pm
by lidnariq
Espozo wrote:-nofilter[...]I actually kind of like it better than Mame normally, because you don't have that dumb filter that makes me feel like my vision is even worse than it is.
I recently discovered that MESS has a drum machine emulator in it.The only video output on this drum machine is a single HD44780 LCD, with 16x2 6x8-dot characters.

Having MESS blow that tiny thing up to full screen with bilinear filtering? Bleh.