|
|
1.1 root 1: /*
1.1.1.3 root 2: Hatari - xbios.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: XBios Handler (Trap #14)
8:
1.1.1.3 root 9: We intercept and direct some XBios calls to handle the RS-232 etc. and help
10: with floppy debugging.
1.1 root 11: */
1.1.1.6 ! root 12: const char XBios_rcsid[] = "Hatari $Id: xbios.c,v 1.11 2006/02/12 21:28:22 eerot Exp $";
1.1 root 13:
14: #include "main.h"
1.1.1.3 root 15: #include "configuration.h"
1.1 root 16: #include "floppy.h"
1.1.1.4 root 17: #include "log.h"
1.1 root 18: #include "m68000.h"
19: #include "misc.h"
20: #include "rs232.h"
1.1.1.3 root 21: #include "screenSnapShot.h"
1.1 root 22: #include "stMemory.h"
1.1.1.3 root 23: #include "xbios.h"
24:
1.1 root 25:
1.1.1.4 root 26: #define XBIOS_DEBUG 0
27:
28:
1.1 root 29: /* List of Atari ST RS-232 baud rates */
1.1.1.6 ! root 30: static const int BaudRates[] = {
1.1.1.2 root 31: 19200, /* 0 */
32: 9600, /* 1 */
33: 4800, /* 2 */
34: 3600, /* 3 */
35: 2400, /* 4 */
36: 2000, /* 5 */
37: 1800, /* 6 */
38: 1200, /* 7 */
39: 600, /* 8 */
40: 300, /* 9 */
41: 200, /* 10 */
42: 150, /* 11 */
43: 134, /* 12 */
44: 110, /* 13 */
45: 75, /* 14 */
46: 50 /* 15 */
1.1 root 47: };
48:
1.1.1.2 root 49:
50: /*-----------------------------------------------------------------------*/
1.1 root 51: /*
52: XBIOS Floppy Read
53: Call 8
54: */
1.1.1.5 root 55: static BOOL XBios_Floprd(Uint32 Params)
1.1 root 56: {
1.1.1.4 root 57: #if XBIOS_DEBUG
1.1 root 58: char *pBuffer;
1.1.1.5 root 59: Uint16 Dev,Sector,Side,Track,Count;
1.1 root 60:
1.1.1.2 root 61: /* Read details from stack */
1.1 root 62: pBuffer = (char *)STRAM_ADDR(STMemory_ReadLong(Params+SIZE_WORD));
63: Dev = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG);
64: Sector = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD);
65: Track = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD+SIZE_WORD);
66: Side = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD+SIZE_WORD+SIZE_WORD);
67: Count = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD);
68:
1.1.1.4 root 69: Log_Printf(LOG_DEBUG, "FLOPRD %s,%d,%d,%d,%d at addr 0x%X\n", EmulationDrives[Dev].szFileName,
70: Side, Track, Sector, Count, m68k_getpc());
1.1 root 71: #endif
72:
73: return(FALSE);
74: }
75:
1.1.1.2 root 76:
77: /*-----------------------------------------------------------------------*/
1.1 root 78: /*
79: XBIOS Floppy Write
80: Call 9
81: */
1.1.1.5 root 82: static BOOL XBios_Flopwr(Uint32 Params)
1.1 root 83: {
1.1.1.4 root 84: #if XBIOS_DEBUG
1.1 root 85: char *pBuffer;
1.1.1.5 root 86: Uint16 Dev,Sector,Side,Track,Count;
1.1 root 87:
1.1.1.2 root 88: /* Read details from stack */
1.1 root 89: pBuffer = (char *)STRAM_ADDR(STMemory_ReadLong(Params+SIZE_WORD));
90: Dev = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG);
91: Sector = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD);
92: Track = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD+SIZE_WORD);
93: Side = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD+SIZE_WORD+SIZE_WORD);
94: Count = STMemory_ReadWord(Params+SIZE_WORD+SIZE_LONG+SIZE_LONG+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD);
95:
1.1.1.4 root 96: Log_Printf(LOG_DEBUG, "FLOPWR %s,%d,%d,%d,%d at addr 0x%X\n", EmulationDrives[Dev].szFileName,
97: Side, Track, Sector, Count, m68k_getpc());
1.1 root 98: #endif
99:
100: return(FALSE);
101: }
102:
1.1.1.2 root 103:
104: /*-----------------------------------------------------------------------*/
1.1 root 105: /*
106: XBIOS RsConf
107: Call 15
108: */
1.1.1.5 root 109: static BOOL XBios_Rsconf(Uint32 Params)
1.1 root 110: {
111: short int Baud,Ctrl,Ucr,Rsr,Tsr,Scr;
112:
113: Baud = STMemory_ReadWord(Params+SIZE_WORD);
114: Ctrl = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD);
115: Ucr = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD+SIZE_WORD);
116: Rsr = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD);
117: Tsr = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD);
118: Scr = STMemory_ReadWord(Params+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD+SIZE_WORD);
119:
1.1.1.3 root 120: /* Set baud rate and other configuration, if RS232 emaulation is enabled */
121: if (ConfigureParams.RS232.bEnableRS232)
122: {
123: if (Baud>=0 && Baud<=15)
124: {
125: /* Convert ST baud rate index to value */
126: int BaudRate = BaudRates[Baud];
127: /* And set new baud rate: */
128: RS232_SetBaudRate(BaudRate);
129: }
130:
131: if (Ucr != -1)
132: {
133: RS232_HandleUCR(Ucr);
134: }
135:
136: if (Ctrl != -1)
137: {
138: RS232_SetFlowControl(Ctrl);
139: }
1.1 root 140:
141: return(TRUE);
142: }
143:
144: return(FALSE);
145: }
146:
1.1.1.2 root 147:
148: /*-----------------------------------------------------------------------*/
1.1 root 149: /*
150: XBIOS Scrdmp
151: Call 20
152: */
1.1.1.5 root 153: static BOOL XBios_Scrdmp(Uint32 Params)
1.1 root 154: {
1.1.1.3 root 155: fprintf(stderr, "XBIOS screendump!\n");
156:
157: ScreenSnapShot_SaveScreen();
158:
1.1.1.2 root 159: /* Correct return code? */
1.1 root 160: Regs[REG_D0] = 0;
161:
162: return(TRUE);
163: }
164:
1.1.1.2 root 165:
166: /*----------------------------------------------------------------------- */
1.1 root 167: /*
168: XBIOS Prtblk
169: Call 36
170: */
1.1.1.5 root 171: static BOOL XBios_Prtblk(Uint32 Params)
1.1 root 172: {
1.1.1.3 root 173: fprintf(stderr, "Intercepted XBIOS Prtblk()\n");
1.1.1.2 root 174:
1.1.1.3 root 175: /* Correct return code? */
1.1 root 176: Regs[REG_D0] = 0;
177:
178: return(TRUE);
179: }
180:
1.1.1.2 root 181:
182: /*-----------------------------------------------------------------------*/
1.1 root 183: /*
184: Check if we need to re-direct XBios call to our own routines
185: */
186: BOOL XBios(void)
187: {
1.1.1.5 root 188: Uint32 Params;
189: Uint16 XBiosCall;
1.1 root 190:
191: /* Find call */
192: Params = Regs[REG_A7];
193: XBiosCall = STMemory_ReadWord(Params);
1.1.1.3 root 194:
1.1.1.4 root 195: /*Log_Printf(LOG_DEBUG, "XBIOS %d\n",XBiosCall);*/
1.1 root 196:
1.1.1.3 root 197: switch(XBiosCall)
198: {
1.1 root 199: case 8:
200: return(XBios_Floprd(Params));
201: case 9:
202: return(XBios_Flopwr(Params));
203: case 15:
204: return(XBios_Rsconf(Params));
205: case 20:
206: return(XBios_Scrdmp(Params));
207: case 36:
208: return(XBios_Prtblk(Params));
209:
1.1.1.2 root 210: default: /* Call as normal! */
1.1 root 211: return(FALSE);
212: }
213: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.