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