Skip to content

Commit 46aa5ba

Browse files
committed
Add commodore stub functions and scripts to generate them
1 parent 545ac88 commit 46aa5ba

File tree

77 files changed

+651
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+651
-9
lines changed

GENERATE_STUBS.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Generating stub functions for new platform
2+
3+
When adding a new platform, the following can be run to generate stub functions for the various devices.
4+
5+
This is a very simple parser of the include files to find function definitions and convert them to stub files that can then be implemented.
6+
7+
## How the scripts work
8+
9+
There are various assumptions in order to make the script very simple.
10+
11+
- Read from the library device include files "fujinet-fuji.h", "fujinet-network.h"
12+
- Look for lines that start with one of the letters "b", "u", "i", or "v" (for bool, uint, int, void)
13+
- And have an open bracket on the line
14+
- Assume the line is the full function definition (i.e. all parameters on 1 line)
15+
- Remove the semi-colon from the line
16+
- Generate a stub file that returns "true" for bool, nothing for void, or 0 for number types.
17+
- Saves stub to "function name".cpp in appropriate subdir of src
18+
19+
## setup
20+
21+
Create the initial directories for the new platform
22+
23+
```shell
24+
NEW_PLATFORM=commodore
25+
mkdir ${NEW_PLATFORM}/src/{bus,fn_fuji,fn_network}
26+
```
27+
28+
## fuji
29+
30+
```shell
31+
grep '^[buiv].*(' fujinet-fuji.h | while read f; do FILE_NAME=$(echo $f | cut -d\( -f1 | awk '{print $2}').cpp; echo $f | awk '{
32+
LINE=gsub(/;/, "")
33+
printf("#include <stdbool.h>\n#include <stdint.h>\n#include \"fujinet-fuji.h\"\n\n%s\n{\n", $0)
34+
if ($1 == "bool") {
35+
printf("\treturn true;\n}\n")
36+
} else if ($1 == "void") {
37+
printf("}\n")
38+
} else {
39+
printf("\treturn 0;\n}\n")
40+
}
41+
}' > $NEW_PLATFORM/src/fn_fuji/${FILE_NAME}; done
42+
```
43+
44+
## network
45+
46+
```shell
47+
grep '^[buiv].*(' fujinet-network.h | while read f; do FILE_NAME=$(echo $f | cut -d\( -f1 | awk '{print $2}').cpp; echo $f | awk '{
48+
LINE=gsub(/;/, "")
49+
printf("#include <stdbool.h>\n#include <stdint.h>\n#include \"fujinet-network.h\"\n\n%s\n{\n", $0)
50+
if ($1 == "bool") {
51+
printf("\treturn true;\n}\n")
52+
} else if ($1 == "void") {
53+
printf("}\n")
54+
} else {
55+
printf("\treturn 0;\n}\n")
56+
}
57+
}' > $NEW_PLATFORM/src/fn_network/${FILE_NAME}; done
58+
```

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# - recursive dirs for src
44
# - final files go into build/ directory instead of root folder (e.g. lbl, com file etc)
55

6-
TARGETS := atari apple2
6+
TARGETS := atari apple2 commodore
77
PROGRAM := fujinet.lib
88
LIBS :=
99
CONFIG :=

apple2/src/fn_fuji/fuji_get_host_slots.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
bool fuji_get_host_slots(HostSlot *h, size_t size)
99
{
10-
sp_error = sp_get_fuji_id();
10+
sp_error = sp_get_fuji_id();
1111
if (sp_error <= 0) {
1212
return false;
1313
}
1414

1515
sp_error = sp_status(sp_fuji_id, 0xF4);
16-
if (sp_error == 0) {
16+
if (sp_error == 0) {
1717
if (sp_count != sizeof(HostSlot) * size) {
1818
// didn't receive the correct amount of data for array we are filling
1919
sp_error = SP_ERR_IO_ERROR;
2020
return false;
2121
}
22-
memcpy(h, &sp_payload[0], sp_count);
23-
}
22+
memcpy(h, &sp_payload[0], sp_count);
23+
}
2424
return sp_error == 0;
2525

2626
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include "fujinet-fuji.h"
4+
5+
uint8_t fuji_appkey_open(AppKeyOpen *buffer)
6+
{
7+
return 0;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include "fujinet-fuji.h"
4+
5+
uint8_t fuji_appkey_read(AppKeyRead *buffer)
6+
{
7+
return 0;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include "fujinet-fuji.h"
4+
5+
uint8_t fuji_appkey_write(uint16_t count, AppKeyWrite *buffer)
6+
{
7+
return 0;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include "fujinet-fuji.h"
4+
5+
uint8_t fuji_base64_decode_compute()
6+
{
7+
return 0;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include "fujinet-fuji.h"
4+
5+
uint8_t fuji_base64_decode_input(char *s, uint16_t len)
6+
{
7+
return 0;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include "fujinet-fuji.h"
4+
5+
uint8_t fuji_base64_decode_length(unsigned long *len)
6+
{
7+
return 0;
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdbool.h>
2+
#include <stdint.h>
3+
#include "fujinet-fuji.h"
4+
5+
uint8_t fuji_base64_decode_output(char *s, uint16_t len)
6+
{
7+
return 0;
8+
}

0 commit comments

Comments
 (0)