Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@learosema
Last active April 13, 2021 16:43
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 learosema/617a1ebfbbfad9316c40656a92cfb184 to your computer and use it in GitHub Desktop.
Save learosema/617a1ebfbbfad9316c40656a92cfb184 to your computer and use it in GitHub Desktop.
Simple animation using 16 bit dos assembly and mode 0x13 (320x200 with 256 colors)

Instructions

  • Download a DOS emulator like DOSBox
  • Get NASM
  • Compile with nasm -f bin -o anim.com anim.asm
  • Run anim.com and enjoy!

License

FRUIT TEA PUBLIC LICENSE (FTPL)

Lea Rosema wrote 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: add ax,bx ; color = lastcolor+x+y
add ax,cx
add ax,dx
xor ah,al
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
jmp start ; next frame
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
ret
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