[fa.info-mac] FEdit sources

info-mac@uw-beaver (info-mac) (10/27/84)

From: Ed Pattermann <PATTERMANN@SUMEX-AIM.ARPA>
Here are FEDIT1.ASM, FEDIT2.ASM, FEDITR.ASM, and FEDIT.LINK

26-Oct-84 19:11:49-PDT,69937;000000000001
Return-Path: <tdn@cmu-cs-spice.arpa>
Received: from CMU-CS-SPICE.ARPA by SUMEX-AIM.ARPA with TCP; Fri 26 Oct 84 19:05:28-PDT
Date: Friday, 26 October 1984 21:56:28 EDT
From: Thomas.Newton@cmu-cs-spice.arpa
To: info-mac@sumex-aim.arpa
Subject: FEdit1.Asm (TO BE ARCHIVED)
Message-ID: <1984.10.27.1.53.14.Thomas.Newton@cmu-cs-spice.arpa>

;   Fedit1.Asm
;______________________________________________________________________
;
;   This program is designed to provide disk information and to
;   edit disk files on the Macintosh.
;
;         Copyright (C) John H. Mitchell, September 1984.
;
;                   All rights reserved.
;
;   Permission is granted for non commercial usage.  This source
;   and its associated code file may be copied and distributed
;   freely, provided that you do not attempt to sell it, use it
;   as the basis for a commercial program, or otherwise obtain any
;   financial gain from it.  You may modify it in any way that you
;   feel appropriate within these limits.
;
;______________________________________________________________________

        Include Mactraps.d
        
        XREF    DiskInserted,EjectDisk,FindVCB,GetVolumeName,Menu5

        XDEF    TempWord,TempHdl,TempRect,Event,What,Message
        XDEF    Count,DlogHdl,ItemHit,DlogStore,WindFlag
        XDEF    Outstring,ClearIOPB,FIOPB,WaitAcknowledge
        XDEF    VCBPtr,WordToHex,CharToHex
        XDEF    Start

SeparateResFile EQU     0       ; Set non zero if separate
                                ; resource file is being used

MenuCount               EQU     5       ; Number of menus in initial bar

AboutCmd                EQU     1       ; Menu 1

OpenVolCmd      EQU     1       ; Menu 2
OpenFileCmd     EQU     2
CloseCmd                EQU     3
QuitCmd         EQU     4

RNextCmd                EQU     1       ; Menu 3
RPrevCmd                EQU     2
RBlockCmd               EQU     3
WBlockCmd               EQU     5
AModCmd         EQU     7
HModCmd         EQU     8
DiscardCmd      EQU     10

ResForkCmd      EQU     1       ; Menu 4
DataForkCmd     EQU     2
DHexCmd         EQU     4
DASCCmd         EQU     5

FileInfoCmd     EQU     1       ; Menu 5
UnitInfoCmd     EQU     2

StartVpos               EQU     48
StartHpos               EQU     32
Vincrement      EQU     20
Hincrement      EQU     6
NrRows          EQU     8
NrColumns               EQU     64
AboveLine               EQU     12
InfoLine                EQU     230

HexVInc         EQU     12
HexHInc         EQU     6
HexTopPoint     EQU     16
HexLeftPoint    EQU     68
HexRightPoint   EQU     308
HexNrColumns    EQU     16
HexAboveLine    EQU     9
HexP2Start      EQU     10
HexP2Index      EQU     160
Hex2Part                EQU     326

srcCopy         EQU     0
srcOr           EQU     1
srcXor          EQU     2
srcBic          EQU     3

v               EQU     0       ; vertical coordinate [word]
h               EQU     2       ; horizontal coordinate [word]

topLeft         EQU     0       ; upper left corner [point]
botRight                EQU     4       ; lower right corner [point]
top             EQU     0       ; top coordinate [word]
left            EQU     2       ; left coordinate [word]
bottom          EQU     4       ; bottom coordinate [word]
right           EQU     6       ; right coordinate [word]

PortRect                EQU     $10     ; offset to port's rectangle [rect]

TagData         EQU     $02FA

VCBCrDate               EQU     10      ; Creation date.
VCBLsBkUp               EQU     14      ; last backup date
VCBAtrb         EQU     18      ; volume attributes. bit 15 = vol lock (1=locked)
VCBNmFls                EQU     20      ; number files in dir  (low byte)
VCBDirSt                EQU     22      ; start dir (512-byte) block on diskette
VCBBlLn         EQU     24      ; length of dir in (512-byte) blocks
VCBNmBlks               EQU     26      ; number of blocks (of alloc size) this device
VCBNmAlBlks     EQU     26      ; (alternate label for a while)
VCBAlBlkSiz     EQU     28      ; num of bytes in an allocation block
VCBClpSiz               EQU     32      ; num of bytes to try to alloc as a clump
VCBAlBlSt               EQU     36      ; starting diskette (512-byte) block in block map
VCBNxtFNum      EQU     38      ; next free file number
VCBFreeBks      EQU     42      ; number of free blocks on this volume
VCBVN           EQU     44      ; volume name (including name length byte)

VCBDrvNum               EQU     72      ; drive number for this VCB
VCBDRefNum      EQU     74      ; driver refnum for this VCB
VCBFSID         EQU     76      ; ID of file system handling this volume
VCBVRefNum      EQU     78      ; unique refnum for this VCB
VCBMAdr         EQU     80      ; volume map address
VCBBufAdr               EQU     84      ; volume buffer address
VCBMLen         EQU     88      ; length of volume map

VCBDirIndex     EQU     90      ; directory index, block number used for
VCBDirBlk               EQU     92      ; GetFileInfo searches by index

ioResult                EQU     $10     ; I/O result code [word]
ioFileName      EQU     $12     ; file name pointer [pointer]
ioVRefNum               EQU     $16     ; volume refnum [word]
ioDrvNum                EQU     $16     ; drive number [word]
ioRefNum                EQU     $18     ; file reference number [word]

ioFileType      EQU     $1A     ; specified along with FileName [byte]

; specific fields for _Read, _Write

ioBuffer                EQU     $20     ; data buffer [pointer]
ioByteCount     EQU     $24     ; requested byte count [long]

ioPosMode               EQU     $2C     ; initial file positioning mode/eol char [word]
ioPosOffset     EQU     $2E     ; file position offset [long]

; specific fields for  _GetFileInfo, _SetFileInfo

ioFDirIndex     EQU     $1C     ; directory index of file [word]
ioFlAttrib      EQU     $1E     ; in-use bit=7, lock bit=0 [byte]
ioFFlType               EQU     $1F     ; file type [byte]
ioFlUsrWds      EQU     $20     ; finder info [16 bytes]
ioFFlNum                EQU     $30     ; file number [long]

ioFlStBlk               EQU     $34     ; start file block (0000 if none) [word]
ioFlLgLen               EQU     $36     ; logical length (EOF) [long]
ioFlPyLen               EQU     $3A     ; physical length in bytes [long]
ioFlRStBlk      EQU     $3E     ; resource fork's start file block [word]
ioFlRLgLen      EQU     $40     ; resource fork's logical length (EOF) [long]
ioFlRPyLen      EQU     $44     ; resource fork's physical length [long]

ioFlCrDat               EQU     $48     ; creation date & time [long]
ioFlMdDat               EQU     $4C     ; last modification date & time [long]

; Specific fields for _GetEOF, _SetEOF

ioLEOF          EQU     $1C     ; logical end-of-file [long]

MonacoFont      EQU     4       ; Font definition

IOPBLength      EQU     80      ; Length of I/O parameter block

AbsBlkNumber    DS.W    1
AlBlkSize               DS.W    1
AlBlkOffset     DS.W    1
BlockNumber     DS.W    1
ChangeMade      DS.W    1
Count           DS.W    1
DlogHdl         DS.L    1
DisplayMode     DS.W    1
DriveNumber     DS.W    1
DriverRef               DS.W    1
FirstAlBlk      DS.W    1
Fork            DS.W    1
HexColumn               DS.W    1
HexlitPosition  DS.L    1
HScroll         DS.L    1
HexStartLine    DS.W    1
InModify                DS.W    1
ItemHit         DS.W    1
LEOFBlock               DS.W    1
LEOFPosition    DS.W    1
Marker          DS.W    1
MaxBlockNr      DS.W    1
ModifyProc      DS.L    1
NextTick                DS.L    1
Position                DS.L    1
PosPosition     DS.L    1
TempHdl         DS.L    1
TempWord                DS.W    1
UnitMode                DS.W    1
VCBPtr          DS.L    1
VolMapAdr               DS.L    1
VP              DS.W    1
VScroll         DS.L    1
WindFlag                DS.W    1

IOPB            DS.B    IOPBLength
FIOPB           DS.B    IOPBLength
IOBuff          DS.B    512
DispBuffer      DS.B    512
SaveBuffer      DS.B    512
OutString               DS.B    40

DlogStore               DS.W    170
WindStore               DS.W    156
DataRect                DS.W    4
MarkRect                DS.W    4
TempRect                DS.W    4

CHandle         DC.L    0
WWindow         DC.L    0

DeskName                DCB.B   16,0
MenuHandle      DCB.L   MenuCount+2,0

DragRect                DC.W    24,4,338,508
SizeRect                DC.W    40,40,342,512
WindRect                DC.W    40,20,328,490

Event
What            DC.W    0
Message         DC.L    0
When            DC.L    0
Point           DC.L    0
Modify          DC.W    0

SFRecord
rGood           DC.B    0
rCopy           DC.B    0
rType           DC.L    0
rVolume         DC.W    0
rVersion                DC.W    0
rName           DCB.B   66,0

MACRO   PushMenu        MenuNr =
        MOVE.L  MenuHandle+{MenuNr}*4,-(SP)|

MACRO   PushItem        MenuNr,ItemNr =
        PushMenu        {MenuNr}
        MOVE    #{ItemNr},-(SP)|

ShowAlert:
        CLR     -(SP)
        MOVE    D0,-(SP)
        CLR.L   -(SP)
        _Alert                  ; Put alert box on screen
        MOVE    (SP)+,D0
        RTS

ExitModify:
        TST     InModify(A5)    ; Are we modifying?
        BEQ     @1              ; No, exit
        MOVE    #5,D0           ; Yes, remove the menu bar item
        ADD     InModify(A5),D0
        MOVE    D0,-(SP)
        _DeleteMenu
        _DrawMenuBar
        
        PushMenu        3               ; Push pointer to menu 3
        MOVE    #AModCmd-1,D0
        ADD     InModify(A5),D0
        MOVE    D0,-(SP)
        CLR     -(SP)
        _CheckItem              ; Remove the check mark
        
        CLR     InModify(A5)    ; Clear the modify flag
        
@1      RTS

WaitAcknowledge:                        ; Wait for mouse button or key
        _SystemTask             ; Perform desk access updates
~r        CLR     -(SP)
        MOVE    #$000B,-(SP)    ; Key & mouse down, null mask
        PEA     Event
        _GetNextEvent           ; Get next event
        MOVE    (SP)+,D0
        BEQ     WaitAcknowledge ; Ignore null events
        RTS

ClearIOPB:
        LEA     IOPB(A5),A0     ; Zero out the IO parameter block

ClearIOPBLoop:
        MOVE.L  A0,-(SP)
        MOVEQ   #IOPBLength/2-1,D0

@1      CLR     (A0)+
        DBRA    D0,@1
        MOVE.L  (SP)+,A0                ; Leave A0 pointing at param block
        RTS

ClearFIOPB:
        LEA     FIOPB(A5),A0
        JMP     ClearIOPBLoop

HexConvert:
        AND     #$0F,D1         ; Convert a hex char to ASCII
        CMP     #10,D1
        BGE     @1
        ADD     #'0',D1
        RTS

@1      ADD     #'A'-10,D1
        RTS

MoveHex:
        MOVE    D0,D1           ; Convert a hex char to ASCII
        LSR     D2,D1           ; and put it in Outstring
        JSR     HexConvert
        MOVE.B  D1,(A0)+
        SUB     #4,D2
        BPL     MoveHex
        MOVE.B  #' ',(A0)+
        RTS

CharToHex:
        LEA     OutString(A5),A0        ; Convert 8 bit char to hex
        MOVE.B  #3,(A0)+
        MOVE    #4,D2
        JMP     MoveHex

WordToHex:
        LEA     OutString(A5),A0        ; Convert 16 bit word to hex
        MOVE.B  #5,(A0)+
        MOVE    #12,D2
        JMP     MoveHex

CopyPortRect:
        LEA     PortRect(A4),A0 ; A4 always holds a pointer
        LEA     TempRect(A5),A1 ; to the current window
        MOVE.L  (A0)+,(A1)+
        MOVE.L  (A0)+,(A1)+
        LEA     TempRect(A5),A1
        RTS

MakeCtlsInvalid:        
        JSR     CopyPortRect    ; Mark scroll bar areas
        MOVE    Bottom(A1),Top(A1)      ; for update
        SUB     #16,Top(A1)
        PEA     TempRect(A5)
        _InvalRect              ; Vertical scroll bar
        
        JSR     CopyPortRect
        MOVE    Right(A1),Left(A1)
        SUB     #16,Left(A1)
        SUB     #16,Bottom(A1)
        PEA     TempRect(A5)
        _InvalRect              ; Horizontal scroll bar
        
        RTS

EraseGrowIcon:
        LEA     TempRect(A5),A1 ; Not really needed, but it
        MOVE.L  VScroll(A5),A0  ; makes a screen resize from
        MOVE.L  (A0),A0         ; small to large look better
        MOVE    8+Right(A0),Right(A1)
        MOVE    8+Left(A0),Left(A1)
        MOVE.L  HScroll(A5),A0
        MOVE.L  (A0),A0
        MOVE    8+Top(A0),Top(A1)
        MOVE    8+Bottom(A0),Bottom(A1)
        MOVE.L  A1,-(SP)
        _EraseRect
        RTS

MoveScrollBars:
        MOVE.L  HScroll(A5),-(SP)       ; Remove the controls
        _HideControl

        MOVE.L  VScroll(A5),-(SP)
        _HideControl

        JSR     EraseGrowIcon

        MOVE.L  HScroll(A5),-(SP)       ; Move HScroll control
        MOVE    PortRect+Left(A4),D0
        SUB     #1,D0
        MOVE    D0,-(SP)
        MOVE    PortRect+Bottom(A4),D0
        SUB     #15,D0
        MOVE    D0,-(SP)
        _MoveControl
        
        MOVE.L  HScroll(A5),-(SP)       ; Redo the thumb position
        MOVE    PortRect+Right(A4),D0
        SUB     PortRect+Left(A4),D0
        SUB     #13,D0
        MOVE    D0,-(SP)
        MOVE    #16,-(SP)
        _SizeControl
        
        MOVE.L  VScroll(A5),-(SP)       ; Move VScroll control
        MOVE    PortRect+Right(A4),D0
        SUB     #15,D0
        MOVE    D0,-(SP)
        MOVE    PortRect+Top(A4),D0
        SUB     #1,D0
        MOVE    D0,-(SP)
        _MoveControl
        
        MOVE.L  VScroll(A5),-(SP)       ; Redo the thumb position
        MOVE    #16,-(SP)
        MOVE    PortRect+Bottom(A4),D0
        SUB     PortRect+Top(A4),D0
        SUB     #13,D0
        MOVE    D0,-(SP)
        _SizeControl
        
        MOVE.L  HScroll(A5),-(SP)       ; Redraw controls
        _ShowControl

        MOVE.L  VScroll(A5),-(SP)
        _ShowControl
        
        MOVE.L  A4,-(SP)
        _DrawGrowIcon

        RTS

CloseWindow:
        TST     WindFlag(A5)    ; Test for open window
        BEQ     @1              ; Exit if not there
        
        CLR     WindFlag(A5)    ; Clear flags
        CLR.L   NextTick(A5)
        JSR     ExitModify      ; Exit modify cmd

        MOVE.L  A4,-(SP)                ; A4 = Current window
        _CloseWindow
        
        PushItem        4,ResForkCmd    ; Uncheck items
        CLR     -(SP)
        _CheckItem
        
        PushItem        4,DataForkCmd
        CLR     -(SP)
        _CheckItem
        
        PushItem        2,CloseCmd      ; Disable menu commands
        _DisableItem
        
        PushItem        3,0
        _DisableItem
        
        PushItem        4,ResForkCmd
        _DisableItem
        
        PushItem        4,DataForkCmd
        _DisableItem
        
        PushItem        5,FileInfoCmd
        _DisableItem
        
        PushItem        5,UnitInfoCmd
        _DisableItem
        
@1      RTS

OpenWindow:
        JSR     CloseWindow     ; Close any open window
        MOVE    #-1,WindFlag(A5)
        
        CLR.L   -(SP)           ; Make a new window
        PEA     WindStore(A5)
        PEA     WindRect
        PEA     rName
        MOVE    #-1,-(SP)
        MOVE    #0,-(SP)
        MOVE.L  #-1,-(SP)
        MOVE    #-1,-(SP)
        CLR.L   -(SP)
        _NewWindow
        
        MOVE.L  (SP),A4         ; Make new window current
        _SetPort

        MOVE    #MonacoFont,-(SP)       ; Set Font type
        _TextFont

        MOVE    #9,-(SP)                ; Set Font size in points
        _TextSize
        
        CLR.L   -(SP)           ; Setup vertical scroll bar
        MOVE.L  A4,-(SP)
        JSR     CopyPortRect
        ADD     #1,Right(A1)
        MOVE    Right(A1),D0
        SUB     #16,D0
        MOVE    D0,Left(A1)
        SUB     #14,Bottom(A1)
        SUB     #1,Top(A1)
        PEA     TempRect(A5)
        CLR.L   -(SP)
        MOVE    #-1,-(SP)
        MOVE    #0,-(SP)
        MOVE    #0,-(SP)
        MOVE    #1,-(SP)
        MOVE    #16,-(SP)
        CLR.L   -(SP)
        _NewControl
        MOVE.L  (SP)+,VScroll(A5)

        
        CLR.L   -(SP)           ; Setup Horizontal scroll bar
        MOVE.L  A4,-(SP)
        JSR     CopyPortRect
        ADD     #1,Bottom(A1)
        MOVE    Bottom(A1),D0
        SUB     #16,D0
        MOVE    D0,Top(A1)
        SUB     #14,Right(A1)
        SUB     #1,Left(A1)
        PEA     TempRect(A5)
        CLR.L   -(SP)
        MOVE    #-1,-(SP)
        MOVE    #0,-(SP)
        MOVE    #0,-(SP)
        MOVE    MaxBlockNr(A5),-(SP)
        MOVE    #16,-(SP)
        CLR.L   -(SP)
        _NewControl
        MOVE.L  (SP)+,HScroll(A5)
        
        LEA     PortRect(A4),A0 ; Copy the port rectangle
        LEA     DataRect(A5),A1
        MOVE.L  (A0)+,(A1)+
        MOVE.L  (A0)+,(A1)+

        LEA     DataRect(A5),A1 ; Make smaller to put
        SUB     #15,Right(A1)   ; controls outside it
        SUB     #15,Bottom(A1)
        
        PushItem        3,0             ; Enable menu 3
        _EnableItem

        PushItem        2,CloseCmd      ; Enable close command
        _EnableItem
        
        TST     UnitMode(A5)    ; Test for file or
        BNE     @1              ; unit mode

        PushItem        4,ResForkCmd    ; File mode items only  
        _EnableItem
        
        PushItem        4,DataForkCmd
        _EnableItem

        PushItem        5,FileInfoCmd
        _EnableItem

        PushMenu        4
        MOVE    Fork(A5),-(SP)
        MOVE    #-1,-(SP)
        _CheckItem

@1      PushItem        5,UnitInfoCmd   ; Enable unit info cmd
        _EnableItem

        CLR     HexStartLine(A5)
        TST     DisplayMode(A5) ; Is it Ascii display
        BEQ     @2              ; No, Hex so exit
        
        MOVE.L  VScroll(A5),-(SP)       ; Yes, make vertical
        MOVE    #255,-(SP)      ; control inactive
        _HiliteControl
        
@2      RTS

