libsidplayfp  0.3.5
mos656x.h
1 /***************************************************************************
2  mos656x.h - Minimal VIC emulation
3  -------------------
4  begin : Wed May 21 2001
5  copyright : (C) 2001 by Simon White
6  email : s_a_white@email.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef _mos656x_h_
19 #define _mos656x_h_
20 
21 #include "sidplayfp/component.h"
22 #include "sidplayfp/event.h"
23 
24 typedef enum
25 {
26  MOS6567R56A, /* OLD NTSC CHIP */
27  MOS6567R8, /* NTSC */
28  MOS6569 /* PAL */
29 } mos656x_model_t;
30 
31 
32 class MOS656X: public component, private Event
33 {
34 private:
35  static const char *credit;
36 
37 protected:
38  event_clock_t m_rasterClk;
39  EventContext &event_context;
40 
41  uint_least16_t yrasters, xrasters, raster_irq;
42  uint_least16_t raster_x, raster_y;
43  uint_least16_t first_dma_line, last_dma_line, y_scroll;
44  bool bad_lines_enabled, bad_line;
45  bool vblanking;
46  bool lp_triggered;
47  uint8_t icr, idr, ctrl1;
48  uint8_t lpx, lpy;
49  uint8_t &sprite_enable, &sprite_y_expansion;
50  uint8_t sprite_dma, sprite_expand_y;
51  uint8_t sprite_mc_base[8];
52 
53  uint8_t regs[0x40];
54 
55 private:
56  event_clock_t clock (void);
57 
58 protected:
59  MOS656X (EventContext *context);
60  void event (void);
61  void trigger (int irq);
62 
63  EventCallback<MOS656X> badLineStateChangeEvent;
64 
65  void badLineStateChange() { addrctrl(false); }
66 
67  // Environment Interface
68  virtual void interrupt (bool state) = 0;
69  virtual void addrctrl (bool state) = 0;
70 
71 public:
72  void chip (mos656x_model_t model);
73  void lightpen ();
74 
75  // Component Standard Calls
76  void reset (void);
77  uint8_t read (uint_least8_t addr);
78  void write (uint_least8_t addr, uint8_t data);
79  const char *credits (void) {return credit;}
80 };
81 
82 
83 /***************************************************************************
84  * Inline functions
85  **************************************************************************/
86 
87 enum
88 {
89  MOS656X_INTERRUPT_RST = 1 << 0,
90  MOS656X_INTERRUPT_LP = 1 << 3,
91  MOS656X_INTERRUPT_REQUEST = 1 << 7
92 };
93 
94 #endif // _mos656x_h_