📄 bcset.c
字号:
#include "proto.h"
/* setup a BC message */
extern struct bc_command_block * bc_command_blocks; /* BC command blocks */
int borland_dll Set_BC_Cmd (unsigned short cmdnum, struct CMDENTRY *entry)
{
if (curmode != BC_MODE)
return (emode);
if (cmdnum > MAXCMDS)
return (einval);
/* do some error checking if it is RT to RT command */
if (entry->control & 0x100) /* if RT to RT */
{
if ( (entry->command1 & 0x400) || /* if 1st command is not RCV */
(!(entry->command2 & 0x400)) || /* if 2nd command is not XMT */
((entry->command1 & 0x1f) != (entry->command2 & 0x1f)) )/*if different word count*/
return (ert2rtcmd);
}
bc_command_blocks[cmdnum].control = entry->control;
bc_command_blocks[cmdnum].command1 = entry->command1;
bc_command_blocks[cmdnum].command2 = entry->command2;
bc_command_blocks[cmdnum].data_ptr =(unsigned short) ((entry->datablk * DATABLKSIZE) + Start_DPRAM);
bc_command_blocks[cmdnum].branch =(unsigned short) ((entry->gotocmd * CMDENTRYSIZE) + CMDOFFSET);
bc_command_blocks[cmdnum].timer = entry->timer;
return(0);
} /* end Set_BC_Cmd */
int borland_dll Get_BC_Cmd (unsigned short cmdnum, struct CMDENTRY *entry)
{
if (curmode != BC_MODE)
return (emode);
if (cmdnum > MAXCMDS)
return (einval);
entry->control = bc_command_blocks[cmdnum].control;
entry->command1 = bc_command_blocks[cmdnum].command1;
entry->command2 = bc_command_blocks[cmdnum].command2;
entry->status1 = bc_command_blocks[cmdnum].status1;
entry->status2 = bc_command_blocks[cmdnum].status2;
entry->datablk = (unsigned short) ((bc_command_blocks[cmdnum].data_ptr - Start_DPRAM) / DATABLKSIZE);
entry->gotocmd = (unsigned short)((bc_command_blocks[cmdnum].branch - CMDOFFSET) / CMDENTRYSIZE);
entry->timer = bc_command_blocks[cmdnum].timer;
return(0);
} /* end Get_BC_Cmd */
int borland_dll Load_BC_Datablk (unsigned short blknum, unsigned short wdcnt, unsigned short *data)
{
short dataind;
unsigned short cardindex;
if (curmode != BC_MODE)
return (emode);
if (blknum > MAXDATABLKS)
return (einval);
if (wdcnt > DATABLKSIZE)
return (einval);
cardindex =(unsigned short) ((blknum * DATABLKSIZE) + Start_DPRAM);
for (dataind = 0; dataind < wdcnt; dataind++)
exc_summit_int[cardindex + dataind] = data[dataind];
return(0);
} /* end Load_BC_Datablk */
int borland_dll Read_BC_Datablk (unsigned short blknum, unsigned short wdcnt, unsigned short *data)
{
short dataind;
short cardindex;
if (curmode != BC_MODE)
return (emode);
if (blknum > MAXDATABLKS)
return (einval);
if (wdcnt > DATABLKSIZE)
return (einval);
cardindex =(unsigned short) ((blknum * DATABLKSIZE) + Start_DPRAM);
for (dataind = 0; dataind < wdcnt; dataind++)
data[dataind] = exc_summit_int[cardindex + dataind];
return(0);
} /* end Read_BC_Datablk */
int borland_dll Run_BC (void)
{
if (curmode != BC_MODE)
return (emode);
exc_summit->pointer = CMDOFFSET; /* Command blocks */
/*
// Use wForceWordWrite to prevent compiler from optimizing this as a byte operation
// Summit control structure of PCMCIA *must* be written to only as words
*/
wForceWordWrite = exc_summit->control | START_EXECUTION;
exc_summit->control = wForceWordWrite;
return(0);
} /* end Run_BC */
int borland_dll Last_BC_Cmd (void)
{
if (curmode != BC_MODE)
return (emode);
return (exc_summit->pointer - CMDOFFSET)/8; /* Command blocks */
} /* end Last_BC_Cmd */
/* CR1 */
int borland_dll Command_Word_MCH(int rtnum, int type, int subaddr, int numwords, usint *commandword)
{
int rtid;
if ((rtnum <0) || (rtnum > 31))
return einval;
if ((type != TRANSMIT) && (type != RECEIVE))
return einval;
if ((subaddr <0 ) || (subaddr > 31))
return einval;
if ((numwords <0) || (numwords >32))
return einval;
if (numwords == 32)
numwords = 0;
rtid = (rtnum << 6) | (type <<5) | subaddr;
*commandword = (rtid<<5) | numwords;
return 0;
}
/* CR1 */
int borland_dll Control_Word_MCH(usint opcode, usint retrynum, usint bus, usint rt2rt_flag, usint ccodes, usint *controlword)
{
if ((opcode & INVALID_OPCODE_MASK) != 0)
return einval;
if ((opcode & RETRY_ON_COND) || (opcode & RETRY_ON_COND_BRANCH) || (opcode & RETRY_ON_COND_BRANCH_ALL_FAIL))
{
if ((retrynum <1) || (retrynum > 4))
return einval;
}
else
retrynum = 0; /* ignored anyway */
if ((bus != BUS_A) && (bus != BUS_B))
return einval;
if ((rt2rt_flag != RT2RT ) && (rt2rt_flag != NOT_RT2RT))
return einval;
if (((ccodes < LOWEST_CCODE) && (ccodes != 0)) || ( ccodes > ALL_CCODES))
return einval;
if (retrynum == 4)
retrynum = 0;
*controlword = (opcode | (retrynum <<10) | bus | rt2rt_flag | ccodes );
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -