rendered paste body[BITS 16]
[ORG 0x7C00]
cli
start:
mov ebx, 0x0B8000
blankscreen:
xor ax, ax
mov cx, 0x0800
mov dx, 0x0000
blankscreen_loop:
call draw
inc ax
cmp ax, cx
jnz blankscreen_loop
drawbars:
xor ax, ax
mov cx, 80
mov dx, 0x20 | (1 << 12)
call drawbar
mov dx, 0x20 | (2 << 12)
call drawbar
mov dx, 0x20 | (4 << 12)
call drawbar
logicloop:
mov ax, [ballpos]
mov dx, 0x0 | (0 << 12)
call draw
call ballcalc
mov ax, [ballpos]
mov cx, word [ds:ebx+eax*2]
mov dx, 0x20 | (15 << 12)
call draw
test cx, cx
jz no_hit
cmp cx, 0x20 | (15 << 12)
jz no_hit
mov dx, 0x0 | (0 << 12)
call draw
call ricochet_y
no_hit:
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
call delay
jmp logicloop
delay:
xor ax, ax
delay_main:
inc ax
test ax, ax
jnz delay_main
ret
ballcalc:
mov ax, [ballpos]
xor cx, cx
mov cl, byte [balldir_y]
add ax, cx
sub ax, 80
mov cl, byte [balldir_x]
add ax, cx
sub ax, 1
mov [ballpos], ax
cmp ax, 24 * 79
ja ricochet_y
abuse:
sub ax, 80
cmp ax, 80
jge abuse
end_the_abuse:
test ax, ax
jz ricochet_x
ret
ricochet_y:
mov dl, byte [balldir_y]
xor dl, 160
mov byte [balldir_y], dl
jmp ballcalc
ricochet_x:
mov dl, byte [balldir_x]
xor dl, 2
mov byte [balldir_x], dl
jmp ballcalc
balldir_x: db 0
balldir_y: db 0
ballpos: dw ((12 * 80) + 40)
draw:
mov word [ds:ebx+eax*2], dx
ret
drawbar:
call draw
inc ax
cmp ax, cx
jnz drawbar
mov cx, ax
add cx, 80
ret