    .nolist
    #include "ion.inc"
    #include "keys.inc"
    .list

#ifdef TI83P
    .org    progstart-2
    .db $BB,$6D
#else
    .org    progstart
#endif
    ret
    jr  nc,FirstBegin
    .db "Dots v1.0 - TCPA",0

_textShadow = saferam3

board   =   _textShadow
ThinkMem    =   saferam1


;width = _textShadow+60
;height = _textShadow+61
Coords = _textShadow+62
OldCoords = _textShadow+64
;Mode = _textShadow+66
Player = _textShadow+67
Order = _textShadow+68
Flag = _textShadow+69
Exist01Flag = _textShadow+70
Exist3Flag = _textShadow+71
NumOfS = _textShadow+72
NumOfFS = _textShadow+73
Points = _textShadow+74
Menu = _textShadow+76
Menu2 = _textShadow+77

FirstBegin:
    bcall(_clrscrf)
    res appTextSave,(iy+appflags)
    ld hl,_textShadow
    ld d,h
    ld e,l
    inc de
    ld (hl),0
    ld bc,80
    ldir

SecondBegin:
    call GameText
MenuRoutine:
    ld a,(Menu)
    or a
    jr nz,NotStart
    set textInverse,(iy+textflags)
NotStart:
    ld hl,36*256+37
    ld (pencol),hl
    ld hl,StartTxt
    bcall(_vputs)
    res textInverse,(iy+textflags)
    ld a,(Menu)
    dec a
    jr nz,NotOptions
    set textInverse,(iy+textflags)
NotOptions:
    ld bc,43*256+33
    ld (pencol),bc
    bcall(_vputs)
    res textInverse,(iy+textflags)

    ld bc,21*256+0
    ld (pencol),bc
    bcall(_vputs)               ;Game mode
    ld bc,28*256+1
    ld (pencol),bc
    bcall(_vputs)               ;board size

    ld bc,21*256+41
    ld (pencol),bc
    ld a,(Mode)
    or a
    jr z,HumanvsHuman
    ld hl,TI86
HumanvsHuman:
    bcall(_vputs)

    ld hl,28*256+41
    ld (pencol),hl
    ld a,(width)
    add a,'0'
    bcall(_vputmap)
    ld a,'x'
    bcall(_vputmap)
    ld a,(height)
    add a,'0'
    bcall(_vputmap)

StartLoop:
    bcall(_getcsc)
    cp G_2nd
    jr z,SecondPressed
    cp G_DOWN
    jr z,ChangeMenu     ;Size
    cp G_UP
    jr z,ChangeMenu
    cp G_ENTER
    jr z,SecondPressed
    cp G_MODE
    jp z,Quit
    jr StartLoop

ChangeMenu:
    ld a,(Menu)
    xor 1
    ld (Menu),a
    jp MenuRoutine

SecondPressed:
    ld a,(Menu)
    or a
    jp z,Begin
                ;Fall through
Options:
    bcall(_clrlcdf)
    call GameText
Options2:
    ld hl,21*256+0
    ld (pencol),hl
    ld hl,ModeTxt
    ld a,(Menu2)
    or a
    jr nz,ONotMode
    set textInverse,(iy+textflags)
ONotMode:
    bcall(_vputs)
    res textInverse,(iy+textflags)
    ld hl,28*256+16
    ld (pencol),hl
    ld hl,HeightTxt
    ld a,(Menu2)
    dec a
    jr nz,ONotHeight
    set textInverse,(iy+textflags)
ONotHeight:
    bcall(_vputs)
    res textInverse,(iy+textflags)
    ld bc,35*256+20
    ld (pencol),bc
    ld a,(Menu2)
    cp 2
    jr nz,ONotWidth
    set textInverse,(iy+textflags)
ONotWidth:
    bcall(_vputs)
    res textInverse,(iy+textflags)
    ld bc,42*256+31
    ld (pencol),bc
    ld a,(Menu2)
    cp 3
    jr nz,ONotMain
    set textInverse,(iy+textflags)
ONotMain:
    bcall(_vputs)
    res textInverse,(iy+textflags)

    ld hl,21*256+42
    ld (pencol),hl
    ld hl,Human
    ld a,(Mode)
    or a
    jr z,Optionsskiplittle
    ld hl,TI86
