|
4 | 4 | .import _fn_device_error |
5 | 5 | .import _fn_error |
6 | 6 | .import _memcpy |
7 | | - .import _sp_clr_payload |
8 | 7 | .import _sp_control |
9 | 8 | .import _sp_network |
10 | 9 | .import _sp_payload |
|
14 | 13 | .import _strncpy |
15 | 14 | .import incsp2 |
16 | 15 | .import incsp4 |
17 | | - .import popa |
18 | 16 | .import popax |
19 | 17 | .import pusha |
20 | 18 | .import pushax |
21 | 19 | .import return0 |
22 | 20 |
|
| 21 | + ; .import _sp_clr_payload |
| 22 | + ; .import _hd |
| 23 | + |
23 | 24 | .include "sp.inc" |
24 | 25 | .include "macros.inc" |
25 | 26 | .include "zp.inc" |
|
29 | 30 | .proc _network_json_query |
30 | 31 | axinto tmp5 ; save string output location |
31 | 32 |
|
32 | | - jsr _sp_clr_payload ; calls bzero, so trashes p1/2/3 |
| 33 | + ; jsr _sp_clr_payload ; calls bzero, so trashes p1/2/3 |
33 | 34 |
|
34 | 35 | ldy #$00 |
35 | 36 | sty _fn_device_error |
|
64 | 65 | setax _sp_payload ; length from payload[0..1] |
65 | 66 | jsr _strncpy ; trashes ptr1-2, but we don't need ptr1 anymore, returns dest |
66 | 67 |
|
67 | | - ;; NOT REQUIRED - we have zero'd whole of sp_payload previous to the strncpy |
| 68 | + ;; NOT REQUIRED |
68 | 69 | ; ; add a 0 to end of query string |
69 | 70 | ; axinto ptr1 ; move sp_payload+2 location into ptr1 |
70 | 71 | ; adw ptr1, _sp_payload ; increment ptr1 by length of query string |
@@ -124,10 +125,46 @@ not_empty: |
124 | 125 | setax ptr4 ; len |
125 | 126 | jsr _memcpy ; doesn't touch ptr4. |
126 | 127 |
|
| 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 | + |
127 | 141 | ; nul terminate the string |
128 | 142 | 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 |
130 | 156 | 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: |
131 | 168 | tya |
132 | 169 | sta (tmp5), y |
133 | 170 |
|
|
0 commit comments