{$ifdef UniPas}

  procedure GotoXY(X, Y: ShortCard);
    code $5f, $d, 15, { SNCI 15 }
	 $30,	      { tsx }
	 $ee, 0,      { ldx x }
	 $31, $31,    { ins, ins }
	 $33, $31,    { plb, ins }
	 $32, $31,    { pla, ins }
	 $4a,	      { deca }
	 $5a,	      { decb }
	 $3f, $15,    { int $15 }
	 $6e, 0;      { jmp x }

  function KeyPressed: boolean;
    code $5f, $d, 17,	{	SNCI	17	}
	 $3f, $10,	{	int	$10	}
	 $5f,		{	clrb		}
	 $4c,		{	inca		}
	 $27, 2,	{	beq	NoKey	}
	 $86, 1,	{	lda	#1	}
	 $30,		{ NoKey tsx		}
	 $ee, 0,	{	ldx	x, 0	; get return address }
	 $31, $31,	{	ins : ins	; pop return address }
	 $37, $36,	{	phb : pha	; Neg Bsex boolean   }
	 $6e, 0;	{	jmp	x, 0	; emulate rts	     }

  function ReadKey: char;
    code $5f, $d, 12,	{	SNCI	12	}
	 $3f, $20,	{	int	$20	}
	 $5f,		{	clrb		}
	 $30,		{	tsx		}
	 $ee, 0,	{	ldx	x, 0	; get return address }
	 $31, $31,	{	ins : ins	; pop return address }
	 $37, $36,	{	phb : pha	; Neg Bsex boolean   }
	 $6e, 0;	{	jmp	x, 0	; emulate rts	     }

  procedure Delay(N: word);
    code $5f, $d, 25, {     SNCI 25 }
	 $30,	      {     tsx }
	 $ee, 0,      {     ldx x }
	 $31, $31,    {     ins, ins }
	 $32, $33,    {     pla, plb }
	 $36,	      {loop pha }
	 $86, 166,    {     lda #166 }
	 $4a,	      {wait deca }
	 $26, $fd,    {     bne wait }
	 $32,	      {     pla }
	 $4d,	      {     tsta }
	 $26, $03,    {     bne Not0}
	 $5a,	      {     decb }
	 $2b, $03,    {     bmi end }
	 $4a,	      {Not0 deca }
	 $20, $f0,    {     bra loop }
	 $6e, 0;      {end  jmp x }

  procedure TextColor(Attribute: byte);
    code $5f, $d, 11, { SNCI 11 }
	 $30,	      { tsx }
	 $ee, 0,      { ldx x }
	 $31, $31,    { ins, ins }
	 $33, $31,    { plb, ins }
	 $3f, $16,    { int $16 }
	 $6e, 0;      { jmp x }

  procedure TextCo40;
    code $5f, $d, 6,  { SNCI 6  }
         $4f,         { clra    }
         $c6, $70,    { ldb #$70}
         $3f, $12,    { int $12 }
         $39;         { rts     }

  procedure TextBW40;
    code $5f, $d, 6,  { SNCI 6  }
         $4f,         { clra    }
         $c6, $00,    { ldb #$00}
         $3f, $12,    { int $12 }
         $39;         { rts     }

  procedure PlayNote(Note: word; length: word);
    code $5f, $d, 24, { SNCI 24  }
	 $30,	      { tsx      }
	 $ee, 0,      { ldx x, 0 }
         $df, $b0,    { stx $b0  }
         $31, $31,    { ins ins  }
         $32,         { pla      }
         $33,         { plb      }
         $36,         { pha      }
         $37,         { phb      }
         $30,         { tsx      }
         $ee, 0,      { ldx x, 0 }
         $31, $31,    { ins ins  }
         $32,         { pla      }
         $33,         { plb      }
         $3f, $6f,    { int $6f  }
         $de, $b0,    { ldx $b0  }
	 $6e, 0;      { jmp x    }

  function WhereX: ShortCard;
    code $5f, $d, 14, { SNCI ??   }
         $32, $33,    { pla; plb; }
         $37, $36,    { phb; pha; }
         $37, $36,    { phb; pha; }
         $3f, $14,    { int $14   }
         $30,         { tsx       }
         $6f, $03,    { clr  x, 3 }
         $a7, $02,    { sta  x, 2 }
         $39;         { rts       }

  function WhereY: ShortCard;
    code $5f, $d, 14, { SNCI ??   }
         $32, $33,    { pla; plb; }
         $37, $36,    { phb; pha; }
         $37, $36,    { phb; pha; }
         $3f, $14,    { int $14   }
         $30,         { tsx       }
         $6f, $03,    { clr  x, 3 }
         $e7, $02,    { stb  x, 2 }
         $39;         { rts       }

  procedure ClrEol;
  begin
  write(message, #24);
  end; { ClrEol }

  procedure ClrScr;
  begin
  write(message, #12);
  end; { ClrScr }

{$endif}