Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 602)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/FlashMenu.asm	(revision 620)
@@ -56,5 +56,5 @@
 	at	MENUITEM.szQuickInfo,		dw	g_szNfoFlashEepromType
 	at	MENUITEM.szHelp,			dw	g_szNfoFlashEepromType
-	at	MENUITEM.bFlags,			db	FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_VISIBLE
 	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOICE
 	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	CFGVARS.bEepromType
@@ -72,5 +72,5 @@
 	at	MENUITEM.szQuickInfo,		dw	g_szNfoFlashSDP
 	at	MENUITEM.szHelp,			dw	g_szHelpFlashSDP
-	at	MENUITEM.bFlags,			db	FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE
 	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOICE
 	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	CFGVARS.bSdpCommand
@@ -88,5 +88,5 @@
 	at	MENUITEM.szQuickInfo,		dw	g_szNfoFlashPageSize
 	at	MENUITEM.szHelp,			dw	g_szHelpFlashPageSize
-	at	MENUITEM.bFlags,			db	FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE | FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_PROGRAMVAR | FLG_MENUITEM_BYTEVALUE
 	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOICE
 	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	CFGVARS.bEepromPage
@@ -134,4 +134,6 @@
 	dw	EEPROM_TYPE.28256_32kiB
 	dw	EEPROM_TYPE.28512_64kiB
+	dw	EEPROM_TYPE.SST_39SF
+
 g_rgszValueToStringLookupForEepromType:
 	dw	g_szValueFlash2816
@@ -140,4 +142,5 @@
 	dw	g_szValueFlash28256
 	dw	g_szValueFlash28512
+	dw	g_szValueFlashSST39SF
 
 g_rgwChoiceToValueLookupForSdpCommand:
@@ -201,6 +204,40 @@
 .AlreadySet:
 	mov		si, g_MenupageForFlashMenu
-	jmp		Menupage_ChangeToNewMenupageInDSSI
-
+	ePUSH_T	bx, Menupage_ChangeToNewMenupageInDSSI
+	cmp		WORD [g_cfgVars+CFGVARS.bEepromType], EEPROM_TYPE.SST_39SF
+	jz		SHORT .DisableMenuitemsUnusedBySstFlash
+	; Fall to .EnableMenuitemsUnusedBySstFlash
+
+;--------------------------------------------------------------------
+; .EnableMenuitemsUnusedBySstFlash
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableMenuitemsUnusedBySstFlash:
+	mov		bx, g_MenuitemFlashSdpCommand
+	call	EnableMenuitemFromCSBX
+	mov		bx, g_MenuitemFlashPageSize
+	jmp		EnableMenuitemFromCSBX
+
+;--------------------------------------------------------------------
+; .DisableMenuitemsUnusedBySstFlash
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.DisableMenuitemsUnusedBySstFlash:
+	mov		bx, g_MenuitemFlashSdpCommand
+	call	DisableMenuitemFromCSBX
+	mov		bx, g_MenuitemFlashPageSize
+	jmp		DisableMenuitemFromCSBX
 
 ;--------------------------------------------------------------------
@@ -217,4 +254,9 @@
 	call	.MakeSureThatImageFitsInEeprom
 	jc		SHORT .InvalidFlashingParameters
+	cmp		WORD [cs:g_cfgVars+CFGVARS.bEepromType], EEPROM_TYPE.SST_39SF
+	jnz		SHORT .SkipAlignmentCheck
+	call	.MakeSureAddress32KAligned
+	jc		SHORT .InvalidFlashingParameters
+.SkipAlignmentCheck:
 	push	es
 	push	ds
@@ -225,6 +267,9 @@
 	call	.InitializeFlashvarsFromDSSI
 	mov		bx, si							; DS:BX now points to FLASHVARS
+	cmp		WORD [cs:g_cfgVars+CFGVARS.bEepromType], EEPROM_TYPE.SST_39SF
+	jz		SHORT .FlashWithoutProgressBar
 	add		si, BYTE FLASHVARS_size			; DS:SI now points to PROGRESS_DIALOG_IO
 	call	Dialogs_DisplayProgressDialogForFlashingWithDialogIoInDSSIandFlashvarsInDSBX
+.FlashComplete:
 	call	.DisplayFlashingResultsFromFlashvarsInDSBX
 
@@ -235,4 +280,8 @@
 	ret
 
+.FlashWithoutProgressBar:					; Worst case. SST devices will
+	call	FlashSst_WithFlashvarsInDSBX	; either complete flashing
+	jmp		SHORT .FlashComplete			; or timeout within 2 seconds. 
+
 ;--------------------------------------------------------------------
 ; .MakeSureThatImageFitsInEeprom
@@ -246,5 +295,5 @@
 ALIGN JUMP_ALIGN
 .MakeSureThatImageFitsInEeprom:
-	call	.GetSelectedEepromSizeInWordsToAX
+	call	Buffers_GetSelectedEepromSizeInWordsToAX
 	cmp		ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
 	jae		SHORT .ImageFitsInSelectedEeprom
@@ -254,5 +303,25 @@
 ALIGN JUMP_ALIGN, ret
 .ImageFitsInSelectedEeprom:
+.AlignmentIs32K:
 .DoNotGenerateChecksumByte:
+	ret
+
+;--------------------------------------------------------------------
+; .MakeSureAddress32KAligned
+;	Parameters:
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		CF:		Set if EEPROM segment is not 32K aligned
+;	Corrupts registers:
+;		AX, BX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.MakeSureAddress32KAligned:
+	mov		ax, [cs:g_cfgVars+CFGVARS.wEepromSegment]
+	and		ax, 007FFh
+	jz		SHORT .AlignmentIs32K
+	mov		dx, g_szErrAddrNot32KAligned
+	call	Dialogs_DisplayErrorFromCSDX
+	stc
 	ret
 
@@ -304,6 +373,11 @@
 	mov		[si+FLASHVARS.bEepromSdpCommand], al
 
+	mov		ax, SST_PAGE_SIZE
+	cmp		WORD [g_cfgVars+CFGVARS.bEepromType], EEPROM_TYPE.SST_39SF
+	jz		SHORT .UseSstPageSize
+
 	eMOVZX	bx, [cs:g_cfgVars+CFGVARS.bEepromPage]
 	mov		ax, [cs:bx+g_rgwEepromPageToSizeInBytes]
+.UseSstPageSize:
 	mov		[si+FLASHVARS.wEepromPageSize], ax
 
@@ -323,5 +397,5 @@
 ALIGN JUMP_ALIGN
 .GetNumberOfPagesToFlashToAX:
-	call	.GetSelectedEepromSizeInWordsToAX
+	call	Buffers_GetSelectedEepromSizeInWordsToAX
 	xor		dx, dx
 	eSHL_IM	ax, 1		; Size in bytes to...
@@ -335,20 +409,4 @@
 
 ;--------------------------------------------------------------------
-; .GetSelectedEepromSizeInWordsToAX
-;	Parameters:
-;		Nothing
-;	Returns:
-;		AX:		Selected EEPROM size in WORDs
-;	Corrupts registers:
-;		BX
-;--------------------------------------------------------------------
-ALIGN JUMP_ALIGN
-.GetSelectedEepromSizeInWordsToAX:
-	eMOVZX	bx, [cs:g_cfgVars+CFGVARS.bEepromType]
-	mov		ax, [cs:bx+g_rgwEepromTypeToSizeInWords]
-	ret
-
-
-;--------------------------------------------------------------------
 ; .DisplayFlashingResultsFromFlashvarsInDSBX
 ;	Parameters:
@@ -368,4 +426,5 @@
 .rgfnFlashResultMessage:
 	dw		.DisplayFlashSuccessful
+	dw		.DisplayDeviceDetectionError
 	dw		.DisplayPollingError
 	dw		.DisplayDataVerifyError
@@ -373,4 +432,5 @@
 
 ;--------------------------------------------------------------------
+; .DisplayDeviceDetectionError
 ; .DisplayPollingError
 ; .DisplayDataVerifyError
@@ -383,4 +443,9 @@
 ;		AX, DX, DI, ES
 ;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.DisplayDeviceDetectionError:
+	mov		dx, g_szErrEepromDetection
+	jmp		Dialogs_DisplayErrorFromCSDX
+
 ALIGN JUMP_ALIGN
 .DisplayPollingError:
