Announcement

Collapse
No announcement yet.

PB35 Line XOR ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PB35 Line XOR ?

    Is there any way to draw a Line with XOR, so a redraw erases it? If I try to GET-PUT, I run out of memory for anything other than a little box. I'm trying to draw and move lines in real time, across the screen. I can do it great in PB-CC, but hope to do it in PB-DOS too. Thanks!

    ------------------

  • #2
    If I try to GET-PUT, I run out of memory for anything other than a little box
    Isn't a "line" automatically a "little" box?

    If you are trying to redraw four(4) lines which make up a box, why not redraw the four lines individually instead of GET-PUT the whole box?


    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      To draw a long diagonal line then "erase" it, the only way I know is to "get" a big svreen box encompassing the endpoints, draw the line, then "put" the box back overtop the line I want to erase. I can't do that because a big box takes too much memory.

      ------------------

      Comment


      • #4
        Here's a snippet from a program of mine that might help.

        Code:
        'XorPix is Bill Sandall's 1994 PIX routine
        '(in "XorGraph.BAS" in PBXtra disk)
        SUB XorPix (x as integer, y as integer, colr as integer, mode as integer)
           if mode = 1 then   'if XOR mode is wanted
             out &H3CE, 3
             out &H3CF, 24
           elseif mode=2 then  'AND mode
             out &H3CE, 3
             out &H3CF, 8
           elseif mode=3 then  'OR mode
             out &H3CE, 3
             out &H3CF, 16
           end if
           pset (x,y), colr
        END SUB
        
        'By EWM & I won't swear on it
        SUB XorReset
            out &H3CE,3
            out &H3CF, 32
        END SUB
        
        'this sub draws 1 ASCII text char
        '(for longer strings see graphstring.bas)--NOT INCLUDED HERE
        'no good in screen 1, or for non-integer sizes
        SUB GraphChar (xx as integer, yy as integer, ASCcode as integer, Colour as integer, TextSize as single, XorMode as integer)
           dim isize as single, jsize as single
           dim size8 as single, TRow as integer, tempint as integer
           dim i as integer, j as integer, k as integer, l as integer
           dim ys8i as integer, tint as integer, xjk as integer
           dim xj as integer
           DIM CharTableOfs as long
        
           IF ASCcode<1 or ASCcode>255 THEN EXIT SUB
        
           DRAW "BM"+str$(xx)+","+str$(yy) 'position the graphics cursor
        
           if XorMode = 1 then   'if XOR mode is wanted
             out &H3CE, 3
             out &H3CF, 24
           elseif XorMode=2 then  'AND mode
             out &H3CE, 3
             out &H3CF, 8
           elseif XorMode=3 then  'OR mode
             out &H3CE, 3
             out &H3CF, 16
           end if
        
           CharTableOfs = &H7A6E
           DEF SEG = &HF800
        
           size8 = TextSize * 8 - 1
        
                tempint = CharTableOfs + ASCcode * 8
                isize = 0
                FOR i = 0 TO 7
                  isize = isize + TextSize!
                  jsize = 0
                  ys8i = yy - size8 + isize
                  TRow = PEEK(tempint + i)
                  FOR j = 0 TO 7
                    jsize = jsize + TextSize
                    tint = BIT(TRow,7-j)
                    xj = xx + jsize
                    IF tint THEN
                      FOR k = 0 TO TextSize - 1
                        xjk = xj + k
                        FOR l = 0 TO TextSize! - 1
                            PSET(xjk, ys8i + l), Colour
                        NEXT
                      NEXT
                    END IF
                  NEXT
                NEXT
                DEF SEG
        END SUB
        ------------------

        Comment


        • #5
          Thanks for your suggestion. I tried using
          out &H3CE, 3
          out &H3CF, 24
          before a LINE call instead of PSET as in your snippet, but it didn't seem to work. Should it/can it? Or must I make my own "Line" call using a zillion PSET's?

          Cheers!

          ------------------

          Comment


          • #6
            >Should it/can it?
            I am not certain.

            >Or must I make my own "Line" call using a zillion PSET's?

            If one must it won't be hard. Let me know if you need help.

            By the way, after I learned to use the above routine
            I never missed GET/PUT. It is fast enough for my purposes, and
            considerably less quirky and error-prone than GET/PUT.

            P.S. (note added 04/20/06)

            Here's a simple XOR-able line drawer.

            Code:
            'XORline by E.W. Menzel, Jr.
            'based on Bill Sandall's 1994 XORPix, in PBEXTRA
            'for PB-DOS
            sub linedraw (x1 as single,y1 as single,x2 as single,y2 as single,colour as long,stepsize as single,XORmode as long)
               dim dx as single, dy as single, d as single
               dim ix as single, iy as single
               if stepsize <1 then stepsize =1
               dx=x2-x1
               dy=y2-y1
               d=sqr(dx^2+dy^2)
            
               if d<1 then exit sub 'avoid div by zero
            
               IF XorMode = 1 THEN   'if XOR mode is wanted
                 OUT &H3CE, 3
                 OUT &H3CF, 24
               ELSEIF XorMode = 2 THEN 'AND mode
                 OUT &H3CE, 3
                 OUT &H3CF, 8
               ELSEIF XorMode = 3 THEN 'OR mode
                 OUT &H3CE, 3
                 OUT &H3CF, 16
               END IF
            
            
               PSET (x1,y1),colour
               PSET (x2,y2),colour
               ix=dx/d  'increment in x at each step
               iy=dy/d  'increment in y
            
               for i=0 to d step stepsize
                  pset (x1+i*ix, y1+i*iy),colour
               next
            end sub
            
            'demo --PB-DOS
            dim x1 as single,y1 as single,x2 as single,y2 as single
            dim colour as long,stepsize as single,XORmode as long
            screen 12
            x1=450: y1=300
            x2=50: y2=180
            colour=14
            stepsize=5
            XORmode=1
            circle (x1,y1),3: circle(x2,y2),10
            'draw
            call linedraw(x1,y1,x2,y2,colour,stepsize,XORmode)
            a$=input$(1)
            'erase (if XORmode=1)
            call linedraw(x1,y1,x2,y2,colour,stepsize,XORmode)
            ------------------


            [This message has been edited by Emil Menzel (edited April 20, 2006).]

            Comment

            Working...
            X