; main loop - generate hotspots, average the buffer, etc
@mainlooper:
mov cx, 378d ; change this to draw more hotspots, 351 looks good
mov bl, 0ffh
; draw hotspots at random positions on the bottom row of the gs buf
@randlooper:
in al, 40h ; get a value from the timer to use as a random number
add ax, bp ; bp is the seed
add bp, ax ; fiddle with it
; divide it a bit so it doesn't go over 320
mov di, ax
sar ax, 8
sar di, 6
add di, ax
add di, 63680d ; 199*320 - bottom of buffer
db 65h, 88h, 1dh ; mov gs:[di], bl
dec cx
jnz @randlooper
mov di, 63999d
push 0a000h
pop ds
; gs -> virscr
; ds -> video memory
; fs -> scr2
; now the main loop which does the averaging
@loop:
; add up our four pixels..
; i use buf[x, y]+buf[x, y-1]+buf[x-1, y]+buf[x+1, y]
; this looks quite good, but you can do whatever you want, really
db 65h, 8ah, 1dh ; mov bl, gs:[di]
mov ax, bx
db 65h, 8ah, 9dh, 0c0h, 0feh ; mov bl, gs:[di-320]
add ax, bx
db 65h, 8ah, 5dh, 0ffh ; mov bl, gs:[di-1]
add ax, bx
db 65h, 8ah, 5dh, 01h ; mov bl, gs:[di+1]
add ax, bx
sar ax, 2 ; ..divide by four..
; ..and al contains the averaged value. we'll make it decay a bit
cmp al, 1
jle @nodecay
sub al, 2
@nodecay:
; draw to fs buffer
db 64h, 88h, 85h, 0c0h, 0feh ; mov fs:[di-320], al
cmp di, 62719d ; (200-4)*320-1 - don't draw the bottom four lines
ja @nodraw
mov [di-320], al ; draw to video memory
@nodraw:
dec di
cmp di, 16000d ; no use averaging the whole screen if the fire never
ja @loop ; gets that high
; blit buffer at fs to buffer at gs
mov cx, di ; when we come out of the averaging loop, di = 16000d
db 0fh, 0a8h ; push gs
pop es
xor di, di
db 0fh, 0a0h ; push fs
pop ds
xor si, si
db 66h
rep movsw ; 32-bit move - rep movsd = rep movsw with db 66h prefix
; check for escape (scancode of 1)
in al, 60h
dec al
jnz @mainlooper
; free previously allocated memory
; es = gs from blit
mov ah, 49h
int 21h
push ds ; ds = fs from blit
pop es
mov ah, 49h
int 21h
; back to text mode
mov ax, 0003h
int 10h
int 20h ; terminate program
Sam
... Linux, the choice of the GNU generation.
--- FMail/386 1.20+
---------------
* Origin: Comms Barrier BBS +61.3.9585.1112, +61.3.9583.6119 (3:632/533)
|