Skip to content

Commit

Permalink
Software: Allow symbol definitions and comments in config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Henning Bekel committed Nov 30, 2016
1 parent 749408c commit fe58a42
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 31 deletions.
28 changes: 23 additions & 5 deletions README.md
Expand Up @@ -2,12 +2,30 @@

*This project is currently in early beta status.*

The overlay64 module allows superimposing predefined texts onto an existing composite signal or onto the luminance portion of an s-video signal depending on the states of up to sixteen digital input lines. An LM1881 video sync separator IC is used to detect the vertical and horizontal sync pulses of the video signal. An Atmega1284 uses these signals to synchronize with the video signal and to superimpose text on the video display by bit-banging the corresponding characters over SPI.
The overlay64 module allows superimposing predefined texts onto an
existing composite signal or onto the luminance portion of an s-video
signal depending on the states of up to sixteen digital input
lines. An LM1881 video sync separator IC is used to detect the
vertical and horizontal sync pulses of the video signal. An Atmega1284
uses these signals to synchronize with the video signal and to
superimpose text on the video display by bit-banging the corresponding
characters over SPI.

The user writes a simple configuration file that determines which texts are to be displayed for which input line states. The configuration file is converted to a binary format using the supplied commandline tool before flashing it to the Atmegas's eeprom memory via the USB interface.
The user writes a simple configuration file that determines which
texts are to be displayed for which input line states. The
configuration file is converted to a binary format using the supplied
commandline tool before flashing it to the Atmegas's eeprom memory via
the USB interface.

Possible uses include displaying the state of control lines for additional hardware installed in a homecomputer such as the Commodore 64, for example to display the currently selected kernal based on the state of the control lines for a multi-kernal adapter.
Possible uses include displaying the state of control lines for
additional hardware installed in a homecomputer such as the Commodore
64, for example to display the currently selected kernal based on the
state of the control lines for a multi-kernal adapter.

