Title Cpm 2.2 Rsx for File Closes and Sequential Reads/Writes (31_Aug_84) ; ; Copyright 1984 ; Morrow Designs, Inc. ; San Leandro Ca. ; ; Howard Fullmer ; Namdar Bolour ; John Zalabak .z80 cseg ;---------------------------------------------------------------------- ; Equates (31_Aug_84) ;-------------------- ; ;Rsx Flags No equ 0 ;Remove/Non_Banked is False Yes equ 0FFh ;Remove/Non_Banked is True ;Bdos Function Numbers Bdos_Close equ 16 ;File Close Bdos_Seq_Read equ 20 ;Sequential Read Bdos_Seq_Write equ 21 ;Sequential Write Bdos_GetAlv Equ 27 ;Get Address of Allocation Vector Bdos_GetDpb Equ 31 ; " " " Disk Parameter Block Bdos_GetVer Equ 12 ;Return Cp/m Version Number ;Fcb Offsets Offset_Ex equ 12 ;Current Extent Offset_Cr equ 32 ;Current Record ;Other Equates Alv_Max Equ 460 ;Room for New Allocation Vector (35meg Max) Dsm_Offset Equ 5 ;Offset from beginning of Dpb to Dsm word. ;---------------------------------------------------------------------- ; Rsx Prefix Section (20_Aug_84) ;------------------------------- ; Serial: db 1,2,3,4,5,6 ;Space for the Serial Number Start: db 0C3h ;Jump to Start of Code dw Start_Rsx ;Vector to Start of Code Next: db 0C3h ;Jump to Start of Next Rsx dw 0 ;Vector to Next Rsx Prev: dw 0 ;Address of Previous Rsx or Location 5 Remove: db No ;No to keep Rsx active after Warm Boot NonBank: db No ;No for using both banked & non-banked systems Name: db 'CPM2 ' ;Name of this Rsx Loader: db 0 ;Loader Flag dw 0 ;Reserved page ;---------------------------------------------------------------------- ; Rsx Code (20_Aug_84) ;--------------------- ; Start_Rsx: ld a,c cp Bdos_Close ;If (This is a File Close) jr nz,RdChk call Check_Entry ; Set Cr and Ex if Necessary jp Next ; Continue on to Bdos RdChk: cp Bdos_Seq_Read ;Else If (This is a Sequential Read) jr nz,WrChk call Check_Entry ; Check Entry Conditions push de call Next ; Do The Sequential Read pop de call Check_Exit ; Check the Exit Conditions ret ; Return to Calling Routine WrChk: cp Bdos_Seq_Write ;Else If (This is a Sequential Write) jr nz,AlChk call Check_Entry ; Check Entry Conditions push de call Next ; Do The Sequential Write pop de call Check_Exit ; Check the Exit Conditions ret ; Return Directly to Calling Rtn AlChk: cp Bdos_GetAlv ;Else If (Get Allocation Vector) jr nz,VrChk call Get_Alloc_Vec ; Adjust the Allocation Vector ret ; Return Directly to Calling Rtn VrChk: cp Bdos_GetVer ;Else If (Return Version Number) jp nz,Next ; (continue with Next if its not) ld hl,22h ; HL:= 22 (cpm version 2.2) ld b,h ; B:= H ld a,l ; A:= L ret ; Return Directly to Calling Rtn page ;---------------------------------------------------------------------- ; Check Entry Conditions (20_Aug_84) ;----------------------------------- ; 1) This routine checks if the entry conditions are met: Cr eq 0 ; And Ex ne 0. ; 2) If the entry conditions are met then: Ex:= Ex - 1 and Cr:= 80h ; 3) Register Usage: ; A -> Set to 0 for tests ; DE -> Pointer to Fcb ; IY -> Pointer to Fcb (exit unchanged) ; Check_Entry: push iy ;(Save IY) push de pop iy ;IY:= Start of Fcb ld a,0 or (iy+Offset_Cr) ;If ( (Current Record eq 0) And jr nz,CenSk1 or (iy+Offset_Ex) ; (Extent eq 0) ) jr z,CenSk1 dec (iy+Offset_Ex) ; Extent:= Extent - 1 ld (iy+Offset_Cr),80h ; Current_Record:= 80h CenSk1: pop iy ;(Restore IY) ret ;Return ;---------------------------------------------------------------------- ; Check the Exit Conditions (20_Aug_84) ;-------------------------------------- ; 1) This routine checks if the exit conditions are met: Cr eq 80h. ; 2) If the exit conditions are met then Ex:= Ex + 1 and Cr:= 0. ; 3) Register Usage: ; DE -> Pointer to Fcb ; IY -> Pointer to Fcb (exit unchanged) ; Check_Exit: push iy ;(Save IY) push de pop iy ;IY:= Start of Fcb push af ld a,(iy+Offset_Cr) cp 80h ;If (Current Rec eq 80h) jr nz,CexSk1 inc (iy+Offset_Ex) ; Extent:= Extent + 1 ld (iy+Offset_Cr),0 ; Current_Record:= 0 CexSk1: pop af pop iy ;(Restore IY) ret ;Return page ;====================================================================== ; Convert Allocation Vector (31_Aug_84) ;====================================== ; Get_Alloc_Vec: ld c,Bdos_GetDpb ;C:= Get drive's Dpb Function call Next ;HL:= Drive's Dpb ld de,Dsm_Offset add hl,de ;HL:= Dsm address ld e,(hl) inc hl ld d,(hl) ;DE:= Dsm ld b,3 ;B:= Counter (for divide by 8) AvLp1: srl d rr e ;Divide Dsm by 8 to get # of bytes djnz AvLp1 ;in Temporary Alv. inc de ;(Add 1 in case there was remainder) push de ;Stack:= # of bytes in Temporary Alv ld c,Bdos_GetAlv ;C:= Get Allocation Vector Addr Function call Next ;HL:= System Allocation Vector Address pop bc ;BC:= Count (length of Alv) ; add hl,bc ;Add this to get addr of Permanent Alv. ld de,Alv ;DE:= Destination (local Alv) xor a ;A=0: Read System Memory function. call Extended_Bios ;Transfer Temporary Alv. ld hl,Alv ;HL:= Address of New Alv ld b,h ;B:= H ld a,l ;A:= L ret ;Return to Calling Routine Directly ;-------------------------------------------------------------------- ; Execute one of the extended bios functions ;------------------------------------------- ; Extended_Biosº pusè hl ;Savå param® tï thió subroutine. ld hl,(1) ld l,0 ;HL=Bios cold boot address. ex (sp),hl ;Swap HL Entry Value and Execution Addr ret ;Execute the Caller's Routine ;-------------------------------------------------------------------- ; Data Storage Areas ;------------------- ; Alv: ds Alv_Max,0 ;Local space, 2.2-compatible Alv. end