p386
ideal
jumps

extrn current:far,ctr1:far,ctr2:far

segment screen para

group emulator screen

assume cs:emulator,ds:nothing,es:nothing,fs:nothing,gs:nothing,ss:nothing

public Screen$Update, Screen$SetModeX, Screen$WaitInt

extrn fastemu@ds:word, ports@border:byte, need_int:byte
extrn ports@exact:byte, ports@emu_tape:byte


;
; colour tables
colours: db 256 dup (0)

palette:
  db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0

dac:
  db 0,0,0
  db 0,0,45
  db 45,0,0
  db 45,0,45
  db 0,45,0
  db 0,45,45
  db 45,45,0
  db 45,45,45
  db 10,20,30
  db 0,0,63
  db 63,0,0
  db 63,0,63
  db 0,63,0
  db 0,63,63
  db 63,63,0
  db 63,63,63

; equates for CRTC
SC_INDEX equ 03c4h         ;Sequence Controller Index
CRTC_INDEX equ 03d4h       ;CRT Controller Index
MISC_OUTPUT equ 03c2h      ;Miscellaneous Output register
SCREEN_SEG equ 0a000h      ;segment of display memory in mode X
INPUT_STATUS_1 equ 03dah   ;Input Status 1 register
START_ADDRESS_HIGH equ 0ch ;bitmap start address high byte
START_ADDRESS_LOW equ 0dh  ;bitmap start address low byte
GC_INDEX equ 03ceh         ;Graphics Controller Index register port
BIT_MASK equ 08h           ;index in GC of Bit Mask register

; Index/data pairs for CRT Controller registers that differ between
; mode 0Dh and 320*240*16
CRTParms:
  dw 00d06h  ;vertical total
  dw 03e07h  ;overflow (bit 8 of vertical counts)
  dw 04109h  ;cell height (2 to double-scan)
  dw 0ea10h  ;v sync start
  dw 0ac11h  ;v sync end and protect cr0-cr7
  dw 0df12h  ;vertical displayed
  dw 0e715h  ;v blank start
  dw 00616h  ;v blank end

;
; set screen to mode X,
;  set screen start address,
;  initialise video-ram tables
;  initialise palette
;
proc Screen$SetModeX far

  push ds
  push es
  push fs
  push gs
  pusha
  pushf

;force a screen update

  mov ax,seg current
  mov es,ax
  mov ds,[fastemu@ds]
  mov di,5800h
  mov cx,768
ForceUpdate:
  mov al,[ds:di]
  inc al
  mov [es:di],al
  inc di
  loop ForceUpdate

  mov ax,0dh            ;set mode 0Dh
  int 10h

;set the palette

  mov dx,offset palette
  mov ax,cs
  mov es,ax
  mov ax,1002h
  int 10h

  mov dx,offset dac
  mov ax,cs
  mov es,ax
  mov bx,0
  mov cx,16
  mov ax,1012h
  int 10h

  mov dx,SC_INDEX
  mov ax,0604h
  out dx,ax             ;disable chain4 mode
  mov ax,0100h
  out dx,ax             ;synchronous reset while setting Misc Output
                        ; for safety, even though clock unchanged
  mov dx,MISC_OUTPUT
  mov al,0e3h
  out dx,al             ;select 25 MHz dot clock & 60 Hz scanning rate

  mov dx,SC_INDEX
  mov ax,0300h
  out dx,ax             ;undo reset (restart sequencer)

  mov dx,CRTC_INDEX     ;reprogram the CRT Controller
  mov al,11h            ;VSync End reg contains register write
  out dx,al             ; protect bit
  inc dx                ;CRT Controller Data register
  in al,dx              ;get current VSync End register setting
  and al,7fh            ;remove write protect on various
  out dx,al             ; CRTC registers
  dec dx                ;CRT Controller Index
  cld
  mov si,offset CRTParms ;point to CRT parameter table
  mov cx,8              ;# of table entries
  mov ax,cs             ;CRTC parms must be in ds
  mov ds,ax
SetCRTParmsLoop:
  lodsw                 ;get the next CRT Index/Data pair
  out dx,ax             ;set the next CRT Index/Data pair
  loop SetCRTParmsLoop

  mov dx,INPUT_STATUS_1
WaitDE:
  in al,dx
  test al,01h
  jnz WaitDE            ;display enable is active low (0 = active)
