home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol135 / mkey.wpf < prev    next >
Encoding:
Text File  |  1984-04-29  |  4.2 KB  |  269 lines

  1. ;MKEY - Give "mkey (filename)"
  2.  
  3. base equ 0
  4. dmad1 equ base+80h
  5. fcb equ base+5ch
  6. fcr equ 32
  7.  
  8. stackp:: dw 0 ;keeps stack ptr
  9. pasbuf:: ds 8
  10.  
  11. start:: ld (stackp),sp
  12.  ld sp,stac0
  13.  call open
  14.  inc a
  15.  jp z,nofdis
  16.  xor a
  17.  ld (fcb+fcr),a
  18.  ld de,buf0
  19.  call rdsec
  20.  jp nz,nregds ;if eof
  21.  ld de,buf0+80h
  22.  call rdsec
  23.  jp nz,nregds ;if eof
  24.  call cpasgt ;gets coded keyword from old and new dmush
  25.  call dmshmk ;reconstitutes dmush
  26.  call comp ;ret nz if not correct
  27.  jp nz,nregds
  28.  call pasinv ;decode keyword from old and new nmush
  29.  call chcvld ;ret c if invalid keyword
  30.  jp c,nregds
  31.  call pasdis ;display valid keyword
  32. reb:: ld sp,(stackp)
  33.  jp base
  34.  
  35.  ;sr open read fcb
  36. open:: ld de,fcb
  37.  ld c,0fh
  38.  call base+5
  39.  ret
  40.  
  41.  ;sr read (fcb) to (de), ret nz if eof
  42. rdsec:: ld c,1ah
  43.  call base+5 ;set dma
  44.  ld de,fcb
  45.  ld c,14h
  46.  call base+5 ;read sequential
  47.  or a
  48.  ret ;nz if eof
  49.  
  50.  ;sr get coded keyword from old and new dmush
  51. cpasgt:: ld c,51 ;arb start offset
  52.  ld b,8 ;ct
  53. clp:: ld hl,buf0+80h ;new dmush
  54.  ld a,c
  55.  add a,l
  56.  ld l,a
  57.  jr nc,clp2
  58.  inc h ;start byte addr
  59. clp2:: ld ix,buf0+50h ;new nmush adr
  60.  ld a,b
  61.  and 7
  62.  ld e,a
  63.  ld d,0
  64.  add ix,de
  65.  ld a,(hl)
  66.  ld e,a
  67.  and 0aah
  68.  rra
  69.  xor e
  70.  dec h
  71.  sub (hl)
  72.  inc h
  73.  ld (ix),a
  74.  ld a,c
  75.  add a,23 ;col incr
  76.  and 7fh
  77.  ld c,a
  78.  djnz clp
  79.  ret
  80.  
  81.  ;sr reconstitute mush
  82. dmshmk:: ld c,51 ;arb start pt
  83.  ld b,80h ;length
  84. mlp:: ld hl,pag1+80h
  85.  ld a,c
  86.  add a,l
  87.  ld l,a
  88.  jr nc,mlp2
  89.  inc h
  90. mlp2:: ld ix,buf0+50h ;poss keyword
  91.  ld a,b ;use b value for keyword ptr
  92.  and 7
  93.  ld e,a
  94.  ld d,0
  95.  add ix,de
  96.  ld a,(ix)
  97.  add a,(hl)
  98.  ld e,a
  99.  and 0aah
  100.  rra
  101.  xor e
  102.  ld (hl),a
  103.  ld a,c
  104.  add a,23 ;col incr
  105.  and 7fh
  106.  ld c,a
  107.  djnz mlp
  108.  ret
  109.  
  110.  ;sr compare reconstituted mush
  111. comp:: ld hl,pag1+80h
  112.  ld de,buf0+80h
  113.  ld b,80h
  114. comp2:: ld a,(de)
  115.  cp (hl)
  116.  ret nz
  117.  inc hl
  118.  inc de
  119.  djnz comp2
  120.  ret
  121.  
  122.  ;sr decode keyword from old and new nmush
  123. pasinv:: ld ix,pasbuf
  124.  ld de,4 ;arb start offset
  125.  ld b,8 ;ct
  126. invlp:: ld hl,buf0+50h
  127.  ld iy,pag1+50h
  128.  add hl,de
  129.  add iy,de
  130.  ld a,(hl)
  131.  ld c,a
  132.  and 55h
  133.  rla
  134.  xor c
  135.  sub (iy)
  136.  ld (ix),a
  137.  ld a,e
  138.  add a,3 ;col incr
  139.  and 7
  140.  ld e,a
  141.  inc ix
  142.  djnz invlp
  143.  ret
  144.  
  145.  ;sr ret c if invalid keyword char
  146. chcvld:: ld hl,pasbuf
  147.  ld b,8
  148. vldlp:: ld a,(hl)
  149.  cp ' '
  150.  jr z,vldchr
  151.  cp '/'
  152.  ret c
  153.  cp ':'
  154.  jr c,vldchr
  155.  cp '@'
  156.  ret c
  157.  cp '['
  158.  ccf
  159.  ret c
  160. vldchr:: inc hl
  161.  djnz vldlp
  162.  xor a ;clear carry
  163.  ret
  164.  
  165. nofdis:: ld de,nofmsg
  166.  call string
  167.  jp reb
  168. nofmsg:: db 'No file',0dh,0ah,'$'
  169.  
  170. nregds:: ld de,nregms
  171.  call string
  172.  jp reb
  173. nregms:: db 'File irregular or not locked'
  174.  db 0dh,0ah,'$'
  175.  
  176. pasdis:: ld de,pasms1
  177.  call string
  178.  ld hl,pasbuf
  179.  ld b,8
  180. pdlp:: ld a,(hl)
  181.  call disp
  182.  inc hl
  183.  djnz pdlp
  184.  ld de,pasms2
  185.  call string
  186.  ret
  187. pasms1:: db 0dh,0ah,'Keyword - $'
  188. pasms2:: db 0dh,0ah,0dh,0ah,'Don''t '
  189.  db 'forget it again!',0dh,0ah,'$'
  190.  
  191. string:: ld c,9
  192.  call base+5
  193.  ret
  194.  
  195. disp:: push bc
  196.  push de
  197.  push hl
  198.  ld e,a
  199.  ld c,2
  200.  call base+5
  201.  pop hl
  202.  pop de
  203.  pop bc
  204.  ret
  205.  
  206. pag1:: .phase base+100h
  207.  
  208.  db 0dh,0ah,'==<Locked file>== ',0dh,0ah,1ah
  209.   ;as a seq of instns, this gives a jump either to
  210.   ;122h or to 173h
  211.  
  212. fill:: ds base+122h-fill ;foll instn shd be 122h
  213.   ;173h will be set to jr 122h later
  214.  
  215. sendms:: ld hl,base+100h
  216.  ld a,(hl)
  217.  cp 1ah
  218.  jp z,base
  219.  push bc
  220.  push de
  221.  push hl
  222.  ld e,a
  223.  ld c,2
  224.  call base+5
  225.  pop hl
  226.  pop de
  227.  pop bc
  228.  inc hl
  229.  jr sendms+3
  230.  
  231.   ;next byte 13ah
  232.  db 0f5h,79h,10h,0afh,23h,09h
  233.  db 51h,00h,19h,71h,0d9h,6fh,0b8h,0b6h
  234.  db 70h,26h,0a6h,63h,51h,03h,44h,20h
  235.  
  236. nmush:: db 57h,7eh,0c5h,14h,8fh,47h,0c1h,27h ;adr 150h
  237.  db 0feh,0eeh,9fh,0edh,09h,0a9h,33h,76h
  238.  db 0e2h,11h,72h,0d7h,0e3h,5dh,74h,66h
  239.  db 66h,39h,0fh,2dh,15h,34h,0ch,81h
  240.  db 25h,61h,33h,09h,12h,3eh,4eh,37h
  241.  db 96h,0b0h,0ebh,41h,89h,0a0h,24h,78h
  242.  
  243. dmush:: db 48h,0e0h,23h,0afh,2ah,77h,0f6h,86h ;adr 180h
  244.  db 0c3h,3ah,0d8h,7eh,5bh,7fh,0c1h,0eh
  245.  db 57h,0f8h,30h,26h,11h,0fh,2eh,0d8h
  246.  db 08h,6dh,0bah,7fh,8ch,0cch,90h,4ah
  247.  
  248.  db 95h,0a5h,0e4h,9fh,76h,5fh,0e0h,01h
  249.  db 1fh,22h,9ah,77h,3ch,5dh,0a0h,0a7h
  250.  db 75h,0a7h,0cfh,76h,0ach,40h,6fh,0aah
  251.  db 3eh,79h,56h,5eh,69h,77h,3ah,64h
  252.  
  253.  db 3eh,56h,53h,4dh,01h,29h,47h,0b2h
  254.  db 61h,85h,6ch,4ah,0a9h,0a2h,0d8h,0f3h
  255.  db 9fh,4fh,0bah,32h,0c2h,43h,4dh,31h
  256.  db 8ch,0ach,09h,58h,5ah,0fh,75h,0f7h
  257.  
  258.  db 0aah,73h,0a5h,9dh,0f3h,2dh,0beh,58h
  259.  db 03h,4ah,0d9h,21h,30h,4eh,0d7h,75h
  260.  db 0a8h,98h,82h,02h,41h,9ch,02h,0eh
  261.  db 0c4h,61h,63h,61h,10h,0a2h,42h,48h
  262.  
  263.  .dephase
  264.  
  265. buf0:: ds 100h
  266.  ds 20h ;for stack
  267.  
  268. stac0:: end start
  269.