Pop!Art VGM Player for MSX

Is known by the brazilian MSX community about the development of Pop!Art VGM player that I’m working on since middle 2014.

Some practical results about Pop!Art were reported in 2014 by one of the most important retrocomputing blogs in Brazil, the Retrocomputaria+ blog and by the biggest brazilian MSX community on FaceBook, the MSX Brasil Oficial.

Pop!Art VGM player already supports all existing chips on the MSX platform, like Konami SCC (K051649), PSG (AY8910), FM (YM2413), SFG01/05(YM2151), OPL3/OPL4 and the Philips Music Module (Y8950).

Note: Some months after I presented some Pop!Art results, another excellent VGM Player (VGMPLAY by Grauw) was released.

My first motivation to start this development was only for fun and also to start learning about how sound chips works. The second motivation was to start a big project in chiptune’s scene.

In fact to get information about these old chips was the biggest challenge because some of them just can be found on manufacturer’s data-sheet that sometimes are poorly written and with a small percentage of useful information.

In most cases these datasheet information are confused so the best alternative to these poor data-sheets are the Linux sound cards drivers source code.
After reading these drivers source code, I got some specific details about how several of these chips really work.

Custom chips like Konami SCC don’t have any data-sheets but fortunately are well documented by the international MSX community and sources like BiFi’s website were my main information source.

Another big source of information for MSX developers in general is the MSX Assembly Pages (brought by the same author of VGMPLAY, Grauw) that in my opinion is the best source of information for developers who want to make useful and cool things for MSX computers.

Presenting Pop!Art

Pop!Art is an original software made using Turbo Pascal 3, almost 97% of it’s code is written in Pascal, with some parts written in Z80 ASM. If you want to compile it’s source code and modify it, feel free because the source code was released under GPLv3 and can be reached at OldSkoolTech SVN’s repositories on SourceForge.net.

It is compatible with Borland Turbo Pascal 3.0 (CP/M80-MSXDOS), Turbo Pascal 3.3f from MSX Club Enschede, (MSXDOS 1 & 2), and it also can be ported to others newer Pascal compilers, like FreePascal (Lazarus) and maybe newer versions of Delphi compiler.

The source code is fully commented and several parts of Pop!Art software were incorporated to the framework that I’m developing since I had started the development of the MSXDUMP in 1995 (best known as PopolonY2k Framework).

This framework can deal with several technologies present on MSX architecture, like IDE device handling, MSXDOS and MSXBIOS function calls and direct console handling.

Pop!Art introduces some important features in the framework, like support to Z80 interrupts, all MSX sound chips handling (K051649 aka SCC, YM2413 aka FM, YM2151 aka SFG01/05, OPL3/OPL4, Y8950 aka Philips Music Module, AY8910 aka PSG) and a better and accurate “wait” routines that can deal with resolutions below 50Hz or 60Hz, fixing time errors caused by songs with “tempo” below these resolutions (50Hz or 60Hz), that minimizes any standard deviation.

The current Pop!Art engine also supports all existing chips for the MSX platform and in future, newer chips supported by the VGM format similar to any existing on MSX platform will be added to the Pop!Art engine.

The VGM file format

VGM, aka Video Game Music, is a logging format based on GYM format which is another video game format used specifically to store Sega Mega Drive (Genesis) songs, but contrary to GYM, the VGM format can be used with several other chips different to Mega Drive sound chip. The first version of VGM was released in 2005 and after this release, six new format specifications were released until the current 1.70.

Another curiosity about VGM is that the format was very popular with Winamp users because this music player was the first player capable of playing VGM songs through a plugin specially created for it.

GD3 tag format

The VGM format has a GD3 metadata present in file header specification. The GD3 format is the same format used by MP3 files to store several tracks information, like author, song name and so on.

Pop!Art VGM Support

Pop!Art supports all VGM version’s format, since 1.0 to 1.70 and the GD3 tag format is partially implemented in Pop!Art engine but will be finished in future releases.

The VGM format contains all data samples sent to the sound chips using a speed rate of 41,000 samples per second, so your library must be very fast and precise to deal with VGM files in an accurate way and basically just assembly codes can reach this performance using all of the chip’s power….right ???

