Dark Bit Factory &  Gravity

Dark Bit Factory & Gravity

  • July 30, 2010 *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Pages: [1]   Go Down

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

0 Members and 1 Guest are viewing this topic.

donvito

  • n00bzor
  • ZX 81
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 15
  • 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
Logged

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
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

Logged
rbz ^ Codigos

donvito

  • n00bzor
  • ZX 81
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 15
  • 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
Logged

Jim

  • ADMIN
  • Senior Member
  • ********
  • Karma: 325
  • Offline Offline
  • Posts: 4676
    • 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
Logged

rbz

  • MOD
  • Senior Member
  • *******
  • Karma: 272
  • Offline Offline
  • Posts: 2133
    • View Profile
    • WWW
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.
Logged
rbz ^ Codigos
Pages: [1]   Go Up
 

 

B l a c k R a i n V.2 by C r i p

Page created in 0.105 seconds with 19 queries.