
   idnt  Paint

   section  one

1. Paint a picture.
   To assemble: web paint
                assem paint.a -o paint.o
                alink paint.o to paint
                delete paint.a
                delete paint.o
                                    --- Greg Lee, July 22, 1986

   --Macro definitions for assembler
   --EQU statements for assembler
   --Definitions of library references


   define  winheight     200
   define  tot_height    400
   define  winwidth      320
   define  tot_width     640
   define  canvas         10

2. Here is where execution starts.

Main

      define   true   1
      define   false  0
      define   arg`a  D1.L
      define   arg`b  D2.L
      define   newline 10
      define   push  -(SP).L
      define   pop    (SP)+
      define   chr    D0.B
      define   wrd    D0.W
      define   lng    D0.L
      define   rtn    D0.L
      define   adr    A0.L

   movem.l   command_tail/tail_length,-(sp)
   --Begin from workbench
   --Initialize standard input and output
   movem.l   (sp)+,command_tail/tail_length

   --Get file name from input line
   --Initialize the screen
   --Set up basic colors

   print    howtoquit

 · without a delay, screen title tends to get written
 · after page is erased
   d0    =  100
   {  push  =  d0
      graph  WaitTOF
      d0.l  =  pop
      d0   -=  1
      bne   }

   Erase the page, and draw the palette

   Make the pointer square

   --Load requested picture

      define   h_pos D6.L
      define   v_pos D7.L
   h_pos   =  0
   v_pos   =  0

      byte    active_scroll

sleep
   lng   =  signalid
   callex   Wait
   { adr   =  messageport
     callex   GetMsg
     --Answer it
     ->  }
.done
   --Close the screen
   --Back to workbench

   rtn  =  0


--Begin from workbench
      long  wb_message
      define  pr_cli     172
      define  pr_msgport  92

   a1.l -= a1
   callex   FindTask
   a4.l  =  d0
   tst.l    pr_cli(a4)
   bne   §
   adr   =  ^pr_msgport(a4)
   callex  WaitPort
   adr   =  ^pr_msgport(a4)
   callex  GetMsg
   wb_message  =  d0


--Back to workbench
   tst.l  wb_message
   beq   §
   callex  Forbid
   a1.l  =  wb_message
   callex  ReplyMsg


--Answer it
   tst.l    rtn
   = { tst.b  active_scroll
       != { --Scroll the screen
            tst.b  active_drag
            beq   §
       }
       tst.b  active_drag
       beq    sleep
       --Drag the thing
       ->   §
   }
   adr   =  rtn
   push  = 20(adr)
   wrd   = 24(adr)
   push  = lng
   a1.l  = adr
   callex   ReplyMsg
   lng   = pop
   d1.l  = pop    · class
   btst  #3,d1
   != { --Process button command
        ->  §
   }
   btst  #10,D1; beq §  · should not be possible

 · here it's a raw key message
   chr  ?  #$45              · escape key?
   beq   .done
   --Process key command






--Process button command
      byte  curr_tool
   chr  ?  #$69
   = { active_drag  =  false
       --Change tools
       ->  §
   }

   tst.b shifttool
   != { chr  ?  #$68
        = « active_drag  =  true »
        chr  ?  #$E8
        = « active_drag  = false »
        ->  §
   }

   tst.b spbar_flag
   = { tst.b sptool
       = { tst.b curr_tool
           = { chr  ?  #$68
               = { Make a box
               }
               ->  §
           }
       }
   }

      byte  active_drag
   chr  ?  #$68
   = { Get mouse coordinates
       d1.w  ?  17
       <= { Select the palette color
            ->  §
       }

       tst.b  spbar_flag
       != { tst.b  active_drag
            != { tst.b sptool
                 = « Draw a real line to here »
            }
       }
       active_drag  =  true
       adr  =  ^line.1pos
       (adr)+.l = d0
       (adr)+.l = d1
       d2  =  -1
       (adr).l  = d2
       tst.b  sptool; bne §
   · if spbar_flag AreaMove or AreaDraw (cf areapoints++)
       tst.b  spbar_flag
       != { adr  = ^areapoints
            d2.w  = (adr); (adr).w += 1
            tst.w  d2
            = {  graphics AreaMove
                 ->  §
            }
            graphics AreaDraw
       }
       ->  §
   }

   chr  ?  #$E8
   = {  tst.b  sptool
	= {  tst.b  spbar_flag; bne §
	}
	tst.b  active_drag; beq §
        active_drag  =  false
	curr_tool  ?  1
	= {  tst.b  sptool; beq §
	}
        Get mouse coordinates
        d1.w  ?  17
        > « Draw a real line to here »
·       ->  §
   }



--Process key command

      define down_up D1.L
   down_up  =  true
   bclr  #7,chr; != « down_up  =  false »

      byte upwards
      byte across

   chr  ?  #$4C   · up arrow
   = {  active_scroll = down_up; beq  §
        upwards = true
        across  = false
   }
   chr  ?  #$4D   · down arrow
   = {  active_scroll = down_up; beq  §
        upwards = false
        across  = false
   }


   chr  ?  #$4E   · forward arrow
   = {  active_scroll = down_up; beq  §
        upwards = false
        across  = true
   }
   chr  ?  #$4F   · backward arrow
   = {  active_scroll = down_up; beq  §
        upwards = true
        across  = true
   }
 · The qualifier supposedly delivered by the IDCMP doesn't work, so ...
 byte  altkey_flag
                  chr  ?  #$64; = « altkey_flag = down_up »
                  chr  ?  #$65; = « altkey_flag = down_up »
 byte  lshift_flag
                  chr  ?  #$60; = « lshift_flag = down_up »
 byte  rshift_flag
                  chr  ?  #$61
                  = { rshift_flag = down_up
                      tst.b  box_tool
                      != { a1.l  =  rememspr
                           Make the pointer a bar pattern
                      }
                  ->  §
                  }
 byte  ctrl_flag
                  chr  ?  #$63; = « ctrl_flag = down_up »

 byte  spbar_flag
 word  areapoints
   chr  ?  #$40
   = { spbar_flag = down_up
       = { active_drag  =  false
        · AreaEnd if enough area points
           adr  =  ^areapoints
           tst.w  (adr); beq  §
           push  =  adr
           Draw a real line to here
           adr   =  pop
           d1.w  ?  17
           > { clr.w  (adr)
               graphics AreaDraw
               graphics AreaEnd
           }
       }
       ->  §
   }

   tst.b  down_up;  beq  §

   chr  ?  #$46   · del
   = {  Erase the page, and draw the palette
        ->  §
   }

   chr  ?  #$21   · S
   = {  --Save picture
        ->  §
   }

   chr  ?  #$13   · R
   = {  Restore picture
        ->  §
   }



