source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Main.asm @ 593

Last change on this file since 593 was 593, checked in by aitotat, 6 years ago

Flashing now works again.
Hack to get Windows 95 to work properly (MODULE_WIN95_CMOS_HACK included for 386 builds by default).
Edited makefile to produce large 386 build.
Fixed recovery time for QDI Vision VLB-IDE controllers.
No more warnings with Nasm 2.13.xx and later.
File dialog now properly restores default drive when file selection is cancelled.

File size: 4.8 KB
Line 
1; Project name  :   XTIDE Universal BIOS Configurator v2
2; Description   :   Program start and exit.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Include .inc files
21
22%define INCLUDE_MENU_DIALOGS
23%define INCLUDE_SERIAL_LIBRARY
24
25%include "AssemblyLibrary.inc"  ; Assembly Library. Must be included first!
26%include "RomVars.inc"          ; XTIDE Universal BIOS variables
27%include "IdeRegisters.inc"     ; Needed for port and device autodetection
28%include "JRIDE_ISA.inc"        ; For JR-IDE/ISA default segment
29%include "ADP50L.inc"           ; For ADP50L default segment
30%include "XTCF.inc"             ; For XT-CF modes
31
32%include "Version.inc"
33%include "MenuCfg.inc"
34%include "MenuStructs.inc"
35%include "Variables.inc"
36
37
38; Section containing code
39SECTION .text
40
41
42; Program first instruction.
43ORG 100h                        ; Code starts at offset 100h (DOS .COM)
44Start:
45    jmp     Main_Start
46
47; Include library sources
48%include "AssemblyLibrary.asm"
49
50; Include sources for this program
51%include "AutoConfigure.asm"
52%include "BiosFile.asm"
53%include "Buffers.asm"
54%include "Dialogs.asm"
55%include "EEPROM.asm"
56%include "Flash.asm"
57%include "IdeAutodetect.asm"
58%include "MenuEvents.asm"
59%include "Menuitem.asm"
60%include "MenuitemPrint.asm"
61%include "Menupage.asm"
62%include "Strings.asm"
63
64%include "BootMenuSettingsMenu.asm"
65%include "ConfigurationMenu.asm"
66%include "FlashMenu.asm"
67%include "IdeControllerMenu.asm"
68%include "MainMenu.asm"
69%include "MasterSlaveMenu.asm"
70
71
72
73;--------------------------------------------------------------------
74; Program start
75;--------------------------------------------------------------------
76ALIGN JUMP_ALIGN
77Main_Start:
78    mov     ah, GET_DOS_VERSION
79    int     DOS_INTERRUPT_21h
80    cmp     al, 2
81    jae     SHORT .DosVersionIsOK
82    mov     dx, g_s$NotMinimumDosVersion
83    mov     ah, WRITE_STRING_TO_STANDARD_OUTPUT
84    int     DOS_INTERRUPT_21h
85    ret
86.DosVersionIsOK:
87    mov     [bDosVersionMajor], al                  ; bDosVersionMajor must be initialized by the application (library code depends on it)
88    cmp     al, 5
89    jb      SHORT .DoNotInstallInt2FhHandler
90    ; Since we are installing our Int2Fh handler we must also hook interrupt 23h to ensure a clean exit on ctrl-c/ctrl-break
91    call    HookInterrupt23h
92    call    HookInterrupt2Fh
93.DoNotInstallInt2FhHandler:
94
95    mov     ax, SCREEN_BACKGROUND_CHARACTER_AND_ATTRIBUTE
96    call    InitializeScreenWithBackgroundCharAndAttrInAX
97
98    call    Main_InitializeCfgVars
99    call    MenuEvents_DisplayMenu
100    mov     ax, DOS_BACKGROUND_CHARACTER_AND_ATTRIBUTE
101    call    InitializeScreenWithBackgroundCharAndAttrInAX
102
103    call    UnhookInterrupt2Fh
104
105    ; Exit to DOS
106    mov     ax, TERMINATE_WITH_RETURN_CODE<<8       ; Errorlevel 0 in AL
107    int     DOS_INTERRUPT_21h
108
109
110;--------------------------------------------------------------------
111; InitializeScreenWithBackgroundCharAndAttrInAX
112;   Parameters:
113;       AL:     Background character
114;       AH:     Background attribute
115;   Returns:
116;       Nothing
117;   Corrupts registers:
118;       AX, DX, DI
119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121InitializeScreenWithBackgroundCharAndAttrInAX:
122    xchg    dx, ax
123    CALL_DISPLAY_LIBRARY InitializeDisplayContext   ; Reset cursor etc
124    xchg    ax, dx
125    JMP_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
126
127
128;--------------------------------------------------------------------
129; Main_InitializeCfgVars
130;   Parameters:
131;       DS:     Segment to CFGVARS
132;   Returns:
133;       Nothing
134;   Corrupts registers:
135;       AX, BX, CX, DI
136;--------------------------------------------------------------------
137ALIGN JUMP_ALIGN
138Main_InitializeCfgVars:
139    push    es
140
141    call    Buffers_Clear
142    call    EEPROM_FindXtideUniversalBiosROMtoESDI
143    jc      SHORT .InitializationCompleted
144    mov     [CFGVARS.wEepromSegment], es
145.InitializationCompleted:
146    pop     es
147    ret
148
149
150; Section containing initialized data
151SECTION .data
152
153ALIGN WORD_ALIGN
154g_cfgVars:
155istruc CFGVARS
156    at  CFGVARS.pMenupage,          dw  g_MenupageForMainMenu
157    at  CFGVARS.wFlags,             dw  DEFAULT_CFGVARS_FLAGS
158    at  CFGVARS.wEepromSegment,     dw  0
159    at  CFGVARS.bEepromType,        db  DEFAULT_EEPROM_TYPE
160    at  CFGVARS.bEepromPage,        db  DEFAULT_PAGE_SIZE
161    at  CFGVARS.bSdpCommand,        db  DEFAULT_SDP_COMMAND
162iend
163
164
165; Section containing uninitialized data
166SECTION .bss
167
168bDosVersionMajor:   resb    1
169
Note: See TracBrowser for help on using the repository browser.