mirror of
https://github.com/bradgrantham/apple2a.git
synced 2024-11-30 06:51:03 +00:00
Add hard-coded print statement.
This commit is contained in:
parent
655b397d86
commit
3260180fb7
25
main.c
25
main.c
@ -109,6 +109,10 @@ static void print(unsigned char *s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_statement() {
|
||||||
|
print("Hello world!\n");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a starts with string b, returns the position in a after b. Else returns null.
|
* If a starts with string b, returns the position in a after b. Else returns null.
|
||||||
*/
|
*/
|
||||||
@ -175,7 +179,7 @@ static void process_input_buffer() {
|
|||||||
char done;
|
char done;
|
||||||
|
|
||||||
input_buffer[input_buffer_length] = '\0';
|
input_buffer[input_buffer_length] = '\0';
|
||||||
s = skip_whitespace(input_buffer);
|
s = input_buffer;
|
||||||
|
|
||||||
// Compile the line of BASIC.
|
// Compile the line of BASIC.
|
||||||
binary_length = 0;
|
binary_length = 0;
|
||||||
@ -186,25 +190,32 @@ static void process_input_buffer() {
|
|||||||
// Default to being done after one command.
|
// Default to being done after one command.
|
||||||
done = 1;
|
done = 1;
|
||||||
|
|
||||||
if (*s == '\0') {
|
s = skip_whitespace(s);
|
||||||
// Nothing.
|
if (*s == '\0' || *s == ':') {
|
||||||
|
// Empty statement.
|
||||||
} else if ((after = skip_over(s, "HOME")) != 0) {
|
} else if ((after = skip_over(s, "HOME")) != 0) {
|
||||||
|
s = after;
|
||||||
add_call(home);
|
add_call(home);
|
||||||
|
} else if ((after = skip_over(s, "PRINT")) != 0) {
|
||||||
|
s = after;
|
||||||
|
|
||||||
|
// TODO: Parse expression.
|
||||||
|
add_call(print_statement);
|
||||||
} else {
|
} else {
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we're at the end of our instruction.
|
// Now we're at the end of our statement.
|
||||||
if (!error) {
|
if (!error) {
|
||||||
s = skip_whitespace(after);
|
s = skip_whitespace(s);
|
||||||
if (*s == ':') {
|
if (*s == ':') {
|
||||||
// Skip colon.
|
// Skip colon.
|
||||||
s += 1;
|
s += 1;
|
||||||
|
|
||||||
// Next instruction.
|
// Next statement.
|
||||||
done = 0;
|
done = 0;
|
||||||
} else if (*s != '\0') {
|
} else if (*s != '\0') {
|
||||||
// Junk at the end of the instruction.
|
// Junk at the end of the statement.
|
||||||
error = 1;
|
error = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user