Skip to content

Conversation

felipesanches
Copy link
Contributor

Screenshot From 2025-09-05 22-06-11

@felipesanches
Copy link
Contributor Author

I do have concerns, though, about the declaration of MIDI ports, as I am not extremely familiar with the way MAME does it, so I would appreciate some help here, because it may be incorrect or there may be cleaner ways to describe this circuit:

Screenshot From 2025-09-05 21-39-08

@felipesanches
Copy link
Contributor Author

felipesanches commented Sep 7, 2025

I do have concerns, though, about the declaration of MIDI ports, as I am not extremely familiar with the way MAME does it, so I would appreciate some help here, because it may be incorrect or there may be cleaner ways to describe this circuit:
Screenshot From 2025-09-05 21-39-08

Connection diagrams from user manual

These are the relevant diagrams for emulating the MIDI ports:


Screenshot From 2025-09-06 21-39-27
image

@felipesanches felipesanches force-pushed the roland_pg1000 branch 2 times, most recently from 5b4f5aa to efbe742 Compare September 7, 2025 01:05
@m1macrophage
Copy link
Contributor

m1macrophage commented Sep 7, 2025

I do have concerns, though, about the declaration of MIDI ports [...]

It is possible I missed some detail, but your first commit seems to emulate all 4 midi ports correctly, based on the linked schematic and documentation.

However, the MIDI_PORT declarations can be simplified a bit. Try grep -r 'MIDI_PORT.*_slot' src/mame for examples. Not sure if the alternate declaration method would make a functional difference.

@felipesanches
Copy link
Contributor Author

I do have concerns, though, about the declaration of MIDI ports [...]

It is possible I missed some detail, but your first commit seems to emulate all 4 midi ports correctly, based on the linked schematic and documentation.

However, the MIDI_PORT declarations can be simplified a bit. Try grep -r 'MIDI_PORT.*_slot' src/mame for examples. Not sure if the alternate declaration method would make a functional difference.

It seems to me that using midiin_slot(...) for declaring the "Parameter In" port was problematic as it was (as far as I could grasp) creating a second -midiin command line option (instead of a custom -paramin option).

@felipesanches
Copy link
Contributor Author

felipesanches commented Sep 9, 2025

I've done the bulk of the work developing this driver and layout and it is now looking beautiful and working almost perfectly. The only one thing that still does not work are the MIDI ports (which is kind of essential for it to be useful, LOL) and I have no idea what's still missing to make it work.

Not sure if I made some mistake in the MIDI description on the driver, or if the serial port support in the UPD78C10 core is not implemented correctly. I inspected a bit of it and it looks reasonable, though...

I would appreciate if someone could take a look at it and give it the final touch to make it work, in case it is something simple. Otherwise, it would be wiser to simply merge it as is and then someday we'll end up figuring out how to fix it. But I personally feel that I have nothing else to add to it at this moment.

Owners' manual explains that all messages received on its MIDI IN are replicated in its MIDI OUT and any parameter adjustments made on the sliders are also sent over MIDI OUT as sysex messages.

So I tried amidi -p virtual -d to dump to the terminal anything that is written to the virtual midi device and then I loaded the driver with -midiin "my usb-midi controller" -midiout "virtual device" but I get nothing logged at MIDI OUT when I play on the controller and I also get nothing while dragging the sliders.

The method of using amidi -p virtual -d works fine with other synth drivers like the Ensoniq ESQ-1.

@m1macrophage
Copy link
Contributor

m1macrophage commented Sep 9, 2025

I do have concerns, though, about the declaration of MIDI ports [...]

It is possible I missed some detail, but your first commit seems to emulate all 4 midi ports correctly, based on the linked schematic and documentation.
However, the MIDI_PORT declarations can be simplified a bit. Try grep -r 'MIDI_PORT.*_slot' src/mame for examples. Not sure if the alternate declaration method would make a functional difference.

It seems to me that using midiin_slot(...) for declaring the "Parameter In" port was problematic as it was (as far as I could grasp) creating a second -midiin command line option (instead of a custom -paramin option).

I can't speak to the approach that uses separate midiin_slot(...) calls. But if you follow the declaration examples above, you should end up with -midiin1, -midiin2, -midiout1 and -midiout2 (use -listmedia to verify). I haven't checked if it is possible to provide custom names (such as -paramin) for these. MAME devs can speak to that.

Once that's set up, you could run your test, but log midi thru instead of midi out. If that works, then you at least know that the MIDI_PORT setup for midi in and thru, and your testing strategy, are sound.

Edit: Also, consider initializing m_midiin_bit and m_paramin_bit to true, which is MIDI "idle". I've seen drivers ignore the first midi message when initializing to false / 0.

@felipesanches
Copy link
Contributor Author

Earlier today I figured out that, by setting m_irr to 0x0400 (equivalent to IRR |= INTFST) via the debugger, I finally get valid sysex messages sent to MIDI OUT.

Screenshot From 2025-09-14 11-04-37

I have been able to connect the emulated PG-1000 to my real D-550 unit using ALSA's aconnect and successfully tweaked parameters of sounds.

So, this means that the handling of interrupts in the upd78c10 core in MAME is a bit broken.

It is unclear to me exactly when should the interrupt requests register be set to trigger the serial interrupt. I have tried to set the flag in the implementation of the MOV SMH, A instruction, but that did not work. I'm here still scratching my head trying to understand what's the correct behavior. All I know is that the only place in the code where the transmit buffer is set is at address 0071, inside the serial int handler.

@felipesanches
Copy link
Contributor Author

ok, I got it! This fixed the issue!

Screenshot From 2025-09-14 14-31-37

@felipesanches
Copy link
Contributor Author

felipesanches commented Sep 14, 2025

Surely the more general solution would be to create a set_serial_mode(u16 value) method and then use it in all instructions that change the value of SMH (and SML). But I don't know how much do we want to change the CPU core in this PG-1000 PR.

@felipesanches
Copy link
Contributor Author

For now, I made it write_smh(uint8_t data) to not over-complicate things...

@felipesanches
Copy link
Contributor Author

I've just fixed MIDI IN. Now every message received on MIDI IN is repeated to MIDI OUT, as the service manual describes as the expected normal behavior.

@felipesanches
Copy link
Contributor Author

@cuavas, I believe this is now ready for your code-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants