VOGONS


OPL2LPT

Topic actions

Reply 300 of 566, by chartreuse

User metadata
Rank Newbie
Rank
Newbie

Decided to go with the devil I know and used a minimal implementation of the Reality Adlib Tracker format with no commands and a fixed speed. Because of that I had to write my own song in the tracker, but that's fine since finding Christmas music already tracked has proven to be quite difficult. Forgive my laziness with the instrument choices.

Here's an Epson QX-10 (a CP/M machine) playing Carol of the Bells using the OPL2LPT https://www.youtube.com/watch?v=X7c6bHQUC4k

I'll have to look into the VGM and IMF file types suggested, my only concern being that while they look simple to progress they run at a fairly fast update rate. The QX-10 is only a 4MHz z80, without using the bankswitching I'd also be limited to around a 64kB music file.

Reply 301 of 566, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

IMF works by sending data as fast as you can then waiting for a certain amount of time before sending more. There are no calculations involved (e.g. converting notes to FNum values), you just output the data and then do nothing for a certain number of ticks. Of all the ways of playing songs on the OPL, IMF probably uses the least CPU power. You'd have no problems on a < 1MHz CPU and since IMF songs are from games that run on XT machines, no long gets even close to 64kB.

Reply 302 of 566, by pdw

User metadata
Rank Newbie
Rank
Newbie

Chartreuse, The origin Adlib Jukebox included a bunch of Christmas songs: http://vgmrips.net/packs/pack/adlib-music-syn … gs-ibm-pc-xt-at
The XMAS and XMASLIB collections here also contain many songs, in ROL format: http://cd.textfiles.com/somuch/smsharew/MUSIC/

Reply 303 of 566, by chartreuse

User metadata
Rank Newbie
Rank
Newbie

Alright, had to give IMF a try. Got the delay loop timing slightly off so it's playing a bit slow, but it works just fine. Feels really weird hearing Commander Keen music being played on a CP/M machine, but that's all thanks to the OPL2LPT. https://youtu.be/AKJ_GgOMLog

It should be easily able to hook up this to any old computer with some form of User port or parallel port, just need 10 output lines. Might make for a neat peripheral for home-brew games on even non-PC systems to support.

Reply 304 of 566, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

That works really well! The 560Hz timing for Commander Keen means each IMF delay value is one 560th of a second, i.e. an IMF delay value of 560 would cause a one second delay, a value of 280 would delay for half a second, and so on. I see in your video there's a date and time displayed on the screen, so one way of getting the timing right would be to do a simple calibration loop, and count the number of times you can do a no-op loop in one second. Divide this count by 560 and that's your single-tick number, the number of no-op loops you have to run to action an IMF delay of one tick. If you then handle your IMF delay bytes by running a do-nothing loop for the IMF delay value multiplied by the single-tick number, then you should get pretty close to the correct playback speed.

If you want to get really fancy, inspect the OPL data bytes before you send them and do something like this to get a simple display that will change in time with the music, by showing you visually which OPL channels are playing notes. It's pretty low CPU power as well and gives you something nice to look at while you're listening to a song.

channel_active[0..8] = false // nine channels, 0-8 inclusive

if register & 0xB0 <> 0 then
channel = register & 0x0F
if channel < 10 then
noteon = value & 0x20
if noteon == 0 then channel_active[channel] = false
else channel_active[channel] = true
endif
endif

if delay > 5 then // no point printing this until all the events have been processed
for each channel_active, if true print "*" else print "_"
print "\r" to go back to the start of the line after all channels are printed
// If your machine is really slow to write to the display, you might need to compensate by reducing the delay a little
delay = delay - 5
endif

Reply 305 of 566, by chartreuse

User metadata
Rank Newbie
Rank
Newbie
Malvineous wrote:

That works really well! The 560Hz timing for Commander Keen means each IMF delay value is one 560th of a second, i.e. an IMF delay value of 560 would cause a one second delay, a value of 280 would delay for half a second, and so on. I see in your video there's a date and time displayed on the screen, so one way of getting the timing right would be to do a simple calibration loop, and count the number of times you can do a no-op loop in one second.

