Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Mod2psg again.... Or Microsoft again!!!

Reply to topic
Author Message
  • Joined: 28 Jan 2017
  • Posts: 358
  • Location: Málaga, Spain
Reply with quote
Mod2psg again.... Or Microsoft again!!!
Post Posted: Wed Sep 05, 2018 9:30 pm
Ummm....

Altgough i have Been working slowly in last months, now that the summer has gone i want to give impulse to the new Game... So i Was going to make a new song this night...

I have mod2psg with msvcr71.dll and msvcp71.dll. the same i have Been using in the last year.

But... Oh SH*T!!! mod2psg fails starting with error setting video Mode !

I have Been trying with Intel integrated card i have (asus laptop i7 5500) and my Nvidia (sure?) 920m, both with latest drivers. In admin Mode, vista,w7,w8,w8.1 modes... And nothing to do.

Maybe the culprit is my latest w10 RS4 installation (done one week ago). Also i have Been reading this error happens with wine too.

Some insights?

If not, Will return to my previous w8.1… but It is a shame we (the community) not have the src to be maintained, as It is a fine piece of software.

Regards!
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 396
  • Location: Spain
Reply with quote
Post Posted: Thu Sep 06, 2018 7:52 am
it's working for me on my Windows 10 without any issue...
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Thu Sep 06, 2018 8:20 am
you can try Dependency Walker to see which DLL(s) is(are) missing.

edit: speaking about Mod2PSG2, it would be wonderful to implement some tool to create SFXs for its audio engine, as it may be a valid alternative to PSGlib.
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 396
  • Location: Spain
Reply with quote
Post Posted: Thu Sep 06, 2018 8:33 am
just for chance I was looking at epsgmod format, and it's far more efficient in space than pure vgm/psg...having this fx would be nice...
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Thu Sep 06, 2018 8:39 am
sure, it's a tracked format, not a log of chip commands.
Trade-off is of course that it requires more CPU to process, but it saves a lot on ROM space.
The reason I wrote PSGlib in the beginning is that I couldn't find how to use SFXs on Mod2PSG2, now if we can create some tools for making them, it would be also interesting to create a C wrapper so that the engine could be used with devkitSMS too.
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 396
  • Location: Spain
Reply with quote
Post Posted: Thu Sep 06, 2018 9:13 am
I need to have a bit more knowledge about how music & sound work...but it sounds promising.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Thu Sep 06, 2018 10:07 am
My problem is that I don't know the SFX format for Mod2PSG2.
The code for playing the SFX is already in there (parts omitted for brevity):

;----------------------------------------------------------
; PSGMOD_PlaySFX_2(B = length, C = priority, HL = address)
PSGMOD_PlaySFX_2:
  ld a, (PSGMOD_SFX_2_PRIORITY)
  cp c
  jr Z, PSGMOD_PlaySFX_2_OK
  ret NC
PSGMOD_PlaySFX_2_OK:
 
  ld a, b
  ld (PSGMOD_SFX_2_CNT), a
  ld a, c
  ld (PSGMOD_SFX_2_PRIORITY), a
  ld (PSGMOD_SFX_2_ADDRESS), hl
  ret

;----------------------------------------------------------
; PSGMOD_PlaySFX_3(B = length, C = priority, HL = address)
PSGMOD_PlaySFX_3:
  ld a, (PSGMOD_SFX_3_PRIORITY)
[...]
  ret

;----------------------------------------------------------
; PSGMOD_PlaySFX_23(B = length, C = priority, HL = address)
PSGMOD_PlaySFX_23:
  ld a, (PSGMOD_SFX_3_PRIORITY)
[...]
  ret
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 396
  • Location: Spain
Reply with quote
Post Posted: Thu Sep 06, 2018 10:22 am
I think that was developed by Martin. Maybe we can ask to him?
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Thu Sep 06, 2018 10:59 am
Last edited by sverx on Thu Sep 06, 2018 11:47 am; edited 1 time in total
PM'ed - let's see.

edit: oh, wait. Readme file contains this:
Here's a list of currenty known bugs/issues:
* Sound effects are not supported in the programming library

which I suspect means that even if the functions to start/stop a SFX are there, the library doesn't honor them. :(

edit again (sorry): well, reading the code seems that support for SFXs is there, and it seems that the SFX format is also very basic, essentially just the data for the PSG chip, 3 bytes for frame (for each channel), juxtaposed (not interleaved!) in case of a SFX that uses both channel 2 and 3 (noise).

Let's see if I can make some effect for testing this...

