#include "ti-85.h"

.org 0
.db "SnowStorm by AP v1.2",0

randseed = $80DF

	ld b,0			; Initialize random seed


Keyloop:			; This routine generates the initial seed from the time
	call GET_KEY		; taken for the enter button to be pressed
	inc b	
	cp K_ENTER
	jr nz, Keyloop		; Enter not pressed, loop and increment b
	ld hl,randseed		;\
	ld (hl),b		; Load b into randseed ($80DF)
	ld de,VIDEO_MEM		; Load video mem address into DE
DRL:
	CALL_(GETRAND)		; Generate a random number
	ld (DE),a		; Load it into the video memory
	inc de			; Next bit of video memory
	ld a,d			; 
	or a			; 
	jr nz,carryon		;
	ld de,VIDEO_MEM
carryon:
	call GET_KEY
	cp K_EXIT
	ret z
	jr DRL
GETRAND:
	ld a,(randseed)
	ld b,a
	ld a,0
	add a,b
	sla b
	sla b
	add a,b
	sla b	
	sla b
	add a,b
	add a,e
	inc a
	rrc a
	ld (randseed),a
	ret

.end

