#!/usr/bin/perl -w
#======================================================================|
# Usage: perl dst.pl < dvb2000.bin > new.bin
#
# Patch DVB2000 to automatically adjust for daylight savings time.
# This patch follows the daylight savings rules for the European Union:
# from the last Sunday in March until the last Sunday in October.
#
# 2001-03-11, Dick Streefland <dicks@xs4all.nl>
# 2002-03-10: adapted to new 2.00.0 (beta) versions
#======================================================================|

binmode STDIN;		# for DOS
binmode STDOUT;		# for DOS
undef $/;
$bin = <>;
$pos = index $bin, "\x12\x39\x01\x00\x0B\xF6\x14\x3C\x00\x24";
die( "instruction not found" ) if $pos < 0;
$off = length( $bin ) - ($pos + 2);
substr( $bin, $pos, 6 ) = pack "nN", 0x61ff, $off;
$patch = unpack "u", <DATA>;
# test for new DVB2000 version:
$new = index $bin, "\x41\xf9\x01\x03\x11\x21\x43\xf9\x01\x03\x11\x30";
$patch =~ s/\x01\x03\x01/\x01\x03\x11/g if $new > 0;
print $bin . $patch;
__END__
M2.<P`!(Y`0`+]C0Y`0,!.+1\``-E$F<6M'P!`&(*9Q1T`0)\_^_#`DS?``Q.
M=6$*:_9@[&$$:^A@[A0Y`0,!0%T":@)>`A8Y`0,!-L;\``K6.0$#`3>6/``9
$E@).=0``