; Set the start offset in display memory of the page to display (0)
  mov dx,CRTC_INDEX
  mov ax,START_ADDRESS_LOW
  out dx,ax             ;start address low
  mov ax,START_ADDRESS_HIGH
  out dx,ax             ;start address high

;call table setup routine, reset de and es

  call setuptables
  mov ax,cs
  mov ds,ax
  mov ax,0a000h
  mov es,ax

;now initialise in-EGA-memory tables
;near-bug: if the loop is from the bottom up 8 will be used for
; black, since non-collapsed values are used.

  mov si,255            ;bgfg byte
mct1:
  mov bh,[si+offset colours]
  test bh,bh            ;this page used?
  jz mct6
  xor bl,bl             ;yes, bx points into video table
mct2:
  mov ax,0102h          ;do first bit-plane...
  mov dx,SC_INDEX
  out dx,ax
  xor dx,dx             ;include neither bg nor fg, but..
  test si,1
  jz mct2a
  dec dl                ;include fg after all
mct2a:
  test si,16
  jz mct2b
  dec dh                ;        bg
mct2b:
  mov al,[es:bx]        ;set one plane in one byte in one page
  mov al,bl
  mov ah,al
  not ah
  and ax,dx
  or al,ah
  mov [es:bx],al
  inc bl                ;next byte in page
  jnz mct2b

  mov ax,0202h          ;do second bit-plane
  mov dx,SC_INDEX
  out dx,ax
  xor dx,dx             ;include neither bg nor fg, but..
  test si,2
  jz mct3a
  dec dl                ;include fg after all
mct3a:
  test si,32
  jz mct3b
  dec dh                ;        bg
mct3b:
  mov al,[es:bx]        ;set one plane in one byte in one page
  mov al,bl
  mov ah,al
  not ah
  and ax,dx
  or al,ah
  mov [es:bx],al
  inc bl                ;next byte in page
  jnz mct3b

  mov ax,0402h          ;do third bit-plane
  mov dx,SC_INDEX
  out dx,ax
  xor dx,dx             ;include neither bg nor fg, but..
  test si,4
  jz mct4a
  dec dl                ;include fg after all
mct4a:
  test si,64
  jz mct4b
  dec dh                ;        bg
mct4b:
  mov al,[es:bx]        ;set one plane in one byte in one page
  mov al,bl
  mov ah,al
  not ah
  and ax,dx
  or al,ah
  mov [es:bx],al
  inc bl                ;next byte in page
  jnz mct4b

  mov ax,0802h          ;do fourth bit-plane, bit 3 and plane 3
  mov dx,SC_INDEX
  out dx,ax
  xor dx,dx             ;include neither bg nor fg, but..
  test si,8
  jz mct5a
  dec dl                ;include fg after all
mct5a:
  test si,128
  jz mct5b
  dec dh                ;        bg
mct5b:
  mov al,[es:bx]        ;set one plane in one byte in one page
  mov al,bl
  mov ah,al
  not ah
  and ax,dx
  or al,ah
  mov [es:bx],al
  inc bl                ;next byte in page
  jnz mct5b

mct6:
  test si,si            ;last page done?
  jz mct7
  dec si                ;no, go back
  jmp mct1
mct7:

;draw hyperellipse

  mov ax,0802h          ;select only one plane
  mov dx,SC_INDEX
  out dx,ax

  mov si,offset hyperellipse
  mov di,0              ;top pixel line
  mov bx,9560           ;bottom
  mov cx,120            ;120 lines
hel_1:
  push di
  push bx
  push cx
  movzx dx,[si]         ;find low-x and width of ellipse
  mov cx,160
  sub cx,dx
  add cx,cx

  mov al,dl
  shr dx,3
  add bx,dx
  add di,dx
  mov dl,7
  and dl,al
  mov dh,128
  xor ax,ax

hel_2:
  test dl,dl            ;more pixels until start of ellipse?
  jz hel_3
  dec dl
  ror dh,1
  jmp hel_2
hel_3:
  test cx,cx            ;more pixels left of ellipse?
  jz hel_6
  test dh,128           ;yes, now at leftmost pixel in byte?
  jnz hel_4
  or ah,dh              ;no, or pixel in
  dec cx
  ror dh,1              ;next pixel
  jnc hel_3
  mov al,[es:bx]        ;at boundary, draw, inc and clear acc
  mov [es:bx],ah
  inc bx
  mov al,[es:di]
  mov [es:di],ah
  inc di
  xor ah,ah
