r16/emu/cpu/ram.c
2024-04-19 09:05:10 +00:00

29 lines
441 B
C

#include "ram.h"
#include <stdlib.h>
r16_int* ram = NULL;
void InitRam()
{
ram = (r16_int*)malloc(sizeof(r16_int) * UINT16_MAX);
}
r16_int GetValue(r16_int address)
{
#ifdef RAM_DO_NULL_CHECK
if (ram == NULL) { InitRam(); }
#endif
return ram[address.u];
}
void SetValue(r16_int address, r16_int value)
{
#ifdef RAM_DO_NULL_CHECK
if (ram == NULL) { InitRam(); }
#endif
ram[address.u] = value;
}