@@ -293,22 +293,9 @@ void handle_address_change(DWORD dwCurrAddress, DWORD dwPrevAddress, BOOL *bVali
293293}
294294
295295void handle_xdata_mode_switch (BYTE byCurrXMode , BYTE * byPrevXMode , BOOL * bValidDataOffset , BYTE * byDataLength , WORD * wDataLengthOffset , BYTE * m_pBinConfig , WORD * m_wDataOffset ) {
296- if (byCurrXMode == XMODE_WRITE_BYTE )
297- {
298- if (* bValidDataOffset )
299- {
300- // Complete the data record before switching XDATA mode
301- m_pBinConfig [* wDataLengthOffset ] = * byDataLength ;
302- * bValidDataOffset = FALSE;
303- }
304- // Switch to new xdata write/set/clear mode
305- m_pBinConfig [(* m_wDataOffset )++ ] = CUSTOM_COMMAND ;
306- m_pBinConfig [(* m_wDataOffset )++ ] = byCurrXMode ;
307-
308- * byPrevXMode = byCurrXMode ;
309- }
310-
311- // Take care of xdata mode switching
296+ /* Update the xdata mode only if the current mode is not same
297+ * of the previous mode */
298+ // Take care of xdata mode switching
312299 if (byCurrXMode != * byPrevXMode )
313300 {
314301 if (* bValidDataOffset )
@@ -447,7 +434,9 @@ int switchtec_convert_ini2bin(FILE *szINIFileName, char *pclog ,BYTE *m_pBinConf
447434 char szKeyList [KEY_BUF_SIZE ];
448435 WORD m_wDataOffset = 0 ;
449436 char szKeyEntry [KEY_BUF_SIZE ];
450- BYTE byPrevXMode = XMODE_WRITE_BYTE ; // By default xdata_write mode
437+ /* xdata mode is added to the binary only on byPrevXMode != byCurrXMode.
438+ * So, initializing the Previous xdata mode to SET_XMODE_NONE */
439+ BYTE byPrevXMode = SET_XMODE_NONE ;
451440 BYTE byCurrXMode = SET_XMODE_NONE ;
452441 unsigned int nTemp = 0 ;
453442 DWORD dwCurrAddress = 0 , dwPrevAddress = 0 ;
@@ -591,4 +580,4 @@ int switchtec_convert_ini2bin(FILE *szINIFileName, char *pclog ,BYTE *m_pBinConf
591580 return TRUE;
592581}
593582
594- #endif
583+ #endif
0 commit comments