PageRenderTime 39ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Configurator/Src/Main.asm

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