← Back to team overview

sslug-teknik team mailing list archive

Vedr: Er du haj til borland pascal 7.0 i dos og c i Linux??

 

p2c er din ven:

"p2c <pascal_file>"

Du skal nok fidle lidt med koden der var en del warnings - vedlagt:

*******************************klip
/* Output from p2c, the Pascal-to-C translator */
/* From input file "test.p" */


/*###################################################
  # LCDTekst T6963 Routines in borland pascal 7.0   #
  ###################################################*/


#include <p2c/p2c.h>


#define LCDTEKST_G
#include "lcdtekst.h"


#ifndef GRAPH_H
#include "graph.h"
#endif


typedef enum {
  H, L
} HiLo;
typedef enum {
  Read, Write
} RW;


#define Data            0x378   /* LPT1 printer port*/

#define Status          (Data + 1)
#define Control         (Data + 2)


Static unsigned short i, j, k, w;
Static uchar d, OldValue;
Static long grDriver, grMode, ErrCode, X0, X1, X2, Y0, Y1, Y2;
Static Char OldValueS[256];
Static uchar x, y;
Static unsigned short fColor;


/***********************************************************************/

Static Void CE(Value)
HiLo Value;
{
  /*/CE is connected to C0-*/
  if (Value == H) {
    PORT(Control) &= ~1;
/* p2c: test.p, line 47: Note: Reference to PORT [191] */
/* p2c: test.p, line 47: Note: Reference to PORT [191] */
/* p2c: test.p, line 48: Warning: Invalid assignment [168] */
  } else {
    PORT(Control) |= 1;
/* p2c: test.p, line 48: Note: Reference to PORT [191] */
/* p2c: test.p, line 48: Note: Reference to PORT [191] */
/* p2c: test.p, line 48: Warning: Invalid assignment [168] */
  }
}


Static Void RD(Value)
HiLo Value;
{
  /*/RD is connected to C1-*/
  if (Value == H) {
    PORT(Control) &= ~2;
/* p2c: test.p, line 53: Note: Reference to PORT [191] */
/* p2c: test.p, line 53: Note: Reference to PORT [191] */
/* p2c: test.p, line 54: Warning: Invalid assignment [168] */
  } else {
    PORT(Control) |= 2;
/* p2c: test.p, line 54: Note: Reference to PORT [191] */
/* p2c: test.p, line 54: Note: Reference to PORT [191] */
/* p2c: test.p, line 54: Warning: Invalid assignment [168] */
  }
}


Static Void WR(Value)
HiLo Value;
{
  /*/WR is connected to C2+*/
  if (Value == L) {
    PORT(Control) &= ~4;
/* p2c: test.p, line 59: Note: Reference to PORT [191] */
/* p2c: test.p, line 59: Note: Reference to PORT [191] */
/* p2c: test.p, line 60: Warning: Invalid assignment [168] */
  } else {
    PORT(Control) |= 4;
/* p2c: test.p, line 60: Note: Reference to PORT [191] */
/* p2c: test.p, line 60: Note: Reference to PORT [191] */
/* p2c: test.p, line 60: Warning: Invalid assignment [168] */
  }
}


Static Void CD(Value)
HiLo Value;
{
  /*/CD is connected to C3-*/
  if (Value == H) {
    PORT(Control) &= ~8;
/* p2c: test.p, line 65: Note: Reference to PORT [191] */
/* p2c: test.p, line 65: Note: Reference to PORT [191] */
/* p2c: test.p, line 66: Warning: Invalid assignment [168] */
  } else {
    PORT(Control) |= 8;
/* p2c: test.p, line 66: Note: Reference to PORT [191] */
/* p2c: test.p, line 66: Note: Reference to PORT [191] */
/* p2c: test.p, line 66: Warning: Invalid assignment [168] */
  }
}


Static Void LPTMode(Mode)
RW Mode;
{
  if (Mode == Write) {
    PORT(Control) &= ~32;
/* p2c: test.p, line 71: Note: Reference to PORT [191] */
/* p2c: test.p, line 71: Note: Reference to PORT [191] */
/* p2c: test.p, line 72: Warning: Invalid assignment [168] */
  } else {
    PORT(Control) |= 32;
/* p2c: test.p, line 72: Note: Reference to PORT [191] */
/* p2c: test.p, line 72: Note: Reference to PORT [191] */
/* p2c: test.p, line 72: Warning: Invalid assignment [168] */
  }
}


/***********************************************************************/

Static Void Init()
{
  LPTMode(Write);
  CE(H);
  RD(H);
  WR(H);
  CD(H);
}


/***********************************************************************/

Static Void CheckStatus()
{
  uchar StatusByte;

  do {
    Delay(1);
/* p2c: test.p, line 92: Warning: Symbol 'DELAY' is not defined [221] */
    LPTMode(Read);
    CD(H);
    WR(H);
    CE(L);
    RD(L);
    StatusByte = PORT(Data);
/* p2c: test.p, line 98: Note: Reference to PORT [191] */
    RD(H);
    CE(H);
  } while ((StatusByte & 1) != 1 || (StatusByte & 2) != 2);
  LPTMode(Write);
}


/***********************************************************************/

Void WriteData(DataByte)
uchar DataByte;
{
  LPTMode(Write);
  CD(L);
  PORT(Data) = DataByte;
/* p2c: test.p, line 110: Note: Reference to PORT [191] */
/* p2c: test.p, line 110: Warning: Invalid assignment [168] */
  CE(L);
  WR(L);
  WR(H);
  CE(H);
  CD(H);
}


/***********************************************************************/

Void WriteCommand(CommandByte)
uchar CommandByte;
{
  LPTMode(Write);
  CD(H);
  PORT(Data) = CommandByte;
/* p2c: test.p, line 123: Note: Reference to PORT [191] */
/* p2c: test.p, line 123: Warning: Invalid assignment [168] */
  CE(L);
  WR(L);
  WR(H);
  CE(H);
}


/***********************************************************************/

Static Void InitT6963()
{
  Init();

  WriteCommand(178);   /*Auto Mode Off*/

  WriteData(0);   /*Text home Address 0780h*/
  WriteData(0);
  WriteCommand(0x40);

  WriteData(0x1e);   /*Text area for 240*64*/
  WriteData(0);
  WriteCommand(0x41);

  WriteData(0);   /*Grapic home address*/
  WriteData(0x2);
  WriteCommand(0x42);

  WriteData(0x1e);   /*Grapich area for 240*64*/
  WriteData(0);
  WriteCommand(0x43);

  WriteCommand(0x81);   /*EXOR Text mode*/

  WriteData(0);   /*Address pointer set*/
  WriteData(0);
  WriteCommand(0x24);

  WriteCommand(97);   /*Cursor On, Blink on*/

  WriteData(0);
  WriteData(0);
  WriteCommand(33);

  WriteCommand(167);

  WriteCommand(147);

  WriteCommand(0x9c);   /*Set display mode (Graphics only)*/
}


/***********************************************************************/

uchar ReadKeys()
{
  uchar OldValue, Eins;

  Init();
  Eins = 1;
  for (i = 1; i <= 4; i++) {
    PORT(Data) = ~Eins;
/* p2c: test.p, line 181: Note: Reference to PORT [191] */
/* p2c: test.p, line 181: Warning: Invalid assignment [168] */
    OldValue = PORT(Status);
/* p2c: test.p, line 182: Note: Reference to PORT [191] */
    if ((OldValue & 16) != 16)
      return (i + 10);
    /*S4+*/
    if ((OldValue & 32) != 32)
      return (i + 20);
    /*S5+*/
    if ((OldValue & 64) != 64)
      return (i + 30);
    /*S6+*/
    if ((OldValue & 128) != 128)
      return (i + 40);
    /*S7-*/
    Eins <<= 1;
  }
  return 0;
}


/***********************************************************************/

/***********************************************************************/



/***********************************************************************/

Static Void LCDClearSlow()
{
  WriteCommand(0xb0);   /*Dato auto write on*/
  WriteData(0);   /*Address pointer set*/
  WriteData(0);
  WriteCommand(0x24);
  for (i = 0; i <= 1919; i++)
    WriteData(0);
  WriteCommand(178);   /*Auto Mode off*/
}


/***********************************************************************/

Void LCDGraphClear()
{
  WriteData(0);   /*Address pointer set*/
  WriteData(0x2);
  WriteCommand(0x24);
  WriteCommand(0xb0);   /*Dato auto write on*/
  LPTMode(Write);
  CD(L);
  CE(L);
  for (i = 0; i <= 1919; i++) {
    PORT(Data) = 0;
/* p2c: test.p, line 224: Note: Reference to PORT [191] */
/* p2c: test.p, line 224: Warning: Invalid assignment [168] */
    WR(L);
    WR(H);
  }
  CE(H);
  CD(H);
  WriteCommand(178);   /*Auto Mode off*/
}



Void LCDTextClear()
{
  WriteData(0);   /*Address pointer set*/
  WriteData(0);
  WriteCommand(0x24);
  WriteCommand(0xb0);   /*Dato auto write on*/
  LPTMode(Write);
  CD(L);
  CE(L);
  for (i = 0; i <= 320; i++) {
    PORT(Data) = 0;
/* p2c: test.p, line 245: Note: Reference to PORT [191] */
/* p2c: test.p, line 245: Warning: Invalid assignment [168] */
    WR(L);
    WR(H);
  }
  CE(H);
  CD(H);
  WriteCommand(178);   /*Auto Mode off*/
}


Void LCDClear()
{
  LCDGraphClear();
  LCDTextClear();
}


/***********************************************************************/

Void TextTest()
{
  WriteData(0);   /*Address pointer set*/
  WriteData(0);
  WriteCommand(0x24);
  WriteCommand(0xb0);   /*Dato auto write on*/
  for (j = 1; j <= 2; j++) {
    for (i = 1; i <= 127; i++)
      WriteData(i);
  }
  WriteCommand(178);   /*Auto Mode off*/
}


/***********************************************************************/
Void LCDGotoXY(X, Y)
uchar X, Y;
{
  long Addr;

  Addr = (Y - 1) * 30 + X - 1;
  WriteData((int)(Addr | 256));
  WriteData(((int)Addr) >> 8);
  WriteCommand(0x24);
}


Void LCDWrite(Tekst)
Char *Tekst;
{
  uchar i, c;

  i = 1;
  do {
    c = Tekst[i - 1] - 0x20;
    if (c < 0)
      c = 0;
    WriteData(c);
    WriteCommand(0xc0);
    i++;
  } while (i <= strlen(Tekst));
}


void _LCDTEKST_init()
{
  static int _was_initialized = 0;
  if (_was_initialized++)
    return;
  InitT6963();
  LCDClear();
}
/* p2c: Note: Remember to call _LCDTEKST_init() in main program [215] */




/* End. */
*******************************************klip
Warnings:

Reading import text for "printer"
Reading import text for "dos"
Reading import text for "crt"
Reading import text for "graph"
/usr/lib/p2c/turbo.imp, line 251: Warning: Symbol 'SHORTINT' is not defined
[221]
CE
test.p, line 47: Note: Reference to PORT [191]
test.p, line 47: Note: Reference to PORT [191]
test.p, line 48: Warning: Invalid assignment [168]
test.p, line 48: Note: Reference to PORT [191]
test.p, line 48: Note: Reference to PORT [191]
test.p, line 48: Warning: Invalid assignment [168]
, RD
test.p, line 53: Note: Reference to PORT [191]
test.p, line 53: Note: Reference to PORT [191]
test.p, line 54: Warning: Invalid assignment [168]
test.p, line 54: Note: Reference to PORT [191]
test.p, line 54: Note: Reference to PORT [191]
test.p, line 54: Warning: Invalid assignment [168]
, WR
test.p, line 59: Note: Reference to PORT [191]
test.p, line 59: Note: Reference to PORT [191]
test.p, line 60: Warning: Invalid assignment [168]
test.p, line 60: Note: Reference to PORT [191]
test.p, line 60: Note: Reference to PORT [191]
test.p, line 60: Warning: Invalid assignment [168]
, CD
test.p, line 65: Note: Reference to PORT [191]
test.p, line 65: Note: Reference to PORT [191]
test.p, line 66: Warning: Invalid assignment [168]
test.p, line 66: Note: Reference to PORT [191]
test.p, line 66: Note: Reference to PORT [191]
test.p, line 66: Warning: Invalid assignment [168]
, LPTMode
test.p, line 71: Note: Reference to PORT [191]
test.p, line 71: Note: Reference to PORT [191]
test.p, line 72: Warning: Invalid assignment [168]
test.p, line 72: Note: Reference to PORT [191]
test.p, line 72: Note: Reference to PORT [191]
test.p, line 72: Warning: Invalid assignment [168]
, Init, CheckStatus
test.p, line 92: Warning: Symbol 'DELAY' is not defined [221]
test.p, line 98: Note: Reference to PORT [191]
, WriteData
test.p, line 110: Note: Reference to PORT [191]
test.p, line 110: Warning: Invalid assignment [168]
test.p, line 181: Note: Reference to PORT [191]
test.p, line 181: Warning: Invalid assignment [168]
test.p, line 182: Note: Reference to PORT [191]
, LCDClearSlow, LCDGraphClear
test.p, line 224: Note: Reference to PORT [191]
test.p, line 224: Warning: Invalid assignment [168]
, LCDTextClear
test.p, line 245: Note: Reference to PORT [191]
test.p, line 245: Warning: Invalid assignment [168]
, LCDClear, TextTest, LCDGotoXY, LCDWrite, LCDTEKST
Note: Remember to call _LCDTEKST_init() in main program [215]


Translation completed.
, WriteCommand
test.p, line 123: Note: Reference to PORT [191]
test.p, line 123: Warning: Invalid assignment [168]
, InitT6963, ReadKeys