Optionsskiplittle:
    bcall(_vputs)
    ld hl,28*256+42
    ld (pencol),hl
    ld a,(Height)
    add a,'0'
    bcall(_vputmap)
    ld hl,35*256+42
    ld (pencol),hl
    ld a,(Width)
    add a,'0'
    bcall(_vputmap)
OptionsKeyLoop:
    bcall(_getcsc)
    dec a
    jr z,ODownPressed
    dec a
    jr z,OLeftPressed
    dec a
    jr z,ORightPressed
    dec a
    jr z,OUpPressed
    cp G_ENTER-4
    jr z,ReturnToMain
    cp G_2nd-4
    jr z,ReturnToMain
    jr OptionsKeyLoop

ReturnToMain:
    bcall(_clrlcdf)
    jp SecondBegin

ODownPressed:
    ld a,(Menu2)
    cp 3
    jr z,OptionsKeyLoop
    inc a
    ld (Menu2),a
    jp Options2

OUpPressed:
    ld a,(Menu2)
    or a
    jr z,OptionsKeyLoop
    dec a
    ld (Menu2),a
    jp Options2

OLeftPressed:
    ld a,(Menu2)
    or a
    jr z,ChangeMode
    dec a
    jr z,DecHeight
    jr DecWidth

ORightPressed:
    ld a,(Menu2)
    or a
    jr z,ChangeMode
    dec a
    jr z,IncHeight

IncWidth:
    ld a,(width)
    cp 9
    jr z,OptionsKeyLoop
    inc a
    ld (width),a
    jp Options2

ChangeMode:
    ld a,(Mode)
    xor 1
    ld (Mode),a
    jp Options2

DecHeight:
    ld a,(height)
    cp 3
    jr z,OptionsKeyLoop
    dec a
    ld (height),a
    jp Options2

DecWidth:
    ld a,(width)
    cp 3
    jr z,OptionsKeyLoop
    dec a
    ld (width),a
    jp Options2

IncHeight:
    ld a,(height)
    cp 6
    jp z,OptionsKeyLoop
    inc a
    ld (height),a
    jp Options2


Begin:
    bcall(_clrlcdf)
    ld hl,plotsscreen
    ld d,h
    ld e,l
    inc de
    ld (hl),0
    ld bc,767
    ldir
    call DrawDots
    ld hl,0
    ld (Coords),hl
    ld (OldCoords),hl
    xor a
    ld (Flag),a
    inc a
    ld (Player),a
    ld bc,$0101
    ld de,marker
    call PutSprite
    call UpdateMenu


MainLoop:
    ld hl,(Coords)
    ld (OldCoords),hl
    ld a,(Mode)
    or a
    jr z,GetInput
    ld a,(Order)
    ld b,a
    ld a,(Player)
    cp b
    jp z,CalcsTurn
GetInput:
    bcall(_getcsc)
    dec a
    jr z,MoveDown
    dec a
    jr z,MoveLeft
    dec a
    jr z,MoveRight
    dec a
    jr z,MoveUp
    cp G_MODE-4
    jp z,FirstBegin         ;Quit
    cp G_2nd-4
    jr z,DrawLineMode
    jr GetInput

MoveDown:
    ld a,(height)
    ld b,a
    ld a,(Coords+1)
    inc a
    cp b
    jr z,GetInput
    ld (Coords+1),a
    jp PutMarker

MoveLeft:
    ld a,(Coords)
    or a
    jr z,GetInput
    dec a
    ld (Coords),a
    jp PutMarker

MoveRight:
    ld a,(width)
    ld b,a
    ld a,(Coords)
    inc a
    cp b
    jr z,GetInput
    ld (Coords),a
    jp PutMarker

MoveUp:
    ld a,(Coords+1)
    or a
    jr z,GetInput
    dec a
    ld (Coords+1),a
    jp PutMarker

DrawLineMode:
    call PutPen
DLMKLoop:
    bcall(_getcsc)
    dec a
    jr z,DrawDown
    dec a
    jr z,DrawLeft
    dec a
    jr z,DrawRight
    dec a
    jr z,DrawUp
    cp G_MODE-4
    jp z,FirstBegin             ;Quit
    cp G_2nd-4
    jr nz,DLMKLoop

EndDrawMode2:
    call PutPen
    ld a,4
    ld (NumberOfChecks),a
    jp MainLoop ;GetInput

DrawDown:
    call CalcAddr
    bit 0,(hl)
    jr nz,DLMKLoop
    set 0,(hl)
    ld a,(Coords+1) ;y
    inc a
    ld b,a
    ld a,(height)
    cp b
    jp z,DrawDLine
    add hl,de
    set 1,(hl)
    jp DrawDLine

