MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Pages: 1

JHake
MAME Fan
Reged: 01/27/21
Posts: 8
Send PM


MAME programming starter pack?
#389733 - 01/27/21 10:56 PM


I want to start hacking MAME, but before I dive-in blind and end up lost and frustrated I want to say out loud where I want to begin and throw the question open to guidance from forum members. FYI: I am already a programmer, just not one with experience using emulators.

The first thing I wanted to do is to write a program which records a controller stream from a game being played and writes it to a file, and it can also feed a controller stream to a game loaded from such a file.

I intend to use a basic ASCII readable RLE format like:

50 n
200 u
10 f

(For 50 frames of neutral then 200 frames of UP then 10 frames of Fire).

Ideally, I'd like the data to be fed in by something which traps controller-port read operation in the game, ie something which traps the operations which load the controller status and feeds them data directly.

On a Commodore 64 for example, this would trap any LDA $DC01 and feed it controller port data sequentially.

The basic question then is:

I want to transparently trap controller-port reads in Mame, where do I start?

Thanks, I hope that's clear.

Edited by JHake (01/28/21 02:07 PM)



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4462
Loc: Melbourne, Australia
Send PM


Re: MAME programming starter pack? new [Re: JHake]
#389738 - 01/28/21 05:51 AM


> The first thing I wanted to do, assuming the idea doesn't exist already (if it does,
> I could be saved much time) is to write a program which records a controller stream
> from a game being played and writes it to a file, and it can also feed a controller
> stream to a game loaded from such a file.

You know, MAME has had the -record and -playback options for over a decade...



JHake
MAME Fan
Reged: 01/27/21
Posts: 8
Send PM


Re: MAME programming starter pack? new [Re: Vas Crabb]
#389739 - 01/28/21 12:33 PM


Thanks for the response. OK, I will look at it.

Let me change my question:

I'd till like to do it myself as a basic starter project, before I go on to try other things.

What would be a good starting point with MAME if I wanted to write such a thing myself?



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: MAME programming starter pack? new [Re: JHake]
#389740 - 01/28/21 01:08 PM


> Thanks for the response. OK, I will look at it.
>
> Let me change my question:
>
> I'd till like to do it myself as a basic starter project, before I go on to try other
> things.
>
> What would be a good starting point with MAME if I wanted to write such a thing
> myself?

what are your end goals?

MAME is a big project, what you focus your effort on learning is important.



JHake
MAME Fan
Reged: 01/27/21
Posts: 8
Send PM


Re: MAME programming starter pack? new [Re: Haze]
#389741 - 01/28/21 02:09 PM


I want to do what it says I want to do in the OP:

I want to write a program which traps controller-port reads and feeds it controller values taken from a file.



Vas Crabb
BOFH
Reged: 12/13/05
Posts: 4462
Loc: Melbourne, Australia
Send PM


Re: MAME programming starter pack? new [Re: JHake]
#389742 - 01/28/21 04:04 PM


> I want to do what it says I want to do in the OP:
>
> I want to write a program which traps controller-port reads and feeds it controller
> values taken from a file.

That’s probably not a good starter project. The learning curve before you got any results at all would be very steep.



JHake
MAME Fan
Reged: 01/27/21
Posts: 8
Send PM


Re: MAME programming starter pack? new [Re: Vas Crabb]
#389743 - 01/28/21 05:22 PM


At the risk of sounding rude, I have asked questions before to various forums and it's almost a necessity to prefix them with "I want an answer to my question. I'm not asking for criticism of my question or my motives or any kind of criticism. I just want the question answered".

It isn't helpful to reply with "That isn't a good starter project", especially without bothering to enlarge on it. I don't want an argument about it. I just want an answer to the question.

As I said, in the hope of heading-off this type of unwanted response: This is NOT a "starter project". I am already a programmer, just not one with emulator or Mame experience. I have written entire games in assembly language before now.

