v6502
The MOS 6502 Virtual Machine and Toolchain Infrastructure
Data Structures | Macros | Typedefs | Functions
mem.h File Reference

Virtual Memory. More...

#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  v6502_mappedRange
 Memory Map Range Record. More...
 
struct  v6502_memory
 Virtual Memory Object. More...
 

Macros

#define YES   1
 Boolean true.
 
#define NO   0
 Boolean false.
 
#define v6502_memoryStartWorkMemory   0x0000
 Start of work memory available for general program use.
 
#define v6502_memoryStartStack   0x0100
 Start of memory reserved for CPU stack.
 
#define v6502_memoryStartPPURegisters   0x2000
 Start of PPU registers for the RP2C02 chipset.
 
#define v6502_memoryStartAPURegisters   0x4000
 Start of APU registers for the RP2A03 chipset.
 
#define v6502_memoryStartExpansionRom   0x4020
 Start of memory mapped expansion ROM.
 
#define v6502_memoryStartSRAM   0x6000
 Start of SRAM backed memory region.
 
#define v6502_memoryStartPRGROM   0x8000
 Start of memory mapped PRGROM.
 
#define v6502_memoryStartInterruptVectors   0xFFFA
 Start of memory mapped interrupt vectors.
 
#define v6502_memoryStartCeiling   0xFFFF
 Maximum memory boundary.
 
#define v6502_memorySizeWorkMemory   0x0800
 Size of work memory available for general program use.
 
#define v6502_memorySizePPURegisters   0x0008
 Size of PPU registers for the RP2C02 chipset.
 
#define v6502_memorySizeInterruptVectors   (v6502_memoryStartCeiling - v6502_memoryStartInterruptVectors)
 Size of the six interrupt vector bytes (Hint: It's six.)
 
#define v6502_memoryVectorNMILow   0xFFFA
 The low byte location of the NMI vector stored in the v6502_memory::interrupt_vectors.
 
#define v6502_memoryVectorNMIHigh   0xFFFB
 The high byte location of the NMI vector stored in the v6502_memory::interrupt_vectors.
 
#define v6502_memoryVectorResetLow   0xFFFC
 The low byte location of the reset vector stored in the v6502_memory::interrupt_vectors.
 
#define v6502_memoryVectorResetHigh   0xFFFD
 The high byte location of the reset vector stored in the v6502_memory::interrupt_vectors.
 
#define v6502_memoryVectorInterruptLow   0xFFFE
 The low byte location of the normal interrupt vector stored in the v6502_memory::interrupt_vectors.
 
#define v6502_memoryVectorInterruptHigh   0xFFFF
 The high byte location of the normal interrupt vector stored in the v6502_memory::interrupt_vectors.
 
#define BYTE_MAX   0xFF
 Maximum possible value of an 8-bit byte.
 

Typedefs

typedef uint8_t() v6502_readFunction(struct _v6502_memory *memory, uint16_t offset, int trap, void *context)
 The function prototype for memory mapped accessors to be used by external virtual hardware.
 
typedef void() v6502_writeFunction(struct _v6502_memory *memory, uint16_t offset, uint8_t value, void *context)
 The function prototype for memory mapped accessors to be used by external virtual hardware.
 

Functions

v6502_memoryv6502_createMemory (size_t size)
 Create v6502_memory, type is a size_t so that you can alloc an entire 64k with 0x1,0000. More...
 
void v6502_destroyMemory (v6502_memory *memory)
 Destroy v6502_memory.
 
void v6502_loadExpansionRomIntoMemory (v6502_memory *memory, uint8_t *rom, uint16_t size)
 Load a binary blob of expansion ROM into a given v6502_memory.
 
int v6502_map (v6502_memory *memory, uint16_t start, size_t size, v6502_readFunction *read, v6502_writeFunction *write, void *context)
 Map an address in v6502_memory. More...
 
uint8_t v6502_read (v6502_memory *memory, uint16_t offset, int trap)
 Read a byte from v6502_memory. More...
 
void v6502_write (v6502_memory *memory, uint16_t offset, uint8_t value)
 Write a byte to v6502_memory. More...
 
v6502_mappedRangev6502_mappedRangeForOffset (v6502_memory *memory, uint16_t offset)
 Locate a v6502_mappedRange inside of v6502_memory, if it exists. More...
 
int8_t v6502_signedValueOfByte (uint8_t byte)
 Convert a raw byte to its signed value.
 
uint8_t v6502_byteValueOfSigned (int8_t i)
 Convert a signed value to its raw byte.
 

Detailed Description

Virtual Memory.