hel_4:
  cmp cx,8              ;at least 8 pixels left?
  jb hel_5
  mov al,[es:bx]        ;yes, write byte
  mov [byte ptr es:bx],255
  inc bx
  mov al,[es:di]
  mov [byte ptr es:di],255
  inc di
  sub cx,8
  jmp hel_4
hel_5:
  test cx,cx            ;last byte - more pixels?
  jz hel_6
  dec cx
  or ah,dh              ;yes, or them in
  ror dh,1
  jmp hel_5
hel_6:
  test ah,ah
  jz hel_7
  mov al,[es:bx]        ;just draw
  mov [es:bx],ah
  mov al,[es:di]
  mov [es:di],ah
hel_7:
  pop cx
  pop bx
  pop di
  sub bx,40             ;step down and up
  add di,40
  inc si
  loop hel_1            ;and repeat

  mov dx,SC_INDEX       ;set mask to default
  mov ax,0f02h
  out dx,ax

  call Screen$Percent

  popf
  popa
  pop gs
  pop fs
  pop es
  pop ds
  ret

endp Screen$SetModeX

hyperellipse:
  db 160, 92, 79, 71, 65, 59, 55, 51, 48, 45
  db  42, 40, 37, 35, 33, 32, 30, 28, 27, 26
  db  24, 23, 22, 21, 20, 19, 18, 17, 16, 15
  db  15, 14, 13, 12, 12, 11, 11, 10, 10,  9
  db   9,  8,  8,  7,  7,  6,  6,  6,  5,  5
  db   5,  5,  4,  4,  4,  4,  3,  3,  3,  3
  db   3,  2,  2,  2,  2,  2,  2,  2,  1,  1
  db   1,  1,  1,  1,  1,  1,  1,  1,  1,  1
  db   0,  0,  0,  0,  0,  0,  0,  0,  0,  0
  db   0,  0,  0,  0,  0,  0,  0,  0,  0,  0
  db   0,  0,  0,  0,  0,  0,  0,  0,  0,  0
  db   0,  0,  0,  0,  0,  0,  0,  0,  0,  0


;
; set up colour tables
proc setuptables near

  mov ax,cs
  mov ds,ax
  mov es,ax

;first create bg-fg -> hi-byte

  mov cl,255            ;initial hi-byte
  xor bx,bx             ;initial bg and fg
@@_1:
  mov al,bl
  xor al,bh
  and al,8              ;fg and bg in same range?
  jz @@_3
@@_2:                   ;no
  inc bl
  and bl,15
  jnz @@_1
  inc bh
  and bh,15
  jnz @@_1
  jmp @@_6              ;last done
@@_3:
  mov ax,bx             ;now force bright black to black
  cmp al,8
  jne @@_4
  xor al,al
@@_4:
  cmp ah,8
  jne @@_5
  xor ah,ah
@@_5:
  shl ah,4              ;allocate a page
  or al,ah
  movzx si,al
  mov [si+offset colours],cl
  dec cl
  jmp @@_2


;then map spectrum attr to bgfg, and further to hi-byte

@@_6:
  mov ax,seg ctr1
  mov ds,ax
  xor cx,cx             ;cl is spectrum attr
@@_7:
  mov al,cl             ;convert to bgfg byte
  mov ah,al
  and ax,7847h
  shl ah,1
  cmp ah,80h
  jne @@_7a
  xor ah,ah
@@_7a:
  cmp al,40h
  jb @@_8
  sub al,38h
  cmp al,8
  jne @@_8
  xor al,al
@@_8:
  or al,ah
  movzx bx,al           ;convert to hi-byte
  mov ah,[cs:bx+offset colours]
  mov bl,cl             ;store hi-byte in ctr1
  mov [ds:bx+offset ctr1],ah
  test cl,128           ;flash?
  jz @@_9
  rol al,4              ;yes, xchg bg & fg, refetch hi-byte
  mov bl,al
  mov ah,[cs:bx+offset colours]
  mov bl,cl
@@_9:
  mov [ds:bx+offset ctr2],ah
  inc cl                ;do next spectrum attr
  jnz @@_7

  ret

endp setuptables

