[rec.video] VCR+: algorithm for first 100

shirriff@sprite.berkeley.edu (Ken Shirriff) (05/14/91)

I've determined the algorithm for the first 100 codes.  I wrote a C program
to decode a code from 1 to 99.  To use this, run "code 42 3" to determine
what happens with code 42 in March.

The first 100 codes correspond to channels 1-4 recording 30 minutes on
a fixed set of 8 times for the 1st to the 3rd of the month.

The first 1000 codes extend the same times and channels for the rest of
the month, but I haven't decoded that yet.

Let me know if you find any errors with this program.
Also, if there's a VCR+ mailing list, can someone add me to it?

/*
 * Copyright 1991 Ken Shirriff   shirriff@sprite.Berkeley.EDU
 */

char *tn[8] = { "6:30", "4", "7:30", "4:30", "3:30", "5:30", "6", "2:30"};

main(argc,argv)
int argc;
char **argv;
{
    int num, month;
    int result, day;
    int time, chan;
    if (argc != 3) {
	printf("usage: code num, month\n");
	exit(-1);
    }
    num = atoi(argv[1]);
    month = atoi(argv[2]);
    code(num, &result, &day);
    result = (result+day*month)&31;
    time = ((result&16)>>2) | ((result&4)>>1) | (result&1);
    chan = (((result&8)>>2) | ((result&2)>>1))+1;
    printf("Code %d in month %d = %s, ch %d on day %d\n", num, month,
	    tn[time], chan, day);
}

code(num,result,day)
int num, *result, *day;
{
    int row, col, rem, div, d;
    int res;

    /*
     * Break up into 7 rows of 5 columns on 3 days.
     * The numbers are broken mod 29 and then broken in half again unevenly.
     */
    rem = num%29;
    div = num/29;
    if (rem<16-div) {
	row = 3-div;
    } else {
	row = 6-div;
	rem -= 13;
    }
    col = 4-(rem-1)/3;
    d = ((rem-1)%3)+1;

    /*
     * The numbers are then assigned consecutively down the columns.
     */
    res = col*7+row;

    /*
     * Swap numbers 1-9 with row 3
     */
    if (num<=9) {
	res = num;
	d = 1;
    } else if (d==1 && res<=9) {
	col = 4-(res-1)/3;
	d = ((res-1)%3)+1;
	row = 3;
	res = col*7+row;
    }

    *day = d;
    *result = res;
}

Ken Shirriff			shirriff@sprite.Berkeley.EDU

jfr@locus.com (Jon Rosen) (05/15/91)

In article <1991May14.074739.3646@agate.berkeley.edu> shirriff@sprite.berkeley.edu (Ken Shirriff) writes:
>I've determined the algorithm for the first 100 codes.  I wrote a C program
>to decode a code from 1 to 99.  To use this, run "code 42 3" to determine
>what happens with code 42 in March.
>
>The first 100 codes correspond to channels 1-4 recording 30 minutes on
>a fixed set of 8 times for the 1st to the 3rd of the month.
>
>The first 1000 codes extend the same times and channels for the rest of
>the month, but I haven't decoded that yet.
>
><stuff and program deleted>
 
Ken, please don't take these a flames, just gentle chiding! :-)
 
But really, what is the point?  Get a life, man!
 
I hope who are doing this just as an intellectual exercise...
 
  (Why do you climb Mt. Everest?  Because it is there!
   Why do you decoed VCR+ codes?  Because they are there!)
 
First of all, the codes are printed in the newspaper right where the
times and channels of the programs are.  I.e., you know exactly all
the information you need to know to program you VCR.  Anyone who
can write a C program that is as good as the one you wrote can not
possibly need something as dunce-like as the VCR+ to program their
VCR!  Second, without the VCR+ equipment, the codes themselves
are useless!  Third, if you wanted to build your own "dunce programmer" 
like the VCR+ for yourself, you could use your own coding scheme
(forget theirs!)  Finally, if you want to build a programmer to
compete with theirs using their coding scheme (so you can get the
benefit of the printing in the TV Guides of the numbers), good luck
and watch out.  I believe they have patented their coding scheme
and it will probably hold up so you will be violating their patent
if you use their codes comercially.  Second, I doubt you can sell
it for less than $60 - their current price - and make much money
at it even if you do not get into patent trouble with them. 
 
What I want to see is a disk distribution of television program
information with a hookup to a VCR remote programmer and a neat
easy to use menu system for selecting shows.  That would really
be slick and might put to use those million or so "home" computers
that Tandy and IBM are selling at under $1000.  People pay for
their cable usage.  Would they pay, oh, say about $5 a month
more to get a complete monthly program guide on disk (or on-line?)
Maybe they would and at that price, if you could get over 5000
subscribers, it would be a pretty neat small business.
 
:-) Jon Rosen :-)
 
(Smileys quite sincere!)