-
Notifications
You must be signed in to change notification settings - Fork 1
/
kim_1_emu.h
101 lines (81 loc) · 2.48 KB
/
kim_1_emu.h
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Copyright (C) 2016. Joo, Young Jin <neoelec@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/**
* Project Name : KIM-1 on Arduino (clone of KIM Uno)
*
* Project Description :
*
* Comments : tabstop = 8, shiftwidth = 8, noexpandtab
*/
/**
* File Name : kim_1_emu.h
*
* File Description :
*
* Author : Joo, Young Jin <neoelec@gmail.com>
* Dept : Raccoon's Cave
* Created Date : 25/Sep/2016
* Version : Baby-Raccoon
*/
#ifndef __KIM_1_EMU_H__
#define __KIM_1_EMU_H__
#include <stdint.h>
#define KIM_1_EMU_UART_KEY_CODE_GO 0x07 /* Ctrl+G */
#define KIM_1_EMU_UART_KEY_CODE_ST 0x14 /* Ctrl+T */
#define KIM_1_EMU_UART_KEY_CODE_RS 0x12 /* Ctrl+R */
#define KIM_1_EMU_UART_KEY_CODE_SST 0X0E /* Ctrl+N */
#define KIM_1_EMU_UART_KEY_CODE_AD 0x01 /* Ctrl+A */
#define KIM_1_EMU_UART_KEY_CODE_DA 0x04 /* Ctrl+D */
#define KIM_1_EMU_UART_KEY_CODE_PC 0x10 /* Ctrl+P */
#define KIM_1_EMU_UART_KEY_CODE_PLUS '+'
#define KIM_1_EMU_UART_KEY_CODE_TERM '\t'
#define KIM_1_EMU_KEY_CODE_GO 0x13
#define KIM_1_EMU_KEY_CODE_AD 0x10
#define KIM_1_EMU_KEY_CODE_DA 0x11
#define KIM_1_EMU_KEY_CODE_PC 0x14
#define KIM_1_EMU_KEY_CODE_PLUS 0x12
#define KIM_1_EMU_KEY_CODE_ST 0x18
#define KIM_1_EMU_KEY_CODE_RS 0x19
#define KIM_1_EMU_KEY_CODE_SST 0x1A
#define KIM_1_EMU_KEY_CODE_INVALID 0xFF
enum kim_1_emu_input_mode_t {
E_KIM_1_EMU_INPUT_MODE_AD = 0,
E_KIM_1_EMU_INPUT_MODE_DA,
};
class kim_1_emu {
public:
virtual void init(void);
virtual void loop(void);
virtual bool is_teletype_connected(void);
virtual bool is_key_available(void);
virtual void display_update_fnd(uint8_t *seg);
virtual uint8_t teletype_in(void);
virtual void teletype_out(uint8_t out_char);
virtual uint8_t keyboard_in(void);
protected:
virtual void display_init(void);
virtual void teletype_scan(void);
virtual void teletype_init(void);
virtual void keyboard_scan(void);
virtual void keyboard_init(void);
virtual void input_process_function_key(void);
bool sst_mode;
kim_1_emu_input_mode_t ad_da_mode;
bool teletype_available;
bool teletype_connected;
uint8_t teletype_data;
bool key_available;
uint8_t key_data;
};
void kim_1_emu_init(void);
void kim_1_emu_loop(void);
uint8_t kim_1_emu_teletype_in(void);
void kim_1_emu_teletype_out(uint8_t out_char);
uint8_t kim_1_emu_keyboard_in(void);
void kim_1_emu_display_led(uint8_t *seg);
#endif /* __KIM_1_EMU_H__ */