Skip to content

Commit b030b8b

Browse files
committed
commodore implementation start
1 parent 565db86 commit b030b8b

Some content is hidden

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

62 files changed

+347
-69
lines changed

.gitignore

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,9 @@
1-
# Prerequisites
2-
*.d
3-
4-
# Object files
5-
*.o
6-
*.ko
7-
*.obj
8-
*.elf
9-
10-
# Linker output
11-
*.ilk
12-
*.map
13-
*.exp
14-
15-
# Precompiled Headers
16-
*.gch
17-
*.pch
18-
19-
# Libraries
20-
*.lib
21-
*.a
22-
*.la
23-
*.lo
24-
25-
# Shared objects (inc. Windows DLLs)
26-
*.dll
27-
*.so
28-
*.so.*
29-
*.dylib
30-
31-
# Executables
32-
*.exe
33-
*.out
34-
*.app
35-
*.i*86
36-
*.x86_64
37-
*.hex
38-
*.xex
39-
40-
# Debug files
41-
*.dSYM/
42-
*.su
43-
*.idb
44-
*.pdb
45-
46-
# Kernel Module Compile Results
47-
*.mod*
48-
*.cmd
49-
.tmp_versions/
50-
modules.order
51-
Module.symvers
52-
Mkfile.old
53-
dkms.conf
54-
551
# generated files
562
dist/
573
obj/
584
build/
595

606
# IDE files
61-
.vscode/
7+
.vscode/
8+
9+
Makefile.options

Changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## [Unreleased]
44

5+
## [4.2.0] - 2024-XX-YY
6+
7+
- Implement commodore fujinet-lib functions
8+
9+
- Add fuji_open_directory2 prototype for applications to send path and
10+
filter separately rather than in fixed 256 byte buffer with \0 delimiter. Used by CBM.
11+
512
## [4.1.2] - 2024-05-20
613

714
Bugfix:

Makefile

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
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 apple2enh c64
6+
#TARGETS := atari apple2 apple2enh c64
7+
TARGETS := c64
78
PROGRAM := fujinet.lib
89
LIBS :=
910
CONFIG :=
@@ -103,11 +104,36 @@ FN_NW_INC = fujinet-network.inc
103104
FN_FUJI_HEADER = fujinet-fuji.h
104105
FN_FUJI_INC = fujinet-fuji.inc
105106

107+
define _listing_
108+
CFLAGS += --listing $$(@:.o=.lst)
109+
ASFLAGS += --listing $$(@:.o=.lst)
110+
endef
111+
112+
define _mapfile_
113+
LDFLAGS += --mapfile $$@.map
114+
endef
115+
116+
define _labelfile_
117+
LDFLAGS += -Ln $$@.lbl
118+
endef
119+
106120
.SUFFIXES:
107121
.PHONY: all clean dist fujinet.lib.$(TARGETLIST)
108122

109123
all: fujinet.lib.$(TARGETLIST)
110124

125+
STATEFILE := Makefile.options
126+
-include $(DEPENDS)
127+
-include $(STATEFILE)
128+
129+
ifeq ($(origin _OPTIONS_),file)
130+
OPTIONS = $(_OPTIONS_)
131+
$(eval $(OBJECTS): $(STATEFILE))
132+
endif
133+
134+
# Transform the abstract OPTIONS to the actual cc65 options.
135+
$(foreach o,$(subst $(COMMA),$(SPACE),$(OPTIONS)),$(eval $(_$o_)))
136+
111137
$(OBJDIR):
112138
$(call MKDIR,$@)
113139

apple2/src/fn_fuji/fuji_close_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "fujinet-fuji.h"
33
#include "fujinet-bus-apple2.h"
44

