OXYGENHUB
# 9120e87480a6 enhanced-x16-emulator / src / memory.h
2.8 KiB · Objective-C · last changed chore(): initial commit 26 days ago source blame history raw
9120e874 Andy McCall 1
// Commander X16 Emulator
2
// Copyright (c) 2019 Michael Steil
3
// All rights reserved. License: 2-clause BSD
4
5
#ifndef _MEMORY_H_
6
#define _MEMORY_H_
7
8
#include <stdbool.h>
9
#include <stdint.h>
10
#include <stdio.h>
11
#include <SDL.h>
12
13
#ifdef __cplusplus
14
extern "C" {
15
#endif
16
17
#define BANK_SIZE 65536
18
19
#define USE_CURRENT_X16_BANK (-1)
20
#define debug_read6502(a, b, x) real_read6502((a), (b), true, (x))
21
22
// The write half of the same contract. A debugger's edit updates the machine
23
// and does nothing else: it spends no cycles and reports no watchpoint, because
24
// the program did not store anything. The byte is simply what was always there.
25
#define debug_write6502(a, b, v) real_write6502((a), (b), (v), true)
26
27
// X16 r0-r15
28
#define X16_REG_R0L (direct_page_add(2))
29
#define X16_REG_R0H (direct_page_add(3))
30
#define X16_REG_R1L (direct_page_add(4))
31
#define X16_REG_R1H (direct_page_add(5))
32
#define X16_REG_R2L (direct_page_add(6))
33
#define X16_REG_R2H (direct_page_add(7))
34
#define X16_REG_R3L (direct_page_add(8))
35
#define X16_REG_R3H (direct_page_add(9))
36
#define X16_REG_R4L (direct_page_add(10))
37
#define X16_REG_R4H (direct_page_add(11))
38
#define X16_REG_R5L (direct_page_add(12))
39
#define X16_REG_R5H (direct_page_add(13))
40
#define X16_REG_R6L (direct_page_add(14))
41
#define X16_REG_R6H (direct_page_add(15))
42
#define X16_REG_R7L (direct_page_add(16))
43
#define X16_REG_R7H (direct_page_add(17))
44
#define X16_REG_R8L (direct_page_add(18))
45
#define X16_REG_R8H (direct_page_add(19))
46
#define X16_REG_R9L (direct_page_add(20))
47
#define X16_REG_R9H (direct_page_add(21))
48
#define X16_REG_R10L (direct_page_add(22))
49
#define X16_REG_R10H (direct_page_add(23))
50
#define X16_REG_R11L (direct_page_add(24))
51
#define X16_REG_R11H (direct_page_add(25))
52
#define X16_REG_R12L (direct_page_add(26))
53
#define X16_REG_R12H (direct_page_add(27))
54
#define X16_REG_R13L (direct_page_add(28))
55
#define X16_REG_R13H (direct_page_add(29))
56
#define X16_REG_R14L (direct_page_add(30))
57
#define X16_REG_R14H (direct_page_add(31))
58
#define X16_REG_R15L (direct_page_add(32))
59
#define X16_REG_R15H (direct_page_add(33))
60
61
uint8_t read6502(uint16_t address, uint8_t bank);
62
uint8_t real_read6502(uint16_t address, uint8_t bank, bool debugOn, int16_t x16Bank);
63
void write6502(uint16_t address, uint8_t bank, uint8_t value);
64
void real_write6502(uint16_t address, uint8_t bank, uint8_t value, bool debugOn);
65
void vp6502();
66
67
void memory_init();
68
void memory_reset();
69
void memory_report_uninitialized_access(bool);
70
void memory_report_usage_statistics(const char *filename);
71
void memory_randomize_ram(bool);
72
73
void memory_save(SDL_RWops *f, bool dump_ram, bool dump_bank);
74
void memory_dump_usage_counts();
75
76
void memory_set_ram_bank(uint8_t bank);
77
void memory_set_rom_bank(uint8_t bank);
78
79
uint8_t memory_get_ram_bank();
80
uint8_t memory_get_rom_bank();
81
82
uint8_t emu_read(uint8_t reg, bool debugOn);
83
void emu_write(uint8_t reg, uint8_t value);
84
85
#ifdef __cplusplus
86
}
87
#endif
88
89
#endif