DrawLeft:
    call CalcAddr
    bit 3,(hl)
    jr nz,DLMKLoop
    set 3,(hl)
    ld a,(Coords)   ;x
    or a
    jp z,DrawLLine
    dec hl
    set 2,(hl)
    jp DrawLLine

DrawRight:
    call CalcAddr
    bit 2,(hl)
    jr nz,DLMKLoop
    set 2,(hl)
    ld a,(Coords)   ;x
    inc a
    ld b,a
    ld a,(width)
    cp b
    jp z,DrawRLine
    inc hl
    set 3,(hl)
    jp DrawRLine

DrawUp:
    call CalcAddr
    bit 1,(hl)
    jr nz,DLMKLoop
    set 1,(hl)
    ld a,(Coords+1) ;y
    or a
    jp z,DrawULine
    and a
    sbc hl,de
    set 0,(hl)
    jp DrawULine


DrawDLine:
    call CalculateLine
    add hl,de
CommonUD:
    ld a,255
    ld (hl),a
    jp EndDrawMode

DrawLLine:
    call CalculateLine
CommonLR:
    ld de,12
    ld b,7
DrawLLLoop:
    ld a,%10000000
    add hl,de
    xor (hl)
    ld (hl),a
    djnz DrawLLLoop
    jp EndDrawMode

DrawRLine:
    call CalculateLine
    inc hl
    jr CommonLR

DrawULine:
    call CalculateLine
    jr CommonUD

CalculateLine:          ;Makes hl point to the square in videomem
    ld hl,plotsscreen+85-96 ;$FC71
    ld de,96
    ld bc,(Coords)
    inc b
CLLoop:
    add hl,de
    djnz CLLoop
    add hl,bc
    ret


CalcAddr:           ;makes hl point to the square pointed to by the coords
    ld bc,(Coords)  ;c=x b=y
    ld hl,board     ;y=coords+1
    ld a,(width)
    ld e,a
    ld d,0
    and a
    sbc hl,de
    inc b
CALoop:
    add hl,de
    djnz CALoop
    add hl,bc
    ret             ;Returns with de=amount to add to get to the next line

DrawDots:
    ld hl,plotsscreen+85    ;$FC71
    ld a,(height)
    inc a
    ld b,a
DDLoop1:
    push bc
    ld a,(width)
    ld c,a
    inc a
    ld b,a
    ld a,11
    sub c
    ld e,a
    ld d,0
    ld a,%10000000
DDLoop2:
    ld (hl),a
    inc hl
    djnz DDLoop2
    add hl,de
    ld de,84        ;112
    add hl,de
    pop bc
    djnz DDLoop1
    ret

Quit:
    set appTextSave,(iy+appflags)
    ret

CalcsTurn:
    xor a
    ld (Exist3Flag),a
    ld (Exist01Flag),a
    call NumberOfSquares
    ld (NumOfS),a
    ld b,a
    ld hl,board     ;Coords
                    ;y=coords+1
QuestFor013:
    ld a,(hl)
    and %00001111
    or a
    jp z,Set01Flag2
    call CheckFor3
    call CheckFor1
    inc hl
    djnz QuestFor013

SkipTheRest1:
    ld de,$0000     ;d=y e=x
    ld c,d
    ld hl,ThinkMem
    push hl
    ld a,(NumOfS)
    ld b,a
    ld hl,board
WriteCoords:
    ld a,(Exist3Flag)
    or a
    jr nz,WeHaveA3
    ld a,(Exist01Flag)
    or a
    jr nz,WeHaveA0Or1
    ld a,(hl)
    and %00001111
    cp %00001100
    jp z,WriteCoord
    cp %00001010
    jp z,WriteCoord
    cp %00000110
    jp z,WriteCoord
    cp %00001001
    jp z,WriteCoord
    cp %00000101
    jp z,WriteCoord
    cp %00000011
    jp z,WriteCoord
    call IncreaseCoord
    djnz WriteCoords
    jp CoordsAreWritten

WeHaveA0Or1:    
    ld a,(hl)
    and %00001111
    or a
    jp z,WriteCoord
    cp %00000001
    jp z,WriteCoord
    cp %00000010
    jp z,WriteCoord
    cp %00000100
    jp z,WriteCoord
    cp %00001000
    jp z,WriteCoord
    call IncreaseCoord
    djnz WriteCoords
    jp CoordsAreWritten

