home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 337.lha / FileMaster_v1.11 / Source / Source210 < prev    next >
Text File  |  1990-01-16  |  131KB  |  7,210 lines

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