> Here's a project I'm working on, eventually it'll be used on an
> old PC (8088) serving as a dumb terminal via null modem cable
> into a Linux box. It has a problem with the escape sequences used
> for the display, [;80H for example fails miserably. These
> are in the procedure called "EscSquare"- a real headache.
> begin 644 term.zip
[clipped]
> end
"A real headache" indeed. I hope you didn't write the layout of the code
yourself (or you don't mind me criticising it ;-) ) ...
I took just a 15 minute glance of the code and didn't directly find anything
wrong with the EscSquare routine, but I would rip out most of the code and
replace it with data structures as follows (all code typed right into the
message, typos included; Numerics should be OK since copied from Pascal code
;-) ) :
Flexibilize section :
VidMem dw ? ; You'll love this when you find an old
; Hercules mono adapter...
ScreenCols dw ? ; Or maybe you find a VGA and want to
ScreenLines dw ? ; use some weird screen resolution ...
ScreenSize dw ? ; Of course all of these must be set
; up...
biosSeg equ 0040h
biosDisplaymode equ 049h
biosDisplayColumns equ 04Ah
biosDisplayRows equ 084h ; Number of rows -1 (on EGA+)
biosDisplaySize equ 04Ch ; Total number of bytes per
; screen
vidBaseColor equ 0B800h
vidBaseMono equ 0B000h
InitializeScreen proc near
push es
push biosSeg ; Point es to the BIOS
; parameters
pop es
mov ax, vidBaseColor
cmp byte ptr es:[biosDisplayMode], 07h
jne @@1
mov ax, vidBaseMono
@@1:
mov [VidBase], ax
xor ax, ax
mov al, es:[biosDisplayColumns]
mov [ScreenCols], ax
mov al, es:[biosDisplayLines]
inc ax
mov [ScreenRows], ax
pop es
ret
endp
For reading a char from the buffer, I would use _one_ centralized routine,
that waits depending on (eg) the carry flag, and returns with the carry flag
set, if a char is returned, no carry->no char available
I would rip out the crude jump table in the routines Control and Escape
and replace them with the following table/code :
ControlTable label word
dw offset notImplemented ; NULL
dw offset notImplemented ; Start of heading, ^A
.
.
.
dw offset Escape ; Escape ^[
Control proc near
; AL = control char just read, AL < 32 !
cbw ; AX <- AL
mov bx, ax ; BX = AL
add bx, ax ; BX = 2*AL
call ControlTable[bx]
; You could even jmp ControlTable[bx] ...
ret
endp
The carriage return routine is a mess. Here is my try at a better one that
works with every screen resolution :
CarriageReturn proc near
; Positions DI to the beginning of the next line, scrolling not up if ;
necessary.
mov bx, ScreenCols
add bx, bx ; Number of bytes between every
; first column
mov cx, ScreenSize ; CX = first column of last line
sub cx, bx
xor ax, ax ; Try with (0,0)
@NextLine:
cmp ax, di ; current line below cursor
; position ?
ja @Found
add ax, bx ; Position one line down
jmp @NextLine ; and try again
@Found:
mov di, ax ; accept new cursor position
cmp di, cx ; And fix position if beyond
; last line on screen
jbe @Done
mov di, cx ; fix cursor position
@Done:
ret
endp
Escape itself is a horror too. Here I would also replace it directly with
offsets of the procedures to call ...
I hope I've given you enough ideas to restructure the whole thing, and maybe
while rewriting, the bugs disappear ;-)
-max
---
---------------
* Origin: Spam!Ware BBS +49-69-97202062 (2:244/1106.17)
|