mori0091 / libmsx

C library for MSX
https://mori0091.github.io/libmsx/
MIT License
31 stars 2 forks source link

About generating PSG data #60

Closed pdpdds closed 1 year ago

pdpdds commented 1 year ago

In the sample, i am looking at the psg_play example. In the sample, the sound source data exists as a C array. but I can't find any reference on how to generate this data or what each byte means. Also, how to convert the existing PSG data so that it can be written to by libMSX. I'm sure there must be a way, but I haven't been able to find a good solution in my research. Any advice would be greatly appreciated.

mori0091 commented 1 year ago

See "Sound - OLD PSG sound driver" section of API reference. Especially reference of struct sound_fragment for data format, that is useful for your purpose probably.

Unfortunately, there is no tools for OLD PSG sound driver such as Tracker, or MML compiler. So I recommend to use SNDDRV - PSG sound driver instead.

pdpdds commented 1 year ago

Thank you for your reply. I didn't have a good look at the manual. Now I understood the data chunks from the link you provided, so I believe it is possible to create PSG data manually. I also checked out SNDDRV. and I know Arkos Tracker 2 and can use it. However, the ultimate purpose of my question is to utilize PSG data from an existing game in-game.

for example, I am in the process of reimplementing a game called king's valley for MSX1 in C language.

You can see the game here:

https://webmsx.org/?ROM=https://github.com/pdpdds/ubox_example/releases/download/v1.0/kings_ver2.rom

The C logic was written by me, and the graphics resources was taken from the existing game. The only remaining puzzle is to utilize the existing soundtrack, but I can't think of a clever way to do that.

In king's valley assembly source, the melody on game clear looked like this.

MUS_StageClr: db 0E8h MUS_StageClr2:
db 0D6h, 0FCh, 1, 1, 0E1h, 1, 11h, 41h, 51h, 41h, 11h db 1, 0E2h, 0A1h, 0E1h, 0, 10h, 0, 10h, 0, 10h, 0, 10h, 0, 10h db 3, 0FFh

The ultimate goal was to see if it was possible to recycle this data by utilizing the OLD PSG sound driver. If this is not possible, I think the only way is to create a new sound source using Arkos Tracker 2.

Now that I understand the struct sound_fragment structure, I think I can try to create a tool to convert existing PSG sound sources to a format for the OLD PSG sound driver.

I would really appreciate it if you could give me some hints or some guidelines on how to convert this existing PSG sound source to a format for the OLD PSG sound driver.

mori0091 commented 1 year ago

I have no idea because I don't know about sound data format of King's Valley. Sound data for the OLD PSG sound driver is similar to PLAY BIOS of standard MSX, so maybe it'll be hints for you.

pdpdds commented 1 year ago

Thank you so much for your help. I'm going to take a look to PLAY BIOS of standard MSX.