Nintaco -- NES-Famicom-Dendy Emulator

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

jblazing wrote:I'm gonna post to hope and see if the dev even sees this.

A problem that I seem to be having is with the C api. Whenever I try to run getPixels(api,pixels) in the FrameListener, once the function escapes the program will segfault. I made sure to make the array size is 256 * 240, I have tried both dynamically allocated memory and array on the stack, both cause a segfault.

I am using the latest versions of both the api and the emulator from 5/1/17 .

Code: https://pastebin.com/mUgsjDQu
The getPixels bug has been fixed. The updated version of nintaco.c has been zipped up here.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

I posted a new build containing a small round of patches.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

I posted a new build with another round of bug fixes including some light gun related patches. A test program I wrote to evaluate those changes evolved into this small fun project.
User avatar
Yodak
Posts: 2
Joined: Thu Oct 19, 2017 1:31 pm

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by Yodak »

Tis FIRE!!! I like playing with your software. I have started learning Java just for it. Now i'm trying to make remote graphic interface. It requires using setGamepad() function. But when i try to use it from simple loop within interface Nintaco freezes. When i try to call it from some method that uses ControllersListener interface like controllersProbed() without the loop it works, but I loose sweet input data. And parameters don't seem to work...
Attachments
buttonmash.rar
(4.93 KiB) Downloaded 567 times
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

Yodak wrote:Tis FIRE!!! I like playing with your software. I have started learning Java just for it. Now i'm trying to make remote graphic interface. It requires using setGamepad() function. But when i try to use it from simple loop within interface Nintaco freezes. When i try to call it from some method that uses ControllersListener interface like controllersProbed() without the loop it works, but I loose sweet input data. And parameters don't seem to work...
Store the inputs in class variables. When controllersProbed() is called, invoke writeGamepad() with parameters based on the inputs stored in the class variables.
User avatar
Yodak
Posts: 2
Joined: Thu Oct 19, 2017 1:31 pm

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by Yodak »

Thank you very much!:mrgreen: That was so simple! I wasted so much time trying to figure it out. Though now it's pure fun and awesomeNESs!!!
radishes
Posts: 1
Joined: Thu Oct 26, 2017 9:14 am

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by radishes »

Has anyone had success running Nintaco on a Raspberry Pi? The program loads on my Pi 3, but I get a black screen upon loading any ROM. I haven't looked for any logs or ways to track errors yet, but I'll look into that later tonight. But in the meantime, does anyone have any tricks for successful Nintacoing on a Raspberry Pi?
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

radishes wrote:Has anyone had success running Nintaco on a Raspberry Pi? The program loads on my Pi 3, but I get a black screen upon loading any ROM. I haven't looked for any logs or ways to track errors yet, but I'll look into that later tonight. But in the meantime, does anyone have any tricks for successful Nintacoing on a Raspberry Pi?
Anything in the log file within the /system subdir?
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

I just added Miracle Piano support to Nintaco. Here are some details on how to use it for those interested. As mentioned on that link, it maps piano keys to keyboard keys (by default) and it maps the Miracle patches to General MIDI instruments. Unfortunately, both of these have issues: rollover limitations and MIDI lag, respectively. But it's still fun nonetheless.

My implementation is based on NoCash's NES doc and the protocol details in the Miracle Piano manuals. However, NoCash failed to document something important regarding this MIDI message:

Code: Select all

  Note on/off command       R/W  9#h,<key>,<velo> 
A chain of note on/off messages directed to the same channel can be achieved in 2 ways:

Code: Select all

90 24 80 90 25 80 90 26 80
90 24 80 25 80 26 80
Both of those sequences are equivalent. They both turn on 3 notes (24, 25 and 26) on channel 0 with velocity 80. However, 90 (note on, channel 0) only appears once at the start of the chain in the second case. Chaining note on/off messages like that reduces reduces the amount of data that the NES sends to the keyboard and it's a feature used in the intro music. It's surprising that neither NoCash nor the Miracle manual mentioned this aspect of the protocol.
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by lidnariq »

zeroone wrote:Chaining note on/off messages like that reduces reduces the amount of data that the NES sends to the keyboard and it's a feature used in the intro music. It's surprising that neither NoCash nor the Miracle manual mentioned this aspect of the protocol.
Not that this helps you now but some number of years ago I was building an esoteric MIDI instrument and got stung by this abbreviated encoding.

Not that it was hard to fix, but required that I know it.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by NewRisingSun »