Select the palette color
      byte  sel_color
      byte  selb_color
      byte  selo_color

   d1.b  =  sel_color
   tst.w    d0; = «  sel_color = 0  »
   != { d0   +=  5
        tst.b  curr_tool; = «  d0   +=  8  »
        d0   /=  10
        sel_color  =  d0
   }
   tst.b  rshift_flag
   != { curr_tool  ?  2
        = { tst.b  alttool
            bne  .letedge
        }
        tst.b  curr_tool
        = { tst.b  box_tool
            =  {  sel_color  =  d1
                  selo_color =  chr
                  d1   =  0
                  d1.b =  chr
                  lng  =  d1
                  d1   =  19
                  push =  d1
                  ->  .blck.edge
            }
          .letedge:
            sel_color  =  d1
            selb_color =  chr
            graphics SetBPen
            d0   =  0
            chr  =  selb_color
            d1   =  17
            push =  d1
            ->  .oth.edge
        }
   }
   curr_color  =  chr
   graphics SetAPen

   d0    =  18   · color register for pointer
   push  =  d0

   d0  =  0
   chr  =  curr_color
 .blck.edge:
   tst.b    chr
   =  { d0.l  = #$033
        ->  .def.edge
   }
 .oth.edge:
   chr  ?  16
   >= { d1  =  canvas; d2.l = d1; d3.l = d1
        chr  ?  48
        >= «  chr -= 48; d2.b = chr  »
        chr  ?  32
        >= «  chr -= 32; d1.b = chr  »
        chr  ?  16
        >= «  chr -= 16; d3.b = chr  »
        ->  .rgb.edge
   }
   adr   =  viewport
   adr   =  4(adr)
   graphics GetRGB4
   d0.l  &= #$0FFF
 .def.edge:
   d1.l  =  d0
   d1.w  >>= 8
   d2.l  =  d0
   d2.w  >>= 4
   d2.w  &=  #$0F
   d3.l  =  d0
   d3.w  &=  #$0F

 .rgb.edge:
· does not work for color > 15 if pass viewport address
· does if we pass null (undocumented feature)
   d0   =  0
   adr  =  d0

   d0.l  =  pop
   graphics SetRGB4


--Set up basic colors
   a2   =  ^basic.colors
·   d0   =  17
·   d1   =  0; d2  =  0; d3  =  0
·   adr  =  d1
·   d1.b =  (a2); d2.b = 1(a2); d3.b = 2(a2)
·   graphics  SetRGB4

   adr  =  viewport
   d0   =  0
   {  d1  =  0;  d2  =  0;  d3  =  0
      d1.b  =  (a2)+
      d2.b  =  (a2)+
      d3.b  =  (a2)+
      push  =  d0
      push  =  adr
      chr  ?  16; >= « adr -= adr »
      graphics  SetRGB4
      adr   =  pop
      d0.l  =  pop
      d0   +=  1
·      chr   ?  16
      chr   ?  20
      bne   }


Make a box
      byte  curr_color
   Get mouse coordinates
   d1.w  ?  17
   <= {  Select the palette color
         ->  §
   }
   What color shall we use?

   d2.l =  d0
   d3.l =  d1
   d2  += 16; d3 += 15
   d0  += 1        · fine tuning
   d2.w  ?  tot_width;  bcc  §
   d3.w  ?  tot_height;  bcc  §
   tst.b  box_tool
   = {  tst.b  alttool
        != { --Copy the last square
              ->  §
        }
   }
   graphics RectFill


--Draw the palette
   lng   =  1
   d1    = -6
   d3    =  2
   {  push  =  lng
      movem.l  d1/d3,-(sp)
      graphics  SetAPen
      movem.l  (sp)+,d0/d2
      d0   +=  10
      d1    =   4    · some border at top
      d2   +=  10
      d3    =  16
      movem.l  d0/d2,-(sp)
      graphics  RectFill
      movem.l  (sp)+,d1/d3
      lng   =  pop
      lng  +=  1
      chr   ?  64
      bne   }


--Drag the thing

   chr  =  shifttool
   != { chr  ?  2
        != { tst.b  curr_tool
              = { Make a box
                  ->  §
              }
        }
        Get mouse coordinates
        d1.w  ?  17
        <= {  Select the palette color
              ->  §
        }
        What color shall we use?
        --Do pattern with template
        ->  §
   }

   What color shall we use?

   Get mouse coordinates
   d1.w  ?  17; >  §
   push  =  d1
   push  =  d0
   tst.b  sptool
   = { tst.b  spbar_flag
   = { curr_tool  ?  1
       = { --Big dot
           ->  §
       }
   }
   }
   Draw ephemeral line
   d0.l  =  pop
   d1.l  =  pop
   adr   =  ^line.2pos
   (adr)+.l = d0
   (adr).l  = d1
   Draw ephemeral line


--Big dot
   tst.b   alttool
   = { d0.w  ?  tot_width - 3
       < { d1.w  ?  tot_height - 3
           >=  [
       }
           a7  +=  8
           ->  §
           ]

       graphics WritePixel
       d0.l  =  (sp)
       d1.l  = 4(sp)
       d0   -=  1
       + « graphics WritePixel »
       d0.l  =  (sp)
       d1.l  = 4(sp)
       d0   +=  1
       graphics WritePixel
       d0.l  =  (sp)
       d1.l  = 4(sp)
       d1   +=  1
       graphics WritePixel
   }
   d0.l  =  pop
   d1.l  =  pop
   d1   -=  1
   graphics WritePixel


Draw a real line to here
   Draw ephemeral line
   What color shall we use?
   adr  =  ^line.1pos
   d0.l =  (adr)+; d2.l = d0
   d1.l =  (adr);  d3.l = d1
   graphics Move
   Get mouse coordinates
   d1.w  ?  17; bls  §
   movem.l  d0/d1,-(sp)
   --Draw a real something
   movem.l  (sp)+,d0/d1


--Draw a real something
   tst.b  sptool
   = { Box or line
       ->  §
   }

   curr_tool  ?  2
   = { movem.l  d0-d3,-(sp)
       Exchange corners
       d0 += 1; d2 -= 1
       d1 += 1; d3 -= 1
       movem.l  d0-d3,saverect
       movem.l  (sp)+,d0-d3
       Box or line
       -> §
   }
   Exchange corners
   tst.b  curr_tool
   = { graphics  RectFill
       -> §
   }
   d2.l -= d0
   d3.l -= d1
   d2.l  >>=  1
   d3.l  >>=  1
   d0.l +=  d2
   d1.l +=  d3
   tst.b  spbar_flag
   = {  graphics  DrawEllipse
	-> §
   }
   graphics  AreaEllipse
   graphics  AreaEnd
   clr.w  areapoints
   active_drag  =  false