5-
bool fuji_close_directory(void)
5+
bool fuji_close_directory()
66
{
77
if (sp_get_fuji_id() == 0) {
88
return false;

commodore/src/bus/fuji_cbm_open.s

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.export _fuji_cbm_open
2+
3+
.import _cbm_k_open
4+
.import _cbm_k_setlfs
5+
.import popa
6+
.import ___oserror
7+
8+
.include "cbm_kernal.inc"
9+
.include "macros.inc"
10+
.include "zp.inc"
11+
12+
; A replacement for cbm_open that takes parameters for location of the data to send to SETNAM and the size
13+
; instead of computing it, which allows us to send binary data as part of the NAME field to pass parameters to FN.
14+
15+
; uint8_t __fastcall__ fuji_cbm_open(
16+
; uint8_t lfn,
17+
; uint8_t device,
18+
; uint8_t sec_addr,
19+
; uint8_t len,
20+
; uint8_t* name
21+
; );
22+
23+
_fuji_cbm_open:
24+
stx tmp1 ; save high byte of name address
25+
tax ; X = ADDR LOW
26+
jsr popa ; A = LEN (leaves X alone)
27+
ldy tmp1 ; Y = ADDR HIGH
28+
jsr SETNAM
29+
30+
jsr popa ; A = SA
31+
jsr _cbm_k_setlfs ; Call SETLFS, pops DEV and LFN
32+
33+
jsr _cbm_k_open ; Call OPEN
34+
sta ___oserror
35+
rts
Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,49 @@
11
#include <stdbool.h>
22
#include <stdint.h>
33
#include "fujinet-fuji.h"
4+
#include "fujinet-fuji-cbm.h"
5+
6+
extern uint16_t ak_creator_id;
7+
extern uint8_t ak_app_id;
8+
extern enum AppKeySize ak_appkey_size;
49

510
bool fuji_read_appkey(uint8_t key_id, uint16_t *count, uint8_t *data)
611
{
7-
return true;
12+
uint8_t mode = 0;
13+
uint16_t buffer_size = 64;
14+
int bytes_read;
15+
uint8_t pl[7];
16+
17+
if (ak_creator_id == 0) {
18+
return false;
19+
}
20+
21+
pl[0] = 0xDC;
22+
pl[1] = ak_creator_id & 0xFF;
23+
pl[2] = ak_creator_id >> 8;
24+
pl[3] = ak_app_id;
25+
pl[4] = key_id;
26+
pl[5] = mode;
27+
pl[6] = 0;
28+
29+
// send the creator / app / mode values
30+
if (fuji_cbm_open(FUJI_CMD_CHANNEL, FUJI_CBM_DEV, FUJI_CMD_CHANNEL, sizeof(pl), (uint8_t *) pl) != 0) {
31+
return false;
32+
}
33+
cbm_close(FUJI_CMD_CHANNEL);
34+
35+
// now do a read of the key
36+
pl[0] = 0xDD;
37+
if (fuji_cbm_open(FUJI_CMD_CHANNEL, FUJI_CBM_DEV, FUJI_CMD_CHANNEL, 1, (uint8_t *) pl) != 0) {
38+
return false;
39+
}
40+
41+
bytes_read = cbm_read(FUJI_CMD_CHANNEL, data, buffer_size);
42+
if (bytes_read <= 0) {
43+
*count = 0;
44+
} else {
45+
*count = bytes_read;
46+
}
47+
cbm_close(FUJI_CMD_CHANNEL);
48+
return bytes_read > 0;
849
}
Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,53 @@
11
#include <stdbool.h>
22
#include <stdint.h>
3+
#include <stdlib.h>
4+
#include <string.h>
35
#include "fujinet-fuji.h"
6+
#include "fujinet-fuji-cbm.h"
7+
8+
extern uint16_t ak_creator_id;
9+
extern uint8_t ak_app_id;
10+
extern enum AppKeySize ak_appkey_size;
411

512
bool fuji_write_appkey(uint8_t key_id, uint16_t count, uint8_t *data)
613
{
7-
return true;
14+
uint8_t err = 0;
15+
uint8_t mode = 0;
16+
uint8_t pl[7];
17+
uint8_t *out_data;
18+
uint16_t data_size = count + 1; // cmd (1 byte) + data length
19+
20+
if (ak_creator_id == 0) {
21+
return false;
22+
}
23+
24+
pl[0] = 0xDC;
25+
pl[1] = ak_creator_id & 0xFF;
26+
pl[2] = ak_creator_id >> 8;
27+
pl[3] = ak_app_id;
28+
pl[4] = key_id;
29+
pl[5] = 0x01; // WRITE mode
30+
pl[6] = 0; // reserved
31+
32+
// send the creator / app / mode values
33+
if (fuji_cbm_open(FUJI_CMD_CHANNEL, FUJI_CBM_DEV, FUJI_CMD_CHANNEL, sizeof(pl), (uint8_t *) pl) != 0) {
34+
return false;
35+
}
36+
cbm_close(FUJI_CMD_CHANNEL);
37+
38+
out_data = malloc(data_size);
39+
memset(out_data, 0, data_size);
40+
41+
// now do a write of the key data, on IEC we don't need to send the count, as the write doesn't have to be a fixed size
42+
out_data[0] = 0xDE;
43+
memcpy(&out_data[1], data, count);
44+
45+
err = fuji_cbm_open(FUJI_CMD_CHANNEL, FUJI_CBM_DEV, FUJI_CMD_CHANNEL, data_size, out_data);
46+
free(out_data);
47+
if (err == 0) {
48+
cbm_close(FUJI_CMD_CHANNEL);
49+
return true;
50+
}
51+
return false;
52+
853
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
#include <stdbool.h>
22
#include <stdint.h>
33
#include "fujinet-fuji.h"
4+
#include "fujinet-fuji-cbm.h"
45

56
bool fuji_close_directory()
67
{
8+
uint8_t pl[1];
9+
pl[0] = 0xF5;
10+
11+
if (fuji_cbm_open(FUJI_CMD_CHANNEL, FUJI_CBM_DEV, FUJI_CMD_CHANNEL, 1, (uint8_t *) pl) != 0) {
12+
return false;
13+
}
14+
cbm_close(FUJI_CMD_CHANNEL);
715
return true;
816
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
#include <stdbool.h>
22
#include <stdint.h>
33
#include "fujinet-fuji.h"
4+
#include "fujinet-fuji-cbm.h"
45

56
bool fuji_get_scan_result(uint8_t n, SSIDInfo *ssid_info)
67
{
7-
return true;
8+
int bytes_read;
9+
uint8_t pl[3];
10+
pl[0] = 0xFC;
11+
pl[1] = n;
12+
pl[2] = 0x00;
13+
14+
if (fuji_cbm_open(FUJI_CMD_CHANNEL, FUJI_CBM_DEV, FUJI_CMD_CHANNEL, 3, (uint8_t *) pl) != 0) {
15+
return false;
16+
}
17+
18+
bytes_read = cbm_read(FUJI_CMD_CHANNEL, ssid_info, sizeof(SSIDInfo));
19+
cbm_close(FUJI_CMD_CHANNEL);
20+
return bytes_read > 0;
821
}
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
#include <stdbool.h>
22
#include <stdint.h>
33
#include "fujinet-fuji.h"
4+
#include "fujinet-fuji-cbm.h"
45

56
bool fuji_get_ssid(NetConfig *net_config)
67
{
7-
return true;
8+
int bytes_read;
9+
uint8_t pl[1];
10+
pl[0] = 0xFE;
11+
12+
if (fuji_cbm_open(FUJI_CMD_CHANNEL, FUJI_CBM_DEV, FUJI_CMD_CHANNEL, 1, (uint8_t *) pl) != 0) {
13+
return false;
14+
}
15+
16+
bytes_read = cbm_read(FUJI_CMD_CHANNEL, net_config, sizeof(NetConfig));
17+
cbm_close(FUJI_CMD_CHANNEL);
18+
return bytes_read > 0;
819
}

0 commit comments

Comments
 (0)