Esempio n. 1
0
t_stat read_card (int32 ilnt, int32 mod)
{
int32 i;
t_stat r;

if (sim_is_active (&cdr_unit)) {                        /* busy? */
    sim_cancel (&cdr_unit);                             /* cancel */
    if (r = cdr_svc (&cdr_unit)) return r;              /* process */
}   

if (((cdp_unit.flags & UNIT_ATT) != 0 ||
    (stack_unit[0].flags & UNIT_ATT) != 0) &&           /* Punch is attached and */
    (cdr_unit.flags & UNIT_ATT) == 0) {                 /* reader is not --- */
        for (i = 0; i < 80; i++) {                      /* Assume blank cards in hopper */
            PutMem(DAR, 0x40);
            DAR++;
        }
        sim_activate (&cdr_unit, cdr_unit.wait);        /* activate */
        return SCPE_OK;
}
        
if ((cdr_unit.flags & UNIT_ATT) == 0) return SCPE_UNATT; /* attached? */

lastcard = carderr = notready = s1sel = s2sel = 0;      /* default stacker */

for (i = 0; i < CBUFSIZE; i++) rbuf[i] = 0x20;          /* clear buffer */
if (mod) {
    for (i = 0; i < 80; i++) {
        rbuf[i] = fgetc(cdr_unit.fileref);              /* Read EBCDIC */
    }   
} else {    
    fgets (rbuf, CBUFSIZE, cdr_unit.fileref);           /* read Ascii */
}   
if (feof (cdr_unit.fileref)) {                          /* eof? */
    notready = 1;
    return STOP_NOCD;
}       
if (ferror (cdr_unit.fileref)) {                        /* error? */
    perror ("Card reader I/O error");
    clearerr (cdr_unit.fileref);
    carderr = 1;  
    return SCPE_OK;  }
cdr_unit.pos = ftell (cdr_unit.fileref);                /* update position */
i = getc (cdr_unit.fileref);                            /* see if more */
if (feof (cdr_unit.fileref)) lastcard = 1;              /* eof? set flag */
fseek (cdr_unit.fileref, cdr_unit.pos, SEEK_SET);
for (i = 0; i < 80; i++) {              
    if (mod == 0) {                                     /* If ASCII mode... */
        if (rbuf[i] == '\n' ||                          /* remove ASCII CR/LF */
            rbuf[i] == '\r' ||
            rbuf[i] == 0x00)
             rbuf[i] = ' ';
        rbuf[i] = ascii_to_ebcdic[rbuf[i]];             /* convert to EBCDIC */
    }   
    PutMem(DAR, rbuf[i]);                               /* Copy to main memory */
    DAR++;
}
sim_activate (&cdr_unit, cdr_unit.wait);                /* activate */
return SCPE_OK;
}
Esempio n. 2
0
/****************************************************************************
 * NGCFreezeMembuffer
 *
 * Copies a snapshot of Snes9x state into memory
 ***************************************************************************/
static int
NGCFreezeMemBuffer ()
{
    int i;
    char buffer[1024];

    bufoffset = 0;

    S9xUpdateRTC ();
    S9xSRTCPreSaveState ();

    for (i = 0; i < 8; i++)
    {
        SoundData.channels[i].previous16[0] =
        (int16) SoundData.channels[i].previous[0];
        SoundData.channels[i].previous16[1] =
        (int16) SoundData.channels[i].previous[1];
    }

    sprintf (buffer, "%s:%04d\n", SNAPSHOT_MAGIC, SNAPSHOT_VERSION);
    PutMem (buffer, strlen (buffer));
    sprintf (buffer, "NAM:%06d:%s%c", (int) strlen (Memory.ROMFilename) + 1,
    Memory.ROMFilename, 0);

    PutMem (buffer, strlen (buffer) + 1);

    NGCFreezeStruct ();

    return 0;
}
Esempio n. 3
0
void
NGCFreezeBlock (char *name, uint8 * block, int size)
{
	char buffer[512];
	sprintf (buffer, "%s:%06d:", name, size);
	PutMem (buffer, strlen (buffer));
	PutMem ((char *) block, size);
}
Esempio n. 4
0
void Cpu::PutData(unsigned char Addressing, unsigned int Argument, unsigned int Data, unsigned int DataType)
{
	unsigned int Size = TypeSize[DataType];
	switch(Addressing)
	{
	case 0:
		PutReg(Argument, Data, Size);
		break;
	case 1:
		PutMem(GetReg(Argument), Data, Size);
		break;
	case 2:
		break;
	case 3:
		PutMem(Argument, Data, Size);
		break;
	default:
		CoreCrash("Unknow addressing: %d", Addressing);
	}
}