Author Topic: "not cl/cx" causing lockup  (Read 1759 times)

0 Members and 1 Guest are viewing this topic.

Offline donvito

  • n00bzor
  • ZX 81
  • *
  • Posts: 15
  • Karma: 1
  • programming <3
    • View Profile
"not cl/cx" causing lockup
« 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

Code: [Select]
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

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2718
  • Karma: 484
    • View Profile
    • http://www.rbraz.com/
Re: "not cl/cx" causing lockup
« Reply #1 on: February 23, 2010 »
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:

Code: [Select]
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

Challenge Trophies Won:

Offline donvito

  • n00bzor
  • ZX 81
  • *
  • Posts: 15
  • Karma: 1
  • programming <3
    • View Profile
Re: "not cl/cx" causing lockup
« Reply #2 on: February 23, 2010 »
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

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: "not cl/cx" causing lockup
« Reply #3 on: February 28, 2010 »
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
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
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
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2718
  • Karma: 484
    • View Profile
    • http://www.rbraz.com/
Re: "not cl/cx" causing lockup
« Reply #4 on: March 01, 2010 »
...
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.
Challenge Trophies Won: