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
|
#ifndef VIA_6522_H
#define VIA_6522_H
#include "device.h"
#include "bus.h"
#include <stdint.h>
#include <stdbool.h>
#ifdef WITH_GUI
#include <SDL.h>
#endif
// the VIA connects to sub-devices itself via the bus. It also
// has things like timers and internal registers
// the VIA is initialized with a base address, the addresses for
// the registers are relative to this base.
enum {
PORTB = 0x00,
PORTA = 0x01,
DDRB = 0x02,
DDRA = 0x03,
T1LCL = 0x04,
T1LCH = 0x05,
ACR = 0x0b,
PCR = 0x0c,
IFR = 0x0d,
IER = 0x0e
};
typedef struct via_6522_t
{
device_t base;
uint16_t addr;
uint8_t ddra;
uint8_t ddrb;
uint8_t pcr;
uint8_t ier;
uint8_t ifr;
bool debug;
bus_t busa;
bus_t busb;
} via_6522_t;
void via_6522_init( via_6522_t *via, uint16_t addr, bool initialize );
void via_6522_reset( via_6522_t *via );
void via_6522_register( via_6522_t *via, int bus, device_t *device );
uint8_t via_6522_read( void *obj, uint16_t addr );
void via_6522_write( void *obj, uint16_t addr, uint8_t data );
#ifdef WITH_GUI
void via_6522_draw( void *obj, SDL_Renderer *renderer );
#endif
void via_6522_deinit( void *obj );
#endif
|