#!/usr/bin/perl

#
# (C)2012 St(u)dio of Computer Games
# Alexander Ozumenko <a.ozumenko@gmail.com>
#

use strict;


while(<>) {
    chomp;

    s/#include "fx2.h"/#include "delay.h"/;
    s/#include "fx2sdly.h"\s+\/\/ SYNCDELAY macro/#include "fx2macros.h"\n#define SYNCDELAY() SYNCDELAY4/;

    s/AUTOPTRH1\s*=\s*MSB\(\s*&WaveData\s*\);/AUTOPTRH1 = MSB( (WORD)&WaveData );/;
    s/AUTOPTRL1\s*=\s*LSB\(\s*&WaveData\s*\);/AUTOPTRL1 = LSB( (WORD)&WaveData );/;
    s/SYNCDELAY\s*;/SYNCDELAY();/;

    print "$_\n";
}