Hummm…..maybe not.

Turbo Pascal

I’m really thinking to start writing code to MSX using modern compilers, like SDCC C compiler, which is known to be one of the most powerful and optimized compilers for small devices, but I have written a lot of code to the old Turbo Pascal 3 for CP-M80/MSX for years and my framework has increased a lot its capabilities to handle several standard devices present in MSX world.

Turbo Pascal

In fact I’m using this good, but not so optimized compiler, to learn about new optimization techniques and about the Turbo Pascal internals. And also how to avoid not optimized coding style when you’re programming for machines with low resources. Maybe in the future I can write a new, modern and optimized Pascal compiler (maybe a cross-compiler) for MSX machines, but this is another dream.

When I started writing this article in 2015, FreePascal compiler was not an alternative because it lacked Z80 binary generation support, but since beginning 2020 FreePascal started supporting Z80 platform.

https://wiki.freepascal.org/Z80

Borland Turbo Pascal 3.0 is an impressive compiler because it is a very fast compiler but unfortunately there are several things that were created to be generic and problem solving in a generic way are known to be slower than a more specialized code generation.

I’m dedicated to improve my framework to be so generic as possible but sometimes I’ll need to be more specific to resolve big performance problems using Turbo Pascal code instead using assembly code.

The small list below can help programmers who are thinking start coding in Turbo Pascal, C and another language different of ASM.

1) In Pascal avoid nested functions – This kind of structured feature is not optimized in Turbo Pascal 3;

2) In any high level language with floating point builtin data types support, like Pascal and C, try to avoid real time processing using these floating point types (float/double in C and Real in Pascal).
These data types can deal with an “excellent” precision but is known that when you have, or want, an “excellent” precision, the processor will pay the price for this precision, so avoid floating point real time operations if is possible. Sometimes this can be done performing some data pre-processing or using fixed point, instead floating point;

3) Use integer instead floating point data and byte instead of Integer data, depending on numeric range, for the same reason of previous item;

4) Try “think” your application in JUMP TABLES, instead nested IF’s or even switch-case (case-of for Pascal programmers);

5) Read this article before coding http://www.popolony2k.com.br/?p=2402

NOTE ABOUT THE 5th ITEM: I’m using GOTO in small pieces of code, because old compilers like Turbo Pascal 3 are very antique, so features like “break” and “continue”, widely used in loop iterations, can be “simulated” by using GOTO.

PopolonY2k framework

As I wrote at the beginning of this text that I’m working on a framework fully written in Turbo Pascal, with some parts in ASM, since I released the MSX DUMP (part of MSX Disk Doctor suite). I thought that this framework was optimized but I was completely wrong, because there’s no framework or any other piece of code which the performance can be measured when discs and slow devices are used by these codes.

So when I tested this framework using my MSX Turbo R machine, everything seemed to be 100% ok and fast, but when I tested the same code on a MSX, running a slower Z80 processor, some problems started to be more visible, then fixing these problems and keep everything working fast using a Z80 in the same way like a R800 processor is a hard work.

This framework was started 20 years ago, when I was leaving the university and in those days I just wrote code for old devices like, disk drives and some generic code code to access the MSXBIOS and MSXDOS (1).
When I restarted coding this framework in 2011, I quickly improved it by adding features to access new devices, like Sunrise IDE devices, Network socket API, UNAPI and RS232 support are still WIP (Work in Progress).

Bellow is the list of all features present on this framework

1) FOUNDATION MODULES – New modules to make Turbo Pascal “more compatible” with new Turbo Pascal releases. New features like Big Integer handling;

2) MSX INTERNALS MODULES – MSX related functions and information (e.g. MSX System Variables);

3) BIOS MODULES – MSX BIOS functions by category;

4) MSXDOS (1 & 2) MODULES – MSX DOS functions;

5) SLOT MANAGEMENT – Functions related to slot manipulation;

6) INTERRUPT HANDLING – Functions to enable interrupt vector function handling using Turbo Pascal;

7) COMMUNICATION – Functions related to communication (RS232 (Work in progress), Sockets);

8) COMMUNICATION DRIVERS – Drivers written to support the Sockets implementation above. Support to OPTONET cards;

