   rem    00000000 00000000
   rem           ^        ^
   rem   badguy/weapon land
   abort 0
   buffers 6
   memory all,chip,fast
   array 64*64*2+1544,2
   memory alla,chipa,fasta
   position 117,30
   load 2,"DF0:WDR.Intro.pic"
   memory allb,chipb,fastb
   load 3,"DF0:WDR.Hero.pic"
   memory allc,chipc,fastc
   load 1,"DF0:WDR.Land.pic"
   memory alld,chipd,fastd
   getmap 1,1
   setblack 1
   setmap 2,1
   a=0
   open a,":dundata"
   if a=0
      close
      print "No such file.  Try Again."
      goto 1
   endif
   read eof,$(0),10
   sx=$(0)
   read eof,$(0),10
   sy=$(0)
   read eof,$(0),10
   mx=$(0)
   read eof,$(0),10
   my=$(0)
   array mx*my*2+1544,1
   st=mx*my*2+20
   mxbad=0
   for i= 0 to mx*my-1 step 4
      read eof,$(st-20),15
      if eof=-1
         print "Error in file length!"
         goto 2
      endif
      eof=$(st-20)
      @(i*2)=eof%256
      @((i+1)*2)=(eof/256)%256
      @((i+2)*2)=(eof/65536)%256
      @((i+3)*2)=(eof/16777216)%256
   next
   close
2  a=0
   open a,":badinfo"
   read eof,$(st-20),15
   mxbad=$(st-20)
   for i=0 to mxbad*6-1 step 4
      read eof,$(st-20),15
      n=$(st-20)
      @(i+st)=n%256
      @(i+st+1)=(n/256)%256
      @(i+st+2)=(n/65536)%256
      @(i+st+3)=(n/16777216)%256
   next
   close
   for i=0 to mxbad-1
      @((@(st+i*6+2)+@(st+i*6+3)*mx)*2+1)=i+1
   next 
   land=0
   weapon=-1
   guy=-1
   display 2
   messx=0
   messy=200
   sy=0
   sx=0
   x=2
   num=32
   div=8
   pen 1,1
   y=2
   gosub 100
   gosub 50
   setblack 0
   pointer 1
   move 10,10
   text all,"  ",chip,"  ",fast
   move 20,20
   text alla,"  ",chipa,"  ",fasta
   move 30,30
   text allb,"  ",chipb,"  ",fastb
   move 40,40
   text allc,"  ",chipc,"  ",fastc
   move 50,50
   text alld,"  ",chipd,"  ",fastd
3  ifmouse xm,ym
   if xm#-1
    if xm<240
     x=sx+xm/48
     y=sy+ym/40
     move messx+50,messy+7
     text "x";x;",y";y;" n";mxbad-1;" (";mx;",";my;")"
     if land>-1
      @((x+y*mx)*2)=land
      a=x+y*mx
      gosub 110
     else
      if guy>-1
       gosub 56
       flag=-1
       for i=0 to mxbad-1
        if (@(st+i*6+5)=0)&(flag=-1)
         flag=i
        endif
       next
       if (flag=-1)&(mxbad<254)
        mxbad=mxbad+1
        flag=mxbad-1
       endif
       if flag>-1
        @((x+y*mx)*2+1)=flag+1
        @(st+flag*6)=guy
        @(st+flag*6+1)=dir+31*4
        @(st+flag*6+2)=x
        @(st+flag*6+3)=y
        @(st+flag*6+4)=59
        @(st+flag*6+5)=50
       endif
       a=x+y*mx
       gosub 110
      else
       if weapon>-1
        gosub 56
        flag=-1
        for i=0 to mxbad-1
         if (@(st+i*6+4)=0)&(flag=-1)
          flag=i
         endif
        next i
        if (flag=-1)&(mxbad<254)
         mxbad=mxbad+1
         flag=mxbad-1
        endif
        if flag>-1
         @((x+y*mx)*2+1)=flag+1
         @(st+flag*6)=15+(weapon+1)*16
         @(st+flag*6+1)=63
         @(st+flag*6+2)=x
         @(st+flag*6+3)=y
         @(st+flag*6+4)=50
         @(st+flag*6+5)=30
        endif
        a=x+y*mx
        gosub 110
       endif
      endif
     endif
    else
     if ((xm>288)&(ym<190))|((xm>240)&(ym>190))
      guy=-1
      weapon=-1
      if ym>190
         land=(xm-240)/12+57
      else
         land=(xm-288)/12+(ym/10)*3
      endif
  rem    blit 3,(land%8)*12,(land/8)*10,messx+10,messy,12,10
     else
      if ym<150
       land=-1
       weapon=-1
       guy=ym/10
       dir=(xm-240)/12
     rem  blit 3,guy*12,81+dir*10,messx+10,messy,12,10
      else
       land=-1
       guy=-1
       weapon=(xm-240)/12+(ym-150)/10*4
   rem    blit 3,weapon*12,123,messx+10,messy,12,10
      endif
     endif
    endif
   endif
   ifkey key
   if key#-1
    if key=-101
     getkey c
     if c=48
      getkey c
      move messx+200,messy+8
      text "CREATURES"