Exchange corners
   d0.l  ?  d2
   > « exg  d0,d2 »
   d1.l  ?  d3
   > « exg  d1,d3 »

Draw ephemeral line
   adr  =  ^line.1pos
   tst.l  8(adr); bmi  §
   push  =  adr
   d0  =  2
   graphics SetDrMd
   adr  =  pop
   d0.l  =  (adr)+; d2.l = d0
   d1.l  =  (adr)+; d3.l = d1
   push  =  adr
   graphics Move
   adr   =  pop
   d0.l  =  (adr)+
   d1.l  =  (adr)
   Box or line


Box or line
   tst.b sptool
   != {  push  =  d1
         push  =  d0
         d1.l  =  d3
         graphics  Draw
         d0.l  =  (sp)
         d1.l  = 4(sp)
         graphics  Draw
         d0.l  =  d2
         d1.l  = 4(sp)
         graphics  Draw
         a7   +=  8
         d0.l  =  d2
         d1.l  =  d3
   }
   graphics Draw



What color shall we use?
   movem.l  d0/d1,-(sp)
   d0  =  0
   tst.b  altkey_flag
   = {   chr  =  sel_color
         bne   ¶
         chr  =  curr_color
         chr +=  1
         chr  ?  64; = « chr  =  1  »
         curr_color  =  chr
   }
   push      =  d0
   graphics SetAPen
   d1.l      =  pop
   d0        =  0
   chr       =  selo_color
   = « chr    =  selb_color »
   adr       =  srastport
· outline pen works only in jam2
   bset     #3,32(adr)
·   tst.b  rshift_flag; != « d1.b = chr »
   27(adr).b = chr     · outline pen

   chr       =  selb_color
   graphics SetBPen
   d0        =  0
   tst.b  ctrl_flag; != « bset  #2,d0  »
   tst.b  lshift_flag; != « bset  #1,d0  »
   tst.b  rshift_flag; != « bset  #0,d0  »
   graphics SetDrMd
   movem.l  (sp)+,d0/d1


Get mouse coordinates
   adr    =  the_screen
   d0     =  0
   d0.w   =  18(adr)
   d0.w  +=  h_pos
   d1     =  0
   d1.w   =  16(adr)
   d1.w  +=  v_pos



--Change tools
      byte  box_tool
      byte  alttool
      byte  shifttool
      byte  sptool
      define lastboxtool  2

   alttool    =  altkey_flag
   shifttool  =  rshift_flag
   sptool     =  spbar_flag

   tst.b  lshift_flag; != « shifttool  =  2 »
   adr  =  srastport
   34(adr).w  = -1

   chr  =  curr_tool
   = { chr  =  box_tool  · here it's one of the box tools
       chr  ?  lastboxtool
       = { curr_tool = 1
           Make the pointer a brush
           ->  §
       }
      chr  += 1
      box_tool  =  chr
      a1   =  ^hbar.sprite
      chr  ?  1; != « a1  =  ^vbar.sprite  »
·      adr  =  srastport
      $1D(adr).b  = 2
      tst.b  alttool; != « a1.l += 80 »

      a2  =  ^square.sprite
      d0.l  =  a1
      d0.l -=  a2
      d0   -=  8
      Set the fill pattern
·      a1  -=  8
·      8(adr).l = a1
·      a1  +=  8
      Make the pointer a bar pattern
      ->  §
   }
   chr  ?  2   · last of brush tools?
   != { chr += 1
        curr_tool  = chr
     · shape select for 2nd brush-type tool
        · in case doing area fill
·       adr        =  srastport
        $1D(adr).b = -2
        d0.l   = # funny.fill - square.sprite
·        34(adr).w  = -1
        a1         =  ^line.sprite
        tst.b  alttool
        != { 34(adr).w  =  %1100110011001100
             a1         =  ^line2.sprite
             tst.b  rshift_flag
             != «  a1  =  ^bline2.sprite  »
             d0.l   =  # funnydot.fill - square.sprite
        }
	Set the fill pattern   
        Make the pointer a pattern
        ->  §
   }
 · done all brush tools, now start boxes
   clr.b   curr_tool
   clr.b   box_tool
·   adr  =  srastport
   8(adr).l  =  0
   tst.b  alttool
   != { Get mouse coordinates
        d0  += 1
        adr  =  ^last.square
        (adr)+.l = d0
        (adr).l  = d1
        a1  =  ^square.2sprite
        Make the pointer a pattern
        ->  §
   }
   Make the pointer square





Make the pointer a brush
   adr =  srastport
   8(adr).l  =  0
   $1D(adr).b = -2
   d0.l = # funny.2fill - square.sprite
   a1.l  =  ^brush.sprite
   tst.b  alttool
   != { a1.l  =  ^brush.2sprite
        d0.l = # funny.3fill - square.sprite
   }
   tst.b  sptool
   = « Set the fill pattern »
   Make the pointer a pattern

Set the fill pattern
   a2.l  =  tempb
   a2.l  +=  d0
   8(adr).l  =  a2

Make the pointer square
   a1.l  =  ^square.sprite
   Make the pointer a pattern


Make the pointer a pattern
      long  rememspr
   rememspr = a1

   chr  =  shifttool
   != { tst.b curr_tool; bne ¶
        a1 += 4
        adr   =  ^blt.pat
        chr  ?  2
        = « adr  =  ^blt.2pat »
        tst.b  sptool
        != « adr  =  ^blt.3pat »
        a2.l  =  temp.sprite
        a2 +=  4
        d3  =  15
        { d1.w  = (adr)+
          d2.w  = (a1)+
          tst.b box_tool
          = « d2 = 0 »
          chr ? 1; = « d1 = -1 »
          d2.w &= d1
          (a2)+.w = d2
          d2.w  = (a1)+
          tst.b box_tool
          = « d2 = -1 »
          chr ? 1; = « d1 = -1 »
          d2.w &= d1
          (a2)+.w = d2
          dbra  d3,}
        a1.l  =  temp.sprite
	->  [
   }

   adr   =  ^square.sprite
   a1.l -=  adr
   adr   =  tempb
   a1.l +=  adr
	]

   adr   =  the_window
   d0    =  16    · height
   d1    =  16    · width
   d2    =  0     · x offset
   d3    =  0     · y offset
   intuit SetPointer

Make the pointer a bar pattern
   tst.b  rshift_flag; != «  Use bars with background  »
   tst.b  rshift_flag;  = «  Use plain bars  »
   Make the pointer a pattern


