
PAGE 01    DAI FIRMWARE 2E1FD-2E315  V1.1

002                         ORG   :E1FD
003                 *
004                 *
005                 *
006                 ************************************
007                 * INITIALISE SCREEN CHARACTER AREA *
008                 ************************************
009                 *
010                 * Fills screen with spaces (clears screen).
011                 * The line mode byte is set #7A, the line colour
012                 * byte to #40, all colour bytes to #00 (4-colour
013                 * text), all character bytes to #20.
014                 *
015                 * Entry: HL: 1st byte after header.
016                 *        DE: end character area.
017                 * Exit:  All registers preserved.
018                 *
019 E1FD F5         FILLS   PUSH  PSW
020 E1FE C5                 PUSH  B
021 E1FF D5                 PUSH  D
022 E200 E5                 PUSH  H
023 E201 367A       FIS10   MVI   M,:7A     Set control byte for char
024                                         mode
025 E203 2B                 DCX   H
026 E204 3640               MVI   M,:40     Set line colour byte
027 E206 2B                 DCX   H
028 E207 0642       FIS20   MVI   B,:42     Number of bytes/line
029 E209 3620       FIS30   MVI   M,:20     Data byte is space
030 E20B 2B                 DCX   H
031 E20C 3600               MVI   M,:00     Colour byte is 00
032 E20E 2B                 DCX   H
033 E20F 05                 DCR   B
034 E210 C209E2             JNZ   :E209     Next screen addr
035 E213 CDFBE6             CALL  :E6FB     All lines done ?
036 E216 C201E2             JNZ   :E201     Next line if not
037 E219 C338E1             JMP   :E138     Popall, ret
038                 *
039                 ****************************
040                 * CHANGE TO CHARACTER MODE *
041                 ****************************
042                 *
043                 * If a character is output when the screen is in
044                 * all-graphic mode, the mode is changed to the
045                 * corresponding split-mode.
046                 * If not sufficient space available, mode 0 is
047                 * tried. If still insufficient space, the emergency
048                 * stop routine is used.
049                 *
050 E21C F5         TMODE   PUSH  PSW
051 E21D 3A9D00             LDA   :009D     Get current screen mode
052 E220 0F                 RRC             Already character mode ?
053 E221 DA31E2             JC    :E231     Abort if true
054 E224 37                 STC             CY=1
055 E225 17                 RAL             Set for split mode
056 E226 CDD9E3             CALL  :E3D9     Change mode
057 E229 3EFF               MVI   A,:FF
058 E22B DCD9E3             CC    :E3D9     Change to mode 0 if not
059                                         sufficient space
060 E22E DA33E2             JC    :E233     Emergency stop if still
061                                         insufficient space
062 E231 F1         TMD10   POP   PSW
063 E232 C9                 RET 

PAGE 02    DAI FIRMWARE 2E1FD-2E315  V1.1

064                             
065                 * If no space for A-mode or mode 0:
066                             
067 E233 2AC600     TMD20   LHLD  :00C6     Get addr emergency stop
068                                         routine
069 E236 E9                 PCHL            Go to this routine
070                 *
071                 ********************
072                 * SET TEXT COLOURS *
073                 ********************
074                 *
075                 * The COLORT parameters are set: the header
076                 * and trailer of the character area are
077                 * initialised.
078                 * The colour values are between 0 and F. The
079                 * top 4 bits are ignored.
080                 * The colour change is immediate.
081                 *
082                 * The 1st 2 colours are the default background
083                 * and foreground colours for characters. The last
084                 * 2 are alternative, and may be used for (e.g.)
085                 * the cursor. Colours may be repeated.
086                 *
087                 * Entry: HL points to a vector of 4 bytes containing
088                 *        the colours to be set.
089                 * Exit:  All registers preserved.
090                 *
091 E237 F5         SCOLT   PUSH  PSW
092 E238 C5                 PUSH  B
093 E239 D5                 PUSH  D
094 E23A E5                 PUSH  H
095 E23B 117C00             LXI   D,:007C   Addr 1st byte colour
096                                         register memory
097 E23E CD54E2             CALL  :E254     Init. COLORT reg memory
098 E241 3A9D00             LDA   :009D     Get current screen mode
099 E244 1F                 RAR             Char mode?
100 E245 2A8A00             LHLD  :008A     Get startaddr char area
101 E248 DC67E2             CC    :E267     If char mode: set colours
102                                         header area
103 E24B 2A8E00             LHLD  :008E     Get addr end of screen
104 E24E DC67E2             CC    :E267     If char mode: set colours
105                                         trailer area
106 E251 C338E1             JMP   :E138     Popall, ret
107                 *
108                 *************************
109                 * SET COLOUR PARAMETERS *
110                 *************************
111                 *
112                 * Loads colour data from ROM into the RAM pointers.
113                 * The high nibbles are 8x, 9x, Ax, Bx.
114                 * Used for both COLORT and COLORG.
115                 *
116                 * Entry: HL: Points to colour parameters.
117                 *        DE: Address colour memory in RAM.
118                 * Exit:  DE: Points after colour memory.
119                 *        Other registers corrupted.
120                 *
121 E254 018010     VCOPY   LXI   B,:1080
122 E257 7E         VCP10   MOV   A,M       Get colour from ROM
123 E258 E60F               ANI   :0F
124 E25A B1                 ORA   C         Add bits 4-7
125 E25B 12                 STAX  D         Store in RAM

