0 Members and 1 Guest are viewing this topic.
%01111111%10111111%11011111%11101111%11110111%11111011%11111101%11111110
ld hl,LUTand 7add a,lld l,ajr nc,$+3inc hlld a,(hl);43cc
smc = 1 ;1 for SMC, 0 for no SMC (use 1 if code is in RAM; it's faster)plotSScreen = 9340hsaveSScreen = 86ECh;==============================#IF smc = 0seed = saveSScreen#ENDIF;==============================.db $BB,$6D.org $9D95fire:;;first, set up. We will be writing bytes to the LCD left to right then down di ld a,7 ;LCD y-increment out (16),a;;setup the keyboard port to read keys [Enter]...[Clear] ld a,%11111101 out (1),a;make the bottom row of pixel;s black to feed the flames ld hl,plotSScreen+756 ld bc,$0CFF ld (hl),c \ inc hl \ djnz $-2fireloopmain: ld ix,plotSScreen+12 in a,(1) and %01000000 ret z call LCG ld b,63fireloop:;wait for LCD delay in a,(16) rla jr c,$-3 ld a,80h+63 sub b out (16),a push bc call LCG ld a,20h out (16),a call fire_2bytes+3 call fire_2bytes call fire_2bytes call fire_2bytes call fire_2bytes call fire_2bytes pop bc djnz fireloop jp fireloopmain fire_2bytes: call lcg push hl call lcg pop de ld a,e or d or l and (ix) out (17),a ld (ix-12),a inc ix push hl call lcg pop af or h or l and (ix) out (17),a ld (ix-12),a inc ix retlcg:;240cc or 241cc, condition dependent (-6cc using SMC);;uses the Lehmer RNG used by the Sinclair ZX81#IF SMC = 1seed = $+1 ld hl,1#ELSE ld hl,(seed)#ENDIF;multiply by 75 ld c,l ld b,h xor a ld d,a adc hl,hl jr nz,$+9 ld hl,-74 ld (seed),hl ret rla add hl,hl \ rla add hl,hl \ rla \ add hl,bc \ adc a,d add hl,hl \ rla add hl,hl \ rla \ add hl,bc \ adc a,d add hl,hl \ rla \ add hl,bc \ adc a,d;mod by 2^16 + 1 (a prime);current form is A*2^16+HL;need:; (A*2^16+HL) mod (2^16+1);add 0 as +1-1; (A*(2^16+1-1)+HL) mod (2^16+1);distribute; (A*(2^16+1)-A+HL) mod (2^16+1);A*(2^16+1) mod 2^16+1 = 0, so remove; (-A+HL) mod (2^16+1);Oh hey, that's easy! :P;I use this trick everywhere, you should, too. ld e,a sbc hl,de ;No need to reset the c flag since it is already jr nc,$+3 inc hl ld (seed),hl ret