|
|
1.1 root 1: /*
2: Hatari
3:
4: Load TOS image file into ST memory, fix/setup for emulator
5:
6: The Atari ST TOS needs to be patched to help with emulation. Eg, it references the MMU chip
7: to set memory size. This is patched to the sizes we need without the complicated emulation
8: of hardware which is not needed(as yet). We also patch DMA devices and Hard Drives.
9: NOTE: TOS versions 1.06 and 1.62 were not designed for use on a real STfm. These were for the
10: STe machine ONLY. They access the DMA/Microwire addresses on boot-up which(correctly) cause a
11: bus-error on Hatari as they would in a real STfm. If a user tries to select any of these images
1.1.1.5 ! root 12: we bring up an error.
1.1 root 13: */
14:
1.1.1.4 root 15: #include <SDL_types.h>
16:
1.1 root 17: #include "main.h"
18: #include "cart.h"
19: #include "debug.h"
20: #include "decode.h"
21: #include "dialog.h"
22: #include "errlog.h"
23: #include "file.h"
24: #include "floppy.h"
1.1.1.4 root 25: #include "gemdos.h"
26: #include "hdc.h"
1.1 root 27: #include "m68000.h"
28: #include "memAlloc.h"
29: #include "memorySnapShot.h"
30: #include "stMemory.h"
31: #include "tos.h"
32: #include "vdi.h"
33:
34:
35: /* Settings for differnt memory sizes */
36: static MEMORY_INFO MemoryInfo[] = {
1.1.1.5 ! root 37: { 0x80000,0x0000,0x00080000 }, /* MEMORYSIZE_512 */
! 38: { 0x100000,0x0101,0x00100000 }, /* MEMORYSIZE_1024 */
! 39: { 0x200000,0x0001,0x00200000 }, /* MEMORYSIZE_2MB */
! 40: { 0x400000,0x1010,0x00400000 } /* MEMORYSIZE_4MB */
1.1 root 41: };
42:
1.1.1.4 root 43: /* Bit masks of connected drives(we support up to C,D,E,F,G,H) */
1.1 root 44: unsigned int ConnectedDriveMaskList[] = {
45: 0x03, /* DRIVELIST_NONE A,B */
46: 0x07, /* DRIVELIST_C A,B,C */
47: 0x0F, /* DRIVELIST_CD A,B,C,D */
48: 0x1F, /* DRIVELIST_CDE A,B,C,D,E */
49: 0x3F, /* DRIVELIST_CDEF A,B,C,D,E,F */
1.1.1.4 root 50: 0x7F, /* DRIVELIST_CDEFG A,B,C,D,E,F,G */
51: 0xFF, /* DRIVELIST_CDEFGH A,B,C,D,E,F,G,H */
1.1 root 52: };
53:
54: unsigned short int TOSVersion; /* eg, 0x0100, 0x0102 */
1.1.1.4 root 55: unsigned long TOSAddress, TOSSize; /* Address in ST memory and size of TOS image */
1.1 root 56: unsigned int ConnectedDriveMask=0x03; /* Bit mask of connected drives, eg 0x7 is A,B,C */
57:
58: /* Possible TOS file extensions to scan for */
59: char *pszTOSNameExts[] = {
60: ".img",
61: ".rom",
62: ".tos",
63: NULL
64: };
65:
66: /* Taken from Decode.asm - Thothy */
67: unsigned long STRamEnd; /* End of ST Ram, above this address is no-mans-land and hardware vectors */
68: unsigned long STRamEnd_BusErr; /* as above, but start of BUS error exception */
69:
70:
71:
1.1.1.3 root 72: /*-----------------------------------------------------------------------*/
1.1 root 73: /*
74: Save/Restore snapshot of local variables('MemorySnapShot_Store' handles type)
75: */
76: void TOS_MemorySnapShot_Capture(BOOL bSave)
77: {
1.1.1.3 root 78: /* Save/Restore details */
1.1 root 79: MemorySnapShot_Store(&TOSVersion,sizeof(TOSVersion));
80: MemorySnapShot_Store(&TOSAddress,sizeof(TOSAddress));
81: MemorySnapShot_Store(&TOSSize,sizeof(TOSSize));
82: MemorySnapShot_Store(&ConnectedDriveMask,sizeof(ConnectedDriveMask));
83: }
84:
1.1.1.3 root 85:
86: /*-----------------------------------------------------------------------*/
1.1 root 87: /*
88: Load TOS Rom image file into ST memory space and fix image so can emulate correctly
89: Pre TOS 1.06 are loaded at 0xFC0000 with later ones at 0xE00000
90: If we cannot find the TOS image, or we detect an error we default to the built-in
91: TOS 1.00 image. This works great for new users who do not understand the idea of a TOS
92: Rom and are confused when presented with a 'select TOS image' dialog.
93: */
94: void TOS_LoadImage(void)
95: {
96: void *pTOSFile = NULL;
97: BOOL bTOSImageLoaded = FALSE;
98:
99: /* Load TOS image into memory so we can check it's vesion */
100: TOSVersion = 0;
1.1.1.4 root 101: pTOSFile = File_Read(ConfigureParams.TOSGEM.szTOSImageFileName,NULL,NULL,pszTOSNameExts);
1.1 root 102:
1.1.1.5 ! root 103: if (pTOSFile)
! 104: {
1.1.1.4 root 105: bTOSImageLoaded = TRUE;
106: /* Now, look at start of image to find Version number and address */
107: TOSVersion = STMemory_Swap68000Int( *(Uint16 *)((Uint32)pTOSFile+2) );
108: TOSAddress = STMemory_Swap68000Long( *(Uint32 *)((Uint32)pTOSFile+8) );
109:
110: TOSSize = File_Length(ConfigureParams.TOSGEM.szTOSImageFileName);
111: if( TOSSize<=0 ) bTOSImageLoaded = FALSE;
112:
113: /* TOSes 1.06 and 1.62 are for the STe ONLY and so don't run on a real STfm. */
114: /* They access illegal memory addresses which don't exist on a real machine and cause the OS */
115: /* to lock up. So, if user selects one of these, show an error */
1.1.1.5 ! root 116: if( TOSVersion==0x0106 || TOSVersion==0x0162 )
! 117: {
1.1.1.4 root 118: Main_Message("TOS versions 1.06 and 1.62 are NOT valid STfm images.\n\n"
119: "These were only designed for use on the STe range of machines.\n", PROG_NAME /*,MB_OK|MB_ICONINFORMATION*/);
120: bTOSImageLoaded = FALSE;
1.1 root 121: }
122:
123: /* Copy loaded image into ST memory, if found valid one*/
124: if (bTOSImageLoaded)
125: memcpy((void *)((unsigned long)STRam+TOSAddress),pTOSFile,TOSSize);
126: }
127:
128: /* Are we allowed VDI under this TOS? */
1.1.1.5 ! root 129: if ( (TOSVersion<0x0104) && (bUseVDIRes) )
! 130: {
1.1 root 131: /* Warn user (exit if need to) */
132: Main_Message("To use GEM Extended resolutions, you must select TOS 1.04 or higher.",PROG_NAME /*,MB_OK|MB_ICONINFORMATION*/);
133: /* And select non VDI */
1.1.1.4 root 134: bUseVDIRes = ConfigureParams.TOSGEM.bUseExtGEMResolutions = FALSE;
1.1 root 135: }
136:
137: /* Did we load a TOS image correctly? */
1.1.1.5 ! root 138: if (!bTOSImageLoaded)
! 139: {
1.1 root 140: fprintf(stderr, "Error: No tos.img loaded!\n");
141: exit(-1);
142: }
143:
144: /* Fix TOS image, modify code for emulation */
145: TOS_FixRom();
146:
147: /* Set connected devices, memory configuration */
148: TOS_SetDefaultMemoryConfig();
149:
150: /* and free loaded image */
151: Memory_Free(pTOSFile);
152: }
153:
1.1.1.3 root 154:
155: /*-----------------------------------------------------------------------*/
1.1 root 156: /*
1.1.1.4 root 157: Patch TOS to skip some TOS setup code which we don't support/need.
1.1 root 158: As TOS Roms need to be modified we can only run images which are entered here.
159:
160: So, how do we find these addresses when we have no commented source code?
161: Easy,
162: Hdv_init: Scan start of TOS for table of move.l <addr>,$46A(a5), around 0x224 bytes in
163: and look at the first entry - that's the hdv_init address.
164: Hdv_boot: Scan start of TOS for table of move.l <addr>,$47A(a5), and look for 5th entry
165: - that's the hdv_boot address. The function starts with link,movem,jsr.
166: Boot from DMA bus: again scan at start of rom for tst.w $482, boot call will be just above it.
167: Set connected drives: search for 'clr.w' and '$4c2' to find, may use (a5) in which case op-code
168: is only 4 bytes and also note this is only do on TOS's after 1.00
169: */
170: void TOS_FixRom(void)
171: {
1.1.1.4 root 172: switch(TOSVersion)
173: {
1.1 root 174: /*
175: TOS 1.00 settings
176: */
177: case 0x0100:
178: /* hdv_init, initialize drives */
1.1.1.3 root 179: STMemory_WriteWord(0xFC0D60,RTS_OPCODE); /* RTS */
1.1 root 180:
181: /* FC1384 JSR $FC0AF8 hdv_boot, load boot sector */
1.1.1.3 root 182: STMemory_WriteWord(0xFC1384,NOP_OPCODE); /* NOP */
183: STMemory_WriteWord(0xFC1384+2,NOP_OPCODE); /* NOP */
184: STMemory_WriteWord(0xFC1384+4,NOP_OPCODE); /* NOP */
1.1 root 185:
186: /* FC03d6 JSR $FC04A8 Boot from DMA bus */
1.1.1.4 root 187: /* This doesn't need to be patched - but we do
188: need to force set condrv ($4c2), because the
189: ACSI driver (if any) will reset it, this is
190: done after the DMA bus boot (when the driver loads),
191: replacing the RTS with our own
192: routine which sets condrv and then RTSes. */
193: if(ACSI_EMU_ON || GEMDOS_EMU_ON)
1.1.1.5 ! root 194: {
1.1.1.4 root 195: STMemory_WriteWord(0xFC04d4, CONDRV_OPCODE);
1.1.1.5 ! root 196: }
1.1.1.4 root 197: else
198: {
1.1.1.5 ! root 199: STMemory_WriteWord(0xFC03D6,NOP_OPCODE); /* NOP */
! 200: STMemory_WriteWord(0xFC03D6+2,NOP_OPCODE); /* NOP */
1.1 root 201: }
202:
203: /* Timer D(MFP init 0xFC21B4), set value before call Set Timer routine */
204: STMemory_WriteWord(0xFC21F6,TIMERD_OPCODE);
205:
206: /* Modify assembler loaded into cartridge area */
207: Cart_WriteHdvAddress(0x167A);
208: break;
209:
210: /*
211: TOS 1.02 settings
212: */
213: case 0x0102:
214: /* hdv_init, initialize drives */
1.1.1.4 root 215: if( STMemory_ReadLong(0xFC0F44)==0x4e56fff0L ) /* Check if we can patch this TOS */
216: STMemory_WriteWord(0xFC0F44, RTS_OPCODE); /* RTS */
1.1 root 217:
218: /* FC1568 JSR $FC0C2E hdv_boot, load boot sector */
1.1.1.5 ! root 219: if( STMemory_ReadLong(0xFC1568)==0x4eb900fcL )
! 220: {
! 221: STMemory_WriteWord(0xFC1568, NOP_OPCODE); /* NOP */
1.1.1.4 root 222: STMemory_WriteWord(0xFC1568+2, NOP_OPCODE); /* NOP */
223: STMemory_WriteWord(0xFC1568+4, NOP_OPCODE); /* NOP */
1.1 root 224: }
225:
1.1.1.5 ! root 226: /* see comments above -Sven */
! 227: if(ACSI_EMU_ON || GEMDOS_EMU_ON)
! 228: {
! 229: STMemory_WriteWord(0xFC0584, CONDRV_OPCODE);
! 230: }
1.1.1.4 root 231: else
1.1.1.5 ! root 232: {
! 233: /* FC0302 CLR.L $4C2 Set connected drives */
! 234: if( STMemory_ReadLong(0xFC0302)==0x42b90000L )
! 235: {
! 236: STMemory_WriteWord(0xFC0302, NOP_OPCODE);
! 237: STMemory_WriteWord(0xFC0302+2, NOP_OPCODE); /* NOP */
! 238: STMemory_WriteWord(0xFC0302+4, NOP_OPCODE); /* NOP */
! 239: }
1.1.1.4 root 240:
1.1.1.5 ! root 241: /* FC0472 BSR.W $FC0558 Boot from DMA bus */
! 242: if( STMemory_ReadLong(0xFC0472)==0x610000e4L )
! 243: {
! 244: STMemory_WriteWord(0xFC0472, NOP_OPCODE); /* NOP */
! 245: STMemory_WriteWord(0xFC0472+2, NOP_OPCODE); /* NOP */
! 246: }
! 247: }
1.1 root 248:
1.1.1.3 root 249: /* Timer D (MFP init 0xFC2408) */
1.1.1.4 root 250: if( STMemory_ReadLong(0xFC2450)==0x74026100 )
251: STMemory_WriteWord(0xFC2450, TIMERD_OPCODE);
1.1 root 252:
1.1.1.3 root 253: /* Modify assembler loaded into cartridge area */
1.1 root 254: Cart_WriteHdvAddress(0x16DA);
255: break;
256:
257: /*
258: TOS 1.04 settings
259: */
260: case 0x0104:
261: /* hdv_init, initialize drives */
1.1.1.3 root 262: STMemory_WriteWord(0xFC16BA,RTS_OPCODE); /* RTS */
1.1 root 263:
264: /* FC1CCE JSR $FC0BD8 hdv_boot, load boot sector */
1.1.1.3 root 265: STMemory_WriteWord(0xFC1CCE,NOP_OPCODE); /* NOP */
266: STMemory_WriteWord(0xFC1CCE + 2,NOP_OPCODE); /* NOP */
267: STMemory_WriteWord(0xFC1CCE + 4,NOP_OPCODE); /* NOP */
1.1 root 268:
269: /* FC0466 BSR.W $FC054C Boot from DMA bus */
1.1.1.4 root 270: /* see comment above -Sven */
1.1.1.5 ! root 271: if(ACSI_EMU_ON || GEMDOS_EMU_ON)
! 272: {
! 273: STMemory_WriteWord(0xFC0576, CONDRV_OPCODE);
! 274: }
1.1.1.4 root 275: else
1.1.1.5 ! root 276: {
! 277: /* FC02E6 CLR.L $4C2(A5) Set connected drives */
! 278: STMemory_WriteWord(0xFC02E6,NOP_OPCODE);
! 279: STMemory_WriteWord(0xFC02E6+2,NOP_OPCODE); /* NOP */
1.1.1.4 root 280:
1.1.1.5 ! root 281: STMemory_WriteWord(0xFC0466,NOP_OPCODE); /* NOP */
! 282: STMemory_WriteWord(0xFC0466+2,NOP_OPCODE); /* NOP */
! 283: }
1.1 root 284:
285: /* Timer D(MFP init 0xFC34FC) */
286: STMemory_WriteWord(0xFC3544,TIMERD_OPCODE);
287:
288: /* Modify assembler loaded into cartridge area */
289: Cart_WriteHdvAddress(0x181C);
290: break;
291:
292: /*
293: TOS 1.06 settings
294: */
295: // case 0x0106:
296: // // hdv_init, initialize drives
297: // STMemory_WriteWord(0xE01892,RTS_OPCODE); //RTS
298: //
299: // // E01EA6 JSR $E00D74 hdv_boot, load boot sector
300: // STMemory_WriteWord(0xE01EA6,NOP_OPCODE); //NOP
301: // STMemory_WriteWord(0xE01EA6+2,NOP_OPCODE); //NOP
302: // STMemory_WriteWord(0xE01EA6+4,NOP_OPCODE); //NOP
303: //
304: // // E00576 BSR.W $E0065C Boot from DMA bus
305: // if (bUseVDIRes) {
306: // STMemory_WriteWord(0xE00576,0xa000); //Init Line-A
307: // STMemory_WriteWord(0xE00576+2,0xa0ff); //Trap Line-A(to get structure)
308: // }
309: // else {
310: // STMemory_WriteWord(0xE00576,NOP_OPCODE); //NOP
311: // STMemory_WriteWord(0xE00576+2,NOP_OPCODE); //NOP
312: // }
313: //
314: // // E002DC CLR.L $4C2(A5) Set connected drives
315: // STMemory_WriteWord(0xE002DC,CONDRV_OPCODE);
316: // STMemory_WriteWord(0xE002DC+2,NOP_OPCODE); //NOP
317: //
318: // // Timer D(MFP init 0xE036BC)
319: // STMemory_WriteWord(0xE03704,TIMERD_OPCODE);
320: //
321: // // Modify assembler loaded into cartridge area
322: // Cart_WriteHdvAddress(0x185C);
323: // break;
324:
325: /*
326: TOS 1.62 settings
327: */
328: // case 0x0162:
329: // // hdv_init, initialize drives
330: // STMemory_WriteWord(0xE01892,RTS_OPCODE); //RTS
331: //
332: // // E01EA6 JSR $E00D74 hdv_boot, load boot sector
333: // STMemory_WriteWord(0xE01EA6,NOP_OPCODE); //NOP
334: // STMemory_WriteWord(0xE01EA6+2,NOP_OPCODE); //NOP
335: // STMemory_WriteWord(0xE01EA6+4,NOP_OPCODE); //NOP
336: //
337: // // E00576 BSR.W $E0065C Boot from DMA bus
338: // if (bUseVDIRes) {
339: // STMemory_WriteWord(0xE00576,0xa000); //Init Line-A
340: // STMemory_WriteWord(0xE00576+2,0xa0ff); //Trap Line-A(to get structure)
341: // }
342: // else {
343: // STMemory_WriteWord(0xE00576,NOP_OPCODE); //NOP
344: // STMemory_WriteWord(0xE00576+2,NOP_OPCODE); //NOP
345: // }
346: //
347: // // E002DC CLR.L $4C2(A5) Set connected drives
348: // STMemory_WriteWord(0xE002DC,CONDRV_OPCODE);
349: // STMemory_WriteWord(0xE002DC+2,NOP_OPCODE); //NOP
350: //
351: // // Timer D(MFP init 0xE036BC)
352: // STMemory_WriteWord(0xE03704,TIMERD_OPCODE);
353: //
354: // // Modify assembler loaded into cartridge area
355: // Cart_WriteHdvAddress(0x185C);
356: // break;
357:
358: /*
359: TOS 2.05 settings
360: */
361: case 0x0205:
1.1.1.3 root 362: /* hdv_init, initialize drives */
363: STMemory_WriteWord(0xE0468C,RTS_OPCODE); /* RTS */
1.1 root 364:
1.1.1.3 root 365: /* E04CA0 JSR $E00E8E hdv_boot, load boot sector */
1.1.1.4 root 366: // STMemory_WriteWord(0xE04CA0,NOP_OPCODE); /* NOP */
367: //STMemory_WriteWord(0xE04CA0+2,NOP_OPCODE); /* NOP */
368: //STMemory_WriteWord(0xE04CA0+4,NOP_OPCODE); /* NOP */
1.1 root 369:
1.1.1.3 root 370: /* E006AE BSR.W $E00794 Boot from DMA bus */
1.1.1.4 root 371: /* The 2.0x DMA bus boot routine uses two RTSes - patch both */
372: if(ACSI_EMU_ON || GEMDOS_EMU_ON)
1.1.1.5 ! root 373: {
! 374: /* no bootable DMA devices */
! 375: STMemory_WriteWord(0xE0081A, CONDRV_OPCODE);
! 376: /* used if we have DMA devices */
! 377: STMemory_WriteWord(0xE00842, CONDRV_OPCODE);
! 378: }
! 379: else
! 380: {
! 381: /* E002FC CLR.L $4C2 Set connected drives */
! 382: STMemory_WriteWord(0xE002FC,CONDRV_OPCODE);
! 383: STMemory_WriteWord(0xE002FC+2,NOP_OPCODE); /* NOP */
1.1.1.4 root 384:
1.1.1.5 ! root 385: /* E006AE BSR.W $E00794 Boot from DMA bus */
! 386: STMemory_WriteWord(0xE006AE,NOP_OPCODE); /* NOP */
! 387: STMemory_WriteWord(0xE006AE + 2,NOP_OPCODE); /* NOP */
! 388: }
! 389:
1.1.1.3 root 390: /* Timer D(MFP init 0xE01928) */
1.1 root 391: STMemory_WriteWord(0xE01972,TIMERD_OPCODE);
392:
1.1.1.3 root 393: /* Modify assembler loaded into cartridge area */
1.1 root 394: Cart_WriteHdvAddress(0x1410);
395: break;
396:
397: /*
398: TOS 2.06 settings
399: */
400: case 0x0206:
1.1.1.5 ! root 401: /* E007FA MOVE.L #$1FFFE,D7 Run checksums on 2xROMs (skip) */
! 402: /* Checksum is total of TOS ROM image, but get incorrect results */
! 403: /* as we've changed bytes in the ROM! So, just skip anyway! */
! 404: if( STMemory_ReadLong(0xE007FA)==0x2E3C0001L ) /* Test if we can patch it */
! 405: {
! 406: STMemory_WriteWord(0xE007FA, BRAW_OPCODE); /* BRA.W $E00894 */
! 407: STMemory_WriteWord(0xE007FA+2, 0x98);
! 408: }
! 409: else
! 410: {
! 411: fprintf(stderr, "TOS ROM won't be patched!\n");
! 412: break; /* Can't patch checksum (is it EmuTOS?) -> skip patches */
! 413: }
! 414:
1.1 root 415: /* hdv_init, initialize drives */
1.1.1.3 root 416: STMemory_WriteWord(0xE0518E,RTS_OPCODE); /* RTS */
1.1 root 417:
418: /* E05944 JSR $E011DC hdv_boot, load boot sector */
1.1.1.3 root 419: STMemory_WriteWord(0xE05944,NOP_OPCODE); /* NOP */
420: STMemory_WriteWord(0xE05944+2,NOP_OPCODE); /* NOP */
421: STMemory_WriteWord(0xE05944+4,NOP_OPCODE); /* NOP */
1.1 root 422:
423: /* E00898 BSR.W $E0097A Boot from DMA bus */
1.1.1.5 ! root 424: if(ACSI_EMU_ON || GEMDOS_EMU_ON)
! 425: {
! 426: /* no bootable DMA devices */
! 427: STMemory_WriteWord(0xE00B3E, CONDRV_OPCODE);
! 428: /* used if we have DMA devices */
! 429: STMemory_WriteWord(0xE00B66, CONDRV_OPCODE);
! 430: }
! 431: else
! 432: {
! 433: /* E00362 CLR.L $4C2 Set connected drives */
! 434: STMemory_WriteWord(0xE00362,NOP_OPCODE);
! 435: STMemory_WriteWord(0xE00362+2,NOP_OPCODE); /* NOP */
! 436:
! 437: /* E00898 BSR.W $E0097A Boot from DMA bus */
! 438: STMemory_WriteWord(0xE00898,NOP_OPCODE); /* NOP */
! 439: STMemory_WriteWord(0xE00898+2,NOP_OPCODE); /* NOP */
! 440: }
1.1.1.4 root 441:
1.1 root 442: /* Timer D(MFP init 0xE02206) */
443: STMemory_WriteWord(0xE02250,TIMERD_OPCODE);
444:
445: /* Modify assembler loaded into cartridge area */
446: Cart_WriteHdvAddress(0x1644);
447: break;
448: }
449: }
450:
1.1.1.3 root 451:
452: /*-----------------------------------------------------------------------*/
1.1 root 453: /*
454: Set default memory configuration, connected floppies and memory size
455: */
456: void TOS_SetDefaultMemoryConfig(void)
457: {
1.1.1.3 root 458: /* As TOS checks hardware for memory size + connected devices on boot-up */
459: /* we set these values ourselves and fill in the magic numbers so TOS */
460: /* skips these tests which would crash the emulator as the reference the MMU */
461:
462: /* Fill in magic numbers, so TOS does not try to reference MMU */
463: STMemory_WriteLong(0x420,0x752019f3); /* memvalid - configuration is valid */
464: STMemory_WriteLong(0x43a,0x237698aa); /* another magic # */
465: STMemory_WriteLong(0x51a,0x5555aaaa); /* and another */
1.1 root 466:
1.1.1.3 root 467: /* Set memory size, adjust for extra VDI screens if needed */
1.1.1.5 ! root 468: if (bUseVDIRes)
! 469: {
1.1.1.3 root 470: /* This is enough for 1024x768x16colour (0x60000) */
471: STMemory_WriteLong(0x436,MemoryInfo[ConfigureParams.Memory.nMemorySize].PhysTop-0x60000); /* mem top - upper end of user memory (before 32k screen) */
472: STMemory_WriteLong(0x42e,MemoryInfo[ConfigureParams.Memory.nMemorySize].PhysTop-0x58000); /* phys top */
1.1 root 473: }
1.1.1.5 ! root 474: else
! 475: {
1.1.1.3 root 476: STMemory_WriteLong(0x436,MemoryInfo[ConfigureParams.Memory.nMemorySize].PhysTop-0x8000); /* mem top - upper end of user memory(before 32k screen) */
477: STMemory_WriteLong(0x42e,MemoryInfo[ConfigureParams.Memory.nMemorySize].PhysTop); /* phys top */
1.1 root 478: }
1.1.1.3 root 479: STMemory_WriteLong(0x424,MemoryInfo[ConfigureParams.Memory.nMemorySize].MemoryConfig); /* 512k configure 0x00=128k 0x01=512k 0x10=2Mb 11=reserved eg 0x1010 = 4Mb */
480: STMemory_WriteLong(0xff8000,MemoryInfo[ConfigureParams.Memory.nMemorySize].MemoryConfig);
1.1 root 481:
1.1.1.3 root 482: /* Set memory range, and start of BUS error */
483: STRamEnd = MemoryInfo[ConfigureParams.Memory.nMemorySize].MemoryEnd; /* Set end of RAM */
484: STRamEnd_BusErr = 0x00420000; /* 4Mb */ /* Between RAM end and this is void space (0's), after is a BUS error */
485:
486: /* Set TOS floppies */
487: STMemory_WriteWord(0x446,nBootDrive); /* Boot up on A(0) or C(2) */
488: STMemory_WriteWord(0x4a6,0x2); /* Connected floppies A,B (0 or 2) */
1.1.1.4 root 489:
1.1.1.3 root 490: ConnectedDriveMask = ConnectedDriveMaskList[ConfigureParams.HardDisc.nDriveList];
1.1.1.4 root 491:
1.1.1.3 root 492: STMemory_WriteLong(0x4c2,ConnectedDriveMask); /* Drives A,B and C - NOTE some TOS images overwrite value, see 'TOS_ConnectedDrive_OpCode' */
1.1 root 493:
1.1.1.3 root 494: /* Mirror ROM boot vectors */
495: STMemory_WriteLong(0x00,STMemory_ReadLong(TOSAddress) );
1.1 root 496: STMemory_WriteLong(0x04,STMemory_ReadLong(TOSAddress+4) );
497: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.