9) UNAPI FRAMEWORK – Support to UNAPI framework in Turbo Pascal (Work in progress);

10) SOUND CHIP DRIVERS – Drivers for all sound chips found on MSX standard;

11) VGM PLAYER FRAMEWORK – Functions to play songs in VGM format;

12) IDE SUNRISE-LIKE FRAMEWORK – Functions to handle Sunrise-like IDE devices;

13) USER INTERFACE AND OPTIMIZED CONSOLE MODULES – New functions to increase the speed of console applications and to handle user interface;

14) UNIT TEST FRAMEWORKPopolonY2k TEST SUITE (PTEST) – Functions providing UNIT tests capabilities for Turbo Pascal 3 projects (widely used in the Big Integer implementation);

An updated framework features list can be reached here.

Pop!Art features list

  1. VGM file support (1.0 up to 1.70 – some commands are still disabled. eg. non MSX existing chip commands);
  2. Memory Mapper support (VGM files longer than 64Kb can be loaded and played);
  3. MSXDOS2 only support (sub-directories access). Maybe MSXDOS1 will be supported in future releases;
  4. AY8910 support;
  5. YM2413 support;
  6. YM2151 (SFG 01/05) support;
  7. Y8950 (Philips Music Module) support;
  8. YMF278 (OPL4) support;
  9. K051649 (SCC) support;

Known Pop!Art missing features in this release (0.0).

  1. VGZ file support (in fact is VGM inside a .tar.gz file);
  2. MSXDOS1 support;

Pop!Art memory layout

The application memory layout is described below:

  1. $0000-$3FFF – MSXDOS CP/M-80 + Turbo Pascal runtime workspace;
  2. $4000-$7FFF – Application object code;
  3. $8000-$BFFF – VGM Song data (16Kb memory mapped paged system);
  4. $C000-$FFFF – Unused;

Pop!Art in action

After writing a long story and mainly a lot of technical stuff, it is time to play some song using Pop!Art finally after 5 years 🙂

Check the video below where I explain technical details about how Pop!Art works internally.

Pop!Art in action (portuguese video only)

Downloading Pop!Art

Pop!Art binaries can be downloaded here, https://sourceforge.net/projects/oldskooltech/files/MSX/Pop%21Art/

Enter the version directory you want (e.g v0.0, etc) and download a preferred compressed file (pop_art_v_?_?.zip or pop_art_v_?_?.lhz).

After downloading and decompressing the chosen file, popvgm.com and popplay.chn files will be extracted, put them together in the same directory and then execute popvgm.com.

These files are the two main modules of Pop!Art described below.

  • popvgm.com is the VGM loader;
  • popplay.chn is the VGM player itself.

Hidden gems

Unfortunately all Turbo Pascal 3.x for MSX, both Borland and MSX Club Enschede, are too old products and are both an one pass compiler, so generated binaries are not so optimized as newer compilers like Free Pascal compiler.

Borland did an excellent work when decided create a powerful runtime not just placing the biggest part of standard library there but all comparison test routines are placed there too.

Using this model, the amount of binary code generated by the compiler was decreased considerably but on the other hand they sacrificed performance with this strategy.

I realized that all If’s in the main Pop!Art streaming routine was jumping to the respectives runtime routines and this behavior was decreasing performance a lot, so after a long time think about this problem finally I decided to change the Borland Turbo Pascal 3.0 binary by adding an extra pre-processing compiler directive to generate inline code for all comparison routines and consider Integer (-32768 .. 32767) like Word/Unsigned int (0 .. 65535).

But changing this behavior could turn specific code written to this specific Turbo Pascal version, incompatible with both Borland and MSX Club Enschede, so instead using the standard compiler directive {$ }, I created an extended compiler directive {% } that is considered by Borland and MSX Club Enschede Turbo Pascal as a regular comment but for my modified Turbo Pascal version is an extended compiler directive.

The first extended directive is {%W} and is a scoped directive, so to activate the starting scope the programmer must start with {%W+} and finish the scope with {%W-}.

This will inform the compiler to treat comparison routines as unsigned integer and generating inline code from starting point {%W+} to ending point {%W-}.

Below a small piece of Pop!Art code using this technique:

