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

« back to all changes in this revision

Viewing changes to src/debugger/TIADebug.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Mario Iseli
  • Date: 2006-04-08 18:38:25 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060408183825-vu1jk57rk929derx
* New Maintainer (Closes: #361345)
* New upstream release (Closes: #349725)
* Build-Depend now on libslang2-dev (Closes: #325577)
* Complete rebuild of debian/, upgraded to policy-standards
  3.6.2 and compat-level 5.
* Removed stellarc since stella only reads ~/.stellarc and even
  works without a first config.
* New debian/watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//============================================================================
 
2
//
 
3
//   SSSS    tt          lll  lll       
 
4
//  SS  SS   tt           ll   ll        
 
5
//  SS     tttttt  eeee   ll   ll   aaaa 
 
6
//   SSSS    tt   ee  ee  ll   ll      aa
 
7
//      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator"
 
8
//  SS  SS   tt   ee      ll   ll  aa  aa
 
9
//   SSSS     ttt  eeeee llll llll  aaaaa
 
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: TIADebug.cxx,v 1.23 2005/10/13 18:53:07 stephena Exp $
 
17
//============================================================================
 
18
 
 
19
#include "System.hxx"
 
20
#include "Debugger.hxx"
 
21
 
 
22
#include "TIADebug.hxx"
 
23
 
 
24
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
25
TIADebug::TIADebug(Debugger* dbg, Console* console)
 
26
  : DebuggerSystem(dbg, console),
 
27
    mySystem(&console->system()),
 
28
    myTIA((TIA*)&console->mediaSource())
 
29
{
 
30
  nusizStrings[0] = "size=8 copy=1";
 
31
  nusizStrings[1] = "size=8 copy=2 spac=8";
 
32
  nusizStrings[2] = "size=8 copy=2 spac=$18";
 
33
  nusizStrings[3] = "size=8 copy=3 spac=8";
 
34
  nusizStrings[4] = "size=8 copy=2 spac=$38";
 
35
  nusizStrings[5] = "size=$10 copy=1";
 
36
  nusizStrings[6] = "size=8 copy=3 spac=$18";
 
37
  nusizStrings[7] = "size=$20 copy=1";
 
38
}
 
39
 
 
40
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
41
DebuggerState& TIADebug::getState()
 
42
{
 
43
  myState.ram.clear();
 
44
  for(int i = 0; i < 0x010; ++i)
 
45
    myState.ram.push_back(myTIA->peek(i));
 
46
 
 
47
  // Color registers
 
48
  myState.coluRegs.clear();
 
49
  myState.coluRegs.push_back(coluP0());
 
50
  myState.coluRegs.push_back(coluP1());
 
51
  myState.coluRegs.push_back(coluPF());
 
52
  myState.coluRegs.push_back(coluBK());
 
53
 
 
54
  // Player 1 & 2 graphics registers
 
55
  myState.gr.clear();
 
56
  myState.gr.push_back(grP0());
 
57
  myState.gr.push_back(grP1());
 
58
 
 
59
  // Position registers
 
60
  myState.pos.clear();
 
61
  myState.pos.push_back(posP0());
 
62
  myState.pos.push_back(posP1());
 
63
  myState.pos.push_back(posM0());
 
64
  myState.pos.push_back(posM1());
 
65
  myState.pos.push_back(posBL());
 
66
 
 
67
  // Horizontal move registers
 
68
  myState.hm.clear();
 
69
  myState.hm.push_back(hmP0());
 
70
  myState.hm.push_back(hmP1());
 
71
  myState.hm.push_back(hmM0());
 
72
  myState.hm.push_back(hmM1());
 
73
  myState.hm.push_back(hmBL());
 
74
 
 
75
  // Playfield registers
 
76
  myState.pf.clear();
 
77
  myState.pf.push_back(pf0());
 
78
  myState.pf.push_back(pf1());
 
79
  myState.pf.push_back(pf2());
 
80
 
 
81
  // Size registers
 
82
  myState.size.clear();
 
83
  myState.size.push_back(nusizP0());
 
84
  myState.size.push_back(nusizP1());
 
85
  myState.size.push_back(nusizM0());
 
86
  myState.size.push_back(nusizM1());
 
87
  myState.size.push_back(sizeBL());
 
88
 
 
89
  // Audio registers
 
90
  myState.aud.clear();
 
91
  myState.aud.push_back(audF0());
 
92
  myState.aud.push_back(audF1());
 
93
  myState.aud.push_back(audC0());
 
94
  myState.aud.push_back(audC1());
 
95
  myState.aud.push_back(audV0());
 
96
  myState.aud.push_back(audV1());
 
97
 
 
98
  return myState;
 
99
}
 
100
 
 
101
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
102
void TIADebug::saveOldState()
 
103
{
 
104
  myOldState.ram.clear();
 
105
  for(int i = 0; i < 0x010; ++i)
 
106
    myOldState.ram.push_back(myTIA->peek(i));
 
107
 
 
108
  // Color registers
 
109
  myOldState.coluRegs.clear();
 
110
  myOldState.coluRegs.push_back(coluP0());
 
111
  myOldState.coluRegs.push_back(coluP1());
 
112
  myOldState.coluRegs.push_back(coluPF());
 
113
  myOldState.coluRegs.push_back(coluBK());
 
114
 
 
115
  // Player 1 & 2 graphics registers
 
116
  myOldState.gr.clear();
 
117
  myOldState.gr.push_back(grP0());
 
118
  myOldState.gr.push_back(grP1());
 
119
 
 
120
  // Position registers
 
121
  myOldState.pos.clear();
 
122
  myOldState.pos.push_back(posP0());
 
123
  myOldState.pos.push_back(posP1());
 
124
  myOldState.pos.push_back(posM0());
 
125
  myOldState.pos.push_back(posM1());
 
126
  myOldState.pos.push_back(posBL());
 
127
 
 
128
  // Horizontal move registers
 
129
  myOldState.hm.clear();
 
130
  myOldState.hm.push_back(hmP0());
 
131
  myOldState.hm.push_back(hmP1());
 
132
  myOldState.hm.push_back(hmM0());
 
133
  myOldState.hm.push_back(hmM1());
 
134
  myOldState.hm.push_back(hmBL());
 
135
 
 
136
  // Playfield registers
 
137
  myOldState.pf.clear();
 
138
  myOldState.pf.push_back(pf0());
 
139
  myOldState.pf.push_back(pf1());
 
140
  myOldState.pf.push_back(pf2());
 
141
 
 
142
  // Size registers
 
143
  myOldState.size.clear();
 
144
  myOldState.size.push_back(nusizP0());
 
145
  myOldState.size.push_back(nusizP1());
 
146
  myOldState.size.push_back(nusizM0());
 
147
  myOldState.size.push_back(nusizM1());
 
148
  myOldState.size.push_back(sizeBL());
 
149
 
 
150
  // Audio registers
 
151
  myOldState.aud.clear();
 
152
  myOldState.aud.push_back(audF0());
 
153
  myOldState.aud.push_back(audF1());
 
154
  myOldState.aud.push_back(audC0());
 
155
  myOldState.aud.push_back(audC1());
 
156
  myOldState.aud.push_back(audV0());
 
157
  myOldState.aud.push_back(audV1());
 
158
}
 
159
 
 
160
/* the set methods now use mySystem->poke(). This will save us the
 
161
        trouble of masking the values here, since TIA::poke() will do it
 
162
        for us.
 
163
 
 
164
        This means that the GUI should *never* just display the value the
 
165
        user entered: it should always read the return value of the set
 
166
        method and display that.
 
167
 
 
168
        An Example:
 
169
 
 
170
        User enters "ff" in the AUDV0 field. GUI calls value = tiaDebug->audV0(0xff).
 
171
        The AUDV0 register is only 4 bits wide, so "value" is 0x0f. That's what
 
172
        should be displayed.
 
173
 
 
174
        In a perfect world, the GUI would only allow one hex digit to be entered...
 
175
        but we allow decimal or binary input in the GUI (with # or \ prefix). The
 
176
        only way to make that work would be to validate the data entry after every
 
177
        keystroke... which would be a pain for both us and the user. Using poke()
 
178
        here is a compromise that allows the TIA to do the range-checking for us,
 
179
        so the GUI and/or TIADebug don't have to duplicate logic from TIA::poke().
 
180
*/
 
181
 
 
182
//       bool vdelP0(int newVal = -1);
 
183
//       bool vdelP1(int newVal = -1);
 
184
//       bool vdelBL(int newVal = -1);
 
185
 
 
186
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
187
bool TIADebug::vdelP0(int newVal)
 
188
{
 
189
  if(newVal > -1)
 
190
    mySystem->poke(VDELP0, ((bool)newVal));
 
191
 
 
192
  return myTIA->myVDELP0;
 
193
}
 
194
 
 
195
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
196
bool TIADebug::vdelP1(int newVal)
 
197
{
 
198
  if(newVal > -1)
 
199
    mySystem->poke(VDELP1, ((bool)newVal));
 
200
 
 
201
  return myTIA->myVDELP1;
 
202
}
 
203
 
 
204
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
205
bool TIADebug::vdelBL(int newVal)
 
206
{
 
207
  if(newVal > -1)
 
208
    mySystem->poke(VDELBL, ((bool)newVal));
 
209
 
 
210
  return myTIA->myVDELBL;
 
211
}
 
212
 
 
213
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
214
bool TIADebug::enaM0(int newVal)
 
215
{
 
216
  if(newVal > -1)
 
217
    mySystem->poke(ENAM0, ((bool)newVal) << 1);
 
218
 
 
219
  return myTIA->myENAM0;
 
220
}
 
221
 
 
222
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
223
bool TIADebug::enaM1(int newVal)
 
224
{
 
225
  if(newVal > -1)
 
226
    mySystem->poke(ENAM1, ((bool)newVal) << 1);
 
227
 
 
228
  return myTIA->myENAM1;
 
229
}
 
230
 
 
231
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
232
bool TIADebug::enaBL(int newVal)
 
233
{
 
234
  if(newVal > -1)
 
235
    mySystem->poke(ENABL, ((bool)newVal) << 1);
 
236
 
 
237
  return myTIA->myENABL;
 
238
}
 
239
 
 
240
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
241
bool TIADebug::resMP0(int newVal)
 
242
{
 
243
  if(newVal > -1)
 
244
    mySystem->poke(RESMP0, ((bool)newVal) << 1);
 
245
 
 
246
  return myTIA->myRESMP0;
 
247
}
 
248
 
 
249
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
250
bool TIADebug::resMP1(int newVal)
 
251
{
 
252
  if(newVal > -1)
 
253
    mySystem->poke(RESMP1, ((bool)newVal) << 1);
 
254
 
 
255
  return myTIA->myRESMP1;
 
256
}
 
257
 
 
258
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
259
bool TIADebug::refP0(int newVal)
 
260
{
 
261
  if(newVal > -1)
 
262
    mySystem->poke(REFP0, ((bool)newVal) << 3);
 
263
 
 
264
  return myTIA->myREFP0;
 
265
}
 
266
 
 
267
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
268
bool TIADebug::refP1(int newVal)
 
269
{
 
270
  if(newVal > -1)
 
271
    mySystem->poke(REFP1, ((bool)newVal) << 3);
 
272
 
 
273
  return myTIA->myREFP1;
 
274
}
 
275
 
 
276
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
277
bool TIADebug::refPF(int newVal)
 
278
{
 
279
  if(newVal > -1)
 
280
  {
 
281
    int tmp = myTIA->myCTRLPF;
 
282
    if(newVal)
 
283
      tmp |= 0x01;
 
284
    else
 
285
      tmp &= ~0x01;
 
286
    mySystem->poke(CTRLPF, tmp);
 
287
  }
 
288
 
 
289
  return myTIA->myCTRLPF & 0x01;
 
290
}
 
291
 
 
292
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
293
bool TIADebug::scorePF(int newVal)
 
294
{
 
295
  if(newVal > -1)
 
296
  {
 
297
    int tmp = myTIA->myCTRLPF;
 
298
    if(newVal)
 
299
      tmp |= 0x02;
 
300
    else
 
301
      tmp &= ~0x02;
 
302
    mySystem->poke(CTRLPF, tmp);
 
303
  }
 
304
 
 
305
  return myTIA->myCTRLPF & 0x02;
 
306
}
 
307
 
 
308
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
309
bool TIADebug::priorityPF(int newVal)
 
310
{
 
311
  if(newVal > -1)
 
312
  {
 
313
    int tmp = myTIA->myCTRLPF;
 
314
    if(newVal)
 
315
      tmp |= 0x04;
 
316
    else
 
317
      tmp &= ~0x04;
 
318
    mySystem->poke(CTRLPF, tmp);
 
319
  }
 
320
 
 
321
  return myTIA->myCTRLPF & 0x04;
 
322
}
 
323
 
 
324
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
325
bool TIADebug::collision(int collID, int newVal)
 
326
{
 
327
  unsigned int mask = 1 << collID;
 
328
 
 
329
  if(newVal > -1)
 
330
  {
 
331
    if(newVal)
 
332
      myTIA->myCollision |= mask;
 
333
    else
 
334
      myTIA->myCollision &= ~mask;
 
335
  }
 
336
 
 
337
  return myTIA->myCollision & mask;
 
338
}  
 
339
 
 
340
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
341
uInt8 TIADebug::audC0(int newVal)
 
342
{
 
343
  if(newVal > -1)
 
344
    mySystem->poke(AUDC0, newVal);
 
345
 
 
346
  return myTIA->myAUDC0;
 
347
}
 
348
 
 
349
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
350
uInt8 TIADebug::audC1(int newVal)
 
351
{
 
352
  if(newVal > -1)
 
353
    mySystem->poke(AUDC1, newVal);
 
354
 
 
355
  return myTIA->myAUDC1;
 
356
}
 
357
 
 
358
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
359
uInt8 TIADebug::audV0(int newVal)
 
360
{
 
361
  if(newVal > -1)
 
362
    mySystem->poke(AUDV0, newVal);
 
363
 
 
364
  return myTIA->myAUDV0;
 
365
}
 
366
 
 
367
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
368
uInt8 TIADebug::audV1(int newVal)
 
369
{
 
370
  if(newVal > -1)
 
371
    mySystem->poke(AUDV1, newVal);
 
372
 
 
373
  return myTIA->myAUDV1;
 
374
}
 
375
 
 
376
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
377
uInt8 TIADebug::audF0(int newVal)
 
378
{
 
379
  if(newVal > -1)
 
380
    mySystem->poke(AUDF0, newVal);
 
381
 
 
382
  return myTIA->myAUDF0;
 
383
}
 
384
 
 
385
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
386
uInt8 TIADebug::audF1(int newVal)
 
387
{
 
388
  if(newVal > -1)
 
389
    mySystem->poke(AUDF1, newVal);
 
390
 
 
391
  return myTIA->myAUDF1;
 
392
}
 
393
 
 
394
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
395
uInt8 TIADebug::pf0(int newVal)
 
396
{
 
397
  if(newVal > -1)
 
398
    mySystem->poke(PF0, newVal << 4);
 
399
 
 
400
  return myTIA->myPF & 0x0f;
 
401
}
 
402
 
 
403
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
404
uInt8 TIADebug::pf1(int newVal)
 
405
{
 
406
  if(newVal > -1)
 
407
    mySystem->poke(PF1, newVal);
 
408
 
 
409
  return (myTIA->myPF & 0xff0) >> 4;
 
410
}
 
411
 
 
412
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
413
uInt8 TIADebug::pf2(int newVal)
 
414
{
 
415
  if(newVal > -1)
 
416
    mySystem->poke(PF2, newVal);
 
417
 
 
418
  return (myTIA->myPF & 0xff000) >> 12;
 
419
}
 
420
 
 
421
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
422
uInt8 TIADebug::coluP0(int newVal)
 
423
{
 
424
  if(newVal > -1)
 
425
    mySystem->poke(COLUP0, newVal);
 
426
 
 
427
  return myTIA->myCOLUP0 & 0xff;
 
428
}
 
429
 
 
430
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
431
uInt8 TIADebug::coluP1(int newVal)
 
432
{
 
433
  if(newVal > -1)
 
434
    mySystem->poke(COLUP1, newVal);
 
435
 
 
436
  return myTIA->myCOLUP1 & 0xff;
 
437
}
 
438
 
 
439
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
440
uInt8 TIADebug::coluPF(int newVal)
 
441
{
 
442
  if(newVal > -1)
 
443
    mySystem->poke(COLUPF, newVal);
 
444
 
 
445
  return myTIA->myCOLUPF & 0xff;
 
446
}
 
447
 
 
448
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
449
uInt8 TIADebug::coluBK(int newVal)
 
450
{
 
451
  if(newVal > -1)
 
452
    mySystem->poke(COLUBK, newVal);
 
453
 
 
454
  return myTIA->myCOLUBK & 0xff;
 
455
}
 
456
 
 
457
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
458
uInt8 TIADebug::nusiz0(int newVal)
 
459
{
 
460
  if(newVal > -1)
 
461
    mySystem->poke(NUSIZ0, newVal);
 
462
 
 
463
  return myTIA->myNUSIZ0;
 
464
}
 
465
 
 
466
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
467
uInt8 TIADebug::nusiz1(int newVal)
 
468
{
 
469
  if(newVal > -1)
 
470
    mySystem->poke(NUSIZ1, newVal);
 
471
 
 
472
  return myTIA->myNUSIZ1;
 
473
}
 
474
 
 
475
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
476
uInt8 TIADebug::nusizP0(int newVal)
 
477
{
 
478
  if(newVal > -1)
 
479
  {
 
480
    uInt8 tmp = myTIA->myNUSIZ0 & ~0x07;
 
481
    tmp |= (newVal & 0x07);
 
482
    mySystem->poke(NUSIZ0, tmp);
 
483
  }
 
484
 
 
485
  return myTIA->myNUSIZ0 & 0x07;
 
486
}
 
487
 
 
488
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
489
uInt8 TIADebug::nusizP1(int newVal)
 
490
{
 
491
  if(newVal > -1)
 
492
  {
 
493
    uInt8 tmp = myTIA->myNUSIZ1 & ~0x07;
 
494
    tmp |= newVal & 0x07;
 
495
    mySystem->poke(NUSIZ1, tmp);
 
496
  }
 
497
 
 
498
  return myTIA->myNUSIZ1 & 0x07;
 
499
}
 
500
 
 
501
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
502
uInt8 TIADebug::nusizM0(int newVal)
 
503
{
 
504
  if(newVal > -1)
 
505
  {
 
506
    uInt8 tmp = myTIA->myNUSIZ0 & ~0x30;
 
507
    tmp |= (newVal & 0x04) << 4;
 
508
    mySystem->poke(NUSIZ0, tmp);
 
509
  }
 
510
 
 
511
  return (myTIA->myNUSIZ0 & 0x30) >> 4;
 
512
}
 
513
 
 
514
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
515
uInt8 TIADebug::nusizM1(int newVal)
 
516
{
 
517
  if(newVal > -1)
 
518
  {
 
519
    uInt8 tmp = myTIA->myNUSIZ1 & ~0x30;
 
520
    tmp |= (newVal & 0x04) << 4;
 
521
    mySystem->poke(NUSIZ1, tmp);
 
522
  }
 
523
 
 
524
  return (myTIA->myNUSIZ1 & 0x30) >> 4;
 
525
}
 
526
 
 
527
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
528
uInt8 TIADebug::grP0(int newVal)
 
529
{
 
530
  if(newVal > -1)
 
531
    mySystem->poke(GRP0, newVal);
 
532
 
 
533
  return myTIA->myGRP0;
 
534
}
 
535
 
 
536
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
537
uInt8 TIADebug::grP1(int newVal)
 
538
{
 
539
  if(newVal > -1)
 
540
    mySystem->poke(GRP1, newVal);
 
541
 
 
542
  return myTIA->myGRP1;
 
543
}
 
544
 
 
545
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
546
uInt8 TIADebug::posP0(int newVal)
 
547
{
 
548
  if(newVal > -1)
 
549
    myTIA->myPOSP0 = newVal;
 
550
  return myTIA->myPOSP0;
 
551
}
 
552
 
 
553
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
554
uInt8 TIADebug::posP1(int newVal)
 
555
{
 
556
  if(newVal > -1)
 
557
    myTIA->myPOSP1 = newVal;
 
558
  return myTIA->myPOSP1;
 
559
}
 
560
 
 
561
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
562
uInt8 TIADebug::posM0(int newVal)
 
563
{
 
564
/* FIXME
 
565
  if(newVal > -1)
 
566
    mySystem->poke(???, newVal);
 
567
*/
 
568
  return myTIA->myPOSM0;
 
569
}
 
570
 
 
571
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
572
uInt8 TIADebug::posM1(int newVal)
 
573
{
 
574
/* FIXME
 
575
  if(newVal > -1)
 
576
    mySystem->poke(???, newVal);
 
577
*/
 
578
  return myTIA->myPOSM1;
 
579
}
 
580
 
 
581
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
582
uInt8 TIADebug::posBL(int newVal)
 
583
{
 
584
/* FIXME
 
585
  if(newVal > -1)
 
586
    mySystem->poke(???, newVal);
 
587
*/
 
588
  return myTIA->myPOSBL;
 
589
}
 
590
 
 
591
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
592
uInt8 TIADebug::ctrlPF(int newVal)
 
593
{
 
594
  if(newVal > -1)
 
595
    mySystem->poke(CTRLPF, newVal);
 
596
 
 
597
  return myTIA->myCTRLPF;
 
598
}
 
599
 
 
600
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
601
uInt8 TIADebug::sizeBL(int newVal)
 
602
{
 
603
  if(newVal > -1)
 
604
  {
 
605
    uInt8 tmp = myTIA->myCTRLPF & ~0x30;
 
606
    tmp |= (newVal & 0x04) << 4;
 
607
    mySystem->poke(CTRLPF, tmp);
 
608
  }
 
609
 
 
610
  return (myTIA->myCTRLPF & 0x30) >> 4;
 
611
}
 
612
 
 
613
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
614
uInt8 TIADebug::hmP0(int newVal)
 
615
{
 
616
  if(newVal > -1)
 
617
    mySystem->poke(HMP0, newVal << 4);
 
618
 
 
619
  return myTIA->myHMP0;
 
620
}
 
621
 
 
622
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
623
uInt8 TIADebug::hmP1(int newVal)
 
624
{
 
625
  if(newVal > -1)
 
626
    mySystem->poke(HMP1, newVal << 4);
 
627
 
 
628
  return myTIA->myHMP1;
 
629
}
 
630
 
 
631
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
632
uInt8 TIADebug::hmM0(int newVal)
 
633
{
 
634
  if(newVal > -1)
 
635
    mySystem->poke(HMM0, newVal << 4);
 
636
 
 
637
  return myTIA->myHMM0;
 
638
}
 
639
 
 
640
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
641
uInt8 TIADebug::hmM1(int newVal)
 
642
{
 
643
  if(newVal > -1)
 
644
    mySystem->poke(HMM1, newVal << 4);
 
645
 
 
646
  return myTIA->myHMM1;
 
647
}
 
648
 
 
649
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
650
uInt8 TIADebug::hmBL(int newVal)
 
651
{
 
652
  if(newVal > -1)
 
653
    mySystem->poke(HMBL, newVal << 4);
 
654
 
 
655
  return myTIA->myHMBL;
 
656
}
 
657
 
 
658
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
659
int TIADebug::frameCount()
 
660
{
 
661
  return myTIA->myFrameCounter;
 
662
}
 
663
 
 
664
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
665
int TIADebug::scanlines()
 
666
{
 
667
  return myTIA->scanlines();
 
668
}
 
669
 
 
670
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
671
int TIADebug::clocksThisLine()
 
672
{
 
673
  return myTIA->clocksThisLine();
 
674
}
 
675
 
 
676
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
677
bool TIADebug::vsync()
 
678
{
 
679
  return (myTIA->myVSYNC & 2) == 2;
 
680
}
 
681
 
 
682
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
683
bool TIADebug::vblank()
 
684
{
 
685
  return (myTIA->myVBLANK & 2) == 2;
 
686
}
 
687
 
 
688
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
689
string TIADebug::colorSwatch(uInt8 c)
 
690
{
 
691
  string ret;
 
692
 
 
693
  ret += char((c >> 1) | 0x80);
 
694
  ret += "\177     ";
 
695
  ret += "\177\003 ";
 
696
 
 
697
  return ret;
 
698
}
 
699
 
 
700
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
701
const string audFreq(uInt8 div)
 
702
{
 
703
  string ret;
 
704
  char buf[20];
 
705
 
 
706
  double hz = 30000.0;
 
707
  if(div) hz /= div;
 
708
  sprintf(buf, "%5.1f", hz);
 
709
  ret += buf;
 
710
  ret += "Hz";
 
711
 
 
712
  return ret;
 
713
}
 
714
 
 
715
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
716
const string booleanWithLabel(string label, bool value)
 
717
{
 
718
  char buf[64];
 
719
  string ret;
 
720
 
 
721
  if(value)
 
722
  {
 
723
    char *p = buf;
 
724
    const char *q = label.c_str();
 
725
    while((*p++ = toupper(*q++)))
 
726
      ;
 
727
    ret += "+";
 
728
    ret += buf;
 
729
    return ret;
 
730
  }
 
731
  else
 
732
    return "-" + label;
 
733
}
 
734
 
 
735
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
736
string TIADebug::state()
 
737
{
 
738
  string ret;
 
739
 
 
740
  // TODO: inverse video for changed regs. Core needs to track this.
 
741
  // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR
 
742
 
 
743
  TiaState state    = (TiaState&) getState();
 
744
// FIXME - change tracking  TiaState oldstate = (TiaState&) getOldState();
 
745
 
 
746
  // build up output, then return it.
 
747
  ret += "scanline ";
 
748
 
 
749
  ret += myDebugger->valueToString(myTIA->scanlines());
 
750
  ret += " ";
 
751
 
 
752
  ret += booleanWithLabel("vsync", vsync());
 
753
  ret += " ";
 
754
 
 
755
  ret += booleanWithLabel("vblank", vblank());
 
756
  ret += "\n";
 
757
 
 
758
  ret += booleanWithLabel("inpt0", myTIA->peek(0x08) & 0x80);
 
759
  ret += " ";
 
760
  ret += booleanWithLabel("inpt1", myTIA->peek(0x09) & 0x80);
 
761
  ret += " ";
 
762
  ret += booleanWithLabel("inpt2", myTIA->peek(0x0a) & 0x80);
 
763
  ret += " ";
 
764
  ret += booleanWithLabel("inpt3", myTIA->peek(0x0b) & 0x80);
 
765
  ret += " ";
 
766
  ret += booleanWithLabel("inpt4", myTIA->peek(0x0c) & 0x80);
 
767
  ret += " ";
 
768
  ret += booleanWithLabel("inpt5", myTIA->peek(0x0d) & 0x80);
 
769
  ret += " ";
 
770
  ret += booleanWithLabel("dump_gnd_0123", myTIA->myDumpEnabled);
 
771
  ret += "\n";
 
772
 
 
773
  ret += "COLUP0: ";
 
774
  ret += myDebugger->valueToString(state.coluRegs[0]);
 
775
  ret += "/";
 
776
  ret += colorSwatch(state.coluRegs[0]);
 
777
 
 
778
  ret += "COLUP1: ";
 
779
  ret += myDebugger->valueToString(state.coluRegs[1]);
 
780
  ret += "/";
 
781
  ret += colorSwatch(state.coluRegs[1]);
 
782
 
 
783
  ret += "COLUPF: ";
 
784
  ret += myDebugger->valueToString(state.coluRegs[2]);
 
785
  ret += "/";
 
786
  ret += colorSwatch(state.coluRegs[2]);
 
787
 
 
788
  ret += "COLUBK: ";
 
789
  ret += myDebugger->valueToString(state.coluRegs[3]);
 
790
  ret += "/";
 
791
  ret += colorSwatch(state.coluRegs[3]);
 
792
 
 
793
  ret += "\n";
 
794
 
 
795
  ret += "P0: GR=";
 
796
  ret += Debugger::to_bin_8(state.gr[P0]);
 
797
  ret += "/";
 
798
  ret += myDebugger->valueToString(state.gr[P0]);
 
799
  ret += " pos=";
 
800
  ret += myDebugger->valueToString(state.pos[P0]);
 
801
  ret += " HM=";
 
802
  ret += myDebugger->valueToString(state.hm[P0]);
 
803
  ret += " ";
 
804
  ret += nusizP0String();
 
805
  ret += " ";
 
806
  ret += booleanWithLabel("reflect", refP0());
 
807
  ret += " ";
 
808
  ret += booleanWithLabel("delay", vdelP0());
 
809
  ret += "\n";
 
810
 
 
811
  ret += "P1: GR=";
 
812
  ret += Debugger::to_bin_8(state.gr[P1]);
 
813
  ret += "/";
 
814
  ret += myDebugger->valueToString(state.gr[P1]);
 
815
  ret += " pos=";
 
816
  ret += myDebugger->valueToString(state.pos[P1]);
 
817
  ret += " HM=";
 
818
  ret += myDebugger->valueToString(state.hm[P1]);
 
819
  ret += " ";
 
820
  ret += nusizP1String();
 
821
  ret += " ";
 
822
  ret += booleanWithLabel("reflect", refP1());
 
823
  ret += " ";
 
824
  ret += booleanWithLabel("delay", vdelP1());
 
825
  ret += "\n";
 
826
 
 
827
  ret += "M0: ";
 
828
  ret += (myTIA->myENAM0 ? " ENABLED" : "disabled");
 
829
  ret += " pos=";
 
830
  ret += myDebugger->valueToString(state.pos[M0]);
 
831
  ret += " HM=";
 
832
  ret += myDebugger->valueToString(state.hm[M0]);
 
833
  ret += " size=";
 
834
  ret += myDebugger->valueToString(state.size[M0]);
 
835
  ret += " ";
 
836
  ret += booleanWithLabel("reset", resMP0());
 
837
  ret += "\n";
 
838
 
 
839
  ret += "M1: ";
 
840
  ret += (myTIA->myENAM1 ? " ENABLED" : "disabled");
 
841
  ret += " pos=";
 
842
  ret += myDebugger->valueToString(state.pos[M1]);
 
843
  ret += " HM=";
 
844
  ret += myDebugger->valueToString(state.hm[M1]);
 
845
  ret += " size=";
 
846
  ret += myDebugger->valueToString(state.size[M1]);
 
847
  ret += " ";
 
848
  ret += booleanWithLabel("reset", resMP1());
 
849
  ret += "\n";
 
850
 
 
851
  ret += "BL: ";
 
852
  ret += (myTIA->myENABL ? " ENABLED" : "disabled");
 
853
  ret += " pos=";
 
854
  ret += myDebugger->valueToString(state.pos[BL]);
 
855
  ret += " HM=";
 
856
  ret += myDebugger->valueToString(state.hm[BL]);
 
857
  ret += " size=";
 
858
  ret += myDebugger->valueToString(state.size[BL]);
 
859
  ret += " ";
 
860
  ret += booleanWithLabel("delay", vdelBL());
 
861
  ret += "\n";
 
862
 
 
863
  ret += "PF0: ";
 
864
  ret += Debugger::to_bin_8(state.pf[0]);
 
865
  ret += "/";
 
866
  ret += myDebugger->valueToString(state.pf[0]);
 
867
  ret += " PF1: ";
 
868
  ret += Debugger::to_bin_8(state.pf[1]);
 
869
  ret += "/";
 
870
  ret += myDebugger->valueToString(state.pf[1]);
 
871
  ret += " PF2: ";
 
872
  ret += Debugger::to_bin_8(state.pf[2]);
 
873
  ret += "/";
 
874
  ret += myDebugger->valueToString(state.pf[2]);
 
875
  ret += "\n     ";
 
876
  ret += booleanWithLabel("reflect",  refPF());
 
877
  ret += " ";
 
878
  ret += booleanWithLabel("score",    scorePF());
 
879
  ret += " ";
 
880
  ret += booleanWithLabel("priority", priorityPF());
 
881
  ret += "\n";
 
882
 
 
883
  ret += "Collisions: ";
 
884
  ret += booleanWithLabel("m0_p1 ", collM0_P1());
 
885
  ret += booleanWithLabel("m0_p0 ", collM0_P0());
 
886
  ret += booleanWithLabel("m1_p0 ", collM1_P0());
 
887
  ret += booleanWithLabel("m1_p1 ", collM1_P1());
 
888
  ret += booleanWithLabel("p0_pf ", collP0_PF());
 
889
  ret += booleanWithLabel("p0_bl ", collP0_BL());
 
890
  ret += booleanWithLabel("p1_pf ", collP1_PF());
 
891
  ret += "\n            ";
 
892
  ret += booleanWithLabel("p1_bl ", collP1_BL());
 
893
  ret += booleanWithLabel("m0_pf ", collM0_PF());
 
894
  ret += booleanWithLabel("m0_bl ", collM0_BL());
 
895
  ret += booleanWithLabel("m1_pf ", collM1_PF());
 
896
  ret += booleanWithLabel("m1_bl ", collM1_BL());
 
897
  ret += booleanWithLabel("bl_pf ", collBL_PF());
 
898
  ret += booleanWithLabel("p0_p1 ", collP0_P1());
 
899
  ret += booleanWithLabel("m0_m1 ", collM0_M1());
 
900
  ret += "\n";
 
901
 
 
902
  ret += "AUDF0: ";
 
903
  ret += myDebugger->valueToString(myTIA->myAUDF0);
 
904
  ret += "/";
 
905
  ret += audFreq(myTIA->myAUDF0);
 
906
  ret += " ";
 
907
 
 
908
  ret += "AUDC0: ";
 
909
  ret += myDebugger->valueToString(myTIA->myAUDC0);
 
910
  ret += " ";
 
911
 
 
912
  ret += "AUDV0: ";
 
913
  ret += myDebugger->valueToString(myTIA->myAUDV0);
 
914
  ret += "\n";
 
915
 
 
916
  ret += "AUDF1: ";
 
917
  ret += myDebugger->valueToString(myTIA->myAUDF1);
 
918
  ret += "/";
 
919
  ret += audFreq(myTIA->myAUDF1);
 
920
  ret += " ";
 
921
 
 
922
  ret += "AUDC1: ";
 
923
  ret += myDebugger->valueToString(myTIA->myAUDC1);
 
924
  ret += " ";
 
925
 
 
926
  ret += "AUDV1: ";
 
927
  ret += myDebugger->valueToString(myTIA->myAUDV1);
 
928
  //ret += "\n";
 
929
 
 
930
  // note: last "ret +=" line should not contain \n, caller will add.
 
931
 
 
932
  return ret;
 
933
}