Add Vortex Tracker to MPAGD

I’ve recently completed my Spectrum game and wanted to add music to it. A cool guy I met on Twitter by the name of Mike Richmond kindly wrote a wonderful tune for my game using Vortex Tracker. Unfortunately, it’s been quite the headache to get this working with my MPAGD game. But, I’ve finally done it!

To start off, I’ve edited the trailer.txt file which comes in the MPAGD ZX Suite to the following:

ay_player_base:	.equ $e000

ay_player_init:	.equ ay_player_base
ay_player_play:	.equ ay_player_base + $05
ay_player_mute:	.equ ay_player_base + $08

ay_player_setup_flag:	.equ ay_player_base + $0A
ay_player_position:	.equ ay_player_base + $0B

corey_mod:	.equ $e86E

code_start:	.equ $df00
	.org code_start
	ld hl,corey_mod
	call ay_player_init
	call ay_player_play

	.org ay_player_base
	INCHOB "Corey_music.$c"
  	savetap "test.tap",start

I exported the music + player from Vortex:

Vortex export

Kees was kind enough to provide me with a user.asm file which he was using to preserve colour in MPAGD and allows USER X calls to run z80 code.

I added my own code for USER 6 for MPAGD:

chk6	cp 6
  jr nz,chk7
  ld hl,corey_mod
  call ay_player_init

To initialise the music player, you need to call USER 6 in the INTRO MENU event script. I call is just after “EVENT INTROMENU”. You could possibly put it in the GAME INITIALISATION section but I have not tested that.

Now for the tricky bit. You need to edit the EngineZX.asm file to play the music from the correct location. Edit the vsync0 section to add the call to the music player:

vsync0 ld a,(23672)        ; current clock reading.
       cp (hl)             ; are they the same?
       jr z,vsync0         ; yes, wait until clock changes.
       ld (hl),a           ; set new clock reading.
       call music_play         ; COREYMUSIC!
vsync5 call plsnd          ; play sound.

The player needs to be put here otherwise you will only hear a static hissing sound while the player isn’t being called due to the cpu being busy waiting for the vsync.
Also, if you are using MPAGD v0.7.9 or later you will need to edit BUILD.BAT file and remove code where it does the ‘del user.asm’ part in the sjasm folder.

And that’s all there is to it! VOILA! 🙂

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.