Skip to content

Commit 2437b13

Browse files
deltecentpkoning2
authored andcommitted
AltairZ80: Adds "rom" option to "load -h"
Adds "rom" option to set pages to ROM when loading an Intel HEX file.
1 parent 36605c4 commit 2437b13

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

AltairZ80/altairz80_cpu.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ uint32 getCommon(void);
209209
uint32 sim_map_resource(uint32 baseaddr, uint32 size, uint32 resource_type,
210210
int32 (*routine)(const int32, const int32, const int32), const char* name, uint8 unmap);
211211

212+
static void PutBYTEasROMorRAM(register uint32 Addr, const register uint32 Value, const register uint32 makeROM);
212213
void PutBYTEExtended(register uint32 Addr, const register uint32 Value);
213214
uint32 GetBYTEExtended(register uint32 Addr);
214215
void cpu_raise_interrupt(uint32 irq);
@@ -1937,6 +1938,15 @@ static void PutBYTE(register uint32 Addr, const register uint32 Value) {
19371938
}
19381939
}
19391940

1941+
static void PutBYTEasROMorRAM(register uint32 Addr, const register uint32 Value, const register uint32 makeROM) {
1942+
Addr &= ADDRMASK; /* registers are NOT guaranteed to be always 16-bit values */
1943+
if ((cpu_unit.flags & UNIT_CPU_BANKED) && (((common_low == 0) && (Addr < common)) || ((common_low == 1) && (Addr >= common))))
1944+
Addr |= bankSelect << MAXBANKSIZELOG2;
1945+
1946+
mmu_table[Addr >> LOG2PAGESIZE] = makeROM ? ROM_PAGE : RAM_PAGE;
1947+
M[Addr] = Value;
1948+
}
1949+
19401950
void PutBYTEExtended(register uint32 Addr, const register uint32 Value) {
19411951
MDEV m;
19421952

@@ -7507,10 +7517,17 @@ t_stat sim_load(FILE *fileref, CONST char *cptr, CONST char *fnam, int flag) {
75077517
https://deramp.com/downloads/misc_software/hex-binary utilities for the PC/
75087518
*/
75097519
static t_stat cpu_hex_load(FILE *fileref, CONST char *cptr, CONST char *fnam, int flag) {
7520+
char gbuf[CBUFSIZE];
75107521
char linebuf[1024], datastr[1024], *bufptr;
75117522
int32 bytecnt, rectype, databyte, chksum, line = 0, cnt = 0;
7523+
uint32 makeROM = FALSE;
75127524
t_addr addr, org = 0;
75137525

7526+
get_glyph(cptr, gbuf, 0);
7527+
if (strcmp(gbuf, "ROM") == 0) {
7528+
makeROM = TRUE;
7529+
}
7530+
75147531
while (!feof(fileref)) {
75157532
if (fgets(linebuf, sizeof(linebuf), fileref) == NULL)
75167533
break;
@@ -7548,7 +7565,7 @@ static t_stat cpu_hex_load(FILE *fileref, CONST char *cptr, CONST char *fnam, in
75487565
}
75497566
bufptr += 2;
75507567

7551-
PutBYTE(addr++, databyte);
7568+
PutBYTEasROMorRAM(addr++, databyte, makeROM);
75527569

75537570
chksum += databyte;
75547571
cnt++;
@@ -7564,7 +7581,7 @@ static t_stat cpu_hex_load(FILE *fileref, CONST char *cptr, CONST char *fnam, in
75647581
}
75657582
}
75667583

7567-
return sim_messagef(SCPE_OK, "%d byte%s loaded at %x.\n", PLURAL(cnt), org);
7584+
return sim_messagef(SCPE_OK, "%d byte%s loaded at %x%s.\n", PLURAL(cnt), org, (makeROM) ? " [ROM]" : "");
75687585
}
75697586

75707587
void cpu_raise_interrupt(uint32 irq) {

0 commit comments

Comments
 (0)