aboutsummaryrefslogtreecommitdiff
path: root/src/fujimenu.c
blob: 29c9d7d07d62463e3410030482ef35ec27a8d904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include "fujichat.h"
#include "common.h"

/* TODO:
	- rewrite in asm
*/

void run_prog(char *file) {
	int c;
	printf("\nLoading %s...\n", file);
	c = atari_exec(file);
	printf("Error %d!\n\xfd", c);
}

void main(void) {
	int c, have_conf;

	disable_break();

	puts("\x7d" BANNER " Main Menu\n");

	have_conf = get_config();
	if(!have_conf)
		set_default_config();

	while(1) {
		printf("\n  %cbout\n", 'A' | 0x80);

		printf("%s%cetup\n",
				(have_conf ? "  " : "* "),
				'S' | 0x80);

		printf("%s%chat\n",
				(have_conf ? "* " : "  "),
				'C' | 0x80);

		printf("  %cOS\n", 'D' | 0x80);

		putchar('\n');
		putchar('>');

		cursor(1);
		c = cgetc();
		if(c == A_EOL || c == ' ')
			c = (have_conf ? 'C' : 'S');

		putchar(c | 0x80);

		switch(c) {
			case 'A':
			case 'a':
				run_prog("D:ABOUT.COM");
				break;

			case 'S':
			case 's':
				run_prog(SETUP_FILENAME);
				break;

			case 'C':
			case 'c':
				run_prog(IRC_FILENAME);
				// run_prog(IRC_LOADER_FILENAME);
				break;

				/*
				if(config_is_valid()) {
					// atari_exec(IRC_LOADER_FILENAME);
					atari_exec(IRC_FILENAME);
					return 0;
				} else {
					putchar(A_BS);
					puts("\nYou must run Setup first");
					break;
				}
				 */

			case 'D':
			case 'd':
				return;

			default:
				putchar(A_BS);
				break;
		}
	}
}