Subversion Repositories SvarDOS

Rev

Rev 1483 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1483 Rev 1484
Line 132... Line 132...
132
; * The LANG ID is simply the value for the two uppercase LANG letters, for  *
132
; * The LANG ID is simply the value for the two uppercase LANG letters, for  *
133
; * example the LANG ID for "PL" is 4C50h (50h = 'P', 4Ch = 'L').            *
133
; * example the LANG ID for "PL" is 4C50h (50h = 'P', 4Ch = 'L').            *
134
; ****************************************************************************
134
; ****************************************************************************
135
 
135
 
136
; DE [44h 45h]
136
; DE [44h 45h]
137
mov     di, TEXT_DE
137
mov     bp, TEXT_DE
138
cmp     ax, 4544h
138
cmp     ax, 4544h
139
je      LANGOK
139
je      LANGOK
140
 
140
 
141
; FR [46h 52h]
141
; FR [46h 52h]
142
mov     di, TEXT_FR
142
mov     bp, TEXT_FR
143
cmp     ax, 5246h
143
cmp     ax, 5246h
144
je      LANGOK
144
je      LANGOK
145
 
145
 
146
; NL [4Eh 4Ch]
146
; NL [4Eh 4Ch]
147
mov     di, TEXT_NL
147
mov     bp, TEXT_NL
148
cmp     ax, 4C4Eh
148
cmp     ax, 4C4Eh
149
je      LANGOK
149
je      LANGOK
150
 
150
 
151
; PL [50h 4Ch]
151
; PL [50h 4Ch]
152
mov     di, TEXT_PL
152
mov     bp, TEXT_PL
153
cmp     ax, 4C50h
153
cmp     ax, 4C50h
154
je      LANGOK
154
je      LANGOK
155
 
155
 
156
; RU [52h 55h]
156
; RU [52h 55h]
157
mov     di, TEXT_RU
157
mov     bp, TEXT_RU
158
cmp     ax, 5552h
158
cmp     ax, 5552h
159
je      LANGOK
159
je      LANGOK
160
 
160
 
161
; TR [54h 52h]
161
; TR [54h 52h]
162
mov     di, TEXT_TR
162
mov     bp, TEXT_TR
163
cmp     ax, 5254h
163
cmp     ax, 5254h
164
je      LANGOK
164
je      LANGOK
165
 
165
 
166
 
166
 
167
; *** LANG NOT FOUND OR LANG ID MATCH FAILED: FALL BACK TO EN ****************
167
; *** LANG NOT FOUND OR LANG ID MATCH FAILED: FALL BACK TO EN ****************
168
 
168
 
169
ENDOFENV:
169
ENDOFENV:
170
mov di, TEXT_EN
170
mov     bp, TEXT_EN
171
 
171
 
172
LANGOK:
172
LANGOK:
173
 
173
 
174
 
174
 
175
; ****************************************************************************
175
; ****************************************************************************
Line 177... Line 177...
177
; * safely close original stdin (file handle 0) and then duplicate stderr    *
177
; * safely close original stdin (file handle 0) and then duplicate stderr    *
178
; * into stdin. The purpose of these shenanigans is to be able to cope with  *
178
; * into stdin. The purpose of these shenanigans is to be able to cope with  *
179
; * situations when stdin is redirected (eg. with CTTY)                      *
179
; * situations when stdin is redirected (eg. with CTTY)                      *
180
; ****************************************************************************
180
; ****************************************************************************
181
 
181
 
182
; duplicate stdin and keep the new file handle in BP
182
; duplicate stdin and keep the new file handle in FHANDLE
183
xor     bx, bx
183
xor     bx, bx
184
mov     ah, 45h
184
mov     ah, 45h
185
int     21h
185
int     21h
186
mov     bp, ax
186
mov     [FHANDLE], ax
187
 
187
 
188
; I can close stdin now
188
; I can close stdin now
189
mov     ah, 3Eh
189
mov     ah, 3Eh
190
int     21h
190
int     21h
191
 
191
 
Line 201... Line 201...
201
; make sure cursor is on column 0
201
; make sure cursor is on column 0
202
mov ah, 2h                             ; write character in DL to stdout
202
mov ah, 2h                             ; write character in DL to stdout
203
mov dl, 0Dh                            ; carriage return
203
mov dl, 0Dh                            ; carriage return
204
int 21h
204
int 21h
205
 
