Skip to content

Commit 83c8bd0

Browse files
committed
only override the C128's C64 kernal when the C128 model is DCR _and_ the already loaded kernal is one of the stock kernals we provide. should fix #2196
git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@45943 379a1393-f5fb-40a0-bcee-ef074d9b53f7
1 parent 5ac885d commit 83c8bd0

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

vice/src/c128/c128rom.c

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
#include <stdio.h>
3030
#include <string.h>
3131

32+
#include "archdep.h"
3233
#include "c128.h"
3334
#include "c128mem.h"
3435
#include "c128memrom.h"
36+
#include "c128model.h"
3537
#include "c128rom.h"
3638
#include "c64memrom.h"
3739
#include "c64rom.h"
@@ -278,9 +280,10 @@ int c128rom_kernal_setup(void)
278280
const char *resname = NULL;
279281
const char *rom_name = NULL;
280282
uint8_t *kernal = NULL;
281-
static const char *last_kernal64 = NULL;
283+
const char *last_kernal64 = NULL;
282284
char *name;
283285
const char *kernal64 = C128_KERNAL64_NAME;
286+
int board_type = BOARD_C128;
284287

285288
if (!rom_loaded) {
286289
return 0;
@@ -320,12 +323,36 @@ int c128rom_kernal_setup(void)
320323
return -1;
321324
}
322325

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+
}
327355
}
328-
last_kernal64 = kernal64;
329356

330357
/* disable traps before loading the ROM */
331358
get_trapflags();

vice/src/c128/c128rom.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ int c128rom_basic64_setup(void);
7575
#define C128_KERNAL_DE_R01_CHECKSUM 22098 /* FIXME: 19680 ? */
7676
#define C128_KERNAL_CH_R01_CHECKSUM 21376
7777

78+
79+
/*
80+
Version BASlo BAShi Kernal C64 BASIC C64 Kernal
81+
------- ----- ----- ------ --------- ----------
82+
First 318018-02 318019-02 318020-03 251913-01lo 251913-01hi
83+
Middle upgrade 318018-03 318019-03 318020-04 251913-01lo 251913-01hi
84+
Final upgrade 318018-04 318019-04 318020-05 251913-01lo 251913-01hi
85+
128DCR 318022-02lo 318022-02hi 318023-02hi combined in 318023-02lo
86+
*/
87+
7888
/* C128 chargen
7989
* CAUTION: some dumps that are circulating have the two charsets swapped.
8090
* The international one should be in the first half (see #2171)
@@ -99,10 +109,16 @@ int c128rom_basic64_setup(void);
99109
#define C128_KERNAL_NO_NAME "kernalno" /* FIXME: identify */
100110
#define C128_KERNAL_SE_NAME "kernal-318034-01.bin"
101111

102-
/* C128 BASIC */
112+
/* C128 BASIC
113+
* NOTE: in the C128DCR the two parts are combined in 318022-02
114+
*/
103115
#define C128_BASICLO_NAME "basiclo-318018-04.bin" /* BASIC */
104116
#define C128_BASICHI_NAME "basichi-318019-04.bin" /* Editor */
105117

118+
/* NOTE: in the regular C128, C64 BASIC and C64 kernal are combined in 251913-01
119+
* in the C128DCR, C64 BASIC, C64 kernal and C128 kernal are combined in 318023-02
120+
*/
121+
106122
/* C64 BASIC */
107123
#define C128_BASIC64_NAME "basic64-901226-01.bin" /* first 8k in 318081-01 */
108124

0 commit comments

Comments
 (0)