That feature is called Running Status and applies to any MIDI message, not just Note On messages. Any time a message's status byte is identical to the previous message's status byte, it can be omitted. System Exclusive messages ($F0 and $F7) cancel the previous status byte, while System Realtime messages (status byte $F8 and above) are exempt and continue the previous status byte. The MIDI Implementation of the Miracle manual probably did not mention this because they considered it common knowledge among people familiar with MIDI. 8-)

Edit:

Code: Select all

90 24 80 90 25 80 90 26 80
90 24 80 25 80 26 80
Velocity can only go up to 7F. If the Miracle Piano really transmits this, then it's transmitting invalid MIDI data, because the 80 could be interpreted as another status byte (of a dedicated NoteOff message, $8x kk vv).

Edit 2: Corrected System Exclusive/System Realtime statement, added link.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

NewRisingSun wrote:Velocity can only go up to 7F. If the Miracle Piano really transmits this, then it's transmitting invalid MIDI data, because the 80 could be interpreted as another status byte (of a dedicated NoteOff message, $8x kk vv).
You are correct. The Miracle does not transmit velocities greater than $7F. The example that I posted contained contrived numbers invented on the fly; I failed to keep the value within the proper range.
NewRisingSun wrote:That feature is called Running Status and applies to any MIDI message, not just Note On messages. Any time a message's status byte is identical to the previous message's status byte, it can be omitted. System Exclusive messages ($F0 and $F7) cancel the previous status byte, while System Realtime messages (status byte $F8 and above) are exempt and continue the previous status byte. The MIDI Implementation of the Miracle manual probably did not mention this because they considered it common knowledge among people familiar with MIDI.
Thanks for that link. It shows a much clearer example of what I was trying to convey.

I should have studied the MIDI protocol. I only applied "running status" to $8x and $9x messages. But given the subset of MIDI in NoCash's spec, that is probably sufficient. NoCash's spec also includes messages that he marked as "unknown" that I encountered during testing. If those are in the MIDI spec anywhere, please point me in that direction.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by tepples »

These MIDI messages also use running status, but I don't know which the Miracle keyboard can generate:

Pressure (An kk pp)
Effect (Bn cc vv)
Instrument (Cn ii)
Pressure all notes (Dn pp)
Pitch bend (En ll hh)

Source: List of MIDI messages from MIDI Manufacturers Association
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by NewRisingSun »

Except for FF, the unknown messages are System Exclusive messages, which any manufacturer can define himself and are therefore not part of the MIDI Specification. So if the manual does not explain them, one is generally out of luck.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Nintaco -- NES-Famicom-Dendy Emulator

Post by zeroone »

tepples wrote:These MIDI messages also use running status, but I don't know which the Miracle keyboard can generate:

Pressure (An kk pp)
Effect (Bn cc vv)
Instrument (Cn ii)
Pressure all notes (Dn pp)
Pitch bend (En ll hh)

Source: List of MIDI messages from MIDI Manufacturers Association
Regarding "running status", it's only relevant to what the NES transmits to the Keyboard. From the aforementioned sources, that includes message types $8x, $9x, $Bx, $Cx, and $Fx. From NewRisingSun's link, $Fx is a real-time status message that can even appear inside another message! I have yet to encounter that and hopefully the NES doesn't generate such messages. Also, "running status" does not apply to $Fx messages per that link. As mentioned, I think I have $8x and $9x covered. As for $Bx and $Cx, if you look at the effect of those messages, it seems unlikely that you would need "running status". I.e., set main volume, sustain/dampen an entire channel, enable/disable the keyboard, silence a channel, etc. These are things you rarely want to use in succession and I didn't encounter that during testing. Long story short, I think I implemented just enough MIDI to communicate with the emulated Miracle software.

----------------------------------------

On a slightly different topic, the Miracle Keyboard is limited to 8 channels. But, in one of those proprietary $Fx messages, there is a way to split the keyboard in half. The keys below middle-C assume one instrument and the remaining keys above assume a different instrument. The teaching system usually only does this at the end of a lesson when you do the virtual performance. Each hand plays with a different instrument, which is fun (at least on real hardware). The human normally plays on channel 0. But during a split, I suspect both channels 0 and 8 are used. Or, more generally, x and x + 8. Meaning, the Keyboard might effectively be able to use all 16 channel. NoCash mentioned something about the SNES version initializing 16 channels. I don't know if there is a connection, but I thought I'd mention all this anyway.
Post Reply