ӴZBGQ11 COMύZBGQ11 NOT$ZBGQ11 Z80)/4Z3ENVSAVE TABLE:1: .!^#Vz(#N#Fx( #*[!K*  "o& "*"!R"!2R"DM ZBGQUIK, Version 1.1 Save length is |qH pages. *^#V"~#m W ͑ D IIM y yG>GO> ;c̀̀ ڌ7þ0þ Ҿʾʾʾ ʾ ʾ>^;@;O*. ZBGQUIK by Jay Sage (derived from BGQUICK by an unknown author) -------------------- Update to version 1.1 I added code to preserve additional memory areas. I needed this to save my DateStamper buffers (just in case) and the time registers of the SB180 BIOS real time clock. It may be possible to save some video memory areas or other buffers that you do not want to have reset to the state they had when BGQ.COM was saved. I also modified the code to use memory more efficiently. The SYSLIB and Z3LIB routines are needed only when ZBGQUIK is run and are not needed by the saved program code. Therefore, I have now put the memory buffer at the beginning of the library code so that it overwrites and reuses that space. A word of caution. The saved BGQ.COM file cannot be used for an initial loading of BGii with a virgin swap file created by PUTBG. It will only work with an initialized swap file. There may very well be other circumstances in which it will not work, since nothing in done to restore the swap file to the condition it was in when BGQ.COM was saved. Coldbooting my SB180 is a painful process (because of the time required to reinitialize the RAM disk), so I have not experimented fully. I would expect that this technique for reloading BGii is very fragile. -------------------- Version 1.0 This is a rewrite of the very clever BGQUICK by an author who never identified himself in the documentation except with his initials (kls). That program was designed to put one into a complete BGii environment without having to go through the time-consuming process of relinking BG.REL using LOADBG.COM. It was a great blessing! This version has been modified for use with BGii running under ZCPR3. The main difference, besides the fact that the source code is fully commented and uses library routines, is that the ZCPR3 multiple command line buffer is preserved when the quick-load file is run. BGQUICK's file always put one back in the directory one was in when the quick-load file was created, and there could be no further commands on the command line after its invocation. The ZBGQUIK loader program can be used in alias scripts (but don't try running it from a ZEX script -- I'm not sure what would happen, but I don't think it would be what one wanted). To use ZBGQUIK, load BGii and set it up in the configuration you prefer, including OCPs, shells, error handlers, etc. Then enter the command: ZBGQUIK A message will appear in the following form: Save length is nnH pages. where 'nn' is the number of pages you should save. You then enter the command: SAVE nnH BGQ.COM using the number of pages given in the message and whatever name you want to use for your BGii quick-loader. A completely installed version of BGii now resides on disk, so that all you have to do to get in to backgrounder in the future is to run BGQ.COM. BGQUICK and ZBGQUIK work by putting a complete image of the operating system memory (from the DOS pointer over the top of memory to the end of the first page) into a file, which, when it is run, restores that complete image. There are risks with this procedure. It was shown by the original author to work on the Kaypro and Superbrain. I have used it on my SB180. Anything else is up for grabs. (Note that if the status line is on with the Kaypro, it will be restored each time BGQ is run. The screen top, however, will be incorrect, so the status line will come up at some random position on the screen. The original author recommended keeping the staus line off, at least until after entering BGQ.) On the Superbrain, the program will restore the screen to look identical to the original save. On the Kaypro, it will not (memory mapped video is banked in on the Kaypro). Similarly, on the Superbrain, video attributes will not be restored. The method used to leave the multiple command line buffer intact when BGQ is run can be extended in a straightforward way to preserve other buffers (e.g., NDR, shell stack, error handler, etc.). It would even be fairly easy to accept command-line parameters to control whether or not various buffers would be restored or left as is. It would also be possible to enhance the ZBGQUIK code to take a file name on the command line and automatically write the resulting image out to disk instead of making the user perform a manual SAVE. Jay Sage, October 26, 1987 ; 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