|
DataMuseum.dkPresents historical artifacts from the history of: RegneCentralen RC850 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about RegneCentralen RC850 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 5376 (0x1500) Types: TextFile Names: »MEMDRV.MAC«
└─⟦9f46c4107⟧ Bits:30005988 Sources for TurboDOS ver. 1.30 device drivers └─⟦this⟧ »MEMDRV.MAC«
.Z80 TITLE DRIVER FOR SEMI DISK IN MEMORY BANK 2 SUBTTL COPYRIGHT (c) by ASE GmbH, Altenstadt, ver.: 16.1.84 NAME ('MEMDRV') ; ;***************************************************************************** ; ; This driver supports the second bank of the 128kb memory expansion ; as an disk drive with a size of 60kb (the area strarting from ; x'F000 is used as common area, so it can't be used by the driver). ; ; copyright (c) by ASE GmbH, Altenstadt ; ;***************************************************************************** ; DRIVES EQU 1 ;Number drives conected FORMPT EQU 0E5H ;FORMAT PATTERN SECSIZ EQU 256 ;sector size SELBN2 EQU 89H ;page 1 bank 2 select address SELBN1 EQU 8BH ;page 2 bank 2 select address SELBN0 EQU 8DH ;page 3 bank 2 select address DSELB2 EQU 88H ;page 1 bank 2 deselect address DSELB1 EQU 8AH ;page 2 bank 2 deselect address DSELB0 EQU 8CH ;page 3 bank 2 deselect address ; PAGE ; HARDWARE INITIALIZATION ; ; During hardware initialization time, the directory area of ; the memory drive will be cleared i.e. filled with X'E5. ; COMMON /?INIT?/ ; DSKIN@::LD HL,CLCODE ;move directory clear code LD DE,0F000H ;to common area LD BC,100 ; LDIR ;move JP 0F000H ;process format code ; CLCODE: .PHASE 0F000H ; LD HL,0 ;set memory address for directory LD B,0 ;set count for 1 sector LD C,4 ;C = blocksize DI IN A,(SELBN1) ;select bank 2 IN A,(SELBN2) ; IN A,(SELBN0) ; LOOP: LD (HL),0E5H ;format code INC HL ; DJNZ LOOP ;format directory DEC C ;4 sectors to format JR NZ,LOOP ; IN A,(DSELB0) ;deselect bank IN A,(DSELB1) ;deselect bank IN A,(DSELB2) ;deselect bank EI RET ;done ; .DEPHASE ; COMMON /?BANK?/ ; DSKDR@::LD A,(IX) ;GET FUNCTION CODE CP 0 ;READ SECTOR(S) JP Z,DREAD ; CP 1 ;WRITE SECTOR(S) JP Z,DWRITE ; CP 2 ;DETERMINE DISK TYPE JP Z,DTYPE ; CP 3 ;SPECIFIC DISK READY JP Z,DREADY ; CP 4 ;FORMAT TRACK JP Z,DFORMA ; LD A,0FFH ;NONE OF THE ABOVE FUNCTIONS, RET ;MUST BE WRONG CALL ; ; ; DREAD: XOR A ;set command to read CALL DREWR ;process common setup code DREAD1: CALL CREWR ;read sector LD (SECADR),HL ;save sector address LD DE,(DMAADR) ;get source address LD HL,SECBUF ;get sector buffer addres LD BC,SECSIZ ;get number of bytes to move LDIR ;move sector to dma address LD HL,(MCOUNT) ;GET NUMBER BYTES TO MOVE LD BC,SECSIZ ;SECTOR LENGTH XOR A ;RESET CARRY BIT SBC HL,BC ;SUBTRACT NUMBERS MOVED LD A,0 ;set good return RET Z ;done if count = 0 LD (MCOUNT),HL ;else restore count LD HL,(DMAADR) ;update the dma address ADD HL,BC ; LD (DMAADR),HL ;and save the DMA address JR DREAD1 ;read the next sector from bank 2 ; ; ; DWRITE: LD A,0FFH ;set write command CALL DREWR ;process common setup code DWRIT1: LD HL,(DMAADR) ;get from address LD DE,SECBUF ;get sector buffer addres LD BC,SECSIZ ;get number of bytes to move LDIR ;move sector to common area CALL CREWR ;write sector LD HL,(MCOUNT) ;GET NUMBER BYTES TO MOVE LD BC,SECSIZ ;SECTOR LENGTH XOR A ;RESET CARRY BIT SBC HL,BC ;SUBTRACT NUMBERS MOVED LD A,0 ;set good return RET Z ;done if count = 0 LD (MCOUNT),HL ;else restore count LD (SECADR),DE ;and save sector address LD HL,(DMAADR) ;update the dma address ADD HL,BC ; LD (DMAADR),HL ;and save the DMA address JR DWRIT1 ;read the next sector from dma address ; ; ; DREWR: LD (RWCMD),A ;save command LD H,(IX+11) ;get dma address LD L,(IX+10) ; LD (DMAADR),HL ;save DMA address LD A,(IX+6) ;get requested sector count LD BC,SECSIZ ;set sector size LD HL,0 ; DREWR1: ADD HL,BC ;transfer count = sector size x count DEC A ;sector count = 0 ? JR NZ,DREWR1 ; LD (MCOUNT),HL ;save number of bytes to move LD A,(IX+4) ;get requested sector number LD D,A ;set sector high address LD E,0 ;set sector low address LD (SECADR),DE ;save sector address RET ; ; CREWR: LD HL,SECBUF ;get sector buffer address in common area LD DE,(SECADR) ;get sector address LD BC,SECSIZ ;get sector size LD A,(RWCMD) ;get requested function OR A ;test request function JR NZ,CREWR1 ;on write request nothing to do EX DE,HL ;else exchange source / destination CREWR1: DI ;select now the memory drive area IN A,(SELBN1) ;select bank 2 IN A,(SELBN2) ; IN A,(SELBN0) ; LDIR ;read or write from or to memory bank 2 IN A,(DSELB0) ;deselect bank 2 IN A,(DSELB1) ; IN A,(DSELB2) ; EI ; RET ;done ; ; ; ; ; ; DTYPE: LD HL,DSKSPT ;GET DISKTYPE TABLE LD (IX+12),L ;SET DISK SPECIFICATION TABLE ADDR. LD (IX+13),H ; LD A,0FFH ;MEANS DRIVE READY RET ;DONE ; ; ; DREADY: LD A,0FFH ;set good return code RET ;done ; ; ; DFORMA: XOR A ;set good return RET ;done ; ; DISKS SPECIFICATION TABLE ; DSKSPT: DB 3H+80H ;BLOCK SIZE = 1k + none removeable DW 60 ;NUMBER OF BLOCKS DB 1 ;NUMBER OF DIRECTORY BLOKS DB 1 ;SECTOR SIZE = 512 DW 240 ;SECTORS PER TRACK DW 1 ;TRACKS PER DISK DW 0 ;RESERVED TRACKS ; RWCMD: DB 0 ;save area for R,W,F commands MCOUNT: DW 0 ;NUMBER OF BYTES TO MOVE DMAADR: DW 0 ;DMA ADDRESS SECADR: DW 0 ;current sector address ; SECBUF: DS 256 ;one sector buffer ; END «eof»