Re: A82: Random routine


[Prev][Next][Index][Thread]

Re: A82: Random routine




Hi everyone!  For some reason, I wasn't able to get either of the shuffling 
routines to work, but the concept of switching around the bytes in an array 
rather than completely generating a new array inspired me to write my own, 
which works just fine.  Here it is:

        ld hl,Board
	ld b,20
ShuffleLoop:
	push bc

GETRAND:                        ; SET UP (RANDSEED) WITH A WORD
	PUSH HL                 ; MAYBE HAVE A COUNTER AT THE TITLE SCREEN
	LD HL,(RANDSEED)        ;
	LD A,H                  ; JASON TODD (ALPHASOFT)
	ADD A,A
	RL L
	RL H
	ADD A,A
	RL L
	RL H
	ADD A,A
	RL L
	RL H
	LD BC,$7415
	ADD HL,BC
	LD (RANDSEED),HL
	LD A,H
	ADD A,L
	POP HL

	and %1111
	ld e,a
	ld d,0
	ld a,(hl)
	push hl
	ld hl,Board
	add hl,de
	ld b,(hl)
	ld (hl),a
	pop hl
	ld a,b
	ld (hl),a
	inc hl
	pop bc
	djnz ShuffleLoop

GETRAND isn't used anywhere else in the program, so I just have it in the 
loop rather than calling it.

By the way, the beta release of Concentration is now out. If you want to 
check it out, download it from my webpage at 
http://pubweb.nwu.edu/~dat927/zoomlabs.  I'd love any suggestions!

Thanks!
Doug

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com