Skip to content

Instantly share code, notes, and snippets.

@RodionGork
Created January 26, 2018 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RodionGork/9ef6141e1b9425079c5e023d82ccff1e to your computer and use it in GitHub Desktop.
Save RodionGork/9ef6141e1b9425079c5e023d82ccff1e to your computer and use it in GitHub Desktop.
Fire in assembly 86
ideal
p386
SCR_W = 320
SCR_H = 200
STARTLINE = 70
assume cs:code,ds:code
segment code public
org 100h
;*******************************
proc Main near
push 0A000h
pop ds
push 13h
call SetMode
call SetPalette
call BurnIt
push 3
call SetMode
ret
endp Main
;*******************************
proc BurnIt near
@@repeat:
mov di,STARTLINE*SCR_W
@@next:
mov ah,0
mov al,[di]
add al,[di-2]
add al,[di+2]
adc ah,0
add al,[di+SCR_W*2+2]
adc ah,0
shr ax,2
cmp al,0
jz @@nodec
dec al
@@nodec:
mov ah,al
mov [di-SCR_W*2],ax
mov [di-SCR_W],ax
add di,SCR_W*2
cmp di,SCR_W*(SCR_H+2)
jb @@next
call Rand
mov ax,[cs:randSeed]
and ax,1
imul ax,ax,160
mov [di],al
mov [di-SCR_W*2],al
sub di,SCR_W*(SCR_H+2-STARTLINE)
inc di
inc di
cmp di,SCR_W*(STARTLINE+1)
jb @@next
mov ah,1
int 16h
jz @@repeat;no keystroke
mov ah,0
int 16h
ret
endp BurnIt
;*******************************
proc SetMode
enter 0,1
push ax
mov ax,[bp+4]
int 10h
pop ax
leave
ret 2
endp SetMode
;*******************************
proc SetPalette
pusha
mov cl,1
@@next:
mov al,cl
mov bh,cl
shl bh,1
dec bh
mov bl,0
mov ah,0
call SetPaletteEntry
add al,20h
mov bl,bh
mov bh,3Fh
call SetPaletteEntry
add al,20h
mov ah,bl
mov bl,bh
call SetPaletteEntry
add al,20h
mov ah,bl
call SetPaletteEntry
inc cl
cmp cl,20h
jbe @@next
popa
ret
endp SetPalette
;*******************************
proc SetPaletteEntry near
;** al=c, bh=r, bl=g, ah=b
pusha
mov dx,3C8h
out dx,al
inc dx
mov al,bh
out dx,al
mov al,bl
out dx,al
mov al,ah
out dx,al
popa
ret
endp SetPaletteEntry
;*******************************
proc Rand near
push es
push di
push eax
push 0
pop es
mov di,46Ch
xor eax,eax
mov ax,[cs:randSeed]
imul eax
shr eax,8
add ax,[es:di]
mov [cs:randSeed],ax
pop eax
pop di
pop es
ret
endp Rand
randSeed dw 0
label buffer byte
ends code
end main
aACgH2oT6G0A6HkA6AYAagPoYgDDv4BXtACKBQJF/gJFAoDUAAKFggKA1ADB6AI8AHQEkJD+yIrg
iYWA/YmFwP6Bx4ACgf+A/HLN6HwALqHuASUBAGnAoACIBYiFgP2B7wClR0eB/8BYcq20Ac0WdKS0
AM0Ww8gAAAFQi0YEzRBYycICAGCxAYrBivnQ5/7PswC0AOgiAAQgit+3P+gZAAQgiuOK3+gQAAQg
iuPoCQD+wYD5IHbRYcNgusgD7kKKx+6Kw+6KxO5hwwZXZlBqAAe/bARmM8Auoe4BZvfoZsHoCCYD
BS6j7gFmWF8HwwAA
@RodionGork
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment