I'll go down through the listing line-by-line.
' flag indicating a valid hit
Set Buffer 256
Set Sprite Buffer 128
'On Error Goto LOWCHIPRAM
Global FH,RIGHT,LEFT,UP,BOTTOM,SELECTED,LGTH,CLICKED,CLICKEDX1,CLICKEDY1
Global LOCKED,CENTERCLICKEDX1,CENTERCLICKEDY1,LOCKEDRIGHT,LOCKEDLEFT,LOCKEDUP,LOCKEDDOWN
Global LASTDIRECTION
LOCKEDRIGHT=False : LOCKEDDOWN=False : LOCKEDLEFT=False : LOCKEDUP=False
' Turn=1 is for player 1 color red, Turn=2 is for player 2 color blue
Global TURN
Global BOARDX,BOARDY,BOARDHEADER,BOARDSTEPS,OFFSETX1,OFFSETY1,OFFSETX2,OFFSETY2
BOARDX=0 : BOARDY=0 : BOARDHEADER=2 : BOARDSTEPS=5 : BOARD=BOARDHEADER+(32*21*BOARDSTEPS)
Here are your first couple of errors. BOARDY should be 1. If BOARDSTEPS=5, you can't use offsets greater than 4 so you'll have to either make the other value stored separately in an array or increase BOARDSTEPS and use a new offset there.
Reserve As Work 15,BOARD
Poke Start(15)+BOARDX,32
Poke Start(15)+BOARDY,21
' Reset the values
LOCKED=False
' Countdown timer for the "Invalid Action!" display
' Hide everything until we have finished drawing:
Auto View Off
Screen Open 0,320,200,64,Lowres
Curs Off
Flash Off : Hide On : Rem Hide mouse pointer
Colour 0,$0
Colour 1,$FFF
Colour 2,$F00
'Colour 3,$FF0
'Colour 4,$FFF
Inverse Off
RIGHT=78 : UP=76 : BOTTOM=77 : LEFT=79 : SELECTED=0
' This colour represents your back IFF pic, just do not use
' colours 0 through 2 in the picture!
Cls 0
CLICKED=True
' Center your rectangular play area:
Global XO
XO=(320-256)/2
EC=35 : F=0 : LGTH=0 : ICOUNTER=0
Proc SETBOARD
Auto View On
DC=-1
'Proc _MISS["All results are suuccessful."]
FD=True : Rem flag for First Dot hit
SELECTEDX1=100
Screen Show 0
Load "dh0:linesformed.abk"
Get Bob Palette $0
Repeat
If Ntsc=0 : Exit : End If
Proc _MISS["?NTSC COMMODORE NOT SUPPORTED! REGION ERROR!"]
Until Ntsc=0
Repeat
Wait Vbl
MC=Mouse Click
K$=Inkey$
SELECTED=Scancode
If Not LOCKED
CLICKEDMAXX1=280 : CLICKEDMAXY1=4
CLICKEDMAXX2=36 : CLICKEDMAXY2=158
Else If LOCKED
If CENTERCLICKEDX1=CLICKEDX1 and CENTERCLICKEDY1=CLICKEDY1
If FINISHED1=0 : CLICKEDMAXX1=(CENTERCLICKEDX1+2) : FINISHED1=1 : End If
If FINISHED2=0 : CLICKEDMAXX2=(CENTERCLICKEDX1-2) : FINISHED2=1 : End If
If FINISHED3=0 : CLICKEDMAXY1=(CENTERCLICKEDY1-2) : FINISHED3=1 : End If
If FINISHED4=0 : CLICKEDMAXY2=(CENTERCLICKEDY1+2) : FINISHED4=1 : End If
LOCKEDDOWN=False : LOCKEDUP=False : LOCKEDLEFT=False : LOCKEDRIGHT=False
Else
If LASTDIRECTION=RIGHT
LOCKEDDOWN=True : LOCKEDUP=True
End If
If LASTDIRECTION=LEFT
LOCKEDDOWN=True : LOCKEDUP=True
End If
If LASTDIRECTION=UP
LOCKEDRIGHT=True : LOCKEDLEFT=True
End If
If LASTDIRECTION=BOTTOM
LOCKEDLEFT=True : LOCKEDRIGHT=True
End If
End If
End If
If CLICKEDX1<CLICKEDMAXX1
If SELECTED=RIGHT and LOCKEDRIGHT=False and SELECTED<>UP and SELECTED<>BOTTOM and SELECTED<>LEFT
Inc RIGHTINC
LASTDIRECTION=RIGHT
If Point(RIGHTINC*8+4+XO,UPINC*8+4)<>2
Proc _MOVE_NEXT_STEP[RIGHTINC,UPINC,XO]
ITISOKTOCLEAR=0
Else If ITISOKTOCLEAR=0
ITISOKTOCLEAR=1
Ink 1
X1=(RIGHTINC-1)*8+4+XO
Y1=UPINC*8+4
CENTERCLICKEDX1=X1 : CENTERCLICKEDY1=Y1
Bar X1-1,Y1-1 To X1+1,Y1+1
End If
End If
End If
If CLICKEDX1>CLICKEDMAXX2
If SELECTED=LEFT and LOCKEDLEFT=False and SELECTED<>RIGHT and SELECTED<>BOTTOM and SELECTED<>UP
Dec RIGHTINC
LASTDIRECTION=LEFT
If Point((RIGHTINC*8+4+XO),UPINC*8+4)<>2
_MOVE_NEXT_STEP[RIGHTINC,UPINC,XO]
ITISOKTOCLEAR=0
Else If ITISOKTOCLEAR=0
ITISOKTOCLEAR=1
Ink 1
X1=(RIGHTINC+1)*8+4+XO
Y1=UPINC*8+4
CENTERCLICKEDX1=X1 : CENTERCLICKEDY1=Y1
Bar X1-1,Y1-1 To X1+1,Y1+1
End If
End If
End If
If CLICKEDY1>CLICKEDMAXY1
If SELECTED=UP and LOCKEDUP=False and SELECTED<>BOTTOM and SELECTED<>LEFT and SELECTED<>RIGHT
Dec UPINC
LASTDIRECTION=UP
If Point((RIGHTINC*8+4+XO),UPINC*8+4)<>2
_MOVE_NEXT_STEP[RIGHTINC,UPINC,XO]
ITISOKTOCLEAR=0
Else If ITISOKTOCLEAR=0
ITISOKTOCLEAR=1
Ink 1
X1=RIGHTINC*8+4+XO
Y1=(UPINC+1)*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
CENTERCLICKEDX1=X1 : CENTERCLICKEDY1=Y1
End If
End If
End If
If CLICKEDY1<CLICKEDMAXY2
If SELECTED=BOTTOM and LOCKEDDOWN=False and SELECTED<>UP and SELECTED<>RIGHT and SELECTED<>LEFT
Inc UPINC
LASTDIRECTION=BOTTOM
If Point((RIGHTINC*8+4+XO),UPINC*8+4)<>2
_MOVE_NEXT_STEP[RIGHTINC,UPINC,XO]
ITISOKTOCLEAR=0
Else If ITISOKTOCLEAR=0
ITISOKTOCLEAR=1
Ink 1
X1=RIGHTINC*8+4+XO
Y1=(UPINC-1)*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
CENTERCLICKEDX1=X1 : CENTERCLICKEDY1=Y1
End If
End If
End If
If SELECTED=64
Proc CLICKED[RIGHTINC,UPINC,XO]
End If
' Simple right-click to exit for this demo:
'
Until MC=%10
End
Procedure CLICKED[X,Y,XO]
Shared CLICKED,PLYRCOLOR,CENTERCLICKEDX1,CENTERCLICKEDY1
Shared LOCKED,FINISHED,FINISHED1,FINISHED2,FINISHED3,FINISHED4
Shared LOCKEDUP,LOCKEDDOWN,LOCKEDLEFT,LOCKEDRIGHT
Shared BOARDSTEPS,BOARDX,BOARDY,BOARD,OFFSETX1,OFFSETY1,OFFSETX2,OFFSETY2
If CLICKED
If LOCKED=True
LOCKED=False : FINISHED1=0 : FINISHED=0 : FINISHED2=0 : FINISHED3=0 : FINISHED4=0
LOCKEDUP=False : LOCKEDDOWN=False : LOCKEDRIGHT=False : LOCKEDLEFT=False
If Point(X,Y)<>2
Ink 2
X1=X*8+4+XO
Y1=Y*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
End If
' Before we perform the final and last step of release the player
' to plot two more dots we will see if two lines can be formed here
For YCOUNTER=0 To 21
For XCOUNTER=0 To 32
Def Fn BOARDARRAY(X,Y,BANKNUM)=BOARDHEADER+((X+Y*(Peek(Start(BANKNUM)))*BOARDSTEPS))
ITEMLOC= Fn BOARDARRAY(XCOUNTER,YCOUNTER,15)
If Peek(ITEMLOC+9)=0
If boardsteps is less than 10 you can't use ITEMLOC+9.
Locate 20,20 : Print " "
Doke ITEMLOC+OFFSETX1,CENTERCLICKEDX1
If you use Doke instead of Poke, you have to use values OFFSETX1 that are even. Where is OFFSETX1 defined? I see that it is allocated as a global but I don't see where the value is set. If it isn't given a value, Amos will just use 0 for everything. This includes all of the field names of the custom type.
Locate 20,20 : Print "CtrClickedX1"+Str$(CENTERCLICKEDX1)
Wait 100
Locate 20,20 : Print " "
Locate 20,20 : Print "Deek X:"+Str$(Deek( Fn BOARDARRAY(XCOUNTER,YCOUNTER,15)+OFFSETX1))
Wait 100
Doke ITEMLOC+OFFSETY1,CENTERCLICKEDY1
Locate 20,20 : Print " "
Locate 20,20 : Print "CtrlickedY1"+Str$(CENTERCLICKEDY1) : Wait 100
Doke ITEMLOC+OFFSETX2,X1
Doke ITEMLOC+OFFSETY2,Y1
Locate 20,20 : Print " "
Locate 20,20 : Print "Deek Y:"+Str$(Deek( Fn BOARDARRAY(XCOUNTER,YCOUNTER,15)+OFFSETY1))
Wait 100 : Locate 20,20 : Print " "
Locate 20,20 : Print "X1 "+Str$(X1)+" Y1 "+Str$(Y1)
Wait 100
Locate 20,20 : Print " "
Locate 20,20 : Print "Deek X1:"+Str$(Deek( Fn BOARDARRAY(XCOUNTER,YCOUNTER,15)+OFFSETX2))+" Deek Y1 "+Str$(Deek( Fn BOARDARRAY(XCOUNTER,YCOUNTER,15)+OFFSETY2))+""
LOCKED=False
Goto SKIPPED : End If
Next XCOUNTER
Next YCOUNTER
End If
Ink 2
If Point(X,Y)<>2
X1=X*8+4+XO
Y1=Y*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
LOCKED=True : CENTERCLICKEDX1=X1 : CENTERCLICKEDY1=Y1
End If
SKIPPED:
Else
Proc _MISS["Invalid action!"]
End If
End Proc
Procedure _MOVE_NEXT_STEP[X,Y,XO]
' Move at the new location specificed
Shared SELECTED,RIGHT,LEFT,UP,BOTTOM,CLICKEDX1,CLICKEDY1
EIGHT=8 : FOUR=4 : NUMBERONE=1
If SELECTED=RIGHT and SELECTED<>LEFT and SELECTED<>UP and SELECTED<>BOTTOM
Ink 7
X3=X*EIGHT+FOUR+XO
Y3=Y*EIGHT+FOUR
CLICKEDX1=X3 : CLICKEDY1=Y3
Bar X3-NUMBERONE,Y3-NUMBERONE To X3+NUMBERONE,Y3+NUMBERONE
Proc _CLEARRIGHT[XO,X,Y]
End If
If SELECTED=UP and SELECTED<>RIGHT and SELECTED<>LEFT and SELECTED<>BOTTOM
Ink 7
X3=X*EIGHT+FOUR+XO
Y3=Y*EIGHT+FOUR
Bar X3-NUMBERONE,Y3-NUMBERONE To X3+NUMBERONE,Y3+NUMBERONE
' Clear the old location all together
CLICKEDX1=X3 : CLICKEDY1=Y3
Proc _CLEARUP[XO,X,Y]
End If
If SELECTED=LEFT and SELECTED<>RIGHT and SELECTED<>BOTTOM and SELECTED<>UP
Ink 7
X3=X*EIGHT+FOUR+XO
Y3=Y*EIGHT+FOUR
Bar X3-NUMBERONE,Y3-NUMBERONE To X3+NUMBERONE,Y3+NUMBERONE
' Clear the old location all together
CLICKEDX1=X3 : CLICKEDY1=Y3
Proc _CLEARLEFT[XO,X,Y]
End If
If SELECTED=BOTTOM and SELECTED<>UP and SELECTED<>LEFT and SELECTED<>RIGHT
Ink 7
X3=X*EIGHT+FOUR+XO
Y3=Y*EIGHT+FOUR
Bar X3-NUMBERONE,Y3-NUMBERONE To X3+NUMBERONE,Y3+NUMBERONE
CLICKEDX1=X3 : CLICKEDY1=Y3
' Clear the old location all together
Proc _CLEARBOTTOM[XO,X,Y]
End If
SELECTEDX1=X3 : SELECTEDY1=Y3
End Proc
Procedure _CLEARRIGHT[XO,X,Y]
Shared CLICKEDX1,CLICKEDY1
If Point(CLICKEDX1-8,CLICKEDY1)<>2
Ink 1
X=X-1
X1=X*8+4+XO
Y1=Y*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
End If
End Proc
Procedure _CLEARLEFT[XO,X,Y]
Shared CLICKEDX1,CLICKEDY1
If Point(CLICKEDX1+8,CLICKEDY1)<>2
Ink 1
X=X+1
X1=X*8+4+XO
Y1=Y*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
End If
End Proc
Procedure _CLEARBOTTOM[XO,X,Y]
Shared CLICKEDX1,CLICKEDY1
If Point(CLICKEDX1,CLICKEDY1-8)<>2
Ink 1
Y=Y-1
X1=X*8+4+XO
Y1=Y*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
End If
End Proc
Procedure _CLEARUP[XO,X,Y]
Shared CLICKEDX1,CLICKEDY1
If Point(CLICKEDX1,CLICKEDY1+8)<>2
Ink 1
Y=Y+1
X1=X*8+4+XO
Y1=Y*8+4
Bar X1-1,Y1-1 To X1+1,Y1+1
End If
End Proc
Procedure _MISS[WORDHERE$]
Shared LGTH
ICOUNTER=0
LGTH=Len(WORDHERE$)*-1
Repeat
For I=320 To(LGTH)*10 Step -1
Ink 2
Text I,195,WORDHERE$
For X=0 To 300 : Next
Next I
Inc ICOUNTER
Until ICOUNTER=1
End Proc
LOWCHIPRAM:
If Chip Free<30080
Repeat
Proc _MISS["?CHIP RAM IS TOO LOW!"]
Until Chip Free>50080
End If
Screen Open 0,320,200,8,Lowres
Auto View On : Curs Off : Hide On
Colour 0,$0 : Colour 1,$FFF : Colour 2,$F00 : Colour 3,$FF0 : Colour 4,$FFF
Screen Show 0 :
Repeat
Proc _MISS["Reason for error: "+Err$(Errn)+"."]
Until X=1
Procedure SETBOARD
Shared XO
Box XO+0,0 To XO+255,167
' This bar represents your background pic
Ink 3
Box XO+1,1 To XO+254,166
For X=0 To 31
For Y=0 To 20
X1=X*8+4+XO
Y1=Y*8+4
Ink 1
Bar X1-1,Y1-1 To X1+1,Y1+1
Ink 0
Box X1-2,Y1-2 To X1+2,Y1+2
Next Y
Next X
End Proc