summaryrefslogtreecommitdiff
path: root/sid/sidplay-libs-2.1.0/libsidplay/src/mos656x/mos656x.h
blob: 7cf9867ebef08fd0d1a1e967f5315ed24754346d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************************************************************
                          mos656x.h  -  Minimal VIC emulation
                             -------------------
    begin                : Wed May 21 2001
    copyright            : (C) 2001 by Simon White
    email                : s_a_white@email.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef _mos656x_h_
#define _mos656x_h_

#include "component.h"
#include "event.h"

typedef enum
{
    MOS6567R56A, /* OLD NTSC CHIP */
    MOS6567R8,   /* NTSC */
    MOS6569      /* PAL */
} mos656x_model_t;


class MOS656X: public component, public Event
{
private:
    static const char *credit;

protected:
    uint8_t        regs[0x40];
    uint8_t        icr, idr, ctrl1;
    uint_least16_t yrasters, xrasters, raster_irq;
    uint_least16_t raster_x, raster_y;
    uint_least16_t first_dma_line, last_dma_line, y_scroll;
    bool           bad_lines_enabled, bad_line;

    event_clock_t m_accessClk;
    EventContext &event_context;

protected:
    MOS656X (EventContext *context);
    void    event       (void);
    void    trigger     (int irq);

    // Environment Interface
    virtual void interrupt (bool state) = 0;
    virtual void busaccess (bool state) = 0;
    virtual void addrctrl  (bool state) = 0;

public:
    void    chip  (mos656x_model_t model);

    // Component Standard Calls
    void    reset (void);
    uint8_t read  (uint_least8_t addr);
    void    write (uint_least8_t addr, uint8_t data);
    const   char *credits (void) {return credit;}
};


/***************************************************************************
 * Inline functions
 **************************************************************************/

enum
{
    MOS656X_INTERRUPT_RST     = 1 << 0,
    MOS656X_INTERRUPT_REQUEST = 1 << 7
};

#endif // _mos656x_h_