Procedure __MoveMapper16BitData{( __pSndChipArrayParms : Pointer )};
  Begin
    {%W+}
    If( nCurrentStreamPos < __ctMapperBufferEndAddr ) Then
    {%W-}
    Begin
      __pSndChipArrayParms := Ptr( nCurrentStreamPos );
      nCurrentStreamPos := nCurrentStreamPos + 2;

      (* Direct jump to command processing routine *)
      Inline( $2A/nFnJmpAddr   { LD HL,(nFnJmpAddr) }
              /$E9             { JP (HL)            } );
    End
    Else
    Begin
      __pSndChipArrayParms := Ptr( Addr( aSndBuffer ) );
      aSndBuffer[0] := Mem[nCurrentStreamPos];
      __ExecMapperPaging;
      aSndBuffer[1] := Mem[nCurrentStreamPos];
      nCurrentStreamPos := Succ( nCurrentStreamPos );

      (* Direct jump to command processing routine *)
      Inline( $2A/nFnJmpAddr   { LD HL,(nFnJmpAddr) }
              /$E9             { JP (HL)            } );
    End;
  End;

All comparison structures below are covered by this extended directive:

  • While .. Do
  • Repeat .. Until
  • If… Then … Else

Conclusion

Pop!Art can still be considered a work in progress and soon some extra and useful features will be added to it’s core engine, like:

  • Add support to VGZ (compressed VGM) file format;
  • Chip sound drivers improvement, adding chip specific extra features still not implemented;
  • Core engine speed optimization (improving Turbo Pascal performance);
  • Add full support to VGM 1.70;

So, I hope you enjoy Pop!Art and thanks for reading.

[]’s
PopolonY2k

Print Friendly, PDF & Email

Computer made music

Chiptune is a music category that has grown over the last few years and it is composed often by musicians, users and fans of old computers. This new music category is growing thanks to a generation whose childhood was affected in some way by computers.

Those who were born in the 70‘s and 80’s know exactly what about I’m writing, because in those days anyone who could get any kind of computer now was able to remember the magic behind it’s sounds and songs created for those machines.

If you lived those magic days, brands like Commodore, Apple, Texas, Philips are familiar to you and some systems and computers standards like C64, AppleII, Amiga, Spectrum, Amstrad CPC and MSX in some way have had some importance and maybe influenced you in your career or hobby.

Today several mainstream artists have been submitting their songs to be produced by producers that were influenced by C64 game made songs and by Amiga demosceners artists. The most famous example of this influence is a recent scandal involving the well known producer Timbaland that has been accused of plagiarism by Amiga computer fans, when he worked for Nelly Furtado’s album, Loose, released in 2006.

Comparing both songs

This is a well known story and in fact Timbaland revealed to have plagiarized some elements of several Amiga’s composers including the demoscener artist Janne Suni (a.k.a Tempest). One of the songs plagiarized by Timbaland was composed by Tempest for the Oldskool Music competition (Assembly 2000) which occurred in 2000 in Helsinki, Finland and reached the first place in the competition.

Nice try Timbaland 🙁
.

To be continued...

[]’s
PopolonY2k

Reference

ChipTune (Wikipedia)
http://en.wikipedia.org/wiki/Chiptune

Timbaland (Wikipedia)
http://en.wikipedia.org/wiki/Timbaland

Nelly Furtado (Wikipedia)
http://en.wikipedia.org/wiki/Nelly_Furtado

Timbaland Plagiarism controversy (Wikipedia)
http://en.wikipedia.org/wiki/Timbaland_plagiarism_controversy

Print Friendly, PDF & Email

COVOX Speech Thing

Apesar do blog estar silencioso nos últimos meses, isso não é sinal de que não estou trabalhando em algo novo. Na verdade tenho trabalhado nos últimos 2 meses em diversos projetos paralelos, sendo alguns relacionados ao MSX e outros nem tanto.

É de conhecimento de grande parte da comunidade MSXzeira que estou desenvolvendo um Player de música, chamado Pop!Art e que no atual estágio de desenvolvimento o mesmo já é compatível com todos, ou a maioria, dos chips existentes para a plataforma MSX, conforme noticiado aqui no blog do Retrocomputaria.

