Re: 6702 chip

From: Rhialto <rhialto_at_falu.nl>
Date: Sat, 26 May 2012 11:15:02 +0200
Message-ID: <20120526091502.GC10175@falu.nl>
On Sat 26 May 2012 at 10:14:41 +0200, Rhialto wrote:
> Unfortunately it doesn't
> pass the validation routine but I haven't looked into the difference.

The difference was with bit 3 which has a period of 1.
For that bit, the order in which to look at "changed" matters.

> and to calculate the next value:
> 
> 	    int v = val;
> 	    int changed = prevodd ^ input;
> 	    int mask = 0x80;
> 
> 	    /* loop over all 8 output bits / shift registers */
> 	    for (i = 7; i >= 0; i--, mask >>= 1) {
  		/* If the input bit changed */
  		if (changed & mask) {
  		    a[i] ^= reload[i] >> 1;
  		}
> 		if (a[i] & 1) {
> 		    v ^= mask;
> 		    a[i] ^= reload[i]; /* wrap bit around */
> 		}
> 		a[i] >>= 1;
> 	    }
> 
> 	    prevodd = input;
> 	    val = v;

This function seems to pass validation in its C incarnation!

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- There's no point being grown-up if you 
\X/ rhialto/at/xs4all.nl    -- can't be childish sometimes. -The 4th Doctor

       Message was sent through the cbm-hackers mailing list
Received on 2012-05-26 10:00:05

Archive generated by hypermail 2.2.0.