;--------------------------------------------------------------------- ; PCW8256.A86 version 2.0 for LSI M-FOUR and CAL-PC computers ; 13-NOV-87 ; Stephen Hunt ;--------------------------------------------------------------------- ; ; ; configure drive B, C or D to Amstrad PCW8256 ss dd format. ; ; Will only be of use if a 3" drive is fitted as the right ; hand drive on dual floppies machines, or the left hand ; drive drive on hard disk machines. ; ; ;--------------------------------------------------------------------- ; prom related equates label_seg equ 0ffffh ; label segment label_ofst equ 05h ; label offset prom_seg equ 0fc00h ; prom segment get_switch equ 03055h ; get switch function (prom call) ; character equates cr equ 0dh ; carriage return lf equ 0ah ; line feed eof equ 01ah ; end of file esc equ 01bh ; escape bit0 equ 00000001b bit1 equ 00000010b bit2 equ 00000100b bit3 equ 00001000b bit4 equ 00010000b bit5 equ 00100000b bit6 equ 01000000b bit7 equ 10000000b cpm equ 0e0h ; macro to CALLF to prom (asm86 does not understand 'CALLF SEG:OFST') codemacro call_prom func_call:dw db 09ah dw func_call dw 0fc00h endm ;--------------------------------------------------------------------- ; CODE SEGMENT ;--------------------------------------------------------------------- cseg org 0000h ;--------------------------------------------------------------------- ; jump past my copywrite message ;--------------------------------------------------------------------- start: ; jmp check_os vers db '(C) STEPHEN HUNT 13-NOV-87, Disk Patch Version 2.0',eof ;--------------------------------------------------------------------- ; check that the operating system is BDOS version 2.x ;--------------------------------------------------------------------- check_os: ; mov cl,0ch ; get o/s version number int cpm and al,0f0h ; mask of lower nyble cmp al,020h ; check version 2.x jz get_machine_type; if ok jump forward ;--------------------------------------------------------------------- ; incorrect BDOS version, so print error & terminate ;--------------------------------------------------------------------- wrong_bdos_version: ; mov dx,offset wrong_version jmp exit_msg ; print message & exit ;--------------------------------------------------------------------- ; check that the machine is a CAL-PC or LSI-M4 ;--------------------------------------------------------------------- get_machine_type: ; mov ax,label_seg mov es,ax mov si,offset m4_label mov di,label_ofst mov cx,06h cld rep cmpsb mov bl,00h ; 0 = LSI-M4 jz set_mc_type mov si,offset cal_label mov di,label_ofst mov cx,06h rep cmpsb mov bl,01h ; 1 = CAL-PC jz set_mc_type mov bl,02h ; 2 = UNKNOWN ;--------------------------------------------------------------------- ; print machine type, and exit if not CAL-PC or LSI-M4 ;--------------------------------------------------------------------- set_mc_type: ; mov mc_type,bl xor bh,bh add bx,bx add bx,offset machines mov dx,[bx] call print_string cmp mc_type,02h jb valid_hware jmp reset ;--------------------------------------------------------------------- ; print signon message ;--------------------------------------------------------------------- valid_hware: ; mov dx,offset signon call print_string ;--------------------------------------------------------------------- ; get system dip switch setting ;--------------------------------------------------------------------- ; settings returnend in AL as follows: ; ; bit 0 - double sided drives ; bit 1 - quad density drives ; bit 2 - 8 inch drives ; bit 3 - hard disk present ; bit 4 - 2 floppy drives present (else only 1) ; bit 5 & 6 - hard disk type: ; 0 0 - 5 Mb ST-412 (M4) or Rodime RO201 (CAL) ; 0 1 - 10 Mb Rodime RO202 ; 1 0 - 15 Mb Rodime RO203 ; 1 1 - 20 Mb Rodime RO204 ; bit 7 - half height 5 inch floppy drives fitted ;--------------------------------------------------------------------- get_system_type_switch: ; call_prom get_switch mov dip_sw,al ;--------------------------------------------------------------------- ; if 8 inch floppy drives fitted print message & exit ;--------------------------------------------------------------------- test_drive_size: ; test al,bit2 ; test for 8" drives jz test_number_drives mov dx,offset eight_inch ; error message jmp exit_msg ; print message & exit ;--------------------------------------------------------------------- ; test if 1 or 2 floppies, if only 1 drive test also for hard disk ; if 2 drives set drive C, right hand drive ;--------------------------------------------------------------------- test_number_drives: ; test al,bit4 ; test for 1 or 2 floppy drives jz test_winchester ; if 1 drive, test for winchester mov drive,02h ; set initialy to drive C: mov drvpos,01h ; set to right hand drive jmp test_number_sides ;--------------------------------------------------------------------- ; test for hard disk, if no hard disk print message & exit ;--------------------------------------------------------------------- test_winchester: ; test al,bit3 ; test for winchester jnz winchester_exists ; if there is a winchester jump forward mov dx,offset one_drive jmp exit_msg ; print message & exit ;--------------------------------------------------------------------- ; hard disk present so set to drive D, left hand drive ;--------------------------------------------------------------------- winchester_exists: ; mov drive,03h ; set initialy to drive D: mov drvpos,0h ; set to left hand drive ;--------------------------------------------------------------------- ; if single sided flopy drives, decrement the drive reference letter ;--------------------------------------------------------------------- test_number_sides: ; test al,bit0 ; test for single or double sided jnz test_density ; if double sided jump forward dec drive ; single sided, so change patch drive ;--------------------------------------------------------------------- ; if quad density floppy drive, set flag in disk controller parameters ;--------------------------------------------------------------------- test_density: ; test al,bit2 ; test for double or quad density drives jz select_drive ; if double, jump forward or flags,bit4 ; set quad density flag ;--------------------------------------------------------------------- ; select required drive via a direct bios call, ; returns the following in this configuration: ; ax = dpb offset ; bx = dpe offset ; es = segment address ;--------------------------------------------------------------------- select_drive: ; mov dx,offset bios_code mov cl,032h int cpm ;--------------------------------------------------------------------- ; if invalid drive (dpb or dpe = 0), print message and exit ;--------------------------------------------------------------------- test_valid_dpb: ; test ax,ax jz drive_select_error test bx,bx jnz set_new_format drive_select_error: ; mov dx,offset select_error jmp exit_msg ; print message & exit ;--------------------------------------------------------------------- ; overwrite the old disk parameters with the new parameters ;--------------------------------------------------------------------- set_new_format: ; mov si,offset new_dpb mov di,ax mov cx,24 cld rep movsb ;--------------------------------------------------------------------- ; get & display the drive that has been patched, and to what format ; before terminating ;--------------------------------------------------------------------- finished_message: ; mov ax,drive add al,'A' mov drv_letter,al mov dx,offset complete ;jmp exit_msg ; print message & exit ;--------------------------------------------------------------------- ; print message at DX, reset all drives, and exit back to CP/M-86 ;--------------------------------------------------------------------- exit_msg: ; call print_string reset: ; reset drives even if errors occur ; mov cl,0dh int cpm exit: ; xor cl,cl xor dl,dl int cpm ;--------------------------------------------------------------------- ; subroutine: print string at offset DX ;--------------------------------------------------------------------- print_string: ; mov cl,09h int cpm ret ;--------------------------------------------------------------------- ; END OF CODE SEGMENT ;--------------------------------------------------------------------- ;--------------------------------------------------------------------- ; DATA SEGMENT ;--------------------------------------------------------------------- dseg org 0100h signon db ' Disk Patch Version 2.0 (C) S.Hunt 13-Nov-87',cr,lf,'$' complete db cr,lf db 'Drive ' drv_letter db 'X' db ': set to Amstrad PCW SS DD format',cr,lf,'$' machines dw offset m_four dw offset cal_pc dw offset unknown m_four db cr,lf,'LSI M-FOUR$' cal_pc db cr,lf,'CAL-PC$' unknown db cr,lf,'Disk Patch only runs on the LSI M-FOUR or CAL-PC$' wrong_version db cr,lf,'Disk Patch Requires CP/M-86 version 2.x$' eight_inch db cr,lf,'Aborting - not configured for 8" drives$' one_drive db cr,lf,'Aborting - not configured for single drive machine' select_error db cr,lf,'Aborting - Unable to access disk parameters$' mc_type db 02h ; machine type dip_sw db 00h ; dip switch setting bios_code db 09h ; select drive function drive dw 00h ; drive code [CX] dw 00h ; " " [DX] m4_label db 'Lsi_M4' cal_label db 'Cal_PC' ; parameters for Amstrad PCW 8256/8512 SS DD drive new_dpb dw 024h ; spt db 03h ; bsh db 07h ; blm db 0h ; exm dw 0aeh ; dsm dw 03fh ; drm db 0c0h ; al0 db 0 ; al1 dw 010h ; cks dw 01h ; off flags db 00h ; parameter flags (initialy SS DD) db 0ah ; retries db 09h ; physical sectors / track drvpos db 01h ; initialy right hand drive db 00h ; ? dw 0168h ; total sectors / disk dw 0200h ; bytes / sector db 0 ;this byte is of no real use ! ;--------------------------------------------------------------------- ; END OF DATA SEGMENT ;--------------------------------------------------------------------- end ;--------------------------------------------------------------------- ; end of Disk Patch v2.00 ;---------------------------------------------------------------------