Pois bem, após diversos feedbacks da comunidade brasileira, um comentário em especial do meu amigo Eliazer Kosciuk me fez iniciar um outro projeto paralelo cujo o resultado final certamente será adicionado ao desenvolvimento do Pop!Art.

Estou me referindo ao suporte a COVOX Speech Thing, que é um dispositivo muito antigo e que fez algum sucesso nos EUA, na década de 80 até o inicio dos anos 90, mas que eu realmente não conhecia até então.

De fato o COVOX é um DAC de 8Bits bem primitivo mas capaz de mostrar excelentes resultados, tornando-o bem atrativo na época, considerando custo/benefício, uma vez que as placas de som eram itens estupidamente caros.

Pois bem, seguindo o tutorial do projeto GR8Bit para a construção de um COVOX, decidi construir esse dispositivo que é bem simples e fácil de ser construído, bastando ter alguma destreza com ferro de solda apenas. Abaixo segue as fotos da construção do COVOX, que no final de tudo coube no próprio invólucro do plugue DB25 da impressora.

My COVOX device (based on GR8Bit project's page)
My COVOX device (based on GR8Bit project’s page)

COVOX Speech Thing
COVOX Speech Thing

COVOX device finished.
COVOX device finished.

Female plug in the back of COVOX device.
Female plug in the back of COVOX device.

FastTracker 2.9

Infelizmente não houve tempo para concluir todas as fases de construção do projeto, que é o meu objetivo. E sobre projeto inteiro, quero dizer construir o dispositivo COVOX e também o software que a utiliza. A parte do hardware posso dizer que está 100% pronto mas o software sequer consegui desenvolver uma linha de código. Entretanto eu procurei na internet e descobri um software que é nada mais nada menos do que um dos music trackers mais famosos, senão for o mais famoso, uma vez que influenciou diversos outros que vieram depois.

Estou me referindo ao FastTracker 2 MOD player, que de fato é um MOD player compatível com as principais placas de som da época e também com dispositivos COVOX.

O FastTracker 2 e os dispositivos COVOX são tão conceituados, que ainda hoje são amplamente utilizados pelo movimento demoscene.


FastTracker 2 playing XENON2 (Bomb the Bass)

FastTracker 2 using my homemade COVOX device (Playing Turrican 2)

Nada mau para um software feito em Turbo Pascal 7 de meados da década de 90. 🙂

[]’s
PopolonY2k

Referências

Pop!Art no Retrocomputaria Plus
http://www.retrocomputaria.com.br/plus/?p=8015

COVOX Speech Thing (Wikipedia)
http://en.wikipedia.org/wiki/Covox_Speech_Thing

DAC (Wikipedia)
http://en.wikipedia.org/wiki/Digital-to-analog_converter

COVOX device by GR8Bit
http://kb.gr8bit.ru/KB0010/GR8BIT-KB0010-Adding-multimedia-capability-covox-device.html

Conectores DB (Wikipedia)
http://pt.wikipedia.org/wiki/Conector_DB

Music Tracker (Wikipedia)
http://en.wikipedia.org/wiki/Music_tracker

MOD Music File (Wikipedia)
http://en.wikipedia.org/wiki/Module_file

DemoScene (Wikipedia)
http://en.wikipedia.org/wiki/Demoscene

Turbo Pascal (Wikipedia)
http://en.wikipedia.org/wiki/Turbo_Pascal

Print Friendly, PDF & Email

Tetrastar – Chiptune electronic music

Quem, na década de 80, poderia imaginar que algum dia seria moda se vestir como nerd e que teríamos programas de TV exaltando o estilo nerd e até mesmo que os nerds estariam no controle das maiores corporações mundiais e que influenciariam na musica, forte instrumento da cultura pop mundial, com produções feitas com as mais modernas tecnologias e/ou até mesmo utilizando computadores e video games com nada mais, nada menos que 20 a 30 anos de idade.

Pois bem, na TV é impossível hoje não conhecer a série do Warner Channel, denominada The Big Bang Theory, que com o seu protagonista, Sheldon Cooper, tem influenciado cada vez mais jovens, divulgando assim a cultura nerd e a tornando objeto de desejo :).

The Big Bang Theory

