I spent hours on trying to solve this, but no matter what I try, for some reason int 15h crashes my entire code. I am currently using a loop for the delay in my code but it's not accurate enough.
I tried: Problems with BIOS delay function (INT 15h / AH = 86h) http://www.techhelpmanual.com/221-int_15h_86h__wait.html and many more, but none helped me... this is the section I would want to change to int 15h, but failed:
delay:
mov ah, 00h
int 1ah
mov si, dx
tick:
mov ah, 00h
int 1ah
cmp si, dx
jz tick
mov si, dx
dec bx
jnz tick
ret
And here is the entire code, if it helps somehow:
IDEAL
MODEL small
STACK 256h
DATASEG
BACKGROUND_COLOR DB 5Ah ; Guessed randomly for more than half an hour
LINK_X DW 94h
LINK_Y DW 65h
start_x DB 0h
start_y DB 0h
ani_fr DB 0h
x DW 0h
y DW 0h
cloop DB 0h
ck DW 0h
lu1 DB 5 dup(0h),6 dup(30h),8 dup(0h),8 dup(30h),5 dup(0h),2Bh,0h,8 dup(30h),0h,2Bh,0h,0h,0h,2Bh,10 dup(30h),2Bh,0h,0h,0h,2Bh,73h,8 dup(30h),73h,2Bh,0h,0h,0h,2Bh,2Bh,73h,73h,4 dup(30h),73h,73h,2Bh,2Bh,4 dup(0h),2Bh,3 dup(73h),30h,30h,3 dup(73h),2Bh,5 dup(0h),73h,30h,6 dup(73h),30h,73h,4 dup(0h),73h,73h,7 dup(30h),73h,73h,4 dup(0h),73h,73h,7 dup(30h),73h,73h,2Bh,4 dup(0h),73h,73h,6 dup(30h),73h,73h,2Bh,4 dup(0h),30h,30h,6 dup(73h),30h,2Bh,2Bh,4 dup(0h),10 dup(30h),5 dup(0h),3 dup(73h),5 dup(30h),73h,6 dup(0h),4 dup(73h),0h,0h,73h,73h,8 dup(0h),73h,73h,9 dup(0h)
lu2 DB 5 dup(0h),6 dup(30h),8 dup(0h),8 dup(30h),5 dup(0h),2Bh,0h,8 dup(30h),0h,2Bh,0h,0h,0h,2Bh,10 dup(30h),2Bh,0h,0h,0h,2Bh,73h,8 dup(30h),73h,2Bh,0h,0h,0h,2Bh,2Bh,73h,73h,4 dup(30h),73h,73h,2Bh,2Bh,4 dup(0h),2Bh,3 dup(73h),30h,30h,3 dup(73h),2Bh,5 dup(0h),73h,30h,6 dup(73h),30h,73h,5 dup(0h),73h,73h,7 dup(30h),73h,73h,3 dup(0h),2Bh,73h,73h,7 dup(30h),73h,73h,3 dup(0h),2Bh,73h,73h,6 dup(30h),73h,73h,4 dup(0h),2Bh,2Bh,30h,6 dup(73h),30h,30h,5 dup(0h),10 dup(30h),6 dup(0h),73h,5 dup(30h),3 dup(73h),7 dup(0h),73h,73h,0h,0h,4 dup(73h),12 dup(0h),73h,73h,0h,0h,0h
ld1 DB 5 dup(0h),6 dup(30h),8 dup(0h),8 dup(30h),5 dup(0h),2Bh,0h,30h,6 dup(73h),30h,0h,2Bh,3 dup(0h),2Bh,0h,8 dup(73h),0h,2Bh,3 dup(0h),2 dup(2Bh),73h,2Bh,30h,2 dup(2Bh),30h,2Bh,73h,2 dup(2Bh),3 dup(0h),2 dup(2Bh),73h,2Bh,73h,2 dup(2Bh),73h,2Bh,73h,2 dup(2Bh),4 dup(0h), 10 dup(2Bh),73h,4 dup(0h),2 dup(30h),2 dup(2Bh),2 dup(73h),2 dup(2Bh),2 dup(30h),73h,2 dup(0h),5 dup(73h),4 dup(2Bh),2 dup(30h),5 dup(73h),2Bh,4 dup(73h),5 dup(30h),2Bh,3 dup(73h),3 dup(2Bh),2 dup(73h),2Bh,2 dup(73h),2 dup(30h),3 dup(2Bh),3 dup(73h),2Bh,3 dup(73h),2Bh,30h,4 dup(73h),3 dup(2Bh),73h,73h,2Bh,3 dup(73h),2Bh,73h,73h,4 dup(30h),2Bh,0h,6 dup(73h),2Bh,5 dup(30h),4 dup(0h),5 dup(2Bh),73h,0h,0h,3 dup(73h),7 dup(0h),3 dup(73h),8 dup(0h)
ld2 DB 5 dup(0h),6 dup(30h),8 dup(0h),8 dup(30h),3 dup(0h),0h,0h,2Bh,0h,30h,6 dup(73h),30h,0h,2Bh,0h,0h,0h,2Bh,0h,8 dup(73h),0h,2Bh,0h,0h,0h,2 dup(2Bh),73h,2Bh,30h,2 dup(2Bh),30h,2Bh,73h,2 dup(2Bh),0h,0h,0h,2 dup(2Bh),73h,2Bh,73h,2 dup(2Bh),73h,2Bh,73h,2 dup(2Bh),0h,3 dup(0h),10 dup(2Bh),73h,0h,4 dup(0h),30h,2Bh,2Bh,73h,73h,2Bh,2Bh,30h,73h,73h,0h,0h,0h,5 dup(73h),3 dup(2Bh),3 dup(30h),2Bh,0h,0h,73h,73h,2Bh,4 dup(73h),5 dup(30h),2Bh,0h,0h,73h,3 dup(2Bh),73h,73h,2Bh,73h,73h,30h,30h,73h,0h,0h,0h,73h,73h,2Bh,3 dup(73h),2Bh,30h,73h,73h,73h,30h,0h,0h,0h,2 dup(73h),2Bh,3 dup(73h),2Bh,73h,73h,3 dup(30h),0h,0h,0h,6 dup(73h),2Bh,3 dup(30h),73h,3 dup(0h),2 dup(0h),5 dup(2Bh),0h,0h,3 dup(73h),3 dup(0h),9 dup(0h),3 dup(73h),3 dup(0h)
ll1 DB 6 dup(0h),4 dup(30h),8 dup(0h),4 dup(73h),5 dup(30h),5 dup(0h),6 dup(73h),30h,30h,2Bh,3 dup(30h),4 dup(0h),6 dup(73h),2Bh,2Bh,4 dup(30h),73h,0h,0h,2Bh,30h,2Bh,2Bh,73h,3 dup(2Bh),30h,30h,0h,30h,73h,3 dup(2Bh),73h,2Bh,2Bh,73h,2Bh,2Bh,73h,73h,30h,0h,0h,73h,0h,0h,6 dup(2Bh),3 dup(73h),0h,0h,0h,73h,0h,0h,4 dup(2Bh),4 dup(30h),4 dup(0h),73h,2Bh,3 dup(73h),7 dup(30h),73h,0h,0h,73h,2Bh,73h,73h,3 dup(30h),3 dup(2Bh),30h,3 dup(73h),0h,73h,0h,73h,73h,3 dup(30h),3 dup(2Bh),4 dup(73h),0h,73h,0h,0h,0h,73h,3 dup(30h),2Bh,2Bh,4 dup(73h),0h,73h,0h,0h,0h,4 dup(73h),30h,30h,73h,73h,30h,6 dup(0h),10 dup(30h),8 dup(0h),4 dup(73h),10 dup(0h),5 dup(73h),4 dup(0h)
ll2 DB 21 dup(0h),4 dup(30h),8 dup(0h),4 dup(73h),5 dup(30h),5 dup(0h),6 dup(73h),30h,30h,2Bh,3 dup(30h),4 dup(0h),6 dup(73h),2Bh,2Bh,4 dup(30h),3 dup(0h),2Bh,30h,2Bh,2Bh,73h,3 dup(2Bh),30h,30h,0h,30h,0h,3 dup(2Bh),73h,2Bh,2Bh,73h,2Bh,2Bh,73h,73h,30h,3 dup(0h),73h,0h,6 dup(2Bh),3 dup(73h),4 dup(0h),73h,0h,4 dup(2Bh),4 dup(30h),5 dup(0h),73h,2Bh,73h,73h,3 dup(2Bh),30h,30h,73h,73h,30h,3 dup(0h),73h,2Bh,73h,30h,3 dup(2Bh),5 dup(73h),3 dup(0h),73h,0h,73h,30h,30h,2Bh,2Bh,5 dup(73h),30h,0h,0h,73h,0h,0h,73h,3 dup(30h),4 dup(73h),30h,30h,0h,0h,73h,0h,30h,4 dup(73h),5 dup(30h),73h,73h,0h,0h,73h,73h,8 dup(30h),3 dup(73h),0h,0h,0h,3 dup(73h),5 dup(0h),3 dup(73h),0h
lr1 DB 21 dup(0h),4 dup(30h),9 dup(0h),5 dup(30h),4 dup(73h),4 dup(0h),3 dup(30h),2Bh,2 dup(30h),6 dup(73h),2 dup(0h),4 dup(30h),2 dup(2Bh),6 dup(73h),3 dup(0h),30h,0h,2 dup(30h),3 dup(2Bh),73h,2 dup(2Bh),30h,2Bh,5 dup(0h),30h,2 dup(73h),2 dup(2Bh),73h,2 dup(2Bh),73h,3 dup(2Bh),4 dup(0h),3 dup(73h),6 dup(2Bh),0h,73h,5 dup(0h),4 dup(30h),4 dup(2Bh),0h,73h,3 dup(0h),30h,2 dup(73h),2 dup(30h),3 dup(2Bh),2 dup(73h),2Bh,73h,3 dup(0h),5 dup(73h),3 dup(2Bh),30h,73h,2Bh,73h,2 dup(0h),30h,5 dup(73h),2 dup(2Bh),2 dup(30h),73h,0h,73h,2 dup(0h),2 dup(30h),4 dup(73h),3 dup(30h),73h,2 dup(0h),73h,0h,2 dup(73h),5 dup(30h),4 dup(73h),30h,0h,73h,0h,3 dup(73h),8 dup(30h),2 dup(73h),3 dup(0h),3 dup(73h),5 dup(0h),3 dup(73h),0h,0h
lr2 DB 5 dup(0h),4 dup(30h),9 dup(0h),5 dup(30h),4 dup(73h),4 dup(0h),3 dup(30h),2Bh,2 dup(30h),6 dup(73h),2 dup(0h),4 dup(30h),2 dup(2Bh),6 dup(73h),3 dup(0h),30h,0h,2 dup(30h),3 dup(2Bh),73h,2 dup(2Bh),30h,2Bh,2 dup(0h),73h,2 dup(0h),30h,2 dup(73h),2 dup(2Bh),73h,2 dup(2Bh),73h,3 dup(2Bh),73h,3 dup(0h),3 dup(73h),6 dup(2Bh),2 dup(0h),73h,4 dup(0h),4 dup(30h),4 dup(2Bh),2 dup(0h),73h,2 dup(0h),73h,7 dup(30h),3 dup(73h),2Bh,73h,0h,3 dup(73h),30h,3 dup(2Bh),3 dup(30h),2 dup(73h),2Bh,73h,0h,4 dup(73h),3 dup(2Bh),3 dup(30h),2 dup(73h),0h,73h,0h,4 dup(73h),2 dup(2Bh),3 dup(30h),73h,3 dup(0h),73h,2 dup(0h),30h,2 dup(73h),2 dup(30h),4 dup(73h),3 dup(0h),73h,0h,10 dup(30h),8 dup(0h),4 dup(73h),11 dup(0h),5 dup(73h),6 dup(0h)
lrs1 DB 5 dup(0h),4 dup(30h),8 dup(0h),4 dup(73h),5 dup(30h),5 dup(0h),6 dup(73h),2 dup(30h),2Bh,2 dup(30h),5 dup(0h),6 dup(73h),2 dup(2Bh),2 dup(30h),5 dup(0h),2Bh,30h,2 dup(2Bh),73h,3 dup(2Bh),3 dup(30h),2 dup(0h),3 dup(2Bh),73h,2 dup(2Bh),73h,2 dup(2Bh),2 dup(73h),3 dup(30h),3 dup(0h),6 dup(2Bh),3 dup(73h),2 dup(0h),30h,2 dup(0h),5 dup(2Bh),5 dup(30h),5 dup(0h),3 dup(2Bh),6 dup(73h),2 dup(30h),5 dup(0h),2 dup(2Bh),7 dup(73h),30h,6 dup(0h),30h,7 dup(73h),2 dup(30h),4 dup(0h),2 dup(73h),3 dup(30h),3 dup(73h),4 dup(30h),3 dup(0h),5 dup(73h),6 dup(30h),2 dup(73h),0h,2 dup(73h),9 dup(30h),7 dup(73h),7 dup(0h),3 dup(73h),16 dup(0h)
;lrs2 DB
CODESEG
link_move_prep:
mov ax, [LINK_X]
mov [x], ax
mov ax, [LINK_Y]
mov [y], ax
call clear_tile
ret
link_up:
call link_move_prep
sub [LINK_Y], 1h
cmp [ani_fr], 4h
jge call_lud1
jle call_lud2
call_lud1:
mov si, offset lu1
call draw_link
ret
call_lud2:
mov si, offset lu2
call draw_link
ret
link_left:
call link_move_prep
sub [LINK_X], 1h
cmp [ani_fr], 4h
jge call_lld1
jle call_lld2
call_lld1:
mov si, offset ll1
call draw_link
ret
call_lld2:
mov si, offset ll2
call draw_link
ret
link_right:
call link_move_prep
add [LINK_X], 1h
cmp [ani_fr], 4h
jge call_lrd1
jle call_lrd2
call_lrd1:
mov si, offset lr1
call draw_link
ret
call_lrd2:
mov si, offset lr2
call draw_link
ret
link_down:
call link_move_prep
add [LINK_Y], 1h
cmp [ani_fr], 4h
jge call_ldd1
jle call_ldd2
call_ldd1:
mov si, offset ld1
call draw_link
ret
call_ldd2:
mov si, offset ld2
call draw_link
ret
draw_pixel:
mov ah, 0Ch ; Changes to pixel writing
mov cx, [x] ; Sets X Coordinates for the pixel
mov dx, [y] ; Sets Y Coordinates for the pixel
int 10h ; Flushes the pixel
ret
proc clear_tile
mov [cloop], 00h
clearmainloop:
mov al, [BACKGROUND_COLOR]
call draw_pixel
add [x], 1h
mov bx, [LINK_X]
sub [x], bx
cmp [x], 0Fh
jge clearbreakline
clearrepeat:
add [x], bx
add [cloop], 1h
cmp [cloop], 0F0h
jne clearmainloop
ret
clearbreakline:
sub [x], 0Fh
add [y], 1h
jmp clearrepeat
endp
proc draw_link
mov ax, [LINK_X]
mov [x], ax
mov ax, [LINK_Y]
mov [y], ax
mov [cloop], 0h
lmainloop:
mov al, [si]
cmp al, 0h
je ad
mov ah, 0Ch
mov bh, 0h
mov cx, [x]
mov dx, [y]
int 10h
ad:
add [x], 1h
mov ax, [LINK_X]
sub [x], ax
cmp [x], 0Fh
jge lbreakline
ldrepeat:
add si, 1h
add [x], ax
add [cloop], 1h
cmp [cloop], 0F0h
jne lmainloop
cmp [ani_fr], 6h
je link_ani_res
add [ani_fr], 1h
ret
link_ani_res:
mov [ani_fr], 0h
ret
lbreakline:
sub [x], 0Fh
add [y], 1h
jmp ldrepeat
endp
proc use_sword
mov ax, 5h
mov bx, 0h
int 33h
cmp ax, 1h
je clkd
ret
clkd:
mov [x],10h
mov [y],10h
call draw_pixel
ret
endp
delay:
mov al, 0h
mov ah, 86h
mov cx, 1h
mov dx, 2h
int 15h
ret
start:
mov ax, @data
mov ds, ax
mov ah, 00h ; Changes to display mode (who needs text?)
mov al, 13h ; Changes screen resolution to 320x200 with 256 color options, for best display
int 10h ; Flushes the display mode
mov ah, 06h ; Changes to scroll up (so it can start drawing the background from the top)
xor al, al ; Clear entire screen because the terminal has already drew the screen black
xor cx, cx ; Moves to the upper left corner
mov dx, 184Fh ; Gets screen size
mov bh, [BACKGROUND_COLOR] ; Paints the screen the background color
int 10h
call link_down
mainloop:
mov ah, 1h
int 16h ; Get keystroke
jz after_press
mov ah, 0h
int 16h
cmp ax, 1177h ; 1177h == scancode for W
jne mlr1
call link_up
mlr1:
cmp ax, 1E61h ; 1E61h == scancode for A
jne mlr2
call link_left
mlr2:
cmp ax, 1F73h ; 1F73h == scancode for S
jne mlr3
call link_down
mlr3:
cmp ax, 2064h ; 2064h == scancode for D
jne after_press
call link_right
after_press:
mov bx, 1h ; delay time
call delay
jmp mainloop
END start
EDIT: found a way to make a proc that uses a milliseconds delay without int 15h:
proc delay
delay_loop:
mov cx, 1h
delRep: push cx
mov cx, 086A0h
delDec: dec cx
jnz delDec
pop cx
dec cx
jnz delRep
sub bx, 1h
cmp bx, 0h
jnz delay_loop
ret
endp
enjoy if you're searching for one