From 52a2001787865624dff2c58c6e1ae6dd64fc39d6 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Sat, 21 Sep 2024 13:38:28 +0100 Subject: [PATCH] 4.7.1 add apple2gs clock functionality and rearrange the apple2 platform source dirs --- Changelog.md | 4 + .../bus/cc65 => apple2-6502/bus}/sp_close.s | 0 .../cc65 => apple2-6502/bus}/sp_close_nw.s | 0 .../cc65 => apple2-6502/bus}/sp_clr_payload.s | 0 .../bus/cc65 => apple2-6502/bus}/sp_data.s | 0 .../cc65 => apple2-6502/bus}/sp_find_clock.s | 0 .../cc65 => apple2-6502/bus}/sp_find_cpm.s | 0 .../cc65 => apple2-6502/bus}/sp_find_device.s | 0 .../cc65 => apple2-6502/bus}/sp_find_fuji.s | 0 .../cc65 => apple2-6502/bus}/sp_find_modem.s | 0 .../bus}/sp_find_network.s | 0 .../bus}/sp_find_printer.s | 0 .../bus/cc65 => apple2-6502/bus}/sp_init.s | 0 .../bus/cc65 => apple2-6502/bus}/sp_open.s | 0 .../bus/cc65 => apple2-6502/bus}/sp_open_nw.s | 0 .../bus/cc65 => apple2-6502/bus}/sp_read.s | 0 .../bus/cc65 => apple2-6502/bus}/sp_read_nw.s | 0 .../cc65 => apple2-6502/bus}/sp_rw_common.s | 0 .../bus}/sp_status_control_dispatch.s | 0 .../bus/cc65 => apple2-6502/bus}/sp_write.s | 0 .../cc65 => apple2-6502/bus}/sp_write_nw.s | 0 .../fn_clock}/clock_get_time.s | 0 .../fn_clock}/clock_get_tz.s | 0 .../fn_clock}/clock_set_tz.s | 12 ++- .../fn_network/bad_unit.s | 0 .../fn_network/fn_error.s | 0 .../fn_network/network_close.s | 0 .../fn_network/network_data.s | 0 .../bus/orca => apple2gs/bus}/sp_common.asm | 0 .../bus/orca => apple2gs/bus}/sp_control.asm | 0 .../bus/orca => apple2gs/bus}/sp_data.asm | 0 .../bus/orca => apple2gs/bus}/sp_dispatch.asm | 0 .../bus/orca => apple2gs/bus}/sp_done.asm | 0 .../bus/orca => apple2gs/bus}/sp_find_clock.c | 0 .../bus/orca => apple2gs/bus}/sp_find_cpm.c | 0 .../orca => apple2gs/bus}/sp_find_device.c | 0 .../bus/orca => apple2gs/bus}/sp_find_fuji.c | 0 .../bus/orca => apple2gs/bus}/sp_find_modem.c | 0 .../orca => apple2gs/bus}/sp_find_network.c | 0 .../orca => apple2gs/bus}/sp_find_printer.c | 0 .../bus/orca => apple2gs/bus}/sp_init.asm | 0 .../bus/orca => apple2gs/bus}/sp_status.asm | 0 apple2/apple2gs/fn_clock/clock_get_time.c | 21 ++++ apple2/apple2gs/fn_clock/clock_get_tz.c | 18 ++++ apple2/apple2gs/fn_clock/clock_set_tz.c | 22 +++++ apple2/src/bus/README.md | 3 + apple2/src/fn_clock/README.md | 3 + commodore/src/fn_fuji/get_fuji_status.c | 4 +- commodore/src/fn_network/network_status.c | 8 +- makefiles/build.mk | 96 +++++++++++++------ makefiles/objects-apple2gs.mk | 4 + makefiles/os.mk | 11 +++ scripts/fix-makelib-path.sh | 42 ++++++++ version.txt | 2 +- 54 files changed, 210 insertions(+), 40 deletions(-) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_close.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_close_nw.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_clr_payload.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_data.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_find_clock.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_find_cpm.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_find_device.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_find_fuji.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_find_modem.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_find_network.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_find_printer.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_init.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_open.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_open_nw.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_read.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_read_nw.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_rw_common.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_status_control_dispatch.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_write.s (100%) rename apple2/{src/bus/cc65 => apple2-6502/bus}/sp_write_nw.s (100%) rename apple2/{src/fn_clock/cc65 => apple2-6502/fn_clock}/clock_get_time.s (100%) rename apple2/{src/fn_clock/cc65 => apple2-6502/fn_clock}/clock_get_tz.s (100%) rename apple2/{src/fn_clock/cc65 => apple2-6502/fn_clock}/clock_set_tz.s (76%) rename apple2/{src => apple2-6502}/fn_network/bad_unit.s (100%) rename apple2/{src => apple2-6502}/fn_network/fn_error.s (100%) rename apple2/{src => apple2-6502}/fn_network/network_close.s (100%) rename apple2/{src => apple2-6502}/fn_network/network_data.s (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_common.asm (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_control.asm (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_data.asm (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_dispatch.asm (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_done.asm (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_find_clock.c (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_find_cpm.c (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_find_device.c (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_find_fuji.c (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_find_modem.c (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_find_network.c (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_find_printer.c (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_init.asm (100%) rename apple2/{src/bus/orca => apple2gs/bus}/sp_status.asm (100%) create mode 100644 apple2/apple2gs/fn_clock/clock_get_time.c create mode 100644 apple2/apple2gs/fn_clock/clock_get_tz.c create mode 100644 apple2/apple2gs/fn_clock/clock_set_tz.c create mode 100644 apple2/src/bus/README.md create mode 100644 apple2/src/fn_clock/README.md create mode 100644 makefiles/objects-apple2gs.mk create mode 100644 scripts/fix-makelib-path.sh diff --git a/Changelog.md b/Changelog.md index 61d576f..6434301 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,10 @@ ## [Unreleased] +## [4.7.1] - 2024-09-21 + +- [clock] add apple2gs clock implementation (untested) + ## [4.7.0] - 2024-09-20 - [clock] a simple clock library to interface with FujiNet clock device with atari/apple2 (cc65) implementations diff --git a/apple2/src/bus/cc65/sp_close.s b/apple2/apple2-6502/bus/sp_close.s similarity index 100% rename from apple2/src/bus/cc65/sp_close.s rename to apple2/apple2-6502/bus/sp_close.s diff --git a/apple2/src/bus/cc65/sp_close_nw.s b/apple2/apple2-6502/bus/sp_close_nw.s similarity index 100% rename from apple2/src/bus/cc65/sp_close_nw.s rename to apple2/apple2-6502/bus/sp_close_nw.s diff --git a/apple2/src/bus/cc65/sp_clr_payload.s b/apple2/apple2-6502/bus/sp_clr_payload.s similarity index 100% rename from apple2/src/bus/cc65/sp_clr_payload.s rename to apple2/apple2-6502/bus/sp_clr_payload.s diff --git a/apple2/src/bus/cc65/sp_data.s b/apple2/apple2-6502/bus/sp_data.s similarity index 100% rename from apple2/src/bus/cc65/sp_data.s rename to apple2/apple2-6502/bus/sp_data.s diff --git a/apple2/src/bus/cc65/sp_find_clock.s b/apple2/apple2-6502/bus/sp_find_clock.s similarity index 100% rename from apple2/src/bus/cc65/sp_find_clock.s rename to apple2/apple2-6502/bus/sp_find_clock.s diff --git a/apple2/src/bus/cc65/sp_find_cpm.s b/apple2/apple2-6502/bus/sp_find_cpm.s similarity index 100% rename from apple2/src/bus/cc65/sp_find_cpm.s rename to apple2/apple2-6502/bus/sp_find_cpm.s diff --git a/apple2/src/bus/cc65/sp_find_device.s b/apple2/apple2-6502/bus/sp_find_device.s similarity index 100% rename from apple2/src/bus/cc65/sp_find_device.s rename to apple2/apple2-6502/bus/sp_find_device.s diff --git a/apple2/src/bus/cc65/sp_find_fuji.s b/apple2/apple2-6502/bus/sp_find_fuji.s similarity index 100% rename from apple2/src/bus/cc65/sp_find_fuji.s rename to apple2/apple2-6502/bus/sp_find_fuji.s diff --git a/apple2/src/bus/cc65/sp_find_modem.s b/apple2/apple2-6502/bus/sp_find_modem.s similarity index 100% rename from apple2/src/bus/cc65/sp_find_modem.s rename to apple2/apple2-6502/bus/sp_find_modem.s diff --git a/apple2/src/bus/cc65/sp_find_network.s b/apple2/apple2-6502/bus/sp_find_network.s similarity index 100% rename from apple2/src/bus/cc65/sp_find_network.s rename to apple2/apple2-6502/bus/sp_find_network.s diff --git a/apple2/src/bus/cc65/sp_find_printer.s b/apple2/apple2-6502/bus/sp_find_printer.s similarity index 100% rename from apple2/src/bus/cc65/sp_find_printer.s rename to apple2/apple2-6502/bus/sp_find_printer.s diff --git a/apple2/src/bus/cc65/sp_init.s b/apple2/apple2-6502/bus/sp_init.s similarity index 100% rename from apple2/src/bus/cc65/sp_init.s rename to apple2/apple2-6502/bus/sp_init.s diff --git a/apple2/src/bus/cc65/sp_open.s b/apple2/apple2-6502/bus/sp_open.s similarity index 100% rename from apple2/src/bus/cc65/sp_open.s rename to apple2/apple2-6502/bus/sp_open.s diff --git a/apple2/src/bus/cc65/sp_open_nw.s b/apple2/apple2-6502/bus/sp_open_nw.s similarity index 100% rename from apple2/src/bus/cc65/sp_open_nw.s rename to apple2/apple2-6502/bus/sp_open_nw.s diff --git a/apple2/src/bus/cc65/sp_read.s b/apple2/apple2-6502/bus/sp_read.s similarity index 100% rename from apple2/src/bus/cc65/sp_read.s rename to apple2/apple2-6502/bus/sp_read.s diff --git a/apple2/src/bus/cc65/sp_read_nw.s b/apple2/apple2-6502/bus/sp_read_nw.s similarity index 100% rename from apple2/src/bus/cc65/sp_read_nw.s rename to apple2/apple2-6502/bus/sp_read_nw.s diff --git a/apple2/src/bus/cc65/sp_rw_common.s b/apple2/apple2-6502/bus/sp_rw_common.s similarity index 100% rename from apple2/src/bus/cc65/sp_rw_common.s rename to apple2/apple2-6502/bus/sp_rw_common.s diff --git a/apple2/src/bus/cc65/sp_status_control_dispatch.s b/apple2/apple2-6502/bus/sp_status_control_dispatch.s similarity index 100% rename from apple2/src/bus/cc65/sp_status_control_dispatch.s rename to apple2/apple2-6502/bus/sp_status_control_dispatch.s diff --git a/apple2/src/bus/cc65/sp_write.s b/apple2/apple2-6502/bus/sp_write.s similarity index 100% rename from apple2/src/bus/cc65/sp_write.s rename to apple2/apple2-6502/bus/sp_write.s diff --git a/apple2/src/bus/cc65/sp_write_nw.s b/apple2/apple2-6502/bus/sp_write_nw.s similarity index 100% rename from apple2/src/bus/cc65/sp_write_nw.s rename to apple2/apple2-6502/bus/sp_write_nw.s diff --git a/apple2/src/fn_clock/cc65/clock_get_time.s b/apple2/apple2-6502/fn_clock/clock_get_time.s similarity index 100% rename from apple2/src/fn_clock/cc65/clock_get_time.s rename to apple2/apple2-6502/fn_clock/clock_get_time.s diff --git a/apple2/src/fn_clock/cc65/clock_get_tz.s b/apple2/apple2-6502/fn_clock/clock_get_tz.s similarity index 100% rename from apple2/src/fn_clock/cc65/clock_get_tz.s rename to apple2/apple2-6502/fn_clock/clock_get_tz.s diff --git a/apple2/src/fn_clock/cc65/clock_set_tz.s b/apple2/apple2-6502/fn_clock/clock_set_tz.s similarity index 76% rename from apple2/src/fn_clock/cc65/clock_set_tz.s rename to apple2/apple2-6502/fn_clock/clock_set_tz.s index f6b4d5c..7b53d40 100644 --- a/apple2/src/fn_clock/cc65/clock_set_tz.s +++ b/apple2/apple2-6502/fn_clock/clock_set_tz.s @@ -30,26 +30,28 @@ got_id: jsr pusha ; store the destination device for call to sp_control ; copy timezone string into sp_payload, including the null terminator - pushax #(_sp_payload + 2) - pushax tmp_tz_ptr + pushax #(_sp_payload + 2) ; push destination for memcpy + pushax tmp_tz_ptr ; push src for memcpy AND set A/X for strlen - doubling down! + jsr _strlen + ; increment for the null terminator of the string clc adc #$01 bcc :+ inx + ; store the length for sp_control call, and A/X is correctly set for memcpy : sta _sp_payload + 0 stx _sp_payload + 1 jsr _memcpy - ; destination was stored on s/w stack already + ; src/dst were both stored on s/w stack already lda #'T' ; set 'T'imezone jsr _sp_control - ; convert to fujinet error + ; convert to fujinet ok/error code jmp _fn_error - .bss tmp_tz_ptr: .res 2 \ No newline at end of file diff --git a/apple2/src/fn_network/bad_unit.s b/apple2/apple2-6502/fn_network/bad_unit.s similarity index 100% rename from apple2/src/fn_network/bad_unit.s rename to apple2/apple2-6502/fn_network/bad_unit.s diff --git a/apple2/src/fn_network/fn_error.s b/apple2/apple2-6502/fn_network/fn_error.s similarity index 100% rename from apple2/src/fn_network/fn_error.s rename to apple2/apple2-6502/fn_network/fn_error.s diff --git a/apple2/src/fn_network/network_close.s b/apple2/apple2-6502/fn_network/network_close.s similarity index 100% rename from apple2/src/fn_network/network_close.s rename to apple2/apple2-6502/fn_network/network_close.s diff --git a/apple2/src/fn_network/network_data.s b/apple2/apple2-6502/fn_network/network_data.s similarity index 100% rename from apple2/src/fn_network/network_data.s rename to apple2/apple2-6502/fn_network/network_data.s diff --git a/apple2/src/bus/orca/sp_common.asm b/apple2/apple2gs/bus/sp_common.asm similarity index 100% rename from apple2/src/bus/orca/sp_common.asm rename to apple2/apple2gs/bus/sp_common.asm diff --git a/apple2/src/bus/orca/sp_control.asm b/apple2/apple2gs/bus/sp_control.asm similarity index 100% rename from apple2/src/bus/orca/sp_control.asm rename to apple2/apple2gs/bus/sp_control.asm diff --git a/apple2/src/bus/orca/sp_data.asm b/apple2/apple2gs/bus/sp_data.asm similarity index 100% rename from apple2/src/bus/orca/sp_data.asm rename to apple2/apple2gs/bus/sp_data.asm diff --git a/apple2/src/bus/orca/sp_dispatch.asm b/apple2/apple2gs/bus/sp_dispatch.asm similarity index 100% rename from apple2/src/bus/orca/sp_dispatch.asm rename to apple2/apple2gs/bus/sp_dispatch.asm diff --git a/apple2/src/bus/orca/sp_done.asm b/apple2/apple2gs/bus/sp_done.asm similarity index 100% rename from apple2/src/bus/orca/sp_done.asm rename to apple2/apple2gs/bus/sp_done.asm diff --git a/apple2/src/bus/orca/sp_find_clock.c b/apple2/apple2gs/bus/sp_find_clock.c similarity index 100% rename from apple2/src/bus/orca/sp_find_clock.c rename to apple2/apple2gs/bus/sp_find_clock.c diff --git a/apple2/src/bus/orca/sp_find_cpm.c b/apple2/apple2gs/bus/sp_find_cpm.c similarity index 100% rename from apple2/src/bus/orca/sp_find_cpm.c rename to apple2/apple2gs/bus/sp_find_cpm.c diff --git a/apple2/src/bus/orca/sp_find_device.c b/apple2/apple2gs/bus/sp_find_device.c similarity index 100% rename from apple2/src/bus/orca/sp_find_device.c rename to apple2/apple2gs/bus/sp_find_device.c diff --git a/apple2/src/bus/orca/sp_find_fuji.c b/apple2/apple2gs/bus/sp_find_fuji.c similarity index 100% rename from apple2/src/bus/orca/sp_find_fuji.c rename to apple2/apple2gs/bus/sp_find_fuji.c diff --git a/apple2/src/bus/orca/sp_find_modem.c b/apple2/apple2gs/bus/sp_find_modem.c similarity index 100% rename from apple2/src/bus/orca/sp_find_modem.c rename to apple2/apple2gs/bus/sp_find_modem.c diff --git a/apple2/src/bus/orca/sp_find_network.c b/apple2/apple2gs/bus/sp_find_network.c similarity index 100% rename from apple2/src/bus/orca/sp_find_network.c rename to apple2/apple2gs/bus/sp_find_network.c diff --git a/apple2/src/bus/orca/sp_find_printer.c b/apple2/apple2gs/bus/sp_find_printer.c similarity index 100% rename from apple2/src/bus/orca/sp_find_printer.c rename to apple2/apple2gs/bus/sp_find_printer.c diff --git a/apple2/src/bus/orca/sp_init.asm b/apple2/apple2gs/bus/sp_init.asm similarity index 100% rename from apple2/src/bus/orca/sp_init.asm rename to apple2/apple2gs/bus/sp_init.asm diff --git a/apple2/src/bus/orca/sp_status.asm b/apple2/apple2gs/bus/sp_status.asm similarity index 100% rename from apple2/src/bus/orca/sp_status.asm rename to apple2/apple2gs/bus/sp_status.asm diff --git a/apple2/apple2gs/fn_clock/clock_get_time.c b/apple2/apple2gs/fn_clock/clock_get_time.c new file mode 100644 index 0000000..4151f7f --- /dev/null +++ b/apple2/apple2gs/fn_clock/clock_get_time.c @@ -0,0 +1,21 @@ +#include +#include + +#include "fujinet-clock.h" +#include "fujinet-bus-apple2.h" + +// these correspond to the enum TimeFormat +const char format_cmds[] = { 'T', 'P', 'A', 'B', 'S', 'Z' }; + +uint8_t clock_get_time(uint8_t* tz, TimeFormat format) { + uint8_t result; + + sp_get_clock_id(); + if (sp_clock_id == 0) return FN_ERR_IO_ERROR; + + result = sp_status(sp_clock_id, 'G'); + if (result == 0) return FN_ERR_IO_ERROR; + + memcpy(tz, sp_payload, sp_count); + return FN_ERR_OK; +} \ No newline at end of file diff --git a/apple2/apple2gs/fn_clock/clock_get_tz.c b/apple2/apple2gs/fn_clock/clock_get_tz.c new file mode 100644 index 0000000..1dc9ef1 --- /dev/null +++ b/apple2/apple2gs/fn_clock/clock_get_tz.c @@ -0,0 +1,18 @@ +#include +#include + +#include "fujinet-clock.h" +#include "fujinet-bus-apple2.h" + +uint8_t clock_get_tz(uint8_t *tz) { + uint8_t result; + + sp_get_clock_id(); + if (sp_clock_id == 0) return FN_ERR_IO_ERROR; + + result = sp_status(sp_clock_id, 'G'); + if (result == 0) return FN_ERR_IO_ERROR; + + memcpy(tz, sp_payload, sp_count); + return FN_ERR_OK; +} \ No newline at end of file diff --git a/apple2/apple2gs/fn_clock/clock_set_tz.c b/apple2/apple2gs/fn_clock/clock_set_tz.c new file mode 100644 index 0000000..deaef19 --- /dev/null +++ b/apple2/apple2gs/fn_clock/clock_set_tz.c @@ -0,0 +1,22 @@ +#include +#include + +#include "fujinet-clock.h" +#include "fujinet-bus-apple2.h" + +uint8_t clock_set_tz(char *tz) { + uint16_t len; + int8_t result; + + sp_get_clock_id(); + if (sp_clock_id == 0) return FN_ERR_IO_ERROR; + + len = strlen(tz) + 1; + + sp_payload[0] = len & 0xFF; + sp_payload[1] = len >> 8; + memcpy(&sp_payload[2], tz, len); + + result = sp_control(sp_clock_id, 'T'); + return fn_error(result); +} \ No newline at end of file diff --git a/apple2/src/bus/README.md b/apple2/src/bus/README.md new file mode 100644 index 0000000..56f51c7 --- /dev/null +++ b/apple2/src/bus/README.md @@ -0,0 +1,3 @@ +# bus + +Only common C files for all apple2 platforms should go in here. diff --git a/apple2/src/fn_clock/README.md b/apple2/src/fn_clock/README.md new file mode 100644 index 0000000..e787112 --- /dev/null +++ b/apple2/src/fn_clock/README.md @@ -0,0 +1,3 @@ +# fn_clock + +Only common C files for all apple2 platforms should go in here. diff --git a/commodore/src/fn_fuji/get_fuji_status.c b/commodore/src/fn_fuji/get_fuji_status.c index 06f385e..ff63e9b 100644 --- a/commodore/src/fn_fuji/get_fuji_status.c +++ b/commodore/src/fn_fuji/get_fuji_status.c @@ -5,7 +5,7 @@ #include "fujinet-fuji-cbm.h" // Use 0x, and NOT string literals to avoid CC65 charmap translations. These are bytes not chars. -uint8_t status_cmd[2] = { 0x01, 0x53 }; +uint8_t fuji_status_cmd[2] = { 0x01, 0x53 }; // An internal version of fuji_status called at the end of the open_ commands // which uses the currently open connection to write the status command to. @@ -19,7 +19,7 @@ bool get_fuji_status(bool should_close) memset(&_fuji_status.raw[0], 0, sizeof(FNStatus)); // do a status call to find out if anything went wrong. Using the current open channel, so just write our bytes - bytes_written = cbm_write(CBM_CMD_CHANNEL, status_cmd, 2); + bytes_written = cbm_write(CBM_CMD_CHANNEL, fuji_status_cmd, 2); if (bytes_written != 2) { // always close on an error cbm_close(CBM_CMD_CHANNEL); diff --git a/commodore/src/fn_network/network_status.c b/commodore/src/fn_network/network_status.c index 645d547..c8e9014 100644 --- a/commodore/src/fn_network/network_status.c +++ b/commodore/src/fn_network/network_status.c @@ -3,12 +3,12 @@ #include "fujinet-network.h" #include "fujinet-network-cbm.h" -uint8_t *status_cmd = "statusb,N"; +uint8_t *nw_status_cmd = "statusb,N"; // we only really need the device id, not the full devicespec in all network_status calls. uint8_t network_status(char *devicespec, uint16_t *bw, uint8_t *c, uint8_t *err) { - // if we do a read on the status_cmd channel, we get the status for the specified devicespec, but we have to tell FN which device we want the status for first + // if we do a read on the nw_status_cmd channel, we get the status for the specified devicespec, but we have to tell FN which device we want the status for first const char *after; uint8_t status[4]; uint16_t temp_bw = 0; @@ -18,9 +18,9 @@ uint8_t network_status(char *devicespec, uint16_t *bw, uint8_t *c, uint8_t *err) // a "binary status" command, requires up to date firmware uint8_t data_channel = getDeviceNumber(devicespec, &after) + CBM_DATA_CHANNEL_0; - status_cmd[8] = data_channel + '0'; // overwrite with network device id + nw_status_cmd[8] = data_channel + '0'; // overwrite with network device id - if (cbm_write(CBM_CMD_CHANNEL, status_cmd, 9) != 9) { + if (cbm_write(CBM_CMD_CHANNEL, nw_status_cmd, 9) != 9) { return FN_ERR_IO_ERROR; } diff --git a/makefiles/build.mk b/makefiles/build.mk index 27ad3f2..7b21767 100644 --- a/makefiles/build.mk +++ b/makefiles/build.mk @@ -13,8 +13,6 @@ ASMEXT = .s -include ./makefiles/os.mk -include ./makefiles/compiler.mk -# CC := cl65 - SRCDIR := src BUILD_DIR := build OBJDIR := obj @@ -27,23 +25,62 @@ PLATFORM_SRC_DIR := $(CURRENT_PLATFORM)/$(SRCDIR) PROGRAM_TGT := $(PROGRAM).$(CURRENT_TARGET) -SOURCES := $(call rwildcard,$(PLATFORM_SRC_DIR),*.c) +SOURCES += $(call rwildcard,$(PLATFORM_SRC_DIR),*.c) SOURCES += $(call rwildcard,$(PLATFORM_SRC_DIR),*$(ASMEXT)) -SOURCES += $(call rwildcard,common/$(SRCDIR)/,*$(ASMEXT)) SOURCES += $(call rwildcard,common/$(SRCDIR)/,*.c) +SOURCES += $(call rwildcard,common/$(SRCDIR)/,*$(ASMEXT)) -# remove trailing and leading spaces. -SOURCES := $(strip $(SOURCES)) +################################################ +# PLATFORM SPECIFIC PATHS/SOURCES + +define ADD_SOURCES +SOURCES += $(call rwildcard,$(CURRENT_PLATFORM)/$(1),*.c) +SOURCES += $(call rwildcard,$(CURRENT_PLATFORM)/$(1),*$(ASMEXT)) +endef + +define ADD_SRC_INC_DIRS +SRC_INC_DIRS += $(sort $(dir $(wildcard $(CURRENT_PLATFORM)/$(1)/*))) +endef + +$(foreach path,$(PLATFORM_SPECIFIC_PATHS),$(eval $(call ADD_SOURCES,$(path)))) +$(foreach path,$(PLATFORM_SPECIFIC_PATHS),$(eval $(call ADD_SRC_INC_DIRS,$(path)))) + +################################################ +# GENERATE OBJECT LIST FROM ALL SOURCES # convert from src/your/long/path/foo.[c|s] to obj//your/long/path/foo.o -# we need the target because compiling for previous target does not pick up potential macro changes OBJ1 := $(SOURCES:.c=$(OBJEXT)) OBJECTS := $(OBJ1:$(ASMEXT)=$(OBJEXT)) -OBJECTS_ORCA := $(OBJECTS) $(patsubst %.c,%.a,$(filter %.c,$(SOURCES))) + +# this needs to undergo all substitutions too, this is the list of files that will be added to the archive (library) +OBJECTS_ARC := $(OBJECTS) + +# add any additional archive objects before doing all the substitutions +-include ./makefiles/objects-$(CURRENT_TARGET).mk + OBJECTS := $(OBJECTS:$(PLATFORM_SRC_DIR)/%=$(OBJDIR)/$(CURRENT_TARGET)/%) OBJECTS := $(OBJECTS:common/$(SRCDIR)/%=$(OBJDIR)/$(CURRENT_TARGET)/common/%) -OBJECTS_ORCA := $(OBJECTS_ORCA:$(PLATFORM_SRC_DIR)/%=$(OBJDIR)/$(CURRENT_TARGET)/%) -OBJECTS_ORCA := $(OBJECTS_ORCA:common/$(SRCDIR)/%=$(OBJDIR)/$(CURRENT_TARGET)/common/%) + +OBJECTS_ARC := $(OBJECTS_ARC:$(PLATFORM_SRC_DIR)/%=$(OBJDIR)/$(CURRENT_TARGET)/%) +OBJECTS_ARC := $(OBJECTS_ARC:common/$(SRCDIR)/%=$(OBJDIR)/$(CURRENT_TARGET)/common/%) + +################################################ +# PLATFORM SPECIFIC OBJECTS + +define SUBSTITUTE_OBJECTS +$($(1):$(CURRENT_PLATFORM)/$(2)/%=$(OBJDIR)/$(CURRENT_TARGET)/%) +endef + +$(foreach path,$(PLATFORM_SPECIFIC_PATHS),$(eval OBJECTS := $(call SUBSTITUTE_OBJECTS,OBJECTS,$(path)))) +$(foreach path,$(PLATFORM_SPECIFIC_PATHS),$(eval OBJECTS_ARC := $(call SUBSTITUTE_OBJECTS,OBJECTS_ARC,$(path)))) + +# remove trailing and leading spaces. +SOURCES := $(strip $(SOURCES)) +OBJECTS := $(strip $(OBJECTS)) +OBJECTS_ARC := $(strip $(OBJECTS_ARC)) + +# ensure the paths are unique +# SRC_INC_DIRS := $(sort $(filter-out %/, $(SRC_INC_DIRS))) # Ensure make recompiles parts it needs to if src files change DEPENDS := $(OBJECTS:$(OBJEXT)=.d) @@ -75,6 +112,7 @@ CHANGELOG = Changelog.md # allow for additional flags etc -include ./makefiles/common.mk +# global PLATFORM custom settings -include ./makefiles/custom-$(CURRENT_PLATFORM).mk # allow for application specific config @@ -87,18 +125,6 @@ all: $(ALL_TASKS) $(PROGRAM_TGT) -include $(DEPENDS) -ifeq ($(BUILD_DIR),) -BUILD_DIR := build -endif - -ifeq ($(OBJDIR),) -OBJDIR := obj -endif - -ifeq ($(DIST_DIR),) -DIST_DIR := dist -endif - $(OBJDIR): $(call MKDIR,$@) @@ -111,12 +137,18 @@ $(BUILD_DIR): $(DIST_DIR): $(call MKDIR,$@) -SRC_INC_DIRS := \ +# Add the default paths for the PLATFORM and common +SRC_INC_DIRS += \ $(sort $(dir $(wildcard $(PLATFORM_SRC_DIR)/*))) \ $(sort $(dir $(wildcard common/$(SRCDIR)/*))) - vpath %.c $(SRC_INC_DIRS) +vpath %$(ASMEXT) $(SRC_INC_DIRS) + +# $(info SOURCES: $(SOURCES)) +# $(info OBJECTS: $(OBJECTS)) +# $(info OBJECTS_ARC: $(OBJECTS_ARC)) +# $(info SRC_INC_DIRS: $(SRC_INC_DIRS)) $(OBJDIR)/$(CURRENT_TARGET)/common/%$(OBJEXT): %.c | $(TARGETOBJDIR) @$(call MKDIR,$(dir $@)) @@ -138,8 +170,6 @@ else $(CC) -c --deps $(CFLAGS) -o $@ $< endif -vpath %$(ASMEXT) $(SRC_INC_DIRS) - ## For now, no asm in common dirs... as it would be compiler specific # $(OBJDIR)/$(CURRENT_TARGET)/common/%$(OBJEXT): %$(ASMEXT) | $(TARGETOBJDIR) # @$(call MKDIR,$(dir $@)) @@ -160,9 +190,19 @@ endif $(BUILD_DIR)/$(PROGRAM_TGT): $(OBJECTS) | $(BUILD_DIR) ifeq ($(CC),cl65) - $(AR) a $@ $(OBJECTS) + $(AR) a $@ $(OBJECTS_ARC) else ifeq ($(CC),iix compile) - $(AR) $@ $(addprefix +,$(OBJECTS_ORCA)) + +ifeq ($(detected_OS),$(filter $(detected_OS),MSYS MINGW)) + rm -rf $(OBJDIR)/flat; \ + FILE_LIST=$$(scripts/fix-makelib-path.sh $(OBJDIR)/$(CURRENT_TARGET) $(OBJDIR)/flat); \ + cd $(OBJDIR)/flat; \ + for f in $$(echo "$${FILE_LIST}" | tr ' ' '\n'); do $(AR) $(PROGRAM_TGT) $${f}; done; \ + mv $(PROGRAM_TGT) ../../$(BUILD_DIR)/ +else + $(AR) $@ $(addprefix +,$(OBJECTS_ARC)) +endif + else $(AR) $@ -a $(OBJECTS) endif diff --git a/makefiles/objects-apple2gs.mk b/makefiles/objects-apple2gs.mk new file mode 100644 index 0000000..c78b3da --- /dev/null +++ b/makefiles/objects-apple2gs.mk @@ -0,0 +1,4 @@ +# target (not platform) changes to OBJECTS/OBJECTS_ARC list + +# this adds all the c files as a files to the archive, as the compiler creates .root and .a files for them. +OBJECTS_ARC += $(patsubst %.c,%.a,$(filter %.c,$(SOURCES))) diff --git a/makefiles/os.mk b/makefiles/os.mk index cf6becd..1eaa5a5 100644 --- a/makefiles/os.mk +++ b/makefiles/os.mk @@ -26,6 +26,17 @@ CURRENT_PLATFORM_coco := coco CURRENT_PLATFORM = $(CURRENT_PLATFORM_$(CURRENT_TARGET)) +# platform specific src paths (PSP) +# These allow us to add additional directories (each entry can have space separated list) to a TARGET +# Used for apple2/enh vs apple2gs, but other platforms if they had different compiled code could use it. + +PSP_apple2 := apple2-6502 +PSP_apple2enh := apple2-6502 +PSP_apple2gs := apple2gs + +PLATFORM_SPECIFIC_PATHS := $(PSP_$(CURRENT_TARGET)) + + ifeq '$(findstring ;,$(PATH))' ';' detected_OS := Windows else diff --git a/scripts/fix-makelib-path.sh b/scripts/fix-makelib-path.sh new file mode 100644 index 0000000..aec5081 --- /dev/null +++ b/scripts/fix-makelib-path.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +if [ $# -ne 2 ]; then + echo "Usage: $(basename $0) SOURCE_DIR DESTINATION_DIR" + echo " This script flattens every file in any directory under SOURCE_DIR into DESTINATION_DIR and then applies 0xb1 filetype for orca makefile" + echo " It will fail if the SOURCE_DIR does not exist" + exit 1 +fi + +SOURCE_DIR=$1 +DEST_DIR=$2 + +if [ ! -d "${SOURCE_DIR}" ]; then + echo "ERROR: SOURCE_DIR '${SOURCE_DIR}' does not exist." + exit 1 +fi + +# Create destination directory if it does not exist +if [ ! -d "$DEST_DIR" ]; then + mkdir -p "$DEST_DIR" +fi + +TEMP_ZIP=$(mktemp -u --tmpdir source_archive_XXXXX.zip) + +# Ensure the temporary file is removed on script exit or interruption +trap 'rm -f "$TEMP_ZIP"' EXIT + +# Create a zip file of the entire source directory (including subdirectories) +zip -r "$TEMP_ZIP" "$SOURCE_DIR"/* >/dev/null 2>&1 + +# Check if destination directory exists, if not create it +if [ ! -d "$DEST_DIR" ]; then + mkdir -p "$DEST_DIR" +fi + +# Extract the zip file without preserving the directory structure +unzip -j "$TEMP_ZIP" -d "$DEST_DIR" > /dev/null 2>&1 + +cd $DEST_DIR +find . -type f -exec iix chtyp -t 0xb1 {} \; +FILE_LIST=$(find . -type f -exec basename {} \; | xargs -I {} echo -n "+{} " | sed 's/ $$//') +echo ${FILE_LIST} diff --git a/version.txt b/version.txt index 1163055..cfacfe4 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -4.7.0 \ No newline at end of file +4.7.1 \ No newline at end of file