Use bars with background
   a1.l  ?  #hbar.sprite;  = « a1  =  ^bhbar.sprite  »
   a1.l  ?  #ahbar.sprite; = « a1  =  ^bahbar.sprite  »
   a1.l  ?  #vbar.sprite;  = « a1  =  ^bvbar.sprite  »
   a1.l  ?  #avbar.sprite; = « a1  =  ^bavbar.sprite  »
   a1.l  ?  #line2.sprite; = « a1  =  ^bline2.sprite  »

Use plain bars
   a1.l  ?  #bhbar.sprite;  = « a1  =  ^hbar.sprite  »
   a1.l  ?  #bahbar.sprite; = « a1  =  ^ahbar.sprite  »
   a1.l  ?  #bvbar.sprite;  = « a1  =  ^vbar.sprite  »
   a1.l  ?  #bavbar.sprite; = « a1  =  ^avbar.sprite  »
   a1.l  ?  #bline2.sprite; = « a1  =  ^line2.sprite  »


--Scroll the screen
      define vscr_incr  4
      define hscr_incr  4

   graph  WaitTOF

   tst.b    across
   != « --Scroll across; ->  §  »

   v_pos += vscr_incr
   tst.b  upwards; != « v_pos -= 2 * vscr_incr »

   wrd  =  v_pos
   -  «  v_pos += vscr_incr; ->  §  »
   wrd  ?  #tot_height  - winheight
   > {  v_pos = #tot_height - winheight
        wrd   = v_pos
   }
   Vertical scroll


--Scroll across

   h_pos += hscr_incr
   tst.b  upwards; != « h_pos -= 2 * hscr_incr »

   wrd  =  h_pos
   -  «  h_pos += hscr_incr; ->  §  »
   wrd  ?  #tot_width  - winwidth
   > { h_pos  =  #tot_width - winwidth
       wrd    =  h_pos
   }
   Horizontal scroll


--Copy the last square
   movem.l  d2-d7,-(sp)

   d2.l  =  d0    · dest x
   d3.l  =  d1    · dest y

   adr   =  ^last.square
   d0.l  =  (adr)+   · source x
   d1.l  =  (adr)    · source y

   adr   =  srastport
   adr   =  4(adr)   · should be bitmap of srastport
   a1.l  =  adr      · source and dest. bitmaps are same
   d4.l  =  15       · size x
   d5.l  =  15       · size y
   Choose minterm
   d7.l  =  #$FF     · mask
   a2.l  =  tempa
   graph BltBitMap

   movem.l  (sp)+,d2-d7

Choose minterm
   d6   =  0
   d6.b = #$E0          · PAT or DEST
   tst.b  altkey_flag; != « d6.b = #$30 »  · !PAT
   tst.b  rshift_flag
   != { d6.b  =  #$C0   · PAT
        tst.b  altkey_flag; != « d6.b = #$60 »  · cookie cut
        ->  §
   }
   tst.b  ctrl_flag; != « d6.b  =  #$80 »    · sieve
   tst.b  lshift_flag; beq  §
   d6.b = #$D0          · PAT or !DEST
   tst.b  altkey_flag; != « d6.b = #$70 »  · !PAT or !DEST


--Do pattern with template
   adr   =  ^blt.pat
   shifttool  ?  2
   = « adr  =  ^blt.2pat »
   tst.b  sptool
   != « adr  =  ^blt.3pat »

   a1  =  ^square.sprite
   adr -=  a1
   a1.l  =  tempb
   adr  +=  a1

   tst.b  curr_tool
   != { d0 -= 8; bmi  §
        d1 -= 8; bmi  §
   }
   d1.w  ?  17; bcs  §

   d2.l  =  d0; d2 += 15
   d2.w  ?  tot_width; bcc  §

   d3.l  =  d1; d3 += 15
   d3.w  ?  tot_height; bcc  §

   d4    =  2
   graphics BltPattern


Horizontal scroll
   adr   =  rasinfo
   8(adr).w = d0    · change Rxoffset (Ryoffset is 10(adr).w)
   adr  = viewport
   graphics ScrollVPort


Vertical scroll
   adr   =  rasinfo
   10(adr).w = d0    · change Rxoffset (Ryoffset is 10(adr).w)
   adr  = viewport
   graphics ScrollVPort




Display string
·  message to console
  define    l_length  D3.L

   tst.l  wb_message; bne §
   arg`a      =  chandle
   l_length   =  0
   l_length.b = (adr)+
   arg`b      =  adr
   calldos  Write



Show string
   push     =  adr
   d0       =  50
   d1       =  50
   graphics Move
   d0       =  2
   graphics SetDrMd
   adr      =  pop
   d0       =  0
   d0.b     =  (adr)+
   d0      -=  1
   graphics Text
   d0       =  0
   graphics SetDrMd


Erase the page, and draw the palette

   a1.l  =  srastport
   push  =  8(a1)    ·   save area pattern
   d0    =  0
   8(a1).l =  d0
   d0.b  =  $19(a1)  ·   save fgpen
   push  =  d0
   d0.b  =  $1C(a1)  ·   save draw mode
   push  =  d0
   d0    =  0
   graphics SetDrMd
   d0    =  0
   graphics SetAPen
   push.w  =  32(a1)
   bclr  #3,32(a1)   · no area outline
   d0    =  0
   d1    =  0
   d2.l  =  tot_width - 1
   d3.l  =  tot_height - 1
   push  =  a1
   graphics RectFill
   --Draw the palette
   a1.l  =  pop
   32(a1).w = pop
   d0.l  =  pop      · old mode
   d2.l  =  pop      · old fg pen
   8(a1).l = pop     · old area pattern
   graphics SetDrMd
   d0.l  =  d2
   graphics SetAPen

--Save picture
   movem.l  saverect,d0-d3
   d2.l    -=  d0; beq §
   d3.l    -=  d1; beq §

   Make a bit map
   Supply memory for planes
   tst.l  d2
   != { --Blit picture to save area
        --Open a file for picture
        != « --Write picture in file and close »
   }
   Return memory for planes