9     getmouse x,y
      if x>240
       goto 9
      endif
      x=x/48+sx
      y=y/40+sy
      creature=@((x+y*mx)*2+1)-1
4     clear
      move 0,10
      pen 1,30
      center 1
      text "PEOPLE/CREATURES"
      center 0
8     c=@(creature*6+st)%16
      d=@(creature*6+st+1)%4
      xh=200:yh=40:d=creature+1:gosub 111
      move 0,30
      text "        NUMBER : ";creature
      move 0,40
      text "          TYPE : ";c
      move 0,50
      text "    OCCUPATION : ";@(creature*6+st)/16
      move 0,60
      text "  FRIENDLINESS : ";@(creature*6+st+1)/4
      move 0,70
      text "ENDURANCE/GOLD : ";@(creature*6+st+4)
      move 0,80
      text "      STRENGTH : ";@(creature*6+st+5)
      move 0,90
      text "         (x,y) : (";@(st+creature*6+2);",";@(st+creature*6+3);")"
      move 0,130
6     text "   Do you want to 1) see another"
      move 0,140
      text "                  2) edit this one"
      move 0,150
      text "                  3) continue"
      move 0,160
      text "   choice :";
      input $(st-20),4
      a=$(st-20)
      if (a>3)+(a<1)
       goto 6
      endif
      if a=3
       clear
       gosub 50
       gosub 100
      endif
      if a=2

      endif
      if a=1
       pen 1,0
       rect 0,120,320,200
       pen 1,30
       center 1
5      move 0,130
       text "enter number (0-";mxbad-1;") :";
       input $(st-20),4
       a=$(st-20)
       if (a<0)|(a>mxbad-1)
        goto 5
       endif
       center 0
       creature=a
       goto 4
      endif
     endif
     if (c=65)&(sy>0)
      sy=sy-1
      gosub 100
     else
      if (c=66)&(sy<my-5)
       sy=sy+1
       gosub 100
      else
       if (c=68)&(sx>0)
        sx=sx-1
        gosub 100
       else
        if (c=67)&(sx<mx-5)
         sx=sx+1
         gosub 100
        endif
       endif
      endif
     endif
    endif
    if key=27
     end
    endif
    if key>63
     if key<128
      @((x+y*mx)*2)=key-64
      a=x+y*mx
      gosub 110
     endif
    endif
    if key=9
     hx=x-13
     vy=y-10
     if hx<0 :hx=0:endif
     if vy<0 :vy=0:endif 
     clear
     if hx+26>mx:h=mx:else:h=hx+26:endif
     if vy+20>my:v=my:else:v=vy+20:endif
     pen 1,7
     for xa=hx to h-1
      for ya=vy to v-1
       a=@((xa+ya*mx)*2)
     rem  blit 3,(a%div)*12,(a/div)*10,(xa-hx)*12,(ya-vy)*10,12,10
       transparent 1
       b=@((xa+ya*mx)*2+1)
       if b>0
        b=b-1
        if @(st+b*6)%16=15
         a=@(st+b*6)/16
         if a>0
        rem  blit 3,(a-1)*12,123,(xa-hx)*12,(ya-vy)*10,12,10
         endif
        else
     rem    blit 3,(@(st+b*6)%16)*12,(@(st+b*6+1)%4)*10+81,(xa-hx)*12,(ya-vy)*10,12,10
        endif
       endif
       transparent -1
      next
     next
     blitmode 51
     mod=0
