%include "nasmorg.mac"

;       SCCSID = @(#)msdata.asm 1.8 85/09/12
%ifndef Kanji
 %iassign Kanji 0
%endif
%ifndef Debug
 %iassign Debug 0
%endif
%ifndef Redirector
 %iassign Redirector 0
%endif
%ifndef ShareF
 %iassign ShareF 0
%endif
 
Break <Uninitialized data overlayed by initialization code>

%define RECORDED none, none
%macro record 2.nolist
%%before:
	%1
%%after:
%assign %%i 0
%rep %%after - %%before
 %assign %%offset %%before + %%i - MSDAT001S
 %xdefine RECORDED RECORDED, %%offset, %2
 %assign %%i %%i + 1
%endrep
%endmacro
 
section DATA
; Init code overlaps with data area below

absolute $

        ORG     0, resb 1
MSDAT001E equ MSDAT001e	; NASM port label
PUBLIC MSDAT001S,MSDAT001E
MSDAT001S       label byte
 
        I_am_nobits    TIMEBUF,6               ; Time read from clock device
        I_am_nobits    DEVIOBUF,2              ; Buffer for I/O under file assignment
;
; The following areas are used as temp buffer in EXEC system call
;
        I_am_nobits    OPENBUF,128             ; buffer for name operations
        I_am_nobits    RenBuf,128              ; buffer for rename destination
; Buffer for search calls
        I_am_nobits    SEARCHBUF,53            ; internal search buffer
        I_am_nobits    DummyCDS,curdirLen
;
; End of contiguous buffer
;
 
;
; Temporary directory entry for use by many routines.  Device directory
; entries (bogus) are built here.
;
DevFCB equ DEVFCB	; NASM port label
        PUBLIC  DevFCB
DEVFCB  LABEL   BYTE                    ; Uses NAME1, NAME2, combined
; WARNING..  do not alter position of NAME1 relative to DEVFCB
; without first examining BUILD_DEVICE_ENT. Look carefully at DOS_RENAME
; as well as it is the only guy who uses NAME2 and DESTSTART.
        I_am_nobits    NAME1,12                ; File name buffer
        I_am_nobits    NAME2,13                ;
        I_am_nobits    DESTSTART,WORD          ;
DIR_ENTRY_struc_size equ dir_entry_struc_size	; NASM port equate
        DB      ((DIR_ENTRY_struc_size) - ($ - DEVFCB)) DUP (?)
;
; End Temporary directory entry.
;
        I_am_nobits    ATTRIB,BYTE             ; storage for file attributes
        I_am_nobits    EXTFCB,BYTE             ; TRUE => extended FCB in use
        I_am_nobits    SATTRIB,BYTE            ; Storage for search attributes
%if EXTFCB + 1 != SATTRIB	; used in macro2.nas
 %error Unexpected layout
%endif
        I_am_nobits    open_access,BYTE        ; access of open system call
        I_am_nobits    FoundDel,BYTE           ; true => file was deleted
        I_am_nobits    Found_dev,BYTE          ; true => search found a device
        I_am_nobits    fSplice,BYTE            ; true => do a splice in transpath
        I_am_nobits    fSharing,BYTE           ; TRUE => no redirection
        I_am_nobits    SECCLUSPOS,BYTE         ; Position of first sector within cluster
        I_am_nobits    TRANS,BYTE              ;
        I_am_nobits    READOP,BYTE             ;
        I_am_nobits    THISDRV,BYTE            ;
        I_am_nobits    CLUSFAC,BYTE            ;
        I_am_nobits    CLUSSPLIT,BYTE          ;
        I_am_nobits    INSMODE,BYTE            ; true => insert mode in buffered read
        I_am_nobits    cMeta,BYTE              ; count of meta'ed components found
        I_am_nobits    VOLID,BYTE              ;
        I_am_nobits    exit_type,BYTE          ; type of exit...
 
        record alignb 2, 90h
 
; WARNING - the following two items are accessed as a word
        I_am_nobits    CREATING,BYTE           ; true => creating a file
        I_am_nobits    DELALL,BYTE             ; true => deleting everything
 
        I_am_nobits    EXITHOLD,DWORD          ; Temp location for proc terminate
        I_am_nobits    user_SP,WORD            ; User SP for system call
        I_am_nobits    user_SS,WORD            ; User SS for system call
        I_am_nobits    CONTSTK,WORD            ;
        I_am_nobits    THISDPB,DWORD           ;
        I_am_nobits    CLUSSAVE,WORD           ;
        I_am_nobits    CLUSSEC,DWORD           ;>32mb                                  AC0000
        I_am_nobits    PREREAD,WORD            ; 0 means preread; 1 means optional
        I_am_nobits    FATBYT,WORD             ; Used by ALLOCATE
        I_am_nobits    FATBYTE,WORD            ; Used by $SLEAZEFUNC
        I_am_nobits    DEVPT,DWORD             ;
        I_am_nobits    THISSFT,DWORD           ; Address of user SFT
        I_am_nobits    THISCDS,DWORD           ; Address of current CDS
        I_am_nobits    THISFCB,DWORD           ; Address of user FCB
        record {I_am_nobits    SFN,WORD,<-1>}, 255           ; SystemFileNumber found for accessfile
        I_am_nobits    JFN,WORD                ; JobFileNumber found for accessfile
        I_am_nobits    PJFN,DWORD              ; PointerJobFileNumber found for accessfile
        I_am_nobits    WFP_START,WORD          ;
        I_am_nobits    REN_WFP,WORD            ;
        I_am_nobits    CURR_DIR_END,WORD       ;
        I_am_nobits    NEXTADD,WORD            ;
        I_am_nobits    LASTPOS,WORD            ;
        I_am_nobits    CLUSNUM,WORD            ;
        I_am_nobits    DIRSEC,DWORD            ;>32mb                                  AC0000
        I_am_nobits    DIRSTART,WORD           ;
        I_am_nobits    SECPOS,DWORD       ;>32mb Position of first sector accessed
        I_am_nobits    VALSEC,DWORD       ;>32mb Number of valid (previously written)
                                        ; sectors
        I_am_nobits    BYTSECPOS,WORD          ; Position of first byte within sector
        I_am_nobits    BYTPOS,4                ; Byte position in file of access
        I_am_nobits    BYTCNT1,WORD            ; No. of bytes in first sector
        I_am_nobits    BYTCNT2,WORD            ; No. of bytes in last sector
        I_am_nobits    SECCNT_DOS,WORD             ; No. of whole sectors
        I_am_nobits    ENTFREE,WORD            ;
        I_am_nobits    ENTLAST,WORD            ;
        I_am_nobits    NXTCLUSNUM,WORD         ;
        I_am_nobits    GROWCNT,DWORD           ;
        I_am_nobits    CURBUF,DWORD            ;
        I_am_nobits    CONSft,DWORD            ; SFT of console swapped guy.
        I_am_nobits    SaveBX,WORD             ;
        I_am_nobits    SaveDS,WORD             ;
        I_am_nobits    restore_tmp,WORD        ; return address for restore world
        I_am_nobits    NSS,WORD
        I_am_nobits    NSP,WORD
        I_am_nobits    EXTOPEN_FLAG,WORD,<0>   ;FT. extended open input flag           ;AN000;
        I_am_nobits    EXTOPEN_ON,BYTE,<0>     ;FT. extended open conditional flag     ;AN000;
        I_am_nobits    EXTOPEN_IO_MODE,WORD,<0>;FT. extende open io mode               ;AN000;
        I_am_nobits    SAVE_DI,WORD            ;FT. extende open saved DI              ;AN000;
        I_am_nobits    SAVE_ES,WORD            ;FT. extende open saved ES              ;AN000;
        I_am_nobits    SAVE_DX,WORD            ;FT. extende open saved DX              ;AN000;
        I_am_nobits    SAVE_CX,WORD            ;FT. extende open saved CX              ;AN000;
        I_am_nobits    SAVE_BX,WORD            ;FT. extende open saved BX              ;AN000;
        I_am_nobits    SAVE_SI,WORD            ;FT. extende open saved SI              ;AN000;
        I_am_nobits    SAVE_DS,WORD            ;FT. extende open saved DS              ;AN000;
        I_am_nobits    HIGH_SECTOR,WORD,<0>    ;>32mb higher sector #                  ;AN000;
        I_am_nobits    HIGH_SECTOR_TEMP,WORD,<0>;>32mb high sector #                   ;AN000;
        I_am_nobits    DISK_FULL,BYTE          ;>32mb indicating disk full when 1      ;AN000;
        I_am_nobits    TEMP_VAR,WORD           ; temporary variable for everyone       ;AN000;
        I_am_nobits    TEMP_VAR2,WORD          ; temporary variable 2 for everyone     ;AN000;
        I_am_nobits    DrvErr,BYTE             ; used to save drive error              ;AN000;
        I_am_nobits    DOS34_FLAG,WORD,<0>     ; common flag for DOS 3.4               ;AN000;
        I_am_nobits    NO_FILTER_PATH,DWORD    ; pointer to orignal path               ;AN000;
        I_am_nobits    NO_FILTER_DPATH,DWORD   ; pointer to orignal path of destination;AN000;
        I_am_nobits   Callback_SS,WORD         ;AN000; call back SS for system call
        I_am_nobits   Callback_SP,WORD         ;AN000; call back SP for system call
        I_am_nobits   Callback_flag,BYTE,<0>   ;AN000; call back flag
 
 
; make those pushes fast!!!
record alignb 2, 90h
StackSize   equ   180h                    ; gross but effective
;;;StackSize   =   300h                    ; This is a "trial" change IBM hasn't
;;;                                        ; made up their minds about
 
;
; WARNING!!!! DskStack may grow into AUXSTACK due to interrupt service.
; This is NO problem as long as AUXSTACK comes immediately before DSKSTACK
;
 
        PUBLIC  RENAMEDMA,AuxStack,DskStack,IOStack
RENAMEDMA   LABEL   BYTE                ; See DOS_RENAME
 
        DB      StackSize DUP (?)       ;
AuxStack    LABEL   BYTE
 
        DB      StackSize DUP (?)       ;
DskStack    LABEL   BYTE
 
        DB      StackSize DUP (?)       ;
IOStack LABEL   BYTE
 
 
; patch space for Boca folks.
; Say What????!!! This does NOT go into the swappable area!
; NOTE: We include the decl of ibmpatch in ms-dos even though it is not needed.
;       This allows the REDIRector to work on either IBM or MS-DOS.
 
PUBLIC  IBMPATCH
IBMPATCH    label byte
        I_am_nobits    PRINTER_FLAG,BYTE,<0>   ; [SYSTEM] status of PRINT utility
        I_am_nobits    VOLCHNG_FLAG,BYTE,<0>   ; [SYSTEM] true if volume label created
        I_am_nobits    VIRTUAL_OPEN,BYTE,<0>   ; [SYSTEM] non-zero if we opened a virtual file
 
; Following 4 variables moved to MSDATA.asm from MSTABLE.asm (P4986)
      I_am_nobits     FSeek_drive,BYTE         ;AN000; fastseek drive #
      I_am_nobits     FSeek_firclus,WORD       ;AN000; fastseek first cluster #
      I_am_nobits     FSeek_logclus,WORD       ;AN000; fastseek logical cluster #
      I_am_nobits     FSeek_logsave,WORD       ;AN000; fastseek returned log clus #
%ifndef BUF2
      record {I_am_nobits     ACT_PAGE,WORD,<-1>}, 255       ;;;;;;; ;BL ; active EMS page                       ;AN000;
%endif

; lDOS extensions
record alignb 2, 90h
	I_am_nobits	CLUSTER_FACTOR_EDR,WORD
	I_am_nobits	CLUSTER_NEXT_EDR,WORD
	I_am_nobits	dosdata_to_doscode,WORD
dosdata_to_doscode_segment equ dosdata_to_doscode
	global dosdata_to_doscode_segment
	record {I_am_nobits	first_umcb, word, <-1>}, 255
	I_am_nobits	enable_uma, byte
	I_am_nobits	alloc_strategy_ext, byte
	I_am_nobits	first_hmcb, word
	I_am_nobits	doslocation3306, byte
	I_am_nobits	doslocation3001, byte
	I_am_nobits	nextmcbinput, word
	I_am_nobits	haltflags, word
	I_am_nobits	backdoor_free_mcb_exec, word
	record {I_am_nobits	backdoor_indicator, dword, <-1, -1>}, 255

	I_am_nobits	shell_return_address, dword
	record {I_am_nobits	shell_return_has_been_freed, byte, <-1>}, 255
	I_am_nobits	create_redirector_called, byte

SWAP_END    LABEL   BYTE
PUBLIC  SWAP_END
 
; THE FOLLOWING BYTE MUST BE HERE, IMMEDIATELY FOLLOWING SWAP_END. IT CANNOT
;   BE USED. If the size of the swap data area is ODD, it will be rounded up
;   to include this byte.
        DB      ?
 
ibmpatch equ IBMPATCH	; NASM port label
            DB      (512+80+32-(SWAP_END-ibmpatch)) DUP (?)
 
MSDAT001e       label byte
 
;.xall
 
; (no prior section) ; DATA    ENDS

