main       proc    near
           jmp     buff
buffer:    db      10h   dup   (0)
buff:      call    init
           call    creat
           call    pswd
           call    getpath
           call    adddisp
           call    close
init       proc    near
           mov     ah, 30h         ;what dos are we under?
           int     21H
           cmp     al,2            ;dos 2.0 or over?
           jae     a1              ;yes, skip
           mov     ah, 09h         ;no, bitch
           mov     dx, offset baddos
           int     21H
           int     20h             ;and exit
a1:        mov     ah,09h          ;print claims
           mov     dx,msg001
           int     21h
           ret
msg001:    db      'This Program is copyrighted  1992.  Ver. 2.00',0Dh,0Ah
           db      'by ROBERT WALLINGFORD, P.E., 2338 N. McVicker Ave., Chicago, IL  60639-2216.',0Dh,0Ah
           db      'Distributed as a part of the Shareware  BOOK  collection of programs.',0Dh,0Ah,0Dh,0Ah
           db      'This Program assembles a set of sequentially numbered,  DISP.Nxx  files',0Dh,0Ah
           db      'and assign the timing and attribute bytes.',0Dh,0Ah,'$'
baddos:    db      'This program requires DOS 2.0!$'
           endp
creat      proc    near
           mov     ah,5bh     ;create file
           mov     cx,0h
           mov     dx,offset bigd    ;name of file
           int     21h
           jc      error1
           mov     w[0104h],ax ;store handle
           mov     ah,09h          ;print msg
           mov     dx,msg4
           int     21h
           jmp     end1
error1:    mov     ah,09h          ;print msg
           mov     dx,msg1
           int     21h
           int     20h
end1:      ret
           endp
msg1:      db      'File already exists.',0Dh,0Ah
           db      'To remake DISPLAY.FIL, you must either delete or rename the old file,',0Dh,0Ah
           db      'or move it to another directory or subdirectory, then delete this copy.',0Dh,0Ah,'$'
msg4:      db      'DISPLAY.FIL  has been created. ',0Dh,0Ah,'$'
bigd:      db      'DISPLAY.FIL $'
pswd       proc    near            ;add password
           mov     ah,40h          ;write file
           mov     bx,w[0104h]     ;get handle
           mov     cx,0005h        ;number of bytes to write
           mov     dx,offset mp1
           int     21h
           mov     ah,00h
           mov     b[010fh],ah
           mov     ah,09h          ;print msg
           mov     dx,msg8
           int     21h
           ret
           endp
mp1:       db      01h,44h,49h,53h,50h
msg8:      db      'Password has been added. ',0Dh,0Ah,'$'
getpath    proc    near
           mov     ax,offset pth
           mov     w[0108h],ax
           mov     si,ax
           mov     ax,1900h        ;get DOS drive no.
           int     21h
           add     al,41h          ;make it a letter
           mov     b[si],al        ;store it
           inc     si
           mov     b[si],3ah       ;add a ":"
           inc     si
           mov     b[si],5ch       ;add a "\"
           inc     si              ;location for path
           mov     dl,00h
           mov     ah,47h          ;get full path
           int     21h
           jc      errgp1
           cmp     b[si],00h
           je      ls2             ;jump if root directory
ls1:       inc     si
           cmp     b[si],00h
           jne     ls1             ;loop till end of path
           mov     b[si],5ch       ;add a "\"
           inc     si
ls2:       mov     w[0106h],si     ;store end of path address
           ret
errgp1:    int     20h
pth:       db      50h  dup  (?)
           endp
addit      proc    near
           mov     ax,3da0h        ;open file to read
           mov     dx,w[0108h]     ;path and filename
           int     21h
           jc      errad1          ;file missing
           inc     b[010fh]
           push    ax
           call    sect
           mov     ax,4000h
           mov     bx,w[0104h]
           mov     cx,0001h
           mov     dx,010ch
           int     21h
           call    attb
           mov     ax,4000h
           mov     bx,w[0104h]
           mov     cx,0001h
           mov     dx,0110h
           int     21h
           mov     ax,3f00h        ;read file to buffer
           pop     bx
           mov     cx,7dh          ;how many to read
           mov     dx,3000         ;buffer
           int     21h
           mov     ax,3e00h        ;close file
           int     21h
           mov     ax,4000h        ;write file from buffer
           mov     bx,w[0104h]     ;get handle
           mov     cx,7dh          ;how mamy to write
           mov     dx,3000         ;buffer
           int     21h
           ret
errad1:    call    close
           ret
           endp
adddisp    proc    near
           mov     si,w[0106h]
           mov     b[si],44h       ;add DISP.N--
           inc     si
           mov     b[si],49h
           inc     si
           mov     b[si],53h
           inc     si
           mov     b[si],50h
           mov     w[0106h],si     ;store address
           mov     b[si + 05h],00h
           mov     b[si + 01h],2eh
           mov     b[si + 02h],4eh
           mov     b[010eh],00h    ;initialize page
           mov     b[010dh],00h
ploop:     inc     b[010eh]        ;new page
           mov     al,b[010eh]
initlp:    mov     bl,b[010dh]
           mov     al,b[010eh]
pnumb:     cmp     al,0ah
           jb      pnumb1
           inc     bl
           sub     al,0ah
           mov     b[010eh],al
           mov     b[010dh],bl
           jmp     pnumb
pnumb1:    add     al,30h
           add     bl,30h
           mov     b[si + 03h],bl
           mov     b[si + 04h],al
           call    addit
           mov     ah,09h
           mov     dx,msgch2
           int     21h
           mov     ah,02h
           mov     dl,b[si + 03h]
           int     21h
           mov     ah,02h
           mov     dl,b[si + 04h]
           int     21h
           mov     ah,09h
           mov     dx,msgch3
           int     21h
           jmp     ploop
           ret
           endp
