apple2a/main.c

66 lines
1.1 KiB
C
Raw Normal View History

2018-07-31 19:02:26 +00:00
#include "platform.h"
2018-07-28 05:30:44 +00:00
char *title = "Apple IIa";
unsigned char title_length = 9;
2018-07-31 07:05:22 +00:00
/**
* Delay for a count of "t". 8000 is about one second.
*/
static void delay(int t) {
while (t >= 0) {
t--;
}
}
/**
* Clear the screen with non-reversed spaces.
*/
static void home() {
2018-07-31 19:02:26 +00:00
volatile unsigned char *p = TEXT_PAGE1_BASE;
2018-07-31 07:05:22 +00:00
unsigned char ch = ' ' | 0x80;
int i;
// TODO: Could write these as words, not chars.
for (i = (40 + 40 + 48)*8; i >= 0; i--) {
*p++ = ch;
}
}
2018-07-28 05:30:44 +00:00
int main(void)
{
2018-07-28 19:12:40 +00:00
int offset = (40 - title_length) / 2;
2018-07-28 05:30:44 +00:00
2018-07-31 19:02:26 +00:00
volatile unsigned char *loc = TEXT_PAGE1_BASE + offset;
2018-07-28 05:30:44 +00:00
int i;
2018-07-31 07:05:22 +00:00
home();
2018-07-28 05:30:44 +00:00
2018-07-31 07:05:22 +00:00
// Title.
2018-07-28 19:12:40 +00:00
for(i = 0; i < title_length; i++) {
2018-07-28 05:30:44 +00:00
loc[i] = title[i] | 0x80;
2018-07-28 19:12:40 +00:00
}
2018-07-28 05:30:44 +00:00
2018-07-31 07:05:22 +00:00
// Prompt.
2018-07-31 19:02:26 +00:00
loc = TEXT_PAGE1_BASE + (40 + 40 + 48)*2;
2018-07-31 07:05:22 +00:00
*loc++ = ']' | 0x80;
// Cursor.
2018-07-31 19:02:26 +00:00
i = 1;
2018-07-31 07:05:22 +00:00
while(1) {
*loc = 127 | 0x80;
delay(2500);
*loc = ' ' | 0x80;
delay(2500);
2018-07-31 19:02:26 +00:00
while(keyboard_test()) {
unsigned char key;
key = keyboard_get();
loc[i++] = key | 0x80;
}
2018-07-31 07:05:22 +00:00
}
return 0;
2018-07-28 05:30:44 +00:00
}