source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/Dialog/ItemLineSplitter.asm@ 625

Last change on this file since 625 was 625, checked in by Krister Nordvall, 22 months ago

Changes:

  • Added a configuration option to let the BIOS store RamVars to an UMB when Full operating mode is enabled. This is primarily for XT class machines with RAM in the UMA (which apparently is a common thing these days).
  • Added two new builds specifically for IBM PS/2 machines. This is for support of the new McIDE adapter from the guys at zzxio.com. Note that the additional hardware specific code (under the USE_PS2 define) is for the PS/2 machines themselves and not for the McIDE adapters, so any controller in an IBM PS/2 machine can be used with the USE_PS2 define.
  • Moved pColorTheme out of the range of ROMVARS being copied over when doing "Load old settings from EEPROM" in XTIDECFG. This fixed a serious bug from r592 where loading a BIOS from file and then loading the old settings from ROM would corrupt 7 bytes of code somewhere in the loaded BIOS.
  • Optimizations (speed and size) to the library. Browsing the menus in XTIDECFG should now feel a little less sluggish.
  • Hopefully fixed a problem with the PostCommitHook script where it sometimes wouldn't find the CommitInProgress file. I say hopefully because testing this is a nightmare.
File size: 4.7 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for splitting strings to item lines.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2023 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
20struc ITEM_LINE_SPLITTER
21 .wMaxTextLineLength resb 2
22 .wLineToFind resb 2
23 .wStartOfLine resb 2
24endstruc
25
26; Section containing code
27SECTION .text
28
29;--------------------------------------------------------------------
30; ItemLineSplitter_GetLinesToAXforStringInDSSI
31; Parameters:
32; DS:SI: Ptr to string
33; SS:BP: Ptr to MENU
34; Returns:
35; AX: Number of lines on string
36; Corrupts registers:
37; BX, CX, DX, SI
38;--------------------------------------------------------------------
39ALIGN JUMP_ALIGN
40ItemLineSplitter_GetLinesToAXforStringInDSSI:
41 push di
42
43 call MenuLocation_GetMaxTextLineLengthToAX
44 eENTER_STRUCT ITEM_LINE_SPLITTER_size
45 mov [bp+ITEM_LINE_SPLITTER.wMaxTextLineLength], ax
46 mov WORD [bp+ITEM_LINE_SPLITTER.wLineToFind], -1
47
48 xor bx, bx ; Line index
49 mov di, si ; Start of first word
50 mov dx, ProcessCharacterFromStringToSplit
51 call StringProcess_DSSIwithFunctionInDX
52
53 xchg bx, ax
54 inc ax
55 eLEAVE_STRUCT ITEM_LINE_SPLITTER_size
56 pop di
57 ret
58
59
60;--------------------------------------------------------------------
61; ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
62; Parameters:
63; CX: Index of line to search for
64; DS:SI: Ptr to string
65; SS:BP: Ptr to MENU
66; Returns:
67; CX: Line length
68; DS:SI: Ptr to beginning of line
69; CF: Set if wanted line was found
70; Corrupts registers:
71; AX, BX, DX
72;--------------------------------------------------------------------
73ALIGN JUMP_ALIGN
74ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX:
75 push di
76
77 call MenuLocation_GetMaxTextLineLengthToAX
78 eENTER_STRUCT ITEM_LINE_SPLITTER_size
79 mov [bp+ITEM_LINE_SPLITTER.wMaxTextLineLength], ax
80 mov [bp+ITEM_LINE_SPLITTER.wLineToFind], cx
81 mov [bp+ITEM_LINE_SPLITTER.wStartOfLine], si
82
83 xor bx, bx ; Line index
84 mov di, si ; Start of first word
85 mov dx, ProcessCharacterFromStringToSplit
86 call StringProcess_DSSIwithFunctionInDX
87
88 mov si, [bp+ITEM_LINE_SPLITTER.wStartOfLine]
89 jc SHORT .ReturnLineInDSSIandLengthInCX
90 call String_GetLengthFromDSSItoCX ; Last or invalid line. Just return last line.
91
92ALIGN JUMP_ALIGN
93.ReturnLineInDSSIandLengthInCX:
94 eLEAVE_STRUCT ITEM_LINE_SPLITTER_size
95 pop di
96 stc
97 ret
98
99
100;--------------------------------------------------------------------
101; Character processing callback function prototype for StringProcess_DSSIwithFunctionInBX.
102; ProcessCharacterFromStringToSplit
103; Parameters:
104; AL: Character to process
105; BX: Line index
106; CX: Number of characters processed (Characters on line so far)
107; DS:SI: Ptr to next character
108; DS:DI: Start of current word
109; SS:BP: Ptr to ITEM_LINE_SPLITTER
110; Returns:
111; CF: Clear to continue with next character
112; Set to stop processing
113; BX: Line index
114; CX: Characters on line so far
115; DS:DI: Start of current word
116; Corrupts registers:
117; AX
118;--------------------------------------------------------------------
119ALIGN JUMP_ALIGN
120ProcessCharacterFromStringToSplit:
121 cmp al, ' '
122 jbe SHORT .ControlCharacterOrSpace
123
124.CheckLineLength:
125 cmp [bp+ITEM_LINE_SPLITTER.wMaxTextLineLength], cx
126 jb SHORT .ChangeToNextLine
127 ret ; With CF cleared
128
129ALIGN JUMP_ALIGN
130.ChangeToNextLine:
131 cmp bx, [bp+ITEM_LINE_SPLITTER.wLineToFind]
132 je SHORT .WantedLineFound
133
134 inc bx ; Increment line
135 mov si, di ; Start from complete word
136 mov [bp+ITEM_LINE_SPLITTER.wStartOfLine], di
137.CarriageReturn:
138 xor cx, cx ; Zero character counter (and clear CF)
139 ret
140
141ALIGN JUMP_ALIGN
142.ControlCharacterOrSpace:
143 mov di, si ; DS:DI now points start of new word
144 je SHORT .CheckLineLength ; Jump if space
145 cmp al, LF
146 je SHORT .ChangeToNextLine
147 cmp al, CR
148 je SHORT .CarriageReturn ; Reset line length
149 ; Unsupported control character - ignore it
150 dec cx
151 clc
152 ret
153
154ALIGN JUMP_ALIGN
155.WantedLineFound:
156 lea cx, [di-1]
157 sub cx, [bp+ITEM_LINE_SPLITTER.wStartOfLine]
158 stc
159 ret
Note: See TracBrowser for help on using the repository browser.