Na área musical temos percebido, principalmente nos últimos 4 anos, um movimento musical denominado Chiptune music, que é basicamente a produção musical utilizando chips de som criados na década de 80, ou até mesmo antes, presente basicamente em computadores antigos, sendo destaque nessa área os Commodore 64, ZX Spectrum/MSX e também video games como Super NES (aka Super Nintendo no Brasil) e Sega Genesis (aka Mega Drive no Brasil).

Até hoje o chip do Commodore 64, o SID, é cultuado como o melhor chip para criação musical no movimento chiptune, sendo utilizado por seus adeptos, seguido pelo chip da General Instruments, AY-3-8910, utilizado pela grande maioria dos computadores da década de 80, incluindo o ZX Spectrum e MSX.

É nesse cenário do movimento chiptune que, navegando em sites internacionais e fóruns, tomei conhecimento de uma dupla de musica eletrônica denominada Tetrastar, que é basicamente formada pelo próprio produtor da dupla, Oliver Hindle e da vocalista, Jaylyn Coffin.

TetraStar – Eletronic music duo

A dupla foi formada em 2010, atuando basicamente no cenário indie  e recentemente liberou para download em seu site o seu primeiro álbum denominado Song’s we didn’t Write (canções que não escrevemos – tradução livre), que basicamente são musicas de outros artistas que foram reestilizadas e produzidas por eles utilizando sintetizadores, Commodore 64, Nintendo Game Boy e NES.

É perceptível os diversos arranjos feitos pelo NES e Game Boy (que por vezes se parece muito com sons de ZX Spectrum/MSX) em todas as musicas da dupla com a marcante batida eletrônica, aliada a excelente voz da cantora Jaylyn Coffin, fazem do Tetrastar uma excelente surpresa no cenário da musica indie e porque não dizer da musica chiptune.

Tetrastar – Crank That

 25/01/2012 – UPDATE

Recentemente TODOS os vídeos oficiais do Tetrastar foram removidos do Youtube e o site oficial http://tetrastar.co.uk, é redirecionado para o site do grupo original do produtor, Oliver Hindle, o SuporPowerLess (http://www.superporwerless.co.uk), o que nos deixa com uma interrogação sobre o futuro do Tetrastar.

Atualizei o vídeo que existia anteriormente, Float On, para o clip Crank That, que ainda não foi removido do Youtube.

[]’s
PopolonY2k

Referência na internet

Definição de Nerd (Wikipedia)
http://pt.wikipedia.org/wiki/Nerd

Warner Channel
http://www.warnerchannel.com/

The Big Bang Theory (Wikipedia)
http://en.wikipedia.org/wiki/The_Big_Bang_Theory

Sheldon Cooper (Wikipedia)
http://en.wikipedia.org/wiki/Sheldon_Cooper

Chiptune Music (Wikipedia)
http://en.wikipedia.org/wiki/Chiptune

Commodore 64 (Wikipedia)
http://en.wikipedia.org/wiki/Commodore_64

ZX Spectrum (Wikipedia)
http://en.wikipedia.org/wiki/ZX_Spectrum

MSX (Wikipedia)
http://en.wikipedia.org/wiki/MSX

Super NES (Wikipedia)
http://en.wikipedia.org/wiki/Super_nes

Sega Genesis (Wikipedia)
http://en.wikipedia.org/wiki/Sega_Genesis

MOS Technology SID (Wikipedia)
http://en.wikipedia.org/wiki/MOS_Technology_SID

General Instruments AY-3-8910 (Wikipedia)
http://en.wikipedia.org/wiki/General_Instrument_AY-3-8910

Tetrastar official page
http://tetrastar.co.uk/

Superpowerless (Oliver Hindle Wikipedia)
http://en.wikipedia.org/wiki/Superpowerless

Independent Music (Indie music – Wikipedia)
http://en.wikipedia.org/wiki/Independent_music

Songs we didn’t write post (Official website)
http://tetrastar.co.uk/?p=62

Nintendo Game Boy (Wikipedia)
http://en.wikipedia.org/wiki/Nintendo_Game_Boy

Nintendo Entertainment System (Wikipedia)
http://en.wikipedia.org/wiki/Nintendo_Entertainment_System

Print Friendly, PDF & Email