PAGE 03    DAI FIRMWARE 2E1FD-2E315  V1.1

126 E25C 23                 INX   H         Next colour
127 E25D 13                 INX   D         Next RAM location
128 E25E 79                 MOV   A,C       )
129 E25F 80                 ADD   B         ) Add #10 to C
130 E260 4F                 MOV   C,A       )
131 E261 FEC0               CPI   :C0       Check if finished
132 E263 C257E2             JNZ   :E257     Next one if not
133 E266 C9                 RET 
134                 *
135                 ***************************************
136                 * LOAD COLOURS IN HEADER/TRAILER AREA *
137                 ***************************************
138                 *
139                 * Sets blanking area colour bytes according to
140                 * information given.
141                 * The colourbytes for the character area are
142                 * loaded into the screen header and trailer area.
143                 *
144                 * Entry: HL: Points to 1st control byte after
145                 *            blanking area.
146                 *        DE: Points after table with colours
147                 *            in RAM.
148                 * Exit:  AFDE preserved, BCHL corrupted.
149                 *
150 E267 F5         BCOLS   PUSH  PSW
151 E268 D5                 PUSH  D
152 E269 010400             LXI   B,:0004   Distance between colour byte
153 E26C 2B                 DCX   H         Addr 1st colour byte of
154                                         screen RAM
155 E26D 1B         BCS10   DCX   D         Addr colour table
156 E26E 1A                 LDAX  D         Get colour byte
157 E26F 09                 DAD   B         HL = addr in screen RAM
158 E270 77                 MOV   M,A       Load byte into screen RAM
159 E271 E630               ANI   :30       Finished ?
160 E273 C26DE2             JNZ   :E26D     Next colourbyte if not
161 E276 D1                 POP   D
162 E277 F1                 POP   PSW
163 E278 C9                 RET 
164                 *
165                 ***********************
166                 * SET CURSOR POSITION *
167                 ***********************
168                 *
169                 * Moves the cursor from its current position to
170                 * any requested position.
171                 * Position 0,0 is the bottom left corner.
172                 *
173                 * Entry: HL contains the y,x position required
174                 *           for the cursor.
175                 * Exit:  BCDEHL preserved.
176                 *        CY=0: OK. F corrupted, A preserved.
177                 *        CY=1: Request off screen.
178                 *              A=01 (error code 'off screen').
179                 *
180 E279 B7         SCURS   ORA   A
181 E27A E5                 PUSH  H
182 E27B D5                 PUSH  D
183 E27C C5                 PUSH  B
184 E27D F5                 PUSH  PSW
185 E27E 7D                 MOV   A,L       X-coord in A
186 E27F FE3C               CPI   :3C       After end of line ?
187 E281 D2C5E2             JNC   :E2C5     Then request off screen

PAGE 04    DAI FIRMWARE 2E1FD-2E315  V1.1

