***************************************
;* psuran23--pseudorandom # generator *
;* of the shift/xor type, 23 bit shift*
;* very good as coin flipper, test +/-*
;* OK (not super) random integers     *
;*    by Tracy Allen  76670,326       *
;* Enter with BASIC  CALL 64704,A,HL  *
;*   A=0 for next # in sequence       *
;*   HL=varptr(X%), returns # in X%   *
;* or                                 *
;*   1<A<256 to re-seed sequence      *
;*   HL=two lo bytes, A=hi byte       *
;**************************************
altbuf:	equ fcc0h	;for M100
			;use F854h in T200
	org altbuf
top:	ora a		;test entry
	jz rule		;its get next #
reset:	shld seed	;it's a reseed
	sta seed+2
	ret
rule:	xchg		;de holds varptr
	lxi h,seed+2	;hi byte
	mov a,m
	ani 42h		;mask for xor
	stc		;perform xor
	jpo rule1
	cmc
rule1	dcx h		;result in carry
	dcx h		;point to lo byte
	mvi c,3		;3 bytes to rotate
rule2	mov a,m		;rotate carry
	ral		;into low bit
	mov m,a		;& rotate all
	inx h		;3 bytes left
	dcr c
	jnz rule2
	lhld seed	;done, get low word
	shli		;store it using varptr
	ret
seed:	db 85,85,85
