--- BasiliskII/src/main.cpp 1999/10/21 22:39:53 1.2 +++ BasiliskII/src/main.cpp 2002/03/19 14:25:50 1.12 @@ -1,7 +1,7 @@ /* * main.cpp - Startup/shutdown code * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2002 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ #include "serial.h" #include "ether.h" #include "clip.h" +#include "adb.h" #include "rom_patches.h" #include "user_strings.h" #include "prefs.h" @@ -41,6 +42,20 @@ #define DEBUG 0 #include "debug.h" +#if ENABLE_MON +#include "mon.h" + +static uint32 mon_read_byte_b2(uint32 adr) +{ + return ReadMacInt8(adr); +} + +static void mon_write_byte_b2(uint32 adr, uint32 b) +{ + WriteMacInt8(adr, b); +} +#endif + /* * Initialize everything, returns false on error @@ -50,7 +65,7 @@ bool InitAll(void) { // Check ROM version if (!CheckROM()) { - ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR)); + ErrorAlert(STR_UNSUPPORTED_ROM_TYPE_ERR); return false; } @@ -65,13 +80,19 @@ bool InitAll(void) TwentyFourBitAddressing = true; break; case ROM_VERSION_II: - CPUType = 2; + CPUType = PrefsFindInt32("cpu"); + if (CPUType < 2) CPUType = 2; + if (CPUType > 4) CPUType = 4; FPUType = PrefsFindBool("fpu") ? 1 : 0; + if (CPUType == 4) FPUType = 1; // 68040 always with FPU TwentyFourBitAddressing = true; break; case ROM_VERSION_32: - CPUType = 3; + CPUType = PrefsFindInt32("cpu"); + if (CPUType < 2) CPUType = 2; + if (CPUType > 4) CPUType = 4; FPUType = PrefsFindBool("fpu") ? 1 : 0; + if (CPUType == 4) FPUType = 1; // 68040 always with FPU TwentyFourBitAddressing = false; break; } @@ -81,11 +102,41 @@ bool InitAll(void) // Load XPRAM XPRAMInit(); + // Load XPRAM default values if signature not found + if (XPRAM[0x0c] != 0x4e || XPRAM[0x0d] != 0x75 + || XPRAM[0x0e] != 0x4d || XPRAM[0x0f] != 0x63) { + D(bug("Loading XPRAM default values\n")); + memset(XPRAM, 0, 0x100); + XPRAM[0x0c] = 0x4e; // "NuMc" signature + XPRAM[0x0d] = 0x75; + XPRAM[0x0e] = 0x4d; + XPRAM[0x0f] = 0x63; + XPRAM[0x01] = 0x80; // InternalWaitFlags = DynWait (don't wait for SCSI devices upon bootup) + XPRAM[0x10] = 0xa8; // Standard PRAM values + XPRAM[0x11] = 0x00; + XPRAM[0x12] = 0x00; + XPRAM[0x13] = 0x22; + XPRAM[0x14] = 0xcc; + XPRAM[0x15] = 0x0a; + XPRAM[0x16] = 0xcc; + XPRAM[0x17] = 0x0a; + XPRAM[0x1c] = 0x00; + XPRAM[0x1d] = 0x02; + XPRAM[0x1e] = 0x63; + XPRAM[0x1f] = 0x00; + XPRAM[0x08] = 0x13; + XPRAM[0x09] = 0x88; + XPRAM[0x0a] = 0x00; + XPRAM[0x0b] = 0xcc; + XPRAM[0x76] = 0x00; // OSDefault = MacOS + XPRAM[0x77] = 0x01; + } + // Set boot volume - int16 i16 = PrefsFindInt16("bootdrive"); + int16 i16 = PrefsFindInt32("bootdrive"); XPRAM[0x78] = i16 >> 8; XPRAM[0x79] = i16 & 0xff; - i16 = PrefsFindInt16("bootdriver"); + i16 = PrefsFindInt32("bootdriver"); XPRAM[0x7a] = i16 >> 8; XPRAM[0x7b] = i16 & 0xff; @@ -112,6 +163,9 @@ bool InitAll(void) // Init clipboard ClipInit(); + // Init ADB + ADBInit(); + // Init audio AudioInit(); @@ -119,6 +173,12 @@ bool InitAll(void) if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC)) return false; + // Set default video mode in XPRAM + XPRAM[0x56] = 0x42; // 'B' + XPRAM[0x57] = 0x32; // '2' + XPRAM[0x58] = DepthToAppleMode(VideoMonitor.mode.depth); + XPRAM[0x59] = 0; + #if EMULATED_68K // Init 680x0 emulation (this also activates the memory system which is needed for PatchROM()) if (!Init680x0()) @@ -127,9 +187,17 @@ bool InitAll(void) // Install ROM patches if (!PatchROM()) { - ErrorAlert(GetString(STR_UNSUPPORTED_ROM_TYPE_ERR)); + ErrorAlert(STR_UNSUPPORTED_ROM_TYPE_ERR); return false; } + +#if ENABLE_MON + // Initialize mon + mon_init(); + mon_read_byte = mon_read_byte_b2; + mon_write_byte = mon_write_byte_b2; +#endif + return true; } @@ -140,6 +208,11 @@ bool InitAll(void) void ExitAll(void) { +#if ENABLE_MON + // Deinitialize mon + mon_exit(); +#endif + // Save XPRAM XPRAMExit(); @@ -149,6 +222,9 @@ void ExitAll(void) // Exit audio AudioExit(); + // Exit ADB + ADBExit(); + // Exit clipboard ClipExit(); @@ -172,3 +248,18 @@ void ExitAll(void) DiskExit(); SonyExit(); } + + +/* + * Display error/warning alert given the message string ID + */ + +void ErrorAlert(int string_id) +{ + ErrorAlert(GetString(string_id)); +} + +void WarningAlert(int string_id) +{ + WarningAlert(GetString(string_id)); +}