Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/MenuCfg.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/MenuCfg.inc	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/MenuCfg.inc	(revision 57)
@@ -0,0 +1,19 @@
+; File name		:	MenuCfg.inc
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	5.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Menu configuration.
+%ifndef MENUCFG_INC
+%define MENUCFG_INC
+
+TITLE_LINES_IN_MENU			EQU		3
+INFO_LINES_IN_MENU			EQU		4
+MENU_WIDTH					EQU		40
+MAX_VALUE_STRING_LENGTH		EQU		12
+
+
+KEY_DISPLAY_ITEM_HELP		EQU		3Bh		; F1
+
+
+%endif ; MENUCFG_INC
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/MenuStructs.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/MenuStructs.inc	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/MenuStructs.inc	(revision 57)
@@ -0,0 +1,57 @@
+; File name		:	MenuStructs.inc
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	2.11.2010
+; Author		:	Tomi Tilli
+; Description	:	Menu page and item structs.
+%ifndef MENU_STRUCTS_INC
+%define MENU_STRUCTS_INC
+
+struc MENUPAGE
+	.fnEnter			resb	2	; Function to initialize MENUPAGE
+	.wMenuitems			resb	2	; Number of MENUITEM structs
+	.rgMenuitem:					; All MENUITEM structs in this MENUPAGE
+endstruc
+
+struc MENUITEM
+	.fnActivate			resb	2	; Offset to item activation function
+	.fnFormatValue		resb	2	; Offset to item value formatting function
+
+	.szName				resb	2	; Offset to item name string
+	.szQuickInfo		resb	2	; Offset to item quick information string
+	.szHelp				resb	2	; Offset to item help string
+
+	.bFlags				resb	1	; Item flags
+	.bType				resb	1	; Item type
+	.itemValue			resb	ITEM_VALUE_size		; ITEM_VALUE for automated item handling
+endstruc
+
+; Bit defines for MENUITEM.bFlags
+FLG_MENUITEM_VISIBLE		EQU	(1<<0)	; Item is visible
+FLG_MENUITEM_MODIFY_MENU	EQU	(1<<1)	; Item modifies visibility of other items
+FLG_MENUITEM_FLAGVALUE		EQU	(1<<2)	; Item value is single bit
+FLG_MENUITEM_BYTEVALUE		EQU	(1<<3)	; Item value is single byte
+
+; Values for MENUITEM.bType
+TYPE_MENUITEM_PAGEBACK		EQU	(0<<1)	; Item returns to previous MENUPAGE
+TYPE_MENUITEM_PAGENEXT		EQU	(1<<1)	; Item changes to next MENUPAGE
+TYPE_MENUITEM_ACTION		EQU	(2<<1)	; Non-configurable item
+TYPE_MENUITEM_MULTICHOISE	EQU	(3<<1)	; Item with multiple predefined choises
+TYPE_MENUITEM_UNSIGNED		EQU	(4<<1)	; Menuitem with user inputted unsigned decimal value
+TYPE_MENUITEM_HEX			EQU	(5<<1)	; Menuitem with user inputted hexadecimal value
+
+
+struc ITEM_VALUE
+	.wRomvarsValueOffset	resb	2	; ROMVARS offset to actual value to be configured
+	.szDialogTitle			resb	2	; Dialog title string
+
+	.szMultichoise			resb	2	; Multiple choises in one string
+	.rgwChoiseToValueLookup	resb	2	; Ptr to lookup table for translating selected choise to actual value
+	.rgszValueToStringLookup:			; Ptr to lookup table for translating value to string
+	.wMinValue				resb	2	; Minimum allowed integer value
+	.wMaxValue:
+	.wValueBitmask			resb	2	; Bitmask for item value flag
+endstruc
+
+
+%endif ; MENU_STRUCTS_INC
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Inc/Variables.inc	(revision 57)
@@ -0,0 +1,56 @@
+; File name		:	Variables.inc
+; Project name	:	XTIDE Univeral BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	1.11.2010
+; Author		:	Tomi Tilli
+; Description	:	Global variables for configuration program.
+%ifndef VARIABLES_INC
+%define VARIABLES_INC
+
+; Equates and defines
+MAX_ALLOWED_IDE_CONTROLLERS			EQU		5	; Maximum number of IDE controllers
+EEPROM_POLLING_TIMEOUT_TICKS		EQU		3	; 1 tick = 54.9 ms
+XTIDE_SIGNATURE_LENGTH				EQU		8	; XTIDE Universal BIOS signature string length
+NUMBER_OF_SUPPORTED_EEPROM_SIZES	EQU		5
+MAX_EEPROM_SIZE						EQU	65536
+
+
+; Program global variables
+struc CFGVARS
+	.pMenupage			resb	2			; Offset to MENUPAGE to display
+	.wFlags				resb	2			; Program flags
+	.wImageSize			resb	2			; Size in bytes for BIOS image to be flashed (0=65536)
+	.wEepromSegment		resb	2			; Segment where EEPROM is located
+	.bPageSize			resb	1			; EEPROM page size in bytes
+	.bSdpCommand		resb	1			; Command for Software Data Protection
+	.szOpenedFile		resb	FILENAME_BUFFER_SIZE
+	.flashVars			resb	FLASHVARS_size
+endstruc
+
+; Bit defines for CFGVARS.wFlags
+FLG_CFGVARS_FILELOADED	EQU		(1<<0)	; BIOS is loaded from file
+FLG_CFGVARS_ROMLOADED	EQU		(1<<1)	; BIOS is loaded from EEPROM
+FLG_CFGVARS_UNSAVED		EQU		(1<<2)	; BIOS has unsaved changes
+FLG_CFGVARS_CHECKSUM	EQU		(1<<3)	; Generate checksum byte
+
+; SDP command for CFGVARS.bSdpCommand
+CMD_SDP_NONE			EQU		(0<<1)	; Do not use any SDP command
+CMD_SDP_ENABLE			EQU		(1<<1)	; Flash with SDP enable command
+CMD_SDP_DISABLE			EQU		(2<<1)	; Flash with SDP disable command
+
+; Default CFGVARS settings
+DEFAULT_CFGVARS_FLAGS	EQU		FLG_CFGVARS_CHECKSUM
+DEFAULT_EEPROM_SEGMENT	EQU		0D000h
+DEFAULT_PAGE_SIZE		EQU		1
+DEFAULT_SDP_COMMAND		EQU		CMD_SDP_ENABLE
+
+
+; Variables required for flashing
+struc FLASHVARS
+	.wTotalPages		resb	2		; Total number of pages to write
+	.wPagesLeft			resb	2		; Pages left to write
+	.wByteOffset		resb	2		; Offset to byte to write next
+endstruc
+
+
+%endif ; VARIABLES_INC
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm	(revision 57)
@@ -0,0 +1,216 @@
+; File name		:	BiosFile.asm
+; Project name	:	XTIDE Univeral BIOS Configurator v2
+; Created date	:	10.10.2010
+; Last update	:	24.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for loading and saving BIOS image file.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; BiosFile_LoadFileFromDSSItoRamBuffer
+;	Parameters:
+;		DS:SI:	Name of file to open
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BiosFile_LoadFileFromDSSItoRamBuffer:
+	push	ds
+
+	call	.OpenFileForLoadingFromDSSIandGetSizeToCX
+	jc		SHORT .DisplayErrorMessage
+	call	.LoadFileWithNameInDSSIhandleInBXandSizeInCXtoRamBuffer
+	jc		SHORT .DisplayErrorMessage
+
+	mov		ax, FLG_CFGVARS_FILELOADED
+	call	Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration
+	call	DisplayFileLoadedSuccesfully
+	call	FileIO_CloseUsingHandleFromBX
+	jmp		SHORT .Return
+
+.DisplayErrorMessage:
+	call	FileIO_CloseUsingHandleFromBX
+	call	DisplayFailedToLoadFile
+ALIGN JUMP_ALIGN
+.Return:
+	pop		ds
+	ret
+
+;--------------------------------------------------------------------
+; .OpenFileForLoadingFromDSSIandGetSizeToCX
+;	Parameters:
+;		DS:SI:	Name of file to open
+;	Returns:
+;		BX:		File handle (if succesfull)
+;		CX:		File size (if succesfull)
+;		CF:		Clear if successfull
+;				Set if error
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.OpenFileForLoadingFromDSSIandGetSizeToCX:
+	mov		al, FILE_ACCESS.ReadOnly
+	call	FileIO_OpenWithPathInDSSIandFileAccessInAL
+	jc		SHORT .FileError
+	call	FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
+	jc		SHORT .FileError
+
+	cmp		dx, BYTE 1		; File size over 65536 bytes?
+	ja		SHORT .FileTooBig
+	jb		SHORT .CopyFileSizeToCX
+	test	ax, ax
+	jnz		SHORT .FileTooBig
+	dec		ax				; Prepare to load 65535 bytes
+.CopyFileSizeToCX:
+	xchg	cx, ax
+	clc
+	ret
+.FileTooBig:
+	call	DisplayFileTooBig
+	stc
+.FileError:
+	ret
+
+;--------------------------------------------------------------------
+; .LoadFileWithNameInDSSIhandleInBXandSizeInCXtoRamBuffer
+;	Parameters:
+;		BX:		File Handle
+;		CX:		File size
+;		DS:SI:	File name
+;	Returns:
+;		CF:		Clear if successfull
+;				Set if error
+;	Corrupts registers:
+;		AX, SI, DI, DS
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.LoadFileWithNameInDSSIhandleInBXandSizeInCXtoRamBuffer:
+	push	es
+
+	call	Buffers_GetFileBufferToESDI
+	call	Registers_ExchangeDSSIwithESDI
+	call	FileIO_ReadCXbytesToDSSIusingHandleFromBX
+	jnc		SHORT .StoreFileNameToCfgvarsFromESDI
+
+	pop		es
+	ret
+
+ALIGN JUMP_ALIGN
+.StoreFileNameToCfgvarsFromESDI:
+	push	cx
+
+	call	Registers_CopyESDItoDSSI	; File name in DS:SI
+	push	cs
+	pop		es
+	mov		di, g_cfgVars+CFGVARS.szOpenedFile
+	cld
+	call	String_CopyDSSItoESDIandGetLengthToCX
+
+	pop		cx
+	pop		es
+	clc
+	ret
+
+
+;--------------------------------------------------------------------
+; BiosFile_SaveUnsavedChanges
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BiosFile_SaveUnsavedChanges:
+	push	ds
+
+	push	cs
+	pop		ds
+	mov		si, g_cfgVars+CFGVARS.szOpenedFile
+	call	BiosFile_SaveRamBufferToFileInDSSI
+
+	pop		ds
+	ret
+
+
+;--------------------------------------------------------------------
+; BiosFile_SaveRamBufferToFileInDSSI
+;	Parameters:
+;		DS:SI:	Name of file to save
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+BiosFile_SaveRamBufferToFileInDSSI:
+	push	es
+	push	ds
+
+	mov		al, FILE_ACCESS.WriteOnly
+	call	FileIO_OpenWithPathInDSSIandFileAccessInAL
+	jc		SHORT .DisplayErrorMessage
+
+	call	Buffers_GenerateChecksum
+	call	Buffers_GetFileBufferToESDI
+	call	Registers_CopyESDItoDSSI
+	mov		cx, [cs:g_cfgVars+CFGVARS.wImageSize]
+	call	FileIO_WriteCXbytesFromDSSIusingHandleFromBX
+	jc		SHORT .DisplayErrorMessage
+
+	call	Buffers_ClearUnsavedChanges
+	call	DisplayFileSavedSuccesfully
+	jmp		SHORT .Return
+
+.DisplayErrorMessage:
+	call	FileIO_CloseUsingHandleFromBX
+	call	DisplayFailedToSaveFile
+ALIGN JUMP_ALIGN
+.Return:
+	pop		ds
+	pop		es
+	ret
+
+
+;--------------------------------------------------------------------
+; DisplayFileLoadedSuccesfully
+; DisplayFileSavedSuccesfully
+; DisplayFailedToLoadFile
+; DisplayFailedToSaveFile
+; DisplayFileTooBig
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+DisplayFileLoadedSuccesfully:
+	mov		dx, g_szDlgMainLoadFile
+	jmp		Dialogs_DisplayNotificationFromCSDX
+
+ALIGN JUMP_ALIGN
+DisplayFileSavedSuccesfully:
+	mov		dx, g_szDlgMainSaveFile
+	jmp		Dialogs_DisplayNotificationFromCSDX
+
+DisplayFailedToLoadFile:
+	mov		dx, g_szDlgMainLoadErr
+	jmp		Dialogs_DisplayErrorFromCSDX
+
+DisplayFailedToSaveFile:
+	mov		dx, g_szDlgMainSaveErr
+	jmp		Dialogs_DisplayErrorFromCSDX
+
+DisplayFileTooBig:
+	mov		dx, g_szDlgMainFileTooBig
+	jmp		Dialogs_DisplayErrorFromCSDX
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm	(revision 57)
@@ -0,0 +1,248 @@
+; File name		:	Buffers.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	6.10.2010
+; Last update	:	10.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for accessing file and flash buffers.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; Buffers_Clear
+;	Parameters:
+;		Nothing
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, CX, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_Clear:
+	call	Buffers_GetFileBufferToESDI
+	mov		cx, ROMVARS_size
+	jmp		Memory_ZeroESDIwithSizeInCX
+
+
+;--------------------------------------------------------------------
+; Buffers_IsXtideUniversalBiosLoaded
+;	Parameters:
+;		Nothing
+;	Returns:
+;		ZF:		Set if supported version of XTIDE Universal BIOS is loaded
+;				Cleared no file or some other file is loaded
+;	Corrupts registers:
+;		CX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_IsXtideUniversalBiosLoaded:
+	test	WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
+	jz		SHORT .NoFileOrBiosLoaded
+
+	call	Buffers_GetFileBufferToESDI
+	jmp		SHORT Buffers_IsXtideUniversalBiosSignatureInESDI
+.NoFileOrBiosLoaded:
+	or		cl, 1		; Clear ZF
+	ret
+
+
+;--------------------------------------------------------------------
+; Buffers_IsXtideUniversalBiosSignatureInESDI
+;	Parameters:
+;		ES:DI:	Ptr to possible XTIDE Universal BIOS location
+;	Returns:
+;		ZF:		Set if supported version of XTIDE Universal BIOS is loaded
+;				Cleared no file or some other file is loaded
+;	Corrupts registers:
+;		CX, SI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_IsXtideUniversalBiosSignatureInESDI:
+	push	di
+
+	mov		si, g_szXtideUniversalBiosSignature
+	add		di, BYTE ROMVARS.rgbSign
+	mov		cx, XTIDE_SIGNATURE_LENGTH / 2
+	cld
+	eSEG_STR repe, cs, cmpsw
+
+	pop		di
+	ret
+
+
+;--------------------------------------------------------------------
+; Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration
+;	Parameters:
+;		AX:		EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
+;		CX:		EEPROM size in bytes
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration:
+	and		WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
+	or		WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
+	; Fall to .AdjustBiosImageSizeToSupportedEepromSize
+
+;--------------------------------------------------------------------
+; .AdjustBiosImageSizeInCXtoSupportedEepromSize
+;	Parameters:
+;		CX:		Size of loaded BIOS image
+;	Returns:
+;		CX:		Size of BIOS image (and EEPROM required)
+;	Corrupts registers:
+;		AX, BX, DX
+;--------------------------------------------------------------------
+.AdjustBiosImageSizeInCXtoSupportedEepromSize:
+	mov		bx, .rgwSupportedEepromSizes
+	mov		dx, NUMBER_OF_SUPPORTED_EEPROM_SIZES-1
+ALIGN JUMP_ALIGN
+.CheckNextEepromSize:
+	cmp		cx, [cs:bx]
+	je		SHORT .StoreImageSizeFromCX
+	jb		SHORT .AppendZeroesToTheEndOfBuffer
+	inc		bx
+	inc		bx
+	dec		dx
+	jnz		SHORT .CheckNextEepromSize
+	xor		cx, cx
+	jmp		SHORT .StoreImageSizeFromCX	; 0 = 65536
+ALIGN WORD_ALIGN
+.rgwSupportedEepromSizes:
+	dw		4<<10
+	dw		8<<10
+	dw		16<<10
+	dw		32<<10
+
+;--------------------------------------------------------------------
+; .AppendZeroesToTheEndOfBuffer
+;	Parameters:
+;		CX:		Size of loaded BIOS image
+;		CS:BX:	Ptr to EEPROM size
+;	Returns:
+;		CX:		EEPROM size
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.AppendZeroesToTheEndOfBuffer:
+	push	es
+	push	di
+
+	call	Buffers_GetFileBufferToESDI
+	mov		ax, [cs:bx]
+	sub		ax, cx			; AX = zeroes to append
+	xchg	ax, cx			; AX = BIOS image size, CX = zeroes to append
+	add		di, ax
+	call	Memory_ZeroESDIwithSizeInCX
+	mov		cx, [cs:bx]
+
+	pop		di
+	pop		es
+	; Fall to .StoreImageSizeFromCX
+
+;--------------------------------------------------------------------
+; .StoreImageSizeFromCX
+;	Parameters:
+;		CX:		Size of BIOS image (and EEPROM required)
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.StoreImageSizeFromCX:
+	mov		[cs:g_cfgVars+CFGVARS.wImageSize], cx
+	ret
+
+
+;--------------------------------------------------------------------
+; Buffers_SetUnsavedChanges
+; Buffers_ClearUnsavedChanges
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_SetUnsavedChanges:
+	or		WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
+	ret
+
+ALIGN JUMP_ALIGN
+Buffers_ClearUnsavedChanges:
+	and		WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
+	ret
+
+
+;--------------------------------------------------------------------
+; Buffers_GenerateChecksum
+;	Parameters:
+;		Nothing
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_GenerateChecksum:
+	push	es
+
+	call	Buffers_GetFileBufferToESDI
+	mov		cx, [cs:g_cfgVars+CFGVARS.wImageSize]
+	dec		cx				; Leave space for checksum byte
+	xor		ax, ax
+ALIGN JUMP_ALIGN
+.SumNextByte:
+	add		al, [es:di]
+	inc		di
+	loop	.SumNextByte
+	neg		al
+	mov		[es:di], al
+
+	pop		es
+	ret
+
+
+;--------------------------------------------------------------------
+; Buffers_GetRomvarsValueToAXfromOffsetInBX
+;	Parameters:
+;		BX:		ROMVARS offset
+;	Returns:
+;		AX:		Value
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_GetRomvarsValueToAXfromOffsetInBX:
+	push	es
+	push	di
+	call	Buffers_GetFileBufferToESDI
+	mov		ax, [es:bx+di]
+	pop		di
+	pop		es
+	ret
+
+
+;--------------------------------------------------------------------
+; Buffers_GetFileBufferToESDI
+; Buffers_GetFileDialogItemBufferToESDI
+;	Parameters:
+;		Nothing
+;	Returns:
+;		ES:DI:	Ptr to file buffer
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Buffers_GetFileDialogItemBufferToESDI:
+Buffers_GetFileBufferToESDI:
+	mov		di, cs
+	add		di, 1000h		; Change to next 64k page
+	mov		es, di
+	xor		di, di			; Ptr now in ES:DI
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Dialogs.asm	(revision 57)
@@ -0,0 +1,125 @@
+; File name		:	Dialogs.asm
+; Project name	:	XTIDE Univeral BIOS Configurator v2
+; Created date	:	10.10.2010
+; Last update	:	10.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for displaying dialogs.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; Dialogs_DisplayHelpFromCSDXwithTitleInCSDI
+;	Parameters:
+;		CS:DX:	Ptr to help string to display
+;		CS:DI:	Ptr to title string for help dialog
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Dialogs_DisplayHelpFromCSDXwithTitleInCSDI:
+	push	ds
+	push	si
+	push	di
+	push	cx
+
+	mov		cx, DIALOG_INPUT_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	call	InitializeDialogInputFromDSSI
+	mov		[si+DIALOG_INPUT.fszTitle], di
+	jmp		SHORT DisplayMessageDialogWithMessageInCSDXandDialogInputInDSSI
+
+;--------------------------------------------------------------------
+; Dialogs_DisplayNotificationFromCSDX
+; Dialogs_DisplayErrorFromCSDX
+;	Parameters:
+;		CS:DX:	Ptr to notification string to display
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Dialogs_DisplayNotificationFromCSDX:
+	push	ds
+	push	si
+	push	di
+	push	cx
+
+	mov		cx, DIALOG_INPUT_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	call	InitializeDialogInputFromDSSI
+	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szNotificationDialog
+	jmp		SHORT DisplayMessageDialogWithMessageInCSDXandDialogInputInDSSI
+
+ALIGN JUMP_ALIGN
+Dialogs_DisplayErrorFromCSDX:
+	push	ds
+	push	si
+	push	di
+	push	cx
+
+	mov		cx, DIALOG_INPUT_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	mov		WORD [si+DIALOG_INPUT.fszTitle], g_szErrorDialog
+ALIGN JUMP_ALIGN
+DisplayMessageDialogWithMessageInCSDXandDialogInputInDSSI:
+	call	InitializeDialogInputFromDSSI
+	mov		[si+DIALOG_INPUT.fszItems], dx
+	CALL_MENU_LIBRARY DisplayMessageWithInputInDSSI
+
+	add		sp, BYTE DIALOG_INPUT_size
+	pop		cx
+	pop		di
+	pop		si
+	pop		ds
+	ret
+
+;--------------------------------------------------------------------
+; InitializeDialogInputFromDSSI
+;	Parameters:
+;		DS:SI:	Ptr to DIALOG_INPUT
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+InitializeDialogInputFromDSSI:
+	mov		[si+DIALOG_INPUT.fszTitle+2], cs
+	mov		[si+DIALOG_INPUT.fszItems+2], cs
+	mov		WORD [si+DIALOG_INPUT.fszInfo], g_szGenericDialogInfo
+	mov		[si+DIALOG_INPUT.fszInfo+2], cs
+	ret
+
+
+;--------------------------------------------------------------------
+; Dialogs_DisplayFileDialogWithDialogIoInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to FILE_DIALOG_IO
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Dialogs_DisplayFileDialogWithDialogIoInDSSI:
+	push	es
+
+	call	Buffers_GetFileDialogItemBufferToESDI
+	mov		WORD [si+FILE_DIALOG_IO.fszTitle], g_szDlgFileTitle
+	mov		[si+FILE_DIALOG_IO.fszTitle+2], cs
+	mov		[si+FILE_DIALOG_IO.fszItemBuffer], di
+	mov		[si+FILE_DIALOG_IO.fszItemBuffer+2], es
+	mov		BYTE [si+FILE_DIALOG_IO.bDialogFlags], FLG_FILEDIALOG_DRIVES
+	mov		BYTE [si+FILE_DIALOG_IO.bFileAttributes], FLG_FILEATTR_DIRECTORY | FLG_FILEATTR_ARCHIVE
+	mov		WORD [si+FILE_DIALOG_IO.fpFileFilterString], g_szDlgFileFilter
+	mov		[si+FILE_DIALOG_IO.fpFileFilterString+2], cs
+	CALL_MENU_LIBRARY GetFileNameWithIoInDSSI
+
+	pop		es
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/EEPROM.asm	(revision 57)
@@ -0,0 +1,148 @@
+; File name		:	EEPROM.asm
+; Project name	:	XTIDE Univeral BIOS Configurator v2
+; Created date	:	19.4.2010
+; Last update	:	10.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for managing EEPROM contents.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; EEPROM_LoadXtideUniversalBiosFromRomToRamBuffer
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CX:		BIOS size in bytes
+;	Corrupts registers:
+;		AX, BX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+EEPROM_LoadXtideUniversalBiosFromRomToRamBuffer:
+	push	es
+
+	call	EEPROM_FindXtideUniversalBiosROMtoESDI
+	call	.GetXtideUniversalBiosSizeFromEStoCX
+	xor		si, si				; Load from beginning of ROM
+	call	LoadBytesFromRomToRamBuffer
+
+	call	.GetXtideUniversalBiosSizeFromEStoCX
+	pop		es
+	ret
+
+;--------------------------------------------------------------------
+; .GetXtideUniversalBiosSizeFromEStoCX
+;	Parameters:
+;		Nothing
+;	Returns:
+;		AX:		Bios size in bytes
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.GetXtideUniversalBiosSizeFromEStoCX:
+	eMOVZX	cx, BYTE [es:ROMVARS.bRomSize]
+	eSHL_IM	cx, 9				; *= 512 for byte count
+	ret
+
+
+;--------------------------------------------------------------------
+; EEPROM_LoadOldSettingsFromRomToRamBuffer
+;	Parameters:
+;		Nothing
+;	Returns:
+;		CF:		Set if EEPROM was found
+;				Cleared if EEPROM not found
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+EEPROM_LoadOldSettingsFromRomToRamBuffer:
+	mov		cx, ROMVARS_size - ROMVARS.wFlags	; Number of bytes to load
+	mov		si, ROMVARS.wFlags					; Offset where to start loading
+	; Fall to LoadBytesFromRomToRamBuffer
+
+;--------------------------------------------------------------------
+; LoadBytesFromRomToRamBuffer
+;	Parameters:
+;		CX:		Number of bytes to load from ROM
+;		SI:		Offset to first byte to load
+;	Returns:
+;		CF:		Set if EEPROM was found
+;				Cleared if EEPROM not found
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+LoadBytesFromRomToRamBuffer:
+	push	es
+	push	ds
+
+	call	EEPROM_FindXtideUniversalBiosROMtoESDI
+	jnc		SHORT .XtideUniversalBiosNotFound
+	push	es
+	pop		ds											; DS:SI points to ROM
+
+	call	Buffers_GetFileBufferToESDI
+	mov		di, si										; ES:DI points to RAM buffer
+
+	cld
+	call	Memory_CopyCXbytesFromDSSItoESDI
+	stc
+
+.XtideUniversalBiosNotFound:
+	pop		ds
+	pop		es
+	ret
+
+
+;--------------------------------------------------------------------
+; EEPROM_FindXtideUniversalBiosROMtoESDI
+;	Parameters:
+;		Nothing
+;	Returns:
+;		ES:DI:	EEPROM segment
+;		CF:		Set if EEPROM was found
+;				Cleared if EEPROM not found
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+EEPROM_FindXtideUniversalBiosROMtoESDI:
+	push	si
+	push	cx
+
+	xor		di, di					; Zero DI (offset)
+	mov		bx, 0C000h				; First possible ROM segment
+ALIGN JUMP_ALIGN
+.SegmentLoop:
+	mov		es, bx					; Possible ROM segment to ES
+	call	Buffers_IsXtideUniversalBiosSignatureInESDI
+	je		SHORT .RomFound
+	add		bx, 200h				; Increment by 8kB
+	jnc		SHORT .SegmentLoop		; Loop until segment overflows
+	clc
+	jmp		SHORT .ReturnWithoutUpdatingCF
+ALIGN JUMP_ALIGN
+.RomFound:
+	stc
+.ReturnWithoutUpdatingCF:
+	pop		cx
+	pop		si
+	ret
+
+
+;--------------------------------------------------------------------
+; EEPROM_GetPointerForFlashingToESDI
+;	Parameters:
+;		Nothing
+;	Returns:
+;		ES:DI:	Ptr to EEPROM to be flashed
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+EEPROM_GetPointerForFlashingToESDI:
+	mov		es, [cs:g_cfgVars+CFGVARS.wEepromSegment]
+	xor		di, di
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm	(revision 57)
@@ -0,0 +1,106 @@
+; File name		:	main.asm
+; Project name	:	XTIDE Univeral BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	3.11.2010
+; Author		:	Tomi Tilli
+; Description	:	Program start and exit.			
+
+; Include .inc files
+%define INCLUDE_MENU_DIALOGS
+%include "AssemblyLibrary.inc"	; Assembly Library. Must be included first!
+%include "Romvars.inc"			; XTIDE Universal BIOS variables
+
+%include "MenuCfg.inc"
+%include "MenuStructs.inc"
+%include "Variables.inc"
+
+
+; Section containing code
+SECTION .text
+
+
+; Program first instruction.
+ORG	100h						; Code starts at offset 100h (DOS .COM)
+Start:
+	jmp		Main_Start
+
+; Include library sources
+%include "AssemblyLibrary.asm"
+
+; Include sources for this program
+%include "BiosFile.asm"
+%include "Buffers.asm"
+%include "Dialogs.asm"
+%include "EEPROM.asm"
+%include "MenuEvents.asm"
+%include "Menuitem.asm"
+%include "MenuitemPrint.asm"
+%include "Menupage.asm"
+%include "Strings.asm"
+
+%include "ConfigurationMenu.asm"
+%include "IdeControllerMenu.asm"
+%include "MainMenu.asm"
+%include "MasterSlaveMenu.asm"
+
+
+
+;--------------------------------------------------------------------
+; Program start
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Main_Start:
+	CALL_DISPLAY_LIBRARY InitializeDisplayContext
+	CALL_DISPLAY_LIBRARY ClearScreen
+
+	call	Main_InitializeCfgVars
+	call	MenuEvents_DisplayMenu
+
+	; Exit to DOS
+	CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware
+	mov 	ax, 4C00h			; Exit to DOS
+	int 	21h
+
+
+;--------------------------------------------------------------------
+; Main_InitializeCfgVars
+;	Parameters:
+;		DS:		Segment to CFGVARS
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Main_InitializeCfgVars:
+	push	es
+
+	call	Buffers_Clear
+	call	EEPROM_FindXtideUniversalBiosROMtoESDI
+	jnc		SHORT .InitializationCompleted
+	mov		[CFGVARS.wEepromSegment], es
+.InitializationCompleted:
+	pop		es
+	ret
+
+
+; Section containing initialized data
+SECTION .data
+
+ALIGN WORD_ALIGN
+g_cfgVars:
+istruc CFGVARS
+	at	CFGVARS.pMenupage,		dw	g_MenupageForMainMenu
+	at	CFGVARS.wFlags,			dw	DEFAULT_CFGVARS_FLAGS
+	at	CFGVARS.wEepromSegment,	dw	DEFAULT_EEPROM_SEGMENT
+	at	CFGVARS.bPageSize,		db	DEFAULT_PAGE_SIZE
+	at	CFGVARS.bSdpCommand,	db	DEFAULT_SDP_COMMAND
+iend
+
+
+; Section containing uninitialized data
+SECTION .bss
+
+g_uninitialized:
+	resb		32768
+
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm	(revision 57)
@@ -0,0 +1,234 @@
+; File name		:	MenuEvents.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	6.10.2010
+; Author		:	Tomi Tilli
+; Description	:	Menu event handling.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; MenuEvents_DisplayMenu
+;	Parameters:
+;		Nothing
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except segments
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuEvents_DisplayMenu:
+	mov		ax, g_MenupageForMainMenu
+	mov		dx, ds
+	mov		bx, MenuEventHandler
+	CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
+	ret
+
+
+;--------------------------------------------------------------------
+; MenuEventHandler
+;	Common parameters for all events:
+;		BX:			Menu event (anything from MENUEVENT struct)
+;		SS:BP:		Menu library handle
+;	Common return values for all events:
+;		CF:			Set if event processed
+;					Cleared if event not processed
+;	Corrupts registers:
+;		All
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuEventHandler:
+	cmp		bx, MENUEVENT.RefreshItemFromCX	; Above last supported item?
+	ja		SHORT .EventNotHandled
+	jmp		[bx+.rgfnEventSpecificHandlers]
+.EventNotHandled:
+.IdleProcessing:
+	clc
+	ret
+
+ALIGN WORD_ALIGN
+.rgfnEventSpecificHandlers:
+	dw		.InitializeMenuinitFromDSSI
+	dw		.ExitMenu
+	dw		.IdleProcessing
+	dw		.ItemHighlightedFromCX
+	dw		.ItemSelectedFromCX
+	dw		.KeyStrokeInAX
+	dw		.RefreshTitle
+	dw		.RefreshInformation
+	dw		.RefreshItemFromCX
+
+
+; Parameters:
+;	DS:SI:		Ptr to MENUINIT struct to initialize
+; Returns:
+;	DS:SI:		Ptr to initialized MENUINIT struct
+ALIGN JUMP_ALIGN
+.InitializeMenuinitFromDSSI:
+	push	ds
+	push	cs
+	pop		ds
+	mov		di, g_MenupageForMainMenu
+	call	Menupage_SetActiveMenupageFromDSDI
+	call	Menupage_GetVisibleMenuitemsToAXfromDSDI
+	pop		ds
+
+	mov		WORD [si+MENUINIT.wTimeoutTicks], NO_TIMEOUT_USED
+	mov		WORD [si+MENUINIT.wItems], ax
+	mov		WORD [si+MENUINIT.bTitleLines], TITLE_LINES_IN_MENU
+	mov		WORD [si+MENUINIT.bInfoLines], INFO_LINES_IN_MENU
+	mov		WORD [si+MENUINIT.bWidth], MENU_WIDTH
+	CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
+	mov		[si+MENUINIT.bHeight], ah
+	stc
+	ret
+
+
+; Parameters:
+;	None
+ALIGN JUMP_ALIGN
+.ExitMenu:
+	stc
+	ret
+
+
+; Parameters:
+;	CX:			Index of new highlighted item
+;	DX:			Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
+ALIGN JUMP_ALIGN
+.ItemHighlightedFromCX:
+	CALL_MENU_LIBRARY ClearInformationArea
+	CALL_MENU_LIBRARY RefreshInformation
+	stc
+	ret
+
+
+; Parameters:
+;	CX:			Index of selected item
+ALIGN JUMP_ALIGN
+.ItemSelectedFromCX:
+	call	Menupage_GetActiveMenupageToDSDI
+	call	Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
+	call	[si+MENUITEM.fnActivate]
+	stc
+	ret
+
+
+; Parameters:
+;	AL:			ASCII character for the key
+;	AH:			Keyboard library scan code for the key
+ALIGN JUMP_ALIGN
+.KeyStrokeInAX:
+	cmp		ah, KEY_DISPLAY_ITEM_HELP
+	jne		SHORT .EventNotHandled
+
+	call	Menupage_GetActiveMenupageToDSDI
+	CALL_MENU_LIBRARY GetHighlightedItemToAX
+	xchg	cx, ax
+	call	Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
+	call	Menuitem_DisplayHelpMessageFromDSSI
+	stc
+	ret
+
+
+; Parameters:
+;	CX:			Index of item to refresh
+;	Cursor has been positioned to the beginning of item line
+ALIGN JUMP_ALIGN
+.RefreshItemFromCX:
+	cmp		cx, NO_ITEM_HIGHLIGHTED
+	je		SHORT .NothingToRefresh
+	call	Menupage_GetActiveMenupageToDSDI
+	call	Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
+	jnc		SHORT .NothingToRefresh
+	call	MenuitemPrint_NameWithPossibleValueFromDSSI
+.NothingToRefresh:
+	stc
+	ret
+
+
+; Parameters:
+;	CX:			Index of highlighted item
+;	Cursor has been positioned to the beginning of first line
+ALIGN JUMP_ALIGN
+.RefreshInformation:
+	cmp		cx, NO_ITEM_HIGHLIGHTED
+	je		SHORT .NothingToRefresh
+	call	Menupage_GetActiveMenupageToDSDI
+	call	Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
+	call	MenuitemPrint_PrintQuickInfoFromDSSI
+	stc
+	ret
+
+
+; Parameters:
+;	CX:			Index of highlighted item
+;	Cursor has been positioned to the beginning of first line
+ALIGN JUMP_ALIGN
+.RefreshTitle:
+	call	.PrintProgramName
+	call	.PrintLoadStatus
+	call	.PrintStatusOfUnsavedChanges
+	stc
+	ret
+
+ALIGN JUMP_ALIGN
+.PrintProgramName:
+	mov		si, g_szProgramTitle
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+	ret
+
+ALIGN JUMP_ALIGN
+.PrintLoadStatus:
+	mov		ax, [g_cfgVars+CFGVARS.wFlags]
+	test	ax, FLG_CFGVARS_FILELOADED
+	jnz		SHORT .PrintNameOfLoadedFile
+	test	ax, FLG_CFGVARS_ROMLOADED
+	jnz		SHORT .PrintLoadedEeprom
+	; Fall to .PrintNothingLoaded
+
+.PrintNothingLoaded:
+	mov		si, g_szBiosIsNotLoaded
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+	ret
+
+ALIGN JUMP_ALIGN
+.PrintNameOfLoadedFile:
+	mov		si, g_cfgVars+CFGVARS.szOpenedFile
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+	jmp		SHORT .PrintTypeOfLoadedBios
+
+ALIGN JUMP_ALIGN
+.PrintLoadedEeprom:
+	mov		si, g_szEEPROM
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+	; Fall to .PrintTypeOfLoadedBios
+
+ALIGN JUMP_ALIGN
+.PrintTypeOfLoadedBios:
+	mov		si, g_szSourceAndTypeSeparator
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+	call	Buffers_IsXtideUniversalBiosLoaded
+	jne		SHORT .PrintUnidentifiedType
+
+	call	Buffers_GetFileBufferToESDI
+	mov		bx, es
+	lea		si, [di+ROMVARS.szVersion]
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
+	ret
+
+ALIGN JUMP_ALIGN
+.PrintUnidentifiedType:
+	mov		si, g_szUnidentified
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+	ret
+
+ALIGN JUMP_ALIGN
+.PrintStatusOfUnsavedChanges:
+	test	WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
+	jz		SHORT .ReturnSinceNothingToPrint
+	mov		si, g_szUnsaved
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+.ReturnSinceNothingToPrint:
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menuitem.asm	(revision 57)
@@ -0,0 +1,315 @@
+; File name		:	Menuitem.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	2.11.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for accessing MENUITEM structs.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; Menuitem_SetVisibleFromDSSI
+; Menuitem_SetInvisibleFromDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns: (Menuitem_IsVisibleFromDSSI only)
+;		ZF:		Clear if visible
+;				Set if not visible
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menuitem_SetVisibleFromDSSI:
+	or		BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	ret
+
+ALIGN JUMP_ALIGN
+Menuitem_SetInvisibleFromDSSI:
+	and		BYTE [si+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+	ret
+
+
+;--------------------------------------------------------------------
+; Menuitem_DisplayHelpMessageFromDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menuitem_DisplayHelpMessageFromDSSI:
+	mov		di, [si+MENUITEM.szName]
+	mov		dx, [si+MENUITEM.szHelp]
+	jmp		Dialogs_DisplayHelpFromCSDXwithTitleInCSDI
+
+
+;--------------------------------------------------------------------
+; Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI:
+	call	Registers_CopyDSSItoESDI
+
+	mov		cx, DIALOG_INPUT_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	call	InitializeDialogInputInDSSIfromMenuitemInESDI
+	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szMultichoise]
+	mov		[si+DIALOG_INPUT.fszItems], ax
+	push	di
+	CALL_MENU_LIBRARY GetSelectionToAXwithInputInDSSI
+	pop		di
+
+	cmp		ax, BYTE NO_ITEM_SELECTED
+	je		SHORT .NothingToChange
+	call	Registers_CopyESDItoDSSI
+	call	Menuitem_StoreValueFromAXtoMenuitemInDSSI
+.NothingToChange:
+	add		sp, BYTE DIALOG_INPUT_size
+	ret
+
+
+;--------------------------------------------------------------------
+; Menuitem_ActivateHexInputForMenuitemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menuitem_ActivateHexInputForMenuitemInDSSI:
+	call	Registers_CopyDSSItoESDI
+
+	mov		cx, WORD_DIALOG_IO_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	call	InitializeDialogInputInDSSIfromMenuitemInESDI
+	mov		BYTE [si+WORD_DIALOG_IO.bNumericBase], 16
+	jmp		SHORT ContinueWordInput
+
+;--------------------------------------------------------------------
+; Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menuitem_ActivateUnsignedInputForMenuitemInDSSI:
+	call	Registers_CopyDSSItoESDI
+
+	mov		cx, WORD_DIALOG_IO_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	call	InitializeDialogInputInDSSIfromMenuitemInESDI
+	mov		BYTE [si+WORD_DIALOG_IO.bNumericBase], 10
+ContinueWordInput:
+	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMinValue]
+	mov		[si+WORD_DIALOG_IO.wMin], ax
+	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.wMaxValue]
+	mov		[si+WORD_DIALOG_IO.wMax], ax
+	push	di
+	CALL_MENU_LIBRARY GetWordWithIoInDSSI
+	pop		di
+
+	cmp		BYTE [si+WORD_DIALOG_IO.bUserCancellation], TRUE
+	je		SHORT .NothingToChange
+	mov		ax, [si+WORD_DIALOG_IO.wReturnWord]
+	call	Registers_CopyESDItoDSSI
+	call	Menuitem_StoreValueFromAXtoMenuitemInDSSI
+.NothingToChange:
+	add		sp, BYTE WORD_DIALOG_IO_size
+	ret
+
+
+;--------------------------------------------------------------------
+; InitializeDialogInputInDSSIfromMenuitemInESDI
+;	Parameters:
+;		DS:SI:	Ptr to DIALOG_INPUT
+;		ES:DI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+InitializeDialogInputInDSSIfromMenuitemInESDI:
+	mov		ax, [es:di+MENUITEM.itemValue + ITEM_VALUE.szDialogTitle]
+	mov		[si+DIALOG_INPUT.fszTitle], ax
+	mov		[si+DIALOG_INPUT.fszTitle+2], cs
+
+	mov		[si+DIALOG_INPUT.fszItems+2], cs
+
+	mov		ax, [es:di+MENUITEM.szQuickInfo]
+	mov		[si+DIALOG_INPUT.fszInfo], ax
+	mov		[si+DIALOG_INPUT.fszInfo+2], cs
+	ret
+
+;--------------------------------------------------------------------
+; Menuitem_StoreValueFromAXtoMenuitemInDSSI
+;	Parameters:
+;		AX:		Value or multichoise selection to store
+;		DS:SI:	Ptr to MENUITEM
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menuitem_StoreValueFromAXtoMenuitemInDSSI:
+	eMOVZX	bx, BYTE [si+MENUITEM.bType]
+	cmp		bl, TYPE_MENUITEM_HEX
+	ja		SHORT .InvalidItemType
+
+	call	Buffers_GetFileBufferToESDI
+	add		di, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	jmp		[cs:bx+.rgfnJumpToStoreValueBasedOnItemType]
+.InvalidItemType:
+	ret
+
+ALIGN WORD_ALIGN
+.rgfnJumpToStoreValueBasedOnItemType:
+	dw		.InvalidItemType									; TYPE_MENUITEM_PAGEBACK
+	dw		.InvalidItemType									; TYPE_MENUITEM_PAGENEXT
+	dw		.InvalidItemType									; TYPE_MENUITEM_ACTION
+	dw		.StoreMultichoiseValueFromAXtoESDIwithItemInDSSI	; TYPE_MENUITEM_MULTICHOISE
+	dw		.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI		; TYPE_MENUITEM_UNSIGNED
+	dw		.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI		; TYPE_MENUITEM_HEX
+
+;--------------------------------------------------------------------
+; .StoreMultichoiseValueFromAXtoESDIwithItemInDSSI
+;	Parameters:
+;		AX:		Multichoise selection (index)
+;		DS:SI:	Ptr to MENUITEM
+;		ES:DI:	Ptr to value variable
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.StoreMultichoiseValueFromAXtoESDIwithItemInDSSI:
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
+	jz		SHORT .TranslateChoiseToValueUsingLookupTable
+
+	test	ax, ax			; Setting item flag?
+	mov		ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
+	jnz		SHORT .SetFlagFromAX
+	not		ax
+	and		[es:di], ax		; Clear flag
+	jmp		SHORT .SetUnsavedChanges
+ALIGN JUMP_ALIGN
+.SetFlagFromAX:
+	or		[es:di], ax
+	jmp		SHORT .SetUnsavedChanges
+
+ALIGN JUMP_ALIGN
+.TranslateChoiseToValueUsingLookupTable:
+	shl		ax, 1			; Shift for WORD lookup
+	add		ax, [si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiseToValueLookup]
+	xchg	bx, ax
+	mov		ax, [bx]		; Lookup complete
+	; Fall to .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
+
+;--------------------------------------------------------------------
+; .StoreByteOrWordValueFromAXtoESDIwithItemInDSSI
+;	Parameters:
+;		AX:		Value to store
+;		DS:SI:	Ptr to MENUITEM
+;		ES:DI:	Ptr to value variable
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.StoreByteOrWordValueFromAXtoESDIwithItemInDSSI:
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
+	jnz		SHORT .StoreByteFromAL
+
+	mov		[es:di+1], ah
+ALIGN JUMP_ALIGN
+.StoreByteFromAL:
+	mov		[es:di], al
+	; Fall to .SetUnsavedChanges
+
+;--------------------------------------------------------------------
+; .SetUnsavedChanges
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.SetUnsavedChanges:
+	call	Buffers_SetUnsavedChanges
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_MODIFY_MENU
+	jnz		SHORT .ModifyItemVisibility
+	CALL_MENU_LIBRARY RefreshTitle
+	CALL_MENU_LIBRARY GetHighlightedItemToAX
+	CALL_MENU_LIBRARY RefreshItemFromAX
+	ret
+
+ALIGN JUMP_ALIGN
+.ModifyItemVisibility:
+	push	es
+	push	ds
+	ePUSHA
+	call	Menupage_GetActiveMenupageToDSDI
+	call	[di+MENUPAGE.fnEnter]
+	ePOPA
+	pop		ds
+	pop		es
+	ret
+
+
+;--------------------------------------------------------------------
+; Menuitem_GetValueToAXfromMenuitemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		AX:		Menuitem value
+;	Corrupts registers:
+;		BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menuitem_GetValueToAXfromMenuitemInDSSI:
+	mov		bx, [si+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_BYTEVALUE
+	jnz		SHORT .ConvertWordToByteValue
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_FLAGVALUE
+	jnz		SHORT .ConvertWordToFlagValue
+	ret
+
+ALIGN JUMP_ALIGN
+.ConvertWordToByteValue:
+	xor		ah, ah
+	ret
+
+ALIGN JUMP_ALIGN
+.ConvertWordToFlagValue:
+	test	ax, [si+MENUITEM.itemValue+ITEM_VALUE.wValueBitmask]
+	jnz		SHORT .ReturnTrue
+	xor		ax, ax
+	ret
+ALIGN JUMP_ALIGN
+.ReturnTrue:
+	mov		ax, TRUE<<1		; Shift for lookup
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm	(revision 57)
@@ -0,0 +1,225 @@
+; File name		:	MenuitemPrint.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	2.11.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for printing MENUITEM name and value.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; MenuitemPrint_PrintQuickInfoFromDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuitemPrint_PrintQuickInfoFromDSSI:
+	push	si
+
+	mov		si, [si+MENUITEM.szQuickInfo]
+	CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
+
+	pop		si
+	ret
+
+
+;--------------------------------------------------------------------
+; MenuitemPrint_NameWithPossibleValueFromDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MenuitemPrint_NameWithPossibleValueFromDSSI:
+	eMOVZX	bx, BYTE [si+MENUITEM.bType]
+	cmp		bl, TYPE_MENUITEM_ACTION
+	ja		SHORT .PrintNameAndValueFromDSSI
+	; Fall to .PrintNameWithoutValueFromDSSI
+
+;--------------------------------------------------------------------
+; .PrintNameWithoutValueFromDSSI
+;	Parameters:
+;		BX:		Menuitem type (MENUITEM.bType)
+;		DS:SI:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+.PrintNameWithoutValueFromDSSI:
+	push	bp
+	push	si
+
+	mov		bp, sp				; BP = SP before pushing parameters
+	push	WORD [cs:bx+.rgwMenuitemTypeCharacter]
+	push	WORD [si+MENUITEM.szName]
+	mov		si, g_szFormatItemWithoutValue
+	CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
+
+	pop		si
+	pop		bp
+	ret
+.rgwMenuitemTypeCharacter:
+	dw		'-'		; TYPE_MENUITEM_PAGEBACK
+	dw		'+'		; TYPE_MENUITEM_PAGENEXT
+	dw		'*'		; TYPE_MENUITEM_ACTION
+
+
+;--------------------------------------------------------------------
+; .PrintNameAndValueFromDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;		SS:BP:	Ptr to buffer for item value
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.PrintNameAndValueFromDSSI:
+	eENTER_STRUCT	MAX_VALUE_STRING_LENGTH+2	; +2 for NULL and alignment
+	call	.FormatValueStringFromItemInDSSItoBufferInSSBP
+	call	.FormatNameFromItemInDSSIandValueFromSSBP
+	eLEAVE_STRUCT	MAX_VALUE_STRING_LENGTH+2
+	ret
+
+;--------------------------------------------------------------------
+; .FormatValueStringFromItemInDSSItoBufferInSSBP
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;		SS:BP:	Ptr to buffer for item value
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.FormatValueStringFromItemInDSSItoBufferInSSBP:
+	push	es
+	call	Registers_CopySSBPtoESDI
+	mov		al, '['
+	stosb
+	call	[si+MENUITEM.fnFormatValue]
+	mov		ax, ']'
+	stosw	; Also terminate with NULL
+	pop		es
+	ret
+
+;--------------------------------------------------------------------
+; .FormatNameFromItemInDSSIandValueFromSSBP
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;		SS:BP:	Ptr to value string
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, DX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.FormatNameFromItemInDSSIandValueFromSSBP:
+	push	si
+
+	mov		bx, bp
+	mov		bp, sp				; BP = SP before pushing parameters
+	push	WORD [si+MENUITEM.szName]
+	push	bx
+	push	ss
+	mov		si, g_szFormatItemNameWithValue
+	CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
+
+	mov		bp, bx
+	pop		si
+	ret
+	
+
+;--------------------------------------------------------------------
+; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;		ES:DI:	Ptr to destination buffer
+;	Returns:
+;		DI:		Updated
+;	Corrupts registers:
+;		AX, BX, CX
+;--------------------------------------------------------------------	
+ALIGN JUMP_ALIGN
+MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI:
+	push	si
+
+	call	Menuitem_GetValueToAXfromMenuitemInDSSI
+	add		ax, [si+MENUITEM.itemValue+ITEM_VALUE.rgszValueToStringLookup]
+	xchg	bx, ax
+	mov		si, [bx]
+	call	String_CopyDSSItoESDIandGetLengthToCX
+
+	pop		si
+	ret
+
+
+;--------------------------------------------------------------------
+; MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;		ES:DI:	Ptr to destination buffer
+;	Returns:
+;		DI:		Updated
+;	Corrupts registers:
+;		AX, BX, CX
+;--------------------------------------------------------------------	
+ALIGN JUMP_ALIGN
+MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI:
+	mov		bx, di
+	mov		cx, MAX_VALUE_STRING_LENGTH
+	CALL_DISPLAY_LIBRARY PushDisplayContext
+	CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
+
+	mov		bx, 10
+	jmp		SHORT PrintByteOrWordValue
+
+;--------------------------------------------------------------------
+; MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to MENUITEM
+;		ES:DI:	Ptr to destination buffer
+;	Returns:
+;		DI:		Updated
+;	Corrupts registers:
+;		AX, BX, CX
+;--------------------------------------------------------------------	
+ALIGN JUMP_ALIGN
+MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI:
+	mov		bx, di
+	mov		cx, MAX_VALUE_STRING_LENGTH
+	CALL_DISPLAY_LIBRARY PushDisplayContext
+	CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
+
+	mov		bx, 16
+PrintByteOrWordValue:
+	push	bx
+	call	Menuitem_GetValueToAXfromMenuitemInDSSI
+	pop		bx
+
+	CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
+	CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
+	xchg	bx, ax
+
+	CALL_DISPLAY_LIBRARY PopDisplayContext
+	mov		di, bx
+	ret
+
+
+; Section containing initialized data
+SECTION .data
+
+ALIGN WORD_ALIGN
+g_rgszValueToStringLookupForFlagBooleans:
+	dw		g_szNo
+	dw		g_szYes
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupage.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupage.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupage.asm	(revision 57)
@@ -0,0 +1,127 @@
+; File name		:	Menupage.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	1.11.2010
+; Author		:	Tomi Tilli
+; Description	:	Functions for accessing MENUPAGE structs.
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; Menupage_ChangeToNewMenupageInDSSI
+;	Parameters:
+;		DS:SI:	Ptr to new MENUPAGE
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menupage_ChangeToNewMenupageInDSSI:
+	mov		di, si
+	call	Menupage_SetActiveMenupageFromDSDI
+	call	Menupage_GetVisibleMenuitemsToAXfromDSDI
+	CALL_MENU_LIBRARY SetTotalItemsFromAX
+	xor		ax, ax
+	CALL_MENU_LIBRARY HighlightItemFromAX
+	CALL_MENU_LIBRARY RefreshWindow
+	ret
+
+
+;--------------------------------------------------------------------
+; Menupage_SetActiveMenupageFromDSDI
+;	Parameters:
+;		DS:DI:	Ptr to MENUPAGE to set active
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, DI
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menupage_SetActiveMenupageFromDSDI:
+	mov		[g_cfgVars+CFGVARS.pMenupage], di
+	ret
+
+
+;--------------------------------------------------------------------
+; Menupage_GetActiveMenupageToDSDI:
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		DS:DI:	Ptr to MENUPAGE
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menupage_GetActiveMenupageToDSDI:
+	push	cs
+	pop		ds
+	mov		di, [g_cfgVars+CFGVARS.pMenupage]
+	ret
+
+
+;--------------------------------------------------------------------
+; Menupage_GetVisibleMenuitemsToAXfromDSDI
+;	Parameters:
+;		DS:DI:	Ptr to MENUPAGE
+;	Returns:
+;		AX:		Number of visible MENUITEMs in MENUPAGE
+;	Corrupts registers:
+;		BX, CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menupage_GetVisibleMenuitemsToAXfromDSDI:
+	xor		ax, ax
+	mov		cx, [di+MENUPAGE.wMenuitems]
+	lea		bx, [di+MENUPAGE.rgMenuitem]
+
+ALIGN JUMP_ALIGN
+.CheckVisibilityFromNextMenuitem:
+	test	BYTE [bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	jz		SHORT .PrepareToLoop
+	inc		ax
+.PrepareToLoop:
+	add		bx, BYTE MENUITEM_size
+	loop	.CheckVisibilityFromNextMenuitem
+	ret
+
+
+;--------------------------------------------------------------------
+; Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
+;	Parameters:
+;		CX:		nth visible MENUITEM to find
+;		DS:DI:	Ptr to MENUPAGE
+;	Returns:
+;		DS:SI:	Ptr to CXth visible MENUITEM
+;		CF:		Set if MENUITEM found
+;				Cleared if MENUITEM not found
+;	Corrupts registers:
+;		AX, CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI:
+	mov		ax, [di+MENUPAGE.wMenuitems]
+	cmp		cx, ax
+	jae		SHORT .MenuitemNotFound
+	xchg	ax, cx
+	inc		ax
+	lea		si, [di+MENUPAGE.rgMenuitem]
+ALIGN JUMP_ALIGN
+.CheckNextMenuitem:
+	test	BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	jz		SHORT .PrepareToLoop
+	dec		ax
+	jz		SHORT .MenuitemFound
+.PrepareToLoop:
+	add		si, BYTE MENUITEM_size
+	loop	.CheckNextMenuitem
+.MenuitemNotFound:
+	clc
+	ret
+ALIGN JUMP_ALIGN
+.MenuitemFound:
+	stc
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/ConfigurationMenu.asm	(revision 57)
@@ -0,0 +1,345 @@
+; File name		:	ConfigurationMenu.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	24.10.2010
+; Last update	:	3.11.2010
+; Author		:	Tomi Tilli
+; Description	:	"Configure XTIDE Universal BIOS" menu structs and functions.
+
+; Section containing initialized data
+SECTION .data
+
+ALIGN WORD_ALIGN
+g_MenupageForConfigurationMenu:
+istruc MENUPAGE
+	at	MENUPAGE.fnEnter,			dw	ConfigurationMenu_EnterMenuOrModifyItemVisibility
+	at	MENUPAGE.wMenuitems,		dw	11
+iend
+
+g_MenuitemConfigurationBackToMainMenu:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	MainMenu_EnterMenuOrModifyItemVisibility
+	at	MENUITEM.szName,			dw	g_szItemCfgBackToMain
+	at	MENUITEM.szQuickInfo,		dw	g_szItemCfgBackToMain
+	at	MENUITEM.szHelp,			dw	g_szItemCfgBackToMain
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGEBACK
+iend
+
+g_MenuitemConfigurationPrimaryIdeController:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	PrimaryIdeController
+	at	MENUITEM.szName,			dw	g_szItemCfgIde1
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgIde
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgIde
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemConfigurationSecondaryIdeController:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	SecondaryIdeController
+	at	MENUITEM.szName,			dw	g_szItemCfgIde2
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgIde
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgIde
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemConfigurationTertiaryIdeController:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	TertiaryIdeController
+	at	MENUITEM.szName,			dw	g_szItemCfgIde3
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgIde
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgIde
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemConfigurationQuaternaryIdeController:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	QuaternaryIdeController
+	at	MENUITEM.szName,			dw	g_szItemCfgIde4
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgIde
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgIde
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemConfigurationQuinaryIdeController:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	QuinaryIdeController
+	at	MENUITEM.szName,			dw	g_szItemCfgIde5
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgIde
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgIde
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemConfigurationBootMenuSettings:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	BootMenuSettings
+	at	MENUITEM.szName,			dw	g_szItemCfgBootMenu
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgBootMenu
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgBootMenu
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemConfigurationBootLoaderType:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemCfgBootLoader
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgBootLoader
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgBootLoader
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOISE
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	ROMVARS.bBootLdrType
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szItemCfgBootLoader
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoise,				dw	g_szMultichoiseCfgBootLoader
+	at	MENUITEM.itemValue + ITEM_VALUE.rgwChoiseToValueLookup,		dw	g_rgwChoiseToValueLookupForBootLoaderType
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	g_rgszValueToStringLookupForBootLoaderType
+iend
+
+g_MenuitemConfigurationFullOperatingMode:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemCfgFullMode
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgFullMode
+	at	MENUITEM.szHelp,			dw	g_szHelpCfgFullMode
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOISE
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	ROMVARS.wFlags
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgCfgFullMode
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoise,				dw	g_szMultichoiseBooleanFlag
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	g_rgszValueToStringLookupForFlagBooleans
+	at	MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,				dw	FLG_ROMVARS_FULLMODE
+iend
+
+g_MenuitemConfigurationKiBtoStealFromRAM:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemCfgStealSize
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgStealSize
+	at	MENUITEM.szHelp,			dw	g_szHelpCfgStealSize
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_UNSIGNED
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	ROMVARS.bStealSize
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgCfgStealSize
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	1
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	255
+iend
+
+g_MenuitemConfigurationIdeControllers:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemCfgIdeCnt
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoCfgIdeCnt
+	at	MENUITEM.szHelp,			dw	g_szNfoCfgIdeCnt
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_UNSIGNED
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	ROMVARS.bIdeCnt
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgCfgIdeCnt
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	1
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	5
+iend
+
+
+g_rgwChoiseToValueLookupForBootLoaderType:
+	dw	BOOTLOADER_TYPE_MENU
+	dw	BOOTLOADER_TYPE_SIMPLE
+	dw	BOOTLOADER_TYPE_NONE
+g_rgszValueToStringLookupForBootLoaderType:
+	dw	g_szValueCfgBootLoaderMenu
+	dw	g_szValueCfgBootLoaderAthenC
+	dw	g_szUnidentified
+	dw	g_szValueCfgBootLoaderSystem
+	
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; MainMenu_EnterMenuOrModifyItemVisibility
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except BP
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ConfigurationMenu_EnterMenuOrModifyItemVisibility:
+	push	cs
+	pop		ds
+	call	.DisableAllIdeControllerMenuitems
+	call	.EnableIdeControllerMenuitemsBasedOnConfiguration
+	call	.EnableOrDisableKiBtoStealFromRAM
+	call	.EnableOrDisableIdeControllerCount
+	mov		si, g_MenupageForConfigurationMenu
+	jmp		Menupage_ChangeToNewMenupageInDSSI
+
+;--------------------------------------------------------------------
+; .DisableAllIdeControllerMenuitems
+; .EnableIdeControllerMenuitemsBasedOnConfiguration
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.DisableAllIdeControllerMenuitems:
+	mov		cx, MAX_ALLOWED_IDE_CONTROLLERS-1
+	mov		bx, g_MenuitemConfigurationSecondaryIdeController
+ALIGN JUMP_ALIGN
+.DisableNextIdeControllerMenuitem:
+	call	.DisableMenuitemFromCSBX
+	add		bx, BYTE MENUITEM_size
+	loop	.DisableNextIdeControllerMenuitem
+	ret
+
+ALIGN JUMP_ALIGN
+.EnableIdeControllerMenuitemsBasedOnConfiguration:
+	call	.GetIdeControllerCountToCX
+	dec		cx			; Primary always enabled
+	jcxz	.PrimaryControllerAlreadyEnabled
+	mov		bx, g_MenuitemConfigurationSecondaryIdeController
+ALIGN JUMP_ALIGN
+.EnableNextIdeControllerMenuitem:
+	call	.EnableMenuitemFromCSBX
+	add		bx, BYTE MENUITEM_size
+	loop	.EnableNextIdeControllerMenuitem
+.PrimaryControllerAlreadyEnabled:
+	ret
+
+;--------------------------------------------------------------------
+; .GetIdeControllerCountToCX
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		CX:		Number of IDE controllers to configure
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.GetIdeControllerCountToCX:
+	mov		bx, ROMVARS.wFlags
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	test	ax, FLG_ROMVARS_FULLMODE
+	jz		SHORT .AllowOnlyOneIdeControllerInLiteMode
+
+	mov		bx, ROMVARS.bIdeCnt
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	eMOVZX	cx, al
+	ret
+ALIGN JUMP_ALIGN
+.AllowOnlyOneIdeControllerInLiteMode:
+	mov		cx, 1
+	ret
+
+;--------------------------------------------------------------------
+; .EnableOrDisableKiBtoStealFromRAM
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableKiBtoStealFromRAM:
+	mov		bx, ROMVARS.wFlags
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	mov		bx, g_MenuitemConfigurationKiBtoStealFromRAM
+	test	ax, FLG_ROMVARS_FULLMODE
+	jz		SHORT .DisableMenuitemFromCSBX
+	jmp		SHORT .EnableMenuitemFromCSBX
+
+;--------------------------------------------------------------------
+; .EnableOrDisableKiBtoStealFromRAM
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableIdeControllerCount:
+	mov		bx, ROMVARS.wFlags
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	mov		bx, g_MenuitemConfigurationIdeControllers
+	test	ax, FLG_ROMVARS_FULLMODE
+	jz		SHORT .DisableMenuitemFromCSBX
+	jmp		SHORT .EnableMenuitemFromCSBX
+
+;--------------------------------------------------------------------
+; .EnableMenuitemFromCSBX
+; .DisableMenuitemFromCSBX
+;	Parameters:
+;		CS:BX:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableMenuitemFromCSBX:
+	or		BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	ret
+
+ALIGN JUMP_ALIGN
+.DisableMenuitemFromCSBX:
+	and		BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+	ret
+
+
+
+;--------------------------------------------------------------------
+; MENUITEM activation functions (.fnActivate)
+;	Parameters:
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except segments
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+PrimaryIdeController:
+	mov		bx, ROMVARS.ideVars0
+	jmp		SHORT DisplayIdeControllerMenu
+
+ALIGN JUMP_ALIGN
+SecondaryIdeController:
+	mov		bx, ROMVARS.ideVars1
+	jmp		SHORT DisplayIdeControllerMenu
+
+ALIGN JUMP_ALIGN
+TertiaryIdeController:
+	mov		bx, ROMVARS.ideVars2
+	jmp		SHORT DisplayIdeControllerMenu
+
+ALIGN JUMP_ALIGN
+QuaternaryIdeController:
+	mov		bx, ROMVARS.ideVars3
+	jmp		SHORT DisplayIdeControllerMenu
+
+ALIGN JUMP_ALIGN
+QuinaryIdeController:
+	mov		bx, ROMVARS.ideVars4
+	; Fall to DisplayIdeControllerMenu
+
+ALIGN JUMP_ALIGN
+DisplayIdeControllerMenu:
+	call	IdeControllerMenu_InitializeToIdevarsOffsetInBX
+	jmp		IdeControllerMenu_EnterMenuOrModifyItemVisibility
+
+
+ALIGN JUMP_ALIGN
+BootMenuSettings:
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/IdeControllerMenu.asm	(revision 57)
@@ -0,0 +1,250 @@
+; File name		:	IdeControllerMenu.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	2.11.2010
+; Last update	:	3.11.2010
+; Author		:	Tomi Tilli
+; Description	:	"IDE Controller" menu structs and functions.
+
+; Section containing initialized data
+SECTION .data
+
+ALIGN WORD_ALIGN
+g_MenupageForIdeControllerMenu:
+istruc MENUPAGE
+	at	MENUPAGE.fnEnter,			dw	IdeControllerMenu_EnterMenuOrModifyItemVisibility
+	at	MENUPAGE.wMenuitems,		dw	8
+iend
+
+g_MenuitemIdeControllerBackToConfigurationMenu:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	ConfigurationMenu_EnterMenuOrModifyItemVisibility
+	at	MENUITEM.szName,			dw	g_szItemBackToCfgMenu
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeBackToCfgMenu
+	at	MENUITEM.szHelp,			dw	g_szNfoIdeBackToCfgMenu
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGEBACK
+iend
+
+g_MenuitemIdeControllerMasterDrive:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	MasterDrive
+	at	MENUITEM.szName,			dw	g_szItemIdeMaster
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeMaster
+	at	MENUITEM.szHelp,			dw	g_szNfoIdeMaster
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemIdeControllerSlaveDrive:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	SlaveDrive
+	at	MENUITEM.szName,			dw	g_szItemIdeSlave
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeSlave
+	at	MENUITEM.szHelp,			dw	g_szNfoIdeSlave
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemIdeControllerBusType:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemIdeBusType
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeBusType
+	at	MENUITEM.szHelp,			dw	g_szNfoIdeBusType
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOISE
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgBusType
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoise,				dw	g_szMultichoiseCfgBusType
+	at	MENUITEM.itemValue + ITEM_VALUE.rgwChoiseToValueLookup,		dw	g_rgwChoiseToValueLookupForBusType
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	g_rgszValueToStringLookupForBusType
+iend
+
+g_MenuitemIdeControllerCommandBlockAddress:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateHexInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemIdeCmdPort
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeCmdPort
+	at	MENUITEM.szHelp,			dw	g_szHelpIdeCmdPort
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_HEX
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgIdeCmdPort
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	0
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	-1
+iend
+
+g_MenuitemIdeControllerControlBlockAddress:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateHexInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemIdeCtrlPort
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeCtrlPort
+	at	MENUITEM.szHelp,			dw	g_szHelpIdeCtrlPort
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_HEX
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgIdeCtrlPort
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	0
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	-1
+iend
+
+g_MenuitemIdeControllerEnableInterrupt:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemIdeEnIRQ
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeEnIRQ
+	at	MENUITEM.szHelp,			dw	g_szHelpIdeEnIRQ
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOISE
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgIdeEnIRQ
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoise,				dw	g_szMultichoiseBooleanFlag
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	g_rgszValueToStringLookupForFlagBooleans
+	at	MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,				dw	15
+iend
+
+g_MenuitemIdeControllerIdeIRQ:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemIdeIRQ
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoIdeIRQ
+	at	MENUITEM.szHelp,			dw	g_szHelpIdeIRQ
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_UNSIGNED
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgIdeIRQ
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	2
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	15
+iend
+
+g_rgwChoiseToValueLookupForBusType:
+	dw	BUS_TYPE_8_DUAL
+	dw	BUS_TYPE_8_SINGLE
+	dw	BUS_TYPE_16
+	dw	BUS_TYPE_32
+g_rgszValueToStringLookupForBusType:
+	dw	g_szValueCfgBusTypeDual8b
+	dw	g_szValueCfgBusType16b
+	dw	g_szValueCfgBusType32b
+	dw	g_szValueCfgBusTypeSingle8b
+
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; IdeControllerMenu_InitializeToIdevarsOffsetInBX
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+IdeControllerMenu_InitializeToIdevarsOffsetInBX:
+	lea		ax, [bx+IDEVARS.drvParamsMaster]
+	mov		[cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+IDEVARS.drvParamsSlave]
+	mov		[cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+IDEVARS.bBusType]
+	mov		[cs:g_MenuitemIdeControllerBusType+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+IDEVARS.wPort]
+	mov		[cs:g_MenuitemIdeControllerCommandBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+IDEVARS.wPortCtrl]
+	mov		[cs:g_MenuitemIdeControllerControlBlockAddress+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+IDEVARS.bIRQ]
+	mov		[cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[cs:g_MenuitemIdeControllerIdeIRQ+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	ret
+
+
+;--------------------------------------------------------------------
+; IdeControllerMenu_EnterMenuOrModifyItemVisibility
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except BP
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+IdeControllerMenu_EnterMenuOrModifyItemVisibility:
+	push	cs
+	pop		ds
+	call	.EnableOrDisableIRQ
+	mov		si, g_MenupageForIdeControllerMenu
+	jmp		Menupage_ChangeToNewMenupageInDSSI
+
+;--------------------------------------------------------------------
+; .EnableOrDisableIRQ
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableIRQ:
+	mov		bx, [cs:g_MenuitemIdeControllerEnableInterrupt+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	mov		bx, g_MenuitemIdeControllerIdeIRQ
+	test	ax, ax
+	jz		SHORT .DisableMenuitemFromCSBX
+	; Fall to .EnableMenuitemFromCSBX
+
+;--------------------------------------------------------------------
+; .EnableMenuitemFromCSBX
+; .DisableMenuitemFromCSBX
+;	Parameters:
+;		CS:BX:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableMenuitemFromCSBX:
+	or		BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	ret
+
+ALIGN JUMP_ALIGN
+.DisableMenuitemFromCSBX:
+	and		BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+	ret
+
+
+;--------------------------------------------------------------------
+; MENUITEM activation functions (.fnActivate)
+;	Parameters:
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except segments
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MasterDrive:
+	mov		bx, [cs:g_MenuitemIdeControllerMasterDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	jmp		SHORT DisplayMasterSlaveMenu
+
+ALIGN JUMP_ALIGN
+SlaveDrive:
+	mov		bx, [cs:g_MenuitemIdeControllerSlaveDrive+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	; Fall to DisplayMasterSlaveMenu
+
+ALIGN JUMP_ALIGN
+DisplayMasterSlaveMenu:
+	call	MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
+	jmp		MasterSlaveMenu_EnterMenuOrModifyItemVisibility
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MainMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MainMenu.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MainMenu.asm	(revision 57)
@@ -0,0 +1,253 @@
+; File name		:	MainMenu.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	6.10.2010
+; Last update	:	2.11.2010
+; Author		:	Tomi Tilli
+; Description	:	Main menu structs and functions.
+
+; Section containing initialized data
+SECTION .data
+
+ALIGN WORD_ALIGN
+g_MenupageForMainMenu:
+istruc MENUPAGE
+	at	MENUPAGE.fnEnter,			dw	MainMenu_EnterMenuOrModifyItemVisibility
+	at	MENUPAGE.wMenuitems,		dw	6
+iend
+
+g_MenuitemMainMenuExitToDos:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	ExitToDos
+	at	MENUITEM.szName,			dw	g_szItemMainExitToDOS
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoMainExitToDOS
+	at	MENUITEM.szHelp,			dw	g_szNfoMainExitToDOS
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGEBACK
+iend
+
+g_MenuitemMainMenuLoadBiosFromFile:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	LoadBiosFromFile
+	at	MENUITEM.szName,			dw	g_szItemMainLoadFile
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoMainLoadFile
+	at	MENUITEM.szHelp,			dw	g_szNfoMainLoadFile
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_ACTION
+iend
+
+g_MenuitemMainMenuLoadXtideUniversalBiosFromRom:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	LoadXtideUniversalBiosFromRom
+	at	MENUITEM.szName,			dw	g_szItemMainLoadROM
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoMainLoadROM
+	at	MENUITEM.szHelp,			dw	g_szNfoMainLoadROM
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_ACTION
+iend
+
+g_MenuitemMainMenuLoadOldSettingsFromEeprom:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	LoadOldSettingsFromEeprom
+	at	MENUITEM.szName,			dw	g_szItemMainLoadStngs
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoMainLoadStngs
+	at	MENUITEM.szHelp,			dw	g_szNfoMainLoadStngs
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_ACTION
+iend
+
+g_MenuitemMainMenuConfigureXtideUniversalBios:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	ConfigureXtideUniversalBios
+	at	MENUITEM.szName,			dw	g_szItemMainConfigure
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoMainConfigure
+	at	MENUITEM.szHelp,			dw	g_szNfoMainConfigure
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+g_MenuitemMainMenuFlashEeprom:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	FlashEeprom
+	at	MENUITEM.szName,			dw	g_szItemMainFlash
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoMainFlash
+	at	MENUITEM.szHelp,			dw	g_szNfoMainFlash
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGENEXT
+iend
+
+%if FALSE
+g_Menuitem:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	NULL
+	at	MENUITEM.fnFormatValue,		dw	NULL
+	at	MENUITEM.szName,			dw	NULL
+	at	MENUITEM.szQuickInfo,		dw	NULL
+	at	MENUITEM.szHelp,			dw	NULL
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoise,				dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.rgwChoiseToValueLookup,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,				dw	NULL
+iend
+%endif
+
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; MainMenu_EnterMenuOrModifyItemVisibility
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except BP
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MainMenu_EnterMenuOrModifyItemVisibility:
+	push	cs
+	pop		ds
+	call	.EnableOrDisableXtideRomItems
+	call	.EnableOrDisableConfigureXtideUniversalBios
+	call	.EnableOrDisableFlashEeprom
+	mov		si, g_MenupageForMainMenu
+	jmp		Menupage_ChangeToNewMenupageInDSSI
+
+;--------------------------------------------------------------------
+; .EnableOrDisableXtideRomItems
+;	Parameters:
+;		DS:		CFGVARS segment
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX, CX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableXtideRomItems:
+	call	EEPROM_FindXtideUniversalBiosROMtoESDI
+	jnc		SHORT .DisableAllRomItems
+	or		BYTE [g_MenuitemMainMenuLoadXtideUniversalBiosFromRom+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	call	Buffers_IsXtideUniversalBiosLoaded
+	jne		SHORT .DisableLoadSettingFromRom
+	or		BYTE [g_MenuitemMainMenuLoadOldSettingsFromEeprom+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	ret
+
+ALIGN JUMP_ALIGN
+.DisableAllRomItems:
+	and		BYTE [g_MenuitemMainMenuLoadXtideUniversalBiosFromRom+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+.DisableLoadSettingFromRom:
+	and		BYTE [g_MenuitemMainMenuLoadOldSettingsFromEeprom+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+	ret
+
+;--------------------------------------------------------------------
+; .EnableOrDisableConfigureXtideUniversalBios
+;	Parameters:
+;		DS:		CFGVARS segment
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		CX, SI, DI, ES
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableConfigureXtideUniversalBios:
+	call	Buffers_IsXtideUniversalBiosLoaded
+	jne		SHORT .DisableConfigureXtideUniversalBios
+	or		BYTE [g_MenuitemMainMenuConfigureXtideUniversalBios+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	ret
+
+ALIGN JUMP_ALIGN
+.DisableConfigureXtideUniversalBios:
+	and		BYTE [g_MenuitemMainMenuConfigureXtideUniversalBios+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+	ret
+
+;--------------------------------------------------------------------
+; .EnableOrDisableFlashEeprom
+;	Parameters:
+;		DS:		CFGVARS segment
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableFlashEeprom:
+	test	WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
+	jz		SHORT .DisableFlashEeprom
+	or		BYTE [g_MenuitemMainMenuFlashEeprom+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	ret
+
+ALIGN JUMP_ALIGN
+.DisableFlashEeprom:
+	and		BYTE [g_MenuitemMainMenuFlashEeprom+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+	ret
+
+
+
+;--------------------------------------------------------------------
+; MENUITEM activation functions (.fnActivate)
+;	Parameters:
+;		SS:BP:	Ptr to MENU
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except segments
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+ExitToDos:
+	CALL_MENU_LIBRARY Close
+	ret
+
+
+ALIGN JUMP_ALIGN
+LoadBiosFromFile:
+	mov		cx, FILE_DIALOG_IO_size
+	call	Memory_ReserveCXbytesFromStackToDSSI
+	call	Dialogs_DisplayFileDialogWithDialogIoInDSSI
+	cmp		BYTE [si+FILE_DIALOG_IO.bUserCancellation], TRUE
+	je		SHORT .CancelFileLoading
+
+	add		si, BYTE FILE_DIALOG_IO.szFile
+	call	BiosFile_LoadFileFromDSSItoRamBuffer
+	call	MainMenu_EnterMenuOrModifyItemVisibility
+.CancelFileLoading:
+	add		sp, BYTE FILE_DIALOG_IO_size
+	ret
+
+
+ALIGN JUMP_ALIGN
+LoadXtideUniversalBiosFromRom:
+	call	EEPROM_LoadXtideUniversalBiosFromRomToRamBuffer
+	mov		ax, FLG_CFGVARS_ROMLOADED
+	call	Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration
+	push	cs
+	pop		ds
+	mov		si, g_szDlgMainLoadROM
+	CALL_MENU_LIBRARY DisplayMessageWithInputInDSSI
+	ret
+
+
+ALIGN JUMP_ALIGN
+LoadOldSettingsFromEeprom:
+	call	EEPROM_LoadOldSettingsFromRomToRamBuffer
+	and		WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
+	push	cs
+	pop		ds
+	mov		si, g_szDlgMainLoadStngs
+	CALL_MENU_LIBRARY DisplayMessageWithInputInDSSI
+	ret
+
+
+ALIGN JUMP_ALIGN
+ConfigureXtideUniversalBios:
+	jmp		ConfigurationMenu_EnterMenuOrModifyItemVisibility
+
+
+ALIGN JUMP_ALIGN
+FlashEeprom:
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MasterSlaveMenu.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MasterSlaveMenu.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/MasterSlaveMenu.asm	(revision 57)
@@ -0,0 +1,204 @@
+; File name		:	MasterSlaveMenu.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	3.11.2010
+; Last update	:	3.11.2010
+; Author		:	Tomi Tilli
+; Description	:	"Master/Slave Drive" menu structs and functions.
+
+; Section containing initialized data
+SECTION .data
+
+ALIGN WORD_ALIGN
+g_MenupageForMasterSlaveMenu:
+istruc MENUPAGE
+	at	MENUPAGE.fnEnter,			dw	MasterSlaveMenu_EnterMenuOrModifyItemVisibility
+	at	MENUPAGE.wMenuitems,		dw	6
+iend
+
+g_MenuitemMasterSlaveBackToIdeControllerMenu:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	IdeControllerMenu_EnterMenuOrModifyItemVisibility
+	at	MENUITEM.szName,			dw	g_szItemDrvBackToIde
+	at	MENUITEM.szQuickInfo,		dw	g_szItemDrvBackToIde
+	at	MENUITEM.szHelp,			dw	g_szItemDrvBackToIde
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_PAGEBACK
+iend
+
+g_MenuitemMasterSlaveBlockModeTransfers:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemDrvBlockMode
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoDrvBlockMode
+	at	MENUITEM.szHelp,			dw	g_szHelpDrvBlockMode
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_FLAGVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOISE
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgDrvBlockMode
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoise,				dw	g_szMultichoiseBooleanFlag
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	g_rgszValueToStringLookupForFlagBooleans
+	at	MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,				dw	FLG_DRVPARAMS_BLOCKMODE
+iend
+
+g_MenuitemMasterSlaveUserCHS:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateMultichoiseSelectionForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemDrvUserCHS
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoDrvUserCHS
+	at	MENUITEM.szHelp,			dw	g_szHelpDrvUserCHS
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU | FLG_MENUITEM_FLAGVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_MULTICHOISE
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgDrvUserCHS
+	at	MENUITEM.itemValue + ITEM_VALUE.szMultichoise,				dw	g_szMultichoiseBooleanFlag
+	at	MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,	dw	g_rgszValueToStringLookupForFlagBooleans
+	at	MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,				dw	FLG_DRVPARAMS_USERCHS
+iend
+
+g_MenuitemMasterSlaveCylinders:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemDrvCyls
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoDrvCyls
+	at	MENUITEM.szHelp,			dw	g_szNfoDrvCyls
+	at	MENUITEM.bFlags,			db	NULL
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_UNSIGNED
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgDrvCyls
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	1
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	16383
+iend
+
+g_MenuitemMasterSlaveHeads:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemDrvHeads
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoDrvHeads
+	at	MENUITEM.szHelp,			dw	g_szNfoDrvHeads
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_UNSIGNED
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgDrvHeads
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	1
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	16
+iend
+
+g_MenuitemMasterSlaveSectors:
+istruc MENUITEM
+	at	MENUITEM.fnActivate,		dw	Menuitem_ActivateUnsignedInputForMenuitemInDSSI
+	at	MENUITEM.fnFormatValue,		dw	MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
+	at	MENUITEM.szName,			dw	g_szItemDrvSect
+	at	MENUITEM.szQuickInfo,		dw	g_szNfoDrvSect
+	at	MENUITEM.szHelp,			dw	g_szNfoDrvSect
+	at	MENUITEM.bFlags,			db	FLG_MENUITEM_BYTEVALUE
+	at	MENUITEM.bType,				db	TYPE_MENUITEM_UNSIGNED
+	at	MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,		dw	NULL
+	at	MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,				dw	g_szDlgDrvSect
+	at	MENUITEM.itemValue + ITEM_VALUE.wMinValue,					dw	1
+	at	MENUITEM.itemValue + ITEM_VALUE.wMaxValue,					dw	63
+iend
+
+
+; Section containing code
+SECTION .text
+
+;--------------------------------------------------------------------
+; MasterSlaveMenu_InitializeToDrvparamsOffsetInBX
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MasterSlaveMenu_InitializeToDrvparamsOffsetInBX:
+	lea		ax, [bx+DRVPARAMS.wFlags]
+	mov		[cs:g_MenuitemMasterSlaveBlockModeTransfers+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	mov		[cs:g_MenuitemMasterSlaveUserCHS+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+DRVPARAMS.wCylinders]
+	mov		[cs:g_MenuitemMasterSlaveCylinders+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+DRVPARAMS.bHeads]
+	mov		[cs:g_MenuitemMasterSlaveHeads+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+
+	lea		ax, [bx+DRVPARAMS.bSect]
+	mov		[cs:g_MenuitemMasterSlaveSectors+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset], ax
+	ret
+
+
+;--------------------------------------------------------------------
+; MasterSlaveMenu_EnterMenuOrModifyItemVisibility
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		All, except BP
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+MasterSlaveMenu_EnterMenuOrModifyItemVisibility:
+	push	cs
+	pop		ds
+	call	.EnableOrDisableCHandS
+	mov		si, g_MenupageForMasterSlaveMenu
+	jmp		Menupage_ChangeToNewMenupageInDSSI
+
+;--------------------------------------------------------------------
+; .EnableOrDisableCHandS
+;	Parameters:
+;		SS:BP:	Menu handle
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		AX, BX
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableOrDisableCHandS:
+	mov		bx, [cs:g_MenuitemMasterSlaveUserCHS+MENUITEM.itemValue+ITEM_VALUE.wRomvarsValueOffset]
+	call	Buffers_GetRomvarsValueToAXfromOffsetInBX
+	test	ax, FLG_DRVPARAMS_USERCHS
+	jz		SHORT .DisableCHandS
+
+	mov		bx, g_MenuitemMasterSlaveCylinders
+	call	.EnableMenuitemFromCSBX
+	mov		bx, g_MenuitemMasterSlaveHeads
+	call	.EnableMenuitemFromCSBX
+	mov		bx, g_MenuitemMasterSlaveSectors
+	call	.EnableMenuitemFromCSBX
+	ret
+
+ALIGN JUMP_ALIGN
+.DisableCHandS:
+	mov		bx, g_MenuitemMasterSlaveCylinders
+	call	.DisableMenuitemFromCSBX
+	mov		bx, g_MenuitemMasterSlaveHeads
+	call	.DisableMenuitemFromCSBX
+	mov		bx, g_MenuitemMasterSlaveSectors
+	call	.DisableMenuitemFromCSBX
+	ret
+
+;--------------------------------------------------------------------
+; .EnableMenuitemFromCSBX
+; .DisableMenuitemFromCSBX
+;	Parameters:
+;		CS:BX:	Ptr to MENUITEM
+;	Returns:
+;		Nothing
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+.EnableMenuitemFromCSBX:
+	or		BYTE [cs:bx+MENUITEM.bFlags], FLG_MENUITEM_VISIBLE
+	ret
+
+ALIGN JUMP_ALIGN
+.DisableMenuitemFromCSBX:
+	and		BYTE [cs:bx+MENUITEM.bFlags], ~FLG_MENUITEM_VISIBLE
+	ret
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Strings.asm	(revision 57)
@@ -0,0 +1,235 @@
+; File name		:	Strings.asm
+; Project name	:	XTIDE Universal BIOS Configurator v2
+; Created date	:	5.10.2010
+; Last update	:	2.11.2010
+; Author		:	Tomi Tilli
+; Description	:	All strings.
+
+
+; Section containing initialized data
+SECTION .data
+
+; Menu title
+g_szProgramTitle:
+	db	"Configuration and Flashing program for XTIDE Universal BIOS v1.1.4.",LF,CR,NULL
+g_szXtideUniversalBiosSignature:	db	"XTIDE110",NULL
+g_szBiosIsNotLoaded:				db	"BIOS is not loaded!",NULL
+g_szEEPROM:							db	"EEPROM",NULL
+g_szSourceAndTypeSeparator:			db	" : ",NULL
+g_szUnidentified:					db	"Unidentified",NULL
+g_szUnsaved:						db	" ",SINGLE_LEFT_HORIZONTAL_TO_VERTICAL,
+									db	"Unsaved",SINGLE_RIGHT_HORIZONTAL_TO_VERTICAL, NULL
+									
+; Item formatting
+g_szFormatItemWithoutValue:			db	"%c%s",NULL
+g_szFormatItemNameWithValue:		db	"%26s%-9S",NULL
+
+
+g_szNo:								db	"No",NULL
+g_szYes:							db	"Yes",NULL
+g_szMultichoiseBooleanFlag:
+									db	"No",LF
+									db	"Yes",NULL
+
+
+; Generic dialog strings
+g_szNotificationDialog:	db	"Notification.",NULL
+g_szErrorDialog:		db	"Error!",NULL
+g_szGenericDialogInfo:	db	"Press ENTER or ESC to close dialog.",NULL
+
+
+; Strings for main menu
+g_szItemMainExitToDOS:	db	"Exit to DOS",NULL
+g_szItemMainLoadFile:	db	"Load BIOS from file",NULL
+g_szItemMainLoadROM:	db	"Load BIOS from EEPROM",NULL
+g_szItemMainLoadStngs:	db	"Load old settings from EEPROM",NULL
+g_szItemMainConfigure:	db	"Configure XTIDE Universal BIOS",NULL
+g_szItemMainFlash:		db	"Flash EEPROM",NULL
+
+g_szDlgMainLoadROM:		db	"Successfully loaded XTIDE Universal BIOS from EEPROM.",NULL
+g_szDlgMainLoadStngs:	db	"Successfully loaded settings from EEPROM.",NULL
+g_szDlgMainLoadFile:	db	"Successfully loaded file for flashing.",NULL
+g_szDlgMainSaveFile:	db	"Successfully saved XTIDE Universal BIOS to file.",NULL
+g_szDlgMainFileTooBig:	db	"Selected file is too big to be loaded for flashing!",NULL
+g_szDlgMainLoadErr:		db	"Failed to load file!",NULL
+g_szDlgMainSaveErr:		db	"Failed to save file!",NULL
+g_szDlgFileTitle:		db	"Select file to be flashed.",NULL
+g_szDlgFileFilter:		db	"*.*",NULL
+
+g_szNfoMainExitToDOS:	db	"Quits XTIDE Universal BIOS Configurator.",NULL
+g_szNfoMainLoadFile:	db	"Load BIOS file to be configured or flashed.",NULL
+g_szNfoMainLoadROM:		db	"Load BIOS from EEPROM to be reconfigured.",NULL
+g_szNfoMainLoadStngs:	db	"Load old XTIDE Universal BIOS settings from EEPROM.",NULL
+g_szNfoMainConfigure:	db	"Configure XTIDE Universal BIOS settings.",NULL
+g_szNfoMainFlash:		db	"Flash loaded BIOS image to EEPROM.",NULL
+
+
+; Strings for XTIDE Universal BIOS configuration menu
+g_szItemCfgBackToMain:	db	"Back to Main Menu",NULL
+g_szItemCfgIde1:		db	"Primary IDE Controller",NULL
+g_szItemCfgIde2:		db	"Secondary IDE Controller",NULL
+g_szItemCfgIde3:		db	"Tertiary IDE Controller",NULL
+g_szItemCfgIde4:		db	"Quaternary IDE Controller",NULL
+g_szItemCfgIde5:		db	"Quinary IDE Controller",NULL
+g_szItemCfgBootMenu:	db	"Boot menu settings",NULL
+g_szItemCfgBootLoader:	db	"Boot loader type",NULL
+g_szItemCfgFullMode:	db	"Full operating mode",NULL
+g_szItemCfgStealSize:	db	"kiB to steal from RAM",NULL
+g_szItemCfgIdeCnt:		db	"Number of IDE controllers",NULL
+
+g_szDlgCfgFullMode:		db	"Enable full operating mode?",NULL
+g_szDlgCfgStealSize:	db	"How many kiB of base memory to steal for XTIDE Universal BIOS variables (1...255)?",NULL
+g_szDlgCfgIdeCnt:		db	"How many IDE controllers to manage (1...5)?",NULL
+
+g_szNfoCfgIde:			db	"IDE controller and drive configuration.",NULL
+g_szNfoCfgBootMenu:		db	"Boot menu configuration.",NULL
+g_szNfoCfgBootLoader:	db	"Boot loader selection for INT 19h.",NULL
+g_szNfoCfgFullMode:		db	"Full mode supports multiple controllers and has more features.",NULL
+g_szNfoCfgStealSize:	db	"Number of kiB of base memory to steal for BIOS variables.",NULL
+g_szNfoCfgIdeCnt:		db	"Number of IDE controllers to manage.",NULL
+
+g_szHelpCfgFullMode:	db	"incbin goes here.",NULL
+g_szHelpCfgStealSize:	db	"incbin goes here.",NULL
+
+g_szMultichoiseCfgBootLoader:
+						db	"Boot menu",LF
+						db	"Drive A then C",LF
+						db	"System boot loader",NULL
+
+g_szValueCfgBootLoaderMenu:		db	"Menu",NULL
+g_szValueCfgBootLoaderAthenC:	db	"A, C",NULL
+g_szValueCfgBootLoaderSystem:	db	"System",NULL
+
+
+; Strings for IDE Controller menu
+g_szItemBackToCfgMenu:	db	"Back to Configuration Menu",NULL
+g_szItemIdeMaster:		db	"Master Drive",NULL
+g_szItemIdeSlave:		db	"Slave Drive",NULL
+g_szItemIdeBusType:		db	"Bus type",NULL
+g_szItemIdeCmdPort:		db	"Base (cmd block) address",NULL
+g_szItemIdeCtrlPort:	db	"Control block address",NULL
+g_szItemIdeEnIRQ:		db	"Enable interrupt",NULL
+g_szItemIdeIRQ:			db	"IRQ",NULL
+
+g_szDlgBusType:			db	"Select type of bus where Ide Controller is connected.",NULL
+g_szDlgIdeCmdPort:		db	"Enter IDE command block (base port) address.",NULL
+g_szDlgIdeCtrlPort:		db	"Enter IDE control block address (usually command block + 200h).",NULL
+g_szDlgIdeEnIRQ:		db	"Enable interrupt?",NULL
+g_szDlgIdeIRQ:			db	"Enter IRQ channel (2...7 for 8-bit controllers, 2...15 for any other controller).",NULL
+
+g_szNfoIdeBackToCfgMenu:db	"Back to XTIDE Universal BIOS Configuration Menu.",NULL
+g_szNfoIdeMaster:		db	"Settings for Master Drive.",NULL
+g_szNfoIdeSlave:		db	"Settings for Slave Drive.",NULL
+g_szNfoIdeBusType:		db	"Select controller bus type.",NULL
+g_szNfoIdeCmdPort:		db	"IDE Controller Command Block (base port) address.",NULL
+g_szNfoIdeCtrlPort:		db	"IDE Controller Control Block address. Usually Cmd Block + 200h.",NULL
+g_szNfoIdeEnIRQ:		db	"Interrupt or polling mode.",NULL
+g_szNfoIdeIRQ:			db	"IRQ channel to use.",NULL
+
+g_szHelpIdeCmdPort:		db	"incbin goes here.",NULL
+g_szHelpIdeCtrlPort:	db	"incbin goes here.",NULL
+g_szHelpIdeEnIRQ:		db	"incbin goes here.",NULL
+g_szHelpIdeIRQ:			db	"incbin goes here.",NULL
+
+g_szMultichoiseCfgBusType:
+						db	"8-bit dual port (XTIDE)",LF
+						db	"8-bit single port",LF
+						db	"16-bit",LF
+						db	"32-bit generic",NULL
+
+g_szValueCfgBusTypeDual8b:		db	"2x8-bit",NULL
+g_szValueCfgBusTypeSingle8b:	db	"1x8-bit",NULL
+g_szValueCfgBusType16b:			db	"16-bit",NULL
+g_szValueCfgBusType32b:			db	"32-bit",NULL
+
+
+; Strings for DRVPARAMS menu
+g_szItemDrvBackToIde:	db	"Back to IDE Controller Menu",NULL
+g_szItemDrvBlockMode:	db	"Block Mode Transfers",NULL
+g_szItemDrvUserCHS:		db	"User specified CHS",NULL
+g_szItemDrvCyls:		db	"Cylinders",NULL
+g_szItemDrvHeads:		db	"Heads",NULL
+g_szItemDrvSect:		db	"Sectors per track",NULL
+
+g_szDlgDrvBlockMode:	db	"Enable Block Mode Transfers?",NULL
+g_szDlgDrvUserCHS:		db	"Specify (P-)CHS parameters manually?",NULL
+g_szDlgDrvCyls:			db	"Enter number of P-CHS cylinders (1...16383).",NULL
+g_szDlgDrvHeads:		db	"Enter number of P-CHS heads (1...16).",NULL
+g_szDlgDrvSect:			db	"Enter number of sectors per track (1...63).",NULL
+
+g_szNfoDrvBlockMode:	db	"Transfer multiple sectors per data request.",NULL
+g_szNfoDrvUserCHS:		db	"Specify (P-)CHS manually instead of autodetect.",NULL
+g_szNfoDrvCyls:			db	"Number of user specified P-CHS cylinders.",NULL
+g_szNfoDrvHeads:		db	"Number of user specified P-CHS heads.",NULL
+g_szNfoDrvSect:			db	"Number of user specified P-CHS sectors per track.",NULL
+
+g_szHelpDrvBlockMode:	db	"incbin goes here.",NULL
+g_szHelpDrvUserCHS:		db	"incbin goes here.",NULL
+
+
+; Strings for boot menu settings menu
+g_szItemBootHeight:		db	"Maximum height",NULL
+g_szItemBootTimeout:	db	"Selection timeout",NULL
+g_szItemBootDrive:		db	"Default boot drive",NULL
+g_szItemBootMinFDD:		db	"Min floppy drive count",NULL
+g_szItemBootSwap:		db	"Swap boot drive numbers",NULL
+g_szItemBootRomBoot:	db	"Display ROM boot",NULL
+g_szItemBootInfo:		db	"Display drive info",NULL
+
+g_szDlgBootHeight:		db	"Enter boot menu maximum height in characters (8...25).",NULL
+g_szDlgBootTimeout:		db	"Enter Boot Menu selection timeout in seconds (1...60, 0 disables timeout).",NULL
+g_szDlgBootDrive:		db	"Enter default drive number (0xh for Floppy Drives, 8xh for Hard Disks, FFh for ROM boot).",NULL
+g_szDlgBootMinFDD:		db	"Enter minimum number of floppy drives.",NULL
+g_szDlgBootSwap:		db	"Enable drive number translation?",NULL
+g_szDlgBootRomBoot:		db	"Show ROM Boot option on boot menu?",NULL
+g_szDlgBootInfo:		db	"Show drive information on boot menu?",NULL
+
+g_szNfoBootHeight:		db	"Boot Menu maximum height in characters.",NULL
+g_szNfoBootTimeout:		db	"Menu item selection timeout in seconds.",NULL
+g_szNfoBootDrive:		db	"Default drive on boot menu.",NULL
+g_szNfoBootMinFDD:		db	"Minimum number of floppy drives to display.",NULL
+g_szNfoBootSwap:		db	"Drive Number Translation (swap first drive with selected).",NULL
+g_szNfoBootRomBoot:		db	"Show ROM Basic or ROM DOS boot option.",NULL
+g_szNfoBootInfo:		db	"Show detailed drive information on boot menu.",NULL
+
+g_szHelpBootTimeout:	db	"incbin goes here.",NULL
+g_szHelpBootDrive:		db	"incbin goes here.",NULL
+g_szHelpBootMinFDD:		db	"incbin goes here.",NULL
+g_szHelpBootSwap:		db	"incbin goes here.",NULL
+g_szHelpBootRomBoot:	db	"incbin goes here.",NULL
+g_szHelpBootInfo:		db	"incbin goes here.",NULL
+
+
+; Strings for Flash menu
+g_szItemFlashStart:		db	"Start flashing",NULL
+g_szItemFlashSDP:		db	"SDP command",NULL
+g_szItemFlashAddr:		db	"EEPROM address",NULL
+g_szItemFlashPageSize:	db	"Page size",NULL
+g_szItemFlashChecksum:	db	"Generate checksum byte",NULL
+
+g_szDlgFlashAddr:		db	"Enter segment address where EEPROM is located.",NULL
+g_szDlgFlashPageSize:	db	"Enter write page size (1, 2, 4, 8, 16, 32 or 64 bytes).",NULL
+g_szDlgFlashChecksum:	db	"Generate checksum byte to the end of BIOS image?",NULL
+
+g_szNfoFlashStart:		db	"Writes BIOS to EEPROM.",NULL
+g_szNfoFlashSDP:		db	"Software Data Protection command.",NULL
+g_szNfoFlashAddr:		db	"Address (segment) where EEPROM is located.",NULL
+g_szNfoFlashPageSize:	db	"Number of bytes to write before delay.",NULL
+g_szNfoFlashChecksum:	db	"Generate checksum byte to the end of BIOS image.",NULL
+
+g_szHelpFlashSDP:		db	"incbin goes here.",NULL
+g_szHelpFlashPageSize:	db	"incbin goes here.",NULL
+g_szHelpFlashChecksum:	db	"incbin goes here.",NULL
+
+
+; Strings for SDP command menu
+g_szValueSdpNone:
+g_szItemSdpNone:		db	"None",NULL
+g_szValueSdpEnable:
+g_szItemSdpEnable:		db	"Enable",NULL
+g_szValueSdpDisable:
+g_szItemSdpDisable:		db	"Disable",NULL
+
+g_szNfoSdpNone:			db	"Do not use Software Data Protection.",NULL
+g_szNfoSdpEnable:		db	"Enable Software Data Protection after flashing.",NULL
+g_szNfoSdpDisable:		db	"Disable Software Data Protection after flashing.",NULL
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/gpl-2.0.txt
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/gpl-2.0.txt	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/gpl-2.0.txt	(revision 57)
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
Index: trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile
===================================================================
--- trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile	(revision 57)
+++ trunk/XTIDE_Universal_BIOS_Configurator_v2/makefile	(revision 57)
@@ -0,0 +1,133 @@
+###############################################################################
+# Generic makefile for building binary files.                                 #
+# v. 1.1.0 (28.7.2007 ... 5.10.2010)                                          #
+# (C) Tomi Tilli                                                              #
+# aitotat@gmail.com                                                           #
+#                                                                             #
+# Valid makefile targets are:                                                 #
+# all		Removes existing files and builds binary file in \Build           #
+# build		Builds binary file in \Build                                      #
+# clean		Removes all files from \Build                                     #
+#                                                                             #
+# Build directory must be created manually if it does not exist.              #
+#                                                                             #
+###############################################################################
+
+###########################################
+# Source files and destination executable #
+###########################################
+
+# Assembly source code file (*.asm):
+SRC_ASM = Src/Main.asm
+
+# Program executable file name without extension:
+PROG = xtidecfg
+EXTENSION = com
+
+
+#######################################
+# Destination and include directories #
+#######################################
+
+# Directory where binary file will be compiled to
+BUILD_DIR = Build
+
+# Subdirectories where included files are:
+HEADERS = Inc/
+HEADERS += Src/
+HEADERS += Src/Menupages/
+
+# Subdirectories where library files are:
+LIBS = ../AssemblyLibrary/Inc/
+LIBS += ../AssemblyLibrary/Src/
+LIBS += ../AssemblyLibrary/Src/Display/
+LIBS += ../AssemblyLibrary/Src/File/
+LIBS += ../AssemblyLibrary/Src/Keyboard/
+LIBS += ../AssemblyLibrary/Src/Menu/
+LIBS += ../AssemblyLibrary/Src/Menu/Dialog/
+LIBS += ../AssemblyLibrary/Src/String/
+LIBS += ../AssemblyLibrary/Src/Time/
+LIBS += ../AssemblyLibrary/Src/Util/
+LIBS += ../XTIDE_Universal_BIOS/Inc/
+HEADERS += $(LIBS)
+
+
+
+#################################################################
+# Assembler preprocessor defines.                               #
+#################################################################
+DEFINES = 
+DEFINES_XT = ELIMINATE_CGA_SNOW
+DEFINES_XTPLUS = USE_186 ELIMINATE_CGA_SNOW
+DEFINES_AT = USE_186 USE_286 USE_AT
+
+
+###################
+# Other variables #
+###################
+
+# Add -D in front of every preprocessor define declaration
+DEFS = $(DEFINES:%=-D%)
+DEFS_XT = $(DEFINES_XT:%=-D%)
+DEFS_XTPLUS = $(DEFINES_XTPLUS:%=-D%)
+DEFS_AT = $(DEFINES_AT:%=-D%)
+
+# Add -I in front of all header directories
+IHEADERS = $(HEADERS:%=-I%)
+
+# Path + target file to be build
+TARGET = $(BUILD_DIR)/$(PROG)
+
+
+#########################
+# Compilers and linkers #
+#########################
+
+# Make
+MAKE = mingw32-make.exe
+
+# Assembler
+AS = yasm.exe
+#AS = nasm.exe
+
+# use this command to erase files.
+RM = -del /Q
+
+
+#############################
+# Compiler and linker flags #
+#############################
+
+# Assembly compiler flags
+ASFLAGS = -f bin				# Produce binary object files
+ASFLAGS += $(DEFS)				# Preprocessor defines
+ASFLAGS += $(IHEADERS)			# Set header file directory paths
+ASFLAGS += -Worphan-labels		# Warn about labels without colon
+ASFLAGS += -O9					# Optimize operands to their shortest forms
+
+
+############################################
+# Build process. Actual work is done here. #
+############################################
+
+.PHONY: all at xtplus xt clean
+
+# Make clean debug and release versions
+all: clean xt
+	@echo All build!
+
+at:
+	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_AT) -o"$(TARGET)_at.$(EXTENSION)"
+	@echo AT version "$(TARGET)_at.$(EXTENSION)" build.
+
+xtplus:
+	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XTPLUS) -o"$(TARGET)_xtp.$(EXTENSION)"
+	@echo XT plus version "$(TARGET)_xtp.$(EXTENSION)" build.
+
+xt:
+	@$(AS) "$(SRC_ASM)" $(ASFLAGS) $(DEFS_XT) -o"$(TARGET).$(EXTENSION)"
+	@echo XT version "$(TARGET).$(EXTENSION)" build.
+
+clean:
+	@$(RM) $(BUILD_DIR)\*.*
+	@echo Deleted "(*.*)" from "$(BUILD_DIR)/"