The solution might be to find a memory map of the hardware I'm interested in, find out where the controller ports are and then look at the program-code disassembly to find out where the software polls the input ports. From there I could write a wedge. It's more likely to be a better solution though to find the portion of the Mame emulator code which converts and passes controller port data from the host system into the emulated system.

Whichever way I do it, I expect I am not the first person ever to want to hack the Mame codebase, so I am hoping for answers primarily from other people who have done so before me.

Therefore I just want some recommendations on where to begin hacking Mame, not a criticism of the question. Thanks.

Edited by JHake (01/28/21 07:07 PM)



Haze
Reged: 09/23/03
Posts: 5245
Send PM


Re: MAME programming starter pack? new [Re: JHake]
#389746 - 01/29/21 12:06 AM


> I want to do what it says I want to do in the OP:
>
> I want to write a program which traps controller-port reads and feeds it controller
> values taken from a file.

MAME has 'autoboot' functionality and such which can send commands to machines. I believe that's done with the lua scripting in some form.

As already mentioned, it also already has input recording / playback functionality behind -record and -playback

I think your best bet would be to study the way the lua scripts work if you want to do this from scratch for your own purpose, although I'm not really sure why you'd want to do it. I asked because it seemed like you were suggesting it as a way to learn MAME, rather than because you needed the functionality.

Either way, it's not an area I'm familiar with, as I tend to do driver development, so I can't be of further assistance here.



smf
I've been here before
Reged: 01/16/15
Posts: 130
Send PM


Re: MAME programming starter pack? new [Re: JHake]
#389751 - 01/29/21 12:12 PM


> At the risk of sounding rude, I have asked questions before to various forums and
> it's almost a necessity to prefix them with "I want an answer to my question. I'm not
> asking for criticism of my question or my motives or any kind of criticism. I just
> want the question answered".

At the risk of sounding rude, if you ask a question in public then you don't have a right to get the answer you want.

People offer help for free and if part of that help is to correct what they consider a mistake in the question, then it is up to you whether you either accept that help or not.

If this is a problem that you are facing on multiple forums, then it would seem to be in your interest to learn to adapt as it's unreasonable to expect the world to change around you.

Alternatively you could try to only solve problems within your abilities without asking for help, or learn how to solve them without help.

> Therefore I just want some recommendations on where to begin hacking Mame, not a
> criticism of the question. Thanks.

As the functionality already exists and you don't have the ability to find it, then it's unlikely you're going to get very far with what you want to do & you'd be back again asking for help.

It's possible that you will find someone willing to walk you through it, but I couldn't justify the amount of effort required to assist in re-implementing something that already exists when it looks like you are just going to argue with any advice given.

I'm sure you are disappointed because you are being prevented from doing what you want because nobody will invest time in helping you, but that is something that you will face in every part of your life & changing your outlook will be a more useful lesson than anything you can learn from making changes to the MAME source code.



Olivier Galibert
Semi-Lurker
Reged: 09/21/03
Posts: 398
Send PM


Re: MAME programming starter pack? new [Re: JHake]
#389796 - 02/01/21 09:40 AM


> The first thing I wanted to do is to write a program which records a controller
> stream from a game being played and writes it to a file, and it can also feed a
> controller stream to a game loaded from such a file.

It already exists, it's the -record and -playback functionality.

Since you seem to want a different format, look around src/emu/ioport.cpp, the methods with "record" or "playback" in the name of the class ioport_manager.

OG.



mhoes
MAME Fan
Reged: 08/27/15
Posts: 170
Send PM


Re: MAME programming starter pack? new [Re: JHake]
#389808 - 02/02/21 03:28 PM


> At the risk of sounding rude, I have asked questions before to various forums and
> it's almost a necessity to prefix them with "I want an answer to my question. I'm not
> asking for criticism of my question or my motives or any kind of criticism. I just
> want the question answered".

Sometimes you get what you want. Sometimes you get what you need. Sometimes you get what you get.


Pages: 1

MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Pi 
0 registered and 33 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 744