;
; draw percent digits
proc Screen$Percent near
  test [ports@exact],255
  jz @@_exit

  mov ax,0a000h
  mov ds,ax
  mov di,2957
  mov si,offset @@_bitmaps
  mov ch,7
  mov dx,GC_INDEX
  mov al,BIT_MASK
@@_100_1:
  push di
  mov cl,3
@@_100_2:
  mov ah,[cs:si]
  inc si
  out dx,ax
  and [byte ptr ds:di],0
  mov ah,[cs:si]
  inc si
  out dx,ax
  or [byte ptr ds:di],255
  inc di
  dec cl
  jnz @@_100_2
  pop di
  add di,40
  dec ch
  jnz @@_100_1

  mov di,8397
  mov ch,7
@@_100_3:
  push di
  mov cl,2
@@_100_4:
  mov ah,[cs:si]
  inc si
  out dx,ax
  and [byte ptr ds:di],0
  mov ah,[cs:si]
  inc si
  out dx,ax
  or [byte ptr ds:di],255
  inc di
  dec cl
  jnz @@_100_4
  pop di
  add di,40
  dec ch
  jnz @@_100_3


@@_exit:
  ret


@@_bitmaps:
  db 026h,000h, 033h,000h, 020h,000h
  db 07fh,026h, 07fh,033h, 0f0h,020h
  db 0ffh,069h, 0ffh,04bh, 0e0h,040h
  db 07fh,029h, 0ffh,048h, 0e0h,080h
  db 07fh,029h, 0ffh,049h, 0f0h,060h
  db 0ffh,076h, 07fh,032h, 0f0h,060h
  db 076h,000h, 032h,000h, 060h,000h

  db 033h,000h, 020h,000h
  db 07fh,033h, 0f0h,020h
  db 0ffh,04bh, 0f0h,040h
  db 0ffh,048h, 0e0h,080h
  db 0ffh,049h, 0e0h,060h
  db 07fh,032h, 0f0h,060h
  db 032h,000h, 060h,000h

endp Screen$Percent


;
; write or delete 'tape' depending on ports@emu_tape
;  corrupts ax,bx,cx,dx,si,di,ds,f
;  preserves es,fs,gs,bp

proc write_tape near

  mov al,[ports@emu_tape]
  cmp al,[@@_tape]
  je @@_exit
  mov [@@_tape],al

  test al,al
  jz @@_3

  mov ax,0a000h
  mov ds,ax
  mov di,9320
  mov si,offset @@_bitmap
  mov ch,7
  mov dx,GC_INDEX
  mov al,BIT_MASK
@@_1:
  push di
  mov cl,3
@@_2:
  mov ah,[cs:si]
  inc si
  out dx,ax
  and [byte ptr ds:di],0
  mov ah,[cs:si]
  inc si
  out dx,ax
  or [byte ptr ds:di],255
  inc di
  dec cl
  jnz @@_2
  pop di
  add di,40
  dec ch
  jnz @@_1

  mov ah,255
  out dx,al
  jmp @@_exit

@@_3:
  mov di,9320
  mov cx,3
  mov bl,7
  mov ax,0a000h
  mov ds,ax
@@_4:
  and [byte ptr ds:di],0
  inc di
  loop @@_4
  add di,33
  dec bl
  jnz @@_4

@@_exit:
  ret

@@_tape db 0

@@_bitmap:
  db 07ch,000h, 08eh,000h, 078h,000h
  db 0ffh,07ch, 0dfh,08eh, 0fch,078h
  db 07fh,011h, 0ffh,049h, 0f8h,040h
  db 03fh,012h, 0ffh,02eh, 0f8h,070h
  db 03fh,013h, 0feh,0e8h, 0f8h,040h
  db 03fh,012h, 0fch,028h, 0fch,078h
  db 03fh,000h, 078h,000h, 078h,000h

endp write_tape





;
; scan line at di, update as necessary
;  assumes fs=0a000h,ds=specdata,es=specseg,bx points to colour trans tbl
update_line:
  and edi,65535
  mov cx,8              ;8 dwords
  mov esi,edi
  mov ax,4
  repe cmpsd
  je ul3
  sub di,ax
  sub si,ax
  inc cx
  shl cx,2