205
 
-
 
206
; reset BX - from now on bh = cur row and bl = cur col
-
 
207
xor     bx, bx
206
 
208
 
207
; consume stdin bytes by loading them into buffer
209
; consume stdin bytes by loading them into buffer
208
RELOADBUF:
210
RELOADBUF:
-
 
211
xchg    di, bx                         ; save BX to DI (contains cur row+col)
209
mov     ah, 3Fh                        ; DOS 2+ - read from file or device
212
mov     ah, 3Fh                        ; DOS 2+ - read from file or device
210
mov     bx, bp                         ; duplicated stdin is still in bp
213
mov     bx, [FHANDLE]                  ; duplicated stdin was saved in FHANDLE
211
mov     cx, 1024
214
mov     cx, 1024
212
mov     dx, offset BUFFER
215
mov     dx, offset BUFFER
213
int     21h
216
int     21h
214
 
217
 
215
; abort on error
218
; abort on error
216
jc EXIT
219
jc EXIT
217
 
220
 
-
 
221
; restore bx
-
 
222
xchg    bx, di
-
 
223
 
218
; did I get any bytes? 0 bytes read means "EOF"
224
; did I get any bytes? 0 bytes read means "EOF"
219
test    ax, ax
225
test    ax, ax
220
jnz     PREPLOOP
226
jnz     PREPLOOP
221
 
227
 
222
EXIT:
228
EXIT:
Line 243... Line 249...
243
 
249
 
244
; [8h] BACKSPACE? moves the cursor back by one column, no effect if it is on
250
; [8h] BACKSPACE? moves the cursor back by one column, no effect if it is on
245
; first column already. it does not blank the characters it passes over.
251
; first column already. it does not blank the characters it passes over.
246
cmp     al, 8h
252
cmp     al, 8h
247
jne     NOTBS
253
jne     NOTBS
248
cmp     byte ptr [CURCOL], 0
254
test    bl, bl                         ; am I on on column 0? (bl = cur col)
249
je      OUTPUT_CHAR
255
jz      OUTPUT_CHAR
250
dec     byte ptr [CURCOL]
256
dec     bl
251
jmp     short OUTPUT_CHAR
257
jmp     short OUTPUT_CHAR
252
NOTBS:
258
NOTBS:
253
 
259
 
254
; [9h] TAB?
260
; [9h] TAB?
255
cmp     al, 9h
261
cmp     al, 9h
256
jne     NOTTAB
262
jne     NOTTAB
257
mov     ah, [CURCOL]
263
add     bl, 8                          ; bl = cur col
258
add     ah, 7
264
and     bl, 248
259
and     ah, 11111000b
-
 
260
inc     ah
-
 
261
mov     [CURCOL], ah
-
 
262
jmp     short OUTPUT_CHAR
265
jmp     short OUTPUT_CHAR
263
NOTTAB:
266
NOTTAB:
264
 
267
 
265
; [0Ah] LF?
268
; [0Ah] LF?
266
cmp     al, 0Ah
269
cmp     al, 0Ah
267
jne     NOTLF
270
jne     NOTLF
268
inc     byte ptr [CURROW]
271
inc     bh                             ; bh = cur row
269
jmp     short OUTPUT_CHAR
272
jmp     short OUTPUT_CHAR
270
NOTLF:
273
NOTLF:
271
 
274
 
272
; [0Dh] CR?
275
; [0Dh] CR?
273
cmp     al, 0Dh
276
cmp     al, 0Dh
274
jnz     NOTCR
277
jnz     NOTCR
275
mov     byte ptr [CURCOL], 0
278
xor     bl, bl                         ; bl = cur col
276
jmp     short OUTPUT_CHAR
279
jmp     short OUTPUT_CHAR
277
NOTCR:
280
NOTCR:
278
 
281
 
279
; otherwise: increment cur column, and then maybe cur row
282
; otherwise: increment cur column, and then maybe cur row
280
inc     byte ptr [CURCOL]
283
inc     bl                             ; bl = cur col
281
mov     ah, [CURCOL]
-
 
