mirror of
https://github.com/rcornwell/sims.git
synced 2026-04-18 00:47:50 +00:00
SIM_CARD: Added type definitions.
This commit is contained in:
43
sim_card.c
43
sim_card.c
@@ -77,11 +77,11 @@
|
||||
|
||||
struct card_context
|
||||
{
|
||||
int punch_count; /* Number of cards punched */
|
||||
t_addr punch_count; /* Number of cards punched */
|
||||
char cbuff[1024]; /* Read in buffer for cards */
|
||||
uint8 hol_to_ascii[4096]; /* Back conversion table */
|
||||
int hopper_size; /* Size of hopper */
|
||||
int hopper_cards; /* Number of cards in hopper */
|
||||
t_addr hopper_size; /* Size of hopper */
|
||||
t_addr hopper_cards; /* Number of cards in hopper */
|
||||
uint16 (*images)[1][80];
|
||||
};
|
||||
|
||||
@@ -478,7 +478,7 @@ sim_hol_to_ebcdic(uint16 hol) {
|
||||
|
||||
|
||||
|
||||
int
|
||||
t_addr
|
||||
sim_hopper_size(UNIT * uptr) {
|
||||
struct card_context *data = (struct card_context *)uptr->card_ctx;
|
||||
if (data == NULL)
|
||||
@@ -486,7 +486,7 @@ sim_hopper_size(UNIT * uptr) {
|
||||
return data->hopper_cards;
|
||||
}
|
||||
|
||||
int
|
||||
t_addr
|
||||
sim_punch_count(UNIT * uptr) {
|
||||
struct card_context *data = (struct card_context *)uptr->card_ctx;
|
||||
if (data == NULL)
|
||||
@@ -494,7 +494,7 @@ sim_punch_count(UNIT * uptr) {
|
||||
return data->punch_count;
|
||||
}
|
||||
|
||||
int
|
||||
t_addr
|
||||
sim_card_input_hopper_count(UNIT *uptr) {
|
||||
struct card_context *data = (struct card_context *)uptr->card_ctx;
|
||||
uint16 col;
|
||||
@@ -510,7 +510,7 @@ sim_card_input_hopper_count(UNIT *uptr) {
|
||||
return (int)((data->hopper_cards - uptr->pos) - ((col & CARD_EOF) ? 1 : 0));
|
||||
}
|
||||
|
||||
int
|
||||
t_addr
|
||||
sim_card_output_hopper_count(UNIT *uptr) {
|
||||
struct card_context *data = (struct card_context *)uptr->card_ctx;
|
||||
|
||||
@@ -521,19 +521,19 @@ sim_card_output_hopper_count(UNIT *uptr) {
|
||||
}
|
||||
|
||||
|
||||
t_stat
|
||||
t_cdstat
|
||||
sim_read_card(UNIT * uptr, uint16 image[80])
|
||||
{
|
||||
int i;
|
||||
struct card_context *data = (struct card_context *)uptr->card_ctx;
|
||||
DEVICE *dptr;
|
||||
uint16 (*img)[80];
|
||||
t_stat r = SCPE_OK;
|
||||
t_stat r = CDSE_OK;
|
||||
|
||||
if (data == NULL || data->hopper_size == 0 || (uptr->flags & UNIT_ATT) == 0)
|
||||
return SCPE_UNATT; /* attached? */
|
||||
if (uptr->pos >= data->hopper_cards)
|
||||
return SCPE_UNATT;
|
||||
if (data == NULL || (uptr->flags & UNIT_ATT) == 0)
|
||||
return CDSE_EMPTY; /* attached? */
|
||||
if (data->hopper_cards == 0 || uptr->pos >= data->hopper_cards)
|
||||
return CDSE_EMPTY;
|
||||
|
||||
dptr = find_dev_from_unit( uptr);
|
||||
img = &(*data->images)[uptr->pos];
|
||||
@@ -563,9 +563,9 @@ sim_read_card(UNIT * uptr, uint16 image[80])
|
||||
}
|
||||
}
|
||||
if ((*img)[0] & CARD_EOF)
|
||||
r = SCPE_EOF;
|
||||
r = CDSE_EOF;
|
||||
else if ((*img)[0] & CARD_ERR)
|
||||
r = SCPE_IOERR;
|
||||
r = CDSE_ERROR;
|
||||
uptr->pos++;
|
||||
data->punch_count++;
|
||||
memcpy(image, img, 80 * sizeof(uint16));
|
||||
@@ -981,6 +981,7 @@ _sim_read_deck(UNIT * uptr, int eof)
|
||||
C modifier is recognized (column binary is implemented)
|
||||
*/
|
||||
|
||||
|
||||
t_stat
|
||||
sim_punch_card(UNIT * uptr, uint16 image[80])
|
||||
{
|
||||
@@ -992,15 +993,17 @@ sim_punch_card(UNIT * uptr, uint16 image[80])
|
||||
/* Try to convert to text */
|
||||
uint8 out[512];
|
||||
int i;
|
||||
int outp;
|
||||
int outp = 0;
|
||||
int mode = uptr->flags & UNIT_CARD_MODE;
|
||||
int ok = 1;
|
||||
struct card_context *data;
|
||||
DEVICE *dptr;
|
||||
|
||||
data = (struct card_context *)uptr->card_ctx;
|
||||
dptr = find_dev_from_unit(uptr);
|
||||
outp = 0;
|
||||
data = (struct card_context *)uptr->card_ctx;
|
||||
|
||||
if (data == NULL || (uptr->flags & UNIT_ATT) == 0)
|
||||
return CDSE_EMPTY; /* attached? */
|
||||
|
||||
/* Fix mode if in auto mode */
|
||||
if (mode == MODE_AUTO) {
|
||||
@@ -1132,7 +1135,7 @@ sim_punch_card(UNIT * uptr, uint16 image[80])
|
||||
uptr->pos = ftell (uptr->fileref);
|
||||
/* Clear image buffer */
|
||||
for (i = 0; i < 80; image[i++] = 0);
|
||||
return SCPE_OK;
|
||||
return CDSE_OK;
|
||||
}
|
||||
|
||||
/* Set card format */
|
||||
@@ -1270,7 +1273,7 @@ sim_card_attach(UNIT * uptr, CONST char *cptr)
|
||||
}
|
||||
|
||||
if (uptr->flags & UNIT_RO) { /* Card Reader? */
|
||||
int previous_cards = data->hopper_cards;
|
||||
t_addr previous_cards = data->hopper_cards;
|
||||
|
||||
/* Check if we should append to end of existing */
|
||||
if ((sim_switches & SWMASK ('S')) == 0) {
|
||||
|
||||
33
sim_card.h
33
sim_card.h
@@ -66,6 +66,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SIM_CARD_API 2 /* API Version */
|
||||
|
||||
#define DEBUG_CARD 0x0000010 /* Show details */
|
||||
|
||||
/* Flags for punch and reader. */
|
||||
@@ -85,21 +87,28 @@ extern "C" {
|
||||
#define MODE_CHAR (0x70 << UNIT_V_CARD_MODE)
|
||||
|
||||
|
||||
/* Card Reader Return Status code */
|
||||
typedef int t_cdstat;
|
||||
#define CDSE_OK 0 /* Good */
|
||||
#define CDSE_EOF 1 /* End of File */
|
||||
#define CDSE_EMPTY 2 /* Input Hopper Empty */
|
||||
#define CDSE_ERROR 3 /* Error Card Read */
|
||||
|
||||
/* Generic routines. */
|
||||
|
||||
/* Read next card into image row 12,11,10,1-9 */
|
||||
/* Return SCPE_EOF if end file detected. */
|
||||
t_stat sim_read_card(UNIT * uptr, uint16 image[80]);
|
||||
t_cdstat sim_read_card(UNIT * uptr, uint16 image[80]);
|
||||
/* Punch card from image row 12,11,10,1-9 */
|
||||
t_stat sim_punch_card(UNIT * uptr, uint16 image[80]);
|
||||
t_cdstat sim_punch_card(UNIT * uptr, uint16 image[80]);
|
||||
/* Check if next card to be read is EOF */
|
||||
int sim_card_eof(UNIT * uptr);
|
||||
/* Return number of cards yet to read */
|
||||
int sim_hopper_size(UNIT * uptr);
|
||||
t_addr sim_hopper_size(UNIT * uptr);
|
||||
/* Return number of cards punched */
|
||||
int sim_punch_count(UNIT * uptr);
|
||||
int sim_card_input_hopper_count(UNIT *uptr);
|
||||
int sim_card_output_hopper_count(UNIT *uptr);
|
||||
t_addr sim_punch_count(UNIT * uptr);
|
||||
t_addr sim_card_input_hopper_count(UNIT *uptr);
|
||||
t_addr sim_card_output_hopper_count(UNIT *uptr);
|
||||
t_stat sim_card_attach(UNIT * uptr, CONST char *file);
|
||||
t_stat sim_card_detach(UNIT *uptr);
|
||||
|
||||
@@ -110,16 +119,16 @@ uint8 sim_hol_to_bcd(uint16 hol);
|
||||
uint16 sim_hol_to_ebcdic(uint16 hol);
|
||||
|
||||
/* Format control routines. */
|
||||
t_stat sim_card_set_fmt (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat sim_card_show_fmt (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
|
||||
t_stat sim_card_set_fmt (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat sim_card_show_fmt (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
|
||||
|
||||
/* Help information */
|
||||
t_stat sim_card_attach_help(FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr);
|
||||
t_stat sim_card_attach_help(FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, const char *cptr);
|
||||
|
||||
/* Translation tables */
|
||||
extern const char sim_six_to_ascii[64]; /* Map BCD to ASCII */
|
||||
extern const char sim_ascii_to_six[128]; /* Map 7 bit ASCII to BCD */
|
||||
extern const uint8 sim_parity_table[64]; /* 64 entry odd parity table */
|
||||
extern CONST char sim_six_to_ascii[64]; /* Map BCD to ASCII */
|
||||
extern CONST char sim_ascii_to_six[128]; /* Map 7 bit ASCII to BCD */
|
||||
extern CONST uint8 sim_parity_table[64]; /* 64 entry odd parity table */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user