Changeset 181 in xtideuniversalbios for trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm


Ignore:
Timestamp:
Nov 13, 2011, 3:38:40 PM (12 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes to all parts of the project:

  • Size optimizations.
  • Added a define (EXCLUDE_FROM_XTIDECFG) to exclude unused library code from XTIDECFG.
  • Tried to minimize time spent with interrupts disabled.
  • Some minor attempts to improve speed (reordering instructions etc).
  • Tried to improve readability, did some cleanup and fixed some errors in comments.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/Menu/MenuScrollbars.asm

    r133 r181  
    3737MenuScrollbars_GetScrollCharacterToALForLineInDI:
    3838    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
    39     call    .GetFirstThumbLineToAX
     39    ; Get first thumb line to AX
     40    mov     ax, [bp+MENU.wFirstVisibleItem]
     41    call    .CalculateFirstOrLastThumbLineToAX
     42
    4043    cmp     di, ax              ; Before first thumb line?
    4144    jb      SHORT .ReturnTrackCharacter
    4245    call    .GetLastThumbLineToAX
    43     cmp     di, ax              ; After last thumb line?
    44     ja      SHORT .ReturnTrackCharacter
    45     mov     al, SCROLL_THUMB_CHARACTER
    46     ret
     46    cmp     ax, di              ; After last thumb line?
    4747ALIGN JUMP_ALIGN
    4848.ReturnTrackCharacter:
    4949    mov     al, SCROLL_TRACK_CHARACTER
     50    jb      SHORT .Return
     51    mov     al, SCROLL_THUMB_CHARACTER
     52ALIGN JUMP_ALIGN, ret
     53.Return:
    5054    ret
    5155
     
    6367.GetLastThumbLineToAX:
    6468    call    MenuScrollbars_GetLastVisibleItemOnPageToAX
    65     jmp     SHORT .CalculateFirstOrLastThumbLineToAX
    66 
    67 ;--------------------------------------------------------------------
    68 ; .GetFirstThumbLineToAX
    69 ;   Parameters
     69    ; Fall to .CalculateFirstOrLastThumbLineToAX
     70
     71;--------------------------------------------------------------------
     72; .CalculateFirstOrLastThumbLineToAX
     73;   Parameters
     74;       AX:     Index of first or last visible item on page
    7075;       CX:     Max visible items on page
    7176;       SS:BP:  Ptr to MENU
     
    7681;--------------------------------------------------------------------
    7782ALIGN JUMP_ALIGN
    78 .GetFirstThumbLineToAX:
    79     mov     ax, [bp+MENU.wFirstVisibleItem]
    8083.CalculateFirstOrLastThumbLineToAX:
    8184    mul     cx
     
    98101    mov     cx, [bp+MENUINIT.wHighlightedItem]
    99102    add     cx, ax
    100     call    .RotateItemInCX
     103    ; Fall to .RotateItemInCX
     104
     105;--------------------------------------------------------------------
     106; .RotateItemInCX
     107;   Parameters
     108;       CX:     Possibly under of overflown item to be rotated
     109;       SS:BP:  Ptr to MENU
     110;   Returns:
     111;       CX:     Valid item index
     112;   Corrupts registers:
     113;       DX
     114;--------------------------------------------------------------------
     115;.RotateItemInCX:
     116    mov     dx, [bp+MENUINIT.wItems]
     117    test    cx, cx
     118    js      SHORT .RotateNegativeItemInCX
     119    sub     cx, dx
     120    jae     SHORT .ScrollPageForNewItemInCX
     121
     122ALIGN JUMP_ALIGN
     123.RotateNegativeItemInCX:
     124    add     cx, dx
    101125    ; Fall to .ScrollPageForNewItemInCX
    102126
     
    111135;       AX, BX, CX, DX, SI, DI
    112136;--------------------------------------------------------------------
     137ALIGN JUMP_ALIGN
    113138.ScrollPageForNewItemInCX:
    114139    call    MenuScrollbars_IsItemInCXonVisiblePage
     
    117142    mov     dx, [bp+MENU.wFirstVisibleItem]
    118143    sub     dx, [bp+MENUINIT.wHighlightedItem]
     144
     145    ; Get MaxFirstVisibleItem to AX
     146    push    cx
     147    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
     148    mov     ax, [bp+MENUINIT.wItems]
     149    sub     ax, cx
     150    pop     cx
     151
    119152    add     dx, cx
    120     MAX_S   dx, 0
    121     call    .GetMaxFirstVisibleItemToAX
    122     MIN_U   ax, dx
     153    jns     .DXisPositive
     154    cwd     ; This won't work if MaxFirstVisibleItem > 32767
     155
     156ALIGN JUMP_ALIGN
     157.DXisPositive:
     158    cmp     ax, dx
     159    jb      .AXisLessThanDX
     160    xchg    dx, ax
     161
     162ALIGN JUMP_ALIGN
     163.AXisLessThanDX:
    123164    mov     [bp+MENU.wFirstVisibleItem], ax
    124165    call    MenuText_RefreshAllItems
     
    127168.HighlightNewItemOnCX:
    128169    jmp     MenuEvent_HighlightItemFromCX
    129 
    130 ;--------------------------------------------------------------------
    131 ; .GetMaxFirstVisibleItemToAX
    132 ;   Parameters
    133 ;       SS:BP:  Ptr to MENU
    134 ;   Returns:
    135 ;       AX:     Max first visible item
    136 ;   Corrupts registers:
    137 ;       Nothing
    138 ;--------------------------------------------------------------------
    139 ALIGN JUMP_ALIGN
    140 .GetMaxFirstVisibleItemToAX:
    141     push    cx
    142 
    143     call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
    144     mov     ax, [bp+MENUINIT.wItems]
    145     sub     ax, cx
    146 
    147     pop     cx
    148     ret
    149 
    150 ;--------------------------------------------------------------------
    151 ; .RotateItemInCX
    152 ;   Parameters
    153 ;       CX:     Possibly under of overflown item to be rotated
    154 ;       SS:BP:  Ptr to MENU
    155 ;   Returns:
    156 ;       CX:     Valid item index
    157 ;   Corrupts registers:
    158 ;       DX
    159 ;--------------------------------------------------------------------
    160 ALIGN JUMP_ALIGN
    161 .RotateItemInCX:
    162     mov     dx, [bp+MENUINIT.wItems]
    163     test    cx, cx
    164     js      SHORT .RotateNegativeItemInCX
    165     cmp     cx, dx
    166     jae     SHORT .RotatePositiveItemInCX
    167     ret
    168 
    169 ALIGN JUMP_ALIGN
    170 .RotatePositiveItemInCX:
    171     sub     cx, dx
    172     ;jae    SHORT .RotatePositiveItemInCX   ; Not needed by scrolling
    173     ret
    174 
    175 ALIGN JUMP_ALIGN
    176 .RotateNegativeItemInCX:
    177     add     cx, dx
    178     ;js     SHORT .RotateNegativeItemInCX   ; Not needed by scrolling
    179     ret
    180170
    181171
     
    216206ALIGN JUMP_ALIGN
    217207MenuScrollbars_GetLastVisibleItemOnPageToAX:
    218     push    cx
    219 
     208    xchg    cx, ax
    220209    call    MenuScrollbars_GetActualVisibleItemsOnPageToCX
    221210    xchg    ax, cx
    222211    dec     ax
    223212    add     ax, [bp+MENU.wFirstVisibleItem]
    224 
    225     pop     cx
    226213    ret
    227214
     
    239226MenuScrollbars_GetActualVisibleItemsOnPageToCX:
    240227    call    MenuScrollbars_GetMaxVisibleItemsOnPageToCX
    241     MIN_U   cx, [bp+MENUINIT.wItems]
     228    cmp     cx, [bp+MENUINIT.wItems]
     229    jb      SHORT .Return
     230    mov     cx, [bp+MENUINIT.wItems]
     231ALIGN JUMP_ALIGN, ret
     232.Return:
    242233    ret
    243234
Note: See TracChangeset for help on using the changeset viewer.