Sigrid Haflínudóttirfirst dirty version of the portd7ad0686 years agoHistory
1224 lines · 25.5 KB · C
RawDownload
/*	VIAEMDEV.c 	Copyright (C) 2008 Philip Cummins, Paul C. Pratt 	You can redistribute this file and/or modify it under the terms	of version 2 of the GNU General Public License as published by	the Free Software Foundation.  You should have received a copy	of the license along with this file; see the file COPYING. 	This file is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	license for more details.*/ /*	Versatile Interface Adapter EMulated DEVice 	Emulates the VIA found in the Mac Plus. 	This code adapted from vMac by Philip Cummins.*/ #ifndef AllFiles#include "SYSDEPNS.h" #include "MYOSGLUE.h"#include "EMCONFIG.h"#include "GLOBGLUE.h"#endif #include "VIAEMDEV.h" /*	ReportAbnormalID unused 0x0410 - 0x04FF*/ #ifdef VIA1_iA0_ChangeNtfyIMPORTPROC VIA1_iA0_ChangeNtfy(void);#endif #ifdef VIA1_iA1_ChangeNtfyIMPORTPROC VIA1_iA1_ChangeNtfy(void);#endif #ifdef VIA1_iA2_ChangeNtfyIMPORTPROC VIA1_iA2_ChangeNtfy(void);#endif #ifdef VIA1_iA3_ChangeNtfyIMPORTPROC VIA1_iA3_ChangeNtfy(void);#endif #ifdef VIA1_iA4_ChangeNtfyIMPORTPROC VIA1_iA4_ChangeNtfy(void);#endif #ifdef VIA1_iA5_ChangeNtfyIMPORTPROC VIA1_iA5_ChangeNtfy(void);#endif #ifdef VIA1_iA6_ChangeNtfyIMPORTPROC VIA1_iA6_ChangeNtfy(void);#endif #ifdef VIA1_iA7_ChangeNtfyIMPORTPROC VIA1_iA7_ChangeNtfy(void);#endif #ifdef VIA1_iB0_ChangeNtfyIMPORTPROC VIA1_iB0_ChangeNtfy(void);#endif #ifdef VIA1_iB1_ChangeNtfyIMPORTPROC VIA1_iB1_ChangeNtfy(void);#endif #ifdef VIA1_iB2_ChangeNtfyIMPORTPROC VIA1_iB2_ChangeNtfy(void);#endif #ifdef VIA1_iB3_ChangeNtfyIMPORTPROC VIA1_iB3_ChangeNtfy(void);#endif #ifdef VIA1_iB4_ChangeNtfyIMPORTPROC VIA1_iB4_ChangeNtfy(void);#endif #ifdef VIA1_iB5_ChangeNtfyIMPORTPROC VIA1_iB5_ChangeNtfy(void);#endif #ifdef VIA1_iB6_ChangeNtfyIMPORTPROC VIA1_iB6_ChangeNtfy(void);#endif #ifdef VIA1_iB7_ChangeNtfyIMPORTPROC VIA1_iB7_ChangeNtfy(void);#endif #ifdef VIA1_iCB2_ChangeNtfyIMPORTPROC VIA1_iCB2_ChangeNtfy(void);#endif #define Ui3rPowOf2(p) (1 << (p))#define Ui3rTestBit(i, p) (((i) & Ui3rPowOf2(p)) != 0) #define VIA1_ORA_CanInOrOut (VIA1_ORA_CanIn | VIA1_ORA_CanOut) #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 7)#ifdef VIA1_iA7#error "VIA1_iA7 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 6)#ifdef VIA1_iA6#error "VIA1_iA6 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 5)#ifdef VIA1_iA5#error "VIA1_iA5 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 4)#ifdef VIA1_iA4#error "VIA1_iA4 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 3)#ifdef VIA1_iA3#error "VIA1_iA3 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 2)#ifdef VIA1_iA2#error "VIA1_iA2 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 1)#ifdef VIA1_iA1#error "VIA1_iA1 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORA_CanInOrOut, 0)#ifdef VIA1_iA0#error "VIA1_iA0 defined but not used"#endif#endif #define VIA1_ORB_CanInOrOut (VIA1_ORB_CanIn | VIA1_ORB_CanOut) #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 7)#ifdef VIA1_iB7#error "VIA1_iB7 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 6)#ifdef VIA1_iB6#error "VIA1_iB6 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 5)#ifdef VIA1_iB5#error "VIA1_iB5 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 4)#ifdef VIA1_iB4#error "VIA1_iB4 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 3)#ifdef VIA1_iB3#error "VIA1_iB3 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 2)#ifdef VIA1_iB2#error "VIA1_iB2 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 1)#ifdef VIA1_iB1#error "VIA1_iB1 defined but not used"#endif#endif #if ! Ui3rTestBit(VIA1_ORB_CanInOrOut, 0)#ifdef VIA1_iB0#error "VIA1_iB0 defined but not used"#endif#endif typedef struct {	ui5b T1C_F;  /* Timer 1 Counter Fixed Point */	ui5b T2C_F;  /* Timer 2 Counter Fixed Point */	ui3b ORB;    /* Buffer B */	/* ui3b ORA_H;     Buffer A with Handshake */	ui3b DDR_B;  /* Data Direction Register B */	ui3b DDR_A;  /* Data Direction Register A */	ui3b T1L_L;  /* Timer 1 Latch Low */	ui3b T1L_H;  /* Timer 1 Latch High */	ui3b T2L_L;  /* Timer 2 Latch Low */	ui3b SR;     /* Shift Register */	ui3b ACR;    /* Auxiliary Control Register */	ui3b PCR;    /* Peripheral Control Register */	ui3b IFR;    /* Interrupt Flag Register */	ui3b IER;    /* Interrupt Enable Register */	ui3b ORA;    /* Buffer A */} VIA1_Ty; LOCALVAR VIA1_Ty VIA1_D; #define kIntCA2 0 /* One_Second */#define kIntCA1 1 /* Vertical_Blanking */#define kIntSR 2 /* Keyboard_Data_Ready */#define kIntCB2 3 /* Keyboard_Data */#define kIntCB1 4 /* Keyboard_Clock */#define kIntT2 5 /* Timer_2 */#define kIntT1 6 /* Timer_1 */ #define VIA1_dolog (dbglog_HAVE && 0) /* VIA1_Get_ORA : VIA Get Port A Data *//*	This function queries VIA Port A interfaced hardware	about their status*/ LOCALFUNC ui3b VIA1_Get_ORA(ui3b Selection){	ui3b Value = (~ VIA1_ORA_CanIn) & Selection & VIA1_ORA_FloatVal; #if Ui3rTestBit(VIA1_ORA_CanIn, 7)	if (Ui3rTestBit(Selection, 7)) {		Value |= (VIA1_iA7 << 7);	}#endif #if Ui3rTestBit(VIA1_ORA_CanIn, 6)	if (Ui3rTestBit(Selection, 6)) {		Value |= (VIA1_iA6 << 6);	}#endif #if Ui3rTestBit(VIA1_ORA_CanIn, 5)	if (Ui3rTestBit(Selection, 5)) {		Value |= (VIA1_iA5 << 5);	}#endif #if Ui3rTestBit(VIA1_ORA_CanIn, 4)	if (Ui3rTestBit(Selection, 4)) {		Value |= (VIA1_iA4 << 4);	}#endif #if Ui3rTestBit(VIA1_ORA_CanIn, 3)	if (Ui3rTestBit(Selection, 3)) {		Value |= (VIA1_iA3 << 3);	}#endif #if Ui3rTestBit(VIA1_ORA_CanIn, 2)	if (Ui3rTestBit(Selection, 2)) {		Value |= (VIA1_iA2 << 2);	}#endif #if Ui3rTestBit(VIA1_ORA_CanIn, 1)	if (Ui3rTestBit(Selection, 1)) {		Value |= (VIA1_iA1 << 1);	}#endif #if Ui3rTestBit(VIA1_ORA_CanIn, 0)	if (Ui3rTestBit(Selection, 0)) {		Value |= (VIA1_iA0 << 0);	}#endif 	return Value;} /* VIA1_Get_ORB : VIA Get Port B Data *//*	This function queries VIA Port B interfaced hardware	about their status*/ LOCALFUNC ui3b VIA1_Get_ORB(ui3b Selection){	ui3b Value = (~ VIA1_ORB_CanIn) & Selection & VIA1_ORB_FloatVal; #if Ui3rTestBit(VIA1_ORB_CanIn, 7)	if (Ui3rTestBit(Selection, 7)) {		Value |= (VIA1_iB7 << 7);	}#endif #if Ui3rTestBit(VIA1_ORB_CanIn, 6)	if (Ui3rTestBit(Selection, 6)) {		Value |= (VIA1_iB6 << 6);	}#endif #if Ui3rTestBit(VIA1_ORB_CanIn, 5)	if (Ui3rTestBit(Selection, 5)) {		Value |= (VIA1_iB5 << 5);	}#endif #if Ui3rTestBit(VIA1_ORB_CanIn, 4)	if (Ui3rTestBit(Selection, 4)) {		Value |= (VIA1_iB4 << 4);	}#endif #if Ui3rTestBit(VIA1_ORB_CanIn, 3)	if (Ui3rTestBit(Selection, 3)) {		Value |= (VIA1_iB3 << 3);	}#endif #if Ui3rTestBit(VIA1_ORB_CanIn, 2)	if (Ui3rTestBit(Selection, 2)) {		Value |= (VIA1_iB2 << 2);	}#endif #if Ui3rTestBit(VIA1_ORB_CanIn, 1)	if (Ui3rTestBit(Selection, 1)) {		Value |= (VIA1_iB1 << 1);	}#endif #if Ui3rTestBit(VIA1_ORB_CanIn, 0)	if (Ui3rTestBit(Selection, 0)) {		Value |= (VIA1_iB0 << 0);	}#endif 	return Value;} #define ViaORcheckBit(p, x) \	(Ui3rTestBit(Selection, p) && \	((v = (Data >> p) & 1) != x)) LOCALPROC VIA1_Put_ORA(ui3b Selection, ui3b Data){#if 0 != VIA1_ORA_CanOut	ui3b v;#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 7)	if (ViaORcheckBit(7, VIA1_iA7)) {		VIA1_iA7 = v;#ifdef VIA1_iA7_ChangeNtfy		VIA1_iA7_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 6)	if (ViaORcheckBit(6, VIA1_iA6)) {		VIA1_iA6 = v;#ifdef VIA1_iA6_ChangeNtfy		VIA1_iA6_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 5)	if (ViaORcheckBit(5, VIA1_iA5)) {		VIA1_iA5 = v;#ifdef VIA1_iA5_ChangeNtfy		VIA1_iA5_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 4)	if (ViaORcheckBit(4, VIA1_iA4)) {		VIA1_iA4 = v;#ifdef VIA1_iA4_ChangeNtfy		VIA1_iA4_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 3)	if (ViaORcheckBit(3, VIA1_iA3)) {		VIA1_iA3 = v;#ifdef VIA1_iA3_ChangeNtfy		VIA1_iA3_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 2)	if (ViaORcheckBit(2, VIA1_iA2)) {		VIA1_iA2 = v;#ifdef VIA1_iA2_ChangeNtfy		VIA1_iA2_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 1)	if (ViaORcheckBit(1, VIA1_iA1)) {		VIA1_iA1 = v;#ifdef VIA1_iA1_ChangeNtfy		VIA1_iA1_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORA_CanOut, 0)	if (ViaORcheckBit(0, VIA1_iA0)) {		VIA1_iA0 = v;#ifdef VIA1_iA0_ChangeNtfy		VIA1_iA0_ChangeNtfy();#endif	}#endif} LOCALPROC VIA1_Put_ORB(ui3b Selection, ui3b Data){#if 0 != VIA1_ORB_CanOut	ui3b v;#endif #if Ui3rTestBit(VIA1_ORB_CanOut, 7)	if (ViaORcheckBit(7, VIA1_iB7)) {		VIA1_iB7 = v;#ifdef VIA1_iB7_ChangeNtfy		VIA1_iB7_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORB_CanOut, 6)	if (ViaORcheckBit(6, VIA1_iB6)) {		VIA1_iB6 = v;#ifdef VIA1_iB6_ChangeNtfy		VIA1_iB6_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORB_CanOut, 5)	if (ViaORcheckBit(5, VIA1_iB5)) {		VIA1_iB5 = v;#ifdef VIA1_iB5_ChangeNtfy		VIA1_iB5_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORB_CanOut, 4)	if (ViaORcheckBit(4, VIA1_iB4)) {		VIA1_iB4 = v;#ifdef VIA1_iB4_ChangeNtfy		VIA1_iB4_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORB_CanOut, 3)	if (ViaORcheckBit(3, VIA1_iB3)) {		VIA1_iB3 = v;#ifdef VIA1_iB3_ChangeNtfy		VIA1_iB3_ChangeNtfy();#endif	}#endif #if Ui3rTestBit(VIA1_ORB_CanOut, 2)	if (ViaORcheckBit(2, VIA1_iB2)) {		VIA1_iB2 = v;#ifdef VIA1_iB2_ChangeNtfy		VIA1_iB2_ChangeNtfy();

Lines 1–500 of 1224.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t