mirror of
https://github.com/bradgrantham/apple2a.git
synced 2025-02-02 11:33:03 +00:00
add platform files
Add files defining platform constants In particular, break out platform.c and do not optimize so that side-effects are honored.
This commit is contained in:
parent
f66faacda9
commit
976d601896
35
platform.c
Normal file
35
platform.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include "platform.h"
|
||||
|
||||
#define KBD_STATUS_OR_KEY ((volatile unsigned char *)0xC000)
|
||||
#define KBD_CLEAR_CURRENT_KEY ((volatile unsigned char *)0xC010)
|
||||
|
||||
#define KEY_READY_MASK 0x80
|
||||
#define KEY_VALUE_MASK 0x7F
|
||||
|
||||
// Returns non-zero if a key is ready to be read.
|
||||
int keyboard_test(void)
|
||||
{
|
||||
return *KBD_STATUS_OR_KEY & KEY_READY_MASK;
|
||||
}
|
||||
|
||||
// Clears current key, sets up next one for test or get
|
||||
void keyboard_clear(void)
|
||||
{
|
||||
unsigned char clear_key;
|
||||
|
||||
// On 6502, a write cycle READS AND THEN WRITES, so just read the
|
||||
// "latch next key" strobe.
|
||||
clear_key = *KBD_CLEAR_CURRENT_KEY;
|
||||
}
|
||||
|
||||
// Wait until a key is ready and then return it without high bit set
|
||||
unsigned char keyboard_get(void)
|
||||
{
|
||||
unsigned char key;
|
||||
|
||||
while(!((key = *KBD_STATUS_OR_KEY) & KEY_READY_MASK));
|
||||
|
||||
keyboard_clear();
|
||||
|
||||
return key & KEY_VALUE_MASK;
|
||||
}
|
11
platform.h
Normal file
11
platform.h
Normal file
@ -0,0 +1,11 @@
|
||||
#define TEXT_PAGE1_BASE ((volatile unsigned char *)0x400)
|
||||
#define TEXT_PAGE2_BASE ((volatile unsigned char *)0x800)
|
||||
|
||||
// Returns non-zero if a key is ready to be read.
|
||||
extern int keyboard_test(void);
|
||||
|
||||
// Clears current key, sets up next one for test or get
|
||||
extern void keyboard_next(void);
|
||||
|
||||
// Wait until a key is ready and then return it without high bit set
|
||||
extern unsigned char keyboard_get(void);
|
Loading…
x
Reference in New Issue
Block a user