home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff361.lzh / FileMaster / Source / Source238 < prev    next >
Text File  |  1990-08-11  |  160KB  |  8,481 lines

  1.  
  2. ; ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  3. ; ­­                                                                   ­­
  4. ; ­­                FILE MASTER V1.2 (1st April 1990)                  ­­
  5. ; ­­                                                                   ­­
  6. ; ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  7. ; ­­                                                                   ­­
  8. ; ­­                COPYRIGHT BY   :   ROGER FISCHLIN                  ­­
  9. ; ­­                                   STEIGERWALDWEG 6                ­­
  10. ; ­­                                   D-6450 HANAU 7                  ­­
  11. ; ­­                                   WEST GERMANY                    ­­
  12. ; ­­                                                                   ­­
  13. ; ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  14. ; ­­                                                                   ­­
  15. ; ­­          Assembler : DevPac Assembler V2  by HiSoft               ­­
  16. ; ­­          Linker    : BLINK by Software Distillery                 ­­
  17. ; ­­                                                                   ­­
  18. ; ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  19. ; ­­                                                                   ­­
  20. ; ­­ This file may be freely distributed as long as you don't gain any ­­
  21. ; ­­ profit and  this  file  must  remain  unchanged. FILE  MASTER  IS ­­
  22. ; ­­ SHAREWARE !!!!!!!!!!                                              ­­
  23. ; ­­                                                                   ­­
  24. ; ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  25.  
  26.  
  27.  
  28. ; some macros to save bytes (2 bytes)
  29.  
  30.  
  31. CALLGRAF_PC    macro
  32.     move.l    _GfxBase(pc),a6
  33.     jsr    _LVO\1(a6)
  34.     endm
  35. CALLDOS_PC    macro
  36.     move.l    _DOSBase(pc),a6
  37.     jsr    _LVO\1(a6)
  38.     endm
  39. CALLINT_PC    macro
  40.     move.l    _IntuitionBase(pc),a6
  41.     jsr    _LVO\1(a6)
  42.     endm
  43.  
  44.  
  45.  
  46.  
  47.  
  48. PrefSize equ     (8*2)+2+2+6
  49.  
  50. ;    Section    "Program",CODE_C
  51.  
  52.     incdir       "ram:include/","fh1:FileMaster/"
  53.  
  54.     include    intuition/intuition.i
  55.     include    intuition/intuition_lib.i
  56.             include     exec/memory.i
  57.     include    exec/exec_lib.i
  58.     include    exec/interrupts.i
  59.     include    exec/IO.i
  60.     include    exec/execbase.i
  61.     include    hardware/intbits.i
  62.     include    graphics/graphics_lib.i
  63.     include    graphics/text.i
  64.     include    libraries/dos_lib.i
  65.     include    libraries/dos.i
  66.     include    devices/inputevent.i
  67.     include    math/mathFFP_lib.i
  68.     include    workbench/startup.i
  69.  
  70.  
  71.  
  72.  
  73. FontFlag    set    0
  74.  
  75. SETAPEN    macro
  76.     move.l    WindowPointer,a1
  77.     move.l    wd_RPort(a1),a1    
  78.     moveq.l    \1,d0
  79.     CALLGRAF_PC    SetAPen
  80.     endm
  81.  
  82. SETBPEN    macro
  83.     move.l    WindowPointer,a1
  84.     move.l    wd_RPort(a1),a1    
  85.     moveq.l    \1,d0
  86.     CALLGRAF_PC    SetBPen
  87.     endm
  88. SETDRMD    macro
  89.      move.l    WindowPointer,a1
  90.     move.l    wd_RPort(a1),a1    
  91.     moveq.l    \1,d0
  92.     CALLGRAF_PC    SetDrMd
  93.     endm
  94. GOTOXY    macro
  95.      move.l    WindowPointer,a1
  96.     move.l    wd_RPort(a1),a1    
  97.     move.w    \1,d0
  98.     move.w    \2,d1
  99.     CALLGRAF_PC    Move
  100.     endm
  101.  
  102. RECTFILL    macro
  103.     move.l    WindowPointer,a1
  104.     move.l    wd_RPort(a1),a1    
  105.     move.w    \1,d0
  106.     move.w    \2,d1
  107.     move.w    \3,d2
  108.     move.w    \4,d3
  109.     CALLGRAF_PC    RectFill
  110.     endm
  111.  
  112. BORDER    macro
  113.     bra.s    MakeBox_\@
  114. MakeBox2_\@    BOX    \1,\2,\3,\4,\5,0
  115. MakeBox_\@    move.l    WindowPointer,a0
  116.     move.l    wd_RPort(a0),a0
  117.     lea.l    MakeBox2_\@(pc),a1
  118.     moveq.l    #0,d0
  119.     moveq.l    #0,d1
  120.     CALLINT_PC    DrawBorder
  121.     endm
  122.  
  123. WRITE    macro
  124.     move.l    WindowPointer,a1
  125.     move.l    wd_RPort(a1),a1
  126.     move.l    a1,a3    
  127.     move.w    \1,d0
  128.     move.w    \2,d1
  129.     CALLGRAF_PC    Move
  130.     move.l    a3,a1    
  131.     moveq.l    \3,d0
  132.     jsr    _LVOSetAPen(a6)
  133.     lea.l    .Write_Text\@(pc),a0
  134.     move.l    a3,a1
  135.     move.l    #.Write_Ende\@-.Write_Text\@,d0
  136.     jsr    _LVOText(a6)
  137.     bra.s    .Write_Label\@
  138. .Write_Text\@    dc.b    \4
  139. .Write_Ende\@    dc.b    0
  140.     even
  141. .Write_Label\@    nop
  142.     endm
  143. WRITEMEM    macro
  144.     move.l    WindowPointer,a1
  145.     move.l    wd_RPort(a1),a1
  146.     move.l    a1,a3    
  147.     move.w    \1,d0
  148.     move.w    \2,d1
  149.     CALLGRAF_PC    Move
  150.     move.l    a3,a1    
  151.     moveq.l    \3,d0
  152.     jsr    _LVOSetAPen(a6)
  153.     lea.l    \4,a0
  154.     move.l    a3,a1
  155.     move.l    \5,d0
  156.     jsr    _LVOText(a6)
  157.     endm
  158.  
  159.  
  160.  
  161. BOX    macro            ; macro to create a border structure
  162.     dc.w    0,0
  163.     dc.b    \5,0,RP_JAM1,5
  164.     dc.l    box_\@,\6
  165. box_\@    dc.w    \1,\2,\3,\2,\3,\4,\1,\4,\1,\2
  166.     endm
  167.  
  168. TEXT    macro            ; macro to create a text structure    
  169.     dc.b    2,0,RP_JAM1,0
  170.     dc.w    \1+1,\2+1
  171.     dc.l    TOPAZ_80,T_String\@,Text2_\@
  172. Text2_\@    dc.b    \3,0,RP_JAM1,0
  173.     dc.w    \1,\2
  174.     dc.l    TOPAZ_80,T_String\@,0
  175. T_String\@    dc.b    \4,0
  176.     even
  177.     IFEQ    FontFlag
  178.  
  179. TOPAZ_80    dc.l    T_80name
  180.     dc.w    TOPAZ_EIGHTY
  181.     dc.b    FS_NORMAL,FPF_ROMFONT
  182.     even
  183. T_80name    dc.b    "topaz.font",0
  184.  
  185. FontFlag    set    1
  186.     endc
  187.     endm
  188.  
  189. GTEXT    macro            ; macro to create a text structure    
  190.     dc.b    1,4,RP_JAM2,0
  191.     dc.w    \1,1
  192.     dc.l    TOPAZ_80,.T_String\@,0
  193. .T_String\@    dc.b    \2,0
  194.     even
  195.     endm
  196. GTEXT2    macro            ; macro to create a text structure    
  197.     dc.b    $e,4,RP_JAM2,0
  198.     dc.w    \1,1
  199.     dc.l    TOPAZ_80,.T_String\@,0
  200. .T_String\@    dc.b    \2,0
  201.     even
  202.     endm
  203.  
  204. GTEXT3    macro            ; macro to create a text structure    
  205.     dc.b    7,4,RP_JAM2,0
  206.     dc.w    \1,1
  207.     dc.l    TOPAZ_80,.T_String\@,0
  208. .T_String\@    dc.b    \2,0
  209.     even
  210.     endm
  211. TEXTR2    macro            ; macro to create a text structure    
  212.     dc.b    \4,4,RP_JAM1,0
  213.     dc.w    \1,\2
  214.     dc.l    TOPAZ_80,\3,0
  215.     even
  216.  
  217.     IFEQ    FontFlag
  218. TOPAZ_80    dc.l    T_80name
  219.     dc.w    TOPAZ_EIGHTY
  220.     dc.b    FS_NORMAL,FPF_ROMFONT
  221.     even
  222. T_80name    dc.b    "topaz.font",0
  223.  
  224. FontFlag    set    1
  225.     endc
  226.     endm
  227.  
  228.  
  229. StartUp    jsr    OpenThem        ; get libraries 
  230.  
  231.     sub.l    a1,a1    
  232.     CALLEXEC     FindTask
  233.     move.l    d0,a4
  234.     tst.l    pr_CLI(a4)
  235.     bne    FromCLI
  236.  
  237.     lea    pr_MsgPort(a4),a0
  238.     CALLEXEC     WaitPort        
  239.     lea    pr_MsgPort(a4),a0
  240.     CALLEXEC     GetMsg        
  241.     move.l    d0,WB_Message
  242.     
  243.     move.l    d0,a0
  244.     move.l    sm_ArgList(a0),a0
  245.     cmp.l    #0,a0
  246.     beq.s    Ende_Startup
  247.     move.l    (a0),d1        
  248.     CALLDOS    CurrentDir
  249.     
  250. Ende_Startup    jsr    FileMaster        ; main code
  251.     
  252.     CALLEXEC     Forbid        
  253.     move.l    WB_Message(pc),a1
  254.     CALLEXEC     ReplyMsg
  255.     moveq.l    #0,d0
  256.     rts
  257.  
  258. WB_Message    dc.l    0
  259.  
  260.  
  261. OpenThem    lea    dosname(pc),a1        ; open libs
  262.     
  263.     CALLEXEC     OldOpenLibrary
  264.     move.l    d0,_DOSBase
  265.     lea    intname(pc),a1                 
  266.     moveq.l    #0,d0        
  267.     CALLEXEC     OpenLibrary
  268.     move.l    d0,_IntuitionBase
  269.     lea    grafname(pc),a1
  270.     CALLEXEC     OldOpenLibrary
  271.     move.l    d0,_GfxBase
  272.     rts
  273.  
  274. dosname    DOSNAME
  275. grafname    GRAFNAME
  276. intname    INTNAME
  277.  
  278. FromCLI    lea.l    StartUp,a0
  279.     tst.l    -(a0)
  280.     move.l    (a0),d3
  281.     move.l    d3,Segment
  282.     clr.l    (a0)
  283.     move.l    #TaskName,d1
  284.     moveq.l    #0,d2
  285.     move.l    #5000,d4
  286.     CALLDOS    CreateProc
  287.     moveq.l    #0,d0
  288.     rts
  289.  
  290.  
  291. ;     MAIN PROGRAM
  292.  
  293.     Section    "PRG",CODE
  294.  
  295. FileMaster    bsr.s    Start
  296.     CALLEXEC    Disable
  297.     move.l    Segment,d1
  298.     CALLDOS    UnLoadSeg
  299.     move.l    _DOSBase(pc),a1
  300.     CALLEXEC    CloseLibrary
  301.     move.l    _GfxBase(pc),a1
  302.     CALLEXEC    CloseLibrary
  303.     move.l    _IntuitionBase(pc),a1
  304.     CALLEXEC    CloseLibrary
  305.     moveq.l    #0,d0
  306.     rts    
  307.  
  308. Segment    dc.l    0
  309. OldWindow    dc.l    0
  310. Window1    dc.l    0
  311. Window2    dc.l    0
  312. TaskName    dc.b    "FileMaster.Task",0
  313.     even
  314.  
  315. FontFlag    set    1
  316.  
  317. Start    lea.l    FONT_PAL1,a0        ; prepare FONTs
  318.     move.l    a0,d0
  319.     add.l    #$34,d0
  320.     move.l    d0,tf_CharData(a0)
  321.     add.l    #($96716-$9620e),d0
  322.     move.l    d0,tf_CharLoc(a0)
  323.  
  324.     lea.l    FONT_NTSC1,a0        
  325.     move.l    a0,d0
  326.     add.l    #$34,d0
  327.     move.l    d0,tf_CharData(a0)
  328.     move.l    tf_CharLoc(a0),d0
  329.     sub.l    #$c4dff2,d0
  330.     add.l    #FONT_NTSC1,d0
  331.     move.l    d0,tf_CharLoc(a0)
  332.  
  333.  
  334.  
  335.     jsr    PAL_NTSC        ; prepare for TV mode (PAL or NTSC)
  336.  
  337.     clr.l    Memory        ; reset all 
  338.     clr.l    AnzahlBytes
  339.     clr.l    Cursor
  340.     clr.l    Size
  341.     clr.l    Filehandle
  342.     clr.l    AnzahlBytes
  343.     clr.b    FlagFile
  344.     clr.b    FlagWrite
  345.     clr.l    SearchPos
  346.     clr.b    CompPuffer
  347.     clr.l    SearchLength
  348.     move.l    #1,SearchMode
  349.     
  350.     lea.l    TOPAZ_80(pc),a0    ; opnen TOPAZ 80
  351.     CALLGRAF_PC    OpenFont
  352.     move.l    d0,FONT80
  353.  
  354.     jsr    GetPrefs            ; get saved (?) preferences
  355.     jsr    Hardcopy_Gadgets    
  356.     lea.l    M1_I6_String+12(pc),a0
  357.     move.b    DriveName+2,(a0)
  358.     move.b    Joker,JoString+12        ; copy joker to menu
  359.  
  360.     lea.l    Screendef(pc),a0        ; open screen
  361.     CALLINT_PC    OpenScreen
  362.     tst.l    d0
  363.     beq    QUIT1
  364.     move.l    d0,ScreenPtr1
  365.  
  366.  
  367.     lea.l    Windowdef1(pc),a0        ; open window    
  368.     CALLINT_PC    OpenWindow
  369.     tst.l    d0
  370.     beq    QUIT2
  371.     move.l    d0,Window1
  372.  
  373.     move.l    d0,a0        ; set colours
  374.     CALLINT_PC    ViewPortAddress
  375.     move.l    d0,a0
  376.     move.w    #16,d0
  377.     lea.l    Palette,a1
  378.     CALLGRAF_PC    LoadRGB4
  379.     CALLINT_PC    RemakeDisplay
  380.  
  381.  
  382.     sub.l    a1,a1        ; DOS requester should appear in FileMaster's window
  383.     CALLEXEC    FindTask
  384.     move.l    d0,a0
  385.     move.l    pr_WindowPtr(a0),OldWindow
  386.     move.l    Window1(pc),pr_WindowPtr(a0)
  387.  
  388.     move.b    WriteMode,d0        ; set marks
  389.     bset.b    #0,M1_I3_Sub1+mi_Flags
  390.     bset.b    #0,M1_I3_Sub2+mi_Flags
  391.     bset.b    #0,M1_I3_Sub3+mi_Flags
  392.     tst.b    d0
  393.     beq.s    .Q1
  394.     bclr.b    #0,M1_I3_Sub1+mi_Flags
  395. .Q1    cmp.b    #1,d0
  396.     beq.s    .Q2
  397.     bclr.b    #0,M1_I3_Sub2+mi_Flags
  398. .Q2    cmp.b    #2,d0
  399.     beq.s    .Q3
  400.     bclr.b    #0,M1_I3_Sub3+mi_Flags
  401. .Q3    
  402.     
  403.  
  404.     move.l    Window1(pc),a0        ; use menus
  405.     lea.l    Menue1(pc),a1
  406.     CALLINT_PC    SetMenuStrip
  407.  
  408.     jsr    OpenCon        ; open console.device
  409.     tst.l    d0
  410.     bne    QUIT3
  411.  
  412.     move.l    ScreenPtr1(pc),a0
  413.     CALLINT_PC    ScreenToFront
  414.  
  415. * create screen
  416.  
  417.     moveq.w    #0,d6        ; File name
  418.     move.w    #11,d7
  419.     move.w    #((32+1+7)*8)+8,d4
  420.     move.w    #11+14,d5
  421.     bsr    Areas
  422.     
  423.     move.w    #(32+1+7)*8+8,d6        ; Sector
  424.     move.w    #11,d7
  425.     move.w    #((32+2+7+16+2)*8)+12,d4
  426.     move.w    #11+14,d5
  427.     bsr    Areas
  428.     
  429.     moveq.w    #0,d6        ; Hex    
  430.     move.w    #11+14,d7
  431.     move.w    #(32+1+7)*8+8,d4
  432.     move.w    Screendef+ns_Height,d5
  433.     bsr    Areas
  434.     
  435.     move.w    #(32+1+7)*8+8,d6    ; ASC
  436.     move.w    #11+14,d7
  437.     move.w    #(32+2+7+16+2)*8+12,d4
  438.     move.w    Screendef+ns_Height,d5
  439.     bsr    Areas
  440.  
  441.  
  442.     move.w    #472+12,d6        ; ABOUT
  443.     move.w    #11,d7
  444.     move.w    #472+84+6,d4
  445.     move.w    #11+29,d5
  446.     bsr    Areas
  447.     
  448.     move.w    #472+84+6,d6        ; QUIT
  449.     move.w    #11,d7
  450.     move.w    #472+84+84,d4
  451.     move.w    #11+29,d5
  452.     bsr    Areas
  453.     
  454.     
  455.     move.w    #472+12,d6        ; PROJECT
  456.     move.w    #11+29,d7
  457.     move.w    #472+168,d4
  458.     move.w    #11+69,d5
  459.     bsr    Areas
  460.  
  461.     move.w    #472+12,d6        ; Forward & Backward
  462.     move.w    #11+69,d7
  463.     move.w    #472+168,d4
  464.     move.w    #11+89,d5
  465.     bsr    Areas
  466.  
  467.     move.w    #472+12,d6        ; Write & Undo
  468.     move.w    #11+89,d7
  469.     move.w    #472+168,d4
  470.     move.w    #11+109,d5
  471.     bsr    Areas
  472.  
  473.     move.w    #472+12,d6        ; Search
  474.     move.w    #11+109,d7
  475.     move.w    #472+168,d4
  476.     move.w    #11+149,d5
  477.     bsr    Areas
  478.  
  479.  
  480.     move.w    #472+12,d6        ; Cursor
  481.     move.w    #11+149,d7
  482.     move.w    #472+84+6,d4
  483.     move.w    #11+179,d5
  484.     bsr    Areas
  485.     
  486.     move.w    #472+84+6,d6        ; Mode
  487.     move.w    #11+149,d7
  488.     move.w    #472+84+84,d4
  489.     move.w    #11+179,d5
  490.     bsr    Areas
  491.  
  492.     move.w    #472+12,d6        ; Space
  493.     move.w    #11+179,d7
  494.     move.w    #472+168,d4
  495.     move.w    Screendef+ns_Height,d5
  496.     bsr    Areas
  497.  
  498.  
  499.     move.l    Window1(pc),a1        ; redraw gadget
  500.     move.l    wd_FirstGadget(a1),a0
  501.     sub.l    a2,a2
  502.     CALLINT_PC    RefreshGadgets
  503.     
  504.     jsr    PrintMode
  505.     jsr    INFO
  506.  
  507.  
  508. WindowPointer set Window1        
  509.  
  510. NewFile    clr.l    Offset
  511.     tst.b    FlagFile
  512.     bne    .L1
  513.     
  514.     moveq.w    #0,d6        ; Clear Screen if no file was opened
  515.     move.w    #11,d7
  516.     move.w    #(32+1+7)*8+8,d4
  517.     move.w    #11+14,d5
  518.     bsr    Areas
  519.     
  520.     move.w    #(32+1+7)*8+8,d6    ; Sector
  521.     move.w    #11,d7
  522.     move.w    #(32+2+7+16+2)*8+12,d4
  523.     move.w    #11+14,d5
  524.     bsr    Areas
  525.     
  526.     moveq.w    #0,d6        ; Hex    
  527.     move.w    #11+14,d7
  528.     move.w    #(32+1+7)*8+8,d4
  529.     move.w    Screendef+ns_Height,d5
  530.     bsr    Areas
  531.     
  532.     move.w    #(32+1+7)*8+8,d6    ; ASC
  533.     move.w    #11+14,d7
  534.     move.w    #(32+2+7+16+2)*8+12,d4
  535.     move.w    Screendef+ns_Height,d5
  536.     bsr    Areas
  537.  
  538.     move.w    #472+12,d6        ; Cursor
  539.     move.w    #11+149,d7
  540.     move.w    #472+84+6,d4
  541.     move.w    #11+179,d5
  542.     bsr    Areas
  543.     bra    NewMode
  544.  
  545. .L1    move.l    WindowPointer(pc),a1
  546.     move.l    wd_RPort(a1),a1    
  547.     move.l    FONT80(pc),a0
  548.     CALLGRAF_PC    SetFont
  549.     SETDRMD    #RP_JAM2
  550.     SETBPEN    #2
  551.     WRITEMEM    #10,#11+3+6,#1,FileName,#37
  552.     tst.l    Size
  553.     beq.s    NewMode
  554.     moveq.l    #0,d0
  555.     bra    GetBlock    
  556.  
  557. NewBlock    bsr    SectorNumber
  558.     tst.l    AnzahlBytes
  559.     beq.s    NewMode
  560.     bsr    ShowPuffer
  561.     lea.l    Color,a0
  562.     move.w    #511,d0
  563. .L1    move.b    #3,(a0)+
  564.     dbra    d0,.L1
  565.  
  566.     move.l    #1,Cursor
  567.     moveq.l    #0,d0
  568.     bsr    SetCursor
  569. NewPos    bsr    PrintPosition
  570.     and.b    #1,Mode        ; if HEX mode -> 1.Nibble
  571.  
  572. NewMode    bsr    PrintMode
  573.  
  574.     move.l    WindowPointer(pc),a1    ; use TOPAZ 80
  575.     move.l    wd_RPort(a1),a1    
  576.     move.l    FONT80(pc),a0
  577.     CALLGRAF_PC    SetFont
  578.     SETDRMD    #RP_JAM1
  579.     
  580.  
  581. wait    move.l    Window1(pc),a0        ; wait .....
  582.     move.l    wd_UserPort(a0),a0
  583.     move.l    a0,a5
  584.     CALLEXEC    WaitPort        
  585.     move.l    a5,a0
  586.     CALLEXEC    GetMsg        ; get message
  587.     move.l    d0,a1    
  588.     move.l    im_Class(a1),d4    ; get data
  589.     move.w    im_Code(a1),d5
  590.     move.w    im_Qualifier(a1),d3
  591.     move.l    im_IAddress(a1),a4
  592.     moveq.l    #0,d6
  593.     moveq.l    #0,d7
  594.     move.w    im_MouseX(a1),d6
  595.     move.w    im_MouseY(a1),d7
  596.     CALLEXEC     ReplyMsg        ; reply message
  597.     
  598.     moveq.l    #0,d0        
  599.     move.b    gg_GadgetID+1(a4),d0    ; get gadget ID
  600.  
  601.     cmp.l    #RAWKEY,d4
  602.     beq    KeyPressed
  603.     
  604.     cmp.l    #GADGETUP,d4
  605.     beq    GADGET
  606.     cmp.l    #GADGETDOWN,d4
  607.     beq    GADGET
  608.     cmp.l    #MENUPICK,d4
  609.     beq.s    MENU
  610.     
  611.  
  612. Error    move.l    ScreenPtr1(pc),a0
  613.     CALLINT_PC    DisplayBeep
  614.     bra    wait
  615.  
  616. MENU    cmp.w    #MENUNULL,d5        ; check if an item was selected ?
  617.     beq    wait
  618.     move.l    d5,d0
  619.     and.l    #$1f,d0
  620.     cmp.b    #3,d0
  621.     beq    GOTO_menu
  622.     cmp.b    #2,d0
  623.     beq    PROJECT_menu
  624.     cmp.b    #1,d0
  625.     beq    DISPLAY_menu
  626.     tst.b    d0
  627.     bne    wait
  628.     move.l    d5,d0
  629.     lsr.l    #5,d0
  630.     and.l    #$1f,d0
  631.     lsl.l    #2,d0
  632.     add.l    #Menu0Table,d0
  633.     move.l    d0,a0
  634.     move.l    (a0),a0
  635.     move.l    d5,d0        ; d0 contains sub item
  636.     lsr.l    #8,d0
  637.     lsr.l    #3,d0
  638.     and.l    #$1f,d0
  639.     jmp    (a0)
  640. Menu0Table    dc.l    COLOUR,NewJoker,ChangeWrite,SavePrefs,DefaultPrefs,DRIVE
  641.  
  642. GOTO_menu    move.l    d5,d0        ; goto-menu
  643.     lsr.l    #5,d0
  644.     and.l    #$1f,d0
  645.     tst.b    d0
  646.     beq.s    .L1
  647.     cmp.b    #1,d0
  648.     beq.s    .L2
  649.     bra    BLOCK
  650. .L1    jmp    FIRSTBLOCK
  651. .L2    jmp    LASTBLOCK
  652.  
  653. DISPLAY_menu    move.l    d5,d0        ; display-menu
  654.     lsr.l    #5,d0
  655.     and.l    #$1f,d0
  656.     jmp    ChangeDisplay    
  657.  
  658. PROJECT_menu    move.l    d5,d0        ; project-menu
  659.     lsr.l    #5,d0
  660.     and.l    #$1f,d0
  661.     tst.b    d0
  662.     beq.s    .W1
  663.     cmp.b    #1,d0
  664.     beq.s    .W2
  665.     cmp.b    #2,d0
  666.     beq.s    .W3
  667.     cmp.b    #3,d0
  668.     beq.s    .W4
  669.     cmp.b    #4,d0
  670.     beq.s    .W5
  671.     bra    wait
  672. .W1    jmp    NEWSHELL
  673. .W2    jmp    MEMORY
  674. .W3    jmp    WORKBENCH
  675. .W4    jmp    PRINT
  676. .W5    jmp    CONVERTER
  677.     
  678.  
  679. GADGET    lsl.l    #2,d0    ; get address from table
  680.     add.l    #Vektoren,d0
  681.     move.l    d0,a0
  682.     move.l    (a0),a0
  683.     jmp    (a0)
  684. Vektoren    dc.l    OPEN,SAVE,SIZE,PREVIOUS,EXECUTE,FORWARD,BACKWARD,WRITE,UNDO,SEARCH
  685.     dc.l    wait,ABOUT,QUIT,ChangeMode,HEX_Gadget,ASC_Gadget,BLOCK,NEXT,wait
  686.     
  687. QUIT    bsr    WriteQuestion
  688.     bsr    SaveQuestion
  689.     bsr    LEAVE        ; ask
  690.     tst.l    d0
  691.     bne    wait
  692.     move.l    Memory,a1        ; free memory if allocated
  693.     cmp.l    #0,a1
  694.     beq    .CloseFile
  695.     move.l    Size,d0
  696.     CALLEXEC    FreeMem
  697.     bra.s    .L1
  698. .CloseFile    move.l    Filehandle,d1        ; close file if opened
  699.     CALLDOS_PC    Close
  700. .L1    bsr    CloseCon
  701.     move.l    Window1(pc),a0
  702.     CALLINT_PC    ClearMenuStrip
  703.     
  704.     sub.l    a1,a1
  705.     CALLEXEC    FindTask
  706.     move.l    d0,a0
  707.     move.l    OldWindow(pc),pr_WindowPtr(a0)
  708.     move.l    Window1(pc),a0        ; bye, bye !
  709.     CALLINT_PC    CloseWindow
  710.     move.l    ScreenPtr1(pc),a0
  711.     CALLINT_PC    CloseScreen
  712.  
  713. NoDev    moveq.l    #0,d0
  714.     rts
  715.  
  716.  
  717. TOPAZ_80    dc.l    T_80name
  718.     dc.w    TOPAZ_EIGHTY
  719.     dc.b    FS_NORMAL,FPF_ROMFONT
  720.     even
  721. T_80name    dc.b    "topaz.font",0
  722.     even
  723. FONT80    dc.l    0
  724.  
  725.  
  726. Screendef    dc.w    0,0,640,256,3
  727.     dc.b    0,1
  728.     dc.w    V_HIRES    
  729.     dc.w    CUSTOMSCREEN!SCREENBEHIND
  730.     dc.l    TOPAZ_80
  731.     dc.l    .S_Title,0,0
  732.     
  733.     even
  734. .S_Title    dc.b    "RF-Tools : File Master   V1.2 © Roger Fischlin April/1990            ",0
  735.     even
  736.  
  737.  
  738. Windowdef1    dc.w    0,0,640,256
  739.     dc.b    7,1
  740.     dc.l    GADGETUP!RAWKEY!GADGETDOWN!MENUPICK
  741.     dc.l    ACTIVATE!SMART_REFRESH!BACKDROP!SMART_REFRESH!BORDERLESS
  742.     dc.l    W1_G1
  743.     dc.l    0
  744.     dc.l    0
  745. ScreenPtr1    dc.l    0,0
  746.     dc.w    0,0,0,0,CUSTOMSCREEN
  747.  
  748. FM_GADGET    macro
  749.     dc.l    \1
  750.     dc.w    \2,\3,\4,12
  751.     dc.w    GADGHNONE!GADGIMAGE
  752.     dc.w    RELVERIFY
  753.     dc.w    BOOLGADGET
  754.     dc.l    .Image,0
  755.     dc.l    .Text
  756.     dc.l    0,0
  757.     dc.w    \5
  758.     dc.l    0
  759. .Text    dc.b    0,0,RP_JAM1,0
  760.     dc.w    (\4-((.S2-.S1-1)*8))/2,((12-8)/2)+1
  761.     dc.l    TOPAZ_80,.S1,.Text2
  762. .S1    dc.b    \6,0
  763. .S2
  764.     even
  765. .Text2    dc.b    \7,0,RP_JAM1,0
  766.     dc.w    (\4-((.S2-.S1-1)*8))/2,(12-8)/2
  767.     dc.l    TOPAZ_80,.S1,0
  768. .Image    dc.w    0,0,\4,12,3
  769.     dc.l    0
  770.     dc.b    0,0
  771.     dc.l    .Image2
  772. .Image2    dc.w    2,1,\4-4,12-2,3
  773.     dc.l    0
  774.     dc.b    0,\8
  775.     dc.l    0
  776.     endm
  777.  
  778. *
  779. * Gadgets
  780. *
  781.  
  782. W1_G1    FM_GADGET    W1_G2,484+6,(11+29)+5,70,0,<"Open">,1,4
  783. W1_G2    FM_GADGET    W1_G3,484+6+3+72,(11+29)+5,70,1,<"Save As">,1,4
  784. W1_G3    FM_GADGET    W1_G4,484+6,(11+29)+5+14+4,70,2,<"Size">,1,4
  785. W1_G4    FM_GADGET    W1_G6,484+6+3+72,(11+29)+5+14+4,70,4,<"Execute">,1,4
  786. W1_G6    FM_GADGET    W1_G7,484+6,(11+69)+4,70,5,<"Forward">,1,7
  787. W1_G7    FM_GADGET    W1_G8,484+6+4+72,(11+69)+4,70,6,<"Backward">,1,7
  788. W1_G8    FM_GADGET    W1_G9,484+6,(11+89)+4,70,7,<"Write">,1,7
  789. W1_G9    FM_GADGET    W1_G10,484+6+3+72,(11+89)+4,70,8,<"Undo">,1,7
  790. W1_G10    FM_GADGET    W1_G11,484+6,(11+109)+5,72+3+70,9,<"Search">,1,7
  791. W1_G11    FM_GADGET    W1_G18,484+6,(11+109)+5+14+4,70,3,<"Previous">,1,7
  792. W1_G18    FM_GADGET    W1_G12,484+6+3+72,(11+109)+4+14+5,70,17,<"Next">,1,7
  793. W1_G12    FM_GADGET    W1_G13,484+9,(11+9),60,11,<"About">,1,4
  794. W1_G13    FM_GADGET    W1_G14,484+78+9,(11+9),60,12,<"Quit">,1,4
  795.  
  796. W1_G14    dc.l    W1_G15        ; mode gadget
  797.     dc.w    472+84+6,11+149,84-6,30
  798.     dc.w    GADGHNONE
  799.     dc.w    GADGIMMEDIATE
  800.     dc.w    BOOLGADGET
  801.     dc.l    0,0
  802.     dc.l    0
  803.     dc.l    0,0
  804.     dc.w    13
  805.     dc.l    0
  806. W1_G15    dc.l    W1_G16        ; HEX gadget
  807.     dc.w    0,11+14,8*(32+1+7)+8,256
  808.     dc.w    GADGHNONE
  809.     dc.w    GADGIMMEDIATE
  810.     dc.w    BOOLGADGET
  811.     dc.l    0,0
  812.     dc.l    0
  813.     dc.l    0,0
  814.     dc.w    14
  815.     dc.l    0
  816. W1_G16    dc.l    W1_G17        ; ASC gadget
  817.     dc.w    8*(32+1+7)+8,11+14,8*(32+2+7+16+2-(32+1+7))+12,256
  818.     dc.w    GADGHNONE
  819.     dc.w    GADGIMMEDIATE
  820.     dc.w    BOOLGADGET
  821.     dc.l    0,0
  822.     dc.l    0
  823.     dc.l    0,0
  824.     dc.w    15
  825.     dc.l    0
  826. W1_G17    dc.l    0        ; sector gadget
  827.     dc.w    8*(32+1+7)+8,11,8*(32+2+7+16+2-(32+1+7)),+14
  828.     dc.w    GADGHNONE
  829.     dc.w    GADGIMMEDIATE
  830.     dc.w    BOOLGADGET
  831.     dc.l    0,0
  832.     dc.l    0
  833.     dc.l    0,0
  834.     dc.w    16
  835.     dc.l    0
  836.  
  837.  
  838.  
  839.  
  840.  
  841. Menue1    dc.l    Menue2
  842.     dc.w    10,0,15*8,10,MENUENABLED
  843.     dc.l    .MenueName
  844.     dc.l    M1_Item1,0,0
  845. .MenueName    dc.b    "Preferences",0
  846.     even
  847. M1_Item1    dc.l    M1_Item2    
  848.     dc.w    0,0,21*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  849.     dc.l    0,.Text,0
  850.     dc.b    "p",0
  851.     dc.l    0,0
  852. .Text    dc.b    4,0,RP_JAM1,0
  853.     dc.w    4,2
  854.     dc.l    0,.String,0
  855. .String    dc.b    "Palette",0
  856. M1_Item2    dc.l    M1_Item3    
  857.     dc.w    0,11,21*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  858.     dc.l    0,.Text,0
  859.     dc.b    "j",0
  860.     dc.l    0,0
  861. .Text    dc.b    4,0,RP_JAM1,0
  862.     dc.w    4,2
  863.     dc.l    0,JoString,0
  864. JoString    dc.b    "Set joker : ?",0
  865. M1_Item3    dc.l    M1_Item4
  866.     dc.w    0,22,21*8,11,ITEMTEXT!HIGHCOMP!ITEMENABLED
  867.     dc.l    0,.Text,0
  868.     dc.b    0,0
  869.     dc.l    M1_I3_Sub1,0
  870. .Text    dc.b    4,0,RP_JAM1,0
  871.     dc.w    4,2
  872.     dc.l    0,.String,0
  873. .String    dc.b    "Write mode",0
  874. M1_Item4    dc.l    M1_Item5
  875.     dc.w    0,33,21*8,11,ITEMTEXT!HIGHCOMP!ITEMENABLED
  876.     dc.l    0,.Text,0
  877.     dc.b    0,0
  878.     dc.l    M1_I4_Sub1,0
  879. .Text    dc.b    4,0,RP_JAM1,0
  880.     dc.w    4,2
  881.     dc.l    0,.String,0
  882. .String    dc.b    "Save prefs",0
  883. M1_Item5    dc.l    M1_Item6
  884.     dc.w    0,44,21*8,11,ITEMTEXT!HIGHCOMP!ITEMENABLED!COMMSEQ
  885.     dc.l    0,.Text,0
  886.     dc.b    "d",0
  887.     dc.l    0,0
  888. .Text    dc.b    4,0,RP_JAM1,0
  889.     dc.w    4,2
  890.     dc.l    0,.String,0
  891. .String    dc.b    "Default prefs",0
  892. M1_Item6    dc.l    0
  893.     dc.w    0,55,21*8,11,ITEMTEXT!HIGHCOMP!ITEMENABLED
  894.     dc.l    0,.Text,0
  895.     dc.b    0,0
  896.     dc.l    0,0
  897. .Text    dc.b    4,0,RP_JAM1,0
  898.     dc.w    4,2
  899.     dc.l    0,M1_I6_String,0
  900. M1_I6_String    dc.b    "2nd drive df1:",0
  901.  
  902.  
  903. M1_I3_Sub1    dc.l    M1_I3_Sub2
  904.     dc.w    12*8,0,29*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED!CHECKIT
  905.     dc.l    0,.Text,0
  906.     dc.b    "a",0
  907.     dc.l    0,0
  908. .Text    dc.b    4,0,RP_JAM1,0
  909.     dc.w    24,2
  910.     dc.l    0,.String,0
  911. .String    dc.b    "Ask",0
  912. M1_I3_Sub2    dc.l    M1_I3_Sub3
  913.     dc.w    12*8,11,29*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED!CHECKIT
  914.     dc.l    0,.Text,0
  915.     dc.b    "w",0
  916.     dc.l    0,0
  917. .Text    dc.b    4,0,RP_JAM1,0
  918.     dc.w    24,2
  919.     dc.l    0,.String,0
  920. .String    dc.b    "Write without asking",0
  921. M1_I3_Sub3    dc.l    0
  922.     dc.w    12*8,22,29*8,11,ITEMTEXT!HIGHCOMP!ITEMENABLED!COMMSEQ!CHECKIT
  923.     dc.l    0,.Text,0
  924.     dc.b    "n",0
  925.     dc.l    0,0
  926. .Text    dc.b    4,0,RP_JAM1,0
  927.     dc.w    24,2
  928.     dc.l    0,.String,0
  929. .String    dc.b    "Do not write",0
  930.  
  931.  
  932. M1_I4_Sub1    dc.l    M1_I4_Sub2
  933.     dc.w    12*8,0,20*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  934.     dc.l    0,.Text,0
  935.     dc.b    "s",0
  936.     dc.l    0,0
  937. .Text    dc.b    4,0,RP_JAM1,0
  938.     dc.w    4,2
  939.     dc.l    0,.String,0
  940. .String    dc.b    "to current dir",0
  941. M1_I4_Sub2    dc.l    0
  942.     dc.w    12*8,11,20*8,11,ITEMTEXT!HIGHCOMP!ITEMENABLED
  943.     dc.l    0,.Text,0
  944.     dc.b    "w",0
  945.     dc.l    0,0
  946. .Text    dc.b    4,0,RP_JAM1,0
  947.     dc.w    4,2
  948.     dc.l    0,.String,0
  949. .String    dc.b    "to DEVS:",0
  950.  
  951.  
  952.  
  953. Menue2    dc.l    Menue3
  954.     dc.w    160,0,10*8,10,MENUENABLED
  955.     dc.l    .MenueName
  956.     dc.l    M2_Item1,0,0
  957. .MenueName    dc.b    "Display",0
  958.     even
  959. M2_Item1    dc.l    M2_Item2    
  960.     dc.w    0,0,24*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED!CHECKIT!CHECKED
  961.     dc.l    2+4,.Text,0
  962.     dc.b    "1",0
  963.     dc.l    0,0
  964. .Text    dc.b    4,0,RP_JAM1,0
  965.     dc.w    24,2
  966.     dc.l    0,.String,0
  967. .String    dc.b    "all",0
  968. M2_Item2    dc.l    M2_Item3    
  969.     dc.w    0,11,24*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED!CHECKIT
  970.     dc.l    1+4,.Text,0
  971.     dc.b    "2",0
  972.     dc.l    0,0
  973. .Text    dc.b    4,0,RP_JAM1,0
  974.     dc.w    24,2
  975.     dc.l    0,.String,0
  976. .String    dc.b    "only characters",0
  977. M2_Item3    dc.l    0
  978.     dc.w    0,22,24*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED!CHECKIT
  979.     dc.l    1+2,.Text,0
  980.     dc.b    "3",0
  981.     dc.l    0,0
  982. .Text    dc.b    4,0,RP_JAM1,0
  983.     dc.w    24,2
  984.     dc.l    0,.String,0
  985. .String    dc.b    "only 32-125",0
  986.  
  987. Menue3    dc.l    Menue4
  988.     dc.w    270,0,10*8,10,MENUENABLED
  989.     dc.l    .MenueName
  990.     dc.l    M3_Item1,0,0
  991. .MenueName    dc.b    "Projects",0
  992.     even
  993. M3_Item1    dc.l    M3_Item2    
  994.     dc.w    0,0,17*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  995.     dc.l    2+4,.Text,0
  996.     dc.b    "i",0
  997.     dc.l    0,0
  998. .Text    dc.b    4,0,RP_JAM1,0
  999.     dc.w    4,2
  1000.     dc.l    0,.String,0
  1001. .String    dc.b    "CLI/Shell",0
  1002.     even
  1003. M3_Item2    dc.l    M3_Item2b
  1004.     dc.w    0,11,17*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  1005.     dc.l    1+4,.Text,0
  1006.     dc.b    "m",0
  1007.     dc.l    0,0
  1008. .Text    dc.b    4,0,RP_JAM1,0
  1009.     dc.w    4,2
  1010.     dc.l    0,.String,0
  1011. .String    dc.b    "Memory",0
  1012.     even
  1013. M3_Item2b    dc.l    M3_Item3
  1014.     dc.w    0,22,17*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  1015.     dc.l    1+4,.Text,0
  1016.     dc.b    "o",0
  1017.     dc.l    0,0
  1018. .Text    dc.b    4,0,RP_JAM1,0
  1019.     dc.w    4,2
  1020.     dc.l    0,.String,0
  1021. .String    dc.b    "Workbench",0
  1022.     even
  1023.  
  1024. M3_Item3    dc.l    M3_Item4
  1025.     dc.w    0,33+6,17*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  1026.     dc.l    1+2,.Text,0
  1027.     dc.b    "h",0
  1028.     dc.l    0,0
  1029. .Text    dc.b    4,0,RP_JAM1,0
  1030.     dc.w    4,2
  1031.     dc.l    0,.String,.Text2
  1032. .String    dc.b    "Hardcopy",0
  1033.     even
  1034. .Text2    dc.b    2,0,RP_JAM1,0
  1035.     dc.w    4,2-8
  1036.     dc.l    0,.String2,0
  1037. .String2    dc.b    "----------------",0
  1038.     even
  1039. M3_Item4    dc.l    M3_Item5
  1040.     dc.w    0,44+6,17*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  1041.     dc.l    1+2,.Text,0
  1042.     dc.b    "c",0
  1043.     dc.l    0,0
  1044. .Text    dc.b    4,0,RP_JAM1,0
  1045.     dc.w    4,2
  1046.     dc.l    0,.String,0
  1047. .String    dc.b    "Converter",0
  1048.     even
  1049. M3_Item5    dc.l    0
  1050.     dc.w    0,55+6,17*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP
  1051.     dc.l    1+2,.Text,0
  1052.     dc.b    "e",0
  1053.     dc.l    0,0
  1054. .Text    dc.b    4,0,RP_JAM1,0
  1055.     dc.w    4,2
  1056.     dc.l    0,.String,0
  1057. .String    dc.b    "Disassemble",0
  1058.     even
  1059.  
  1060. Menue4    dc.l    0
  1061.     dc.w    410,0,7*8,10,MENUENABLED
  1062.     dc.l    .MenueName
  1063.     dc.l    M4_Item1,0,0
  1064. .MenueName    dc.b    "Go to",0
  1065.     even
  1066. M4_Item1    dc.l    M4_Item2    
  1067.     dc.w    0,0,18*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  1068.     dc.l    2+4,.Text,0
  1069.     dc.b    "f",0
  1070.     dc.l    0,0
  1071. .Text    dc.b    4,0,RP_JAM1,0
  1072.     dc.w    4,2
  1073.     dc.l    0,.String,0
  1074. .String    dc.b    "First sector",0
  1075. M4_Item2    dc.l    M4_Item3
  1076.     dc.w    0,11,18*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  1077.     dc.l    1+4,.Text,0
  1078.     dc.b    "l",0
  1079.     dc.l    0,0
  1080. .Text    dc.b    4,0,RP_JAM1,0
  1081.     dc.w    4,2
  1082.     dc.l    0,.String,0
  1083. .String    dc.b    "Last sector",0
  1084. M4_Item3    dc.l    0
  1085.     dc.w    0,22,18*8,11,ITEMTEXT!COMMSEQ!HIGHCOMP!ITEMENABLED
  1086.     dc.l    1+4,.Text,0
  1087.     dc.b    "x",0
  1088.     dc.l    0,0
  1089. .Text    dc.b    4,0,RP_JAM1,0
  1090.     dc.w    4,2
  1091.     dc.l    0,.String,0
  1092. .String    dc.b    "sector",0
  1093.  
  1094.  
  1095. Cursor    dc.l    0
  1096. Memory    dc.l    0
  1097. Filehandle    dc.l    0
  1098. Size    dc.l    0
  1099. Offset    dc.l    0    
  1100.  
  1101.  
  1102. QUIT3    move.l    Window1(pc),a0
  1103.     CALLINT_PC    ClearMenuStrip
  1104.     move.l    Window1(pc),a0        
  1105.     CALLINT_PC    CloseWindow
  1106.  
  1107. QUIT2    move.l    ScreenPtr1(pc),a0
  1108.     CALLINT_PC    CloseScreen
  1109.  
  1110. QUIT1    move.l    #RECOVERY_ALERT,d0    ; error message
  1111.     move.w    #30,d1
  1112.     lea.l    ErrorText(pc),a0
  1113.     CALLINT_PC    DisplayAlert
  1114.     moveq.l    #0,d0
  1115.     rts
  1116.  
  1117.  
  1118. ErrorText    dc.w    60
  1119.     dc.b    17
  1120.     dc.b    "File Master: ERROR !?! I cannot open the screen / window !"
  1121.     dc.b     0,0
  1122.  
  1123.  
  1124.  
  1125. MK_Window    dc.l    0
  1126.  
  1127.  
  1128. MakeWindow    move.l    ScreenPtr1(pc),nw_Screen(a0)      ; open window
  1129.     CALLINT_PC    OpenWindow          ; draw border and background
  1130.     tst.l    d0
  1131.     beq    QUIT1
  1132.     move.l    d0,-(sp)
  1133.     move.l    d0,a0
  1134.     move.l    d0,MK_Window
  1135.  
  1136. WindowPointer set MK_Window
  1137.  
  1138.     move.w    wd_Height(a0),d5
  1139.     move.w    wd_Width(a0),d4
  1140.     subq    #1,d5
  1141.     subq    #1,d4
  1142.  
  1143.     move.l    wd_RPort(a0),-(sp)
  1144.  
  1145.     SETAPEN    #7
  1146.  
  1147.     move.w    d4,d2
  1148.     move.w    d5,d3
  1149.     subq.l    #2,d2
  1150.     subq.l    #1,d3
  1151.     moveq.l    #1,d1
  1152.     moveq.l    #2,d0
  1153.     move.l    (sp),a1
  1154.     CALLGRAF_PC    RectFill
  1155.     
  1156.     SETAPEN    #0
  1157.  
  1158.     moveq.l    #0,d0    ; Top
  1159.     moveq.l    #0,d1
  1160.     move.w    d4,d2
  1161.     moveq.l    #0,d3
  1162.     bsr    .Line
  1163.     moveq.l    #0,d0    ; Bottom
  1164.     move.l    d5,d1
  1165.     move.w    d4,d2
  1166.     move.l    d5,d3
  1167.     bsr    .Line
  1168.     
  1169.     moveq.l    #0,d0    ; Left I
  1170.     moveq.l    #0,d1
  1171.     moveq.l    #0,d2
  1172.     move.l    d5,d3
  1173.     bsr    .Line
  1174.  
  1175.     moveq.l    #1,d0    ; Left II
  1176.     moveq.l    #0,d1
  1177.     moveq.l    #1,d2
  1178.     move.l    d5,d3
  1179.     bsr    .Line
  1180.     
  1181.     move.l    d4,d0    ; Right I
  1182.     moveq.l    #0,d1
  1183.     move.l    d4,d2
  1184.     move.l    d5,d3
  1185.     bsr    .Line
  1186.  
  1187.     move.l    d4,d0    ; Right II
  1188.     moveq.l    #0,d1
  1189.     move.l    d4,d2
  1190.     move.l    d5,d3
  1191.     subq.l    #1,d0
  1192.     subq.l    #1,d2
  1193.     bsr    .Line
  1194.  
  1195.     move.l    (sp)+,d0
  1196.     move.l    (sp),a1
  1197.  
  1198.     move.l    wd_FirstGadget(a1),a0
  1199.     cmp.l    #0,a0
  1200.     beq    .Label2
  1201.     sub.l    a2,a2
  1202.     CALLINT_PC    RefreshGadgets
  1203. .Label2    move.l    (sp)+,d0
  1204.  
  1205. .exit    rts
  1206.     
  1207.  
  1208. .Line    move.l    4(sp),a1
  1209.     CALLGRAF_PC    Move
  1210.     move.w    d2,d0
  1211.     move.w    d3,d1
  1212.     move.l    4(sp),a1
  1213.     CALLGRAF_PC    Draw
  1214.     rts
  1215.  
  1216.  
  1217.  
  1218. Areas    ; draw a area - used to create screen
  1219. WindowPointer set Window1
  1220.     
  1221.     subq    #1,d5
  1222.     subq    #1,d4
  1223.  
  1224.     move.l    Window1(pc),a0
  1225.     move.l    wd_RPort(a0),-(sp)
  1226.  
  1227.     SETAPEN    #7
  1228.     
  1229.     move.w    d4,d0
  1230.     move.w    d4,d2
  1231.     move.w    d7,d1
  1232.     move.w    d5,d3    
  1233.     subq    #4,d0
  1234.     move.l    (sp),a1
  1235.     CALLGRAF_PC    RectFill
  1236.     
  1237.     move.w    d6,d0
  1238.     move.w    d5,d1
  1239.     subq    #4,d1
  1240.     move.w    d4,d2
  1241.     move.w    d5,d3
  1242.     move.l    (sp),a1
  1243.     CALLGRAF_PC    RectFill
  1244.     
  1245.     SETAPEN    #2
  1246.  
  1247.     move.w    d6,d0
  1248.     addq.l    #4,d0
  1249.     move.w    d7,d1
  1250.     addq.l    #2,d1
  1251.     move.w    d4,d2
  1252.     subq    #4,d2
  1253.     move.w    d5,d3
  1254.     subq    #2,d3
  1255.     move.l    (sp),a1
  1256.     CALLGRAF_PC    RectFill
  1257.         
  1258.     SETAPEN    #5
  1259.  
  1260.     move.w    d6,d0
  1261.     move.w    d7,d1
  1262.     move.w    d7,d3
  1263.     move.w    d4,d2
  1264.     bsr    .Line
  1265.  
  1266.     move.w    d6,d0
  1267.     move.w    d7,d1
  1268.     move.w    d7,d3
  1269.     addq.l    #1,d1
  1270.     addq.l    #1,d3
  1271.     move.w    d4,d2
  1272.     subq    #2,d2
  1273.     bsr    .Line
  1274.  
  1275.     move.w    d6,d0
  1276.     move.w    d7,d1
  1277.     move.w    d6,d2
  1278.     move.w    d5,d3
  1279.     subq    #1,d3
  1280.     bsr    .Line
  1281.     
  1282.     move.w    d6,d0
  1283.     addq.l    #1,d0
  1284.     move.w    d7,d1
  1285.     move.w    d6,d2
  1286.     addq.l    #1,d2
  1287.     move.w    d5,d3
  1288.     subq    #1,d3
  1289.     bsr    .Line
  1290.     
  1291.     move.w    d6,d0
  1292.     addq    #2,d0
  1293.     move.w    d7,d1
  1294.     move.w    d6,d2
  1295.     addq    #2,d2
  1296.  
  1297.     move.w    d5,d3
  1298.     subq    #2,d3
  1299.     bsr    .Line
  1300.  
  1301.     move.w    d6,d0
  1302.     addq    #3,d0
  1303.     move.w    d7,d1
  1304.     move.w    d6,d2
  1305.     addq    #3,d2
  1306.     move.w    d5,d3
  1307.     subq    #2,d3
  1308.     bsr    .Line
  1309.  
  1310.     move.l    (sp)+,d0
  1311. .exit    rts
  1312.     
  1313.  
  1314. .Line    move.l    4(sp),a1
  1315.     CALLGRAF_PC    Move
  1316.     move.w    d2,d0
  1317.     move.w    d3,d1
  1318.     move.l    4(sp),a1
  1319.     CALLGRAF_PC    Draw
  1320.     rts
  1321.  
  1322. OpenCon    sub.l    a1,a1        ; open console device
  1323.     CALLEXEC    FindTask        ; it's used to convert RAWKEY
  1324.     lea.l    ReplyPort(pc),a1
  1325.     move.l    d0,$10(a1)        ; into ASCII
  1326.     CALLEXEC    AddPort
  1327.     moveq.l    #0,d0
  1328.     moveq.l    #0,d1
  1329.     lea.l    ConName(pc),a0
  1330.     lea.l    ConIO(pc),a1
  1331.     move.l    Window1(pc),$28(a1)
  1332.     move.l    #48,$24(a1)
  1333.  
  1334.     CALLEXEC    OpenDevice
  1335.     tst.l    d0
  1336.     bne.s    CloseCon2
  1337.     rts
  1338.  
  1339. ConIO    ds.b    48
  1340. ReplyPort    ds.l    8
  1341. ConName    dc.b    "console.device",0
  1342.     even
  1343.  
  1344.  
  1345. CloseCon    lea.l    ConIO(pc),a1        ; close device 
  1346.     CALLEXEC    CloseDevice
  1347. CloseCon2    lea.l    ReplyPort(pc),a1
  1348.     CALLEXEC    RemPort
  1349.     moveq.l    #-1,d0
  1350.     rts
  1351.  
  1352. KeyPressed    cmp.b    #CURSORLEFT,d5    ; cursor key ?    
  1353.     beq    MoveCursorL
  1354.     cmp.b    #CURSORRIGHT,d5
  1355.     beq    MoveCursorR
  1356.     cmp.b    #CURSORUP,d5
  1357.     beq    MoveCursorU
  1358.     cmp.b    #CURSORDOWN,d5
  1359.     beq    MoveCursorD
  1360.  
  1361.     btst    #7,d5
  1362.     beq    wait
  1363.     and.l    #$7f,d5
  1364.     move.l    d3,d0
  1365.     and.l    #128+64,d0    ; skip if AMIGA-Key pressed 
  1366.     bne    wait    ; (because user only wanted to select a menu
  1367.             ; but he didn't want to enter a character) 
  1368.     cmp.b    #$45,d5    ; ESC
  1369.     beq    .QUIT
  1370.     cmp.b    #$50,d5    ; F1
  1371.     beq    .OPEN
  1372.     cmp.b    #$51,d5    ; F2
  1373.     beq    .SAVE
  1374.     cmp.b    #$52,d5    ; F3
  1375.     beq    .EXECUTE
  1376.     cmp.b    #$53,d5    ; F4
  1377.     beq    .FORWARD
  1378.     cmp.b    #$54,d5    ; F5
  1379.     beq    .BACKWARD
  1380.     cmp.b    #$55,d5    ; F6
  1381.     beq    .WRITE
  1382.     cmp.b    #$56,d5    ; F7
  1383.     beq    .UNDO
  1384.     cmp.b    #$57,d5    ; F8
  1385.     beq    .SEARCH
  1386.     cmp.b    #$58,d5    ; F9
  1387.     beq    .PREVIOUS
  1388.     cmp.b    #$59,d5    ; F10
  1389.     beq    .NEXT
  1390.     cmp.b    #$5f,d5    ; Help
  1391.     beq    .KEY_INFO
  1392.     cmp.b    #$46,d5    ; DEL
  1393.     beq    .UNDO_CHAR
  1394.     cmp.b    #$f,d5    ; NK 0
  1395.     bne    KL1
  1396.     
  1397.     bra.s    ChangeMode
  1398. .QUIT    jmp    QUIT
  1399. .OPEN    jmp    OPEN
  1400. .SAVE    jmp    SAVE
  1401. .EXECUTE    jmp    EXECUTE
  1402. .FORWARD    jmp    FORWARD
  1403. .BACKWARD    jmp    BACKWARD
  1404. .WRITE    jmp    WRITE
  1405. .UNDO    jmp    UNDO
  1406. .SEARCH    jmp    SEARCH
  1407. .PREVIOUS    jmp    PREVIOUS
  1408. .NEXT    jmp    NEXT
  1409. .KEY_INFO    jmp    KEY_INFO
  1410. .UNDO_CHAR    jmp    UNDO_CHAR
  1411.  
  1412. ChangeMode    eor.b    #1,Mode        ; change mode
  1413.     and.b    #1,Mode
  1414.     bra    NewMode
  1415.  
  1416. KL1    tst.l    AnzahlBytes        ; check, if there are bytes 
  1417.     beq    wait
  1418.     cmp.b    #$41,d5
  1419.     beq    BackSpace
  1420.     
  1421.     lea.l    IE(pc),a0        ; put up INPUT EVENT structure
  1422.     move.w    d5,ie_Code(a0)
  1423.     move.w    d3,ie_Qualifier(a0)    
  1424.     move.b    #IECLASS_RAWKEY,ie_Class(a0)
  1425.  
  1426.     lea.l    ASCII(pc),a1    
  1427.     moveq.l    #4,d1
  1428.     sub.l    a2,a2
  1429.  
  1430.     move.l    ConIO+IO_DEVICE,a6    ; convert INPUT EVENT into ASCII
  1431.     jsr    -$30(a6)
  1432.     cmp.b    #1,d0
  1433.     bne    wait
  1434.     tst.b    Mode
  1435.     bne    HEX_Input
  1436.     lea.l    Puffer,a0
  1437.     add.l    Cursor(pc),a0
  1438.     move.b    ASCII,(a0)
  1439.     lea.l    Color,a0
  1440.     add.l    Cursor(pc),a0
  1441.     move.b    #1,(a0)
  1442.     
  1443.     
  1444.     move.l    Cursor(pc),d0
  1445.     addq.l    #1,d0
  1446.     cmp.l    AnzahlBytes,d0
  1447.     bge.s    .L2
  1448.     bsr    SetCursor
  1449.     bra    wait
  1450. .L2    move.l    Cursor(pc),d0
  1451.     bsr    SetCursor
  1452.     bra    wait
  1453.  
  1454.     even
  1455. IE    ds.b    ie_SIZEOF
  1456.     even
  1457. ASCII    ds.b    10
  1458.  
  1459.  
  1460. WindowPointer set Window1        
  1461.  
  1462. ShowPuffer    SETDRMD    #RP_JAM2
  1463.     SETAPEN    #3
  1464.     SETBPEN    #2
  1465.     bsr    Set_Font
  1466.  
  1467.     lea.l    Puffer,a3
  1468.     move.l    a3,a4
  1469.     add.l    AnzahlBytes,a4
  1470.  
  1471.     moveq.l    #0,d5
  1472.  
  1473. .L1    lea.l    .Line(pc),a0
  1474.     move.w    #99,d0
  1475. .L2    move.b    #" ",(a0)+
  1476.     dbra    d0,.L2
  1477.     
  1478.     lea.l    .Line2(pc),a0
  1479.     move.w    #23,d0
  1480. .L3    move.b    #" ",(a0)+
  1481.     dbra    d0,.L3
  1482.  
  1483. .L4    lea.l    .Line(pc),a5
  1484.     lea.l    .Line2(pc),a6
  1485.  
  1486.     move.l    Bytes_Per_Row,d7
  1487.     lsr.l    #2,d7
  1488.     subq.l    #1,d7
  1489.  
  1490. .L5    moveq.l    #3,d6
  1491.     
  1492. .L6    moveq.l    #0,d4
  1493.     move.b    (a3)+,d4
  1494.     lea.l    HEX(pc),a0
  1495.     
  1496.     cmp.l    a4,a3
  1497.     bhi    .L7
  1498.     
  1499.     tst.b    DisplayMode        ; replace nothing (show all ASCIIs)        
  1500.     beq    .K1
  1501.     cmp.b    #1,DisplayMode        ; replace 0-$1f and $80-$9f
  1502.     bne    .K2
  1503.     move.b    d4,d0
  1504.     and.b    #$7f,d0
  1505.     cmp.b    #$1f,d0
  1506.     bhi    .K1
  1507. .K4    move.b    #".",(a6)+
  1508.     bra.s    .K3
  1509.  
  1510. .K2    cmp.b    #$7d,d4        ; replace 0-$1f and $7e-$ff
  1511.     bhi.s    .K4
  1512.     cmp.b    #$1f,d4
  1513.     bls.s    .K4    
  1514.  
  1515. .K1    move.b    d4,(a6)+    
  1516. .K3    move.l    d4,d0
  1517.     lsr.b    #4,d0
  1518.     and.l    #$f,d4
  1519.     move.b    (a0,d0),(a5)+
  1520.     move.b    (a0,d4),(a5)+
  1521.     bra.s    .L8
  1522.  
  1523. .L7    move.b    #" ",(a5)+
  1524.     move.b    #" ",(a5)+
  1525.     move.b    #" ",(a6)+
  1526.  
  1527. .L8    dbra    d6,.L6
  1528.  
  1529.     move.b    #" ",(a5)+
  1530.     
  1531.     dbra    d7,.L5
  1532.     
  1533.     move.l    Window1(pc),a1
  1534.     move.l    wd_RPort(a1),a1
  1535.     move.l    HEX_X,d0
  1536.     move.l    d5,d1
  1537.     mulu    FONT_Y+2,d1    
  1538.     add.l    HEX_Y,d1
  1539.     CALLGRAF_PC    Move
  1540.     move.l    Window1(pc),a1
  1541.     move.l    wd_RPort(a1),a1
  1542.     lea.l    .Line(pc),a0
  1543.     move.l    HEX_Breite,d0
  1544.     CALLGRAF_PC    Text
  1545.  
  1546.     move.l    Window1(pc),a1
  1547.     move.l    wd_RPort(a1),a1
  1548.     move.l    ASC_X,d0
  1549.     move.l    d5,d1
  1550.     mulu    FONT_Y+2,d1    
  1551.     add.l    ASC_Y,d1
  1552.     CALLGRAF_PC    Move
  1553.     move.l    Window1,a1
  1554.     move.l    wd_RPort(a1),a1
  1555.     lea.l    .Line2(pc),a0
  1556.     move.l    ASC_Breite,d0
  1557.     CALLGRAF_PC    Text
  1558.     
  1559.     addq.l    #1,d5
  1560.     cmp.l    Zeilen,d5
  1561.     bne    .L1
  1562.     rts
  1563.  
  1564. .Line    ds.b    100
  1565. .Line2    ds.b    32
  1566. HEX    dc.b    "0123456789ABCDEF"
  1567.     
  1568.  
  1569. Set_Font    move.l    Window1(pc),a1
  1570.     move.l    wd_RPort(a1),a1
  1571.     move.l    FM_Font,a0
  1572.     CALLGRAF_PC    SetFont
  1573.     rts
  1574.  
  1575. SetCursor    tst.l    AnzahlBytes
  1576.     beq    .NoFile
  1577.     
  1578.     move.l    d0,-(sp)    ; d0=Pos
  1579.     bsr.s    Set_Font
  1580.     cmp.l    #-1,Cursor
  1581.     beq    .SetNew
  1582.  
  1583.     lea.l    Color,a0        ; clear old cursor position
  1584.     moveq.l    #0,d0
  1585.     move.l    Cursor(pc),d1
  1586.     move.b    (a0,d1),d0
  1587.     move.l    Window1(pc),a1
  1588.     move.l    wd_RPort(a1),a1    
  1589.     CALLGRAF_PC    SetAPen
  1590.     moveq.l    #2,d0
  1591.     move.l    Window1(pc),a1
  1592.     move.l    wd_RPort(a1),a1    
  1593.     CALLGRAF_PC    SetBPen
  1594.     moveq.l    #RP_JAM2,d0
  1595.     move.l    Window1(pc),a1
  1596.     move.l    wd_RPort(a1),a1    
  1597.     CALLGRAF_PC    SetDrMd    
  1598.     move.l    Cursor(pc),d0
  1599.     bsr    PutCursor    
  1600.  
  1601. .SetNew    lea.l    Color,a0        ; pos new cursor
  1602.     moveq.l    #0,d0
  1603.     move.l    (sp),d1
  1604.     move.b    (a0,d1),d0
  1605.     move.b    d0,d5
  1606.     move.l    Window1(pc),a1
  1607.     move.l    wd_RPort(a1),a1    
  1608.     CALLGRAF_PC    SetAPen
  1609.     moveq.l    #4,d0
  1610.     cmp.b    #1,d5
  1611.     beq.s    .L1
  1612.     addq.l    #2,d0
  1613. .L1    move.l    Window1(pc),a1
  1614.     move.l    wd_RPort(a1),a1    
  1615.     CALLGRAF_PC    SetBPen
  1616.     moveq.l    #RP_JAM2,d0
  1617.     move.l    Window1(pc),a1
  1618.     move.l    wd_RPort(a1),a1    
  1619.     CALLGRAF_PC    SetDrMd    
  1620.     move.l    (sp)+,d0
  1621.     move.l    d0,Cursor
  1622.     bsr    PutCursor
  1623. .NoFile    rts
  1624.  
  1625. PutCursor    move.l    d0,d6
  1626.     divu    Bytes_Per_Row+2,d0
  1627.     move.l    d0,d1
  1628.     lsr.l    #8,d0
  1629.     lsr.l    #8,d0
  1630.     move.l    d0,d2
  1631.     lsr.l    #2,d2
  1632.     lsl.l    #1,d0
  1633.     add.l    d2,d0
  1634.     mulu    FONT_X+2,d0
  1635.     add.l    HEX_X,d0
  1636.     and.l    #$ff,d1
  1637.     mulu    FONT_Y+2,d1
  1638.     add.l    HEX_Y,d1
  1639.  
  1640.     move.l    Window1(pc),a1
  1641.     move.l    wd_RPort(a1),a1
  1642.     CALLGRAF_PC    Move
  1643.     
  1644.     lea.l    Puffer,a0
  1645.     add.l    d6,a0
  1646.     moveq.l    #0,d0
  1647.     move.b    (a0),d0
  1648.     lea.l    HEX(pc),a1
  1649.     move.l    d0,d4
  1650.     lsr.b    #4,d0
  1651.     and.l    #$f,d4
  1652.     lea.l    .HEX_Puffer(pc),a0
  1653.     move.b    (a1,d0),(a0)
  1654.     move.b    (a1,d4),1(a0)
  1655.     moveq.l    #2,d0
  1656.     move.l    Window1(pc),a1
  1657.     move.l    wd_RPort(a1),a1
  1658.     CALLGRAF_PC    Text
  1659.  
  1660.     move.l    d6,d0
  1661.     divu    Bytes_Per_Row+2,d0
  1662.     move.l    d0,d1
  1663.     lsr.l    #8,d0
  1664.     lsr.l    #8,d0
  1665.     mulu    FONT_X+2,d0
  1666.     add.l    ASC_X,d0
  1667.     and.l    #$ff,d1
  1668.     mulu    FONT_Y+2,d1
  1669.     add.l    ASC_Y,d1
  1670.     move.l    Window1(pc),a1
  1671.     move.l    wd_RPort(a1),a1
  1672.     CALLGRAF_PC    Move
  1673.     
  1674.     lea.l    Puffer,a0
  1675.     add.l    d6,a0
  1676.     moveq.l    #0,d0
  1677.     move.b    (a0),d0
  1678.     tst.b    DisplayMode        ; replace nothing (show all ASCIIs)        
  1679.     beq    .K1
  1680.     cmp.b    #1,DisplayMode        ; replace 0-$1f and $80-$9f
  1681.     bne    .K2
  1682.     move.b    d0,d1
  1683.     and.l    #$7f,d1
  1684.     cmp.b    #$1f,d1
  1685.     bhi    .K1
  1686. .K4    move.b    #".",d0
  1687.     bra.s    .K1
  1688. .K2    cmp.b    #$7D,d0        ; replace 0-$1f and $7e-$ff
  1689.     bhi.s    .K4
  1690.     cmp.b    #$1f,d0
  1691.     bls.s    .K4    
  1692. .K1    lea.l    .HEX_Puffer(pc),a0    
  1693.     move.b    d0,(a0)
  1694.     moveq.l    #1,d0
  1695.     move.l    Window1(pc),a1
  1696.     move.l    wd_RPort(a1),a1
  1697.     CALLGRAF_PC    Text
  1698.     rts
  1699. .HEX_Puffer    ds.b    2
  1700.  
  1701.  
  1702.  
  1703. *
  1704. * move cursor 
  1705. *
  1706.  
  1707. MoveCursorL    moveq.l    #0,d1
  1708.     move.w    d3,d1
  1709.     lsr.w    #1,d1
  1710.     or.w    d3,d1
  1711.     btst    #0,d1
  1712.     bne    MoveCursorL_Shift
  1713.     tst.l    Cursor
  1714.     beq.s    .wait
  1715.     move.l    Cursor(pc),d0
  1716.     subq.l    #1,d0
  1717.     bsr    SetCursor
  1718. .wait    bra    NewPos
  1719.  
  1720. MoveCursorU    moveq.l    #0,d1
  1721.     move.w    d3,d1
  1722.     lsr.w    #1,d1
  1723.     or.w    d3,d1
  1724.     btst    #0,d1
  1725.     bne    MoveCursorU_Shift
  1726.     move.l    Cursor(pc),d0
  1727.     sub.l    ASC_Breite,d0
  1728.     tst.l    d0    
  1729.     bmi.s    .wait
  1730.     bsr    SetCursor
  1731. .wait    bra    NewPos
  1732.  
  1733. MoveCursorR    moveq.l    #0,d1
  1734.     move.w    d3,d1
  1735.     lsr.w    #1,d1
  1736.     or.w    d3,d1
  1737.     btst    #0,d1
  1738.     bne    MoveCursorR_Shift
  1739.     move.l    Cursor(pc),d0
  1740.     addq.l    #1,d0
  1741.     cmp.l    AnzahlBytes,d0
  1742.     beq.s    .wait
  1743.     bsr    SetCursor
  1744. .wait    bra    NewPos
  1745.  
  1746. MoveCursorD    moveq.l    #0,d1
  1747.     move.w    d3,d1
  1748.     lsr.w    #1,d1
  1749.     or.w    d3,d1
  1750.     btst    #0,d1
  1751.     bne    MoveCursorD_Shift
  1752.     move.l    Cursor(pc),d0
  1753.     add.l    ASC_Breite,d0
  1754.     cmp.l    AnzahlBytes,d0
  1755.     bge.s    .wait
  1756.     bsr    SetCursor
  1757. .wait    bra    NewPos
  1758.  
  1759. MoveCursorL_Shift        
  1760.     move.l    Cursor(pc),d0
  1761.     subq.l    #4,d0
  1762.     and.l    #-1-3,d0
  1763.     tst.l    d0
  1764.     bpl.s    .L1
  1765.     moveq.l    #0,d0
  1766. .L1    bsr    SetCursor
  1767.     bra    NewPos
  1768.  
  1769. MoveCursorU_Shift    
  1770.     move.l    Cursor(pc),d0
  1771.     moveq.l    #3,d1
  1772. .L1    sub.l    ASC_Breite,d0
  1773.     tst.l    d0    
  1774.     bmi.s    .L2
  1775.     dbra    d1,.L1
  1776.     sub.l    ASC_Breite,d0
  1777. .L2    add.l    ASC_Breite,d0
  1778.     bsr    SetCursor
  1779. .wait    bra    NewPos
  1780.  
  1781. MoveCursorR_Shift    
  1782.     move.l    Cursor(pc),d0
  1783.     addq.l    #4,d0
  1784.     and.l    #-1-3,d0
  1785.     cmp.l    AnzahlBytes,d0
  1786.     bge.s    .L1
  1787.     bsr    SetCursor
  1788. .wait    bra    NewPos
  1789. .L1    move.l    AnzahlBytes,d0
  1790.     subq.l    #1,d0
  1791.     bsr    SetCursor
  1792.     bra    NewPos
  1793.     
  1794.  
  1795. MoveCursorD_Shift
  1796.     move.l    Cursor(pc),d0
  1797.     moveq.l    #3,d1
  1798. .L1    add.l    ASC_Breite,d0
  1799.     cmp.l    AnzahlBytes,d0
  1800.     bge.s    .L2
  1801.     dbra    d1,.L1
  1802.     add.l    ASC_Breite,d0
  1803. .L2    sub.l    ASC_Breite,d0
  1804.     bsr    SetCursor
  1805. .wait    bra    NewPos
  1806.  
  1807. File    dc.l    0
  1808.  
  1809. OPEN    bsr    WriteQuestion
  1810.     bsr    SaveQuestion
  1811.     lea.l    Open_Text(pc),a5    ; OPEN A FILE
  1812.     move.l    #R_G1a,R_def+nw_FirstGadget
  1813.     bsr    FileRequester
  1814.     tst.l    d0
  1815.     beq    wait
  1816.     move.l    d0,File
  1817.  
  1818.     moveq.w    #0,d6        ; Clear Screen 
  1819.     move.w    #11,d7
  1820.     move.w    #((32+1+7)*8)+8,d4
  1821.     move.w    #11+14,d5
  1822.     bsr    Areas
  1823.     
  1824.     move.w    #(32+1+7)*8+8,d6    ; Sector
  1825.     move.w    #11,d7
  1826.     move.w    #(32+2+7+16+2)*8+12,d4
  1827.     move.w    #11+14,d5
  1828.     bsr    Areas
  1829.     
  1830.     moveq.w    #0,d6        ; Hex    
  1831.     move.w    #11+14,d7
  1832.     move.w    #(32+1+7)*8+8,d4
  1833.     move.w    Screendef+ns_Height,d5
  1834.     bsr    Areas
  1835.     
  1836.     move.w    #(32+1+7)*8+8,d6    ; ASC
  1837.     move.w    #11+14,d7
  1838.     move.w    #(32+2+7+16+2)*8+12,d4
  1839.     move.w    Screendef+ns_Height,d5
  1840.     bsr    Areas
  1841.  
  1842.     move.w    #484,d6        ; Cursor
  1843.     move.w    #11+149,d7
  1844.     move.w    #484+84-6,d4
  1845.     move.w    #11+179,d5
  1846.     bsr    Areas
  1847.  
  1848.  
  1849.     move.l    Memory(pc),a1        ; free memory if allocated
  1850.     cmp.l    #0,a1
  1851.     beq    .CloseFile
  1852.     move.l    Size(pc),d0
  1853.     CALLEXEC    FreeMem
  1854.     bra.s    .L1
  1855. .CloseFile    move.l    Filehandle(pc),d1    ; close file if opened
  1856.     CALLDOS_PC    Close
  1857. .L1    clr.l    AnzahlBytes
  1858.     clr.l    Cursor
  1859.     clr.l    Size
  1860.     clr.l    Filehandle
  1861.     clr.b    FlagFile
  1862.     clr.b    FlagWrite
  1863.     clr.l    Memory
  1864.     clr.l    SearchSector
  1865.  
  1866.  
  1867. Q    tst.b    R_Gadget
  1868.     beq    .Open_File
  1869.  
  1870.     move.l    File(pc),d1        ; Copy file to RAM
  1871.     move.l    #MODE_OLDFILE,d2
  1872.     CALLDOS_PC    Open
  1873.     tst.l    d0
  1874.     beq    OpenError
  1875.     
  1876.     move.l    d0,Filehandle
  1877.     
  1878.     move.l    d0,d1        ; get file size
  1879.     moveq.l    #0,d2
  1880.     moveq.l    #OFFSET_END,d3
  1881.     CALLDOS_PC    Seek
  1882.     tst.l    d0
  1883.     bmi    DiskError
  1884.  
  1885.     move.l    Filehandle(pc),d1    
  1886.     moveq.l    #0,d2
  1887.     moveq.l    #OFFSET_CURRENT,d3
  1888.     CALLDOS_PC    Seek
  1889.     tst.l    d0
  1890.     bmi    DiskError
  1891.     move.l    d0,.FileSize
  1892.  
  1893.     move.l    Filehandle(pc),d1    
  1894.     moveq.l    #0,d2
  1895.     moveq.l    #OFFSET_BEGINNING,d3
  1896.     CALLDOS_PC    Seek
  1897.     tst.l    d0
  1898.     bmi    DiskError
  1899.  
  1900.     tst.l    .FileSize
  1901.     beq    .EmptyFile
  1902.  
  1903.     moveq.l    #MEMF_PUBLIC,d1
  1904.     CALLEXEC    AllocMem
  1905.     tst.l    d0
  1906.     beq    .NoMemory    
  1907.     move.l    d0,Memory
  1908.     
  1909.     move.l    d0,d2
  1910.     move.l    Filehandle(pc),d1
  1911.     move.l    .FileSize(pc),d3
  1912.     CALLDOS_PC    Read
  1913.     cmp.l    d3,d0
  1914.     bne    .DiskError
  1915.     
  1916.     move.l    Filehandle(pc),d1
  1917.     CALLDOS_PC    Close
  1918.     clr.l    Filehandle
  1919.     move.l    .FileSize(pc),Size
  1920.  
  1921. .Z0    lea.l    FileName(pc),a0    ; Copy file name
  1922.     lea.l    PrintHeader+9,a2
  1923.     move.w    #59,d0
  1924. .L0    move.b    #" ",(a0)
  1925.     move.b    (a0)+,(a2)+
  1926.     dbra    d0,.L0
  1927.  
  1928.     lea.l    R_File(pc),a0
  1929.     lea.l    FileName(pc),a1
  1930.     lea.l    PrintHeader+9,a2
  1931. .L3    move.b    (a0),(a1)+
  1932.     move.b    (a0)+,(a2)+
  1933.     bne.s    .L3
  1934.     move.b    #" ",-1(a1)
  1935.     move.b    #" ",-1(a2)
  1936.     move.b    #1,FlagFile
  1937.     
  1938.     lea.l    FileName+28(pc),a0    ; copy file size
  1939.     move.l    Size(pc),d0
  1940.     move.b    #"/",(a0)+
  1941.     moveq.l    #7,d2
  1942.     moveq.l    #0,d3
  1943.     lea.l    .Potenzen(pc),a2
  1944. .Z1    move.b    #"0"-1,d1
  1945. .Z2    addq    #1,d1
  1946.     sub.l    (a2),d0
  1947.     bcc.s    .Z2
  1948.     add.l    (a2)+,d0
  1949.     tst.b    d2
  1950.     beq.s    .Z3
  1951.     cmp.b    #"0",d1
  1952.     beq.s    .Z4
  1953.     moveq.l    #1,d3
  1954.     bra.s    .Z3
  1955. .Z4    tst.b    d3
  1956.     bne.s    .Z3
  1957.     move.b    #" ",d1
  1958. .Z3    move.b    d1,(a0)+
  1959.     dbra    d2,.Z1
  1960.     bra    NewFile
  1961.  
  1962. .Potenzen    dc.l    10000000
  1963.     dc.l    1000000
  1964.     dc.l    100000
  1965.     dc.l    10000
  1966.     dc.l    1000
  1967.     dc.l    100
  1968.     dc.l    10
  1969.     dc.l    1
  1970.  
  1971. .DiskError    move.l    .FileSize(pc),d0
  1972.     move.l    Memory(pc),a1
  1973.     CALLEXEC    FreeMem
  1974.     clr.l    Memory
  1975.     bra    DiskError
  1976. .NoMemory    move.l    Filehandle(pc),d1
  1977.     CALLDOS_PC    Close
  1978.     clr.l    Filehandle    
  1979.     bra    NoMemory
  1980. .EmptyFile    move.l    Filehandle(pc),d1
  1981.     CALLDOS_PC    Close    
  1982.     clr.l    Filehandle
  1983.     bra    EmptyFile
  1984.  
  1985. .FileSize    dc.l    0
  1986. .Open_File    move.l    File(pc),d1        ; Open File
  1987.     move.l    #MODE_OLDFILE,d2
  1988.     CALLDOS_PC    Open
  1989.     tst.l    d0
  1990.     beq    OpenError
  1991.     move.l    d0,Filehandle
  1992.     move.l    d0,d1    
  1993.     moveq.l    #0,d2
  1994.     moveq.l    #OFFSET_END,d3
  1995.     CALLDOS_PC    Seek
  1996.     tst.l    d0
  1997.     bmi    DiskError
  1998.     move.l    Filehandle(pc),d1    
  1999.     moveq.l    #0,d2
  2000.     moveq.l    #OFFSET_CURRENT,d3
  2001.     CALLDOS_PC    Seek
  2002.     tst.l    d0
  2003.     bmi    DiskError
  2004.     tst.l    d0
  2005.     beq    EmptyFile
  2006.     move.l    d0,Size
  2007.     
  2008.     bra    .Z0
  2009.  
  2010.  
  2011.  
  2012. FileName    dc.b    "                                                                         "
  2013.     even
  2014.  
  2015. Open_Text    dc.b    "               Open File:               "
  2016.     even
  2017.  
  2018.  
  2019. *
  2020. *    Disk error
  2021. *
  2022.  
  2023.  
  2024. WindowPointer set Window2
  2025.  
  2026. Windowdef2    dc.w    60,50,300,70
  2027.     dc.b    -1,-1
  2028.     dc.l    GADGETUP
  2029.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  2030.     dc.l    .Gadget1
  2031.     dc.l    0
  2032.     dc.l    0
  2033.     dc.l    0,0
  2034.     dc.w    0,0,0,0,CUSTOMSCREEN
  2035.  
  2036. .Gadget1    FM_GADGET    0,125,50,50,0,<"OK">,1,4
  2037.  
  2038. DiskError    move.l    Filehandle(pc),d1
  2039.     CALLDOS_PC    Close
  2040.     clr.l    Filehandle
  2041. OpenError    move.l    ScreenPtr1(pc),a0
  2042.     CALLINT_PC    DisplayBeep    
  2043.     lea.l    Windowdef2(pc),a0
  2044.     bsr    MakeWindow
  2045.     tst.l    d0
  2046.     beq    .wait
  2047.     move.l    d0,Window2
  2048.     SETDRMD    #RP_JAM1
  2049.     WRITE    #6+(290-17*8)/2,#19,#0,<"»» DISK ERROR ««">
  2050.     WRITE    #5+(290-17*8)/2,#18,#1,<"»» DISK ERROR ««">
  2051.     SETAPEN    #0
  2052.     move.l    Window2(pc),a1
  2053.     move.l    wd_RPort(a1),a1
  2054.     move.l    a1,a3    
  2055.     moveq.l    #6+((290-31*8)/2),d0
  2056.     move.l    #36,d1
  2057.     CALLGRAF_PC    Move
  2058.     CALLDOS_PC    IoErr
  2059.     bsr    .ErrorPointer
  2060.     move.l    a0,a5
  2061.     move.l    a3,a1
  2062.     move.l    #31,d0
  2063.     CALLGRAF_PC    Text
  2064.     SETAPEN    #1
  2065.     move.l    Window2(pc),a1
  2066.     move.l    wd_RPort(a1),a1
  2067.     move.l    a1,a3    
  2068.     moveq.l    #5+((290-31*8)/2),d0
  2069.     move.l    #35,d1
  2070.     CALLGRAF_PC    Move
  2071.     move.l    a5,a0
  2072.     move.l    a3,a1
  2073.     move.l    #31,d0
  2074.     CALLGRAF_PC    Text
  2075.     move.l    Window2(pc),a0        
  2076.     move.l    wd_UserPort(a0),a0
  2077.     move.l    a0,a5
  2078.     CALLEXEC    WaitPort        
  2079.     move.l    Window2(pc),a0
  2080.     CALLINT_PC    CloseWindow
  2081. .wait    bra    wait
  2082. .ErrorPointer    and.l    #$ff,d0
  2083.     tst.b    d0
  2084.     bne.s    .Label1
  2085.     add.b    #232,d0
  2086. .Label1    sub.b    #202,d0
  2087.     mulu    #31,d0
  2088.     add.l    #.Errors,d0
  2089.     move.l    d0,a0
  2090.     rts
  2091. .Errors    dc.b    "         Object in use         "
  2092.     dc.b    "     Object already exists     "
  2093.     dc.b    "      Directory not found      "
  2094.     dc.b    "        Object not found       "
  2095.     dc.b    "        Invalid window         "
  2096.     dc.b    "             ?????             "
  2097.     dc.b    "             ?????             "
  2098.     dc.b    " Packet requested type unknown "
  2099.     dc.b    " Invalid stream component name "
  2100.     dc.b    "     Invalid object lock       "
  2101.     dc.b    "  Object not of required type  "
  2102.     dc.b    "      Disk not validated       "
  2103.     dc.b    "     Disk write-protected      "
  2104.     dc.b    "Rename across devices attemted "
  2105.     dc.b    "     Directory not empty       "
  2106.     dc.b    "             ?????             "
  2107.     dc.b    "     Devices not mounted       "
  2108.     dc.b    "         Seek Error            "
  2109.     dc.b    "       Comment too big         "
  2110.     dc.b    "         Disk full             "
  2111.     dc.b    "File is protected from deletion"
  2112.     dc.b    "File is protected from writing "
  2113.     dc.b    "File is protected from reading "
  2114.     dc.b    "        Not a DOS disk         "
  2115.     dc.b    "       No Disk in Drive        "
  2116.     dc.b    "  No More entries in Directory " 
  2117.     dc.b    "             OK                " 
  2118.  
  2119.  
  2120. NoMemory    move.l    ScreenPtr1(pc),a0
  2121.     CALLINT_PC    DisplayBeep    
  2122.     lea.l    Windowdef2(pc),a0
  2123.     bsr    MakeWindow
  2124.     tst.l    d0
  2125.     beq    .wait
  2126.     move.l    d0,Window2
  2127.     SETDRMD    #RP_JAM1
  2128.     WRITE    #6+(290-20*8)/2,#19+10,#0,<"Not enough memory !">
  2129.     WRITE    #5+(290-20*8)/2,#18+10,#1,<"Not enough memory !">
  2130.     move.l    Window2(pc),a0        
  2131.     move.l    wd_UserPort(a0),a0
  2132.     move.l    a0,a5
  2133.     CALLEXEC    WaitPort        
  2134.     move.l    Window2(pc),a0
  2135.     CALLINT_PC    CloseWindow
  2136. .wait    bra    wait
  2137.  
  2138. EmptyFile    clr.l    Filehandle
  2139.     move.l    ScreenPtr1(pc),a0
  2140.     CALLINT_PC    DisplayBeep    
  2141.     lea.l    Windowdef2(pc),a0
  2142.     bsr    MakeWindow
  2143.     tst.l    d0
  2144.     beq    .wait
  2145.     move.l    d0,Window2
  2146.     SETDRMD    #RP_JAM1
  2147.     WRITE    #6+(290-16*8)/2,#19+10,#0,<"File is empty !">
  2148.     WRITE    #5+(290-16*8)/2,#18+10,#1,<"File is empty !">
  2149.     move.l    Window2(pc),a0        
  2150.     move.l    wd_UserPort(a0),a0
  2151.     move.l    a0,a5
  2152.     CALLEXEC    WaitPort        
  2153.     move.l    Window2(pc),a0
  2154.     CALLINT_PC    CloseWindow
  2155. .wait    bra    wait
  2156.  
  2157. *
  2158. *    File Requester 
  2159. *
  2160.  
  2161.     include    libraries/dosextens.i
  2162.  
  2163. TEXTR    macro            ; macro to create a text structure    
  2164.     dc.b    \4,0,RP_JAM1,0
  2165.     dc.w    \1,\2
  2166.     dc.l    TOPAZ_80,\3,0
  2167.     even
  2168.  
  2169.     IFEQ    FontFlag
  2170. TOPAZ_80    dc.l    T_80name
  2171.     dc.w    TOPAZ_EIGHTY
  2172.     dc.b    FS_NORMAL,FPF_ROMFONT
  2173.     even
  2174. T_80name    dc.b    "topaz.font",0
  2175.  
  2176. FontFlag    set    1
  2177.     endc
  2178.     endm
  2179.  
  2180.  
  2181. R_def    dc.w    60,6,296+72,189    
  2182.     dc.b    0,1
  2183.     dc.l    GADGETUP!GADGETDOWN
  2184.     dc.l    SMART_REFRESH!ACTIVATE!RMBTRAP    
  2185.     dc.l    R_G1,0,0
  2186. R_S1    dc.l    0,0
  2187.     dc.w    0,0,0,0,CUSTOMSCREEN
  2188. R_Window    dc.l    0
  2189.  
  2190.  
  2191. R_G1a    FM_GADGET    R_G1b,10+(3*72),189-15,132,0,<"Edit On Device">,1,2
  2192. R_G1b    FM_GADGET    R_G2,10+72,189-15,132,-1,<"Edit In RAM">,1,2
  2193.  
  2194. R_G1c    FM_GADGET    R_G2,10+(3*72),189-15,132,0,<"ProPatch">,1,2
  2195. ;R_G1d    FM_GADGET    R_G2,10+72,189-15,132,-1,<"FM-Patch">,1,2     ; someday perhaps ...
  2196.  
  2197. R_G1    FM_GADGET    R_G2,296-70+72,189-15,60,0,<"OK">,1,2
  2198. R_G2    FM_GADGET    R_G3,10,189-15,60,1,<"Cancel">,1,2
  2199. R_G3    FM_GADGET    R_G4,10,189-35,60,2,<"DF0:">,1,4
  2200.  
  2201. R_G4    dc.l    R_G5
  2202.     dc.w    10+72,189-35,60,12
  2203.     dc.w    GADGHNONE!GADGIMAGE
  2204.     dc.w    RELVERIFY
  2205.     dc.w    BOOLGADGET
  2206.     dc.l    .Image,0
  2207.     dc.l    .Text
  2208.     dc.l    0,0
  2209.     dc.w    3
  2210.     dc.l    0
  2211. .Text    dc.b    0,0,RP_JAM1,0
  2212.     dc.w    (60-32)/2,((12-8)/2)+1
  2213.     dc.l    TOPAZ_80,DriveName,.Text2
  2214.     even
  2215. .Text2    dc.b    1,0,RP_JAM1,0
  2216.     dc.w    (60-32)/2,(12-8)/2
  2217.     dc.l    TOPAZ_80,DriveName,0
  2218. .Image    dc.w    0,0,60,12,3
  2219.     dc.l    0
  2220.     dc.b    0,0
  2221.     dc.l    .Image2
  2222. .Image2    dc.w    2,1,60-4,12-2,3
  2223.     dc.l    0
  2224.     dc.b    0,4
  2225.     dc.l    0
  2226.  
  2227.  
  2228. R_G5    FM_GADGET    R_G6,10+(2*72),189-35,60,4,<"RAM:">,1,4
  2229. R_G6    FM_GADGET    R_G30,10+(3*72),189-35,60,5,<"Parent">,1,4
  2230. R_G30    FM_GADGET    R_G7,10+(4*72),189-35,60,30,<"Devs">,1,4
  2231.  
  2232.  
  2233. R_G7    dc.l    R_G8
  2234.     dc.w    70,-55,216+72,10,GADGHCOMP!GRELBOTTOM,RELVERIFY,STRGADGET
  2235.     dc.l    R_G7_Box,0,R_G7_Text,0,R_G7_Info
  2236.     dc.w    0,0,0
  2237. R_G7_Box    BOX    -60,-2,216+72,9,1,R_G7_Box2
  2238. R_G7_Box2    BOX    -60,-2,-4,9,1,R_G7_Box3
  2239. R_G7_Box3    BOX    -3,-1,215+72,8,0,R_G7_Box4
  2240. R_G7_Box4    BOX    -2,-1,-1,8,0,0
  2241. R_G7_Text    TEXTR    -60+2,0,R_G7_string,1
  2242. R_G7_string    dc.b    "file  ",0
  2243. R_G7_Info    dc.l    R_File,R_File_Undo
  2244.     dc.w    0,43
  2245.     ds.w    12
  2246. R_File    ds.b    44
  2247. R_File_Undo    ds.b    44
  2248. R_G8    dc.l    R_G9
  2249.     dc.w    70,18,216+72,10,GADGHCOMP,RELVERIFY,STRGADGET
  2250.     dc.l    R_G7_Box,0,R_G8_Text,0,R_G8_Info
  2251.     dc.w    7,0,0
  2252. R_G8_Text    TEXTR    -60+2,0,R_G8_string,1
  2253. R_G8_string    dc.b    "Drawer",0
  2254. R_G8_Info    dc.l    R_Drawer,R_Drawer_Undo
  2255.     dc.w    0,100
  2256.     ds.w    12
  2257. R_Drawer    dc.b    ":",0
  2258.     ds.b    302
  2259. R_Drawer_Undo    ds.b    302
  2260. R_G9    dc.l    R_G10
  2261.     dc.w    11,51-16,15,9,GADGHNONE!GADGIMAGE,RELVERIFY!GADGIMMEDIATE,BOOLGADGET
  2262.     dc.l    R_G9_PfeilUp,0,0,0,0
  2263.     dc.w    8,0,0
  2264. R_G10    dc.l    R_G11
  2265.     dc.w    11,51-16+63+18,15,9,GADGHNONE!GADGIMAGE,RELVERIFY!GADGIMMEDIATE,BOOLGADGET
  2266.     dc.l    R_G10_PfeilD,0,0,0,0
  2267.     dc.w    9,0,0
  2268. R_G11    dc.l    R_G12
  2269.     dc.w    11,61-16,15,52+18,GADGHNONE!GADGIMAGE,RELVERIFY!GADGIMMEDIATE,PROPGADGET
  2270.     dc.l    R_G11_mover,0,0,0,R_G11_Info
  2271.     dc.w    10,0,0
  2272. R_G11_mover    ds.w    6
  2273. R_G11_Info    dc.w    AUTOKNOB!PROPBORDERLESS!FREEVERT
  2274.     dc.w    0,0,0,$ffff
  2275.     ds.w    7
  2276. R_G12    dc.l    R_G13
  2277.     dc.w    27,51-16+(0*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2278.     dc.l    0,0,0,0,0
  2279.     dc.w    11,0,0
  2280. R_G13    dc.l    R_G14
  2281.     dc.w    27,51-16+(1*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2282.     dc.l    0,0,0,0,0
  2283.     dc.w    12,0,0
  2284. R_G14    dc.l    R_G15
  2285.     dc.w    27,51-16+(2*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2286.     dc.l    0,0,0,0,0
  2287.     dc.w    13,0,0
  2288. R_G15    dc.l    R_G16
  2289.     dc.w    27,51-16+(3*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2290.     dc.l    0,0,0,0,0
  2291.     dc.w    14,0,0
  2292. R_G16    dc.l    R_G17
  2293.     dc.w    27,51-16+(4*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2294.     dc.l    0,0,0,0,0
  2295.     dc.w    15,0,0
  2296. R_G17    dc.l    R_G18
  2297.     dc.w    27,51-16+(5*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2298.     dc.l    0,0,0,0,0
  2299.     dc.w    16,0,0
  2300. R_G18    dc.l    R_G19
  2301.     dc.w    27,51-16+(6*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2302.     dc.l    0,0,0,0,0
  2303.     dc.w    17,0,0
  2304. R_G19    dc.l    R_G20
  2305.     dc.w    27,51-16+(7*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2306.     dc.l    0,0,0,0,0
  2307.     dc.w    18,0,0
  2308. R_G20    dc.l    R_G21
  2309.     dc.w    27,51-16+(8*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2310.     dc.l    0,0,0,0,0
  2311.     dc.w    19,0,0
  2312. R_G21    dc.l    0
  2313.     dc.w    27,51-16+(9*9),259+72,9,GADGHCOMP,RELVERIFY,BOOLGADGET
  2314.     dc.l    0,0,0,0,0
  2315.     dc.w    20,0,0
  2316. R_G22
  2317.  
  2318.  
  2319.  
  2320. R_FileBox    BOX    0,0,276+72,73+18,6,R_FileBox2
  2321. R_FileBox2    BOX    0,0,16,73+18,6,R_FileBox3
  2322. R_FileBox3    BOX    0,10,16,63+18,6,0
  2323.  
  2324.  
  2325. R_maxEntries equ 300
  2326.  
  2327. FileRequester    cmp.l    #R_G1,R_def+nw_FirstGadget
  2328.     beq.s    R_1
  2329.     clr.w    R_G7+gg_Activation        
  2330.     
  2331. R_1    lea.l    R_def(pc),a0
  2332.     bsr    MakeWindow
  2333.     tst.l    d0
  2334.     beq    Rexit
  2335.     move.l    d0,R_Window
  2336.  
  2337.     move.l    d0,a1
  2338.     move.l    wd_RPort(a1),a1
  2339.     moveq.l    #0,d0
  2340.     CALLGRAF_PC    SetAPen
  2341.     move.l    R_Window(pc),a1
  2342.     move.l    wd_RPort(a1),a1
  2343.     move.w    #10+17,d0
  2344.     move.w    #51-16,d1
  2345.     move.w    #11+273+1+72,d2
  2346.     move.w    #49+73+2,d3
  2347.     CALLGRAF_PC    RectFill
  2348.  
  2349.     move.l    R_Window(pc),a1
  2350.     move.l    wd_RPort(a1),a1
  2351.     move.l    a1,a2    
  2352.     moveq.l    #RP_JAM1,d0    
  2353.     CALLGRAF_PC    SetDrMd
  2354.     move.l    a2,a1
  2355.     move.w    #11,d1
  2356.     move.w    #(296+72-320)/2,d0
  2357.     CALLGRAF_PC    Move    
  2358.     move.l    a2,a1    
  2359.     moveq.l    #0,d0
  2360.     CALLGRAF_PC    SetAPen    
  2361.     move.l    a5,a0
  2362.     move.l    a2,a1
  2363.     move.l    #40,d0
  2364.     CALLGRAF_PC    Text
  2365.     move.l    a2,a1    
  2366.     move.w    #10,d1
  2367.     move.w    #(296+72-320)/2,d0
  2368.     CALLGRAF_PC    Move    
  2369.     move.l    a2,a1    
  2370.     moveq.l    #1,d0
  2371.     CALLGRAF_PC    SetAPen    
  2372.     move.l    a5,a0
  2373.     move.l    a2,a1
  2374.     move.l    #40,d0
  2375.     CALLGRAF_PC    Text
  2376.  
  2377.     move.l    a2,a1    
  2378.     moveq.l    #RP_JAM2,d0    
  2379.     CALLGRAF_PC    SetDrMd
  2380.  
  2381.     move.l    R_Window(pc),a1
  2382.     sub.l    a2,a2
  2383.     lea.l    R_G17(pc),a0
  2384.     CALLINT_PC    RefreshGadgets
  2385.  
  2386.  
  2387.     move.l    R_Window(pc),a0
  2388.     move.l    wd_RPort(a0),a0
  2389.     lea.l    R_FileBox(pc),a1
  2390.     moveq.l    #10,d0
  2391.     move.w    #50-16,d1
  2392.     CALLINT_PC    DrawBorder
  2393.  
  2394.     move.l    #-1,R_Selected
  2395.  
  2396.     tst.l    R_Read
  2397.     beq    R_Label30
  2398.  
  2399.     
  2400. R_NewDrawer    clr.l    R_Anzahl
  2401.     clr.l    R_Position
  2402.     move.l    #-1,R_Selected
  2403.     bsr    R_RemakeGadget
  2404.     bsr    R_RemakeProp
  2405.     move.l    R_Window(pc),a1
  2406.     move.l    wd_RPort(a1),a1
  2407.     moveq.l    #0,d0
  2408.     CALLGRAF_PC    SetAPen
  2409.     move.l    R_Window(pc),a1
  2410.     move.l    wd_RPort(a1),a1
  2411.     move.w    #10+17,d0
  2412.     move.w    #51-16,d1
  2413.     move.w    #11+273+72,d2
  2414.     move.w    #49+73+2,d3
  2415.     CALLGRAF_PC    RectFill
  2416.  
  2417.     move.l    #R_Drawer,d1
  2418.     moveq.l    #-2,d2
  2419.     CALLDOS_PC    Lock
  2420.     move.l    d0,R_Lock
  2421.     tst.l    d0
  2422.     beq    R_Error
  2423.     move.l    R_Lock(pc),d1
  2424.     move.l    #R_FIB,d2
  2425.     CALLDOS_PC    Examine
  2426.     tst.l    d0
  2427.     beq    R_freeLock
  2428.     move.l    R_Lock(pc),d1
  2429.     move.l    #R_FIB,d2
  2430.     CALLDOS_PC    ExNext
  2431.     tst.l    d0
  2432.     beq    R_freeLock
  2433.     
  2434.  
  2435. R_Label14    lea.l    R_FIB(pc),a0
  2436.     move.l    R_Anzahl(pc),d0
  2437.     mulu    #38,d0
  2438.     add.l    R_Namen(pc),d0
  2439.     move.l    d0,a1
  2440.     move.l    fib_DirEntryType(a0),d0
  2441.     and.l    #1,d0
  2442.     move.b    d0,(a1)+
  2443.     move.w    #31,d0
  2444.     lea.l    fib_FileName(a0),a0
  2445. R_Label20    move.b    (a0)+,(a1)+
  2446.     dbra    d0,R_Label20
  2447.     clr.b    (a1)+
  2448.     move.l    fib_Size+R_FIB,(a1)+
  2449.     addq.l    #1,R_Anzahl
  2450.     
  2451.     bsr    R_RemakeProp
  2452.  
  2453.     move.l    #1,R_Read
  2454.  
  2455.     move.l    R_Window(pc),a0
  2456.     move.l    wd_UserPort(a0),a0
  2457.     CALLEXEC    GetMsg
  2458.     tst.l    d0
  2459.     beq    R_Label40
  2460.     move.l    d0,a1
  2461.     moveq.l    #0,d2
  2462.     moveq.l    #0,d3
  2463.     move.l    im_Class(a1),d4
  2464.     move.w    im_Code(a1),d5
  2465.     move.l    im_IAddress(a1),a4
  2466.     CALLEXEC    ReplyMsg
  2467.     moveq.l    #0,d0
  2468.     move.b    gg_GadgetID+1(a4),d0
  2469.     cmp.b    #30,d0
  2470.     beq.s    R_Label41a
  2471.     tst.b    d0    
  2472.     bmi.s    R_Label41a
  2473.     cmp.b    #7,d0
  2474.     bhi    R_Label40
  2475.  
  2476.  
  2477. R_Label41a    move.l    d0,d6
  2478.     move.l    R_Lock(pc),d1
  2479.     CALLDOS_PC    UnLock
  2480.     move.l    d6,d0
  2481.     bra    R_Label41
  2482.  
  2483. R_Label40    cmp.l    #R_maxEntries,R_Anzahl
  2484.     beq    R_Label40a
  2485.     move.l    R_Lock(pc),d1
  2486.     move.l    #R_FIB,d2
  2487.     CALLDOS_PC    ExNext
  2488.     tst.l    d0
  2489. R_Label40a    bne    R_Label14
  2490.     clr.l    R_Read
  2491.  
  2492. R_freeLock    move.l    R_Lock(pc),d1
  2493.     CALLDOS_PC    UnLock
  2494. R_V3    bsr    R_SORT
  2495.     
  2496. R_Label30    bsr    R_RemakeGadget
  2497.  
  2498.     bsr    R_RemakeProp
  2499.     bsr    R_FilePrint
  2500.  
  2501.     move.l    R_def+nw_FirstGadget(pc),a0
  2502.     move.l    R_Window(pc),a1
  2503.     sub.l    a2,a2
  2504.     CALLINT_PC    RefreshGadgets
  2505.     
  2506.  
  2507. R_wait    move.l    R_Window(pc),a0
  2508.     move.l    wd_UserPort(a0),a0
  2509.     move.l    a0,a4
  2510.     CALLEXEC    WaitPort
  2511.     move.l    a4,a0
  2512.     CALLEXEC    GetMsg
  2513.     tst.l    d0
  2514.     beq.s    R_wait
  2515.     move.l    d0,a1
  2516.     moveq.l    #0,d2
  2517.     moveq.l    #0,d3
  2518.     move.l    im_Class(a1),d4
  2519.     move.w    im_Code(a1),d5
  2520.     move.l    im_IAddress(a1),a4
  2521.     CALLEXEC    ReplyMsg
  2522.     moveq.l    #0,d0
  2523.     move.b    gg_GadgetID+1(a4),d0
  2524.  
  2525. R_Label41    cmp.b    #10,d0
  2526.     beq    R_PROP
  2527.     cmp.b    #8,d0
  2528.     beq    R_UP
  2529.     
  2530.     cmp.b    #9,d0
  2531.     beq    R_DOWN
  2532.     cmp.b    #2,d0
  2533.     beq    R_DF0
  2534.     cmp.b    #3,d0
  2535.     beq    R_DF1    
  2536.     cmp.b    #30,d0
  2537.     beq    R_DEVICES
  2538.     cmp.b    #4,d0
  2539.     beq    R_RAM
  2540.     cmp.b    #7,d0
  2541.     beq    R_NewDrawer
  2542.     cmp.b    #5,d0
  2543.     beq    R_Parent
  2544.     cmp.b    #10,d0
  2545.     bgt    R_Select
  2546.     cmp.b    #1,d0
  2547.     beq    RcloseWindow
  2548.     move.b    d0,R_Gadget
  2549. R_OK    lea.l    R_Drawer(pc),a0
  2550.     lea.l    R_FileName(pc),a1
  2551. R_Label120    move.b    (a0)+,(a1)+
  2552.     bne.s    R_Label120
  2553.     tst.b    -(a1)
  2554.     cmp.b    #":",-1(a1)
  2555.     beq.s    R_Label122
  2556.     move.b    #"/",(a1)+
  2557. R_Label122    lea.l    R_File(pc),a0
  2558. R_Label121    move.b    (a0)+,(a1)+
  2559.     bne.s    R_Label121
  2560.     move.l    R_Window(pc),A0
  2561.     CALLINT_PC    CloseWindow
  2562.     move.l    #R_FileName,d0
  2563.     rts
  2564. ;
  2565. ; prop gadget
  2566. ;
  2567.  
  2568. R_PROP    cmp.l    #GADGETUP,d4
  2569.     beq.s    .UpDown
  2570.     bsr    R_ChangePos
  2571.     move.l    R_Window(pc),a0
  2572.     move.l    wd_UserPort(a0),a0
  2573.     CALLEXEC    GetMsg
  2574.     tst.l    d0
  2575.     beq.s    R_PROP
  2576.     move.l    d0,a1
  2577.     CALLEXEC    ReplyMsg    
  2578. .UpDown    bsr    R_ChangePos
  2579.     bra    R_wait
  2580.  
  2581. RcloseWindow    move.l    R_Window(pc),A0
  2582.     CALLINT_PC    CloseWindow
  2583. Rexit    moveq.l    #0,d0
  2584.     rts
  2585.     dc.b    "::"
  2586. R_FileName    ds.b    400
  2587. R_Namen    dc.l    NamenPuffer
  2588. R_Lock    dc.l    0
  2589. R_Anzahl    dc.l    0    
  2590. R_Position    dc.l    0
  2591. R_Selected    dc.l    0
  2592. R_Read    dc.l    1
  2593. R_Puffer    ds.b    48*11
  2594. R_Gadget    dc.b    0
  2595.     cnop    0,4
  2596. R_FIB    ds.b    $104
  2597. R_SORT    cmp.l    #1,R_Anzahl
  2598.     bls    R_SORT_Label0    
  2599.     movem.l    d1-d7/a0-a2,-(sp)
  2600.     move.l    a0,a2
  2601.  
  2602.     move.l    R_Anzahl(pc),d5
  2603.     subq.l    #1,d5
  2604.  
  2605. R_SORT_Label1    moveq.l    #0,d7    
  2606.     moveq.l    #0,d6    
  2607.     
  2608. R_SORT_Label2    move.l    d6,d0
  2609.     move.l    d0,d1
  2610.     addq.l    #1,d1
  2611.     bsr    R_COMPARE
  2612.     bls.s    R_SORT_Label3
  2613.  
  2614.     move.l    d6,d0
  2615.     move.l    d0,d1
  2616.     addq.l    #1,d1
  2617.     moveq.l    #1,d7
  2618.     bsr    R_SWAP
  2619.  
  2620. R_SORT_Label3    addq    #1,d6
  2621.     cmp.l    d6,d5
  2622.     bhi    R_SORT_Label2
  2623.  
  2624.     subq    #1,d5
  2625.  
  2626.     tst.b    d7
  2627.     bne    R_SORT_Label1    
  2628.  
  2629.     movem.l    (sp)+,d1-d7/a0-a2
  2630. R_SORT_Label0    rts
  2631. R_COMPARE    mulu    #38,d0
  2632.     mulu    #38,d1
  2633.     add.l    R_Namen(pc),d0
  2634.     add.l    R_Namen(pc),d1
  2635.     move.l    d0,a0
  2636.     move.l    d1,a1
  2637.     move.w    #38,d2
  2638.     subq.l    #1,d2
  2639. R_SORT_Label6    move.b    (a1)+,d0
  2640.     jsr    UPCASE
  2641.     move.b    d0,d1
  2642.     move.b    (a0)+,d0
  2643.     jsr    UPCASE
  2644. R_SORT_Label8    cmp.b    d1,d0
  2645.     bne.s    R_SORT_Label5
  2646.     dbra    d2,R_SORT_Label6
  2647. R_SORT_Label5    rts
  2648. R_SWAP    mulu    #38,d0
  2649.     mulu    #38,d1
  2650.     add.l    R_Namen(pc),d0
  2651.     add.l    R_Namen(pc),d1
  2652.     move.l    d0,a0
  2653.     move.l    d1,a1
  2654.     move.w    #38,d0
  2655.     subq.l    #1,d0
  2656. R_SORT_Label9    move.b    (a0),d1
  2657.     move.b    (a1),(a0)+
  2658.     move.b    d1,(a1)+
  2659.     dbra    d0,R_SORT_Label9
  2660.     rts
  2661. R_DF0    move.l    #"df0:",R_Drawer
  2662.     clr.b    R_Drawer+4
  2663.     lea.l    R_G8(pc),a0
  2664.     move.l    R_Window(pc),a1
  2665.     sub.l    a2,a2
  2666.     CALLINT_PC    RefreshGadgets
  2667.     bra    R_NewDrawer
  2668. R_DF1    move.l    DriveName,R_Drawer
  2669.     clr.b    R_Drawer+4
  2670.     lea.l    R_G8(pc),a0
  2671.     move.l    R_Window(pc),a1
  2672.     sub.l    a2,a2
  2673.     CALLINT_PC    RefreshGadgets
  2674.     bra    R_NewDrawer
  2675. R_RAM    move.l    #"ram:",R_Drawer
  2676.     clr.b    R_Drawer+4
  2677.     lea.l    R_G8(pc),a0
  2678.     move.l    R_Window(pc),a1
  2679.     sub.l    a2,a2
  2680.     CALLINT_PC    RefreshGadgets
  2681.     bra    R_NewDrawer
  2682. R_Parent    lea.l    R_Drawer(pc),a0
  2683.     move.l    a0,a1
  2684. R_Label60    tst.b    (a0)+
  2685.     bne.s    R_Label60
  2686.     tst.b    -(a0)
  2687.     tst.b    -(a0)
  2688. R_Label61    cmp.l    a0,a1
  2689.     beq.s    R_Label62
  2690.     move.b    -(a0),d0
  2691.     cmp.b    #":",d0
  2692.     beq.s    R_Label63
  2693.     cmp.b    #"/",d0
  2694.     bne.s    R_Label61
  2695.     tst.b    -(a0)
  2696. R_Label63    clr.b    1(a0)
  2697.     lea.l    R_G8(pc),a0
  2698.     move.l    R_Window(pc),a1
  2699.     sub.l    a2,a2
  2700.     CALLINT_PC    RefreshGadgets
  2701.     bra    R_NewDrawer
  2702. R_Label62    bra    R_wait
  2703.  
  2704. R_Text    dc.b    "Drawer doesn't exist !",0 
  2705. R_Error    bsr    R_RemakeGadget
  2706.     bsr    R_RemakeProp
  2707.     bsr    R_FilePrint
  2708.     move.l    R_Window(pc),a1
  2709.     move.l    wd_RPort(a1),a1
  2710.     move.l    a1,a2    
  2711.     move.l    #58+(3*9),d1
  2712.     move.l    #68+(72/2),d0
  2713.     CALLGRAF_PC    Move    
  2714.     move.l    a2,a1    
  2715.     moveq.l    #6,d0
  2716.     CALLGRAF_PC    SetAPen    
  2717.     lea.l    R_Text(pc),a3
  2718.     move.l    a3,a0
  2719.     move.l    a2,a1
  2720.     moveq.l    #-1,d0
  2721. R_Label100    addq.l    #1,d0
  2722.     tst.b    (a3)+
  2723.     bne.s    R_Label100
  2724.     CALLGRAF_PC    Text
  2725.     bra    R_wait
  2726.  
  2727. R_Select    sub.b    #11,d0
  2728.     and.l    #$f,d0
  2729.     add.l    R_Position(pc),d0
  2730.     move.l    d0,d7
  2731.     mulu    #38,d0
  2732.     add.l    R_Namen(pc),d0
  2733.     move.l    d0,a0
  2734.     move.b    (a0)+,d0
  2735.     beq    R_Dir
  2736.     cmp.b    #2,d0
  2737.     beq    R_DEV
  2738.     
  2739.     lea.l    R_File(pc),a1
  2740.     move.w    #31,d0
  2741. R_Label70    move.b    (a0)+,(a1)+
  2742.     beq.s    R_Label71
  2743.     dbra    d0,R_Label70
  2744. R_Label71    lea.l    R_G7(pc),a0
  2745.     move.l    R_Window(pc),a1
  2746.     sub.l    a2,a2
  2747.     CALLINT_PC    RefreshGadgets
  2748.     cmp.l    #R_G1,R_def+nw_FirstGadget
  2749.     bne    R_wait
  2750.     cmp.l    R_Selected(pc),d7
  2751.     beq    R_OK    
  2752.     move.l    d7,R_Selected
  2753.     bra    R_wait
  2754. R_Dir    lea.l    R_Drawer(pc),a1
  2755. R_Label72    tst.b    (a1)+
  2756.     bne.s    R_Label72
  2757.     tst.b    -(a1)
  2758.     cmp.b    #":",-1(a1)
  2759.     beq    R_Label75
  2760.     move.b    #"/",(a1)+
  2761. R_Label75    move.w    #31,d0
  2762. R_Label73    move.b    (a0)+,(a1)+
  2763.     beq.s    R_Label74
  2764.     dbra    d0,R_Label73
  2765. R_Label74    lea.l    R_G7(pc),a0
  2766.     move.l    R_Window(pc),a1
  2767.     sub.l    a2,a2
  2768.     CALLINT_PC    RefreshGadgets
  2769.     bra    R_NewDrawer
  2770.  
  2771. R_DEV    lea.l    R_Drawer(pc),a1
  2772.     move.w    #31,d0
  2773. R_Label200    move.b    (a0)+,(a1)+
  2774.     beq.s    R_Label201
  2775.     dbra    d0,R_Label200
  2776. R_Label201    lea.l    R_G7(pc),a0
  2777.     move.l    R_Window(pc),a1
  2778.     sub.l    a2,a2
  2779.     CALLINT_PC    RefreshGadgets
  2780.     bra    R_NewDrawer
  2781.  
  2782. R_Colors    dc.b    1,6,2
  2783.     even
  2784. R_FilePrint    move.l    #48*11-1,d0
  2785.     lea.l    R_Puffer(pc),a0
  2786. R_Label1    move.b    #" ",(a0)+
  2787.     dbra    d0,R_Label1    
  2788.     move.l    R_Position(pc),d0
  2789.     move.l    d0,d6
  2790.     moveq.l    #0,d5
  2791.     mulu    #38,d0
  2792.     add.l    R_Namen(pc),d0
  2793.     move.l    d0,a0
  2794.  
  2795. R_Label2    move.l    d5,d0
  2796.     mulu    #48,d0
  2797.     add.l    #R_Puffer,d0
  2798.     move.l    d0,a1
  2799.  
  2800.     cmp.l    R_Anzahl(pc),d6
  2801.     beq    R_Label6
  2802.  
  2803.     move.b    (a0)+,(a1)+
  2804.     moveq.l    #0,d1
  2805.     move.l    #31,d4
  2806. R_Label3    move.b    (a0)+,d0
  2807.     tst.b    d1
  2808.     bne.s    R_Label3a
  2809.     tst.b    d0
  2810.     bne.s    R_Label4
  2811.     moveq.l    #1,d1
  2812. R_Label3a    move.b    #" ",d0
  2813. R_Label4    move.b    d0,(a1)+
  2814.     dbra    d4,R_Label3
  2815.     lea.l    1(a1),a1
  2816.     lea.l    1(a0),a0    
  2817.     move.l    (a0)+,d0
  2818.     bsr    R_PrintSize
  2819.     addq.l    #1,d6
  2820.     addq.l    #1,d5
  2821.     cmp.b    #10,d5
  2822.     bne    R_Label2
  2823.  
  2824. R_Label6    lea.l    R_Puffer(pc),a3
  2825.     moveq.l    #0,d5
  2826.     
  2827. R_Label5    move.l    R_Window(pc),a1
  2828.     move.l    wd_RPort(a1),a1    
  2829.     move.l    a1,a2
  2830.     move.l    #28,d0
  2831.     move.l    d5,d1
  2832.     mulu    #9,d1    
  2833.     add.l    #58-16,d1    
  2834.     CALLGRAF_PC    Move        
  2835.     move.l    a2,a1    
  2836.     lea.l    R_Colors(pc),a0
  2837.     and.l    #$f,d0    
  2838.     move.b    (a3)+,d0
  2839.     move.b    (a0,d0),d0
  2840.     CALLGRAF_PC    SetAPen
  2841.     move.l    a2,a1        
  2842.     move.l    a3,a0
  2843.     move.l    #41,d0
  2844.     CALLGRAF_PC    Text
  2845.     add.l    #47,a3
  2846.     addq    #1,d5
  2847.     cmp.b    #10,d5
  2848.     bne    R_Label5
  2849.     rts
  2850.  
  2851. R_PrintSize    movem.l    d0-d7/a0-a5,-(sp)
  2852.     move.b    -38(a0),d2
  2853.     tst.b    d2
  2854.     beq    R_PS_Dir
  2855.     cmp.b    #2,d2
  2856.     beq    R_PS_Dev
  2857.     moveq.l    #7,d2
  2858.     moveq.l    #0,d3
  2859.     lea.l    R_Potenzen(pc),a2
  2860. R_PS1    move.b    #"0"-1,d1
  2861. R_PS2    addq    #1,d1
  2862.     sub.l    (a2),d0
  2863.     bcc    R_PS2
  2864.     add.l    (a2)+,d0
  2865.     tst.b    d2
  2866.     beq    R_PS3
  2867.     cmp.b    #"0",d1
  2868.     beq    R_PS4
  2869.     moveq.l    #1,d3
  2870.     bra    R_PS3
  2871. R_PS4    tst.b    d3
  2872.     bne    R_PS3
  2873.     move.b    #" ",d1
  2874. R_PS3    move.b    d1,(a1)+
  2875.     dbra    d2,R_PS1
  2876.     movem.l    (sp)+,d0-d7/a0-a5
  2877.     rts
  2878. R_Potenzen    dc.l    10000000
  2879.     dc.l    1000000
  2880.     dc.l    100000
  2881.     dc.l    10000
  2882.     dc.l    1000
  2883.     dc.l    100
  2884.     dc.l    10
  2885.     dc.l    1
  2886. R_PS_Dir_Text    dc.b    " « Dir »"
  2887. R_PS_Dev_Text    dc.b    " « Dev »"
  2888.  
  2889. R_PS_Dir    lea.l    R_PS_Dir_Text(pc),a2
  2890.     moveq.l    #7,d0
  2891. R_PS_Dir2    move.b    (a2)+,(a1)+
  2892.     dbra    d0,R_PS_Dir2
  2893.     movem.l    (sp)+,d0-d7/a0-a5
  2894.     rts
  2895. R_PS_Dev    lea.l    R_PS_Dev_Text(pc),a2
  2896.     moveq.l    #7,d0
  2897. R_PS_Dev2    move.b    (a2)+,(a1)+
  2898.     dbra    d0,R_PS_Dev2
  2899.     movem.l    (sp)+,d0-d7/a0-a5
  2900.     rts
  2901.     
  2902.  
  2903. R_UP    tst.l    R_Position
  2904.     beq    R_wait
  2905.     bmi    R_wait
  2906.     sub.l    #1,R_Position
  2907.     bsr    R_FilePrint
  2908.     bsr    R_RemakeProp
  2909.     move.l    R_Window(pc),a0
  2910.     move.l    wd_UserPort(a0),a0
  2911.     CALLEXEC    GetMsg
  2912.     tst.l    d0
  2913.     beq    R_UP
  2914.     move.l    d0,a1
  2915.     CALLEXEC    ReplyMsg
  2916.     bra    R_wait
  2917. R_DOWN    move.l    R_Position(pc),d0
  2918.     add.l    #10,d0
  2919.     cmp.l    R_Anzahl(pc),d0
  2920.     bge    R_wait
  2921.     add.l    #1,R_Position
  2922.     bsr    R_FilePrint
  2923.     bsr    R_RemakeProp
  2924.     move.l    R_Window(pc),a0
  2925.     move.l    wd_UserPort(a0),a0
  2926.     CALLEXEC    GetMsg
  2927.     tst.l    d0
  2928.     beq    R_DOWN
  2929.     move.l    d0,a1
  2930.     CALLEXEC    ReplyMsg
  2931.     bra    R_wait
  2932.  
  2933. R_RemakeProp    lea.l    R_G11(pc),a0
  2934.     move.l    R_Window(pc),a1
  2935.     sub.l    a2,a2
  2936.     move.l    #AUTOKNOB!PROPBORDERLESS!FREEVERT,d0
  2937.     moveq.l    #0,d1
  2938.     moveq.l    #0,d3
  2939.     move.l    R_Anzahl(pc),d2
  2940.     sub.l    #10,d2
  2941.     tst.w    d2
  2942.     beq.s    R_Label10x
  2943.     bpl.s    R_Label10
  2944. R_Label10x    moveq.l    #1,d2
  2945. R_Label10    move.l    #$ffff,d4
  2946.     divu    d2,d4
  2947.     and.l    #$ffff,d4    
  2948.     move.l    R_Position,d2
  2949. R_Label11    mulu    d4,d2        
  2950.     CALLINT_PC    ModifyProp
  2951.     rts
  2952. R_ChangePos    cmp.l    #10,R_Anzahl
  2953.     bls    R_Label12
  2954.     lea.l    R_G11_Info(pc),a0
  2955.     moveq.l    #0,d0
  2956.     move.w    pi_VertPot(a0),d0
  2957.     divu    pi_VertBody(a0),d0
  2958.     and.l    #$ffff,d0
  2959.     cmp.l    R_Position,d0
  2960.     beq    R_Label12
  2961.     move.l    d0,R_Position
  2962.     bsr    R_FilePrint
  2963. R_Label12    rts
  2964. R_RemakeGadget    lea.l    R_G12(pc),a0
  2965.     move.l    R_Anzahl,d0
  2966.     cmp.l    #10,d0
  2967.     bls    R_Label50
  2968.     moveq.l    #10,d0
  2969. R_Label50    tst.l    d0
  2970.     beq    R_Label51
  2971.     move.w    #GADGHCOMP,gg_Flags(a0)
  2972.     move.w    #RELVERIFY,gg_Activation(a0)
  2973.     lea.l    gg_SIZEOF(a0),a0
  2974.     subq.l    #1,d0
  2975.     bra.s    R_Label50
  2976. R_Label51    cmp.l    #R_G22,a0
  2977.     beq    R_Label52
  2978.     move.w    #GADGHNONE,gg_Flags(a0)
  2979.     clr.w    gg_Activation(a0)
  2980.     lea.l    gg_SIZEOF(a0),a0
  2981.     bra.s    R_Label51
  2982. R_Label52    rts
  2983.  
  2984. R_DEVICES    clr.l    R_Anzahl
  2985.     clr.l    R_Position
  2986.     move.l    #-1,R_Selected
  2987.     bsr    R_RemakeGadget
  2988.     bsr    R_RemakeProp
  2989.     move.l    R_Window,a1
  2990.     move.l    wd_RPort(a1),a1
  2991.     moveq.l    #0,d0
  2992.     CALLGRAF_PC    SetAPen
  2993.     move.l    R_Window,a1
  2994.     move.l    wd_RPort(a1),a1
  2995.     move.w    #10+17,d0
  2996.     move.w    #51-16,d1
  2997.     move.w    #11+273+1+72,d2
  2998.     move.w    #49+75,d3
  2999.     CALLGRAF_PC    RectFill
  3000.     move.l    _DOSBase,a2
  3001.     move.l    dl_Root(a2),a2
  3002.     move.l    rn_Info(a2),a2
  3003.     add.l    a2,a2
  3004.     add.l    a2,a2
  3005.     move.l    di_DevInfo(a2),a2
  3006.     add.l    a2,a2
  3007.     add.l    a2,a2
  3008.     
  3009. R_V1    cmp.l    #DLT_DEVICE,dl_Type(a2)
  3010.     bne    R_V2
  3011.     tst.l    dl_Task(a2)
  3012.     beq    R_V2    
  3013.     move.l    R_Anzahl,d0
  3014.     mulu    #38,d0
  3015.     add.l    R_Namen,d0
  3016.     move.l    d0,a1
  3017.     move.b    #2,(a1)+
  3018.     move.l    a1,a3
  3019.     moveq.l    #0,d0
  3020.     move.l    dl_Name(a2),a0
  3021.     add.l    a0,a0
  3022.     add.l    a0,a0
  3023.     move.b    (a0)+,d0
  3024.     subq    #1,d0
  3025. R_V20    move.b    (a0)+,(a1)+
  3026.     dbra    d0,R_V20
  3027.     move.b    #":",(a1)+
  3028.     clr.b    (a1)
  3029.  
  3030. R_V23    addq.l    #1,R_Anzahl
  3031. R_V2    move.l    (a2),a2
  3032.     add.l    a2,a2
  3033.     add.l    a2,a2
  3034.     cmp.l    #0,a2
  3035.     bne    R_V1
  3036.     bra    R_V3
  3037.     even
  3038.  
  3039. WindowPointer set Window1
  3040.  
  3041. PrintMode    SETDRMD    #RP_JAM2        ; write mode  (0=HEX, 1=ASC)
  3042.     SETBPEN    #2    
  3043.     move.l    WindowPointer,a1
  3044.     move.l    wd_RPort(a1),a1    
  3045.     move.l    FONT80(pc),a0
  3046.     CALLGRAF_PC    SetFont
  3047.     
  3048.     move.b    Mode,d0
  3049.     tst.b    d0
  3050.     beq    PM1
  3051.     WRITE    #(484+78+((78-3*8)/2)),#11+149+15-4+6,#0,<"HEX">
  3052.     rts
  3053. PM1    WRITE    #(484+78+((78-3*8)/2)),#11+149+15-4+6,#0,<"ASC">
  3054.     rts
  3055.  
  3056. PS_Text    dc.b    "$.../..."
  3057.     even
  3058.  
  3059. PrintPosition    SETDRMD    #RP_JAM2        ; write cursor position
  3060.     SETBPEN    #2
  3061.     move.l    WindowPointer(pc),a1
  3062.     move.l    wd_RPort(a1),a1    
  3063.     move.l    FONT80(pc),a0
  3064.     CALLGRAF_PC    SetFont
  3065.     
  3066.     move.l    Cursor(pc),d0        
  3067.     lea.l    PS_Text+1(pc),a5    
  3068.     lea.l    HEX(pc),a4
  3069.     lsr.l    #8,d0
  3070.     move.b    (a4,d0),(a5)+
  3071.     move.l    Cursor(pc),d0
  3072.     lsr.l    #4,d0
  3073.     and.l    #$f,d0
  3074.     move.b    (a4,d0),(a5)+
  3075.     move.l    Cursor(pc),d0
  3076.     and.l    #$f,d0
  3077.     move.b    (a4,d0),(a5)+
  3078.     
  3079.     move.l    Cursor(pc),d0
  3080.     lea.l    1(a5),a5
  3081.     moveq.l    #2,d2
  3082.     moveq.l    #0,d3
  3083.     lea.l    PS_Potenzen(pc),a2
  3084. .PS1    move.b    #"0"-1,d1
  3085. .PS2    addq    #1,d1
  3086.     sub.l    (a2),d0
  3087.     bcc.s    .PS2
  3088.     add.l    (a2)+,d0
  3089.     tst.b    d2
  3090.     beq.s    .PS3
  3091.     cmp.b    #"0",d1
  3092.     beq.s    .PS4
  3093.     moveq.l    #1,d3
  3094.     bra.s    .PS3
  3095. .PS4    tst.b    d3
  3096.     bne.s    .PS3
  3097.     move.b    #" ",d1
  3098. .PS3    move.b    d1,(a5)+
  3099.     dbra    d2,.PS1
  3100.     WRITEMEM    #484+((78-8*8)/2),#11+149+15-4+6,#0,PS_Text,#8
  3101.     rts
  3102.  
  3103. PS_Potenzen    dc.l    100
  3104.     dc.l    10
  3105.     dc.l    1
  3106.  
  3107. ASC_Gadget    sub.l    ASC_X,d6        ; user clicked ASC gadget
  3108.     sub.l    ASC_Y,d7
  3109.     add.l    BaseLine,d7
  3110.     tst.l    d6
  3111.     bmi.s    .wait
  3112.     tst.l    d7
  3113.     bmi.s    .wait
  3114.     divu    FONT_X+2,d6
  3115.     and.l    #$ff,d6
  3116.     cmp.l    Bytes_Per_Row,d6
  3117.     bge.s    .wait
  3118.     divu    FONT_Y+2,d7
  3119.     and.l    #$ff,d7
  3120.     mulu    ASC_Breite+2,d7
  3121.     add.l    d6,d7
  3122.     cmp.l    AnzahlBytes,d7
  3123.     bge.s    .wait
  3124.     move.l    d7,d0
  3125.     bsr    SetCursor
  3126.     clr.b    Mode
  3127.     bsr    PrintPosition
  3128.     bra    NewMode
  3129. .wait    bra    wait
  3130.  
  3131. HEX_Gadget    sub.l    HEX_X,d6    ; user clicked HEX gadget
  3132.     sub.l    HEX_Y,d7
  3133.     add.l    BaseLine,d7
  3134.     and.l    #$ffff,d7
  3135.     divu    FONT_Y+2,d7
  3136.     and.l    #$ffff,d7
  3137.     mulu    Bytes_Per_Row+2,d7
  3138.     
  3139.     divu    FONT_X+2,d6
  3140.     and.l    #$ffff,d6    
  3141.     divu    #9,d6
  3142.  
  3143.     move.l    d6,d5
  3144.     and.l    #$ffff,d6
  3145.     lsl.w    #2,d6
  3146.     
  3147.     swap    d5
  3148.     and.l    #$ffff,d5
  3149.     cmp.b    #8,d5
  3150.     beq.s    .wait
  3151.     lsr.l    #1,d5
  3152.     add.l    d5,d6
  3153.     
  3154.     add.l    d6,d7
  3155.     cmp.l    AnzahlBytes,d7
  3156.     bge.s    .wait
  3157.     move.l    d7,d0
  3158.     bsr    SetCursor
  3159.     move.b    #1,Mode
  3160.     bsr    PrintPosition
  3161.     bra    NewMode
  3162. .wait    bra    wait
  3163.  
  3164. HEX_Input    moveq.l    #0,d0    
  3165.     move.b    ASCII(pc),d0
  3166.     lea.l    .Hex(pc),a0    ; convert ASCII (d0) to nibble (d1)
  3167.     moveq.l    #-1,d1
  3168. .L1    addq.l    #1,d1
  3169.     cmp.b    #32,d1
  3170.     bhi    .Error
  3171.     cmp.b    (a0)+,d0
  3172.     bne.s    .L1
  3173.     and.l    #$f,d1    ; don't care about A or a            
  3174.     
  3175.     cmp.b    #1,Mode    ; fist nibble ?    
  3176.     beq.s    .L2
  3177.     or.b    Nibble,d1
  3178.     lea.l    Puffer,a0
  3179.     add.l    Cursor(pc),a0
  3180.     move.b    d1,(a0)
  3181.     lea.l    Color,a0
  3182.     add.l    Cursor(pc),a0
  3183.     move.b    #1,(a0)
  3184.     move.b    #1,Mode
  3185.     move.l    Cursor(pc),d0
  3186.     addq.l    #1,d0
  3187.     cmp.l    AnzahlBytes,d0
  3188.     bge.s    .L3
  3189.     bsr    SetCursor
  3190.     bra    wait
  3191. .L3    move.l    Cursor(pc),d0
  3192.     bsr    SetCursor
  3193.     bra    wait
  3194.  
  3195. .L2    lea.l    .Hex+16(pc),a0
  3196.     move.b    (a0,d1),.ASCII
  3197.     lsl.b    #4,d1    
  3198.     move.b    d1,Nibble
  3199.     move.b    #3,Mode
  3200.  
  3201.     bsr    Set_Font    ; write first  nibble
  3202.     
  3203.     lea.l    Color,a0        
  3204.     move.l    Cursor(pc),d1
  3205.     move.b    (a0,d1),d1
  3206.     moveq.l    #4,d0
  3207.     moveq.l    #6,d4
  3208.     cmp.b    #1,d1
  3209.     beq.s    .L5
  3210.     addq.l    #2,d0
  3211.     subq.l    #2,d4
  3212. .L5    move.l    Window1(pc),a1
  3213.     move.l    wd_RPort(a1),a1    
  3214.     CALLGRAF_PC    SetBPen
  3215.     move.l    d4,d0
  3216.     move.l    Window1(pc),a1
  3217.     move.l    wd_RPort(a1),a1    
  3218.     CALLGRAF_PC    SetAPen
  3219.     
  3220.  
  3221.     moveq.l    #RP_JAM2,d0
  3222.     move.l    Window1(pc),a1
  3223.     move.l    wd_RPort(a1),a1    
  3224.     CALLGRAF_PC    SetDrMd    
  3225.  
  3226.     move.l    Cursor(pc),d0
  3227.     divu    Bytes_Per_Row+2,d0
  3228.     move.l    d0,d1
  3229.     lsr.l    #8,d0
  3230.     lsr.l    #8,d0
  3231.     move.l    d0,d2
  3232.     lsr.l    #2,d2
  3233.     lsl.l    #1,d0
  3234.     add.l    d2,d0
  3235.     mulu    FONT_X+2,d0
  3236.     add.l    HEX_X,d0
  3237.     and.l    #$ff,d1
  3238.     mulu    FONT_Y+2,d1
  3239.     add.l    HEX_Y,d1
  3240.  
  3241.     move.l    Window1(pc),a1
  3242.     move.l    wd_RPort(a1),a1
  3243.     CALLGRAF_PC    Move
  3244.     
  3245.     moveq.l    #1,d0
  3246.     move.l    Window1(pc),a1
  3247.     move.l    wd_RPort(a1),a1
  3248.     lea.l    .ASCII(pc),a0
  3249.     CALLGRAF_PC    Text
  3250.     bra    wait
  3251.  
  3252. .Hex    dc.b    "0123456789abcdef"
  3253.     dc.b    "0123456789ABCDEF"
  3254. .ASCII    dc.b    0
  3255.     even
  3256. .Error    bra    Error
  3257.  
  3258. BackSpace    cmp.b    #3,Mode
  3259.     bne    .UNDO_CHAR_BACK    ; delete last byte
  3260.     move.l    Cursor(pc),d0        ; delete last nibble
  3261.     bsr    SetCursor
  3262.     move.b    #1,Mode
  3263.     bra    wait
  3264. .UNDO_CHAR_BACK
  3265.     jmp    UNDO_CHAR_BACK
  3266.  
  3267.  
  3268. GetBlock    move.l    d0,.Offset
  3269.     tst.l    Memory        ; get block offset d0
  3270.     beq.s    .GetBlockDisk
  3271.     move.l    Memory(pc),a0
  3272.     add.l    d0,a0
  3273.     lea.l    Puffer,a1
  3274.     lea.l    UndoPuffer,a2
  3275.     move.l    #511,d0
  3276. .L0    move.b    (a0),(a1)+    
  3277.     move.b    (a0)+,(a2)+    
  3278.     dbra    d0,.L0
  3279.     move.l    Size(pc),d0
  3280.     sub.l    .Offset(pc),d0
  3281.     cmp.l    #512,d0
  3282.     bls.s    .L3
  3283.     move.l    #512,d0
  3284. .L3    move.l    d0,AnzahlBytes
  3285.     move.l    .Offset(pc),Offset
  3286.     bra    NewBlock
  3287.  
  3288. .GetBlockDisk    move.l    Filehandle(pc),d1
  3289.     tst.l    d1
  3290.     beq    .Error
  3291.     move.l    .Offset(pc),d2
  3292.     moveq.l    #OFFSET_BEGINNING,d3
  3293.     CALLDOS_PC    Seek
  3294.     move.l    Filehandle(pc),d1
  3295.     move.l    Size(pc),d3
  3296.     sub.l    .Offset(pc),d3
  3297.     cmp.l    #512,d3
  3298.     bls.s    .L1
  3299.     move.l    #512,d3
  3300. .L1    move.l    d3,d5
  3301.     move.l    #Puffer2,d2
  3302.     CALLDOS_PC    Read
  3303.     cmp.l    d0,d5
  3304.     bne    OpenError
  3305.     lea.l    Puffer2,a0
  3306.     lea.l    Puffer,a1
  3307.     lea.l    UndoPuffer,a2
  3308.     move.l    #511,d0
  3309. .L2    move.b    (a0),(a1)+    
  3310.     move.b    (a0)+,(a2)+    
  3311.     dbra    d0,.L2
  3312.     move.l    d5,AnzahlBytes
  3313.     move.l    .Offset(pc),Offset
  3314. .Error    bra    NewBlock            
  3315. .Offset    dc.l    0
  3316.  
  3317. WindowPointer set Window1
  3318. SectorNumber    move.l    Size(pc),d0        ; show current sector number and number of sectors
  3319.     divu    #512,d0
  3320.     move.l    d0,d1
  3321.     swap    d1
  3322.     and.l    #$ffff,d0
  3323.     tst.w    d1
  3324.     beq.s    .SN1
  3325.     addq    #1,d0
  3326. .SN1    lea.l    SN_Text+12(pc),a0
  3327.     bsr    SN_Number
  3328.     move.l    d7,d0
  3329.     lea.l    PrintHeader2+9,a0
  3330.     bsr    SN_Number
  3331.     
  3332.     move.l    Offset(pc),d0
  3333.     add.l    #511,d0
  3334.     divu    #512,d0
  3335.     move.l    d0,d1
  3336.     swap    d1
  3337.     and.l    #$ffff,d0
  3338.     tst.w    d1
  3339.     beq.s    .SN2
  3340.     addq    #1,d0
  3341. .SN2    move.l    d0,d7
  3342.     lea.l    SN_Text+5(pc),a0
  3343.     bsr    SN_Number
  3344.     move.l    d7,d0
  3345.     lea.l    PrintHeader2+9,a0
  3346.     bsr    SN_Number
  3347.     
  3348.     SETBPEN    #2
  3349.     SETDRMD    #RP_JAM2
  3350.     move.l    WindowPointer(pc),a1
  3351.     move.l    wd_RPort(a1),a1    
  3352.     move.l    FONT80(pc),a0
  3353.     CALLGRAF_PC    SetFont
  3354.     WRITEMEM    #(32+1+7+1)*8+8,#11+3+6,#1,SN_Text,#17
  3355.     rts
  3356. SN_Number    moveq.l    #4,d2
  3357.     moveq.l    #0,d3
  3358.     lea.l    SN_Potenzen(pc),a2
  3359. SN_Z1    move.b    #"0"-1,d1
  3360. SN_Z2    addq    #1,d1
  3361.     sub.l    (a2),d0
  3362.     bcc.s    SN_Z2
  3363.     add.l    (a2)+,d0
  3364.     tst.b    d2
  3365.     beq.s    SN_Z3
  3366.     cmp.b    #"0",d1
  3367.     beq.s    SN_Z4
  3368.     moveq.l    #1,d3
  3369.     bra.s    SN_Z3
  3370. SN_Z4    tst.b    d3
  3371.     bne.s    SN_Z3
  3372.     move.b    #" ",d1
  3373. SN_Z3    move.b    d1,(a0)+
  3374.     dbra    d2,SN_Z1
  3375.     rts
  3376. SN_Potenzen    dc.l    10000
  3377.     dc.l    1000
  3378.     dc.l    100
  3379.     dc.l    10
  3380.     dc.l    1    
  3381.  
  3382.  
  3383. SN_Text    dc.b    "Sec :..... /....."
  3384.  
  3385. FORWARD    tst.b    FlagFile        ; next sector
  3386.     beq.s    .Nothing
  3387.     move.l    Offset(pc),d0
  3388.     add.l    #512,d0
  3389.     cmp.l    Size(pc),d0
  3390.     bge.s    .Nothing
  3391.     bsr    WriteQuestion
  3392.     move.l    Offset(pc),d0
  3393.     add.l    #512,d0
  3394.     bra    GetBlock
  3395. .Nothing    bra    wait
  3396.  
  3397. BACKWARD    tst.b    FlagFile        ; previous sector
  3398.     beq.s    .Nothing
  3399.     move.l    Offset(pc),d0
  3400.     sub.l    #512,d0
  3401.     tst.l    d0
  3402.     bmi.s    .Nothing
  3403.     bsr    WriteQuestion
  3404.     move.l    Offset(pc),d0
  3405.     sub.l    #512,d0
  3406.     bra    GetBlock
  3407. .Nothing    bra    wait
  3408.  
  3409. UNDO    tst.b    FlagFile        ; next sector
  3410.     beq.s    .Nothing
  3411.     lea.l    UndoPuffer,a0
  3412.     lea.l    Puffer,a1
  3413.     move.l    #511,d0
  3414. .L1    move.b    (a0)+,(a1)+
  3415.     dbra    d0,.L1
  3416.     bra    NewBlock
  3417. .Nothing    bra    wait
  3418.  
  3419.  
  3420. *
  3421. * write sector 
  3422. *
  3423.  
  3424. WRITE    bsr    SaveBlock
  3425.     bsr    ShowPuffer
  3426.     lea.l    Color,a0
  3427.     move.l    #511,d0
  3428. .L1    move.b    #3,(a0)+
  3429.     dbra    d0,.L1
  3430.     move.l    Cursor(pc),d0
  3431.     bsr    SetCursor
  3432.     bra    NewPos
  3433.  
  3434. SaveBlock    tst.l    Memory        ; Save current block
  3435.     beq.s    .SaveBlockDisk        ; Subroutine
  3436.     move.l    Memory(pc),a0
  3437.     move.l    a0,a5        
  3438.     add.l    Offset(pc),a0
  3439.     lea.l    Puffer,a1
  3440.     lea.l    UndoPuffer,a2
  3441.     add.l    Size(pc),a5    
  3442.     move.w    #511,d0
  3443. .L0    cmp.l    a0,a5        ; reached end of file ?????
  3444.     beq.s    .L1        ; (in that case V1.11 crashed)
  3445.     move.b    (a1),(a0)+    
  3446.     move.b    (a1)+,(a2)+    
  3447.     dbra    d0,.L0
  3448. .L1    move.b    #1,FlagWrite
  3449.     rts
  3450.  
  3451. .SaveBlockDisk    move.l    Filehandle(pc),d1    ; write block to device
  3452.     tst.l    d1
  3453.     beq.s    .Error
  3454.     move.l    Offset(pc),d2
  3455.     moveq.l    #OFFSET_BEGINNING,d3
  3456.     CALLDOS_PC    Seek
  3457.     move.l    Filehandle(pc),d1
  3458.     move.l    #Puffer,d2
  3459.     move.l    AnzahlBytes,d3
  3460.     CALLDOS_PC    Write
  3461.     cmp.l    d3,d0
  3462.     bne.s    .DiskError
  3463.     lea.l    Puffer,a1
  3464.     lea.l    UndoPuffer,a2
  3465.     move.l    #511,d0
  3466. .L2    move.b    (a1)+,(a2)+    
  3467.     dbra    d0,.L2
  3468. .Error    rts
  3469. .DiskError    lea.l    4(sp),sp    ; Leave subroutine with returning
  3470.     bra    OpenError    
  3471.     
  3472.  
  3473. *
  3474. * SAVE AS - you mustn't edit on device
  3475. *
  3476.  
  3477. SAVE_Text    dc.b    "               Save File:               "
  3478.     even
  3479. SAVE    tst.b    FlagFile
  3480.     beq    .wait
  3481.     tst.l    Memory    
  3482.     beq    RAM_ONLY
  3483.     bsr    WriteQuestion
  3484.     lea.l    SAVE_Text(pc),a5    ; Save file
  3485.     move.l    #R_G1,R_def+nw_FirstGadget
  3486.     bsr    FileRequester
  3487.     tst.l    d0
  3488.     beq    .wait
  3489.     move.l    d0,.File
  3490.     move.l    .File(pc),d1        ; Copy file from RAM to device
  3491.     move.l    #MODE_NEWFILE,d2
  3492.     CALLDOS_PC    Open
  3493.     tst.l    d0
  3494.     beq    OpenError
  3495.     move.l    d0,Filehandle
  3496.     move.l    d0,d1
  3497.     move.l    Size(pc),d3
  3498.     move.l    Memory(pc),d2
  3499.     CALLDOS_PC    Write
  3500.     cmp.l    d3,d0
  3501.     bne    DiskError
  3502.     
  3503.     move.l    Filehandle(pc),d1
  3504.     CALLDOS_PC    Close
  3505.     clr.b    FlagWrite
  3506. .wait    bra    wait
  3507. .File    dc.l    0
  3508.  
  3509. *
  3510. * error message - "you mustn't edit on device !"
  3511. *
  3512.  
  3513. WindowPointer set Window2
  3514.  
  3515. RAM_ONLY    move.l    ScreenPtr1(pc),a0
  3516.     CALLINT_PC    DisplayBeep    
  3517.     lea.l    Windowdef2(pc),a0
  3518.     bsr    MakeWindow
  3519.     tst.l    d0
  3520.     beq    .wait
  3521.     move.l    d0,Window2
  3522.     SETDRMD    #RP_JAM1
  3523.     WRITE    #6+(290-28*8)/2,#19+10,#0,<"You mustn't edit on device !">
  3524.     WRITE    #5+(290-28*8)/2,#18+10,#1,<"You mustn't edit on device !">
  3525.     move.l    Window2(pc),a0        
  3526.     move.l    wd_UserPort(a0),a0
  3527.     move.l    a0,a5
  3528.     CALLEXEC    WaitPort        
  3529.     move.l    Window2(pc),a0
  3530.     CALLINT_PC    CloseWindow
  3531. .wait    bra    wait
  3532.  
  3533.  
  3534. *
  3535. * question "Do ya really wanna quit ?"
  3536. *
  3537.  
  3538.  
  3539. WindowPointer set Window2
  3540.  
  3541. Windowdef3    dc.w    60,50,300,70
  3542.     dc.b    -1,-1
  3543.     dc.l    GADGETUP!VANILLAKEY
  3544.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  3545.     dc.l    LE_Gadget1
  3546.     dc.l    0
  3547.     dc.l    0
  3548.     dc.l    0,0
  3549.     dc.w    0,0,0,0,CUSTOMSCREEN
  3550.  
  3551. LE_Gadget1    FM_GADGET    LE_Gadget2,50,50,50,1,<"NO">,1,4
  3552. LE_Gadget2    FM_GADGET    0,200,50,50,0,<"YES">,1,4
  3553.  
  3554.  
  3555. LEAVE    lea.l    Windowdef3(pc),a0
  3556.     bsr    MakeWindow
  3557.     tst.l    d0
  3558.     beq    .wait
  3559.     move.l    d0,Window2
  3560.     SETDRMD    #RP_JAM1
  3561.     WRITE    #6+(290-28*8)/2,#19+10,#0,<"Do you really want to quit ?">
  3562.     WRITE    #5+(290-28*8)/2,#18+10,#1,<"Do you really want to quit ?">
  3563.  
  3564. .WAIT    move.l    Window2(pc),a0        ; wait .....
  3565.     move.l    wd_UserPort(a0),a0
  3566.     move.l    a0,a5
  3567.     CALLEXEC    WaitPort        
  3568.     move.l    a5,a0
  3569.     CALLEXEC    GetMsg        ; get message
  3570.     move.l    d0,a1    
  3571.     move.l    im_Class(a1),d4    ; get data
  3572.     move.w    im_Code(a1),d5
  3573.     move.l    im_IAddress(a1),a4
  3574.     CALLEXEC     ReplyMsg        ; reply message        
  3575.     moveq.l    #0,d0
  3576.     cmp.l    #VANILLAKEY,d4
  3577.     beq.s    .Key
  3578.     move.l    Window2(pc),a0
  3579.     CALLINT_PC    CloseWindow
  3580.     moveq.l    #0,d0        
  3581.     move.w    gg_GadgetID(a4),d0    
  3582. .wait    rts
  3583. .Key    cmp.b    #"y",d5
  3584.     beq.s    .Yes        ; yes
  3585.     cmp.b    #"Y",d5
  3586.     beq.s    .Yes        ; yes
  3587.     cmp.b    #"N",d5
  3588.     beq.s    .No
  3589.     cmp.b    #"n",d5
  3590.     bne    .WAIT
  3591. .No    moveq.l    #10,d1
  3592.     CALLDOS_PC    Delay
  3593.     move.l    Window2(pc),a0
  3594.     CALLINT_PC    CloseWindow
  3595.     moveq.l    #1,d0
  3596.     rts
  3597. .Yes    moveq.l    #10,d1
  3598.     CALLDOS_PC    Delay
  3599.     move.l    Window2(pc),a0
  3600.     CALLINT_PC    CloseWindow
  3601.     moveq.l    #0,d0
  3602.     rts
  3603.  
  3604. *
  3605. * Question "Write sector ?" & write sector
  3606. *
  3607.  
  3608. WriteQuestion    move.l    (sp)+,.Return
  3609.     lea.l    Color,a0    ; check, if you've changed anything
  3610.     move.l    #511,d0
  3611. .A1    cmp.b    #1,(a0)+
  3612.     beq.s    .A2
  3613.     dbra    d0,.A1
  3614.     bra    .NoWrite
  3615. .A2    cmp.b    #1,WriteMode    ; which mode ?
  3616.     beq    .Autowrite
  3617.     cmp.b    #2,WriteMode
  3618.     beq    .NoWrite
  3619.     lea.l    Windowdef3(pc),a0
  3620.     bsr    MakeWindow
  3621.     tst.l    d0
  3622.     beq    .NoWrite
  3623.     move.l    d0,Window2
  3624.     SETDRMD    #RP_JAM1
  3625.     WRITE    #6+(290-24*8)/2,#19,#0,<"Do you want to write the">
  3626.     WRITE    #6+(290-8*8)/2,#19+15,#0,<"sector ?">
  3627.     WRITE    #5+(290-24*8)/2,#18,#1,<"Do you want to write the">
  3628.     WRITE    #5+(290-8*8)/2,#18+15,#1,<"sector ?">
  3629.  
  3630. .WAIT    move.l    Window2(pc),a0        ; wait .....
  3631.     move.l    wd_UserPort(a0),a0
  3632.     move.l    a0,a5
  3633.     CALLEXEC    WaitPort        
  3634.     move.l    a5,a0
  3635.     CALLEXEC    GetMsg        ; get message
  3636.     move.l    d0,a1    
  3637.     move.l    im_Class(a1),d4    ; get data
  3638.     move.w    im_Code(a1),d5
  3639.     move.l    im_IAddress(a1),a4
  3640.     CALLEXEC     ReplyMsg        ; reply message        
  3641.     moveq.l    #0,d0
  3642.     cmp.l    #VANILLAKEY,d4
  3643.     beq.s    .Key
  3644.     move.l    Window2(pc),a0
  3645.     CALLINT_PC    CloseWindow
  3646.     moveq.l    #0,d0        
  3647.     move.w    gg_GadgetID(a4),d0    
  3648. .wait    bra.s    .DoIT
  3649. .Key    cmp.b    #"y",d5
  3650.     beq.s    .Yes        ; yes
  3651.     cmp.b    #"Y",d5
  3652.     beq.s    .Yes        ; yes
  3653.     cmp.b    #"N",d5
  3654.     beq.s    .No
  3655.     cmp.b    #"n",d5
  3656.     bne    .WAIT
  3657. .No    moveq.l    #10,d1
  3658.     CALLDOS_PC    Delay
  3659.     move.l    Window2(pc),a0
  3660.     CALLINT_PC    CloseWindow
  3661.     moveq.l    #1,d0
  3662.     bra.s    .DoIT
  3663. .Yes    moveq.l    #10,d1
  3664.     CALLDOS_PC    Delay
  3665.     move.l    Window2(pc),a0
  3666.     CALLINT_PC    CloseWindow
  3667.     moveq.l    #0,d0
  3668.  
  3669.  
  3670. .DoIT    tst.b    d0
  3671.     bne.s    .NoWrite
  3672. .Autowrite    bsr    SaveBlock        ; write sector
  3673.     bsr    ShowPuffer
  3674.     lea.l    Color,a0
  3675.     move.l    #511,d0
  3676. .L1    move.b    #3,(a0)+
  3677.     dbra    d0,.L1
  3678. .NoWrite    move.l    .Return(pc),a0
  3679.     jmp    (a0)
  3680. .Return    dc.l    0
  3681.  
  3682.  
  3683. *    
  3684. *    change colours
  3685. *
  3686. * the basic palette program was taken from XColor 1.2 . The public
  3687. * domain program of mine was published on FISH 244. 
  3688. *
  3689. *    
  3690.  
  3691. _MathBase    dc.l    0
  3692. Mathname    FFPNAME
  3693.  
  3694. COLOUR    move.w    #$ff,Colour_Mode
  3695.     lea    Mathname(pc),a1
  3696.     moveq.l    #0,d0
  3697.     CALLEXEC     OpenLibrary
  3698.     move.l    d0,_MathBase
  3699.     bne.s    .C1
  3700. .C0    bra    wait
  3701. .C1    clr.b    Colour_Mode        ; set to normal mode
  3702.     move.b    #$ff,OldColour_Mode
  3703.  
  3704.     lea.l    NewWindow1(pc),a0
  3705.     bsr    MakeWindow        ; open the window
  3706.     tst.l    d0
  3707.     beq.s    .C0
  3708.     move.l    d0,Window1_Ptr
  3709.  
  3710.     move.l    d0,a1    
  3711.     move.l    wd_RPort(a1),a1
  3712.     moveq.l    #7,d0
  3713.     CALLGRAF_PC    SetBPen
  3714.  
  3715.     bsr    GetDepth
  3716.     bsr    SaveForUndo        ; save color for undo function
  3717. IN3    
  3718. IN1    move.l    Window1_Ptr(pc),a1    ; draw border
  3719.     move.l    wd_RPort(a1),a0
  3720.     lea.l    CG_Box(pc),a1
  3721.     moveq.w    #10,d0
  3722.     move.w    #15,d1
  3723.     CALLINT_PC    DrawBorder
  3724.  
  3725. IN0    lea.l    Colour_Gadget1(pc),a0        ; refresh gadgets
  3726.     move.l    Window1_Ptr(pc),a1
  3727.     sub.l    a2,a2
  3728.     CALLINT_PC    RefreshGadgets
  3729.  
  3730.     clr.l    COLOR        ; current color = 0    
  3731.     bsr    GetDepth        ; get depth
  3732.     bsr    MakeCG        ; create color gadget
  3733. IN2    bsr    NewColor        ; edit new color
  3734.     bsr    RGB        ; write R,G,B
  3735.  
  3736.  
  3737.  
  3738. Colour_wait    lea.l    Colour_Gadget1(pc),a0    ; refresh gadgets again
  3739.     move.l    Window1_Ptr(pc),a1
  3740.     sub.l    a2,a2
  3741.     CALLINT_PC    RefreshGadgets
  3742.  
  3743.     move.l    Window1_Ptr(pc),a1
  3744.     move.l    wd_RPort(a1),a1
  3745.     move.l    a1,a2
  3746.     moveq.l    #1,d0
  3747.     CALLGRAF_PC    SetAPen
  3748.  
  3749.     move.l    a2,a1    
  3750.     move.w    #(185-13*8)/2,d0
  3751.     move.w    #10,d1
  3752.     CALLGRAF_PC    Move    
  3753.  
  3754.  
  3755.     moveq.l    #0,d0
  3756.     move.b    Colour_Mode(pc),d0
  3757.     cmp.b    OldColour_Mode(pc),d0
  3758.     beq.s    Colour_wait2
  3759.     move.b    d0,OldColour_Mode
  3760.     mulu    #14,d0
  3761.     add.l    #Title0,d0
  3762.     move.l    d0,a0
  3763.     move.l    #13,d0
  3764.     move.l    a2,a1
  3765.     CALLGRAF_PC    Text
  3766.  
  3767. Colour_wait2    move.l    Window1_Ptr(pc),a0    ; wait .....
  3768.     move.l    wd_UserPort(a0),a0
  3769.     move.l    a0,a5
  3770.     CALLEXEC    WaitPort        
  3771.     move.l    a5,a0
  3772.     CALLEXEC    GetMsg        ; get message
  3773.     move.l    d0,a1    
  3774.     move.l    im_Class(a1),d4    ; get data
  3775.     move.w    im_Code(a1),d5
  3776.     move.l    im_IAddress(a1),a4
  3777.     move.w    im_MouseX(a1),d6
  3778.     move.w    im_MouseY(a1),d7
  3779.     CALLEXEC     ReplyMsg        ; reply message        
  3780.     cmp.l    #GADGETDOWN,d4
  3781.     beq    G1_HandlerA
  3782.     
  3783.     moveq.l    #0,d0        
  3784.     move.w    gg_GadgetID(a4),d0    
  3785.     tst.w    d0
  3786.     beq    G0_Handler
  3787.     cmp.w    #3,d0
  3788.     bls    G1_HandlerB
  3789.     cmp.w    #7,d0    
  3790.     beq    UNDO_colour
  3791.     cmp.b    #10,d0
  3792.     beq    Black_White
  3793.     cmp.b    #5,d0
  3794.     beq    UNDO_ALL
  3795.     cmp.b    #11,d0
  3796.     beq    ANTIK
  3797.     cmp.b    #4,d0
  3798.     beq    QUIT_color
  3799.     cmp.b    #12,d0
  3800.     beq    COPY
  3801.     cmp.b    #13,d0
  3802.     beq    EXCHANGE
  3803.     cmp.b    #14,d0
  3804.     beq    SPREAD
  3805.     cmp.b    #20,d0
  3806.     beq    DEFAULT
  3807.     
  3808.  
  3809.     bra    Colour_wait    
  3810.  
  3811.  
  3812. QUIT_color    move.l    Window1_Ptr(pc),a0    ; the exit
  3813.     CALLINT_PC    CloseWindow
  3814.     move.l    _MathBase(pc),a1
  3815.     CALLEXEC    CloseLibrary
  3816.     bra    wait
  3817.  
  3818.  
  3819.  
  3820.  
  3821. MakeCG    move.l    Depth(pc),d0        ; get size of block
  3822.     subq    #1,d0        ; from table and draw
  3823.     lsl.l    #2,d0        ; the blocks
  3824.     lea.l    SizeTable(pc),a0
  3825.     move.w    (a0,d0),d6
  3826.     move.w    2(a0,d0),d7
  3827.     moveq.l    #0,d5
  3828.     move.w    #0,-(sp)
  3829.  
  3830.  
  3831. MCG0    moveq.l    #0,d4
  3832.  
  3833. MCG1    move.w    (sp),d0
  3834.     move.l    Window1_Ptr(pc),a1
  3835.     move.l    wd_RPort(a1),a1
  3836.     move.l    a1,a3
  3837.     CALLGRAF_PC    SetAPen
  3838.     move.l    a3,a1
  3839.     move.w    d4,d0
  3840.     move.w    d5,d1
  3841.     add.w    d6,d4
  3842.     move.w    d4,d2
  3843.     move.w    d5,d3
  3844.     add.w    d7,d3
  3845.     add    #10,d0
  3846.     add    #15,d1
  3847.     add    #10,d2
  3848.     add    #15,d3
  3849.     CALLGRAF_PC    RectFill
  3850.     add.w    #1,(sp)
  3851.     cmp.w    #159,d4
  3852.     bls    MCG1
  3853. MCG2    add.w    d7,d5
  3854.     cmp.w    #39,d5
  3855.     bls    MCG0
  3856.     lea.l    2(sp),sp
  3857.     rts    
  3858.     
  3859. Depth    dc.l    0
  3860. SizeTable    dc.w    160/2,40/1    ; 2   colors
  3861.     dc.w    160/2,40/2    ; 4   colors
  3862.     dc.w    160/4,40/2    ; 8   colors
  3863.     dc.w    160/4,40/4    ; 16  colors
  3864.     dc.w    160/8,40/4    ; 32  colors
  3865.     dc.w    160/16,40/4    ; 64  colors    
  3866.     
  3867.     
  3868. Colour_Gadget0    dc.l    Colour_Gadget10
  3869.     dc.w    10,15,160,40
  3870.     dc.w    GADGHNONE
  3871.     dc.w    RELVERIFY
  3872.     dc.w    BOOLGADGET
  3873.     dc.l    0,0
  3874.     dc.l    0
  3875.     dc.l    0,0
  3876.     dc.w    0
  3877.     dc.l    0
  3878.  
  3879. Colour_Gadget1    dc.l    Colour_Gadget2
  3880.     dc.w    40+10,50+15,114,11
  3881.     dc.w    GADGHCOMP
  3882.     dc.w    RELVERIFY!GADGIMMEDIATE
  3883.     dc.w    PROPGADGET
  3884.     dc.l    G1_image,0
  3885.     dc.l    0
  3886.      dc.l    0,G1_info
  3887.     dc.w    1
  3888.     dc.l    0
  3889. G1_image    ds.w    4
  3890. G1_info    dc.w    FREEHORIZ!AUTOKNOB
  3891.     dc.w    0
  3892.     dc.w    0
  3893.     dc.w    $ffff/15
  3894.     ds.w    7
  3895. Colour_Gadget2    dc.l    Colour_Gadget3
  3896.     dc.w    40+10,50+30,114,11
  3897.     dc.w    GADGHCOMP
  3898.     dc.w    RELVERIFY!GADGIMMEDIATE
  3899.     dc.w    PROPGADGET
  3900.     dc.l    G2_image,0
  3901.     dc.l    0
  3902.     dc.l    0,G2_info
  3903.     dc.w    2
  3904.     dc.l    0
  3905. G2_image    ds.w    4
  3906. G2_info    dc.w    FREEHORIZ!AUTOKNOB
  3907.     dc.w    0
  3908.     dc.w    0
  3909.     dc.w    $ffff/15
  3910.     ds.w    7
  3911. Colour_Gadget3    dc.l    Colour_Gadget7
  3912.     dc.w    40+10,50+45,114,11
  3913.     dc.w    GADGHCOMP
  3914.     dc.w    RELVERIFY!GADGIMMEDIATE
  3915.     dc.w    PROPGADGET
  3916.     dc.l    G3_image,0
  3917.     dc.l    0
  3918.     dc.l    0,G3_info
  3919.     dc.w    3
  3920.     dc.l    0
  3921.  
  3922. G3_image    ds.w    4
  3923. G3_info    dc.w    FREEHORIZ!AUTOKNOB
  3924.     dc.w    0
  3925.     dc.w    0
  3926.     dc.w    $ffff/15
  3927.     ds.w    7
  3928.  
  3929. Colour_Gadget7    dc.l    0
  3930.     dc.w    11,66,20,30
  3931.     dc.w    GADGHBOX
  3932.     dc.w    RELVERIFY
  3933.     dc.w    BOOLGADGET
  3934.     dc.l    C_Box,0
  3935.     dc.l    0
  3936.     dc.l    0,0
  3937.     dc.w    7
  3938.     dc.l    0
  3939.  
  3940. Colour_Gadget10    
  3941.     FM_GADGET    Colour_Gadget11,185,3,72,10,<"B&W">,1,4
  3942. Colour_Gadget11    
  3943.     FM_GADGET    Colour_Gadget12,185,3+(1*14),72,11,<"Antik">,1,4
  3944. Colour_Gadget12    
  3945.     FM_GADGET    Colour_Gadget13,185,3+(2*14),72,12,<"Copy">,1,4
  3946. Colour_Gadget13    
  3947.     FM_GADGET    Colour_Gadget14,185,3+(3*14),72,13,<"Exchange">,1,4
  3948. Colour_Gadget14    
  3949.     FM_GADGET    Colour_Gadget15,185,3+(4*14),72,14,<"Spread">,1,4
  3950. Colour_Gadget15    
  3951.     FM_GADGET    Colour_Gadget16,185,3+(5*14),72,5,<"Undo All">,1,4
  3952. Colour_Gadget16    
  3953.     FM_GADGET    Colour_Gadget17,185,3+(6*14),72,20,<"Default">,1,4
  3954. Colour_Gadget17    
  3955.     FM_GADGET    Colour_Gadget1,185,3+(7*14),72,4,<"EXIT">,1,4
  3956.  
  3957.  
  3958. NewWindow1    dc.w    110,45
  3959.     dc.w    270,116
  3960.     dc.b    -1,-1
  3961.     dc.l    GADGETUP!GADGETDOWN
  3962.     dc.l    ACTIVATE!SMART_REFRESH
  3963.     dc.l    Colour_Gadget0
  3964.     dc.l    0
  3965.     dc.l    0
  3966.     dc.l    0
  3967.     dc.l    0
  3968.     dc.w    140,100
  3969.     dc.w    140,100
  3970.     dc.w    CUSTOMSCREEN
  3971.  
  3972. Window1_Ptr    dc.l    0        ; window pointer
  3973. Undo    dc.w    0        ; undo
  3974. CG_Box    BOX    -1,-1,161,41,1,0
  3975. C_Box    BOX    -1,-1,20,30,1,0
  3976.  
  3977. COLOR    dc.l    0        ; current color
  3978. MoverSize    dc.w    0        ; size of mover ($ffff/15 or $ffff/7)
  3979.  
  3980. NewColor    move.w    #$ffff/15,d0        ; edit a new color 
  3981.     cmp.l    #$1f,COLOR        ; color is halfbrite ( >$1f) => mover is smaller !
  3982.     bls    NC0
  3983.     move.w    #$ffff/7,d0
  3984. NC0    move.w    d0,MoverSize
  3985.     
  3986.  
  3987.     move.l    Window1_Ptr(pc),a1    ; write color number
  3988.     move.l    wd_RPort(a1),a1
  3989.     move.l    a1,a2
  3990.     moveq.l    #1,d0
  3991.     CALLGRAF_PC    SetAPen
  3992.  
  3993.     move.l    a2,a1    
  3994.     move.w    #12,d0
  3995.     move.w    #50+15+6+1+15+15+2,d1
  3996.     CALLGRAF_PC    Move    
  3997.  
  3998.     lea.l    Zahlen2(pc),a0
  3999.     move.l    COLOR(pc),d0
  4000.     add.l    d0,d0
  4001.     add.l    d0,a0
  4002.     moveq.l    #2,d0
  4003.     CALLGRAF_PC    Text
  4004.  
  4005.  
  4006.     move.l    Window1_Ptr(pc),a0    ; get RGB and save for undo !
  4007.     CALLINT_PC    ViewPortAddress
  4008.     move.l    d0,a0
  4009.     move.l    vp_ColorMap(a0),a0
  4010.     move.l    COLOR(pc),d0
  4011.     CALLGRAF_PC    GetRGB4
  4012.     move.w    d0,Undo
  4013.     move.w    d0,-(sp)        ; remake prop-gadgets
  4014.     lsr.w    #8,d0
  4015.     and.w    #$f,d0
  4016.     moveq.l    #0,d1
  4017.     move.b    d0,d1
  4018.     mulu.w    MoverSize(pc),d1
  4019.     lea.l    Colour_Gadget1(pc),a0
  4020.     move.l    Window1_Ptr(pc),a1
  4021.     sub.l    a2,a2
  4022.     moveq.l    #0,d2
  4023.     move.w    MoverSize(pc),d3
  4024.     moveq.l    #0,d4
  4025.     move.w    #FREEHORIZ!AUTOKNOB,d0
  4026.     CALLINT_PC    ModifyProp
  4027.     
  4028.     moveq.l    #0,d1
  4029.     move.w    (sp),d1
  4030.     lsr.w    #4,d1
  4031.     and.w    #$f,d1
  4032.     mulu.w    MoverSize(pc),d1
  4033.     lea.l    Colour_Gadget2(pc),a0
  4034.     move.l    Window1_Ptr(pc),a1
  4035.     sub.l    a2,a2
  4036.     moveq.l    #0,d2
  4037.     move.w    MoverSize(pc),d3
  4038.     moveq.l    #0,d4
  4039.     move.w    #FREEHORIZ!AUTOKNOB,d0
  4040.     CALLINT_PC    ModifyProp
  4041.  
  4042.     moveq.l    #0,d1
  4043.     move.w    (sp)+,d1
  4044.     and.w    #$f,d1
  4045.     mulu.w    MoverSize(pc),d1
  4046.     lea.l    Colour_Gadget3(pc),a0
  4047.     move.l    Window1_Ptr(pc),a1
  4048.     sub.l    a2,a2
  4049.     moveq.l    #0,d2
  4050.     move.w    MoverSize(pc),d3
  4051.     moveq.l    #0,d4
  4052.     move.w    #FREEHORIZ!AUTOKNOB,d0
  4053.     CALLINT_PC    ModifyProp
  4054.  
  4055.     move.l    Window1_Ptr(pc),a1    ; draw block for undo gadget
  4056.     move.l    wd_RPort(a1),a1
  4057.     move.l    COLOR(pc),d0
  4058.     CALLGRAF_PC    SetAPen
  4059.     move.l    Window1_Ptr(pc),a1
  4060.     move.l    wd_RPort(a1),a1
  4061.     move.w    #10+1,d0    
  4062.     move.w    #15+50+1,d1
  4063.     move.w    #10+19+1,d2    
  4064.     move.w    #15+50+29+1,d3
  4065.     CALLGRAF_PC    RectFill
  4066.     bra    Print_HEX        ; write mover positions as numbers
  4067.  
  4068. G0_Handler    cmp.b    #1,Colour_Mode        
  4069.     beq    Copy_Color
  4070.     cmp.b    #2,Colour_Mode
  4071.     beq    Exchange_Color
  4072.     cmp.b    #3,Colour_Mode
  4073.     beq    Spread_Color
  4074.  
  4075.  
  4076.     move.w    d6,d0        ; color gadget was selected but 
  4077.     move.w    d7,d1        ; which color ?
  4078.     move.l    Window1_Ptr(pc),a1
  4079.     move.l    wd_RPort(a1),a1
  4080.     CALLGRAF_PC    ReadPixel
  4081.     move.l    d0,COLOR
  4082.     bsr    NewColor        
  4083.     bra    Colour_wait
  4084.  
  4085. Zahlen    dc.b    "0123456789ABCDEF"
  4086. Zahlen2    dc.b    "000102030405060708090a0b0c0d0e0f"
  4087.     dc.b    "101112131415161718191a1b1c1d1e1f"
  4088.     
  4089. Print_HEX    move.l    Window1_Ptr(pc),a0    ; write mover position as hex number
  4090.     CALLINT_PC    ViewPortAddress
  4091.     move.l    d0,a0
  4092.     move.l    vp_ColorMap(a0),a0
  4093.     move.l    COLOR(pc),d0
  4094.     CALLGRAF_PC    GetRGB4
  4095.     move.w    d0,d5
  4096.  
  4097.     move.l    Window1_Ptr(pc),a1
  4098.     move.l    wd_RPort(a1),a1
  4099.     move.l    a1,a2
  4100.     moveq.l    #1,d0
  4101.     CALLGRAF_PC    SetAPen
  4102.  
  4103.     move.l    a2,a1    
  4104.     move.w    #114+50+4,d0
  4105.     move.w    #50+15+6+2,d1
  4106.     CALLGRAF_PC    Move    
  4107.  
  4108.     lea.l    Zahlen(pc),a0
  4109.     move.l    d5,d0
  4110.     lsr.l    #8,d0
  4111.     and.l    #$f,d0    
  4112.     add.l    d0,a0
  4113.     moveq.l    #1,d0
  4114.     CALLGRAF_PC    Text
  4115.  
  4116.     move.l    a2,a1    
  4117.     move.w    #114+50+4,d0
  4118.     move.w    #50+15+6+15+2,d1
  4119.     CALLGRAF_PC    Move    
  4120.  
  4121.     lea.l    Zahlen(pc),a0
  4122.     move.l    d5,d0
  4123.     lsr.l    #4,d0
  4124.     and.l    #$f,d0
  4125.     add.l    d0,a0
  4126.     moveq.l    #1,d0
  4127.     CALLGRAF_PC    Text
  4128.  
  4129.     move.l    a2,a1    
  4130.     move.w    #114+50+4,d0
  4131.     move.w    #50+15+6+15+15+2,d1
  4132.     CALLGRAF_PC    Move    
  4133.  
  4134.     lea.l    Zahlen(pc),a0
  4135.     and.l    #$f,d5    
  4136.     add.l    d5,a0
  4137.     moveq.l    #1,d0
  4138.     CALLGRAF_PC    Text
  4139.     rts
  4140. G1_HandlerA    bsr    ReadColor        ; prop gadget was selected
  4141.     bsr    Print_HEX
  4142.     move.l    Window1_Ptr(pc),a0        
  4143.     move.l    wd_UserPort(a0),a0
  4144.     CALLEXEC    GetMsg
  4145.     tst.l    d0
  4146.     beq.s    G1_HandlerA
  4147.     move.l    d0,a1    
  4148.     CALLEXEC     ReplyMsg
  4149. G1_HandlerB    bsr    ReadColor        ;  " (but left button was released afterwards)
  4150.     bsr    Print_HEX
  4151.     bra    Colour_wait
  4152.  
  4153. ReadColor    move.l    Window1_Ptr(pc),a0        ; get mover position and set RGB 
  4154.     CALLINT_PC    ViewPortAddress
  4155.     move.l    d0,a0
  4156.     moveq.l    #0,d1
  4157.     moveq.l    #0,d2
  4158.     moveq.l    #0,d3
  4159.     
  4160.     move.w    G1_info+2(pc),d1
  4161.     divu    G1_info+6(pc),d1
  4162.     move.w    G2_info+2(pc),d2
  4163.     divu    G2_info+6(pc),d2
  4164.     move.w    G3_info+2(pc),d3
  4165.     divu    G3_info+6(pc),d3
  4166.     move.l    COLOR(pc),d0
  4167.     CALLGRAF_PC    SetRGB4
  4168.     rts
  4169. UNDO_colour    move.l    Window1_Ptr(pc),a0    ; undo color
  4170.     CALLINT_PC    ViewPortAddress
  4171.     move.l    d0,a0
  4172.     move.l    COLOR(pc),d0
  4173.     move.w    Undo(pc),d1
  4174.     move.w    d1,d2
  4175.     move.w    d2,d3
  4176.     lsr.w    #8,d1
  4177.     and.l    #$f,d1
  4178.     lsr.w    #4,d2
  4179.     and.l    #$f,d2
  4180.     and.l    #$f,d3
  4181.     CALLGRAF_PC    SetRGB4        
  4182.     bsr    NewColor
  4183.     bra    Colour_wait
  4184. GetDepth    move.l    ScreenPtr1,a0        ; get depth (HAM=4!)
  4185.     lea.l    sc_BitMap(a0),a0
  4186.     moveq.l    #0,d0
  4187.     move.b    bm_Depth(a0),d0
  4188.     move.l    d0,Depth
  4189.     rts
  4190.  
  4191. R    dc.b    "R"
  4192. G    dc.b    "G"
  4193. B    dc.b    "B"
  4194.  
  4195. RGB    move.l    Window1_Ptr(pc),a1    ; print out R, G , B
  4196.     move.l    wd_RPort(a1),a1
  4197.     move.l    a1,a2
  4198.     moveq.l    #1,d0
  4199.     CALLGRAF_PC    SetAPen
  4200.  
  4201.     move.l    a2,a1    
  4202.     move.w    #40,d0
  4203.     move.w    #50+15+6+2,d1
  4204.     CALLGRAF_PC    Move    
  4205.  
  4206.     lea.l    R(pc),a0
  4207.     moveq.l    #1,d0
  4208.     CALLGRAF_PC    Text
  4209.  
  4210.     move.l    a2,a1    
  4211.     move.w    #40,d0
  4212.     move.w    #50+15+6+15+2,d1
  4213.     CALLGRAF_PC    Move    
  4214.  
  4215.     lea.l    G(pc),a0
  4216.     moveq.l    #1,d0
  4217.     CALLGRAF_PC    Text
  4218.  
  4219.     move.l    a2,a1    
  4220.     move.w    #40,d0
  4221.     move.w    #50+15+6+15+15+2,d1
  4222.     CALLGRAF_PC    Move    
  4223.  
  4224.     lea.l    B(pc),a0
  4225.     moveq.l    #1,d0
  4226.     CALLGRAF_PC    Text
  4227.     rts    
  4228.  
  4229.     even
  4230. ColorBuffer    ds.w    64
  4231. UNDOBuffer    ds.w    64
  4232. UNDODepth    dc.l    0
  4233.  
  4234. * How to make B&W
  4235. *
  4236. * C=r+g+b    ; add all three parts red, green, blue
  4237. * r=g=b=C/3  ; new parts
  4238.  
  4239. Black_White    move.l    Window1_Ptr(pc),a0        
  4240.     CALLINT_PC    ViewPortAddress
  4241.     move.l    d0,a0
  4242.     move.l    Depth(pc),d0        ; copy colors to buffer
  4243.     moveq.l    #0,d1
  4244.     bset    d0,d1
  4245.     subq    #1,d1
  4246.     
  4247.     move.l    vp_ColorMap(a0),a0
  4248.     move.l    cm_ColorTable(a0),a0
  4249.     lea.l    ColorBuffer(pc),a1
  4250. .X    move.w    (a0)+,(a1)+
  4251.     dbra    d1,.X
  4252.     
  4253.     move.l    Depth(pc),d0        ; convert colors to b&W
  4254.     moveq.l    #0,d1
  4255.     bset    d0,d1
  4256.     subq    #1,d1
  4257.     lea.l    ColorBuffer(pc),a1
  4258. .Y    moveq.l    #0,d0
  4259.     add.b    (a1),d0
  4260.     moveq.l    #0,d2
  4261.     move.b    1(a1),d2
  4262.     move.b    d2,d3
  4263.     and.b    #$f,d3
  4264.     lsr.b    #4,d2
  4265.     add.b    d2,d0
  4266.     add.b    d3,d0
  4267.     and.l    #$ff,d0
  4268.     divu    #3,d0
  4269.     move.b    d0,(a1)+
  4270.     move.b    d0,d2
  4271.     lsl.b    #4,d0
  4272.     or.b    d2,d0
  4273.     move.b    d0,(a1)+
  4274.     dbra    d1,.Y
  4275.     move.l    Window1_Ptr(pc),a0        
  4276.     CALLINT_PC    ViewPortAddress
  4277.     move.l    d0,a0
  4278.     lea.l    ColorBuffer(pc),a1
  4279.     move.l    Depth(pc),d1        
  4280.     moveq.l    #0,d0
  4281.     bset    d1,d0
  4282.     CALLGRAF_PC    LoadRGB4
  4283.     CALLINT_PC    RemakeDisplay
  4284.     bra    IN2
  4285.  
  4286. * How to make ANTIK
  4287. *
  4288. * C=r+g+b    ; add all three parts red, green, blue
  4289. * r=C/3      ; new parts
  4290. * g=C/4
  4291. * b=C/5
  4292.  
  4293. ANTIK    move.l    Window1_Ptr(pc),a0        
  4294.     CALLINT_PC    ViewPortAddress
  4295.     move.l    d0,a0
  4296.     move.l    Depth(pc),d0        ; copy colors to buffer
  4297.     moveq.l    #0,d1
  4298.     bset    d0,d1
  4299.     subq    #1,d1
  4300.     
  4301.     move.l    vp_ColorMap(a0),a0
  4302.     move.l    cm_ColorTable(a0),a0
  4303.     lea.l    ColorBuffer(pc),a1
  4304. .X    move.w    (a0)+,(a1)+
  4305.     dbra    d1,.X
  4306.     
  4307.     move.l    Depth(pc),d0        ; convert colors to b&W
  4308.     moveq.l    #0,d1
  4309.     bset    d0,d1
  4310.     subq    #1,d1
  4311.     lea.l    ColorBuffer(pc),a1
  4312. .Y    moveq.l    #0,d0
  4313.     add.b    (a1),d0
  4314.     moveq.l    #0,d2
  4315.     move.b    1(a1),d2
  4316.     move.b    d2,d3
  4317.     and.b    #$f,d3
  4318.     lsr.b    #4,d2
  4319.     add.b    d2,d0
  4320.     add.b    d3,d0
  4321.     and.l    #$ff,d0
  4322.     move.l    d0,d5
  4323.     divu    #3,d0
  4324.     move.b    d0,(a1)+
  4325.     move.l    d5,d0
  4326.     lsl.w    #2,d0
  4327.     and.w    #$f0,d0
  4328.     divu    #5,d5
  4329.     or.b    d5,d0
  4330.     move.b    d0,(a1)+
  4331.     dbra    d1,.Y
  4332.     move.l    Window1_Ptr(pc),a0        
  4333.     CALLINT_PC    ViewPortAddress
  4334.     move.l    d0,a0
  4335.     lea.l    ColorBuffer(pc),a1
  4336.     move.l    Depth(pc),d1        
  4337.     moveq.l    #0,d0
  4338.     bset    d1,d0
  4339.     CALLGRAF_PC    LoadRGB4
  4340.     CALLINT_PC    RemakeDisplay
  4341.     bra    IN2
  4342.  
  4343.  
  4344. SaveForUndo    move.l    Window1_Ptr(pc),a0        
  4345.     CALLINT_PC    ViewPortAddress
  4346.     move.l    d0,a0
  4347.     move.l    Depth(pc),d0        
  4348.     moveq.l    #0,d1
  4349.     bset    d0,d1
  4350.     cmp.b    #32,d1
  4351.     bls.s    .Z
  4352.     move.l    #32,d1
  4353. .Z    move.l    d1,UNDODepth
  4354.     subq    #1,d1
  4355.  
  4356.     move.l    vp_ColorMap(a0),a0
  4357.     move.l    cm_ColorTable(a0),a0
  4358.     lea.l    UNDOBuffer(pc),a1
  4359. .X    move.w    (a0)+,(a1)+
  4360.     dbra    d1,.X        
  4361.     rts
  4362.  
  4363. UNDO_ALL    move.l    Window1_Ptr(pc),a0    ; restor save color map        
  4364.     CALLINT_PC    ViewPortAddress
  4365.     move.l    d0,a0
  4366.     lea.l    UNDOBuffer(pc),a1
  4367.     move.l    UNDODepth(pc),d0        
  4368.     CALLGRAF_PC    LoadRGB4
  4369.     CALLINT_PC    RemakeDisplay
  4370.     bra    IN3
  4371.  
  4372.  
  4373. Colour_Mode    dc.b    0
  4374. OldColour_Mode    dc.b    $ff
  4375.     even
  4376.  
  4377.  
  4378. Title0    dc.b    "   Colours   ",0
  4379. Title1    dc.b    "  Copy to :  ",0
  4380. Title2    dc.b    "Exchange to :",0
  4381. Title3    dc.b    " Spread to : ",0 
  4382.  
  4383. COPY    cmp.b    #1,Colour_Mode
  4384.     beq.s    .Label1
  4385.     move.b    #1,Colour_Mode
  4386.     bra    Colour_wait
  4387. .Label1    clr.b    Colour_Mode
  4388.     bra    Colour_wait
  4389.  
  4390. Copy_Color    move.l    Window1_Ptr(pc),a0        
  4391.     CALLINT_PC    ViewPortAddress
  4392.     move.l    d0,a0
  4393.     move.l    vp_ColorMap(a0),a0
  4394.     move.l    cm_ColorTable(a0),a3    ; pointer color map
  4395.  
  4396.     move.w    d6,d0        ; get color        
  4397.     move.w    d7,d1        
  4398.     move.l    Window1_Ptr(pc),a1
  4399.     move.l    wd_RPort(a1),a1
  4400.     CALLGRAF_PC    ReadPixel
  4401.     
  4402.     move.l    d0,d3        ; You can only change colours between 0 and $1f or between $20 and $3f
  4403.     move.l    COLOR(pc),d4
  4404.     and.b    #$20,d3
  4405.     and.b    #$20,d4
  4406.     cmp.b    d3,d4
  4407.     bne    Colour_Error
  4408.  
  4409.  
  4410.     and.w    #$1f,d0        ; change colours ( EHB colour-> normal colour) 
  4411.     add.w    d0,d0
  4412.     move.l    COLOR(pc),d1
  4413.     and.w    #$1f,d1
  4414.     add.w    d1,d1
  4415.  
  4416.  
  4417.  
  4418.     move.w    (a3,d1),(a3,d0)    ; copy it !
  4419.     clr.b    Colour_Mode
  4420.  
  4421.     CALLINT_PC    RemakeDisplay        
  4422.     bra    IN2
  4423.  
  4424. EXCHANGE    cmp.b    #2,Colour_Mode
  4425.     beq.s    .Label1
  4426.     move.b    #2,Colour_Mode
  4427.     bra    Colour_wait
  4428. .Label1    clr.b    Colour_Mode
  4429.     bra    Colour_wait
  4430.  
  4431. Exchange_Color    move.l    Window1_Ptr(pc),a0        
  4432.     CALLINT_PC    ViewPortAddress
  4433.     move.l    d0,a0
  4434.     move.l    vp_ColorMap(a0),a0
  4435.     move.l    cm_ColorTable(a0),a3    ; pointer color map
  4436.  
  4437.     move.w    d6,d0        ; get color        
  4438.     move.w    d7,d1        
  4439.     move.l    Window1_Ptr(pc),a1
  4440.     move.l    wd_RPort(a1),a1
  4441.     CALLGRAF_PC    ReadPixel
  4442.  
  4443.     move.l    d0,d3        ; You can only change colours between 0 and $1f or between $20 and $3f
  4444.     move.l    COLOR(pc),d4
  4445.     and.b    #$20,d3
  4446.     and.b    #$20,d4
  4447.     cmp.b    d3,d4
  4448.     bne    Colour_Error
  4449.  
  4450.     and.l    #$1f,d0
  4451.  
  4452.     add.w    d0,d0
  4453.     move.l    COLOR(pc),d1
  4454.     and.l    #$1f,d1
  4455.     add.w    d1,d1
  4456.  
  4457.     move.w    (a3,d1),d2        ; exchange it !
  4458.     move.w    (a3,d0),(a3,d1)
  4459.     move.w    d2,(a3,d0)
  4460.     
  4461.     clr.b    Colour_Mode
  4462.  
  4463.     CALLINT_PC    RemakeDisplay        
  4464.     bra    IN2
  4465.  
  4466. DefaultPalette    dc.w    $000,$eee,$775,$313,$04d,$997,$4b9,$553
  4467.  
  4468. DEFAULT    move.l    Window1_Ptr(pc),a0    ; set default colors
  4469.     CALLINT_PC    ViewPortAddress
  4470.     move.l    d0,a0
  4471.     move.w    #16,d0
  4472.     lea.l    Palette,a1
  4473.     CALLGRAF_PC    LoadRGB4
  4474.     CALLINT_PC    RemakeDisplay
  4475.     bra    IN2
  4476.  
  4477.  
  4478. SPREAD    cmp.b    #3,Colour_Mode
  4479.     beq.s    .Label1
  4480.     move.b    #3,Colour_Mode
  4481.     bra    Colour_wait
  4482. .Label1    clr.b    Colour_Mode
  4483.     bra    Colour_wait
  4484.  
  4485. Spread_Color    move.l    Window1_Ptr(pc),a0        
  4486.     CALLINT_PC    ViewPortAddress
  4487.     move.l    d0,a0
  4488.     move.l    vp_ColorMap(a0),a0
  4489.     move.l    cm_ColorTable(a0),a3    ; pointer color map
  4490.  
  4491.     move.w    d6,d0        ; get color        
  4492.     move.w    d7,d1        
  4493.     move.l    Window1_Ptr(pc),a1
  4494.     move.l    wd_RPort(a1),a1
  4495.     CALLGRAF_PC    ReadPixel
  4496.     move.l    COLOR(pc),d1
  4497.  
  4498. P    cmp.w    d1,d0
  4499.     bls.s    .L1
  4500.     move.l    d0,d2
  4501.     move.l    d1,d0    
  4502.     move.l    d2,d1
  4503. .L1    move.l    d1,d2
  4504.     sub.l    d0,d2
  4505.     cmp.l    #1,d2
  4506.     bls    .exit
  4507.  
  4508.     move.l    d0,d3    ; You can only change colours between 0 and $1f or between $20 and $3f
  4509.     move.l    d1,d4
  4510.     and.b    #$20,d3
  4511.     and.b    #$20,d4
  4512.     cmp.b    d3,d4
  4513.     bne    Colour_Error
  4514.  
  4515.     and.l    #$1f,d0
  4516.     and.l    #$1f,d1
  4517.  
  4518.     move.l    d0,FirstColor
  4519.     move.l    d1,LastColor
  4520.     move.l    d2,DiffColor
  4521.     move.l    d2,d6
  4522.     subq    #2,d6
  4523.  
  4524.     move.l    FirstColor(pc),d0    ;get RGB of first colour 
  4525.     bsr    ReadColorII
  4526.     movem.l    d0-d2,FirstR
  4527.     
  4528.     move.l    LastColor(pc),d0    ;get RGB of last colour 
  4529.     bsr    ReadColorII
  4530.     sub.l    FirstR(pc),d0
  4531.     move.l    d0,DiffR        ; What's the difference ?
  4532.     sub.l    FirstG(pc),d1
  4533.     move.l    d1,DiffG
  4534.     sub.l    FirstB(pc),d2
  4535.     move.l    d2,DiffB
  4536.     
  4537.  
  4538.  
  4539.     moveq.l    #6,d4        ; convert integer to FFP
  4540.     lea.l    FirstR(pc),a3
  4541. .L2    move.l    (a3),d0
  4542.     CALLFFP    SPFlt
  4543.     move.l    d0,(a3)+
  4544.     dbra    d4,.L2
  4545.  
  4546.     lea.l    DiffR(pc),a3
  4547.     lea.l    FaktorR(pc),a4
  4548.  
  4549.     move.l    (a3)+,d0        ; How much R (,G,B)  has to be added each colour ?
  4550.     move.l    DiffColor(pc),d1
  4551.     CALLFFP    SPDiv
  4552.     move.l    d0,(a4)+
  4553.     move.l    (a3)+,d0
  4554.     move.l    DiffColor(pc),d1
  4555.     CALLFFP    SPDiv
  4556.     move.l    d0,(a4)+
  4557.     move.l    (a3)+,d0
  4558.     move.l    DiffColor(pc),d1
  4559.     CALLFFP    SPDiv
  4560.     move.l    d0,(a4)+
  4561.  
  4562. .L3    lea.l    FirstR(pc),a3
  4563.     lea.l    FaktorR(pc),a4
  4564.     lea.l    R_Wert(pc),a5
  4565.     
  4566.     move.l    (a3),d0        ; add to R,G,B
  4567.     move.l    (a4)+,d1
  4568.     CALLFFP    SPAdd
  4569.     move.l    d0,(a3)+
  4570.     CALLFFP    SPFix        ; convert result to integer
  4571.     move.l    d0,(a5)+
  4572.     move.l    (a3),d0
  4573.     move.l    (a4)+,d1
  4574.     CALLFFP    SPAdd
  4575.     move.l    d0,(a3)+
  4576.     CALLFFP    SPFix
  4577.     move.l    d0,(a5)+
  4578.     move.l    (a3),d0
  4579.     move.l    (a4)+,d1
  4580.     CALLFFP    SPAdd
  4581.     move.l    d0,(a3)+
  4582.     CALLFFP    SPFix
  4583.     move.l    d0,(a5)+
  4584.     
  4585.     addq.l    #1,FirstColor        ; set colour
  4586.     move.l    FirstColor(pc),d0
  4587.     movem.l    R_Wert(pc),d1-d3
  4588.     bsr    WriteColor
  4589.     dbra    d6,.L3
  4590.  
  4591.     
  4592.     
  4593. .exit    clr.b    Colour_Mode
  4594.     CALLINT_PC    RemakeDisplay        ; remake copper list
  4595.     bra    IN2
  4596.  
  4597.  
  4598. FirstR    dc.l    0
  4599. FirstG    dc.l    0
  4600. FirstB    dc.l    0
  4601. DiffR    dc.l    0
  4602. DiffG    dc.l    0
  4603. DiffB    dc.l    0
  4604. DiffColor    dc.l    0    
  4605. FaktorR    dc.l    0
  4606. FaktorG    dc.l    0
  4607. FaktorB    dc.l    0
  4608. FirstColor    dc.l    0
  4609. LastColor    dc.l    0
  4610. ColorNumber    dc.l    0
  4611.  
  4612. R_Wert    dc.l    0
  4613. G_Wert    dc.l    0
  4614. B_Wert    dc.l    0
  4615.     
  4616.  
  4617.  
  4618. ReadColorII    move.l    d0,-(sp)
  4619.     move.l    Window1_Ptr(pc),a0
  4620.     CALLINT_PC    ViewPortAddress
  4621.     move.l    d0,a0
  4622.     move.l    (sp)+,d0
  4623.     move.l    vp_ColorMap(a0),a0
  4624.     and.l    #$1f,d0
  4625.     CALLGRAF_PC    GetRGB4
  4626.     move.b    d0,d1
  4627.     move.b    d0,d2
  4628.     and.l    #$f,d2
  4629.     lsr.b    #4,d1
  4630.     and.l    #$f,d1    
  4631.     lsr.w    #8,d0
  4632.     and.l    #$f,d0
  4633.     rts
  4634.  
  4635. WriteColor    and.w    #$1f,d0
  4636.     move.l    d0,-(sp)
  4637.     move.l    Window1_Ptr(pc),a0
  4638.     CALLINT_PC    ViewPortAddress
  4639.     move.l    d0,a0
  4640.     move.l    (sp)+,d0
  4641.     CALLGRAF_PC    SetRGB4
  4642.     rts
  4643. Colour_Error    move.l    ScreenPtr1,a0    ; User tried to copy, spread or exchange a normal colour and a EHB colour!
  4644.     CALLINT_PC    DisplayBeep
  4645.     clr.b    Colour_Mode
  4646.     bra    Colour_wait
  4647.  
  4648. ********************* end of COLOUR
  4649.  
  4650.  
  4651. _DOSBase    dc.l    0
  4652. _GfxBase    dc.l    0
  4653. _IntuitionBase    dc.l    0
  4654.  
  4655. *
  4656. * goto sector
  4657. *
  4658.  
  4659.  
  4660. WindowPointer set Window2
  4661.  
  4662. Windowdef4    dc.w    60,50,310,100
  4663.     dc.b    -1,-1
  4664.     dc.l    GADGETUP
  4665.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  4666.     dc.l    GB_Gadget1
  4667.     dc.l    0
  4668.     dc.l    0
  4669.     dc.l    0,0
  4670.     dc.w    0,0,0,0,CUSTOMSCREEN
  4671.  
  4672. GB_Gadget1    FM_GADGET    GB_Gadget5,5,80,56,1,<"Cancel">,1,2
  4673. GB_Gadget5    FM_GADGET    GB_Gadget6,61+5,80,56,5,<"First">,1,4
  4674. GB_Gadget6    FM_GADGET    GB_Gadget7,122+5,80,56,6,<"Last">,1,4
  4675. GB_Gadget7    FM_GADGET    GB_Gadget8,183+5,80,56,7,<"Offset">,1,4
  4676. GB_Gadget8    FM_GADGET    GB_Gadget3,244+5,80,56,8,<"Sector">,1,4
  4677.  
  4678.  
  4679.  
  4680. GB_Gadget3    dc.l    GB_Gadget4
  4681.     dc.w    146+5,40-12,10*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  4682.     dc.l    GB_G1_Box,0,0,0,GB_G1_Info
  4683.     dc.w    100,0,0
  4684. GB_G1_Box    BOX    -1,-1,81,8,2,GB_G1_Box2
  4685. GB_G1_Box2    BOX    -2,-2,82,9,1,0
  4686. GB_G1_Info    dc.l    GB_G1_Puffer,GB_G1_Undo
  4687.     dc.w    0,10
  4688.     ds.w    12
  4689. GB_G1_Puffer    ds.b    12
  4690. GB_G1_Undo    ds.b    12    
  4691. GB_Gadget4    dc.l    0
  4692.     dc.w    146+5,65-12,10*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  4693.     dc.l    GB_G1_Box,0,0,0,GB_G2_Info
  4694.     dc.w    101,0,0
  4695. GB_G2_Info    dc.l    GB_G2_Puffer,GB_G2_Undo
  4696.     dc.w    0,10
  4697.     ds.w    12
  4698. GB_G2_Puffer    ds.b    12
  4699. GB_G2_Undo    ds.b    12    
  4700.  
  4701.  
  4702. BLOCK    tst.b    FlagFile    ; have you already opened a file ?        
  4703.     beq    .wait
  4704.     move.l    Offset,d0
  4705.     lea.l    GB_G2_Puffer(pc),a0
  4706.     bsr    MakeHex
  4707.     clr.b    (a0)    
  4708.     move.l    Offset,d0
  4709.     divu    #512,d0
  4710.     and.l    #$ffff,d0
  4711.     addq    #1,d0
  4712.     lea.l    GB_G1_Puffer(pc),a0
  4713.     bsr    MakeZahl
  4714.     clr.b    (a0)    
  4715.  
  4716.     lea.l    Windowdef4(pc),a0
  4717.     bsr    MakeWindow
  4718.     tst.l    d0
  4719.     beq    .wait
  4720.     move.l    d0,Window2
  4721.     SETDRMD    #RP_JAM1
  4722.     WRITE    #6+(300-13*8)/2,#11,#0,<"Goto sector :">
  4723.     WRITE    #5+(300-13*8)/2,#10,#1,<"Goto sector :">
  4724.     WRITE    #5+(300-19*8)/2,#40-6,#1,<"Sector : ">
  4725.     WRITE    #5+(300-19*8)/2,#65-6,#1,<"Offset : ">
  4726.     
  4727.     lea.l    GB_Gadget3(pc),a0
  4728.     move.l    WindowPointer(pc),a1
  4729.     sub.l    a2,a2
  4730.     CALLINT_PC    ActivateGadget
  4731.     
  4732.  
  4733.     move.l    Window2(pc),a0        ; wait .....
  4734.     move.l    wd_UserPort(a0),a0
  4735.     move.l    a0,a5
  4736.     CALLEXEC    WaitPort        
  4737.     move.l    a5,a0
  4738.     CALLEXEC    GetMsg        ; get message
  4739.     move.l    d0,a1    
  4740.     move.l    im_Class(a1),d4    ; get data
  4741.     move.w    im_Code(a1),d5
  4742.     move.l    im_IAddress(a1),a4
  4743.     CALLEXEC     ReplyMsg        ; reply message        
  4744.     moveq.l    #10,d1
  4745.     CALLDOS_PC    Delay
  4746.     move.l    Window2(pc),a0
  4747.     CALLINT_PC    CloseWindow
  4748.     moveq.l    #0,d0        
  4749.     move.w    gg_GadgetID(a4),d0    
  4750.     cmp.b    #5,d0
  4751.     beq.s    FIRSTBLOCK
  4752.     cmp.b    #6,d0
  4753.     beq    LASTBLOCK
  4754.     cmp.b    #8,d0
  4755.     beq    GOTOBLOCK
  4756.     cmp.b    #100,d0
  4757.     beq    GOTOBLOCK
  4758.     cmp.b    #9,d0
  4759.     beq    GOTOOFFSET
  4760.     cmp.b    #101,d0
  4761.     beq    GOTOOFFSET
  4762. .wait    bra    wait
  4763.  
  4764. ***************************************
  4765.  
  4766. FIRSTBLOCK    tst.b    FlagFile
  4767.     beq.s    .Nothing
  4768.     bsr    WriteQuestion    ; go to 1. sector
  4769.     moveq.l    #0,d0
  4770.     bra    GetBlock
  4771. .Nothing    bra    wait
  4772.  
  4773. ***************************************
  4774.     
  4775. LASTBLOCK    tst.b    FlagFile
  4776.     beq.s    .Nothing
  4777.     bsr    WriteQuestion    ; go to last sector
  4778.     move.l    Size,d0
  4779.     subq.l    #1,d0
  4780.     and.l    #-1-511,d0
  4781.     bra    GetBlock
  4782. .Nothing    bra    wait
  4783.  
  4784. ****************************************
  4785.  
  4786. GOTOBLOCK    lea.l    GB_G1_Puffer(pc),a0    ; go to special sector
  4787.     bsr    GetZahl
  4788.     tst.l    d1
  4789.     bne.s    .Wally
  4790.     tst.l    d0
  4791.     beq.s    WallyII
  4792.     subq.l    #1,d0
  4793.     mulu    #512,d0
  4794.     cmp.l    Size(pc),d0
  4795.     bge.s    WallyII
  4796.     move.l    d0,.Sector
  4797.     bsr    WriteQuestion
  4798.     move.l    .Sector(pc),d0    
  4799.     bra    GetBlock
  4800. .Wally    move.l    ScreenPtr1(pc),a0    ; user is unable to enter a number correctly
  4801.     CALLINT_PC    DisplayBeep
  4802.     bra    BLOCK
  4803. .Sector    dc.l    0
  4804.  
  4805. WallyII    lea.l    Windowdef2(pc),a0    ; sector doesn't exist !
  4806.     bsr    MakeWindow
  4807.     tst.l    d0
  4808.     beq    .wait
  4809.     move.l    d0,Window2
  4810.     SETDRMD    #RP_JAM1
  4811.     WRITE    #6+(290-22*8)/2,#19+10,#0,<"Sector doesn't exist !">
  4812.     WRITE    #5+(290-22*8)/2,#18+10,#1,<"Sector doesn't exist !">
  4813.     move.l    Window2(pc),a0        
  4814.     move.l    wd_UserPort(a0),a0
  4815.     move.l    a0,a5
  4816.     CALLEXEC    WaitPort        
  4817.     move.l    Window2(pc),a0
  4818.     CALLINT_PC    CloseWindow
  4819. .wait    bra    wait    
  4820.  
  4821.  
  4822. ****************************************
  4823.  
  4824. GOTOOFFSET    lea.l    GB_G2_Puffer(pc),a0    ; go to special byte
  4825.     bsr    GetZahl
  4826.     tst.l    d1
  4827.     bne    .Wally
  4828.     cmp.l    Size,d0
  4829.     bge    WallyII
  4830.     move.l    d0,.OffsetC
  4831.     bsr    WriteQuestion
  4832.     move.l    .OffsetC(pc),d0    
  4833.     and.l    #-1-511,d0
  4834.     
  4835.     move.l    d0,.Offset
  4836.     tst.l    Memory        ; get block offset d0
  4837.     beq.s    .GetBlockDisk
  4838.     move.l    Memory(pc),a0
  4839.     add.l    d0,a0
  4840.     lea.l    Puffer,a1
  4841.     lea.l    UndoPuffer,a2
  4842.     move.w    #511,d0
  4843. .L0    move.b    (a0),(a1)+    
  4844.     move.b    (a0)+,(a2)+    
  4845.     dbra    d0,.L0
  4846.     move.l    Size,d0
  4847.     sub.l    .Offset(pc),d0
  4848.     cmp.l    #512,d0
  4849.     bls.s    .L3
  4850.     move.l    #512,d0
  4851. .L3    move.l    d0,AnzahlBytes
  4852.     move.l    .Offset(pc),Offset
  4853.     bra    .NewBlock
  4854.  
  4855. .GetBlockDisk    move.l    Filehandle(pc),d1
  4856.     tst.l    d1
  4857.     beq    .Error
  4858.     move.l    .Offset(pc),d2
  4859.     moveq.l    #OFFSET_BEGINNING,d3
  4860.     CALLDOS_PC    Seek
  4861.     move.l    Filehandle(pc),d1
  4862.     move.l    Size(pc),d3
  4863.     sub.l    .Offset(pc),d3
  4864.     cmp.l    #512,d3
  4865.     bls    .L1
  4866.     move.l    #512,d3
  4867. .L1    move.l    d3,d5
  4868.     move.l    #Puffer2,d2
  4869.     CALLDOS_PC    Read
  4870.     cmp.l    d0,d5
  4871.     bne    OpenError
  4872.     lea.l    Puffer2,a0
  4873.     lea.l    Puffer,a1
  4874.     lea.l    UndoPuffer,a2
  4875.     move.w    #511,d0
  4876. .L2    move.b    (a0),(a1)+    
  4877.     move.b    (a0)+,(a2)+    
  4878.     dbra    d0,.L2
  4879.     move.l    d5,AnzahlBytes
  4880.     move.l    .Offset(pc),Offset
  4881. .Error    
  4882. .NewBlock    bsr    SectorNumber
  4883.     tst.l    AnzahlBytes
  4884.     beq    NewMode
  4885.     bsr    ShowPuffer
  4886.     lea.l    Color,a0
  4887.     move.w    #511,d0
  4888. .L4    move.b    #3,(a0)+
  4889.     dbra    d0,.L4
  4890.  
  4891.     clr.l    Cursor
  4892.     move.l    .OffsetC(pc),d0
  4893.     and.l    #511,d0
  4894.     bsr    SetCursor
  4895.     bsr    PrintPosition
  4896.     and.b    #1,Mode
  4897.     bra    NewMode            
  4898.  
  4899. .Wally    move.l    ScreenPtr1(pc),a0    ; user is unable to enter a number correctly
  4900.     CALLINT_PC    DisplayBeep
  4901.     bra    BLOCK
  4902.  
  4903. .Offset    dc.l    0
  4904. .OffsetC    dc.l    0
  4905.  
  4906. ****************************************
  4907.  
  4908.  
  4909.  
  4910. MakeZahl    movem.l    d0-d7/a1-a5,-(sp)    ; convert d0 into ASCII (a0 ^buffer)
  4911.     tst.l    d0
  4912.     bpl.s    .MZ0
  4913.     move.b    #"-",(a0)+
  4914.     neg.l    d0
  4915. .MZ0    moveq.l    #9,d2
  4916.     moveq.l    #0,d3
  4917.     lea.l    .MZ_Potenzen(pc),a2
  4918. .MZ1    move.b    #"0"-1,d1
  4919. .MZ2    addq    #1,d1
  4920.     sub.l    (a2),d0
  4921.     bcc.s    .MZ2
  4922.     add.l    (a2)+,d0
  4923.     tst.b    d2
  4924.     beq.s    .MZ3
  4925.     cmp.b    #"0",d1
  4926.     beq.s    .MZ4
  4927.     moveq.l    #1,d3
  4928.     bra.s    .MZ3
  4929. .MZ4    tst.b    d3
  4930.     beq.s    .MZ5
  4931. .MZ3    move.b    d1,(a0)+
  4932. .MZ5    dbra    d2,.MZ1
  4933.     movem.l    (sp)+,d0-d7/a1-a5
  4934.     rts
  4935. .MZ_Potenzen    dc.l    1000000000
  4936.     dc.l    100000000
  4937.     dc.l    10000000
  4938.     dc.l    1000000
  4939.     dc.l    100000
  4940.     dc.l    10000
  4941.     dc.l    1000
  4942.     dc.l    100
  4943.     dc.l    10
  4944.     dc.l    1
  4945.  
  4946. **************************************
  4947.  
  4948. MakeHex    movem.l    d0-d7/a1-a5,-(sp)    ; convert d0 into HEX (a0 ^buffer)
  4949.     tst.l    d0
  4950.     bpl.s    .MH0
  4951.     move.b    #"-",(a0)+
  4952.     neg.l    d0
  4953. .MH0    move.b    #"$",(a0)+
  4954.     move.l    d0,d1
  4955.     move.l    #32-4,d2
  4956.     lea.l    .Hex(pc),a1        
  4957.     moveq.l    #0,d3
  4958. .MH1    move.l    d1,d0
  4959.     lsr.l    d2,d0
  4960.     and.l    #$f,d0
  4961.     tst.l    d2
  4962.     beq.s    .MH3
  4963.     tst.b    d3
  4964.     bne.s    .MH3
  4965.     tst.b    d0
  4966.     beq.s    .MH2
  4967. .MH3    move.b    (a1,d0),(a0)+    
  4968.     moveq.l    #1,d3
  4969. .MH2    subq.l    #4,d2
  4970.     cmp.l    #-4,d2
  4971.     bne.s    .MH1
  4972.     movem.l    (sp)+,d0-d7/a1-a5
  4973.     rts        
  4974. .Hex    dc.b    "0123456789abcdef"
  4975.  
  4976. ***************************************
  4977.  
  4978. GetZahl    movem.l    d2-d7/a0-a6,-(sp)    ; convert ASCII to number
  4979.     bsr.s    .label20        ; set a0 ^ASCII
  4980.     tst.l    .Invert
  4981.     beq.s    .L21
  4982.     neg.l    d0
  4983. .L21    movem.l    (sp)+,d2-d7/a0-a6    ; result : d0= number, d1= error flag
  4984.     rts    
  4985. .Invert    dc.l    0
  4986.  
  4987. .label20    cmp.b    #" ",(a0)+
  4988.     beq.s    .label20
  4989.     tst.b    -(a0)
  4990.     clr.l    .Invert
  4991.     cmp.b    #"-",(a0)
  4992.     bne.s    .label21
  4993.     tst.b    (a0)+
  4994.     move.l    #-1,.Invert
  4995. .label21    move.l    a0,a1    
  4996.     cmp.b    #"$",(a0)        ; Hex ?
  4997.     beq    .GetHex
  4998.     lea.l    .Potenzen-4(pc),a2    ; Pointer to 10^x
  4999.     moveq.l    #0,d0         
  5000. .label7    tst.b    (a0)+         
  5001.     bne.s    .label7        ; get last character 
  5002.     tst.b    -(a0)
  5003. .label8    move.b    -(a0),d1         
  5004.     cmp.l    a1,a0        ; already reached to first character
  5005.     bge.s    .label9        ; no ! 
  5006.  
  5007.     moveq.l    #0,d1        ; no error
  5008.     rts
  5009.  
  5010. .label9    tst.l    (a2)+        ; next 10^x
  5011.     beq.s    .label12        ; number too high !
  5012.     sub.b    #"0",d1        ; 
  5013.     cmp.b    #9,d1        ; useful ?
  5014.     bhi.s    .label12
  5015.     tst.b    d1        ; add as many times as demanded
  5016.     beq.s    .label8        ; 
  5017.     subq    #1,d1
  5018.     and.l    #15,d1
  5019. .label11    add.l    (a2),d0
  5020.     dbra    d1,.label11
  5021.     bra.s    .label8        ; previous character
  5022.  
  5023. .label12    moveq.l    #-1,d1        ; error !!!
  5024.     rts
  5025.  
  5026.  
  5027. .GetHex    tst.b    (a0)+        ; do not read "$"
  5028.     move.l    a0,a1
  5029.     lea.l    .Hex(pc),a2        ; Hex table
  5030.     moveq.l    #0,d0
  5031.     moveq.l    #-4,d2        ; d2 = how often has the nibble to be moved to the left
  5032.                  
  5033.                  
  5034. .label13    tst.b    (a0)+        : get last character
  5035.     bne.s    .label13
  5036.     tst.b    -(a0)
  5037. .label14    move.b    -(a0),d1
  5038.     cmp.l    a1,a0        ; already reached the first character
  5039.                 
  5040.     bge.s    .label15
  5041.     moveq.l    #0,d1        ; no error
  5042.     rts
  5043.  
  5044. .label15    addq.l    #4,d2        ; nibbel has to be moved 4 bits more
  5045.     cmp.b    #32,d2        ; number to high ?
  5046.     beq.s    .label12
  5047.  
  5048.     moveq.l    #-1,d3        ; look up for ascii
  5049. .label16    addq    #1,d3
  5050.     cmp.b    #32,d3
  5051.     beq.s    .label12
  5052.     cmp.b    (a2,d3),d1
  5053.     bne.s    .label16
  5054.     and.l    #$f,d3        
  5055.     lsl.l    d2,d3        ; move nibble to right position in the long word 
  5056.     add.l    d3,d0        ; add it
  5057.     bra.s    .label14        ; next character
  5058.             
  5059. .Potenzen    dc.l    1
  5060.     dc.l    10
  5061.     dc.l    100
  5062.     dc.l    1000
  5063.     dc.l    10000
  5064.     dc.l    100000
  5065.     dc.l    1000000
  5066.     dc.l    10000000
  5067.     dc.l    100000000
  5068.     dc.l    1000000000
  5069.     dc.l    0
  5070. .Hex    dc.b    "0123456789abcdef"
  5071.     dc.b    "0123456789ABCDEF"
  5072.  
  5073.  
  5074.  
  5075. ***************************
  5076.  
  5077. * change size - add or sub bytes
  5078. *
  5079. *
  5080.  
  5081. Windowdef5    dc.w    60,40,310,130
  5082.     dc.b    -1,-1
  5083.     dc.l    GADGETUP
  5084.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  5085.     dc.l    SI_Gadget1
  5086.     dc.l    0
  5087.     dc.l    0
  5088.     dc.l    0,0
  5089.     dc.w    0,0,0,0,CUSTOMSCREEN
  5090.  
  5091. SI_Gadget1    FM_GADGET    SI_Gadget2,5,110,70,1,<"Cancel">,1,2
  5092. SI_Gadget2    FM_GADGET    SI_Gadget3,80,110,130,2,<"Create new file">,1,4
  5093. SI_Gadget3    FM_GADGET    SI_Gadget4,215,110,90,3,<"Same file">,1,4
  5094.  
  5095.  
  5096.  
  5097. SI_Gadget4    dc.l    SI_Gadget5
  5098.     dc.w    146+5+16,60-12,10*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  5099.     dc.l    SI_G4_Box,0,0,0,SI_G4_Info
  5100.     dc.w    4,0,0
  5101. SI_G4_Box    BOX    -1,-1,81,8,2,SI_G4_Box2
  5102. SI_G4_Box2    BOX    -2,-2,82,9,1,0
  5103. SI_G4_Info    dc.l    SI_G4_Puffer,SI_G4_Undo
  5104.     dc.w    0,10
  5105.     ds.w    12
  5106. SI_G4_Puffer    ds.b    12
  5107. SI_G4_Undo    ds.b    12    
  5108. SI_Gadget5    dc.l    SI_Gadget6
  5109.     dc.w    146+5+16,80-12,10*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  5110.     dc.l    SI_G4_Box,0,0,0,SI_G5_Info
  5111.     dc.w    5,0,0
  5112. SI_G5_Info    dc.l    SI_G5_Puffer,SI_G5_Undo
  5113.     dc.w    0,10
  5114.     ds.w    12
  5115. SI_G5_Puffer    ds.b    12
  5116. SI_G5_Undo    ds.b    12    
  5117. SI_Gadget6    dc.l    0
  5118.     dc.w    146+5+16,100-12,10*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  5119.     dc.l    SI_G4_Box,0,0,0,SI_G6_Info
  5120.     dc.w    5,0,0
  5121. SI_G6_Info    dc.l    SI_G6_Puffer,SI_G6_Undo
  5122.     dc.w    0,10
  5123.     ds.w    12
  5124. SI_G6_Puffer    ds.b    12
  5125. SI_G6_Undo    ds.b    12    
  5126.  
  5127. Size_Top    dc.l    0
  5128. Size_Bottom    dc.l    0
  5129. Size_Byte    dc.l    0
  5130.  
  5131. NS_Text    dc.b    "Size:          / New size:           "
  5132.     even
  5133.  
  5134. SIZE    tst.b    FlagFile    ; have you already opened a file ?        
  5135.     beq    .wait
  5136.     tst.l    Memory    
  5137.     beq    RAM_ONLY
  5138.     bsr    WriteQuestion
  5139.     move.l    Size_Top,d0
  5140.     lea.l    SI_G4_Puffer(pc),a0
  5141.     bsr    MakeZahl
  5142.     clr.b    (a0)    
  5143.     move.l    Size_Bottom,d0
  5144.     lea.l    SI_G5_Puffer(pc),a0
  5145.     bsr    MakeZahl
  5146.     clr.b    (a0)    
  5147.     move.l    Size_Byte,d0
  5148.     lea.l    SI_G6_Puffer(pc),a0
  5149.     bsr    MakeHex
  5150.     clr.b    (a0)    
  5151.  
  5152.  
  5153.     lea.l    Windowdef5(pc),a0
  5154.     bsr    MakeWindow
  5155.     tst.l    d0
  5156.     beq    .wait
  5157.     move.l    d0,Window2
  5158.     SETDRMD    #RP_JAM1
  5159.     WRITE    #6+(300-18*8)/2,#11,#0,<"Change file size :">
  5160.     WRITE    #5+(300-18*8)/2,#10,#1,<"Change file size :">
  5161.     WRITE    #5+(300-23*8)/2,#60-6,#1,<"First byte :">
  5162.     WRITE    #5+(300-23*8)/2,#80-6,#1,<"Last byte  :">
  5163.     WRITE    #5+(300-23*8)/2,#100-6,#1,<"Byte       :">
  5164.     
  5165.     lea.l    SI_Gadget4(pc),a0
  5166.     move.l    WindowPointer(pc),a1
  5167.     sub.l    a2,a2
  5168.     CALLINT_PC    ActivateGadget
  5169.  
  5170. .NewSize    move.l    Size,d0
  5171.     lea.l    NS_Text+5(pc),a0
  5172.     bsr    SI_PrintSize            
  5173.  
  5174.     move.l    Size,d0
  5175.     add.l    Size_Top,d0
  5176.     add.l    Size_Bottom,d0
  5177.     lea.l    NS_Text+26(pc),a0
  5178.     bsr    SI_PrintSize        
  5179.     SETDRMD    #RP_JAM2
  5180.     SETBPEN    #7    
  5181.  
  5182.  
  5183.     WRITEMEM    #16,#30,#1,NS_Text,#35
  5184.  
  5185.     move.l    Window2(pc),a0        ; wait .....
  5186.     move.l    wd_UserPort(a0),a0
  5187.     move.l    a0,a5
  5188.     CALLEXEC    WaitPort        
  5189.     move.l    a5,a0
  5190.     CALLEXEC    GetMsg        ; get message
  5191.     move.l    d0,a1    
  5192.     move.l    im_Class(a1),d4    ; get data
  5193.     move.w    im_Code(a1),d5
  5194.     move.l    im_IAddress(a1),a4
  5195.     CALLEXEC     ReplyMsg        ; reply message        
  5196.     moveq.l    #10,d1
  5197.     CALLDOS_PC    Delay
  5198.     moveq.l    #0,d0        
  5199.     move.w    gg_GadgetID(a4),d0
  5200.     cmp.b    #3,d0
  5201.     bhi    .Number
  5202.     cmp.b    #1,d0
  5203.     bne    .ChangeSize
  5204.     move.l    Window2(pc),a0
  5205.     CALLINT_PC    CloseWindow
  5206. .wait    bra    wait
  5207.  
  5208. .Number    lea.l    SI_G4_Puffer(pc),a0    ; convert ASCII to hex
  5209.     bsr    GetZahl        ; undo if error
  5210.     move.l    d1,d6
  5211.     tst.l    d1
  5212.     bne.s    .W1
  5213.     move.l    d0,Size_Top
  5214. .W1    lea.l    SI_G5_Puffer(pc),a0
  5215.     bsr    GetZahl
  5216.     add.l    d1,d6
  5217.     tst.l    d1
  5218.     bne.s    .W2
  5219.     move.l    d0,Size_Bottom
  5220. .W2    lea.l    SI_G6_Puffer(pc),a0
  5221.     bsr    GetZahl
  5222.     add.l    d1,d6
  5223.     cmp.l    #255,d0
  5224.     bhi.s    .W3
  5225.     tst.l    d6
  5226.     bne.s    .W3        
  5227.     move.l    d0,Size_Byte
  5228.     bra    .NewSize
  5229.  
  5230. .W3    move.l    ScreenPtr1(pc),a0        ; error -> undo 
  5231.     CALLINT_PC    DisplayBeep
  5232.     move.l    Size_Top(pc),d0
  5233.     lea.l    SI_G4_Puffer(pc),a0
  5234.     bsr    MakeZahl
  5235.     clr.b    (a0)    
  5236.     move.l    Size_Bottom,d0
  5237.     lea.l    SI_G5_Puffer(pc),a0
  5238.     bsr    MakeZahl
  5239.     clr.b    (a0)    
  5240.     move.l    Size_Byte(pc),d0
  5241.     lea.l    SI_G6_Puffer(pc),a0
  5242.     bsr    MakeHex
  5243.     clr.b    (a0)    
  5244.     lea.l    SI_Gadget4(pc),a0
  5245.     move.l    Window2(pc),a1
  5246.     sub.l    a2,a2
  5247.     CALLINT_PC    RefreshGadgets
  5248.     bra    .NewSize
  5249.  
  5250. .ChangeSize    subq.l    #2,d0
  5251.     move.l    d0,.Mode
  5252.     lea.l    SI_G4_Puffer(pc),a0    ; convert ASCII to hex
  5253.     bsr    GetZahl        ; go back if error
  5254.     move.l    d1,d6
  5255.     tst.l    d1
  5256.     bne.s    .Z1
  5257.     move.l    d0,Size_Top
  5258. .Z1    lea.l    SI_G5_Puffer(pc),a0
  5259.     bsr    GetZahl
  5260.     add.l    d1,d6
  5261.     tst.l    d1
  5262.     bne.s    .Z2
  5263.     move.l    d0,Size_Bottom
  5264. .Z2    lea.l    SI_G6_Puffer(pc),a0
  5265.     bsr    GetZahl
  5266.     add.l    d1,d6
  5267.     cmp.l    #255,d0
  5268.     bhi    .W3
  5269.     tst.l    d6
  5270.     bne    .W3        
  5271.     move.l    d0,Size_Byte
  5272.     move.l    Size(pc),d0        ; Does the user really
  5273.     add.l    Size_Top(pc),d0    ; want to create a file
  5274.     add.l    Size_Bottom(pc),d0    ; ( size >0 ) ????
  5275.     subq.l    #1,d0
  5276.     tst.l    d0
  5277.     bmi    .W3        ; NO !!!
  5278.     move.l    Size_Top(pc),d0
  5279.     neg.l    d0
  5280.     cmp.l    Size(pc),d0
  5281.     bgt    .W3
  5282.     beq    .W3
  5283.     move.l    Size_Bottom(pc),d0
  5284.     neg.l    d0
  5285.     cmp.l    Size(pc),d0
  5286.     bgt    .W3
  5287.     beq    .W3
  5288. .Z3    move.l    Window2(pc),a0
  5289.     CALLINT_PC    CloseWindow
  5290.     move.l    .Mode,d0
  5291.     tst.l    Memory
  5292.     bne    SIZE_RAM
  5293.     bra    wait
  5294.     
  5295. .Mode    dc.l    0
  5296.  
  5297.  
  5298.  
  5299.  
  5300. SI_PrintSize    movem.l    d0-d7/a0-a5,-(sp)
  5301.     move.b    #" ",d1
  5302.     tst.l    d0
  5303.     bpl.s    SI_PS0
  5304.     move.b    #"-",d1
  5305.     neg.l    d0
  5306. SI_PS0    move.b    d1,(a0)+
  5307.     moveq.l    #7,d2
  5308.     moveq.l    #0,d3
  5309.     lea.l    SI_Potenzen(pc),a2
  5310. SI_PS1    move.b    #"0"-1,d1
  5311. SI_PS2    addq    #1,d1
  5312.     sub.l    (a2),d0
  5313.     bcc    SI_PS2
  5314.     add.l    (a2)+,d0
  5315.     tst.b    d2
  5316.     beq    SI_PS3
  5317.     cmp.b    #"0",d1
  5318.     beq    SI_PS4
  5319.     moveq.l    #1,d3
  5320.     bra    SI_PS3
  5321. SI_PS4    tst.b    d3
  5322.     bne    SI_PS3
  5323.     move.b    #" ",d1
  5324. SI_PS3    move.b    d1,(a0)+
  5325.     dbra    d2,SI_PS1
  5326.     movem.l    (sp)+,d0-d7/a0-a5
  5327.     rts
  5328. SI_Potenzen    dc.l    10000000
  5329.     dc.l    1000000
  5330.     dc.l    100000
  5331.     dc.l    10000
  5332.     dc.l    1000
  5333.     dc.l    100
  5334.     dc.l    10
  5335.     dc.l    1
  5336.  
  5337.  
  5338. SIZE_RAM    tst.l    d0    ; change size / edit in RAM
  5339.     beq    .NewFile    
  5340.     move.l    Size(pc),d0
  5341.     add.l    Size_Top(pc),d0
  5342.     add.l    Size_Bottom(pc),d0
  5343.     move.l    d0,.NewSize
  5344.     moveq.l    #MEMF_PUBLIC,d1
  5345.     CALLEXEC    AllocMem    ; get menory
  5346.     tst.l    d0
  5347.     bne.s    .CS1
  5348.     bra    NoMemory
  5349. .CS1    move.l    d0,.NewMem    ; fill with demanded byte
  5350.     move.l    d0,a0
  5351.     move.l    d0,a1
  5352.     move.l    .NewSize(pc),d1
  5353.     subq.l    #1,d1
  5354. .CS2    move.b    Size_Byte+3,(a0)+
  5355.     dbra    d1,.CS2
  5356.  
  5357.     move.l    Memory(pc),a0    ; copy it
  5358.     move.l    Size(pc),d1
  5359.     move.l    Size_Top(pc),d0
  5360.     bpl    .CS3
  5361.     add.l    d0,d1
  5362.     neg.l    d0
  5363.     add.l    d0,a0
  5364.     bra    .CS4
  5365.  
  5366. .CS3    add.l    d0,a1
  5367. .CS4    move.l    Size_Bottom(pc),d0
  5368.     tst.l    d0
  5369.     bpl    .CS5
  5370.     add.l    d0,d1
  5371. .CS5    subq.l    #1,d1    ; -> DBRA
  5372.  
  5373. .CS6    move.b    (a0)+,(a1)+
  5374.     dbra    d1,.CS6
  5375.  
  5376.     move.l    Size(pc),d0    ; free memory used for the old file
  5377.     move.l    Memory(pc),a1
  5378.     CALLEXEC    FreeMem
  5379.     move.l    .NewMem(pc),Memory    ; prepare for new file
  5380.     move.l    .NewSize(pc),Size
  5381.     clr.b    FlagWrite
  5382.     bra    NewFile
  5383.  
  5384. .NewMem    dc.l    0
  5385. .NewSize    dc.l    0
  5386. .File    dc.l    0
  5387. .Filehandle    dc.l    0
  5388.  
  5389. .NewFile    lea.l    .NF_Text(pc),a5    ; save new file
  5390.     move.l    #R_G1,R_def+nw_FirstGadget
  5391.     bsr    FileRequester
  5392.     tst.l    d0
  5393.     beq    wait
  5394.     move.l    d0,.File
  5395.  
  5396.     move.l    #MODE_NEWFILE,d2
  5397.     move.l    d0,d1
  5398.     CALLDOS_PC    Open
  5399.     tst.l    d0
  5400.     beq    OpenError
  5401.     move.l    d0,.Filehandle
  5402.  
  5403.     move.l    Memory(pc),d6
  5404.     move.l    Size(pc),d7
  5405.     move.l    Size_Top(pc),d5
  5406.     subq.l    #1,d5
  5407.     tst.l    d5
  5408.     bmi    .K1
  5409.     
  5410. .K0    move.l    .Filehandle(pc),d1    ; write bytes at top
  5411.     moveq.l    #1,d3
  5412.     move.l    #Size_Byte+3,d2
  5413.     CALLDOS_PC    Write
  5414.     cmp.l    #1,d0
  5415.     bne    DiskError
  5416.     dbra    d5,.K0
  5417.     bra.s    .K2
  5418. .K1    sub.l    Size_Top(pc),d6    ; add Size_Top  -(-x) = +x   
  5419.     add.l    Size_Top(pc),d7
  5420. .K2    move.l    d6,d2        ; write main part of file
  5421.     move.l    d7,d3
  5422.     tst.l    Size_Bottom
  5423.     bpl.s    .K3
  5424.     add.l    Size_Bottom(pc),d3
  5425. .K3    move.l    d3,d5
  5426.     move.l    .Filehandle(pc),d1
  5427.     CALLDOS_PC    Write
  5428.     cmp.l    d5,d0
  5429.     bne    DiskError
  5430.  
  5431.  
  5432.     move.l    Size_Bottom(pc),d5
  5433.     subq.l    #1,d5
  5434.     tst.l    d5
  5435.     bmi    .K4
  5436.     
  5437. .K5    move.l    .Filehandle(pc),d1    ; write bytes at bottom
  5438.     moveq.l    #1,d3
  5439.     move.l    #Size_Byte+3,d2
  5440.     CALLDOS_PC    Write
  5441.     cmp.l    #1,d0
  5442.     bne    DiskError
  5443.     dbra    d5,.K5
  5444.  
  5445. .K4    move.l    .Filehandle(pc),d1
  5446.     CALLDOS_PC    Close
  5447. .wait    bra    wait
  5448.     
  5449.  
  5450. .NF_Text    dc.b    "       Save File With New Size :        "
  5451.     even
  5452.  
  5453. ****************************
  5454.  
  5455. SaveQuestion    move.l    (sp)+,.Return
  5456.     tst.b    FlagFile    ; ask if you want to save file
  5457.     beq    .wait
  5458.     tst.l    Memory    ; have you change anything or    
  5459.     beq    .wait    ; do you edit on device ?
  5460.     tst.b    FlagWrite
  5461.     beq    .wait
  5462.  
  5463.     lea.l    Windowdef3(pc),a0
  5464.     bsr    MakeWindow
  5465.     tst.l    d0
  5466.     beq    .wait
  5467.     move.l    d0,Window2
  5468.     SETDRMD    #RP_JAM1
  5469.     WRITE    #6+(290-23*8)/2,#19,#0,<"Do you want to save the">
  5470.     WRITE    #6+(290-6*8)/2,#19+15,#0,<"file ?">
  5471.     WRITE    #5+(290-23*8)/2,#18,#1,<"Do you want to save the">
  5472.     WRITE    #5+(290-6*8)/2,#18+15,#1,<"file ?">
  5473.  
  5474.  
  5475. .WAIT    move.l    Window2(pc),a0        ; wait .....
  5476.     move.l    wd_UserPort(a0),a0
  5477.     move.l    a0,a5
  5478.     CALLEXEC    WaitPort        
  5479.     move.l    a5,a0
  5480.     CALLEXEC    GetMsg        ; get message
  5481.     move.l    d0,a1    
  5482.     move.l    im_Class(a1),d4    ; get data
  5483.     move.w    im_Code(a1),d5
  5484.     move.l    im_IAddress(a1),a4
  5485.     CALLEXEC     ReplyMsg        ; reply message        
  5486.     moveq.l    #0,d0
  5487.     cmp.l    #VANILLAKEY,d4
  5488.     beq.s    .Key
  5489.     move.l    Window2(pc),a0
  5490.     CALLINT_PC    CloseWindow
  5491.     moveq.l    #0,d0        
  5492.     move.w    gg_GadgetID(a4),d0    
  5493.     bra    .Label1
  5494. .Key    cmp.b    #"y",d5
  5495.     beq.s    .Yes        ; yes
  5496.     cmp.b    #"Y",d5
  5497.     beq.s    .Yes        ; yes
  5498.     cmp.b    #"N",d5
  5499.     beq.s    .No
  5500.     cmp.b    #"n",d5
  5501.     bne    .WAIT
  5502. .No    moveq.l    #10,d1
  5503.     CALLDOS_PC    Delay
  5504.     move.l    Window2(pc),a0
  5505.     CALLINT_PC    CloseWindow
  5506.     moveq.l    #1,d0
  5507.     bra    .Label1
  5508. .Yes    moveq.l    #10,d1
  5509.     CALLDOS_PC    Delay
  5510.     move.l    Window2(pc),a0
  5511.     CALLINT_PC    CloseWindow
  5512.     moveq.l    #0,d0
  5513.  
  5514. .Label1    tst.b    d0
  5515.     bne    .wait
  5516.     lea.l    SAVE_Text(pc),a5    ; Save file
  5517.     move.l    #R_G1,R_def+nw_FirstGadget
  5518.     bsr    FileRequester
  5519.     tst.l    d0
  5520.     beq    .wait
  5521.     move.l    d0,.File
  5522.     move.l    .File(pc),d1        ; Copy file from RAM to device
  5523.     move.l    #MODE_NEWFILE,d2
  5524.     CALLDOS_PC    Open
  5525.     tst.l    d0
  5526.     beq    OpenError
  5527.     move.l    d0,Filehandle
  5528.     move.l    d0,d1
  5529.     move.l    Size(pc),d3
  5530.     move.l    Memory(pc),d2
  5531.     CALLDOS_PC    Write
  5532.     cmp.l    Size(pc),d0
  5533.     bne    DiskError
  5534.     
  5535.     move.l    Filehandle(pc),d1
  5536.     CALLDOS_PC    Close
  5537.     clr.b    FlagWrite
  5538. .wait    move.l    .Return(pc),a0
  5539.     jmp    (a0)
  5540. .Return    dc.l    0
  5541. .File    dc.l    0
  5542.  
  5543.  
  5544. ***************************
  5545.  
  5546.  
  5547. ChangeWrite    move.b    d0,WriteMode        ; change write mode flag
  5548.     tst.b    d0
  5549.     beq.s    .Q1
  5550.     bclr.b    #0,M1_I3_Sub1+mi_Flags
  5551. .Q1    cmp.b    #1,d0
  5552.     beq.s    .Q2
  5553.     bclr.b    #0,M1_I3_Sub2+mi_Flags
  5554. .Q2    cmp.b    #2,d0
  5555.     beq.s    .Q3
  5556.     bclr.b    #0,M1_I3_Sub3+mi_Flags
  5557. .Q3    bra    wait            
  5558.     
  5559. ************************************
  5560.  
  5561. PrefName    dc.b    "DEVS:FileMaster.Pref",0
  5562.     even
  5563. GetPrefs    lea.l    PrefName+5(pc),a0    ; current dir
  5564.     move.l    a0,d1        ; load preferences
  5565.     move.l    #MODE_OLDFILE,d2    ; if available  in 
  5566.     CALLDOS_PC    Open        ; the current dir
  5567.     tst.l    d0
  5568.     beq.s    .Try_DEVS
  5569.     move.l    d0,d1
  5570.     move.l    d0,d6
  5571.     move.l    #PrefSize,d3
  5572.     move.l    #PREFS,d2
  5573.     CALLDOS_PC    Read
  5574.     move.l    d6,d1
  5575.     CALLDOS_PC    Close
  5576.     rts
  5577.  
  5578. .Try_DEVS    lea.l    PrefName(pc),a0    ; DEVS:
  5579.     move.l    a0,d1        ; load preferences
  5580.     move.l    #MODE_OLDFILE,d2    ; if available  in 
  5581.     CALLDOS_PC    Open        ; the current dir
  5582.     tst.l    d0
  5583.     beq.s    .L1
  5584.     move.l    d0,d1
  5585.     move.l    d0,d6
  5586.     move.l    #PrefSize,d3
  5587.     move.l    #PREFS,d2
  5588.     CALLDOS_PC    Read
  5589.     move.l    d6,d1
  5590.     CALLDOS_PC    Close
  5591. .L1    rts
  5592.  
  5593. ************************************
  5594.  
  5595. SavePrefs    move.b    d0,d6
  5596.     move.l    Window1,a0        ; save preferences
  5597.     CALLINT_PC    ViewPortAddress    ; copy colours
  5598.     move.l    d0,a0
  5599.     move.l    vp_ColorMap(a0),a0
  5600.     move.l    cm_ColorTable(a0),a0
  5601.     lea.l    PREFS,a1
  5602.     moveq.l    #7,d0
  5603. .L0    move.w    (a0)+,(a1)+
  5604.     dbra    d0,.L0
  5605.     lea.l    PrefName(pc),a0
  5606.     move.l    a0,d1
  5607.     tst.b    d6        ; current dir or DEVS:
  5608.     bne.s    .Devs
  5609.     addq.l    #5,d1        ; skip "DEVS:"
  5610. .Devs    move.l    #MODE_NEWFILE,d2    
  5611.     CALLDOS_PC    Open        
  5612.     tst.l    d0
  5613.     beq    OpenError
  5614.     move.l    d0,d1
  5615.     move.l    d0,d6
  5616.     move.l    #PrefSize,d3
  5617.     move.l    #PREFS,d2
  5618.     CALLDOS_PC    Write
  5619.     cmp.l    d3,d0
  5620.     bne    .DiskError
  5621.     move.l    d6,d1
  5622.     CALLDOS_PC    Close
  5623. .L1    bra    wait
  5624.  
  5625. .DiskError    move.l    d6,d1
  5626.     CALLDOS_PC    Close
  5627.     bra    OpenError    
  5628.  
  5629. ************************************        
  5630.  
  5631. DefaultPrefs    lea.l    PREFS,a0    ; use default prefs
  5632.     lea.l    DPrefs,a1
  5633.     move.w    #PrefSize-1,d0
  5634. .L1    move.b    (a1)+,(a0)+
  5635.     dbra    d0,.L1
  5636.  
  5637.     move.l    Window1,a0        ; set colours
  5638.     CALLINT_PC    ViewPortAddress
  5639.     move.l    d0,a0
  5640.     move.l    #16,d0
  5641.     lea.l    Palette,a1
  5642.     CALLGRAF_PC    LoadRGB4
  5643.     CALLINT_PC    RemakeDisplay
  5644.  
  5645.     move.b    WriteMode,d0        ; set marks
  5646.     bset.b    #0,M1_I3_Sub1+mi_Flags
  5647.     bset.b    #0,M1_I3_Sub2+mi_Flags
  5648.     bset.b    #0,M1_I3_Sub3+mi_Flags
  5649.     tst.b    d0
  5650.     beq.s    .Q1
  5651.     bclr.b    #0,M1_I3_Sub1+mi_Flags
  5652. .Q1    cmp.b    #1,d0
  5653.     beq.s    .Q2
  5654.     bclr.b    #0,M1_I3_Sub2+mi_Flags
  5655. .Q2    cmp.b    #2,d0
  5656.     beq.s    .Q3
  5657.     bclr.b    #0,M1_I3_Sub3+mi_Flags
  5658. .Q3    jsr    Hardcopy_Gadgets
  5659.     lea.l    M1_I6_String+12(pc),a0
  5660.     move.b    DriveName+2,(a0)
  5661.     move.b    Joker,JoString+12        ; copy joker to menu
  5662.     bra    wait
  5663.     
  5664. *************************************    
  5665.  
  5666. *
  5667. * who's the author of File Master ?????
  5668. *
  5669.  
  5670.  
  5671. WindowPointer set Window2
  5672.  
  5673. Windowdef6    dc.w    50,34,350,150
  5674.     dc.b    -1,-1
  5675.     dc.l    GADGETUP!VANILLAKEY
  5676.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  5677.     dc.l    .Gadget1
  5678.     dc.l    0
  5679.     dc.l    0
  5680.     dc.l    0,0
  5681.     dc.w    0,0,0,0,CUSTOMSCREEN
  5682.  
  5683. .Gadget1    FM_GADGET    0,150,130,50,0,<"OK">,1,4
  5684.  
  5685. ABOUT    jsr    INFO
  5686.     bra    wait
  5687.  
  5688. INFO    lea.l    Windowdef6(pc),a0
  5689.     bsr    MakeWindow
  5690.     tst.l    d0
  5691.     beq    .wait
  5692.     move.l    d0,Window2
  5693.  
  5694.     move.l    d0,a0
  5695.     move.l    wd_RPort(a0),a0
  5696.     lea.l    FM_LOGO,a1
  5697.     moveq.l    #4,d1
  5698.     move.l    #(350-241)/2,d0
  5699.     CALLINT_PC    DrawImage
  5700.  
  5701.  
  5702.     SETDRMD    #RP_JAM1
  5703.  
  5704.     WRITE    #6+(340-41*8)/2,#36+5,#0,<"Source  238 / Release 1.2 / Date  1.04.90">
  5705.     
  5706.     WRITE    #6+(340-24*8)/2,#51+5,#0,<"© by    ROGER FISCHLIN  ">
  5707.     WRITE    #6+(340-24*8)/2,#61+5,#0,<"        STEIGERWALDWEG 6">
  5708.     WRITE    #6+(340-24*8)/2,#71+5,#0,<"        D-6450 HANAU 7  ">
  5709.     WRITE    #6+(340-24*8)/2,#81+5,#0,<"        WEST GERMANY    ">
  5710.     WRITE    #6+(340-24*8)/2,#91+5,#0,<"Phone : (06181) 650266">
  5711.     
  5712.     WRITE    #6+(340-42*8)/2,#106+5,#0,<"This program is SHAREWARE - if you use it,">
  5713.     WRITE    #6+(340-42*8)/2,#116+5,#0,<"please send me US $10 (or DM 10 only EEC).">
  5714.     
  5715.  
  5716.     WRITE    #5+(340-41*8)/2,#35+5,#5,<"Source  238 / Release 1.2 / Date  1.04.90">
  5717.     
  5718.     WRITE    #5+(340-24*8)/2,#50+5,#1,<"© by    ROGER FISCHLIN  ">
  5719.     WRITE    #5+(340-24*8)/2,#60+5,#1,<"        STEIGERWALDWEG 6">
  5720.     WRITE    #5+(340-24*8)/2,#70+5,#1,<"        D-6450 HANAU 7  ">
  5721.     WRITE    #5+(340-24*8)/2,#80+5,#1,<"        WEST GERMANY    ">
  5722.     WRITE    #5+(340-24*8)/2,#90+5,#1,<"Phone : (06181) 650266">
  5723.     
  5724.     WRITE    #5+(340-42*8)/2,#105+5,#5,<"This program is SHAREWARE - if you use it,">
  5725.     WRITE    #5+(340-42*8)/2,#115+5,#5,<"please send me US $10 (or DM 10 only EEC).">
  5726.     
  5727.     move.l    Window2,a0
  5728.     move.l    wd_UserPort(a0),a0
  5729.     move.l    a0,a5
  5730.     CALLEXEC    WaitPort        
  5731.     move.l    Window2,a0
  5732.     CALLINT_PC    CloseWindow
  5733. .wait    rts
  5734.  
  5735.  
  5736. ****************************************
  5737.  
  5738. *
  5739. * search (HEX or ASCII)
  5740. *
  5741.  
  5742. WindowPointer set Window2
  5743.  
  5744. Windowdef7    dc.w    40,36,370,140
  5745.     dc.b    -1,-1
  5746.     dc.l    GADGETUP!GADGETDOWN
  5747.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  5748.     dc.l    SE_Gadget1
  5749.     dc.l    0
  5750.     dc.l    0
  5751.     dc.l    0,0
  5752.     dc.w    0,0,0,0,CUSTOMSCREEN
  5753.  
  5754. SE_Gadget1    FM_GADGET    SE_Gadget2,10,120,110,1,<"Cancel">,1,2
  5755. SE_Gadget2    FM_GADGET    SE_Gadget3,130,120,110,2,<"Search ASCII">,1,2
  5756. SE_Gadget3    FM_GADGET    SE_Gadget4,250,120,110,3,<"Search HEX">,1,2
  5757. SE_Gadget4    FM_GADGET    SE_Gadget5,210,50,70,4,<"First">,1,4
  5758. SE_Gadget5    FM_GADGET    SE_Gadget6,290,50,70,5,<"Last">,1,4
  5759. SE_Gadget6    FM_GADGET    SE_Gadget7,210,70,70,6,<"Yes">,1,4
  5760. SE_Gadget7    FM_GADGET    SE_Gadget8,290,70,70,7,<"No">,1,4
  5761. SE_Gadget8    FM_GADGET    SE_Gadget9,210,90,70,8,<"Forward">,1,4
  5762. SE_Gadget9    FM_GADGET    SE_Gadget10,290,90,70,9,<"Backward">,1,4
  5763.  
  5764.  
  5765. SE_Gadget10    dc.l    SE_Gadget11
  5766.     dc.w    11,30+1,43*8,10,GADGHCOMP,STRINGCENTER,STRGADGET
  5767.     dc.l    SE_G10_Box,0,0,0,SE_G10_Info
  5768.     dc.w    10,0,0
  5769. SE_G10_Box    BOX    -1,-1,344,8,2,SE_G10_Box2
  5770. SE_G10_Box2    BOX    -2,-2,345,9,1,0
  5771. SE_G10_Info    dc.l    SE_G10_Puffer,SE_G10_Undo
  5772.     dc.w    0,44
  5773.     ds.w    12
  5774. SE_G10_Puffer    ds.b    50
  5775. SE_G10_Undo    ds.b    50    
  5776.  
  5777. SE_Gadget11    dc.l    0
  5778.     dc.w    130,50+2,64,10,GADGHCOMP,RELVERIFY,STRGADGET
  5779.     dc.l    SE_G11_Box,0,0,0,SE_G11_Info
  5780.     dc.w    11,0,0
  5781. SE_G11_Box    BOX    -1,-1,64,8,2,SE_G11_Box2
  5782. SE_G11_Box2    BOX    -2,-2,65,9,1,0
  5783. SE_G11_Info    dc.l    SE_G11_Puffer,SE_G11_Undo
  5784.     dc.w    0,10
  5785.     ds.w    12
  5786. SE_G11_Puffer    ds.b    20
  5787. SE_G11_Undo    ds.b    20    
  5788.  
  5789. Xwait    jmp    wait
  5790.  
  5791. SEARCH    tst.b    FlagFile            ; have you already opened a file ?        
  5792.     beq.s    Xwait
  5793.     move.w    #GADGIMMEDIATE,d0
  5794.     move.w    d0,SE_Gadget4+gg_Activation        ; modify gadgets
  5795.     move.w    d0,SE_Gadget5+gg_Activation
  5796.     move.w    d0,SE_Gadget6+gg_Activation
  5797.     move.w    d0,SE_Gadget7+gg_Activation
  5798.     move.w    d0,SE_Gadget8+gg_Activation
  5799.     move.w    d0,SE_Gadget9+gg_Activation
  5800.  
  5801.     move.l    Offset,d0
  5802.     divu    #512,d0
  5803.     and.l    #$ffff,d0
  5804.     addq    #1,d0
  5805.     move.l    d0,SearchSector
  5806.     lea.l    SE_G11_Puffer(pc),a0
  5807.     bsr    MakeZahl
  5808.     clr.b    (a0)    
  5809.     clr.l    SearchPos
  5810.  
  5811.     lea.l    Windowdef7(pc),a0
  5812.     bsr    MakeWindow
  5813.     tst.l    d0
  5814.     beq.s    Xwait
  5815.     move.l    d0,Window2
  5816.     SETDRMD    #RP_JAM1
  5817.     WRITE    #6+(370-8*8)/2,#11,#0,<"Search :">
  5818.     WRITE    #5+(370-8*8)/2,#10,#1,<"Search :">
  5819.     WRITE    #10,#58,#1,<"Sector       :">
  5820.     WRITE    #10,#78,#1,<"Case sensitiv:">
  5821.     WRITE    #10,#98,#1,<"Direction    :">
  5822.  
  5823. S_NewPref    SETDRMD    #RP_JAM2        ; write input
  5824.     SETBPEN    #7
  5825.     tst.l    SearchCase
  5826.     bne.s    .L1
  5827.     WRITE    #130,#78,#5,<"yes">
  5828.     bra.s    .L2
  5829. .L1    WRITE    #130,#78,#5,<"no ">
  5830. .L2    tst.l    SearchDirection
  5831.     bmi.s    .L3
  5832.     WRITE    #130,#98,#5,<"forward ">
  5833.     bra.s    .L4
  5834. .L3    WRITE    #130,#98,#5,<"backward">
  5835.  
  5836. .L4    lea.l    SE_Gadget11(pc),a0
  5837.     move.l    WindowPointer,a1
  5838.     sub.l    a2,a2
  5839.     CALLINT_PC    RefreshGadgets
  5840.     
  5841.  
  5842.     
  5843.     lea.l    SE_Gadget10(pc),a0
  5844.     move.l    WindowPointer,a1
  5845.     sub.l    a2,a2
  5846.     CALLINT_PC    ActivateGadget
  5847.     
  5848.  
  5849. .Message    move.l    Window2,a0        ; wait .....
  5850.     move.l    wd_UserPort(a0),a0
  5851.     move.l    a0,a5
  5852.     CALLEXEC    WaitPort        
  5853.     move.l    a5,a0
  5854.     CALLEXEC    GetMsg        ; get message
  5855.     move.l    d0,a1    
  5856.     move.l    im_Class(a1),d4    ; get data
  5857.     move.w    im_Code(a1),d5
  5858.     move.l    im_IAddress(a1),a4
  5859.     CALLEXEC     ReplyMsg        ; reply message        
  5860.     moveq.l    #0,d0        
  5861.     move.w    gg_GadgetID(a4),d0
  5862.     cmp.b    #3,d0
  5863.     bls    .Goon
  5864.     cmp.b    #6,d0
  5865.     beq    .YES
  5866.     cmp.b    #7,d0
  5867.     beq    .NO
  5868.     cmp.b    #8,d0
  5869.     beq    .FORWARD
  5870.     cmp.b    #9,d0
  5871.     beq    .BACKWARD
  5872.     cmp.b    #4,d0
  5873.     beq    .FIRST
  5874.     cmp.b    #5,d0
  5875.     beq    .LAST
  5876.     cmp.b    #11,d0
  5877.     beq    .Sector
  5878.     bra    .Message
  5879.  
  5880. .YES    clr.l    SearchCase
  5881.     bra    S_NewPref
  5882. .NO    move.l    #1,SearchCase
  5883.     bra    S_NewPref
  5884. .FORWARD    move.l    #1,SearchDirection
  5885.     bra    S_NewPref
  5886. .BACKWARD    move.l    #-1,SearchDirection
  5887.     bra    S_NewPref
  5888. .FIRST    move.w    #$3100,SE_G11_Puffer
  5889.     move.l    #1,SearchSector
  5890.     bra    S_NewPref
  5891. .LAST    move.l    Size,d0
  5892.     divu    #512,d0
  5893.     move.l    d0,d1
  5894.     swap    d1
  5895.     and.l    #$ffff,d0
  5896.     tst.w    d1
  5897.     beq.s    .SN1
  5898.     addq    #1,d0
  5899. .SN1    move.l    d0,SearchSector
  5900.     lea.l    SE_G11_Puffer(pc),a0
  5901.     bsr    MakeZahl
  5902.     clr.b    (a0)    
  5903.     bra    S_NewPref
  5904. .Sector    lea.l    SE_G11_Puffer(pc),a0
  5905.     bsr    GetZahl
  5906.     tst.l    d0
  5907.     beq    .Q2
  5908.     tst.l    d1
  5909.     beq    .Q1
  5910. .Q2    move.l    ScreenPtr1,a0
  5911.     CALLINT_PC    DisplayBeep
  5912.     move.l    SearchSector(pc),d0
  5913.     lea.l    SE_G11_Puffer(pc),a0
  5914.     bsr    MakeZahl
  5915.     clr.b    (a0)    
  5916.     bra    S_NewPref
  5917. .Q1    move.l    d0,d1
  5918.     subq.l    #1,d1
  5919.     mulu    #512,d1
  5920.     cmp.l    Size,d1
  5921.     bge.s    .Q2
  5922.     move.l    d0,SearchSector
  5923.     bra    .Message
  5924.     
  5925. .Goon    cmp.b    #2,d0
  5926.     beq    SearchString
  5927.     cmp.b    #3,d0
  5928.     beq    SearchHex
  5929.     moveq.l    #10,d1
  5930.     CALLDOS_PC    Delay
  5931.     move.l    Window2,a0
  5932.     CALLINT_PC    CloseWindow
  5933.     moveq.l    #0,d0        
  5934.     move.w    gg_GadgetID(a4),d0    
  5935. .wait    jmp    wait
  5936.  
  5937. SearchSector    dc.l    0
  5938. SearchDirection        
  5939.     dc.l    1
  5940. SearchCase    dc.l    0    
  5941. SearchMode    dc.l    -1
  5942.  
  5943. **************************************
  5944.  
  5945. SearchHex    and.l    #$ff,d0
  5946.     move.l    d0,SearchMode
  5947.     lea.l    SE_G11_Puffer(pc),a0    ; check sector
  5948.     bsr    GetZahl
  5949.     tst.l    d0
  5950.     beq    .D2
  5951.     tst.l    d1
  5952.     beq    .Q1
  5953. .D2    move.l    ScreenPtr1,a0
  5954.     CALLINT_PC    DisplayBeep
  5955.     move.l    SearchSector(pc),d0
  5956.     lea.l    SE_G11_Puffer(pc),a0
  5957.     bsr    MakeZahl
  5958.     clr.b    (a0)    
  5959.     bra    S_NewPref
  5960.  
  5961. .Q1    move.l    d0,d1
  5962.     subq.l    #1,d1
  5963.     mulu    #512,d1
  5964.     cmp.l    Size,d1
  5965.     bge.s    .Q2
  5966.     move.l    d0,SearchSector
  5967.     
  5968.     lea.l    SE_G10_Puffer(pc),a0    
  5969.     lea.l    CompPuffer,a1
  5970.     clr.b    (a1)
  5971.  
  5972. .Q2    move.b    (a0)+,d0        ; skip all spaces and $
  5973.     tst.b    d0
  5974.     beq    .Q4
  5975.     cmp.b    #" ",d0
  5976.     beq.s    .Q2
  5977.     cmp.b    #"$",d0
  5978.     beq.s    .Q2
  5979.     move.b    d0,d2        ; joker ?
  5980.     cmp.b    Joker,d0
  5981.     beq    .W5
  5982.     lea.l    .Hex(pc),a2        ; ASCII -> Hex
  5983.     moveq.l    #-1,d2        ; get 1. nibble
  5984. .W3    addq.l    #1,d2
  5985.     cmp.l    #32,d2
  5986.     bhi    .Error
  5987.     cmp.b    (a2)+,d0
  5988.     bne.s    .W3
  5989.     and.l    #$f,d2
  5990.     move.b    (a0)+,d0
  5991.     lea.l    .Hex(pc),a2        ; ASCII -> Hex
  5992.     moveq.l    #-1,d3        ; get 2. nibble
  5993. .W4    addq.l    #1,d3
  5994.     cmp.l    #32,d3
  5995.     bhi    .Error
  5996.     cmp.b    (a2)+,d0
  5997.     bne.s    .W4
  5998.     and.l    #$f,d3
  5999.     lsl.b    #4,d2
  6000.     or.b    d3,d2
  6001. .W5    move.b    d2,(a1)+        ; copy to buffer
  6002.     bra    .Q2        
  6003.  
  6004. .Q4    move.l    a1,d0        ; get length
  6005.     sub.l    #CompPuffer,d0
  6006.     move.l    d0,SearchLength
  6007.     tst.l    d0
  6008.     beq    .Q2
  6009.     move.l    Window2,a0
  6010.     CALLINT_PC    CloseWindow
  6011.     bra    J
  6012.     
  6013. .Error    move.l    ScreenPtr1,a0
  6014.     CALLINT_PC    DisplayBeep
  6015.     bra    S_NewPref
  6016.  
  6017.  
  6018. .Hex    dc.b    "0123456789abcdef"
  6019.     dc.b    "0123456789ABCDEF"
  6020.  
  6021. ***************************************
  6022.  
  6023. SearchString    and.l    #$ff,d0
  6024.     move.l    d0,SearchMode
  6025.     lea.l    SE_G11_Puffer(pc),a0    ; check sector
  6026.     bsr    GetZahl
  6027.     tst.l    d0
  6028.     beq    .Q2
  6029.     tst.l    d1
  6030.     beq    .Q1
  6031. .Q2    move.l    ScreenPtr1,a0
  6032.     CALLINT_PC    DisplayBeep
  6033.     move.l    SearchSector(pc),d0
  6034.     lea.l    SE_G11_Puffer(pc),a0
  6035.     bsr    MakeZahl
  6036.     clr.b    (a0)    
  6037.     bra    S_NewPref
  6038.  
  6039. .Q1    move.l    d0,d1
  6040.     subq.l    #1,d1
  6041.     mulu    #512,d1
  6042.     cmp.l    Size,d1
  6043.     bge.s    .Q2
  6044.     move.l    d0,SearchSector
  6045.     
  6046.     lea.l    SE_G10_Puffer(pc),a0    ; get length
  6047.     lea.l    CompPuffer,a1
  6048.     moveq.l    #-1,d0
  6049.     moveq.l    #0,d1
  6050. .Q3    addq.l    #1,d0
  6051.     moveq.l    #0,d1
  6052.     move.b    (a0)+,d1
  6053.     tst.b    d1
  6054.     beq    .Q3a
  6055.     jsr    UPCASE_D1
  6056. .Q3b    move.b    d1,(a1)+
  6057.     bra    .Q3
  6058.     
  6059.     
  6060. .Q3a    move.l    d0,SearchLength
  6061.     tst.l    d0
  6062.     beq    .Q2
  6063.     move.l    Window2,a0
  6064.     CALLINT_PC    CloseWindow    
  6065.  
  6066. J    bsr    Search_OpenWindow    
  6067. .E1    move.l    SearchSector(pc),d0    
  6068.     tst.l    d0        ; reached EOF ?
  6069.     beq    .NotFound
  6070.     move.l    d0,d1
  6071.     subq.l    #1,d1
  6072.     mulu    #512,d1
  6073.     cmp.l    Size,d1
  6074.     bge    .NotFound
  6075.     bsr    GetSearchSector    ; get sector
  6076.     tst.l    d0        ; error ?
  6077.     bne    .DiskError
  6078.     bsr    Search_Update        ; write new sector number, check if user break
  6079.     tst.l    d0
  6080.     bne    .Cancel
  6081.     bsr    Search_it        ; search it
  6082.     tst.l    d0        ; found it ?
  6083.     bne    FOUND
  6084.     move.l    SearchSector(pc),d0
  6085.     add.l    SearchDirection(pc),d0
  6086.     move.l    d0,SearchSector
  6087.     bra    .E1
  6088. .NotFound    bsr    Search_CloseWindow
  6089.     bra    NotFound
  6090. .DiskError    bsr    Search_CloseWindow
  6091.     bra    OpenError
  6092. .Cancel    bsr    Search_CloseWindow
  6093.     jmp    wait
  6094.  
  6095.  
  6096. FOUND    bsr    Search_CloseWindow
  6097.     lea.l    SearchPufferII+64,a0    ; show sector
  6098.     lea.l    Puffer,a1
  6099.     lea.l    UndoPuffer,a2
  6100.     move.w    #511,d0
  6101. .L0    move.b    (a0),(a1)+    
  6102.     move.b    (a0)+,(a2)+    
  6103.     dbra    d0,.L0
  6104.     move.l    SearchSector(pc),d1
  6105.     subq.l    #1,d1
  6106.     mulu    #512,d1
  6107.     move.l    Size,d0
  6108.     sub.l    d1,d0
  6109.     cmp.l    #512,d0
  6110.     bls    .L3
  6111.     move.l    #512,d0
  6112. .L3    move.l    d0,AnzahlBytes
  6113.     move.l    d1,Offset
  6114.     bsr    SectorNumber
  6115.     bsr    ShowPuffer
  6116.  
  6117.     lea.l    Color,a0
  6118.     lea.l    SearchColors+64,a1
  6119.     move.w    #511,d0
  6120. .L1    move.b    (a1)+,(a0)+
  6121.     dbra    d0,.L1
  6122.     
  6123. WindowPointer set Window1
  6124.     
  6125.     SETAPEN    #4
  6126.     moveq.l    #0,d0        ; show strings
  6127.     lea.l    Color,a0
  6128. .Z1    cmp.b    #4,(a0)+
  6129.     bne.s    .Z2
  6130.     movem.l    d0/a0,-(sp)    
  6131.     bsr    PutCursor
  6132.     movem.l    (sp)+,d0/a0
  6133. .Z2    addq.l    #1,d0
  6134.     cmp.l    AnzahlBytes,d0
  6135.     bne.s    .Z1
  6136.  
  6137.     lea.l    Color,a0        ; put cursor to first byte
  6138.     moveq.l    #-1,d0
  6139. .Z4    addq.l    #1,d0
  6140.     cmp.l    #511,d0
  6141.     beq    .Z5
  6142.     cmp.b    #4,(a0)+
  6143.     bne.s    .Z4
  6144.  
  6145.     move.l    #1,Cursor
  6146.     bsr    SetCursor
  6147.     jmp    NewPos
  6148. .Z5    move.l    #1,Cursor
  6149.     moveq.l    #0,d0
  6150.     bsr    SetCursor
  6151.     jmp    NewPos
  6152.  
  6153.  
  6154. GetSearchSector    
  6155.     move.l    d0,-(sp)        ; get sector
  6156.     move.b    CompPuffer,d1        ; and some bytes of the
  6157.     eor.b    #$ff,d1        ; previous sector and
  6158.     move.w    #1023,d2        ; the next sector
  6159.     lea.l    SearchColors,a0    
  6160.     lea.l    SearchPuffer,a1    ; fill buffer with
  6161. .G1    move.b    d1,(a1)+        ; different byte
  6162.     move.b    #3,(a0)+
  6163.     dbra    d2,.G1
  6164.     
  6165.     move.l    (sp)+,d3    
  6166.     subq.l    #1,d3
  6167.     mulu    #512,d3
  6168.     sub.l    #64,d3        ; get 64 bytes of previous sector
  6169.     move.l    #SearchPuffer,d4
  6170.     tst.l    d3        ; first sector -> no bytes from previous sector 
  6171.     bpl    .G2
  6172.     add.l    #64,d4
  6173.     add.l    #64,d3
  6174. .G2    move.l    d3,d5
  6175.     add.l    #512+64+64,d5        ; d3 = offset
  6176.     cmp.l    Size,d5        ; d4 = ^buffer
  6177.     bls    .G3        ; d5 = length
  6178.     move.l    Size,d5
  6179. .G3    sub.l    d3,d5
  6180.     tst.l    Memory
  6181.     beq    .Device
  6182.         
  6183.     move.l    d4,a1
  6184.     move.l    Memory,a0
  6185.     add.l    d3,a0
  6186.     subq.l    #1,d5
  6187. .G4    move.b    (a0)+,(a1)+
  6188.     dbra    d5,.G4
  6189.  
  6190.  
  6191. .G6a    lea.l    SearchPuffer,a0
  6192.     lea.l    SearchPufferII,a1
  6193.     move.w    #1023,d0
  6194. .O1    move.b    (a0)+,(a1)+
  6195.     dbra    d0,.O1
  6196.  
  6197. .G6    cmp.l    #3,SearchMode    
  6198.     beq.s    .G7
  6199.     tst.l    SearchCase
  6200.     beq.s    .G7
  6201.  
  6202.     lea.l    SearchPuffer,a0    ; Upcase
  6203.     move.w    #512+64+64-1,d0
  6204. .G8    move.b    (a0)+,d1
  6205.     jsr    UPCASE_D1
  6206.     move.b    d1,-1(a0)
  6207. .G9    dbra    d0,.G8    
  6208. .G7    moveq.l    #0,d0
  6209.     rts
  6210. .Device    move.l    d3,d2    ; get sector from device
  6211.     move.l    Filehandle,d1
  6212.     moveq.l    #OFFSET_BEGINNING,d3
  6213.     CALLDOS_PC    Seek
  6214.     move.l    Filehandle,d1
  6215.     move.l    d4,d2
  6216.     move.l    d5,d3
  6217.     CALLDOS_PC    Read
  6218.     cmp.l    d5,d0    
  6219.     beq    .G6a
  6220.     moveq.l    #-1,d0
  6221.     rts
  6222.  
  6223. ****************************************
  6224.  
  6225.  
  6226. * search it !!!
  6227.  
  6228. Search_it    move.l    #512+64+64-1,d0
  6229.     lea.l    SearchPuffer,a0
  6230.     lea.l    SearchColors,a1
  6231.  
  6232. .W1    move.l    a0,a3        ; compare
  6233.     move.l    a1,a4
  6234.     lea.l    CompPuffer,a2
  6235.     move.l    SearchLength(pc),d1
  6236.     subq.l    #1,d1
  6237. .W3    move.b    (a2)+,d3
  6238.     move.b    (a3)+,d4
  6239.     cmp.l    #3,SearchMode        ; if you search for hex
  6240.     beq.s    .W10        ; don't compare to joker
  6241.     cmp.b    Joker,d3
  6242.     beq.s    .W5
  6243. .W10    cmp.b    d3,d4
  6244.     bne    .W2
  6245. .W5    dbra    d1,.W3
  6246.     move.l    SearchLength(pc),d1    ; found it !!!
  6247.     subq.l    #1,d1
  6248. .W4    move.b    #4,(a4)+
  6249.     dbra    d1,.W4
  6250. .W2    tst.b    (a1)+
  6251.     tst.b    (a0)+
  6252.     dbra    d0,.W1
  6253.     
  6254.     moveq.l    #0,d2
  6255.     lea.l    SearchColors+64,a0
  6256.     move.l    #511,d0
  6257. .W6    cmp.b    #4,(a0)+
  6258.     bne.s    .W7
  6259.     moveq.l    #1,d2
  6260. .W7    dbra    d0,.W6
  6261.  
  6262.     move.l    d2,d0
  6263.     rts
  6264.     
  6265.  
  6266. SearchPos    dc.l    0
  6267. SearchLength    dc.l    0
  6268.  
  6269. ************************************
  6270.  
  6271. *
  6272. * continue searching (forward) 
  6273. *
  6274.  
  6275. NEXT    tst.b    FlagFile        ; file opened ?    
  6276.     beq.s    .nothing
  6277.     tst.l    SearchLength        ; Have you entered a search string ?
  6278.     beq.s    .nothing                
  6279.     move.l    #1,SearchDirection    ; forward
  6280.     move.l    Offset,d0        ; start with current sector
  6281.     divu    #512,d0        ; except File Master just
  6282.     and.l    #$ffff,d0        ; found it on that sector
  6283.     addq.l    #1,d0
  6284.     cmp.l    SearchSector(pc),d0
  6285.     bne.s    .W1
  6286.     add.l    SearchDirection(pc),d0
  6287. .W1    move.l    d0,SearchSector
  6288.     bra    J
  6289. .nothing    jmp    wait
  6290.  
  6291. ************************************
  6292.  
  6293. *
  6294. * continue searching (backward) 
  6295. *
  6296.  
  6297. PREVIOUS    tst.b    FlagFile        ; file opened ?    
  6298.     beq.s    .nothing
  6299.     tst.l    SearchLength        ; Have you entered a search string ?
  6300.     beq.s    .nothing                
  6301.     move.l    #-1,SearchDirection    ; backward
  6302.     move.l    Offset,d0        ; start with current sector
  6303.     divu    #512,d0        ; except File Master just
  6304.     and.l    #$ffff,d0        ; found it on that sector
  6305.     addq.l    #1,d0
  6306.     cmp.l    SearchSector(pc),d0
  6307.     bne.s    .W1
  6308.     add.l    SearchDirection(pc),d0
  6309. .W1    move.l    d0,SearchSector
  6310.     bra    J
  6311. .nothing    jmp    wait    
  6312.  
  6313.  
  6314.  
  6315. ************************************
  6316.  
  6317. WindowPointer set Window2
  6318.  
  6319. NotFound    move.l    Offset,d0        ; next time : start with current sector
  6320.     divu    #512,d0        ; 
  6321.     and.l    #$ffff,d0        ; 
  6322.     addq.l    #1,d0
  6323.     move.l    d0,SearchSector
  6324.  
  6325.     move.l    ScreenPtr1,a0
  6326.     CALLINT_PC    DisplayBeep    
  6327.     lea.l    Windowdef2,a0
  6328.     jsr    MakeWindow
  6329.     tst.l    d0
  6330.     beq    .wait
  6331.     move.l    d0,Window2
  6332.     SETDRMD    #RP_JAM1
  6333.     WRITE    #6+(290-11*8)/2,#19+10,#0,<"Not found !">
  6334.     WRITE    #5+(290-11*8)/2,#18+10,#1,<"Not found !">
  6335.     move.l    Window2,a0        
  6336.     move.l    wd_UserPort(a0),a0
  6337.     move.l    a0,a5
  6338.     CALLEXEC    WaitPort        
  6339.     move.l    Window2,a0
  6340.     CALLINT_PC    CloseWindow
  6341. .wait    jmp    wait
  6342.  
  6343. **************************************************
  6344.  
  6345. *
  6346. *    Search window
  6347. *
  6348.  
  6349.  
  6350. WindowPointer set Window2
  6351.  
  6352. Windowdef8    dc.w    60,50,300,70
  6353.     dc.b    -1,-1
  6354.     dc.l    GADGETUP!RAWKEY
  6355.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  6356.     dc.l    .Gadget1
  6357.     dc.l    0
  6358.     dc.l    0
  6359.     dc.l    0,0
  6360.     dc.w    0,0,0,0,CUSTOMSCREEN
  6361.  
  6362. .Gadget1    FM_GADGET    0,110,50,80,0,<"Cancel">,1,4
  6363.  
  6364. Search_OpenWindow    
  6365.     lea.l    Windowdef8(pc),a0
  6366.     jsr    MakeWindow
  6367.     move.l    d0,Window2
  6368.     tst.l    d0
  6369.     beq    .NoWindow
  6370.     SETDRMD    #RP_JAM1
  6371.     WRITE    #6+(290-25*8)/2,#19,#0,<"Searching - please wait !">
  6372.     WRITE    #5+(290-25*8)/2,#18,#1,<"Searching - please wait !">
  6373.     SETDRMD    #RP_JAM2
  6374.     SETBPEN    #7
  6375. .NoWindow    rts
  6376.  
  6377. Search_Update    move.l    Window2,d0    ; write new sector number
  6378.     tst.l    d0
  6379.     beq    .NoWindow
  6380.     move.l    #$20202020,SSector_text+10
  6381.     move.b    #" ",SSector_text+9
  6382.     lea.l    SSector_text+9(pc),a0
  6383.     move.l    SearchSector(pc),d0
  6384.     jsr    MakeZahl
  6385.     WRITEMEM    #5+(290-11*8)/2,#35,#1,SSector_text,#15
  6386.  
  6387.     move.l    Window2,a0        ; user break ??        
  6388.     move.l    wd_UserPort(a0),a0
  6389.     CALLEXEC    GetMsg
  6390.     tst.l    d0
  6391.     beq    .NoWindow        
  6392.     move.l    d0,a1    
  6393.     CALLEXEC     ReplyMsg
  6394.     moveq.l    #1,d0
  6395. .NoWindow    rts
  6396.  
  6397.     even
  6398. SSector_text    dc.b    "sector : .....            "
  6399.  
  6400. Search_CloseWindow            ; close window    
  6401.     tst.l    Window2
  6402.     beq    .NoWindow
  6403.     moveq.l    #10,d1
  6404.     CALLDOS    Delay
  6405.     move.l    Window2,a0
  6406.     CALLINT_PC    CloseWindow
  6407. .NoWindow    rts
  6408.  
  6409.  
  6410.  
  6411. **************************************************
  6412.  
  6413. ChangeDisplay    move.b    d0,DisplayMode    ; change Display (replace ASCII with ".")
  6414.     jsr    ShowPuffer
  6415.  
  6416.     move.l    Cursor,-(sp)
  6417.     lea.l    Color,a5
  6418.     moveq.l    #0,d7
  6419. .K1    cmp.b    #3,(a5)+
  6420.     beq    .K2
  6421.     movem.l    d7/a5,-(sp)
  6422.     move.l    d7,d0
  6423.     jsr    SetCursor
  6424.     movem.l    (sp)+,d7/a5
  6425. .K2    addq.l    #1,d7
  6426.     cmp.l    #512,d7
  6427.     bne.s    .K1
  6428.     move.l    (sp)+,d0
  6429.     jsr    SetCursor    
  6430.     jmp    wait
  6431.  
  6432. **************************************************
  6433.  
  6434. NEWCLI    move.l    #Nil,d1
  6435.     move.l    #1005,d2
  6436.     CALLDOS_PC    Open
  6437.     tst.l    d0
  6438.     beq.s    .wait
  6439.     move.l    d0,d2
  6440.     move.l    d0,d3
  6441.     move.l    #NC,d1
  6442.     CALLDOS_PC    Execute
  6443.     tst.l    d0
  6444.     bpl.s    .wait
  6445.     CALLINT_PC    WBenchToFront    
  6446. .wait    jmp    wait
  6447.     even
  6448. NC    dc.b    "newcli",0
  6449.     even
  6450. Nil    dc.b    "NIL:",0
  6451.     even
  6452.  
  6453. ************************************************
  6454.  
  6455. NEWSHELL    move.l    #Nil,d1
  6456.     move.l    #1005,d2
  6457.     CALLDOS_PC    Open
  6458.     tst.l    d0
  6459.     beq.s    .wait
  6460.     move.l    d0,d2
  6461.     move.l    d0,d3
  6462.     move.l    #ns,d1
  6463.     CALLDOS_PC    Execute
  6464.     tst.l    d0
  6465.     bpl.s    NEWCLI
  6466.     CALLINT_PC    WBenchToFront    
  6467. .wait    jmp    wait
  6468.     even
  6469. ns    dc.b    "newshell",0
  6470.     even
  6471.  
  6472.  
  6473.  
  6474. *************************************************
  6475.  
  6476. * which Amiga ( PAL / NTSC ) are you using ???
  6477.  
  6478. PAL_NTSC    move.l    4,a6
  6479.     cmp.b    #50,VBlankFrequency(a6)
  6480.     bne.s    NTSC_AMIGA
  6481.     move.l    #FONT_PAL1,FM_Font
  6482.     rts
  6483. NTSC_AMIGA    move.l    #FONT_NTSC1,FM_Font
  6484.     move.w    #207,Windowdef1+nw_Height
  6485.     move.w    #207,Screendef+ns_Height
  6486.     lea.l    NTSC,a0
  6487.     lea.l    PAL,a1
  6488.     move.l    #PAL_end-PAL-1,d0
  6489. .Q1    move.b    (a0)+,(a1)+
  6490.     dbra    d0,.Q1
  6491.     rts
  6492.  
  6493. **********************************************
  6494.  
  6495. *
  6496. * how much memory is available ???
  6497. *
  6498.  
  6499. WindowPointer set Window2
  6500.  
  6501. Windowdef9    dc.w    60,50,300,100
  6502.     dc.b    -1,-1
  6503.     dc.l    GADGETUP!VANILLAKEY
  6504.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  6505.     dc.l    .Gadget1
  6506.     dc.l    0
  6507.     dc.l    0
  6508.     dc.l    0,0
  6509.     dc.w    0,0,0,0,CUSTOMSCREEN
  6510.  
  6511. .Gadget1    FM_GADGET    0,125,80,50,0,<"OK">,1,4
  6512.  
  6513. MEMORY    lea.l    Windowdef9(pc),a0
  6514.     jsr    MakeWindow
  6515.     tst.l    d0
  6516.     beq    .wait
  6517.     move.l    d0,Window2
  6518.     SETDRMD    #RP_JAM1
  6519.     WRITE    #6+(290-6*8)/2,#19,#0,<"Memory">
  6520.     WRITE    #5+(290-6*8)/2,#18,#1,<"Memory">
  6521.  
  6522.     moveq.l    #MEMF_PUBLIC,d1
  6523.     CALLEXEC    AvailMem
  6524.     lea.l    Mem_text1+48-32(pc),a0
  6525.     jsr    MakeMZahl
  6526.     moveq.l    #MEMF_CHIP,d1
  6527.     CALLEXEC    AvailMem
  6528.     lea.l    Mem_text2+48-32(pc),a0
  6529.     jsr    MakeMZahl
  6530.     moveq.l    #MEMF_FAST,d1
  6531.     CALLEXEC    AvailMem
  6532.     lea.l    Mem_text3+48-32(pc),a0
  6533.     jsr    MakeMZahl
  6534.     move.l    #MEMF_PUBLIC!MEMF_LARGEST,d1
  6535.     CALLEXEC    AvailMem
  6536.     lea.l    Mem_text1+58-32(pc),a0
  6537.     jsr    MakeMZahl
  6538.     move.l    #MEMF_CHIP!MEMF_LARGEST,d1
  6539.     CALLEXEC    AvailMem
  6540.     lea.l    Mem_text2+58-32(pc),a0
  6541.     jsr    MakeMZahl
  6542.     move.l    #MEMF_FAST!MEMF_LARGEST,d1
  6543.     CALLEXEC    AvailMem
  6544.     lea.l    Mem_text3+58-32(pc),a0
  6545.     jsr    MakeMZahl
  6546.         
  6547.     WRITEMEM    #5+(290-34*8)/2,#40,#1,Mem_text1,#34
  6548.     WRITEMEM    #5+(290-34*8)/2,#50,#1,Mem_text2,#34
  6549.     WRITEMEM    #5+(290-34*8)/2,#60,#1,Mem_text3,#34
  6550.  
  6551.     move.l    Window2,a0        
  6552.     move.l    wd_UserPort(a0),a0
  6553.     move.l    a0,a5
  6554.     CALLEXEC    WaitPort        
  6555.     move.l    Window2,a0
  6556.     CALLINT_PC    CloseWindow
  6557. .wait    jmp    wait
  6558.  
  6559. Mem_text1    dc.b    "Public memory : ........ /........"
  6560.     even
  6561. Mem_text2    dc.b    "CHIP   memory : ........ /........"
  6562.     even
  6563. Mem_text3    dc.b    "FAST   memory : ........ /........"
  6564.     even 
  6565.  
  6566.  
  6567. MakeMZahl    movem.l    d0-d7/a1-a5,-(sp)    ; convert d0 into ASCII (a0 ^buffer)
  6568.     tst.l    d0
  6569.     moveq.l    #7,d2
  6570.     moveq.l    #0,d3
  6571.     lea.l    .MZ_Potenzen(pc),a2
  6572. .MZ1    move.b    #"0"-1,d1
  6573. .MZ2    addq    #1,d1
  6574.     sub.l    (a2),d0
  6575.     bcc.s    .MZ2
  6576.     add.l    (a2)+,d0
  6577.     tst.b    d2
  6578.     beq.s    .MZ3
  6579.     cmp.b    #"0",d1
  6580.     beq.s    .MZ4
  6581.     moveq.l    #1,d3
  6582.     bra.s    .MZ3
  6583. .MZ4    tst.b    d3
  6584.     bne.s    .MZ3
  6585.     move.b    #" ",d1
  6586. .MZ3    move.b    d1,(a0)+
  6587.     dbra    d2,.MZ1
  6588.     movem.l    (sp)+,d0-d7/a1-a5
  6589.     rts
  6590. .MZ_Potenzen    dc.l    10000000
  6591.     dc.l    1000000
  6592.     dc.l    100000
  6593.     dc.l    10000
  6594.     dc.l    1000
  6595.     dc.l    100
  6596.     dc.l    10
  6597.     dc.l    1
  6598.  
  6599.  
  6600. **********************************************
  6601.  
  6602. *
  6603. * Enter new joker
  6604. *
  6605.  
  6606.  
  6607. WindowPointer set Window2
  6608.  
  6609. Windowdef10    dc.w    60,50,300,70
  6610.     dc.b    -1,-1
  6611.     dc.l    GADGETUP
  6612.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  6613.     dc.l    JO_Gadget1
  6614.     dc.l    0
  6615.     dc.l    0
  6616.     dc.l    0,0
  6617.     dc.w    0,0,0,0,CUSTOMSCREEN
  6618.  
  6619. JO_Gadget1    FM_GADGET    JO_Gadget2,50,50,60,1,<"OK">,1,4
  6620. JO_Gadget2    FM_GADGET    JO_Gadget3,200,50,60,0,<"Cancel">,1,4
  6621.  
  6622. JO_Gadget3    dc.l    0
  6623.     dc.w    (300-24)/2,30,24,10,GADGHCOMP,RELVERIFY,STRGADGET
  6624.     dc.l    JO_G3_Box,0,0,0,JO_G3_Info
  6625.     dc.w    3,0,0
  6626. JO_G3_Box    BOX    -1,-1,24,8,2,JO_G3_Box2
  6627. JO_G3_Box2    BOX    -2,-2,25,9,1,0
  6628. JO_G3_Info    dc.l    JO_G3_Puffer,JO_G3_Undo
  6629.     dc.w    0,4
  6630.     ds.w    12
  6631. JO_G3_Puffer    ds.b    6
  6632. JO_G3_Undo    ds.b    6
  6633.  
  6634.  
  6635.  
  6636. NewJoker    lea.l    JO_G3_Puffer(pc),a0
  6637.     move.b    Joker,(a0)+
  6638.     clr.b    (a0)
  6639.     lea.l    Windowdef10(pc),a0
  6640.     jsr    MakeWindow
  6641.     tst.l    d0
  6642.     beq    .K3
  6643.     move.l    d0,Window2
  6644.     SETDRMD    #RP_JAM1
  6645.     WRITE    #6+(290-15*8)/2,#19,#0,<"Enter new joker">
  6646.     WRITE    #5+(290-15*8)/2,#18,#1,<"Enter new joker">
  6647.     
  6648. .wait    lea.l    JO_Gadget3(pc),a0
  6649.     move.l    Window2,a1
  6650.     sub.l    a2,a2
  6651.     CALLINT_PC    ActivateGadget
  6652.  
  6653.  
  6654.     move.l    Window2,a0        ; wait .....
  6655.     move.l    wd_UserPort(a0),a0
  6656.     move.l    a0,a5
  6657.     CALLEXEC    WaitPort        
  6658.     move.l    a5,a0
  6659.     CALLEXEC    GetMsg        ; get message
  6660.     move.l    d0,a1    
  6661.     move.l    im_Class(a1),d4    ; get data
  6662.     move.w    im_Code(a1),d5
  6663.     move.l    im_IAddress(a1),a4
  6664.     CALLEXEC     ReplyMsg        ; reply message        
  6665.     cmp.w    #1,gg_GadgetID(a4)
  6666.     beq    .K1
  6667.     tst.b    JO_G3_Puffer        ; check if correct (no " " , no "$")
  6668.     beq.s    .K2
  6669.     cmp.b    #" ",JO_G3_Puffer
  6670.     beq.s    .K2
  6671.     cmp.b    #"$",JO_G3_Puffer
  6672.     beq.s    .K2
  6673.     tst.b    JO_G3_Puffer+1        ; correct size (1)
  6674.     bne.s    .K2
  6675.     
  6676.     jmp    .K1
  6677. .K2    move.l    ScreenPtr1,a0
  6678.     CALLINT_PC    DisplayBeep
  6679.     lea.l    JO_G3_Puffer(pc),a0
  6680.     move.b    Joker,(a0)+
  6681.     clr.b    (a0)
  6682.     bra    .wait
  6683.  
  6684. .K1    moveq.l    #10,d1
  6685.     CALLDOS_PC    Delay
  6686.     move.l    Window2,a0
  6687.     CALLINT_PC    CloseWindow
  6688.     moveq.l    #0,d0        
  6689.     move.w    gg_GadgetID(a4),d0
  6690.     cmp.b    #1,d0
  6691.     beq.s    .K3
  6692.     move.b    JO_G3_Puffer(pc),Joker    ; copy new joker    
  6693.     move.b    JO_G3_Puffer(pc),JoString+12    
  6694.     moveq.l    #10,d1
  6695.     CALLDOS_PC    Delay
  6696. .K3    jmp    wait
  6697.  
  6698.  
  6699. **********************************************
  6700.  
  6701. Exec_Puffer1    ds.b    44
  6702. Exec_Puffer2    dc.b    ":",0
  6703.     ds.b    302
  6704. Exec_File    dc.l    0
  6705. Exec_Filehandle    dc.l    0
  6706. Exec_Memory    dc.l    0
  6707. Exec_Size    dc.l    0
  6708. Exec_Seek    dc.l    0
  6709.  
  6710. EXECUTE    tst.b    FlagFile
  6711.     beq    .wait
  6712.     move.l    #1,R_Read        ; don't display old file list
  6713.     lea.l    Exec_Puffer1(pc),a0    ; exchange file name and drawer
  6714.     lea.l    R_File,a1
  6715.     move.l    #43,d0
  6716. .L1    move.b    (a1),d1
  6717.     move.b    (a0),(a1)+
  6718.     move.b    d1,(a0)+
  6719.     dbra    d0,.L1
  6720.     lea.l    R_Drawer,a1
  6721.     move.l    #301,d0
  6722. .L2    move.b    (a1),d1
  6723.     move.b    (a0),(a1)+
  6724.     move.b    d1,(a0)+
  6725.     dbra    d0,.L2
  6726.  
  6727.     jsr    WriteQuestion
  6728.     
  6729.     lea.l    Exec_Text(pc),a5    ; get file to execute
  6730.     move.l    #R_G1c,R_def+nw_FirstGadget
  6731.     jsr    FileRequester
  6732.     move.l    d0,Exec_File    
  6733.  
  6734.     lea.l    Exec_Puffer1(pc),a0    ; restore file name and drawer
  6735.     lea.l    R_File,a1
  6736.     move.l    #43,d0
  6737. .L3    move.b    (a0),d1
  6738.     move.b    (a1),(a0)+
  6739.     move.b    d1,(a1)+
  6740.     dbra    d0,.L3
  6741.     lea.l    R_Drawer,a1
  6742.     move.l    #301,d0
  6743. .L4    move.b    (a0),d1
  6744.     move.b    (a1),(a0)+
  6745.     move.b    d1,(a1)+
  6746.     dbra    d0,.L4
  6747.     move.l    #1,R_Read
  6748.     tst.l    Exec_File
  6749.     bne    Show_Patch
  6750. .wait    move.l    #1,R_Read        ; don't display old file list
  6751.     jmp    wait
  6752.  
  6753.  
  6754. Exec_Text    dc.b    "             Execute  File:             "
  6755.     even
  6756.  
  6757. Show_Patch    move.l    Exec_File,d1        ; Copy file to RAM
  6758.     move.l    #MODE_OLDFILE,d2
  6759.     CALLDOS_PC    Open
  6760.     tst.l    d0
  6761.     beq    .OpenError
  6762.     
  6763.     move.l    d0,Exec_Filehandle
  6764.     
  6765.     move.l    d0,d1        ; get file size
  6766.     moveq.l    #0,d2
  6767.     moveq.l    #OFFSET_END,d3
  6768.     CALLDOS_PC    Seek
  6769.  
  6770.     move.l    Exec_Filehandle(pc),d1    
  6771.     moveq.l    #0,d2
  6772.     moveq.l    #OFFSET_CURRENT,d3
  6773.     CALLDOS_PC    Seek
  6774.     move.l    d0,Exec_Size
  6775.  
  6776.     move.l    Exec_Filehandle(pc),d1    
  6777.     moveq.l    #0,d2
  6778.     moveq.l    #OFFSET_BEGINNING,d3
  6779.     CALLDOS_PC    Seek
  6780.  
  6781.     tst.l    Exec_Size
  6782.     beq    .EmptyFile
  6783.  
  6784.     addq.l    #1,d0
  6785.     moveq.l    #MEMF_PUBLIC,d1
  6786.     CALLEXEC    AllocMem
  6787.     tst.l    d0
  6788.     beq    .NoMemory    
  6789.     move.l    d0,Exec_Memory
  6790.     
  6791.     move.l    d0,d2
  6792.     move.l    Exec_Filehandle(pc),d1
  6793.     move.l    Exec_Size(pc),d3
  6794.     CALLDOS_PC    Read
  6795.     cmp.l    Exec_Size(pc),d0
  6796.     bne    .DiskError
  6797.  
  6798.     add.l    Exec_Memory(pc),d0    ; put 0 Byte at end of patch
  6799.     move.l    d0,a0
  6800.     clr.b    (a0)
  6801.     
  6802.     move.l    Exec_Filehandle(pc),d1
  6803.     CALLDOS_PC    Close
  6804.     
  6805.  
  6806.     bsr    Display_Patch
  6807.     tst.l    d0
  6808.     bne.s    .T1
  6809.     bsr    Do_Patch
  6810.     cmp.l    #2,d0
  6811.     bne.s    .T1
  6812.     move.l    Exec_Memory(pc),a1
  6813.     move.l    Exec_Size(pc),d0
  6814.     addq.l    #1,d0
  6815.     CALLEXEC    FreeMem
  6816.     jmp    OpenError
  6817. .T1    move.l    Exec_Memory(pc),a1
  6818.     move.l    Exec_Size(pc),d0
  6819.     addq.l    #1,d0
  6820.     CALLEXEC    FreeMem
  6821.     move.l    Offset,d0
  6822.     jmp    GetBlock
  6823.  
  6824. .NoMemory    move.l    Exec_Filehandle(pc),d1
  6825.     CALLDOS_PC    Close    
  6826.     jmp    NoMemory
  6827. .EmptyFile    move.l    Exec_Filehandle(pc),d1
  6828.     CALLDOS_PC    Close    
  6829.     jmp    EmptyFile
  6830. .DiskError    move.l    Exec_Filehandle(pc),d1
  6831.     CALLDOS_PC    Close    
  6832. .OpenError    jmp    OpenError
  6833.  
  6834. ; +++++++++++++++++++++++++++++++++++++++++++++++++++++
  6835.  
  6836. ; Display patch !!!
  6837.  
  6838. WindowPointer set Window2
  6839.  
  6840. Windowdef11    dc.w    8,26,464,165
  6841.     dc.b    -1,-1
  6842.     dc.l    GADGETUP!RAWKEY
  6843.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  6844.     dc.l    DI_Gadget1
  6845.     dc.l    0
  6846.     dc.l    0
  6847.     dc.l    0,0
  6848.     dc.w    0,0,0,0,CUSTOMSCREEN
  6849.  
  6850. DI_Gadget1    FM_GADGET    DI_Gadget2,20,145,90,1,<"Cancel">,1,2
  6851. DI_Gadget2    FM_GADGET    DI_Gadget3,464-90-21,145,90,0,<"Execute">,1,2
  6852. DI_Gadget3    FM_GADGET    DI_Gadget4,131,145,90,2,<"Move down">,1,4
  6853. DI_Gadget4    FM_GADGET    0,242,145,90,3,<"Move Up">,1,4
  6854.  
  6855.  
  6856.  
  6857. DI_Text    ds.b    14*56
  6858.  
  6859. DT_Box    BOX    -1,-1,56*8,14*8,1,0
  6860. DI_Pos    dc.l    0
  6861.  
  6862. Display_Patch    lea.l    Windowdef11(pc),a0        ; Display top of patch
  6863.     jsr    MakeWindow
  6864.     tst.l    d0
  6865.     beq    .D1
  6866.     move.l    d0,Window2
  6867.     SETDRMD    #RP_JAM1
  6868.     WRITE    #6+(454-7*8)/2,#14,#0,<"Execute">
  6869.     WRITE    #5+(454-7*8)/2,#13,#1,<"Execute">
  6870.     clr.l    DI_Pos
  6871.     
  6872.     lea.l    DT_Box(pc),a1
  6873.     move.l    Window2,a0
  6874.     move.l    wd_RPort(a0),a0
  6875.     moveq.l    #8,d0
  6876.     move.l    #30-6,d1
  6877.     CALLINT_PC    DrawBorder    
  6878.  
  6879. .loop    lea.l    DI_Text(pc),a0        ; clear buffer
  6880.     move.l    #(14*56)-1,d0
  6881. .F0    move.b    #" ",(a0)+
  6882.     dbra    d0,.F0
  6883.     
  6884.     move.l    Exec_Memory(pc),a0        ; copy file to puffer
  6885.     add.l    DI_Pos,a0
  6886.     move.w    #13,d7
  6887.     lea.l    DI_Text,a1
  6888. .F1    moveq.l    #0,d6
  6889.     move.l    a1,a2
  6890. .F2    move.b    (a0)+,d0
  6891.     tst.b    d0
  6892.     beq    .F3
  6893.     cmp.b    #10,d0    
  6894.     beq    .F4
  6895.     addq.l    #1,d6
  6896.     cmp.b    #56,d6
  6897.     bhi.s    .F2
  6898.     move.b    d0,(a2)+
  6899.     bra.s    .F2
  6900. .F4    lea.l    56(a1),a1
  6901.     dbra    d7,.F1
  6902.  
  6903. .F3    SETDRMD    #RP_JAM2
  6904.     SETBPEN    #0
  6905.     WRITEMEM    #8,#30,#6,DI_Text,#56
  6906.     WRITEMEM    #8,#30+(1*8),#6,DI_Text+(1*56),#56
  6907.     WRITEMEM    #8,#30+(2*8),#6,DI_Text+(2*56),#56
  6908.     WRITEMEM    #8,#30+(3*8),#6,DI_Text+(3*56),#56
  6909.     WRITEMEM    #8,#30+(4*8),#6,DI_Text+(4*56),#56
  6910.     WRITEMEM    #8,#30+(5*8),#6,DI_Text+(5*56),#56
  6911.     WRITEMEM    #8,#30+(6*8),#6,DI_Text+(6*56),#56
  6912.     WRITEMEM    #8,#30+(7*8),#6,DI_Text+(7*56),#56
  6913.     WRITEMEM    #8,#30+(8*8),#6,DI_Text+(8*56),#56
  6914.     WRITEMEM    #8,#30+(9*8),#6,DI_Text+(9*56),#56
  6915.     WRITEMEM    #8,#30+(10*8),#6,DI_Text+(10*56),#56
  6916.     WRITEMEM    #8,#30+(11*8),#6,DI_Text+(11*56),#56
  6917.     WRITEMEM    #8,#30+(12*8),#6,DI_Text+(12*56),#56
  6918.     WRITEMEM    #8,#30+(13*8),#6,DI_Text+(13*56),#56
  6919.     
  6920.  
  6921.  
  6922. .wait    move.l    Window2,a0        ; wait .....
  6923.     move.l    wd_UserPort(a0),a0
  6924.     move.l    a0,a5
  6925.     CALLEXEC    WaitPort        
  6926.     move.l    a5,a0
  6927.     CALLEXEC    GetMsg        ; get message
  6928.     move.l    d0,a1    
  6929.     move.l    im_Class(a1),d4    ; get data
  6930.     move.w    im_Code(a1),d5
  6931.     move.l    im_IAddress(a1),a4
  6932.     CALLEXEC     ReplyMsg        ; reply message        
  6933.     cmp.l    #RAWKEY,d4
  6934.     beq    .Key
  6935.     moveq.l    #0,d0
  6936.     move.w    gg_GadgetID(a4),d0
  6937.     cmp.b    #2,d0
  6938.     beq    .down
  6939.     cmp.b    #3,d0
  6940.     beq    .up
  6941.     move.l    Window2,a0
  6942.     CALLINT_PC    CloseWindow
  6943.     moveq.l    #0,d0
  6944.     move.w    gg_GadgetID(a4),d0
  6945. .D1    rts
  6946. .Key    cmp.b    #$4d,d5    
  6947.     beq.s    .down
  6948.     cmp.b    #$4c,d5
  6949.     bne    .wait
  6950.         
  6951. .up    move.l    Exec_Memory(pc),a0    ; move up
  6952.     move.l    DI_Pos(pc),d7
  6953.     add.l    d7,a0
  6954. .U1    tst.l    d7        ; reached top ?
  6955.     beq    .U2
  6956.     subq.l    #1,d7
  6957.     cmp.b    #10,-(a0)
  6958.     bne    .U1
  6959. .U3    tst.l    d7    
  6960.     beq    .U2
  6961.     subq.l    #1,d7
  6962.     cmp.b    #10,-(a0)
  6963.     bne    .U3
  6964.     addq.l    #1,d7        ; Return belongs to previous line !
  6965. .U2    move.l    d7,DI_Pos
  6966.     bra    .loop
  6967.  
  6968. .down    move.l    Exec_Memory(pc),a0    ; move down
  6969.     move.l    DI_Pos(pc),d7
  6970.     add.l    d7,a0
  6971. .P1    tst.b    (a0)        ; reached EOF ?
  6972.     beq.s    .P2
  6973.     addq.l    #1,d7
  6974.     cmp.b    #10,(a0)+
  6975.     bne.s    .P1
  6976. .P2    move.l    d7,DI_Pos
  6977.     bra    .loop
  6978.     
  6979.  
  6980. ; +++++++++++++++++++++++++++++++++++++++++++++++++++
  6981.  
  6982. *
  6983. * execute the patch !!!!
  6984. *
  6985.  
  6986. WindowPointer set Window2
  6987.  
  6988. Windowdef12    dc.w    8,80,464,70
  6989.     dc.b    -1,-1
  6990.     dc.l    GADGETUP
  6991.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  6992.     dc.l    DP_Gadget1
  6993.     dc.l    0
  6994.     dc.l    0
  6995.     dc.l    0,0
  6996.     dc.w    0,0,0,0,CUSTOMSCREEN
  6997.  
  6998. DP_Gadget1    FM_GADGET    DP_Gadget2,71,50,60,0,<"Cancel">,1,4
  6999. DP_Gadget2    FM_GADGET    DP_Gadget3,71+71+60,50,60,1,<"OK">,1,4
  7000. DP_Gadget3    FM_GADGET    0,71+71+71+60+60,50,60,2,<"Skip">,1,4
  7001.  
  7002.  
  7003. DP_Text    ds.b    56
  7004.  
  7005. DP_Box    BOX    -3,-3,56*8+2,10,1,DP_Box2
  7006. DP_Box2    BOX    -2,-2,56*8+1,9,0,DP_Box3
  7007. DP_Box3    BOX    -1,-1,56*8,8,0,0
  7008.  
  7009.  
  7010. Do_Patch    lea.l    Windowdef12(pc),a0        
  7011.     jsr    MakeWindow
  7012.     tst.l    d0
  7013.     beq    .End
  7014.     move.l    d0,Window2
  7015.  
  7016.     lea.l    DP_Gadget2(pc),a0
  7017.     move.l    Window2,a1
  7018.     sub.l    a2,a2
  7019.     CALLINT_PC    OffGadget
  7020.  
  7021.     lea.l    DP_Gadget3(pc),a0
  7022.     move.l    Window2,a1
  7023.     sub.l    a2,a2
  7024.     CALLINT_PC    OffGadget
  7025.     
  7026.     SETDRMD    #RP_JAM1
  7027.     WRITE    #6+(454-9*8)/2,#14,#0,<"Executing">
  7028.     WRITE    #5+(454-9*8)/2,#13,#1,<"Executing">
  7029.     
  7030.     lea.l    DP_Box(pc),a1
  7031.     move.l    Window2,a0
  7032.     move.l    wd_RPort(a0),a0
  7033.     moveq.l    #8,d0
  7034.     move.l    #30-6,d1
  7035.     CALLINT_PC    DrawBorder    
  7036.  
  7037.  
  7038.     move.l    Exec_Memory(pc),a4    
  7039.     
  7040. .NewLine    move.l    Window2,a0        ; user break ?
  7041.     move.l    wd_UserPort(a0),a0
  7042.     CALLEXEC    GetMsg    
  7043.     tst.l    d0    
  7044.     beq.s    .F100
  7045.     move.l    d0,a1    
  7046.     CALLEXEC     ReplyMsg
  7047.     jmp    .Exit
  7048.  
  7049.  
  7050. .F100    lea.l    DP_Text(pc),a0        ; clear buffer
  7051.     move.w    #55,d0
  7052. .F0    move.b    #" ",(a0)+
  7053.     dbra    d0,.F0
  7054.     move.l    a4,-(sp)
  7055.     
  7056.     lea.l    DP_Text(pc),a1        ; copy to buffer
  7057. .F1    moveq.l    #0,d6
  7058. .F2    move.b    (a4)+,d0
  7059.     tst.b    d0
  7060.     beq.s    .F4
  7061.     cmp.b    #10,d0    
  7062.     beq.s    .F4
  7063.     addq.l    #1,d6
  7064.     cmp.b    #56,d6
  7065.     bhi.s    .F2
  7066.     move.b    d0,(a1)+
  7067.     bra.s    .F2
  7068. .F4    SETDRMD    #RP_JAM2        ; show current line
  7069.     SETBPEN    #0
  7070.     WRITEMEM    #8,#30,#6,DP_Text,#56
  7071.  
  7072.  
  7073.     move.l    (sp)+,a4
  7074.     move.l    a4,.Line
  7075. .NewLine2    move.b    (a4)+,d0
  7076.     cmp.b    #9,d0        ; skip tab and spaces 
  7077.     beq.s    .NewLine2
  7078.     cmp.b    #" ",d0
  7079.     beq.s    .NewLine2
  7080.     tst.b    d0
  7081.     beq    .End
  7082.     cmp.b    #";",d0        ; comment ?
  7083.     beq.s    .Rem
  7084.     cmp.b    #"*",d0        ; comment ?
  7085.     beq.s    .Rem
  7086.     cmp.b    #10,d0        ; empty line ?
  7087.     beq    .NewLine
  7088.     bra    .Y1
  7089.  
  7090. .Rem    move.b    (a4)+,d0        ; skip line
  7091.     tst.b    d0
  7092.     beq    .End
  7093.     cmp.b    #10,d0
  7094.     bne.s    .Rem
  7095.     bra    .NewLine
  7096.  
  7097. .Offset    ds.b    20
  7098. .Y1    lea.l    .Offset(pc),a0
  7099.     move.l    #18,d2
  7100.     move.b    d0,(a0)+
  7101. .Y2    move.b    (a4)+,d1    ; copy into buufer until
  7102.     cmp.b    #" ",d1    ; you encounter tab,space,":","="
  7103.     beq.s    .Y3
  7104.     cmp.b    #"=",d1
  7105.     beq.s    .Y3
  7106.     cmp.b    #":",d1
  7107.     beq.s    .Y3
  7108.     cmp.b    #9,d1
  7109.     beq.s    .Y3
  7110.     tst.b    d1
  7111.     beq    .Error
  7112.     move.b    d1,(a0)+
  7113.     dbra    d2,.Y2
  7114.     bra    .Error
  7115. .Y3    clr.b    (a0)    ; convert ASCII into hex
  7116.     lea.l    .Offset(pc),a0
  7117.     jsr    GetZahl
  7118.     tst.l    d1
  7119.     bne    .Error
  7120.     move.l    d0,Exec_Seek    ; compare offset to file size
  7121.     cmp.l    Size,d0
  7122.     bge    .Error
  7123. .Y4    move.b    (a4)+,d0    ; skip spaces,tabs and $
  7124.     cmp.b    #" ",d0
  7125.     beq.s    .Y4
  7126.     cmp.b    #9,d0
  7127.     beq.s    .Y4
  7128.     cmp.b    #"$",d0
  7129.     beq.s    .Y4
  7130.     cmp.b    #":",d0
  7131.     beq.s    .Y4
  7132.     tst.b    d0
  7133.     beq    .Error
  7134.     cmp.b    #34,d0    ; " ,' or ` -> ASCIIs
  7135.     beq    .ASCIIs
  7136.     cmp.b    #180,d0
  7137.     beq    .ASCIIs
  7138.     cmp.b    #$27,d0
  7139.     beq    .ASCIIs
  7140.     
  7141.     
  7142.     
  7143. .Y6    bsr    .GetHex    ; get hex
  7144.     tst.l    d0
  7145.     bmi    .Error
  7146.     jsr    .Exec_Write
  7147.     cmp.l    #2,d0
  7148.     beq    .Error
  7149.     cmp.l    #1,d0
  7150.     bne    .DiskError    
  7151.     
  7152. .Y5    move.b    (a4)+,d0    ; skip spaces,tabs and $
  7153.     cmp.b    #" ",d0
  7154.     beq.s    .Y5
  7155.     cmp.b    #9,d0
  7156.     beq.s    .Y5
  7157.     cmp.b    #"$",d0
  7158.     beq.s    .Y5
  7159.     tst.b    d0
  7160.     beq    .End
  7161.     cmp.b    #10,d0
  7162.     beq    .NewLine
  7163.     bra    .Y6
  7164.  
  7165. .Error    move.l    ScreenPtr1,a0
  7166.     CALLINT_PC    DisplayBeep
  7167.  
  7168.     lea.l    DP_Gadget1(pc),a0    ; switch off OK gadget
  7169.     move.l    Window2,a1        
  7170.     sub.l    a2,a2
  7171.     CALLINT_PC    OnGadget
  7172.     lea.l    DP_Gadget2(pc),a0
  7173.     move.l    Window2,a1
  7174.     sub.l    a2,a2
  7175.     CALLINT_PC    OffGadget
  7176.     lea.l    DP_Gadget3(pc),a0
  7177.     move.l    Window2,a1
  7178.     sub.l    a2,a2
  7179.     CALLINT_PC    OnGadget
  7180.     
  7181.     move.l    Window2,a0        ; wait .....
  7182.     move.l    wd_UserPort(a0),a0
  7183.     move.l    a0,a5
  7184.     CALLEXEC    WaitPort        
  7185.     move.l    a5,a0
  7186.     CALLEXEC    GetMsg        ; get message
  7187.     move.l    d0,a1    
  7188.     move.l    im_Class(a1),d4    ; get data
  7189.     move.w    im_Code(a1),d5
  7190.     move.l    im_IAddress(a1),a4
  7191.     CALLEXEC     ReplyMsg        ; reply message        
  7192.     cmp.w    #2,gg_GadgetID(a4)
  7193.     bne    .L1
  7194.     move.l    .Line(pc),a4        ; skip the line
  7195. .L2    move.b    (a4)+,d0
  7196.     tst.b    d0        ; EOF ?
  7197.     beq.s    .L1    
  7198.     cmp.b    #10,d0        ; end of line ( $a) reached ?
  7199.     bne.s    .L2
  7200.     jmp    .NewLine
  7201.  
  7202. .L1    move.l    Window2,a0
  7203.     CALLINT_PC    CloseWindow
  7204.     moveq.l    #-1,d0
  7205.     rts
  7206.  
  7207. .End    SETDRMD    #RP_JAM2        
  7208.     SETBPEN    #0
  7209.     WRITE    #8,#30,#2,<"                    »»   Done !   ««                    ">
  7210.  
  7211.     
  7212.     lea.l    DP_Gadget1(pc),a0    ; switch on only OK gadget
  7213.     move.l    Window2,a1        
  7214.     sub.l    a2,a2
  7215.     CALLINT_PC    OffGadget
  7216.     lea.l    DP_Gadget2(pc),a0
  7217.     move.l    Window2,a1
  7218.     sub.l    a2,a2
  7219.     CALLINT_PC    OnGadget
  7220.     lea.l    DP_Gadget3(pc),a0
  7221.     move.l    Window2,a1
  7222.     sub.l    a2,a2
  7223.     CALLINT_PC    OffGadget
  7224.     
  7225.     move.l    Window2,a0        ; wait  until user selects cancel
  7226.     move.l    wd_UserPort(a0),a0
  7227.     CALLEXEC    WaitPort
  7228.  
  7229. .Exit    move.l    Window2,a0
  7230.     CALLINT_PC    CloseWindow
  7231.     moveq.l    #0,d0
  7232.     rts
  7233.  
  7234. .DiskError    move.l    Window2,a0
  7235.     CALLINT_PC    CloseWindow
  7236.     moveq.l    #2,d0
  7237.     rts
  7238.  
  7239.     even
  7240. .Line    dc.l    0
  7241.  
  7242. ;++++++++++
  7243.  
  7244. .Mark    dc.b    0    
  7245.     even
  7246. .ASCIIs    move.b    d0,.Mark
  7247. .T1    move.b    (a4)+,d0    ; there must be at least a character
  7248.     tst.b    d0
  7249.     beq    .Error
  7250.     cmp.b    .Mark(pc),d0
  7251.     beq    .Error
  7252.     cmp.b    #10,d0
  7253.     beq    .Error
  7254.  
  7255. .T2    bsr    .Exec_Write    ; write it
  7256.     cmp.l    #2,d0
  7257.     beq    .Error
  7258.     cmp.l    #1,d0
  7259.     bne    .DiskError
  7260.     move.b    (a4)+,d0    
  7261.     beq    .Error
  7262.     cmp.b    .Mark(pc),d0
  7263.     beq    .ASCII_End
  7264.     cmp.b    #10,d0
  7265.     beq    .NewLine
  7266.     bra    .T2
  7267.  
  7268. .ASCII_End    move.b    (a4)+,d0    ; skip tabs and spaces
  7269.     cmp.b    #" ",d0
  7270.     beq.s    .ASCII_End
  7271.     cmp.b    #9,d0
  7272.     beq.s    .ASCII_End
  7273.     tst.b    d0
  7274.     beq    .End    ; reached EOF ?
  7275.     cmp.b    #10,d0
  7276.     bne    .Error
  7277.     bra    .NewLine
  7278.     
  7279.  
  7280. .GetHex    lea.l    .Hex(pc),a2        ; ASCII -> Hex
  7281.     moveq.l    #-1,d2        ; get 1. nibble
  7282. .W3    addq.l    #1,d2
  7283.     cmp.l    #32,d2
  7284.     bhi    .GHError
  7285.     cmp.b    (a2)+,d0
  7286.     bne.s    .W3
  7287.     and.l    #$f,d2
  7288.     move.b    (a4)+,d0
  7289.     lea.l    .Hex(pc),a2        ; ASCII -> Hex
  7290.     moveq.l    #-1,d3        ; get 2. nibble
  7291. .W4    addq.l    #1,d3
  7292.     cmp.l    #32,d3
  7293.     bhi    .GHError
  7294.     cmp.b    (a2)+,d0
  7295.     bne.s    .W4
  7296.     and.l    #$f,d3
  7297.     lsl.b    #4,d2
  7298.     or.b    d3,d2
  7299. .W5    move.b    d2,d0
  7300.     rts
  7301. .GHError    moveq.l    #-1,d0
  7302.     rts
  7303. .Hex    dc.b    "0123456789abcdef"
  7304.     dc.b    "0123456789ABCDEF"
  7305.  
  7306.  
  7307. .Exec_Write    move.l    Memory,a0    ; write d0 
  7308.     cmp.l    #0,a0
  7309.     beq    .Write_Device
  7310.     move.l    Exec_Seek(pc),d1
  7311.     cmp.l    Size,d1
  7312.     bge    .J2
  7313.     add.l    Exec_Seek(pc),a0
  7314.     move.b    d0,(a0)
  7315.     add.l    #1,Exec_Seek
  7316.     move.b    #1,FlagWrite    ; something was changed !!!
  7317.     moveq.l    #1,d0
  7318.     rts
  7319. .J2    moveq.l    #2,d0
  7320.     rts
  7321. .Write_Device    move.l    d0,.Buffer    ; write d0 on device
  7322.     move.l    Filehandle,d1
  7323.     move.l    Exec_Seek(pc),d2
  7324.     moveq.l    #OFFSET_BEGINNING,d3
  7325.     CALLDOS_PC    Seek    
  7326.     tst.l    d0
  7327.     bmi    .J1
  7328.     move.l    Filehandle,d1
  7329.     move.l    #.Buffer,d2
  7330.     moveq.l    #1,d3
  7331.     CALLDOS_PC    Write
  7332. .J1    rts
  7333. .Buffer    dc.b    0
  7334.  
  7335. ********************************************************
  7336.  
  7337. KEY_INFO    lea.l    Windowdef6,a0        ; show keys
  7338.     jsr    MakeWindow
  7339.     tst.l    d0
  7340.     beq    .wait
  7341.     move.l    d0,Window2
  7342.  
  7343.     move.l    d0,a0
  7344.     move.l    wd_RPort(a0),a0
  7345.     lea.l    FM_LOGO,a1
  7346.     moveq.l    #4,d1
  7347.     move.l    #(350-241)/2,d0
  7348.     CALLINT_PC    DrawImage
  7349.  
  7350.  
  7351.     SETDRMD    #RP_JAM1
  7352.  
  7353.     WRITE    #6+(340-8*8)/2,#46,#0,<"» Keys «"
  7354.     WRITE    #6+(340-38*8)/2,#61,#0,<"F1  - Open           F6  - Write      ">      
  7355.     WRITE    #6+(340-38*8)/2,#71,#0,<"F2  - Save As        F7  - Undo       "> 
  7356.     WRITE    #6+(340-38*8)/2,#81,#0,<"F3  - Execute        F8  - Search     ">
  7357.     WRITE    #6+(340-38*8)/2,#91,#0,<"F4  - Forward        F9  - Previous   ">      
  7358.     WRITE    #6+(340-38*8)/2,#101,#0,<"F5  - Backward       F10 - Next       ">
  7359.     WRITE    #6+(340-38*8)/2,#111,#0,<"ESC - Quit           Ins - Change Mode">
  7360.     
  7361.     WRITE    #5+(340-8*8)/2,#45,#6,<"» Keys «"
  7362.     WRITE    #5+(340-38*8)/2,#60,#5,<"F1  - Open           F6  - Write      ">      
  7363.     WRITE    #5+(340-38*8)/2,#70,#5,<"F2  - Save As        F7  - Undo       "> 
  7364.     WRITE    #5+(340-38*8)/2,#80,#5,<"F3  - Execute        F8  - Search     ">
  7365.     WRITE    #5+(340-38*8)/2,#90,#5,<"F4  - Forward        F9  - Previous   ">      
  7366.     WRITE    #5+(340-38*8)/2,#100,#5,<"F5  - Backward       F10 - Next       ">
  7367.     WRITE    #5+(340-38*8)/2,#110,#5,<"ESC - Quit           Ins - Change Mode">
  7368.     
  7369.     move.l    Window2,a0
  7370.     move.l    wd_UserPort(a0),a0
  7371.     move.l    a0,a5
  7372.     CALLEXEC    WaitPort        
  7373.     move.l    Window2,a0
  7374.     CALLINT_PC    CloseWindow
  7375. .wait    jmp     wait
  7376.  
  7377.  
  7378. ***********************************************************
  7379.  
  7380. ; close Workbench (saves about 40 KB) or open it if it's closed
  7381.  
  7382. WORKBENCH    CALLINT_PC    CloseWorkBench
  7383.     tst.l    d0
  7384.     bne    .Close
  7385.     CALLINT_PC    OpenWorkBench
  7386.     tst.l    d0            ; success ?
  7387.     beq    .Error
  7388.     
  7389.     move.l    ScreenPtr1,a0
  7390.     CALLINT_PC    ScreenToFront
  7391.  
  7392.     lea.l    Windowdef13(pc),a0    
  7393.     jsr    MakeWindow
  7394.     tst.l    d0
  7395.     beq    .wait
  7396.     move.l    d0,Window2
  7397.     SETDRMD    #RP_JAM1
  7398.     WRITE    #5+(290-33*8)/2,#19,#0,<"Workbench opened / Close failed !">
  7399.     WRITE    #5+(290-33*8)/2,#18,#1,<"Workbench opened / Close failed !"> 
  7400.     bra    .Warten
  7401. .Close    lea.l    Windowdef13(pc),a0    
  7402.     jsr    MakeWindow
  7403.     tst.l    d0
  7404.     beq    .wait
  7405.     move.l    d0,Window2
  7406.     SETDRMD    #RP_JAM1
  7407.     WRITE    #5+(290-18*8)/2,#19,#0,<"Workbench closed !">
  7408.     WRITE    #5+(290-18*8)/2,#18,#1,<"Workbench closed !"> 
  7409.     bra    .Warten
  7410.  
  7411.  
  7412. .Error    lea.l    Windowdef13(pc),a0
  7413.     jsr    MakeWindow
  7414.     tst.l    d0
  7415.     beq    .wait
  7416.     move.l    d0,Window2
  7417.     SETDRMD    #RP_JAM1
  7418.     WRITE    #5+(290-28*8)/2,#19,#0,<"Can't open/close Workbench !">
  7419.     WRITE    #5+(290-28*8)/2,#18,#1,<"Can't open/close Workbench !">
  7420.  
  7421. .Warten    move.l    Window2,a0        
  7422.     move.l    wd_UserPort(a0),a0
  7423.     move.l    a0,a5
  7424.     CALLEXEC    WaitPort        
  7425.     move.l    Window2,a0
  7426.     CALLINT_PC    CloseWindow
  7427. .wait    jmp    wait
  7428.  
  7429. Windowdef13    dc.w    60,75,300,50
  7430.     dc.b    -1,-1
  7431.     dc.l    GADGETUP!VANILLAKEY
  7432.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  7433.     dc.l    .Gadget1
  7434.     dc.l    0
  7435.     dc.l    0
  7436.     dc.l    0,0
  7437.     dc.w    0,0,0,0,CUSTOMSCREEN
  7438.  
  7439. .Gadget1    FM_GADGET    0,125,30,50,0,<"OK">,1,4
  7440.  
  7441.     
  7442.  
  7443. **********************************************************
  7444.  
  7445. UNDO_CHAR    tst.b    FlagFile
  7446.     beq.s    .Nothing
  7447.     lea.l    Puffer,a0        ; copy byte from undo buffer
  7448.     move.l    Cursor,d0        ; to display
  7449.     lea.l    UndoPuffer,a1
  7450.     move.b    (a1,d0),(a0,d0)    ; copy
  7451.     lea.l    Color,a0
  7452.     move.b    #3,(a0,d0)        ; reset colour
  7453.     addq.l    #1,d0        ; write byte and move cursor
  7454.     cmp.l    AnzahlBytes,d0
  7455.     bge.s    .L2
  7456.     jsr    SetCursor
  7457.     jmp    wait
  7458. .L2    subq.l    #1,d0
  7459.     jsr    SetCursor
  7460. .Nothing    jmp    wait
  7461.  
  7462. ***************************************************************
  7463.  
  7464. UNDO_CHAR_BACK    tst.b    FlagFile
  7465.     beq.s    .Nothing
  7466.     lea.l    Puffer,a0        ; copy byte from undo buffer
  7467.     move.l    Cursor,d0        ; to display
  7468.     beq.s    .L3
  7469.     subq.l    #1,d0
  7470. .L3    lea.l    UndoPuffer,a1
  7471.     move.b    (a1,d0),(a0,d0)    ; copy
  7472.     lea.l    Color,a0
  7473.     move.b    #3,(a0,d0)        ; reset colour
  7474.     jsr    SetCursor        ; write byte and move cursor
  7475. .Nothing    jmp    wait
  7476.  
  7477. ***************************************************************
  7478.  
  7479.  
  7480. ; convert ASCII to HEX , etc.
  7481.  
  7482. WindowPointer set Window2
  7483.  
  7484. Windowdef14    dc.w    50,40,370,130
  7485.     dc.b    -1,-1
  7486.     dc.l    GADGETUP
  7487.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  7488.     dc.l    CO_Gadget1
  7489.     dc.l    0
  7490.     dc.l    0
  7491.     dc.l    0,0
  7492.     dc.w    0,0,0,0,CUSTOMSCREEN
  7493.  
  7494. CO_Gadget1    FM_GADGET    CO_Gadget2,(360-80)/2,110,80,0,<"OK">,1,4
  7495.  
  7496.  
  7497.  
  7498. CO_Gadget2    dc.l    CO_Gadget3
  7499.     dc.w    80,40-12,34*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  7500.     dc.l    CO_G1_Box,0,0,0,CO_G1_Info
  7501.     dc.w    100,0,0
  7502. CO_G1_Box    BOX    -1,-1,272+1,8,2,CO_G1_Box2
  7503. CO_G1_Box2    BOX    -2,-2,272+2,9,1,0
  7504. CO_G1_Info    dc.l    CO_G1_Puffer,CO_G1_Undo
  7505.     dc.w    0,34
  7506.     ds.w    34
  7507. CO_G1_Puffer    ds.b    40
  7508. CO_G1_Undo    ds.b    40
  7509.  
  7510. CO_Gadget3    dc.l    CO_Gadget4
  7511.     dc.w    80,40-12+20,34*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  7512.     dc.l    CO_G1_Box,0,0,0,CO_G2_Info
  7513.     dc.w    101,0,0
  7514. CO_G2_Info    dc.l    CO_G2_Puffer,CO_G2_Undo
  7515.     dc.w    0,34
  7516.     ds.w    34
  7517.     dc.b    " $"
  7518. CO_G2_Puffer    ds.b    40
  7519. CO_G2_Undo    ds.b    40
  7520.  
  7521. CO_Gadget4    dc.l    CO_Gadget5
  7522.     dc.w    80,40-12+40,34*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  7523.     dc.l    CO_G1_Box,0,0,0,CO_G3_Info
  7524.     dc.w    102,0,0
  7525. CO_G3_Info    dc.l    CO_G3_Puffer,CO_G3_Undo
  7526.     dc.w    0,34
  7527.     ds.w    34
  7528. CO_G3_Puffer    ds.b    40
  7529. CO_G3_Undo    ds.b    40
  7530.  
  7531. CO_Gadget5    dc.l    0
  7532.     dc.w    80,40-12+60,34*8,10,GADGHCOMP,RELVERIFY,STRGADGET
  7533.     dc.l    CO_G1_Box,0,0,0,CO_G4_Info
  7534.     dc.w    103,0,0
  7535. CO_G4_Info    dc.l    CO_G4_Puffer,CO_G4_Undo
  7536.     dc.w    0,34
  7537.     ds.w    34
  7538. CO_G4_Puffer    ds.b    40
  7539. CO_G4_Undo    ds.b    40
  7540.  
  7541.  
  7542.  
  7543.  
  7544. CONVERTER    lea.l    Windowdef14(pc),a0
  7545.     jsr    MakeWindow
  7546.     tst.l    d0
  7547.     beq    .wait
  7548.     move.l    d0,Window2
  7549.     SETDRMD    #RP_JAM1
  7550.     WRITE    #6+(360-11*8)/2,#11,#0,<"Converter :">
  7551.     WRITE    #5+(360-11*8)/2,#10,#1,<"Converter :">
  7552.     WRITE    #10,#40-6,#5,<"Decimal:">
  7553.     WRITE    #10,#60-6,#5,<"Hex ($):">
  7554.     WRITE    #10,#80-6,#5,<"Bin (%):">
  7555.     WRITE    #10,#100-6,#5,<"ASCII  :">
  7556.  
  7557.     
  7558.     lea.l    CO_Gadget2(pc),a0
  7559.     move.l    WindowPointer,a1
  7560.     sub.l    a2,a2
  7561.     CALLINT_PC    ActivateGadget
  7562.  
  7563. .WARTEN    move.l    Window2,a0        ; wait .....
  7564.     move.l    wd_UserPort(a0),a0
  7565.     move.l    a0,a5
  7566.     CALLEXEC    WaitPort        
  7567.     move.l    a5,a0
  7568.     CALLEXEC    GetMsg        ; get message
  7569.     move.l    d0,a1    
  7570.     move.l    im_Class(a1),d4    ; get data
  7571.     move.w    im_Code(a1),d5
  7572.     move.l    im_IAddress(a1),a4
  7573.     CALLEXEC     ReplyMsg        ; reply message        
  7574.     move.w    gg_GadgetID(a4),d0
  7575.     cmp.b    #100,d0
  7576.     beq    .NewDecimal
  7577.     cmp.b    #101,d0
  7578.     beq    .NewHex
  7579.     cmp.b    #102,d0
  7580.     beq    .ReadBin
  7581.     cmp.b    #103,d0
  7582.     beq    .NewASCII
  7583.     tst.b    d0
  7584.     bne.s    .WARTEN
  7585. .Exit    move.l    Window2,a0
  7586.     CALLINT_PC    CloseWindow
  7587. .wait    jmp    wait
  7588.  
  7589. .Zahl    dc.l    12345
  7590.  
  7591. .Error    clr.b    CO_G1_Puffer        ; error
  7592.     clr.b    CO_G2_Puffer
  7593.     clr.b    CO_G3_Puffer
  7594.     clr.b    CO_G4_Puffer
  7595.     lea.l    CO_Gadget2(pc),a0
  7596.     move.l    WindowPointer,a1    ; redraw gadgets
  7597.     sub.l    a2,a2
  7598.     CALLINT_PC    RefreshGadgets
  7599.     move.l    ScreenPtr1,a0
  7600.     CALLINT_PC    DisplayBeep
  7601.     bra    .WARTEN
  7602.  
  7603. .NewDecimal    lea.l    CO_G1_Puffer(pc),a0    ; get decimal
  7604.     jsr    GetZahl
  7605.     tst.l    d1
  7606.     bne    .Error
  7607.     move.l    d0,.Zahl
  7608.     bra    .NewInput
  7609. .NewHex    lea.l    CO_G2_Puffer-1(pc),a0    ; get hex (add "$")
  7610.     jsr    GetZahl
  7611.     tst.l    d1
  7612.     bne    .Error
  7613.     move.l    d0,.Zahl
  7614.     bra    .NewInput
  7615.  
  7616. .NewASCII    lea.l    CO_G4_Puffer(pc),a0    ; get ASCII
  7617.     moveq.l    #0,d0
  7618.     move.b    (a0)+,d0        ; last Char ? 
  7619.     beq.s    .Error        ; empty string ????
  7620.     lsl.l    #8,d0
  7621.     move.b    (a0)+,d0        ; last Char ? 
  7622.     beq.s    .Z1
  7623.     lsl.l    #8,d0
  7624.     move.b    (a0)+,d0        ; last Char ? 
  7625.     beq.s    .Z1
  7626.     lsl.l    #8,d0
  7627.     move.b    (a0)+,d0        ; last Char ? 
  7628.     beq.s    .Z1
  7629.     move.l    d0,.Zahl
  7630.     bra.s    .NewInput
  7631. .Z1    lsr.l    #8,d0
  7632.     move.l    d0,.Zahl
  7633.  
  7634. ; write new numbers & text
  7635.  
  7636. .NewInput    move.l    d0,d6        ; decimal
  7637.     lea.l    CO_G1_Puffer(pc),a0
  7638.     jsr    MakeZahlU
  7639.     clr.b    (a0)
  7640.     move.l    d6,d0
  7641.     lea.l    CO_G2_Puffer(pc),a0    ; hex ($)
  7642.     jsr    MakeHexU
  7643.     clr.b    (a0)    
  7644.  
  7645.     
  7646.     lea.l    CO_G3_Puffer(pc),a0    ; bin (%)
  7647.     move.w    #31,d1
  7648. .Label1    move.b    #"0",d2
  7649.     btst    d1,d6
  7650.     beq.s    .Zero
  7651.     bset    #0,d2
  7652. .Zero    move.b    d2,(a0)+
  7653.     dbra    d1,.Label1
  7654.     clr.b    (a0)+
  7655.     
  7656.     lea.l    CO_G4_Puffer+5(pc),a0    ; ASCII
  7657.     clr.b    -(a0)
  7658.     moveq.l    #3,d1
  7659. .Label2    move.b    d6,d0
  7660.     tst.b    d0
  7661.     bne.s    .NotZero
  7662.     move.b    #" ",d0
  7663. .NotZero    move.b    d0,-(a0)
  7664.     lsr.l    #8,d6
  7665.     dbra    d1,.Label2
  7666.  
  7667.     lea.l    CO_Gadget2(pc),a0
  7668.     move.l    WindowPointer,a1    ; redraw gadgets
  7669.     sub.l    a2,a2
  7670.     CALLINT_PC    RefreshGadgets
  7671.     bra    .WARTEN
  7672.  
  7673. .ReadBin    lea.l    CO_G3_Puffer(pc),a0    ; read bin (%)
  7674. .O1    tst.b    (a0)+
  7675.     bne.s    .O1
  7676.     tst.b    -(a0)
  7677.     moveq.l    #0,d0
  7678.     moveq.l    #0,d1
  7679. .O2    move.b    -(a0),d2
  7680.     cmp.b    #"0",d2
  7681.     beq.s    .O4
  7682.     cmp.b    #"1",d2
  7683.     bne    .Error
  7684.     bset    d1,d0        ; set bit
  7685. .O4    addq.l    #1,d1
  7686.     cmp.l    #CO_G3_Puffer,a0
  7687.     beq.s    .O3
  7688.     cmp.b    #32,d1
  7689.     beq    .Error
  7690.     bra.s    .O2
  7691. .O3    move.l    d0,.Zahl
  7692.     bra    .NewInput
  7693.     
  7694.     
  7695.  
  7696.  
  7697.  
  7698. MakeHexU    movem.l    d0-d7/a1-a5,-(sp)    ; convert d0 into HEX without -/+ (a0 ^buffer)
  7699. .MH0    move.l    d0,d1
  7700.     move.l    #32-4,d2
  7701.     lea.l    .Hex(pc),a1        
  7702.     moveq.l    #0,d3
  7703. .MH1    move.l    d1,d0
  7704.     lsr.l    d2,d0
  7705.     and.l    #$f,d0
  7706.     tst.l    d2
  7707.     beq.s    .MH3
  7708.     tst.b    d3
  7709.     bne.s    .MH3
  7710.     tst.b    d0
  7711.     beq.s    .MH2
  7712. .MH3    move.b    (a1,d0),(a0)+    
  7713.     moveq.l    #1,d3
  7714. .MH2    subq.l    #4,d2
  7715.     cmp.l    #-4,d2
  7716.     bne.s    .MH1
  7717.     movem.l    (sp)+,d0-d7/a1-a5
  7718.     rts        
  7719. .Hex    dc.b    "0123456789abcdef"
  7720.  
  7721. MakeZahlU    movem.l    d0-d7/a1-a5,-(sp)    ; convert d0 into ASCII without +/- (a0 ^buffer)
  7722. .MZ0    moveq.l    #9,d2
  7723.     moveq.l    #0,d3
  7724.     lea.l    .MZ_Potenzen(pc),a2
  7725. .MZ1    move.b    #"0"-1,d1
  7726. .MZ2    addq    #1,d1
  7727.     sub.l    (a2),d0
  7728.     bcc.s    .MZ2
  7729.     add.l    (a2)+,d0
  7730.     tst.b    d2
  7731.     beq.s    .MZ3
  7732.     cmp.b    #"0",d1
  7733.     beq.s    .MZ4
  7734.     moveq.l    #1,d3
  7735.     bra.s    .MZ3
  7736. .MZ4    tst.b    d3
  7737.     beq.s    .MZ5
  7738. .MZ3    move.b    d1,(a0)+
  7739. .MZ5    dbra    d2,.MZ1
  7740.     movem.l    (sp)+,d0-d7/a1-a5
  7741.     rts
  7742. .MZ_Potenzen    dc.l    1000000000
  7743.     dc.l    100000000
  7744.     dc.l    10000000
  7745.     dc.l    1000000
  7746.     dc.l    100000
  7747.     dc.l    10000
  7748.     dc.l    1000
  7749.     dc.l    100
  7750.     dc.l    10
  7751.     dc.l    1
  7752.  
  7753. ******************************************************************
  7754.  
  7755. ; set marks accoding to preferences
  7756.  
  7757. Hardcopy_Gadgets    
  7758.     move.b    PrintQuality,d0        ; set marks
  7759.  
  7760.     lea.l    HC_Gadget3+gg_GadgetRender,a0
  7761.     move.l    (a0),a0
  7762.     move.l    ig_NextImage(a0),a0
  7763.     clr.l    ig_NextImage(a0)
  7764.     lea.l    HC_Gadget4+gg_GadgetRender,a0
  7765.     move.l    (a0),a0
  7766.     move.l    ig_NextImage(a0),a0
  7767.     clr.l    ig_NextImage(a0)
  7768.     lea.l    HC_Gadget5+gg_GadgetRender,a0
  7769.     move.l    (a0),a0
  7770.     move.l    ig_NextImage(a0),a0
  7771.     clr.l    ig_NextImage(a0)
  7772.  
  7773.  
  7774.     lea.l    HC_Gadget3+gg_GadgetRender,a0
  7775.     tst.b    d0
  7776.     beq.s    .Label1
  7777.     lea.l    HC_Gadget4+gg_GadgetRender,a0
  7778.     cmp.b    #1,d0
  7779.     beq.s    .Label1
  7780.     lea.l    HC_Gadget5+gg_GadgetRender,a0
  7781. .Label1    move.l    (a0),a0
  7782.     move.l    ig_NextImage(a0),a0
  7783.     move.l    #SELECT_Image,ig_NextImage(a0)
  7784.  
  7785.     move.b    PrintMark,d0
  7786.  
  7787.     move.l    HC_Gadget6+gg_GadgetRender,a0
  7788.     move.l    ig_NextImage(a0),a0
  7789.     clr.l    ig_NextImage(a0)
  7790.     move.l    HC_Gadget7+gg_GadgetRender,a0
  7791.     move.l    ig_NextImage(a0),a0
  7792.     clr.l    ig_NextImage(a0)
  7793.     move.l    HC_Gadget8+gg_GadgetRender,a0
  7794.     move.l    ig_NextImage(a0),a0
  7795.     clr.l    ig_NextImage(a0)
  7796.     move.l    HC_Gadget9+gg_GadgetRender,a0
  7797.     move.l    ig_NextImage(a0),a0
  7798.     clr.l    ig_NextImage(a0)
  7799.  
  7800.     btst    #0,d0
  7801.     beq.s    .Label2
  7802.     move.l    HC_Gadget6+gg_GadgetRender,a0
  7803.     move.l    ig_NextImage(a0),a0
  7804.     move.l    #SELECT_Image,ig_NextImage(a0)
  7805. .Label2    btst    #1,d0
  7806.     beq.s    .Label3
  7807.     move.l    HC_Gadget7+gg_GadgetRender,a0
  7808.     move.l    ig_NextImage(a0),a0
  7809.     move.l    #SELECT_Image,ig_NextImage(a0)
  7810. .Label3    btst    #2,d0
  7811.     beq.s    .Label4
  7812.     move.l    HC_Gadget8+gg_GadgetRender,a0
  7813.     move.l    ig_NextImage(a0),a0
  7814.     move.l    #SELECT_Image,ig_NextImage(a0)
  7815. .Label4    btst    #3,d0
  7816.     beq.s    .Label5
  7817.     move.l    HC_Gadget9+gg_GadgetRender,a0
  7818.     move.l    ig_NextImage(a0),a0
  7819.     move.l    #SELECT_Image,ig_NextImage(a0)
  7820. .Label5    rts
  7821.  
  7822. *******************************************************************
  7823. ; hardcopy of sector
  7824.  
  7825. PrintHandle    dc.l    0
  7826.  
  7827. WindowPointer set Window2
  7828.  
  7829. Windowdef15    dc.w    40,36,370,140
  7830.     dc.b    -1,-1
  7831.     dc.l    GADGETUP!GADGETDOWN
  7832.     dc.l    ACTIVATE!SMART_REFRESH!RMBTRAP
  7833.     dc.l    HC_Gadget1
  7834.     dc.l    0
  7835.     dc.l    0
  7836.     dc.l    0,0
  7837.     dc.w    0,0,0,0,CUSTOMSCREEN
  7838.  
  7839. HC_Gadget1    FM_GADGET    HC_Gadget2,10,120,110,0,<"Cancel">,1,2
  7840. HC_Gadget2    FM_GADGET    HC_Gadget2b,130,120,110,1,<"Write">,1,2
  7841. HC_Gadget2b    FM_GADGET    HC_Gadget3,250,120,110,2,<"Write/Header">,1,2
  7842.  
  7843. HC_Gadget3    FM_GADGET    HC_Gadget4,130-40,50,70+13,0+128,<"Draft">,1,4
  7844. HC_Gadget4    FM_GADGET    HC_Gadget5,210-40+13,50,70+13,1+128,<"Letter">,1,4
  7845. HC_Gadget5    FM_GADGET    HC_Gadget6,290-40+26,50,70+13,2+128,<"Default">,1,4
  7846. HC_Gadget6    FM_GADGET    HC_Gadget7,130-40,70,70+40+20,0+64,<"Italics">,1,4
  7847. HC_Gadget7    FM_GADGET    HC_Gadget8,210+40-20,70,70+40+20,1+64,<"Bold">,1,4
  7848. HC_Gadget8    FM_GADGET    HC_Gadget9,130-40,90,70+40+20,2+64,<"Underline">,1,4
  7849. HC_Gadget9    FM_GADGET    HC_Gadget12,210+40-20,90,70+40+20,3+64,<"Colour">,1,4
  7850.  
  7851.  
  7852. HC_Gadget12    dc.l    0
  7853.     dc.w    11,30+1,43*8,10,GADGHCOMP,STRINGCENTER,STRGADGET
  7854.     dc.l    HC_G12_Box,0,0,0,HC_G12_Info
  7855.     dc.w    10,0,0
  7856. HC_G12_Box    BOX    -1,-1,344,8,2,HC_G12_Box2
  7857. HC_G12_Box2    BOX    -2,-2,345,9,1,0
  7858. HC_G12_Info    dc.l    HC_G12_Puffer,HC_G12_Undo
  7859.     dc.w    0,98
  7860.     ds.w    12
  7861. HC_G12_Puffer    dc.b    "PRT:",0
  7862.     ds.b    100
  7863.     even
  7864. HC_G12_Undo    ds.b    100    
  7865.     even
  7866.  
  7867. PRINT    move.w    #GADGIMMEDIATE,d0
  7868.     move.w    d0,HC_Gadget3+gg_Activation        ; modify gadgets
  7869.     move.w    d0,HC_Gadget4+gg_Activation
  7870.     move.w    d0,HC_Gadget5+gg_Activation
  7871.     move.w    d0,HC_Gadget6+gg_Activation
  7872.     move.w    d0,HC_Gadget7+gg_Activation
  7873.     move.w    d0,HC_Gadget8+gg_Activation
  7874.     move.w    d0,HC_Gadget9+gg_Activation
  7875.  
  7876.     tst.b    FlagFile            ; no sector -> no hardcopy
  7877.     beq    .wait
  7878.     move.l    Offset,d0
  7879.     divu    #512,d0
  7880.     and.l    #$ffff,d0
  7881.     addq    #1,d0
  7882.     move.l    d0,.PrintSector
  7883.  
  7884.     lea.l    Windowdef15(pc),a0
  7885.     jsr    MakeWindow
  7886.     tst.l    d0
  7887.     beq    .wait
  7888.     move.l    d0,Window2
  7889.     SETDRMD    #RP_JAM1
  7890.     WRITE    #6+(370-10*8)/2,#11,#0,<"Hardcopy :">
  7891.     WRITE    #5+(370-10*8)/2,#10,#1,<"Hardcopy :">
  7892.     WRITE    #10,#58,#1,<"Quality:">
  7893.     WRITE    #10,#78,#1,<"Mark   :">
  7894.  
  7895.     lea.l    HC_Gadget12(pc),a0
  7896.     move.l    WindowPointer,a1
  7897.     sub.l    a2,a2
  7898.     CALLINT_PC    RefreshGadgets
  7899.     
  7900.     lea.l    HC_Gadget12(pc),a0
  7901.     move.l    WindowPointer,a1
  7902.     sub.l    a2,a2
  7903.     CALLINT_PC    ActivateGadget
  7904.     
  7905.  
  7906. .Message    move.l    Window2,a0        ; wait .....
  7907.     move.l    wd_UserPort(a0),a0
  7908.     move.l    a0,a5
  7909.     CALLEXEC    WaitPort        
  7910.     move.l    a5,a0
  7911.     CALLEXEC    GetMsg        ; get message
  7912.     move.l    d0,a1    
  7913.     move.l    im_Class(a1),d4    ; get data
  7914.     move.w    im_Code(a1),d5
  7915.     move.l    im_IAddress(a1),a4
  7916.     CALLEXEC     ReplyMsg        ; reply message        
  7917.     moveq.l    #0,d0        
  7918.     move.w    gg_GadgetID(a4),d0
  7919.     btst    #7,d0        ; quality gadget ?
  7920.     bne    .NewQuality    
  7921.     btst    #6,d0        ; mark gadget ?
  7922.     bne    .NewMark
  7923.     move.b    d0,d5
  7924.     move.l    Window2,a0        ; close window
  7925.     CALLINT_PC    CloseWindow
  7926.     tst.b    d5        ; cancel selected ?
  7927.     bne    Print_It
  7928. .wait    jmp    wait
  7929.  
  7930. .PrintSector    dc.l    0
  7931. .NewQuality    bclr    #7,d0            ; set new quality
  7932.     move.b    d0,PrintQuality
  7933.     
  7934.     lea.l    HC_Gadget3+gg_GadgetRender(pc),a0    ; clear
  7935.     move.l    (a0),a0
  7936.     move.l    ig_NextImage(a0),a0
  7937.     clr.l    ig_NextImage(a0)    
  7938.     lea.l    HC_Gadget4+gg_GadgetRender(pc),a0    ; clear
  7939.     move.l    (a0),a0
  7940.     move.l    ig_NextImage(a0),a0
  7941.     clr.l    ig_NextImage(a0)    
  7942.     lea.l    HC_Gadget5+gg_GadgetRender(pc),a0    ; clear
  7943.     move.l    (a0),a0
  7944.     move.l    ig_NextImage(a0),a0
  7945.     clr.l    ig_NextImage(a0)    
  7946.  
  7947.     lea.l    HC_Gadget3+gg_GadgetRender(pc),a0    ; set mark
  7948.     tst.b    d0
  7949.     beq.s    .Label1
  7950.     lea.l    HC_Gadget4+gg_GadgetRender(pc),a0
  7951.     cmp.b    #1,d0
  7952.     beq.s    .Label1
  7953.     lea.l    HC_Gadget5+gg_GadgetRender(pc),a0
  7954. .Label1    move.l    (a0),a0
  7955.     move.l    ig_NextImage(a0),a0
  7956.     move.l    #SELECT_Image,ig_NextImage(a0)
  7957.  
  7958.     lea.l    HC_Gadget3(pc),a0        ; draw mark
  7959.     move.l    WindowPointer,a1
  7960.     sub.l    a2,a2
  7961.     moveq.l    #3,d0
  7962.     CALLINT_PC    RefreshGList
  7963.     bra    .Message
  7964.     
  7965. .NewMark    bclr    #6,d0            ; new mark 
  7966.     bchg    d0,PrintMark            ; invert flag
  7967.     beq    .Set_Flag            ; set flag
  7968.     move.l    gg_GadgetRender(a4),a0        ; clear
  7969.     move.l    ig_NextImage(a0),a0
  7970.     clr.l    ig_NextImage(a0)
  7971.     
  7972.     move.l    a4,a0            ; refresh gadgets
  7973.     move.l    WindowPointer,a1
  7974.     sub.l    a2,a2
  7975.     moveq.l    #1,d0
  7976.     CALLINT_PC    RefreshGList
  7977.     bra    .Message
  7978.     
  7979. .Set_Flag    move.l    gg_GadgetRender(a4),a0        ; clear
  7980.     move.l    ig_NextImage(a0),a0
  7981.     move.l    #SELECT_Image,ig_NextImage(a0)    
  7982.     
  7983.     move.l    a4,a0            ; refresh gadgets
  7984.     move.l    WindowPointer,a1
  7985.     sub.l    a2,a2
  7986.     moveq.l    #1,d0
  7987.     CALLINT_PC    RefreshGList
  7988.     bra    .Message
  7989.  
  7990.  
  7991. ; print sector
  7992.  
  7993. Print_It    move.b    d5,.Header
  7994.     clr.b    PrintMarkFlag
  7995.     move.l    #HC_G12_Puffer,d1    ; open output file
  7996.     move.l    #MODE_NEWFILE,d2
  7997.     CALLDOS_PC    Open
  7998.     move.l    d0,PrintHandle
  7999.     beq    .OpenError
  8000.  
  8001.     tst.b    PrintQuality        ; set quality
  8002.     bne.s    .NoDraft
  8003.     move.l    PrintHandle(pc),d1    ; draft
  8004.     lea.l    .Draft(pc),a0
  8005.     move.l    a0,d2
  8006.     moveq.l    #4,d3
  8007.     CALLDOS_PC    Write
  8008.     cmp.l    d3,d0
  8009.     bne    .Error
  8010.     bra    .Default    
  8011. .NoDraft    cmp.b    #1,PrintQuality
  8012.     bne.s    .Default
  8013.     move.l    PrintHandle(pc),d1    ; NLQ
  8014.     lea.l    .NLQ(pc),a0
  8015.     move.l    a0,d2
  8016.     moveq.l    #4,d3
  8017.     CALLDOS_PC    Write
  8018.     cmp.l    d3,d0
  8019.     bne    .Error
  8020.  
  8021. .Default    cmp.b    #1,.Header
  8022.     beq.s    .NoHeader
  8023.     move.l    PrintHandle(pc),d1    ; write header
  8024.     lea.l    PrintHeader(pc),a0
  8025.     move.l    a0,d2
  8026.     move.l    #PH_End-PrintHeader,d3
  8027.     CALLDOS_PC    Write
  8028.     cmp.l    d3,d0
  8029.     bne    .Error
  8030.  
  8031. .NoHeader    lea.l    Puffer,a4        ; a4 ^ buffer
  8032.     move.l    a4,a5        ; a5 ^ buffer
  8033.     move.l    a4,a3        ; a3 ^ end of buffer
  8034.     add.l    AnzahlBytes,a3
  8035.  
  8036.     move.l    PrintHandle(pc),d1    ; write $a
  8037.     lea.l    .Return(pc),a0
  8038.     move.l    a0,d2
  8039.     moveq.l    #1,d3
  8040.     CALLDOS_PC    Write
  8041.     cmp.l    d3,d0
  8042.     bne    .Error
  8043.  
  8044. .Label0    bsr    UndoStyle        ; undo style
  8045.     tst.l    d0
  8046.     bne    .Error
  8047.     move.l    a4,a0        ; write offset
  8048.     sub.l    #Puffer,a0
  8049.     move.l    a0,d2
  8050.     lsr.l    #2,d2
  8051.     lea.l    .Lines(pc),a0
  8052.     add.l    a0,d2
  8053.     moveq.l    #4,d3
  8054.     move.l    PrintHandle(pc),d1
  8055.     CALLDOS_PC    Write
  8056.     cmp.l    d0,d3
  8057.     bne    .Error
  8058.     move.l    PrintHandle(pc),d1    ; write space
  8059.     lea.l    .Space(pc),a0
  8060.     move.l    a0,d2
  8061.     moveq.l    #1,d3
  8062.     CALLDOS_PC    Write
  8063.     cmp.l    d3,d0
  8064.     bne    .Error
  8065.  
  8066.  
  8067.  
  8068.     moveq.l    #3,d7        ; 4 longwords
  8069. .Label1    moveq.l    #3,d6        ; containing 4 bytes
  8070.  
  8071. .Label2    cmp.b    #3,Color-Puffer(a4)    ; check if byte should be marked
  8072.     beq.s    .No1
  8073.     bsr    ChangeStyle
  8074.     bra.s    .T1
  8075. .No1    bsr    UndoStyle        ; undo style
  8076. .T1    tst.l    d0
  8077.     bne    .Error
  8078.  
  8079.     lea.l    HEX,a0        ; convert byte into hex
  8080.     lea.l    .ASCII(pc),a1
  8081.     moveq.l    #0,d0
  8082.     move.b    (a4),d0
  8083.     lsr.l    #4,d0
  8084.     move.b    (a0,d0),(a1)
  8085.     move.b    (a4)+,d0
  8086.     and.w    #$f,d0
  8087.     move.b    (a0,d0),1(a1)
  8088.  
  8089.     cmp.l    a3,a4        ; print space if end of sector
  8090.     bls    .Label6
  8091.     move.b    #" ",(a1)
  8092.     move.b    #" ",1(a1)
  8093.  
  8094.     move.l    a1,-(sp)
  8095.     bsr    UndoStyle        ; undo style
  8096.     move.l    (sp)+,a1
  8097.     tst.l    d0
  8098.     bne    .Error
  8099.  
  8100. .Label6    move.l    PrintHandle(pc),d1    ; write hex
  8101.     move.l    a1,d2
  8102.     moveq.l    #2,d3
  8103.     CALLDOS_PC    Write
  8104.     cmp.l    d3,d0
  8105.     bne    .Error
  8106.     dbra    d6,.Label2
  8107.  
  8108.     bsr    UndoStyle        ; undo style
  8109.     tst.l    d0
  8110.     bne    .Error
  8111.  
  8112.  
  8113.     move.l    PrintHandle(pc),d1    ; write space
  8114.     lea.l    .Space(pc),a0
  8115.     move.l    a0,d2
  8116.     moveq.l    #1,d3
  8117.     CALLDOS_PC    Write
  8118.     cmp.l    d3,d0
  8119.     bne    .Error
  8120.     dbra    d7,.Label1
  8121.  
  8122.     bsr    UndoStyle        ; undo style
  8123.     tst.l    d0
  8124.     bne    .Error
  8125.  
  8126.     move.l    PrintHandle(pc),d1    ; write some spaces
  8127.     lea.l    .Space(pc),a0
  8128.     move.l    a0,d2
  8129.     moveq.l    #4,d3
  8130.     CALLDOS_PC    Write
  8131.     cmp.l    d3,d0
  8132.     bne    .Error
  8133.     
  8134.     move.w    #15,d7        ; write 16 ASCII codes
  8135.     lea.l    .Byte(pc),a2
  8136.  
  8137. .Label3    cmp.b    #3,Color-Puffer(a5)    ; check if byte should be marked
  8138.     beq.s    .No2
  8139.     bsr    ChangeStyle
  8140.     bra.s    .T2
  8141. .No2    bsr    UndoStyle        ; undo style
  8142. .T2    tst.l    d0
  8143.     bne    .Error
  8144.     move.b    (a5)+,d4
  8145.     cmp.b    #$7f,d4        ; $7f must be replaced !!!!!!!!
  8146.     beq.s    .K4
  8147.     cmp.b    #1,DisplayMode        ; replace 0-$1f and $80-$9f
  8148.     bhi.s    .K2        , display mode 0 is impossible
  8149. .K5    move.b    d4,d0
  8150.     and.b    #$7f,d0
  8151.     cmp.b    #$1f,d0
  8152.     bhi.s    .K1
  8153. .K4    move.b    #".",d4
  8154.     bra.s    .K1
  8155. .K2    cmp.b    #$7d,d4        ; replace 0-$1f and $7e-$ff
  8156.     bhi.s    .K4
  8157.     cmp.b    #$1f,d4
  8158.     bls.s    .K4    
  8159. .K1    move.b    d4,(a2)
  8160.  
  8161.     cmp.l    a3,a5        ; print space if end of sector
  8162.     bls    .Label4
  8163.     move.w    #" ",(a2)
  8164. .Label4    move.l    PrintHandle(pc),d1    ; write ASCII code
  8165.     move.l    a2,d2
  8166.     moveq.l    #1,d3
  8167.     CALLDOS_PC    Write
  8168.     cmp.l    d3,d0
  8169.     bne    .Error
  8170.     dbra    d7,.Label3
  8171.  
  8172.     move.l    PrintHandle(pc),d1    ; write $a
  8173.     lea.l    .Return(pc),a0
  8174.     move.l    a0,d2
  8175.     moveq.l    #1,d3
  8176.     CALLDOS_PC    Write
  8177.     cmp.l    d3,d0
  8178.     bne    .Error
  8179.     
  8180.     cmp.l    a4,a3
  8181.     bhi    .Label0
  8182.  
  8183.     move.l    PrintHandle(pc),d1    ; write $a
  8184.     lea.l    .Return(pc),a0
  8185.     move.l    a0,d2
  8186.     moveq.l    #1,d3
  8187.     CALLDOS_PC    Write
  8188.     cmp.l    d3,d0
  8189.     bne    .Error
  8190.  
  8191.     bsr    UndoStyle        ; undo style
  8192.     tst.l    d0
  8193.     bne    .Error
  8194.     nop
  8195. .Error    move.l    PrintHandle(pc),d1
  8196.     CALLDOS_PC    Close
  8197. .OpenError    jmp    wait    
  8198.  
  8199.  
  8200. .Lines    dc.b    "000:010:020:030:040:050:060:070:080:090:0A0:0B0:0C0:0D0:0E0:0F0:"
  8201.     dc.b    "100:110:120:130:140:150:160:170:180:190:1A0:1B0:1C0:1D0:1E0:1F0:"
  8202.     even
  8203. .ASCII    dc.b    "xx"    
  8204.     even
  8205. .Space    dc.b    "    "
  8206.     even 
  8207. .Return    dc.b    $a
  8208. .Header    dc.b    0
  8209.     even
  8210. .Byte    dc.b    "x"
  8211.     even
  8212. .Draft    dc.b    $9b,'1"z'
  8213.     even
  8214. .NLQ    dc.b    $9b,'2"z'
  8215.     even
  8216.  
  8217. PrintMarkFlag    dc.b    0
  8218.     even
  8219.  
  8220. ChangeStyle    lea.l    PrintMarkFlag(pc),a0
  8221.     tst.b    (a0)
  8222.     bne    .OK
  8223.     move.b    #1,(a0)
  8224.     move.b    PrintMark,d4        ; mark changes
  8225.     move.b    #"1",d1
  8226.     btst    #3,d4
  8227.     beq.s    .PM_1
  8228.     addq    #2,d1
  8229. .PM_1    move.b    d1,.ITALICS+4        ; change colour
  8230.     move.b    d1,.BOLD+4
  8231.     move.b    d1,.UNDERLINE+4
  8232.  
  8233.     btst    #0,d4
  8234.     beq.s    .NoItalics        
  8235.     move.l    PrintHandle(pc),d1    ; set style : italics
  8236.     lea.l    .ITALICS(pc),a0
  8237.     move.l    a0,d2
  8238.     moveq.l    #9,d3
  8239.     CALLDOS_PC    Write
  8240.     cmp.l    d3,d0
  8241.     bne    .Error        
  8242. .NoItalics    btst    #1,d4
  8243.     beq.s    .NoBold
  8244.     move.l    PrintHandle(pc),d1    ; set style : bold
  8245.     lea.l    .BOLD(pc),a0
  8246.     move.l    a0,d2
  8247.     moveq.l    #9,d3
  8248.     CALLDOS_PC    Write
  8249.     cmp.l    d3,d0
  8250.     bne    .Error        
  8251. .NoBold    btst    #2,d4
  8252.     beq.s    .NoUnderline
  8253.     move.l    PrintHandle(pc),d1    ; set style : underline
  8254.     lea.l    .UNDERLINE(pc),a0
  8255.     move.l    a0,d2
  8256.     moveq.l    #9,d3
  8257.     CALLDOS_PC    Write
  8258.     cmp.l    d3,d0
  8259.     bne    .Error    
  8260. .OK    
  8261. .NoUnderline    moveq.l    #0,d0        ; no error occurred
  8262.     rts
  8263. .Error    moveq.l    #-1,d0
  8264.     rts
  8265. .ITALICS    dc.b    $9b,"3;31;40m"
  8266.     even
  8267. .BOLD    dc.b    $9b,"1;31;40m"
  8268.     even
  8269. .UNDERLINE    dc.b    $9b,"4;31;40m"
  8270.     even
  8271.  
  8272. UndoStyle    lea.l    PrintMarkFlag(pc),a0    ; if style wasn't changed
  8273.     tst.b    (a0)        ; it needn't be reseted.
  8274.     beq.s    .OK
  8275.     clr.b    (a0)
  8276.     move.l    PrintHandle(pc),d1    ; undo style
  8277.     lea.l    .UNDOSTYLE(pc),a0
  8278.     move.l    a0,d2
  8279.     moveq.l    #9,d3
  8280.     CALLDOS_PC    Write
  8281.     cmp.l    d3,d0
  8282.     bne    .Error
  8283. .OK    moveq.l    #0,d0
  8284.     rts
  8285. .Error    moveq.l    #-1,d0
  8286.     rts
  8287.     
  8288. .UNDOSTYLE     dc.b    $9b,"0;31;40m"
  8289.     even
  8290.  
  8291.  
  8292. PrintHeader    dc.b    "FILE   : "        ; header
  8293.     ds.b    60
  8294.     dc.b    $a
  8295. PrintHeader2    dc.b    "SECTOR : "
  8296.     ds.b    5
  8297.     dc.b    $A
  8298.     dc.b    "-------------------------------------------------------------"
  8299. PH_End
  8300.  
  8301. ***************************************************************
  8302.  
  8303. UPCASE    cmp.b    #"A"-1,d0        ; check A-Z
  8304.     bls.s    .Different
  8305.     cmp.b    #"Z",d0
  8306.     bhi.s    .Different
  8307.     add.b    #"a"-"A",d0
  8308. .Different    cmp.b    #$e0-1,d0        ; foreign characters ?
  8309.     bls.s    .NoChange
  8310.     sub.b    #$20,d0
  8311. .NoChange    rts
  8312.  
  8313. UPCASE_D1    tst.l    SearchCase        ; case sensitive  ?
  8314.     beq    .NoChange
  8315.     cmp.b    Joker,d1        ; joker ?
  8316.     beq    .NoChange
  8317.     cmp.b    #"A"-1,d1        ; check A-Z
  8318.     bls.s    .Different
  8319.     cmp.b    #"Z",d1
  8320.     bhi.s    .Different
  8321.     add.b    #"a"-"A",d1
  8322. .Different    cmp.b    #$e0-1,d1        ; foreign characters ?
  8323.     bls.s    .NoChange
  8324.     sub.b    #$20,d1
  8325. .NoChange    rts
  8326.  
  8327. **********************************************************************
  8328.  
  8329. ; exchange drive names  DF1: / DF2:   (file requester)
  8330.  
  8331. DRIVE    lea.l    M1_I6_String+12,a0
  8332.     lea.l    DriveName+2,a1
  8333.     cmp.b    #"1",(a0)
  8334.     beq.s    .df2
  8335.     move.b    #"1",(a0)
  8336.     move.b    #"1",(a1)
  8337.     jmp    wait
  8338. .df2    move.b    #"2",(a0)
  8339.     move.b    #"2",(a1)
  8340.     jmp    wait
  8341.  
  8342. **********************************************************************
  8343. **********************************************************************
  8344.  
  8345. * this section contains several images so it has to be in CHIP mem !!!
  8346.  
  8347.  
  8348.  
  8349.     Section     "Pfeile",DATA_C
  8350.  
  8351.  
  8352. R_G9_PfeilUp    dc.w    0,0,15,9,1
  8353.     dc.l    R_G9_PU_image
  8354.     dc.b    1,0
  8355.     dc.l    0
  8356. R_G9_PU_image    dc.w    0
  8357.     dc.w    %0000000100000000
  8358.     dc.w    %0000001110000000
  8359.     dc.w    %0000011111000000
  8360.     dc.w    %0000111111100000
  8361.     dc.w    %0001111111110000
  8362.     dc.w    %0011111111111000
  8363.     dc.w    %0111111111111100
  8364.     dc.w    0
  8365. R_G10_PfeilD    dc.w    0,0,15,9,1
  8366.     dc.l    R_G10_PD_image
  8367.     dc.b    1,0
  8368.     dc.l    0
  8369. R_G10_PD_image    dc.w    0
  8370.     dc.w    %0111111111111100
  8371.     dc.w    %0011111111111000
  8372.     dc.w    %0001111111110000
  8373.     dc.w    %0000111111100000
  8374.     dc.w    %0000011111000000
  8375.     dc.w    %0000001110000000
  8376.     dc.w    %0000000100000000
  8377.     dc.w    0
  8378.  
  8379.  
  8380. SELECT_Image    dc.w    0,0,14,12,3
  8381.     dc.l    .Image
  8382.     dc.b    1+2+4,0
  8383.     dc.l    0
  8384. .Image    
  8385.     incbin    "Sign.Raw"    
  8386.  
  8387. FM_LOGO    dc.w    0,0,241,23,3
  8388.     dc.l    FM_Data
  8389.     dc.b    1+2+4,0
  8390.     dc.l    0
  8391.     even
  8392. FM_Data
  8393.     incbin    "FM.Image"
  8394.  
  8395.     
  8396.  
  8397. FONT_PAL1 
  8398.     incbin    "Font1.data"
  8399.     even
  8400. FONT_NTSC1
  8401.     incbin    "Font3.Data"    
  8402.  
  8403.     even
  8404.  
  8405. FM_Font    dc.l    0
  8406. Puffer    ds.b    512
  8407. UndoPuffer    ds.b    512
  8408. Puffer2    ds.b    512
  8409. Color    ds.b    512
  8410. AnzahlBytes    dc.l    499
  8411.  
  8412. Mode    dc.b    1
  8413. Nibble    dc.b    0
  8414. FlagFile    dc.b    0
  8415. FlagWrite    dc.b    0
  8416. DisplayMode    dc.b    0
  8417.     even
  8418.  
  8419. ; preferences
  8420.  
  8421. PREFS
  8422. Palette    dc.w    $000,$eee,$775,$313,$04d,$997,$4b9,$553
  8423. WriteMode    dc.b    0    ;0=ask, 1=write, 2=do nothing
  8424. Joker    dc.b    "?"
  8425. PrintQuality    dc.b    2    ; 0=draft, 1=NQL , 2=default
  8426. PrintMark    dc.b    %1010    ; 1= Italics, 2= Bold, 4= Underline, 8=Colour
  8427. DriveName    dc.b    "DF1:",0
  8428.     dc.b    0
  8429.  
  8430. ; default prefernces
  8431.  
  8432. DPrefs    dc.w    $000,$eee,$775,$313,$04d,$997,$4b9,$553
  8433.     dc.b    0
  8434.     dc.b    "?"
  8435.     dc.b    2
  8436.     dc.b    %1010
  8437.     dc.b    "DF1:",0
  8438.     dc.b    0
  8439.     even
  8440.  
  8441.  
  8442. PAL
  8443. HEX_X    dc.l    24    ; basic datas for PAL Amigas
  8444. HEX_Y    dc.l    11+14+3+6    ; X and Y  position of Hex 
  8445. ASC_X    dc.l    (32+1+7)*8+22
  8446. ASC_Y    dc.l    11+14+3+6    ; X and Y  position of ASCII
  8447. BaseLine    dc.l    6    ; Baseline of font
  8448. Bytes_Per_Row    dc.l    16    ; Bytes per row
  8449. Zeilen    dc.l    32    ; number of lines
  8450. FONT_X    dc.l    8    ; X size of font
  8451. FONT_Y    dc.l    7    ; Y size of font
  8452. HEX_Breite    dc.l    35    ; number of characters per  Hex   row (plus spaces)
  8453. ASC_Breite    dc.l    16    ;   "     "     "       "   ASCII  "   
  8454. PAL_end
  8455.     
  8456.  
  8457. NTSC            ; basic datas for NTSC Amigas
  8458. .HEX_X    dc.l    5
  8459. .HEX_Y    dc.l    11+14+3+7
  8460. .ASC_X    dc.l    328+5
  8461. .ASC_Y    dc.l    11+14+3+7
  8462. .BaseLine    dc.l    7
  8463. .Bytes_Per_Row    dc.l    24
  8464. .Zeilen    dc.l    22
  8465. .FONT_X    dc.l    6
  8466. .FONT_Y    dc.l    8
  8467. .HEX_Breite    dc.l    53
  8468. .ASC_Breite    dc.l    24
  8469.  
  8470.     Section    "NP",BSS
  8471.  
  8472. NamenPuffer    ds.b    38*300
  8473. SearchColors    ds.b    1024
  8474. SearchPuffer    ds.b    1024
  8475. SearchPufferII    ds.b    1024
  8476. CompPuffer    ds.b    100
  8477.  
  8478.     even
  8479.  
  8480.     
  8481.