Skip to content

Commit 2bab0c7

Browse files
committed
change prefs to use config device enumerations.
1 parent d026198 commit 2bab0c7

File tree

24 files changed

+210
-185
lines changed

24 files changed

+210
-185
lines changed

src/apple2/config.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,11 @@ extern ConfigInfo config;
2424
*/
2525
void config_set_defaults(void)
2626
{
27-
config.io_mode = IO_MODE_SERIAL;
2827
config.baud = SER_BAUD_2400;
29-
config.use_dhcp = true;
30-
config.ip_address=0;
31-
config.netmask=0;
32-
config.gateway=0;
33-
config.dns=0;
3428
config.xon_threshold=XON_THRESHOLD;
3529
config.xoff_threshold=XOFF_THRESHOLD;
3630
config.fill=false;
37-
strcpy(config.driver_ser,CONFIG_DEFAULT_SERIAL_DRIVER);
38-
strcpy(config.driver_mou,CONFIG_DEFAULT_MOUSE_DRIVER);
31+
config.driver_ser=CONFIG_DEFAULT_SERIAL_DRIVER;
32+
config.driver_mou=CONFIG_DEFAULT_MOUSE_DRIVER;
3933
config_save();
4034
}
41-
42-
void config_init_hook(void)
43-
{
44-
}

src/apple2/io.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void io_init_funcptrs(void)
3636
if (io_load_successful==false)
3737
return;
3838

39-
if (strcmp(config.driver_ser,CONFIG_SERIAL_DRIVER_SSC)==0)
39+
if (config.driver_ser==CONFIG_SERIAL_DRIVER_SSC)
4040
{
4141
io_serial_buffer_size=io_serial_buffer_size_ssc;
4242
io_recv_serial_flow_off=io_recv_serial_flow_off_ssc;
@@ -84,3 +84,15 @@ void io_recv_serial_flow_on_ssc(void)
8484
if (io_load_successful==false)
8585
return;
8686
}
87+
88+
/**
89+
* io_ser_driver_name() - return serial driver name given constant
90+
*/
91+
const char* io_ser_driver_name(unsigned char driver)
92+
{
93+
switch(driver)
94+
{
95+
case CONFIG_SERIAL_DRIVER_SSC:
96+
return "a2.ssc.ser";
97+
}
98+
}

src/apple2/prefs.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ void prefs_touch(void)
4545
{
4646
case 'm':
4747
prefs_select("mouse");
48-
strcpy(config.driver_mou,CONFIG_MOUSE_DRIVER_STDMOU);
49-
touch_prefs_updated=true;
50-
prefs_need_updating=true;
48+
config.driver_mou=CONFIG_MOUSE_DRIVER_STDMOU;
5149
break;
5250
case 'b':
5351
prefs_select("back");
5452
break;
5553
}
54+
55+
prefs_check_for_change();
5656
}
5757

5858
/**
@@ -69,13 +69,12 @@ void prefs_driver(void)
6969
{
7070
case 's':
7171
prefs_select("ssc");
72-
strcpy(config.driver_ser,CONFIG_SERIAL_DRIVER_SSC);
73-
io_prefs_updated=true;
74-
prefs_need_updating=true;
72+
config.driver_ser=CONFIG_SERIAL_DRIVER_SSC;
7573
break;
7674
case 'b':
7775
prefs_select("back");
7876
break;
7977
}
78+
prefs_check_for_change();
8079
}
8180

src/apple2/touch.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "../protocol.h"
1111
#include "../convert_coordinates.h"
1212
#include <stdint.h>
13+
#include "../config.h"
1314

1415
/**
1516
* touch_translate - Translate coordinates from native system to PLATO
@@ -19,3 +20,15 @@ void touch_translate(padPt* Coord)
1920
Coord->x = touch_scale_256(Coord->x);
2021
Coord->y = touch_scale_192(Coord->y);
2122
}
23+
24+
/**
25+
* touch_driver_name() - Get the driver name for the given driver #
26+
*/
27+
const char* touch_driver_name(unsigned char driver)
28+
{
29+
switch(driver)
30+
{
31+
case CONFIG_MOUSE_DRIVER_STDMOU:
32+
return "a2.stdmou.mou";
33+
}
34+
}

src/atari/config.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,21 @@
1818
#define CONFIG_DEFAULT_MOUSE_DRIVER CONFIG_MOUSE_DRIVER_ATRJOY
1919

2020
extern ConfigInfo config;
21-
extern char configFile[13];
22-
static unsigned char dunit;
2321

2422
/**
2523
* config_set_defaults()
2624
* Set default values for config file
2725
*/
2826
void config_set_defaults(void)
2927
{
30-
config.io_mode = IO_MODE_SERIAL;
3128
config.baud = SER_BAUD_1200;
32-
config.use_dhcp = false;
33-
config.ip_address=0;
34-
config.netmask=0;
35-
config.gateway=0;
36-
config.dns=0;
3729
config.xon_threshold=XON_THRESHOLD;
3830
config.xoff_threshold=XOFF_THRESHOLD;
3931
config.fill=false;
40-
strcpy(config.driver_ser,CONFIG_DEFAULT_SERIAL_DRIVER);
41-
strcpy(config.driver_mou,"NONE");
32+
config.driver_ser=CONFIG_DEFAULT_SERIAL_DRIVER;
33+
config.driver_mou=CONFIG_DEFAULT_MOUSE_DRIVER;
4234
config.color_foreground=TGI_COLOR_WHITE;
4335
config.color_background=TGI_COLOR_BLACK;
4436
config.color_border=TGI_COLOR_BLACK;
4537
config_save();
4638
}
47-
48-
void config_atari_fix_driver_filenames(void)
49-
{
50-
// Put EOL at end of driver filename.
51-
configFile[6]=0x9B;
52-
}
53-
54-
void config_init_hook(void)
55-
{
56-
config_atari_fix_driver_filenames();
57-
}

src/atari/io.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void io_init_funcptrs(void)
3434
if (io_load_successful==false)
3535
return;
3636

37-
if (strcmp(config.driver_ser,CONFIG_SERIAL_DRIVER_ATRRDEV)==0)
37+
if (config.driver_ser==CONFIG_SERIAL_DRIVER_ATRRDEV)
3838
{
3939
io_serial_buffer_size=io_serial_buffer_size_atari;
4040
io_recv_serial_flow_off=io_recv_serial_flow_off_atari;
@@ -82,3 +82,15 @@ void io_recv_serial_flow_on_atari(void)
8282
xoff_enabled=false;
8383
ser_put(0x11);
8484
}
85+
86+
/**
87+
* io_ser_driver_name() - return serial driver name given constant
88+
*/
89+
const char* io_ser_driver_name(unsigned char driver)
90+
{
91+
switch(driver)
92+
{
93+
case CONFIG_SERIAL_DRIVER_ATRRDEV:
94+
return "atrrdev.ser";
95+
}
96+
}

src/atari/prefs.c

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,43 +45,32 @@ void prefs_touch(void)
4545
{
4646
case 'a':
4747
prefs_select("amiga");
48-
strcpy(config.driver_mou,CONFIG_MOUSE_DRIVER_ATRAMI);
49-
touch_prefs_updated=true;
50-
prefs_need_updating=true;
48+
config.driver_mou=CONFIG_MOUSE_DRIVER_ATRAMI;
5149
break;
5250
case 'j':
5351
prefs_select("joy");
54-
strcpy(config.driver_mou,CONFIG_MOUSE_DRIVER_ATRJOY);
55-
touch_prefs_updated=true;
56-
prefs_need_updating=true;
52+
config.driver_mou=CONFIG_MOUSE_DRIVER_ATRJOY;
5753
break;
5854
case 'k':
5955
prefs_select("koala");
60-
strcpy(config.driver_mou,CONFIG_MOUSE_DRIVER_ATRTT);
61-
touch_prefs_updated=true;
62-
prefs_need_updating=true;
56+
config.driver_mou=CONFIG_MOUSE_DRIVER_ATRTT;
6357
break;
6458
case 's':
6559
prefs_select("st");
66-
strcpy(config.driver_mou,CONFIG_MOUSE_DRIVER_ATRST);
67-
touch_prefs_updated=true;
68-
prefs_need_updating=true;
60+
config.driver_mou=CONFIG_MOUSE_DRIVER_ATRST;
6961
break;
7062
case 't':
7163
prefs_select("trkball");
72-
strcpy(config.driver_mou,CONFIG_MOUSE_DRIVER_ATRTRK);
73-
touch_prefs_updated=true;
74-
prefs_need_updating=true;
64+
config.driver_mou=CONFIG_MOUSE_DRIVER_ATRTRK;
7565
break;
7666
case 'n':
7767
prefs_select("none");
78-
strcpy(config.driver_mou,"NONE");
79-
touch_prefs_updated=true;
80-
prefs_need_updating=true;
68+
config.driver_mou=CONFIG_MOUSE_DRIVER_NONE;
8169
case 'b':
8270
prefs_select("back");
8371
break;
8472
}
73+
prefs_check_for_change();
8574
}
8675

