mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2025-12-25 23:12:17 +11:00
Add code to read KB
This commit is contained in:
parent
d8f5c22350
commit
8ea172e603
6 changed files with 50 additions and 14 deletions
20
src/input.c
Normal file
20
src/input.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "input.h"
|
||||
|
||||
#include "utility.h"
|
||||
#include "mem_registers.h"
|
||||
|
||||
key read_kb(void) {
|
||||
POKE(IO_DATAOUT, 0x40);
|
||||
if (PEEK(IO_DATAIN) & DATAIN_KB_MASK) return K_UP;
|
||||
|
||||
POKE(IO_DATAOUT, 0x20);
|
||||
if (PEEK(IO_DATAIN) & DATAIN_KB_MASK) return K_DOWN;
|
||||
|
||||
POKE(IO_DATAOUT, 0x10);
|
||||
if (PEEK(IO_DATAIN) & DATAIN_KB_MASK) return K_RIGHT;
|
||||
|
||||
POKE(IO_DATAOUT, 0x08);
|
||||
if (PEEK(IO_DATAIN) & DATAIN_KB_MASK) return K_LEFT;
|
||||
|
||||
return K_NONE;
|
||||
}
|
||||
16
src/input.h
Normal file
16
src/input.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef _INPUT_HEADER_
|
||||
#define _INPUT_HEADER_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
K_NONE = 0,
|
||||
K_UP,
|
||||
K_DOWN,
|
||||
K_LEFT,
|
||||
K_RIGHT,
|
||||
} key;
|
||||
|
||||
key read_kb(void);
|
||||
|
||||
#endif /* _INPUT_HEADER_ */
|
||||
11
src/main.c
11
src/main.c
|
|
@ -6,9 +6,9 @@
|
|||
#include "utility.h"
|
||||
#include "mem_registers.h"
|
||||
#include "mem_map.h"
|
||||
#include "input.h"
|
||||
|
||||
#include "monitor_subroutines.h"
|
||||
|
||||
void __low_level_init(void);
|
||||
|
||||
// Low level initialization
|
||||
void __low_level_init(void) {
|
||||
|
|
@ -24,10 +24,11 @@ void __low_level_init(void) {
|
|||
}
|
||||
|
||||
__task int main(void) {
|
||||
|
||||
|
||||
key k;
|
||||
|
||||
while(1){
|
||||
|
||||
lfsr_update();
|
||||
k = read_kb();
|
||||
};
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#define ZP_WNDBTM 0x0023 // 24, bottom line of the scroll window
|
||||
|
||||
#define ZP_CH 0x0024 // Displacement from window left for the cursor
|
||||
#define ZP_CV 0x0025 // Displacement from top of screen (now window!) for the cursor
|
||||
#define ZP_CV 0x0025 // Displacement from top of screen (not window!) for the cursor
|
||||
|
||||
#define ZP_INVFLAG 0x0032 // Either 0x00 or 0x7F, set text color inversion
|
||||
#define ZP_PROMPT 0x0033 // Prompt character
|
||||
|
|
@ -21,11 +21,10 @@
|
|||
#define P3_PWRDUP_REF 0x03F3
|
||||
#define P3_PWRDUP 0x03F4 // Already-powered-up indicator. If it is set to the content of 0x03F3 XOR'd with 0xA5, the soft reset vector is considered valid
|
||||
|
||||
typedef struct {
|
||||
uint8_t kb: 5; // 0:5
|
||||
uint8_t prnt: 6;
|
||||
uint8_t tapein: 7;
|
||||
} datain;
|
||||
|
||||
#define DATAIN_KB_MASK 0x3F
|
||||
#define DATAIN_PRNT_MASK 0x40
|
||||
#define DATAIN_TAPEIN_MASK 0x80
|
||||
|
||||
#define IO_DATAOUT 0xC000 // (W) To keyboard and printer port
|
||||
#define IO_DATAIN 0xC010 // (R) Data input from keyboard (0:5), printer (6) and tape (7)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue