-
Couldn't load subscription status.
- Fork 19
Implement host prefix cmds #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6ef5b5a
b63ec91
b4363fe
2dbdbe6
5153a30
213c51f
a49f6d6
0cb6177
380a170
e2362ff
a6c3695
8093431
1012619
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,30 @@ | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include "fujinet-fuji.h" | ||
| #include <eos.h> | ||
| #include <string.h> | ||
|
|
||
| extern unsigned char response[1024]; | ||
|
|
||
| bool fuji_get_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| return true; | ||
| struct _ghp | ||
| { | ||
| unsigned char cmd; | ||
| unsigned char hs; | ||
| } ghp; | ||
|
|
||
| memset(response,0,sizeof(response)); | ||
| ghp.cmd = 0xE0; | ||
| ghp.hs = hs; | ||
|
|
||
| if (eos_write_character_device(0x0f,ghp,sizeof(ghp)) != 0x80) | ||
| return false; | ||
|
|
||
| if (eos_read_character_device(0x0f,response,sizeof(response)) != 0x80) | ||
| return false; | ||
|
|
||
| strcpy(prefix,response); | ||
|
|
||
| return true; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,23 @@ | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include "fujinet-fuji.h" | ||
| #include <eos.h> | ||
| #include <string.h> | ||
|
|
||
| bool fuji_set_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| return true; | ||
| struct _shp | ||
| { | ||
| unsigned char cmd; | ||
| unsigned char hs; | ||
| unsigned char prefix[256]; | ||
| } shp; | ||
|
|
||
| shp.cmd = FUJICMD_SET_HOST_PREFIX; | ||
| shp.hs = hs; | ||
| strcpy(shp.prefix,prefix); | ||
|
|
||
| eos_write_character_device(0x0f,&shp,sizeof(shp)); | ||
|
|
||
| return true; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,20 @@ | ||
| #include <stdint.h> | ||
| #include <string.h> | ||
| #include "fujinet-fuji.h" | ||
| #include "fujinet-bus-apple2.h" | ||
|
|
||
| // A8 to AF are now being allocated as get host prefix for slots 0 to 7. | ||
| bool fuji_get_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| // Not implemented in A2 | ||
| return false; | ||
| uint8_t stat = hs + 0xA8; | ||
|
|
||
| if (sp_get_fuji_id() == 0) { | ||
| return false; | ||
| } | ||
|
|
||
| sp_error = sp_status(sp_fuji_id, stat); | ||
| if (sp_error == 0) { | ||
| memcpy(prefix, &sp_payload[0], 256); | ||
| } | ||
| return sp_error == 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,29 @@ | ||
| #include <stdint.h> | ||
| #include <string.h> | ||
| #include "fujinet-fuji.h" | ||
| #include "fujinet-bus-apple2.h" | ||
|
|
||
| bool fuji_set_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| // Not implemented in A2 | ||
| return false; | ||
| // Not implemented in A2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the comment |
||
| size_t filename_len = strlen(prefix); | ||
| if (filename_len >= 254) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| sp_error = sp_get_fuji_id(); | ||
| if (sp_error <= 0) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| sp_payload[0] = (filename_len + 1) & 0xFF; | ||
| sp_payload[1] = 0; | ||
| sp_payload[2] = hs; | ||
| strcpy((char *) &sp_payload[3], prefix); | ||
|
|
||
| sp_error = sp_control(sp_fuji_id, FUJICMD_SET_HOST_PREFIX); | ||
|
|
||
| return sp_error == 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,27 @@ | ||
| #include <cmoc.h> | ||
| #include <coco.h> | ||
| #include <dw.h> | ||
| #include <fujinet-fuji-coco.h> | ||
| #include "fujinet-fuji.h" | ||
|
|
||
| bool fuji_get_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| // TODO: not implemented in firmware. | ||
| return true; | ||
| struct _ghp | ||
| { | ||
| uint8_t opcode; | ||
| uint8_t cmd; | ||
| uint8_t hs; | ||
| } ghp; | ||
|
|
||
| ghp.opcode = OP_FUJI; | ||
| ghp.cmd = FUJICMD_GET_HOST_PREFIX; | ||
| ghp.hs = hs; | ||
|
|
||
| bus_ready(); | ||
|
|
||
| dwwrite((uint8_t *)&ghp, sizeof(ghp)); | ||
| if (fuji_get_error()) | ||
| return false; | ||
|
|
||
| return fuji_get_response((uint8_t *)prefix, 256); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,26 @@ | ||
| #include <cmoc.h> | ||
| #include <coco.h> | ||
| #include "fujinet-fuji.h" | ||
| #include <dw.h> | ||
| #include <fujinet-fuji-coco.h> | ||
|
|
||
| bool fuji_set_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| // Not implemented anywhere yet. | ||
| return true; | ||
| struct _shp | ||
| { | ||
| uint8_t opcode; | ||
| uint8_t cmd; | ||
| uint8_t hs; | ||
| char filename[256]; | ||
| } shp; | ||
|
|
||
| shp.opcode = OP_FUJI; | ||
| shp.cmd = FUJICMD_SET_HOST_PREFIX; | ||
| shp.hs = hs; | ||
| strcpy(shp.filename,prefix); | ||
|
|
||
| bus_ready(); | ||
| dwwrite((uint8_t *)&shp, sizeof(shp)); | ||
|
|
||
| return !fuji_get_error(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,26 @@ | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include "fujinet-fuji.h" | ||
| #include "fujinet-fuji-cbm.h" | ||
|
|
||
| bool fuji_get_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| // not implemented on CBM | ||
| return false; | ||
| uint8_t *filename; | ||
| bool is_success; | ||
| int bytes_read; | ||
|
|
||
| filename = malloc(256); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've avoided using malloc in library. it pulls a huge chunk of cc65 into the application and is much better just using a static array. |
||
| if (filename == NULL) { | ||
| return false; | ||
| } | ||
| memset(filename, 0, 256); | ||
|
|
||
| is_success = open_read_close_data_1(FUJICMD_GET_HOST_PREFIX, &bytes_read, hs, 256, (uint8_t *) filename); | ||
| if (is_success) { | ||
| strcpy(prefix, (char *)filename); | ||
| } | ||
| free(filename); | ||
| return is_success; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,29 @@ | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
| #include "fujinet-fuji.h" | ||
| #include "fujinet-fuji-cbm.h" | ||
|
|
||
| bool fuji_set_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| // Not implemented in IEM fuji firmware | ||
| return false; | ||
| uint8_t *pl; | ||
| uint16_t pl_len; | ||
| bool ret; | ||
|
|
||
| pl_len = strlen(prefix) + 3 + 1; // add 1 for the null string terminator, although technically not required as we go by lengths | ||
|
|
||
| pl = malloc(pl_len); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto (just trying to tag them all) |
||
| if (pl == NULL) { | ||
| status_error(ERROR_MALLOC_FAILED, FUJICMD_SET_HOST_PREFIX); | ||
| return false; | ||
| } | ||
|
|
||
| pl[0] = hs; | ||
| strcpy((char *) &pl[1], prefix); | ||
| pl[pl_len - 1] = '\0'; | ||
|
|
||
| ret = open_close_data(FUJICMD_SET_HOST_PREFIX, true, pl_len, pl); | ||
| free(pl); | ||
| return ret; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,25 @@ | ||
| #include <dw.h> | ||
| #include <fujinet-fuji-pmd85.h> | ||
| #include <string.h> | ||
| #include "fujinet-fuji.h" | ||
|
|
||
| bool fuji_set_host_prefix(uint8_t hs, char *prefix) | ||
| { | ||
| // Not implemented anywhere yet. | ||
| return true; | ||
| struct _shp | ||
| { | ||
| uint8_t opcode; | ||
| uint8_t cmd; | ||
| uint8_t hs; | ||
| char filename[256]; | ||
| } shp; | ||
|
|
||
| shp.opcode = OP_FUJI; | ||
| shp.cmd = FUJICMD_SET_HOST_PREFIX; | ||
| shp.hs = hs; | ||
| strcpy(shp.filename,prefix); | ||
|
|
||
| bus_ready(); | ||
| dwwrite((uint8_t *)&shp, sizeof(shp)); | ||
|
|
||
| return !fuji_get_error(); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't required anymore, the values are immediately set