summaryrefslogtreecommitdiff
path: root/emu/7seg.h
blob: 0256f831ab96b19906258f8d3b285af189a18bc1 (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
#ifndef SEG7_H
#define SEG7_H

#include "device.h"

#include <stdint.h>
#include <stdbool.h>

// VIA connected on PORTA to 3 wires leading to the 3 coupled 74HC595
// shift register which enable the ROM address lines to read the LED
// segment data (cells 0-15 contain the encoded 7 segments of 16 hexdigits)
//
// PORTA connected as follows:
// xxxxx111
//        +--- SER
//       +---- RCLK
//      +----- SRCLK
enum {
	PORTA = 0x01,
	DDRA  = 0x03,
	
	SER   = 0x01,
	RCLK  = 0x02,
	SRCLK = 0x04
};

typedef struct seg7_t
{
	device_t base;
	
	uint16_t addr;
	
	uint8_t ddr;
	uint16_t shift;
	uint16_t latch;

	bool debug;
} seg7_t;

void seg7_init( seg7_t *seg, uint16_t addr, bool initialize );

uint8_t seg7_read( void *obj, uint16_t addr );
void seg7_write( void *obj, uint16_t addr, uint8_t data );
#ifdef WITH_GUI
void seg7_draw( void *obj, SDL_Renderer *renderer );
#endif
void seg7_deinit( void *obj );

#endif