home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
ZCPR33
/
S-Z
/
ZBGQ11.LBR
/
ZBGQ11.ZZ0
/
ZBGQ11.Z80
Wrap
Text File
|
2000-06-30
|
6KB
|
212 lines
; Program: ZBGQUIK
; Author: Jay Sage
; Date: October 26, 1987
; Derivation: BGQUICK by unknown author
version equ 11
; Version 1.0 October 26, 1987
;
; This program builds a complete image of the operating system in memory, from
; the bottom of BGii (determined from the address of the DOS vector in page 0)
; through the first page of memory up to 100h. The image, together with a
; loader constructed by the program, is stored in a new file by a user-entered
; SAVE command.
;
; One refinement is added here to the original code by XXXXXX XXXXXXXX. We
; do not want the ZCPR3 multiple command line to be overwritten. The current
; contents should be copied into the correct location before the reload is
; performed.
; Version 1.1 October 27, 1987
;
; Added code to preserve additional blocks of memory, such as those that
; contain time and date buffers or DateStamper code. There is a list of blocks
; at the beginning of the code that can be patched in using ZPATCH or a
; debugger. Each entry has two words: the starting address in the real
; operating system and the number of bytes to preserve. The table ends with
; a starting address or a length of 0.
;
; A second change was to make the image buffer overlie the library code to
; keep the saved program file shorter. The library routines are only needed
; during the operation of ZBGQUIK, not when the saved program is run.
extrn z3init,print,pa2hc,getcl1
cr defl 13
lf defl 10
tab defl 09
; Standard ZCPR3 header
jp start
defb 'Z3ENV',1 ; ZCPR3 type-1 environment
envaddr:
defw 0 ; Filled in by CCP
; Table of real addresses not to reload. Put clock routines here, for
; example, so that reloading BGii does not set the time back to the value
; when ZBGQUIK was run.
defb 'SAVE TABLE:'
savetbl:
block0:
defw 0ff00h ; Filled in with address and
defw 208 ; ..length of command line buffer
block1:
defw 0 ; Address of block 1
defw 0 ; Length of block1
block2:
defw 0 ; Address of block2
defw 0 ; Length of block2
block3:
defw 0 ; Space for expansion
defw 0
block4:
defw 0 ; Space for expansion
defw 0
block5:
defw 0 ; Space for expansion
defw 0
block6:
defw 0 ; Space for expansion
defw 0
defw 0 ; End of blocks (if not sooner)
; Beginning of code
start:
ld sp,100h ; Set up a local stack
; This code performs two functions. One is to capture the memory the image.
; The second is to perform the reloading when the saved image is invoked
; later. The value in FLAG determines which function is performed. When
; ZBGQUIK is loaded, FLAG has the value FFH so that CAPTURE is run. The
; program resets FLAG to 0 so that the saved program will run RELOAD.
ld a,(flag)
or a
jr nz,capture
; This code will be run after the flag has been set to zero. The entire BGii
; memory environment will be restored by this code.
reload:
; First we save the contents of any memory buffers in the table at the
; beginning of the program. The data for the multiple command line buffer
; was filled in by the CAPTURE code.
ld hl,savetbl ; Point to table of blocks
saveloop:
ld e,(hl) ; Get starting address of block
inc hl ; ..into DE
ld d,(hl)
ld a,d ; See if end of table
or e
jr z,loadmem ; If so, branch to load memory
inc hl
ld c,(hl) ; Load length of block to save
inc hl
ld b,(hl)
ld a,b ; See if length of block is 0
or c
jr z,loadmem ; If so, branch to load memory
inc hl
push hl ; Save table pointer
ld hl,(offset) ; Get offset value
add hl,de ; Calculate destination in image
ex de,hl ; Switch source and destination
ldir ; Copy the block
pop hl ; Get table pointer back
jr saveloop ; Back for any more blocks
; Now we copy the image of the BGii memory environment into the real system.
loadmem:
ld de,(imagebeg) ; Destination for memory image
ld hl,imagebuf ; Source for memory image
ld bc,(imagesiz) ; Size of memory image
ldir ; Restore the BGii environment in toto
jp 0 ; Warm boot
; Here we copy a complete image of the operating system to the end of this
; program and display a message to the user telling him how big a file to
; save.
capture:
ld hl,(envaddr)
call z3init ; Initialize for ZCPR3
call getcl1 ; Set HL to command line buffer
ld (block0),hl ; Save as save block 0
ld l,a ; Move length into HL
ld h,0
ld bc,5 ; Overhead bytes
add hl,bc
ld (block0+2),hl ; Save length to save
ld hl,(6) ; Bottom of BGii
ld (imagebeg),hl ; Save for use by quick loader
ex de,hl ; Switch it into DE
ld hl,imagebuf ; Get address where image is saved
xor a ; Clear carry flag
sbc hl,de ; Get offset from real address to
ld (offset),hl ; ..image and save it
ld hl,0100h ; End of page 1
xor a ; Clear carry flag
ld (flag),a ; ..and set flag to run quick loader
sbc hl,de ; Compute bytes to store
ld (imagesiz),hl ; Save for use by quick loader
ld b,h ; Put count in BC
ld c,l
ex de,hl ; Source (HL) is bottom of BGii
ld de,imagebuf ; Destination
push hl ; Save all the pointers
push de
push bc ; Save size
call print
defb cr,lf
defb 'ZBGQUIK, Version '
defb version/10 +'0','.',version mod 10 + '0'
defb cr,lf
defb ' Save length is ',0
pop hl ; Get size of image into HL
push bc
ld de,imagebuf ; Starting address of buffer
add hl,de ; Ending address in HL
ld a,h ; Number of pages to A
call pa2hc ; Print number of hex pages
call print
db 'H pages.',cr,lf,0
pop bc ; Restore pointers
pop de
pop hl
ldir ; Copy operating system to image
jp 0 ; Warm boot out
flag:
defb 0ffh ; Initial value of flag is 0FFH
offset:
defs 2
imagebeg:
defs 2
imagesiz:
defs 2
imagebuf: ; Memory image goes here
end