Skip to content

Commit

Permalink
Minor fixes to LTK to emulate hardware better
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@44161 379a1393-f5fb-40a0-bcee-ef074d9b53f7
  • Loading branch information
OldWoman37 committed Jul 1, 2023
1 parent 0ff4012 commit 41b6cb3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 15 additions & 1 deletion vice/src/c128/functionrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#include "types.h"
#include "util.h"
#include "viciitypes.h"

#include "cartridge.h"
#include "ltkernal.h"

#define INTERNAL_FUNCTION_ROM_SIZE 0x8000

Expand Down Expand Up @@ -201,6 +202,13 @@ static int functionrom_load_internal(void)

uint8_t internal_function_rom_read(uint16_t addr)
{
/* LTK MMU modification prioritises over internal function rom */
if (cartridge_get_id(0) == CARTRIDGE_LT_KERNAL) {
if (c128ltkernal_ram_read(addr, &(vicii.last_cpu_val))) {
return vicii.last_cpu_val;
}
}

if (internal_function_rom_enabled == INT_FUNCTION_RTC) {
vicii.last_cpu_val = bq4830y_read(rtc1_context, (uint16_t)(addr & 0x7fff));
} else {
Expand All @@ -222,6 +230,12 @@ uint8_t internal_function_rom_peek(uint16_t addr)
void internal_function_rom_store(uint16_t addr, uint8_t value)
{
vicii.last_cpu_val = value;
/* LTK MMU modification prioritises over internal function rom */
if (cartridge_get_id(0) == CARTRIDGE_LT_KERNAL) {
if (c128ltkernal_ram_store(addr, value)) {
return;
}
}
if (internal_function_rom_enabled == INT_FUNCTION_RTC) {
bq4830y_store(rtc1_context, (uint16_t)(addr & 0x7fff), value);
ram_store(addr, value);
Expand Down
8 changes: 4 additions & 4 deletions vice/src/c64/cart/ltkernal.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ that area.
$DF04 - $DF07:
The LTK Port can be between 0 and 15. Only adaptors set to port 0 are allowed
to change the host configuration. Any writes to this register while PB2.6 and
CB2 are high (1), will result in the Lt. Kernal Host Adaptor being removed
from the bus until a hard reset, essentially reconfiguring to a stock system.
to change the host configuration.
bit meaning
--- -------
Expand Down Expand Up @@ -756,7 +754,6 @@ static void ltk_set_cb2(mc6821_state *ctx)
LOG2((LOG, "LTK RESET SCHEDULED at 0x%04x", reg_pc));
ltk_alarm_time = maincpu_clk + 57;
alarm_set(ltk_alarm, ltk_alarm_time);
/* machine_trigger_reset(MACHINE_RESET_MODE_SOFT); */
}
}
}
Expand All @@ -769,6 +766,8 @@ static void ltkernal_io_store(uint16_t addr, uint8_t value)
IDBG((LOG, "--------------------"));
if (addr & 0x4) {
/* any writes to 4, 5, 6 or 7 turn off LTK I/O until reset */
/* it turns out nothing happens when you write here. */
/*
if (ltk_ramwrite) {
ltk_on = 0;
ltk_ramwrite = 0;
Expand All @@ -777,6 +776,7 @@ static void ltkernal_io_store(uint16_t addr, uint8_t value)
ltk_ramh = 0;
LOG1((LOG, "LTK OFF at %04x", reg_pc));
}
*/
} else {
port = (addr >> 1) & 1; /* rs1 */
reg = (addr >> 0) & 1; /* rs0 */
Expand Down

0 comments on commit 41b6cb3

Please sign in to comment.