An early working prototype can be seen in [this video](https://www.youtube.com/watch?v=0exp2yM0WHM), where it displays the runtime configuration of the MixSID Stereo SID board.
An early working prototype can be seen in [this
video](https://www.youtube.com/watch?v=0exp2yM0WHM), where it displays
the runtime configuration of the MixSID Stereo SID board.

This repository includes the complete sourcecode of the client software, the firmware and all design files in KiCAD format. The project is licensed under the GPLv3.
This repository includes the complete sourcecode of the client
software, the firmware and all design files in KiCAD format. The
project is licensed under the GPLv3.
56 changes: 36 additions & 20 deletions overlay64.conf
@@ -1,3 +1,18 @@
PRIORITY = 7
REVERSED = 0
NORMAL = 1

MODE = 0
STEREO = 0
PARALLEL = 1

MIXER = 1 2
KERNAL = 3 4
CHARSET = 5 6

IO1 = 8
IO2 = 9

timeout 100

control 16 manual 0 1
Expand All @@ -8,17 +23,18 @@ screen notify
write 28 0 "LCHN MODE PRIORITY"
write 28 35 "$D400 5IO RCHN"

sample 7
when 0
sample PRIORITY
when REVERSED
write 28 27 "8580"
write 29 27 "6581"
write 29 17 "REVERSED"
when 1

when NORMAL
write 28 27 "6581"
write 29 27 "8580"
write 29 17 " NORMAL "

sample 0 8 9
sample MODE IO1 IO2
when 000 write 29 35 "$D420 +++"
when 001 write 29 35 "$D400 ---"
when 010 write 29 35 "$D420 +-+"
Expand All @@ -28,17 +44,17 @@ sample 0 8 9
when 110 write 29 35 "$D420 +--"
when 111 write 29 35 "$D400 ---"

sample 0
when 0
sample MODE
when STEREO
write 29 7 " STEREO "
write 28 32 "RW"
write 29 32 "RW"
when 1
when PARALLEL
write 29 7 "PARALLEL"
write 28 32 "RW"
write 29 32 "WO"

sample 1 2
sample MIXER
when 00
write 29 0 "8580"
write 29 48 "8580"
Expand All @@ -54,42 +70,42 @@ sample 1 2

screen

sample 3 4
sample KERNAL
when 00 write 0 15 "KERNAL : XLINK SERVER V1"
when 01 write 0 15 "KERNAL : JIFFYDOS V6.01 "
when 10 write 0 15 "KERNAL : ORIGINAL REV-03"
when 11 write 0 15 "KERNAL : UNDEFINED "

sample 5 6
sample CHARSET
when 00 write 1 15 "CHARSET: ORIGINAL C64 "
when 01 write 1 15 "CHARSET: RETROFAN SMALL"
when 10 write 1 15 "CHARSET: FUTURISTIC "
when 01 write 1 15 "CHARSET: FUTURISTIC "
when 10 write 1 15 "CHARSET: RETROFAN SMALL"
when 11 write 1 15 "CHARSET: ORIGINAL PET "

screen notify

sample 3 4
sample KERNAL
when 00 write 0 9 "SWITCHED KERNAL TO XLINK SERVER V1"
when 01 write 0 9 "SWITCHED KERNAL TO JIFFYDOS V6.01 "
when 10 write 0 9 "SWITCHED KERNAL TO ORIGINAL REV-03"
when 11 write 0 9 "UNDEFINED "

screen notify

sample 5 6
sample CHARSET
when 00 write 0 9 " SWITCHED CHARSET TO ORIGINAL C64 "
when 01 write 0 9 "SWITCHED CHARSET TO RETROFAN SMALL"
when 10 write 0 9 " SWITCHED CHARSET TO FUTURISTIC "
when 01 write 0 9 " SWITCHED CHARSET TO FUTURISTIC "
when 10 write 0 9 "SWITCHED CHARSET TO RETROFAN SMALL"
when 11 write 0 9 " SWITCHED CHARSET TO ORIGINAL PET "

screen notify

sample 0
sample MODE
when 0 write 0 16 " STEREO ADDRESSING "
when 1 write 0 16 "PARALLEL ADDRESSING"

screen notify

sample 7
when 0 write 0 17 " NORMAL PRIORITY "
when 1 write 0 17 "REVERSED PRIORITY"
sample PRIORITY
when REVERSED write 0 17 "REVERSED PRIORITY"
when NORMAL write 0 17 " NORMAL PRIORITY "
66 changes: 60 additions & 6 deletions parser.c
Expand Up @@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

volatile Config* config;
uint16_t written = 0;
const char *ws = " \t";

static int fputcc(int ch, FILE* fp) {
fputc(ch, fp);
Expand Down Expand Up @@ -93,18 +94,71 @@ static bool parseMode(char* word, uint8_t *mode) {

bool Config_parse(volatile Config* self, FILE* in) {
bool result = true;
char buf[0x10000];
char* buffer = (char*) calloc(4096, sizeof(char));
char *line;
char *word;
char *comment;
char *name;
char *value;
char *equals;
int keyword;
int trailing = 0;
uint8_t timeout;
Screen* screen = NULL;

fread(buf, sizeof(char), sizeof(buf), in);

StringList* words = StringList_new();
StringList_append_quoted(words, buf, "\n\t ");
int i = 0;

fseek(in, 0, SEEK_SET);

int pos = 0;
while(fgets(buffer, 4095, in) != NULL) {
line = buffer;
pos++;

// skip leading whitespace
line += strspn(line, ws);

// skip empty lines and comments
if(line[0] == '\n' || line[0] == '\r' || line[0] == '#') continue;

// remove comment at the end of the line
if((comment = strstr(line, "#")) != NULL) {
comment[0] = '\0';
}

// discard newlines
if(line[strlen(line)-1] == '\n') {
line[strlen(line)-1] = '\0';
}

if(line[strlen(line)-1] == '\r') {
line[strlen(line)-1] = '\0';
}

// check if this command is a definition
if((equals = strstr(line, "=")) != NULL) {
name = line;
equals[0] = '\0';

if((trailing = strcspn(name, ws)) > 0) {
name[trailing] = '\0';
}

value = equals+1;
value = trim(value);

if(StringList_has_definition(name)) {
fprintf(stderr, "error: line %d: '%s': symbol already defined\n", pos, name);
return false;
}

StringList_add_definition(name, value);
}
else {
StringList_append_quoted(words, line, "\n\t ");
}
}

int i = 0;
while(i<words->size) {
word = StringList_get(words, i);

Expand Down
18 changes: 18 additions & 0 deletions strings.c
Expand Up @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>

Expand Down Expand Up @@ -210,3 +211,20 @@ void StringList_free(StringList *self) {
free(self->strings);
free(self);
}

char* trim(char* s)
{
int len = strlen(s);

while (len && isspace(s[0]))
{
s++; len--;
}

while (len && isspace(s[len - 1]))
{
s[len - 1] = 0; len--;
}

return s;
}
2 changes: 2 additions & 0 deletions strings.h
Expand Up @@ -45,4 +45,6 @@ char* StringList_last(StringList *self);
void StringList_remove_last(StringList *self);
void StringList_free(StringList *self);

char* trim(char* s);

#endif // STRINGS_H

0 comments on commit fe58a42

Please sign in to comment.