Restore picture
   --Open the old picture file
   beq   §
   --Find out where picture came from
   --Put it where mouse is
   Make a bit map
   Supply memory for planes
   tst.l  d2
   != { --Read file to raster
        --Blit picture back to canvas
   }
   arg`a  =  pichandle
   calldos Close
   Return memory for planes


--Put it where mouse is
   Get mouse coordinates
   d1.w  ?  17; bls  §
   movem.l d4-d5,-(sp)
   d4.l  =  d0
   d5.l  =  d1
   movem.l  saverect,d0-d3
   d4.l -=  d0
   d0.l +=  d4
   d2.l +=  d4
   d5.l -=  d1
   d1.l +=  d5
   d3.l +=  d5
   movem.l (sp)+,d4-d5
   d2.w  ?  tot_width; bcc §
   d3.w  ?  tot_height; bcc §
   movem.l  d0-d3,saverect


Make a bit map
   movem.l  saverect,d0-d3
   d2.l    -=  d0
   d3.l    -=  d1
   d1.l     =  d2
   d2.l     =  d3
   adr      =  ^save.bit.map
   d0       =  6        · depth
   graphics InitBitMap

Supply memory for planes
   movem.l  saverect,d0-d3
   d2.l    -=  d0
   d3.l    -=  d1
   d0.l     =  d2
   d1.l     =  d3
   adr      =  ^save.planes
   d3  =  5
   {  movem.l  d0/d1/a0,-(sp)
      graph  AllocRaster
      d2.l  =  rtn
      movem.l  (sp)+,d0/d1/a0
      (adr)+.l =   d2
      tst.l d2; beq ¶
      dbra  d3,}


--Blit picture to save area
   a2.l -=  a2
   Blit to or from canvas

--Blit picture back to canvas
   a2     =  1
   Blit to or from canvas


Blit to or from canvas
   movem.l  d2-d7,-(sp)

   adr   =  srastport
   adr   =  4(adr)   · bitmap of srastport
   a1.l  =  ^save.bit.map

   movem.l  saverect,d0-d3
   d4.l = d2; d4.l -= d0   · size x
   d5.l = d3; d5.l -= d1   · size y
   d2  =  0    · dest x
   d3  =  0    · dest y

   d6.l = #$C0

   d7   =  a2
   != { exg  d0,d2
        exg d1,d3
        exg a0,a1
        Choose minterm
   }

   d7.l  =  #$FF     · mask
   a2.l  =  tempa
   graph BltBitMap

   movem.l  (sp)+,d2-d7




--Open a file for picture
      long pichandle
   arg`a  =  picturename
   arg`b  =  # 1006
   calldos  Open
   pichandle  =  rtn

--Open the old picture file
      long pichandle
   arg`a  =  picturename
   arg`b  =  # 1005
   calldos  Open
   pichandle  =  rtn

Name of picture file
pfname
   dc.b 'ram:pic',0
   cnop  0,2

--Find out where picture came from
   arg`a  =  pichandle; beq §
   arg`b  = # saverect
   d3     =  16
   calldos  Read

--Write picture in file and close
( keep where it came from )
   arg`a  =  pichandle; beq §
   arg`b  = # saverect
   d3     =  16
   calldos  Write

   How big is each plane?

   a2     =  ^save.planes
   arg`a  =  pichandle
   d0  =  5
   {  arg`b  =  (a2)+
      beq   ¶
      movem.l  d0/arg`a,-(sp)
      calldos  Write
      movem.l  (sp)+,d0/arg`a
      dbra  d0,}

   calldos  Close

--Read file to raster
   How big is each plane?

   a2     =  ^save.planes
   arg`a  =  pichandle
   d0  =  5
   {  arg`b  =  (a2)+
      beq   ¶
      movem.l  d0/arg`a,-(sp)
      calldos  Read
      movem.l  (sp)+,d0/arg`a
      dbra  d0,}



How big is each plane?
   movem.l  saverect,d0-d3
   d2.l  -=  d0
   d2    += 7
   d2.l >>=  3    · bytes per row
   d2    +=  1    · round to word
   bclr  #0,d2
   d3.l  -=  d1   · rows
   d3    *=  d2   · bytes per plane


Return memory for planes
   movem.l  saverect,d0-d3
   d2.l    -=  d0
   d3.l    -=  d1
   d0.l     =  d2
   d1.l     =  d3
   adr      =  ^save.planes
   d3  =  5
   {  d2.l  =  (adr)+
      beq   ¶
      movem.l  d0/d1/a0,-(sp)
      adr   =  d2
      graph  FreeRaster
      movem.l  (sp)+,d0/d1/a0
      dbra  d3,}




--Get file name from input line
   long     picturename
   define   command_tail   A0.L
   define   tail_length    D0
   define   input_name     A1.L
   define   fn_char        D1.B


   tst.l  wb_message
   != { --Get file name from message
        ->  §
   }

   input_name     =  ^infname
   push  =  input_name

   ->       next_fname_char
   {  fn_char  =  (command_tail)+
      fn_char  ?  ' ' + 1;   blt   ¶
      (input_name)+.b  =  fn_char
      tail_length -= 1
  next_fname_char:
      tst.l    tail_length
      bne   }
   clr.b    (input_name)

   input_name  =  pop
   tst.b  (input_name); beq  §
   picturename = input_name


--Get file name from message

   a3.l -= a3
   a2.l  =  wb_message
   28(a2).l  ?  1; bls  §

   d0.l  =  36(a2)
   != {  adr  =  d0
         arg`a = 8(adr)
         != { a3.l  = 12(adr)
              calldos CurrentDir
         }
   }
   lng  = a3; beq  §
   picturename = a3


--Load requested picture

   adr  =  ^ picturename
   tst.l  (adr)
   = { (adr).l  =  # pfname
       ->  §
   }
   Restore picture



--Initialize standard input and output
   long  chandle
   long  dosbase

   a1       =  ^libname
   d0       =  0
   callex   OpenLibrary
   dosbase  =  rtn
   tst.l  wb_message; bne §
   calldos  Output
   chandle  =  rtn


--Initialize the screen

   long  intuitionbase
   long  graphicsbase

   a1       =  ^ilibname
   d0       =  0
   callex   OpenLibrary
   intuitionbase = rtn

   a1       =  ^glibname
   d0       =  0
   callex   OpenLibrary
   graphicsbase = rtn

 long    tempa
   d0.l     =  128
   d1       =   2       · chip memory
   callex   AllocMem
   tempa    =  rtn

 long	tempb
   d0.l     =  # endofsprites - square.sprite
   push     =  d0
   d0.l    +=  72
   d1.l     =  #$10002
   callex   AllocMem
   tempb    =  rtn
   a1.l     =  rtn
   d0.l     =  pop
   a0       =  ^square.sprite
   d0      -=  1
   {   (a1)+.b  =  (a0)+
       dbra   d0,}
   temp.sprite.l  =  a1

   adr      =  ^bit.map
   d0       =  6        · depth
   d1.l     =  tot_width
   d5.l  =  d1
   d2.l     =  tot_height
   d6.l  =  d2
   graphics InitBitMap

   d0.l  =  d5
   d1.l  =  d6
   graphics AllocRaster
   bm.1plane.l = d0
   d0.l  =  d5
   d1.l  =  d6
   graphics AllocRaster
   bm.2plane.l = d0
   d0.l  =  d5
   d1.l  =  d6
   graphics AllocRaster
   bm.3plane.l = d0
   d0.l  =  d5
   d1.l  =  d6
   graphics AllocRaster
   bm.4plane.l = d0
   d0.l  =  d5
   d1.l  =  d6
   graphics AllocRaster
   bm.5plane.l = d0
   d0.l  =  d5
   d1.l  =  d6
   graphics AllocRaster
   bm.6plane.l = d0
   d0.l  =  d5
   d1.l  =  d6
   graphics AllocRaster
   area.raster.l = d0

 long  the_screen
   a0       =  ^new.screen
   intuit   OpenScreen
   the_screen  =  rtn
   win.sptr.l  =  rtn
 long  viewport
   adr      =  rtn
   adr      =  ^$2C(adr)
   viewport =  adr
 long  rasinfo
   adr   =  ^6*4+6*2(adr)
   rasinfo = (adr)
 long  srastport
   adr      =  ^4(adr)
   srastport = adr

· ShowTitle(FALSE) around here ??

 long  the_window
   adr      =  ^new.window
   intuit   OpenWindow
   the_window  =  rtn

 long  rastport
   adr      =  rtn
   adr      =  ^$32(adr)
   rastport =  (adr)
 long  messageport
 long  signalid
   adr         =  rtn
   adr         =  $56(adr)
   messageport =  adr
   d1       =  0
   d1.b     =  $0F(adr)
   lng      =  1
   lng    <<=  d1
   signalid =  lng

 long  currfont
   adr      =  ^screenfont
   graphics OpenFont
   currfont =  rtn
   adr      =  rtn
   graphics SetFont

   d0       =  1
   graphics SetAPen


   a1.l  =  srastport
   adr   =  ^tmpras
   $0C(a1).l = adr
   a1.l  =  area.raster
   d0.l  =  tot_width * tot_height
   graph    InitTmpRas

   a1.l  =  srastport
   adr   =  ^areainfo
   $10(a1).l = adr
   a1    =  ^areabuffer
   d0.l  =  #area.size
   graph    InitArea


--Close the screen

   adr      =  the_window
   intuit   CloseWindow

   adr      =  the_screen
   intuit   CloseScreen

   adr      =  bm.1plane
   d0.l     =  tot_width
   d1.l     =  tot_height
   graphics FreeRaster
   adr      =  bm.2plane
   d0.l     =  tot_width
   d1.l     =  tot_height
   graphics FreeRaster
   adr      =  bm.3plane
   d0.l     =  tot_width
   d1.l     =  tot_height
   graphics FreeRaster
   adr      =  bm.4plane
   d0.l     =  tot_width
   d1.l     =  tot_height
   graphics FreeRaster
   adr      =  bm.5plane
   d0.l     =  tot_width
   d1.l     =  tot_height
   graphics FreeRaster
   adr      =  bm.6plane
   d0.l     =  tot_width
   d1.l     =  tot_height
   graphics FreeRaster
   adr      =  area.raster
   d0.l     =  tot_width
   d1.l     =  tot_height
   graphics FreeRaster

   a1.l     =  tempb
   d0.l     =  # endofsprites - square.sprite
   d0.l    +=  72 
   callex   FreeMem

   a1.l     =  tempa
   d0.l     =  128
   callex   FreeMem


¶

Data sections

   section  three,bss

temp.sprite ds.l  1
saverect    ds.l  4

bit.map     ds.w  1  · bytes per row
            ds.w  1  · rows
            ds.b  1  · flags
            ds.b  1  · depth
            ds.w  1  · pad
bm.1plane   ds.l  1  · planes
bm.2plane   ds.l  1
bm.3plane   ds.l  1
bm.4plane   ds.l  1
bm.5plane   ds.l  1
bm.6plane   ds.l  1
            ds.l  2  · req. to make room for 8

save.bit.map
            ds.w  1  · bytes per row
            ds.w  1  · rows
            ds.b  1  · flags
            ds.b  1  · depth
            ds.w  1  · pad
save.planes
            ds.l  8  · planes


area.raster ds.l  1

tmpras      ds.l  2
areainfo    ds.l  4
            ds.w  4

areabuffer  ds.b  5*area.size

infname     ds.b  30



   section two,data

libname  dc.b  'dos.library',0

         bstr  howtoquit,<TYPE ESCAPE TO EXIT>

signature    dc.b  ' Paint    © Greg Lee, July, 1986 ',0
            cnop     0,2

· ========================================================================
· === NewScreen ==========================================================
· ========================================================================
· STRUCTURE NewScreen,0
·
·    WORD ns_LeftEdge      ; initial Screen dimensions
·    WORD ns_TopEdge      ; initial Screen dimensions
·    WORD ns_Width      ; initial Screen dimensions
·    WORD ns_Height      ; initial Screen dimensions
·    WORD ns_Depth      ; initial Screen dimensions
·
·    BYTE ns_DetailPen      ; default rendering pens (for Windows too)
·    BYTE ns_BlockPen      ; default rendering pens (for Windows too)
·
·    WORD ns_ViewModes      ; display "modes" for this Screen
·
·    WORD ns_Type      ; Intuition Screen Type specifier
·
·    APTR ns_Font      ; default font for Screen and Windows
·
·    APTR ns_DefaultTitle   ; Title when Window doesn't care
·
·    APTR ns_Gadgets      ; Your own initial Screen Gadgets
·
·    ; if you are opening a CUSTOMSCREEN and already have a BitMap
·    ; that you want used for your Screen, you set the flags CUSTOMBITMAP in
·    ; the Types variable and you set this variable to point to your BitMap
·    ; structure.  The structure will be copied into your Screen structure,
·    ; after which you may discard your own BitMap if you want
·    APTR ns_CustomBitMap;
·
· LABEL    ns_SIZEOF
·

new.screen
   dc.w     0,0,winwidth,winheight
   dc.w     6             ·    depth
   dc.b     0,3
   dc.w     $4800         ·    modes = sprites & ham
   dc.w     $0F+$40       ·    type = custon & bitmap
   dc.l     screenfont    ·    font
   dc.l     signature     ·    title
   dc.l     0             ·    no gadgets
   dc.l     bit.map       ·    bitmap


new.window
   dc.w     0,0,winwidth,winheight
   dc.b     0,3
   dc.l     $00000400+$08    ·  rawkey & mouse buttons
· flag req. simple refresh ($40), borderless,
· activate ($1000), rmbtrap ($10000), nocarerefresh ($20000)
   dc.l     $40+$0800+$1000+$10000+$20000
   dc.l      0           ·  first gadget
   dc.l      0           ·  check mark
   dc.l      signature   ·  title
win.sptr
   dc.l      0           ·  screen
   dc.l      0           ·  bitmap
   dc.w     0,0     ·    minimum width and height
   dc.w     0,0     ·    maximum width and height
   dc.w     $0F     ·       type = customscreen  (not bitmap, I guess)



screenfont
   dc.l     dfname
   dc.w     8
   dc.b     0
   dc.b     %01
dfname   dc.b  'topaz.font',0


ilibname       dc.b  'intuition.library',0
glibname       dc.b  'graphics.library',0

basic.colors
   dc.b   canvas,canvas,canvas
   dc.b   3,12,3      · green
   dc.b   13,4,2      · red
   dc.b   0,0,15      · blue
   dc.b   11,11,11    · white
   dc.b   12,12,0     · yellow
   dc.b   0,8,2       · olive
   dc.b   10,0,9      · wine
   dc.b   6,2,0       · rust
   dc.b   0,6,6       · sea
   dc.b   9,15,1      · apple
   dc.b   14,11,0     · orange
   dc.b   12,0,4      · fire
   dc.b   9,2,15      · grape
   dc.b   12,7,7      · salmon
   dc.b   0,15,8      · sky
· for the pointer
   dc.b   0,0,0   · cr 16 is not shown
   dc.b   canvas,canvas,canvas   · cr 17: background
   dc.b   0,3,3   · cr 18: foreground
   dc.b   0,3,3   · cr 19: outline


   cnop  0,2

line.1pos   dc.l  0,0
line.2pos   dc.l  0,0

last.square dc.l  0,17

square.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1100000000000011
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  0,0


square.2sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0011111111111100,%1111111111111111
   dc.w  %0011111111111100,%1111111111111111
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000110000000,%1100000110000011
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  0,0


brush.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1111110000000000
   dc.w  %0000100000000000,%1111111100000000
   dc.w  %0000010000000000,%1111111111000000
   dc.w  %0000001000000000,%1111111111110000
   dc.w  %0000000100000000,%1111111111110000
   dc.w  %0000000100000000,%1111111111000000
   dc.w  %0000000100000000,%0011111111000000
   dc.w  %0000000000000000,%0000111111000000
   dc.w  %0000000000000000,%0000001110000000
   dc.w  %0000001000000000,%0000000111000000
   dc.w  %0000000100000000,%0000000011100000
   dc.w  %0000000010000000,%0000000001110000
   dc.w  %0000000001000000,%0000000000111000
   dc.w  %0000000000100000,%0000000000011100
   dc.w  %0000000000010000,%0000000000001110
   dc.w  %0000000000001000,%0000000000000111
   dc.w  0,0


brush.2sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1110000000000000
   dc.w  %0001000000000000,%1111100000000000
   dc.w  %0000100000000000,%1111111000000000
   dc.w  %0000010000000000,%0111111111000000
   dc.w  %0000001000000000,%0111111111000000
   dc.w  %0000010000000000,%0011111110000000
   dc.w  %0000010000000000,%0000111110000000
   dc.w  %0000000000000000,%0000001100000000
   dc.w  %0000000000000000,%0000000110000000
   dc.w  %0000001000000000,%0000000011000000
   dc.w  %0000000100000000,%0000000001100000
   dc.w  %0000000010000000,%0000000000110000
   dc.w  %0000000001000000,%0000000000011000
   dc.w  %0000000000100000,%0000000000001100
   dc.w  %0000000000010000,%0000000000000110
   dc.w  %0000000000001000,%0000000000000011
   dc.w  0,0

funny.fill
   dc.w  %1111111111111111
   dc.w  %1111111111111111
   dc.w  %0000000000000000
   dc.w  %0000000000000000

   dc.w  %1100000000000000
   dc.w  %1100000000000000
   dc.w  %1100001100110011
   dc.w  %1100001100110011

   dc.w  %1100000011001100
   dc.w  %1100000011001100
   dc.w  %1100000011001111
   dc.w  %1100000011001111

   dc.w  %1100110000001100
   dc.w  %1100110000001100
   dc.w  %1100110000111100
   dc.w  %1100110000111100

   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %1111111111111111
   dc.w  %1111111111111111

   dc.w  %0000000011000000
   dc.w  %0000000011000000
   dc.w  %0000000000110000
   dc.w  %0000000000110000


funny.3fill
   dc.w  %1100000011000000
   dc.w  %0011000000110000
   dc.w  %0000110000001100
   dc.w  %0000001100000011

funny.2fill
   dc.w  %0000000011111111
   dc.w  %0000000011111111
   dc.w  %0000000011111111
   dc.w  %0000000011111111

   dc.w  %0000111100001111
   dc.w  %0000111100001111
   dc.w  %0000111100001111
   dc.w  %0000111100001111

   dc.w  %0011001100110011
   dc.w  %0011001100110011
   dc.w  %0011001100110011
   dc.w  %0011001100110011

   dc.w  %0101010101010101
   dc.w  %0101010101010101
   dc.w  %0101010101010101
   dc.w  %0101010101010101


   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %1111111111111111
   dc.w  %1111111111111111

   dc.w  %0000000000000000
   dc.w  %1111111111111111
   dc.w  %0000000000000000
   dc.w  %1111111111111111

line.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1000000000000000
   dc.w  %0000000000000000,%1110000000000000
   dc.w  %0000000000000000,%0111000000000000
   dc.w  %0000000000000000,%0011100000000000
   dc.w  %0000000000000000,%0001110000000000
   dc.w  %0000000000000000,%0000111000000000
   dc.w  %0000000000000000,%0000011100000000
   dc.w  %0000000000000000,%0000001110000000
   dc.w  %0000000000000000,%0000000111000000
   dc.w  %0000000000000000,%0000000011100000
   dc.w  %0000000000000000,%0000000001110000
   dc.w  %0000000000000000,%0000000000111000
   dc.w  %0000000000000000,%0000000000011100
   dc.w  %0000000000000000,%0000000000001110
   dc.w  %0000000000000000,%0000000000000111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  0,0



funnydot.fill
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000011111111
   dc.w  %0000000011111111

   dc.w  %0000000000001111
   dc.w  %0000000000001111
   dc.w  %0000111100001111
   dc.w  %0000111100001111

   dc.w  %0000001100000011
   dc.w  %0000001100000011
   dc.w  %0011001100110011
   dc.w  %0011001100110011

   dc.w  %0001000100010001
   dc.w  %0001000100010001
   dc.w  %0101010101010101
   dc.w  %0101010101010101


   dc.w  %1100110000000000
   dc.w  %1100110000000000
   dc.w  %0000000000110000
   dc.w  %0000000000110000

   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0011001100000011
   dc.w  %0011001100000011

line2.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1000000000000000
   dc.w  %0000000000000000,%1110000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0001110000000000
   dc.w  %0000000000000000,%0000111000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000111000000
   dc.w  %0000000000000000,%0000000011100000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000011100
   dc.w  %0000000000000000,%0000000000001110
   dc.w  %0000000000000000,%0000000000000111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  0,0


bline2.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1000000000000000
   dc.w  %0000000000000000,%1110000000000000
   dc.w  %0111000000000000,%0000000000000000
   dc.w  %0011100000000000,%0000000000000000
   dc.w  %0000000000000000,%0001110000000000
   dc.w  %0000000000000000,%0000111000000000
   dc.w  %0000011100000000,%0000000000000000
   dc.w  %0000001110000000,%0000000000000000
   dc.w  %0000000000000000,%0000000111000000
   dc.w  %0000000000000000,%0000000011100000
   dc.w  %0000000001110000,%0000000000000000
   dc.w  %0000000000111000,%0000000000000000
   dc.w  %0000000000000000,%0000000000011100
   dc.w  %0000000000000000,%0000000000001110
   dc.w  %0000000000000000,%0000000000000111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  0,0



   dc.w  %1111111111111111
   dc.w  %1111111111111111
   dc.w  %0000000000000000
   dc.w  %0000000000000000
hbar.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%0000000000000000
   dc.w  0,0


 · alternate hbar

   dc.w  %1111111111111111
   dc.w  %0000000000000000
   dc.w  %1111111111111111
   dc.w  %0000000000000000
ahbar.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%0000000000000000
   dc.w  0,0

   dc.w  %1100110011001100
   dc.w  %1100110011001100
   dc.w  %1100110011001100
   dc.w  %1100110011001100
vbar.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  %0000000000000000,%1100110011001100
   dc.w  0,0

· alternate vbar

   dc.w  %1010101010101010
   dc.w  %1010101010101010
   dc.w  %1010101010101010
   dc.w  %1010101010101010
avbar.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  %0000000000000000,%1010101010101010
   dc.w  0,0

· following sprites display background color

bhbar.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %1111111111111111,%0000000000000000
   dc.w  0,0


bahbar.sprite
   dc.w  0,0
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  %0000000000000000,%1111111111111111
   dc.w  %1111111111111111,%0000000000000000
   dc.w  0,0

bvbar.sprite
   dc.w  0,0
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  %0011001100110011,%1100110011001100
   dc.w  0,0

bavbar.sprite
   dc.w  0,0
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  %0101010101010101,%1010101010101010
   dc.w  0,0

blt.pat
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000001111000000
   dc.w  %0000011111100000
   dc.w  %0000111111110000
   dc.w  %0000111111110000
   dc.w  %0000011111100000
   dc.w  %0000001111000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000

blt.2pat
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000001111000000
   dc.w  %0000011111100000
   dc.w  %0000011111100000
   dc.w  %0000001111000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000
   dc.w  %0000000000000000

blt.3pat
   dc.w  %0000000000000000
   dc.w  %0000011111100000
   dc.w  %0001111111111000
   dc.w  %0011111111111100
   dc.w  %0111111111111110
   dc.w  %0111111111111110
   dc.w  %1111111111111111
   dc.w  %1111111111111111
   dc.w  %1111111111111111
   dc.w  %1111111111111111
   dc.w  %0111111111111110
   dc.w  %0111111111111110
   dc.w  %0011111111111100
   dc.w  %0001111111111000
   dc.w  %0000011111100000
   dc.w  %0000000000000000

endofsprites

   section  one


¶

--EQU statements for assembler
sysBase     equ   4
area.size   equ   200

¶

--Macro definitions for assembler

lref  macro
_LVO\1      equ  -6*(\2+4)
      endm


callex macro
       a6.l  =  sysBase
       jsr    _LVO\1(A6)
       endm

calldos macro
       a6.l  =  dosbase
       jsr    _LVO\1(A6)
       endm

intuit macro
      a6.l   =  intuitionbase
      jsr    _LVO\1(A6)
      endm

graphics macro
      a6.l    =  graphicsbase
      a1.l    =  srastport
      jsr      _LVO\1(A6)
      endm

graph macro
      a6.l    =  graphicsbase
      jsr      _LVO\1(A6)
      endm

print macro
      a0     =  ^\1
      Show string
      endm

printerr macro
      a0     =  ^\1
      Display string
      endm

bstr  macro
\1    dc.b  1$-*-1
      dc.b  '\2',10
1$
      endm



¶ Following to avoid slow linking with amiga.lib

--Definitions of library references

      · Exec
   lref  Forbid,18
   lref  AllocMem,29
   lref  FreeMem,31
   lref  FindTask,45
   lref  Wait,49
 · lref  AllocSignal,51
 · lref  FreeSignal,52
 · lref  AddPort,55
 · lref  RemPort,56
   lref  GetMsg,58
   lref  ReplyMsg,59
   lref  WaitPort,60
 · lref  OpenDevice,70
 · lref  CloseDevice,71
 · lref  DoIO,72
 · lref  SendIO,73
   lref  OpenLibrary,88

      · AmigaDOS
   lref  Open,1
   lref  Close,2
   lref  Read,3
   lref  Write,4
   lref  Input,5
   lref  Output,6
 · lref  DeleteFile,8
   lref  CurrentDir,17
 · lref  IoErr,18
 · lref  LoadSeg,21
 · lref  UnLoadSeg,22
   lref  Delay,29
 · lref  IsInteractive,32

      · Intuition
   lref  ClearPointer,6
   lref  CloseScreen,7
   lref  CloseWindow,8
   lref  OpenScreen,29
   lref  OpenWindow,30
   lref  SetPointer,41

      · Graphics
   lref  BltBitMap,1
 · lref  ClearScreen,4
 · lref  TextLength,5
   lref  Text,6
   lref  SetFont,7
   lref  OpenFont,8
   lref  CloseFont,9
   lref  DrawEllipse,26
   lref  AreaEllipse,27
   lref  Move,36
   lref  Draw,37
   lref  AreaMove,38
   lref  AreaDraw,39
   lref  AreaEnd,40
   lref  WaitTOF,41
   lref  InitArea,43
   lref  SetRGB4,44
   lref  RectFill,47
   lref  BltPattern,48
   lref  WritePixel,50
 · lref  Flood,51
   lref  SetAPen,53
   lref  SetBPen,54
   lref  SetDrMd,55
   lref  InitBitMap,61
   lref  WaitBOVP,63
   lref  InitTmpRas,74
   lref  AllocRaster,78
   lref  FreeRaster,79
   lref  GetRGB4,93
   lref  ScrollVPort,94

