Пример #1
0
static void Out1_nrfdhi(int tr)
{
	static BYTE b;

	par_status = parallel_trap_receivebyte(&b, 1);
	parallel_emu_set_bus((BYTE)(b ^ 0xff));

	if (par_status & 0x40)
		parallel_emu_set_eoi(1);
	else
		parallel_emu_set_eoi(0);

	parallel_emu_set_dav(1);

	Go(Out1a);
}
Пример #2
0
static void Out2_ndachi(int tr)
{
	static BYTE b;

	parallel_emu_set_dav(0);
	parallel_emu_set_eoi(0);
	parallel_emu_set_bus(0xff);

	par_status = parallel_trap_receivebyte(&b, 0);

	if (par_status & 0xff)
	{
		ResetBus();
		Go(WaitATN);
	}
	else
		Go(Out1);
}
Пример #3
0
static int parallelcommand(void)
{
    serial_t *p;
    BYTE b;
    int channel;
    int i, st = 0;
    void *vdrive;
    unsigned int dnr;

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        if ((unsigned int)(TrapDevice & 0x0f) == dnr + 8
            && drive_context[dnr]->drive->enable) {
            return 0x83;    /* device not present */
        }
    }

    /* which device ? */
    p = serial_device_get(TrapDevice & 0x0f);
    vdrive = (void *)file_system_get_vdrive(TrapDevice & 0x0f);
    channel = TrapSecondary & 0x0f;

    /* if command on a channel, reset output buffer... */
    if ((TrapSecondary & 0xf0) != 0x60) {
        p->nextok[channel] = 0;
        p->lastok[channel] = 0;
    }
    switch (TrapSecondary & 0xf0) {
        case 0x60:
            /* Open Channel */
            if (!p->isopen[channel] == 1) {
                p->isopen[channel] = 2;
                st = (*(p->openf))(vdrive, NULL, 0, channel, NULL);
                for (i = 0; i < SerialPtr; i++) {
                    (*(p->putf))(vdrive, SerialBuffer[i], channel);
                }
                SerialPtr = 0;
            }
            if (p->flushf) {
                (*(p->flushf))(vdrive, channel);
            }

            if ((!st) && ((TrapDevice & 0xf0) == 0x40)) {
                /* any error, except eof */
                st = parallel_trap_receivebyte(&b, 1) & 0xbf;
            }
            break;
        case 0xE0:
            /* Close File */
            p->isopen[channel] = 0;
            st = (*(p->closef))(vdrive, channel);
            break;
        case 0xF0:
            /* Open File */
            if (p->isopen[channel]) {
#ifndef DELAYEDCLOSE
                if (p->isopen[channel] == 2) {
                    log_warning(parallel_log, "Bogus close?");
                    (*(p->closef))(vdrive, channel);
                }
                p->isopen[channel] = 2;
                SerialBuffer[SerialPtr] = 0;
                st = (*(p->openf))(vdrive, SerialBuffer, SerialPtr, channel, NULL);
                SerialPtr = 0;

                if (st) {
                    p->isopen[channel] = 0;
                    (*(p->closef))(vdrive, channel);
                    log_error(parallel_log, "Cannot open file. Status $%02x.", st);
                }
#else
                if (SerialPtr != 0 || channel == 0x0f) {
                    (*(p->closef))(vdrive, channel);
                    p->isopen[channel] = 2;

                    SerialBuffer[SerialPtr] = 0;
                    st = (*(p->openf))(vdrive, SerialBuffer, SerialPtr, channel, NULL);
                    SerialPtr = 0;

                    if (st) {
                        p->isopen[channel] = 0;
                        (*(p->closef))(vdrive, channel);
                        log_error(parallel_log, "Cannot open file. Status $%02x.", st);
                    }
                }
#endif
            }
            if (p->flushf) {
                (*(p->flushf))(vdrive, channel);
            }
            break;
        default:
            log_error(parallel_log, "Unknown command %02X.", TrapSecondary & 0xff);
    }
    return (st);
}