Listing 1. The code needed to implement the keyboard buffer in the NZCOM virtual BIOS. ; Everything is standard in the KEYBIOS, even the opening ; jump table START: JP BOOT ; Cold boot WBOOTE: JP WBOOT JP CONST JP CONIN JP CONOUT JP LIST JP PUNCH JP READER ; ... standard VBIOS code omitted here ; We make a small change in the auxillary IOP jumps. The ; console status (CONST) and console input (CONIN) entries ; jump to our new code. AUXJMP: CONST: JP KCONST ; Jump to extended routine CONIN: JP KCONIN ; Jump to extended routine CONOUT: JP ICONOT LIST: JP ILIST PUNCH: JP IPUNCH READER: JP IREADR LISTST: JP ILSTST ; End of Header.... The following code is free-form and ; may be moved around if necessary. ; --------------------------------------------------------- ; The new code for the keyboard buffer is inserted right ; after the auxilliary jump table. It starts with an ; identifying signature. Then comes the actual keyin ; buffer followed by the new code. The buffer starts with a ; word that points to the next character to fetch, if any. ; The pointer is initialized to the start of the buffer, ; which is initialized to a null to indicate the end of the ; buffer's contents. ; The following equate defines the number of actual ; characters that the keyboard input buffer can hold, ; exclusive of the terminating null and the header ; information. kbufsize equ 60 db 'KEYIN' ; Signature db kbufsize ; Length of buffer keyptr: dw keybuf ; Pointer to next char keybuf: ds kbufsize,0 ; Fill with nulls db 0 ; Terminating null ; Subroutine to fetch the next key from the keyboard buffer ; and set zero flag if no character. HL is left pointing ; to the pointer to the next character. ktest: ld hl,(keyptr) ; Get ptr to next char ld a,(hl) ; Get the character or a ; Test for null ret ; Extended console status code. It checks the keyboard ; buffer and returns true if there is a character in the ; buffer. Otherwise it passes the call on to the CBIOS. kconst: call ktest ; Test for key in buffer jp z,iconst ; If none, call BIOS ld a,0ffh ; Otherwise return FF ret ; Extended console input code. If there is a character in ; the keyboard buffer, then it is returned and the pointer ; is advanced. Otherwise the CBIOS is called. kconin: call ktest ; Test for key in buffer jp z,iconin ; If none, call BIOS inc hl ; Increment pointer ld (keyptr),hl ; Save it ret ; Return with key in A ; ... the rest of the stardard VBIOS code follows