msgch2:    db      'DISP.N$'
msgch3:    db      '  has been added to DISPLAY.FIL  with its timing byte. ',0Dh,0Ah,'$'
sect       proc    near
           mov     ah,09h
           mov     dx,msgch0
           int     21h
           mov     ah,02h
           mov     dl,b[si + 03h]
           int     21h
           mov     ah,02h
           mov     dl,b[si + 04h]
           int     21h
           mov     ah,09h
           mov     dx,msgch1
           int     21h
           mov     cl,00h          ;initialize
           mov     b[010ah],cl     ;initialize
           mov     b[010bh],cl     ;initialize
           mov     cx,0002h        ;initialize
           mov     bp,010ah        ;initialize
mor:       mov     ah,00h          ;wait for a character
           int     16h
           cmp     ah,00h          ;is it special?
           jz      mor
           cmp     ax,1c0dh        ;is it ENTER?
           je      stopp
           cmp     al,39h          ;bigger than 9?
           ja      mor
           cmp     al,30h          ;smaller than 0?
           jb      mor
           push    cx
           push    ax
           mov     ah,09h
           mov     bh,00h
           mov     bl,0fh
           mov     cx,01h
           int     10h
           mov     ah,03h
           int     10h
           add     dl,01h
           mov     ah,02h
           int     10h
           pop     ax
           pop     cx
           sub     al,30h
           mov     b[bp],al
           inc     bp
           dec     cx
           cmp     cx,0000h
           jne     mor
           jmp     stop2
stopp:     cmp     cx,0002h
           jne     stop1
           mov     ah,09h
           mov     dx,stmsg1
           int     21h
           jmp     mor
stmsg1:    db      0dh,0ah,'NO NUMBER, try again.',0dh,0ah,'$'
stmsg2:    db      0dh,0ah,'$'
stop1:     cmp     cx,0001h
           jne     stop2
           mov     ah,b[010ah]
           mov     b[010bh],ah
           mov     ah,00h
           mov     b[010ah],ah
stop2:     mov     ah,00h
           mov     al,b[010ah]
           mov     dh,0ah
           mul     dh
           mov     dh,00h
           mov     dl,b[010bh]
           add     ax,dx
           mov     b[010ch],al
           mov     ah,09h
           mov     dx,stmsg2
           int     21h
           ret
msgch0:    db      'How many seconds do you want  DISP.N$'
msgch1:     db      ' to be displayed?',0Dh,0Ah
           db      '(Type a number from 1 to 99, then press ENTER.)',0Dh,0Ah,'$'
           endp
attb       proc    near
           mov     ah,09h
           mov     dx,msgat0
           int     21h
           mov     ah,02h
           mov     dl,b[si + 03h]
           int     21h
           mov     ah,02h
           mov     dl,b[si + 04h]
           int     21h
           mov     ah,09h
           mov     dx,msgat1
           int     21h
mor0:      mov     ah,00h          ;wait for a character
           int     16h
           cmp     ah,00h          ;is it special?
           jz      mor0
           cmp     ax,1c0dh        ;is it ENTER?
           jz      at0
           cmp     al,31h          ;is it 1 ?
           jz      at1
           cmp     al,32h          ;is it 2 ?
           jz      at2
           cmp     al,33h          ;is it 3 ?
           jz      at3
           cmp     al,34h          ;is it 4 ?
           jz      at4
           jmp     mor0
at0:       nop
at1:       mov     al,07h          ;white on black
           jmp     att
at2:       mov     al,70h          ;black on white
           jmp     att
at3:       mov     al,0fh          ;high white on black
           jmp     att
at4:       mov     al,78h          ;black on high white
att:       push    ax
           mov     ah,09h
           mov     dx,msgat2
           int     21h
mor1:      mov     ah,00h          ;wait for a character
           int     16h
           cmp     ah,00h          ;is it special?
           jz      mor1
           cmp     ax,1c0dh        ;is it ENTER?
           jz      att0
           cmp     al,4eh          ;is it N ?
           jz      att1
           cmp     al,6eh          ;is it n ?
           jz      att1
           cmp     al,59h          ;is it Y ?
           jz      att2
           cmp     al,79h          ;is it y ?
           jz      att2
           jmp     mor1
att0:      nop
att1:      mov     bl,00h
           jmp     attt
att2:      mov     bl,80h
attt:      pop     ax
           add     al,bl
           mov     b[0110h],al
           ret
msgat0:    db      'What attribute do you want  DISP.N$'
msgat1:    db      ' to have in the display?',0Dh,0Ah
           db      'Press 1 for normal white on black.',0dh,0ah
           db      'Press 2 for black on normal white.',0dh,0ah
           db      'Press 3 for bright white on black.',0dh,0ah
           db      'Press 4 for black on bright white.',0dh,0ah,'$'
msgat2:    db      0dh,0ah,'Do you want it to blink ?',0dh,0ah
           db      '(Press  Y  or  N  )',0dh,0ah,'$'
           endp
close      proc    near
           mov     ax,4200h
           mov     bx,w[0104h]
           mov     cx,0000h
           mov     dx,0000h
           int     21h
           mov     ah,40h
           mov     bx,w[0104h]
           mov     cx,0001h
           mov     dx,010fh
           int     21h
           mov     ah,3eh          ;close file
           mov     bx,word ptr [0104h] ;get handle
           int     21h
           jc      errc
           mov     ah,09h          ;print msg
           mov     dx,msgc
           int     21h
errc:      int     20h             ;end program anyway
           ret
msgc:      db      'DISPLAY.FIL  has been successfully closed. Thank You. $'
           endp
           end
