|
29 | 29 | #include <stdio.h> |
30 | 30 | #include <string.h> |
31 | 31 |
|
| 32 | +#include "archdep.h" |
32 | 33 | #include "c128.h" |
33 | 34 | #include "c128mem.h" |
34 | 35 | #include "c128memrom.h" |
| 36 | +#include "c128model.h" |
35 | 37 | #include "c128rom.h" |
36 | 38 | #include "c64memrom.h" |
37 | 39 | #include "c64rom.h" |
@@ -278,9 +280,10 @@ int c128rom_kernal_setup(void) |
278 | 280 | const char *resname = NULL; |
279 | 281 | const char *rom_name = NULL; |
280 | 282 | uint8_t *kernal = NULL; |
281 | | - static const char *last_kernal64 = NULL; |
| 283 | + const char *last_kernal64 = NULL; |
282 | 284 | char *name; |
283 | 285 | const char *kernal64 = C128_KERNAL64_NAME; |
| 286 | + int board_type = BOARD_C128; |
284 | 287 |
|
285 | 288 | if (!rom_loaded) { |
286 | 289 | return 0; |
@@ -320,12 +323,36 @@ int c128rom_kernal_setup(void) |
320 | 323 | return -1; |
321 | 324 | } |
322 | 325 |
|
323 | | - log_verbose(c128rom_log, "kernal64:%s", kernal64); |
324 | | - |
325 | | - if (kernal64 != last_kernal64) { |
326 | | - resources_set_string("Kernal64Name", kernal64); |
| 326 | + /* HACK: In the C128DCR, C64 kernal+BASIC are combined with C128 kernal |
| 327 | + * in a single chip. Since we don't have separate resources for localized |
| 328 | + * C64 kernals, we load it automatically here. */ |
| 329 | + resources_get_int("BoardType", &board_type); |
| 330 | + if (board_type == BOARD_C128D) { |
| 331 | + const char *p; |
| 332 | + resources_get_string("Kernal64Name", &last_kernal64); |
| 333 | + /* get only the name of the file, remove the path */ |
| 334 | + p = strrchr(last_kernal64, ARCHDEP_DIR_SEP_CHR); |
| 335 | + if (p != NULL) { |
| 336 | + /* dir separator was found, move pointer behind it */ |
| 337 | + p++; |
| 338 | + } else { |
| 339 | + /* separator not found, use original string */ |
| 340 | + p = last_kernal64; |
| 341 | + } |
| 342 | + /* now check if the loaded C64 kernal is one of the stock kernals we |
| 343 | + * provide, and only then replace it by another stock kernal */ |
| 344 | + if (!strcmp(p, C128_KERNAL64_NAME) || |
| 345 | + !strcmp(p, C128_KERNAL64_NO_NAME) || |
| 346 | + !strcmp(p, C128_KERNAL64_SE_NAME)) { |
| 347 | + log_warning(c128rom_log, |
| 348 | + "On C128DCR boards the C64 kernal is in the same IC as the C128 kernal, using: %s", |
| 349 | + kernal64); |
| 350 | + /* if the file changed, load the new one */ |
| 351 | + if (strcmp(kernal64, last_kernal64) != 0) { |
| 352 | + resources_set_string("Kernal64Name", kernal64); |
| 353 | + } |
| 354 | + } |
327 | 355 | } |
328 | | - last_kernal64 = kernal64; |
329 | 356 |
|
330 | 357 | /* disable traps before loading the ROM */ |
331 | 358 | get_trapflags(); |
|
0 commit comments