Skip to content

Commit

Permalink
[4.0.0] Make all functions return sucess status
Browse files Browse the repository at this point in the history
This is a breaking change for appkeys and hashing functions, hence version bump.
  • Loading branch information
markjfisher committed May 6, 2024
1 parent f1d3210 commit 8eefe43
Show file tree
Hide file tree
Showing 43 changed files with 117 additions and 99 deletions.
8 changes: 8 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## [Unreleased]

## [4.0.0] - 2024-05-06

Breaking Changes

- [appkey] Update signature of appkey functions to return bool instead of uint8_t
- [appkey] Change return values of appkey to indicate SUCCESS status to be consistent with other functions
- [hashing] All hashing/base64 functions have been updated similarly to return bool status of success instead of error

## [3.0.4] - 2024-05-05

- [apple2] Add appkey support (thanks Eric Carr)
Expand Down
3 changes: 2 additions & 1 deletion apple2/src/fn_fuji/fuji_appkey_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include "fujinet-fuji.h"
#include "fujinet-bus-apple2.h"

uint8_t fuji_appkey_open(AppKeyOpen *buffer)
// Open app-key, returns error status
bool fuji_appkey_open(AppKeyOpen *buffer)
{
sp_error = sp_get_fuji_id();
if (sp_error <= 0) {
Expand Down
3 changes: 2 additions & 1 deletion apple2/src/fn_fuji/fuji_appkey_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#include "fujinet-fuji.h"
#include "fujinet-bus-apple2.h"

uint8_t fuji_appkey_read(AppKeyRead *buffer)
// reads the app-key, returns error status
bool fuji_appkey_read(AppKeyRead *buffer)
{
sp_error = sp_get_fuji_id();
if (sp_error <= 0) {
Expand Down
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_appkey_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "fujinet-bus-apple2.h"
#include <string.h>

uint8_t fuji_appkey_write(uint16_t count, AppKeyWrite *buffer)
// writes app-key, returns error status
bool fuji_appkey_write(uint16_t count, AppKeyWrite *buffer)
{
sp_error = sp_get_fuji_id();

if (sp_error <= 0) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_base64_decode_compute.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_base64_decode_compute()
bool fuji_base64_decode_compute()
{
return 1;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_base64_decode_input.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_base64_decode_input(char *s, uint16_t len)
bool fuji_base64_decode_input(char *s, uint16_t len)
{
return 1;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_base64_decode_length.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_base64_decode_length(unsigned long *len)
bool fuji_base64_decode_length(unsigned long *len)
{
return 1;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_base64_decode_output.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_base64_decode_output(char *s, uint16_t len)
bool fuji_base64_decode_output(char *s, uint16_t len)
{
return 1;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_base64_encode_compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "fujinet-fuji.h"
#include "fujinet-bus-apple2.h"

uint8_t fuji_base64_encode_compute()
bool fuji_base64_encode_compute()
{
// send CTRL command: 0xCF
// PAYLOAD: N/A

return sp_control(0, 0xCF);
return sp_control(0, 0xCF) == 0;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_base64_encode_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "fujinet-fuji.h"
#include "fujinet-bus-apple2.h"

uint8_t fuji_base64_encode_input(char *s, uint16_t len)
bool fuji_base64_encode_input(char *s, uint16_t len)
{
// send CTRL command: 0xD0
// PAYLOAD:
Expand All @@ -13,6 +13,6 @@ uint8_t fuji_base64_encode_input(char *s, uint16_t len)

if (len > MAX_DATA_LEN) return 1;
strncpy(sp_payload, s, len);
return sp_control(0, 0xD0);
return sp_control(0, 0xD0) == 0;

}
12 changes: 2 additions & 10 deletions apple2/src/fn_fuji/fuji_base64_encode_length.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
#include "fujinet-fuji.h"
#include "fujinet-bus-apple2.h"

uint8_t fuji_base64_encode_length(unsigned long *len)
bool fuji_base64_encode_length(unsigned long *len)
{
// send STATUS command: 0xCE
// Return has length in first 2 bytes of payload

// TODO: how do we detect an error status coming back rather than data returned?

uint16_t length = sp_payload[0] | (sp_payload[1] << 8);
*len = length;

return 0;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_base64_encode_output.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_base64_encode_output(char *s, uint16_t len)
bool fuji_base64_encode_output(char *s, uint16_t len)
{
return 1;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_hash_compute.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_hash_compute(uint8_t type)
bool fuji_hash_compute(uint8_t type)
{
return 0;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_hash_input.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_hash_input(char *s, uint16_t len)
bool fuji_hash_input(char *s, uint16_t len)
{
return 0;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_hash_length.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_hash_length(uint8_t mode)
bool fuji_hash_length(uint8_t mode)
{
return 0;
return true;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_fuji/fuji_hash_output.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-fuji.h"

uint8_t fuji_hash_output(uint8_t output_type, char *s, uint16_t len)
bool fuji_hash_output(uint8_t output_type, char *s, uint16_t len)
{
return 0;
return true;
}
8 changes: 4 additions & 4 deletions atari/src/fn_fuji/fuji_appkey_open_read.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.export _fuji_appkey_read

.import _bus
.import _fuji_error
.import _fuji_success
.import copy_fuji_cmd_data
.import popa, popax

Expand All @@ -11,7 +11,7 @@
.include "device.inc"
.include "fujinet-fuji.inc"

; uint8_t fuji_appkey_open(AppKeyOpen *buffer);
; bool fuji_appkey_open(AppKeyOpen *buffer);
;
_fuji_appkey_open:
axinto tmp7
Expand All @@ -23,10 +23,10 @@ ak_common:
mwa tmp7, IO_DCB::dbuflo

jsr _bus
jmp _fuji_error
jmp _fuji_success


; uint8_t fuji_appkey_read(AppKeyRead *buffer);
; bool fuji_appkey_read(AppKeyRead *buffer);
;
_fuji_appkey_read:
axinto tmp7 ; buffer location
Expand Down
7 changes: 4 additions & 3 deletions atari/src/fn_fuji/fuji_appkey_write.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.export _fuji_appkey_write

.import _bus
.import _fuji_error
.import _fuji_success
.import copy_fuji_cmd_data
.import popa, popax

Expand All @@ -10,8 +10,9 @@
.include "device.inc"
.include "fujinet-fuji.inc"

; uint8_t fuji_appkey_write(uint16_t count, AppKeyWrite *buffer);
; bool fuji_appkey_write(uint16_t count, AppKeyWrite *buffer);
;
; NOTE: in other implementations there's a check to keep count maxed at 64 bytes
.proc _fuji_appkey_write
axinto tmp7 ; save buffer address

Expand All @@ -24,7 +25,7 @@
stx IO_DCB::daux2

jsr _bus
jmp _fuji_error
jmp _fuji_success
.endproc

.rodata
Expand Down
8 changes: 4 additions & 4 deletions atari/src/fn_fuji/fuji_base64_xxcode_compute.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

.import copy_fuji_cmd_data
.import _bus
.import _fuji_error
.import _fuji_success
.import popa, popax

.include "zp.inc"
.include "macros.inc"
.include "device.inc"

; uint8_t fuji_base64_decode_compute();
; bool fuji_base64_decode_compute();
;
_fuji_base64_decode_compute:
setax #t_fuji_base64_decode_compute
Expand All @@ -19,9 +19,9 @@ c_common:
jsr copy_fuji_cmd_data
mva #$03, IO_DCB::dtimlo
jsr _bus
jmp _fuji_error
jmp _fuji_success

; uint8_t fuji_base64_encode_compute();
; bool fuji_base64_encode_compute();
;
_fuji_base64_encode_compute:
setax #t_fuji_base64_encode_compute
Expand Down
8 changes: 4 additions & 4 deletions atari/src/fn_fuji/fuji_base64_xxcode_io.s
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
.include "macros.inc"
.include "device.inc"

; uint8_t fuji_base64_decode_input(char *s, uint16_t len);
; bool fuji_base64_decode_input(char *s, uint16_t len);
;
_fuji_base64_decode_input:
axinto tmp7 ; len in tmp7/8
setax #t_fuji_base64_decode_input
jmp io_common

; uint8_t fuji_base64_decode_output(char *s, uint16_t len);
; bool fuji_base64_decode_output(char *s, uint16_t len);
;
_fuji_base64_decode_output:
axinto tmp7 ; len in tmp7/8
setax #t_fuji_base64_decode_output
jmp io_common

; uint8_t fuji_base64_encode_input(char *s, uint16_t len);
; bool fuji_base64_encode_input(char *s, uint16_t len);
;
_fuji_base64_encode_input:
axinto tmp7 ; len in tmp7/8
setax #t_fuji_base64_encode_input
jmp io_common

; uint8_t fuji_base64_encode_output(char *s, uint16_t len);
; bool fuji_base64_encode_output(char *s, uint16_t len);
;
_fuji_base64_encode_output:
axinto tmp7 ; len in tmp7/8
Expand Down
8 changes: 4 additions & 4 deletions atari/src/fn_fuji/fuji_base64_xxcode_length.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

.import copy_fuji_cmd_data
.import _bus
.import _fuji_error
.import _fuji_success
.import popa, popax

.include "zp.inc"
.include "macros.inc"
.include "device.inc"

; uint8_t fuji_base64_decode_length(unsigned long *len);
; bool fuji_base64_decode_length(unsigned long *len);
;
_fuji_base64_decode_length:
axinto tmp7 ; pointer to len in tmp7/8
Expand All @@ -22,9 +22,9 @@ de_common:
mwa tmp7, IO_DCB::dbuflo
mva #$03, IO_DCB::dtimlo
jsr _bus
jmp _fuji_error
jmp _fuji_success

; uint8_t fuji_base64_encode_length(unsigned long *len);
; bool fuji_base64_encode_length(unsigned long *len);
;
_fuji_base64_encode_length:
axinto tmp7 ; pointer to len in tmp7/8
Expand Down
4 changes: 2 additions & 2 deletions atari/src/fn_fuji/fuji_crypto_common.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.export io_common

.import _bus
.import _fuji_error
.import _fuji_success
.import copy_fuji_cmd_data
.import popax

Expand All @@ -24,5 +24,5 @@
stx IO_DCB::dbufhi

jsr _bus
jmp _fuji_error
jmp _fuji_success
.endproc
6 changes: 3 additions & 3 deletions atari/src/fn_fuji/fuji_hash_compute.s
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.export _fuji_hash_compute

.import _bus
.import _fuji_error
.import _fuji_success
.import copy_fuji_cmd_data
.import popa, popax

.include "zp.inc"
.include "macros.inc"
.include "device.inc"

; uint8_t fuji_hash_compute(uint8_t type);
; bool fuji_hash_compute(uint8_t type);
;
.proc _fuji_hash_compute
sta tmp7 ; hash type, one of HashType. No validation done though
Expand All @@ -20,7 +20,7 @@
mva tmp7, IO_DCB::daux1
mva #$03, IO_DCB::dtimlo
jsr _bus
jmp _fuji_error
jmp _fuji_success
.endproc

.rodata
Expand Down
2 changes: 1 addition & 1 deletion atari/src/fn_fuji/fuji_hash_input.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.include "zp.inc"
.include "macros.inc"

; uint8_t fuji_hash_input(char *s, uint16_t len);
; bool fuji_hash_input(char *s, uint16_t len);
;
.proc _fuji_hash_input
axinto tmp7 ; len in tmp7/8
Expand Down
Loading

0 comments on commit 8eefe43

Please sign in to comment.