source: xtideuniversalbios/trunk/Configurator/Src/Main.asm@ 578

Last change on this file since 578 was 2, checked in by Tomi Tilli, 15 years ago
File size: 4.9 KB
RevLine 
[2]1; File name : main.asm
2; Project name : XTIDE Univeral BIOS Configurator
3; Created date : 16.4.2010
4; Last update : 30.4.2010
5; Author : Tomi Tilli
6; Description : Program start and exit.
7
8; Include .inc files
9%include "emulate.inc" ; Emulation library. Must be first!
10%include "BiosData.inc" ; For BIOS Data Area variables
11%include "Variables.inc" ; Global variables for this program
12%include "MenuPage.inc" ; Menu page and item structs
13%include "RomVars.inc" ; XTIDE Universal BIOS ROMVARS
14
15
16; Section containing code
17SECTION .text
18
19; Program first instruction.
20ORG 100h ; Code starts at offset 100h (DOS .COM)
21Start:
22 jmp Main_Start
23
24; Include library sources
25%include "math.asm"
26%include "print.asm"
27%include "string.asm"
28%include "keys.asm"
29%include "file.asm"
30%include "menu.asm"
31
32; Include sources for this program
33%include "Strings.asm" ; For program strings
34%include "MenuEvent.asm" ; For handling menu library events
35%include "MenuEventHotkey.asm" ; For handling menu hotkeys
36%include "MenuPage.asm" ; For accessing MENUPAGE structs
37%include "MenuPageItem.asm" ; For accessing MENUPAGEITEM structs
38%include "MenuPageItemFormat.asm" ; For printing menuitem names
39%include "FormatTitle.asm" ; For printing menu title
40%include "BiosFile.asm" ; For loading and saving BIOS file
41%include "EEPROM.asm" ; For handling EEPROM contents
42%include "Flash.asm" ; For flashing EEPROM
43
44%include "MainMenu.asm" ; For main menu
45%include "ConfigurationMenu.asm" ; For XTIDE Universal BIOS configuration menu
46%include "BootLoaderValueMenu.asm" ; For selecting boot loader type
47%include "IdeControllerMenu.asm" ; For configuring IDEVARS
48%include "BusTypeValueMenu.asm" ; For selecting bus type
49%include "DrvParamsMenu.asm" ; For configuring DRVPARAMS
50%include "BootMenuSettingsMenu.asm" ; For configuring boot menu
51%include "FlashMenu.asm" ; For flash settings
52%include "SdpCommandValueMenu.asm" ; For selecting SDP command
53
54
55;--------------------------------------------------------------------
56; Program start
57;--------------------------------------------------------------------
58ALIGN JUMP_ALIGN
59Main_Start:
60 call MenuDraw_ClrScr ; Clear screen
61 call Main_InitializeVariables
62
63 ; Create main menu
64 mov si, g_MenuPageMain ; DS:SI points to MENUPAGE for main menu
65 call MainMenu_SetMenuitemVisibility
66 call Main_EnterMenu ; Enter menu
67 call MenuDraw_ClrScr ; Clear screen
68
69 ; Exit to DOS
70 mov ax, 4C00h ; Exit to DOS
71 int 21h
72
73
74;--------------------------------------------------------------------
75; Initializes global variables used in this program.
76;
77; Main_InitializeVariables
78; Parameters:
79; Nothing
80; Returns:
81; Nothing
82; Corrupts registers:
83; AX, BX, CX, DX, SI, DI, ES
84;--------------------------------------------------------------------
85ALIGN JUMP_ALIGN
86Main_InitializeVariables:
87 ; Zero all global variables
88 mov di, g_cfgVars ; ES:DI points to global variables
89 mov cx, (CFGVARS_size+ROMVARS_size)/2 ; Size in words
90 xor ax, ax ; To store zero
91 cld ; STOSW to increment DI
92 rep stosw ; Zero all variables
93
94 ; Find Xtide Universal BIOS segment
95 mov dx, 0D000h ; XTIDE default segment
96 call EEPROM_FindXtideUniversalBiosROM
97 jnc SHORT .InitializeVariables
98 mov dx, es ; XTIDE segment to DX
99
100ALIGN JUMP_ALIGN
101.InitializeVariables:
102 mov WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_CHECKSUM
103 mov WORD [g_cfgVars+CFGVARS.wEepromSegment], dx
104 mov BYTE [g_cfgVars+CFGVARS.bPageSize], 1
105 mov BYTE [g_cfgVars+CFGVARS.bSdpCommand], CMD_SDP_ENABLE
106 ret
107
108
109;--------------------------------------------------------------------
110; Enters main or submenu.
111;
112; Main_EnterMenu
113; Parameters:
114; DS:SI: Ptr to MENUPAGE (also menu user far pointer for MENUVARS.user)
115; Returns:
116; CX: Index of last pointed Menuitem (not necessary selected with ENTER)
117; FFFFh if cancelled with ESC
118; Corrupts registers:
119; AX, BX, CX, DX, SI, DI
120;--------------------------------------------------------------------
121ALIGN JUMP_ALIGN
122Main_EnterMenu:
123 call MenuPage_GetNumberOfVisibleItems
124 mov cl, al ; Number of visible menuitems to CL
125 mov ax, (CNT_SCRN_ROW<<8) | WIDTH_MENU
126 mov bx, (CNT_INFO_LINES<<8) | CNT_TITLE_LINES
127 mov ch, [cs:g_cfgVars+CFGVARS.wFlags] ; Load program flags to CH
128 and ch, FLG_MNU_HIDENFO ; Clear all but info flag
129 xor dx, dx ; No selection timeout
130 mov di, MenuEvent_Handler ; CS:DI points to menu event handler
131 inc BYTE [cs:g_cfgVars+CFGVARS.bMenuCnt]
132 call Menu_Enter
133 dec BYTE [cs:g_cfgVars+CFGVARS.bMenuCnt]
134 jz SHORT .Return
135
136 ; Update info visibility for previous menu where to resume
137 test BYTE [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_HIDEINFO
138 jnz SHORT .HideInfo
139 call Menu_ShowInfo
140 ret
141ALIGN JUMP_ALIGN
142.HideInfo:
143 call Menu_HideInfo
144.Return:
145 ret
146
147
148; Section containing uninitialized data
149SECTION .bss
150
151ALIGN WORD_ALIGN ; All global variables
152g_cfgVars: resb CFGVARS_size
Note: See TracBrowser for help on using the repository browser.