|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * A "replacement" for a missing Kickstart ! 5: * Warning! Q&D ! 6: * ! 7: * (c) 1995 Bernd Schmidt ! 8: */ ! 9: ! 10: #include "sysconfig.h" ! 11: #include "sysdeps.h" ! 12: ! 13: #include "config.h" ! 14: #include "options.h" ! 15: #include "memory.h" ! 16: #include "custom.h" ! 17: #include "newcpu.h" ! 18: #include "cia.h" ! 19: #include "disk.h" ! 20: #include "ersatz.h" ! 21: ! 22: #define EOP_INIT 0 ! 23: #define EOP_NIMP 1 ! 24: #define EOP_SERVEINT 2 ! 25: #define EOP_DOIO 3 ! 26: #define EOP_OPENLIB 4 ! 27: #define EOP_AVAILMEM 5 ! 28: #define EOP_ALLOCMEM 6 ! 29: #define EOP_ALLOCABS 7 ! 30: ! 31: void init_ersatz_rom (UBYTE *data) ! 32: { ! 33: fprintf(stderr, "Trying to use Kickstart replacement.\n"); ! 34: *data++ = 0x00; *data++ = 0x08; /* initial SP */ ! 35: *data++ = 0x00; *data++ = 0x00; ! 36: *data++ = 0x00; *data++ = 0xF8; /* initial PC */ ! 37: *data++ = 0x00; *data++ = 0x08; ! 38: ! 39: *data++ = 0xFF; *data++ = 0x0D; ! 40: *data++ = 0x00; *data++ = EOP_INIT; ! 41: *data++ = 0xFF; *data++ = 0x0D; ! 42: *data++ = 0x00; *data++ = EOP_NIMP; ! 43: ! 44: *data++ = 0xFF; *data++ = 0x0D; ! 45: *data++ = 0x00; *data++ = EOP_DOIO; ! 46: *data++ = 0x4E; *data++ = 0x75; ! 47: *data++ = 0xFF; *data++ = 0x0D; ! 48: ! 49: *data++ = 0x00; *data++ = EOP_SERVEINT; ! 50: *data++ = 0x4E; *data++ = 0x73; ! 51: *data++ = 0xFF; *data++ = 0x0D; ! 52: *data++ = 0x00; *data++ = EOP_AVAILMEM; ! 53: ! 54: *data++ = 0x4E; *data++ = 0x75; ! 55: *data++ = 0xFF; *data++ = 0x0D; ! 56: *data++ = 0x00; *data++ = EOP_ALLOCMEM; ! 57: *data++ = 0x4E; *data++ = 0x75; ! 58: ! 59: *data++ = 0xFF; *data++ = 0x0D; ! 60: *data++ = 0x00; *data++ = EOP_ALLOCABS; ! 61: *data++ = 0x4E; *data++ = 0x75; ! 62: } ! 63: ! 64: static void ersatz_doio (void) ! 65: { ! 66: CPTR request = regs.a[1]; ! 67: switch (get_word (request + 0x1C)) { ! 68: case 9: /* TD_MOTOR is harmless */ ! 69: case 2: case 0x8002: /* READ commands */ ! 70: break; ! 71: ! 72: default: ! 73: fprintf(stderr, "Only CMD_READ supported in DoIO()\n"); ! 74: abort(); ! 75: } ! 76: { ! 77: CPTR dest = get_long (request + 0x28); ! 78: int start = get_long (request + 0x2C) / 512; ! 79: int nsecs = get_long (request + 0x24) / 512; ! 80: int tr = start / 11; ! 81: int sec = start % 11; ! 82: while (nsecs--) { ! 83: DISK_ersatz_read (tr, sec, dest); ! 84: dest += 512; ! 85: if (++sec == 11) ! 86: sec = 0, tr++; ! 87: } ! 88: } ! 89: } ! 90: ! 91: static void ersatz_init (void) ! 92: { ! 93: int f; ! 94: CPTR request; ! 95: CPTR a; ! 96: ! 97: regs.s = 0; ! 98: /* Set some interrupt vectors */ ! 99: for (a = 8; a < 0xC0; a += 4) { ! 100: put_long (a, 0xF80016); ! 101: } ! 102: regs.isp = regs.msp = regs.usp = 0x800; ! 103: regs.a[7] = 0x80000; ! 104: regs.intmask = 0; ! 105: ! 106: /* Build a dummy execbase */ ! 107: put_long (4, regs.a[6] = 0x676); ! 108: put_byte (0x676 + 0x129, 0); ! 109: for (f = 1; f < 105; f++) { ! 110: put_word (0x676 - 6*f, 0x4EF9); ! 111: put_long (0x676 - 6*f + 2, 0xF8000C); ! 112: } ! 113: /* Some "supported" functions */ ! 114: put_long (0x676 - 456 + 2, 0xF80010); ! 115: put_long (0x676 - 216 + 2, 0xF8001C); ! 116: put_long (0x676 - 198 + 2, 0xF80022); ! 117: put_long (0x676 - 204 + 2, 0xF80028); ! 118: put_long (0x676 - 210 + 2, 0xF80026); ! 119: ! 120: /* Build an IORequest */ ! 121: request = 0x800; ! 122: put_word (request + 0x1C, 2); ! 123: put_long (request + 0x28, 0x4000); ! 124: put_long (request + 0x2C, 0); ! 125: put_long (request + 0x24, 0x200 * 4); ! 126: regs.a[1] = request; ! 127: ersatz_doio (); ! 128: m68k_setpc (0x400C); ! 129: ! 130: /* Init the hardware */ ! 131: put_long (0x3000, 0xFFFFFFFE); ! 132: put_long (0xDFF080, 0x3000); ! 133: put_word (0xDFF088, 0); ! 134: put_word (0xDFF096, 0xE390); ! 135: put_word (0xDFF09A, 0xE02C); ! 136: put_word (0xDFF09E, 0x0000); ! 137: put_word (0xDFF092, 0x0038); ! 138: put_word (0xDFF094, 0x00D0); ! 139: put_word (0xDFF08E, 0x2C81); ! 140: put_word (0xDFF090, 0xF4C1); ! 141: put_word (0xDFF02A, 0x8000); ! 142: ! 143: put_byte (0xBFD100, 0xF7); ! 144: put_byte (0xBFEE01, 0); ! 145: put_byte (0xBFEF01, 0x08); ! 146: put_byte (0xBFDE00, 0x04); ! 147: put_byte (0xBFDF00, 0x84); ! 148: put_byte (0xBFDD00, 0x9F); ! 149: put_byte (0xBFED01, 0x9F); ! 150: } ! 151: ! 152: void ersatz_perform (UWORD what) ! 153: { ! 154: switch (what) { ! 155: case EOP_INIT: ! 156: ersatz_init (); ! 157: break; ! 158: ! 159: case EOP_SERVEINT: ! 160: /* Just reset all the interrupt request bits */ ! 161: put_word (0xDFF09C, get_word (0xDFF01E) & 0x3FFF); ! 162: break; ! 163: ! 164: case EOP_DOIO: ! 165: ersatz_doio (); ! 166: break; ! 167: ! 168: case EOP_AVAILMEM: ! 169: regs.d[0] = regs.d[1] & 4 ? 0 : 0x70000; ! 170: break; ! 171: ! 172: case EOP_ALLOCMEM: ! 173: regs.d[0] = regs.d[1] & 4 ? 0 : 0x0F000; ! 174: break; ! 175: ! 176: case EOP_ALLOCABS: ! 177: regs.d[0] = regs.a[1]; ! 178: break; ! 179: ! 180: case EOP_NIMP: ! 181: fprintf(stderr, "Unimplemented Kickstart function called\n"); ! 182: abort (); ! 183: case EOP_OPENLIB: ! 184: default: ! 185: fprintf(stderr, "Internal error. Giving up.\n"); ! 186: abort (); ! 187: } ! 188: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.