Dark Bit Factory & Gravity
PROGRAMMING => Other languages => ASM => Topic started by: donvito on February 23, 2010
-
hey guys, im having a problem with the following bit of code...
this is hacked together from many of the posts and work of others on this site. (im learning :D forgive my sins)
it generates a colored-starry effect, but causes the escape check to fail, any ideas?
thanks
org 100h ; com file
les si,[bx] ; ES = 0A000h [video buffer]
mov dx,03DAh ; DX = v-sync port address
mov al,13h ; call video mode 13
int 10h
main:in al,dx ; wait for vertical
test al,8 ; retrace
jz main
draw:and al,ah
xchg ah,al
not cl
xor ax,cx
and al,ah
xchg ax,di
add al,bl
stosb
loop draw
exit:in al,60h ; Escape Pressed? (get keyboard state)
dec al ; try to set value to 0
jnz main ; If not, go back to main.
ret ; if so, exit
-
If you look at LOOP instruction you will see that it decrements it's counter register, in this case CX. The problem is that you are modifying it's value in your draw loop (neg cl) and CX counter won't reach zero and it loop forever.
Try this one, btw I've added a simple code to exit to text mode:
org 100h ; com file
les si,[bx] ; ES = 0A000h [video buffer]
mov dx,03DAh ; DX = v-sync port address
mov al,13h ; call video mode 13
int 10h
main:in al,dx ; wait for vertical
test al,8 ; retrace
jz main
not cl
draw:and al,ah
xchg ah,al
xor ax,cx
and al,ah
xchg ax,di
add al,bl
stosb
loop draw
exit:in al,60h ; Escape Pressed? (get keyboard state)
dec al ; try to set value to 0
jnz main ; If not, go back to main.
;----------------Return to text mode
mov al,0x03
int 0x10
ret ; if so, exit
-
thanks for the explanation rbz! i learned something :D
also, thanks for the exit to textmode code!
im still scouring the net for a vga mode reference guide, so i dont have to just randomly try things to see what happens :D
-
When it comes to DOS interrupt programming there's never been a better reference than Ralf Brown's Interrupt List
http://www.ctyme.com/rbrown.htm (http://www.ctyme.com/rbrown.htm)
It's been going for better than 15 years.
Int 10h is the guy you're probably most interested in
http://www.ctyme.com/intr/int-10.htm (http://www.ctyme.com/intr/int-10.htm)
It might not get in to the port stuff that you need to set the palette and whatnot, so let us know if you get bogged down.
Jim
-
...
im still scouring the net for a vga mode reference guide, so i dont have to just randomly try things to see what happens :D
...
Take a look here:
http://www.dbfinteractive.com/forum/index.php/topic,83.0.html
I've attached 02 zip file/tutorials which was off line, they are old but still nice to read.