Skip to content

Commit

Permalink
integra: fix failure to enter reset code on Ctrl-@-Break.
Browse files Browse the repository at this point in the history
See https://stardot.org.uk/forums/viewtopic.php?f=4&t=17675&p=249181#p248995

There was an issue where Ctrl-@-Break would offer the option to reset
the configuration on real hardware but not in B-Em or in BeebEm.  This
turned out to be due to the failure to emulate the resetting of RTC
registers B and C.  This commit adds an implementation of this.
  • Loading branch information
Steve Fosdick committed Sep 25, 2019
1 parent 48e1203 commit eb19a01
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/cmos.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ uint8_t cmos_read_data_integra(void)
if (++uip_count == 100) {
val |= 0x80;
uip_count = 0;
log_debug("cmos: read_data_integra, faking update");
}
log_debug("cmos: read_data_integra, return register A %02X", cmos_data);
}
Expand All @@ -188,6 +189,12 @@ uint8_t cmos_read_data_integra(void)
return val;
}

void cmos_reset(void)
{
cmos[0xb] &= 0x87; /* clear bits in register B */
cmos[0xc] = 0;
}

void cmos_load(MODEL m) {
FILE *f;
ALLEGRO_PATH *path;
Expand Down
1 change: 1 addition & 0 deletions src/cmos.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void cmos_write_addr_integra(uint8_t val);
void cmos_write_data_integra(uint8_t val);
uint8_t cmos_read_data_integra(void);
uint8_t cmos_read(void);
void cmos_reset(void);
void cmos_load(MODEL m);
void cmos_save(MODEL m);

Expand Down
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void main_reset()
else tube_exec = NULL;
tube_reset();

memset(ram, 0, 64 * 1024);
memset(ram, 0, RAM_SIZE);
}

static const char helptext[] =
Expand Down Expand Up @@ -376,6 +376,7 @@ static void main_key_down(ALLEGRO_EVENT *event)
wd1770_reset();
sid_reset();
music5000_reset();
cmos_reset();

if (curtube != -1)
tubes[curtube].reset();
Expand Down
1 change: 0 additions & 1 deletion src/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ void mem_init() {
ram = (uint8_t *)malloc(RAM_SIZE);
rom = (uint8_t *)malloc(ROM_NSLOT * ROM_SIZE);
os = (uint8_t *)malloc(ROM_SIZE);
memset(ram, 0, RAM_SIZE);
os_dir = al_create_path_for_directory("roms/os");
rom_dir = al_create_path_for_directory("roms/general");
}
Expand Down

0 comments on commit eb19a01

Please sign in to comment.