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