WeHaveA3:
    ld a,(hl)
    and %00001111
    cp %00001110
    jp z,WriteCoord
    cp %00001101
    jp z,WriteCoord
    cp %00001011
    jp z,WriteCoord
    cp %00000111
    jp z,WriteCoord
    call IncreaseCoord
    djnz WriteCoords




CoordsAreWritten:
    call Delay
    pop hl              ;EndOfThinkMem
    ld bc,ThinkMem
    and a
    sbc hl,bc
    ld a,l
    ;or a
    ;jp z,_jforcecmdnochar
    sra a
    call Random
    add a,a
    ld hl,ThinkMem
    ld c,a
    ld b,0
    add hl,bc
    ld a,(hl)
    ld (Coords),a
    inc hl
    ld a,(hl)
    ld (Coords+1),a

    ld bc,(OldCoords)
    ld de,marker
    inc b
    inc c
    call PutSprite
    ld bc,(Coords)
    ld de,marker
    inc b
    inc c
    call PutSprite

    ld hl,(Coords)
    ld (OldCoords),hl

    call PutPen
    call Delay

GetLRUD:
    ld a,4
    call Random
    or a
    jr z,TestLeft
    cp 1
    jr z,TestRight
    cp 2
    jr z,TestUp
    ;jr TestDown

TestDown:
    call CalcAddr
    bit 0,(hl)
    jr nz,GetLRUD
    ld a,(Difficulty)
    cp 1
    call z,LevelTwoCheckDown
    set 0,(hl)
    ld a,(Coords+1) ;y
    inc a
    ld b,a
    ld a,(height)
    cp b
    jp z,DrawDLine
    add hl,de
    set 1,(hl)
    jp DrawDLine

TestLeft:
    call CalcAddr
    bit 3,(hl)
    jr nz,GetLRUD
    ld a,(Difficulty)
    cp 1
    call z,LevelTwoCheckLeft
    set 3,(hl)
    ld a,(Coords)   ;x
    or a
    jp z,DrawLLine
    dec hl
    set 2,(hl)
    jp DrawLLine

TestRight:
    call CalcAddr
    bit 2,(hl)
    jr nz,GetLRUD
    ld a,(Difficulty)
    cp 1
    call z,LevelTwoCheckRight
    set 2,(hl)
    ld a,(Coords)   ;x
    inc a
    ld b,a
    ld a,(width)
    cp b
    jp z,DrawRLine
    inc hl
    set 3,(hl)
    jp DrawRLine

TestUp:
    call CalcAddr
    bit 1,(hl)
    jr nz,GetLRUD
    ld a,(Difficulty)
    cp 1
    call z,LevelTwoCheckUp
    set 1,(hl)
    ld a,(Coords+1) ;y
    or a
    jp z,DrawULine
    and a
    sbc hl,de
    set 0,(hl)
    jp DrawULine


LevelTwoCheckDown:
    ld a,(Coords+1) ;y
    inc a
    ld b,a
    ld a,(height)
    cp b
    ret z
    push hl
    add hl,de

Controlling:
    ld a,(hl)
    and %00001111
    cp %00001100
    jr z,NewDir
    cp %00001010
    jr z,NewDir
    cp %00000110
    jr z,NewDir
    cp %00001001
    jr z,NewDir
    cp %00000101
    jr z,NewDir
    cp %00000011
    jr z,NewDir
    pop hl
    ret

LevelTwoCheckLeft:
    ld a,(Coords)   ;x
    or a
    ret z
    push hl
    dec hl
    jr Controlling

LevelTwoCheckRight:
    ld a,(Coords)   ;x
    inc a
    ld b,a
    ld a,(width)
    cp b
    ret z
    push hl
    inc hl
    jr Controlling


LevelTwoCheckUp:
    ld a,(Coords+1) ;y
    or a
    ret z
    push hl
    and a
    sbc hl,de
    jr Controlling

NewDir:
    pop hl
    ld a,(NumberOfChecks)
    dec a
    or a
    ret z
    ld (NumberOfChecks),a
    pop hl                  ;Get rid of garbage address
    jp GetLRUD


Random:                ; Creates a random number 0 <= x < A
    ld b,a
    ld a,r
    add a,a
    ld hl,0
    ld d,0
    ld e,a
RMul:
    add hl,de
    djnz RMul
    ld a,h
    ret


