libsidplayfp  0.3.5
sid6526.h
1 /***************************************************************************
2  sid6526.h - fake CIA timer for sidplay1
3  environment modes
4  -------------------
5  begin : Wed Jun 7 2000
6  copyright : (C) 2000 by Simon White
7  email : s_a_white@email.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 /***************************************************************************
19  * $Log: sid6526.h,v $
20  * Revision 1.6 2004/06/26 11:06:52 s_a_white
21  * Changes to support new calling convention for event scheduler.
22  *
23  * Revision 1.5 2003/10/28 00:22:53 s_a_white
24  * getTime now returns a time with respect to the clocks desired phase.
25  *
26  * Revision 1.4 2003/02/20 18:55:14 s_a_white
27  * sid2crc support.
28  *
29  * Revision 1.3 2002/07/20 08:34:52 s_a_white
30  * Remove unnecessary and pointless conts.
31  *
32  * Revision 1.2 2002/03/11 18:00:29 s_a_white
33  * Better mirror sidplay1s handling of random numbers.
34  *
35  * Revision 1.1 2001/09/01 11:11:19 s_a_white
36  * This is the old fake6526 code required for sidplay1 environment modes.
37  *
38  ***************************************************************************/
39 
40 #ifndef _sid6526_h_
41 #define _sid6526_h_
42 
43 #include "sidplayfp/component.h"
44 #include "sidplayfp/event.h"
45 #include "sidplayfp/c64env.h"
46 
47 class SID6526: public component, private Event
48 {
49 private:
50  static const char * const credit;
51 
52  c64env &m_env;
53  EventContext &m_eventContext;
54  event_clock_t m_accessClk;
55  event_phase_t m_phase;
56 
57  uint_least16_t ta_latch;
58  uint_least16_t ta; // Current count (reduces to zero)
59  uint_least32_t rnd;
60  uint_least16_t m_count;
61  bool locked; // Prevent code changing CIA.
62  uint8_t cra; // Timer A Control Register
63  uint8_t regs[0x10];
64 
65 public:
66  SID6526 (c64env *env);
67 
68  //Common:
69  void reset (void) { reset (false); }
70  void reset (bool seed);
71  uint8_t read (uint_least8_t addr);
72  void write (uint_least8_t addr, uint8_t data);
73  const char *credits (void) {return credit;}
74  const char *error (void) {return "";}
75 
76  // Specific:
77  void event (void);
78  void clock (uint_least16_t count) { m_count = count; }
79  void lock () { locked = true; }
80 };
81 
82 #endif // _sid6526_h_