ul1:
  repe cmpsb            ;scan for changes
  je ul3                ;skip if all equal
  push si               ;push registers
  push di
  push bx
  dec di                ;back to the byte we're processing
  dec si
  mov bl,[es:di]        ;copy to 'current'
  mov [ds:di],bl
  mov ah,[ds:bx]        ;ax now points into the video array
  and si,31             ;find video addr in si
  add si,dx
  mov bx,di             ;find top pixel row addr in bx
  and bh,3
  shl bh,3
  add bh,64
  mov di,bx             ;put in di
  mov bh,ah             ;bx is video-array-ptr
  lcv=0
  lcs=0
  rept 8
    mov bl,[es:di+lcs]
    mov ah,[fs:bx]
    mov [ds:di+lcs],bl
    mov [fs:si+lcv],ah
    lcv=lcv+40
    lcs=lcs+256
  endm
  pop bx                ;restore registers
  pop di
  pop si
  test cx,cx
  jnz ul1               ;and repeat if necessary
ul3:
  mov ax,di             ;move si and di from attr to top pixel
  sub ax,32
  and ax,3e0h
  shl ah,3
  add ah,64
  mov di,ax
ul4:
  mov si,di
  mov cx,8
  repe cmpsd            ;first try dwords
  je ul7
  sub di,4
  sub si,4
  inc cx
  shl cx,2
ul5:
  repe cmpsb            ;scan for changes
  je ul7                ;skip if all are equal
  push si               ;push registers
  push di
  push bx
  push cx
  dec di
  dec si
  and si,31             ;find video addr in si
  add si,dx
  mov cx,bx             ;store trans array table ptr - xx00!!!!
  mov bx,di             ;find attr addr
  shr bh,3
  and bh,3
  mov bl,[ds:bx+5800h]  ;and byte
  mov bh,ch             ;translate attr into video-array index
  mov bh,[ds:bx]
ul6:
  mov bl,[es:di]
  mov ah,[fs:bx]
  mov [ds:di],bl
  mov [fs:si],ah
  add di,256
  add si,40
  test di,700h
  jnz ul6
  pop cx
  pop bx
  pop di
  pop si
  test cx,cx
  jnz ul5               ;and repeat if necessary
ul7:
  add dx,40
  add di,256-32
  test di,700h
  jnz ul4
  retn


;
; update the current image
; must preserve all registers
proc Screen$Update near
  push ds
  push es
  push fs
  pusha
  pushf

  mov ax,40h
  mov ds,ax
  mov ax,[ds:6ch]
  cmp ax,[timer]
  jb @@_4
  add ax,6
  mov [timer],ax
  mov ax,[c_ctr]
  cmp ax,offset ctr1
  je @@_1
  mov [c_ctr],offset ctr1
  jmp @@_2
@@_1:
  mov [c_ctr],offset ctr2
@@_2:
  mov di,57feh
  mov cx,180h
  mov dx,8080h
  mov ds,[fastemu@ds]
  mov ax,seg current
  mov es,ax
@@_3:
  inc di
  inc di
  test dx,[ds:di]
  jz @@_3b
  mov ax,[ds:di]
  add ax,257
  mov [es:di],ax
@@_3b:
  loop @@_3

@@_4:

  mov dx,GC_INDEX       ;set the bit mask to select all bits
  mov ax,00000h+BIT_MASK ; from the latches and none from
  out dx,ax             ; the CPU, so that we can write the
                        ; latch contents directly to memory

  mov dx,SC_INDEX       ;set the map mask to 0fh so all bits
  mov ax,0f02h          ; get written
  out dx,ax

  mov ax,seg current
  mov ds,ax
  mov es,[fastemu@ds]
  mov ax,0a000h
  mov fs,ax

  mov bx,[c_ctr]
  mov cx,24
  mov di,5800h
  mov dx,964
  cld
@@_5:
  push cx
  push di
  call update_line
  pop di
  pop cx
  add di,32
  loop @@_5

  mov dx,GC_INDEX       ;set the bit mask to select all bits
  mov ax,0ff00h+BIT_MASK ; from the CPU and none from
  out dx,ax             ; the latches

  mov ax,cs
  mov ds,ax
  mov dx,03c8h
  mov al,[ports@border]
  and ax,7
  cmp al,[c_border]
  je @@_6
  mov si,ax
  add si,ax
  add si,ax
  add si,offset dac
  mov al,8
  out dx,al
  inc dl
  lodsb
  jmp short $+2
  out dx,al
  lodsb
  jmp short $+2
  out dx,al
  lodsb
  jmp short $+2
  out dx,al

