Skip to content

Commit e294d91

Browse files
committed
(2.1.4) Fix network_json_query on a2 to remove cr/lf/9b as last char
Also reduce sp_payload to 512 from 1024, I don't think anything uses more than that, might bite me on the arse, so see you in the future!
1 parent 3a38805 commit e294d91

File tree

14 files changed

+113
-89
lines changed

14 files changed

+113
-89
lines changed

Changelog.md

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

33
## [Unreleased]
44

5+
## [2.1.4] - 2024-01-06
6+
7+
### Fixed
8+
9+
- [apple2] network_json_query removes any trailing CR/LF/0x9b in results as last character
10+
11+
### Changed
12+
13+
- [apple2] reduced payload memory from 1024 to 512.
14+
515
## [2.1.3] - 2024-01-03
616

717
### Changed

apple2/src/fn_fuji/inc/sp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020
#define SP_ERR_NON_FATAL50 (0x50) // ; DEVICE SPECIFIC WARNING
2121
#define SP_ERR_NON_FATAL7F (0x7F) // ; DEVICE SPECIFIC WARNING
2222

23+
#define SP_PAYLOAD_SIZE (512)
24+
2325
#endif /* SP_H */

apple2/src/fn_fuji/inc/sp.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ SP_ERR_DEV_SPECF := $3F
3131
; SP_ERR_RESERVED $40-$4F
3232
SP_ERR_NON_FATAL50 := $50
3333
SP_ERR_NON_FATAL7F := $7F
34+
35+
SP_PAYLOAD_SIZE := 512

apple2/src/fn_fuji/sp_clr_payload.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
.import pushax
66

77
.include "macros.inc"
8+
.include "sp.inc"
89

910
; void sp_clr_payload();
1011

1112
.proc _sp_clr_payload
1213
pushax #_sp_payload
13-
setax #$400
14+
setax #SP_PAYLOAD_SIZE
1415
jmp _bzero
1516
.endproc

apple2/src/fn_fuji/sp_data.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
.export _sp_is_init
77
.export _sp_payload
88

9+
.include "sp.inc"
10+
911
.data
1012
; has the init routine been run?
1113
_sp_is_init: .byte 0
1214

13-
1415
.bss
1516

1617
_sp_dest: .res 1
@@ -19,5 +20,4 @@ _sp_count: .res 2
1920
_sp_dispatch_fn: .res 2
2021
_sp_cmdlist: .res 10
2122

22-
; can this be reduced in size? not sure much more than 512 is used in library
23-
_sp_payload: .res 1024
23+
_sp_payload: .res SP_PAYLOAD_SIZE

apple2/src/fn_fuji/sp_find_device.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
.proc _sp_find_device
2121
axinto ptr1 ; the device name we're looking for
2222

23-
; find the device count - do we need to keep doing this?
23+
; find the device count by sending 0/0 status request
2424
pusha #$00 ; doubles up as both parameters
2525
jsr _sp_status
2626
beq :+

apple2/src/fn_fuji/sp_init.s

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@
6363

6464
@found_sp:
6565
; set _sp_dispatch_fn address while we have the correct slot in ptr1
66+
; first copy it into ptr2, as we need to keep the original ptr1 for next loop if this card fails.
67+
mwa ptr1, ptr2
6668
ldy #$ff
67-
lda (ptr1), y ; _sp_dispatch vector is this value +3
69+
lda (ptr2), y ; _sp_dispatch vector is this value +3
6870
clc
6971
adc #$03
70-
adw1 ptr1, a ; move ptr1 to _sp_dispatch address, and store it
71-
mwa ptr1, _sp_dispatch_fn
72+
adw1 ptr2, a ; move ptr1 to _sp_dispatch address, and store it
73+
mwa ptr2, _sp_dispatch_fn
7274

7375
; does this device have a NETWORK adapter?
74-
; first save X which is the slot ID
76+
; first save X which is our counter for number of devices tested so far
7577
txa
7678
pha
7779

apple2/src/fn_io/fn_io_base64_encode_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ uint8_t fn_io_base64_encode_input(char *s, uint16_t len)
1111
// 0,1 : length
1212
// 2+ : string
1313

14-
if (len > MAX_SP_PAYLOAD) return 1;
14+
if (len > MAX_DATA_LEN) return 1;
1515
strncpy(sp_payload, s, len);
1616
return sp_control(0, 0xD0);
1717

apple2/src/fn_network/network_json_query.s

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
.import _fn_device_error
55
.import _fn_error
66
.import _memcpy
7-
.import _sp_clr_payload
87
.import _sp_control
98
.import _sp_network
109
.import _sp_payload
@@ -14,12 +13,14 @@
1413
.import _strncpy
1514
.import incsp2
1615
.import incsp4
17-
.import popa
1816
.import popax
1917
.import pusha
2018
.import pushax
2119
.import return0
2220

21+
; .import _sp_clr_payload
22+
; .import _hd
23+
2324
.include "sp.inc"
2425
.include "macros.inc"
2526
.include "zp.inc"
@@ -29,7 +30,7 @@
2930
.proc _network_json_query
3031
axinto tmp5 ; save string output location
3132

32-
jsr _sp_clr_payload ; calls bzero, so trashes p1/2/3
33+
; jsr _sp_clr_payload ; calls bzero, so trashes p1/2/3
3334

3435
ldy #$00
3536
sty _fn_device_error
@@ -64,7 +65,7 @@
6465
setax _sp_payload ; length from payload[0..1]
6566
jsr _strncpy ; trashes ptr1-2, but we don't need ptr1 anymore, returns dest
6667

67-
;; NOT REQUIRED - we have zero'd whole of sp_payload previous to the strncpy
68+
;; NOT REQUIRED
6869
; ; add a 0 to end of query string
6970
; axinto ptr1 ; move sp_payload+2 location into ptr1
7071
; adw ptr1, _sp_payload ; increment ptr1 by length of query string
@@ -124,10 +125,46 @@ not_empty:
124125
setax ptr4 ; len
125126
jsr _memcpy ; doesn't touch ptr4.
126127

128+
; ----------------------------------------------
129+
; DEBUG hex dump the retruned string.
130+
; pushax tmp5
131+
; pushax ptr4
132+
133+
; pushax tmp5
134+
; setax ptr4 ; length
135+
; jsr _hd
136+
137+
; popax ptr4
138+
; popax tmp5
139+
; ----------------------------------------------
140+
127141
; nul terminate the string
128142
adw tmp5, ptr4 ; set tmp5 to end of string
129-
sbw1 tmp5, #$01 ; remove 1 for the 0x9b char at the end of the result
143+
sbw1 tmp5, #$01
144+
145+
; ----------------------------------------------
146+
; pushax tmp5
147+
148+
; pushax tmp5
149+
; setax #$08
150+
; jsr _hd
151+
152+
; popax tmp5
153+
; ----------------------------------------------
154+
155+
; check if last char is 9b/0d/0a, if it is not, move on 1 char before nul terminating
130156
ldy #$00
157+
lda (tmp5), y
158+
cmp #$9b
159+
beq @skip_add
160+
cmp #$0d
161+
beq @skip_add
162+
cmp #$0a
163+
beq @skip_add
164+
165+
adw1 tmp5, #$01
166+
167+
@skip_add:
131168
tya
132169
sta (tmp5), y
133170

atari/src/fn_network/network_read_asm.s

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)