ScnLoctoPos:
        LEA     Point,A0                ; Take an ASCII screen location
        MOVE    V(A0),D3                ; and discover which character (if
        SUB     #StartVpos,D3   ; (if any) it's pointing at
        ADD     #AboveLine,D3
        BMI     @1
        EXT.L   D3
        DIVU    #Vincrement,D3
        CMP     #NrRows-1,D3
        BHI     @1
        LSL     #6,D3
        
        MOVE    H(A0),D1
        SUB     #StartHpos,D1
        BMI     @1
        EXT.L   D1
        DIVU    #Hincrement,D1
        CMP     #NrColumns-1,D1
        BHI     @1
        ADD     D1,D3
        RTS

@1      MOVE    #-1,D3
        RTS

HScnLoctoPos:
        LEA     Point,A0                ; Take an Hex screen location
        MOVE    V(A0),D3                ; and derive the character
        SUB     #HexTopPoint,D3 ; index into the block
        ADD     #HexAboveLine,D3
        BMI     @9
        EXT.L   D3
        DIVU    #HexVInc,D3
        MULU    #HexNrColumns*2,D3
        TST     HexStartLine(A5)
        BEQ     @1
        ADD     #HexP2Index*2,D3
        BRA     @2

@1      SUB     #HexNrColumns*4,D3
        BMI     @9

@2      MOVE    H(A0),D1
        CMP     #HexRightPoint,D1
        BHI     @9
        SUB     #HexLeftPoint,D1
        BMI     @9
        EXT.L   D1
        DIVU    #HexHInc,D1
        MOVE    D1,D0
        ADD     #1,D0
        EXT.L   D0
        DIVU    #5,D0
        SUB     D0,D1
        ADD     D1,D3
        CMP     #1023,D3
        BHI     @9
        RTS

@9      MOVE    #-1,D3
        RTS

PostoScnLoc:
        MOVE    Marker(A5),D0   ; Convert ASCII marker position
        EXT.L   D0              ; to actual character location
        DIVU    #NrColumns,D0   ; on the screen
        MOVE    D0,D1
        MULU    #Vincrement,D1
        ADD     #StartVpos,D1
        
        SWAP    D0
        EXT.L   D0
        MULU    #Hincrement,D0
        ADD     #StartHpos,D0
        RTS

HPostoScnLoc:
        MOVE    Marker(A5),D0   ; Convert Hex marker position
        TST     HexStartLine(A5)        ; to actual character location
        BEQ     @1              ; on the screen
        SUB     #HexP2Index*2,D0
        BRA     @2

@1      ADD     #HexNrColumns*4,D0

@2      EXT.L   D0
        DIVU    #HexNrColumns*2,D0
        MOVE    D0,D1
        MULU    #HexVinc,D1
        ADD     #HexTopPoint,D1
        
        SWAP    D0
        MOVE    D0,HexColumn(A5)
        MOVE    D0,D2
        LSR     #2,D2
        ADD     D2,D0
        MULU    #HexHInc,D0
        ADD     #HexLeftPoint,D0
        RTS

PutMark:
        JSR     PostoScnLoc     ; Calc char screen location
        LEA     MarkRect(A5),A2 ; Calc box position under it
        ADD     #3,D1
        MOVE    D1,Top(A2)
        ADD     #3,D1
        MOVE    D1,Bottom(A2)
        MOVE    D0,Left(A2)
        ADD     #Hincrement-1,D0
        MOVE    D0,Right(A2)

        CLR     -(SP)           ; Get intersection of DataRect
        PEA     DataRect(A5)    ; and MarkRect in case the mark
        PEA     MarkRect(A5)    ; box is at the edge of draw area
        PEA     MarkRect(A5)
        _SectRect
        MOVE    (SP)+,D0

        PEA     MarkRect(A5)    ; Paint box black
        _PaintRect
        
        CLR.L   -(SP)           ; Set time to invert the box
        _TickCount
        MOVE.L  (SP)+,NextTick(A5)
        ADD.L   #20,NextTick(A5)
        RTS
        
DeleteMark:
        TST.L   NextTick(A5)    ; Change marker box to white
        BEQ     @1
        PEA     MarkRect(A5)
        _EraseRect
        CLR.L   NextTick(A5)
        
@1      RTS

HexInvert:
        JSR     HPostoScnLoc    ; Calculate hex character box
        LEA     MarkRect(A5),A2
        SUB     #9,D1
        MOVE    D1,Top(A2)
        ADD     #11,D1
        MOVE    D1,Bottom(A2)
        SUB     #1,D0
        MOVE    D0,Left(A2)
        ADD     #HexHInc+1,D0
        MOVE    D0,Right(A2)
        
        MOVE.L  A2,-(SP)                ; Invert character box on screen
        _InverRect
        
        RTS
        
HexNormal:
        PEA     MarkRect(A5)    ; Remove inverted box
        _InverRect

        RTS

ModifyBlockA:
        MOVE.L  Message,D3      ; Character code in bottom byte

ModifyBlock:
        LEA     IOBuff(A5),A0
        ADD     Marker(A5),A0
        MOVE.B  D3,(A0)         ; Update I/O buffer

        LEA     DispBuffer(A5),A0
        ADD     Marker(A5),A0
        CMP.B   #$1F,D3
        BLS     @1
        CMP.B   #$7E,D3
        BLS     @2
@1      MOVE.B  #'.',D3
@2      MOVE.B  D3,(A0)         ; Update display buffer

        LEA     MarkRect(A5),A0
        SUB     #Vincrement,Top(A0)
        ADD     #1,Right(A0)
        JSR     DeleteMark      ; Remove mark under character

        JSR     PostoScnLoc     ; Draw char on screen

        MOVE    D0,-(SP)
        MOVE    D1,-(SP)
        _MoveTo

        MOVE    D3,-(SP)
        _DrawChar

        MOVE    #1,ChangeMade(A5)       ; Mark block as modified

        PushItem        3,DiscardCmd    ; Enable discard cmd
        _EnableItem

        PushItem        3,WBlockCmd     ; Enable write block cmd
        _EnableItem

        ADD     #1,Marker(A5)   ; Increment mark position
        MOVE    #$01FF,D0
        AND     D0,Marker(A5)

        JSR     PutMark         ; Put new mark on screen
        JMP     ShowPosition    ; and update info line

GetNextKey:
        _SystemTask             ; Perform desk access updates
        JSR     Ticker
        CLR     -(SP)
        MOVE    #$0029,-(SP)    ; Key down and null mask
        PEA     Event
        _GetNextEvent           ; Get next event
        MOVE    (SP)+,D0
        BEQ     GetNextkey      ; Ignore null events
        MOVE    Modify,D0
        BTST    #8,D0           ; Ignore command keys
        BNE     GetNextKey
        RTS

BlankHexArea:
        MOVE    #srcCopy,-(SP)  ; Blank out the place to
        _TextMode                       ; put a hex literal
        
        MOVE.L  HexlitPosition(A5),-(SP)
        _MoveTo

        MOVE    #' ',-(SP)
        _DrawChar

        MOVE    #srcOr,-(SP)
        _TextMode
        
        MOVE.L  HexlitPosition(A5),-(SP)
        _MoveTo

        RTS

GetHexChar:
        MOVE.L  Message,D4      ; Get a key press and convert
        AND     #$00FF,D4               ; to hex (in D3).  Leave 
        MOVE    D4,D3           ; original in D4.
        CMP.B   #'0'-1,D4
        BLS     @1
        CMP.B   #'9',D4
        BHI     @2
        SUB.B   #'0',D3
        RTS

@1      MOVE    #-1,D3          ; Return if not hex vhar
        RTS

@2      CMP.B   #'A'-1,D4
        BLS     @1
        CMP.B   #'F',D4
        BHI     @3
        SUB.B   #'A'-10,D3
        RTS

@3      CMP.B   #'a'-1,D4
        BLS     @1
        CMP.B   #'f',D4
        BHI     @1
        SUB.B   #'a'-10,D3
        SUB.B   #$20,D4         ; Upcase
        RTS

ModifyBlockH:
        TST     DisplayMode(A5) ; Hex modify - test mode
        BEQ     ModifyBlockHH   ; Branch if not ASCII

        JSR     GetHexChar      ; Get keyboard char
        TST     D3              ; D3 negative if not hex
        BMI     ShowPosition

        MOVE    D3,D5           ; Save for later
        LSL     #4,D5           

        JSR     BlankHexArea    ; Blank hex display area

        MOVE    D4,-(SP)
        _DrawChar                       ; Draw the character
        
        JSR     GetNextKey      ; Get next character
        MOVE.L  Message,D0
        CMP.B   #8,D0           ; Test for backspace
        BEQ     @1              ; Yes, remove last char
        
        JSR     GetHexChar      ; Test for hex char
        TST     D3              ; Branch if not
        BMI     ShowPosition
        
        OR      D5,D3   
        JMP     ModifyBlock     ; Go do the block modify

@1      JSR     BlankHexArea    ; Handle backspace
        JMP     ModifyBlockH

ModifyBlockHH:
        JSR     GetHexChar      ; Hex modify, hex display
        TST     D3              ; Test char for hex
        BMI     @5              ; exit if not

        PEA     DataRect(A5)    ; Borderline case
        _ClipRect

        LEA     IOBuff(A5),A0   ; Modify the block
        MOVE    Marker(A5),D0
        LSR     #1,D0
        ADD     D0,A0
        MOVE.B  (A0),D2
        MOVE    Marker(A5),D1
        BTST    #0,D1
        BNE     @1

        AND.B   #$0F,D2
        LSL.B   #4,D3
        BRA     @2

@1      AND.B   #$F0,D2
        AND.B   #$0F,D3

@2      OR.B    D3,D2
        MOVE.B  D2,(A0)

        LEA     DispBuffer(A5),A0
        ADD     D0,A0
        CMP.B   #$1F,D2
        BLS     @3
        CMP.B   #$7E,D2
        BLS     @4
@3      MOVE.B  #'.',D2
@4      MOVE.B  D2,(A0)
        MOVE    D2,Tempword(A5)

        PEA     MarkRect(A5)    ; Erase old character
        _EraseRect

        JSR     HPostoScnLoc    ; Write the new one

        MOVE    D0,-(SP)
        MOVE    D1,-(SP)
        _MoveTo

        MOVE    D4,-(SP)
        _DrawChar

        LEA     MarkRect(A5),A1 ; Calculate position on
        MOVE    HexColumn(A5),D0        ; ASCII side of screen
        LSR     #1,D0
        MULU    #HexHInc,D0
        ADD     #Hex2Part,D0
        MOVE    D0,Left(A1)
        ADD     #HexHInc,D0
        MOVE    D0,Right(A1)

        MOVE.L  A1,-(SP)                ; Erase old ASCII character
        _EraseRect

        LEA     MarkRect(A5),A1 ; Draw new one
        MOVE    Left(A1),-(SP)
        MOVE    Bottom(A1),D0
        SUB     #2,D0
        MOVE    D0,-(SP)
        _MoveTo
        
        MOVE    TempWord(A5),-(SP)
        _DrawChar

        MOVE    #1,ChangeMade(A5)       ; Mark block as modified

        PushItem        3,DiscardCmd    ; Enable discard cmd
        _EnableItem

        PushItem        3,WBlockCmd     ; Enable write block cmd
        _EnableItem

        ADD     #1,Marker(A5)   ; Increment mark position
        MOVE    #$03FF,D0
        AND     D0,Marker(A5)

        JSR     HexInvert               ; Invert marked character

        PEA     PortRect(A4)
        _ClipRect

@5      RTS

DisplayAscii:                   ; Display block in ASCII
        MOVE    BlockNumber(A5),D0      ; Is LEOF in this block?
        CMP     LEOFBlock(A5),D0
        BNE     @0              ; No, branch forward
        
        MOVE    #StartHpos,-(SP)        ; Tell user
        MOVE    #24,-(SP)
        _MoveTo
        
        CLR.L   -(SP)
        MOVE    #260,-(SP)      ; Says "Logical EOF..."
        _GetString
        
        MOVE.L  (SP),A0
        MOVE.L  (A0),(SP)
        _DrawString

        MOVE    #' ',-(SP)
        _DrawChar

        LEA     OutString(A5),A0
        MOVE    LEOFPosition(A5),D0
        EXT.L   D0
        CLR     -(SP)
        _Pack7                  ; NumToString

        MOVE.L  A0,-(SP)
        _DrawString
        
        MOVE    #' ',-(SP)
        _DrawChar

        CLR.L   -(SP)
        MOVE    #261,-(SP)      ; Says "in this block"
        _GetString
        
        MOVE.L  (SP),A0
        MOVE.L  (A0),(SP)
        _DrawString

@0      CLR     D3              ; Row Counter
        MOVE    #StartVpos,D4   ; Row baseline
        CLR     D5              ; Index into block
        
@1      MOVE    #StartHpos,-(SP)
        MOVE    D4,-(SP)
        _MoveTo
        
        PEA     DispBuffer(A5)
        MOVE    D5,-(SP)
        MOVE    #NrColumns,-(SP)
        _DrawText
        
        ADD     #NrColumns,D5
        ADD     #Vincrement,D4
        ADD     #1,D3
        CMP     #NrRows,D3
        BNE     @1
        
        JSR     PutMark         ; Mark current character

        MOVE    #srcCopy,-(SP)
        _TextMode
        
        MOVE    #StartHpos,-(SP)
        MOVE    #InfoLine,D4
        MOVE    D4,-(SP)
        _MoveTo

        CLR.L   -(SP)
        MOVE    #257,-(SP)      ; Says "Hex:"
        _GetString
        
        MOVE.L  (SP),A0
        MOVE.L  (A0),(SP)
        _DrawString

        MOVE    #' ',-(SP)
        _DrawChar

        PEA     HexlitPosition(A5)
        _GetPen

        LEA     IOBuff(A5),A0
        ADD     Marker(A5),A0
        MOVE.B  (A0),D0
        JSR     CharToHex
        
        PEA     OutString(A5)
        _DrawString
        
        MOVE    #180,-(SP)
        MOVE    D4,-(SP)
        _MoveTo
        
        CLR.L   -(SP)
        MOVE    #258,-(SP)      ; Says "Position:"
        _GetString
        
        MOVE.L  (SP),A0
        MOVE.L  (A0),(SP)
        _DrawString

        MOVE    #' ',-(SP)
        _DrawChar

        PEA     PosPosition(A5)
        _GetPen

        LEA     OutString(A5),A0
        MOVE    Marker(A5),D0
        EXT.L   D0
        CLR     -(SP)
        _Pack7                  ; NumToString
        
        MOVE.L  A0,-(SP)
        _DrawString
        
        MOVE    #360,-(SP)
        MOVE    D4,-(SP)
        _MoveTo

        CLR.L   -(SP)
        MOVE    #259,-(SP)      ; Says "Block:"
        _GetString
        
        MOVE.L  (SP),A0
        MOVE.L  (A0),(SP)
        _DrawString

        MOVE    #' ',-(SP)
        _DrawChar

        LEA     OutString(A5),A0
        MOVE    BlockNumber(A5),D0
        EXT.L   D0
        CLR     -(SP)
        _Pack7                  ; NumToString
        
        MOVE.L  A0,-(SP)
        _DrawString
        
        MOVE    #srcOr,-(SP)
        _TextMode
        
        RTS

ShowPosition:
        PEA     DataRect(A5)    ; Update the ASCII display
        _ClipRect                       ; for changed position

        MOVE    #srcCopy,-(SP)
        _TextMode
        
        MOVE.L  HexlitPosition(A5),-(SP)
        _MoveTo

        LEA     IOBuff(A5),A0
        ADD     Marker(A5),A0
        MOVE.B  (A0),D0
        JSR     CharToHex
        
        PEA     OutString(A5)
        _DrawString
        
        MOVE.L  PosPosition(A5),-(SP)
        _MoveTo
        
        LEA     OutString(A5),A0
        MOVE    Marker(A5),D0
        EXT.L   D0
        CLR     -(SP)
        _Pack7                  ; NumToString
        
        MOVE.L  A0,-(SP)
        _DrawString
        
        MOVE    #srcOr,-(SP)
        _TextMode
        
        PEA     PortRect(A4)
        _ClipRect

        RTS

DisplayTags:                    ; Display tags on hex screen
        PEA     'Tags: '
        _DrawString

        LEA     TagData+2,A2
        MOVE    #5,D6
        
@1      MOVE    (A2)+,D0
        JSR     WordtoHex
        PEA     OutString(A5)
        _DrawString
        
        DBRA    D6,@1
        RTS

DisplayHex:
        MOVE    #HexTopPoint,D4 ; Row baseline

        TST     HexStartLine(A5)
        BNE     @2

        MOVE    #StartHPos,-(SP)
        MOVE    D4,-(SP)
        _MoveTo

        PEA     'Blk : '
        _DrawString

        MOVE    BlockNumber(A5),D0
        JSR     WordToHex
        PEA     OutString(A5)
        _DrawString

        MOVE    BlockNumber(A5),D0
        CMP     LEOFBlock(A5),D0
        BNE     @1
        
        MOVE    #30,-(SP)
        CLR     -(SP)
        _Move
        
        CLR.L   -(SP)
        MOVE    #260,-(SP)      ; Says "Logical EOF..."
        _GetString
        
        MOVE.L  (SP),A0
        MOVE.L  (A0),(SP)
        _DrawString

        MOVE    #' ',-(SP)
        _DrawChar

        MOVE    LEOFPosition(A5),D0
        JSR     WordToHex
        PEA     OutString(A5)
        _DrawString

        CLR.L   -(SP)
        MOVE    #261,-(SP)      ; Says "in this block"
        _GetString
        
        MOVE.L  (SP),A0
        MOVE.L  (A0),(SP)
        _DrawString

@1      MOVE    #StartHPos,-(SP)
        ADD     #HexVInc,D4
        MOVE    D4,-(SP)
        _MoveTo

        JSR     DisplayTags

        ADD     #HexVinc,D4

@2      MOVE    HexStartLine(A5),D5
        LSL     #4,D5           ; Index into block
        LEA     IOBuff(A5),A2
        ADD     D5,A2
        
        MOVE    D4,D3
        SWAP    D3
        MOVE    #StartHpos,D3
        
@3      MOVE.L  D3,-(SP)
        _MoveTo
        
        MOVE    D5,D0
        JSR     WordToHex
        LEA     OutString(A5),A0
        MOVE.B  #4,(A0)
        MOVE.L  A0,-(SP)
        _DrawString
        
        PEA     ': '
        _DrawString
        
        MOVE    #7,D6
        
@4      MOVE    (A2)+,D0
        JSR     WordtoHex
        PEA     OutString(A5)
        _DrawString
        
        DBRA    D6,@4
        
        MOVE    #18,-(SP)
        CLR     -(SP)
        _Move
        
        PEA     DispBuffer(A5)
        MOVE    D5,-(SP)
        MOVE    #HexNrColumns,-(SP)
        _DrawText
        
        ADD     #HexVInc,D4
        ADD     #HexNrColumns,D5

        CMP     #511,D5
        BHI     @5
        
        MOVE    D4,D3
        SWAP    D3
        MOVE    #StartHpos,D3

        CLR     -(SP)
        MOVE.L  D3,-(SP)
        PEA     PortRect(A4)
        _PtInRect
        MOVE    (SP)+,D0
        BTST    #8,D0
        BNE     @3

@5      JSR     HexInvert               ; Invert marked character
        RTS

DisplayBlock:
        PEA     DataRect(A5)    ; Routine to display one
        _ClipRect                       ; block of data

        PEA     DataRect(A5)
        _EraseRect
        
        TST     DisplayMode(A5)
        BNE     @1

        JSR     DisplayHex
        BRA     @2
        
@1      JSR     DisplayAscii

@2      PEA     PortRect(A4)
        _ClipRect
        
        PEA     PortRect(A4)
        _ValidRect
        
        RTS

ChangePos:
        CLR     -(SP)           ; Change current character
        MOVE.L  Point,-(SP)     ; pointer by mouse click
        PEA     DataRect(A5)
        _PtInRect
        MOVE    (SP)+,D0
        BTST    #8,D0
        BEQ     @1              ; Exit if not in data area

        TST     DisplayMode(A5) ; Branch if hex display screen
        BEQ     HexChangePos

        JSR     ScnLoctoPos     ; Convert screen location
        TST     D3              ; to position, or -1
        BMI     @1              ; if cursor not on character

        PEA     DataRect(A5)
        _ClipRect

        JSR     DeleteMark      ; Delete old marker boc
        MOVE    D3,Marker(A5)
        JSR     PutMark         ; Draw a new one
        JMP     ShowPosition    ; Update information line

@1      RTS

HexChangePos:
        JSR     HScnLoctoPos    ; Convert mouse posn to char
        TST     D3
        BMI     @1              ; Exit if not pointing at char

        PEA     DataRect(A5)
        _ClipRect

        JSR     HexNormal               ; Remove invertion on last char
        MOVE    D3,Marker(A5)   ; Set new position
        JSR     HexInvert               ; Invert new marked character

        PEA     PortRect(A4)
        _ClipRect

@1      RTS

FindNextAlBlk:
        MOVE.L  VolMapAdr(A5),A0        ; Read Volume allocation map
        SUB     #2,D0           ; to determine next allocation
        LSR     #1,D0           ; block for the file
        BCC     @2

        MULU    #3,D0
        BTST.B  #0,D0
        BEQ     @1

        ADD     #1,D0
        ADD     D0,A0
        MOVE    (A0),D0
        AND     #$0FFF,D0
        RTS

@1      ADD     D0,A0
        MOVE.L  (A0),D0
        MOVE    #8,D1
        LSR.L   D1,D0
        AND     #$0FFF,D0
        RTS

@2      MULU    #3,D0
        BTST.B  #0,D0
        BEQ     @3

        SUB     #1,D0
        ADD     D0,A0
        MOVE.L  (A0),D0
        MOVE    #12,D1
        LSR.L   D1,D0
        AND     #$0FFF,D0
        RTS

@3      ADD     D0,A0
        MOVE    (A0),D0
        LSR     #4,D0
        RTS

ConvertBlkNr:                   ; Convert a relative blocknumber
        TST     UnitMode(A5)    ; to an absolute block on disk
        BEQ     @1
        MOVE    BlockNumber(A5),AbsBlkNumber(A5)
        RTS

@1      MOVE    BlockNumber(A5),D2
        EXT.L   D2
        DIVU    AlBlkSize(A5),D2
        
        MOVE    FirstAlBlk(A5),D0
        CLR     D3

@2      CMP     D2,D3
        BEQ     @3
        CMP     #1,D0
        BEQ     @4
        JSR     FindNextAlBlk
        ADD     #1,D3
        BRA     @2

@3      SUB     #2,D0
        MULU    AlBlkSize(A5),D0
        SWAP    D2
        ADD     D2,D0
        ADD     AlBlkOffset(A5),D0
        MOVE    D0,AbsBlkNumber(A5)
        RTS

@4      MOVE    #24,D0
        JMP     ShowAlert

ConvertBlock:                   ; Convert a block into printable
        LEA     IOBuff(A5),A0   ; characters
        LEA     DispBuffer(A5),A1
        LEA     SaveBuffer(A5),A2
        MOVE    #511,D0
@2      MOVE.B  (A0)+,D1
        MOVE.B  D1,(A2)+
        CMP.B   #$1F,D1
        BLS     @3
        CMP.B   #$7E,D1
        BLS     @4      
@3      MOVE.B  #'.',D1
@4      MOVE.B  D1,(A1)+
        DBRA    D0,@2
        RTS

ReadBlock:                      ; Read a Block from disk
        JSR     ExitModify
        JSR     ConvertBlkNr
        JSR     ClearIOPB
        MOVE    DriveNumber(A5),ioDrvNum(A0)
        MOVE    DriverRef(A5),ioRefNum(A0)
        LEA     IOBuff(A5),A1
        MOVE.L  A1,IOBuffer(A0)
        MOVE.L  #512,ioByteCount(A0)
        MOVE    #1,ioPosMode(A0)
        MOVE    AbsBlkNumber(A5),D0
        MULU    #512,D0
        MOVE.L  D0,ioPosOffset(A0)
        MOVE.L  D0,Position(A5)
        _Read
        MOVE    D0,D7           ; Test errorcode
        BNE     @1              ; There was an error

        JSR     ConvertBlock
        CLR     ChangeMade(A5)

        PushItem        3,DiscardCmd    ; Disable discard cmd
        _DisableItem

        PushItem        3,WBlockCmd     ; Disable write block cmd
        _DisableItem

        RTS

@1      MOVE    #24,D0
        TST     UnitMode(A5)
        BEQ     @3
        MOVE    #27,D0

@3      JMP     ShowAlert

Blurb:
        CLR.L   -(SP)           ; Put dialog about Fedit on screen
        MOVE    #51,-(SP)
        PEA     DlogStore(A5)   ; Space for storing dialog record
        MOVE.L  #-1,-(SP)
        _GetNewDialog
        
        MOVE.L  (SP),A3         ; Make Dialog current port
        _SetPort
        
        MOVE.L  A3,-(SP)                ; Draw the dialog info
        _DrawDialog
        
        JSR     WaitAcknowledge ; Allow user to read the text
        
        MOVE.L  A3,-(SP)                ; Dump the dialog
        _CloseDialog
        
        TST     WindFlag(A5)    ; Return to normal grafport
        BEQ     @1              ; if there is one
        MOVE.L  A4,-(SP)
        _SetPort
        
@1      RTS                     ; Return to main loop

DeskAcc:
        PushMenu        1               ; Get name of menu item chosen
        MOVE    D4,-(SP)
        PEA     DeskName
        _GetItem

        CLR     -(SP)           ; Let system open the accessory
        PEA     DeskName
        _OpenDeskAcc

        MOVE    (SP)+,D0
        RTS                     ; Back to main loop

Menu1:
        CMP     #AboutCmd,D4    ; Is it "About Fedit..." command
        BEQ     Blurb           ; Yes, tell it like it is
        JMP     DeskAcc         ; No, must be desk accessory

GetFile:
        MOVE    #80,-(SP)               ; Call SFGetFile
        MOVE    #80,-(SP)
        CLR.L   -(SP)
        CLR.L   -(SP)
        MOVE    #-1,-(SP)
        CLR.L   -(SP)
        CLR.L   -(SP)
        PEA     SFRecord
        MOVE    #2,-(SP)
        _Pack3

        MOVE.B  rGood,D0                ; Was a file selected?
        AND     #1,D0
        BNE     @1              ; Yes, go on
        RTS                     ; No, exit
        
@1      JSR     CloseWindow
        MOVE    #23,D6
        CLR     Unitmode(A5)    ; Mark as file mode

        JSR     ClearFIOPB      ; Get info on file
        LEA     rName,A1
        MOVE.L  A1,ioFileName(A0)
        MOVE    rVolume,ioVRefNum(A0)
        MOVE.B  rVersion,ioFileType(A0)
        _GetFileInfo

        MOVE    rVolume,D0      ; Get info on unit
        JSR     FindVCB
        MOVE.L  A2,VCBPtr(A5)
        MOVE    VCBDrefNum(A2),DriverRef(A5)
        MOVE    VCBDrvNum(A2),DriveNumber(A5)
        MOVE.L  VCBAlBlkSiz(A2),D0
        DIVU    #512,D0
        MOVE    D0,AlBlkSize(A5)
        MOVE.L  VCBMadr(A2),VolMapAdr(A5)
        MOVE    VCBAlBlSt(A2),AlBlkOffset(A5)

        MOVE    #DataForkCmd,Fork(A5)
        MOVE.L  ioFlLgLen(A0),D1
        MOVE    ioFlStBlk(A0),D0
        BNE     GetBlockCount

        MOVE    #ResForkCmd,Fork(A5)
        MOVE.L  ioFlRLgLen(A0),D1
        MOVE    ioFlRStBlk(A0),D0
        BNE     GetBlockCount

        MOVE    #29,D6          ; Empty file
        MOVE    D6,D0
        JMP     ShowAlert

GetBlockCount:
        MOVE    D0,FirstAlBlk(A5)
        SUB.L   #1,D1
        MOVE.L  D1,D7
        DIVU    #512,D1
        MOVE    D1,LEOFBlock(A5)
        AND     #$1FF,D7
        MOVE    D7,LEOFPosition(A5)

        CLR.L   D7              ; Calc blocks in fork

@1      JSR     FindNextAlBlk
        ADD     #1,D7
        CMP     #1,D0
        BNE     @1

        MULU    AlBlkSize(A5),D7
        SUB     #1,D7
        MOVE    D7,MaxBlockNr(A5)

ReadFirst:
        CLR     BlockNumber(A5) ; Initialize block number
        JSR     ReadBlock               ; Read the first block
        CMP     #0,D7           ; Was there an error
        BNE     @1              ; Yes, do not open window
        CLR     Marker(A5)
        JMP     OpenWindow
        
@1      RTS

GetVolume:
        JSR     GetVolumeName
        CMP     #-1,D7
        BNE     @1
        RTS

@1      JSR     CloseWindow
        JSR     ClearFIOPB

        MOVE.L  A2,VCBPtr(A5)
        MOVE    VCBDrefNum(A2),DriverRef(A5)
        MOVE    VCBDrvNum(A2),DriveNumber(A5)

        LEA     VCBVN(A2),A0
        LEA     rName,A1
        MOVE.L  #64,D0
        _BlockMove

        MOVE.L  VCBAlBlkSiz(A2),D0
        DIVU    #512,D0
        MOVE    VCBNmBlks(A2),D1
        ADD     #1,D1
        MULU    D1,D0
        ADD     VCBAlBlSt(A2),D0
        SUB     #1,D0
        MOVE    D0,MaxBlockNr(A5)
        MOVE    #-1,LEOFBlock(A5)

        MOVE    #1,UnitMode(A5)
        JMP     ReadFirst

Menu2:
        CMP     #OpenFileCmd,D4 ; Is it "Open File"
        BEQ     GetFile
        CMP     #OpenVolCmd,D4  ; Is it "Open Volume"
        BEQ     GetVolume
        CMP     #CloseCmd,D4    ; Is it "Close"
        BEQ     CloseWindow
        CMP     #QuitCmd,D4     ; Was Quit selected
        BEQ     @1
        RTS
        
@1      JSR     CloseWindow
        _ExitToShell

GetNextBlk:
        MOVE    BlockNumber(A5),D0      ; At end of file/unit?
        CMP     MaxBlockNr(A5),D0
        BCC     @2              ; Yes, ignore request
        ADD     #1,BlockNumber(A5)
        JSR     ReadBlock
        CMP     #0,D7
        BNE     @1
        CLR     Marker(A5)
        JSR     DisplayBlock
        MOVE.L  HScroll(A5),-(SP)
        MOVE    BlockNumber(A5),-(SP)
        _SetCtlValue
        RTS
        
@1      SUB     #1,BlockNumber(A5)
@2      RTS
        
GetPrevBlk:
        MOVE    BlockNumber(A5),D0
        BEQ     @2
        SUB     #1,BlockNumber(A5)
        JSR     ReadBlock
        CMP     #0,D7
        BNE     @1
        CLR     Marker(A5)
        JSR     DisplayBlock
        MOVE.L  HScroll(A5),-(SP)
        MOVE    BlockNumber(A5),-(SP)
        _SetCtlValue
        RTS
        
@1      ADD     #1,BlockNumber(A5)
@2      RTS

GetBlockNr:
        CLR.L   -(SP)
        MOVE    #53,-(SP)
        PEA     DlogStore(A5)
        MOVE.L  #-1,-(SP)
        _GetNewDialog
        
        MOVE.L  (SP),A3
        _SetPort
        
        CLR.L   -(SP)
        PEA     ItemHit(A5)
        _ModalDialog
        
        MOVE    ItemHit(A5),D0
        CMP     #1,D0
        BEQ     @1
        
        MOVE.L  A3,-(SP)
        _CloseDialog
        
        MOVE.L  A4,-(SP)
        _SetPort

        RTS
        
@1      MOVE.L  A3,-(SP)
        MOVE    #4,-(SP)
        PEA     TempWord(A5)
        PEA     TempHdl(A5)
        PEA     TempRect(A5)
        _GetDItem
        
        MOVE.L  TempHdl(A5),-(SP)
        PEA     OutString(A5)
        _GetItext
        
        MOVE.L  A3,-(SP)
        _CloseDialog
        
        MOVE.L  A4,-(SP)
        _SetPort
        
        LEA     OutString(A5),A0
        MOVE    #1,-(SP)                ; StringToNum
        _Pack7
        
        TST     D0
        BPL     GetBlockN
        CLR     D0
        
GetBlockN:
        CMP     MaxBlockNr(A5),D0       ; Outside value range?
        BCS     @1              ; No, get block
        MOVE    MaxBlockNr(A5),D0       ; Yes, set to max number
        
@1      MOVE    BlockNumber(A5),-(SP)
        MOVE    D0,BlockNumber(A5)
        JSR     ReadBlock
        MOVE    (SP)+,D0
        TST     D7
        BNE     @2

        CLR     Marker(A5)
        JSR     DisplayBlock
        BRA     @3

@2      MOVE    D0,BlockNumber(A5)

@3      MOVE.L  HScroll(A5),-(SP)
        MOVE    BlockNumber(A5),-(SP)
        _SetCtlValue
        RTS
        
RevertBlock:
        MOVE    #21,D0          ; Get user to confirm
        JSR     ShowAlert
        CMP     #1,D0
        BEQ     @1

        JSR     ExitModify
        LEA     SaveBuffer(A5),A0
        LEA     IOBuff(A5),A1
        MOVE.L  #512,D0
        _BlockMove
        JSR     ConvertBlock
        CLR     Marker(A5)
        JSR     DisplayBlock
        CLR     ChangeMade(A5)

        PushItem        3,DiscardCmd    ; Disable discard cmd
        _DisableItem

        PushItem        3,WBlockCmd     ; Disable write block cmd
        _DisableItem

@1      RTS

WriteBlock:
        MOVE    #26,D0
        JSR     ShowAlert               ; Make user confirm it
        CMP     #1,D0
        BEQ     @1

        JSR     ExitModify
        JSR     ClearIOPB
        MOVE    DriveNumber(A5),ioDrvNum(A0)
        MOVE    DriverRef(A5),ioRefNum(A0)
        LEA     IOBuff(A5),A1
        MOVE.L  A1,IOBuffer(A0)
        MOVE.L  #512,ioByteCount(A0)
        MOVE    #1,ioPosMode(A0)
        MOVE.L  Position(A5),ioPosOffset(A0)
        _Write

        MOVE    D0,D7           ; Test errorcode
        BNE     @2

        JSR     ClearIOPB               ; Flush volume
        MOVE.L  VCBPtr(A5),A1
        MOVE    VCBVRefNum(A1),ioVRefNum(A0)
        _FlushVol
        MOVE    D0,D7
        BNE     @2

        CLR     ChangeMade(A5)

        PushItem        3,DiscardCmd    ; Disable discard cmd
        _DisableItem

        PushItem        3,WBlockCmd     ; Disable write block cmd
        _DisableItem
        
        MOVE    #512,D0         ; Save IO buffer
        LEA     IOBuff(A5),A0
        LEA     SaveBuffer(A5),A1
        _BlockMove

@1      RTS

@2      MOVE    #28,D0          ; Handle write error
        JMP     ShowAlert

SetupModify:
        CLR.L   -(SP)
        MOVE    #6,D0
        ADD     InModify(A5),D0
        MOVE    D0,-(SP)
        _GetRMenu
        
        CLR     -(SP)
        _InsertMenu
        
        _DrawMenuBar

        PushMenu        3
        MOVE    #AModCmd,D0
        ADD     InModify(A5),D0
        MOVE    D0,-(SP)
        MOVE    #-1,-(SP)
        _CheckItem

        ADD     #1,InModify(A5)
        RTS

AsciiModify:
        MOVE    InModify(A5),D0
        BEQ     @1
        CMP     #1,D0
        BEQ     ExitModify

        JSR     ExitModify
        MOVE    #0,InModify(A5)

@1      LEA     ModifyBlockA,A0
        MOVE.L  A0,ModifyProc(A5)
        JMP     SetupModify

HexModify:
        MOVE    InModify(A5),D0
        BEQ     @1
        CMP     #2,D0
        BEQ     ExitModify
        
        JSR     ExitModify

@1      MOVE    #1,InModify(A5)
        LEA     ModifyBlockH,A0
        MOVE.L  A0,ModifyProc(A5)
        JMP     SetupModify

Menu3:
        CMP     #RNextCmd,D4
        BEQ     GetNextBlk
        CMP     #RPrevCmd,D4
        BEQ     GetPrevBlk
        CMP     #RBlockCmd,D4
        BEQ     GetBlockNr
        CMP     #DiscardCmd,D4
        BEQ     RevertBlock
        CMP     #AModCmd,D4
        BEQ     AsciiModify
        CMP     #HModCmd,D4
        BEQ     HexModify
        CMP     #WBlockCmd,D4
        BEQ     WriteBlock
        RTS

ChangeMode:
        MOVE    D4,D5
        SUB     #DHexCmd,D5
        CMP     DisplayMode(A5),D5
        BEQ     @5

        PushMenu        4
        ADD     #DHexCmd,DisplayMode(A5)
        MOVE    DisplayMode(A5),-(SP)
        CLR     -(SP)
        _CheckItem

        MOVE    D4,DisplayMode(A5)
        SUB     #DHexCmd,DisplayMode(A5)

        PushMenu        4
        MOVE    D4,-(SP)
        MOVE    #-1,-(SP)
        _CheckItem

        CMP     #DHexCmd,D4
        BEQ     @1

        PushItem        3,AModCmd
        _EnableItem
        
        BRA     @2

@1      PushItem        3,AModCmd
        _DisableItem

@2      TST     WindFlag(A5)
        BEQ     @5

        CMP     #DHexCmd,D4
        BNE     @3

        LSL     Marker(A5)
        CLR     D0
        
        MOVE    InModify(A5),D1
        BEQ     @4
        CMP     #2,D1
        BEQ     @4
        
        JSR     ExitModify
        BRA     @4

@3      LSR     Marker(A5)
        MOVE    #255,D0

@4      MOVE.L  VScroll(A5),-(SP)       ; Set vertical
        MOVE    D0,-(SP)                ; control Status
        _HiliteControl
        CLR.L   NextTick(A5)
        JMP     DisplayBlock

@5      RTS

ChangeFork:
        CMP     Fork(A5),D4     ; User selected current fork
        BNE     @1              ; So exit
        RTS

@1      LEA     FIOPB(A5),A0    ; Pointer to the File info block
        CMP     #ResForkCmd,D4
        BEQ     @2
        
        MOVE.L  ioFlLgLen(A0),D1
        MOVE    ioFlStBlk(A0),D0        ; Is there another fork?
        BEQ     @3              ; No, error message
        MOVE    D4,Fork(A5)
        JMP     GetBlockCount

@2      MOVE.L  ioFlRLgLen(A0),D1
        MOVE    ioFlRStBlk(A0),D0
        BEQ     @3
        MOVE    D4,Fork(A5)
        JMP     GetBlockCount

@3      MOVE    #22,D0          ; Cannot open empty fork
        JMP     ShowAlert

Menu4:
        CMP     #ResForkCmd,D4
        BEQ     ChangeFork
        CMP     #DataForkCmd,D4
        BEQ     ChangeFork
        CMP     #DHexCmd,D4
        BEQ     ChangeMode
        CMP     #DAscCmd,D4
        BEQ     ChangeMode

Menu0:
        RTS

MenuTable:
        DC      Menu0-MenuTable
        DC      Menu1-MenuTable
        DC      Menu2-MenuTable
        DC      Menu3-MenuTable
        DC      Menu4-MenuTable
        DC      Menu5-MenuTable
        DC      ExitModify-MenuTable
        DC      ExitModify-MenuTable

DoMenuItem:
        CLR.L   -(SP)           ; What item was selected
        MOVE.L  Point,-(SP)
        _MenuSelect
        MOVE.L  (SP)+,D4

DoCommand:
        MOVE.L  D4,D5           ; Find out which menu is involved
        SWAP    D5
        LSL     #1,D5
        MOVE    MenuTable(D5),D0
        JMP     MenuTable(D0)

InMenu:
        JSR     DoMenuItem
        CLR     -(SP)           ; Remove highlighting from menu bar
        _HiLiteMenu
        JMP     GetEvent

SystemStuff:
        PEA     Event           ; Probably a desk accessory...
        MOVE.L  WWindow,-(SP)   ; Let the system do its thing
        _SystemClick
        JMP     GetEvent

TestActive:                     ; Is this the active windoe
        CLR.L   -(SP)           ; Get pointer to front window
        _FrontWindow
        MOVE.L  (SP)+,A0

        CMP.L   WWindow,A0      ; Is the event window at front
        BEQ     TestControl     ; Yes, go on

        MOVE.L  WWindow,-(SP)   ; No, select the event window
        _SelectWindow
        JMP     GetEvent                ; and return to main loop
        
TestControl:
        PEA     Point           ; Convert pointer to local
        _GlobalToLocal          ; coordinates for current window
        
        CLR     -(SP)
        MOVE.L  Point,-(SP)
        MOVE.L  A4,-(SP)
        PEA     CHandle
        _FindControl            ; Is the mouse in a control
        MOVE    (SP)+,D0
        BNE     @0              ; Yes, handle as control

        JSR     ChangePos               ; No, handle in text area
        JMP     GetEvent
        
@0      MOVE.L  CHandle,A1
        CMP.L   HScroll(A5),A1  ; Is this the HScroll control
        BNE     VScrollCtl      ; No, must be Vscroll
        
        CMP     #129,D0         ; Is the mouse in thumb
        BNE     @2              ; No, branch

        CLR     -(SP)           ; Find starting thumb position
        MOVE.L  CHandle,-(SP)
        _GetCtlValue
        MOVE    (SP)+,D3

        CLR     -(SP)           ; Redraw the control
        MOVE.L  CHandle,-(SP)
        MOVE.L  Point,-(SP)
        CLR.L   -(SP)
        _TrackControl
        MOVE    (SP)+,D0

        CLR     -(SP)           ; Find new thumb position
        MOVE.L  CHandle,-(SP)
        _GetCtlValue
        MOVE    (SP)+,D0
        
        CMP     D0,D3           ; Did position change?
        BEQ     GetEvent                ; No, exit
        
@1      JSR     GetBlockN               ; Read new block from disk
        JMP     GetEvent

@2      CLR     -(SP)           ; Repeatedly call procedure that
        MOVE.L  CHandle,-(SP)   ; will read blocks from disk
        MOVE.L  Point,-(SP)     ; until user releases mouse button
        PEA     GetABlock
        _TrackControl
        MOVE    (SP)+,D0
        JMP     GetEvent

GetABlock:
        MOVE.L  D3,-(SP)                ; Preserve D3
        MOVE    8(SP),D0                ; Get Partcode
        CMP     #20,D0          ; In up arrow
        BEQ     @1
        CMP     #21,D0          ; In down arrow
        BEQ     @2
        CMP     #22,D0          ; In page up
        BEQ     @1
        CMP     #23,D0          ; In page down
        BEQ     @2
        JMP     @3              ; In limbo?
        
@1      JSR     GetPrevBlk      ; Read lower numbered block
        JMP     @3

@2      JSR     GetNextBlk      ; Read higher numbered block

@3      MOVE.L  (SP)+,D3                ; Restore D3
        MOVE.L  (SP)+,A1                ; Get return address
        ADD     #6,SP           ; Adjust stack pointer
        JMP     (A1)            ; Just like an RTS...

VScrollCtl:
        CMP     #129,D0         ; Is mouse in thumb
        BNE     @2
        
        CLR     -(SP)           ; Find starting thumb position
        MOVE.L  CHandle,-(SP)
        _GetCtlValue
        MOVE    (SP)+,D3

        CLR     -(SP)           ; Track the control
        MOVE.L  CHandle,-(SP)
        MOVE.L  Point,-(SP)
        CLR.L   -(SP)
        _TrackControl
        MOVE    (SP)+,D0

        CLR     -(SP)           ; Find new thumb position
        MOVE.L  CHandle,-(SP)
        _GetCtlValue
        MOVE    (SP)+,D0
        
        CMP     D0,D3           ; Did position change?
        BEQ     GetEvent                ; No, exit
        
        MULU    #HexP2Start,D0  ; No, force it to page 2
        MOVE    D0,HexStartLine(A5)
        JSR     DisplayBlock
        JMP     GetEvent

@2      CLR     -(SP)           ; Repeatedly call procedure that
        MOVE.L  CHandle,-(SP)   ; will move control until
        MOVE.L  Point,-(SP)     ; user releases mouse button
        PEA     MoveHexCtl
        _TrackControl
        MOVE    (SP)+,D0
        JMP     GetEvent

MoveHexCtl:
        MOVE.L  D3,-(SP)                ; Preserve D3
        MOVE    8(SP),D0                ; Get Partcode
        CMP     #20,D0          ; In up arrow
        BEQ     @1
        CMP     #21,D0          ; In down arrow
        BEQ     @2
        CMP     #22,D0          ; In page up
        BEQ     @1
        CMP     #23,D0          ; In page down
        BEQ     @2
        JMP     @4              ; In limbo?
        
@1      TST     HexStartLine(A5)        ; Move up block
        BEQ     @4
        CLR     D7
        JMP     @3

@2      TST     HexStartLine(A5)        ; Move down block
        BNE     @4
        MOVE    #1,D7

@3      MOVE.L  CHandle,-(SP)
        MOVE    D7,-(SP)
        _SetCtlValue

        MULU    #HexP2Start,D7
        MOVE    D7,HexStartLine(A5)
        JSR     DisplayBlock

@4      MOVE.L  (SP)+,D3                ; Restore D3
        MOVE.L  (SP)+,A1                ; Get return address
        ADD     #6,SP           ; Adjust stack pointer
        JMP     (A1)            ; Just like an RTS...

Dragger:
        MOVE.L  A4,-(SP)                ; Drag the window around
        MOVE.L  Point,-(SP)
        PEA     DragRect                ; Limits of drag area
        _DragWindow
        JMP     GetEvent

Grower:
        CLR.L   -(SP)           ; Follow the mouse until user   
        MOVE.L  A4,-(SP)                ; releases the button
        MOVE.L  Point,-(SP)
        PEA     SizeRect
        _GrowWindow
        MOVE.L  (SP)+,D3                ; Did the window size change?
        BEQ     GetEvent                ; No, exit
        
        JSR     MakeCtlsInvalid

        MOVE.L  A4,-(SP)
        MOVE.L  D3,-(SP)
        MOVE    #-1,-(SP)
        _SizeWindow             ; Enlarge or shrink window
        
        LEA     PortRect(A4),A0 ; Copy port rectangle
        LEA     DataRect(A5),A1
        MOVE.L  (A0)+,(A1)+
        MOVE.L  (A0)+,(A1)+

        LEA     DataRect(A5),A1 ; Set up new Datarect
        SUB     #15,Right(A1)
        SUB     #15,Bottom(A1)
        
        PEA     PortRect(A4)
        _ClipRect                       ; Change clip area

        CLR.L   NextTick(A5)
        JSR     MoveScrollBars  ; Move the scroll bars

        TST     DisplayMode(A5)
        BEQ     @1

        PEA     MarkRect(A5)
        _InvalRect

@1      JMP     GetEvent

GoAwayArea:
        CLR     -(SP)           ; Follow the mouse until user
        MOVE.L  WWindow,-(SP)   ; releases the button
        MOVE.L  Point,-(SP)
        _TrackGoAway

        MOVE    (SP)+,D0                ; Still in goaway box?
        BEQ     GetEvent                ; No, exit
        
        JSR     CloseWindow     ; Yes, close everything

NoAction:
        JMP     GetEvent

MouseTable:
        DC      NoAction-MouseTable
        DC      InMenu-MouseTable
        DC      SystemStuff-MouseTable
        DC      TestActive-MouseTable
        DC      Dragger-MouseTable
        DC      Grower-MouseTable
        DC      GoAwayArea-MouseTable
        
MouseDown:
        CLR     -(SP)           ; Find out where the mouse points
        MOVE.L  Point,-(SP)
        PEA     WWindow
        _FindWindow
        MOVE    (SP)+,D0
        LSL     #1,D0
        MOVE    MouseTable(D0),D0
        JMP     MouseTable(D0)
        
KeyDown:
        MOVE    Modify,D0               ; Is it a command key
        AND     #$0100,D0
        BEQ     HandleKey               ; No, handle as standard key
        CLR.L   -(SP)
        MOVE.L  Message,D0
        MOVE    D0,-(SP)                ; Yes, find out for what item
        _MenuKey
        MOVE.L  (SP)+,D4                ; Find out which menu is involved
        JSR     DoCommand
        CLR     -(SP)           ; Remove highlighting from menu bar
        _HiLiteMenu
        JMP     GetEvent

Autokey:
        MOVE    Modify,D0               ; Is it a command key
        AND     #$0100,D0
        BNE     GetEvent                ; Yes, ignore for autokey

HandleKey:
        TST     InModify(A5)    ; Are we modifying a block
        BEQ     @1              ; No, exit
        MOVE.L  ModifyProc(A5),A0       ; Yes, call appropriate routine
        JSR     (A0)

@1      JMP     GetEvent                ; Ignore normal keypresses

UpdateEvt:
        CMP.L   Message,A4      ; Is this my window?
        BNE     @1              ; No, exit
        
        MOVE.L  A4,-(SP)                ; Set update area
        _BeginUpdate
        
        MOVE.L  A4,-(SP)                ; Draw Grow icon
        _DrawGrowIcon
        
        MOVE.L  A4,-(SP)                ; Draw scoll bars
        _DrawControls
        
        JSR     DisplayBlock    ; Draw text window
                
        MOVE.L  A4,-(SP)                ; Reset proper draw area
        _EndUpdate
        
@1      JMP     GetEvent

DiskInsert:
        JSR     DiskInserted    ; Toolbox does most of it
        JMP     GetEvent

Activate:
        CMP.L   Message,A4      ; Is this my window?
        BNE     GetEvent                ; No, exit now

        MOVE.L  A4,-(SP)                ; Make it the current port
        _SetPort
        
        MOVE    Modify,D0               ; Is it an activate
        AND     #1,D0           ; or deactivate event
        BEQ     @1
        
        MOVE.L  HScroll(A5),-(SP)       ; Window is being activated
        _ShowControl
        
        MOVE.L  VScroll(A5),-(SP)       ; So show the scroll bars
        _ShowControl
        
        MOVE.L  A4,-(SP)
        _DrawGrowIcon
        
        JMP     GetEvent

@1      
        MOVE.L  HScroll(A5),-(SP)       ; Window is being deactivated
        _HideControl
        
        MOVE.L  VScroll(A5),-(SP)       ; So hide the scroll bars
        _HideControl
        
        MOVE.L  A4,-(SP)
        _DrawGrowIcon
        
        JMP     GetEvent

Ticker:
        TST.L   NextTick(A5)    ; Is Blinking box on screen?
        BEQ     @1              ; No, exit

        CLR.L   -(SP)           ; Get current time
        _TickCount

        MOVE.L  (SP)+,D0                ; Is it time to blink box
        CMP.L   NextTick(A5),D0
        BMI     @1              ; No, exit

        ADD.L   #20,D0
        MOVE.L  D0,NextTick(A5) ; Set new blink time

        PEA     MarkRect(A5)    ; and invert box
        _InverRect

@1      RTS

EventTable:
        DC      GetEvent-EventTable
        DC      MouseDown-EventTable
        DC      GetEvent-EventTable
        DC      KeyDown-EventTable
        DC      GetEvent-EventTable
        DC      AutoKey-EventTable
        DC      UpdateEvt-EventTable
        DC      DiskInsert-EventTable
        DC      Activate-EventTable
        DC      GetEvent-EventTable
        DC      GetEvent-EventTable

GetEvent:
        _SystemTask             ; Perform any desk access updates
        JSR     Ticker
        CLR     -(SP)
        MOVE    #-1,-(SP)
        PEA     Event
        _GetNextEvent           ; Get next event
        
        MOVE    (SP)+,D0
        CMP     #0,D0           ; Null Event Ignored
        BEQ     GetEvent
        MOVE    What,D0
        LSL     #1,D0           ; Convert to word offset
        MOVE    EventTable(D0),D0       ; Get offset
        JMP     EventTable(D0)  ; and jump to code

DrawMenu:
        LEA     MenuHandle,A3   ; Point to menuhandle[1]
        CLR.L   (A3)+
        
        CLR.L   -(SP)           ; Set up first menu with
        MOVE    #1,-(SP)                ; desk accessories list
        _GetRMenu

        MOVE.L  (SP),(A3)               ; Save Menu handle
        CLR     -(SP)
        _InsertMenu

        MOVE.L  (A3)+,-(SP)     ; Get desk accessories list
        MOVE.L  #'DRVR',-(SP)
        _AddResMenu

        MOVE    #2,D4
@1      CLR.L   -(SP)           ; Get menu from resource file
        MOVE    D4,-(SP)
        _GetRMenu

        MOVE.L  (SP),(A3)+      ; Save menu handle
        CLR     -(SP)
        _InsertMenu

        ADD     #1,D4           ; Increment Menu Number
        CMP     #Menucount,D4
        BLS     @1

        _DrawMenuBar            ; Display menu bar on screen
        RTS

Start:
        PEA     -4(A5)          ; Magic to initialize graphics
        _InitGraf
        _InitFonts              ; Init other handlers
        _InitWindows
        _InitMenus
        CLR.L   -(SP)
        _InitDialogs
        _TEInit

        IF      SeparateResFile

        CLR     -(SP)           ; Get resources file
        PEA     'FeditRes'
        _OpenResFile
        MOVE    (SP)+,D0

        ENDIF

        JSR     DrawMenu                ; Draw Menu Bar on Screen

        _InitCursor             ; Init Cursor to arrow
        
        PushItem        3,0             ; Disable menu 3
        _DisableItem

        MOVE    #21,D7

@1      MOVE    D7,-(SP)                ; Preload alerts
        _CouldAlert
        ADD     #1,D7
        CMP     #30,D7
        BNE     @1
        
        MOVE    #51,D7

@2      MOVE    D7,-(SP)                ; Preload dialogs
        _CouldDialog
        ADD     #1,D7
        CMP     #54,D7
        BNE     @2

        MOVE    #257,D7

@3      CLR.L   -(SP)           ; Preload strings
        MOVE    D7,-(SP)
        _GetString
        MOVE.L  (SP)+,D0
        ADD     #1,D7
        CMP     #262,D7
        BNE     @3

        MOVE    #6,D7

@4      CLR.L   -(SP)           ; Preload menus
        MOVE.L  #'MENU',-(SP)
        MOVE    D7,-(SP)
        _GetResource
        MOVE.L  (SP)+,D0
        ADD     #1,D7
        CMP     #8,D7
        BNE     @4

        CLR.L   -(SP)           ; Load monaco font, 9 point
        MOVE.L  #'FONT',-(SP)
        MOVE    #521,-(SP)
        _GetResource
        MOVE    (SP)+,D0
        
        MOVE    #2,-(SP)                ; Call DILoad in pack 2
        _Pack2

        CLR     -(SP)
        MOVE    #4,-(SP)
        _Pack6
        MOVE    (SP)+,D0                ; Force load of pack6
        
        LEA     OutString(A5),A0
        CLR     D0
        CLR     -(SP)
        _Pack7                  ; Force load of pack7

        MOVE    #1,DisplayMode(A5)      ; Set mode to ASCII
        CLR     UnitMode(A5)    ; Set unitmode to true
        CLR     WindFlag(A5)    ; No window open
        CLR     ChangeMade(A5)  ; Buffer not changed
        CLR     InModify(A5)    ; Clear modify flag
        CLR     HexStartline(A5)        ; Start hex at page top
        CLR.L   NextTick(A5)    ; Ticker not active

        MOVE.L  #$FFFF,D0               ; Dump any left over events
        _FlushEvents
        
        JSR     GetFile         ; Open a file, and force load
        JMP     GetEvent                ; Enter main loop

        END

26-Oct-84 19:13:10-PDT,12154;000000000001
Return-Path: <tdn@cmu-cs-spice.arpa>
Received: from CMU-CS-SPICE.ARPA by SUMEX-AIM.ARPA with TCP; Fri 26 Oct 84 19:11:59-PDT
Date: Friday, 26 October 1984 21:58:05 EDT
From: Thomas.Newton@cmu-cs-spice.arpa
To: info-mac@sumex-aim.arpa
Subject: FEdit2.Asm (TO BE ARCHIVED)
Message-ID: <1984.10.27.1.56.54.Thomas.Newton@cmu-cs-spice.arpa>

;   Fedit2.Asm
;______________________________________________________________________
;
;   This program is designed to provide disk information and to
;   edit disk files on the Macintosh.
;
;         Copyright (C) John H. Mitchell, September 1984.
;
;                   All rights reserved.
;
;   Permission is granted for non commercial usage.  This source
;   and its associated code file may be copied and distributed
;   freely, provided that you do not attempt to sell it, use it
;   as the basis for a commercial program, or otherwise obtain any
;   financial gain from it.  You may modify it in any way that you
;   feel appropriate within these limits.
;
;______________________________________________________________________

        Include FSEqu.d
        Include Mactraps.d
        
        XDEF    DiskInserted,EjectDisk,GetVolumeName,FindVCB,Menu5

        XREF    TempWord,TempHdl,TempRect,Event,What,Message
        XREF    Count,DlogHdl,ItemHit,DlogStore,WindFlag
        XREF    Outstring,ClearIOPB,FIOPB,WaitAcknowledge
        XREF    VCBPtr,WordToHex,CharToHex
        
FileInfoCmd     EQU     1       ; Menu 5
UnitInfoCmd     EQU     2

PortRect                EQU     $10     ; offset to port's rectangle [rect]

MACRO   WordOut Index =
        MOVE    {Index}(A2),D0
        JSR     WordToHex
        PEA     OutString(A5)
        _DrawString|

MACRO   ByteItem        Title,Index =
        LEA     '{Title}:',A3
        JSR     SetupLine
        MOVE.B  {Index}(A2),D0
        JSR     CharToHex
        PEA     OutString(A5)
        _DrawString|

MACRO   WordItem        Title,Index =
        LEA     '{Title}:',A3
        JSR     SetupLine
        WordOut {Index}|

MACRO   LongItem        Title,Index =
        LEA     '{Title}:',A3
        JSR     SetupLine
        WordOut {Index}
        WordOut {Index}+2|

MACRO   StrItem Title,Index =
        LEA     '{Title}:',A3
        JSR     SetupLine
        PEA     {Index}(A2)
        _DrawString|

MACRO   FdrItem Title,Index =
        LongItem        {Title},{Index}
        MOVE.L  {Index}(A2),D0
        JSR     LongPrint|

MACRO   DateItem        Title,Index =
        LongItem        {Title},{Index}
        MOVE.L  {Index}(A2),D0
        JSR     DatePrint|

MACRO   WordDec Index =
        MOVE    {Index}(A2),D0
        JSR     WordDecimal|
        
MACRO   LongDec Index =
        MOVE.L  {Index}(A2),D0
        JSR     LongDecimal|
        
FindVCB:
        MOVE.L  VCBQHdr+2,A2    ; Search volume control block
        BRA     @2              ; queue for VCB for selected file

@1      MOVE.L  (A2),A2

@2      CMP.L   #0,A2
        BEQ     @3
        CMP     VCBVRefNum(A2),D0
        BNE     @1

@3      RTS

EjectDisk:
        MOVEM.L A0-A2/D0-D2,-(SP)       ; Eject disk who's indicated by
        JSR     ClearIOPB               ; VCB pointer in A2
        MOVE    VCBVRefNum(A2),ioVRefNum(A0)
        _Eject
        MOVEM.L (SP)+,A0-A2/D0-D2
        RTS

NoDrives:
        CLR     TempWord(A5)    ; Volume name routine when all
        MOVE.L  TempHdl(A5),-(SP)       ; disks have been ejected
        PEA     TempWord(A5)
        _SetIText

NoDrvEvent:
        _SystemTask
        CLR     -(SP)
        MOVE    #-1,-(SP)
        PEA     Event
        _GetNextEvent
        MOVE    (SP)+,D0
        
        BEQ     NoDrvEvent
        MOVE    What,D0
        CMP     #1,D0
        BEQ     NoDrvMouse
        CMP     #7,D0
        BEQ     NoDrvDiskEvt
        JMP     NoDrvEvent

NoDrvDiskEvt:
        JSR     DiskInserted
        MOVE    #1,Count(A5)
        JMP     DriveTest1

NoDrvMouse:
        CLR     -(SP)
        PEA     Event
        _IsDialogEvent
        MOVE    (SP)+,D0
        BTST    #8,D0
        BEQ     NoDrvEvent

        CLR     -(SP)
        PEA     Event
        PEA     DlogHdl(A5)
        PEA     ItemHit(A5)
        _DialogSelect
        MOVE    (SP)+,D0
        BTST    #8,D0
        BEQ     NoDrvEvent

        MOVE    ItemHit(A5),D0
        CMP     #2,D0           ; Cancel Button
        BEQ     CancelVDlog
        JMP     NoDrvEvent
        
GetVolumeName:
        CLR.L   -(SP)
        MOVE    #52,-(SP)
        PEA     DlogStore(A5)
        MOVE.L  #-1,-(SP)
        _GetNewDialog
        
        MOVE.L  (SP),A3
        _SetPort
        
        MOVE.L  A3,-(SP)
        MOVE    #5,-(SP)
        PEA     TempWord(A5)
        PEA     TempHdl(A5)
        PEA     TempRect(A5)
        _GetDItem
        MOVE    #1,Count(A5)

DriveTest1:
        TST     Count(A5)
        BEQ     NoDrives
        CLR     Count(A5)
        MOVE.L  VCBQHdr+2,A2
        BRA     DriveTest3

DriveTest2:
        MOVE.L  (A2),A2
        CMP.L   #0,A2
        BEQ     DriveTest1

DriveTest3:
        TST     VCBDrefNum(A2)
        BPL     DriveTest2
        ADD     #1,Count(A5)

        MOVE.L  TempHdl(A5),-(SP)
        PEA     VCBVN(A2)
        _SetIText
        
GetVolEvent:
        _SystemTask
        CLR     -(SP)
        MOVE    #-1,-(SP)
        PEA     Event
        _GetNextEvent
        MOVE    (SP)+,D0
        
        BEQ     GetVolEvent
        MOVE    What,D0
        CMP     #1,D0
        BEQ     GetVolMouse
        CMP     #7,D0
        BEQ     GetVolDiskEvt
        JMP     GetVolEvent

GetVolDiskEvt:
        JSR     DiskInserted
        JMP     GetVolEvent

DiskInserted:
        MOVE.L  Message,D0      ; Was there an error while
        SWAP    D0              ; mounting the disk?
        CMP     #0,D0
        BNE     @1              ; Yes, call toolbox to fix
        RTS

@1      CLR     -(SP)           ; Wonderful things are in
        MOVE    #100,-(SP)      ; this toolbox
        MOVE    #100,-(SP)
        MOVE.L  Message,-(SP)
        CLR     -(SP)           ; Call DIBadMount
        _Pack2                  ; to initialize the disk
        MOVE    (SP)+,D0
        RTS

GetVolMouse:
        CLR     -(SP)
        PEA     Event
        _IsDialogEvent
        MOVE    (SP)+,D0
        BTST    #8,D0
        BEQ     GetVolEvent

        CLR     -(SP)
        PEA     Event
        PEA     DlogHdl(A5)
        PEA     ItemHit(A5)
        _DialogSelect
        MOVE    (SP)+,D0
        BTST    #8,D0
        BEQ     GetVolEvent

        MOVE    ItemHit(A5),D0
        CMP     #1,D0           ; Open Button
        BEQ     OpenVol
        CMP     #2,D0           ; Cancel Button
        BEQ     CancelVDlog
        CMP     #4,D0           ; Drive Button
        BEQ     DriveTest2
        JSR     EjectDisk               ; Eject Button
        JMP     DriveTest2

CancelVDlog:
        MOVE    #-1,D7
        JMP     CloseVolDlog

OpenVol:
        CLR     D7

CloseVolDlog:
        MOVE.L  A3,-(SP)
        _CloseDialog

        TST     WindFlag(A5)    ; Return to normal grafport
        BEQ     @1              ; if there is one
        MOVE.L  A4,-(SP)
        _SetPort

@1      RTS
        
SetupLine:
        MOVE    #32,-(SP)
        MOVE    D4,-(SP)
        _MoveTo
        
        MOVE.L  A3,-(SP)
        _DrawString
        
        MOVE    #165,-(SP)
        MOVE    D4,-(SP)
        _MoveTo
        
        ADD     D7,D4
        RTS

WordDecimal:
        MOVE    D0,D5
        BEQ     @1

        MOVE    #48,-(SP)
        CLR     -(SP)
        _Move
        
        MOVE    #'(',-(SP)
        _DrawChar

        LEA     OutString(A5),A0
        MOVE    D5,D0
        EXT.L   D0
        CLR     -(SP)
        _Pack7

        MOVE.L  A0,-(SP)
        _DrawString

        MOVE    #')',-(SP)
        _DrawChar

@1      RTS

LongDecimal:
        MOVE.L  D0,D5
        BEQ     @1

        MOVE    #18,-(SP)
        CLR     -(SP)
        _Move
        
        MOVE    #'(',-(SP)
        _DrawChar

        LEA     OutString(A5),A0
        MOVE.L  D5,D0
        CLR     -(SP)
        _Pack7

        MOVE.L  A0,-(SP)
        _DrawString

        MOVE    #')',-(SP)
        _DrawChar

@1      RTS
        
LongPrint:
        MOVE.L  D0,OutString(A5)
        BEQ     @1

        MOVE    #18,-(SP)
        CLR     -(SP)
        _Move
        
        MOVE    #'(',-(SP)
        _DrawChar

        PEA     OutString(A5)
        CLR     -(SP)
        MOVE    #4,-(SP)
        _DrawText

        MOVE    #')',-(SP)
        _DrawChar

@1      RTS

DatePrint:
        MOVE.L  D0,D5
        BEQ     @1

        MOVE    #18,-(SP)
        CLR     -(SP)
        _Move
        
        MOVE    #'(',-(SP)
        _DrawChar

        MOVE.L  D5,-(SP)
        CLR     -(SP)
        PEA     OutString(A5)
        CLR     -(SP)
        _Pack6

        PEA     OutString(A5)
        _DrawString

        MOVE    #' ',-(SP)
        _DrawChar

        MOVE.L  D5,-(SP)
        CLR     -(SP)
        PEA     OutString(A5)
        MOVE    #2,-(SP)
        _Pack6

        PEA     OutString(A5)
        _DrawString

        MOVE    #')',-(SP)
        _DrawChar

@1      RTS

AnalyzeFile:
        LEA     FIOPB(A5),A2
        PEA     PortRect(A4)
        _ClipRect

        PEA     PortRect(A4)
        _EraseRect

        MOVE    #32,D4
        MOVE    #13,D7

        ByteItem        Attributes,ioFlAttrib
        ByteItem        Filetype,ioFFlType

        FdrItem Finder File Type,ioFlUsrWds
        FdrItem Finder Creator,ioFlUsrWds+4
        WordItem        Finder Flags,ioFlUsrWds+8
        LongItem        Finder Location,ioFlUsrWds+10
        WordItem        Finder Folder,ioFlUsrWds+14

        LongItem        File Number,ioFFlNum

        WordItem        Data Start Block,ioFlStBlk
        WordDec ioFlStBlk
        LongItem        Data Logical Length,ioFlLgLen
        LongDec ioFlLgLen
        LongItem        Data Physical Length,ioFlPyLen
        LongDec ioFlPyLen

        WordItem        Res Start Block,ioFlRStBlk
        WordDec ioFlRStBlk
        LongItem        Res Logical Length,ioFlRLgLen
        LongDec ioFlRLgLen
        LongItem        Res Physical Length,ioFlRPyLen
        LongDec ioFlRPyLen

        DateItem        Creation Date,ioFlCrDat
        DateItem        Last Modification,ioFlMdDat

        JSR     WaitAcknowledge

        PEA     PortRect(A4)
        _InvalRect

        RTS

AnalyzeVol:
        MOVE.L  VCBPtr(A5),A2
        PEA     PortRect(A4)
        _ClipRect

        PEA     PortRect(A4)
        _EraseRect

        MOVE    #32,D4
        MOVE    #15,D7

        StrItem Volume Name,VCBVN

        DateItem        Creation Date,VCBCrDate
        DateItem        Last Backup Date,VCBLsBkUp

        WordItem        Attributes,VCBAtrb

        WordItem        Number of Files,VCBNmFls
        WordDec VCBNmFls

        WordItem        Directory Start,VCBDirSt
        WordDec VCBDirSt
        WordItem        Directory Length,VCBBlLn
        WordDec VCBBlLn

        WordItem        Allocation Blocks,VCBNmBlks
        WordDec VCBNmBlks
        LongItem        Allocation Blksize,VCBAlBlkSiz
        LongDec VCBAlBlkSiz
        LongItem        Allocation Clipsize,VCBClpSiz
        LongDec VCBClpSiz
        WordItem        First Allocation Blk,VCBAlBlSt
        WordDec VCBAlBlSt
        LongItem        Next File Number,VCBNxtFNum
        WordItem        Unused Blocks,VCBFreeBks
        WordDec VCBFreeBks

        JSR     WaitAcknowledge

        PEA     PortRect(A4)
        _InvalRect

        RTS

Menu5:
        CMP     #1,D4
        BEQ     AnalyzeFile
        CMP     #2,D4
        BEQ     AnalyzeVol
        RTS
        
        END

26-Oct-84 19:14:57-PDT,11168;000000000001
Return-Path: <tdn@cmu-cs-spice.arpa>
Received: from CMU-CS-SPICE.ARPA by SUMEX-AIM.ARPA with TCP; Fri 26 Oct 84 19:13:55-PDT
Date: Friday, 26 October 1984 22:00:24 EDT
From: Thomas.Newton@cmu-cs-spice.arpa
To: info-mac@sumex-aim.arpa
Subject: FEditR.Asm (TO BE ARCHIVED)
Message-ID: <1984.10.27.1.58.20.Thomas.Newton@cmu-cs-spice.arpa>

;______________________________________________________________________
;
;   This program is designed to provide disk information and to
;   edit disk files on the Macintosh.
;
;         Copyright (C) John H. Mitchell, September 1984.
;
;                   All rights reserved.
;
;   Permission is granted for non commercial usage.  This source
;   and its associated code file may be copied and distributed
;   freely, provided that you do not attempt to sell it, use it
;   as the basis for a commercial program, or otherwise obtain any
;   financial gain from it.  You may modify it in any way that you
;   feel appropriate within these limits.
;
;______________________________________________________________________

        String_Format 2

Visible EQU     1
Invisible       EQU     0

GoAway  EQU     1
NoGoAway        EQU     0

Enabled EQU     0
Disabled        EQU     128

MACRO   MakeMENU        Name,ID,Flags =
        RESOURCE        'MENU'{ID} 'z'
        DC.B    {ID}>>8,{ID}
        DC.B    0,0
        DC.B    0,0
        DC.B    0,0
        DC.B    0,0
        LongHex {Flags}
        DC.B    {Name}
        |

MACRO   MenuItem        Text,Mark,Key =
        DC.B    {Text}
        DC.B    0
        DC.B    {Key}
        DC.B    {Mark}
        DC.B    0
        |

MACRO   MakeSTR ID,Text =
        RESOURCE        'STR ' {ID} 'z'
        DC.B    {Text}
        |

MACRO   MakeDLOG        ID,RectTop,RectLeft,RectBottom,RectRight,VisibleFlag,GoawayFlag,Procedure,DITL =
        RESOURCE        'DLOG' {ID} 'z'
        DC.B    {RectTop}>>8,{RectTop},{RectLeft}>>8,{RectLeft}
        DC.B    {RectBottom}>>8,{RectBottom},{RectRight}>>8,{RectRight}
        DC.B    {Procedure}>>8,{Procedure}
        DC.B    {VisibleFlag}
        DC.B    0
        DC.B    {GoawayFlag}
        DC.B    0
        DC.B    0,0,0,0
        DC.B    {DITL}>>8,{DITL}
        DC.B    0,0
        |

MACRO   MakeALRT        ID,RectTop,RectLeft,RectBottom,RectRight,DITL,Stages =
        RESOURCE        'ALRT' {ID} 'z'
        DC.B    {RectTop}>>8,{RectTop},{RectLeft}>>8,{RectLeft}
        DC.B    {RectBottom}>>8,{RectBottom},{RectRight}>>8,{RectRight}
        DC.B    {DITL}>>8,{DITL}
        DC.B    {Stages}>>8,{Stages}
        |

MACRO   MakeDITL        ID,Count =
        RESOURCE        'DITL' {ID} 'z'
        DC.B    0,{Count}-1
        |

MACRO   DITLButn        EnableFlag,RectTop,RectLeft,RectBottom,RectRight,Text =
        DC.B    0,0,0,0
        DC.B    {RectTop}>>8,{RectTop},{RectLeft}>>8,{RectLeft}
        DC.B    {RectBottom}>>8,{RectBottom},{RectRight}>>8,{RectRight}
        DC.B    4+{EnableFlag}
        DC.B    {Text}
        |

MACRO   DITLEdit        EnableFlag,RectTop,RectLeft,RectBottom,RectRight =
        DC.B    0,0,0,0
        DC.B    {RectTop}>>8,{RectTop},{RectLeft}>>8,{RectLeft}
        DC.B    {RectBottom}>>8,{RectBottom},{RectRight}>>8,{RectRight}
        DC.B    16+{EnableFlag}
        DC.B    0
        |

MACRO   DITLStat        EnableFlag,RectTop,RectLeft,RectBottom,RectRight,Text =
        DC.B    0,0,0,0
        DC.B    {RectTop}>>8,{RectTop},{RectLeft}>>8,{RectLeft}
        DC.B    {RectBottom}>>8,{RectBottom},{RectRight}>>8,{RectRight}
        DC.B    8+{EnableFlag}
        DC.B    {Text}
        |

MACRO   DITLIcon        EnableFlag,RectTop,RectLeft,RectBottom,RectRight,ID =
        DC.B    0,0,0,0
        DC.B    {RectTop}>>8,{RectTop},{RectLeft}>>8,{RectLeft}
        DC.B    {RectBottom}>>8,{RectBottom},{RectRight}>>8,{RectRight}
        DC.B    32
        DC.B    2               ; Always enabled
        DC.B    {ID}>>8,{ID}
        |

MACRO   MakeICON        ID =
        RESOURCE        'ICON' {ID} 'z'|

MACRO   LongHex V =
        DC.B    {V}>>24,{V}>>16,{V}>>8,{V}|

        RESOURCE        'MENU' 1 'z'
        DC.B    0,1
        DC.B    0,0
        DC.B    0,0
        DC.B    0,0
        DC.B    0,0
        LongHex $FFFFFFFB
        DC.B    $01,$14
        MenuItem        'About Fedit...',0,0
        MenuItem        '-',0,0
        DC.B    0
        
        MakeMENU        'File',2,$FFFFFFF7
        MenuItem        'Open Volume...',0,0
        MenuItem        'Open File...',0,0
        MenuItem        'Close',0,0
        MenuItem        'Quit',0,$51
        DC.B    0

        MakeMENU        'Edit',3,$FFFFFDAF
        MenuItem        'Read Next Block',0,$4E
        MenuItem        'Read Previous Block',0,$50
        MenuItem        'Read Block...',0,$42
        MenuItem        '-',0,0
        MenuItem        'Write Block',0,$57
        MenuItem        '-',0,0
        MenuItem        'ASCII Modify',0,$41
        MenuItem        'Hex Modify',0,$48
        MenuItem        '-',0,0
        MenuItem        'Undo Changes',0,$5A
        DC.B    0
        
        MakeMENU        'Options',4,$FFFFFFF1
        MenuItem        'Resource Fork',0,0
        MenuItem        'Data Fork',0,0
        MenuItem        '-',0,0
        MenuItem        'Display in Hex',0,0
        MenuItem        'Display in ASCII',$12,0
        DC.B    0

        MakeMENU        'Display',5,$FFFFFFF9
        MenuItem        'File Information',0,0
        MenuItem        'Disk Information',0,0
        DC.B    0

        MakeMENU        '*** ASCII modify command active ***',6,$FFFFFFFD
        MenuItem        '-',0,0
        MenuItem        'End Modifications',0,$43
        DC.B    0

        MakeMENU        '*** Hex modify command active ***',7,$FFFFFFFD
        MenuItem        '-',0,0
        MenuItem        'End Modifications',0,$43
        DC.B    0
        
        MakeSTR 257,'Hex:'
        MakeSTR 258,'Position:'
        MakeSTR 259,'Block:'
        MakeSTR 260,'Logical EOF is after position'
        MakeSTR 261,'in this block'

        MakeDLOG        51,60,120,220,400,Visible,NoGoAway,1,51
        MakeDLOG        52,100,152,236,360,Visible,NoGoAway,1,52
        MakeDLOG        53,100,55,185,455,Visible,NoGoAway,1,53

        MakeALRT        21,100,96,228,416,21,$4444
        MakeALRT        22,100,96,228,416,22,$4444
        MakeALRT        23,100,96,228,416,23,$4444
        MakeALRT        24,100,96,228,416,24,$4444
        MakeALRT        25,100,96,228,416,25,$4444
        MakeALRT        26,100,96,228,416,26,$4444
        MakeALRT        27,100,96,228,416,27,$4444
        MakeALRT        28,100,96,228,416,28,$4444
        MakeALRT        29,100,96,228,416,29,$4444
        
        MakeDITL        21,4
        DITLButn        Enabled,90,50,116,150,'No'
        DITLButn        Enabled,90,180,116,280,'Yes '
        DITLIcon        Enabled,30,20,62,52,1
        DITLStat        Enabled,23,70,84,310,'Do you really want to discard the changes that you have made to this block? '
        
        MakeDITL        22,3
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,0
        DITLStat        Enabled,25,70,84,310,'Unable to open that fork because it has no disk blocks allocated. '
        
        MakeDITL        23,3
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,0
        DITLStat        Enabled,25,70,84,310,'An error occurred while attempting to open the file on disk.'
        
        MakeDITL        24,3
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,0
        DITLStat        Enabled,25,70,84,310,'An error occurred while attempting to read a block from the disk file.'
        
        MakeDITL        25,3
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,0
        DITLStat        Enabled,25,70,84,310,'An error occurred while attempting to rewrite this block in the disk file.'
        
        MakeDITL        26,4
        DITLButn        Enabled,90,50,116,150,'Cancel'
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,1
        DITLStat        Enabled,25,70,84,310,'Are you sure you want to write this block to disk?'
        
        MakeDITL        27,3
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,0
        DITLStat        Enabled,25,70,84,310,'An error occurred while attempting to read a block from the disk volume.'
        
        MakeDITL        28,3
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,0
        DITLStat        Enabled,25,70,84,310,'An error occurred while attempting to write this block to disk. '
        
        MakeDITL        29,3
        DITLButn        Enabled,90,180,116,280,'OK'
        DITLIcon        Enabled,22,20,54,52,0
        DITLStat        Enabled,25,70,84,310,'This file cannot be displayed because it contains no data or resource blocks. '
        
        MakeDITL        51,4
        DITLStat        Enabled,30,70,50,270,'File and Volume Edit Program'
        DITLStat        Enabled,100,25,116,260,'This program was written for the'
        DITLStat        Enabled,120,35,136,260,'Macintosh by John H. Mitchell '
        DITLIcon        Enabled,24,20,56,52,511
        
        MakeDITL        52,5
        DITLButn        Enabled,59,12,77,92,'Open'
        DITLButn        Enabled,100,12,118,92,'Cancel'
        DITLButn        Enabled,59,116,77,196,'Eject '
        DITLButn        Enabled,100,116,118,196,'Drive '
        DITLStat        Disabled,20,70,38,196,' '
        
        MakeDITL        53,4
        DITLButn        Enabled,50,250,72,325,'OK'
        DITLButn        Enabled,50,80,72,155,'Cancel'
        DITLStat        Disabled,20,20,36,300,'Enter number of block to read from disk '
        DITLEdit        Disabled,20,320,36,380
        
        MakeICON        511
        LongHex $0007FF80
        LongHex $00080000
        LongHex $00087E20
        LongHex $00080120
        LongHex $00080120
        LongHex $04080120
        LongHex $0C080120
        LongHex $08080120
        LongHex $66080120
        LongHex $99080120
        LongHex $8108FE20
        LongHex $80080020
        LongHex $80080020
        LongHex $4A001F20
        LongHex $34000020
        LongHex $00FC0020
        LongHex $03000000
        LongHex $0401FFF0
        LongHex $04000008
        LongHex $03E01FE4
        LongHex $00100552
        LongHex $001000A9
        LongHex $00200001
        LongHex $002001FE
        LongHex $00180000
        LongHex $00040000
        LongHex $0000C000
        LongHex $00012000
        LongHex $00025000
        LongHex $00008800
        LongHex $00000800
        LongHex $00001000
        
        END

26-Oct-84 19:15:10-PDT,394;000000000001
Return-Path: <tdn@cmu-cs-spice.arpa>
Received: from CMU-CS-SPICE.ARPA by SUMEX-AIM.ARPA with TCP; Fri 26 Oct 84 19:15:05-PDT
Date: Friday, 26 October 1984 22:01:52 EDT
From: Thomas.Newton@cmu-cs-spice.arpa
To: info-mac@sumex-aim.arpa
Subject: FEdit.Link
Message-ID: <1984.10.27.2.0.41.Thomas.Newton@cmu-cs-spice.arpa>

!START
]
/OUTPUT Fedit
FEDIT1
FEDIT2

/RESOURCES
FEDITR
$
-------

info-mac@uw-beaver (info-mac) (10/29/84)

From: Thomas.Newton@cmu-cs-spice.arpa
The other day, I downloaded the FEdit sources from Compuserve.  At first
glance, they seem to be for the earlier version of FEdit (the one without
the File Finder Attributes menu item).  My next four messages contain the
FEdit sources, which I assume will be intercepted and archived on sumex.
The files are named FEdit1.Asm, FEdit2.Asm, FEdit.Link, and FEditR.Asm.

[Ed. Files are on {SUMEX}<INFO-MAC>. They will also be sent to FA.INFO-MAC]