MCPcopy Create free account
hub / github.com/TASEmulators/fceux / UNROM512_Init

Function UNROM512_Init

src/boards/unrom512.cpp:183–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183void UNROM512_Init(CartInfo *info) {
184 info->Power = UNROM512LatchPower;
185 info->Close = UNROM512LatchClose;
186 GameStateRestore = StateRestore;
187
188 flash_state = 0;
189 flash_id_mode = 0;
190 flash_save = info->battery;
191 bus_conflict = !info->battery; // Is it required by any game?
192
193 int mirror = (head.ROM_type & 1) | ((head.ROM_type & 8) >> 2);
194 switch (mirror)
195 {
196 case 0: // hard horizontal, internal
197 SetupCartMirroring(MI_H, 1, NULL);
198 break;
199 case 1: // hard vertical, internal
200 SetupCartMirroring(MI_V, 1, NULL);
201 break;
202 case 2: // switchable 1-screen, internal (flags: 4-screen + horizontal)
203 SetupCartMirroring(MI_0, 0, NULL);
204 break;
205 case 3: // hard four screen, last 8k of 32k RAM (flags: 4-screen + vertical)
206 SetupCartMirroring( 4, 1, VROM + (info->vram_size - 8192));
207 break;
208 }
209
210 if(flash_save)
211 {
212 // Allocate memory for flash
213 size_t flash_size = PRGsize[ROM_CHIP];
214 flash_data = (uint8*)FCEU_gmalloc(flash_size);
215 // Copy ROM to flash data
216 for (size_t i = 0; i < flash_size; i++) {
217 flash_data[i] = PRGptr[ROM_CHIP][i];
218 }
219 SetupCartPRGMapping(FLASH_CHIP, flash_data, flash_size, 1);
220 info->addSaveGameBuf( flash_data, flash_size, UNROM512_FlashReset );
221
222 flash_id[0] = 0xBF;
223 flash_id[1] = 0xB5 + (ROM_size >> 4);
224 SetupCartPRGMapping(CFI_CHIP, flash_id, sizeof(flash_id), 0);
225
226 AddExState(flash_data, flash_size, 0, "FLSH");
227 AddExState(&flash_state, sizeof(flash_state), 0, "FLST");
228 AddExState(&flash_id_mode, sizeof(flash_id_mode), 0, "FLMD");
229 AddExState(flash_buffer_a, sizeof(flash_buffer_a), 0, "FLBA");
230 AddExState(flash_buffer_v, sizeof(flash_buffer_v), 0, "FLBV");
231 }
232 AddExState(&latcha, sizeof(latcha), 0, "LATA");
233 AddExState(&latche, sizeof(latche), 0, "LATC");
234 AddExState(&bus_conflict, sizeof(bus_conflict), 0, "BUSC");
235}

Callers

nothing calls this directly

Calls 5

SetupCartMirroringFunction · 0.85
FCEU_gmallocFunction · 0.85
SetupCartPRGMappingFunction · 0.85
AddExStateFunction · 0.85
addSaveGameBufMethod · 0.80

Tested by

no test coverage detected