@@_6:
  popf
  popa
  pop fs
  pop es
  pop ds
  ret

endp Screen$Update


c_line dw 5800h
c_vline dw 964
c_border db 99
needswap db 0
c_ctr dw offset ctr1
timer dw 0

measure_point dw 0


;
; update the current image, return as soon as need_int#0
; must preserve all registers
proc Screen$WaitInt near
  push ds
  push es
  push fs
  pusha
  pushf

  mov dx,191
  sub dx,di
  cmp dx,191
  ja @@_measure_1
  mov ax,40
  mul dx
  add ax,876
  mov bx,[measure_point]
  cmp ax,bx
  je @@_measure_1
  mov cx,ax

  mov ax,0a000h
  mov ds,ax
  test bx,bx
  jz @@_measure_2
  mov ax,0802h          ;select only one plane
  mov dx,SC_INDEX
  out dx,ax
  mov ax,03c00h+BIT_MASK ;select four bits
  mov dx,GC_INDEX
  out dx,ax
  or [byte ptr ds:bx-40],255
  or [byte ptr ds:bx+40],255
  mov ax,07e00h+BIT_MASK
  mov dx,GC_INDEX
  out dx,ax
  or [byte ptr ds:bx],255
  mov ax,0702h          ;the other three planes
  mov dx,SC_INDEX
  out dx,ax
  and [byte ptr ds:bx],0
@@_measure_2:
  mov bx,cx
  mov ax,0802h
  mov dx,SC_INDEX
  out dx,ax
  mov ax,03c00h+BIT_MASK
  mov dx,GC_INDEX
  out dx,ax
  and [byte ptr ds:bx-40],0
  and [byte ptr ds:bx+40],0
  mov ax,04200h+BIT_MASK
  mov dx,GC_INDEX
  out dx,ax
  and [byte ptr ds:bx],0
  mov ax,0f02h
  mov dx,SC_INDEX
  out dx,ax
  mov ax,03c00h+BIT_MASK
  mov dx,GC_INDEX
  out dx,ax
  or [byte ptr ds:bx],0ffh

  mov [measure_point],bx

@@_measure_1:
  mov dx,GC_INDEX       ;restore registers
  mov ax,0ff00h+BIT_MASK
  out dx,ax
  mov ax,0f02h
  mov dx,SC_INDEX
  out dx,ax
@@_measure_3:

  call write_tape

  mov ax,40h
  mov ds,ax
  mov ax,[ds:6ch]
  cmp ax,[timer]
  jb @@_4
  call Screen$Update
@@_4:

  mov dx,GC_INDEX       ;set the bit mask to select all bits
  mov ax,00000h+BIT_MASK ; from the latches and none from
  out dx,ax             ; the CPU, so that we can write the
                        ; latch contents directly to memory

  mov dx,SC_INDEX       ;set the map mask to 0fh so all bits
  mov ax,0f02h          ; get written
  out dx,ax

  mov ax,seg current
  mov ds,ax
  mov es,[fastemu@ds]
  mov ax,0a000h
  mov fs,ax

  mov bx,[c_ctr]
  mov di,[c_line]
  mov dx,[c_vline]
  cld
@@_5:
  push di
  call update_line
  pop di
  add di,32
  cmp di,5b00h
  jb @@_6
  mov di,5800h
  mov dx,964
@@_6:
  test [need_int],255
  jz @@_5
  mov [c_line],di
  mov [c_vline],dx

  mov dx,GC_INDEX       ;set the bit mask to select all bits
  mov ax,0ff00h+BIT_MASK ; from the CPU and none from
  out dx,ax             ; the latches

  mov ax,cs
  mov ds,ax
  mov dx,03c8h
  mov al,[ports@border]
  and ax,7
  cmp al,[c_border]
  je @@_7
  mov si,ax
  add si,ax
  add si,ax
  add si,offset dac
  mov al,8
  out dx,al
  inc dl
  lodsb
  jmp short $+2
  out dx,al
  lodsb
  jmp short $+2
  out dx,al
  lodsb
  jmp short $+2
  out dx,al

@@_7:
  popf
  popa
  pop fs
  pop es
  pop ds
  ret

endp Screen$WaitInt


ends screen

end
