diff --git a/src/check_wifi.c b/src/check_wifi.c index 33bd992c..44178835 100644 --- a/src/check_wifi.c +++ b/src/check_wifi.c @@ -45,7 +45,6 @@ #endif /* BUILD_RC2014 */ #ifdef _CMOC_VERSION_ -#include "coco/stdbool.h" #include "coco/io.h" #include "coco/globals.h" #endif /* CMOC_VERSION */ @@ -67,15 +66,15 @@ void check_wifi(void) state=HOSTS_AND_DEVICES; } else if (io_get_wifi_status() == 3) - { - state=HOSTS_AND_DEVICES; - } + { + state = HOSTS_AND_DEVICES; + } else if (io_get_ssid()->ssid[0] == 0x00) - { - state=SET_WIFI; - } + { + state = SET_WIFI; + } else - { - state=CONNECT_WIFI; - } + { + state = CONNECT_WIFI; + } } diff --git a/src/coco/bar.c b/src/coco/bar.c index ec680672..5797ae8d 100644 --- a/src/coco/bar.c +++ b/src/coco/bar.c @@ -6,7 +6,6 @@ #include #include "bar.h" -#include "stdbool.h" /** * static local variables for bar y, max, and index. diff --git a/src/coco/bar.h b/src/coco/bar.h index c41c0965..9b2cc0dd 100644 --- a/src/coco/bar.h +++ b/src/coco/bar.h @@ -9,7 +9,6 @@ #define true 1 #define false 0 -#include "stdbool.h" #include "globals.h" /** diff --git a/src/coco/globals.h b/src/coco/globals.h index 36eacc2b..02579ff7 100644 --- a/src/coco/globals.h +++ b/src/coco/globals.h @@ -9,8 +9,6 @@ #ifndef GLOBALS_H #define GLOBALS_H -#define bool unsigned char - #define NUM_DEVICE_SLOTS 4 // # of files to display on the page. Moved from select_file.c to here, for Atari. diff --git a/src/coco/input.h b/src/coco/input.h index aff6f647..342d5baa 100644 --- a/src/coco/input.h +++ b/src/coco/input.h @@ -6,8 +6,8 @@ #ifndef INPUT_H #define INPUT_H -#include "stdbool.h" #include "../typedefs.h" +#include "../fuji_typedefs.h" /** * Get input from keyboard/joystick diff --git a/src/coco/io.c b/src/coco/io.c index a8fc30d8..4c8a569a 100644 --- a/src/coco/io.c +++ b/src/coco/io.c @@ -4,7 +4,6 @@ */ #include -#include "stdbool.h" #include "io.h" #include "globals.h" #include "screen.h" diff --git a/src/coco/io.h b/src/coco/io.h index fe2ac956..d1539af7 100644 --- a/src/coco/io.h +++ b/src/coco/io.h @@ -7,7 +7,6 @@ #ifndef IO_H #define IO_H -#include "stdbool.h" #include "../fuji_typedefs.h" bool io_error(void); diff --git a/src/coco/screen.c b/src/coco/screen.c index a8afb43d..b2ce9010 100644 --- a/src/coco/screen.c +++ b/src/coco/screen.c @@ -31,7 +31,7 @@ extern DeviceSlot deviceSlots[NUM_DEVICE_SLOTS]; extern HostSlot hostSlots[8]; char uppercase_tmp[32]; // temp space for strupr(s) output. - // so original strings doesn't get changed. + // so original strings doesn't get changed. char *screen_upper(char *s) { @@ -95,9 +95,12 @@ void screen_set_wifi(AdapterConfig *ac) void screen_set_wifi_display_ssid(char n, SSIDInfo *s) { char meter[4]={0x20,0x20,0x20,0x00}; - char ds[32]; + char ds[33]; memset(ds,0x20,32); + ds[32] = 0x00; + // Print spaces first + locate(0,n+2); printf("%-32s",screen_upper(ds)); strncpy(ds,s->ssid,32); if (s->rssi > -50) @@ -126,7 +129,7 @@ void screen_set_wifi_select_network(unsigned char nn) printf(" up/down TO SELECT "); printf("hIDDEN SSID rESCAN enter SELECT"); bar_draw(0,false); - bar_set(2,1,nn,0); + bar_set(2,0,nn,0); screen_add_shadow(nn+2,CYAN); } @@ -386,7 +389,7 @@ void screen_hosts_and_devices_hosts() locate(0,0); printf("%32s","host\x80slots"); - memset(0x400,0xAF,22); + memset(SCREEN_RAM_TOP,0xAF,22); (*(unsigned char *)0x041a) = 0x20; locate(0,13); @@ -451,13 +454,16 @@ const char host_slot_char(unsigned char hostSlot) const char device_slot_mode(unsigned char mode) { - switch(mode) + // Mask out 0x40 + unsigned char masked_mode = mode & ~MODE_MOUNTED; + + switch(masked_mode) { case 0: return 0x80; - case 1: + case MODE_READ: return 0xAF; - case 2: + case MODE_WRITE: return 0x9F; } } @@ -513,19 +519,45 @@ void screen_hosts_and_devices_long_filename(const char *f) void screen_init(void) { - // TODO: figure out lowercase. + // Make sure the screen is in 32 column mode + width(32); } void screen_destination_host_slot(char *h, char *p) { + cls(3); + locate(0,11); + + printf("%32s","copy\x80\x66rom\x80host\x80slot"); + + locate(0, 12); printf("%-32s", screen_upper(h)); + locate(0, 13); printf("%-128s", p); } void screen_destination_host_slot_choose(void) { + locate(0, 0); + printf("%32s","copy\x80to\x80host\x80slot"); + screen_hosts_and_devices_host_slots(&hostSlots[0]); + locate(0,13); + printf("1-8 choose\x80slot ENTER select"); + locate(0,14); + printf("BREAK quit"); + screen_add_shadow(15,BLUE); + + bar_set(1,1,8,selected_host_slot); } void screen_perform_copy(char *sh, char *p, char *dh, char *dp) { + cls(3); + + locate(0,0); printf("%32s","COPYING FILE FROM:"); + locate(0,2); printf("%32s",sh); + locate(0,3); printf("%-128s",p); + locate(0,7); printf("%32s","COPYING FILE TO:"); + locate(0,9); printf("%32s",dh); + locate(0,10); printf("%-128s",dp); } void screen_connect_wifi(NetConfig *nc) diff --git a/src/coco/stdbool.h b/src/coco/stdbool.h deleted file mode 100644 index 8f8e4daf..00000000 --- a/src/coco/stdbool.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @brief stdbool definition needed by config - * @author Thomas Cherryhomes - * @email thom dot cherryhomes at gmail dot com - * @license gpl v. 3, see LICENSE for details - */ - -#ifndef STDBOOL_H -#define STDBOOL_H - -#define true 1 -#define false 0 - -typedef unsigned char bool; - -#endif /* STDBOOL_H */ diff --git a/src/connect_wifi.c b/src/connect_wifi.c index 70a7b53a..4ad9830a 100644 --- a/src/connect_wifi.c +++ b/src/connect_wifi.c @@ -7,7 +7,6 @@ #ifdef _CMOC_VERSION_ #include -#include "coco/stdbool.h" #include "coco/bar.h" #include "coco/globals.h" #include "coco/io.h" @@ -79,11 +78,7 @@ extern bool screen_should_be_cleared; void connect_wifi(void) { -#ifndef _CMOC_VERSION_ unsigned char retries = 20; -#else - unsigned char retries = 2; -#endif NetConfig nc; unsigned char s, key; @@ -99,24 +94,14 @@ void connect_wifi(void) #ifndef _CMOC_VERSION_ // check for esc key and abort if (input() == KEY_ABORT) -#else - unsigned char c = inkey(); - if (c!=0) - { - char szMsg[32]; - sprintf(szMsg, "c = %02x\n", c); - screen_error(szMsg); - pause(150); - } - if (c==' ' || c==0x3) -#endif /* _CMOC_VERSION_ */ { screen_error("CONNECTION ABORTED"); pause(150); - state=HOSTS_AND_DEVICES; + state=SET_WIFI; return; } - +#endif /* _CMOC_VERSION_ */ + s = io_get_wifi_status(); switch (s) @@ -134,23 +119,13 @@ void connect_wifi(void) pause(60); return; case 4: - screen_error("CONNECT FAILED1"); - //pause(150); - // ws_subState = WS_SCAN; - state = HOSTS_AND_DEVICES; + screen_error("CONNECT FAILED"); + pause(150); return; case 5: screen_error("CONNECTION LOST"); pause(150); return; -#ifdef _CMOC_VERSION_ - case 6: - //screen_error("CONNECT FAILED"); - screen_error("BAD PSK"); - pause(150); - state = HOSTS_AND_DEVICES; - return; -#endif default: screen_error("PLEASE WAIT..."); pause(150); diff --git a/src/destination_host_slot.c b/src/destination_host_slot.c index 98b0e625..e1484515 100644 --- a/src/destination_host_slot.c +++ b/src/destination_host_slot.c @@ -6,7 +6,6 @@ #ifdef _CMOC_VERSION_ #include -#include "coco/stdbool.h" #include "coco/screen.h" #include "coco/input.h" #include "coco/globals.h" diff --git a/src/fuji_typedefs.h b/src/fuji_typedefs.h index 0e97bd35..02ab4a1e 100644 --- a/src/fuji_typedefs.h +++ b/src/fuji_typedefs.h @@ -14,6 +14,7 @@ #define MODE_READ 1 #define MODE_WRITE 2 +#define MODE_MOUNTED 0x40 #define MAX_HOST_LEN 32 #define NUM_HOST_SLOTS 8 diff --git a/src/fuji_typedefs_io.h b/src/fuji_typedefs_io.h index 7ab7ddb9..3f6c8aab 100644 --- a/src/fuji_typedefs_io.h +++ b/src/fuji_typedefs_io.h @@ -8,6 +8,12 @@ #define FILE_MAXLEN 36 #define SSID_MAXLEN 33 /* 32 + NULL */ +#ifdef _CMOC_VERSION_ +typedef unsigned char bool; +#define true 1 +#define false 0 +#endif /* _CMOC_VERSION_ */ + /** * Returned info for a single SSID entry * from a WiFi scan diff --git a/src/hosts_and_devices.c b/src/hosts_and_devices.c index 9777cc51..01b36b0a 100644 --- a/src/hosts_and_devices.c +++ b/src/hosts_and_devices.c @@ -8,7 +8,6 @@ #ifdef _CMOC_VERSION_ #include -#include "coco/stdbool.h" #include "coco/globals.h" #include "coco/io.h" #include "coco/screen.h" @@ -147,7 +146,7 @@ void hosts_and_devices_edit_host_slot(unsigned char i) { // re-use 'o' here to save a little memory. If it's original value is needed in some future enhancement, // declare a new variable for the loop counter. - for ( o = 0; o +#elif defined(_CMOC_VERSION_) + +#define KEY_LEFT_ARROW 0x08 +#define KEY_RIGHT_ARROW 0x09 +#define KEY_UP_ARROW 0x5E +#define KEY_DOWN_ARROW 0x0A +#define KEY_SHIFT_UP_ARROW 0x5F +#define KEY_SHIFT_DOWN_ARROW 0x5B +#define KEY_ENTER 0x0D +#define KEY_BREAK 0x03 +#define KEY_CLEAR 0x0C + +#define KEY_0 0x30 +#define KEY_1 0x31 +#define KEY_2 0x32 +#define KEY_3 0x33 + #endif // defined(...) #endif // KEY_CODES_H diff --git a/src/main.c b/src/main.c index 86e5729b..7727e5c8 100644 --- a/src/main.c +++ b/src/main.c @@ -4,11 +4,13 @@ */ #ifdef _CMOC_VERSION_ -#include "coco/stdbool.h" +#include +#include #else #include #endif /* CMOC_VERSION */ +#include "fuji_typedefs.h" #include "typedefs.h" #include "check_wifi.h" #include "connect_wifi.h" diff --git a/src/perform_copy.c b/src/perform_copy.c index a36394bc..0c87f988 100644 --- a/src/perform_copy.c +++ b/src/perform_copy.c @@ -6,7 +6,6 @@ #ifdef _CMOC_VERSION_ #include -#include "coco/stdbool.h" #include "coco/screen.h" #include "coco/io.h" #include "coco/globals.h" diff --git a/src/select_file.c b/src/select_file.c index 445e3958..4b89ece8 100644 --- a/src/select_file.c +++ b/src/select_file.c @@ -7,7 +7,6 @@ #ifdef _CMOC_VERSION_ #include #include "coco/strrchr.h" -#include "coco/stdbool.h" #include "coco/screen.h" #include "coco/io.h" #include "coco/globals.h"