|
|
1.1 root 1: /* 1.1.1.2 ! root 2: Hatari - bios.c ! 3: ! 4: This file is distributed under the GNU Public License, version 2 or at ! 5: your option any later version. Read the file gpl.txt for details. 1.1 root 6: 7: Bios Handler (Trap #13) 8: 1.1.1.2 ! root 9: We intercept and direct some Bios calls to handle input/output to RS-232 ! 10: or the printer etc... 1.1 root 11: */ 1.1.1.2 ! root 12: char Bios_rcsid[] = "Hatari $Id: bios.c,v 1.5 2004/04/23 15:33:58 thothy Exp $"; 1.1 root 13: 14: #include "main.h" 1.1.1.2 ! root 15: #include "configuration.h" 1.1 root 16: #include "debug.h" 17: #include "floppy.h" 18: #include "m68000.h" 19: #include "misc.h" 20: #include "printer.h" 21: #include "rs232.h" 22: #include "stMemory.h" 1.1.1.2 ! root 23: #include "bios.h" 1.1 root 24: 25: 26: /*-----------------------------------------------------------------------*/ 27: /* 28: BIOS Return input device status 29: Call 1 30: */ 1.1.1.2 ! root 31: static BOOL Bios_Bconstat(unsigned long Params) 1.1 root 32: { 33: unsigned short Dev; 34: 35: Dev = STMemory_ReadWord(Params+SIZE_WORD); 1.1.1.2 ! root 36: ! 37: switch(Dev) ! 38: { ! 39: case 0: /* PRT: Centronics */ ! 40: if (ConfigureParams.Printer.bEnablePrinting) ! 41: { ! 42: Regs[REG_D0] = 0; /* No characters ready (cannot read from printer) */ ! 43: return(TRUE); ! 44: } ! 45: else ! 46: { ! 47: return(FALSE); ! 48: } ! 49: break; ! 50: case 1: /* AUX: RS-232 */ ! 51: if (ConfigureParams.RS232.bEnableRS232) ! 52: { ! 53: if (RS232_GetStatus()) ! 54: Regs[REG_D0] = -1; /* Chars waiting */ ! 55: else ! 56: Regs[REG_D0] = 0; ! 57: return(TRUE); ! 58: } 1.1 root 59: else 1.1.1.2 ! root 60: { ! 61: return(FALSE); ! 62: } ! 63: break; 1.1 root 64: } 65: 66: return(FALSE); 67: } 68: 1.1.1.2 ! root 69: 1.1 root 70: /*-----------------------------------------------------------------------*/ 71: /* 72: BIOS Read character from device 73: Call 2 74: */ 1.1.1.2 ! root 75: static BOOL Bios_Bconin(unsigned long Params) 1.1 root 76: { 77: unsigned short Dev; 78: unsigned char Char; 79: 80: Dev = STMemory_ReadWord(Params+SIZE_WORD); 1.1.1.2 ! root 81: ! 82: switch(Dev) ! 83: { ! 84: case 0: /* PRT: Centronics */ ! 85: if (ConfigureParams.Printer.bEnablePrinting) ! 86: { ! 87: Regs[REG_D0] = 0; /* Force NULL character (cannot read from printer) */ ! 88: return(TRUE); ! 89: } ! 90: else ! 91: { ! 92: return(FALSE); ! 93: } ! 94: break; ! 95: case 1: /* AUX: RS-232 */ ! 96: if (ConfigureParams.RS232.bEnableRS232) ! 97: { ! 98: RS232_ReadBytes(&Char, 1); ! 99: Regs[REG_D0] = Char; ! 100: return(TRUE); ! 101: } ! 102: else ! 103: { ! 104: return(FALSE); ! 105: } ! 106: break; 1.1 root 107: } 108: 109: return(FALSE); 110: } 111: 1.1.1.2 ! root 112: 1.1 root 113: /*-----------------------------------------------------------------------*/ 114: /* 115: BIOS Write character to device 116: Call 3 117: */ 1.1.1.2 ! root 118: static BOOL Bios_Bconout(unsigned long Params) 1.1 root 119: { 120: unsigned short Dev; 121: unsigned char Char; 122: 123: Dev = STMemory_ReadWord(Params+SIZE_WORD); 124: Char = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD); 1.1.1.2 ! root 125: ! 126: switch(Dev) ! 127: { 1.1 root 128: case 0: /* PRT: Centronics */ 1.1.1.2 ! root 129: if (ConfigureParams.Printer.bEnablePrinting) ! 130: { ! 131: Printer_TransferByteTo(Char); ! 132: return(TRUE); ! 133: } ! 134: else ! 135: { ! 136: return(FALSE); ! 137: } ! 138: break; 1.1 root 139: case 1: /* AUX: RS-232 */ 1.1.1.2 ! root 140: if (ConfigureParams.RS232.bEnableRS232) ! 141: { ! 142: RS232_TransferBytesTo(&Char, 1); ! 143: return(TRUE); ! 144: } ! 145: else ! 146: { ! 147: return(FALSE); ! 148: } ! 149: break; 1.1 root 150: } 151: 152: return(FALSE); 153: } 154: 1.1.1.2 ! root 155: 1.1 root 156: /*-----------------------------------------------------------------------*/ 157: /* 158: BIOS Read/Write disc sector 159: Call 4 160: */ 1.1.1.2 ! root 161: static BOOL Bios_RWabs(unsigned long Params) 1.1 root 162: { 163: #ifdef DEBUG_TO_FILE 164: char *pBuffer; 165: unsigned short int RWFlag,Number,RecNo,Dev; 166: 167: /* Read details from stack */ 168: RWFlag = STMemory_ReadWord(Params+SIZE_WORD); 169: pBuffer = (char *)STMemory_ReadLong(Params+SIZE_WORD+SIZE_WORD); 170: Number = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD+SIZE_LONG); 171: RecNo = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD+SIZE_LONG+SIZE_WORD); 172: Dev = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD+SIZE_LONG+SIZE_WORD+SIZE_WORD); 173: 174: Debug_FDC("RWABS %s,%d,0x%X,%d,%d\n",EmulationDrives[Dev].szFileName,RWFlag,(char *)STRAM_ADDR(pBuffer),RecNo,Number); 175: #endif 176: 177: return(FALSE); 178: } 179: 1.1.1.2 ! root 180: 1.1 root 181: /*-----------------------------------------------------------------------*/ 182: /* 183: BIOS Return output device status 184: Call 8 185: */ 1.1.1.2 ! root 186: static BOOL Bios_Bcostat(unsigned long Params) 1.1 root 187: { 188: unsigned short Dev; 189: 190: Dev = STMemory_ReadWord(Params+SIZE_WORD); 1.1.1.2 ! root 191: ! 192: switch(Dev) ! 193: { 1.1 root 194: case 0: /* PRT: Centronics */ 1.1.1.2 ! root 195: if (ConfigureParams.Printer.bEnablePrinting) ! 196: { ! 197: Regs[REG_D0] = -1; /* Device ready */ ! 198: return(TRUE); ! 199: } ! 200: else ! 201: { ! 202: return(FALSE); ! 203: } ! 204: break; 1.1 root 205: case 1: /* AUX: RS-232 */ 1.1.1.2 ! root 206: if (ConfigureParams.RS232.bEnableRS232) ! 207: { ! 208: Regs[REG_D0] = -1; /* Device ready */ ! 209: return(TRUE); ! 210: } ! 211: else ! 212: { ! 213: return(FALSE); ! 214: } ! 215: break; 1.1 root 216: } 217: 218: return(FALSE); 219: } 220: 221: 222: /*-----------------------------------------------------------------------*/ 223: /* 224: Check Bios call and see if we need to re-direct to our own routines 225: Return TRUE if we've handled the exception, else return FALSE to let TOS attempt it 226: */ 227: BOOL Bios(void) 228: { 229: unsigned long Params; 230: unsigned short int BiosCall; 231: 232: /* Get call */ 233: Params = Regs[REG_A7]; 234: BiosCall = STMemory_ReadWord(Params); 1.1.1.2 ! root 235: ! 236: /* Debug_File("BIOS %d\n",BiosCall); */ 1.1 root 237: 238: /* Intercept? */ 1.1.1.2 ! root 239: switch(BiosCall) ! 240: { 1.1 root 241: case 0x1: 242: return(Bios_Bconstat(Params)); 243: case 0x2: 244: return(Bios_Bconin(Params)); 245: case 0x3: 246: return(Bios_Bconout(Params)); 247: case 0x4: 248: return(Bios_RWabs(Params)); 249: case 0x8: 250: return(Bios_Bcostat(Params)); 251: default: /* Call as normal! */ 252: return(FALSE); 253: } 254: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.