Jump to content
  • entries
    28
  • comments
    27
  • views
    20,906

A/Rexx: Converting VGM to TI-99/4 ISR sound list


OLD CS1

194 views

drawer_ti99.png.f67d2fba4a05139379b735bab0c8538f.pngThere is plenty of music and sound effects available for download in the VGM format for the SN76489 PSG (programmable sound generator,) a cousin of the TMS-9919 sound generator in the TI-99/4 and 4A computers.  For a while I have enjoyed working with the sound list format played by the 99/4's ISR (interrupt service routine) as defined in the Editor/Assembler manual.  It is a simple format defined in rows or frames, each containing a number of bytes sent directly to the 9919, and each row may have a duration (or delay until processing the next row) from 1/60th of a second to 255/60ths (roughly 4.25 seconds.)

 

The format is well-defined in the E/A manual, and suffice to say, each row looks basically like below, and a song is terminated by a row with duration of >00.

      x  {          y          }  z
BYTE >06,>8E,>0F,>93,>AC,>1F,>B3,>28

Where x is the number of bytes to send to the 9919, {y} is the set of bytes to send, and z is the duration of this row or frame in 1/60th second jiffies (or 1/50th for PAL consoles, as it is timed by the vertical blank.)

 

This script will take a VGM file for PSG and convert it into a binary containing an equivalent ISR sound list.  It is an oafish and ham-fisted way to do it, but it works and most lists output can be loaded by SoundListRipper for review, editing, or conversion to Extended BASIC statements.  The caveat here is vgm2isr does no processing of the VGM, so fancy things like frequency sweeps may produce binaries which cannot be loaded in SLR, and loops are ignored.  It cannot produce usable output of pseudo-PCM encoding nor VGMs with timing which differs from 50Hz or 60Hz frame-rate.

 

This script requires Regina Rexx or compatible.  While it was originally written to work in ARexx, I can no longer guarantee it runs on an Amiga as my system has been non-functional for a while.

 

In Amiga parlance, the command template is

vgm2isr FILENAME/A,TO/K,NF=NTSCFIX/S,D1=DEBUG/S,D2=DEBUG2/S,BYTE/S,V1/S

Or for non-Amiga types

vgm2isr.rexx <filename> [to <filename>] [{nf|ntscfix}] [{d1|debug}|{d2|debug2}] [byte] [v1]

nf or ntscfix will brute-force a PAL VGM into NTSC timing by inserting an additional jiffy every four (or add 1/60s every 4/60s.)

byte will output a list of assembler BYTE commands of the ISR list, one BYTE command per row.

to followed by a filename will over-ride the default output filename which replaces .vgm with .bin

v1 forces VGM file recognition as under v1.50 (see notes below)

The two debug levels output information as the VGM is processed.

 

Do not use filenames or paths with spaces.

 

vgm2isr.rexx help

or just the command with no arguments will display command template and example.

 

Just remember, the ISR sound list format is not optimized.  Long songs can be ridiculously wasteful of memory.  It works just fine for short songs, fanfares, sound effects, interludes, &c.  But level background music (like Sonic the Hedgehog) can easily take up most or all of cartridge space memory.  There are better tools for such work, like the VGM Compression Tool.

 

Notes on current version:

  • Not all debugging is enabled or in place -- currently just identifies the VGM header version.
  • Byte output does not prevent binary file output.
  • Syntax checking is not complete and could over-write your source file if you are not careful.
  • v1 switch is added to deal with v1.50+ VGMs in which the commands do not start at 0x100. This may be my misreading of the spec, but if a conversion is missing some leading data in the output and debug shows v1.5 VGM or later, try the v1 switch.
  • ISR output is not optimized: commands and rows may be repeated unnecessarily.

 

Priority to-do:

  • Some game systems use a different timing for generator 3 modulated periodic noise, so the output will be a semi-tone off. (The fix is currently part of my personal sound_list.rexx manipulation script.)
  • Dual-channel PSG support.
  • ISR output optimization.

 

Example of the v1 switch, see the included "madness2.vgm" and two output files, "madness2.bin" and "madness2_v1.bin". Other working examples included are inchworm.vgm song, and powerup6.vgm sound effect.

 

 

 

vgm2isr_74.zip

  • Like 1

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...