@@ -293,22 +293,7 @@ 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 of the previous mode
312297 if (byCurrXMode != * byPrevXMode )
313298 {
314299 if (* bValidDataOffset )
@@ -447,7 +432,9 @@ int switchtec_convert_ini2bin(FILE *szINIFileName, char *pclog ,BYTE *m_pBinConf
447432 char szKeyList [KEY_BUF_SIZE ];
448433 WORD m_wDataOffset = 0 ;
449434 char szKeyEntry [KEY_BUF_SIZE ];
450- BYTE byPrevXMode = XMODE_WRITE_BYTE ; // By default xdata_write mode
435+ // xdata mode is added to the binary only on byPrevXMode != byCurrXMode.
436+ // So, initializing the Previous xdata mode to SET_XMODE_NONE
437+ BYTE byPrevXMode = SET_XMODE_NONE ;
451438 BYTE byCurrXMode = SET_XMODE_NONE ;
452439 unsigned int nTemp = 0 ;
453440 DWORD dwCurrAddress = 0 , dwPrevAddress = 0 ;
@@ -591,4 +578,4 @@ int switchtec_convert_ini2bin(FILE *szINIFileName, char *pclog ,BYTE *m_pBinConf
591578 return TRUE;
592579}
593580
594- #endif
581+ #endif
0 commit comments