Hi, I've got some source code in C I would like to translate to Delphi 4 (Object Pascal). I would be glad if someone could help me out.<br>I've got the same source for Turbo Pascal, Visual Basic 3.0 & 4.0, C and QBasic.<br>You'll think: he's got it in Turbo Pascal, why not use it in Delphi directly. Well I tried but it makes use or TPs PORT array, which doesn't exist in Delphi.<br><br>Here's one of the most important procedures. If you really want to help me, I could send you one of the units.<br>Mind that I've never programmed in this language before, so there could be some missing things.<br><br>This stands in the beginning:<br><FONT FACE=monospace><br>#include <stdio.h><br>#include <dos.h><br>#include <string.h><br>#include <stdlib.h><br></font><br>And this is the procedure I would like to have decrypted <br><FONT FACE=monospace><br>void ReadIOchip(int Chip_no)<br>{<br> int Start_Channel, Channel, Data, cport, i, j;<br><br> /*Generate start condition*/<br> outport(ControlPort, 0x06);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> outport(ControlPort, 0x0E);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br><br> /*Serial output of Chipcode for readmode*/<br> Data = ((IOchipCode[Chip_no] ¦ 0x01) << 8); /*Shift data 8 bits left*/<br> for (j = 1; j <= 8; j++) {<br> cport = (Data < 0) ? 0x0C: 0x0E;<br> outport(ControlPort, cport);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> cport = cport & 0x07;<br> outport(ControlPort, cport);<br> Data <<= 1;<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> cport = cport ¦ 0x08;<br> outport(ControlPort, cport);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> };<br><br> /*Clock pulse for acknowledgement*/<br> outport(ControlPort, 0x0C);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> outport(ControlPort, 0x04);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> outport(ControlPort, 0x0C);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br><br> /*Serial input of ChipData*/<br> Data = 0; /*Clear Data*/<br> for (j = 1; j <= 8; j++) {<br> Data <<= 1;<br> outport(ControlPort, 0x04);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> if (inport(StatusPort) & 0x10) Data = Data ¦ 0x0001;<br> outport(ControlPort, 0x0C);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> };<br> IOdata[Chip_no] = ~Data;<br><br> /*Clock pulse for acknowledgement*/<br> outport(ControlPort, 0x0C);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> outport(ControlPort, 0x04);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> outport(ControlPort, 0x0C);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br><br> /*Generate stop condition*/<br> outport(ControlPort, 0x0E);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> outport(ControlPort, 0x06);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br> outport(ControlPort, 0x04);<br> for (i = 0; i <= I2CbusDelay; i++) {}; /*I2c-bus timing*/<br><br> /*Update 'IO' array*/<br> Start_Channel = Chip_no * 8 + 1; /*Calculate start channel*/<br> for (Channel = 0; Channel <= 7; Channel++) /*Test status 8 ch. of the IOchip*/<br> IO[Start_Channel+Channel] = ((IOdata[Chip_no] & (0x01 << Channel)) != 0);<br>};<br></font><br><br><br>Thanks in advance,<br> <p>Bert Vingerhoets<br><a href=mailto:vingerhoetsbert@hotmail.com>vingerhoetsbert@hotmail.com</a><br><a href= > </a><br>