WriteCoord:
    pop hl
    ld (hl),e
    inc hl
    ld (hl),d
    inc hl
    push hl
    push bc
    ld b,0
    ld hl,board
    add hl,bc
    pop bc
    call IncreaseCoord
    dec b
    jp nz,WriteCoords
    jp CoordsAreWritten

IncreaseCoord:
    inc c
    inc hl
    ld a,(width)
    dec a
    cp e
    jr z,NextLineOfS
    inc e
    ret
NextLineOfS:
    inc d
    ld e,0
    ret

CheckFor1:
    cp %00000001
    jr z,Set01Flag
    cp %00000010
    jr z,Set01Flag
    cp %00000100
    jr z,Set01Flag
    cp %00001000
    ret nz
Set01Flag:
    pop de          ;Remove call
Set01Flag2:
    ld a,1
    ld (Exist01Flag),a
    inc hl
    dec b
    jp nz,QuestFor013
    jp SkipTheRest1

CheckFor3:
    cp %00001110
    jr z,Set3Flag
    cp %00001101
    jr z,Set3Flag
    cp %00001011
    jr z,Set3Flag
    cp %00000111
    ret nz
Set3Flag:
    ld a,1
    ld (Exist3Flag),a
    pop hl              ;Remove the call
    jp SkipTheRest1




NumberOfSquares:
    ld a,(width)
    ld b,a
    ld a,(height)
    ld c,a
    xor a
NOSLoop:
    add a,c
    djnz NOSLoop
    ret



EndDrawMode:
    call NumberOfSquares
    ld b,a
    ld hl,board
CheckForFullLoop:
    ld a,(hl)
    bit 7,a
    jr nz,SkipSomething
    and %00001111
    cp %00001111
    call z,FullSquare
SkipSomething:
    inc hl
    djnz CheckForFullLoop
    call UpdateMenu
    jp EndDrawMode2

FullSquare:
    push bc
    push hl
    set 7,a
    ld (hl),a
    ld bc,_textShadow
    ld de,0
    and a
    sbc hl,bc
    ld a,(width)
    ld c,a
    ld a,l
FullSquareCalc:
    cp c
    jr c,TakeItEasy
    inc d               ;y
    sub c
    jr FullSquareCalc
TakeItEasy:
    inc e           ;x
    dec a
    jr nz,TakeItEasy

    ld b,d
    ld c,e
    inc b
    inc c
    ld de,circle
    ld a,(Player)
    or a
    jr nz,LoadCross
Return:
    call PutSprite
    ld hl,Points
    ld a,(Player)
    ld c,a
    ld b,0
    add hl,bc
    inc (hl)
    ld a,1
    ld (Flag),a
    call NumberOfSquares
    ld b,a
    ld a,(NumOfFS)
    inc a
    ld (NumOfFS),a
    cp b
    jr z,FullBoard
    pop hl
    pop bc
    ret

LoadCross:
    ld de,cross
    jr Return

GameText:
    ld hl,$0000
    ld (currow),hl
    ld hl,Text
    set textInverse,(iy+textflags)
    bcall(_puts)                ;Dots
    res textInverse,(iy+textflags)
    ld bc,8*256+28
    ld (pencol),bc
    bcall(_vputs)               ;a tcpa game
    ld bc,14*256+25
    ld (pencol),bc
    bcall(_vputs)               ;tcpa.calc.org

    ld bc,50*256+12
    ld (pencol),bc
    bcall(_vputs)               ;Made by
    ld bc,56*256+17
    ld (pencol),bc
    bcall(_vputs)               ;andreas@calc.org
    ret


FullBoard:
    pop hl
    pop hl
    pop hl
    call UpdateMenu
    call BlackBar
    call PutPen
    ld a,(Points)
    ld b,a
    ld a,(Points+1)
    cp b
    jr z,ItsADraw
    jr c,FirstWins
SecondWins:
    ld a,(Mode)         ;0=human vs. human 1=human vs. calc
    or a
    jr nz,YouWin
    ld hl,Win2txt
    jr DisplayWintxt
YouWin
    ld hl,YouWintxt
    jr DisplayWintxt
ItsADraw:
    ld hl,Drawtxt
    jr DisplayWintxt
FirstWins:
    ld a,(Mode)
    or a
    jr nz,CalcWin
    ld hl,Win1txt
    jr DisplayWintxt
CalcWin:
    ld hl,CalcWintxt

