You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
1.7 KiB
C

#include "memory/memory.h"
#include "cpu/65el02.h"
#include "display/display.h"
#include "drive/drive.h"
int memory_max = 0x2000;
// ----------------------------------------------------------------------------
void
mem_store(int ptr, unsigned char value)
{
int id = cpu.mmuRBA & 0xff;
ptr &= 0xffff;
// printf("%d %04x\n",cpu.mmuEnRB,cpu.mmuRBB);
if ((cpu.mmuEnRB) && (ptr >= cpu.mmuRBB) && (ptr < cpu.mmuRBB + 256))
{
ptr = ptr - cpu.mmuRBB;
switch (peripherals[id])
{
case 1:
case 2:
disp_store(id, ptr, value);
break;
case 3:
drive_store(id, ptr, value);
break;
case 4:
if (ptr == 2)
ioextender[id].output = (ioextender[id].output & 0xff00) | value;
if (ptr == 3)
ioextender[id].output = (ioextender[id].output & 0xff) | value << 8;
break;
}
}
else
{
if (ptr < memory_max)
ram[ptr] = value;
}
}
// ----------------------------------------------------------------------------
unsigned char
mem_load(int ptr)
{
int id = cpu.mmuRBA & 0xff;
ptr &= 0xffff;
if ((cpu.mmuEnRB) && (ptr >= cpu.mmuRBB) && (ptr < cpu.mmuRBB + 256))
{
ptr = ptr - cpu.mmuRBB;
switch (peripherals[id])
{
case 1:
case 2:
return disp_load(id, ptr);
break;
case 3:
return drive_load(id, ptr);
break;
case 4:
if (ptr == 0)
return ioextender[id].input & 0xff;
if (ptr == 1)
return (ioextender[id].input >> 8) & 0xff;
if (ptr == 2)
return ioextender[id].output & 0xff;
if (ptr == 3)
return (ioextender[id].output >> 8) & 0xff;
break;
}
return 0;
}
else
{
if (ptr < memory_max)
return ram[ptr];
else
return 0;
}
}
// ----------------------------------------------------------------------------