yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
addressing.cc
Go to the documentation of this file.
2
3namespace yaze {
4namespace app {
5namespace emu {
6namespace audio {
7
8// adressing modes
9
10uint16_t Spc700::ind() {
11 read(PC);
12 return X | (PSW.P << 8);
13}
14
15uint16_t Spc700::idx() {
16 uint8_t pointer = ReadOpcode();
17 callbacks_.idle(false);
18 return read_word(((pointer + X) & 0xff) | (PSW.P << 8));
19}
20
21uint16_t Spc700::dpx() {
22 uint16_t res = ((ReadOpcode() + X) & 0xff) | (PSW.P << 8);
23 callbacks_.idle(false);
24 return res;
25}
26
27uint16_t Spc700::dp_y() {
28 uint16_t res = ((ReadOpcode() + Y) & 0xff) | (PSW.P << 8);
29 callbacks_.idle(false);
30 return res;
31}
32
33uint16_t Spc700::abs_x() {
34 uint16_t res = (ReadOpcodeWord() + X) & 0xffff;
35 callbacks_.idle(false);
36 return res;
37}
38
39uint16_t Spc700::abs_y() {
40 uint16_t res = (ReadOpcodeWord() + Y) & 0xffff;
41 callbacks_.idle(false);
42 return res;
43}
44
45uint16_t Spc700::idy() {
46 uint8_t pointer = ReadOpcode();
47 uint16_t adr = read_word(pointer | (PSW.P << 8));
48 callbacks_.idle(false);
49 return (adr + Y) & 0xffff;
50}
51
52uint16_t Spc700::dp_imm(uint8_t* srcVal) {
53 *srcVal = ReadOpcode();
54 return ReadOpcode() | (PSW.P << 8);
55}
56
57uint16_t Spc700::ind_ind(uint8_t* srcVal) {
58 read(PC);
59 *srcVal = read(Y | (PSW.P << 8));
60 return X | (PSW.P << 8);
61}
62
63uint8_t Spc700::abs_bit(uint16_t* adr) {
64 uint16_t adrBit = ReadOpcodeWord();
65 *adr = adrBit & 0x1fff;
66 return adrBit >> 13;
67}
68
69uint16_t Spc700::dp_word(uint16_t* low) {
70 uint8_t adr = ReadOpcode();
71 *low = adr | (PSW.P << 8);
72 return ((adr + 1) & 0xff) | (PSW.P << 8);
73}
74
75uint16_t Spc700::ind_p() {
76 read(PC);
77 return X++ | (PSW.P << 8);
78}
79
80// Immediate
81uint16_t Spc700::imm() { return PC++; }
82
83// Direct page
84uint8_t Spc700::dp() {
85 return ReadOpcode() | (PSW.P << 8);
86}
87
88// Direct page indexed by X
90 PC++;
91 uint8_t offset = read(PC);
92 return read((PSW.P << 8) + offset + X);
93}
94
95// Direct page indexed by Y
97 PC++;
98 uint8_t offset = read(PC);
99 return read((PSW.P << 8) + offset + Y);
100}
101
102// Indexed indirect (add index before 16-bit lookup).
104 PC++;
105 uint16_t addr = read_word(PC + X);
106 return addr;
107}
108
109// Indirect indexed (add index after 16-bit lookup).
111 PC++;
112 uint16_t offset = read_word(PC);
113 return offset + Y;
114}
115
116uint16_t Spc700::dp_dp(uint8_t* src) {
117 *src = read(ReadOpcode() | (PSW.P << 8));
118 return ReadOpcode() | (PSW.P << 8);
119}
120
121uint16_t Spc700::abs() { return ReadOpcodeWord(); }
122
123int8_t Spc700::rel() {
124 PC++;
125 return static_cast<int8_t>(read(PC));
126}
127
128uint8_t Spc700::i() { return read((PSW.P << 8) + X); }
129
131 uint8_t value = read((PSW.P << 8) + X);
132 X++;
133 return value;
134}
135
137 PC++;
138 uint16_t addr = read(PC) | (read(PC) << 8);
139 return read(addr) + X;
140}
141
143 PC++;
144 uint16_t addr = read(PC) | (read(PC) << 8);
145 addr += X;
146 return read(addr) | (read(addr + 1) << 8);
147}
148
149} // namespace audio
150} // namespace emu
151} // namespace app
152} // namespace yaze
uint16_t dp_word(uint16_t *low)
Definition addressing.cc:69
uint16_t dp_dp(uint8_t *src)
uint16_t read_word(uint16_t address)
Definition spc700.h:148
uint8_t abs_bit(uint16_t *adr)
Definition addressing.cc:63
uint16_t ind_ind(uint8_t *srcVal)
Definition addressing.cc:57
uint16_t dp_imm(uint8_t *srcVal)
Definition addressing.cc:52
uint8_t read(uint16_t address)
Definition spc700.h:146
Definition common.cc:21
std::function< void(bool)> idle
Definition spc700.h:58