|
|
1.1 root 1: /* 1.1.1.4 ! root 2: Hatari - cart.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: Cartridge Pexec program 8: 9: To load programs into memory, through TOS, we need to intercept GEMDOS so we can 10: relocate/execute programs via GEMDOS call $4B(PExec). 1.1.1.4 ! root 11: We have some 68000 assembler, located at 0xFA1000 (cartridge memory), which is used as our 1.1 root 12: new GEMDOS handler. This checks if we need to intercept the call. 13: 1.1.1.4 ! root 14: The assembler routine can be found in 'cart_asm.s', and has been converted to a byte ! 15: array and stored in 'cart_img[]'. 1.1 root 16: */ 1.1.1.4 ! root 17: char Cart_rcsid[] = "Hatari $Id: cart.c,v 1.6 2004/12/19 13:46:33 thothy Exp $"; 1.1 root 18: 19: #include "main.h" 20: #include "cart.h" 1.1.1.4 ! root 21: #include "configuration.h" ! 22: #include "file.h" 1.1 root 23: #include "stMemory.h" 1.1.1.4 ! root 24: #include "vdi.h" 1.1 root 25: 26: 1.1.1.4 ! root 27: /* Cartridge header with system initialization code */ ! 28: /* C-Init flag has bit 3 set = before disk boot, but after GEMDOS init */ ! 29: unsigned char cart_hdr[] = 1.1 root 30: { 1.1.1.4 ! root 31: 0xAB,0xCD,0xEF,0x42, /* C-FLAG */ ! 32: 0x00,0x00,0x00,0x00, /* C-NEXT */ ! 33: 0x08,0xFA,0x00,0x24, /* C-INIT */ ! 34: 0x00,0x00,0x00,0x00, /* C-RUN */ ! 35: 0x00,0x00, /* C-TIME */ ! 36: 0x00,0x00, /* C-DATE */ ! 37: 0x00,0x00,0x00,0x00, /* C-BSIZ, offset: $14*/ ! 38: 'H','A','T','A','R','I','.','I','M','G',0x00,0x00, /* C-NAME */ ! 39: ! 40: /* Code ($FA0024) - Set up GEMDOS handler and initialize some system variables */ ! 41: 0xA0,0x00, /* Line-A init (for VDI resolutions, see OpCode_SysInit()) */ ! 42: 0x00,0x0A, /* SYSINIT_OPCODE */ ! 43: 0x4E,0x75 /* RTS */ ! 44: }; ! 45: ! 46: ! 47: /* This is the assembled code from cart_asm.s with our gemdos handler. ! 48: * NOTE: Remove first 0x1c (PRG_HEADER_SIZE) bytes from the assembled program ! 49: * file or use an assembler like TurboAss that can generate absolute binary images. ! 50: */ ! 51: unsigned char cart_img[] = ! 52: { ! 53: 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x08,0x69,0x0a,0x66,0x02, ! 54: 0x4e,0x73,0x2f,0x3a,0xff,0xf0,0x4e,0x75,0x41,0xef,0x00,0x08,0x08,0x17,0x00,0x05, ! 55: 0x66,0x04,0x4e,0x68,0x54,0x48,0x4a,0x50,0x66,0x3c,0x2f,0x0e,0x2c,0x48,0x2f,0x0e, ! 56: 0x61,0x48,0x2c,0x5f,0x61,0x00,0x00,0x98,0x61,0x00,0x00,0xb6,0x42,0xae,0x00,0x02, ! 57: 0x42,0xae,0x00,0x0a,0x2d,0x40,0x00,0x06,0x3f,0x3c,0x00,0x30,0x4e,0x41,0x54,0x4f, ! 58: 0xe0,0x58,0xb0,0x7c,0x00,0x15,0x6c,0x06,0x3c,0xbc,0x00,0x04,0x60,0x04,0x3c,0xbc, ! 59: 0x00,0x06,0x2c,0x5f,0x60,0xac,0x0c,0x50,0x00,0x03,0x66,0xa6,0x2f,0x0e,0x2c,0x48, ! 60: 0x61,0x08,0x61,0x5a,0x61,0x7a,0x2c,0x5f,0x4e,0x73,0x3f,0x3c,0x00,0x2f,0x4e,0x41, ! 61: 0x54,0x4f,0x20,0x40,0x2f,0x18,0x2f,0x18,0x2f,0x18,0x2f,0x18,0x2f,0x18,0x2f,0x18, ! 62: 0x2f,0x18,0x2f,0x18,0x2f,0x18,0x2f,0x18,0x2f,0x18,0x2f,0x08,0x3f,0x3c,0x00,0x17, ! 63: 0x2f,0x2e,0x00,0x02,0x3f,0x3c,0x00,0x4e,0x4e,0x41,0x50,0x4f,0x20,0x5f,0x21,0x1f, ! 64: 0x21,0x1f,0x21,0x1f,0x21,0x1f,0x21,0x1f,0x21,0x1f,0x21,0x1f,0x21,0x1f,0x21,0x1f, ! 65: 0x21,0x1f,0x21,0x1f,0x4a,0x80,0x67,0x04,0x58,0x4f,0x60,0xaa,0x4e,0x75,0x2f,0x2e, ! 66: 0x00,0x0a,0x2f,0x2e,0x00,0x06,0x42,0xa7,0x3f,0x3c,0x00,0x05,0x3f,0x3c,0x00,0x4b, ! 67: 0x4e,0x41,0x4f,0xef,0x00,0x10,0x4a,0x80,0x6b,0x02,0x4e,0x75,0x58,0x4f,0x60,0x86, ! 68: 0x48,0xe7,0x03,0x1c,0x2a,0x40,0x42,0x67,0x2f,0x2e,0x00,0x02,0x3f,0x3c,0x00,0x3d, ! 69: 0x4e,0x41,0x50,0x4f,0x2c,0x00,0x2f,0x0d,0x06,0x97,0x00,0x00,0x00,0xe4,0x48,0x78, ! 70: 0x00,0x1c,0x3f,0x06,0x3f,0x3c,0x00,0x3f,0x4e,0x41,0x4f,0xef,0x00,0x0c,0x2f,0x0d, ! 71: 0x06,0x97,0x00,0x00,0x01,0x00,0x48,0x79,0x7f,0xff,0xff,0xff,0x3f,0x06,0x3f,0x3c, ! 72: 0x00,0x3f,0x4e,0x41,0x4f,0xef,0x00,0x0c,0x3f,0x06,0x3f,0x3c,0x00,0x3e,0x4e,0x41, ! 73: 0x58,0x4f,0x49,0xed,0x00,0x08,0x20,0x0d,0xd0,0xbc,0x00,0x00,0x01,0x00,0x28,0xc0, ! 74: 0x20,0x2d,0x00,0xe6,0x28,0xc0,0xd0,0xad,0x00,0x08,0x28,0xc0,0x28,0xed,0x00,0xea, ! 75: 0xd0,0xad,0x00,0xea,0x28,0xc0,0x28,0xed,0x00,0xee,0x20,0x0d,0xd0,0xbc,0x00,0x00, ! 76: 0x00,0x80,0x2b,0x40,0x00,0x20,0x28,0x6d,0x00,0x18,0xd9,0xed,0x00,0xf2,0x26,0x6d, ! 77: 0x00,0x08,0x20,0x0b,0x4a,0x6d,0x00,0xfe,0x66,0x3a,0x1e,0x14,0x42,0x1c,0xe1,0x4f, ! 78: 0x1e,0x14,0x42,0x1c,0x48,0x47,0x1e,0x14,0x42,0x1c,0xe1,0x4f,0x1e,0x14,0x42,0x1c, ! 79: 0x4a,0x87,0x67,0x20,0xd7,0xc7,0x7e,0x00,0xd1,0x93,0x1e,0x14,0x18,0xfc,0x00,0x00, ! 80: 0x4a,0x07,0x67,0x10,0xbe,0x3c,0x00,0x01,0x66,0x06,0x47,0xeb,0x00,0xfe,0x60,0xea, ! 81: 0xd6,0xc7,0x60,0xe4,0x20,0x2d,0x00,0x1c,0x67,0x0a,0x20,0x6d,0x00,0x18,0x42,0x18, ! 82: 0x53,0x80,0x66,0xfa,0x20,0x0d,0x4c,0xdf,0x38,0xc0,0x4e,0x75 ! 83: }; 1.1 root 84: 85: 86: /*-----------------------------------------------------------------------*/ 87: /* 1.1.1.4 ! root 88: Load ST GEMDOS intercept program image into cartridge memory space. ! 89: This is used as an interface to the host file system and for GemDOS. 1.1 root 90: */ 1.1.1.4 ! root 91: void Cart_LoadImage(void) 1.1 root 92: { 1.1.1.4 ! root 93: char *pCartFileName = ConfigureParams.Rom.szCartridgeImageFileName; ! 94: ! 95: /* "Clear" cartridge ROM space */ ! 96: memset(&STRam[0xfa0000], 0xff, 0x20000); ! 97: ! 98: if (bUseVDIRes || ConfigureParams.HardDisc.bUseHardDiscDirectories) ! 99: { ! 100: /* Copy cartrige header into ST's cartridge memory */ ! 101: memcpy(&STRam[0xfa0000], cart_hdr, sizeof(cart_hdr)); ! 102: ! 103: /* Copy 'cart.img' file into ST's cartridge memory */ ! 104: memcpy(&STRam[0xfa1000], cart_img, sizeof(cart_img)); ! 105: } ! 106: else if (strlen(pCartFileName) > 0) ! 107: { ! 108: /* Check if we can load an external cartridge file: */ ! 109: if (bUseVDIRes) ! 110: fprintf(stderr, "Warning: Cartridge can't be used together with extended VDI resolution!\n"); ! 111: else if (ConfigureParams.HardDisc.bUseHardDiscDirectories) ! 112: fprintf(stderr, "Warning: Cartridge can't be used together with GEMDOS harddisc emulation!\n"); ! 113: else if (!File_Exists(pCartFileName)) ! 114: fprintf(stderr, "Cartridge file not found: %s\n", pCartFileName); ! 115: else if (File_Length(pCartFileName) > 0x20000) ! 116: fprintf(stderr, "Cartridge file %s is too big.\n", pCartFileName); ! 117: else ! 118: { ! 119: /* Now we can load it: */ ! 120: File_Read(pCartFileName, &STRam[0xfa0000], NULL, NULL); ! 121: } ! 122: } 1.1 root 123: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.