Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Darksubs
#1
I made a couple of commands:

DarkLine
and
DarkWait

- DarkLine is much much much slower than the original line command, but allows thickness modification. Its actually not that useful, but just a test to see wether I caould produce a line drawing sub. It works a treat, though.

- DarkWait is like the original WAIT command, but doesnt hang your programs. Wink


--- DarkLine ---
Code:
'DarkLine
'--------
'(c) 2004 <Dark>

'DarkLine x1, y1, x2, y2, col, thinkness, step
'The arguments:

'***x1, y1, x2, y2***
'-starting and ending coords
'***col***
'-colour of the line
'***thickness***
'-Need I say more? Thickess of 1 is normal size
'***step***
'-the step of the line (1 = full, 2 = dotted, etc)

SUB darkline (x1, y1, x2, y2, linecol, thick, stp)
thick = thick - 1
dist = CINT(SQR((x2 - x1) ^ 2 + (y2 - y1) ^ 2))
xstep = (x2 - x1) / dist
ystep = (y2 - y1) / dist
linex = x1
liney = y1
FOR dl = 1 TO dist STEP stp
  linex = linex + xstep * stp
  liney = liney + ystep * stp
  LINE (linex, liney)-(linex + thick, liney + thick), linecol, BF
NEXT
END SUB


--- DarkWait ---
Code:
'DarkWait
'--------
'(c) 2004 DarkPrevail

'An improvement on the WAIT command. If the wait command is used on an
'inactive port, then it will hang your program indefintely and cause
'problems. This version of WAIT can be exited using CTRL+BREAK
'Otherwise it is identical to the original

DECLARE SUB DarkWait (portno!, andexp!, xorexp!)

'Usage:
'(same as original, but instead of completely missing out the second
'expression if neccessary, just put 0)

DarkWait 255, 8, 0
'or
DarkWait &H3DA, 8, 8

'Usage example: (for VSynching)

'original commands:
WAIT &H3DA, 8
WAIT &H3DA, 8, 8

'DarkWait commands:
DarkWait &H3DA, 8, 0
DarkWait &H3DA, 8, 8

SUB DarkWait (portno, andexp, xorexp)

SELECT CASE xorexp
  CASE 0
    DO: LOOP WHILE (INP(&H3DA) AND andexp) = 0
  CASE IS <> 0
    DO: LOOP WHILE (INP(&H3DA) XOR xorexp) AND andexp = 0
END SELECT

END SUB

The DarkWait command works a treat an and is no slower than the original. Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)