/*
 * Z80SIM  -  a Z80-CPU simulator
 *
 * Copyright (C) 2016 by Udo Munk
 *
 * This module implements the memory for an Altair 8800 system
 *
 * History:
 * 19-DEC-2016 stuff moved to here for better memory abstraction
 */

#include "sim.h"
#include "simglb.h"
#include "config.h"
#include "../../frontpanel/frontpanel.h"
#include "memory.h"

/* 64KB non banked memory */
BYTE memory[65536];

/* page table with memory configuration/state */
int p_tab[256];

/* memory write protected flag */
BYTE mem_wp;

void init_memory(void)
{
	register int i;

	/* initialize memory page table, no memory available */
	for (i = 0; i < 256; i++)
		p_tab[i] = MEM_NONE;

	/* then set the first ram_size pages to RAM */
	for (i = 0; i < ram_size; i++)
		p_tab[i] = MEM_RW;

	/* then set rom_size pages in upper memory to ROM */
	for (i = 256 - rom_size; i < 256; i++)
		p_tab[i] = MEM_RO;
}