I tried to just do it by cycle counting, but I think I ended up with a mistake in calculation. Plus as you mentioned the QX-10 is displaying the clock on screen, so presumably that's causing an interrupt occasionally (I could disable that clock in the settings). My error is probably just an off by 1 in the DCYCLEVAL.

;-------------------------------------------------------------------------------
; Delay for 1 IMF cycle
; Cycle length depends on file. Either 280Hz (Duke Nukem II), 560Hz, or 700Hz
;
; 280 -> 4MHz/280Hz -> 14 285.7 cycles
; We'll ignore 280, if we want to do it, then call twice with 560
; 560 -> 4MHz/560Hz -> 7 142.8 cycles
; 700 -> 4MHz/700Hz -> 5 714.3 cycles
;
; DCYCLEVAL calculation
; (cycles - 4350)/17
; 560 -> (7143-4350)/17 -> 164.3 -> 164
; 700 -> (5714-4350)/17 -> 80.2 -> 80
DCYCLEVAL EQU 164 ; For 560Hz files
;DCYCLEVAL EQU 80 ; For 700Hz files

DELAYCYCLE:
#local
PUSH BC ; 11
LD B, 0 ; 7
L1:
NOP ; 4
DJNZ L1 ; 13/8
; 255 * 17 + 15 = 4350
LD B, DCYCLEVAL ; 7
L2:
NOP ; 4
DJNZ L2 ; 13/8
POP BC ; 11
RET
#endlocal
Malvineous wrote:

If you want to get really fancy, inspect the OPL data bytes before you send them and do something like this to get a simple display that will change in time with the music, by showing you visually which OPL channels are playing notes. It's pretty low CPU power as well and gives you something nice to look at while you're listening to a song.

Might be a fun thing to add to this project, currently looking into file I/O on CP/M so I'll have it load song files from disk instead of being hard-coded. Have to wonder who my target audience is besides me. Who else out there is running OPL2LPTs hooked up to CP/M machines and not just hooking them up to 486 laptops. 😀

Reply 306 of 566, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie

If you're not doing it for your own fun then you're doing it for the wrong reasons 😀 Plus I'm sure at least a few of us without CP/M machines will watch if you put a video up about it. The chances of me getting a CP/M machine are pretty low but I can enjoy it by proxy if there's a video to watch!

Reply 307 of 566, by Scali

User metadata
Rank l33t
Rank
l33t
chartreuse wrote:

I tried to just do it by cycle counting, but I think I ended up with a mistake in calculation. Plus as you mentioned the QX-10 is displaying the clock on screen, so presumably that's causing an interrupt occasionally (I could disable that clock in the settings).

Well, that would mean there's some kind of interrupt timer in the system. Perhaps you can take over that timer and use it to play the music?
That way you could have the music play in the background, while other stuff is running in the foreground.
Who knows, perhaps you could make the player into some kind of TSR, and then return to the CP/M prompt, so you get background music while you work 😀

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 308 of 566, by Paralel

User metadata
Rank Member
Rank
Member
Malvineous wrote:

If you're not doing it for your own fun then you're doing it for the wrong reasons 😀...

I couldn't agree more strongly with this. This is why we all do this, right? For our own personal satisfaction? Personally, I love making old hardware do new things, even if it requires a new piece to make it do such. Its amazing to think that this kind of stuff actually could have been done before, just no one ever did it. Imagine how many of these would have sold at the time if they had been made? It would have been huge!

Reply 309 of 566, by SteveC

User metadata
Rank Member
Rank
Member
Malvineous wrote:

If you're not doing it for your own fun then you're doing it for the wrong reasons 😀 Plus I'm sure at least a few of us without CP/M machines will watch if you put a video up about it. The chances of me getting a CP/M machine are pretty low but I can enjoy it by proxy if there's a video to watch!

