Fabio Fumi
/
send_to_sharp
Renamed
Diff: send_pc1403.cpp
- Revision:
- 1:9289febf4ae9
- Parent:
- 0:07819bc70660
- Child:
- 2:dff96be9617e
--- a/send_pc1403.cpp Tue Feb 15 15:37:06 2022 +0000 +++ b/send_pc1403.cpp Fri Feb 18 11:07:34 2022 +0000 @@ -2,20 +2,6 @@ #include "bit_send.h" /////////////////////////////////////////////////////// -// mbed objects -/* Timer bit_timer; -*/ - -// volatile force main to reread from SRAM -// with the new contents the interrupt wrote to it -// but, since both read/write there, this should be 'protected'! -// https://os.mbed.com/questions/5146/Sharing-Variables-with-Interrupts/ -volatile uint32_t bit_tick_flags; -static uint8_t bit_tick_count; -static uint8_t bit_cycle_count; -static uint32_t bit_out_value; - -/////////////////////////////////////////////////////// // variables from PocketTools code uint SHCc = 0 , /* Read not from bin, but from Transfile PC plus SHC-format (header included) */ SHCe = 0 ; /* End marks are the SHC Basic image included only*/ @@ -38,53 +24,27 @@ ulong err_cnt = 0 ; /* counts minor errors */ ulong wrn_cnt = 0 ; /* counts warnings */ - -/** replaced by the buffered -int bitSend (uint8_t bit, uint8_t invert){ - - uint8_t cycle_n; - uint32_t theor_time = 0; - - bit_timer.reset(); - bit_timer.start(); - switch (bit ^ invert) - { - case 0: - for ( cycle_n = 0; cycle_n < BIT_0_NCYCLES; cycle_n++) { - bit_out = 1; - wait_us( BIT_0_DELAY_HIGH ); - bit_out = 0; - wait_us( BIT_0_DELAY_LOW ); - } - theor_time = ( BIT_0_DELAY_LOW + BIT_0_DELAY_HIGH) * BIT_0_NCYCLES; - - case 1: - for ( cycle_n = 0; cycle_n < BIT_0_NCYCLES; cycle_n++) { - bit_out = 1; - wait_us( BIT_1_DELAY_HIGH ); - bit_out = 0; - wait_us( BIT_1_DELAY_LOW ); - } - theor_time = ( BIT_1_DELAY_LOW + BIT_1_DELAY_HIGH) * BIT_1_NCYCLES; - } - bit_timer.stop(); - - return (bit_timer.read_us() - theor_time); // difference real - theoretical timing (in us), per bit - -} -*/ - //////////////////////////////////////////////////////////////////////////////// // WriteBitToWav replaced from PocketTools version (writing to a WAV file) // Here we send directly signals to OUT lines int WriteBitToWav (int value, FileInfo* ptrFile) { - // Calling the buffered bit sending routine - if ( bitWaitSend ( value, 0 ) > MAX_BIT_TIME_ERR ) - return ( ERR_NOK ) ; - else - return ( ERR_OK ) ; + // Calling the buffered bit-sending routine + switch ( value ) { + case 1: + if ( bitWaitSend ( value, 0 ) > MAX_BIT_TIME_ERR ) + return ( ERR_NOK ) ; + break; + case 0: + if ( bitWaitSend ( value, 0 ) > MAX_BIT_TIME_ERR ) + return ( ERR_NOK ) ; + break; + default: + break; + } + + return ( ERR_OK ) ; } //////////////////////////////////////////////////////////////////////////////// @@ -99,8 +59,9 @@ int error ; // if (TAPc > 0) return (WriteQuaterToTap (value, ptrFile)); // no - + do { + error = WriteBitToWav (0, ptrFile) ; if (error != ERR_OK) break ; @@ -191,48 +152,6 @@ return (0); } -int WriteByteSumToWav (ulong value, - uchar order, - uchar mode, - FileInfo* ptrFile) -{ - int error; - -// ... - - error = WriteByteToWav (value, order, mode, ptrFile) ; - - if (mode == MODE_B22) ptrFile->sum += value ; - else if (mode == MODE_B9) CheckSumE (value, ptrFile) ; - else CheckSumB1 (value, ptrFile) ; - - ++ptrFile->count ; - ++ptrFile->total ; - - switch (mode) { - // ... - case MODE_B14 : - case MODE_B13 : - if ( ptrFile->count >= BLK_NEW) { - - if ( (ptrFile->debug & 0x0040) > 0 ) - printf(" (%02X)", (uchar) ptrFile->sum); - - /* Write the checksum */ - error = WriteByteToWav (ptrFile->sum, order, mode, ptrFile) ; - if (error != ERR_OK) break ; - - ptrFile->count = 0 ; - ptrFile->sum = 0 ; - } - break ; - default : - // printf ("%s: Unknown Mode\n", argP) ; - break ; - } - return (error); - -} int WriteSyncToWav (ulong nbSync, // FileInfo* ptrFile) @@ -254,6 +173,211 @@ return (error); } +int WriteUsedatLenToQTWav ( uchar order, /* Quick-Tape incomplete blocks with fill data */ + uchar mode, + FileInfo* ptrFile) +{ long tmpL ; + int error ; + + tmpL = ptrFile->nbByte - ptrFile->total_diff - ptrFile->total ; //not for IDENT_QT_DAT: variable block in RAM based + + if (tmpL > 0) { + if (tmpL > BLK_OLD) tmpL = BLK_OLD ; + --tmpL ; + if (tmpL < BLK_OLD -1) ptrFile->usedat_len = tmpL + 1 ; + else ptrFile->usedat_len = 0 ; /* L:0x4F ignored, no effect */ + + error = WriteByteToWav (tmpL, order, mode, ptrFile) ; + if (error != ERR_OK) return (error) ; + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG (L:%02X)", (uint) tmpL); + + ptrFile->sum = tmpL ; + } + else if (tmpL == 0 ) error = ERR_OK ; + else { + printf(" WUsedatLQT: End of file was expected"); + error = ERR_FMT ; + } + ptrFile->count = 0 ; + + return (error); +} + +int WriteByteSumToWav (ulong value, + uchar order, + uchar mode, + FileInfo* ptrFile) +{ + int error ; + bool writ_full_block = false ; + + do { + + if ( (ptrFile->debug & 0x0040) > 0) { + debug_printf(" %02X", (uchar) value); + if ( ptrFile->total %0x100 == 0xFF ) printf("\n"); + } + error = WriteByteToWav (value, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + if (mode == MODE_B22 || mode == MODE_B11) ptrFile->sum += value ; + else if (mode == MODE_B9 || mode == MODE_B10) CheckSumE (value, ptrFile) ; //ptrFile + else CheckSumB1 (value, ptrFile) ; + + ++ptrFile->count ; + if (!writ_full_block) ++ptrFile->total ; + + if ( ptrFile->usedat_len > 0) { /* QTape incomplete block */ + if (--ptrFile->usedat_len == 0) { + if ( ( (ptrFile->debug & 0x0040) > 0 ) && (Qcnt == 0) ) debug_printf("DEBUG Fill data:"); + value = 0x00 ; + writ_full_block = true ; + } + } + + switch (mode) { + case MODE_B22 : + if ( ptrFile->count >= BLK_OLD ) { + + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf(" (%04X)", (uint) ptrFile->sum); + + /* Write the checksum */ + error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + ptrFile->count = 0 ; + ptrFile->sum = 0 ; + } + break ; + + case MODE_B21 : + case MODE_B20 : + case MODE_B19 : + if ( (ptrFile->count % BLK_OLD_SUM) == 0) { + + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf(" (%02X)", (uchar) ptrFile->sum); + + /* Write the checksum */ + error = WriteByteToWav (ptrFile->sum, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + if ( ptrFile->count >= BLK_OLD ) { + ptrFile->count = 0 ; + ptrFile->sum = 0 ; + // if (pcgrpId==IDENT_PC1211) error = WriteSyncToWav (1803, ptrFile) ; //DATA not + if (ptrFile->ident == IDENT_PC1211) /* default 1803 bits, data not */ + error = WriteSyncToWav (ptrFile->nbSync, ptrFile) ; + } + } + break ; + + case MODE_B17 : + case MODE_B16 : + case MODE_B15 : + if ( ptrFile->count >= BLK_OLD_SUM) { + + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf(" (%02X)", (uchar) ptrFile->sum); + + /* Write the checksum */ + error = WriteByteToWav (ptrFile->sum, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + ptrFile->count = 0 ; + ptrFile->sum = 0 ; + } + break ; + + case MODE_B14 : + case MODE_B13 : + if ( ptrFile->count >= BLK_NEW) { + + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf(" (%02X)", (uchar) ptrFile->sum); + + /* Write the checksum */ + error = WriteByteToWav (ptrFile->sum, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + ptrFile->count = 0 ; + ptrFile->sum = 0 ; + } + break ; + + case MODE_B9 : /* PC-E/G/1600 */ + if ( ptrFile->count >= ptrFile->block_len ) { + + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf(" (%04X)", (uint) ptrFile->sum & 0xFFFF); + + /* Write the checksum */ + error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + ptrFile->count = 0 ; + ptrFile->sum = 0 ; + } + break ; + + case MODE_B10 : /* SuperTape */ + if ( ptrFile->count >= ptrFile->block_len ) { + + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf(" (%04X)", (uint) ptrFile->sum & 0xFFFF); + + /* Write the checksum */ + error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + if ( (ptrFile->debug & 0x0040) > 0) debug_printf(" %02X", (uchar) SUPT_END); + error = WriteByteToWav (SUPT_END, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + ptrFile->count = 0 ; + ptrFile->sum = 0 ; + } + break ; + + case MODE_B11 : + if ( ptrFile->count >= BLK_OLD ) { + + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf(" (%04X)", (uint) ptrFile->sum); + /* Write the checksum */ + error = WriteByteToWav (ptrFile->sum >> 8 & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + error = WriteByteToWav (ptrFile->sum & 0xFF, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + + error = WriteByteToWav (EOF_15, order, mode, ptrFile) ; + if (error != ERR_OK) break ; + if ( (ptrFile->debug & 0x0040) > 0) debug_printf(" (E:%02X)", (uint) EOF_15); + writ_full_block = false ; + + error = WriteSyncToWav (50, ptrFile) ; /* 0.02 s */ + if (error != ERR_OK) break ; + error = WriteUsedatLenToQTWav (order, mode, ptrFile) ; + } + break ; + + default : + debug_printf ("%s: Unknown Mode\n", argP) ; + break ; + } + + } while (writ_full_block) ; + + return (error); +} + ulong SwapByte (ulong byte) { return ( (byte >> 4) + (byte << 4 & 0xF0) ); @@ -270,7 +394,7 @@ char tmpS[20] ; int error ; - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG ptrName %s\n\r", ptrName); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG ptrName %s\n\r", ptrName); do { /* Uppercase the name is done in main if needed */ @@ -285,7 +409,7 @@ tmpS[ii] = ptrName[ii] ; tmpS[tmpL] = 0 ; - //if (Qcnt == 0) printf ("Save name : %s\n", tmpS) ; + //if (Qcnt == 0) debug_printf ("Save name : %s\n", tmpS) ; // strncpy( ptrName, tmpS, cLPF-1) ; for (ii = 0; ii < cLPF-1 && ptrName[ii] != '\0'; ii++) tmpS[ii] = ptrName[ii]; @@ -297,7 +421,7 @@ for ( ii = 0 ; ii < tmpL ; ++ii ) tmpS[ii] = 0 ; - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG tmpS %s\n\r", tmpS); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG tmpS %s\n\r", tmpS); for ( ii = tmpL ; ii < 7 ; ++ii ) { byte = (ulong) ptrName[6 - ii] ; @@ -355,42 +479,42 @@ do { /* Uppercase the name is done in main if needed */ tmpL = strlen (ptrName) ; - printf("DEBUG tmpL %u\n\r", tmpL); + debug_printf("DEBUG tmpL %u\n\r", tmpL); if (tmpL > 7) tmpL = 7 ; for ( ii = 0 ; ii < tmpL ; ++ii ) { - printf("DEBUG ptrName[ii] %c\n\r", ptrName[ii]); + debug_printf("DEBUG ptrName[ii] %c\n\r", ptrName[ii]); tmpS[ii] = ptrName[ii] ; } tmpS[tmpL] = 0 ; - //if (Qcnt == 0) printf ("Save name : %s\n", tmpS) ; - printf("DEBUG ptrName %s\n\r", ptrName); - printf("DEBUG i 1 "); + //if (Qcnt == 0) debug_printf ("Save name : %s\n", tmpS) ; + debug_printf("DEBUG ptrName %s\n\r", ptrName); + debug_printf("DEBUG i 1 "); // strncpy( ptrName, tmpS, cLPF-1) ; for (i = 0; i < cLPF-1 && ptrName[i] != '\0'; i++) { - printf("%u ", i); + debug_printf("%u ", i); tmpS[i] = ptrName[i]; } - printf("\n\rDEBUG i 2 "); + debug_printf("\n\rDEBUG i 2 "); /* crash? for ( ; i < cLPF-1; i++) { - printf("%u ", i); + debug_printf("%u ", i); tmpS[i] = '\0'; } */ - printf("\n\rDEBUG tmpS %s\n\r", tmpS); + debug_printf("\n\rDEBUG tmpS %s\n\r", tmpS); tmpL = 7 - tmpL ; for ( ii = 0 ; ii < tmpL ; ++ii ) tmpS[ii] = 0 ; - printf("DEBUG tmpS %s\n\r", tmpS); + debug_printf("DEBUG tmpS %s\n\r", tmpS); /* reverse-order bytes */ for ( ii = tmpL ; ii < 7 ; ++ii ) { byte = (ulong) ptrName[6 - ii] ; - printf("DEBUG byte %u\n\r", byte); + debug_printf("DEBUG byte %u\n\r", byte); switch (mode) { case MODE_B19 : @@ -411,7 +535,7 @@ tmpS[ii] = (char) SwapByte(byte) ; } tmpS[7] = 0x5F ; - printf("DEBUG ii %u\n\r", ii); + debug_printf("DEBUG ii %u\n\r", ii); /* Write the Name */ ptrFile->count = 0 ; @@ -420,19 +544,19 @@ error = WriteByteSumToWav (tmpS[ii], ORDER_STD, mode, ptrFile) ; if (error != ERR_OK) break ; } - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG Name - Bytes was printed swapped.\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Name - Bytes was printed swapped.\n\r"); - printf("DEBUG WriteSyncToWav prima\n\r"); + debug_printf("DEBUG WriteSyncToWav prima\n\r"); if (ptrFile->ident == IDENT_PC1211) error = WriteSyncToWav (151, ptrFile) ; else if (ptrFile->ident == IDENT_PC121_DAT) error = WriteSyncToWav (111, ptrFile) ; - printf("DEBUG WriteSyncToWav dopo\n\r"); + debug_printf("DEBUG WriteSyncToWav dopo\n\r"); ptrFile->count = 0 ; ptrFile->sum = 0 ; - printf("DEBUG fine\n\r"); + debug_printf("DEBUG fine\n\r"); } while (0) ; return (error); @@ -452,8 +576,8 @@ do { /* if (Qcnt == 0) { - printf ("Start Address: 0x%04X\n", (uint) addr); - printf ("End Address: 0x%04X, Length: %d bytes\n", (uint) (addr + size -1), (uint) size); + debug_printf ("Start Address: 0x%04X\n", (uint) addr); + debug_printf ("End Address: 0x%04X, Length: %d bytes\n", (uint) (addr + size -1), (uint) size); } */ @@ -505,21 +629,22 @@ if (error != ERR_OK) break ; if ( (ptrFile->debug & 0x00C0) > 0 ) - printf(" EOF:%02X", (uchar) BAS_NEW_EOF); + debug_printf(" EOF:%02X", (uchar) BAS_NEW_EOF); error = WriteByteToWav(ptrFile->sum, ORDER_STD, ptrFile->mode, ptrFile) ; if (error != ERR_OK) break ; if ( (ptrFile->debug & 0x0040) > 0 ) - printf(" (%02X)", (uchar) ptrFile->sum); + debug_printf(" (%02X)", (uchar) ptrFile->sum); /* there are 2bits more HIGH at the end of transmission (at least for PC-1402) M. NOSSWITZ */ - + /* Needed ??? error = WriteBitToWav (1, ptrFile) ; if (error != ERR_OK) break ; error = WriteBitToWav (1, ptrFile) ; if (error != ERR_OK) break ; +*/ /* This puts 2 bits of silence (or 2 HIGH bits alternatively) to the end of the wave file. */ /* CLOAD does not accept any sound, that could be interpreted as a start bit, */ @@ -527,11 +652,12 @@ /* end of transmission, before the motor of the cassette recorder is switched off. */ /* This level out is visible in the CSAVE audio signal after the last bit. T. Muecker */ - error = WriteBitToWav (3, ptrFile) ; + /* REMOVED FROM HERE - handeled in the bit sending routine at stream end + error = WriteBitToWav (3, ptrFile) ; 125us High , if (error != ERR_OK) break ; - - error = WriteBitToWav (2, ptrFile) ; + error = WriteBitToWav (2, ptrFile) ; 1 ms Midsignal if (error != ERR_OK) break ; + */ } while (0) ; return (error); @@ -546,7 +672,7 @@ if (error != ERR_OK) break ; if ( (ptrFile->debug & 0x0040) > 0 ) - printf(" (%02X)", (uchar) ptrFile->sum); + debug_printf(" (%02X)", (uchar) ptrFile->sum); error = WriteBitToWav (1, ptrFile) ; if (error != ERR_OK) break ; @@ -586,9 +712,10 @@ nbByte = FileSize; ptrFile->nbSync = nbSync; - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG ptrFile->ident %u\n\r",ptrFile->ident); - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG nbSync %u\n\r",nbSync); - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG nbByte %u\n\r",nbByte); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG FileName %s\n\r",FileName); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG ptrFile->ident %u\n\r",ptrFile->ident); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG nbSync %u\n\r",nbSync); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG nbByte %u\n\r",nbByte); switch (ptrFile->ident) { /* . . .*/ @@ -602,7 +729,7 @@ type = TYPE_IMG ; break ; default : - printf ("%s: Unknown Ident\n", argP) ; + debug_printf ("%s: Unknown Ident\n", argP) ; return (ERR_ARG); } @@ -611,7 +738,7 @@ } else { // PC-1211 to PC-1500, QTape */ - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG WriteSyncToWav\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG WriteSyncToWav\n\r"); error = WriteSyncToWav (nbSync, ptrFile) ; /* . . . @@ -629,7 +756,7 @@ */ break; default : - printf ("%s: Pocket computer %d is not implemented\n", argP, pcId) ; + debug_printf ("%s: Pocket computer %d is not implemented\n", argP, pcId) ; // MoreInfo (ERR_ARG); error = ERR_ARG ; // break ; @@ -639,7 +766,8 @@ /* ... else { // PC-121x ... PC-1475 */ - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG set Header Mode\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) + debug_printf("DEBUG set Header Mode (ident %d)\n\r", ptrFile->ident); switch (ptrFile->ident) { /* Header Mode */ case IDENT_PC1211 : ptrFile->mode = ptrFile->mode_h = MODE_B20 ; @@ -668,24 +796,24 @@ break ; default : - printf ("%s: Unknown Ident\n", argP) ; + debug_printf ("%s: Unknown Ident\n", argP) ; ptrFile->mode = ptrFile->mode_h = MODE_B21 ; return (ERR_ARG); } - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG Header ptrFile->mode_h %u\n\r",ptrFile->mode_h); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Header ptrFile->mode_h %u\n\r",ptrFile->mode_h); /* Write the TAPE code */ - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG Write the TAPE code\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Write the TAPE code\n\r"); error = WriteByteToWav ( (ulong) ptrFile->ident, ORDER_STD, ptrFile->mode_h, ptrFile) ; if (error != ERR_OK) return ( error ) ; /* Write the Name */ - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG Write the Name\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Write the Name\n\r"); error = WriteSaveNameToWav ( FileName, ptrFile->mode_h, ptrFile) ; - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG error (ERR_OK) %d (%d)\n\r", error, ERR_OK); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG error (ERR_OK) %d (%d)\n\r", error, ERR_OK); if (error != ERR_OK) return ( error ) ; - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG set Body Data Mode\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG set Body Data Mode\n\r"); switch (ptrFile->ident) { /* Body Data Mode */ case IDENT_PC1211 : ptrFile->mode = MODE_B20 ; @@ -719,10 +847,10 @@ break ; default : - printf ("%s: Unknown Ident\n", argP) ; + debug_printf ("%s: Unknown Ident\n", argP) ; return ( ERR_ARG ); } - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG Body ptrFile->mode %u\n\r", ptrFile->mode); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Body ptrFile->mode %u\n\r", ptrFile->mode); ptrFile->total = 0 ; /* count bytes of body only */ @@ -733,15 +861,15 @@ case IDENT_NEW_BAS : case IDENT_NEW_CSL : case IDENT_EXT_BAS : - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG Write the datas\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG Write the datas\n\r"); /* Write the datas */ // info.mode = MODE_B13 ; /*PC-1403 and newer should be MODE_14 */ /* the older simple algorithm seems to work as well, but this is now, what the PC does originally */ for ( ii = 0 ; ii < nbByte - 1 ; ++ii ) { - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG LOOP ii %u\n\r", ii); + //if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG LOOP ii %u\n\r", ii); inVal = FileStream[ii] ; // fgetc (srcFd) ; - if ( inVal == EOF ) break ; + if ( inVal == EOF ) break ; // premature ending shouldn't happen... if ( inVal == BAS_NEW_EOF ) { if (ptrFile->count + 1 == BLK_NEW && ptrFile->sum == 0xE1) { /* Constellation will generate 2-times BAS_NEW_EOF */ @@ -759,7 +887,7 @@ if (error != ERR_OK) break ; } if (error != ERR_OK) break ; - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG ii %u\n\r", ii); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG ii %u\n\r", ii); inVal = FileStream[ii] ; // fgetc (srcFd) ; /* Read the last byte before EOF mark */ if (inVal == EOF) break ; @@ -770,7 +898,7 @@ /* if end of block, then an additional checksum would be written, but this does work anyhow */ } else { - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG last byte: %02X\n\r", (uchar) inVal); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG last byte: %02X\n\r", (uchar) inVal); error = WriteByteToWav ( (uint) inVal, ORDER_STD, ptrFile->mode, ptrFile) ; if (error != ERR_OK) break ; CheckSumB1 ((uint) inVal, ptrFile) ; /* never write the checksum before BAS_NEW_EOF */ @@ -780,7 +908,7 @@ } /* Write the END code */ - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG WriteFooterToNewWav prima\n\r"); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG WriteFooterToNewWav prima\n\r"); error = WriteFooterToNewWav (ptrFile) ; break ; // IDENT_NEW_BAS, IDENT_EXT_BAS @@ -799,7 +927,7 @@ /* Write the datas */ for ( ii = 0 ; ii < nbByte - 1 ; ++ii ) { inVal = FileStream[ii] ; // fgetc (srcFd) ; - if (inVal == EOF) break ; // Should not happen ... + if (inVal == EOF) break ; // premature ending shouldn't happen ... error = WriteByteSumToWav ( (uint) inVal, ORDER_STD, ptrFile->mode, ptrFile) ; if (error != ERR_OK) break ; @@ -809,7 +937,7 @@ inVal = FileStream[ii] ; // fgetc (srcFd) ; /* Read the last byte before EOF mark */ if (inVal == EOF) break ; - if ( (ptrFile->debug & 0x0040) > 0 ) printf(" %02X", (uchar) inVal); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG %02X", (uchar) inVal); error = WriteByteToWav ( (uint) inVal, ORDER_STD, ptrFile->mode, ptrFile) ; if (error != ERR_OK) break ; CheckSumB1 ( (uint) inVal, ptrFile ) ; /* never write the checksum before BAS_NEW_EOF */ @@ -827,7 +955,7 @@ break; } - if ( (ptrFile->debug & 0x0040) > 0 ) printf("DEBUG FileSend error %d\n\r", error); + if ( (ptrFile->debug & 0x0040) > 0 ) debug_printf("DEBUG FileSend error %d\n\r", error); return (error); } \ No newline at end of file