last edit - promised: SFX format seems different for channel 2 and 3 (noise).
* SFX for channel 2 is 3 data bytes for the PSG chip for each frame
* SFX for channel 3 is one header byte (boolean flag) followed by either 1 or 2 data bytes for the PSG chip - I suspect it's so to do not 'break' the noise channel sound by rewriting the frequency register when it's not needed.
  View user's profile Send private message Visit poster's website
  • Joined: 30 Mar 2009
  • Posts: 257
Reply with quote
Post Posted: Thu Sep 06, 2018 11:28 am
I have it working on W7, W8 and W10, without issues.
I've uploaded by Mod2PSG2 folder here:

http://www.classicgames.com.br/temp/Mod2PSG2_V2_04.rar

See if it helps.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Thu Sep 06, 2018 3:26 pm
I can't make that asm example work. Anyone had used this library before? I can compile that properly (after some fixing of the example source), interrupts are enabled and the code gets called. No output, no writes to PSG :|

Help?

edit: even if I found out that the example also requires you to provide your own VDP initialization routine to enable vBlank IRQ and requires you that you take care of acknowledging the IRQ / re-enable interrupts... it still fails.

Now it's pushing some data to the PSG, though, but it just changes the first wave frequency, nothing else, then it's not outputting any audio :|

final edit: uff, it was putting my module in bank2 withouth putting it in slot2, thus giving it address $0000 instead of address $8000. Sorry for the mess. I'll go on with my tests ASAP.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Fri Sep 07, 2018 1:19 pm
OK, some news about SFX support in Mod2PSG2 own engine.


  • it can independently play one SFX on chn2 and/or one SFX on chn3 (noise) - or a compound SFX using both channels.
  • as said before, header-less data format for chn2's SFX is just "bytes pushed straight to PSG chip", 3 of them at each and every frame (thus the required 'length' function call parameter can be obtained by dividing the size of your data by 3)
  • conversely, chn3's SFX are different. They're either a single or two bytes that need to be pushed to PSG, preceded by a boolean byte value which indicates if there's just 1 byte to push (false, value = 0) or 2 bytes (true, any non 0 value). This means that the required 'length' function call parameter can't be obtained by simply dividing the size of your data by 3, unless the data is forcibly generated so that it always contains two data bytes per frame.
  • SFXs that use both channels are simply the SFX for chn2 and the one for chn3 juxtaposed. 'length' parameter is still needed.
  • maximum duration of a SFX is 255 frames (4.26 seconds on NTSC, 5.12 seconds on PAL).
  • a SFX will/won't interrupt another playing SFX on the same channel, according to priority. (0 is the lowest priority, 255 the highest).
  • although the engine sports automatic paging for background music, it doesn't do that for SFX. Since when playing it automatically maps the ROM bank where the tune is stored, you have to either store your SFXs in that very same bank OR in the lower ('un-banked') ROM space.
  • the v. 2.04 implementation available here is broken, at least when it comes to play a SFX on chn2. Data isn't pushed to PSG chip.
    To fix it, locate this:
    PSGMOD_Play_NoSFX_2_End:
      ld hl, (PSGMOD_SFX_2_ADDRESS)
      outi
      outi
      outi
      ld (PSGMOD_SFX_2_ADDRESS), hl

    and add one line of code this way:
    PSGMOD_Play_NoSFX_2_End:
      ld hl, (PSGMOD_SFX_2_ADDRESS)
      ld c,PSGMOD_PSG_PORT            ; this line was missing!
      outi
      outi
      outi
      ld (PSGMOD_SFX_2_ADDRESS), hl



(I will update this again if needed)
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 358
  • Location: Málaga, Spain
Reply with quote
Post Posted: Fri Sep 07, 2018 7:10 pm
Changed to w8.1 and' even before installing the drivers, It works :)

I have Been using mod2psg with w10 the last year without trouble, so i suspect the RS4 installation is the culprit here.

Happy this thread have Been of utility to Talk about the player.