188 E284 87                 ADD   A         X-coord *2
189 E285 4F                 MOV   C,A       in C
190 E286 0618               MVI   B,:18     Nr of lines in mode 0
191 E288 3A9D00             LDA   :009D     Get current screen mode
192 E28B B7                 ORA   A
193 E28C FA95E2             JM    :E295     Jump if mode 0
194 E28F 0604               MVI   B,:04     Nr of lines in A-modes
195 E291 1F                 RAR 
196 E292 D2C5E2             JNC   :E2C5     Error if all-graphics mode
197 E295 7C         SCS10   MOV   A,H       Y-coord in A
198 E296 B8                 CMP   B         More than max value
199 E297 D2C5E2             JNC   :E2C5     Then request off screen
200 E29A CD6BE3             CALL  :E36B     Delete old cursor
201 E29D 3C                 INR   A
202 E29E 218600             LXI   H,:0086   Length 1 char line
203 E2A1 CD46EB             CALL  :EB46     Calc length reqd number of
204                                         lines (HL=A*HL)
205 E2A4 EB                 XCHG            in DE
206 E2A5 2A8C00             LHLD  :008C     Store end archive area
207 E2A8 19                 DAD   D         Start of reqd line
208 E2A9 CD98E6             CALL  :E698     Store addr line mode byte
209                                         current line and store last
210                                         byte on that line
211 E2AC 110800             LXI   D,:0008
212 E2AF CDF2E6             CALL  :E6F2     HL=start of right border
213 E2B2 59                 MOV   E,C
214 E2B3 1600               MVI   D,:00
215 E2B5 CDF2E6             CALL  :E6F2     Subtract char offset
216 E2B8 CD30E3             CALL  :E330     Put cursor on screen
217 E2BB 3E00               MVI   A,:00
218 E2BD 327B00             STA   :007B     No extended lines
219 E2C0 F1                 POP   PSW       No-error return
220 E2C1 C1         SCS20   POP   B
221 E2C2 D1                 POP   D
222 E2C3 E1                 POP   H
223 E2C4 C9                 RET 
224                             
225                 * If error 'off screen':
226                             
227 E2C5 F1         SCS30   POP   PSW
228 E2C6 3E01               MVI   A,:01     Set error code
229 E2C8 3F                 CMC             Change CY to 1
230 E2C9 C3C1E2             JMP   :E2C1     Pop, ret
231                 *
232                 *************************************************
233                 * ASK CURSOR POSITION AND SIZE CHARACTER SCREEN *
234                 *************************************************
235                 *
236                 * Returns the position of the cursor and the
237                 * range of possible values.
238                 * Values given in DE are maximum values of
239                 * coordinates.
240                 * If the mode is all graphics: DE=HL=0.
241                 *
242                 * Entry: None.
243                 * Exit:  HL gives y,x cursor position.
244                 *        DE gives y,x size of character part of
245                 *           the screen (mode 0: #17,#3B: A-modes:
246                 *           #03,#3B).
247                 *        AFBC preserved.
248                 *
249 E2CC F5         SCURA   PUSH  PSW

PAGE 05    DAI FIRMWARE 2E1FD-2E315  V1.1

250 E2CD C5                 PUSH  B
251 E2CE 210000             LXI   H,:0000
252 E2D1 54                 MOV   D,H
253 E2D2 5D                 MOV   E,L       DE=HL=0
254 E2D3 3A9D00             LDA   :009D     Get current screen mode
255 E2D6 1F                 RAR             Char mode ?
256 E2D7 D213E3             JNC   :E313     Abort if not
257 E2DA 2A7800             LHLD  :0078     Get startaddr cursor line
258 E2DD E5                 PUSH  H         Save it on stack
259 E2DE 11F8FF             LXI   D,:FFF8   Size left border
260 E2E1 19                 DAD   D         Get addr 1st char byte
261 E2E2 EB                 XCHG            in DE
262 E2E3 2A7200             LHLD  :0072     Get cursor pos addr
263 E2E6 EB                 XCHG
264 E2E7 CDF2E6             CALL  :E6F2     Calc difference of cursor
265                                         pos from begin of line
266 E2EA D1                 POP   D         Get startaddr current line
267 E2EB 7D                 MOV   A,L       (x-coord cursor)*2 in A
268 E2EC B7                 ORA   A
269 E2ED 1F                 RAR             Now x-coord cursor in A
270 E2EE F5                 PUSH  PSW       Save it on stack
271 E2EF 2A8C00             LHLD  :008C     Get addr end char area
272 E2F2 018600             LXI   B,:0086   Length 1 char line
273 E2F5 AF                 XRA   A         Init Y-pos
274 E2F6 F5         SCA10   PUSH  PSW       Save it on stack
275 E2F7 09                 DAD   B         Get line mode byte next line
276 E2F8 CDFBE6             CALL  :E6FB     Is current line this line?
277 E2FB CA03E3             JZ    :E303     Then jump
278 E2FE F1                 POP   PSW       Get Y-coord
279 E2FF 3C                 INR   A         Incr it
280 E300 C3F6E2             JMP   :E2F6     Check if on next line
281 E303 E1         SCA20   POP   H         Y-coord cursor in H
282 E304 F1                 POP   PSW       X-coord cursor in A
283 E305 6F                 MOV   L,A       and now in L
284 E306 1617               MVI   D,:17     Nr of lines for mode 0 -1
285 E308 3A9D00             LDA   :009D     Get current screen mode
286 E30B B7                 ORA   A
287 E30C FA11E3             JM    :E311     Jump if mode 0
288 E30F 1603               MVI   D,:03     Nr of lines for A-modes -1
289 E311 1E3B       SCA30   MVI   E,:3B     Nr of char/line -1
290 E313 C1         SCA40   POP   B
291 E314 F1                 POP   PSW
292 E315 C9                 RET 
293                 *
294                 *
295                 *
296 E316                    END 
 
***************************
* S Y M B O L   T A B L E *
***************************
 
BCOLS  E267   BCS10  E26D   FILLS  E1FD   FIS10  E201   
FIS20  E207   FIS30  E209   SCA10  E2F6   SCA20  E303   
SCA30  E311   SCA40  E313   SCOLT  E237   SCS10  E295   
SCS20  E2C1   SCS30  E2C5   SCURA  E2CC   SCURS  E279   
TMD10  E231   TMD20  E233   TMODE  E21C   VCOPY  E254   
VCP10  E257