DisplayWintxt:
    ld bc,$0203
    ld (currow),bc
    set textInverse,(iy+textflags)
    bcall(_puts)
    res textInverse,(iy+textflags)
WinLoop:
    bcall(_getcsc)
    or a
    jr z,WinLoop
    jp FirstBegin

BlackBar:
    ld hl,plotsscreen+(12*23)
    ld a,255
    ld b,120
BBLoop:
    ld (hl),a
    inc hl
    djnz BBLoop
    call ionFastCopy
    ret

UpdateMenu:
    set textwrite,(iy+sgrflags)
    ld a,(Flag)
    or a
    jr nz,SkipSwitch
    ld a,(Player)
    xor 1
    ld (Player),a
SkipSwitch:
    xor a
    ld (Flag),a
    ld a,(Player)
    or a
    jr nz,SkipInvert1
    set textInverse,(iy+textflags)
SkipInvert1:
    ld hl,0*256+85
    ld (pencol),hl
    ld hl,Player1txt
    bcall(_vputs)
    res textInverse,(iy+textflags)
    ld a,(Player)
    or a
    jr z,SkipInvert2
    set textInverse,(iy+textflags)
SkipInvert2:
    ld bc,30*256+85
    ld (pencol),bc
    bcall(_vputs)
    res textInverse,(iy+textflags)
    ld hl,8*256+85
    ld (pencol),hl
    ld a,(Points)
    call DispA
    ld hl,38*256+85
    ld (pencol),hl
    ld a,(Points+1)
    call DispA
    call ionFastCopy
    res textwrite,(iy+sgrflags)
    ret
    

DispA:
    bcall(_setxxop1)
    ld a,2
    bcall(_dispop1a)
    ret

Delay:
    ei
    ld b,$90
DelayLoop:
    halt
    djnz DelayLoop
    ret

PutMarker:
    ld bc,(OldCoords)
    ld de,marker
    inc b
    inc c
    call PutSprite
    ld bc,(Coords)
    ld de,marker
    inc b
    inc c
    call PutSprite
    jp MainLoop

PutPen:
    ld b,7
    ld c,10
    ld de,pen
    jp PutSprite

; de = sprite
; b,c = y,x

PutSprite:
    push de
    ld hl,plotsscreen-96
    inc b
    ld de,96
PSLoop:
    add hl,de
    djnz PSLoop
    add hl,bc
    pop de
    ld b,8
PSLoop2:
    push bc
    ld bc,12
    ld a,(de)
    xor (hl)
    ld (hl),a
    inc de
    add hl,bc
    pop bc
    djnz PSLoop2
    call ionFastCopy
    ret


Difficulty:
    .db 1

NumberOfChecks:
    .db 4

Player1txt:
    .db " P 1",0
Player2txt:
    .db " P 2",0

Text:
    .db "   Dots  v1.0   ",0
TCPA:
    .db "a TCPA game",0
Web:
    .db "tcpa.calc.org",0

Author:
    .db "Made by Andreas Finne",0
Mail:
    .db "andreas@calc.org",0


StartTxt:
    .db " START",0
OptionsTxt:
    .db " OPTIONS",0

ModeTxt:
    .db " Game mode:",0
Sizetxt:
    .db "Board size:",0

Human:
    .db "Human vs Human",0
TI86:
    .db "Human vs Calc      ",0

HeightTxt:
    .db " Height:",0
WidthTxt:
    .db " Width:",0
MainTxt:
    .db " Main menu",0

Win1txt:
    .db "Player 1 wins ",0
Win2txt:
    .db "Player 2 wins ",0
CalcWintxt:
    .db "The calc wins ",0
YouWintxt:
    .db "   You win    ",0
Drawtxt:
    .db " It's a draw  ",0

cross:
    .db %00000000
    .db %00100010
    .db %00010100
    .db %00001000
    .db %00010100
    .db %00100010
    .db %00000000
    .db %00000000

width:
    .db 5
height:
    .db 5
Mode:
    .db 0

circle:
    .db %00000000
    .db %00011100
    .db %00100010
    .db %00100010
    .db %00100010
    .db %00011100
    .db %00000000
    .db %00000000

marker:
    .db %00000000
    .db %00000000
    .db %00011100
    .db %00011100
    .db %00011100
    .db %00000000
    .db %00000000
    .db %00000000

pen:
    .db %00001100
    .db %00010010
    .db %00100001
    .db %01000001
    .db %10000010
    .db %10000100
    .db %11001000
    .db %11110000

.end
