Skip to content

Commit f526741

Browse files
committed
Created enums netProtoTranslation_t and netProtoOpenMode_t
Removed a ton more hardcoded values, set types to fujiCommandID_t, netProtoTranslation_t, and netProtoOpenMode_t to help compiler catch things. No logic changes, just more cleanup in preparation for unified and fujiversal.
1 parent 571e594 commit f526741

39 files changed

+648
-592
lines changed

include/fujiCommandID.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ enum fujiCommandID_t {
9090
FUJICMD_GETTZTIME = 0x9A,
9191
FUJICMD_SETTZ = 0x99,
9292
FUJICMD_GETTIME = 0x93,
93+
FUJICMD_JSON_QUERY = 0x81,
94+
FUJICMD_JSON_PARSE = 0x80,
95+
FUJICMD_GET_REMOTE = 0x72, // r
96+
FUJICMD_CLOSE_CLIENT = 0x63, // c
9397
FUJICMD_TIMER = 0x5A, // Z
9498
FUJICMD_STREAM = 0x58, // X
9599
FUJICMD_WRITE = 0x57, // W
@@ -106,6 +110,8 @@ enum fujiCommandID_t {
106110
FUJICMD_PERCOM_READ = 0x4E, // N
107111
FUJICMD_UNLISTEN = 0x4D, // M
108112
FUJICMD_LISTEN = 0x4C, // L
113+
FUJICMD_GET_ERROR = 0x45, // E
114+
FUJICMD_SET_DESTINATION = 0x44, // D
109115
FUJICMD_SET_DUMP = 0x44, // D
110116
FUJICMD_CLOSE = 0x43, // C
111117
FUJICMD_CONFIGURE = 0x42, // B

lib/device/adamnet/network.cpp

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ void adamNetwork::adamnet_special_inquiry()
583583
{
584584
}
585585

586-
void adamNetwork::do_inquiry(unsigned char inq_cmd)
586+
void adamNetwork::do_inquiry(fujiCommandID_t inq_cmd)
587587
{
588588
// Reset inq_dstats
589589
inq_dstats = 0xff;
@@ -599,30 +599,30 @@ void adamNetwork::do_inquiry(unsigned char inq_cmd)
599599
{
600600
switch (inq_cmd)
601601
{
602-
case 0x20:
603-
case 0x21:
604-
case 0x23:
605-
case 0x24:
606-
case 0x2A:
607-
case 0x2B:
608-
case 0x2C:
609-
case 0xFD:
610-
case 0xFE:
602+
case FUJICMD_RENAME:
603+
case FUJICMD_DELETE:
604+
case FUJICMD_LOCK:
605+
case FUJICMD_UNLOCK:
606+
case FUJICMD_MKDIR:
607+
case FUJICMD_RMDIR:
608+
case FUJICMD_CHDIR:
609+
case FUJICMD_SCAN_NETWORKS:
610+
case FUJICMD_GET_SSID:
611611
inq_dstats = 0x80;
612612
break;
613-
case 0x30:
613+
case FUJICMD_GETCWD:
614614
inq_dstats = 0x40;
615615
break;
616-
case 'Z': // Set interrupt rate
616+
case FUJICMD_TIMER: // Set interrupt rate
617617
inq_dstats = 0x00;
618618
break;
619-
case 'T': // Set Translation
619+
case FUJICMD_TRANSLATION:
620620
inq_dstats = 0x00;
621621
break;
622-
case 0x80: // JSON Parse
622+
case FUJICMD_JSON_PARSE:
623623
inq_dstats = 0x00;
624624
break;
625-
case 0x81: // JSON Query
625+
case FUJICMD_JSON_QUERY:
626626
inq_dstats = 0x80;
627627
break;
628628
default:
@@ -741,49 +741,49 @@ void adamNetwork::adamnet_control_ack()
741741
void adamNetwork::adamnet_control_send()
742742
{
743743
uint16_t s = adamnet_recv_length(); // receive length
744-
uint8_t c = adamnet_recv(); // receive command
744+
fujiCommandID_t c = (fujiCommandID_t) adamnet_recv(); // receive command
745745

746746
s--; // Because we've popped the command off the stack
747747

748748
switch (c)
749749
{
750-
case ' ':
750+
case FUJICMD_RENAME:
751751
rename(s);
752752
break;
753-
case '!':
753+
case FUJICMD_DELETE:
754754
del(s);
755755
break;
756-
case '*':
756+
case FUJICMD_MKDIR:
757757
mkdir(s);
758758
break;
759-
case ',':
759+
case FUJICMD_CHDIR:
760760
set_prefix(s);
761761
break;
762-
case '0':
762+
case FUJICMD_GETCWD:
763763
get_prefix();
764764
break;
765-
case 'E':
765+
case FUJICMD_GET_ERROR:
766766
get_error();
767767
break;
768-
case 'O':
768+
case FUJICMD_OPEN:
769769
open(s);
770770
break;
771-
case 'C':
771+
case FUJICMD_CLOSE:
772772
close();
773773
break;
774-
case 'S':
774+
case FUJICMD_STATUS:
775775
status();
776776
break;
777-
case 'W':
777+
case FUJICMD_WRITE:
778778
write(s);
779779
break;
780-
case 0xFC:
780+
case FUJICMD_JSON:
781781
channel_mode();
782782
break;
783-
case 0xFD: // login
783+
case FUJICMD_USERNAME: // login
784784
set_login(s);
785785
break;
786-
case 0xFE: // password
786+
case FUJICMD_PASSWORD: // password
787787
set_password(s);
788788
break;
789789
default:
@@ -805,12 +805,14 @@ void adamNetwork::adamnet_control_send()
805805
case JSON:
806806
switch (c)
807807
{
808-
case 'P':
808+
case FUJICMD_PARSE:
809809
json_parse();
810810
break;
811-
case 'Q':
811+
case FUJICMD_QUERY:
812812
json_query(s);
813813
break;
814+
default:
815+
break;
814816
}
815817
break;
816818
default:

lib/device/adamnet/network.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ class adamNetwork : public virtualDevice
402402
* @brief Perform the inquiry, handle both local and protocol commands.
403403
* @param inq_cmd the command to check against.
404404
*/
405-
void do_inquiry(unsigned char inq_cmd);
405+
void do_inquiry(fujiCommandID_t inq_cmd);
406406

407407
/**
408408
* @brief set translation specified by aux1 to aux2_translation mode.

lib/device/drivewire/network.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ void drivewireNetwork::set_password()
716716
*/
717717
void drivewireNetwork::special()
718718
{
719-
do_inquiry(cmdFrame.comnd);
719+
do_inquiry((fujiCommandID_t) cmdFrame.comnd);
720720

721721
switch (inq_dstats)
722722
{
@@ -744,13 +744,13 @@ void drivewireNetwork::special_inquiry()
744744
{
745745
Debug_printf("drivewireNetwork::special_inquiry(%02x)\n", cmdFrame.aux1);
746746

747-
do_inquiry(cmdFrame.aux1);
747+
do_inquiry((fujiCommandID_t) cmdFrame.aux1);
748748

749749
// Finally, return the completed inq_dstats value back to CoCo
750750
SYSTEM_BUS.write(&inq_dstats, sizeof(inq_dstats));
751751
}
752752

753-
void drivewireNetwork::do_inquiry(unsigned char inq_cmd)
753+
void drivewireNetwork::do_inquiry(fujiCommandID_t inq_cmd)
754754
{
755755
// Reset inq_dstats
756756
inq_dstats = 0xff;

lib/device/drivewire/network.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class drivewireNetwork : public virtualDevice
414414
* @brief Perform the inquiry, handle both local and protocol commands.
415415
* @param inq_cmd the command to check against.
416416
*/
417-
void do_inquiry(unsigned char inq_cmd);
417+
void do_inquiry(fujiCommandID_t inq_cmd);
418418

419419
/**
420420
* @brief set translation specified by aux1 to aux2_translation mode.

lib/device/iec/network.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void iecNetwork::iec_open()
7171

7272
// Check if the payload is RAW (i.e. from fujinet-lib) by the presence of "01" as the first uint8_t, which can't happen for BASIC.
7373
// If it is, then the next 2 bytes are the aux1/aux2 values (mode and trans), and the rest is the actual URL.
74-
// This is an efficiency so we don't have to send a 2nd command to tell it what the parameters should have been.
74+
// This is an efficiency so we don't have to send a 2nd command to tell it what the parameters should have been.
7575
// BASIC will still need to use "openparams" command, as the OPEN line doesn't have capacity for the parameters (can't use a "," as that's a valid URL character)
7676
if (payload[0] == 0x01) {
7777
channel_aux1 = payload[1];
@@ -80,7 +80,7 @@ void iecNetwork::iec_open()
8080
// capture the trans mode as though "settrans" had been invoked
8181
channel_data.translationMode = channel_aux2;
8282
// translationMode[commanddata.channel] = channel_aux2;
83-
83+
8484
// remove the marker bytes so the payload can continue as with BASIC setup
8585
if (payload.length() > 3)
8686
payload = payload.substr(3);
@@ -102,7 +102,7 @@ void iecNetwork::iec_open()
102102
channel_data.urlParser = std::move(PeoplesUrlParser::parseURL(channel_data.deviceSpec));
103103

104104
// Convert scheme to uppercase
105-
std::transform(channel_data.urlParser->scheme.begin(), channel_data.urlParser->scheme.end(), channel_data.urlParser->scheme.begin(),
105+
std::transform(channel_data.urlParser->scheme.begin(), channel_data.urlParser->scheme.end(), channel_data.urlParser->scheme.begin(),
106106
[](unsigned char c) { return std::toupper(c); });
107107

108108
// Instantiate protocol based on the scheme
@@ -385,7 +385,7 @@ void iecNetwork::parse_bite()
385385

386386
count++;
387387
} while ( end < channel_data.receiveBuffer.size() );
388-
388+
389389
//bites += "\"";
390390
//Debug_printv("[%s]", bites.c_str());
391391
channel_data.receiveBuffer = mstr::toPETSCII2(bites);
@@ -510,13 +510,13 @@ void iecNetwork::iec_command()
510510
return;
511511
}
512512

513-
uint8_t m = channel_data.protocol->special_inquiry(pt[0][0]);
513+
AtariSIODirection m = channel_data.protocol->special_inquiry((fujiCommandID_t) pt[0][0]);
514514
Debug_printv("pt[0][0]=[%2X] pt[1]=[%d] size[%d] m[%d]", pt[0][0], channel, pt.size(), m);
515-
if (m == 0x00)
515+
if (m == SIO_DIRECTION_NONE)
516516
perform_special_00();
517-
else if (m == 0x40)
517+
else if (m == SIO_DIRECTION_READ)
518518
perform_special_40();
519-
else if (m == 0x80)
519+
else if (m == SIO_DIRECTION_WRITE)
520520
perform_special_80();
521521
}
522522
}
@@ -970,7 +970,7 @@ void iecNetwork::set_open_params()
970970
iecStatus.msg = "invalid # of parameters";
971971
return;
972972
}
973-
973+
974974
int channel = atoi(pt[1].c_str());
975975
int mode = atoi(pt[2].c_str());
976976
int trans = atoi(pt[3].c_str());
@@ -1017,14 +1017,14 @@ bool iecNetwork::transmit(NetworkData &channel_data)
10171017
Debug_printf("iec_reopen_channel_listen() - Not connected");
10181018
return false;
10191019
}
1020-
1020+
10211021
// force incoming data from HOST to fixed ascii
10221022
// Debug_printv("[1] DATA: >%s< [%s]", channel_data.transmitBuffer.c_str(), mstr::toHex(channel_data.transmitBuffer).c_str());
10231023
clean_transform_petscii_to_ascii(channel_data.transmitBuffer);
10241024
// Debug_printv("[2] DATA: >%s< [%s]", channel_data.transmitBuffer.c_str(), mstr::toHex(channel_data.transmitBuffer).c_str());
1025-
1025+
10261026
Debug_printf("Received %u bytes. Transmitting.", channel_data.transmitBuffer.length());
1027-
1027+
10281028
channel_data.protocol->write(channel_data.transmitBuffer.length());
10291029
channel_data.transmitBuffer.clear();
10301030
channel_data.transmitBuffer.shrink_to_fit();
@@ -1035,19 +1035,19 @@ bool iecNetwork::transmit(NetworkData &channel_data)
10351035
bool iecNetwork::receive(NetworkData &channel_data, uint16_t rxBytes)
10361036
{
10371037
NetworkStatus ns;
1038-
1039-
if (!channel_data.protocol)
1038+
1039+
if (!channel_data.protocol)
10401040
{
10411041
//Debug_printv("No protocol set");
10421042
return false;
10431043
}
1044-
1044+
10451045
if (file_not_found)
10461046
{
10471047
Debug_printv("file not found");
10481048
return false;
10491049
}
1050-
1050+
10511051
// Get status
10521052
channel_data.protocol->status(&ns);
10531053
if( ns.rxBytesWaiting>0 )
@@ -1122,7 +1122,7 @@ uint8_t iecNetwork::getStatusData(char *buffer, uint8_t bufferSize)
11221122
{
11231123
if( is_binary_status )
11241124
{
1125-
if (!active_status_channel)
1125+
if (!active_status_channel)
11261126
Debug_printf("No active status channel\r\n");
11271127

11281128
if( !network_data_map[active_status_channel].protocol )
@@ -1135,17 +1135,17 @@ uint8_t iecNetwork::getStatusData(char *buffer, uint8_t bufferSize)
11351135
Debug_printf("msg: %s\r\n", iecStatus.msg.c_str());
11361136
util_petscii_to_ascii_str(iecStatus.msg); // are the util pescii/asccii functions reversed?
11371137
Debug_printf("msgPETSCII: %s\r\n", iecStatus.msg.c_str());
1138-
snprintf(buffer, bufferSize, "%d,%s,%02d,%02d\r\n",
1138+
snprintf(buffer, bufferSize, "%d,%s,%02d,%02d\r\n",
11391139
iecStatus.error, iecStatus.msg.c_str(), iecStatus.channel, iecStatus.connected);
11401140

11411141
Debug_printf("Sending status: %s\r\n", buffer);
1142-
1142+
11431143
// reset status
11441144
iecStatus.error = 0;
11451145
iecStatus.channel = 0;
11461146
iecStatus.connected = 0;
11471147
iecStatus.msg = "ok";
1148-
1148+
11491149
return strlen(buffer);
11501150
}
11511151
}

lib/device/iwm/iwmFuji.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ void iwmFuji::iwm_stat_read_device_slots()
11011101
int returnsize;
11021102

11031103
// Load the data from our current device array
1104-
for (int i = 0; i < MAX_DISK_DEVICES; i++)
1104+
for (int i = 0; i < MAX_A2DISK_DEVICES; i++)
11051105
{
11061106
diskSlots[i].mode = _fnDisks[i].access_mode;
11071107
diskSlots[i].hostSlot = _fnDisks[i].host_slot;
@@ -1199,7 +1199,7 @@ void iwmFuji::_populate_config_from_slots()
11991199
}
12001200
}
12011201

1202-
for (int i = 0; i < MAX_DISK_DEVICES; i++)
1202+
for (int i = 0; i < MAX_A2DISK_DEVICES; i++)
12031203
{
12041204
if (_fnDisks[i].host_slot >= MAX_HOSTS || _fnDisks[i].filename[0] == '\0')
12051205
Config.clear_mount(i);

0 commit comments

Comments
 (0)