Regards.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Mon Sep 10, 2018 9:37 am
Unfortunately it's not easy at all to 'wrap' the Mod2PSG2 player engine to C. First and foremost, absolute alignment of the RAM area is required, and that's something still unsupported with current SDCC.
Given that one could find a workaround (for instance lock that at address 0xC000 and allocate an unused array at the beginning of your program so that these two overlap, and of course you won't then use that array) there are still troubles with the actual code as it won't assemble easily on sdas, because of the macros.

Thus I'm not really working on this, but I can give support if someone else wants to tackle the job.
  View user's profile Send private message Visit poster's website
  • Joined: 29 Mar 2012
  • Posts: 396
  • Location: Spain
Reply with quote
Post Posted: Mon Sep 10, 2018 9:49 am
Something we can look into in the future (code is more than 10 years old, so it can wait some months :-) )
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Mon Sep 10, 2018 1:53 pm
Martin just told me a few interesting things.
- there's a v2.05 available, dating back to 2015 - it was already available as an attachment on this forum, in the Mod2PSG2 specific thread - I've now also uploaded it to the Mod2PSG2 page.
- a 'combined' SFX will play on both channels (given its priority is higher than any SFX(s) currently playing) or won't play at all. But nonetheless a 'combined' SFX will be only partially interrupted by a new 'simple' SFX - the other channel will go on playing.
- no license problem should we port the epsgmod z80 player to a different assembler/platform
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Tue Sep 11, 2018 10:06 am
Unfortunately the epsgmod format changed from version 2.04 to version 2.05 - which means that epsgmod files generated with one version won't work on the other player. :|
---> details from version 2.05's readme.txt file:
Quote
[2.05] xx.1.2008 / 1.2.2015 - Final version
- EPSGMOD player for the TI-99/4A by Tursi
- Added macro-functionality
- Added the load-recent feature
- The system-clipboard can now be used to copy/paste pattern and instrument data
- Added 4 internal (non-system) clipboards for pattern data (selectable in the Edit-menu)
- Made the PSG frequencies of the notes a bit more accurate
(When loading modules made in older versions, there can be little frequency differences.)
- Changed the way the volume is calculated when playing a note (should sound better)
- Changed the vibrato curve for vibrato speed 0 a bit
- Added the CTRL cursor-movement hotkeys
- Added hotkeys for copy and paste in the instrument editor
- The volume/instrument column can be copied and pasted separately
(Can be switched on/off in the edit->options menu)
- Multiple notes/effects/commands can be added now with just one key press when
more than one line is selected (within one column)
- Changes in the EPSGMOD format to make it a bit smaller

all these changes means that I should probably use the v. 2.05 format/engine - weird that the module I converted to epsgmod format with ver. 2.05 it's (slightly) bigger instead of smaller than what I got with version 2.04.

Any suggestions from those who use that? I wonder if should we 'ignore' the "Final Version" (v. 2.05) and stick with what's deeply tested?
  View user's profile Send private message Visit poster's website
  • Joined: 04 Nov 2004
  • Posts: 265
  • Location: Deutschland
Reply with quote
Post Posted: Sat Sep 15, 2018 9:19 pm
Hello

I can only vaguely remember the changes I did to the format for this version, maybe if I see the module I could guess why the export is bigger. The size optimizations were probably not meant for very small modules.

A big limitation of the exporter is that it always sets the sequence size to 32 (or less at the end of a pattern), and that worked well for me, but the sequence size should be more flexible. The format itself supports any sequence size between 1 and 256 iirc, with the limitation of being able to address only up to 32 different tones.

If someone wants to try writing a custom exporter, I could provide loader code for psgmod files (for v2.05 and below). Documentation about epsgmod is in the v2.05 archive. I could provide code for the exporter, too, but that has always been a bit messy, and I'm not sure which versions of it I still have sources of. I think it would be better to start a new one and get rid of the sequence size limit.

About Windows and video modes, the readme says it uses Direct3D9. I would expect that to be less troublesome than DirectDraw nowadays, it's hard to say now at what point it fails exactly and why. :/
(Edit: It runs fine on my win10, I have Intel and Nvidia on it, too.)
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 358
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sat Sep 15, 2018 9:38 pm
The fact is i have Been using on w10 too, for a year.

Last months reinstalled w10 RS4 64bits… drivers and also DirectX runtimes. Did not work.

Black to w8.1… did work even without install nothing.
  View user's profile Send private message
  • Joined: 04 Nov 2004
  • Posts: 265
  • Location: Deutschland
Reply with quote
Post Posted: Sun Sep 16, 2018 8:34 pm
Did you try different video mode settings in the config file? I expect windowed mode to be safer than fullscreen mode. I get an error if I set depth to 16.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 2296
Reply with quote
Post Posted: Mon Oct 01, 2018 9:00 am
Martin wrote
maybe if I see the module I could guess why the export is bigger. The size optimizations were probably not meant for very small modules.


here are the original module and the exported ones
module.rar (4.85 KB)
the original module, the exported one with v2.04, the exported one with v2.05

  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!