source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuLocation.asm@ 142

Last change on this file since 142 was 104, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

  • Some more optimizations.
  • Moved macros.inc from XTIDE Universal BIOS to Assembly Library.
File size: 4.1 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for calculation menu window dimensions.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; MenuLocation_GetTitleTextTopLeftCoordinatesToAX
9; MenuLocation_GetInformationTextTopLeftCoordinatesToAX
10; Parameters
11; SS:BP: Ptr to MENU
12; Returns:
13; AL: Column (X)
14; AH: Row (Y)
15; Corrupts registers:
16; Nothing
17;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19MenuLocation_GetTitleTextTopLeftCoordinatesToAX:
20 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
21 jmp SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
22
23ALIGN JUMP_ALIGN
24MenuLocation_GetInformationTextTopLeftCoordinatesToAX:
25 mov ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
26 jmp SHORT AddInformationBordersTopLeftCoordinatesToAX
27
28
29;--------------------------------------------------------------------
30; MenuLocation_GetTextCoordinatesToAXforItemInAX
31; Parameters
32; AX: Item index
33; SS:BP: Ptr to MENU
34; Returns:
35; AL: Column (X)
36; AH: Row (Y)
37; Corrupts registers:
38; Nothing
39;--------------------------------------------------------------------
40ALIGN JUMP_ALIGN
41MenuLocation_GetTextCoordinatesToAXforItemInAX:
42 sub ax, [bp+MENU.wFirstVisibleItem] ; Item to line
43 xchg al, ah ; Line to AH, clear AL
44 add ax, (MENU_TEXT_ROW_OFFSET<<8) | MENU_TEXT_COLUMN_OFFSET
45 jmp SHORT AddItemBordersTopLeftCoordinatesToAX
46
47
48;--------------------------------------------------------------------
49; MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
50; MenuLocation_GetItemBordersTopLeftCoordinatesToAX
51; MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
52; Parameters
53; SS:BP: Ptr to MENU
54; Returns:
55; AL: Column (X)
56; AH: Row (Y)
57; Corrupts registers:
58; Nothing
59;--------------------------------------------------------------------
60ALIGN JUMP_ALIGN
61MenuLocation_GetTitleBordersTopLeftCoordinatesToAX:
62 xor ax, ax
63 jmp SHORT MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
64
65ALIGN JUMP_ALIGN
66MenuLocation_GetItemBordersTopLeftCoordinatesToAX:
67 xor ax, ax
68 jmp SHORT AddItemBordersTopLeftCoordinatesToAX
69
70ALIGN JUMP_ALIGN
71MenuLocation_GetBottomBordersTopLeftCoordinatesToAX:
72 xor ax, ax
[104]73 ; Fall to .AddBottomBordersTopLeftCoordinatesToAX
[41]74
75;--------------------------------------------------------------------
[104]76; .AddBottomBordersTopLeftCoordinatesToAX
[41]77; AddInformationBordersTopLeftCoordinatesToAX
78; AddItemBordersTopLeftCoordinatesToAX
79; MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
80; Parameters
81; AX: Zero of offset
82; SS:BP: Ptr to MENU
83; Returns:
84; AL: Column (X)
85; AH: Row (Y)
86; Corrupts registers:
87; Nothing
88;--------------------------------------------------------------------
[104]89.AddBottomBordersTopLeftCoordinatesToAX:
[41]90 stc ; Compensate for Information top border
91 adc ah, [bp+MENUINIT.bInfoLines]
92ALIGN JUMP_ALIGN
93AddInformationBordersTopLeftCoordinatesToAX:
94 push cx
95 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
96 inc cx ; Compensate for Items top border
97 add ah, cl
98 pop cx
99ALIGN JUMP_ALIGN
100AddItemBordersTopLeftCoordinatesToAX:
101 stc ; Compensate for Title top border
102 adc ah, [bp+MENUINIT.bTitleLines]
103ALIGN JUMP_ALIGN
104MenuLocation_AddTitleBordersTopLeftCoordinatesToAX:
105 push di
106 push ax
107 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
108 sub al, [bp+MENUINIT.bWidth]
109 sub ah, [bp+MENUINIT.bHeight]
110 shr al, 1
111 shr ah, 1
112 pop di ; Old AX to DI
113 add ax, di ; Add old AX to menu top left coordinates
114 pop di
115 ret
116
117
118;--------------------------------------------------------------------
119; MenuLocation_GetMaxTextLineLengthToAX
120; Parameters
121; SS:BP: Ptr to MENU
122; Returns:
123; AX: Maximum text line length in characters
124; Corrupts registers:
125; Nothing
126;--------------------------------------------------------------------
127ALIGN JUMP_ALIGN
128MenuLocation_GetMaxTextLineLengthToAX:
129 eMOVZX ax, BYTE [bp+MENUINIT.bWidth]
130 sub ax, BYTE MENU_HORIZONTAL_BORDER_LINES + MENU_TEXT_COLUMN_OFFSET
131 ret
Note: See TracBrowser for help on using the repository browser.