34   ifkey c
      ifmouse ix,iy
      if ix#-1
       if mod=1
    rem    blit 2,(x-hx)*12,(y-vy)*10,(x-hx)*12,(y-vy)*10,12,10
        mod=0
       endif
       x=ix/12+hx
       y=iy/10+vy
       sx=(0~(x-2))_(mx-5)
       sy=(0~(y-2))_(my-5)
      endif
      mod=(mod+1)%2
  rem    blit 2,(x-hx)*12,(y-vy)*10,(x-hx)*12,(y-vy)*10,12,10
     if c=-1:goto 34:endif
     clear
   rem  if mod=1:blit 2,(x-hx)*12,(y-vy)*10,(x-hx)*12,(y-vy)*10,12,10:endif
     blitmode 192
     gosub 100
     gosub 50
    endif
    if key=32
     gosub 56
     a=x+y*mx
     gosub 110
    endif
    if key=33
     clear
     move 10,10
     text "Enter the starting x-coordinates (";sx;") :"
     input $(st-10),10
     x=$(st-10)
     move 10,30
     text "Enter the starting y-coordinates (";sy;") :"
     input $(st-10),10
     y=$(st-10)
     if x>0
       sx=x 
     endif
     if y>0
        sy=y
     endif  
     clear
     move 10,10
     text "Enter filename :";
     input $(st-10),10
     gosub 100
     gosub 50
     a=1
     open a,$(st-10)
     write sx
     write sy
     write mx
     write my
     for i=0 to mx*my-1 step 4
      a=0
      b=1
      for p=0 to 3
       a=a+@((i+p)*2)*b
       b=b*256
      next p
      write a
     next i
     close
     a=1
     open a,":badinfo"
     write mxbad
     for i=0 to mxbad*6-1 step 4
      a=0
      b=1
      for p=0 to 3
       a=a+@(st+i+p)*b
       b=b*256
      next p
      write a
rem type+occupation*16
rem direction+friendliness*4
rem x pos
rem y pos
rem endurance
rem strentgh
rem         friendliness (0-63,0=satan,63=ghandi)
rem         when type=15,weapon 
     next
     close
    endif
   endif
   goto 3

50 for i=0 to 56
  rem    blit 3,(i%8)*12,(i/8)*10,288+(i%3)*12,(i/3)*10,12,10
   next
   for i= 0 to 14
     for x=0 to 3
    rem   blit 3,i*12,x*10+81,240+x*12,i*10,12,10
     next
   next
   for i= 0 to 15
   rem   blit 3,i*12,123,240+(i%4)*12,150+(i/4)*10,12,10
   next
 rem  blit 3,12,70,240,190,84,10
 rem  blit 3,0,0,240,30,96,80
rem    blit 3,0,81,240,110,96,40
rem    blit 3,96,81,240,150,96,40
rem    blit 3,0,123,240,190,96,10
    if land>0
    rem blit 3,(land%8)*12,(land/8)*10,messx+10,messy,12,10
    else
     if guy>0
   rem   blit 3,guy*12,81+dir*10,messx+10,messy,12,10
     else
      if weapon>0
      rem blit 3,weapon*12,123,messx+10,messy,12,10
      endif
     endif
    endif
    return

56   if @((x+y*mx)*2+1)>0
      for i=0 to 5
       @(st+(@((x+y*mx)*2+1)-1)*6+i)=0
      next
      @((x+y*mx)*2+1)=0
     endif
    return

100 for ix=0 to 9
     for iy=0 to 7
      x=sx+ix
      y=sy+iy
      a=x+y*mx
      gosub 110
     next
    next
   return

110 xh=(x-sx)*36
    yh=(y-sy)*54
    b=@(a*2)
    blit 1,(b % 16)*36,(b/16)*54,xh,yh,36,54
    d=@(a*2+1)
111 transparent 1
    if d>0
     d=d-1
     if (@(st+d*6)%16)=15
      b=@(st+d*6)/16-1
      blit 1,504+(b/4)*36,216+(b%4)*54,xh,yh,36,54
     else
       blit 1,(@(st+d*6)%16)*36,216+(@(st+d*6+1)%4)*54,xh,yh,36,54
      endif
     endif
    endif
    transparent -1
   return
