home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / EXTRA-ST / CPM-80-E / CPM-0.2 / CPM-0 / cpm-0.2 / z80-sources / system / zccp.mac < prev   
Encoding:
Text File  |  1994-06-06  |  31.9 KB  |  1,343 lines

  1.         MACLIB biosbase.def
  2. ;****************************************************************;
  3. ;*                                *;
  4. ;*        ZDOS Version 1.0                *;
  5. ;*        extended CCP Features for Cp/M            *;
  6. ;*        (c) 1985 by Michael Bischoff            *;
  7. ;*                                *;
  8. ;****************************************************************;
  9. ;*                                *;
  10. ;*        edit history:                    *;
  11. ;* 26.05.1985:    nochmal neu }berarbeitet.            *;
  12. ;*        Ben|tigt jetzt CBIOS-Rou-            *;
  13. ;*        tine bei CBIOS + 33h zum            *;
  14. ;*        'merken' des Userpath.                *;
  15. ;* 27.05.1985:    Ben|tigt Routine nicht mehr.            *;
  16. ;*        jetzt ist von 40h bis 4fh            *;
  17. ;*        der BIOS-Scratch-Bereich des            *;
  18. ;*        Cp/M daf}r reserviert. Bei            *;
  19. ;*        Systemstart sollte da korrekt             *;
  20. ;*        initialisiert werden                *;
  21. ;* 16.06.1985:    Der Bereich f}r PATH ist jetzt von        *;
  22. ;*        8h bis 11h. ERA ohne Argumente ist        *;
  23. ;*        jetzt abgefangen und COPY kopiert        *;
  24. ;*        nicht mehr auf sich selber.            *;
  25. ;*        Die Zero-Page ist jetzt voll belegt.        *;
  26. ;*        Der BDOS-Ansprung geht wieder }ber        *;
  27. ;*        5h, damit die RSM-Module funktio-        *;
  28. ;*        nieren.                        *;
  29. ;* 11.08.1985:    COPY kopiert jetzt auch R/O-Dateien.        *;
  30. ;*        Sollte STAT.COM $R/O oder $R/W nicht        *;
  31. ;*        akzeptieren, so liegt dies daran, da~        *;
  32. ;*        STAT das Attribut im deffcb2 erwartet,        *;
  33. ;*        ZDOS aber das '/'-Zeichen nicht in den        *;
  34. ;*        FCB }bernimmt (korrekt laut Cp/M-Hand-        *;
  35. ;*        buch)                        *;
  36. ;*        Alle Befehle mit /Q Option nehmen jetzt        *;
  37. ;*        die Eingabe 'G' (go) an. Dies bewirkt        *;
  38. ;*        eine automatische 'N'-Eingabe aller        *;
  39. ;*        weiteren Abfragen.                *;
  40. ;* 08.09.1985    Diese Version ist ein COM-File, welches ein    *;
  41. ;*        Overlay bei D000h benutzt, wenn BIG_DOS auf    *;
  42. ;*        einen Wert definiert wird. Die Zero-Page    *;
  43. ;*        wurde umgestellt und arbeitet jetzt mit PAS-    *;
  44. ;*        CAL/M zusammen (ab 10h MM DD YY HH MM in BCD)    *;
  45. ;* 15.09.1985    Diese Version geht in Richtung einer wirklich    *;
  46. ;*        universellen Form, die auf allen Rechnern    *;
  47. ;*        laufen sollte. Anforderungen: 1) BIOS springt    *;
  48. ;*        beim Kaltstart CCP an, danach CCP+3. 2)    Die    *;
  49. ;*        Zero-Page bleibt unver{ndert. (0-f, 30-37,    *;
  50. ;*        3b-5b)                        *;
  51. ;* 29.09.1985    Die Labels CCP und BDOS eingef}hrt, das Label    *;
  52. ;*        BASE (Top Memory f}r Dateinamen-sammelei) va-    *;
  53. ;*        riabel gemacht und auf 8000h gesetzt.        *;
  54. ;* 04.10.1985    Label BASE von 8000h auf 9000h gesetzt, da    *;
  55. ;*        die WordStar-Overlays f}r COPY zu gro~ waren.    *;
  56. ;* 23.11.1985    Control-ECHO wieder erlaubt, conditional execu-    *;
  57. ;*        tion eingebaut bei Zeilen, die mit '?' beginnen    *;
  58. ;* 08.05.1986    Befehl EXIT eingebaut. Dieser Befehl l|scht die    *;
  59. ;*        A:$$$.SUB-Datei und beendet somit Job-Control    *;
  60. ;* 19.05.1986    [nderung in Conditional-Statements: TRUE ist    *;
  61. ;*        wegen Kompatibilit{t zu UNIX jetzt 0.        *;
  62. ;*        BASE ist jetzt variabel.            *;
  63. ;*                                *;
  64. ;****************************************************************;
  65.  
  66. false        equ 0
  67. true        equ not false
  68. r_enab        equ false        ;'R'-Command (we have better in INLINE)
  69. c_enab        equ true        ;conditional execution
  70.  
  71.         .z80            ;geschrieben in ZILOG-Code
  72.         if1
  73.         .printx $ Assembling ZDOS System-Track Version vom 19.05.1986 $
  74.         else
  75.         .printx $ ...Pass 2 $
  76.         endif
  77.  
  78. fill        macro length,byte
  79.         rept length
  80.         db byte
  81.         endm
  82.         endm
  83.  
  84. echoflag    equ 0037h        ;ECHO-Flag
  85. pathtab        equ 0008h        ;PATH-Tabelle
  86.  
  87. ccp_fcb        equ 003bh        ;default FCB for internal use
  88. deffcb        equ 005ch        ;default FCB address
  89. deffcb2        equ 006ch        ;default FCB address 2
  90. defdma        equ 0080h        ;default DMA address
  91.  
  92. tab        equ 09h            ;ASCII Tabulator
  93. cr        equ 0dh            ;ASCII carriage return
  94. lf        equ 0ah            ;ASCII linefeed
  95.  
  96. ;****************************************************************;
  97. ;*                                *;
  98. ;*        BDOS-Systemcalls                *;
  99. ;*                                *;
  100. ;****************************************************************;
  101.  
  102. system_reset    equ 0
  103. console_in    equ 1
  104. console_out    equ 2
  105. reader_in    equ 3
  106. punch_out    equ 4
  107. list_out    equ 5
  108. direct_conio    equ 6
  109. get_iobyte    equ 7
  110. set_iobyte    equ 8
  111. print_string    equ 9
  112. inline        equ 0ah
  113. get_con_status    equ 0bh
  114. return_version    equ 0ch
  115. disk_reset    equ 0dh
  116. select_disk    equ 0eh
  117. open_file    equ 0fh
  118. close_file    equ 10h
  119. srch_for_first    equ 11h
  120. srch_for_next    equ 12h
  121. delete_file    equ 13h
  122. read_seq    equ 14h
  123. write_seq    equ 15h
  124. make_file    equ 16h
  125. rename_file    equ 17h
  126. get_login_vec    equ 18h
  127. get_cur_disk    equ 19h
  128. set_dma_addr    equ 1ah
  129. get_alloc_addr    equ 1bh
  130. set_ro_disk    equ 1ch
  131. get_ro_vector    equ 1dh
  132. set_file_attr    equ 1eh
  133. get_dpb_addr    equ 1fh
  134. set_get_user    equ 20h
  135. read_random    equ 21h
  136. write_random    equ 22h
  137. comp_file_size    equ 23h
  138. set_rand_rec    equ 24h
  139. reset_drive    equ 25h
  140.  
  141.  
  142. wr_rand_with_0    equ 28h
  143.  
  144. bdos        macro callnr,arg    ;Macro ruft BDOS auf
  145.         ifnb <arg>        ;Argument ist Funktionsnummer
  146.         ld de,arg        ;evtl. auch Parameter
  147.         endif            ;
  148.         ld c,callnr        ;
  149.         call bdos_entry        ;Ausf}hrung
  150.         endm            ;
  151.  
  152. bdos        macro callnr,arg    ;diese Version benutzt RST 30H
  153.         ifnb <arg>        ;gleich
  154.         ld de,arg        ;gleich
  155.         endif            ;gleich
  156.         rst 30h            ;rufe BDOS auf
  157.         db callnr        ;holt sich der Restart
  158.         endm            ;
  159.  
  160. ccp        equ cbios-1600h
  161. bdos        equ ccp+806h
  162.  
  163. ;base        equ 9000h        ;hier drunter werden die DIRECTORY-
  164.                     ;Eintr{ge gesammelt! VORSICHT!
  165.                     ;kann mit RSM und GO kollidieren
  166.                     ; ACHTUNG: jetzt variabel!
  167. stacktop    equ bdos
  168.  
  169. bdos_entry    equ 5            ;(nicht cbios-0dfah)
  170.  
  171.  
  172.  
  173.         db 36            ;(erster Sektor)
  174.         db 36+16        ;(letzter Sektor+1)
  175.  
  176.         .phase ccp        ;Beginn des ZDOS
  177.  
  178.         jp init            ;Sprungvektor 1
  179.         jp warm_entry        ;Sprungvektor 2
  180.  
  181. inline_buffer:    db 7fh            ;
  182. inline_count:    db 7            ;
  183. inline_text:    db 'PATH AB',0        ;
  184.         db '****************'    ;
  185.         db '* ZDOS Ver 1.1 *'    ;
  186.         db '* M. Bischoff  *'    ;
  187.         db '* May-27 1985  *'    ;
  188.         db '****************'    ;
  189.  
  190. init:        ld hl,bdos        ;mache ein JP BDOS aus dem ersten
  191.         ld (ccp+4),hl        ;Sprungvektor, dann ist FREEZE einfacher
  192.         ld hl,'@'        ;initial PATH
  193.         ld (pathtab),hl        ;store it in ZEROPAGE
  194.         ld b,8
  195.         ld hl,rst30        ;Tabelle f}r Bytes 30h..37h
  196.         ld de,30h
  197. loop_init:    ld a,(hl)
  198.         ld (de),a
  199.         inc hl
  200.         inc de
  201.         djnz loop_init        ;bis 8 Byte }bertragen sing
  202.         jp cold_entry
  203.  
  204. rst30:        ex (sp),hl        ;hl = Aufrufadresse + 1
  205.         ld c,(hl)        ;da steht die Funktionsnummer
  206.         inc hl            ;return 1 Byte weiter
  207.         ex (sp),hl        ;R}ckkehradresse wieder auf Stack
  208.         jr $+2-36h+5        ;und in das BDOS
  209.         db 0            ;lastkey  (used by BDOS)
  210.         db 0            ;Echoflag (OFF)
  211.  
  212.         if $ gt ccp+88h
  213.         .printx $ FATAL: Initialization Routine needs too much memory $
  214.         endif
  215.  
  216.         fill ccp+88h-$,0    ;um auf den richtigen Platz zu kommen
  217.  
  218. pointer_1:    dw inline_text        ;
  219. pointer_2:    dw 0            ;
  220.  
  221.  
  222.  
  223. ;****************************************************************;
  224. ;*                                *;
  225. ;*        Bis hier die h{ufig ben|tigten            *;
  226. ;*        Unterprogramme. Es folgt die            *;
  227. ;*        Tabelle der Befehle und ihrer            *;
  228. ;*        Ansprungadressen.                *;
  229. ;*                                *;
  230. ;****************************************************************;
  231.  
  232.  
  233. space_out:    ld a,' '        ;gib ein Leerzeichen aus
  234. akku_out:    push de            ;gib Akku aus.
  235.         push bc            ;Die Register DE und BC werden
  236.         ld e,a            ;gerettet
  237.         bdos console_out    ;gib Zeichen }ber BDOS aus
  238.         pop bc            ;hole Register zur}ck
  239.         pop de            ;
  240.         ret            ;und zur}ck ins Hauptprogramm
  241.  
  242. crlf_out:    ld a,cr            ;gib Carriage-return und Linefeed aus
  243.         call akku_out        ;
  244.         ld a,lf            ;
  245.         jr akku_out        ;
  246.  
  247. prompt_out:    ld bc,prompt        ;gibt Promptmeldung aus
  248. crlf_bc_out:    call crlf_out        ;gib cr, lf und Text ab bc aus
  249. ab_bc_out:    ld a,(bc)        ;gib Text ab bc aus (bis 0)
  250.         or a            ;
  251.         ret z            ;
  252.         ;cp ' '            ;ist es ein Ctrl-Zeichen?
  253.         ;jr nc,normal_out    ;nein
  254.         ;ld a,'^'        ;sonst graphisch darstellen
  255.         ;call akku_out        ;ausgeben
  256.         ;ld a,(bc)        ;erneut Zeichen holen
  257.         ;add a,40h        ;Upper case character
  258. normal_out:    call akku_out        ;
  259.         inc bc            ;
  260.         jr ab_bc_out        ;
  261.  
  262. set_defdma:    ld de,80h        ;set default DMA address
  263.         bdos set_dma_addr    ;
  264.         ret
  265.  
  266. set_def_drive:    ld a,(default_drive)    ;setze Defaultlaufwerk
  267. set_drive:    cp 255            ;schon gesetzt?
  268. current_drive    equ $-1            ;wird hier geladen
  269.         ret z            ;wenn gleich, kein BDOS-Aufruf
  270.         ld (current_drive),a    ;neues Current-Drive
  271.         ld e,a            ;f}r BDOS
  272.         bdos select_disk    ;}ber RST 30H
  273.         ld e,1            ;markiere 'other' f}r COPY
  274.         ret            ;
  275.  
  276. open_seq:    ld de,ccp_fcb        ;|ffnet Datei zum sequentiellem Lesen
  277. open_fcb:    ld c,open_file        ;
  278. bdos_store_w0:    xor a            ;oder Schreiben.
  279.         ld (ccp_fcb+12),a    ;ex
  280.         ld (ccp_fcb+14),a    ;s2
  281.         ld (ccp_fcb+32),a    ;setze Record-Count im Extend auf 0
  282. bdos_store:    call bdos_entry        ;
  283.         ld (result_byte),a    ;speichere Ergebnis
  284.         inc a            ;wenn vorher 0ffh war,
  285.         ret            ;dann return mit Zero-Flag gesetzt
  286.  
  287. sff_ccp_fcb:    ld de,ccp_fcb        ;default CCP FCB
  288.         ld c,srch_for_first    ;search for first
  289.         jr bdos_store        ;suche und speichere Ergebnis
  290.  
  291. delete_ccp_fcb:    ld de,ccp_fcb        ;l|sche File ccp_fcb
  292.         bdos delete_file    ;Datei l|schen
  293.         ret
  294.  
  295. set_def_user:    ld a,(default_user)    ;setze Default-User
  296. set_user:    cp 255
  297. current_user    equ $-1            ;damit nicht unn|tig BDOS aufgerufen wird
  298.         ret z
  299.         ld (current_user),a    ;abspeichern
  300.         ld e,a            ;setzte User (A)
  301.         bdos set_get_user    ;BDOS-Funktion
  302.         ld e,1
  303.         ret
  304.  
  305. read_ccp_fcb:    ld de,ccp_fcb        ;lies sequentiell aus ccp_fcb
  306. read_seqf:    bdos read_seq        ;BDOS-Funktionscode
  307.         or a            ;Ergebnis?
  308.         ret            ;
  309.  
  310. const_uchar:    bdos get_con_status    ;wurde eine Taste gedr}ckt?
  311.         or a            ;
  312.         ret z            ;keine Taste gedr}ckt
  313. conin:        bdos console_in        ;bedingungslos Taste einlesen
  314.         or a            ;or a, damit Status von const_uchar richtig
  315.         ret
  316.  
  317. get_user_line:    ld a,1            ;lies neue Befehlszeile von Tastatur oder $$$.SUB
  318. submitflag    equ $-1            ;wenn hier erst mal 0 drin ist, kein SUBMIT
  319.         or a            ;
  320.         jr z,end_submit        ;
  321.  
  322.         bdos set_dma_addr,inline_count    ;da soll der Record hin
  323.         ld de,sub_fcb        ;lies neue Befehlszeile ein
  324.         call open_fcb        ;sieh nach, ob A:$$$.SUB existiert
  325.         j≥ z,end_submit        ;wenn nicht, l|sche Datei
  326.         ld a,(sub_fcb+15)    ;Datei existiert, hole Anzahl Records
  327.         dec a            ;-1 => letzte Recordnummer
  328.         ld (sub_fcb+32),a    ;abspeichern, wird als n{chstes gelesen
  329.         ld de,sub_fcb        ;Zeiger auf FCB
  330.         call read_seqf        ;und lesen...
  331.         jr nz,end_submit    ;End of file? dann l|schen
  332.         ld hl,sub_fcb+14    ;
  333.         ld (hl),0        ;(im Handbuch steht: "for system use")
  334.         inc hl            ;Anzahl Records
  335.         dec (hl)        ;einen weniger
  336.         bdos close_file,sub_fcb    ;Datei dichtmachen
  337.         inc a            ;hat geklappt?            
  338.         jr z,end_submit        ;nein, dann l|sche A:$$$.SUB
  339.         ld a,(echoflag)        ;echo on or off?
  340.         rrca            ;bit 0 z{hlt
  341.         jr nc,continue        ;dann auch keine Abfrage, ob Taste gedr}ckt
  342.  
  343.         call prompt_out        ;Prompt ausgeben
  344.         ld bc,inline_text    ;gib gelesene Zeile aus
  345.         call ab_bc_out        ;
  346.         call const_uchar    ;wurde Taste gedr}ckt?
  347.         jr z,continue        ;nein
  348.         call del_subm        ;ja, dann breche SUBMIT ab
  349.         jp reentry        ;und gehe in die Hauptschleife
  350.  
  351. end_submit:    call del_subm        ;versuche, A:$$$.SUB zu l|schen
  352.         call prompt_out
  353.         ld de,inline_buffer
  354.  
  355.         bdos inline         ;lies }ber BDOS von Tastatur ein
  356.         ld hl,inline_count    ;Z{hler eingelesene Buchstaben
  357.  
  358.         if r_enab        ;R-enable
  359.         ld a,(hl)        ;
  360.         dec a            ;war Z{hler 1 ?
  361.         jr nz,no_repeat        ;wenn nicht, ist R nicht m|glich
  362.         inc hl            ;pointet auf erstes (einziges) Zeichen
  363.         ld a,(hl)        ;einlesen...
  364.         dec hl            ;Pointer zur}ck
  365.         or ' '            ;CAPS=>lower
  366.         cp 'r'            ;R-Kommando?
  367.         jr nz,no_repeat        ;wenn nicht
  368.         ld de,5201h        ;vorl{ufig R<cr>
  369. repeatmem    equ $-2            ;Initial value = R<cr>
  370.         ld (inline_count),de    ;und abgespeichert
  371. no_repeat:
  372.         endif
  373.         ld c,5fh        ;convert to upper case
  374.         ld b,(hl)        ;nochmal die Anzahl der Zeichen
  375.         inc b            ;einen erh|hen f}r Abschlu~byte 00
  376. to_upper:    inc hl            ;Schleife, wandelt Zeile in Gro~buchstaben um
  377.         ld a,(hl)        ;n{chstes Zeichen
  378.         cp 9            ;ist es ein Tabulator?
  379.         jr nz,notab        ;nein
  380.         ld (hl),' '        ;sonst in Leerzeichen umwandeln,
  381. notab:        cp 'a'            ;da CCP allergisch gegen TABs ist
  382.         jr c,next_conv        ;wenn kleiner als a, keine [nderung
  383.         cp 'z'+1        ;wenn gr|~er als z auch nicht
  384.         jr nc,next_conv        ;sondern n{chstes Zeichen
  385.         and c                  ;to UPPER case
  386.         ld (hl),a        ;und abspeichern
  387. next_conv:    cp '"'
  388.         jr nz,next_conv2
  389.         set 5,c
  390. next_conv2:    djnz to_upper        ;Schleife wiederholen bis Ende
  391.         ld (hl),b        ;b ist jetzt 0, schlie~t Zeile ab
  392.  
  393. continue:
  394.         if r_enab
  395.         ld hl,(inline_count)    ;hier steigt SUBMIT ein
  396.         ld (repeatmem),hl    ;neuer Wert f}r R<cr>
  397.         endif
  398.  
  399.         ld hl,inline_text    ;Zeiger initialisieren
  400.  
  401.         if c_enab    ;Conditional enable
  402.         ld a,(hl)
  403.         sub '?'        ;conditional line?
  404.         jr nz,true_exec
  405.         inc hl
  406.         ld a,0
  407. return_code    equ $-1
  408.         or a
  409.         jp nz,get_user_line
  410.         endif
  411.  
  412. true_exec:    ld (pointer_1),hl    ;
  413.         ret            ;und zur}ck
  414.  
  415. del_subm:    ld hl,submitflag    ;pr}fe, ob A:$$$.SUB schon gel|scht ist
  416.         xor a            ;
  417.         cp (hl)            ;na?
  418.         ret z            ;jawoll!
  419.         ld (hl),a        ;sonst wird es jetzt getan
  420.         bdos delete_file,sub_fcb;FCB daf}r
  421.         ret
  422. no_error:    cp a
  423.         ret
  424. test:        ld a,(de)        ;pr}fe Zeichen auf G}ltigkeit f}r Dateinamen
  425.         or a            ;Ende der Zeile?
  426.         ret z            ;ja
  427.         cp ' '            ;space?
  428.         jp c,no_error        ;Controlsequenzen sind nicht erw}nscht
  429.         ret z            ;zero auch bei space
  430.         exx            ;save Registers
  431.         ld b,18            ;Anzahl der ung}ltigen Zeichen
  432.         ld hl,char_tabelle    ;
  433. check_char:    cp (hl)            ;
  434.         jr z,invalid_ch        ;
  435.         inc hl            ;
  436.         djnz check_char        ;
  437.         exx            ;
  438.         or a            ;
  439.         ret            ;valid characters
  440. invalid_ch:    exx            ;wieder alten Registersatz
  441.         ret            ;mit ZERO Flag
  442.  
  443.  
  444.  
  445. get_next_ptr:    ld hl,(pointer_1)    ;da war er vorher gespeichert
  446. get_next_hl:    ld a,(hl)        ;erstes Zeichen
  447.         or a            ;wenn Zeilenende,
  448.         ret z            ;dann return
  449.         cp ' '            ;wenn space,
  450.         ret nz            ;dann weitersuchen, bis Space gefunden
  451.         inc hl            ;dazu Pointer erh|hen
  452.         jr get_next_hl        ;
  453.  
  454. setup_fcb:    ld de,ccp_fcb        ;Default FCB
  455. setup_fcb_de:    push de            ;FCB Beginn
  456.         xor a            ;jetzt Default-Drive
  457.         ld (de),a        ;in FCB-Drivefeld
  458.         call get_next_ptr    ;erhasche erstes Zeichen des Namens
  459.         ld (pointer_2),hl    ;f}r Error-Ausgabe
  460.         ex de,hl        ;
  461.         jr z,fill_fcb        ;war garnichts
  462.         inc de            ;
  463.         ld a,(de)        ;zweites Zeichen
  464.         dec de            ;
  465.         cp ':'            ;Laufwerksangabe?
  466.         jr nz,fill_fcb        ;nein
  467.         ld a,(de)        ;ist eine Laufwerkangabe
  468.         sub 'A'            ;
  469.         cp 'P'            ;
  470.         jr nc,fill_fcb        ;falsche Laufwerkangabe wird ignoriert
  471.         inc de            ;zeigt jetzt auf ':'
  472.         inc de            ;
  473.         inc a            ;
  474.         ld (hl),a        ;
  475.  
  476. fill_fcb:    ld b,8            ;8 Characters Filename
  477.         call UP2        ;generieren
  478.         ld b,3            ;3 Characters Fileextension
  479.         call UP2a        ;generieren (aber . anders behandeln)
  480.  
  481.         ld b,3            ;setze diverse Z{hler auf 0
  482. set_0:        inc hl            ;
  483.         ld (hl),0        ;
  484.         djnz set_0        ;
  485.  
  486.         ld (pointer_1),de    ;weiter geht's beim ersten Byte hinter dem Namen
  487.         pop hl            ;nochmal FCB Adresse
  488.  
  489.         ld bc,11*256        ;z{hle ? im FCB
  490.         ld a,'?'        ;
  491. count_wildcart:    inc hl            ;
  492.         cp (hl)            ;ist es Fragezeichen?
  493.         jr nz,test_next        ;
  494.         inc c            ;Z{hler erh|hen
  495. test_next:    djnz count_wildcart    ;next one
  496.         ld a,c            ;Anzahl
  497.         or a            ;ZERO-Flag richtig setzen
  498.         ret            ;und zur}ck
  499.  
  500. UP2a:        cp '.'
  501.         jr nz,fill_space
  502.         inc de
  503. UP2:        call test
  504.         jr z,fill_space
  505.         inc hl
  506.         cp '*'
  507.         jr nz,not_all
  508.         ld (hl),'?'
  509.         jr next_x
  510. not_all:    ld (hl),a
  511.         inc de
  512. next_x:        djnz UP2
  513.         cp '*'
  514.         jr nz,ignore_rest    ;es fehlt noch inc de
  515.         inc de
  516. ignore_rest:    call test
  517.         ret z            ;ok, nichts mehr an Buchstaben da
  518.         jp error        ;weil zu lang!
  519. fill_space:    inc hl            ;Rest des Teiles mit space f}llen
  520.         ld (hl),' '
  521.         djnz fill_space
  522.         ret
  523.  
  524. ;****************************************************************;
  525. ;*                                *;
  526. ;*            ZDOS Entry-Point            *;
  527. ;*        bei cold_entry wird die im Buffer        *;
  528. ;*        befindliche Kommandozeile ausgef}hrt        *;
  529. ;*                                *;
  530. ;****************************************************************;
  531.                     ;
  532. warm_entry:    xor a            ;Anzahl der Zeichen im
  533.         ld (inline_count),a    ;Buffer auf 0 setzen
  534.                     ;
  535. cold_entry:    ld sp,stacktop        ;hat eigenen Stack
  536.         push bc            ;Usernummer/Disknummer
  537.         ld a,c            ;Drive Nr.
  538.         ld (4),a        ;in Defauldrive speichern
  539.         rra            ;
  540.         rra            ;
  541.         rra            ;
  542.         rra            ;
  543.         and 00001111b        ;Drivenummer ausblenden
  544.         ld (default_user),a    ;und merken
  545.         call set_user        ;dem BDOS Usernummer mitteilen
  546.                     ;und auch selber merken
  547.         bdos disk_reset        ;Drive A=Online
  548.         pop bc            ;Usernummer/Disknummer
  549.         ld a,c            ;
  550.         and 00001111b        ;nur die Laufwerknummer selektieren
  551.         ld (default_drive),a    ;und merken
  552.         call set_drive        ;f}r das BDOS
  553.                     ;
  554.         ld a,(inline_count)    ;pr}fe, ob Startup-Kommando ausgef}hrt
  555.         or a            ;werden mu~
  556.         jr nz,common        ;wenn Buffer gef}llt
  557.                     ;
  558. reentry:    ld sp,stacktop        ;Neuinitialisation Stack
  559.         ld hl,new_drive
  560.         ld a,(hl)
  561.         ld (hl),0
  562.         or a
  563.         jr z,reentry_nodrv
  564.         dec a
  565.         ld (default_drive),a
  566.         call set_drive
  567. reentry_nodrv:    ld a,0            ;set Byte (4) correct
  568. default_user    equ $-1
  569.         ld c,a            ;merken
  570.         rlca
  571.         rlca
  572.         rlca
  573.         rlca
  574.         ld b,a
  575.         ld a,0
  576. default_drive    equ $-1
  577.         or b        
  578.         ld (4),a
  579.         and 00001111b        ;wieder nur Default-Disklaufwerk
  580.         ld hl,prompt        ;prompt string
  581.         add a,'A'        ;Offset zum ASCII-Code
  582.         ld (hl),a        ;und ausgeben
  583.         inc hl            ;Pointer erh|hen
  584.         ld a,c            ;Default-Usernummer
  585.         cp 10            ;zweistellig?
  586.         jr c,einstellig        ;
  587.         sub 10            ;dann zieh Rest auch ab
  588.         ld (hl),'1'        ;speichere einen Zehner
  589.         inc hl            ;Pointer + 1
  590. einstellig:    add a,'0'        ;Offset ASCII
  591.         ld (hl),a        ;und ausgeben
  592.         inc hl            ;jetzt letztes Zeichen
  593.         ld (hl),'>'        ;noch ein Teil des Prompts
  594.         inc hl
  595.         ld (hl),0
  596.         call get_user_line    ;Eingabe einer Kommandozeile von
  597.                     ;Keyboard oder SUBMIT-File
  598. common:        ld a,(7)        ; bottom RSM or BDOS
  599.         cp high(ccp)
  600.         jr c,rsm_exist
  601.         ld a,high(ccp)        ; CCP is lower
  602. rsm_exist:    ld h,a
  603.         ld l,0
  604.         ld (TPA_top),hl        ; store it!
  605.         call set_def_drive
  606.         call set_def_user
  607.         ld hl,error        ;h{ufigstes Ansprungziel auf den Stack
  608.         push hl
  609.         call set_defdma        ;setze Default DMA Adresse
  610.         call setup_fcb        ;generiere Dateinamen
  611.         ret nz            ;if * or ? in Filename => ERROR
  612.  
  613.         ld (tail_beginn),de    ;Beginn der restl. Kommandozeile
  614.         ld hl,ccp_fcb+9        ;wurde Fileextension eingegeben?
  615.         ld a,(hl)
  616.         cp ' '
  617.         ret nz            ;wenn ja, error
  618.         ld (hl),'C'        ;sonst ist sie COM
  619.         inc hl
  620.         ld (hl),'O'
  621.         inc hl
  622.         ld (hl),'M'
  623.  
  624.         ld a,(ccp_fcb)        ;wurde lfw: angegeben?
  625.         or a            ;wenn ja, kann es nur
  626.         jp nz,TRANSIENT        ;ein transientes Programm sein
  627.  
  628.         ld hl,tabelle        ;pr}fe, ob ein eingebautes Kommando vorliegt
  629. next_command:    ld e,(hl)        ;als erstes steht Zieladresse
  630.         inc hl            ;auf dem Stack
  631.         ld d,(hl)
  632.         inc hl
  633.         push de
  634.         xor a            ;Test, ob Ende der Tabelle
  635.         cp (hl)            ;wenn Befehl mit 00 beginnt
  636.         ret z            ;auf dem Stack ist Adresse
  637.         ld (beginn_name),hl
  638.         ld de,ccp_fcb+1        ;Beginn des Namens
  639.         ld b,4            ;L{nge Kommando
  640. vergleiche:    ld a,(de)        ;eingegebenes Zeichen
  641.         cp (hl)            ;= verlangtem Zeichen?
  642.         jr nz,onefail        ;nein
  643.         inc hl            ;sonst restliche Zeichen pr}fen
  644.         inc de            ;dazu Pointer erh|hen
  645.         djnz vergleiche        ;und Vergleich wiederholen
  646.         ld a,(de)        ;der Rest des FCB mu~ space sein
  647.         cp ' '
  648.         pop de            ;R}ckkehradresse
  649.         jr nz,next_command
  650.         push de            ;wird doch ben|tigt
  651.         jp setup_fcb        ;da meist gebraucht, danach ins Programm
  652.  
  653. onefail:    inc hl            ;Kommando sah anders aus
  654.         djnz onefail        ;Pointer updaten
  655.         pop de            ;Ansprungadresse
  656.         jr next_command        ;und n{chstes versuchen
  657.  
  658. test_end_ptr:    ld hl,(pointer_1)    ;Anfang letzter Bytefolge
  659. test_end_hl:    call get_next_hl    ;n{chstes Zeichen
  660.         ret z            ;mu~ 00 sein
  661.         jr error_hl        ;sonst ERROR
  662.  
  663. error:        ld hl,(pointer_2)
  664. error_hl:    ld c,l
  665.         ld b,h
  666. error_bc:    call crlf_bc_out
  667.         ld a,'?'
  668.         call akku_out
  669.         call del_subm
  670.         xor a
  671.         ld (new_drive),a
  672.         jp reentry
  673.  
  674. only_this:    call test_end_ptr    ;darf kein zweiter FCB folgen
  675. test_lfw_ext:    ld hl,ccp_fcb        ;da steht die Zahl drin
  676.         ld a,(ccp_fcb+9)    ;"file extension"
  677.         sub ' '            ;sollte jetzt 0 sein
  678.         or (hl)            ;Drive sollte Default sein
  679.         jr nz,error        ;sonst Error
  680.         inc hl            ;auf ccp_fcb+1
  681.         ret            ;so ist es OK
  682.  
  683. get_number:    call test_lfw_ext    ;reine Zahl erw}nscht
  684.         ld c,a            ;steht 0 drin...
  685.         ld a,(hl)        ;get digit
  686. next_digit:    sub '0'
  687.         cp 10
  688.         jr nc,error
  689.         ld b,a
  690.         ld a,c
  691.         cp 26            ;schon mehr ?
  692.         jr nc,error        ;weil beim multiplizieren ]bertrag ent-
  693.         add a,a            ;stehen w}rde
  694.         ld c,a
  695.         add a,a
  696.         add a,a
  697.         add a,c            ;Akku := Akku * 10
  698.  
  699.         add a,b            ;jetzt die neue Ziffer dazu!
  700.         jr c,error
  701.         ld c,a
  702.         inc hl
  703.         ld a,(hl)
  704.         cp ' '
  705.         ret z
  706.         or a
  707.         jr nz,next_digit
  708.         ret            ;return number in c
  709.  
  710. loadprog:    ld hl,100h
  711. TR2:        push hl
  712.         ex de,hl
  713.         bdos set_dma_addr
  714.         ld de,ccp_fcb
  715.         call read_seqf
  716.         pop hl
  717.         ret nz
  718.         ld de,0080h
  719.         add hl,de
  720.         ld a,(TPA_top+1)
  721.         cp h
  722.         jr nz,TR2
  723. bad_load:    ld bc,text_bad_load
  724.         jp exit_with_print
  725.  
  726. ;=======================================;
  727. ;                    ;
  728. ;        C O P Y            ;
  729. ;                    ;
  730. ;=======================================;
  731.  
  732. COPY:        call collect
  733. loopcopy:    call end_files_test
  734.         push de
  735.         call set_drv_usr    ;to selected
  736.         call open_seq
  737.         call loadprog        ;load file into memory
  738.         push hl            ;HL is Maxmem+1
  739.         call set_def_drive
  740.         call set_def_user
  741.         pop hl
  742.         call saveupro        ;write it back a la save
  743.         pop de
  744.         jr loopcopy
  745.  
  746. ;=======================================;
  747. ;                    ;
  748. ;        P A T H            ;
  749. ;                    ;
  750. ;=======================================;
  751.  
  752. PATH:        call only_this        ;darf nichts folgen und
  753.                     ;darf weder Laufwerk noch extension
  754.         ld a,(hl)        ;angegeben sein
  755.         cp ' '
  756.         ld bc,pathtab
  757.         jr z,exit_with_print
  758.         ld e,c
  759.         ld d,b
  760.         ld bc,7
  761. pathloop:    cp 40h            ;n{chstes Zeichen
  762.         ret c            ;Error, wenn kein Buchstabe
  763.         cp 'P'+1
  764.         ret nc
  765.         ldi
  766.         xor a
  767.         ld (de),a        ;erst mal beenden...
  768.         ld a,(hl)        ;ein weiteres
  769.         cp ' '
  770.         jr nz,pathloop        ;weiter geht's
  771.         inc c
  772.         ret z            ;wenn es 8 Zeichen waren
  773. to_reentry2:    jp reentry
  774.  
  775.         ;
  776.         ;===============================================
  777.         ;
  778. bad_drive:    ld bc,bad_drive_txt
  779. exit_with_print:call crlf_bc_out
  780.         jp to_reentry2
  781.  
  782. set_drv_usr:    ld e,0            ;modify-Flag
  783.         ld a,0
  784. temp_user    equ $-1
  785.         call set_user        ;anderer als Defaultuser
  786.  
  787.         ld a,(temp_drive)    ;
  788.         jp set_drive        ;auch anderes Drive
  789.  
  790. collect:    ld a,(default_user)
  791.         ld (temp_user),a    ;temporary User
  792.         call get_next_ptr
  793.         cp '/'
  794.         ld de,20h        ;jr nz,...
  795.         ld c,0            ;User number
  796.         jr nz,opt_end
  797.         ld (pointer_2),hl
  798. next_opt:    inc hl
  799.         ld a,(hl)
  800.         and 11011111b        ;00 oder Spaces
  801.         jr z,opt_end        ;nix mehr
  802.         and 11111001b        ;Test auf Q, S, U, W
  803.         cp 'Q'
  804.         ld a,(hl)
  805.         jr nz,must_be_digit    ;sonst error
  806.         rrca
  807.         and 3
  808.         ld b,a
  809.         inc b
  810.         ld a,40h
  811. turn:        rlca
  812.         djnz turn
  813.         or d
  814.         ld d,a
  815.         jr next_opt
  816.  
  817. must_be_digit:    call next_digit        ;versuche, eine Usernummer einzulesen
  818.         or a
  819.         jp nz,error        ;Ende
  820.         ld a,c
  821.         cp 16
  822.         jp nc,error
  823.         ld (temp_user),a
  824. opt_end:    call test_end_hl    ;darf nichts mehr folgen
  825.         ld a,d
  826.         rrca            ;S=>Carry
  827.         jr nc,not_only_sys
  828.         ld e,28h        ;jr z,off
  829. not_only_sys:    rrca            ;U=>Carry
  830.         jr nc,not_only_user    ;
  831.         ld e,3eh        ;ld a,...
  832. not_only_user:    ld a,e
  833.         ld (jpselect),a
  834.         ld a,d
  835.         ld (option_bits),a    ;Q und W
  836.  
  837.         ld hl,ccp_fcb
  838.         ld a,(hl)
  839.         dec a
  840.         jp p,other_drive
  841.         ld a,(default_drive)
  842. other_drive:    ld (temp_drive),a
  843.         ld (hl),0
  844.         inc hl
  845.         ld de,(beginn_name)    ;Pointer auf ersten Buchstaben des Commandos
  846.         ld a,(hl)
  847.         cp ' '
  848.         ld a,(de)
  849.         jr nz,isn_all
  850.         cp 'E'            ;era?
  851.         jp z,error        ;einfach ERA geht nicht
  852.         ld b,11
  853. loop:        ld (hl),'?'
  854.         inc hl
  855.         djnz loop
  856. isn_all:    push af            ;Copy?
  857.         call set_drv_usr
  858.         pop af
  859.         sub 'C'
  860.         jr nz,no_eq_test
  861.         or e            ;wurde umgeschaltet?
  862.         jp z,bad_drive
  863.         
  864. no_eq_test:    call set_drv_usr
  865.  
  866.         call sff_ccp_fcb
  867.         jr z,none_found
  868.         ld de,0
  869. TPA_top        equ $-2
  870.         dec de            ;load names below ZDOS or RSM
  871. collectloop:    ld a,d
  872.         or a
  873.         ld bc,no_room_text
  874.         jp z,exit_with_print    ;raus und melden
  875. enough_space:    ld a,0
  876. result_byte    equ $-1
  877.         rrca
  878.         rrca
  879.         rrca
  880.         add a,80h+10        ;2.last char of filename
  881.         ld l,a
  882.         ld h,0
  883.         bit 7,(hl)
  884. jpselect:    jr nz,noaccept
  885.         inc l
  886.         ld a,0
  887. option_bits    equ $-1            ;evtl fragen, ob }berhaupt...
  888.         rlca            ;Bit 7(Q) => Carry
  889.         jr nc,take_it
  890.         push de
  891.         push hl
  892.         ld de,-10        ;zeigte vorher auf 11.Zeichen
  893.         add hl,de        ;hl jetzt Pointer auf Filename
  894.         call crlf_file_out    ;Dateinamen ausgeben
  895.         call space_out
  896.         ld de,0
  897. beginn_name    equ $-2            ;dir, era, copy, type        
  898.         ld bc,0401h
  899.         call fno2        ;ausgeben
  900.         ld bc,q_mark
  901.         call ab_bc_out
  902. askkill:    call conin
  903.         cp 3
  904.         jp z,reentry
  905.         and 0dfh        ;to upper
  906.         pop hl
  907.         pop de
  908.         cp 'Y'
  909.         jr z,take_it
  910.         cp 'N'
  911.         jr z,noaccept
  912.         cp 'G'
  913.         jr z,go_copy
  914.         push de
  915.         push hl
  916.         jr askkill
  917.  
  918. take_it:    ld bc,11
  919.         lddr
  920. noaccept:    push de
  921.         ld c,srch_for_next
  922.         call bdos_store
  923.         pop de
  924.         jr nz,collectloop
  925. go_copy:    ;hier moeglichkeit, dateien zu sortieren...
  926.         inc de
  927.         ld a,(TPA_top+1)
  928.         cp d
  929.         ret nz
  930. none_found:
  931. no_file:    ld bc,no_file_text
  932.         call crlf_bc_out
  933.         jp reentry
  934. end_files_test:    ld a,(TPA_top+1)
  935.         cp d
  936.         jp z,reentry
  937.         push de
  938.         ex de,hl
  939.         ld de,ccp_fcb+1
  940.         ld bc,11
  941.         ldir
  942.         ex (sp),hl
  943.         call crlf_file_out
  944.         pop de
  945.         ret
  946.  
  947. crlf_file_out:    ex de,hl
  948.         call crlf_out
  949. filename_out:    ld bc,0802h        ;ab de, de nach auf 1 Zeichen sp{ter
  950. fno2:        ld a,(de)
  951.         inc de
  952. rein:        call akku_out
  953.         djnz fno2
  954.         dec c
  955.         ret z
  956.         ld b,4
  957.         ld a,'.'
  958.         jr rein        
  959.  
  960. ;=======================================;
  961. ;                    ;
  962. ;        E C H O            ;
  963. ;                    ;
  964. ;=======================================;
  965.  
  966. ECHO:        call only_this        ;kein zweiter FCB
  967.         ld b,(hl)        ;darf nur Y oder N folgen
  968.         inc hl
  969.         ld a,(hl)        ;zweites Zeichen mu~ space sein
  970.         cp ' '
  971.         ret nz
  972.         ld a,b            ;erstes Zeichen
  973.         cp 'Y'            ;erstes Zeichen
  974.         jr z,echo_on
  975.         sub 'N'
  976.         ret nz            ;weder Y noch N
  977. echo_on:    ld (echoflag),a
  978. to_reentry3:    jp reentry
  979.  
  980. ;=======================================;
  981. ;                    ;
  982. ;        E X I T            ;
  983. ;                    ;
  984. ;=======================================;
  985.  
  986. EXIT:        call del_subm        ; l|sche nur $$$.SUB
  987.         jr to_reentry3        ; sonst nichts
  988.  
  989. ;=======================================;
  990. ;                    ;
  991. ;        E R A            ;
  992. ;                    ;
  993. ;=======================================;
  994.  
  995. ERA:        call collect
  996. kill_loop:    call end_files_test
  997.         push de
  998.         call delete_ccp_fcb
  999.         pop de            ;pointer next file
  1000.         jr kill_loop
  1001.  
  1002. ;=======================================;
  1003. ;                    ;
  1004. ;        D I R            ;
  1005. ;                    ;
  1006. ;=======================================;
  1007.  
  1008. zeilcount:    db 0
  1009. DIR:        call collect
  1010.         ld a,1
  1011.         ld (zeilcount),a
  1012. dirloop:    ld a,(TPA_top+1)
  1013.         cp d
  1014.         jp z,to_reentry3
  1015.         ld hl,zeilcount
  1016.         dec (hl)
  1017.         ld a,' '
  1018.         jr nz,no_newline
  1019.         ld (hl),5
  1020.         call crlf_out
  1021.         ld a,0
  1022. temp_drive    equ $-1
  1023.         add a,'A'
  1024. no_newline:    call akku_out
  1025.         ld a,':'
  1026.         call akku_out
  1027.         call space_out
  1028.         call filename_out
  1029.         jr dirloop
  1030.  
  1031. ;=======================================;
  1032. ;                    ;
  1033. ;        U S E R            ;
  1034. ;                    ;
  1035. ;=======================================;
  1036.  
  1037. USERa:        call setup_fcb        ;alternate USER-Befehl = /nn
  1038. USER:        call test_end_ptr    ;nach Usernummer Schlu~
  1039.         call get_number
  1040.         ld a,c
  1041.         cp 16
  1042.         ret nc
  1043.         ld (default_user),a
  1044.         call set_user
  1045.         jp reentry
  1046.  
  1047. ;=======================================;
  1048. ;                    ;
  1049. ;        S A V E            ;
  1050. ;                    ;
  1051. ;=======================================;
  1052.  
  1053. SAVE:        call get_number
  1054.         ld h,c
  1055.         ld l,0
  1056.         inc h
  1057.         push hl            ;maxmem+1
  1058.         call setup_fcb
  1059.         jp nz,error
  1060.         call test_end_ptr
  1061.         pop hl
  1062.         call saveupro
  1063.         jp reentry
  1064.  
  1065. saveupro:    push hl
  1066.         call delete_ccp_fcb
  1067.         ld de,ccp_fcb
  1068.         ld hl,ccp_fcb+9        ;1.char Extension
  1069.         res 7,(hl)        ;reset R/O-Bit
  1070.         ld c,make_file        ;make FCB
  1071.         call bdos_store_w0
  1072.         jr z,no_space
  1073.         ld de,100h        ;start TPA
  1074. SAVE1:        pop hl            ;maxmem+1
  1075.         push hl
  1076.         or a
  1077.         sbc hl,de        ;=jetzige DMA?
  1078.         jr z,save_close        ;dann Schlu~!
  1079.         ld hl,80h
  1080.         add hl,de
  1081.         push hl
  1082.         bdos set_dma_addr
  1083.         bdos write_seq,ccp_fcb
  1084.         or a
  1085.         pop de
  1086.         jr z,SAVE1
  1087.         bdos close_file,ccp_fcb
  1088. no_space:    ld bc,no_space_text
  1089.         jp exit_with_print
  1090.  
  1091. save_close:    pop hl
  1092.         bdos close_file,ccp_fcb
  1093.         inc a
  1094.         jr z,no_space
  1095.         jp set_defdma
  1096.  
  1097. ;=======================================;
  1098. ;                    ;
  1099. ;        T Y P E            ;
  1100. ;                    ;
  1101. ;=======================================;
  1102.  
  1103. MORE:        call collect        ;damit ZERO-Flag richtig bleibt
  1104.         push de
  1105. drucke:        xor a
  1106.         ld (linecount),a
  1107.         pop de
  1108.         call end_files_test
  1109.         push de
  1110.         call open_seq
  1111.         call crlf_out
  1112. DRUCKE1:    call read_ccp_fcb
  1113.         jr nz,drucke
  1114.         ld bc,80h
  1115. DRUCKE2:    ld a,(bc)
  1116.         cp 1ah            ;EOF
  1117.         jr z,drucke
  1118.  
  1119.         push bc
  1120.         cp lf
  1121.         jr nz,DRUCKE3
  1122.  
  1123.         ld hl,option_bits    ;anhalten?
  1124.         bit 2,(hl)
  1125.         jr z,continuous        ;nein!
  1126.         ld a,0
  1127. linecount    equ $-1
  1128.         dec a
  1129.         jp m,page_end
  1130.         ld (linecount),a
  1131.         jr DRUCKE3a
  1132.  
  1133. page_end:    ld bc,more_text
  1134.         call crlf_bc_out
  1135.         call conin
  1136.         cp 3
  1137.         jp z,reentry
  1138.         cp cr
  1139.         jr z,one_weiter
  1140.         pop bc
  1141.         cp '.'            ;next File?
  1142.         jr z,drucke
  1143.         push bc
  1144.         ld a,21            ; else next page
  1145.         ld (linecount),a
  1146. one_weiter:    ld bc,un_more
  1147.         call ab_bc_out
  1148.         jr DRUCKE3b        ;da ab_bc_out Steuerzeichen umwandelt
  1149.  
  1150. continuous:    ;call const_uchar    ;disabled, da }ber BDOS-Statusabfrage
  1151.         ;jp nz,reentry        ;^S, ^C m|glich ist!
  1152. DRUCKE3a:    ld a,lf
  1153. DRUCKE3:    call akku_out
  1154. DRUCKE3b:    pop bc
  1155.         inc c
  1156.         jr nz,DRUCKE2
  1157.         jr DRUCKE1
  1158.  
  1159. ;=======================================;
  1160. ;                    ;
  1161. ;        R E N            ;
  1162. ;                    ;
  1163. ;=======================================;
  1164.  
  1165. REN:        ret nz            ;war ambiguous Filename
  1166.         call get_next_ptr    ;jetzt mu~ das '='-Zeichen folgen
  1167.         cp '='            ;ist es das?
  1168.         ret nz            ;sonst ERROR
  1169.         inc hl            ;Pointer updaten
  1170.         ld (pointer_1),hl    ;
  1171.  
  1172.         call sff_ccp_fcb    ;existiert Soll-Name?
  1173.         ld bc,text_exists    ;"File exists"
  1174.         jp nz,exit_with_print    ;ausschreiben und weg
  1175.         ld hl,ccp_fcb        ;sonst in Feld 2 schieben
  1176.         ld de,ccp_fcb+16    ;
  1177.         ld bc,16        ;
  1178.         ldir            ;
  1179.         call setup_fcb        ;zweiten Dateinamen holen
  1180.         ret nz            ;ambiguous file name
  1181.  
  1182.         call test_end_ptr    ;ist jetzt Schlu~?
  1183.  
  1184.         ld hl,ccp_fcb
  1185.         ld a,(ccp_fcb+16)
  1186.         or a
  1187.         jr z,drive_ok
  1188.         cp (hl)
  1189.         jr z,drive_ok
  1190.         push af
  1191.         xor a
  1192.         or (hl)
  1193.         jp nz,bad_drive
  1194.         pop af
  1195.         ld (hl),a
  1196. drive_ok:    call sff_ccp_fcb
  1197.         jp z,no_file
  1198.         ld de,ccp_fcb
  1199.         bdos rename_file
  1200.         jp reentry
  1201.  
  1202. ;=======================================;
  1203. ;                    ;
  1204. ;    Transientes Programm laden    ;
  1205. ;                    ;
  1206. ;=======================================;
  1207.  
  1208. TRANSIENT:    ld a,(ccp_fcb+1)    ;Feld f}r erstes Zeichen des Programmnamens
  1209.         sub ' '
  1210.         jr nz,program
  1211.         ld hl,ccp_fcb        ;Drive Code
  1212.         or (hl)            ;auch gleich 0?
  1213.         jr z,comment        ;dann nur <Enter> gedr}ckt
  1214.         ld (new_drive),a
  1215. comment:    call get_next_ptr
  1216.         jr z,to_reentry
  1217.         inc hl
  1218.         ld (pointer_1),hl
  1219.         cp '/'            ;alternate USER-Befehl
  1220.         jp z,USERa
  1221.         sub '"'
  1222.         ret nz            ;dann ERROR
  1223.         ld a,(echoflag)        ;ECHO on
  1224.         rrca
  1225.         ld b,h
  1226.         ld c,l
  1227.         call nc,crlf_bc_out
  1228. to_reentry:    jp reentry
  1229.  
  1230. program:    ld hl,(pointer_1)
  1231.         ld a,(hl)
  1232.         sub '/'            ;Option?
  1233.         jr nz,no_user_nr
  1234.         inc hl
  1235.         ld c,a            ;0
  1236.         call next_digit-1
  1237.         ld (pointer_1),hl
  1238.         ld (tail_beginn),hl
  1239.         ld a,c
  1240.         cp 16
  1241.         ret nc            ;zu gro~
  1242.         call set_user
  1243. no_user_nr:    ld de,pathtab
  1244.         ld a,(ccp_fcb)
  1245.         or a
  1246.         jr z,loadloop        ;suche auf Laufwerken
  1247.         ld de,pathtab+7        ;Pointer auf 0
  1248.         jr reinload
  1249. loadloop:    ld a,(de)
  1250.         sub 40h
  1251.         ret c            ;nicht Syntax, sondern File nicht existent
  1252.         inc de
  1253.         ld (ccp_fcb),a
  1254. reinload:    push de
  1255.         call open_seq
  1256.         pop de
  1257.         jr z,loadloop
  1258.         call loadprog        ;load progam into mem
  1259.         call set_def_user
  1260.         call setup_fcb
  1261. GO:        ld de,ccp_fcb+16
  1262.         call setup_fcb_de
  1263.         xor a
  1264.         ld (ccp_fcb+32),a
  1265.         ld de,deffcb
  1266.         ld hl,ccp_fcb
  1267.         ld bc,21h
  1268.         ldir
  1269.  
  1270.         ld hl,0
  1271. tail_beginn    equ $-2
  1272.         ld de,81h        ;ab da wird Command-Tail gespeichert
  1273. transfer2:    cp (hl)            ;a ist noch 0
  1274.         ldi            ;}bertrage
  1275.         jr nz,transfer2        ;n{chstes Byte
  1276. end_tr:        ld a,e
  1277.         sub defdma+2        ;L{nge des Restes
  1278.         ld (defdma),a        ;abspeichern
  1279.         call crlf_out        ;Zeilenvorschub
  1280.         call set_defdma        ;Default DMA setzen
  1281.         pop af            ;Error-Adresse
  1282.         call 100h        ;starte Programm
  1283.         if c_enab
  1284.         ld (return_code),a
  1285.         endif
  1286.         ld a,255
  1287.         ld (current_user),a    ;User now undefined
  1288.         ld (current_drive),a    ;Drive auch
  1289.         jp reentry        ;Hauptschleife
  1290.  
  1291. tabelle:    ;Tabelle der eingebauten Kommandos und ihrer Ansprung-
  1292.         ;Adressen
  1293.  
  1294.         dw DIR
  1295.         db 'DIR '
  1296.         dw ERA
  1297.         db 'ERA '
  1298.         dw MORE
  1299.         db 'TYPE'
  1300.         dw SAVE
  1301.         db 'SAVE'
  1302.         dw REN
  1303.         db 'REN '
  1304.         dw COPY
  1305.         db 'COPY'
  1306.         dw GO
  1307.         db 'GO  '
  1308.         dw PATH
  1309.         db 'PATH'
  1310.         dw ECHO
  1311.         db 'ECHO'
  1312.         dw EXIT
  1313.         db 'EXIT'
  1314.  
  1315. ;        dw USER            ; must go in favour of 'UNIX'
  1316. ;        db 'USER'
  1317.         dw cbios        ; simply cold boot
  1318.         db 'UNIX'
  1319.  
  1320.         dw TRANSIENT
  1321.         db 0            ;Ende der Tabelle
  1322.  
  1323. prompt:        db 'A15>',0        ;Prompt String
  1324. char_tabelle:    db '"<>.,;:=[\]_%|()/',7fh                    ;
  1325. bad_drive_txt:    db 'Bad Drive',0
  1326. no_file_text:    db 'No File',0
  1327. no_room_text:    db 'List full',0
  1328. more_text:    db '<More>',0
  1329. un_more:    db cr,tab,cr,0
  1330. no_space_text:    db 'No Space',0
  1331. text_bad_load:    db 'Bad load',0
  1332. text_exists:    db 'File exists',0
  1333.  
  1334. q_mark:        db ' it? ',0
  1335. new_drive:    db 0
  1336.         ift $ gt bdos-33-22    ;das letzte ist Stack Space
  1337.         .printx $ FATAL: ZDOS Module too big!! $
  1338.         endif
  1339. sub_fcb:    db 1,'$$$     SUB'
  1340.         fill bdos-6-$,0        ;runde auf
  1341.         .dephase
  1342.         end
  1343.