Changeset 48 in xtideuniversalbios for trunk


Ignore:
Timestamp:
Oct 8, 2010, 3:44:05 PM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to Assembly Library:
Added functions to clear Menu Title and Information areas.
Implemented automatic line change when writing Menu Title and Information areas.
CGA snow related functions have been moved to CgaSnow.asm.
Keyboard input functions no longer produce beep for backspace.

Location:
trunk/Assembly_Library
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Inc/AssemblyLibrary.inc

    r41 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   2.7.2010
    4 ; Last update   :   16.9.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Common defines for all library functions.
     
    1212%include "BiosData.inc"
    1313%include "BiosFunctions.inc"
     14%include "CgaSnow.inc"
    1415%include "Debug.inc"
    1516%include "DosFunctions.inc"
  • trunk/Assembly_Library/Inc/Display.inc

    r45 r48  
    22; Project name  :   AssemblyLibrary
    33; Created date  :   25.6.2010
    4 ; Last update   :   28.9.2010
     4; Last update   :   6.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Defines for display library.
     
    2626    %elifidn %1, PopDisplayContext
    2727        call    DisplayContext_Pop
     28    %elifidn %1, PrepareOffScreenBufferInESBXtoESDI
     29        call    DisplayContext_PrepareOffScreenBufferInESBXtoESDI
    2830    %else
    2931        mov     di, DISPLAY_LIB.%1
     
    3739    .PushDisplayContext:
    3840    .PopDisplayContext:
     41    .PrepareOffScreenBufferInESBXtoESDI:
    3942    .InitializeDisplayContext                       resb    2
    4043
     
    181184COLOR_TEXT_SEGMENT          EQU     0B800h  ; Text modes 0...3 (CGA+)
    182185MONO_TEXT_SEGMENT           EQU     0B000h  ; Text mode 7 (MDA, Hercules)
     186
     187OFFSET_TO_CGA_STATUS_REGISTER   EQU     6   ; Base port 3D4h + 6 = 3DAh
     188CGA_STATUS_REGISTER             EQU     3DAh
    183189
    184190
  • trunk/Assembly_Library/Inc/Menu.inc

    r45 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   13.7.2010
    4 ; Last update   :   15.9.2010
     4; Last update   :   5.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Defines for Menu library.
     
    3535        call    MenuInit_SetTitleHeightFromAL
    3636
     37    %elifidn %1, GetHighlightedItemToAX
     38        call    MenuInit_GetHighlightedItemToAX
     39
    3740    %elifidn %1, SetTotalItemsFromAX
    3841        call    MenuInit_SetTotalItemsFromAX
     
    6063
    6164    .SetTitleHeightFromAL:
     65    .ClearTitleArea                             resb    2
    6266    .RefreshTitle                               resb    2
    6367
     68    .GetHighlightedItemToAX:
    6469    .HighlightItemFromAX                        resb    2
    6570    .SetTotalItemsFromAX:
     
    6772
    6873    .SetInformationHeightFromAL:
     74    .ClearInformationArea                       resb    2
    6975    .RefreshInformation                         resb    2
    7076
     
    130136NO_ITEM_SELECTED                    EQU     -1
    131137NO_ITEM_HIGHLIGHTED                 EQU     -1
     138NO_TIMEOUT_USED                     EQU     0
    132139
    133140
  • trunk/Assembly_Library/Inc/MenuEvents.inc

    r41 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   13.7.2010
    4 ; Last update   :   11.8.2010
     4; Last update   :   5.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Defines for Menu events send to the user.
     
    4949
    5050    ; Parameters:
    51     ;   None but cursor has been positioned to the beginning of first line
     51    ;   CX:         Index of highlighted item
     52    ;   Cursor has been positioned to the beginning of first line
    5253    .RefreshTitle                   resb    2
    5354    .RefreshInformation             resb    2
  • trunk/Assembly_Library/Src/AssemblyLibrary.asm

    r45 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   15.9.2010
    4 ; Last update   :   29.9.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Assembly Library main file. This is the only file that
     
    1111
    1212%ifdef INCLUDE_DISPLAY_LIBRARY
     13    %include "CgaSnow.asm"
    1314    %include "Display.asm"
    1415    %include "DisplayCharOut.asm"
  • trunk/Assembly_Library/Src/Display/DisplayCharOut.asm

    r47 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   26.6.2010
    4 ; Last update   :   4.10.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for outputting characters to video memory.
     
    1111; Section containing code
    1212SECTION .text
    13 
    14 ;--------------------------------------------------------------------
    15 ; WAIT_RETRACE_IF_NECESSARY_THEN
    16 ;   Parameters:
    17 ;       AL:     Character to output
    18 ;       AH:     Attribute to output (stosw only)
    19 ;       DS:     BDA segment (zero)
    20 ;       ES:DI:  Ptr to video memory where to output
    21 ;   Returns:
    22 ;       DI:     Incremented for next character
    23 ;   Corrupts registers:
    24 ;       AX, DX
    25 ;--------------------------------------------------------------------
    26 %macro WAIT_RETRACE_IF_NECESSARY_THEN 1
    27 %ifdef ELIMINATE_CGA_SNOW
    28     %ifidn %1, stosb
    29         call    StosbWithoutCgaSnow
    30     %else
    31         call    StoswWithoutCgaSnow
    32     %endif
    33 %else
    34     %1          ; STOSB or STOSW
    35 %endif
    36 %endmacro
    37 
    3813
    3914;--------------------------------------------------------------------
     
    155130.BufferFull:
    156131    ret
    157 
    158 
    159 ; STOSB and STOSW replacement functions to prevent CGA snow. These will slow
    160 ; drawing a lot so use them only if it is necessary to eliminate CGA snow.
    161 %ifdef ELIMINATE_CGA_SNOW
    162 
    163 OFFSET_TO_CGA_STATUS_REGISTER   EQU     6       ; Base port 3D4h + 6 = 3DAh
    164 CGA_STATUS_REGISTER             EQU     3DAh
    165 
    166 ;--------------------------------------------------------------------
    167 ; WAIT_UNTIL_SAFE_CGA_WRITE
    168 ;   Parameters:
    169 ;       DX:     CGA Status Register Address (3DAh)
    170 ;   Returns:
    171 ;       Nothing
    172 ;   Corrupts registers:
    173 ;       AL
    174 ;--------------------------------------------------------------------
    175 %macro WAIT_UNTIL_SAFE_CGA_WRITE 0
    176 %%WaitUntilNotInRetrace:
    177     in      al, dx
    178     shr     al, 1   ; 1 = Bit 0: A 1 indicates that regen-buffer memory access can be
    179                     ; made without interfering with the display. (H or V retrace)
    180     jc      SHORT %%WaitUntilNotInRetrace
    181 %%WaitUntilNextRetraceStarts:
    182     in      al, dx
    183     shr     al, 1
    184     jnc     SHORT %%WaitUntilNextRetraceStarts
    185 %endmacro
    186 
    187 ;--------------------------------------------------------------------
    188 ; StosbWithoutCgaSnow
    189 ; StoswWithoutCgaSnow
    190 ;   Parameters:
    191 ;       AL:     Character to output
    192 ;       AH:     Attribute to output (StoswWithoutCgaSnow only)
    193 ;       DS:     BDA segment (zero)
    194 ;       ES:DI:  Ptr to video memory where to output
    195 ;   Returns:
    196 ;       DI:     Incremented for next character
    197 ;   Corrupts registers:
    198 ;       AX, DX
    199 ;--------------------------------------------------------------------
    200 ALIGN JUMP_ALIGN
    201 StosbWithoutCgaSnow:
    202     call    DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    203     jne     SHORT .StosbWithoutWaitSinceUnknownPort
    204 
    205     mov     ah, al
    206     cli             ; Interrupt request would mess up timing
    207     WAIT_UNTIL_SAFE_CGA_WRITE
    208     mov     al, ah
    209 .StosbWithoutWaitSinceUnknownPort:
    210     stosb
    211     sti
    212     ret
    213 
    214 ALIGN JUMP_ALIGN
    215 StoswWithoutCgaSnow:
    216     push    bx
    217     call    DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    218     jne     SHORT .StoswWithoutWaitSinceUnknownPort
    219 
    220     xchg    bx, ax
    221     cli             ; Interrupt request would mess up timing
    222     WAIT_UNTIL_SAFE_CGA_WRITE
    223     xchg    ax, bx
    224 .StoswWithoutWaitSinceUnknownPort:
    225     stosw
    226     pop     bx
    227     sti
    228     ret
    229 
    230 
    231 ;--------------------------------------------------------------------
    232 ; DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    233 ;   Parameters:
    234 ;       DS:     BDA segment (zero)
    235 ;   Returns:
    236 ;       DX:     CGA Status Register Address
    237 ;       ZF:     Set if CGA Base Port found in BDA
    238 ;   Corrupts registers:
    239 ;       Nothing
    240 ;--------------------------------------------------------------------
    241 ALIGN JUMP_ALIGN
    242 DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA:
    243     mov     dx, [BDA.wVidPort]
    244     add     dl, OFFSET_TO_CGA_STATUS_REGISTER
    245     cmp     dx, CGA_STATUS_REGISTER
    246     ret
    247 
    248 %endif ; ELIMINATE_CGA_SNOW
  • trunk/Assembly_Library/Src/Display/DisplayContext.asm

    r45 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   25.6.2010
    4 ; Last update   :   28.9.2010
     4; Last update   :   5.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for managing display context.
     
    102102
    103103;--------------------------------------------------------------------
     104; DisplayContext_PrepareOffScreenBufferInESBXtoESDI
     105;   Parameters:
     106;       BX:AX:  Ptr to off screen buffer
     107;   Returns:
     108;       Nothing
     109;   Corrupts registers:
     110;       AX
     111;--------------------------------------------------------------------
     112ALIGN JUMP_ALIGN
     113DisplayContext_PrepareOffScreenBufferInESBXtoESDI:
     114    push    ds
     115
     116    LOAD_BDA_SEGMENT_TO ds, di
     117    xchg    ax, bx
     118    mov     bx, es
     119    call    DisplayContext_SetCharacterPointerFromBXAX  ; ES:DI now has the pointer
     120
     121    mov     bl, ATTRIBUTES_NOT_USED
     122    mov     ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
     123    call    DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
     124
     125    mov     bx, di
     126    pop     ds
     127    ret
     128
     129
     130;--------------------------------------------------------------------
    104131; DisplayContext_SynchronizeToHardware
    105132;   Parameters:
     
    123150;       DS:     BDA segment (zero)
    124151;   Returns:
    125 ;       ES:DI:  Pointer that was in DX:AX
     152;       ES:DI:  Pointer that was in BX:AX
    126153;   Corrupts registers:
    127154;       AX
  • trunk/Assembly_Library/Src/Display/DisplayFormat.asm

    r47 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   29.6.2010
    4 ; Last update   :   4.10.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for displaying formatted strings.
     
    220220    dec     di                  ; DI = Offset where to move last byte formatted
    221221    xchg    bx, ax              ; BX = BYTEs to prepend
    222     call    .ReverseMoveCXbytesFromESSItoESDI
     222    call    .ReverseCopyCXbytesFromESSItoESDI
    223223    xchg    ax, bx
    224224    call    .ReversePrintAXspacesStartingFromESDI
     
    231231
    232232;--------------------------------------------------------------------
    233 ; .ReverseMoveCXbytesFromESSItoESDI
    234 ;   Parameters:
    235 ;       CX:     Number of bytes to move
    236 ;       DS:     BDA segment (zero)
    237 ;       ES:SI:  Ptr to source in video RAM
    238 ;       ES:DI:  Ptr to destination in video RAM
    239 ;   Returns:
    240 ;       DI:     Offset to character preceeding string just moved
     233; .ReverseCopyCXbytesFromESSItoESDI
     234;   Parameters:
     235;       CX:     Number of bytes to copy
     236;       DS:     BDA segment (zero)
     237;       ES:SI:  Ptr to old location
     238;       ES:DI:  Ptr to new location
     239;   Returns:
     240;       DI:     Updated to before last character copied
    241241;   Corrupts registers:
    242242;       AX, CX, DX, SI
    243243;--------------------------------------------------------------------
    244244ALIGN JUMP_ALIGN
    245 .ReverseMoveCXbytesFromESSItoESDI:
    246 %ifdef ELIMINATE_CGA_SNOW
    247     call    DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    248     je      SHORT .WaitUntilReadyToMoveNextByte
    249 %endif
    250 
     245.ReverseCopyCXbytesFromESSItoESDI:
     246    test    BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
     247    jz      SHORT .CopyWithoutDisplayProcessing
     248
     249    WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
     250    dec     di                  ; Point to preceeding character instead of attribute
     251    ret
     252ALIGN JUMP_ALIGN
     253.CopyWithoutDisplayProcessing:
    251254    eSEG_STR rep, es, movsb
    252 
    253 %ifdef ELIMINATE_CGA_SNOW
    254     jmp     SHORT .AlignDIforFirstPreceedingSpace
    255 .WaitUntilReadyToMoveNextByte:
    256     cli             ; Interrupt request would mess up timing
    257     WAIT_UNTIL_SAFE_CGA_WRITE
    258 .MovsbWithoutWaitSinceUnknownPort:
    259     eSEG    es
    260     movsb
    261     sti
    262     loop    .WaitUntilReadyToMoveNextByte
    263 %endif
    264     ; Fall to .AlignDIforFirstPreceedingSpace
    265 
    266 ;--------------------------------------------------------------------
    267 ; .AlignDIforFirstPreceedingSpace
    268 ;   Parameters:
    269 ;       DS:     BDA segment (zero)
    270 ;       ES:DI:  Byte offset before last byte moved
    271 ;   Returns:
    272 ;       DI:     Offset to space preceeding moved string
    273 ;   Corrupts registers:
    274 ;       AX
    275 ;--------------------------------------------------------------------
    276 ALIGN JUMP_ALIGN
    277 .AlignDIforFirstPreceedingSpace:
    278     mov     al, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags]
    279     and     ax, BYTE FLG_CONTEXT_ATTRIBUTES
    280     not     ax
    281     and     di, ax
    282255    ret
    283256
  • trunk/Assembly_Library/Src/Display/DisplayPrint.asm

    r44 r48  
    2525;   minimum number of characters. For example %8d would append spaces
    2626;   after integer so that at least 8 characters would be printed.
     27;
     28;   When placing '-' after number, then spaces will be used for prepending.
     29;   For example %8-d would prepend integer with spaces so that at least
     30;   8 characters would be printed.
    2731;
    2832; DisplayPrint_FormattedNullTerminatedStringFromCSSI
  • trunk/Assembly_Library/Src/Keyboard/Keyboard.asm

    r41 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   5.7.2010
    4 ; Last update   :   12.8.2010
     4; Last update   :   7.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for managing keyboard.
     
    9797    loop    .GetCharacterFromUser
    9898.PlayBellForRejectedCharacter:
     99    cmp     al, BS                              ; No bell for backspace
     100    je      SHORT .GetCharacterFromUser
    99101    call    Keyboard_PlayBellForUnwantedKeystroke
    100102    jmp     SHORT .GetCharacterFromUser
     
    169171    dec     di
    170172    call    Keyboard_PrintBackspace
     173    mov     al, BS                              ; Restore character
    171174.RejectCharacter:
    172175    test    al, al                              ; Clear ZF...
     
    227230    push    di
    228231    CALL_DISPLAY_LIBRARY PrintCharacterFromAL
    229     CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware
     232    CALL_DISPLAY_LIBRARY SynchronizeDisplayContextToHardware    ; Hardware cursor
    230233    pop     di
    231234    ret
  • trunk/Assembly_Library/Src/LibraryTests.asm

    r46 r48  
    8383    ret
    8484.szMenuTitle:
    85     db      "First line for menu title.",CR,LF,
    86     db      "This is the second line.",NULL
     85    db      "Simple test program for Assembly Library. Can be used to find bugs.",NULL
    8786
    8887ALIGN JUMP_ALIGN
     
    9796.szInfoTitle:
    9897    db      "Information line 1,",CR,LF,
    99     db      "Information line 2,",CR,LF,
    100     db      "This is the last information line.",NULL
     98    db      "Information line 2. ",
     99    db      "This comes (12) right after Information line 2.",NULL
    101100
    102101ALIGN JUMP_ALIGN
  • trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm

    r46 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   6.8.2010
    4 ; Last update   :   1.10.2010
     4; Last update   :   7.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Common functions for many dialogs.
     
    291291ALIGN JUMP_ALIGN
    292292.RedrawDialogAreaAndWholeParentWindow:
     293    push    si
     294    call    MenuBorders_AdjustDisplayContextForDrawingBorders
     295    pop     si
    293296    mov     al, SCREEN_BACKGROUND_ATTRIBUTE
    294297    CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
    295     call    MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
    296     CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
    297298    mov     ax, [bp+MENUINIT.wWidthAndHeight]
    298299    CALL_DISPLAY_LIBRARY ClearAreaWithHeightInAHandWidthInAL
  • trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm

    r46 r48  
    260260    mov     bx, di
    261261    CALL_DISPLAY_LIBRARY PushDisplayContext
    262 
    263     xchg    ax, bx
    264     mov     bx, es
    265     CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
    266     mov     bl, ATTRIBUTES_NOT_USED
    267     mov     ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
    268     CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
     262    CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXtoESDI
    269263
    270264    call    .FormatFileOrDirectoryToBufferFromDTAinDSSI
    271265
    272266    CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
    273     mov     es, bx
    274267    xchg    bx, ax
    275268    CALL_DISPLAY_LIBRARY PopDisplayContext
  • trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm

    r45 r48  
    3333;       Nothing
    3434;   Corrupts registers:
    35 ;       AX, BX, DX, SI, DI
     35;       AX, BX, CX, DX, SI, DI
    3636;--------------------------------------------------------------------
    3737ALIGN JUMP_ALIGN
  • trunk/Assembly_Library/Src/Menu/Menu.asm

    r41 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   3.8.2010
    4 ; Last update   :   15.9.2010
     4; Last update   :   7.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Menu Library functions for CALL_MENU_LIBRARY macro
     
    4646
    4747    ;at MENU_LIB.SetTitleHeightFromAL,          dw  MenuInit_SetTitleHeightFromAL           ; Special case in CALL_MENU_LIBRARY
     48    at  MENU_LIB.ClearTitleArea,                dw  MenuText_ClearTitleArea
    4849    at  MENU_LIB.RefreshTitle,                  dw  MenuText_RefreshTitle
    4950
     
    5354
    5455    ;at MENU_LIB.SetInformationHeightFromAL,    dw  MenuInit_SetInformationHeightFromAL     ; Special case in CALL_MENU_LIBRARY
     56    at  MENU_LIB.ClearInformationArea,          dw  MenuText_ClearInformationArea
    5557    at  MENU_LIB.RefreshInformation,            dw  MenuText_RefreshInformation
    5658
  • trunk/Assembly_Library/Src/Menu/MenuCharOut.asm

    r41 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   15.7.2010
    4 ; Last update   :   4.8.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Character out function for printing withing menu window.
     
    2929ALIGN JUMP_ALIGN
    3030.PrintCRandAdjustColumnToMenuBorders:
    31     call    DisplayCharOut_TeletypeOutputWithAttribute
     31    call    DisplayCharOut_BiosTeletypeOutput
    3232    xor     ax, ax                  ; No offset, cursor to start of border
    3333    jmp     SHORT SetCursorToNextMenuLine
     
    3535
    3636;--------------------------------------------------------------------
     37; MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
    3738; MenuCharOut_MenuTextTeletypeOutputWithAttribute
    3839;   Parameters:
     
    4748;--------------------------------------------------------------------
    4849ALIGN JUMP_ALIGN
     50MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange:
     51    push    di
     52    push    ax
     53    mov     al, DOUBLE_VERTICAL
     54    add     di, BYTE MENU_TEXT_COLUMN_OFFSET    ; Border char comes after space
     55    WAIT_RETRACE_IF_NECESSARY_THEN scasb
     56    pop     ax
     57    pop     di
     58    je      SHORT MovePartialWordToNewTextLineAndPrintCharacterFromAX
     59    ; Fall to MenuCharOut_MenuTextTeletypeOutputWithAttribute
     60
     61ALIGN JUMP_ALIGN
    4962MenuCharOut_MenuTextTeletypeOutputWithAttribute:
    5063    cmp     al, CR                      ; Carriage return?
    51     je      SHORT .PrintCRandAdjustColumnToMenuText
     64    je      SHORT PrintCRfromALandAdjustColumnToMenuText
    5265    jmp     DisplayCharOut_TeletypeOutputWithAttribute
    5366
    54 ALIGN JUMP_ALIGN
    55 .PrintCRandAdjustColumnToMenuText:
    56     call    DisplayCharOut_TeletypeOutputWithAttribute
     67
     68;--------------------------------------------------------------------
     69; MovePartialWordToNewTextLineAndPrintCharacterFromAX
     70;   Parameters:
     71;       AL:     Character to output
     72;       AH:     Attribute to output
     73;       DS:     BDA segment (zero)
     74;       ES:DI:  Ptr to end of text line in video memory
     75;   Returns:
     76;       DI:     Incremented for next character
     77;   Corrupts registers:
     78;       AX, DX
     79;--------------------------------------------------------------------
     80ALIGN JUMP_ALIGN
     81MovePartialWordToNewTextLineAndPrintCharacterFromAX:
     82    cmp     al, ' '
     83    je      SHORT .MoveCursorInDItoBeginningOfNextLine
     84    push    si
     85    push    cx
     86    push    ax
     87
     88    call    .GetOffsetToPartialWordToSIandSizeToCX
     89    call    .MoveCursorInDItoBeginningOfNextLine
     90    jcxz    .NothingToMove
     91    call    .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
     92.NothingToMove:
     93    pop     ax
     94    pop     cx
     95    pop     si
     96    jmp     DisplayCharOut_TeletypeOutputWithAttribute
     97
     98;--------------------------------------------------------------------
     99; .GetOffsetToPartialWordToSIandSizeToCX
     100;   Parameters:
     101;       ES:DI:  Ptr to space before border character
     102;   Returns:
     103;       CX:     Number of bytes that needs to be moved
     104;       ES:SI:  Ptr to beginning of partial word that needs to be moved to new line
     105;   Corrupts registers:
     106;       Nothing
     107;--------------------------------------------------------------------
     108ALIGN JUMP_ALIGN
     109.GetOffsetToPartialWordToSIandSizeToCX:
     110    xor     cx, cx
     111    mov     si, di
     112ALIGN JUMP_ALIGN
     113.ScanNextCharacter:     ; Space will always be found since one comes after border
     114    dec     si
     115    dec     si
     116    cmp     BYTE [es:si], ' '
     117    je      SHORT .PartialWordFound
     118    inc     cx
     119    jmp     SHORT .ScanNextCharacter
     120ALIGN JUMP_ALIGN
     121.PartialWordFound:
     122    inc     si
     123    inc     si          ; SI now points one past space
     124    shl     cx, 1       ; Characters to bytes
     125    ret
     126
     127;--------------------------------------------------------------------
     128; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
     129;   Parameters:
     130;       CX:     Number of bytes in partial word
     131;       DS:     BDA segment (zero)
     132;       ES:SI:  Ptr to partial word on previous line
     133;       ES:DI:  Ptr to new empty line
     134;   Returns:
     135;       ES:DI:  Ptr where to store next character
     136;   Corrupts registers:
     137;       AX, CX, DX, SI
     138;--------------------------------------------------------------------
     139ALIGN JUMP_ALIGN
     140.MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
     141    push    si
     142    push    cx
     143    WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
     144    pop     cx
     145    pop     si
     146    xchg    di, si
     147    shr     cx, 1       ; Bytes to characters
     148    mov     al, ' '
     149    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
     150    mov     di, si
     151    ret
     152
     153;--------------------------------------------------------------------
     154; .MoveCursorInDItoBeginningOfNextLine
     155;   Parameters:
     156;       DS:     BDA segment (zero)
     157;       ES:DI:  Ptr to cursor location
     158;   Returns:
     159;       ES:DI:  Ptr to beginning of new line
     160;   Corrupts registers:
     161;       AX, DX
     162;--------------------------------------------------------------------
     163ALIGN JUMP_ALIGN
     164.MoveCursorInDItoBeginningOfNextLine:
     165    mov     al, LF
     166    call    DisplayCharOut_BiosTeletypeOutput
     167    mov     al, CR
     168    ; Fall to PrintCRfromALandAdjustColumnToMenuText
     169
     170
     171;--------------------------------------------------------------------
     172; PrintCRfromALandAdjustColumnToMenuText
     173;   Parameters:
     174;       AL:     Character to output (CR)
     175;       DS:     BDA segment (zero)
     176;       ES:DI:  Ptr to video memory where to output
     177;   Returns:
     178;       DI:     Incremented for next text line
     179;   Corrupts registers:
     180;       AX, DX
     181;--------------------------------------------------------------------
     182ALIGN JUMP_ALIGN
     183PrintCRfromALandAdjustColumnToMenuText:
     184    call    DisplayCharOut_BiosTeletypeOutput
    57185    mov     al, MENU_TEXT_COLUMN_OFFSET ; Offset to start of text
    58186    ; Fall to SetCursorToNextMenuLine
  • trunk/Assembly_Library/Src/Menu/MenuEvent.asm

    r41 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   13.7.2010
    4 ; Last update   :   11.8.2010
     4; Last update   :   5.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for initializing menu system.
     
    6565; MenuEvent_RefreshInformation
    6666;   Parameters
     67;       SS:BP:  Ptr to MENU
    6768;       Cursor will be positioned to beginning of window
    6869;   Returns:
     
    7071;               Cleared if event not processed
    7172;   Corrupts registers:
    72 ;       AX, BX, DX
     73;       AX, CX, BX, DX
    7374;--------------------------------------------------------------------
    7475ALIGN JUMP_ALIGN
    7576MenuEvent_RefreshTitle:
    7677    mov     bx, MENUEVENT.RefreshTitle
    77     jmp     SHORT MenuEvent_SendFromBX
     78    jmp     SHORT LoadHighlightedItemToCXandSendMessageFromBX
     79
    7880ALIGN JUMP_ALIGN
    7981MenuEvent_RefreshInformation:
    8082    mov     bx, MENUEVENT.RefreshInformation
     83LoadHighlightedItemToCXandSendMessageFromBX:
     84    mov     cx, [bp+MENU.wHighlightedItem]
    8185    jmp     SHORT MenuEvent_SendFromBX
    8286
     
    8690;   Parameters
    8791;       CX:     Index of item to refresh
     92;       SS:BP:  Ptr to MENU
    8893;       Cursor has been positioned to the beginning of item line
    8994;   Returns:
     
    103108;   Parameters
    104109;       CX:     Index of item to highlight
     110;       SS:BP:  Ptr to MENU
    105111;   Returns:
    106112;       Nothing
     
    128134;       AL:     ASCII character for the key
    129135;       AH:     Keyboard library scan code for the key
     136;       SS:BP:  Ptr to MENU
    130137;   Returns:
    131138;       CF:     Set if event processed
     
    144151;   Parameters
    145152;       CX:     Index of selected item
     153;       SS:BP:  Ptr to MENU
    146154;   Returns:
    147155;       CF:     Set if event processed
  • trunk/Assembly_Library/Src/Menu/MenuInit.asm

    r46 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   13.7.2010
    4 ; Last update   :   1.10.2010
     4; Last update   :   5.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for initializing menu system.
     
    113113    jmp     MenuScrollbars_MoveHighlightedItemByAX
    114114
     115;--------------------------------------------------------------------
     116; MenuInit_GetHighlightedItemToAX
     117;   Parameters
     118;       SS:BP:  Ptr to MENU
     119;   Returns:
     120;       AX:     Index of highlighted item or NO_ITEM_HIGHLIGHTED
     121;   Corrupts registers:
     122;       Nothing
     123;--------------------------------------------------------------------
     124ALIGN JUMP_ALIGN
     125MenuInit_GetHighlightedItemToAX:
     126    mov     ax, [bp+MENU.wHighlightedItem]
     127    ret
     128
    115129
    116130;--------------------------------------------------------------------
  • trunk/Assembly_Library/Src/Menu/MenuText.asm

    r45 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   21.7.2010
    4 ; Last update   :   28.9.2010
     4; Last update   :   7.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for drawing menu texts by the user.
     
    1010
    1111;--------------------------------------------------------------------
     12; MenuText_ClearTitleArea
     13; MenuText_ClearInformationArea
     14;   Parameters
     15;       SS:BP:  Ptr to MENU
     16;   Returns:
     17;       Nothing
     18;   Corrupts registers:
     19;       AX, BX, CX, DX, SI, DI
     20;--------------------------------------------------------------------
     21ALIGN JUMP_ALIGN
     22MenuText_ClearTitleArea:
     23    call    PrepareToDrawTitleArea
     24    mov     cl, [bp+MENUINIT.bTitleLines]
     25    jmp     SHORT ClearCLlinesOfText
     26
     27ALIGN JUMP_ALIGN
     28MenuText_ClearInformationArea:
     29    call    PrepareToDrawInformationArea
     30    mov     cl, [bp+MENUINIT.bInfoLines]
     31ClearCLlinesOfText:
     32    mov     al, [bp+MENUINIT.bWidth]
     33    sub     al, MENU_HORIZONTAL_BORDER_LINES+MENU_TEXT_COLUMN_OFFSET
     34    mul     cl
     35    xchg    cx, ax
     36    mov     al, ' '
     37    CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
     38    ret
     39
     40
     41;--------------------------------------------------------------------
    1242; MenuText_RefreshTitle
    1343; MenuText_RefreshInformation
     
    1747;       Nothing
    1848;   Corrupts registers:
    19 ;       AX, BX, DX, SI, DI
     49;       AX, BX, CX, DX, SI, DI
    2050;--------------------------------------------------------------------
    2151ALIGN JUMP_ALIGN
     
    2353    cmp     BYTE [bp+MENUINIT.bTitleLines], 0
    2454    jz      SHORT NothingToRefresh
    25 
    26     mov     si, ATTRIBUTE_CHARS.cTitle
    27     call    AdjustDisplayContextForDrawingTexts
    28     call    MenuLocation_GetTitleTextTopLeftCoordinatesToAX
    29     CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
     55    call    PrepareToDrawTitleArea
    3056    jmp     MenuEvent_RefreshTitle
    3157
     
    3460    cmp     BYTE [bp+MENUINIT.bInfoLines], 0
    3561    jz      SHORT NothingToRefresh
    36 
     62    call    PrepareToDrawInformationArea
     63    jmp     MenuEvent_RefreshInformation
     64
     65;--------------------------------------------------------------------
     66; PrepareToDrawTitleArea
     67; PrepareToDrawInformationArea
     68;   Parameters
     69;       SS:BP:  Ptr to MENU
     70;   Returns:
     71;       Nothing
     72;   Corrupts registers:
     73;       AX, BX, DX, SI, DI
     74;--------------------------------------------------------------------
     75ALIGN JUMP_ALIGN
     76PrepareToDrawTitleArea:
     77    mov     si, ATTRIBUTE_CHARS.cTitle
     78    mov     ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
     79    call    AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
     80    call    MenuLocation_GetTitleTextTopLeftCoordinatesToAX
     81    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
     82    ret
     83
     84ALIGN JUMP_ALIGN
     85PrepareToDrawInformationArea:
    3786    mov     si, ATTRIBUTE_CHARS.cInformation
    38     call    AdjustDisplayContextForDrawingTexts
     87    mov     ax, MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
     88    call    AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
    3989    call    MenuLocation_GetInformationTextTopLeftCoordinatesToAX
    4090    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
    41     jmp     MenuEvent_RefreshInformation
     91    ret
    4292
    4393
     
    109159    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
    110160    call    .GetItemTextAttributeTypeToSIforItemInCX
    111     jmp     SHORT AdjustDisplayContextForDrawingTexts
     161    mov     ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute
     162    jmp     SHORT AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
    112163
    113164;--------------------------------------------------------------------
     
    142193;       Nothing
    143194;   Corrupts registers:
    144 ;       AX, DX, SI, DI
     195;       AX, BX, DX, SI, DI
    145196;--------------------------------------------------------------------
    146197ALIGN JUMP_ALIGN
     
    188239;       Nothing
    189240;   Corrupts registers:
    190 ;       AX, DX, SI, DI
     241;       AX, BX, DX, SI, DI
    191242;--------------------------------------------------------------------
    192243ALIGN JUMP_ALIGN
     
    194245    push    cx
    195246
    196     mov     si, ATTRIBUTE_CHARS.cBordersAndBackground
    197     call    MenuAttribute_SetToDisplayContextFromTypeInSI
     247    call    MenuBorders_AdjustDisplayContextForDrawingBorders
    198248
    199249    mov     ax, cx
     
    211261
    212262;--------------------------------------------------------------------
    213 ; AdjustDisplayContextForDrawingTexts
    214 ;   Parameters
     263; AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX
     264;   Parameters
     265;       AX:     Character output function
    215266;       SI:     Attribute type (from ATTRIBUTE_CHARS)
    216267;       SS:BP:  Ptr to MENU
     
    221272;--------------------------------------------------------------------
    222273ALIGN JUMP_ALIGN
    223 AdjustDisplayContextForDrawingTexts:
     274AdjustDisplayContextForDrawingTextsWithCharOutFunctionFromAX:
    224275    mov     bl, ATTRIBUTES_ARE_USED
    225     mov     ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute
    226276    CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInBL
    227277
Note: See TracChangeset for help on using the changeset viewer.