org 0x7C00 init: mov word [body_start], 2000 mov word [body_end], 2000 mov word [head_dir], -160 ; clear the screen mov ax, 0xB800 mov es, ax mov cx, (80 * 25) xor ax, ax mov di, ax rep stosw ; clear the game memory mov es, ax mov di, 0x0500 mov cx, (80 * 25) rep stosw call game_tick ; store the original timer isr cli xor ax, ax mov ax, [32] mov [orig_isr8], ax mov ax, [34] mov [orig_isr8 + 2], ax ; install our timer isr mov word [32], timer_tick mov word [34], 0 sti .loop: jmp .loop orig_isr8: dd 0 tick_count: db 0 timer_tick: mov al, [tick_count] inc al cmp al, 9 jl .nogametick call game_tick .nogametick: mov [tick_count], al jmp far [orig_isr8] game_tick: ; grab some vars before switching to game seg mov si, [body_start] mov di, [body_end] mov dx, [head_dir] mov ax, 0x0050 mov ds, ax mov es, ax .noinit: ; update head position mov ax, si add ax, dx mov [si], ax mov si, ax mov bx, [di] mov word [di], 0 mov di, bx ; check if body overlapping cmp word [si], 0 je .nodie add sp, 2 jmp init .nodie: .end: xor ax, ax mov ds, ax mov es, ax mov [body_start], si mov [body_end], di ret head_dir: dw 0 body_start: dw 0 body_end: dw 0 ; Pad out the rest of the boot sector and add magic bytes times 510 - ($ - $$) db 0 dw 0xAA55 ; Pad out the rest of a 1.44MB floppy image times (2880 * 512) - ($ - $$) db 0