Improved-PPMCK

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Improved-PPMCK
by on (#97019)
This is improved version of PPMCK. http://zzo38computer.org/nes_program/ppmck.zip (version 2)

New features includes:
  • #MACRO to make assembly macro
  • #CUSTOM-TUNING adjusts tuning tables, including the letters in the scale (which can be "a" to "j" now, not only "a" to "g"), and how many notes in one octave
  • #CUSTOM-NOISE to adjust noise table, to tell which noise is made from each note
  • #RAISE-VRC7 makes the VRC7 pitch higher but less relatively detuned from equal temperament
  • ? at the start of a line adds an assembly code to the output
  • * at the start of a line makes a preprocessor macro, which can be named by one letter, and called in a track or @ definition by * and the same letter
  • Xb set data begin of music
  • Xc call assembly code subroutine during playback
  • Xg branch the music to another point (even before Xb)
  • Xr to return from Xg
  • Xl make a label for use by Xg and by macros and assembly codes
  • Xm call a macro defined by #MACRO
  • ? in a track is a track questioning command
  • ' after a note letter (after - and + if there is any) to make one octave higher note
  • Some of the playback engine codes have been made tail recursion
  • K (transpose) can be used with all tracks
  • It will put "<?>" if #TITLE #COMPOSER #MAKER is not filled in (agrees with .NSF specification)
  • #PROGRAMMER is same as #PROGRAMER (both works same thing)
  • #EX-VRC-VII alias for #EX-VRC7
  • #EX-VRC-VI alias for #EX-VRC6
  • #EX-SUNSOFT5B alias for #EX-FME7
  • #EX-SUN5B alias for #EX-FME7
  • #EX-NAMCO163 alias for #EX-NAMCO106
  • Z is direct write to $4011 same as y$4011

Example of track questioning:
Code:
#EX-VRC7

GHI @@8 o3 t120 l2 v13
G K0
H K4
I K7

*x ?HK4?IK8?.
*+ ?HK4?IK7?.
*- ?HK3?IK7?.
*o ?HK3?IK6?.

; Play eight chords using white piano keys
GHI *+c*-de*+fg*-a*ob*+c'
Re: Improved-PPMCK
by on (#97021)
Maybe, It shall be a yes under the following terms:

All ASM Routines shall be at least in 4k or less ROM Space at $8000-$BFFF for use as the main program. in case one is to use it in games,

Add a GUI if needed, It makes the features down there easier to control, like _mic's XPMCK.

Let the user select any features needed, So they could shave off some unnessicary routines that are not needed for games!

Add a Sound Effects engine, (see SMWCentral.net's Addmusic v4.05 program, This is what I need)

Less RAM is good for games too, at least keep several ram variables around $0300-$07FF, and about 10-16 (decimal) more zero page variables at $00-$FF

the choice of the RAM range is truly ours to choose that way.
Re: Improved-PPMCK
by on (#97027)
Hamtaro126 wrote:
Maybe, It shall be a yes under the following terms:

All ASM Routines shall be at least in 4k or less ROM Space at $8000-$BFFF for use as the main program. in case one is to use it in games,
I did not write the engine, although I have modified it. I could be able to make it smaller somewhat, and possibly with some features turned off makes more smaller. (I have not intended it to be used in games, although I don't know if the original author has intended this. Regardless, it is possible to use the data with different engines if you can understand it; you could write the engine to fit with the game, I suppose. The standard engine I have is intended for .NSF but may be usable with games too; I may be able to improve it to that point.)

Hamtaro126 wrote:
Add a GUI if needed, It makes the features down there easier to control, like _mic's XPMCK.
I won't add a GUI (others can add it if they want).

Hamtaro126 wrote:
Let the user select any features needed, So they could shave off some unnessicary routines that are not needed for games!
OK, perhaps they can either be automatically turned off or be activated/deactivated by a #FEATURE command.

Hamtaro126 wrote:
Add a Sound Effects engine, (see SMWCentral.net's Addmusic v4.05 program, This is what I need)
Can you explain it better? I don't know about this Addmusic program. But I can think that for sound effects, you could use channels which is not used by music. It is also possible to poke the memory variables the address for those channels by the address of sound effect for playing if it is not DPCM (if it is DPCM, just access them directly). (If it is .NSF player embedded in different software, rather than NES/Famicom game, then hopefully the player library has a command to poke values into the emulated memory. If it is NES/Famicom game, then the addresses can be set easily of course, you also have .)

Hamtaro126 wrote:
Less RAM is good for games too, at least keep several ram variables around $0300-$07FF, and about 10-16 (decimal) more zero page variables at $00-$FF
OK, I will try this.

Hamtaro126 wrote:
the choice of the RAM range is truly ours to choose that way.
OK

Thanks for the suggestions. If I make changes to the program I will post the information here. I will also post the codes here when ready.

by on (#97029)
Sound Effects are usually masked from music, creating effects of sound

on the NES, because people do not usually use expansion because of limits of the Euro and American NESes, only the original Famicom had such expansion hardware for sound!

by on (#97062)
I have posted the file now. http://zzo38computer.org/nes_program/ppmck.zip Including some additional features I have listed in the top message.

I have not yet added the feature you have suggested, but may do so later, but I may also accept patches.

by on (#97088)
I believe Jarhmander was in the process of adding some of his own improvements on ppMCK as well. Might be worth a shot communicating with him, see if you guys can team up or something so we don't end up with competing builds of ppMCK!

by on (#97092)
jrlepage wrote:
I believe Jarhmander was in the process of adding some of his own improvements on ppMCK as well. Might be worth a shot communicating with him, see if you guys can team up or something so we don't end up with competing builds of ppMCK!


Where is Jarhmander, for contact?
Re: Improved-PPMCK
by on (#97093)
Hamtaro126 wrote:
All ASM Routines shall be at least in 4k or less ROM Space at $8000-$BFFF for use as the main program. in case one is to use it in games,

...

Let the user select any features needed, So they could shave off some unnessicary routines that are not needed for games!


The assembly source has always been included with PPMCK; removing features is very easy to do, and you can place the code at whatever address you need.

by on (#97097)
Hamtaro126 wrote:
jrlepage wrote:
I believe Jarhmander was in the process of adding some of his own improvements on ppMCK as well. Might be worth a shot communicating with him, see if you guys can team up or something so we don't end up with competing builds of ppMCK!


Where is Jarhmander, for contact?

Ah, I thought he went by Jarhmander on these forums, my mistake. His profile is here, he is known as ~J-@D!~ on nesdev. :)

by on (#97098)
jrlepage wrote:
I believe Jarhmander was in the process of adding some of his own improvements on ppMCK as well. Might be worth a shot communicating with him, see if you guys can team up or something so we don't end up with competing builds of ppMCK!
Thanks for telling me about this. Let's them come on this thread too; perhaps we can combine these ideas with his ideas too.

by on (#97100)
jrlepage wrote:
Ah, I thought he went by Jarhmander on these forums, my mistake. he is known as ~J-@D!~ on nesdev. :)


Thanks.

by on (#97184)
Thank jrlepage for the clarification: "~J-@D!~" and "Jarhmander" refer to the same guy (me). On #nesdev I'm "Jarhmnder" due to restrictions on the lenght of the account name

I already answered to zzo38's private message, but now that I have a bit of time I post a better answer here: yes I did some minor improvements on ppMCK. Here's what I did:

-Fixed some engrish in error messages
-Added "#EX-VRC-VII" : alias for "#EX-VRC7"
-Added "#EX-VRC-VI" : alias for "#EX-VRC6"
-Added "#EX-SUNSOFT5B" and "#EX-SUN5B" : alias for "#EX-FME7"
-Added "#EX-NAMCO163" : alias for "#EX-NAMCO106"
-Added MN<num> for XYZ tracks : it's like M<num> (Sunsoft 5B hardware speed) but produce tuned notes at NTSC speed.
-Added Z<num> : direct write to $4011 (like in FamiTracker)
-Added Y<num> : sample offset (like in FamiTracker, though because I never used the Y command in FamiTracker, I don't know if it does the exact same thing)
-Added @@<num> support for XYZ tracks, but results are not yet satisfying because of how the ppMCK driver handles the noise mode with notes.
-Added a weird hack (special looped mode) in DPCM code.

As you can see, they are rather simple improvements, if not simply "mods". The "weird hack" is only a change of the meaning of "IRQ DPCM mode" : it plays the sample in looped mode, but then immediately rewrite $4012 and $4013 with the last two bytes of the sample (added to that purpose) to change the loop points in the sound. Works on real hardware, but is likely not useful to anybody else. I can explain it more and post a demo of it in action when I have the time.

I'll come back with this when I finish my final exams and my project for the project course.

by on (#97195)
~J-@D!~ wrote:
I already answered to zzo38's private message, but now that I have a bit of time I post a better answer here: yes I did some minor improvements on ppMCK. Here's what I did:....
OK, I have added these aliases and the Z command to my version too. The others I do not entirely understand.

Thank you for information.

by on (#97198)
~J-@D!~, on the subject of a loop point for DPCM samples, do you need to use an IRQ? Can you just rewrite $4012/4013 with the loop points immediately after starting playback?

I haven't tested this on hardware, but I would kind of expect that the hardware doesn't read the $4012/4013 register values except when starting playback or restarting the loop.

Or... were you saying that this does work, and you had replaced PPMCK's DPCM IRQ feature with it as a hack?

by on (#97201)
rainwarrior wrote:
~J-@D!~, on the subject of a loop point for DPCM samples, do you need to use an IRQ? Can you just rewrite $4012/4013 with the loop points immediately after starting playback?

I haven't tested this on hardware, but I would kind of expect that the hardware doesn't read the $4012/4013 register values except when starting playback or restarting the loop.

Or... were you saying that this does work, and you had replaced PPMCK's DPCM IRQ feature with it as a hack?


If you try to change the loop point immediately, it may fail if there is a byte sitting in the DMC buffer. But it's safe to write the loop points one frame later. Need to wait for the remaining sample byte to drain, which can take up to 3500 CPU cycles.

by on (#97207)
Why the need for the Roman numerals on the VRC chips? Also, is there a NSF example of the DPCM hack?

by on (#97215)
Thanks for the info, Dwedit. I'd been meaning to test that out, but hadn't gotten to it yet.

by on (#97220)
Never actually tested this out, it's still a guess. But I just implemented a silent (counter-only) DMC channel, so the strange features where it holds a byte and waits for it to drain are fresh on my mind.

by on (#97228)
B00daW wrote:
Why the need for the Roman numerals on the VRC chips?

Presumably to match the marking on the chip itself.

by on (#97234)
rainwarrior wrote:
~J-@D!~, on the subject of a loop point for DPCM samples, do you need to use an IRQ? Can you just rewrite $4012/4013 with the loop points immediately after starting playback?

I haven't tested this on hardware, but I would kind of expect that the hardware doesn't read the $4012/4013 register values except when starting playback or restarting the loop.

Or... were you saying that this does work, and you had replaced PPMCK's DPCM IRQ feature with it as a hack?

Last statement: exactly. IRQ mode with NSF is pretty useless, so I hacked it into my special looped version. I tested it on my powerpak and it works flawlessly.

I think blargg has verified that when setting the playback bit, the internal address and length registers are immediately reloaded.

by on (#97242)
In regard to microtuning, I think extra flats/sharps would be more flexible than extra note letters.

by on (#97249)
cak wrote:
In regard to microtuning, I think extra flats/sharps would be more flexible than extra note letters.
You still can use flats/sharps but simply - is down one and + is up one so if there are more spaces between the letters then you may need more than one sharps/flats to access some notes. However, due to the playback engine there is only up to sixteen notes in one octave regardless of what each letter corresponds to and what frequencies (or periods) are used for each note of an octave. (For example, c+-++-++-- is also a C sharp note same as c+ is, and if the scale you set has three extra unnamed notes between the "c" and "d" then you would need double flat/sharp like c++ or d-- to access the note in between.)

by on (#97259)
Very simple and quick demo, doesn't sound too good. The crappy "intro" shows more the special looped mode. You can also try a decent nsf player (nsfplay) ans slow it down. Works on the powerpak. https://dl.dropbox.com/u/5476016/mmltest.nsf

What the mml looks like: https://dl.dropbox.com/u/5476016/mmltest.mml. I abused the "Y" command.

Source provided, but don't expect support for the moment. https://dl.dropbox.com/u/5476016/mck9aex2_mod.7z

by on (#97297)
I have nothing to really contribute other than I'm happy these have been made, and whatever enhancement branch is finished should be called 3pmck :P