Skip to content

Instantly share code, notes, and snippets.

@killroy42
Created March 13, 2021 16:36
Show Gist options
  • Save killroy42/b43516a4fa19cb6a0c60b7dd5d8c431c to your computer and use it in GitHub Desktop.
Save killroy42/b43516a4fa19cb6a0c60b7dd5d8c431c to your computer and use it in GitHub Desktop.
; Ever since I saw TINYFIRE.ASM by Rex Deathstar I desired
; to write a fire routine which is not only small but fast
; and in full color as well.
;
; Well, here it is:
; - 192 shades of red and yellow set at run-time
; - 160 by 100 resolution for higher speed
; - limited screen area based at the bottom of the screen
; - NO Memory variables used
; - LESS THAN 200 bytes! (186 in July 1997)
;
; Of course there is room for improvement, but I didn't want to
; make this my live's work either ;)
; The routine is this big because the low resolution drawing
; (always four pixels at a time) makes it neccesary to go by X and
; Y coordinates rather then the usuall offset into video mem.
;
; by KILLROY 1997
;
; email: csitc@mail.link.net.mt
.MODEL TINY
.386
.CODE
.STARTUP ;No idea what this does, I just saw it in many examples
org 100h ;(I never really "learned" asm)
mov al,13h
int 10h
push 0a000h
pop ds ;no es: segment overrides (one byte each!)
mov cl,63
mov dx,3c8h
SetPal1: ;Colors 0 to 63
mov al,cl
out dx,al
inc dx
out dx,al
xor al,al
out dx,al
out dx,al
dec dx
dec cx
jge SetPal1
mov bl,63
SetPal2: ;Colors 64 to 127
mov al,bl
add al,64
out dx,al
inc dx
mov al,63
out dx,al
mov al,bl
out dx,al
xor al,al
out dx,al
dec dx
dec bx
jge SetPal2
mov cl,63
SetPal3: ;Colors 128 to 191
mov al,cl
add al,128
out dx,al
inc dx
mov al,63
out dx,al
out dx,al
mov al,cl
out dx,al
dec dx
dec cl ;I don't know where, but ch gets destroyed (so does bh in SetPal2)
jge SetPal3
MainLoop:
mov cl,240
loop0: ;My random number generator
mov ax,bx ;Quite big, since I just took my Pascal one
rol ax,3 ;instead of writing a new one
sub ax,7
xor ax,di
mov bx,di
mov di,ax
and ax,127
mov dx,ax
shl dx,1
mov si,62368
sub si,dx
mov al,192
mov [si],al
dec cx
jnz loop0
push bx
mov si,19200
mov bx,69
Yloop: ;Do lines (lines 30 to 99)
add si,32
mov cl,128
Xloop: ;Do columns (columns 32 to 287)
xor ah,ah
xor dh,dh
lodsb
mov dl,[si-3]
inc si
add dx,ax
mov al,[si]
add dx,ax
mov al,[si+638]
add dx,ax
shr dx,2
cmp dx,2
jl NoDec
dec dx
dec dx
NoDec:
mov dh,dl
mov [si-642],dx
mov [si-322],dx
dec cx
jnz Xloop
add si,32
add si,320
dec bx
jnz Yloop
mov bx,160
pop bx
mov ah,1 ;Originally I stored the value from port 60h and
int 016h ;compared it, but that's bigger
jz MainLoop
mov ax,3
int 010h
ret ;Theoretically this messes up the stack
End ;(poping the flags). What can I say? It works...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment