~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/emucore/m6502/src/M6502Low.m4

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-07-12 23:49:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100712234936-juawrr3etzhr2qpv
Tags: 3.1.2-1
* New maintainer (closes: #532039).
* New upstream version (closes: #461121):
  - includes launcher (closes: #396058).
* Fix the reference to the X Window System in the description (closes:
  #411815).
* Move to main, DFSG-free ROMs are available (see README.Debian).
* Enhance the package description.
* Drop the libslang2-dev dependency (closes: #560274).
* Remove the Encoding entry from stella.desktop.
* Avoid ignoring errors when cleaning.
* Add ${misc:Depends} to the package dependencies.
* Provide a doc-base file to install the documentation using doc-base.
* Switch to debhelper 7 with a simplified rules file.
* Use autotools-dev to provide updated configuration files.
* Update to Standards-Version 3.9.0:
  - Move to menu section Applications/Emulators.
  - Move the homepage declaration.
* Re-write the manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//============================================================================
2
 
//
3
 
// MM     MM  6666  555555  0000   2222
4
 
// MMMM MMMM 66  66 55     00  00 22  22
5
 
// MM MMM MM 66     55     00  00     22
6
 
// MM  M  MM 66666  55555  00  00  22222  --  "A 6502 Microprocessor Emulator"
7
 
// MM     MM 66  66     55 00  00 22
8
 
// MM     MM 66  66 55  55 00  00 22
9
 
// MM     MM  6666   5555   0000  222222
10
 
//
11
 
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
12
 
//
13
 
// See the file "license" for information on usage and redistribution of
14
 
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
 
//
16
 
// $Id: M6502Low.m4,v 1.4 2006/02/05 02:49:47 stephena Exp $
17
 
//============================================================================
18
 
 
19
 
/**
20
 
  Code to handle addressing modes and branch instructions for
21
 
  low compatibility emulation
22
 
 
23
 
  @author  Bradford W. Mott
24
 
  @version $Id: M6502Low.m4,v 1.4 2006/02/05 02:49:47 stephena Exp $
25
 
*/
26
 
 
27
 
#ifndef NOTSAMEPAGE
28
 
  #define NOTSAMEPAGE(_addr1, _addr2) (((_addr1) ^ (_addr2)) & 0xff00)
29
 
#endif
30
 
 
31
 
define(M6502_IMPLIED, `{
32
 
}')
33
 
 
34
 
define(M6502_IMMEDIATE_READ, `{
35
 
  operandAddress = PC++;
36
 
  operand = peek(operandAddress);
37
 
}')
38
 
 
39
 
define(M6502_ABSOLUTE_READ, `{
40
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
41
 
  PC += 2;
42
 
  operand = peek(operandAddress);
43
 
}')
44
 
 
45
 
define(M6502_ABSOLUTE_WRITE, `{
46
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
47
 
  PC += 2;
48
 
}')
49
 
 
50
 
define(M6502_ABSOLUTE_READMODIFYWRITE, `{
51
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
52
 
  PC += 2;
53
 
  operand = peek(operandAddress);
54
 
}')
55
 
 
56
 
define(M6502_ABSOLUTEX_READ, `{
57
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
58
 
  PC += 2;
59
 
 
60
 
  // See if we need to add one cycle for indexing across a page boundary
61
 
  if(NOTSAMEPAGE(operandAddress, operandAddress + X))
62
 
  {
63
 
    mySystem->incrementCycles(mySystemCyclesPerProcessorCycle);
64
 
  }
65
 
 
66
 
  operandAddress += X;
67
 
  operand = peek(operandAddress);
68
 
}')
69
 
 
70
 
define(M6502_ABSOLUTEX_WRITE, `{
71
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
72
 
  PC += 2;
73
 
  operandAddress += X; 
74
 
}')
75
 
 
76
 
define(M6502_ABSOLUTEX_READMODIFYWRITE, `{
77
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
78
 
  PC += 2;
79
 
  operandAddress += X;
80
 
  operand = peek(operandAddress);
81
 
}')
82
 
 
83
 
define(M6502_ABSOLUTEY_READ, `{
84
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
85
 
  PC += 2;
86
 
 
87
 
  // See if we need to add one cycle for indexing across a page boundary
88
 
  if(NOTSAMEPAGE(operandAddress, operandAddress + Y))
89
 
  {
90
 
    mySystem->incrementCycles(mySystemCyclesPerProcessorCycle);
91
 
  }
92
 
 
93
 
  operandAddress += Y;
94
 
  operand = peek(operandAddress);
95
 
}')
96
 
 
97
 
define(M6502_ABSOLUTEY_WRITE, `{
98
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
99
 
  PC += 2;
100
 
  operandAddress += Y; 
101
 
}')
102
 
 
103
 
define(M6502_ABSOLUTEY_READMODIFYWRITE, `{
104
 
  operandAddress = (uInt16)peek(PC) | ((uInt16)peek(PC + 1) << 8);
105
 
  PC += 2;
106
 
  operandAddress += Y;
107
 
  operand = peek(operandAddress);
108
 
}')
109
 
 
110
 
define(M6502_ZERO_READ, `{
111
 
  operandAddress = peek(PC++);
112
 
  operand = peek(operandAddress);
113
 
}')
114
 
 
115
 
define(M6502_ZERO_WRITE, `{
116
 
  operandAddress = peek(PC++);
117
 
}')
118
 
 
119
 
define(M6502_ZERO_READMODIFYWRITE, `{
120
 
  operandAddress = peek(PC++);
121
 
  operand = peek(operandAddress);
122
 
}')
123
 
 
124
 
define(M6502_ZEROX_READ, `{
125
 
  operandAddress = (uInt8)(peek(PC++) + X);
126
 
  operand = peek(operandAddress); 
127
 
}')
128
 
 
129
 
define(M6502_ZEROX_WRITE, `{
130
 
  operandAddress = (uInt8)(peek(PC++) + X);
131
 
}')
132
 
 
133
 
define(M6502_ZEROX_READMODIFYWRITE, `{
134
 
  operandAddress = (uInt8)(peek(PC++) + X);
135
 
  operand = peek(operandAddress);
136
 
}')
137
 
 
138
 
define(M6502_ZEROY_READ, `{
139
 
  operandAddress = (uInt8)(peek(PC++) + Y);
140
 
  operand = peek(operandAddress); 
141
 
}')
142
 
 
143
 
define(M6502_ZEROY_WRITE, `{
144
 
  operandAddress = (uInt8)(peek(PC++) + Y);
145
 
}')
146
 
 
147
 
define(M6502_ZEROY_READMODIFYWRITE, `{
148
 
  operandAddress = (uInt8)(peek(PC++) + Y);
149
 
  operand = peek(operandAddress);
150
 
}')
151
 
 
152
 
define(M6502_INDIRECT, `{
153
 
  uInt16 addr = peek(PC) | ((uInt16)peek(PC + 1) << 8);
154
 
  PC += 2;
155
 
 
156
 
  // Simulate the error in the indirect addressing mode!
157
 
  uInt16 high = NOTSAMEPAGE(addr, addr + 1) ? (addr & 0xff00) : (addr + 1);
158
 
 
159
 
  operandAddress = peek(addr) | ((uInt16)peek(high) << 8);
160
 
}')
161
 
 
162
 
define(M6502_INDIRECTX_READ, `{
163
 
  uInt8 pointer = peek(PC++) + X;
164
 
  operandAddress = peek(pointer) | ((uInt16)peek(pointer + 1) << 8);
165
 
  operand = peek(operandAddress);
166
 
}')
167
 
 
168
 
define(M6502_INDIRECTX_WRITE, `{
169
 
  uInt8 pointer = peek(PC++) + X;
170
 
  operandAddress = peek(pointer) | ((uInt16)peek(pointer + 1) << 8);
171
 
}')
172
 
 
173
 
define(M6502_INDIRECTX_READMODIFYWRITE, `{
174
 
  uInt8 pointer = peek(PC++) + X;
175
 
  operandAddress = peek(pointer) | ((uInt16)peek(pointer + 1) << 8);
176
 
  operand = peek(operandAddress);
177
 
}')
178
 
 
179
 
define(M6502_INDIRECTY_READ, `{
180
 
  uInt8 pointer = peek(PC++);
181
 
  operandAddress = (uInt16)peek(pointer) | ((uInt16)peek(pointer + 1) << 8); 
182
 
 
183
 
  if(NOTSAMEPAGE(operandAddress, operandAddress + Y))
184
 
  {
185
 
    mySystem->incrementCycles(mySystemCyclesPerProcessorCycle);
186
 
  }
187
 
 
188
 
  operandAddress += Y;
189
 
  operand = peek(operandAddress);
190
 
}')
191
 
 
192
 
define(M6502_INDIRECTY_WRITE, `{
193
 
  uInt8 pointer = peek(PC++);
194
 
  operandAddress = (uInt16)peek(pointer) | ((uInt16)peek(pointer + 1) << 8); 
195
 
  operandAddress += Y;
196
 
}')
197
 
 
198
 
define(M6502_INDIRECTY_READMODIFYWRITE, `{
199
 
  uInt8 pointer = peek(PC++);
200
 
  operandAddress = (uInt16)peek(pointer) | ((uInt16)peek(pointer + 1) << 8); 
201
 
  operandAddress += Y;
202
 
  operand = peek(operandAddress);
203
 
}')
204
 
 
205
 
 
206
 
define(M6502_BCC, `{
207
 
  if(!C)
208
 
  {
209
 
    uInt16 address = PC + (Int8)operand;
210
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
211
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
212
 
    PC = address;
213
 
  }
214
 
}')
215
 
 
216
 
define(M6502_BCS, `{
217
 
  if(C)
218
 
  {
219
 
    uInt16 address = PC + (Int8)operand;
220
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
221
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
222
 
    PC = address;
223
 
  }
224
 
}')
225
 
 
226
 
define(M6502_BEQ, `{
227
 
  if(!notZ)
228
 
  {
229
 
    uInt16 address = PC + (Int8)operand;
230
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
231
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
232
 
    PC = address;
233
 
  }
234
 
}')
235
 
 
236
 
define(M6502_BMI, `{
237
 
  if(N)
238
 
  {
239
 
    uInt16 address = PC + (Int8)operand;
240
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
241
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
242
 
    PC = address;
243
 
  }
244
 
}')
245
 
 
246
 
define(M6502_BNE, `{
247
 
  if(notZ)
248
 
  {
249
 
    uInt16 address = PC + (Int8)operand;
250
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
251
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
252
 
    PC = address;
253
 
  }
254
 
}')
255
 
 
256
 
define(M6502_BPL, `{
257
 
  if(!N)
258
 
  {
259
 
    uInt16 address = PC + (Int8)operand;
260
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
261
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
262
 
    PC = address;
263
 
  }
264
 
}')
265
 
 
266
 
define(M6502_BVC, `{
267
 
  if(!V)
268
 
  {
269
 
    uInt16 address = PC + (Int8)operand;
270
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
271
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
272
 
    PC = address;
273
 
  }
274
 
}')
275
 
 
276
 
define(M6502_BVS, `{
277
 
  if(V)
278
 
  {
279
 
    uInt16 address = PC + (Int8)operand;
280
 
    mySystem->incrementCycles(NOTSAMEPAGE(PC, address) ?
281
 
        mySystemCyclesPerProcessorCycle << 1 : mySystemCyclesPerProcessorCycle);
282
 
    PC = address;
283
 
  }
284
 
}')
285
 
 
286