Skip to content

Instantly share code, notes, and snippets.

Last active March 22, 2022 13:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
16 bit DOS assembly, circular rainbow pattern

Circular rainbow pattern

Made for DOS/DOSBox. Compile via NASM: nasm -f bin -o anim.asm



@lea_rosema made this. You can do whatever you want with it. If we meet some day, and you think this stuff is worth it, you can buy me a fruit tea in return.

org 100h
section .text
init_gfx: mov ax,13h
int 10h
mov di,0a000h
mov es,di
start: xor di,di ; pixel offset
xor bx,bx ; x position
xor cx,cx ; y position
call ticks ; dx=tick count (initially 0)
pixel: xor ax,ax
sub ax,04567h
sub ax,dx
add ax,bx
add ax,cx
imul ax,ax
mov si,bx
imul bx,cx
sub ax,bx
sub ax,bx
mov bx,si
shr ax,8
add ax,dx
mov [es:di+bx],al
inc bx ; increment x counter
cmp bx,320
jnz pixel
add di,bx
xor bx,bx ; reset x counter
inc cx ; increment y counter
cmp cx,200
jnz pixel
mov ah,01
int 16h
jz start
mov ah,0
int 16h
cmp al,27 ; unless escape pressed
jnz start ; go to next frame
quit: mov ax,3
int 10h
int 20h
ticks: ; returns DX=Tickcount
push es
push cx
mov cx,[initialTime]
push 40h
pop es
mov dx,[es:6ch]
cmp cx,0
jnz ticks_1
mov cx,dx
mov [initialTime],cx
ticks_1: sub dx,cx
pop cx
pop es
section .data
initialTime: dw 0
section .bss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment