Renamed

Dependencies:   mbed

Committer:
ffxx68
Date:
Fri Feb 18 11:07:34 2022 +0000
Revision:
1:9289febf4ae9
Parent:
0:07819bc70660
Child:
2:dff96be9617e
Changed repo name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ffxx68 0:07819bc70660 1 #include "send_pc1403.h"
ffxx68 0:07819bc70660 2 #include "bit_send.h"
ffxx68 0:07819bc70660 3
ffxx68 0:07819bc70660 4 ///////////////////////////////////////////////////////
ffxx68 0:07819bc70660 5 // variables from PocketTools code
ffxx68 0:07819bc70660 6 uint SHCc = 0 , /* Read not from bin, but from Transfile PC plus SHC-format (header included) */
ffxx68 0:07819bc70660 7 SHCe = 0 ; /* End marks are the SHC Basic image included only*/
ffxx68 0:07819bc70660 8 uint QTc = 0 ; /* Write to Quick-Tape wave format */
ffxx68 0:07819bc70660 9 uint STc = 0 ; /* Header of SuperTape or file header of PC-1600 format is in the image included */
ffxx68 0:07819bc70660 10 uint TAPc = 0 ; /* Write not to wave format but to emulator tap format (raw bytes)*/
ffxx68 0:07819bc70660 11 uint Qcnt = 0 ; /* Quiet, minimal output */
ffxx68 0:07819bc70660 12 uint Scnt = 0 ; /* Number of sync parameters or sync and sync spaces was defined */
ffxx68 0:07819bc70660 13 uint Acnt = 0 ; /* Number of address parameters, non standard load or entry addresses */
ffxx68 0:07819bc70660 14 uint Mcnt = 0 ; /* Read header parameter from a file */
ffxx68 0:07819bc70660 15
ffxx68 0:07819bc70660 16 double speed = 1.00 ; /* Used it for modified Pocket Computer with a CPU Speed Up switched on */
ffxx68 0:07819bc70660 17
ffxx68 0:07819bc70660 18 ulong pcId = 1500 ; /* ID number of the pocket computer */
ffxx68 0:07819bc70660 19 ushort pcgrpId = IDENT_UNKNOWN ;
ffxx68 0:07819bc70660 20 // ulong pcAddr = 0 ; /* PC-specific address, used for the end of variable data of PCs with DB-tables */
ffxx68 0:07819bc70660 21 bool cnvstr_upr = false ; /* Convert strings to upper, for Pokecon with SML-key not */
ffxx68 0:07819bc70660 22 bool type_asm = false ; /* Image contains assembler source code (subtype), true for CASL and CAP-X */
ffxx68 0:07819bc70660 23 // TODO (mr#2#): Count all warnings and errors
ffxx68 0:07819bc70660 24 ulong err_cnt = 0 ; /* counts minor errors */
ffxx68 0:07819bc70660 25 ulong wrn_cnt = 0 ; /* counts warnings */
ffxx68 0:07819bc70660 26
ffxx68 0:07819bc70660 27 ////////////////////////////////////////////////////////////////////////////////
ffxx68 0:07819bc70660 28 // WriteBitToWav replaced from PocketTools version (writing to a WAV file)
ffxx68 0:07819bc70660 29 // Here we send directly signals to OUT lines
ffxx68 0:07819bc70660 30 int WriteBitToWav (int value,
ffxx68 0:07819bc70660 31 FileInfo* ptrFile)
ffxx68 0:07819bc70660 32 {
ffxx68 1:9289febf4ae9 33 // Calling the buffered bit-sending routine
ffxx68 1:9289febf4ae9 34 switch ( value ) {
ffxx68 1:9289febf4ae9 35 case 1:
ffxx68 1:9289febf4ae9 36 if ( bitWaitSend ( value, 0 ) > MAX_BIT_TIME_ERR )
ffxx68 1:9289febf4ae9 37 return ( ERR_NOK ) ;
ffxx68 1:9289febf4ae9 38 break;
ffxx68 1:9289febf4ae9 39 case 0:
ffxx68 1:9289febf4ae9 40 if ( bitWaitSend ( value, 0 ) > MAX_BIT_TIME_ERR )
ffxx68 1:9289febf4ae9 41 return ( ERR_NOK ) ;
ffxx68 1:9289febf4ae9 42 break;
ffxx68 1:9289febf4ae9 43 default:
ffxx68 1:9289febf4ae9 44 break;
ffxx68 1:9289febf4ae9 45 }
ffxx68 1:9289febf4ae9 46
ffxx68 1:9289febf4ae9 47 return ( ERR_OK ) ;
ffxx68 0:07819bc70660 48 }
ffxx68 0:07819bc70660 49
ffxx68 0:07819bc70660 50 ////////////////////////////////////////////////////////////////////////////////
ffxx68 0:07819bc70660 51 // Write* methods taken from Pocket-Tools source code
ffxx68 0:07819bc70660 52 // https://www.peil-partner.de/ifhe.de/sharp/
ffxx68 0:07819bc70660 53 int WriteQuaterToWav (uint value,
ffxx68 0:07819bc70660 54 uint stopBits,
ffxx68 0:07819bc70660 55 FileInfo* ptrFile)
ffxx68 0:07819bc70660 56 {
ffxx68 0:07819bc70660 57 uint tmp ;
ffxx68 0:07819bc70660 58 uint ii ;
ffxx68 0:07819bc70660 59 int error ;
ffxx68 0:07819bc70660 60
ffxx68 0:07819bc70660 61 // if (TAPc > 0) return (WriteQuaterToTap (value, ptrFile)); // no
ffxx68 1:9289febf4ae9 62
ffxx68 0:07819bc70660 63 do {
ffxx68 1:9289febf4ae9 64
ffxx68 0:07819bc70660 65 error = WriteBitToWav (0, ptrFile) ;
ffxx68 0:07819bc70660 66 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 67
ffxx68 0:07819bc70660 68 for ( ii = 0 ; ii < 4 ; ++ii ) {
ffxx68 0:07819bc70660 69 tmp = 1 << ii ;
ffxx68 0:07819bc70660 70 if ( (value & tmp) == 0 )
ffxx68 0:07819bc70660 71 error = WriteBitToWav (0, ptrFile) ;
ffxx68 0:07819bc70660 72 else
ffxx68 0:07819bc70660 73 error = WriteBitToWav (1, ptrFile) ;
ffxx68 0:07819bc70660 74
ffxx68 0:07819bc70660 75 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 76 }
ffxx68 0:07819bc70660 77 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 78
ffxx68 0:07819bc70660 79 for ( ii = 0 ; ii < stopBits ; ++ii ) {
ffxx68 0:07819bc70660 80 error = WriteBitToWav (1, ptrFile) ;
ffxx68 0:07819bc70660 81 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 82 }
ffxx68 0:07819bc70660 83 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 84
ffxx68 0:07819bc70660 85 } while (0) ;
ffxx68 0:07819bc70660 86 return (error);
ffxx68 0:07819bc70660 87 }
ffxx68 0:07819bc70660 88
ffxx68 0:07819bc70660 89 int WriteByteToWav (ulong value,
ffxx68 0:07819bc70660 90 uchar order,
ffxx68 0:07819bc70660 91 uchar mode,
ffxx68 0:07819bc70660 92 FileInfo* ptrFile)
ffxx68 0:07819bc70660 93 {
ffxx68 0:07819bc70660 94 uint lsq ;
ffxx68 0:07819bc70660 95 uint msq ;
ffxx68 0:07819bc70660 96 int error ;
ffxx68 0:07819bc70660 97
ffxx68 0:07819bc70660 98 // if (TAPc > 0) return (WriteByteToTap (value, order, ptrFile)) ; // no
ffxx68 0:07819bc70660 99
ffxx68 0:07819bc70660 100 // if (order == ORDER_E) return (WriteByteToEWav (value, ptrFile)) ; // no 1403
ffxx68 0:07819bc70660 101
ffxx68 0:07819bc70660 102 do {
ffxx68 0:07819bc70660 103 lsq = value & 0x0F ;
ffxx68 0:07819bc70660 104 msq = (value >> 4) & 0x0F ;
ffxx68 0:07819bc70660 105 if (order == ORDER_INV) {
ffxx68 0:07819bc70660 106 error = WriteQuaterToWav (lsq, Mode[mode].stopb1, ptrFile) ;
ffxx68 0:07819bc70660 107 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 108 error = WriteQuaterToWav (msq, Mode[mode].stopb2, ptrFile) ;
ffxx68 0:07819bc70660 109 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 110 }
ffxx68 0:07819bc70660 111 else {
ffxx68 0:07819bc70660 112 error = WriteQuaterToWav (msq, Mode[mode].stopb1, ptrFile) ;
ffxx68 0:07819bc70660 113 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 114 error = WriteQuaterToWav (lsq, Mode[mode].stopb2, ptrFile) ;
ffxx68 0:07819bc70660 115 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 116 }
ffxx68 0:07819bc70660 117
ffxx68 0:07819bc70660 118 } while (0) ;
ffxx68 0:07819bc70660 119 return (error);
ffxx68 0:07819bc70660 120 }
ffxx68 0:07819bc70660 121
ffxx68 0:07819bc70660 122 int CheckSumB1 ( ulong Byte,
ffxx68 0:07819bc70660 123 FileInfo* ptrFile)
ffxx68 0:07819bc70660 124 {
ffxx68 0:07819bc70660 125 ushort sum ;
ffxx68 0:07819bc70660 126
ffxx68 0:07819bc70660 127 /* Update the checksum */
ffxx68 0:07819bc70660 128 sum = ptrFile->sum + ((Byte & 0xF0) >> 4) ;
ffxx68 0:07819bc70660 129 if (sum > 0xFF) {
ffxx68 0:07819bc70660 130 ++sum ;
ffxx68 0:07819bc70660 131 sum &= 0xFF ;
ffxx68 0:07819bc70660 132 }
ffxx68 0:07819bc70660 133 ptrFile->sum = (sum + (Byte & 0x0F)) & 0xFF ;
ffxx68 0:07819bc70660 134
ffxx68 0:07819bc70660 135 return (0);
ffxx68 0:07819bc70660 136 }
ffxx68 0:07819bc70660 137
ffxx68 0:07819bc70660 138
ffxx68 0:07819bc70660 139 int CheckSumE ( ulong Byte,
ffxx68 0:07819bc70660 140 // ulong* ptrSum )
ffxx68 0:07819bc70660 141 FileInfo* ptrFile)
ffxx68 0:07819bc70660 142 {
ffxx68 0:07819bc70660 143 uint tmp, ii ;
ffxx68 0:07819bc70660 144
ffxx68 0:07819bc70660 145 /* Update the checksum */
ffxx68 0:07819bc70660 146 tmp = 0x80 ;
ffxx68 0:07819bc70660 147 for ( ii = 0 ; ii < 8 ; ++ii, tmp >>= 1 )
ffxx68 0:07819bc70660 148 if ( (Byte & tmp) != 0 )
ffxx68 0:07819bc70660 149 // ++ *ptrSum ;
ffxx68 0:07819bc70660 150 ++ ptrFile->sum ;
ffxx68 0:07819bc70660 151
ffxx68 0:07819bc70660 152 return (0);
ffxx68 0:07819bc70660 153 }
ffxx68 0:07819bc70660 154
ffxx68 0:07819bc70660 155
ffxx68 0:07819bc70660 156 int WriteSyncToWav (ulong nbSync, //
ffxx68 0:07819bc70660 157 FileInfo* ptrFile)
ffxx68 0:07819bc70660 158 {
ffxx68 0:07819bc70660 159 ulong ii ;
ffxx68 0:07819bc70660 160 int error = ERR_OK ;
ffxx68 0:07819bc70660 161
ffxx68 0:07819bc70660 162 if (TAPc > 0) return (ERR_OK); // no
ffxx68 0:07819bc70660 163
ffxx68 0:07819bc70660 164 do {
ffxx68 0:07819bc70660 165 /* Write the Synchro patern */
ffxx68 0:07819bc70660 166 for ( ii = 0 ; ii < nbSync ; ++ii ) {
ffxx68 0:07819bc70660 167 error = WriteBitToWav (1, ptrFile) ;
ffxx68 0:07819bc70660 168 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 169 }
ffxx68 0:07819bc70660 170 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 171
ffxx68 0:07819bc70660 172 } while (0) ;
ffxx68 0:07819bc70660 173 return (error);
ffxx68 0:07819bc70660 174 }
ffxx68 0:07819bc70660 175
ffxx68 1:9289febf4ae9 176 int WriteUsedatLenToQTWav ( uchar order, /* Quick-Tape incomplete blocks with fill data */
ffxx68 1:9289febf4ae9 177 uchar mode,
ffxx68 1:9289febf4ae9 178 FileInfo* ptrFile)
ffxx68 1:9289febf4ae9 179 { long tmpL ;
ffxx68 1:9289febf4ae9 180 int error ;
ffxx68 1:9289febf4ae9 181
ffxx68 1:9289febf4ae9 182 tmpL = ptrFile->nbByte - ptrFile->total_diff - ptrFile->total ; //not for IDENT_QT_DAT: variable block in RAM based
ffxx68 1:9289febf4ae9 183
ffxx68 1:9289febf4ae9 184 if (tmpL > 0) {
ffxx68 1:9289febf4ae9 185 if (tmpL > BLK_OLD) tmpL = BLK_OLD ;
ffxx68 1:9289febf4ae9 186 --tmpL ;
ffxx68 1:9289febf4ae9 187 if (tmpL < BLK_OLD -1) ptrFile->usedat_len = tmpL + 1 ;
ffxx68 1:9289febf4ae9 188 else ptrFile->usedat_len = 0 ; /* L:0x4F ignored, no effect */
ffxx68 1:9289febf4ae9 189
ffxx68 1:9289febf4ae9 190 error = WriteByteToWav (tmpL, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 191 if (error != ERR_OK) return (error) ;
ffxx68 1:9289febf4ae9 192 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG (L:%02X)", (uint) tmpL);
ffxx68 1:9289febf4ae9 193
ffxx68 1:9289febf4ae9 194 ptrFile->sum = tmpL ;
ffxx68 1:9289febf4ae9 195 }
ffxx68 1:9289febf4ae9 196 else if (tmpL == 0 ) error = ERR_OK ;
ffxx68 1:9289febf4ae9 197 else {
ffxx68 1:9289febf4ae9 198 printf(" WUsedatLQT: End of file was expected");
ffxx68 1:9289febf4ae9 199 error = ERR_FMT ;
ffxx68 1:9289febf4ae9 200 }
ffxx68 1:9289febf4ae9 201 ptrFile->count = 0 ;
ffxx68 1:9289febf4ae9 202
ffxx68 1:9289febf4ae9 203 return (error);
ffxx68 1:9289febf4ae9 204 }
ffxx68 1:9289febf4ae9 205
ffxx68 1:9289febf4ae9 206 int WriteByteSumToWav (ulong value,
ffxx68 1:9289febf4ae9 207 uchar order,
ffxx68 1:9289febf4ae9 208 uchar mode,
ffxx68 1:9289febf4ae9 209 FileInfo* ptrFile)
ffxx68 1:9289febf4ae9 210 {
ffxx68 1:9289febf4ae9 211 int error ;
ffxx68 1:9289febf4ae9 212 bool writ_full_block = false ;
ffxx68 1:9289febf4ae9 213
ffxx68 1:9289febf4ae9 214 do {
ffxx68 1:9289febf4ae9 215
ffxx68 1:9289febf4ae9 216 if ( (ptrFile->debug & 0x0040) > 0) {
ffxx68 1:9289febf4ae9 217 debug_printf(" %02X", (uchar) value);
ffxx68 1:9289febf4ae9 218 if ( ptrFile->total %0x100 == 0xFF ) printf("\n");
ffxx68 1:9289febf4ae9 219 }
ffxx68 1:9289febf4ae9 220 error = WriteByteToWav (value, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 221 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 222
ffxx68 1:9289febf4ae9 223 if (mode == MODE_B22 || mode == MODE_B11) ptrFile->sum += value ;
ffxx68 1:9289febf4ae9 224 else if (mode == MODE_B9 || mode == MODE_B10) CheckSumE (value, ptrFile) ; //ptrFile
ffxx68 1:9289febf4ae9 225 else CheckSumB1 (value, ptrFile) ;
ffxx68 1:9289febf4ae9 226
ffxx68 1:9289febf4ae9 227 ++ptrFile->count ;
ffxx68 1:9289febf4ae9 228 if (!writ_full_block) ++ptrFile->total ;
ffxx68 1:9289febf4ae9 229
ffxx68 1:9289febf4ae9 230 if ( ptrFile->usedat_len > 0) { /* QTape incomplete block */
ffxx68 1:9289febf4ae9 231 if (--ptrFile->usedat_len == 0) {
ffxx68 1:9289febf4ae9 232 if ( ( (ptrFile->debug & 0x0040) > 0 ) && (Qcnt == 0) ) debug_printf("DEBUG Fill data:");
ffxx68 1:9289febf4ae9 233 value = 0x00 ;
ffxx68 1:9289febf4ae9 234 writ_full_block = true ;
ffxx68 1:9289febf4ae9 235 }
ffxx68 1:9289febf4ae9 236 }
ffxx68 1:9289febf4ae9 237
ffxx68 1:9289febf4ae9 238 switch (mode) {
ffxx68 1:9289febf4ae9 239 case MODE_B22 :
ffxx68 1:9289febf4ae9 240 if ( ptrFile->count >= BLK_OLD ) {
ffxx68 1:9289febf4ae9 241
ffxx68 1:9289febf4ae9 242 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 243 debug_printf(" (%04X)", (uint) ptrFile->sum);
ffxx68 1:9289febf4ae9 244
ffxx68 1:9289febf4ae9 245 /* Write the checksum */
ffxx68 1:9289febf4ae9 246 error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 247 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 248 error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 249 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 250
ffxx68 1:9289febf4ae9 251 ptrFile->count = 0 ;
ffxx68 1:9289febf4ae9 252 ptrFile->sum = 0 ;
ffxx68 1:9289febf4ae9 253 }
ffxx68 1:9289febf4ae9 254 break ;
ffxx68 1:9289febf4ae9 255
ffxx68 1:9289febf4ae9 256 case MODE_B21 :
ffxx68 1:9289febf4ae9 257 case MODE_B20 :
ffxx68 1:9289febf4ae9 258 case MODE_B19 :
ffxx68 1:9289febf4ae9 259 if ( (ptrFile->count % BLK_OLD_SUM) == 0) {
ffxx68 1:9289febf4ae9 260
ffxx68 1:9289febf4ae9 261 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 262 debug_printf(" (%02X)", (uchar) ptrFile->sum);
ffxx68 1:9289febf4ae9 263
ffxx68 1:9289febf4ae9 264 /* Write the checksum */
ffxx68 1:9289febf4ae9 265 error = WriteByteToWav (ptrFile->sum, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 266 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 267
ffxx68 1:9289febf4ae9 268 if ( ptrFile->count >= BLK_OLD ) {
ffxx68 1:9289febf4ae9 269 ptrFile->count = 0 ;
ffxx68 1:9289febf4ae9 270 ptrFile->sum = 0 ;
ffxx68 1:9289febf4ae9 271 // if (pcgrpId==IDENT_PC1211) error = WriteSyncToWav (1803, ptrFile) ; //DATA not
ffxx68 1:9289febf4ae9 272 if (ptrFile->ident == IDENT_PC1211) /* default 1803 bits, data not */
ffxx68 1:9289febf4ae9 273 error = WriteSyncToWav (ptrFile->nbSync, ptrFile) ;
ffxx68 1:9289febf4ae9 274 }
ffxx68 1:9289febf4ae9 275 }
ffxx68 1:9289febf4ae9 276 break ;
ffxx68 1:9289febf4ae9 277
ffxx68 1:9289febf4ae9 278 case MODE_B17 :
ffxx68 1:9289febf4ae9 279 case MODE_B16 :
ffxx68 1:9289febf4ae9 280 case MODE_B15 :
ffxx68 1:9289febf4ae9 281 if ( ptrFile->count >= BLK_OLD_SUM) {
ffxx68 1:9289febf4ae9 282
ffxx68 1:9289febf4ae9 283 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 284 debug_printf(" (%02X)", (uchar) ptrFile->sum);
ffxx68 1:9289febf4ae9 285
ffxx68 1:9289febf4ae9 286 /* Write the checksum */
ffxx68 1:9289febf4ae9 287 error = WriteByteToWav (ptrFile->sum, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 288 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 289
ffxx68 1:9289febf4ae9 290 ptrFile->count = 0 ;
ffxx68 1:9289febf4ae9 291 ptrFile->sum = 0 ;
ffxx68 1:9289febf4ae9 292 }
ffxx68 1:9289febf4ae9 293 break ;
ffxx68 1:9289febf4ae9 294
ffxx68 1:9289febf4ae9 295 case MODE_B14 :
ffxx68 1:9289febf4ae9 296 case MODE_B13 :
ffxx68 1:9289febf4ae9 297 if ( ptrFile->count >= BLK_NEW) {
ffxx68 1:9289febf4ae9 298
ffxx68 1:9289febf4ae9 299 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 300 debug_printf(" (%02X)", (uchar) ptrFile->sum);
ffxx68 1:9289febf4ae9 301
ffxx68 1:9289febf4ae9 302 /* Write the checksum */
ffxx68 1:9289febf4ae9 303 error = WriteByteToWav (ptrFile->sum, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 304 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 305
ffxx68 1:9289febf4ae9 306 ptrFile->count = 0 ;
ffxx68 1:9289febf4ae9 307 ptrFile->sum = 0 ;
ffxx68 1:9289febf4ae9 308 }
ffxx68 1:9289febf4ae9 309 break ;
ffxx68 1:9289febf4ae9 310
ffxx68 1:9289febf4ae9 311 case MODE_B9 : /* PC-E/G/1600 */
ffxx68 1:9289febf4ae9 312 if ( ptrFile->count >= ptrFile->block_len ) {
ffxx68 1:9289febf4ae9 313
ffxx68 1:9289febf4ae9 314 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 315 debug_printf(" (%04X)", (uint) ptrFile->sum & 0xFFFF);
ffxx68 1:9289febf4ae9 316
ffxx68 1:9289febf4ae9 317 /* Write the checksum */
ffxx68 1:9289febf4ae9 318 error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 319 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 320 error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 321 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 322
ffxx68 1:9289febf4ae9 323 ptrFile->count = 0 ;
ffxx68 1:9289febf4ae9 324 ptrFile->sum = 0 ;
ffxx68 1:9289febf4ae9 325 }
ffxx68 1:9289febf4ae9 326 break ;
ffxx68 1:9289febf4ae9 327
ffxx68 1:9289febf4ae9 328 case MODE_B10 : /* SuperTape */
ffxx68 1:9289febf4ae9 329 if ( ptrFile->count >= ptrFile->block_len ) {
ffxx68 1:9289febf4ae9 330
ffxx68 1:9289febf4ae9 331 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 332 debug_printf(" (%04X)", (uint) ptrFile->sum & 0xFFFF);
ffxx68 1:9289febf4ae9 333
ffxx68 1:9289febf4ae9 334 /* Write the checksum */
ffxx68 1:9289febf4ae9 335 error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 336 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 337 error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 338 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 339
ffxx68 1:9289febf4ae9 340 if ( (ptrFile->debug & 0x0040) > 0) debug_printf(" %02X", (uchar) SUPT_END);
ffxx68 1:9289febf4ae9 341 error = WriteByteToWav (SUPT_END, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 342 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 343
ffxx68 1:9289febf4ae9 344 ptrFile->count = 0 ;
ffxx68 1:9289febf4ae9 345 ptrFile->sum = 0 ;
ffxx68 1:9289febf4ae9 346 }
ffxx68 1:9289febf4ae9 347 break ;
ffxx68 1:9289febf4ae9 348
ffxx68 1:9289febf4ae9 349 case MODE_B11 :
ffxx68 1:9289febf4ae9 350 if ( ptrFile->count >= BLK_OLD ) {
ffxx68 1:9289febf4ae9 351
ffxx68 1:9289febf4ae9 352 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 353 debug_printf(" (%04X)", (uint) ptrFile->sum);
ffxx68 1:9289febf4ae9 354 /* Write the checksum */
ffxx68 1:9289febf4ae9 355 error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 356 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 357 error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 358 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 359
ffxx68 1:9289febf4ae9 360 error = WriteByteToWav (EOF_15, order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 361 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 362 if ( (ptrFile->debug & 0x0040) > 0) debug_printf(" (E:%02X)", (uint) EOF_15);
ffxx68 1:9289febf4ae9 363 writ_full_block = false ;
ffxx68 1:9289febf4ae9 364
ffxx68 1:9289febf4ae9 365 error = WriteSyncToWav (50, ptrFile) ; /* 0.02 s */
ffxx68 1:9289febf4ae9 366 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 367 error = WriteUsedatLenToQTWav (order, mode, ptrFile) ;
ffxx68 1:9289febf4ae9 368 }
ffxx68 1:9289febf4ae9 369 break ;
ffxx68 1:9289febf4ae9 370
ffxx68 1:9289febf4ae9 371 default :
ffxx68 1:9289febf4ae9 372 debug_printf ("%s: Unknown Mode\n", argP) ;
ffxx68 1:9289febf4ae9 373 break ;
ffxx68 1:9289febf4ae9 374 }
ffxx68 1:9289febf4ae9 375
ffxx68 1:9289febf4ae9 376 } while (writ_full_block) ;
ffxx68 1:9289febf4ae9 377
ffxx68 1:9289febf4ae9 378 return (error);
ffxx68 1:9289febf4ae9 379 }
ffxx68 1:9289febf4ae9 380
ffxx68 0:07819bc70660 381 ulong SwapByte (ulong byte)
ffxx68 0:07819bc70660 382 {
ffxx68 0:07819bc70660 383 return ( (byte >> 4) + (byte << 4 & 0xF0) );
ffxx68 0:07819bc70660 384 }
ffxx68 0:07819bc70660 385
ffxx68 0:07819bc70660 386 /* File name for New and Old BASIC */
ffxx68 0:07819bc70660 387 int WriteSaveNameToWav (char* ptrName,
ffxx68 0:07819bc70660 388 uchar mode,
ffxx68 0:07819bc70660 389 FileInfo* ptrFile)
ffxx68 0:07819bc70660 390 {
ffxx68 0:07819bc70660 391 uint ii ;
ffxx68 0:07819bc70660 392 uint tmpL ;
ffxx68 0:07819bc70660 393 char byte ;
ffxx68 0:07819bc70660 394 char tmpS[20] ;
ffxx68 0:07819bc70660 395 int error ;
ffxx68 0:07819bc70660 396
ffxx68 1:9289febf4ae9 397 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG ptrName %s\n\r", ptrName);
ffxx68 0:07819bc70660 398
ffxx68 0:07819bc70660 399 do {
ffxx68 0:07819bc70660 400 /* Uppercase the name is done in main if needed */
ffxx68 0:07819bc70660 401 // tmpL = strlen (ptrName) ;
ffxx68 0:07819bc70660 402 for (ii = 0; ii < cLPF-1 && ptrName[ii] != '\0'; ii++) ;
ffxx68 0:07819bc70660 403 tmpL = ii;
ffxx68 0:07819bc70660 404
ffxx68 0:07819bc70660 405 if (tmpL > 7)
ffxx68 0:07819bc70660 406 tmpL = 7 ;
ffxx68 0:07819bc70660 407
ffxx68 0:07819bc70660 408 for ( ii = 0 ; ii < tmpL ; ++ii )
ffxx68 0:07819bc70660 409 tmpS[ii] = ptrName[ii] ;
ffxx68 0:07819bc70660 410
ffxx68 0:07819bc70660 411 tmpS[tmpL] = 0 ;
ffxx68 1:9289febf4ae9 412 //if (Qcnt == 0) debug_printf ("Save name : %s\n", tmpS) ;
ffxx68 0:07819bc70660 413 // strncpy( ptrName, tmpS, cLPF-1) ;
ffxx68 0:07819bc70660 414 for (ii = 0; ii < cLPF-1 && ptrName[ii] != '\0'; ii++)
ffxx68 0:07819bc70660 415 tmpS[ii] = ptrName[ii];
ffxx68 0:07819bc70660 416 /* crash?
ffxx68 0:07819bc70660 417 for ( ; ii < cLPF-1; ii++)
ffxx68 0:07819bc70660 418 tmpS[ii] = '\0';
ffxx68 0:07819bc70660 419 */
ffxx68 0:07819bc70660 420 tmpL = 7 - tmpL ;
ffxx68 0:07819bc70660 421 for ( ii = 0 ; ii < tmpL ; ++ii )
ffxx68 0:07819bc70660 422 tmpS[ii] = 0 ;
ffxx68 0:07819bc70660 423
ffxx68 1:9289febf4ae9 424 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG tmpS %s\n\r", tmpS);
ffxx68 0:07819bc70660 425 for ( ii = tmpL ; ii < 7 ; ++ii ) {
ffxx68 0:07819bc70660 426 byte = (ulong) ptrName[6 - ii] ;
ffxx68 0:07819bc70660 427
ffxx68 0:07819bc70660 428 switch (mode) {
ffxx68 0:07819bc70660 429 case MODE_B19 :
ffxx68 0:07819bc70660 430 case MODE_B20 :
ffxx68 0:07819bc70660 431
ffxx68 0:07819bc70660 432 if (byte < 0x80)
ffxx68 0:07819bc70660 433 byte = CodeOld[byte] ;
ffxx68 0:07819bc70660 434 else
ffxx68 0:07819bc70660 435 byte = CodeOld[0] ;
ffxx68 0:07819bc70660 436 break ;
ffxx68 0:07819bc70660 437
ffxx68 0:07819bc70660 438 default :
ffxx68 0:07819bc70660 439
ffxx68 0:07819bc70660 440 if (byte >= 0x80)
ffxx68 0:07819bc70660 441 byte = 0x20 ;
ffxx68 0:07819bc70660 442 break ;
ffxx68 0:07819bc70660 443 }
ffxx68 0:07819bc70660 444 tmpS[ii] = (char) SwapByte(byte) ;
ffxx68 0:07819bc70660 445 }
ffxx68 0:07819bc70660 446 tmpS[7] = 0x5F ;
ffxx68 0:07819bc70660 447
ffxx68 0:07819bc70660 448 /* Write the Name */
ffxx68 0:07819bc70660 449 ptrFile->count = 0 ;
ffxx68 0:07819bc70660 450 ptrFile->sum = 0 ;
ffxx68 0:07819bc70660 451 for ( ii = 0 ; ii < 8 ; ++ii ) {
ffxx68 0:07819bc70660 452 error = WriteByteSumToWav (tmpS[ii], ORDER_STD, mode, ptrFile) ;
ffxx68 0:07819bc70660 453 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 454 }
ffxx68 0:07819bc70660 455
ffxx68 0:07819bc70660 456 if (ptrFile->ident == IDENT_PC1211)
ffxx68 0:07819bc70660 457 error = WriteSyncToWav (151, ptrFile) ;
ffxx68 0:07819bc70660 458 else if (ptrFile->ident == IDENT_PC121_DAT)
ffxx68 0:07819bc70660 459 error = WriteSyncToWav (111, ptrFile) ;
ffxx68 0:07819bc70660 460
ffxx68 0:07819bc70660 461 ptrFile->count = 0 ;
ffxx68 0:07819bc70660 462 ptrFile->sum = 0 ;
ffxx68 0:07819bc70660 463
ffxx68 0:07819bc70660 464 } while (0) ;
ffxx68 0:07819bc70660 465 return (error);
ffxx68 0:07819bc70660 466 }
ffxx68 0:07819bc70660 467
ffxx68 0:07819bc70660 468 int DEBUGSaveNameToWav (char* ptrName,
ffxx68 0:07819bc70660 469 uchar mode,
ffxx68 0:07819bc70660 470 FileInfo* ptrFile)
ffxx68 0:07819bc70660 471 {
ffxx68 0:07819bc70660 472 uint ii ;
ffxx68 0:07819bc70660 473 uint i ;
ffxx68 0:07819bc70660 474 ulong byte ;
ffxx68 0:07819bc70660 475 ulong tmpL ;
ffxx68 0:07819bc70660 476 char tmpS[10] ;
ffxx68 0:07819bc70660 477 int error ;
ffxx68 0:07819bc70660 478
ffxx68 0:07819bc70660 479 do {
ffxx68 0:07819bc70660 480 /* Uppercase the name is done in main if needed */
ffxx68 0:07819bc70660 481 tmpL = strlen (ptrName) ;
ffxx68 1:9289febf4ae9 482 debug_printf("DEBUG tmpL %u\n\r", tmpL);
ffxx68 0:07819bc70660 483
ffxx68 0:07819bc70660 484 if (tmpL > 7)
ffxx68 0:07819bc70660 485 tmpL = 7 ;
ffxx68 0:07819bc70660 486
ffxx68 0:07819bc70660 487 for ( ii = 0 ; ii < tmpL ; ++ii ) {
ffxx68 1:9289febf4ae9 488 debug_printf("DEBUG ptrName[ii] %c\n\r", ptrName[ii]);
ffxx68 0:07819bc70660 489 tmpS[ii] = ptrName[ii] ;
ffxx68 0:07819bc70660 490 }
ffxx68 0:07819bc70660 491 tmpS[tmpL] = 0 ;
ffxx68 1:9289febf4ae9 492 //if (Qcnt == 0) debug_printf ("Save name : %s\n", tmpS) ;
ffxx68 1:9289febf4ae9 493 debug_printf("DEBUG ptrName %s\n\r", ptrName);
ffxx68 1:9289febf4ae9 494 debug_printf("DEBUG i 1 ");
ffxx68 0:07819bc70660 495
ffxx68 0:07819bc70660 496 // strncpy( ptrName, tmpS, cLPF-1) ;
ffxx68 0:07819bc70660 497 for (i = 0; i < cLPF-1 && ptrName[i] != '\0'; i++) {
ffxx68 1:9289febf4ae9 498 debug_printf("%u ", i);
ffxx68 0:07819bc70660 499 tmpS[i] = ptrName[i];
ffxx68 0:07819bc70660 500 }
ffxx68 1:9289febf4ae9 501 debug_printf("\n\rDEBUG i 2 ");
ffxx68 0:07819bc70660 502 /* crash?
ffxx68 0:07819bc70660 503 for ( ; i < cLPF-1; i++) {
ffxx68 1:9289febf4ae9 504 debug_printf("%u ", i);
ffxx68 0:07819bc70660 505 tmpS[i] = '\0';
ffxx68 0:07819bc70660 506 }
ffxx68 0:07819bc70660 507 */
ffxx68 1:9289febf4ae9 508 debug_printf("\n\rDEBUG tmpS %s\n\r", tmpS);
ffxx68 0:07819bc70660 509 tmpL = 7 - tmpL ;
ffxx68 0:07819bc70660 510 for ( ii = 0 ; ii < tmpL ; ++ii )
ffxx68 0:07819bc70660 511 tmpS[ii] = 0 ;
ffxx68 1:9289febf4ae9 512 debug_printf("DEBUG tmpS %s\n\r", tmpS);
ffxx68 0:07819bc70660 513
ffxx68 0:07819bc70660 514 /* reverse-order bytes */
ffxx68 0:07819bc70660 515 for ( ii = tmpL ; ii < 7 ; ++ii ) {
ffxx68 0:07819bc70660 516 byte = (ulong) ptrName[6 - ii] ;
ffxx68 1:9289febf4ae9 517 debug_printf("DEBUG byte %u\n\r", byte);
ffxx68 0:07819bc70660 518
ffxx68 0:07819bc70660 519 switch (mode) {
ffxx68 0:07819bc70660 520 case MODE_B19 :
ffxx68 0:07819bc70660 521 case MODE_B20 :
ffxx68 0:07819bc70660 522
ffxx68 0:07819bc70660 523 if (byte < 0x80)
ffxx68 0:07819bc70660 524 byte = CodeOld[byte] ;
ffxx68 0:07819bc70660 525 else
ffxx68 0:07819bc70660 526 byte = CodeOld[0] ;
ffxx68 0:07819bc70660 527 break ;
ffxx68 0:07819bc70660 528
ffxx68 0:07819bc70660 529 default :
ffxx68 0:07819bc70660 530
ffxx68 0:07819bc70660 531 if (byte >= 0x80)
ffxx68 0:07819bc70660 532 byte = 0x20 ;
ffxx68 0:07819bc70660 533 break ;
ffxx68 0:07819bc70660 534 }
ffxx68 0:07819bc70660 535 tmpS[ii] = (char) SwapByte(byte) ;
ffxx68 0:07819bc70660 536 }
ffxx68 0:07819bc70660 537 tmpS[7] = 0x5F ;
ffxx68 1:9289febf4ae9 538 debug_printf("DEBUG ii %u\n\r", ii);
ffxx68 0:07819bc70660 539
ffxx68 0:07819bc70660 540 /* Write the Name */
ffxx68 0:07819bc70660 541 ptrFile->count = 0 ;
ffxx68 0:07819bc70660 542 ptrFile->sum = 0 ;
ffxx68 0:07819bc70660 543 for ( ii = 0 ; ii < 8 ; ++ii ) {
ffxx68 0:07819bc70660 544 error = WriteByteSumToWav (tmpS[ii], ORDER_STD, mode, ptrFile) ;
ffxx68 0:07819bc70660 545 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 546 }
ffxx68 1:9289febf4ae9 547 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Name - Bytes was printed swapped.\n\r");
ffxx68 0:07819bc70660 548
ffxx68 1:9289febf4ae9 549 debug_printf("DEBUG WriteSyncToWav prima\n\r");
ffxx68 0:07819bc70660 550
ffxx68 0:07819bc70660 551 if (ptrFile->ident == IDENT_PC1211)
ffxx68 0:07819bc70660 552 error = WriteSyncToWav (151, ptrFile) ;
ffxx68 0:07819bc70660 553 else if (ptrFile->ident == IDENT_PC121_DAT)
ffxx68 0:07819bc70660 554 error = WriteSyncToWav (111, ptrFile) ;
ffxx68 1:9289febf4ae9 555 debug_printf("DEBUG WriteSyncToWav dopo\n\r");
ffxx68 0:07819bc70660 556
ffxx68 0:07819bc70660 557 ptrFile->count = 0 ;
ffxx68 0:07819bc70660 558 ptrFile->sum = 0 ;
ffxx68 1:9289febf4ae9 559 debug_printf("DEBUG fine\n\r");
ffxx68 0:07819bc70660 560
ffxx68 0:07819bc70660 561 } while (0) ;
ffxx68 0:07819bc70660 562 return (error);
ffxx68 0:07819bc70660 563 }
ffxx68 0:07819bc70660 564
ffxx68 0:07819bc70660 565 /* Head of Binary Data for New and Old series */
ffxx68 0:07819bc70660 566 int WriteHeadToBinWav (ulong addr,
ffxx68 0:07819bc70660 567 ulong size,
ffxx68 0:07819bc70660 568 uchar mode,
ffxx68 0:07819bc70660 569 FileInfo* ptrFile)
ffxx68 0:07819bc70660 570 {
ffxx68 0:07819bc70660 571 int ii ;
ffxx68 0:07819bc70660 572 ulong len ;
ffxx68 0:07819bc70660 573 ulong tmpL ;
ffxx68 0:07819bc70660 574 int error ;
ffxx68 0:07819bc70660 575
ffxx68 0:07819bc70660 576 do {
ffxx68 0:07819bc70660 577 /* if (Qcnt == 0)
ffxx68 0:07819bc70660 578 {
ffxx68 1:9289febf4ae9 579 debug_printf ("Start Address: 0x%04X\n", (uint) addr);
ffxx68 1:9289febf4ae9 580 debug_printf ("End Address: 0x%04X, Length: %d bytes\n", (uint) (addr + size -1), (uint) size);
ffxx68 0:07819bc70660 581 }
ffxx68 0:07819bc70660 582 */
ffxx68 0:07819bc70660 583
ffxx68 0:07819bc70660 584 ptrFile->count = 0 ;
ffxx68 0:07819bc70660 585 ptrFile->sum = 0 ;
ffxx68 0:07819bc70660 586 for ( ii = 0 ; ii < 4 ; ++ii ) {
ffxx68 0:07819bc70660 587 error = WriteByteSumToWav (0, ORDER_STD, mode, ptrFile) ;
ffxx68 0:07819bc70660 588 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 589 }
ffxx68 0:07819bc70660 590
ffxx68 0:07819bc70660 591 /* Write the address, this method is necessary because of swapped checksums in the header. */
ffxx68 0:07819bc70660 592 tmpL = ((addr >> 4) & 0xF0) + (addr >> 12) ; /* H swapped */
ffxx68 0:07819bc70660 593 error = WriteByteSumToWav (tmpL, ORDER_STD, mode, ptrFile) ;
ffxx68 0:07819bc70660 594 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 595
ffxx68 0:07819bc70660 596 tmpL = ((addr << 4) & 0xF0) + ((addr >> 4) & 0x0F) ;/* L swapped */
ffxx68 0:07819bc70660 597 error = WriteByteSumToWav (tmpL, ORDER_STD, mode, ptrFile) ;
ffxx68 0:07819bc70660 598 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 599
ffxx68 0:07819bc70660 600 /* Write the Length */
ffxx68 0:07819bc70660 601 len = size - 1 ;
ffxx68 0:07819bc70660 602 tmpL = ((len >> 4) & 0xF0) + (len >> 12) ;
ffxx68 0:07819bc70660 603 error = WriteByteSumToWav (tmpL, ORDER_STD, mode, ptrFile) ;
ffxx68 0:07819bc70660 604 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 605
ffxx68 0:07819bc70660 606 tmpL = ((len << 4) & 0xF0) + ((len >> 4) & 0x0F) ;
ffxx68 0:07819bc70660 607 error = WriteByteSumToWav (tmpL, ORDER_STD, mode, ptrFile) ;
ffxx68 0:07819bc70660 608 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 609
ffxx68 0:07819bc70660 610 ptrFile->count = 0 ;
ffxx68 0:07819bc70660 611 ptrFile->sum = 0 ;
ffxx68 0:07819bc70660 612
ffxx68 0:07819bc70660 613 } while (0) ;
ffxx68 0:07819bc70660 614 return (error);
ffxx68 0:07819bc70660 615 }
ffxx68 0:07819bc70660 616
ffxx68 0:07819bc70660 617 int WriteFooterToNewWav (FileInfo* ptrFile)
ffxx68 0:07819bc70660 618 {
ffxx68 0:07819bc70660 619 int error ;
ffxx68 0:07819bc70660 620
ffxx68 0:07819bc70660 621 do {
ffxx68 0:07819bc70660 622 ptrFile->count = 0 ; /* no checksum writing from here until the end */
ffxx68 0:07819bc70660 623
ffxx68 0:07819bc70660 624 error = WriteByteSumToWav(BAS_NEW_EOF, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 625 // error = WriteByteSumToB13Wav (BAS_NEW_EOF, ptrFile) ;
ffxx68 0:07819bc70660 626 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 627
ffxx68 0:07819bc70660 628 error = WriteByteToWav(BAS_NEW_EOF, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 629 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 630
ffxx68 0:07819bc70660 631 if ( (ptrFile->debug & 0x00C0) > 0 )
ffxx68 1:9289febf4ae9 632 debug_printf(" EOF:%02X", (uchar) BAS_NEW_EOF);
ffxx68 0:07819bc70660 633
ffxx68 0:07819bc70660 634 error = WriteByteToWav(ptrFile->sum, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 635 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 636
ffxx68 0:07819bc70660 637 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 638 debug_printf(" (%02X)", (uchar) ptrFile->sum);
ffxx68 0:07819bc70660 639
ffxx68 0:07819bc70660 640 /* there are 2bits more HIGH at the end of transmission (at least for PC-1402) M. NOSSWITZ */
ffxx68 1:9289febf4ae9 641 /* Needed ???
ffxx68 0:07819bc70660 642 error = WriteBitToWav (1, ptrFile) ;
ffxx68 0:07819bc70660 643 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 644
ffxx68 0:07819bc70660 645 error = WriteBitToWav (1, ptrFile) ;
ffxx68 0:07819bc70660 646 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 647 */
ffxx68 0:07819bc70660 648
ffxx68 0:07819bc70660 649 /* This puts 2 bits of silence (or 2 HIGH bits alternatively) to the end of the wave file. */
ffxx68 0:07819bc70660 650 /* CLOAD does not accept any sound, that could be interpreted as a start bit, */
ffxx68 0:07819bc70660 651 /* during post-processing. Original CSAVE switches the signal low ms after the */
ffxx68 0:07819bc70660 652 /* end of transmission, before the motor of the cassette recorder is switched off. */
ffxx68 0:07819bc70660 653 /* This level out is visible in the CSAVE audio signal after the last bit. T. Muecker */
ffxx68 0:07819bc70660 654
ffxx68 1:9289febf4ae9 655 /* REMOVED FROM HERE - handeled in the bit sending routine at stream end
ffxx68 1:9289febf4ae9 656 error = WriteBitToWav (3, ptrFile) ; 125us High ,
ffxx68 0:07819bc70660 657 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 658 error = WriteBitToWav (2, ptrFile) ; 1 ms Midsignal
ffxx68 0:07819bc70660 659 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 660 */
ffxx68 0:07819bc70660 661
ffxx68 0:07819bc70660 662 } while (0) ;
ffxx68 0:07819bc70660 663 return (error);
ffxx68 0:07819bc70660 664 }
ffxx68 0:07819bc70660 665
ffxx68 0:07819bc70660 666 int WriteFooterToMemoWav (FileInfo* ptrFile)
ffxx68 0:07819bc70660 667 {
ffxx68 0:07819bc70660 668 int error ;
ffxx68 0:07819bc70660 669
ffxx68 0:07819bc70660 670 do {
ffxx68 0:07819bc70660 671 error = WriteByteToWav(ptrFile->sum, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 672 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 673
ffxx68 0:07819bc70660 674 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 675 debug_printf(" (%02X)", (uchar) ptrFile->sum);
ffxx68 0:07819bc70660 676
ffxx68 0:07819bc70660 677 error = WriteBitToWav (1, ptrFile) ;
ffxx68 0:07819bc70660 678 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 679
ffxx68 0:07819bc70660 680 error = WriteBitToWav (1, ptrFile) ;
ffxx68 0:07819bc70660 681 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 682
ffxx68 0:07819bc70660 683 /* This puts 2 bits of silence (or 2 HIGH bits alternatively) to the end of the wave file. */
ffxx68 0:07819bc70660 684
ffxx68 0:07819bc70660 685 error = WriteBitToWav (3, ptrFile) ;
ffxx68 0:07819bc70660 686 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 687
ffxx68 0:07819bc70660 688 error = WriteBitToWav (2, ptrFile) ;
ffxx68 0:07819bc70660 689 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 690
ffxx68 0:07819bc70660 691 } while (0) ;
ffxx68 0:07819bc70660 692 return (error);
ffxx68 0:07819bc70660 693 }
ffxx68 0:07819bc70660 694
ffxx68 0:07819bc70660 695 /////////////////////////////////////////////////////////////////////////////
ffxx68 0:07819bc70660 696 // My file-send implementation
ffxx68 0:07819bc70660 697 // Inspired to Pocket-Tools source code ...
ffxx68 0:07819bc70660 698 int FileSend ( char* FileName, char* FileStream, uint FileSize, FileInfo* ptrFile )
ffxx68 0:07819bc70660 699 {
ffxx68 0:07819bc70660 700 int pcId = PC_ID;
ffxx68 0:07819bc70660 701 uchar type ;
ffxx68 0:07819bc70660 702
ffxx68 0:07819bc70660 703 uint32_t ii ;
ffxx68 0:07819bc70660 704 uint32_t nbByte;
ffxx68 0:07819bc70660 705 uint32_t nbSync = N_SYNC_BITS;
ffxx68 0:07819bc70660 706 uint32_t addr;
ffxx68 0:07819bc70660 707 int error ;
ffxx68 0:07819bc70660 708 char inVal;
ffxx68 0:07819bc70660 709
ffxx68 0:07819bc70660 710
ffxx68 0:07819bc70660 711 // BIN file stored statically, until I integrate an SD-Card...
ffxx68 0:07819bc70660 712 nbByte = FileSize;
ffxx68 0:07819bc70660 713 ptrFile->nbSync = nbSync;
ffxx68 0:07819bc70660 714
ffxx68 1:9289febf4ae9 715 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG FileName %s\n\r",FileName);
ffxx68 1:9289febf4ae9 716 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG ptrFile->ident %u\n\r",ptrFile->ident);
ffxx68 1:9289febf4ae9 717 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG nbSync %u\n\r",nbSync);
ffxx68 1:9289febf4ae9 718 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG nbByte %u\n\r",nbByte);
ffxx68 0:07819bc70660 719
ffxx68 0:07819bc70660 720 switch (ptrFile->ident) {
ffxx68 0:07819bc70660 721 /* . . .*/
ffxx68 0:07819bc70660 722 case IDENT_NEW_BIN :
ffxx68 0:07819bc70660 723 pcgrpId = GRP_NEW ; /*or GRP_EXT */
ffxx68 0:07819bc70660 724 type = TYPE_BIN ;
ffxx68 0:07819bc70660 725 break ;
ffxx68 0:07819bc70660 726 /* . . .*/
ffxx68 0:07819bc70660 727 case IDENT_NEW_BAS :
ffxx68 0:07819bc70660 728 pcgrpId = GRP_NEW ;
ffxx68 0:07819bc70660 729 type = TYPE_IMG ;
ffxx68 0:07819bc70660 730 break ;
ffxx68 0:07819bc70660 731 default :
ffxx68 1:9289febf4ae9 732 debug_printf ("%s: Unknown Ident\n", argP) ;
ffxx68 0:07819bc70660 733 return (ERR_ARG);
ffxx68 0:07819bc70660 734 }
ffxx68 0:07819bc70660 735
ffxx68 0:07819bc70660 736 /* if (pcgrpId == GRP_E || pcgrpId == GRP_G || pcgrpId == GRP_16) {
ffxx68 0:07819bc70660 737 . . .
ffxx68 0:07819bc70660 738 }
ffxx68 0:07819bc70660 739 else { // PC-1211 to PC-1500, QTape
ffxx68 0:07819bc70660 740 */
ffxx68 1:9289febf4ae9 741 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG WriteSyncToWav\n\r");
ffxx68 0:07819bc70660 742 error = WriteSyncToWav (nbSync, ptrFile) ;
ffxx68 0:07819bc70660 743 /*
ffxx68 0:07819bc70660 744 . . .
ffxx68 0:07819bc70660 745 */
ffxx68 0:07819bc70660 746 if (error != ERR_OK) return ( error ) ;
ffxx68 0:07819bc70660 747
ffxx68 0:07819bc70660 748 switch (pcId) {
ffxx68 0:07819bc70660 749 /*
ffxx68 0:07819bc70660 750 . . .
ffxx68 0:07819bc70660 751 */
ffxx68 0:07819bc70660 752 case 1403:
ffxx68 0:07819bc70660 753 /* if (type == TYPE_BIN && Acnt==0 && SHCc==0 && addr==0) */ addr = TYPE_BIN_ADDR;
ffxx68 0:07819bc70660 754 /*
ffxx68 0:07819bc70660 755 . . .
ffxx68 0:07819bc70660 756 */
ffxx68 0:07819bc70660 757 break;
ffxx68 0:07819bc70660 758 default :
ffxx68 1:9289febf4ae9 759 debug_printf ("%s: Pocket computer %d is not implemented\n", argP, pcId) ;
ffxx68 0:07819bc70660 760 // MoreInfo (ERR_ARG);
ffxx68 0:07819bc70660 761 error = ERR_ARG ;
ffxx68 0:07819bc70660 762 // break ;
ffxx68 0:07819bc70660 763 }
ffxx68 0:07819bc70660 764 if (error != ERR_OK) return ( error ) ;
ffxx68 0:07819bc70660 765
ffxx68 0:07819bc70660 766 /* ...
ffxx68 0:07819bc70660 767 else { // PC-121x ... PC-1475
ffxx68 0:07819bc70660 768 */
ffxx68 1:9289febf4ae9 769 if ( (ptrFile->debug & 0x0040) > 0 )
ffxx68 1:9289febf4ae9 770 debug_printf("DEBUG set Header Mode (ident %d)\n\r", ptrFile->ident);
ffxx68 0:07819bc70660 771 switch (ptrFile->ident) { /* Header Mode */
ffxx68 0:07819bc70660 772 case IDENT_PC1211 :
ffxx68 0:07819bc70660 773 ptrFile->mode = ptrFile->mode_h = MODE_B20 ;
ffxx68 0:07819bc70660 774 break ;
ffxx68 0:07819bc70660 775
ffxx68 0:07819bc70660 776 case IDENT_PC121_DAT :
ffxx68 0:07819bc70660 777 case IDENT_OLD_BAS :
ffxx68 0:07819bc70660 778 case IDENT_OLD_DAT :
ffxx68 0:07819bc70660 779 case IDENT_OLD_BIN :
ffxx68 0:07819bc70660 780 case IDENT_OLD_MEM :
ffxx68 0:07819bc70660 781 ptrFile->mode = ptrFile->mode_h = MODE_B19 ;
ffxx68 0:07819bc70660 782 break ;
ffxx68 0:07819bc70660 783
ffxx68 0:07819bc70660 784 case IDENT_NEW_TEL :
ffxx68 0:07819bc70660 785 case IDENT_NEW_SCD :
ffxx68 0:07819bc70660 786 case IDENT_NEW_NOT :
ffxx68 0:07819bc70660 787 case IDENT_NEW_CRD :
ffxx68 0:07819bc70660 788
ffxx68 0:07819bc70660 789 case IDENT_NEW_CSL :
ffxx68 0:07819bc70660 790
ffxx68 0:07819bc70660 791 case IDENT_NEW_BAS :
ffxx68 0:07819bc70660 792 case IDENT_EXT_BAS :
ffxx68 0:07819bc70660 793 case IDENT_NEW_DAT :
ffxx68 0:07819bc70660 794 case IDENT_NEW_BIN :
ffxx68 0:07819bc70660 795 ptrFile->mode = ptrFile->mode_h = MODE_B16 ;
ffxx68 0:07819bc70660 796 break ;
ffxx68 0:07819bc70660 797
ffxx68 0:07819bc70660 798 default :
ffxx68 1:9289febf4ae9 799 debug_printf ("%s: Unknown Ident\n", argP) ;
ffxx68 0:07819bc70660 800 ptrFile->mode = ptrFile->mode_h = MODE_B21 ;
ffxx68 0:07819bc70660 801 return (ERR_ARG);
ffxx68 0:07819bc70660 802 }
ffxx68 1:9289febf4ae9 803 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Header ptrFile->mode_h %u\n\r",ptrFile->mode_h);
ffxx68 0:07819bc70660 804
ffxx68 0:07819bc70660 805 /* Write the TAPE code */
ffxx68 1:9289febf4ae9 806 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Write the TAPE code\n\r");
ffxx68 0:07819bc70660 807 error = WriteByteToWav ( (ulong) ptrFile->ident, ORDER_STD, ptrFile->mode_h, ptrFile) ;
ffxx68 0:07819bc70660 808 if (error != ERR_OK) return ( error ) ;
ffxx68 0:07819bc70660 809
ffxx68 0:07819bc70660 810 /* Write the Name */
ffxx68 1:9289febf4ae9 811 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Write the Name\n\r");
ffxx68 0:07819bc70660 812 error = WriteSaveNameToWav ( FileName, ptrFile->mode_h, ptrFile) ;
ffxx68 1:9289febf4ae9 813 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG error (ERR_OK) %d (%d)\n\r", error, ERR_OK);
ffxx68 0:07819bc70660 814 if (error != ERR_OK) return ( error ) ;
ffxx68 0:07819bc70660 815
ffxx68 1:9289febf4ae9 816 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG set Body Data Mode\n\r");
ffxx68 0:07819bc70660 817 switch (ptrFile->ident) { /* Body Data Mode */
ffxx68 0:07819bc70660 818 case IDENT_PC1211 :
ffxx68 0:07819bc70660 819 ptrFile->mode = MODE_B20 ;
ffxx68 0:07819bc70660 820 break ;
ffxx68 0:07819bc70660 821
ffxx68 0:07819bc70660 822 case IDENT_PC121_DAT :
ffxx68 0:07819bc70660 823 case IDENT_OLD_BAS :
ffxx68 0:07819bc70660 824 case IDENT_OLD_BIN :
ffxx68 0:07819bc70660 825 case IDENT_OLD_MEM :
ffxx68 0:07819bc70660 826 ptrFile->mode = MODE_B19 ;
ffxx68 0:07819bc70660 827 break ;
ffxx68 0:07819bc70660 828
ffxx68 0:07819bc70660 829 case IDENT_OLD_DAT :
ffxx68 0:07819bc70660 830 case IDENT_NEW_DAT :
ffxx68 0:07819bc70660 831 ptrFile->mode = MODE_B15 ;
ffxx68 0:07819bc70660 832 break ;
ffxx68 0:07819bc70660 833
ffxx68 0:07819bc70660 834 case IDENT_EXT_BAS :
ffxx68 0:07819bc70660 835
ffxx68 0:07819bc70660 836 case IDENT_NEW_BAS :
ffxx68 0:07819bc70660 837 case IDENT_NEW_CSL :
ffxx68 0:07819bc70660 838
ffxx68 0:07819bc70660 839 case IDENT_NEW_TEL :
ffxx68 0:07819bc70660 840 case IDENT_NEW_SCD :
ffxx68 0:07819bc70660 841 case IDENT_NEW_NOT :
ffxx68 0:07819bc70660 842 case IDENT_NEW_CRD :
ffxx68 0:07819bc70660 843 case IDENT_NEW_BIN :
ffxx68 0:07819bc70660 844 // TODO (mr#2#): Check whitch MODE_B13 or _B14
ffxx68 0:07819bc70660 845 if (cnvstr_upr && pcId < 1440) ptrFile->mode = MODE_B13 ; /*older part of new series*/
ffxx68 0:07819bc70660 846 else ptrFile->mode = MODE_B14 ; /*new series and extended series*/
ffxx68 0:07819bc70660 847 break ;
ffxx68 0:07819bc70660 848
ffxx68 0:07819bc70660 849 default :
ffxx68 1:9289febf4ae9 850 debug_printf ("%s: Unknown Ident\n", argP) ;
ffxx68 0:07819bc70660 851 return ( ERR_ARG );
ffxx68 0:07819bc70660 852 }
ffxx68 1:9289febf4ae9 853 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Body ptrFile->mode %u\n\r", ptrFile->mode);
ffxx68 0:07819bc70660 854
ffxx68 0:07819bc70660 855 ptrFile->total = 0 ; /* count bytes of body only */
ffxx68 0:07819bc70660 856
ffxx68 0:07819bc70660 857 switch (ptrFile->ident) { /* header was written, write all data now */
ffxx68 0:07819bc70660 858 /* ...
ffxx68 0:07819bc70660 859 case
ffxx68 0:07819bc70660 860 ... */
ffxx68 0:07819bc70660 861 case IDENT_NEW_BAS :
ffxx68 0:07819bc70660 862 case IDENT_NEW_CSL :
ffxx68 0:07819bc70660 863 case IDENT_EXT_BAS :
ffxx68 1:9289febf4ae9 864 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Write the datas\n\r");
ffxx68 0:07819bc70660 865 /* Write the datas */
ffxx68 0:07819bc70660 866 // info.mode = MODE_B13 ; /*PC-1403 and newer should be MODE_14 */
ffxx68 0:07819bc70660 867 /* the older simple algorithm seems to work as well, but this is now, what the PC does originally */
ffxx68 0:07819bc70660 868 for ( ii = 0 ; ii < nbByte - 1 ; ++ii ) {
ffxx68 1:9289febf4ae9 869 //if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG LOOP ii %u\n\r", ii);
ffxx68 0:07819bc70660 870
ffxx68 0:07819bc70660 871 inVal = FileStream[ii] ; // fgetc (srcFd) ;
ffxx68 1:9289febf4ae9 872 if ( inVal == EOF ) break ; // premature ending shouldn't happen...
ffxx68 0:07819bc70660 873
ffxx68 0:07819bc70660 874 if ( inVal == BAS_NEW_EOF ) {
ffxx68 0:07819bc70660 875 if (ptrFile->count + 1 == BLK_NEW && ptrFile->sum == 0xE1) { /* Constellation will generate 2-times BAS_NEW_EOF */
ffxx68 0:07819bc70660 876 printf ("\nERROR %i at %lu. byte, usually the low byte of a BASIC line number\n", ERR_SUM, ptrFile->total) ;
ffxx68 0:07819bc70660 877 printf ("This binary constellation activates the CLOAD bug of this series. The line\n") ;
ffxx68 0:07819bc70660 878 printf ("number must be changed or minor changes done in the BASIC text before.\n") ;
ffxx68 0:07819bc70660 879 /* Seldom Bug in CLOAD, for PC-1402/(01) at known ROM address: 40666 */
ffxx68 0:07819bc70660 880 if ((ptrFile->debug & 0x800) == 0 ) {
ffxx68 0:07819bc70660 881 error = ERR_SUM ;
ffxx68 0:07819bc70660 882 break ;
ffxx68 0:07819bc70660 883 }
ffxx68 0:07819bc70660 884 }
ffxx68 0:07819bc70660 885 }
ffxx68 0:07819bc70660 886 error = WriteByteSumToWav ( (uint) inVal, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 887 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 888 }
ffxx68 0:07819bc70660 889 if (error != ERR_OK) break ;
ffxx68 1:9289febf4ae9 890 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG ii %u\n\r", ii);
ffxx68 0:07819bc70660 891
ffxx68 0:07819bc70660 892 inVal = FileStream[ii] ; // fgetc (srcFd) ; /* Read the last byte before EOF mark */
ffxx68 0:07819bc70660 893 if (inVal == EOF) break ;
ffxx68 0:07819bc70660 894
ffxx68 0:07819bc70660 895 if (inVal == BAS_NEW_EOF) {
ffxx68 0:07819bc70660 896 /* EOF mark should not be included for this file type normally*/
ffxx68 0:07819bc70660 897 if (Qcnt == 0) printf ("End of File mark %i should not be included in the image\n", inVal) ;
ffxx68 0:07819bc70660 898 /* if end of block, then an additional checksum would be written, but this does work anyhow */
ffxx68 0:07819bc70660 899 }
ffxx68 0:07819bc70660 900 else {
ffxx68 1:9289febf4ae9 901 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG last byte: %02X\n\r", (uchar) inVal);
ffxx68 0:07819bc70660 902 error = WriteByteToWav ( (uint) inVal, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 903 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 904 CheckSumB1 ((uint) inVal, ptrFile) ; /* never write the checksum before BAS_NEW_EOF */
ffxx68 0:07819bc70660 905
ffxx68 0:07819bc70660 906 ++ptrFile->total ;
ffxx68 0:07819bc70660 907 ++ptrFile->count ; /* for debug purposes only, WriteFooter will reset it */
ffxx68 0:07819bc70660 908 }
ffxx68 0:07819bc70660 909
ffxx68 0:07819bc70660 910 /* Write the END code */
ffxx68 1:9289febf4ae9 911 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG WriteFooterToNewWav prima\n\r");
ffxx68 0:07819bc70660 912 error = WriteFooterToNewWav (ptrFile) ;
ffxx68 0:07819bc70660 913
ffxx68 0:07819bc70660 914 break ; // IDENT_NEW_BAS, IDENT_EXT_BAS
ffxx68 0:07819bc70660 915
ffxx68 0:07819bc70660 916 case IDENT_NEW_BIN :
ffxx68 0:07819bc70660 917 /* Write the address and length */
ffxx68 0:07819bc70660 918 error = WriteHeadToBinWav (addr, nbByte, ptrFile->mode_h, ptrFile) ;
ffxx68 0:07819bc70660 919 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 920 /* no break */
ffxx68 0:07819bc70660 921
ffxx68 0:07819bc70660 922 case IDENT_NEW_TEL :
ffxx68 0:07819bc70660 923 case IDENT_NEW_SCD :
ffxx68 0:07819bc70660 924 case IDENT_NEW_NOT :
ffxx68 0:07819bc70660 925 case IDENT_NEW_CRD :
ffxx68 0:07819bc70660 926
ffxx68 0:07819bc70660 927 /* Write the datas */
ffxx68 0:07819bc70660 928 for ( ii = 0 ; ii < nbByte - 1 ; ++ii ) {
ffxx68 0:07819bc70660 929 inVal = FileStream[ii] ; // fgetc (srcFd) ;
ffxx68 1:9289febf4ae9 930 if (inVal == EOF) break ; // premature ending shouldn't happen ...
ffxx68 0:07819bc70660 931
ffxx68 0:07819bc70660 932 error = WriteByteSumToWav ( (uint) inVal, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 933 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 934 }
ffxx68 0:07819bc70660 935 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 936
ffxx68 0:07819bc70660 937 inVal = FileStream[ii] ; // fgetc (srcFd) ; /* Read the last byte before EOF mark */
ffxx68 0:07819bc70660 938 if (inVal == EOF) break ;
ffxx68 0:07819bc70660 939
ffxx68 1:9289febf4ae9 940 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG %02X", (uchar) inVal);
ffxx68 0:07819bc70660 941 error = WriteByteToWav ( (uint) inVal, ORDER_STD, ptrFile->mode, ptrFile) ;
ffxx68 0:07819bc70660 942 if (error != ERR_OK) break ;
ffxx68 0:07819bc70660 943 CheckSumB1 ( (uint) inVal, ptrFile ) ; /* never write the checksum before BAS_NEW_EOF */
ffxx68 0:07819bc70660 944 ++ptrFile->total ;
ffxx68 0:07819bc70660 945 ++ptrFile->count ; /* for debug purposes only, WriteFooter will reset it */
ffxx68 0:07819bc70660 946
ffxx68 0:07819bc70660 947 /* Write the END code */
ffxx68 0:07819bc70660 948 if ( ptrFile->ident == IDENT_NEW_BIN) error = WriteFooterToNewWav ( ptrFile ) ;
ffxx68 0:07819bc70660 949 else WriteFooterToMemoWav ( ptrFile ) ;
ffxx68 0:07819bc70660 950
ffxx68 0:07819bc70660 951 break ; // IDENT_NEW_BIN and IDENT_NEW_Memos
ffxx68 0:07819bc70660 952 default:
ffxx68 0:07819bc70660 953 printf ("%s: Unknown Ident\n", argP) ;
ffxx68 0:07819bc70660 954 error = ERR_ARG;
ffxx68 0:07819bc70660 955 break;
ffxx68 0:07819bc70660 956 }
ffxx68 0:07819bc70660 957
ffxx68 1:9289febf4ae9 958 if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG FileSend error %d\n\r", error);
ffxx68 0:07819bc70660 959 return (error);
ffxx68 0:07819bc70660 960
ffxx68 0:07819bc70660 961 }