;SAVBIOS.Z80 Version 1.1 by Jon Schneider ; Z-Node #39 915-592-4976 ; ;Based on SYSGEN1.ASM Version 1.1 by Edward J. Mckinnon ; Acton, Ca. (805) 269-1124 ; ; This program will allow those running a modified version of ; Montezuma Micro's CP/M 2.2 to run CONFIG and then save the modified ; BIOS to the disk without trashing the CCP or BDOS (which CONFIG ; would do if you were running an altered CCP or BDOS). ; All that is necessary is to NOT use the save changes to disk ; option in CONFIG, but instead exit CONFIG, and save the changes by ; calling this program. ; ; EQUATES ; base equ 0 conout equ 2 bdos equ 5 dmaset equ 26 seldriv equ 14 ; true equ 0ffh false equ 0 cr equ 13 lf equ 10 bs equ 008h cls equ 01ah ; lastsec equ 36 ; Last sector for BIOS ; org 100h ; ; Set up new stack - initialize BIOS routines ; ld hl,0 add hl,sp ld (stack),hl ; Save old stack ld sp,stack ; Set up new stack call setaddr ; Find BIOS addresses call ilprt db cr,lf,cls,16h,' SAV-BIOS Ver 1.1 - for MM CP/M ' db cr,lf,' (c) 1985 by Jon Schneider ',16h,0 askdest call ilprt db cr,lf,lf,'Enter destination drive ',cr,lf,cr,lf db '[A,B,etc., or ENTER to abort] -->[ ]',bs,bs,0 ld a,00 call keyin ; Get the character from console cp cr ; CR to abort? jp z,exit1 ; Yes then skip and back to cpm call seldrv ; Select the disk drive call ilprt db cr,lf,cr,lf,'Writing BIOS to disk.',cr,lf,0 ; sector ld a,(sectnum) ; Set sector call settrk call setsec call setdma ; Set to next buffer block call write ; next call nxtblk ; Next 128 bytes call nxtsec ; Increment sector count jp nz,sector ; Continue if not to sector 35 jp exit ; All done ; ;Subroutines ; keyin ld c,01 ; Get character from keyboard call 0005 cp 'a' ; Make sure upper case ret c cp 'z'+1 ret nc and 5fh ret ; nxtblk ld hl,(biosptr) ; Increment the pointer in memory ld de,80h add hl,de ld (biosptr),hl ret ; ;Set SECCNT to next sector ; nxtsec ld a,(sectnum) inc a cp lastsec ; Last sector yet? jp z,secdone ld (sectnum),a ret ; Zero flag reset if not done ; secdone xor a ld (sectnum),a ret ; Zero flag set if done ; ; ;Select drive ; seldrv sub 'A' ; Convert drive number from ASCII push af push bc push de push hl ld e,a ld c,seldriv call bdos pop hl pop de pop bc pop af ret ; ;Initialize BIOS direct access routines ; setaddr ld hl,(base+1) ld l,1eh ; Point to settrk ld (vsettrk+1),hl ld l,21h ; Point to setsec ld (vsetsec+1),hl ld l,2ah ; Point to write ld (vwrite+1),hl ld hl,(base+1) ; Get base address of BIOS dec l dec l dec l ld (biosptr),hl ret ; ;Send character to screen ; ctype push af push bc push de push hl ld e,a ld c,conout ; Via BDOS call bdos pop hl pop de pop bc pop af ret ; ; Print message ; ilprt ex (sp),hl ; Exchange sp&hl loop ld a,(hl) ; Get character or a ; Set flags jp z,ilpret ; Is it 0 call ctype ; Output character inc hl ; Set to next character jp loop ; Not done yet ; ilpret ex (sp),hl ; Exchange sp&hl - set sp to msg + 1 ret ; setdma push af push bc push de push hl ld hl,(biosptr) ex de,hl ld c,dmaset ; Via BDOS call bdos pop hl pop de pop bc pop af ret ; ;Set track ; settrk push af push bc push de push hl ld b,0 ld c,1 vsettrk call $-$ ; Filled in at run time pop hl pop de pop bc pop af ret ; ;Set Sector ; setsec push af push bc push de push hl ld b,0 ld c,a vsetsec call $-$ ; Filled in at run time pop hl pop de pop bc pop af ret ; ; ;Write to specified track and sector ; write push af push bc push de push hl ld a,0 ; Say its a normal write vwrite call $-$ ; Filled in at run time or a jp nz,dskerr pop hl pop de pop bc pop af ret ; ;Exit to CP/M ; exit call ilprt db cr,lf,'New Configuration Saved!',0 exit1 call ilprt db cr,lf,0 ld hl,(stack) ld sp,hl jp 0000 ; Warm boot to flush buffers ; ;Error messages ; ; dskerr call ilprt db cr,lf,'Disk drive error',cr,lf,0 jp exit1 ; ;Variable storage ; biosptr dw 0 sectnum db 10 ds 24 stack ds 2 ; end