home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 1 / VECTRONIX1.iso / area.1 / 231.lzh / 231.MSA / EMULATOR.C64 / SOURCE / VC.S < prev   
Text File  |  1987-04-22  |  27KB  |  1,095 lines

  1. ********************************************************************************
  2. *                                                                              *
  3. *                              C64-Emulator V3.0                               *
  4. *                             ╜ 1987 by Uwe Seimet                             *
  5. *                             Buchenlochstra₧e 29                              *
  6. *                             6750 Kaiserslautern                              *
  7. *                                                                              *
  8. *                       Linkreihenfolge: C64.O,VC.O,EMULATOR.O                 *
  9. *                                                                              *
  10. ********************************************************************************
  11.  
  12.  
  13. GEMDOS  = 1
  14.  
  15. PROUT   = $05
  16. SETDRV  = $0E
  17. DFREE   = $36
  18. CREATE  = $3C
  19. OPEN    = $3D
  20. CLOSE   = $3E
  21. READ    = $3F
  22. WRITE   = $40
  23. UNLINK  = $41
  24. CHMODE  = $43
  25. MALLOC  = $48
  26. MFREE   = $49
  27. SFIRST  = $4E
  28. SNEXT   = $4F
  29. RENAME  = $56
  30.  
  31.  
  32.         globl vc1541
  33.         globl vcopen
  34.         globl vcclose
  35.         globl vcread
  36.         globl vcwrite
  37.         globl vcchkin
  38.         globl vckout
  39.         globl compnt
  40.         globl dta
  41.         globl fsave
  42.         globl fload
  43.         globl file
  44.         globl printer
  45.         globl prfont
  46.         
  47.  
  48.         text
  49.  
  50. fload:
  51.         move.b d6,$c3(a6)
  52.         move.b d7,$c4(a6)
  53.         move.b d5,$93(a6)
  54.         clr.b $90(a6)
  55.         bsr iopar
  56.         lea c64+$f0c9,a2                *"SEARCHING"
  57.         bsr print
  58.         lea c64+$f0d4,a2                *"FOR"
  59.         bsr print
  60.         lea file,a2
  61.         bsr print
  62.         cmp.b #"$",file
  63.         beq cat
  64.         clr -(sp)
  65.         pea file
  66.         move #SFIRST,-(sp)
  67.         trap #GEMDOS
  68.         addq.l #8,sp
  69.         tst d0
  70.         beq ld0
  71.         move #$f704,d0
  72.         bra ret64
  73. ld0:    tst.b $93(a6)
  74.         bne ver
  75.         lea c64+$f106,a2                *"LOADING"
  76.         bsr print
  77.         clr -(sp)
  78.         pea file
  79.         move #OPEN,-(sp)
  80.         trap #GEMDOS
  81.         addq.l #8,sp
  82.         move d0,d2
  83.         bmi loaderr
  84.         pea $ae(a6)
  85.         pea 2
  86.         move d2,-(sp)
  87.         move #READ,-(sp)
  88.         trap #GEMDOS
  89.         add.l #12,sp
  90.         tst.l d0
  91.         bmi loaderr
  92.         tst.b $b9(a6)
  93.         bne sadr
  94.         move.b d6,$ae(a6)
  95.         move.b d7,$af(a6)
  96. sadr:   clr.l d0
  97.         move.b $af(a6),d0
  98.         asl #8,d0
  99.         move.b $ae(a6),d0
  100.         pea (a6,d0.l)
  101.         move.l dta+26,-(sp)
  102.         move d2,-(sp)
  103.         move #READ,-(sp)
  104.         trap #GEMDOS
  105.         add.l #12,sp
  106.         tst.l d0
  107.         bmi loaderr
  108.         move d2,-(sp)
  109.         move #CLOSE,-(sp)
  110.         trap #GEMDOS
  111.         addq.l #4,sp
  112.         tst d0
  113.         bmi loaderr
  114.         move.b dta+28,d0
  115.         add.b dta+29,d6
  116.         addx.b d0,d7
  117.         subq.b #2,d6
  118.         bcc ld9
  119.         subq.b #1,d7
  120. ld9:    move.b d6,$ae(a6)
  121.         move.b d7,$af(a6)
  122.         bra ok
  123. ver:    lea c64+$f116,a2                *"VERIFYING"
  124.         bsr print
  125.         bra ok
  126.  
  127. loaderr:
  128.         or.b #$bf,$90(a6)
  129.         or.b #$11,d4
  130.         moveq #$1d,d5
  131.         rts
  132.  
  133. cat:    lea c64+$f106,a2
  134.         bsr print
  135.         tst.b $b9(a6)
  136.         beq scat
  137.         move.b #$01,$c3(a6)
  138.         move.b #$04,$c4(a6)
  139. scat:   clr.l d0
  140.         move.b $c4(a6),d0
  141.         asl #8,d0
  142.         move.b $c3(a6),d0
  143.         lea (a6,d0.l),a2
  144.         bsr odir
  145.         move.l a2,d0
  146.         sub.l a6,d0
  147.         move.b d0,d6
  148.         lsr #8,d0
  149.         move.b d0,d7
  150.         bra ld9
  151.  
  152. fsave:
  153.         move.b d6,$ae(a6)
  154.         move.b d7,$af(a6)
  155.         lea (a6,d5),a0
  156.         move.b (a0),$c1(a6)
  157.         move.b 1(a0),$c2(a6)
  158.         bsr iopar
  159.         lea c64+$f10e,a2
  160.         bsr print
  161.         lea file,a2
  162.         bsr print
  163.         clr -(sp)
  164.         pea file
  165.         move #CREATE,-(sp)
  166.         trap #GEMDOS
  167.         addq.l #8,sp
  168.         move d0,d2
  169.         bmi saveerr
  170.         pea $c1(a6)
  171.         pea 2
  172.         move d2,-(sp)
  173.         move #WRITE,-(sp)
  174.         trap #GEMDOS
  175.         add.l #12,sp
  176.         tst.l d0
  177.         bmi saveerr
  178.         move.b $c2(a6),d0
  179.         asl #8,d0
  180.         move.b $c1(a6),d0
  181.         move.l d7,d1
  182.         asl #8,d1
  183.         move.b d6,d1
  184.         sub d0,d1
  185.         bcs saveerr
  186.         pea (a6,d0)
  187.         move.l d1,-(sp)
  188.         move d2,-(sp)
  189.         move #WRITE,-(sp)
  190.         trap #GEMDOS
  191.         add.l #12,sp
  192.         tst.l d0
  193.         bmi saveerr
  194.         move d2,-(sp)
  195.         move #CLOSE,-(sp)
  196.         trap #GEMDOS
  197.         addq.l #4,sp
  198.         tst d0
  199.         bpl ok
  200. saveerr:move #$f70d,d0                  *"NOT OUTPUT FILE"
  201.         bra ret64
  202.  
  203. iopar:
  204.         move #$f713,d0                  *"ILLEGAL DEVICE NUMBER"
  205.         move.b $ba(a6),d3
  206.         cmp.b #1,d3
  207.         bgt io0
  208.         move.b drv(pc),d3
  209. io0:    cmp.b #8,d3
  210.         blt iret64
  211.         cmp.b #17,d3
  212.         bgt iret64
  213.         move #$f710,d0                  *"MISSING FILENAME"
  214.         tst.b $b7(a6)
  215.         beq iret64
  216. io4:    move.b d3,drv
  217.         subq.b #8,d3
  218.         move d3,-(sp)
  219.         move #SETDRV,-(sp)
  220.         trap #GEMDOS
  221.         addq.l #4,sp
  222.         move.b $b7(a6),d3
  223.         clr.l d0
  224.         lea $bb(a6),a1
  225.         move.b 1(a1),d0
  226.         asl #8,d0
  227.         move.b (a1),d0
  228.         lea (a6,d0.l),a1
  229.         lea file,a0
  230.         clr.b (a0,d3)
  231.         subq.b #1,d3
  232. io1:    move.b (a1,d3),(a0,d3)
  233.         dbf d3,io1
  234.         clr d3
  235.         rts
  236. iret64: addq.l #4,sp
  237.         bra ret64
  238.         
  239. vc1541:
  240.         clr.b track                     *Spur und Sektor
  241.         clr.b sector
  242.         lea file,a0
  243.         move.l compnt(pc),d0
  244.         sub.l a0,d0
  245.         tst.b d0                        *Länge der Kommandozeile
  246.         beq ok                          *kein Kommando-
  247.         cmp.b #$0d,(a0)
  248.         beq ok                          *kein Kommando-
  249.         move.b (a0),d1
  250.         moveq #$0b,d0                   *Anzahl der Befehle
  251.         lea com(pc),a1
  252. flp0:   cmp.b (a1,d0),d1
  253.         beq flp
  254.         dbf d0,flp0
  255.         bra err2
  256. flp:    asl #2,d0
  257.         lea adr(pc),a1
  258.         move.l (a1,d0),a1
  259.         moveq #$3a,d0                   *":"
  260.         bsr find
  261.         jsr (a1)
  262.         rts
  263.  
  264. *File öffnen, logische Filenummer in D0
  265. vcopen:
  266.         clr.b teof
  267.         move.b d0,tmp                   *logische Filenummer
  268.         move.b $ba(a6),d3               *Geräteadresse
  269.         bsr io4                         *Filename nach A0
  270.         moveq #$2c,d0                   *","
  271.         bsr find                        *suchen
  272.         bne readf                       *nicht gefunden-File lesen
  273.         clr.b (a0,d0)                   *Ende des Filenamens markieren
  274.         cmp.b #"S",1(a0,d0)             *SEQ?
  275.         beq seq                         *ja-
  276.         cmp.b #"P",1(a0,d0)             *PRG?
  277.         bne err4                        *nein-
  278. seq:    cmp.b #",",2(a0,d0)             *Komma?
  279.         bne err4                        *nein-
  280.         cmp.b #"R",3(a0,d0)             *File lesen?
  281.         beq readf                       *ja-
  282.         cmp.b #"W",3(a0,d0)             *File schreiben
  283.         bne err4                        *nein-
  284.         st rwflg                        *Flag für Schreiben
  285.         clr -(sp)
  286.         pea file
  287.         move #CREATE,-(sp)
  288.         bra readf1
  289. readf:  clr.b rwflg
  290.         moveq #-1,d0                    *Dummy-Handle
  291.         cmp.b #"$",file                 *Directory?
  292.         beq odi                         *ja-
  293.         clr -(sp)
  294.         pea file
  295.         move #OPEN,-(sp)
  296. readf1: trap #GEMDOS
  297.         addq.l #8,sp
  298.         tst d0
  299.         bmi err4
  300. odi:    clr d1
  301.         move.b $98(a6),d1               *Position des Fileeintrags
  302.         subq.b #1,d1                    *Position in Liste
  303.         lea filenr,a0
  304.         move.b tmp,(a0,d1)              *logische Filenummer
  305.         lea eofs,a0
  306.         clr.b (a0,d1)                   *EOF-Flag löschen
  307.         lea rwflgs,a0
  308.         move.b rwflg,(a0,d1)            *Flag für Lesen/Schreiben
  309.         add d1,d1
  310.         lea fhandle,a0
  311.         move d0,(a0,d1)                 *Handle merken
  312.         lea fillen,a0
  313.         clr (a0,d1)                     *keine gültigen Bytes
  314.         add d1,d1
  315.         move d1,d0
  316.         lea bufpnt,a0
  317.         mulu #$0400,d0                  *Bufferadresse berechnen
  318.         add.l #filbuf,d0
  319.         move.l d0,(a0,d1)               *Adresse für Schreiben/Lesen
  320.         rts
  321.  
  322. vcread:
  323.         move.b $b9(a6),d0
  324.         and.b #$0f,d0
  325.         cmp.b #$0f,d0                   *Kommandokanal?
  326.         beq readc                       *ja-
  327.         tst tlen
  328.         bne fil1
  329.         st d5                           *Byte an Dateiende
  330.         tst.b teof                      *Dateiende?
  331.         bne eof                         *ja-
  332.         bsr vcr1                        *nächsten Block lesen
  333. fil1:   move.l tpnt(pc),a0
  334.         move.b (a0)+,d5
  335.         move.l a0,tpnt
  336.         subq #1,tlen
  337.         bne eof
  338.         tst.b teof
  339.         beq eof
  340. ceof:   or.b #$40,$90(a6)               *EOF
  341. eof:    and.b #$ee,d4
  342.         rts
  343. vcr1:   tst thand                       *Directory-File?
  344.         bmi getdir                      *ja-
  345.         move.l bufadr(pc),-(sp)         *Bufferadresse
  346.         pea $1000
  347.         move thand,-(sp)
  348.         move #READ,-(sp)
  349.         trap #GEMDOS
  350.         add.l #12,sp
  351.         move d0,tlen
  352.         bmi err4
  353.         cmp #$1000,d0
  354.         beq noeof
  355. gdir:   st teof
  356. noeof:  move.l bufadr(pc),tpnt
  357.         rts
  358. getdir: move.l bufadr(pc),a2
  359.         bsr opdir
  360.         sub.l bufadr(pc),a2
  361.         move a2,tlen
  362.         bsr ok
  363.         bra gdir
  364. readc:  move.l compnt(pc),a0
  365.         move.b (a0)+,d5
  366.         move.l a0,compnt
  367.         tst.b (a0)
  368.         bne eof
  369.         bsr ok
  370.         bra ceof
  371.  
  372. vcwrite:
  373.         move.b $b9(a6),d0
  374.         and.b #$0f,d0
  375.         cmp.b #$0f,d0                   *Kommandokanal?
  376.         beq wcom                        *ja-
  377.         move.l tpnt(pc),a0
  378.         move.b d5,(a0)+
  379.         move.l a0,tpnt
  380.         addq #1,tlen
  381.         cmp #$1000,tlen
  382.         bne nowr
  383.         move.l bufadr(pc),-(sp)         *Bufferadresse
  384.         pea $1000
  385.         move thand,-(sp)
  386.         move #WRITE,-(sp)
  387.         trap #GEMDOS
  388.         add.l #12,sp
  389.         tst.l d0
  390.         bmi err4
  391.         clr tlen
  392.         move.l bufadr(pc),tpnt
  393.         bra nowr
  394. wcom:   move.l compnt(pc),a0
  395.         move.b d5,(a0)+
  396.         move.l a0,compnt
  397. nowr:   and.b #$ee,d4
  398.         rts
  399.  
  400. *File schlie₧en, logische Filenummer in D0
  401. vcclose:
  402.         bsr getfil                      *Nummer in Tabelle holen
  403.         lea rwflgs,a0
  404.         tst.b (a0,d1)                   *Lesen?
  405.         beq cls1                        *ja-
  406.         move d1,d0
  407.         lea bufpnt,a0
  408.         mulu #$1000,d0                  *Bufferadresse berechnen
  409.         add.l #filbuf,d0
  410.         move.l d0,-(sp)                 *Adresse für Schreiben/Lesen
  411.         add d1,d1
  412.         lea fillen,a0
  413.         clr.l d0
  414.         move (a0,d1),d0
  415.         move.l d0,-(sp)                 *Blocklänge
  416.         lea fhandle,a0
  417.         move (a0,d1),-(sp)              *File-Handle
  418.         move #WRITE,-(sp)
  419.         trap #GEMDOS
  420.         add.l #12,sp
  421.         tst.l d0
  422.         bmi err4
  423.         bra cls2
  424. cls1:   add d1,d1
  425. cls2:   lea fhandle,a0
  426.         tst (a0,d1)                     *Directory-File?
  427.         bmi clcom                       *ja-
  428.         move (a0,d1),-(sp)
  429.         move #CLOSE,-(sp)
  430.         trap #GEMDOS
  431.         addq.l #4,sp
  432. clcom:  rts
  433.  
  434. *Ein-/Ausgabe auf IEC-Bus, logische Filenummer in D0
  435. vcchkin:
  436. vckout:
  437.         tst onr
  438.         beq fchk
  439.         move onr,d1
  440.         subq #1,d1
  441.         lea eofs,a0
  442.         move.b teof,(a0,d1)             *EOF-Flag
  443.         add d1,d1
  444.         lea fillen,a0
  445.         move tlen,(a0,d1)               *Blocklänge
  446.         add d1,d1
  447.         lea bufpnt,a0
  448.         move.l tpnt(pc),(a0,d1)         *Bufferpointer
  449. fchk:   bsr getfil                      *Parameter holen
  450.         move d1,onr
  451.         addq #1,onr                     *als gültig markieren
  452.         move d1,d0
  453.         lea eofs,a0
  454.         move.b (a0,d1),teof             *EOF-Flag
  455.         add d1,d1
  456.         lea fillen,a0
  457.         move (a0,d1),tlen               *Blocklänge
  458.         lea fhandle,a0
  459.         move (a0,d1),thand              *File-Handle
  460.         add d1,d1
  461.         lea bufpnt,a0
  462.         move.l (a0,d1),tpnt             *Bufferpointer
  463.         mulu #$1000,d0                  *Bufferadresse berechnen
  464.         lea filbuf,a0
  465.         add.l d0,a0
  466.         move.l a0,bufadr                *Adresse für Schreiben/Lesen
  467.         rts
  468.  
  469. getfil:
  470.         lea filenr,a0
  471. gf:     cmp.b (a0)+,d0
  472.         bne gf
  473.         sub.l #filenr+1,a0
  474.         move a0,d1
  475.         rts
  476.  
  477. opdir:
  478.         move #$0401,(a2)+       *Programmstart bei $0400
  479. odir:   st (a2)+                *Dummy für Zeilennummer
  480.         st (a2)+
  481.         move.b $ba(a6),(a2)     *Drivenummer
  482.         subq.b #8,(a2)+
  483.         clr.b (a2)+
  484.         move.b #$12,(a2)+       *RVS ON
  485.         move.b #$22,(a2)+
  486.         lea dta,a1
  487.         move #$08,-(sp)         *Diskname suchen
  488.         pea joker(pc)           *"*.*"
  489.         move #SFIRST,-(sp)
  490.         trap #GEMDOS
  491.         addq.l #8,sp
  492.         tst d0
  493.         bne vol1
  494. vol0:   tst.b 30(a1,d0)
  495.         beq vol2
  496.         move.b 30(a1,d0),(a2)+  *Diskname übertragen
  497.         addq.b #1,d0
  498.         bra vol0
  499. vol1:   clr d0        
  500. vol2:   cmp.b #16,d0
  501.         beq vol3
  502.         move.b #" ",(a2)+
  503.         addq.b #1,d0
  504.         bra vol2
  505. vol3:   lea format(pc),a0       *"ST 2A"
  506. vol4:   move.b (a0)+,(a2)+
  507.         bne vol4
  508.         move #$01,-(sp)
  509.         pea joker(pc)           *"*.*"
  510.         move #SFIRST,-(sp)
  511.         trap #GEMDOS
  512.         addq.l #8,sp
  513.         tst d0
  514.         bne dir0                *nicht gefunden-
  515. dir9:   bsr dir                 *Directoryeintrag erzeugen
  516.         move #SNEXT,-(sp)
  517.         trap #GEMDOS
  518.         addq.l #2,sp
  519.         tst d0
  520.         beq dir9                *nächste Datei-
  521. dir0:   clr -(sp)
  522.         lea buffer,a1
  523.         move.l a1,-(sp)
  524.         move #DFREE,-(sp)
  525.         trap #GEMDOS
  526.         addq.l #8,sp
  527.         move.l (a1),d0
  528.         mulu 14(a1),d0          *Disk-Speicherplatz berechnen
  529.         mulu 10(a1),d0
  530.         divu #256,d0
  531.         st (a2)+                *Dummy-Zeilennummer
  532.         st (a2)+
  533.         move.b d0,(a2)+         *Platz auf Disk
  534.         lsr #8,d0
  535.         move.b d0,(a2)+
  536.         lea free(pc),a0         *"BLOCKS FREE."
  537. dira:   move.b (a0)+,(a2)+
  538.         bne dira
  539.         clr.b (a2)+             *Programmende
  540.         clr.b (a2)+
  541.         rts
  542.  
  543. dir:
  544.         st (a2)+                *Dummy-Zeilennummer
  545.         st (a2)+
  546.         move.l 26(a1),d0        *Dateilänge
  547.         add.l #258,d0           *Blockzahl berechnen
  548.         divu #254,d0
  549.         move.b d0,(a2)+
  550.         ror #8,d0
  551.         move.b d0,(a2)+
  552.         ror #8,d0
  553.         cmp #10,d0
  554.         bge dir3
  555.         move.b #" ",(a2)+
  556. dir3:   cmp #100,d0
  557.         bge dir4
  558.         move.b #" ",(a2)+
  559. dir4:   move.b #" ",(a2)+
  560.         move.b #$22,(a2)+       *Beginn des Filenamens
  561.         clr d0
  562. dir1:   move.b 30(a1,d0),d1
  563.         beq dir6                *Ende des Filenamens-
  564.         cmp.b #".",d1
  565.         beq dir6
  566.         move.b d1,(a2)+
  567.         addq.b #1,d0
  568.         bra dir1
  569. dir6:   move.b #$22,(a2)+       *Ende des Filenamens
  570.         move.b d0,d3
  571. dir2:   cmp.b #17,d0
  572.         beq dir5
  573.         move.b #" ",(a2)+       *Mit Spaces füllen
  574.         addq.b #1,d0
  575.         bra dir2
  576. dir5:   tst.b 30(a1,d3)         *Extension?
  577.         beq dir7                *nein-
  578.         tst.b 31(a1,d3)
  579.         bne di0                 *Extension untersuchen
  580. dir7:   move.b #" ",(a2)+
  581.         move.b #" ",(a2)+
  582.         move.b #" ",(a2)+
  583.         bra di3                 *Keine Extension
  584. di0:    move.b 31(a1,d3),(a2)+
  585.         tst.b 32(a1,d3)
  586.         bne di1
  587.         move.b #" ",(a2)+
  588.         move.b #" ",(a2)+
  589.         bra di3
  590. di1:    move.b 32(a1,d3),(a2)+
  591.         tst.b 33(a1,d3)
  592.         bne di2
  593.         move.b #" ",(a2)+
  594.         bra di3
  595. di2:    move.b 33(a1,d3),(a2)+
  596. di3:    btst #0,21(a1)
  597.         beq dirb                *ungeschütztes File-
  598.         move.b #"<",(a2)+       *geschütztes File kennzeichnen
  599. dirb:   clr.b (a2)+             *Zeilenende
  600.         rts
  601.  
  602. ok:     lea msg0(pc),a0
  603.         and.b #$ee,d4
  604.         bra err
  605. err1:   lea msg1(pc),a0
  606.         bra err
  607. err2:   lea msg2(pc),a0
  608.         bra err
  609. err3:   lea msg3(pc),a0
  610.         bra err
  611. err4:   lea msg4(pc),a0
  612.         bra err
  613. err5:   lea msg5(pc),a0
  614. err:    lea file,a1
  615.         move.l a1,compnt
  616. cerr:   move.b (a0)+,(a1)+
  617.         bne cerr
  618.         move.b #",",-1(a1)
  619.         move.b track,d0
  620.         bsr asc
  621.         move.b #",",(a1)+
  622.         move.b sector,d0
  623. asc:    move.b #"0"-1,d1
  624. asc0:   addq.b #1,d1
  625.         sub.b #10,d0
  626.         bcc asc0
  627.         add.b #10,d0
  628.         move.b d1,(a1)+
  629.         add.b #"0",d0
  630.         move.b d0,(a1)+
  631.         clr.b (a1)
  632.         rts
  633.  
  634. validate:
  635.         bra ok
  636.  
  637. init:
  638.         bra ok
  639.  
  640. memory:
  641.         bra ok
  642.  
  643. block:
  644.         bra ok
  645.  
  646. user:
  647.         cmp.b #"9",1(a0)
  648.         beq err3                *"VC 1541 EMULATOR"
  649.         bra ok
  650.  
  651. record:
  652.         bra ok
  653.  
  654. lbl:
  655.         bra ok
  656.  
  657. copy:
  658.         bne err2                *kein Doppelpunkt-
  659.         lea 1(a0,d0),a2
  660.         move.l a2,a0
  661.         moveq #$3d,d0           *"="
  662.         bsr find                *suchen
  663.         bne err2
  664.         tst.b 1(a0,d0)
  665.         beq err2                *kein Filename-
  666.         move.b d0,d3
  667.         clr.b (a0,d0)           *Ende des Filenamens markieren
  668.         clr -(sp)
  669.         move.l a2,-(sp)         *neuer Filename
  670.         move #SFIRST,-(sp)
  671.         trap #GEMDOS
  672.         addq.l #8,sp
  673.         tst d0
  674.         beq err5                *"FILE EXISTS"
  675.         move.l dta+26,-(sp)
  676.         move #MALLOC,-(sp)
  677.         trap #GEMDOS
  678.         addq.l #6,sp
  679.         tst.l d0
  680.         bmi ok
  681.         move.l d0,d2
  682.         clr -(sp)
  683.         pea 1(a2,d3)
  684.         move #OPEN,-(sp)
  685.         trap #GEMDOS
  686.         addq.l #8,sp
  687.         tst.l d0
  688.         bmi cok
  689.         move d0,d3
  690.         move.l d2,-(sp)
  691.         move.l dta+26,-(sp)
  692.         move d3,-(sp)
  693.         move #READ,-(sp)
  694.         trap #GEMDOS
  695.         add.l #12,sp
  696.         tst.l d0
  697.         bmi cok
  698.         move d3,-(sp)
  699.         move #CLOSE,-(sp)
  700.         trap #GEMDOS
  701.         addq.l #4,sp
  702.         tst d0
  703.         bmi cok
  704.         clr -(sp)
  705.         move.l a2,-(sp)
  706.         move #CREATE,-(sp)
  707.         trap #GEMDOS
  708.         addq.l #8,sp
  709.         tst.l d0
  710.         bmi cok
  711.         move d0,d3
  712.         move.l d2,-(sp)
  713.         move.l dta+26,-(sp)
  714.         move d3,-(sp)
  715.         move #WRITE,-(sp)
  716.         trap #GEMDOS
  717.         add.l #12,sp
  718.         tst.l d0
  719.         bmi cok
  720.         move d3,-(sp)
  721.         move #CLOSE,-(sp)
  722.         trap #GEMDOS
  723.         addq.l #4,sp
  724. cok:    move.l d2,-(sp)
  725.         move #MFREE,-(sp)
  726.         trap #GEMDOS
  727.         addq.l #6,sp
  728.         clr.l d2
  729.         bra ok
  730.  
  731. rename:
  732.         bne err2                *kein Doppelpunkt-
  733.         lea 1(a0,d0),a2
  734.         move.l a2,a0
  735.         moveq #$3d,d0           *"="
  736.         bsr find                *suchen
  737.         bne err2
  738.         move.b d0,d3
  739.         clr.b (a0,d0)           *Ende des Filenamens markieren
  740.         clr -(sp)
  741.         move.l a2,-(sp)         *neuer Filename
  742.         move #SFIRST,-(sp)
  743.         trap #GEMDOS
  744.         addq.l #8,sp
  745.         tst d0
  746.         beq err5                *"FILE EXISTS"
  747.         move.l a2,-(sp)
  748.         pea 1(a2,d3)
  749.         clr -(sp)
  750.         move #RENAME,-(sp)
  751.         trap #GEMDOS
  752.         add.l #12,sp
  753.         tst d0
  754.         beq ok
  755.         bra err4                *"FILE NOT FOUND"
  756.  
  757. scratch:
  758.         bne err2                *kein Doppelpunkt-
  759. s2:     lea 1(a0,d0),a2
  760.         tst.b (a2)
  761.         beq err1                *kein Filename-
  762.         move.l a2,a0
  763.         moveq #$2c,d0           *Komma
  764.         bsr find                *suchen
  765.         clr.b (a0,d0)
  766. s4:     move.l a2,-(sp)
  767.         move #UNLINK,-(sp)
  768.         trap #GEMDOS
  769.         addq.l #6,sp
  770.         tst d0
  771.         bmi s3
  772.         addq.b #1,track         *zählt gelöschte Files
  773.         bra s4                  *nächstes File
  774. s3:     move.l a2,a0
  775.         clr d0
  776.         bsr find
  777.         bra s2                  *nächstes File-
  778.  
  779. new:
  780.         bra ok
  781.  
  782. toggle:
  783.         bne err2                *kein Doppelpunkt-
  784. t2:     lea 1(a0,d0),a2
  785.         tst.b (a2)
  786.         beq ok                  *kein Filename-
  787.         move.l a2,a0
  788.         moveq #$2c,d0           *Komma
  789.         bsr find                *suchen
  790.         clr.b (a0,d0)
  791. t4:     clr.l -(sp)
  792.         move.l a2,-(sp)
  793.         move #CHMODE,-(sp)
  794.         trap #GEMDOS
  795.         add.l #10,sp
  796.         tst d0
  797.         bmi t3
  798.         bchg #0,d0
  799.         move d0,-(sp)
  800.         move #$01,-(sp)
  801.         move.l a2,-(sp)
  802.         move #CHMODE,-(sp)
  803.         trap #GEMDOS
  804.         add.l #10,sp
  805. t3:     move.l a2,a0
  806.         clr d0
  807.         bsr find
  808.         bra t2                  *nächstes File-
  809.  
  810. *Zeichen in D0 suchen, Pointer auf String in A0, Position in D0
  811. find:
  812.         move.b d0,d1
  813.         clr d0
  814. find1:  move.b (a0,d0),d2
  815.         beq nfound
  816.         cmp.b d2,d1
  817.         beq found
  818.         addq #1,d0
  819.         bra find1
  820. nfound: and #$fb,ccr
  821. found:  rts
  822.  
  823. *Druckeremulation
  824. printer:
  825.         move.b $b9(a6),d3
  826.         bmi sa0
  827.         and.b #$0f,d3
  828.         asl.b #2,d3
  829.         move.l saadr(pc,d3),a0
  830.         jmp (a0)
  831.  
  832. saadr:  dc.l sa0,sa1,sa2,sa3,sa4,sa5,sa6,sa7,sa8,sa9,sa10
  833.  
  834. out:    cmp.b #$0a,d5
  835.         beq prrt
  836.         move d5,d0
  837.         bsr prout
  838.         cmp.b #$0d,d5
  839.         bne prrt
  840.         moveq #$0a,d0
  841.         bsr prout
  842.         clr.b revflg
  843.         clr.b qflg
  844.         clr chrpnt
  845. prrt:   rts
  846.  
  847. spc:
  848.         moveq #$20,d0
  849.         bra prout
  850. cr:
  851.         clr chrpnt
  852.         clr.b revflg
  853.         clr.b qflg
  854.         moveq #$0d,d0
  855.         bra prout
  856.  
  857. sa0:    clr.b caseflg
  858. sa1:
  859.         cmp.b #$0d,d5
  860.         beq crout
  861.         cmp.b #$22,d5
  862.         bne quote
  863.         not.b qflg
  864.         bra qout
  865. quote:  tst.b qflg
  866.         bne qout
  867.         cmp.b #$12,d5
  868.         bne rev
  869.         st revflg
  870.         rts
  871. rev:    cmp.b #$92,d5
  872.         bne norev
  873.         clr.b revflg
  874.         rts
  875. norev:  cmp.b #$11,d5
  876.         bne nolo
  877.         st caseflg
  878.         rts
  879. nolo:   cmp.b #$91,d5
  880.         bne noup
  881.         clr.b caseflg
  882.         rts
  883. noup:   cmp.b #$01,d5
  884.         bne enh
  885.         st expflg
  886.         rts
  887. enh:    cmp.b #$81,d5
  888.         bne noenh
  889.         clr.b expflg
  890.         rts
  891. noenh:  cmp.b #$1d,d5
  892.         beq spc
  893.         cmp.b #$8d,d5
  894.         beq cr
  895.         cmp.b #$20,d5
  896.         bcs out
  897. qout:   cmp.b #$fe,d5
  898.         beq defchr
  899.         move.l d5,d0
  900.         tst.b d0
  901.         bmi grprnt
  902.         cmp.b #$20,d0
  903.         blt qcode
  904.         cmp.b #$60,d0
  905.         blt code1
  906.         and.b #$df,d0
  907.         bra normal
  908. code1:  and.b #$3f,d0
  909.         bra normal
  910. grprnt: and.b #$7f,d0
  911.         cmp.b #$20,d0
  912.         blt qcode1
  913.         cmp.b #$7f,d0
  914.         bne nopi
  915.         moveq #$5e,d0
  916.         bra normal
  917. qcode1: or.b #$40,d0
  918. qcode:  or.b #$80,d0
  919.         bra normal
  920. nopi:   or.b #$40,d0
  921. normal: asl #3,d0
  922.         tst.b caseflg
  923.         beq nosml
  924.         add.l #2048,d0
  925. nosml:  lea prfont,a1
  926.         add.l d0,a1
  927.         bra nodef
  928. defchr: lea char,a1
  929. nodef:  moveq #7,d2
  930.         move.l pbufpnt(pc),a0
  931. setout: move.b (a1)+,d3
  932.         tst.b revflg
  933.         beq norev2
  934.         not.b d3
  935. norev2: move.b d3,(a0)+
  936.         tst.b expflg
  937.         beq noexp2
  938.         move.b d3,(a0)+
  939. noexp2: dbf d2,setout
  940.         move.l a0,pbufpnt
  941.         rts
  942.  
  943. crout:
  944.         cmp.l #prbuf,pbufpnt
  945.         beq out
  946.         lea grprt(pc),a1
  947. grout:  move.b (a1)+,d0
  948.         bmi grend
  949.         bsr prouta
  950.         bra grout
  951. grend:  move.l pbufpnt(pc),a1
  952.         sub.l #prbuf,a1
  953.         move a1,d0
  954.         bsr prouta
  955.         move a1,d0
  956.         lsr #8,d0
  957.         bsr prout
  958.         move a1,d2
  959.         subq #1,d2
  960.         lea prbuf,a1
  961.         move.l a1,pbufpnt
  962. eplop:  move.b (a1)+,d0
  963.         bsr prouta
  964.         dbf d2,eplop
  965.         bra out
  966.  
  967. sa3:
  968.         moveq #$43,d2
  969.         bra sa6_1
  970.  
  971. sa5:
  972.         cmp #$08,chrpnt
  973.         beq sa4
  974.         move chrpnt,d0
  975.         lea char,a0
  976.         move.b d5,(a0,d0)
  977.         addq #1,chrpnt
  978. sa4:    rts
  979.  
  980. sa6:
  981.         moveq #$41,d2
  982. sa6_1:  bsr esc
  983.         move d5,d0
  984.         bra prout
  985.  
  986. sa7:
  987.         st caseflg
  988. sa2:    rts
  989.  
  990. sa8:
  991.         clr.b caseflg
  992. sa9:    rts
  993.  
  994. sa10:
  995.         moveq #$40,d2
  996.  
  997. esc:
  998.         moveq #$1b,d0
  999.         bsr prout
  1000.         move d2,d0
  1001. prouta: and #$ff,d0        
  1002. prout:  move d0,-(sp)
  1003.         move #PROUT,-(sp)
  1004.         trap #GEMDOS
  1005.         addq.l #4,sp
  1006.         rts
  1007.  
  1008.  
  1009. com:    dc.b "VIDMUP&CRSNT"
  1010.  
  1011. adr:    dc.l validate,init,memory
  1012.         dc.l block,user,record,lbl
  1013.         dc.l copy,rename,scratch,new
  1014.         dc.l toggle
  1015.  
  1016. drv:    dc.b 8                          *letzter Drive
  1017.  
  1018. joker:  dc.b "*.*",0
  1019.  
  1020. format: dc.b $22," ST 2A",0
  1021.  
  1022. free:   dc.b "BLOCKS FREE.",0
  1023.  
  1024. compnt: dc.l file+3                     *Default für Floppy-Reset
  1025.  
  1026. msg0:   dc.b "00, OK",0
  1027. msg1:   dc.b "01, FILES SCRATCHED",0
  1028. msg2:   dc.b "30,SYNTAX ERROR",0
  1029. msg3:   dc.b "73,VC 1541 EMULATOR",0
  1030. msg4:   dc.b "63,FILE NOT FOUND",0
  1031. msg5:   dc.b "62,FILE EXISTS",0
  1032.  
  1033. pbufpnt:dc.l prbuf
  1034.  
  1035. grprt:  dc.b $1b,$2a,$04,$ff
  1036.  
  1037. bufadr: ds.l 1                  *aktuelle Bufferadresse
  1038.  
  1039. tpnt:   ds.l 1                  *aktueller Bufferpointer
  1040.  
  1041.  
  1042.         bss
  1043.  
  1044. track:  ds.b 1
  1045.  
  1046. sector: ds.b 1
  1047.  
  1048. filbuf: ds.b $1000*10           *File-Buffer
  1049.  
  1050. bufpnt: ds.l 10                 *Bufferpointer
  1051.  
  1052. fhandle:ds 10                   *File-Handles
  1053.  
  1054. fillen: ds 10                   *Blocklängen
  1055.  
  1056. filenr: ds.b 10                 *logische Filenummern
  1057.  
  1058. eofs:   ds.b 10                 *EOF-Flags
  1059.  
  1060. rwflgs: ds.b 10                 *Flags für Lesen/Schreiben
  1061.  
  1062. tlen:   ds 1                    *aktuelle Blocklänge
  1063.  
  1064. thand:  ds 1                    *aktuelles File-Handle
  1065.  
  1066. teof:   ds.b 1                  *aktuelles EOF-Flag
  1067.  
  1068. rwflg:  ds.b 1                  *Flag für Lesen/Schreiben
  1069.  
  1070. onr:    ds 1                    *aktuelle Nummer in Liste
  1071.  
  1072. dta:    ds.b 44
  1073.  
  1074. buffer: ds.l 4                  *für Berechnung der freien Blöcke
  1075.  
  1076. file:   ds.b 81                 *für Parameterübergabe
  1077.  
  1078. tmp:    ds.b 1
  1079.  
  1080. chrpnt: ds 1
  1081.  
  1082. prfont: ds.b 4096
  1083.  
  1084. prbuf:  ds.b 8*160
  1085.  
  1086. char:   ds.b 8
  1087.  
  1088. revflg: ds.b 1
  1089.  
  1090. caseflg:ds.b 1
  1091.  
  1092. expflg: ds.b 1
  1093.  
  1094. qflg:   ds.b 1
  1095.