📄 plc2.c
字号:
void ctt_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void ctt_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[CTT_OBJ].label,fg,bg);
coverlay(r,c,objs[CTT_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
showregtype(r+TEXTHEIGHT,c,nodeptr->opflags[2],(DWORD)(*(WORD *)&nodeptr->opcode[2]));
}
WORD ctt_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 4;
return(compile_endian_node(nodeptr,2,buf,2));
}
void ctf_init(nodeptr)
struct logic_element *nodeptr;
{
BYTE strr[12], strlimit[12];
BYTE typer, typelimit;
DWORD regr, reglimit;
get_values("Counter TRUE->FALSE",
"Counter register ? ",
"Preset limit ? ",
NULL,
strr,
strlimit,
NULL);
if ((parse_io_str(strr,&typer,®r))
&& (parse_io_str(strlimit,&typelimit,®limit)))
{
if (((typelimit == WORDVAL_TYPE) || (typelimit == BYTEVAL_TYPE))
&& (typer == COUNTER_TYPE))
{
nodeptr->opcode[0] = CTF;
nodeptr->opcode[1] = regr;
nodeptr->opflags[1] = typer;
nodeptr->opcode[2] = reglimit & 0xff;
nodeptr->opflags[2] = WORDVAL_TYPE; /* this always wants to be a WORD */
nodeptr->opcode[3] = (reglimit >> 8);
}
else
beep();
}
}
void ctf_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void ctf_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[CTF_OBJ].label,fg,bg);
coverlay(r,c,objs[CTF_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
showregtype(r+TEXTHEIGHT,c,nodeptr->opflags[2],(DWORD)(*(WORD *)&nodeptr->opcode[2]));
}
WORD ctf_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 4;
return(compile_endian_node(nodeptr,2,buf,2));
}
void tmt_init(nodeptr)
struct logic_element *nodeptr;
{
BYTE strr[12], strticks[12];
BYTE typer, typeticks;
DWORD regr, regticks;
get_values("Timer TRUE",
"Timer register ? ",
"ticks (1ms) ? ",
NULL,
strr,
strticks,
NULL);
if ((parse_io_str(strr,&typer,®r))
&& (parse_io_str(strticks,&typeticks,®ticks)))
{
if (((typeticks == WORDVAL_TYPE) || (typeticks == BYTEVAL_TYPE))
&& (typer == TIMER_TYPE))
{
nodeptr->opcode[0] = TMT;
nodeptr->opcode[1] = regr;
/* EVEN dataregs are flags/accum, ODD are used for RTC storage */
nodeptr->opflags[1] = typer;
nodeptr->opcode[2] = regticks & 0xff;
nodeptr->opflags[2] = WORDVAL_TYPE; /* this always wants to be a WORD */
nodeptr->opcode[3] = (regticks >> 8);
}
else
beep();
}
}
void tmt_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void tmt_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[TMT_OBJ].label,fg,bg);
coverlay(r,c,objs[TMT_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
showregtype(r+TEXTHEIGHT,c,nodeptr->opflags[2],(DWORD)(*(WORD *)&nodeptr->opcode[2]));
}
WORD tmt_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 4;
return(compile_endian_node(nodeptr,2,buf,2));
}
void tmf_init(nodeptr)
struct logic_element *nodeptr;
{
BYTE strr[12], strticks[12];
BYTE typer, typeticks;
DWORD regr, regticks;
get_values("Timer FALSE",
"Timer register ? ",
"ticks (1ms) ? ",
NULL,
strr,
strticks,
NULL);
if ((parse_io_str(strr,&typer,®r))
&& (parse_io_str(strticks,&typeticks,®ticks)))
{
if (((typeticks == WORDVAL_TYPE) || (typeticks == BYTEVAL_TYPE))
&& (typer == TIMER_TYPE))
{
nodeptr->opcode[0] = TMF;
nodeptr->opcode[1] = regr;
/* EVEN dataregs are flags/accum, ODD are used for RTC storage */
nodeptr->opflags[1] = typer;
nodeptr->opcode[2] = regticks & 0xff;
nodeptr->opflags[2] = WORDVAL_TYPE; /* this always wants to be a WORD */
nodeptr->opcode[3] = (regticks >> 8);
}
else
beep();
}
}
void tmf_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void tmf_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[TMF_OBJ].label,fg,bg);
coverlay(r,c,objs[TMF_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
showregtype(r+TEXTHEIGHT,c,nodeptr->opflags[2],(DWORD)(*(WORD *)&nodeptr->opcode[2]));
}
WORD tmf_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 4;
return(compile_endian_node(nodeptr,2,buf,2));
}
void rtmt_init(nodeptr)
struct logic_element *nodeptr;
{
BYTE strr[12], strticks[12];
BYTE typer, typeticks;
DWORD regr, regticks;
get_values("Retentive Timer TRUE",
"Timer register ? ",
"ticks (1ms) ? ",
NULL,
strr,
strticks,
NULL);
if ((parse_io_str(strr,&typer,®r))
&& (parse_io_str(strticks,&typeticks,®ticks)))
{
if (((typeticks == WORDVAL_TYPE) || (typeticks == BYTEVAL_TYPE))
&& (typer == TIMER_TYPE))
{
nodeptr->opcode[0] = RTMT;
nodeptr->opcode[1] = regr;
/* EVEN dataregs are flags/accum, ODD are used for RTC storage */
nodeptr->opflags[1] = typer;
nodeptr->opcode[2] = regticks & 0xff;
nodeptr->opflags[2] = WORDVAL_TYPE; /* this always wants to be a WORD */
nodeptr->opcode[3] = (regticks >> 8);
}
else
beep();
}
}
void rtmt_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void rtmt_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[RTMT_OBJ].label,fg,bg);
coverlay(r,c,objs[RTMT_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
showregtype(r+TEXTHEIGHT,c,nodeptr->opflags[2],(DWORD)(*(WORD *)&nodeptr->opcode[2]));
}
WORD rtmt_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 4;
return(compile_endian_node(nodeptr,2,buf,2));
}
void rtmf_init(nodeptr)
struct logic_element *nodeptr;
{
BYTE strr[12], strticks[12];
BYTE typer, typeticks;
DWORD regr, regticks;
get_values("Retentive Timer FALSE",
"Timer register ? ",
"ticks (1ms) ? ",
NULL,
strr,
strticks,
NULL);
if ((parse_io_str(strr,&typer,®r))
&& (parse_io_str(strticks,&typeticks,®ticks)))
{
if (((typeticks == WORDVAL_TYPE) || (typeticks == BYTEVAL_TYPE))
&& (typer == TIMER_TYPE))
{
nodeptr->opcode[0] = RTMF;
nodeptr->opcode[1] = regr;
/* EVEN dataregs are flags/accum, ODD are used for RTC storage */
nodeptr->opflags[1] = typer;
nodeptr->opcode[2] = regticks & 0xff;
nodeptr->opflags[2] = WORDVAL_TYPE; /* this always wants to be a WORD */
nodeptr->opcode[3] = (regticks >> 8);
}
else
beep();
}
}
void rtmf_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void rtmf_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[RTMF_OBJ].label,fg,bg);
coverlay(r,c,objs[RTMF_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
showregtype(r+TEXTHEIGHT,c,nodeptr->opflags[2],(DWORD)(*(WORD *)&nodeptr->opcode[2]));
}
WORD rtmf_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 4;
return(compile_endian_node(nodeptr,2,buf,2));
}
void reset_init(nodeptr)
struct logic_element *nodeptr;
{
BYTE str[12];
BYTE type;
DWORD reg;
get_values("Reset timer/counter","timer/counter ? ",NULL,NULL,str,NULL,NULL);
if (parse_io_str(str,&type,®))
{
if ((type == TIMER_TYPE) || (type == COUNTER_TYPE))
{
nodeptr->opcode[0] = RESET;
if (type == TIMER_TYPE)
nodeptr->opcode[1] = reg;
/* EVEN dataregs are flags/accum, ODD are used for RTC storage */
else
nodeptr->opcode[1] = reg;
nodeptr->opflags[1] = type;
}
else
beep();
}
}
void reset_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void reset_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[RESET_OBJ].label,fg,bg);
coverlay(r,c,objs[RESET_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
}
WORD reset_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 2;
return(compile_node(nodeptr,*len,buf));
}
void inv_init(nodeptr)
struct logic_element *nodeptr;
{
nodeptr->opcode[0] = INVERT;
}
void inv_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void inv_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
cstrout(r,c,objs[INVERT_OBJ].label,fg,bg);
coverlay(r,c,objs[INVERT_OBJ].overlay,fg);
}
WORD inv_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 1;
return(compile_node(nodeptr,*len,buf));
}
void lbl_init(nodeptr)
struct logic_element *nodeptr;
{
BYTE str[12];
BYTE type;
DWORD reg;
WORD rung, index, found;
for (found = FALSE, rung = 0; rung < MAX_RUNGS; rung++)
{
if (used_rungs[rung])
{
for (index = 0; index < rungs[rung].num_elements; index++)
{
if (nodeptr == &rungs[rung].node[index])
{
found = TRUE;
break; /* UGLY, UGLY KLUDGE! */
}
}
if (found)
break; /* exit outer loop, too */
}
}
/* I have to make sure this is the *FIRST* node on a *ROOT* rung, and
* since the rung/index are not available, I have to find it. UGLY!
*/
if (index != 0)
{
nodeptr->objindex = NULL_OBJ;
return(beep());
}
for (index = 0; index < ladder_size; index++)
if (rung_list[index] == rung)
break;
if (index == ladder_size) /* not a root rung */
{
nodeptr->objindex = NULL_OBJ;
return(beep());
}
get_values("LABEL","Label number ? ",NULL,NULL,str,NULL,NULL);
if (parse_io_str(str,&type,®))
{
if (type == LABEL_TYPE)
{
nodeptr->opcode[0] = LBL;
nodeptr->opcode[1] = reg;
nodeptr->opflags[1] = type;
}
else
beep();
}
}
void lbl_del(r,c,nodeptr)
WORD r,c;
struct logic_element *nodeptr;
{
erase_node_notes(r,c);
clear_node(nodeptr);
}
void lbl_draw(r,c,nodeptr,fg,bg)
WORD r,c;
struct logic_element *nodeptr;
WORD fg,bg;
{
BYTE abuf[12];
cstrout(r,c,objs[LBL_OBJ].label,fg,bg);
coverlay(r,c,objs[LBL_OBJ].overlay,fg);
showregtype(r-TEXTHEIGHTSMALL,c+2*TEXTWIDTH,nodeptr->opflags[1],(DWORD)nodeptr->opcode[1]);
}
WORD lbl_comp(nodeptr,len,buf)
struct logic_element *nodeptr;
WORD *len;
BYTE *buf;
{
*len = 0;
if (label_addresses[nodeptr->opcode[1]] != NULL_LABEL)
{
if (program_len)
{
if (label_addresses[nodeptr->opcode[1]] == program_len-1)
return(COMPILE_OK);
return(COMPILE_DUP_ADDR);
}
return(COMPILE_UNKNOWN_ADDR);
}
if (program_len == 0)
return(COMPILE_UNKNOWN_ADDR); /* close enough... */
label_addresses[nodeptr->opcode[1]] = program_len - 1;
/* the JMP target must be the SETLINETRUE at the start of this line */
return(COMPILE_OK);
}
void nullfn() /* something to point to */
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -