Skip to content

Commit 0fdfd2e

Browse files
RichStephensFozzTexx
authored andcommitted
Define constants to replace hard coded values
1 parent ab069a5 commit 0fdfd2e

18 files changed

+85
-81
lines changed

src/check_wifi.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#endif /* BUILD_RC2014 */
4646

4747
#ifdef _CMOC_VERSION_
48-
#include "coco/stdbool.h"
4948
#include "coco/io.h"
5049
#include "coco/globals.h"
5150
#endif /* CMOC_VERSION */
@@ -67,15 +66,15 @@ void check_wifi(void)
6766
state=HOSTS_AND_DEVICES;
6867
}
6968
else if (io_get_wifi_status() == 3)
70-
{
71-
state=HOSTS_AND_DEVICES;
72-
}
69+
{
70+
state = HOSTS_AND_DEVICES;
71+
}
7372
else if (io_get_ssid()->ssid[0] == 0x00)
74-
{
75-
state=SET_WIFI;
76-
}
73+
{
74+
state = SET_WIFI;
75+
}
7776
else
78-
{
79-
state=CONNECT_WIFI;
80-
}
77+
{
78+
state = CONNECT_WIFI;
79+
}
8180
}

src/coco/bar.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <cmoc.h>
88
#include "bar.h"
9-
#include "stdbool.h"
109