8776
/**
@@ -98,13 +87,11 @@ void prefs_driver(void)
9887
{
9988
case 'r':
10089
prefs_select("rdevice");
101-
strcpy(config.driver_ser,CONFIG_SERIAL_DRIVER_ATRRDEV);
102-
io_prefs_updated=true;
103-
prefs_need_updating=true;
90+
config.driver_ser=CONFIG_SERIAL_DRIVER_ATRRDEV;
10491
break;
10592
case 'b':
10693
prefs_select("back");
10794
break;
10895
}
96+
prefs_check_for_change();
10997
}
110-

src/atari/touch.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "../convert_coordinates.h"
1111
#include "../protocol.h"
12+
#include "../config.h"
1213

1314
/**
1415
* touch_translate - Translate coordinates from native system to PLATO
@@ -19,4 +20,22 @@ void touch_translate(padPt* Coord)
1920
Coord->y = touch_scale_192(Coord->y);
2021
}
2122

22-
23+
/**
24+
* touch_driver_name() - Get the driver name for the given driver #
25+
*/
26+
const char* touch_driver_name(unsigned char driver)
27+
{
28+
switch(driver)
29+
{
30+
case CONFIG_MOUSE_DRIVER_ATRAMI:
31+
return "atrami.mou";
32+
case CONFIG_MOUSE_DRIVER_ATRJOY:
33+
return "atrjoy.mou";
34+
case CONFIG_MOUSE_DRIVER_ATRST:
35+
return "atrst.mou";
36+
case CONFIG_MOUSE_DRIVER_ATRTRK:
37+
return "atrtrk.mou";
38+
case CONFIG_MOUSE_DRIVER_ATRTT:
39+
return "atrtt.mou";
40+
}
41+
}

src/c128/config.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,14 @@ extern ConfigInfo config;
2525
*/
2626
void config_set_defaults(void)
2727
{
28-
config.io_mode = IO_MODE_SERIAL;
2928
config.baud = SER_BAUD_9600;
30-
config.use_dhcp = false;
31-
config.ip_address=0;
32-
config.netmask=0;
33-
config.gateway=0;
34-
config.dns=0;
3529
config.xon_threshold=XON_THRESHOLD;
3630
config.xoff_threshold=XOFF_THRESHOLD;
3731
config.fill=true;
38-
strcpy(config.driver_ser,CONFIG_DEFAULT_SERIAL_DRIVER);
39-
strcpy(config.driver_mou,CONFIG_DEFAULT_MOUSE_DRIVER);
32+
config.driver_ser=CONFIG_DEFAULT_SERIAL_DRIVER;
33+
config.driver_mou=CONFIG_DEFAULT_MOUSE_DRIVER;
4034
config.color_foreground=TGI_COLOR_LIGHTBLUE;
4135
config.color_background=TGI_COLOR_BLUE;
4236
config.color_border=TGI_COLOR_LIGHTBLUE;
4337
config_save();
4438
}
45-
46-
void config_init_hook(void)
47-
{
48-
}

src/c128/io.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void io_init_funcptrs(void)
3535
if (io_load_successful==false)
3636
return;
3737

38-
if (strcmp(config.driver_ser,CONFIG_SERIAL_DRIVER_SWIFTLINK)==0)
38+
if (config.driver_ser==CONFIG_SERIAL_DRIVER_SWIFTLINK)
3939
{
4040
io_serial_buffer_size=io_serial_buffer_size_swiftlink;
4141
io_recv_serial_flow_off=io_recv_serial_flow_off_swiftlink;
@@ -88,3 +88,15 @@ void io_recv_serial_flow_on_swiftlink(void)
8888
io_send_byte(0x11);
8989
xoff_enabled=false;
9090
}
91+
92+
/**
93+
* io_ser_driver_name() - return serial driver name given constant
94+
*/
95+
const char* io_ser_driver_name(unsigned char driver)
96+
{
97+
switch (driver)
98+
{
99+
case CONFIG_SERIAL_DRIVER_SWIFTLINK:
100+
return "ser-swlink";
101+
}
102+
}

0 commit comments

Comments
 (0)