| 97 | } |
| 98 | } |
| 99 | void initializeGameboy() { |
| 100 | enableSleepMode(); |
| 101 | gameboyFrameCounter = 0; |
| 102 | sgbMode = false; |
| 103 | |
| 104 | if (gbsMode) { |
| 105 | resultantGBMode = 1; // GBC |
| 106 | probingForBorder = false; |
| 107 | } |
| 108 | else { |
| 109 | switch(gbcModeOption) { |
| 110 | case 0: // GB |
| 111 | initGBMode(); |
| 112 | break; |
| 113 | case 1: // GBC if needed |
| 114 | if (romSlot0[0x143] == 0xC0) |
| 115 | initGBCMode(); |
| 116 | else |
| 117 | initGBMode(); |
| 118 | break; |
| 119 | case 2: // GBC |
| 120 | if (romSlot0[0x143] == 0x80 || romSlot0[0x143] == 0xC0) |
| 121 | initGBCMode(); |
| 122 | else |
| 123 | initGBMode(); |
| 124 | break; |
| 125 | } |
| 126 | |
| 127 | bool sgbEnhanced = romSlot0[0x14b] == 0x33 && romSlot0[0x146] == 0x03; |
| 128 | if (sgbEnhanced && resultantGBMode != 2 && probingForBorder) { |
| 129 | resultantGBMode = 2; |
| 130 | } |
| 131 | else { |
| 132 | probingForBorder = false; |
| 133 | } |
| 134 | } // !gbsMode |
| 135 | |
| 136 | initMMU(); |
| 137 | initCPU(); |
| 138 | initLCD(); |
| 139 | initGFX(); |
| 140 | initSND(); |
| 141 | |
| 142 | if (!gbsMode && !probingForBorder && suspendStateExists) { |
| 143 | loadState(-1); |
| 144 | } |
| 145 | |
| 146 | if (gbsMode) |
| 147 | gbsInit(); |
| 148 | |
| 149 | // We haven't calculated the # of cycles to the next hardware event. |
| 150 | cyclesToEvent = 1; |
| 151 | } |
| 152 | |
| 153 | void initializeGameboyFirstTime() { |
| 154 | if (sgbBordersEnabled) |
no test coverage detected