1110
/**
1211
* static local variables for bar y, max, and index.

src/coco/bar.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define true 1
1010
#define false 0
1111

12-
#include "stdbool.h"
1312
#include "globals.h"
1413

1514
/**

src/coco/globals.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#ifndef GLOBALS_H
1010
#define GLOBALS_H
1111

12-
#define bool unsigned char
13-
1412
#define NUM_DEVICE_SLOTS 4
1513

1614
// # of files to display on the page. Moved from select_file.c to here, for Atari.

src/coco/input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#ifndef INPUT_H
77
#define INPUT_H
88

9-
#include "stdbool.h"
109
#include "../typedefs.h"
10+
#include "../fuji_typedefs.h"
1111

1212
/**
1313
* Get input from keyboard/joystick

src/coco/io.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
#include <cmoc.h>
7-
#include "stdbool.h"
87
#include "io.h"
98
#include "globals.h"
109
#include "screen.h"

src/coco/io.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#ifndef IO_H
88
#define IO_H
99

10-
#include "stdbool.h"
1110
#include "../fuji_typedefs.h"
1211

1312
bool io_error(void);

src/coco/screen.c

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern DeviceSlot deviceSlots[NUM_DEVICE_SLOTS];
3131
extern HostSlot hostSlots[8];
3232

3333
char uppercase_tmp[32]; // temp space for strupr(s) output.
34-
// so original strings doesn't get changed.
34+
// so original strings doesn't get changed.
3535

3636
char *screen_upper(char *s)
3737
{
@@ -95,9 +95,12 @@ void screen_set_wifi(AdapterConfig *ac)
9595
void screen_set_wifi_display_ssid(char n, SSIDInfo *s)
9696
{
9797
char meter[4]={0x20,0x20,0x20,0x00};
98-
char ds[32];
98+
char ds[33];
9999

100100
memset(ds,0x20,32);
101+
ds[32] = 0x00;
102+
// Print spaces first
103+
locate(0,n+2); printf("%-32s",screen_upper(ds));
101104
strncpy(ds,s->ssid,32);
102105

103106
if (s->rssi > -50)
@@ -126,7 +129,7 @@ void screen_set_wifi_select_network(unsigned char nn)
126129
printf(" up/down TO SELECT ");
127130
printf("hIDDEN SSID rESCAN enter SELECT");
128131
bar_draw(0,false);
129-
bar_set(2,1,nn,0);
132+
bar_set(2,0,nn,0);
130133

131134
screen_add_shadow(nn+2,CYAN);
132135
}
@@ -386,7 +389,7 @@ void screen_hosts_and_devices_hosts()
386389
locate(0,0);
387390
printf("%32s","host\x80slots");
388391

389-
memset(0x400,0xAF,22);
392+
memset(SCREEN_RAM_TOP,0xAF,22);
390393
(*(unsigned char *)0x041a) = 0x20;
391394

392395
locate(0,13);
@@ -451,13 +454,16 @@ const char host_slot_char(unsigned char hostSlot)
451454

452455
const char device_slot_mode(unsigned char mode)
453456
{
454-
switch(mode)
457+
// Mask out 0x40
458+
unsigned char masked_mode = mode & ~MODE_MOUNTED;
459+
460+
switch(masked_mode)
455461
{
456462
case 0:
457463
return 0x80;
458-
case 1:
464+
case MODE_READ:
459465
return 0xAF;
460-
case 2:
466+
case MODE_WRITE:
461467
return 0x9F;
462468
}
463469
}
@@ -513,19 +519,45 @@ void screen_hosts_and_devices_long_filename(const char *f)
513519

514520
void screen_init(void)
515521
{
516-
// TODO: figure out lowercase.
522+
// Make sure the screen is in 32 column mode
523+
width(32);
517524
}
518525

519526
void screen_destination_host_slot(char *h, char *p)
520527
{
528+
cls(3);
529+
locate(0,11);
530+
531+
printf("%32s","copy\x80\x66rom\x80host\x80slot");
532+
533+
locate(0, 12); printf("%-32s", screen_upper(h));
534+
locate(0, 13); printf("%-128s", p);
521535
}
522536

523537
void screen_destination_host_slot_choose(void)
524538
{
539+
locate(0, 0);
540+
printf("%32s","copy\x80to\x80host\x80slot");
541+
screen_hosts_and_devices_host_slots(&hostSlots[0]);
542+
locate(0,13);
543+
printf("1-8 choose\x80slot ENTER select");
544+
locate(0,14);
545+
printf("BREAK quit");
546+
screen_add_shadow(15,BLUE);
547+
548+
bar_set(1,1,8,selected_host_slot);
525549
}
526550

527551
void screen_perform_copy(char *sh, char *p, char *dh, char *dp)
528552
{
553+
cls(3);
554+
555+
locate(0,0); printf("%32s","COPYING FILE FROM:");
556+
locate(0,2); printf("%32s",sh);
557+
locate(0,3); printf("%-128s",p);
558+
locate(0,7); printf("%32s","COPYING FILE TO:");
559+
locate(0,9); printf("%32s",dh);
560+
locate(0,10); printf("%-128s",dp);
529561
}
530562

531563
void screen_connect_wifi(NetConfig *nc)

src/coco/stdbool.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/connect_wifi.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#ifdef _CMOC_VERSION_
99
#include <cmoc.h>
10-
#include "coco/stdbool.h"
1110
#include "coco/bar.h"
1211
#include "coco/globals.h"
1312
#include "coco/io.h"
@@ -79,11 +78,7 @@ extern bool screen_should_be_cleared;
7978

8079
void connect_wifi(void)
8180
{
82-
#ifndef _CMOC_VERSION_
8381
unsigned char retries = 20;
84-
#else
85-
unsigned char retries = 2;
86-
#endif
8782
NetConfig nc;
8883
unsigned char s, key;
8984

@@ -99,24 +94,14 @@ void connect_wifi(void)
9994
#ifndef _CMOC_VERSION_
10095
// check for esc key and abort
10196
if (input() == KEY_ABORT)
102-
#else
103-
unsigned char c = inkey();
104-
if (c!=0)
105-
{
106-
char szMsg[32];
107-
sprintf(szMsg, "c = %02x\n", c);
108-
screen_error(szMsg);
109-
pause(150);
110-
}
111-
if (c==' ' || c==0x3)
112-
#endif /* _CMOC_VERSION_ */
11397
{
11498
screen_error("CONNECTION ABORTED");
11599
pause(150);
116-
state=HOSTS_AND_DEVICES;
100+
state=SET_WIFI;
117101
return;
118102
}
119-
103+
#endif /* _CMOC_VERSION_ */
104+
120105
s = io_get_wifi_status();
121106

122107
switch (s)
@@ -134,23 +119,13 @@ void connect_wifi(void)
134119
pause(60);
135120
return;
136121
case 4:
137-
screen_error("CONNECT FAILED1");
138-
//pause(150);
139-
// ws_subState = WS_SCAN;
140-
state = HOSTS_AND_DEVICES;
122+
screen_error("CONNECT FAILED");
123+
pause(150);
141124
return;
142125
case 5:
143126
screen_error("CONNECTION LOST");
144127
pause(150);
145128
return;
146-
#ifdef _CMOC_VERSION_
147-
case 6:
148-
//screen_error("CONNECT FAILED");
149-
screen_error("BAD PSK");
150-
pause(150);
151-
state = HOSTS_AND_DEVICES;
152-
return;
153-
#endif
154129
default:
155130
screen_error("PLEASE WAIT...");
156131
pause(150);

0 commit comments

Comments
 (0)