+1 This! 😀

YouTube: https://www.youtube.com/c/StevesTechShed
Twitter: https://twitter.com/SteveTechShed

Reply 310 of 566, by chartreuse

User metadata
Rank Newbie
Rank
Newbie
Paralel wrote:
Malvineous wrote:

If you're not doing it for your own fun then you're doing it for the wrong reasons 😀...

I couldn't agree more strongly with this. This is why we all do this, right? For our own personal satisfaction?

Oh for sure that's really the only reason I do most of these things, I love playing with and programming on my vintage computers. It's especially fun making an old system do something that it never has done before. Like the QX-10, before the OPL2LPT the only sound option was an internal speaker, which I believe is controlled much like the Apple ]['s.

Scali wrote:

Who knows, perhaps you could make the player into some kind of TSR, and then return to the CP/M prompt, so you get background music while you work 😀

I think that would probably be a bit of a stretch, though it probably could be done provided the music is small enough. Place the "TSR" in memory below the CCP and modify the top of memory marker in CP/M to remove it. Perhaps even leave most of the code in one of the extra memory banks since most CP/M programs won't touch them.

Paralel wrote:

Imagine how many of these would have sold at the time if they had been made? It would have been huge!

It's honestly a surprise that no company attempted this before, someone could have conceivable made this around the time of the Adlib and got some game developers to support it. Could have been a standard, especially for low cost systems.

Reply 312 of 566, by Paralel

User metadata
Rank Member
Rank
Member
Megadisk wrote:

What are the chances of having an external parallel to gameport adapter along side the OPL2LPT? Something like this: http://stripesnoop.sourceforge.net/hardware/parallel2.html

I'm not too familiar with the Gameport. Is everything about it standardized, or is it more variable than something like a Parallel port?

Reply 313 of 566, by chartreuse

User metadata
Rank Newbie
Rank
Newbie
Paralel wrote:

I'm not too familiar with the Gameport. Is everything about it standardized, or is it more variable than something like a Parallel port?

It's fairly standardized, at least for older joysticks, I think some of the later 90s ones with more than 4 buttons start doing weird things to get more inputs. There's 2 or 4 digital button inputs (if it can support 2 controllers), and two pairs of analog X, Y inputs (Variable resistors). That adapter linked Only seems to be connecting the 4 buttons inputs from the joystick directly to 4 of the data pins (presumably he parallel port has been set-up in bidirectional mode for input first). It's not meant for connecting actual joysticks to the parallel port, just the face buttons if anything. That circuit is a complete hack as it's relying on the floating button inputs to be above the input threshold on the parallel port, and shorts to ground when pressed. It wouldn't work with the OPL2LPT since the parallel port is in output mode, and the joystick buttons would be shorting various lines of the data-bus to ground.

Reply 314 of 566, by dreamblaster

User metadata
Rank Oldbie
Rank
Oldbie

Some news from dkgrizzly :

He patched adlib tracker to support OPL2LPT and 2xOPL2LPT ! :
https://github.com/dkgrizzly/at2lpt/releases/ … at2lpt-beta-001
AT2LPT Beta Build 001
Patched Adlib Tracker II to support OPL2LPT.
To specify a second OPL2LPT use config option adlib_dual instead of adlib_port.
For adt2play, you can specify which lpt port(s) to use with /lpt1 /lpt2 and/or /lpt3.
The first port mentioned will be the primary, and last port mentioned will be the secondary.

Also he designed a 3d printable case for OPL2LPT : https://www.thingiverse.com/thing:2740939

case.jpg
Filename
case.jpg
File size
53.56 KiB
Views
1155 views
File license
Fair use/fair dealing exception

And he also started to work on a case for CVX4 : https://www.thingiverse.com/thing:2743947

Thanks dkgrizzly !

Visit http://www.serdashop.com for retro sound cards, video converters, ...
DreamBlaster X2, S2, S2P, HDD Clicker, ... many projects !
New X2GS SE & X16GS sound card : https://www.serdashop.com/X2GS-SE ,
Thanks for your support !

Reply 315 of 566, by SteveC

User metadata
Rank Member
Rank
Member

Ooh I'll have to see if I can resurrect my 3d printer (not had a successful print in months - does filament 'go off'?) and print this case out!

YouTube: https://www.youtube.com/c/StevesTechShed
Twitter: https://twitter.com/SteveTechShed

Reply 316 of 566, by Malvineous

User metadata
Rank Oldbie
Rank
Oldbie
chartreuse wrote:

That adapter linked Only seems to be connecting the 4 buttons inputs from the joystick directly to 4 of the data pins (presumably he parallel port has been set-up in bidirectional mode for input first). [...] It wouldn't work with the OPL2LPT since the parallel port is in output mode, and the joystick buttons would be shorting various lines of the data-bus to ground.

The parallel port always supported full duplex 8-bit output and 4-bit input from the start. Bi-directional mode and the later enhancements allowed data to come in on the original 8-bit output pins for increased performance, but even the basic port allowed 4-bit input and 8-bit output at the same time. That's how the computer could tell the printer was out of paper mid-print, because one of those four inputs is the 'out of paper' signal. See IEEE 1284 for some details on the various modes.

In theory you could bit-bang joystick data over the 4-bit input while the OPL2LPT was active, but it would use some CPU power so probably wouldn't be ideal. On top of that, if you think it's tricky patching games to send their Adlib data over the LPT, it's at least the same, possibly worse for the joystick!

(EDIT: @SteveC: Yes I believe filament will absorb moisture from the air and then cause printing problems. Google will give you some tips on how to dry it out again.)

Reply 317 of 566, by matze79

User metadata
Rank l33t
Rank
l33t

Hell, YES a case!

i really want a case!

The OPL2TEST works fine on the 286 System.
Need to patch some other Games, need to check for CGA.

https://www.retrokits.de - blog, retro projects, hdd clicker, diy soundcards etc
https://www.retroianer.de - german retro computer board

Reply 318 of 566, by Jo22

User metadata
Rank l33t++
Rank
l33t++
dreamblaster wrote:

Some news from dkgrizzly :

He patched adlib tracker to support OPL2LPT and 2xOPL2LPT ! :
https://github.com/dkgrizzly/at2lpt/releases/ … at2lpt-beta-001

Wait, I thought Adlib Tracker II was all about OPL3 now and that OPL2 support was
considered deprecated years ago! 😳

So does that mean it is based on the older 2.0.x series ?

Q: So, what is Adlib Tracker II, or AT2 for short, anyway?
A: It is an 18-channel FM tracker for the OPL3-chip (or compatible) [..]

Source: http://www.adlibtracker.net/programfaq.php

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//

Reply 319 of 566, by jaZz_KCS

User metadata
Rank Oldbie
Rank
Oldbie
Jo22 wrote:
Wait, I thought Adlib Tracker II was all about OPL3 now and that OPL2 support was considered deprecated years ago! :shocked: […]
Show full quote
dreamblaster wrote:

Some news from dkgrizzly :

He patched adlib tracker to support OPL2LPT and 2xOPL2LPT ! :
https://github.com/dkgrizzly/at2lpt/releases/ … at2lpt-beta-001

Wait, I thought Adlib Tracker II was all about OPL3 now and that OPL2 support was
considered deprecated years ago! 😳

So does that mean it is based on the older 2.0.x series ?

Q: So, what is Adlib Tracker II, or AT2 for short, anyway?
A: It is an 18-channel FM tracker for the OPL3-chip (or compatible) [..]

Source: http://www.adlibtracker.net/programfaq.php

Well yeah, OPL3 is (amongst other things) stereo. So using 2xOPL2LPTs here does at least make sense, as it can give you stereo when operating two of those at the same time with different data.

But let's face it, it is rare to begin with to be even able to have/use two parallel ports at the same time (all my laptops and desktops only feature one each).