282
cmp     ah, [MAXCOL]
284
cmp     bl, [MAXCOL]
283
jb      OUTPUT_CHAR
285
jb      OUTPUT_CHAR
284
inc     byte ptr [CURROW]
286
inc     bh                             ; bh = cur row
285
mov     byte ptr [CURCOL], 0
287
xor     bl, bl                         ; bl = cur col
286
 
288
 
287
OUTPUT_CHAR:
289
OUTPUT_CHAR:
288
mov     dl, al
290
mov     dl, al
289
mov     ah, 2h
291
mov     ah, 2h
290
int     21h
292
int     21h
291
mov     ah, [CURROW]
-
 
292
cmp     ah, [MAXROW]
293
cmp     bh, [MAXROW]                   ; bh = cur row
293
jae     PRESSANYKEY
294
jae     PRESSANYKEY
294
 
295
 
295
CHARLOOP:
296
CHARLOOP:
296
loop    NEXTCHAR                       ; dec cx and jmp to NEXTCHAR if cx > 0
297
loop    NEXTCHAR                       ; dec cx and jmp to NEXTCHAR if cx > 0
297
jmp     RELOADBUF
298
jmp     RELOADBUF
Line 300... Line 301...
300
; display " --- More ---"
301
; display " --- More ---"
301
PRESSANYKEY:
302
PRESSANYKEY:
302
mov     ah, 9h                         ; disp $-termin. string pointed by DX
303
mov     ah, 9h                         ; disp $-termin. string pointed by DX
303
mov     dx, offset SEPAR1
304
mov     dx, offset SEPAR1
304
int     21h
305
int     21h
305
mov     dx, di
306
mov     dx, bp
306
int     21h
307
int     21h
307
mov     dx, offset SEPAR2
308
mov     dx, offset SEPAR2
308
int     21h
309
int     21h
309
 
310
 
310
; wait for a keypress
311
; wait for a keypress
Line 318... Line 319...
318
 
319
 
319
; output a CR/LF pair and reset counters
320
; output a CR/LF pair and reset counters
320
mov     dx, offset CRLF
321
mov     dx, offset CRLF
321
mov     ah, 9h
322
mov     ah, 9h
322
int     21h
323
int     21h
323
mov     byte ptr [CURCOL], 0
-
 
324
mov     byte ptr [CURROW], 0
324
xor     bx, bx                         ; bh = cur row, bl = cur col
325
jmp     CHARLOOP
325
jmp     CHARLOOP
326
 
326
 
327
 
327
 
328
; ****************************************************************************
328
; ****************************************************************************
329
; * DATA                                                                     *
329
; * DATA                                                                     *
330
; ****************************************************************************
330
; ****************************************************************************
331
 
331
 
332
MAXROW  db      24                     ; maximum *addressable* row (not total)
332
MAXROW  db      24                     ; maximum *addressable* row (not total)
333
MAXCOL  db      80                     ; total available columns
333
MAXCOL  db      80                     ; total available columns
334
CURROW  db      0
-
 
335
CURCOL  db      0
-
 
336
 
-
 
337
 
334
 
338
CRLF DB 13, 10, '$'
335
CRLF DB 13, 10, '$'
339
LANG DB "LANG="
336
LANG DB "LANG="
340
SEPAR1 DB "--- $"
337
SEPAR1 DB "--- $"
341
SEPAR2 DB " ---$"
338
SEPAR2 DB " ---$"
Line 346... Line 343...
346
TEXT_NL DB "MEER$"
343
TEXT_NL DB "MEER$"
347
TEXT_PL DB "DALEJ$"
344
TEXT_PL DB "DALEJ$"
348
TEXT_RU DB 84h,80h,8Bh,85h,85h,'$'     ; "DALEE" (CP 866)
345
TEXT_RU DB 84h,80h,8Bh,85h,85h,'$'     ; "DALEE" (CP 866)
349
TEXT_TR DB "DAHA FAZLA$"
346
TEXT_TR DB "DAHA FAZLA$"
350
 
347
 
351
; uninitialized buffer area (must be defined last)
348
; uninitialized area (must be defined last)
-
 
349
 
-
 
350
FHANDLE dw      ?                      ; file handle I read from (DUPed stdin)
-
 
351
 
352
BUFFER:
352
BUFFER: