diff --git a/orig/.DS_Store b/orig/.DS_Store deleted file mode 100644 index 9177191..0000000 Binary files a/orig/.DS_Store and /dev/null differ diff --git a/orig/src/ansiterm.22b b/orig/src/ansiterm.22b deleted file mode 100644 index 878b0f6..0000000 --- a/orig/src/ansiterm.22b +++ /dev/null @@ -1,993 +0,0 @@ -1 print "ANSI EMULATION" -;---------------------------------------- -; -; ANSI EMULATION -; -; Emulate the Ansi standard -; N.B. Turned on when Chr -; 27 recieved. -; Entry - A = Char -; Exit - None -; Used - None -; -;---------------------------------------- -.JAnsi BYTE &C9 ; 0 = on, &C9 = off -.Ansi PUSH HL - PUSH DE - PUSH BC - PUSH AF - LD C,A ; Move character into C for safe keeping - CP 27 - JP Z,AnsiMore ; If it is Chr 27 then we haven't just - ; been turned on, so don't bother with - ; all the checking. - LD A,(CharacterNo) ; Character number in sequence - OR A ; Is this the first character? - JP Z,AnsiFirst ; Yes, deal with this strange occurance! - - LD A,C ; Put character back in C to check - - CP ";" ; Is it a semi colon? - JP Z,AnsiSemi - - CP "0" ; Is it a number? - JR C,Ansi_NN ; If <0 then no - CP "9"+1 ; If >9 then no - JP C,AnsiNumber - -.Ansi_NN - CP "?" ; Simple trap for simple problem! - JP Z,AnsiMore - - CP "@" ; Is it a letter? - JP C,AnsiExit ; Abandon if not letter; something wrong - -.AnsiFound - LD A,&C9 - LD (JAnsi),A ; Turn itself off now... - XOR A ; zero end of sequence marker - LD (JScrnBuf),A - LD (JScreenWrite),A - - LD HL,(NumberPos) ; Get value of number buffer - LD A,(HaveLoaded) ; Did we put anything in this byte? - OR A - JR NZ,AF1 - LD (HL),255 ; Mark the fact that nothing was put in -.AF1 INC HL - LD A,254 - LD (HL),A ; Mark end of sequence (for unlimited length - ; sequences) -;*** Disable cursor, because it might well move! - LD A,(CursorOn) - OR A ; Well, what do we have here?! - CALL NZ,ToggleCursor ; If cursor on, then remove - - XOR A - LD (CursorOn),A ; And cursor is now off - LD (CursorCount),A ; Restart count - LD A,&C9 - LD (JChangeCursor),A ; Disable flashing temp. - - LD HL,NumberBuffer ; For the routine called. - LD A,C ; Restore number -; -; Now work out what happens... -; - CP "A" ; Check for supported Ansi characters - JP Z,CUU ; Upwards - CP "B" - JP Z,CUD ; Downwards - CP "C" - JP Z,CUF ; Forward - CP "D" - JP Z,CUB ; Backward - CP "H" - JP Z,CUP ; Locate - CP "f" - JP Z,HVP ; Locate - CP "J" - JP Z,ED ; Clear screen - CP "m" - JP Z,SGR ; Set graphics renditon - CP "K" - JP Z,EL ; Clear to end of line - CP "s" - JP Z,SCP ; Save the cursor position - CP "u" - JP Z,RCP ; Restore the cursor position - -.AnsiExit - LD HL,NumberBuffer ; Numbers buffer position - LD (NumberPos),HL - XOR A - LD (CharacterNo),A ; Next time it runs, it will be the - ; first character - LD (HaveLoaded),A ; We haven't filled this byte! - LD (JChangeCursor),A ; Cursor allowed back again! -.AnsiMore - POP AF - POP BC - POP DE - POP HL - RET - -; -; The various routines needed to handle the filtered characters -; -.AnsiFirst - LD A,255 - LD (CharacterNo),A ; Next character is not first! - LD A,C ; Get character back - LD (AnsiWasFirst),A ; Save first character to check later - CP "(" ; ( and [ have characters to follow - JP Z,AnsiMore ; and are legal. - CP "[" - JP Z,AnsiMore - CP &9B ; CSI - JP Z,AnsiF1 ; Pretend that "[" was first ;-) - LD A,&C9 - LD (JAnsi),A ; Turn itself off now... - XOR A ; and turn the screen back on - LD (JScrnBuf),A - LD (JScreenWrite),A - JP AnsiExit ; = and > don't have anything to follow - ; them but are legal. - ; Others are illegal, so abandon anyway. -.AnsiF1 - LD A,"[" ; Put a "[" for first character - LD (AnsiWasFirst),A - JP AnsiExit - -.AnsiSemi - LD HL,(NumberPos) ; Move the number pointer to the - LD A,(HaveLoaded) ; Did we put anything in this byte? - OR A - JR NZ,AS1 - LD (HL),255 ; Mark the fact that nothing was put in -.AS1 INC HL ; move to next byte - LD (NumberPos),HL - XOR A - LD (HaveLoaded),A ; New byte => not filled! - JP AnsiMore - -.AnsiNumber - LD HL,(NumberPos) ; Get address for number - LD A,(HaveLoaded) - OR A ; If value is zero - JR NZ,AN1 - LD A,C ; Get value into A - SUB "0" ; Remove ASCII offset - LD (HL),A ; Save and Exit - LD A,255 - LD (HaveLoaded),A ; Yes, we _have_ put something in! - JP AnsiMore - -.AN1 - LD A,(HL) ; Stored value in A; TBA in C - ADD A ; 2 * - LD D,A ; Save the 2* for later - ADD A ; 4 * - ADD A ; 8 * - ADD D ; 10 * - ADD C ; 10 * + new num - SUB "0" ; And remove offset from C value! - LD (HL),A ; Save and Exit. - JP AnsiMore - ; Note routine will only work up to 100 - ; which should be okay for this application. - -;-------------------------------- -; GET NUMBER -; -; Gets the next number from -; the list -; -; Entry - HL = address to get -; from -; Exit - HL = next address -; A = value -; IF a=255 then default value -; If a=254 then end of sequence -; Used - None -;-------------------------------- -.GetNumber - LD A,(HL) ; Get number - CP 254 - RET Z ; Return if end of sequence,ie still point to - ; end - INC HL ; Return pointing to next byte - RET ; Else next address and return - -;*** ANSI UP -; -.CUU CALL GetNumber ; Number into A - LD B,A ; Save value into B - CP 255 - JR NZ,CUUlp - LD B,1 ; Default value -.CUUlp LD A,(CursorPosition) ; A <- Row - CP A,B ; Is it too far? - JR C,CUU1 - SUB B ; No, then go back that far. - LD (CursorPosition),A ; Row <- A - JP AnsiExit -.CUU1 LD A,0 ; Make the choice, top line. - LD (CursorPosition),A ; Row <- A - JP AnsiExit - -;*** ANSI DOWN -; -.CUD LD A,(AnsiWasFirst) - CP "[" - JP NZ,AnsiExit ; Ignore ESC(B - CALL GetNumber - LD B,A ; Save value in b - CP 255 - JR NZ,CUDlp - LD B,1 ; Default -.CUDlp LD A,(CursorPosition) ; A <- Row - ADD A,B - CP screen_depth ; Too far? - JP C,CUD1 - LD A,screen_depth-1 ; Too far then bottom of screen -.CUD1 LD (CursorPosition),A ; Row <- A - JP AnsiExit - -;*** ANSI RIGHT -; -.CUF CALL GetNumber ; Number into A - LD B,A ; Value saved in B - CP 255 - JR NZ,CUFget - LD B,1 ; Default -.CUFget LD A,(CursorPosition+1) ; A <- Column - ADD B ; Add movement. - CP 80 ; Too far? - JR C,CUF2 - LD A,79 ; Yes, right edge -.CUF2 LD (CursorPosition+1),A ; Column <- A - JP AnsiExit - -;*** ANSI LEFT -; -.CUB CALL GetNumber ; Number into A - LD B,A ; Save value in B - CP 255 - JR NZ,CUBget - LD B,1 ; Default -.CUBget LD A,(CursorPosition+1) ; A <- Column - CP A,B ; Too far? - JR C,CUB1a - SUB A,B - LD (CursorPosition+1),A ; Column <-A - JP AnsiExit -.CUB1a LD A,0 - LD (CursorPosition+1),A ; Column <-A - JP AnsiExit - -;*** ANSI LOCATE -; -.HVP -.CUP CALL GetNumber - CP 255 - CALL Z,DefaultLine ; Default = 1 - CP 254 ; Sequence End -> 1 - CALL Z,DefaultLine - CP screen_depth+1 ; Out of range then don't move - JP NC,AnsiExit - OR A - CALL Z,DefaultLine ; 0 means default, some strange reason - LD E,A - CALL GetNumber - CP 255 ; Default = 1 - CALL Z,DefaultColumn - CP 254 ; Sequence End -> 1 - CALL Z,DefaultColumn - CP 81 ; Out of range, then don't move - JP NC,AnsiExit - OR A - CALL Z,DefaultColumn ; 0 means go with default - LD D,A - EX HL,DE - DEC H ; Translate from Ansi co-ordinates to hardware - DEC L ; co-ordinates - LD (CursorPosition),HL ; Set the cursor position. - JP AnsiExit - -.DefaultColumn -.DefaultLine - LD A,1 - RET - -;*** ANSI CLEAR SCREEN -; -.ED CALL GetNumber - OR A - JP Z,ED1 ; Zero means first option - CP 254 ; Also default - JP Z,ED1 - CP 255 - JP Z,ED1 - CP 1 - JP Z,ED2 - CP 2 - JP NZ,AnsiExit -;*** Option 2 -; -.ED3 LD HL,0 - LD (CursorPosition),HL ; Home the cursor - - LD A,(JSW_FF) - OR A - JP NZ,ED_Set_LF - - XOR A ; Save inks - CALL SCR_GET_INK - - LD (Ink0),BC - - LD A,1 - CALL SCR_GET_INK - - LD (Ink1),BC - - XOR A ; Blank the inks - LD B,A - LD C,A - CALL SCR_SET_INK - - LD A,1 - LD B,0 - LD C,B - CALL SCR_SET_INK - - CALL MC_WAIT_FLYBACK - - LD HL,&C000 ; From - LD DE,&C001 ; To - LD BC,16383 ; Screen length - LD (HL),0 - LDIR - - XOR A - LD BC,(ink0) - CALL SCR_SET_INK - - LD A,1 - LD BC,(ink1) - CALL SCR_SET_INK - - LD A,&C9 ; Prevent clear screen - LD (JSW_FF),A ; until something written - - CALL SW_FF_Buf ; And clear buffer too. - ; No messing around -- local routines - ; do NOT use Ansi - - JP AnsiExit - -.ED_Set_LF - XOR A ; Note simply so that - LD (JSW_LF),A ; ESC[2J works the same as CTRL-L - JP AnsiExit - -;*** Option 0 -; -.ED1 - LD HL,(CursorPosition) ; Get and save cursor position - LD A,H - OR L - JP Z,ED3 ; If we are at the top of the - ; screen and clearing to the bottom - ; then we are clearing all the screen! - - PUSH HL - - LD A,screen_depth-1 - SUB L ; screen_depth - Row - - LD HL,0 ; Zero start - - OR A ; Do we have any lines to add? - JR Z,ED1_2 ; If no bypass that addition! - - LD B,A ; Number of lines to count - LD DE,80 -.ED1_1 - ADD HL,DE - DJNZ ED1_1 - -.ED1_2 - EX HL,DE ; Value into DE - POP HL - LD A,80 - SUB H ; 80 - Columns - LD L,A ; Add to value before - LD H,0 - ADD HL,DE - - PUSH HL ; Value saved for later - - LD HL,(CursorPosition) ; _that_ value again! - CALL FindCursor ; So where does it all begin? - - POP BC ; Number to blank - PUSH BC ; Save for a moment! - - CALL ScreenBlank ; Now do it! - - LD HL,(CursorPosition) ; Get the cursor position again - CALL GetAddress ; Address in buffer - - POP BC - - CALL BufferBlank - - JP AnsiExit ; Then exit properly - -;*** Option 1 -; -.ED2 - LD HL,(CursorPosition) ; Get and save cursor position - PUSH HL - - LD A,L - - LD HL,0 ; Zero start - - OR A ; Do we have any lines to add? - JR Z,ED2_2 ; If no bypass that addition! - - LD B,A ; Number of lines - LD DE,80 -.ED2_1 - ADD HL,DE - DJNZ ED2_1 - -.ED2_2 - EX HL,DE ; Value into DE - POP HL - LD L,H ; Add to value before - LD H,0 - ADD HL,DE - - PUSH HL ; Value saved for later - - LD HL,0 ; Find the begining! - CALL FindCursor ; So where does it all begin? - - POP BC ; Number to blank - PUSH BC ; Save for a while - - CALL ScreenBlank ; Now do it! - - LD HL,0 ; Find start position - CALL GetAddress ; Address in buffer - POP BC - - CALL BufferBlank - - JP AnsiExit ; Then exit properly - -; *** ANSI CLEAR LINE -; -.EL CALL GetNumber ; Get value - CP 0 - JP Z,EL1 ; Zero & Default are the same - CP 255 - JP Z,EL1 - CP 254 - JP Z,EL1 - CP 1 - JP Z,EL2 - CP 2 - JP NZ,AnsiExit ; Otherwise don't do a thing -;*** Option 2 -; - LD HL,(CursorPosition) - LD H,0 - PUSH HL - CALL FindCursor ; Start of line position - - LD BC,80 ; 80 bytes to clear (whole line) - - CALL ScreenBlank - - POP HL - CALL GetAddress - LD BC,80 - - CALL BufferBlank - - JP AnsiExit - -;*** Option 0 -; -.EL1 LD HL,(CursorPosition) - LD A,80 ; Calculate distance to end of line - SUB H - LD C,A - LD B,0 - PUSH BC - PUSH HL - PUSH BC - CALL FindCursor ; Find current position - POP BC - CALL ScreenBlank - - POP HL - CALL GetAddress - POP BC - - CALL BufferBlank - - JP AnsiExit - -;*** Option 1 -; -.EL2 LD HL,(CursorPosition) - LD C,H ; BC = distance from start of line - LD B,0 - LD H,0 - PUSH BC - PUSH HL - PUSH BC - CALL FindCursor ; Find start of line - POP BC - CALL ScreenBlank - - POP HL - CALL GetAddress - POP BC - - CALL BufferBlank - - JP AnsiExit - -.ScreenBlank -; -; HL = address to clear from -; BC = number of bytes to clear -; Uses/Abuses - Most registers -; - LD D,8 ; Value to add between lines -.ScreenBlank_Next - LD E,8 ; 8 bytes down - PUSH HL -.ScreenBlank_Down - LD A,(JInverse) ; Flag for inverse on. - OR A - JR Z,SBD1 - XOR A ; If off, then fill with zeros. - JR Z,SBD2 -.SBD1 - CPL ; If on (0), load with 255's. -.SBD2 - LD (HL),A ; Loop downwards - LD A,H ; Add offset - ADD D - LD H,A - DEC E ; 1 less line to go - LD A,E - OR A ; Are there any lines left? - JR NZ,ScreenBlank_Down - POP HL - CALL ScreenBlank_Across - DEC BC ; 1 less across now! - LD A,C - OR B - JR NZ,ScreenBlank_Next - - RET - -.ScreenBlank_Across - INC HL ; HL = HL + 1 - LD A,H - AND A,%00000111 ; Mask back into range of screen - ADD A,&C0 ; Add base of screen address - LD H,A - RET - -.BufferBlank -; HL = address -; BC = length - PUSH HL ; 1 for later! - LD D,H - LD E,L -; PUSH HL -; POP DE - INC DE ; DE <- HL +1 - PUSH BC ; Save the value a little longer! - LD (HL),32 ; Blank this area! - LDIR ; *** just like magic *** - ; only I forgot it in 22a! - - - POP BC ; Restore values - POP HL - LD DE,2048 ; Move to attributes block - ADD HL,DE - LD D,H - LD E,L -; PUSH HL -; POP DE - INC DE ; DE = HL + 1 - LD A,(fontset) ; Save in the current values. - LD (HL),A - LDIR - RET - -;*** ANSI SET GRAPHICS RENDITION -; -.SGR CALL GetNumber - CP 254 ; 254 signifies end of sequence - JP Z,AnsiExit - OR A - CALL Z,AllOff - CP 255 ; Default means all off - CALL Z,AllOff - CP 1 - CALL Z,BoldOn - CP 2 - CALL Z,BoldOff - CP 4 - CALL Z,UnderOn - CP 5 - CALL Z,ItalicOn - CP 6 - CALL Z,ItalicOn - CP 7 - CALL Z,InverseOn -IF Colour - CP 8 - CALL Z,Samebackfore - CP 29 ; 30 to 37 are foreground colours. - CALL NC,Back_Fore -ENDIF - JP SGR ; Code is re-entrant - -;-------------------------------- -; -; RESET GRAPHICS -; -; Entry - None -; Exit - None -; Used - None -;-------------------------------- -.AllOff - PUSH AF ; Save registers - LD A,&C9 ; = off - LD (JBold),A ; Turn the flags off - LD (JItalics),A - LD (JUnder),A - LD (JInverse),A -IF Colour - LD (JSmash),A - LD (JHighInt),A - XOR A ; Reset background to black - LD (backcolour),A - LD A,7 ; Reset foreground to white - LD (forecolour),A -ENDIF - XOR A - LD (fontset),A ; Reset the bit map store - POP AF ; Restore register - RET - -;-------------------------------- -; -; TURN BOLD ON -; -; Entry - None -; Exit - None -; Used - None -;-------------------------------- -.BoldOn PUSH AF ; Save register - XOR A ; 0 means on - LD (JBold),A -IF Colour - LD (JHighInt),A - LD A,(forecolour) ; And update the foreground colour, - CP 8 ; (if less than 8) - JR NC,BOn1 - OR A ; so long as it is not 0. - JR Z,BOn1 - ADD 8 - LD (forecolour),A - LD A,&C9 ; If bold is on, then it only affects fore. - LD (JSmash),A ; So we MUST NOT clear the character. -.BOn1 -ENDIF - LD A,(fontset) - SET 0,A ; turn ON indicator flag - LD (fontset),A - POP AF ; Restore register - RET - -;-------------------------------- -; -; TURN BOLD OFF -; -; Entry - None -; Exit - None -; Used - None -;-------------------------------- -.BoldOff - PUSH AF ; Save register - PUSH BC - LD A,&C9 ; &C9 means off - LD (JBold),A -IF Colour - LD (JHighInt),A - LD A,(forecolour) ; And update the foreground colour - CP 8 ; so long as it is above 8. - JR C,BO1 - SUB 8 - LD (forecolour),A - LD C,A - LD A,(backcolour) - LD B,A - LD A,C - CALL SmashThem ; Do we now clear the colour? -.BO1 -ENDIF - LD A,(fontset) - RES 0,A ; turn OFF indicator flag - LD (fontset),A - POP BC - POP AF ; Restore register - RET - -;-------------------------------- -; -; TURN ITALICS ON -; (replaces flashing) -; Entry - None -; Exit - None -; Used - None -;-------------------------------- -.ItalicOn - PUSH AF ; Save AF - XOR A - LD (JItalics),A ; 0 means on - LD A,(fontset) - SET 1,A ; turn ON indicator flag - LD (fontset),A - POP AF ; Restore register - RET - -;-------------------------------- -; -; TURN UNDERLINE ON -; -; Entry - None -; Exit - None -; Used - None -;-------------------------------- -.UnderOn - PUSH AF ; Save register - XOR A ; 0 means on - LD (JUnder),A - LD A,(fontset) - SET 2,A ; turn ON indicator flag - LD (fontset),A - POP AF ; Restore register - RET - -;-------------------------------- -; -; TURN INVERSE ON -; -; Entry - None -; Exit - None -; Used - None -;-------------------------------- -.InverseOn - PUSH AF ; Save register - XOR A ; 0 means on - LD (JInverse),A -IF Colour - LD A,(backcolour) ; Save back colour - PUSH AF - LD A,(forecolour) ; Copy fore colour into back colour - LD (backcolour),A - POP AF ; Retrieve back colour, and copy into - LD (forecolour),A ; fore colour -ENDIF - LD A,(fontset) - SET 3,A ; turn ON indicator flag - LD (fontset),A - POP AF ; Restore AF - RET - -;-------------------------------- -; -; SET FOREGROUND COLOUR -; TO BACKGROUND -; -; Entry - None -; Exit - None -; Used - None -; -;-------------------------------- -IF Colour -.Samebackfore - PUSH AF - LD A,(backcolour) ; Get background colour - LD (forecolour),A ; Save into foreground colour - XOR A - LD (JSmash),A ; Turn Smash! on. - LD A,(fontset) - SET 4,A ; turn ON indicator flag - LD (fontset),A - POP AF - RET - -;-------------------------------- -; -; BACK/FORE GROUND -; -; Entry - A = >39 for fore -; >29 for back -; Exit - None -; Used - None -; -;-------------------------------- -.Back_Fore - CP 39 - JR NC,BackGround -; otherwise drop through to foreground colour. - -;-------------------------------- -; -; SET FOREGROUND COLOUR -; -; Entry - None -; Exit - None -; Used - None -; -;-------------------------------- -.foreground - PUSH AF - PUSH BC - SUB 30 ; Bring down to 0 base. - OR A ; If not zero then - CALL NZ,JHighInt ; Add 8 if high intensity - LD (forecolour),A ; Save colour - LD C,A - LD A,(backcolour) ; get the other one. - LD B,A ; B = background - LD A,C ; A = foreground - CALL SmashThem ; Toggle smash? -; CP A,B ; are they the same? -; JR Z,fg1 -; LD A,&C9 ; RET -; LD (JSmash),A ; turn off smash! -; POP BC -; POP AF -; RET -;.fg1 -; XOR A -; LD (JSmash),A ; turn smash! on - POP BC - POP AF - RET - -;-------------------------------- -; -; SET BACKGROUND COLOUR -; -; Entry - None -; Exit - None -; Used - None -; -;-------------------------------- -.background - PUSH AF - PUSH BC - SUB 40 ; Bring down to 0 base. -; CALL JHighInt ; Add 8 if high intensity - ; -- NOT BACKGROUND --?????? - LD (backcolour),A ; Save colour - LD B,A - LD A,(forecolour) ; get the other one. - CALL SmashThem ; Turn smash on? -; CP A,B ; are they the same? -; JR Z,bg1 -; LD A,&C9 ; RET -; LD (JSmash),A ; turn off smash! -; POP BC -; POP AF -; RET -;.bg1 -; XOR A -; LD (JSmash),A ; turn smash! on - POP BC - POP AF - RET - -;------------------------------- -; -; SMASH ON/OFF -; -; Entry - A/B = fore/back -; Exit - Smash on if same -; Underline on if 4 -; Used - AF -; -;------------------------------- -.SmashThem - PUSH AF - CP A,B ; are they the same? - JR Z,STB1 - LD A,&C9 ; RET - LD (JSmash),A ; turn off smash! - LD A,(fontset) - RES 4,A ; turn OFF indicator flag. - LD (fontset),A - POP AF - AND 7 ; Mask out high intensity flag. - OR A ; Is A zero? - JR NZ,ST1 - LD (JInverse),A ; Inverse ON, if 0 - LD A,(fontset) - SET 3,A ; turn ON indicator flag - LD (fontset),A -; LD A,&C9 ; If it is 0 then it cannot be 4!! -; LD (JUnder),A ; Underline off. - RET -.ST1 -; PUSH AF - LD A,&C9 ; Turn inverse off if not 0 - LD (JInverse),A - LD A,(fontset) - RES 3,A ; turn OFF indicator flag. - LD (fontset),A -; POP AF -; CP 4 ; Is it 4? -; JR NZ,ST2 -; XOR A ; If so, turn underline on. -; LD (JUnder),A -; RET -.ST2 -; LD A,&C9 ; Otherwise turn it off. -; LD (JUnder),A - RET - -.STB1 XOR A ; NOP - LD (JSmash),A ; turn smash! on - LD A,(fontset) - SET 4,A ; turn ON indicator flag. - LD (fontset),A - POP AF - RET - -;------------------------------- -; -; SET HIGH INTENSITY -; -; Entry - A = Colour -; Exit - A = Colour or -; A = High Intensity Colour -; Used - None -; -;------------------------------- -.JHighInt - BYTE &C9 ; 0 means on, &C9 means off -.HighInt - ADD 8 - RET -ENDIF - -;*** ANSI SAVE CURSOR POSITION -; -.SCP LD HL,(CursorPosition) ; (backup) <- (current) - LD (Cursor_Pos),HL - JP AnsiExit - -;*** ANSI RESTORE CURSOR POSITION -; -.RCP LD HL,(Cursor_Pos) ; (current) <- (backup) - LD (CursorPosition),HL - JP AnsiExit diff --git a/orig/src/data.22b b/orig/src/data.22b deleted file mode 100644 index 9fe4253..0000000 --- a/orig/src/data.22b +++ /dev/null @@ -1,427 +0,0 @@ -1 PRINT "DATA AND MISC ROUTINES" -;------------------------------------------------------------ -; -; PRINT STRING -; -; Routine to print string, to screen only. -; Entry - HL points to string -; Exit - None -; Used - AF,HL -; -; The top bit of the last letter of the string should -; be set to indicate the end of the string. -; -;------------------------------------------------------------ -.prints LD A,(HL) ; Get first letter - OR A - RET Z ; If zero, then finished. Exit. - CALL TXT_OUTPUT ; To the screen only. - INC HL ; Move to next character - JR prints ; And loop back to print that. - -;----------------------------------------------- -; -; |CDUMP -; -; Simple character based screen dump. -; Entry - None -; Exit - None -; Used - IX,IY -; -; -;----------------------------------------------- -.CharDump - PUSH HL ; Save registers - PUSH DE - PUSH BC - PUSH AF - LD HL,Screen_C ; Screen buffer - LD B,80 - LD C,25 ; 80 chars across by 25 down -.CDLoop LD A,(HL) ; Get character - INC HL ; Next position - CALL MC_PRINT_CHAR ; print it out - JR NC,CD1 - DJNZ CDLoop - JR CD2 ; Go on with life. -.CD1 - CALL kissoflife ; try to fix the problem. - JR NC,abandonprint ; Abandon printing, if timed out - DEC HL ; Try the same character again - JR CDLoop ; Back for more - -.CD2 - LD A,13 ; Send CR/LF as well. - CALL MC_PRINT_CHAR - JR C,CD3 ; If that was okay, go on. - CALL kissoflife ; Try to fix the non response - JR NC,abandonprint - JR CD2 ; Try again then. - -.CD3 - LD A,10 ; Output a LF - CALL MC_PRINT_CHAR - JR C,CD4 - CALL kissoflife ; Try to fix the non response - JR NC,abandonprint - JR CD3 ; Try it gain. - -.CD4 - DEC C ; Zero set if zero now. - LD B,80 ; Restore value of B - JR NZ,CDLoop ; Back for more otherwise - -.printexit - POP AF ; Restore registers - POP BC - POP DE - POP HL - RET - -.abandonprint - LD A,7 ; A beep for failure. - CALL TXT_OUTPUT - JR printexit ; And now exit - -.kissoflife ; Check if printer is alive. - ; C if alive again. - ; NC if dead. - LD DE,20000 ; A few times around -.kol1 - CALL MC_BUSY_PRINTER - CCF ; Pretend it is a MC_READ_PRINTER... - RET C ; If it okay now, return - DEC DE ; Decrease counter. - LD A,D ; And check for zero. - OR E - JR NZ,kol1 ; Once more, unless finished. - OR A ; Reset Carry == NC. - RET - -; This delay should be enough. It should be over half a second -; which on top of the 0.4 of a second in MC_PRINT_CHAR, should be -; enough for most printers. - - -;---------------------------------------- -; -; DATA AREA -; -; All data for the Terminal -; Program is stored here. -; -;---------------------------------------- - -.term_program - TEXT "Ewen-Term ",0 - -.signon_message - TEXT "Ver 2.2b Written by Ewen McNeill (4/4/1991)." - BYTE 13,10,10,0 - -.signoff_terminal - BYTE 13,10 - TEXT "Ewen-Term Exited." - BYTE 13,10,0 - -.abandon_terminal - BYTE 13,10 - TEXT "Ewen-Term failed to find AMSTRAD RS232C RSX's : *ABANDONED*" - BYTE 7,7,7,13,10,0 - -.ESC_key RMEM 1 ; 1 byte to store current ESC setting. -.COPY_key RMEM 1 ; 1 byte to store current COPY setting. -.CLR_key RMEM 1 ; 1 byte to store current CLR setting. -.expansion_token - BYTE 0 ; Two bytes for storage of -.char_position - BYTE 0 ; Macro temporary buffer. -.LDestDel RMEM 1 -.RDestDel RMEM 1 - -.Put_Buffer WORD 0 ; Buffering storage -.Get_Buffer WORD 0 -.From_Buffer DEFB 0 ; Buffering storage -.To_Buffer DEFB 0 -.INK0 RMEM 2 ; Save the ink colours. -.INK1 RMEM 2 -.SetupMessage TEXT 13,"Setup mode for Ewen-Term ",0 -.WordWrapMessage -; TEXT "Do you want word wrap on ? ",0 - TEXT "Word Wrap?",0 -.RemoteEchoMessage -; TEXT "Do you want remote echo on ? ",0 - TEXT "Remote Echo?",0 -.LocalEchoMessage -; TEXT "Do you want local echo on ? ",0 - TEXT "Local Echo?",0 -.LocalDestDelMessage -; TEXT "Do you want local destructive delete on ? ",0 - TEXT "(L) DEST DEL?",0 -.LocalAddLFMessage -; TEXT "Do you want local ADD LF TO CR on ? ",0 - TEXT "(L) ADD LF?",0 -.LocalTabExpandMessage -; TEXT "Do you want local tab expand on ? ",0 - TEXT "(L) TAB EXPAND?",0 -.RemoteDestDelMessage -; TEXT "Do you want remote destructive delete on ? ",0 - TEXT "(R) DEST DEL?",0 -.RemoteAddLFMessage -; TEXT "Do you want remote ADD LF TO CR on ? ",0 - TEXT "(R) ADD LF?",0 -.RemoteTabExpandMessage -; TEXT "Do you want remote tab expand on ? ",0 - TEXT "(R) TAB EXPAND?",0 -.Yes TEXT "Yes.",13,10,0 -.No TEXT "No.",13,10,0 -;.BufferPos WORD AnsiBuffer ; Used by Ansi expander -;.Space RMEM 20 ; Used by Fonts routine -;.Old_Jump RMEM 3 -.Dat1 BYTE 0 -.Dat2 BYTE 0 -;.Bold_Dat JP Bold_Rtn ; Various jumpblocks -;.Italic_Dat JP Italic_Rtn ; ******** -;.Under_Dat JP Under_Rtn ; Removed, because not needed -;.BoldSet BYTE 0 ; in current setup -;.ItalicsSet BYTE 0 ; ******** -;.UnderSet BYTE 0 -;.InverseSet BYTE 0 -;.Bold_Jump RMEM 3 -;.Italics_Jump RMEM 3 -;.Under_Jump RMEM 3 -.Cursor_Pos WORD 0 ; Cursor save position;default 0,0 - -.ScreenOffset WORD 0 ; Offset from &C000 to start of screen - -.Romstate BYTE 0 - -.HaveLoaded BYTE 0 ; To show that a value has been put in - ; for Ansi emualtor. - -.AnsiWasFirst BYTE 0 ; Holds first character of Ansi sequence - -.NumberBuffer - RMEM 20 ; Buffer for numbers in Ansi - -.NumberPos WORD NumberBuffer ; Address within buffer - -.CharacterNo BYTE 0 ; Byte within Ansi sequence. 0=first,255=other - -.CursorBlock RMEM 9 ; Block for cursor event - -.CursorCount BYTE 0 ; 1/50ths of a second since last change - -.FastBlock RMEM 2 ; Buffering blocks -.TickBlock RMEM 7 -.DataAreaHere -.DPrintChar BYTE %00001001 -.DKeyboard BYTE %00000001 -.DRemoteTabExpand - BYTE &C9 -;.Char255 WORD 0 ; ** direct screen writes now ** -.backcolour BYTE 0 -.forecolour BYTE 7 -.namelength BYTE 0 ; For Capture file -.filename RMEM 20 ; Enough for ANY file name! -.fontset BYTE 0 ; Ansi font setup. -.JSW_FF BYTE 0 ; Byte value to turn on/off FF routine -.JSW_LF BYTE 0 ; Byte value to turn on/off LF routine - -.bottom - -.length EQU bottom-top - -IF2 - PRINT "EWEN-TERM 2.2a statistics." - PRINT " Begins = &Top" - PRINT " Ends = &Bottom" - PRINT " Length = &Length" - -ENDIF - -.CurrentLow EQU Bottom MOD &100 -.ToNextPage EQU &100 - CurrentLow - RMEM ToNextPage -.LocalTrans - DB &00,&01,&02,&03,&04,&05,&06,&07,&08,&09,&0A,&0b,&0C,&0D,&0E,&0F - DB &10,&11,&12,&13,&14,&15,&16,&17,&18,&19,&1A,&1B,&1C,&1D,&1E,&1F - DB &20,&21,&22,&23,&24,&25,&26,&27,&28,&29,&2A,&2B,&2C,&2D,&2E,&2F - DB &30,&31,&32,&33,&34,&35,&36,&37,&38,&39,&3A,&3B,&3C,&3D,&3E,&3F - DB &40,&41,&42,&43,&44,&45,&46,&47,&48,&49,&4A,&4B,&4C,&4D,&4E,&4F - DB &50,&51,&52,&53,&54,&55,&56,&57,&58,&59,&5A,&5B,&5C,&5D,&5E,&5F - DB &60,&61,&62,&63,&64,&65,&66,&67,&68,&69,&6A,&6B,&6C,&6D,&6E,&6F - DB &70,&71,&72,&73,&74,&75,&76,&77,&78,&79,&7A,&7B,&7C,&7D,&7E,&08 - DB &80,&81,&82,&83,&84,&85,&86,&87,&88,&89,&8A,&8B,&8C,&8D,&8E,&8F - DB &90,&91,&92,&93,&94,&95,&96,&97,&98,&99,&9A,&9B,&9C,&9D,&9E,&9F - DB &A0,&A1,&A2,&A3,&A4,&A5,&A6,&A7,&A8,&A9,&AA,&AB,&AC,&AD,&AE,&AF - DB &B0,&B1,&B2,&B3,&B4,&B5,&B6,&B7,&B8,&B9,&BA,&BB,&BC,&BD,&BE,&BF - DB &C0,&C1,&C2,&C3,&C4,&C5,&C6,&C7,&C8,&C9,&CA,&CB,&CC,&CD,&CE,&CF - DB &D0,&D1,&D2,&D3,&D4,&D5,&D6,&D7,&D8,&D9,&DA,&DB,&DC,&DD,&DE,&DF - DB &E0,&E1,&E2,&E3,&E4,&E5,&E6,&E7,&E8,&E9,&EA,&EB,&EC,&ED,&EE,&EF - DB &F0,&F1,&F2,&F3,&F4,&F5,&F6,&F7,&F8,&F9,&FA,&FB,&FC,&FD,&FE,&FF -.HighLocalTrans EQU LocalTrans/&100 - -;.LocalBlock -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&00,&00,&00,&00,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -;.HighLocalBlock EQU LocalBlock/&100 - -.RemoteTrans - DB &00,&01,&02,&03,&04,&05,&06,&07,&08,&09,&0A,&0B,&0C,&0D,&0E,&0F - DB &10,&11,&12,&13,&14,&15,&16,&17,&18,&19,&1A,&1B,&1C,&1D,&1E,&1F - DB &20,&21,&22,&23,&24,&25,&26,&27,&28,&29,&2A,&2B,&2C,&2D,&2E,&2F - DB &30,&31,&32,&33,&34,&35,&36,&37,&38,&39,&3A,&3B,&3C,&3D,&3E,&3F - DB &40,&41,&42,&43,&44,&45,&46,&47,&48,&49,&4A,&4B,&4C,&4D,&4E,&4F - DB &50,&51,&52,&53,&54,&55,&56,&57,&58,&59,&5A,&5B,&5C,&5D,&5E,&5F - DB &60,&61,&62,&63,&64,&65,&66,&67,&68,&69,&6A,&6B,&6C,&6D,&6E,&6F - DB &70,&71,&72,&73,&74,&75,&76,&77,&78,&79,&7A,&7B,&7C,&7D,&7E,&08 - DB &80,&81,&82,&83,&84,&85,&86,&87,&88,&89,&8A,&8B,&8C,&8D,&8E,&8F - DB &90,&91,&92,&93,&94,&95,&96,&97,&98,&99,&9A,&9B,&9C,&9D,&9E,&9F - DB &A0,&A1,&A2,&A3,&A4,&A5,&A6,&A7,&A8,&A9,&AA,&AB,&AC,&AD,&AE,&AF - DB &B0,&B1,&B2,&B3,&B4,&B5,&B6,&B7,&B8,&B9,&BA,&BB,&BC,&BD,&BE,&BF - DB &C0,&C1,&C2,&C3,&C4,&C5,&C6,&C7,&C8,&C9,&CA,&CB,&CC,&CD,&CE,&CF - DB &D0,&D1,&D2,&D3,&D4,&D5,&D6,&D7,&D8,&D9,&DA,&DB,&DC,&DD,&DE,&DF - DB &E0,&E1,&E2,&E3,&E4,&E5,&E6,&E7,&E8,&E9,&EA,&EB,&EC,&ED,&EE,&EF - DB &F0,&F1,&F2,&F3,&F4,&F5,&F6,&F7,&F8,&F9,&FA,&FB,&FC,&FD,&FE,&FF -.HighRemoteTrans EQU RemoteTrans/&100 - -;.RemoteBlock -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -; DB &FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF,&FF -;.HighRemoteBlock EQU RemoteBlock/&100 - - - -.AddressBuffer - WORD 0*80+Screen_C - WORD 1*80+Screen_C - WORD 2*80+Screen_C - WORD 3*80+Screen_C - WORD 4*80+Screen_C - WORD 5*80+Screen_C - WORD 6*80+Screen_C - WORD 7*80+Screen_C - WORD 8*80+Screen_C - WORD 9*80+Screen_C - WORD 10*80+Screen_C - WORD 11*80+Screen_C - WORD 12*80+Screen_C - WORD 13*80+Screen_C - WORD 14*80+Screen_C - WORD 15*80+Screen_C - WORD 16*80+Screen_C - WORD 17*80+Screen_C - WORD 18*80+Screen_C - WORD 19*80+Screen_C - WORD 20*80+Screen_C - WORD 21*80+Screen_C - WORD 22*80+Screen_C - WORD 23*80+Screen_C - WORD 24*80+Screen_C -.HighAddressBuffer EQU AddressBuffer/&100 - -.Character - RMEM 8 ; To buffer character to be printed. -.CursorPosition - WORD 0 ; Cursor position, default 0,0. - -.CursorOn - BYTE 0 ; Cursor on/off toggle value - -.Bottom2 ; Realign on page, for above -.CurrentLow2 EQU Bottom2 MOD &100 ; short block -.ToNextPage2 EQU &100 - CurrentLow2 - RMEM ToNextPage2 - -.Amstrad_Screen EQU &C000 -.ScreenAddress - WORD 0*80+Amstrad_Screen - WORD 1*80+Amstrad_Screen - WORD 2*80+Amstrad_Screen - WORD 3*80+Amstrad_Screen - WORD 4*80+Amstrad_Screen - WORD 5*80+Amstrad_Screen - WORD 6*80+Amstrad_Screen - WORD 7*80+Amstrad_Screen - WORD 8*80+Amstrad_Screen - WORD 9*80+Amstrad_Screen - WORD 10*80+Amstrad_Screen - WORD 11*80+Amstrad_Screen - WORD 12*80+Amstrad_Screen - WORD 13*80+Amstrad_Screen - WORD 14*80+Amstrad_Screen - WORD 15*80+Amstrad_Screen - WORD 16*80+Amstrad_Screen - WORD 17*80+Amstrad_Screen - WORD 18*80+Amstrad_Screen - WORD 19*80+Amstrad_Screen - WORD 20*80+Amstrad_Screen - WORD 21*80+Amstrad_Screen - WORD 22*80+Amstrad_Screen - WORD 23*80+Amstrad_Screen - WORD 24*80+Amstrad_Screen -.HighScreenAddress EQU ScreenAddress/&100 - -.HereIam -.HighHere EQU HereIam/&100 -.NextHighHere EQU HighHere + 1 - -.Buffer EQU NextHighHere * &100 -; RMEM 4*256 ; 1024 byte wrap around buffer, Sio in -;.High_Buffer EQU Buffer/&100 - -;.OutBuffer EQU HereIam + Fornexthigh + 1024 ; Length of other - ; buffer. -; RMEM 256 ; 256 byte wrap around buffer, Sio out -;.High_Buffer_Out EQU OutBuffer/&100 -.High_Buffer_Out EQU NextHighHere + 4 -.OutBuffer EQU High_Buffer_Out * &100 - -; -; Used to mark the last address -; -.LastAddress -.TotalLength EQU LastAddress - Top -.TablesLength EQU LastAddress - Bottom -IF2 - PRINT " Tables = &TablesLength" - PRINT "---------------" - PRINT " Total = &TotalLength" - PRINT "---------------" - PRINT " Final = &LastAddress" - PRINT "---------------" - PRINT " " - PRINT "Screen Address = &ScreenAddress" - PRINT "Address Buffer = &AddressBuffer" - PRINT "Out Buffer = &OutBuffer" - PRINT "In Buffer = &Buffer" -ENDIF diff --git a/orig/src/mainline.22b b/orig/src/mainline.22b deleted file mode 100644 index b38b55b..0000000 --- a/orig/src/mainline.22b +++ /dev/null @@ -1,562 +0,0 @@ -1 PRINT "MAINLINE CODE" -; -; TERMINAL MODE begins here -; -; -.term - LD A,2 - CALL SCR_SET_MODE - - CALL KL_U_ROM_DISABLE ; Disable upper rom - LD (RomState),A - - CALL SetBuf ; Setup buffering - - LD A,66 ; ESC key. - CALL KM_GET_TRANSLATE ; Get current normal setting. - LD (ESC_key),A ; Save for later... - - LD A,66 ; Set up the ESC key to return - LD B,27 ; the normal ESC char when pressed - CALL KM_SET_TRANSLATE ; without Control/Shift - - LD A,9 ; COPY key. - CALL KM_GET_TRANSLATE ; Get current normal setting. - LD (COPY_key),A ; Save for later... - - LD A,9 ; Set up the COPY key to return - LD B,255 ; an invalid number when pressed - CALL KM_SET_TRANSLATE ; without Control/Shift - - LD A,16 ; CLR key. - CALL KM_GET_TRANSLATE - LD (CLR_key),A - - LD A,16 ; Make it send CTRL-G - LD B,7 - CALL KM_SET_TRANSLATE - - CALL AllOff - LD IY,DataAreaHere ; Data area of program - - LD A,12 ; Clear screen, and buffer - CALL ToScreen - - LD HL,0 ; No offset, just set mode - LD (ScreenOffset),HL - - CALL SetCursorInterupt ; Turn on interupt! - -; -; MAINLINE -; -.loop CALL Check_exit ; Check for abandoning ESC - JR NZ,exit ; IF ESC pressed then exit -; LD A,7 -; CALL TXT_OUTPUT ; Make a beep! - CALL outside ; Get something if we can - ; and deal with it - XOR A ; Kill the character so it doesn't - ; disturb us later. - CALL keys ; If so, we can send some more, so - ; get a keypress and respond to it.. - CP &FC ; Check for ESC in buffer - JR Z,Exit ; Go to the exit routine if so. - JP loop ; Take it from the top! - -;---------------------------------------- -; -; CHECK EXIT -; -; This routine checks for ESC -; being pressed. -; Entry - None -; Exit - Zero flag set if pressed -; Used - AF -; -;---------------------------------------- -.Check_Exit - LD A,66 ; Test for ESC - PUSH BC ; Save options register - CALL KM_TEST_KEY ; Is key pressed? - CALL NZ,leave ; Test for leave key. - POP BC ; Restore options register - RET - -.leave ; This checks that ESC is pressed - ; with either [SHIFT] or [CONTROL] - BIT 7,C ; Control key? -; RET NZ -; BIT 5,C ; Shift key? - RET - -;---------------------------------------- -; -; EXIT -; -; This routine exits the terminal -; program normally. -; Entry - None -; Exit - Never returns -; Used - AF,BC,HL -;---------------------------------------- - - -.exit - CALL KM_READ_CHAR ; Empty buffer before exiting.. - JR C,exit ; If there is a character then - ; try again. - LD A,(ESC_key) ; Restore ESC key to normal. - LD B,A - LD A,66 - CALL KM_SET_TRANSLATE - LD A,(COPY_key) ; Restore Copy key to normal. - LD B,A - LD A,9 - CALL KM_SET_TRANSLATE - LD A,(CLR_key) ; Restore CLR key. - LD B,A - LD A,16 - CALL KM_SET_TRANSLATE -; CALL TXT_CUR_OFF ; Cursor off -; CALL ToggleCursor ; Cursor now off -.Exit_1 -; CALL AllOff ; All attributes off. - ON ENTRY - - CALL ClearBuffer ; Clear out the buffers, and - ; delete fast ticker block. - LD HL,Signoff_terminal ; Signoff message - CALL prints ; And back to Basic - LD A,1 - LD (DKeyboard),A - LD A,&C9 - LD (JAnsi),A - XOR A - LD (JScrnBuf),A - LD (JScreenWrite),A -; CALL JCloseFile - CALL OffCursorInterupt - LD A,(RomState) - CALL KL_ROM_RESTORE - XOR A - LD (HaveLoaded),A - LD HL,NumberBuffer - LD (NumberPos),HL - RET - -;--------------------------------------- -; -; ABANDON -; -; This routine aborts with an -; error message -; Entry - None -; Exit - Never Returns -; Used - HL -; -;--------------------------------------- -.Abandon - LD HL,Abandon_Terminal - JP Prints - -;--------------------------------------------- -; -; READ KEY -; -; Read the next key from the keyboard -; Entry - None -; Exit - A = Character -; Used - Flags -; -;--------------------------------------------- -.Keys - CALL NotEmpty ; Is the buffer empty? - RET NZ ; don't get a key if it isn't! - CALL Keyboard ; Is there a character there?? - RET NC ; No keys pressed, back to mainline - CP &FC ; Check for ESC in buffer - RET Z ; If so then back to mainline - CP &E0 ; Check for Copy key. - JP Z,CharDump ; Do the screen dump, if pressed - CP 128 ; Check if character >= 128 - JR NC,Handle_Expansion ; If greater then do expansion.. - CALL Sendout ; Output to modem - JP JLocalEcho ; Echo locally if needed. - -;--------------------------------------------- -; -; EXPAND EXPANSION TOKEN -; -; This routine reads the next character -; from the expansion token and sends -; Entry - A = Expansion Token (+128) -; Exit - None -; Used - AF -; -;--------------------------------------------- -.Handle_Expansion - CP 138 ; Only send Macros with a value - ; below 138 (f0-f9) - RET NC - LD (Expansion_Token),A ; Save value of A in memory - XOR A - LD (char_position),A ; Save position in memory - LD A,(DKeyboard) ; Set the routine on. - RES 0,A - SET 1,A - LD (DKeyboard),A - RET - -;---------------------------------------- -; -; GET EXPANSION -; -; Get the next character from an -; expansion token -; Entry - None -; Exit - A = character -; Used - None -; -;---------------------------------------- -.ExpndKey - PUSH DE - PUSH HL - LD A,(char_position) ; Get position - LD L,A - LD A,(Expansion_Token) ; and expansion token - CALL KM_GET_EXPAND - JR NC,EXK_Exit ; If it failed, then we have finished! - SCF ; Set carry to say got character - INC L - PUSH AF - LD A,L - LD (char_position),A ; Save new position - POP AF - POP HL - POP DE - RET -.EXK_Exit - LD A,(DKeyboard) ; Turn this off. - SET 0,A - RES 1,A - LD (DKeyboard),A - SCF ; Clear the carry flag - no char! - CCF - POP HL - POP DE - RET - -;---------------------------------------- -; -; READ SIO -; -; This routine gets a character -; from the SIO and deals with it -; Entry - None -; Exit - None -; Used - AF -; -;---------------------------------------- -.Outside - CALL ReadBuffer ; Call the RSX to read in a character - OR A ; Return if nothing there - JR Z,Out2 -.Out1 CALL JRemoteEcho - JP PrintChar ; Print to screen - -.Out2 ; No need to save A - it MUST contain 0 - LD A,B ; Is there anything in the buffer? - OR C - RET Z ; If Zero, then Nothing in buffer! - XOR A ; Otherwise, GO ON, print the chr(0) - JR Out1 - -;---------------------------------------- -; -; SENDOUT -; -; This routine outputs characters -; to the modem. -; Entry - A = Character -; Exit - None -; Used - None -; -;---------------------------------------- -.JRemoteEcho - DEFB &C9 ; Remote echo location. 0 means on. -.SendOut - PUSH AF ; Save registers - PUSH HL -; LD H,HighRemoteBlock ; Put character through block mask -; LD L,A ; Will be zero if masked out -; LD A,(HL) -; OR A -; JR Z,SOexit ; If masked then exit now -; *** 22b - back to old translation tables. Seems better. - - LD H,HighRemoteTrans ; Put through translation table - LD L,A - LD A,(HL) ; Got the translation, no use it! - OR A - JR Z,SOexit - - CP 9 ; Is it TAB? - JP NZ,SO1 - CALL JRTabExpand - JP SOexit -.SO1 CALL WriteBuffer ; Send character out - CP 8 ; Is it DEL? - CALL Z,JRDestDel - CP 13 ; Is it CR? - CALL Z,JRAddLF -.SOexit POP HL ; Restore registers - POP AF - RET - -;---------------------------------------- -; -; REMOTE DESTRUCTIVE DELETE -; -; This echos a 32 then an 8 to go -; with the other 8, overwriting -; the space. -; Entry - None -; Exit - None -; Used - AF -; -;----------------------------------------- -.JRDestDel - DEFB &C9 ; Remote Destructive Delete. 0 = on. -.RemoteDestDel - LD A,32 - CALL WriteBuffer - LD A,8 - JP WriteBuffer - -;------------------------------------------ -; -; REMOTE ADD LF TO CR -; -; This will add a LF to the previously -; printed CR -; Entry - None -; Exit - None -; Used - AF -; -;------------------------------------------- -.JRAddLF - DEFB &C9 ; Remote Add LF to CR. 0 means on. -.RemoteAddLF - LD A,10 - JP WriteBuffer - -;-------------------------------------------- -; -; REMOTE TAB EXPANDER -; -; This will expand a TAB to a string -; of spaces. TAB stops set at every 8 -; Entry - None -; Exit - None -; Used - AF -; -;--------------------------------------------- -.JRTabExpand - BIT 0,(IY+2) - JP NZ,WriteBuffer -.RemoteTabExpand - PUSH HL - CALL TXT_GET_CURSOR - LD A,H ; Put column in A - CP 72 ; Is it greater than last tab stop? - JR NC,rt4 ; If so then replace it with a - ; CR. - DEC A ; Convert from Logical to Physical - ; coordinates, ie left edge = 0 -.rt1 CP 8 ; Is it less than 8 - JR C,rt2 - SUB A,8 ; Reduce A by 8 - JP rt1 ; Go and check again... -.rt2 LD B,A ; B = 8 - A - LD A,8 - SUB B - LD B,A - LD A,32 -.rt3 CALL WriteBuffer ; Then send the character - DJNZ rt3 - POP HL ; Restore HL - RET -.rt4 LD A,13 ; Print a CR (with LF if on) - CALL SendOut - POP HL - RET - -;---------------------------------------- -; -; WAIT FOR EMPTY SIO LINE -; -; This routine will wait until it -; gets an empty line, so that it -; can send the character safely. -; Entry : None -; Exit : None -; Used : None -; -;---------------------------------------- -;.WaitEmpty ; Replaced by buffering -; PUSH AF -;.WE1 CALL SioStatus ; Bit 2 is transmit buffer empty -; BIT 2,A -; JR Z,WE1 ; If not ready back to try again. -;.WE2 POP AF -; RET - -;---------------------------------------- -; -; PRINT CHARACTER -; -; This routine handles printing -; a character to the screen. -; Entry - A = Charcter -; Exit - Ignore if A = 0 -; Used - None -; -;---------------------------------------- -.JLocalEcho - DEFB &C9 ; Local echo location. 0 means on. -.PrintChar - PUSH AF ; Save AF - PUSH HL ; Save HL -; LD H,HighLocalBlock ; Put character through block mask -; LD L,A ; Will be zero if masked out -; LD A,(HL) -; OR A -; JR Z,PCexit ; If masked then exit now -; *** 22b - back to old translation tables. Seems better. - - LD H,HighLocalTrans ; Put through translation table - LD L,A - LD A,(HL) ; Now use the value! - - OR A - JP Z,PCexit -; Now dealt with in the screen output routine. -; -; CP 27 ; Does it start an Ansi sequence? -; JR NZ,PrintC1 -; LD A,&C9 -; LD (JScrnBuf),A ; Screen buffer off -; LD (JScreenWrite),A ; Screen display off. -; XOR A -; LD (JAnsi),A ; Ansi display on. -; JP PCexit -.PrintC1 - CP 9 ; Is it TAB? - JP NZ,PC1 - CALL JLTabExpand - JP PCexit -.PC1 CALL ToScreen ; Print the character - CP 8 ; Is it DEL? - CALL Z,JLDestDel - CP 13 ; Is it RET? - CALL Z,JLAddLF -.PCexit POP HL ; Restore HL - POP AF ; Restore AF - RET - -;---------------------------------------- -; -; LOCAL DESTRUCTIVE DELETE -; -; This echos a 32 then an 8 to go -; with the other 8, overwriting -; the space. -; Entry - None -; Exit - None -; Used - AF -; -;----------------------------------------- -.JLDestDel - DEFB &C9 ; Destructive Delete (Local). -.LocalDestDel - LD A,32 - CALL ToScreen - LD A,8 - JP ToScreen - -;------------------------------------------ -; -; LOCAL ADD LF TO CR -; -; This will add a LF to the previously -; printed CR -; Entry - None -; Exit - None -; Used - AF -; -;------------------------------------------- -.JLAddLF - DEFB &C9 ; Local Add LF to CR. 0 means on. -.LocalAddLF - LD A,10 - JP ToScreen - -;-------------------------------------------- -; -; LOCAL TAB EXPANDER -; -; This will expand a TAB to a string -; of spaces. TAB stops set at every 8 -; Entry - None -; Exit - None -; Used - AF -; -;--------------------------------------------- -.JLTabExpand - DEFB 0 ; Local Tab Expander, &c9 means off. -.LocalTabExpand - PUSH HL - CALL TXT_GET_CURSOR - LD A,H ; Put column in A - CP 72 ; Is it greater than last tab stop? - JR NC,lt4 ; If so then replace it with a - ; CR. - DEC A ; Convert from Logical to Physical - ; coordinates, ie left edge = 0 -.lt1 CP 8 ; Is it less than 8 - JR C,lt2 - SUB A,8 ; Reduce A by 8 - JP lt1 ; Go and check again... -.lt2 LD B,A ; B = 8 - A - LD A,8 - SUB B - LD B,A - LD A,32 -.lt3 CALL ToScreen ; Send it to the screen - DJNZ lt3 - POP HL ; Restore HL - RET -.lt4 LD A,13 ; Print a CR (with LF if on) - CALL ToScreen - POP HL - RET - -;---------------------------------------- -; -; TO SCREEN -; -; This routine handles where to -; send the character to be printed -; Entry - A = Character -; Exit - None -; Used - None -; -;---------------------------------------- -;.ToScreen -; CALL JWordWrap ; If word wrap doesn't want the -; OR A ; character printed it will set -; RET Z ; it to be zero. -; JP TXT_OUTPUT ; Send it to the screen now. -; CP 12 -; JP NZ,TXT_OUTPUT -; JR FastCls ; ClearScreen faster. -; JP JCapture ; Only needs to be put in later diff --git a/orig/src/mainline.txt b/orig/src/mainline.txt deleted file mode 100644 index a4e0a45..0000000 --- a/orig/src/mainline.txt +++ /dev/null @@ -1,562 +0,0 @@ -1 PRINT "MAINLINE CODE" -; -; TERMINAL MODE begins here -; -; -.term - LD A,2 - CALL SCR_SET_MODE - -; CALL KL_U_ROM_DISABLE ; Disable upper rom -; LD (RomState),A - - CALL SetBuf ; Setup buffering - - LD A,66 ; ESC key. - CALL KM_GET_TRANSLATE ; Get current normal setting. - LD (ESC_key),A ; Save for later... - - LD A,66 ; Set up the ESC key to return - LD B,27 ; the normal ESC char when pressed - CALL KM_SET_TRANSLATE ; without Control/Shift - - LD A,9 ; COPY key. - CALL KM_GET_TRANSLATE ; Get current normal setting. - LD (COPY_key),A ; Save for later... - - LD A,9 ; Set up the COPY key to return - LD B,255 ; an invalid number when pressed - CALL KM_SET_TRANSLATE ; without Control/Shift - - LD A,16 ; CLR key. - CALL KM_GET_TRANSLATE - LD (CLR_key),A - - LD A,16 ; Make it send CTRL-G - LD B,7 - CALL KM_SET_TRANSLATE - - CALL AllOff - LD IY,DataAreaHere ; Data area of program - - LD A,12 ; Clear screen, and buffer - CALL ToScreen - - LD HL,0 ; No offset, just set mode - LD (ScreenOffset),HL - - CALL SetCursorInterupt ; Turn on interupt! - -; -; MAINLINE -; -.loop CALL Check_exit ; Check for abandoning ESC - JR NZ,exit ; IF ESC pressed then exit -; LD A,7 -; CALL TXT_OUTPUT ; Make a beep! - CALL outside ; Get something if we can - ; and deal with it - XOR A ; Kill the character so it doesn't - ; disturb us later. - CALL keys ; If so, we can send some more, so - ; get a keypress and respond to it.. - CP &FC ; Check for ESC in buffer - JR Z,Exit ; Go to the exit routine if so. - JP loop ; Take it from the top! - -;---------------------------------------- -; -; CHECK EXIT -; -; This routine checks for ESC -; being pressed. -; Entry - None -; Exit - Zero flag set if pressed -; Used - AF -; -;---------------------------------------- -.Check_Exit - LD A,66 ; Test for ESC - PUSH BC ; Save options register - CALL KM_TEST_KEY ; Is key pressed? - CALL NZ,leave ; Test for leave key. - POP BC ; Restore options register - RET - -.leave ; This checks that ESC is pressed - ; with either [SHIFT] or [CONTROL] - BIT 7,C ; Control key? -; RET NZ -; BIT 5,C ; Shift key? - RET - -;---------------------------------------- -; -; EXIT -; -; This routine exits the terminal -; program normally. -; Entry - None -; Exit - Never returns -; Used - AF,BC,HL -;---------------------------------------- - - -.exit - CALL KM_READ_CHAR ; Empty buffer before exiting.. - JR C,exit ; If there is a character then - ; try again. - LD A,(ESC_key) ; Restore ESC key to normal. - LD B,A - LD A,66 - CALL KM_SET_TRANSLATE - LD A,(COPY_key) ; Restore Copy key to normal. - LD B,A - LD A,9 - CALL KM_SET_TRANSLATE - LD A,(CLR_key) ; Restore CLR key. - LD B,A - LD A,16 - CALL KM_SET_TRANSLATE -; CALL TXT_CUR_OFF ; Cursor off -; CALL ToggleCursor ; Cursor now off -.Exit_1 -; CALL AllOff ; All attributes off. - ON ENTRY - - CALL ClearBuffer ; Clear out the buffers, and - ; delete fast ticker block. - LD HL,Signoff_terminal ; Signoff message - CALL prints ; And back to Basic - LD A,1 - LD (DKeyboard),A - LD A,&C9 - LD (JAnsi),A - XOR A - LD (JScrnBuf),A - LD (JScreenWrite),A -; CALL JCloseFile - CALL OffCursorInterupt - LD A,(RomState) - CALL KL_ROM_RESTORE - XOR A - LD (HaveLoaded),A - LD HL,NumberBuffer - LD (NumberPos),HL - RET - -;--------------------------------------- -; -; ABANDON -; -; This routine aborts with an -; error message -; Entry - None -; Exit - Never Returns -; Used - HL -; -;--------------------------------------- -.Abandon - LD HL,Abandon_Terminal - JP Prints - -;--------------------------------------------- -; -; READ KEY -; -; Read the next key from the keyboard -; Entry - None -; Exit - A = Character -; Used - Flags -; -;--------------------------------------------- -.Keys - CALL NotEmpty ; Is the buffer empty? - RET NZ ; don't get a key if it isn't! - CALL Keyboard ; Is there a character there?? - RET NC ; No keys pressed, back to mainline - CP &FC ; Check for ESC in buffer - RET Z ; If so then back to mainline - CP &E0 ; Check for Copy key. - JP Z,CharDump ; Do the screen dump, if pressed - CP 128 ; Check if character >= 128 - JR NC,Handle_Expansion ; If greater then do expansion.. - CALL Sendout ; Output to modem - JP JLocalEcho ; Echo locally if needed. - -;--------------------------------------------- -; -; EXPAND EXPANSION TOKEN -; -; This routine reads the next character -; from the expansion token and sends -; Entry - A = Expansion Token (+128) -; Exit - None -; Used - AF -; -;--------------------------------------------- -.Handle_Expansion - CP 138 ; Only send Macros with a value - ; below 138 (f0-f9) - RET NC - LD (Expansion_Token),A ; Save value of A in memory - XOR A - LD (char_position),A ; Save position in memory - LD A,(DKeyboard) ; Set the routine on. - RES 0,A - SET 1,A - LD (DKeyboard),A - RET - -;---------------------------------------- -; -; GET EXPANSION -; -; Get the next character from an -; expansion token -; Entry - None -; Exit - A = character -; Used - None -; -;---------------------------------------- -.ExpndKey - PUSH DE - PUSH HL - LD A,(char_position) ; Get position - LD L,A - LD A,(Expansion_Token) ; and expansion token - CALL KM_GET_EXPAND - JR NC,EXK_Exit ; If it failed, then we have finished! - SCF ; Set carry to say got character - INC L - PUSH AF - LD A,L - LD (char_position),A ; Save new position - POP AF - POP HL - POP DE - RET -.EXK_Exit - LD A,(DKeyboard) ; Turn this off. - SET 0,A - RES 1,A - LD (DKeyboard),A - SCF ; Clear the carry flag - no char! - CCF - POP HL - POP DE - RET - -;---------------------------------------- -; -; READ SIO -; -; This routine gets a character -; from the SIO and deals with it -; Entry - None -; Exit - None -; Used - AF -; -;---------------------------------------- -.Outside - CALL ReadBuffer ; Call the RSX to read in a character - OR A ; Return if nothing there - JR Z,Out2 -.Out1 CALL JRemoteEcho - JP PrintChar ; Print to screen - -.Out2 ; No need to save A - it MUST contain 0 - LD A,B ; Is there anything in the buffer? - OR C - RET Z ; If Zero, then Nothing in buffer! - XOR A ; Otherwise, GO ON, print the chr(0) - JR Out1 - -;---------------------------------------- -; -; SENDOUT -; -; This routine outputs characters -; to the modem. -; Entry - A = Character -; Exit - None -; Used - None -; -;---------------------------------------- -.JRemoteEcho - DEFB &C9 ; Remote echo location. 0 means on. -.SendOut - PUSH AF ; Save registers - PUSH HL -; LD H,HighRemoteBlock ; Put character through block mask -; LD L,A ; Will be zero if masked out -; LD A,(HL) -; OR A -; JR Z,SOexit ; If masked then exit now -; *** 22b - back to old translation tables. Seems better. - - LD H,HighRemoteTrans ; Put through translation table - LD L,A - LD A,(HL) ; Got the translation, no use it! - OR A - JR Z,SOexit - - CP 9 ; Is it TAB? - JP NZ,SO1 - CALL JRTabExpand - JP SOexit -.SO1 CALL WriteBuffer ; Send character out - CP 8 ; Is it DEL? - CALL Z,JRDestDel - CP 13 ; Is it CR? - CALL Z,JRAddLF -.SOexit POP HL ; Restore registers - POP AF - RET - -;---------------------------------------- -; -; REMOTE DESTRUCTIVE DELETE -; -; This echos a 32 then an 8 to go -; with the other 8, overwriting -; the space. -; Entry - None -; Exit - None -; Used - AF -; -;----------------------------------------- -.JRDestDel - DEFB &C9 ; Remote Destructive Delete. 0 = on. -.RemoteDestDel - LD A,32 - CALL WriteBuffer - LD A,8 - JP WriteBuffer - -;------------------------------------------ -; -; REMOTE ADD LF TO CR -; -; This will add a LF to the previously -; printed CR -; Entry - None -; Exit - None -; Used - AF -; -;------------------------------------------- -.JRAddLF - DEFB &C9 ; Remote Add LF to CR. 0 means on. -.RemoteAddLF - LD A,10 - JP WriteBuffer - -;-------------------------------------------- -; -; REMOTE TAB EXPANDER -; -; This will expand a TAB to a string -; of spaces. TAB stops set at every 8 -; Entry - None -; Exit - None -; Used - AF -; -;--------------------------------------------- -.JRTabExpand - BIT 0,(IY+2) - JP NZ,WriteBuffer -.RemoteTabExpand - PUSH HL - CALL TXT_GET_CURSOR - LD A,H ; Put column in A - CP 72 ; Is it greater than last tab stop? - JR NC,rt4 ; If so then replace it with a - ; CR. - DEC A ; Convert from Logical to Physical - ; coordinates, ie left edge = 0 -.rt1 CP 8 ; Is it less than 8 - JR C,rt2 - SUB A,8 ; Reduce A by 8 - JP rt1 ; Go and check again... -.rt2 LD B,A ; B = 8 - A - LD A,8 - SUB B - LD B,A - LD A,32 -.rt3 CALL WriteBuffer ; Then send the character - DJNZ rt3 - POP HL ; Restore HL - RET -.rt4 LD A,13 ; Print a CR (with LF if on) - CALL SendOut - POP HL - RET - -;---------------------------------------- -; -; WAIT FOR EMPTY SIO LINE -; -; This routine will wait until it -; gets an empty line, so that it -; can send the character safely. -; Entry : None -; Exit : None -; Used : None -; -;---------------------------------------- -;.WaitEmpty ; Replaced by buffering -; PUSH AF -;.WE1 CALL SioStatus ; Bit 2 is transmit buffer empty -; BIT 2,A -; JR Z,WE1 ; If not ready back to try again. -;.WE2 POP AF -; RET - -;---------------------------------------- -; -; PRINT CHARACTER -; -; This routine handles printing -; a character to the screen. -; Entry - A = Charcter -; Exit - Ignore if A = 0 -; Used - None -; -;---------------------------------------- -.JLocalEcho - DEFB &C9 ; Local echo location. 0 means on. -.PrintChar - PUSH AF ; Save AF - PUSH HL ; Save HL -; LD H,HighLocalBlock ; Put character through block mask -; LD L,A ; Will be zero if masked out -; LD A,(HL) -; OR A -; JR Z,PCexit ; If masked then exit now -; *** 22b - back to old translation tables. Seems better. - - LD H,HighLocalTrans ; Put through translation table - LD L,A - LD A,(HL) ; Now use the value! - - OR A - JP Z,PCexit -; Now dealt with in the screen output routine. -; -; CP 27 ; Does it start an Ansi sequence? -; JR NZ,PrintC1 -; LD A,&C9 -; LD (JScrnBuf),A ; Screen buffer off -; LD (JScreenWrite),A ; Screen display off. -; XOR A -; LD (JAnsi),A ; Ansi display on. -; JP PCexit -.PrintC1 - CP 9 ; Is it TAB? - JP NZ,PC1 - CALL JLTabExpand - JP PCexit -.PC1 CALL ToScreen ; Print the character - CP 8 ; Is it DEL? - CALL Z,JLDestDel - CP 13 ; Is it RET? - CALL Z,JLAddLF -.PCexit POP HL ; Restore HL - POP AF ; Restore AF - RET - -;---------------------------------------- -; -; LOCAL DESTRUCTIVE DELETE -; -; This echos a 32 then an 8 to go -; with the other 8, overwriting -; the space. -; Entry - None -; Exit - None -; Used - AF -; -;----------------------------------------- -.JLDestDel - DEFB &C9 ; Destructive Delete (Local). -.LocalDestDel - LD A,32 - CALL ToScreen - LD A,8 - JP ToScreen - -;------------------------------------------ -; -; LOCAL ADD LF TO CR -; -; This will add a LF to the previously -; printed CR -; Entry - None -; Exit - None -; Used - AF -; -;------------------------------------------- -.JLAddLF - DEFB &C9 ; Local Add LF to CR. 0 means on. -.LocalAddLF - LD A,10 - JP ToScreen - -;-------------------------------------------- -; -; LOCAL TAB EXPANDER -; -; This will expand a TAB to a string -; of spaces. TAB stops set at every 8 -; Entry - None -; Exit - None -; Used - AF -; -;--------------------------------------------- -.JLTabExpand - DEFB 0 ; Local Tab Expander, &c9 means off. -.LocalTabExpand - PUSH HL - CALL TXT_GET_CURSOR - LD A,H ; Put column in A - CP 72 ; Is it greater than last tab stop? - JR NC,lt4 ; If so then replace it with a - ; CR. - DEC A ; Convert from Logical to Physical - ; coordinates, ie left edge = 0 -.lt1 CP 8 ; Is it less than 8 - JR C,lt2 - SUB A,8 ; Reduce A by 8 - JP lt1 ; Go and check again... -.lt2 LD B,A ; B = 8 - A - LD A,8 - SUB B - LD B,A - LD A,32 -.lt3 CALL ToScreen ; Send it to the screen - DJNZ lt3 - POP HL ; Restore HL - RET -.lt4 LD A,13 ; Print a CR (with LF if on) - CALL ToScreen - POP HL - RET - -;---------------------------------------- -; -; TO SCREEN -; -; This routine handles where to -; send the character to be printed -; Entry - A = Character -; Exit - None -; Used - None -; -;---------------------------------------- -;.ToScreen -; CALL JWordWrap ; If word wrap doesn't want the -; OR A ; character printed it will set -; RET Z ; it to be zero. -; JP TXT_OUTPUT ; Send it to the screen now. -; CP 12 -; JP NZ,TXT_OUTPUT -; JR FastCls ; ClearScreen faster. -; JP JCapture ; Only needs to be put in later diff --git a/orig/src/screen.22b b/orig/src/screen.22b deleted file mode 100644 index 04af982..0000000 --- a/orig/src/screen.22b +++ /dev/null @@ -1,784 +0,0 @@ -print "SCREEN EMULATION" -;------------------------------------ -; -; TO SCREEN -; -; This routine sends the outputed -; character to all the relevant -; places -; -; Entry - A = Character -; Exit - None -; Used - AF -; -;------------------------------------ -ToScreen - CALL JScreenWrite ; THE screen, and buffer - CALL JAnsi ; Ansi emulator (not on when screen is) - RET - -;------------------------------------ -; -; SCREEN WRITE -; -; This routine modifies the -; character to the Ansi -; graphic type set, and then -; sends it to the screen -; -; Entry - A = Charcter -; Exit - A = Character -; Used - None -; -;------------------------------------ -JScreenWrite - BYTE 0 ; Set to &C9 if screen not being - ; sent to -ScreenWrite - PUSH HL - PUSH DE - PUSH BC - PUSH AF ; Save registers - LD D,A ; Temp save for A - - LD A,(CursorOn) - OR A ; Well, what do we have here?! - CALL NZ,ToggleCursor ; If cursor on, then remove - - XOR A - LD (CursorOn),A ; And cursor is now off - LD (CursorCount),A ; Restart count - LD A,&C9 - LD (JChangeCursor),A ; Disable flashing temp - - LD A,D ; Restore value of A - - CP 31 ; Is it a control character? - JP NC,SW1 - CP 7 ; Is it a control character used? - JP Z,SW_Bell - CP 8 - JP Z,SW_BS - CP 9 - JP Z,SW_TAB - CP 10 - JP Z,SW_LF - CP 12 - JP Z,SW_FF - CP 13 - JP Z,SW_CR - CP 27 ; Is it the ESC character, starting - ; an ANSI sequence? - JP Z,SW_Ansi - ; If so, make the screen act on it - ; otherwise print it out - CP &9B - JP Z,SW_Ansi ; Also, an Ansi switch on - ; Ansi handler does the rest -SW1 - CALL JScrnBuf ; Put the character into the buffer - LD HL,Character ; Character buffer address - CALL Getcharacter - CALL JItalics ; Set the character matrix up - CALL JBold - CALL JUnder - CALL JInverse -IF Colour - CALL JSmash -ENDIF - EX HL,DE - LD HL,(CursorPosition) - PUSH HL ; Save cursor position for later - CALL FindCursor ; Now HL = screen memory address - ; DE = character data address - LD B,8 ; Value to add between lines(high only) - LD A,(DE) ; From buffer - LD (HL),A ; To screen - LD A,H ; To next block - ADD B - LD H,A - INC E ; To next byte - - LD A,(DE) ; 2 - LD (HL),A - LD A,H - ADD B - LD H,A - INC E ; NB Must not be split across page - - LD A,(DE) ; 3 - LD (HL),A - LD A,H - ADD B - LD H,A - INC E - - LD A,(DE) ; 4 - LD (HL),A - LD A,H - ADD B - LD H,A - INC E - - LD A,(DE) ; 5 - LD (HL),A - LD A,H - ADD B - LD H,A - INC E - - LD A,(DE) ; 6 - LD (HL),A - LD A,H - ADD B - LD H,A - INC E - - LD A,(DE) ; 7 - LD (HL),A - LD A,H - ADD B - LD H,A - INC E - - LD A,(DE) ; 8 - LD (HL),A - - POP HL ; Restore cursor position - LD A,H - CP 79 ; Are we at the right edge? - JR NZ,SW1_5 ; If yes - LD H,0 ; Column zero now - - - CALL SW_LFn ; Move down the line (don't load) - - LD A,&C9 - LD (JSW_LF),A ; Turn off line feed for next - ; character - JP SWR_None ; _don't_ re-enable LF and there - ; is no need to re-enable FF either - -SW1_5 INC H ; One more across - LD (CursorPosition),HL - -SW_Restore ; Restore all values, and then return - XOR A - LD (JSW_LF),A ; Turn LF back on - LD (JSW_FF),A ; Turn FF back on -SWR_None - XOR A ; Cursor int back on - LD (JChangeCursor),A - POP AF - POP BC - POP DE - POP HL - RET - -SWR_FF XOR A - LD (JSW_FF),A ; Turn FF back on - LD (JChangeCursor),A ; And cursor may flash now - POP AF ; Then registers - POP BC - POP DE - POP HL - RET - -SWR_LF XOR A - LD (JSW_LF),A ; Turn LF back on - LD (JChangeCursor),A ; And cursor may flash now - POP AF ; and registers - POP BC - POP DE - POP HL - RET - -SW_Bell ; Sound the bell - CALL TXT_OUTPUT ; Force firmware to handle this! - JP SWR_None ; And that was it! - -SW_BS - LD A,(CursorPosition+1) ; A = column - OR A ; Is zero? - JP Z,SWR_None ; Don't wrap back - DEC A ; Back one column - LD (CursorPosition+1),A ; Resave cursor position - JP SWR_None ; That's it folks! - -SW_TAB - LD A,(CursorPosition+1) ; A = column - AND %11111000 ; Mult of 8 - CP 72 ; If at 72, then we CR/LF not TAB!! - JR NZ,SW_Tab1 - XOR A - LD (CursorPosition+1),A ; Do the CR - JP SW_LF_All ; _must_ do it, so no messing with - ; jumpblocks -SW_Tab1 - ADD A,8 ; Next stop - LD (CursorPosition+1),A ; And save - JP SWR_None ; And that was that! - -SW_LF LD A,(JSW_LF) - OR A - CALL Z,SW_LF_All - JP SWR_LF ; We have just avoided it, or done it - ; either way allow it now -SW_LF_All - LD HL,(CursorPosition) ; Do we need to scroll? -SW_LFn INC L ; Next line - LD A,L ; Now, put it into A so we can do - ; things with it! - CP screen_depth ; Have we gone past the end? - JR Z,SWLF1 ; Must scroll - LD (CursorPosition),HL ; Save new position - RET - -SWLF1 ; Now the hard bit - DEC L ; Back to line 24 - LD (CursorPosition),HL ; Resave cursor position - -;*** Scroll the screen up - - LD HL,(ScreenOffset) ; Get current offset - LD DE,80 ; Offset to add - ADD HL,DE ; Addit! - LD A,H - AND A,%00000111 ; Mask back into range - LD H,A - - LD (ScreenOffset),HL -; CALL SCR_SET_OFFSET ; Tell the hardware about it -; -;*** Now blank the bottom line -; -; LD HL,24 ; Get address of bottom line -; CALL FindCursor -; LD DE,2048 ; Value to add between lines -; LD C,80 -;SW_LF_Next -; XOR A ; Value to load in; ie 0 -; LD B,8 -; PUSH HL -;SW_LF_Down -; LD (HL),A ; Loop downwards -; ADD HL,DE -; DJNZ SW_LF_Down -; POP HL -; CALL SW_LF_Across -; DEC C ; 1 less across now! -; LD A,C -; OR A -; JR NZ,SW_LF_Next - - LD A,(JScrnBuf) ; Is the buffer on? - LD (SW_LF_JBuf),A - CALL SW_LF_JBuf - - LD B,255 ; Scroll upwards - XOR A ; Fill with 0's - CALL SCR_HW_ROLL ; Move the screen up and blank - ; the bottom line - - RET ; That's all here - -;SW_LF_Across -; INC HL ; HL = HL + 1 -; LD A,H -; AND A,%00000111 ; Mask back into range of screen -; ADD A,&C0 ; Add base of screen address -; LD H,A -; RET - - - -SW_FF ; Clear the screen - LD HL,0 - LD (CursorPosition),HL ; Home the cursor - - LD A,(JSW_FF) - OR A - JP NZ,SWR_LF - - XOR A ; Save inks - CALL SCR_GET_INK - - LD (Ink0),BC - - LD A,1 - CALL SCR_GET_INK - - LD (Ink1),BC - - XOR A ; Blank the inks - LD B,A - LD C,A - CALL SCR_SET_INK - - LD A,1 - LD B,0 - LD C,B - CALL SCR_SET_INK - - CALL MC_WAIT_FLYBACK - - LD HL,&C000 ; From - LD DE,&C001 ; To - LD BC,16383 ; Screen length - LD (HL),0 - LDIR - - XOR A - LD BC,(ink0) - CALL SCR_SET_INK - - LD A,1 - LD BC,(ink1) - CALL SCR_SET_INK - - LD A,&C9 ; Prevent clear screen - LD (JSW_FF),A ; until something written - - LD A,(JScrnBuf) ; Is the buffer on? - LD (SW_FF_JBuf),A - CALL SW_FF_JBuf - - JP SWR_LF - - -SW_CR - LD HL,(CursorPosition) ; Get cursor pos - LD H,0 ; Zero column - LD (CursorPosition),HL ; Save cursor pos - JP SWR_None ; Say your prayers - -SW_Ansi - LD A,&C9 - LD (JScrnBuf),A ; Screen buffer off - LD (JScreenWrite),A ; Screen display off - XOR A - LD (JAnsi),A ; Ansi display on - JP SWR_None - -; SCREEN BUFFER CHARACTER UPDATE -; Entry A = character -; -JScrnBuf BYTE 0 ; Runtime flag 0 = on; &c9 = off -ScrnBuf - PUSH AF ; Save character - LD HL,(CursorPosition) ; Where are we? - CALL GetAddress ; Find where to put byte - LD (HL),A ; and save it there - LD A,(fontset) - LD DE,2048 ; Move to attrib block - ADD HL,DE - LD (HL),A - POP AF ; Restore character - RET - -; Roll buffer down -; -SW_LF_JBuf - BYTE 0 ; Gets set at runtime; self modifying -SW_LF_Buf - LD BC,screen_depth-1*80 ; # - LD HL,Screen_C+80 ; FROM - LD DE,Screen_C ; TO - LDIR - LD BC,screen_depth-1*80 ; # - LD HL,Screen_A+80 ; FROM - LD DE,Screen_A ; TO - LDIR - - LD HL,screen_depth-1*80+Screen_C - LD DE,screen_depth-1*80+Screen_C+1 - LD BC,79 - LD (HL),32 - LDIR - LD HL,screen_depth-1*80+Screen_A - LD DE,screen_depth-1*80+Screen_A+1 - LD BC,79 - LD (HL),0 - LDIR - RET - -; Clear buffer -; -SW_FF_JBuf - BYTE 0 ; Runtime option; 0 = on,&c9 =off -SW_FF_Buf - LD BC,2047 ; Length of block -1 (start 1 up) - LD HL,Screen_C ; FROM - LD DE,Screen_C+1 ; TO , overlapping - LD (HL),32 ; Fill first byte - LDIR - LD BC,2047 ; Length - LD HL,Screen_A ; FROM - LD DE,Screen_A+1 ; TO, overlapping - LD (HL),0 ; Fill first byte - LDIR - RET - -;--------------------------------------- -; -; GET ADDRESS -; -; This routine finds the address -; to put the byte into -; -; Entry - HL = Cursor position -; Exit - HL = Address wanted -; Used - DE,BC -; -;--------------------------------------- -GetAddress - PUSH AF - PUSH HL - LD A,L ; Get row in A - ADD L ; double row number - LD L,A ; Get low byte into L - LD H,highaddressbuffer ; Get high byte into H - LD E,(HL) ; Get into DE - INC HL - LD D,(HL) - POP HL - LD L,H ; Prepare value to add - LD H,0 - ADD HL,DE ; Offset now in HL - POP AF - RET - -;--------------------------------------- -; -; TOGGLE CURSOR -; -; This routine turns the cursor -; off, or turns it on depending -; on its current state -; -; Entry - None -; Exit - None -; Used - AF,BC,HL -; -;--------------------------------------- -ToggleCursor - LD HL,(CursorPosition) ; Get position on screen - CALL FindCursor ; Find out where we are! - LD B,8 ; Value to add between lines - - LD A,(HL) ; From Screen - CPL ; 1's to 0's, and vice versa - LD (HL),A ; To screen - LD A,H ; Move to next block - ADD B - LD H,A - - LD A,(HL) ; 2 - CPL - LD (HL),A - LD A,H - ADD B - LD H,A - - LD A,(HL) ; 3 - CPL - LD (HL),A - LD A,H - ADD B - LD H,A - - LD A,(HL) ; 4 - CPL - LD (HL),A - LD A,H - ADD B - LD H,A - - LD A,(HL) ; 5 - CPL - LD (HL),A - LD A,H - ADD B - LD H,A - - LD A,(HL) ; 6 - CPL - LD (HL),A - LD A,H - ADD B - LD H,A - - LD A,(HL) ; 7 - CPL - LD (HL),A - LD A,H - ADD B - LD H,A - - LD A,(HL) ; 8 - CPL - LD (HL),A - - RET ; Back to life - -;--------------------------------------- -; SET CURSOR FLASHING INT ON -; -; Turns on a SCR FLYBACK event -; which will flash cursor -; -; Entry - None -; Exit - None -; Used - AF,BC,DE,HL -; -;--------------------------------------- -SetCursorInterupt - LD HL,CursorBlock ; Frame Fly Event block - LD DE,ChangeCursor ; Routine to call - LD BC,&81FF ; Async event, Near address - ; Disable roms - CALL KL_NEW_FRAME_FLY ; Initialise it - CALL ToggleCursor - LD A,255 - LD (CursorOn),A ; Tell routine cursor is on screen - XOR A - LD (JChangeCursor),A ; Tell routine that cursor is allowed - ; flash - LD (CursorCount),A ; Count for flash frequencey - RET - -;--------------------------------------- -; TURN CURSOR FLASHING OFF -; -; Turns off SCR_FLYBACK event -; and removes cursor -; -; Entry - None -; Exit - None -; Used - AF,BC,DE,HL -; -;--------------------------------------- -OffCursorInterupt - DI - LD HL,CursorBlock+2 ; Address of event block - CALL KL_DISARM_EVENT ; Disable the event - LD HL,CursorBlock ; Address of frame fly block - CALL KL_DEL_FRAME_FLY ; And disable it - DI ; Just incase it was about to do - ; naughty things! - LD A,(CursorOn) - OR A - CALL NZ,ToggleCursor ; Remove if on screen - XOR A - LD (CursorOn),A ; Tell routine cursor is off - LD A,&C9 - LD (JChangeCursor),A ; and _must_not_ flash - EI - RET - -;--------------------------------------- -; CHANGE CURSOR STATE -; -; Called in interupt line -; -; Entry - None -; Exit - None -; Used - None -; -;--------------------------------------- -; *** A couple of equates for fast changes first -C_Time_Off EQU 13 -C_Time_On EQU 26 -; *** Now the actual code -ChangeCursor -JChangeCursor - BYTE 0 ; &c9 to disable, 0 to enable - PUSH AF - LD A,(CursorOn) ; Is the cursor on (for timings)? - OR A - JR NZ,CC_On -;*** Cursor is Off - LD A,(CursorCount) ; Counter - CP C_Time_Off ; Have we been off long enough - JR Z,CC_Turn_On ; If yes, then do the work - INC A - LD (CursorCount),A ; Otherwise increase and save -CC_NoChange - POP AF - RET ; Restore registers, and continue - -CC_Turn_On - PUSH BC - PUSH DE - PUSH HL - XOR A - LD (CursorCount),A ; Restart count, for off - LD A,255 - LD (CursorOn),A ; Make note that cursor is now on - CALL ToggleCursor ; Do the actual work - POP HL - POP DE - POP BC - POP AF - RET - -CC_On - LD A,(CursorCount) ; Counter - CP C_Time_On ; Have we been on long enough? - JR Z,CC_Turn_Off ; If yes, then do the toggle - INC A - LD (CursorCount),A ; Otherwise increase and save - POP AF - RET - -CC_Turn_Off - PUSH BC - PUSH DE - PUSH HL - XOR A - LD (CursorCount),A ; Restart count, for off - LD (CursorOn),A ; Make note that cursor is now off - CALL ToggleCursor ; Do the actual work - POP HL - POP DE - POP BC - POP AF - RET - -;--------------------------------------- -; -; FIND SCREEN BYTE -; -; Finds appropriate byte in screen -; memory for cursor position -; -; Entry - HL = Cursor position -; Exit - HL = Byte in screen -; Used - None -; -;--------------------------------------- -FindCursor - PUSH AF - PUSH DE - PUSH HL - LD A,L ; Get row in A - ADD L ; double row number - LD L,A ; Get low byte into L - LD H,HighScreenAddress ; Get high byte into H - LD E,(HL) ; Get into DE - INC HL - LD D,(HL) - POP HL - LD L,H ; Prepare value to add - LD H,0 - ADD HL,DE ; Offset now in HL - EX HL,DE ; Save value into DE - LD HL,(ScreenOffset) ; Get offset from start - ADD HL,DE ; Add that in too - LD A,H - AND A,%00000111 ; Mask into 2K region - ADD A,&C0 ; Bring back into range - LD H,A - POP DE - POP AF - RET - -;------------------------------------ -; -; GET CHARACTER -; -; Entry - HL = address to put -; A = character -; Exit - None -; Used - DE -; -;------------------------------------ -GetCharacter - PUSH HL - LD E,A - LD D,HCharSet - LD B,8 -GC1 LD A,(DE) - LD (HL),A - INC D - INC HL - DJNZ GC1 - POP HL - RET - -;------------------------------------ -; -; SCREEN ATRIBUTES -; -; These routines configure -; the character suitably! -; Entry - HL = Address of character -; Exit - None -; Used - AF,BC,DE -;------------------------------------ -JBold BYTE &C9 ; 0 = On, &C9 = off -Bold_rtn - PUSH HL ; Preserve HL through routine - LD B,8 ; 8 bytes to modify -Bold1 LD A,(HL) ; Get line of character - SRL A ; Rotate left, - OR (HL) ; and add to the previous version (form bold) - LD (HL),A ; resave byte - INC HL ; next line - DJNZ Bold1 ; And back again for more - POP HL ; Restore HL - RET - -JItalics - BYTE &C9 ; 0 = on, &C9 = off -Italic_rtn - PUSH HL ; Save HL through routine - LD B,04 ; First 4 characters moved right -Ital1 LD A,(HL) ; Get byte - SRL A ; Move right - LD (HL),A ; And resave - INC HL ; Next byte - DJNZ Ital1 - POP HL ; Restore HL - RET - -JUnder BYTE &C9 ; 0 = on, &c9 = off -Under_rtn - PUSH HL ; Save HL - LD B,7 -Und1 INC HL ; Move up 7 - DJNZ Und1 - LD A,(JBold) ; Is bold on? - OR A - JR Z,Und2 ; Yes, skip past - LD A,85 ; If no on, then Semi-solid line - JR Z,Und3 -Und2 CPL ; If on, then solid underline -Und3 LD (HL),A ; Save bottom line - POP HL - RET - -JInverse - BYTE &C9 ; 0 = on, &c9 = off -Inverse - PUSH HL ; Save HL - LD B,8 -Inv1 LD A,(HL) ; Get byte - CPL ; turn it inverse - LD (HL),A ; Resave - INC HL ; next byte - DJNZ Inv1 - POP HL ; restore HL - RET - -IF Colour -JSmash BYTE &C9 ; 0 = on, &C9 = off -Smash PUSH HL ; Save HL - LD B,8 - XOR A -Sm1 LD (HL),A ; 0 all bytes -- ie, concealed - INC HL - DJNZ Sm1 - POP HL - RET -ENDIF \ No newline at end of file diff --git a/orig/src/setp.22b b/orig/src/setp.22b deleted file mode 100644 index 27d8e45..0000000 --- a/orig/src/setp.22b +++ /dev/null @@ -1,417 +0,0 @@ -1 PRINT "BUFFERING/SETUP (SETP-22A)." -;---------------------------------------- -; -; BUFFER - USER SIDE -; -; This routine reads from buffered -; serial input -; Entry - None -; Exit - A = Character -; BC = No characters in buffer -; (before this one taken) -; If no characters, A=0 BC=0 -; Used - None -; -;---------------------------------------- -.ReadBuffer - PUSH HL ; Save registers - PUSH DE - LD HL,(Get_Buffer) ; Output pointer - LD DE,(Put_Buffer) ; Input pointer - SCF - CCF ; Clear carry - PUSH HL ; Save buffer address - SBC HL,DE - LD B,H - LD C,L ; Difference into HL - POP HL ; Retrieve buffer address - LD A,B ; How may characters in buffer? - OR C - JR Z,Exitit ; Exit - both zero, so no characters - ; in buffer -.RB_DoIt - PUSH HL ; Save offset - LD DE,Buffer ; Start of buffer - ADD HL,DE ; Offset within buffer. - LD A,(HL) ; Get byte into A - POP HL ; Retrieve offset - PUSH AF ; Temporary save character - INC HL ; Move Get pointer up - LD A,H - CP 4 - JR NZ,RB_Save - LD H,0 -.RB_Save - LD (Get_Buffer),HL ; And resave - POP AF ; And restore - POP DE - POP HL - RET -.Exitit XOR A ; Set A to zero to say not found - ; BC already equals zero. - POP DE - POP HL ; Restore HL - RET - -;---------------------------------------- -; -; BUFFER - USER SIDE -; -; This routine reads from buffered -; serial input -; Entry - A = Character -; Exit - C = 255 if buffer nearly full -; Used - None -; -;---------------------------------------- -.WriteBuffer - PUSH HL ; Save register - PUSH AF - LD A,(To_Buffer) ; Get buffer pointer - LD L,A ; Put in L - POP AF ; Get the character we are saving - PUSH AF ; And save it again - LD H,High_Buffer_Out ; High byte - LD (HL),A ; Save byte to buffer - INC L ; Next address - LD A,L - LD (To_Buffer),A ; Save buffer pointer - LD A,(From_Buffer) ; Get where from pointer - LD H,A ; From into H - LD A,L ; To into L - SUB H ; To - From - CP 250 ; Is it less than 250? - JR C,WBOkay - LD C,255 ; Getting FULL! - JR WBexit -.WBOkay LD C,0 ; All is fine. -.WBexit POP AF - POP HL ; Restore all saved registers - RET - -;---------------------------------------- -; -; BUFFER NOT EMPTY -; -; This routine tells the program -; when the buffer is not empty -; -; Entry - None -; Exit - Zero Flag = -; Z - Buffer empty -; NZ- Buffer not empty -; -; Used - F -;---------------------------------------- -.NotEmpty - PUSH HL ; Save registers - PUSH BC - LD B,A ; A into B for safe keeping - LD A,(From_Buffer) ; Output pointer - LD L,A - LD A,(To_Buffer) ; Input pointer - CP A,L ; Compare - LD A,B ; And restore them all. - POP BC - POP HL - RET - -;---------------------------------------- -; -; BUFFER - SERIAL SIDE -; -; This routine sends anything needing -; sending, and recieves anything needing -; to be recieved. -; Entry - None -; Exit - None -; Used - None -; -;---------------------------------------- -.SerialBuffer - PUSH AF ; Save ALL registers for later - PUSH BC - PUSH DE - PUSH HL -; PUSH IX -; PUSH IY -.WB2 -; CALL SioStatus ; Get status - LD BC,&FADD ; RS232 Channel A, control - LD A,%00110000 ; Error reset, register 0. - OUT (C),A ; Set up state - IN A,(C) ; Read register (status) - BIT 0,A ; If there is something to get - JR Z,Exit2 ; else, onwards. - PUSH AF ; Save status bit - LD HL,(Put_Buffer) ; Get buffer pointer - PUSH HL - LD DE,Buffer - ADD HL,DE -; CALL InChar ; then get it! - LD BC,&FADC ; RS232 Channel A, data - IN A,(C) ; Get data (which IS there) - LD (HL),A ; Save byte - POP HL - INC HL ; Next address - LD A,H - CP 4 - JR NZ,Sb_Save - LD H,0 -.Sb_Save - LD (Put_Buffer),HL ; Save buffer pointer - POP AF ; Restore status bit -.Exit2 BIT 2,A - JR Z,Exit3 ; If there is no space then skip this - LD A,(From_Buffer) ; Output pointer - LD L,A - LD A,(To_Buffer) ; Input pointer - CP A,L ; Compare - JR Z,Exit3 ; Exit if nothing to send - LD H,High_Buffer_Out ; High byte - LD A,(HL) ; Get byte into A -; CALL OutChar ; send it out then - LD BC,&FADC ; RS232 Channel A, data - OUT (C),A ; send the data out. - INC L ; Move Get pointer up - LD A,L - LD (From_Buffer),A ; And resave -.Exit3 -; POP IY -; POP IX - POP HL ; Restore registers - POP DE - POP BC - POP AF - RET ; Exit - -;---------------------------------------- -; -; SETUP BUFFER -; -; This routine sets up the buffering -; needed to make things work -; Entry - None -; Exit - None -; Used - AF,BC,DE,HL -; -;---------------------------------------- -.SetBuf LD HL,FastBlock ; Data block - LD DE,SerialBuffer ; Address to CALL - LD BC,&81FF ; Class/Rom State - JP KL_NEW_FAST_TICKER ; Enable, and return - -;--------------------------------------- -; -; CLEAR BUFFER -; -; This routine clears the buffer. -; Also turns off ticker interupt. -; Called remotely, only. -; -;--------------------------------------- -.Clearbuffer - XOR A ; Clear slow response buffers - LD HL,0 - LD (Get_Buffer),HL - LD (Put_Buffer),HL - LD (To_Buffer),A - LD (From_Buffer),A - LD HL,TickBlock ; Address of EVENT block - CALL KL_DISARM_EVENT ; Disable - LD HL,FastBlock ; Address of FAST TICKER block - JP KL_DEL_FAST_TICKER ; Remove, and exit - -;---------------------------------------- -; -; SETUP -; -; This routine is setups all the various -; options -; Called remotely. -; -;---------------------------------------- -.Setup CALL TXT_CUR_ON - LD HL,SetupMessage ; Print up signon message - CALL prints - LD HL,signon_message ; Print version and date - CALL Prints -; -; LD HL,WordWrapMessage ; Question -; LD DE,DPrintChar ; Patch address -; LD B,%11111011 ; AND, if NO -; LD C,%00000100 ; OR, if YES -; LD A,"N" ; Default -; CALL GetAnswer ; Now do it. -; - LD HL,RemoteEchoMessage - LD DE,JRemoteEcho - CALL TwoState ; Sets up B,C, and A if two state - CALL GetAnswer -; - LD HL,LocalEchoMessage - LD DE,JLocalEcho - CALL TwoState - CALL GetAnswer -; - LD HL,LocalDestDelMessage - LD DE,JLDestDel - CALL TwoState - CALL GetAnswer -; - LD HL,LocalAddLFMessage - LD DE,JLAddLF - CALL TwoState - CALL GetAnswer -; - LD HL,LocalTabExpandMessage - LD DE,JLTabExpand - CALL TwoState - CALL GetAnswer -; - LD HL,RemoteDestDelMessage - LD DE,JRDestDel - CALL TwoState - CALL GetAnswer -; - LD HL,RemoteAddLFMessage - LD DE,JRAddLF - CALL TwoState - CALL GetAnswer -; - LD HL,RemoteTabExpandMessage - LD DE,DRemoteTabExpand - CALL TwoState - CALL GetAnswer -; - JP TXT_CUR_OFF ; Back to BASIC now. - -;--------------------------------------- -; -; TWO STATE SETUP -; -; Sets up B & C & A if 255 and 0 -; are only values concerned -; Entry - DE = address of patch -; Exit - B = No value -; C = Yes value -; A = Default -; Used - None -; -;--------------------------------------- -.TwoState - LD B,&C9 ; No - LD C,0 ; Yes - LD A,(DE) ; Default - OR A - JR Z,TS_Yes ; Set to "Y" - LD A,"N" ; Set to "N" - RET -.TS_Yes LD A,"Y" - RET - -;--------------------------------------- -; -; GET ANSWER -; -; This routine gets the users answer -; and processes it. -; Entry - HL = String to print -; DE = Address to patch -; B = Value to AND with, No -; C = Value to OR with, Yes -; A = Default (Y/N) -; Exit - None -; Used - AF,BC,DE,HL -; -;--------------------------------------- -.GetAnswer - PUSH AF ; Save default - CALL Prints ; Print out the string - POP AF - CALL TXT_OUTPUT ; Print default - PUSH AF - LD A,8 ; Back track - CALL TXT_OUTPUT -.GA1 CALL KM_WAIT_CHAR ; Get the character - CP "Y" ; Is it yes? - JR Z,GA_Yes - CP "y" - JR Z,GA_Yes - CP "N" ; Is it no? - JR Z,GA_No - CP "n" - JR Z,GA_No - CP 13 ; Is it return - JR Z,Ga_Leave - CP 252 ; Is it ESC? - JR Z,GA_Exit ; If so do something about it - LD A,7 ; BEL - CALL TXT_OUTPUT - JP GA1 ; Back to the top to try again. -; -.GA_Exit - POP AF ; Remove AF save - POP AF ; Remove return address for - ; this routine - JP TXT_CUR_OFF ; Exit same as above. - -; -.GA_Yes POP AF ; Restore AF - LD HL,Yes ; Print yes message - CALL Prints - LD A,C ; Yes value - LD (DE),A ; Resave value - RET ; Back to mainline. - -.GA_No POP AF ; Restore AF - LD HL,No ; Print No message - CALL Prints - LD A,B ; No value - LD (DE),A ; Resave - RET ; Back to mainline - -.GA_Leave - POP AF ; Restore default, and go to it - PUSH AF ; And save it again, for Yes/No - CP "Y" - JR Z,GA_Yes - CP "N" - JR Z,GA_No - LD A,13 ; If not expected then down line - CALL TXT_OUTPUT ; and return. - LD A,10 - CALL TXT_OUTPUT - RET - -; -; Terminal program JUMPBLOCK -; -;.ToScreen -; BIT 2,(IY) ; Word wrap first -; CALL NZ,WordWrap -; OR A -; RET Z -; BIT 4,(IY) ; Capture buffer gets all. -; CALL NZ,Capture -; BIT 1,(IY) -; CALL NZ,Ansi ; Ansi Buffer if wanted there -; OR A -; RET Z -; BIT 3,(IY) ; Screen buffer gets same as screen! -; CALL NZ,ScrnBuf -; BIT 0,(IY) -; RET Z -; JP TXT_OUTPUT ; Screen if wanted there -; -.Keyboard - BIT 0,(IY+1) - JP NZ,KM_READ_KEY - BIT 1,(IY+1) - JP NZ,ExpndKey -; BIT 2,(IY+1) -; JP NZ,FileKey - RET -; -; Dummy labels, things not written -.Filekey diff --git a/orig/src/telnet.s b/orig/src/telnet.s deleted file mode 100644 index 6733c3e..0000000 --- a/orig/src/telnet.s +++ /dev/null @@ -1,1422 +0,0 @@ - - ; Telnet client v1.0.1 beta example for M4 Board - ; Written by Duke 2018 - ; Requires firmware v1.1.0 upwards - ; Assembles with RASM (www.roudoudou.com/rasm) - ; Formatted for Notepad++, see : - ; http://www.cpcwiki.eu/forum/amstrad-cpc-hardware/amstrad-cpc-wifi/msg150664/#msg150664 - ; to easily cross compile and test quick on real CPC - - - - org 0x1000 - nolist - -DATAPORT equ 0xFE00 -ACKPORT equ 0xFC00 - -; m4 commands used -C_NETSOCKET equ 0x4331 -C_NETCONNECT equ 0x4332 -C_NETCLOSE equ 0x4333 -C_NETSEND equ 0x4334 -C_NETRECV equ 0x4335 -C_NETHOSTIP equ 0x4336 - -; firmware functions used -km_read_char equ 0xBB09 -km_wait_key equ 0xBB18 -txt_output equ 0xBB5A -txt_set_column equ 0xBB6F -txt_set_row equ 0xBB72 -txt_set_cursor equ 0xBB75 -txt_get_cursor equ 0xBB78 -txt_cur_on equ 0xBB81 -scr_reset equ 0xBC0E -scr_set_ink equ 0xBC32 -scr_set_border equ 0xBC38 -mc_wait_flyback equ 0xBD19 -kl_rom_select equ 0xb90f - -; telnet negotiation codes -DO equ 0xfd -WONT equ 0xfc -WILL equ 0xfb -DONT equ 0xfe -CMD equ 0xff -CMD_ECHO equ 1 -CMD_WINDOW_SIZE equ 31 - -start: ld a,2 - call scr_reset ; set mode 2 - xor a - ld b,a - call scr_set_border - xor a - ld b,0 - ld c,0 - call scr_set_ink - ld a,1 - ld b,26 - ld c,26 - call scr_set_ink - ld h,20 - ld l,1 - call txt_set_cursor - ld hl,msgtitle - call disptextz - ld h,20 - ld l,2 - call txt_set_cursor - - ld hl,msgtitle2 - call disptextz - call crlf - - ; find rom M4 rom number - - ld a,(m4_rom_num) - cp 0xFF - call z,find_m4_rom - cp 0xFF - jr nz, found_m4 - - ld hl,msgnom4 - call disptextz - jp exit - -found_m4: ld hl,msgfoundm4 - call disptextz - ld hl,(0xFF00) ; get version - ld a,h - call print_lownib - ld a,0x2E - call txt_output - ld a,l - rr a - rr a - rr a - rr a - call print_lownib - ld a,0x2E - call txt_output - ld a,l - call print_lownib - - ; compare version - - ld de,0x110 ; v1.1.0 lowest version required - ld a,h - xor d - jp m,cmpgte2 - sbc hl,de - jr nc,cmpgte3 -cmpgte1: ld hl,msgverfail - call disptextz - jp exit -cmpgte2: bit 7,d - jr z,cmpgte1 -cmpgte3: ld hl,msgok - call disptextz - - ; ask for server / ip -loop_ip: - ld hl,msgserverip - call disptextz - call get_server - cp 0 - jr nz, loop_ip - - ld hl,msgconnecting - call disptextz - - ld hl,ip_addr - call disp_ip - - ld hl,msgport - call disptextz - - ld hl,(port) - call disp_port - call crlf - call telnet_session - jr loop_ip - -exit: - jp km_wait_key - -print_lownib: - and 0xF ; keep lower nibble - add 48 ; 0 + x = neric ascii - jp txt_output - -get_server: - ld hl,buf - call get_textinput - - ;cp 0xFC ; ESC? - ;ret z - xor a - cp c - jr z, get_server - - ; check if any none neric chars - - ld b,c - ld hl,buf -check_neric: - ld a,(hl) - cp 59 ; bigger than ':' ? - jr nc,dolookup - inc hl - djnz check_neric - jp convert_ip - - ; make dns lookup -dolookup: - ; copy name to packet - - ld hl,buf - ld de,lookup_name - ld b,0 -copydns: ld a,(hl) - cp 58 - jr z,copydns_done - cp 0 - jr z,copydns_done - ld a,b - ldi - inc a - ld b,a - jr copydns -copydns_done: - push hl - xor a - ld (de),a ; terminate with zero - - ld hl,cmdlookup - inc b - inc b - inc b - ld (hl),b ; set size - - ; disp servername - - ld hl,msgresolve - call disptextz - ld hl,lookup_name - call disptextz - - ; do the lookup - call dnslookup - pop hl - cp 0 - jr z, lookup_ok - - ld hl,msgfail - call disptextz - ld a,1 - - - - ret - -lookup_ok: push hl ; contains port "offset" - ld hl,msgok - call disptextz - - ; copy IP from socket 0 info - ld hl,(0xFF06) - ld de,4 - add hl,de - ld de,ip_addr - ldi - ldi - ldi - ldi - pop hl - jr check_port - ; convert ascii IP to binary, no checking for non decimal chars format must be x.x.x.x -convert_ip: - ld hl,buf - call ascii2dec - ld (ip_addr+3),a - call ascii2dec - ld (ip_addr+2),a - call ascii2dec - ld (ip_addr+1),a - call ascii2dec - ld (ip_addr),a - dec hl -check_port: ld a,(hl) - cp 0x3A ; any ':' for port number ? - jr nz, no_port - - push hl - pop ix - call port2dec - - jr got_port - -no_port: ld hl,23 -got_port: - ld (port),hl - xor a - ret - - -dnslookup: ld hl,(0xFF02) ; get response buffer address - push hl - pop iy - - ld hl,(0xFF06) ; get sock info - push hl - pop ix ; ix ptr to current socket status - - - ld hl,cmdlookup - call sendcmd - ld a,(iy+3) - cp 1 - jr z,wait_lookup - ld a,1 - ret - -wait_lookup: - ld a,(ix+0) - cp 5 ; ip lookup in progress - jr z, wait_lookup - ret - - - ; actual telnet session - ; M4 rom should be mapped as upper rom. - -telnet_session: - ld hl,(0xFF02) ; get response buffer address - push hl - pop iy - - ; get a socket - - ld hl,cmdsocket - call sendcmd - ld a,(iy+3) - cp 255 - ret z - - ; store socket in predefined packets - - ld (csocket),a - ld (clsocket),a - ld (rsocket),a - ld (sendsock),a - - - ; multiply by 16 and add to socket status buffer - - sla a - sla a - sla a - sla a - - ld hl,(0xFF06) ; get sock info - ld e,a - ld d,0 - add hl,de ; sockinfo + (socket*4) - push hl - pop ix ; ix ptr to current socket status - - ; connect to server - - ld hl,cmdconnect - call sendcmd - ld a,(iy+3) - cp 255 - jp z,exit_close -wait_connect: - ld a,(ix) ; get socket status (0 ==IDLE (OK), 1 == connect in progress, 2 == send in progress) - cp 1 ; connect in progress? - jr z,wait_connect - cp 0 - jr z,connect_ok - call disp_error - jp exit_close -connect_ok: ld hl,msgconnect - call disptextz - - -mainloop: ld bc,1 - call recv_noblock - - call km_read_char - jr nc,mainloop - cp 0xFC ; ESC? - jp z, exit_close - cp 0x9 ; TAB? - jr nz, no_pause -wait_no_tab: - call km_read_char - cp 0x9 - jr z, wait_no_tab - -pause_loop: - call km_read_char - cp 0xFC ; ESC? - jp z, exit_close - cp 0x9 ; TAB again to leave - jr nz, pause_loop - jr mainloop -no_pause: - - ld hl,sendtext - ld (hl),a - - - -wait_send: ld a,(ix) - cp 2 ; send in progress? - jr z,wait_send - cp 0 - call nz,disp_error - - ;xor a - ;ld (isEscapeCode),a - - ld a,(hl) - ;call txt_output - cp 0xD - jr nz, plain_text - inc hl - ld a,0xA - ;call txt_output - ld (hl),a - - ld a,7 - ld (cmdsend),a - ld a,2 - ld (sendsize),a - ld hl,cmdsend - call sendcmd - - jp mainloop - -plain_text: - ld a,6 - ld (cmdsend),a - ld a,1 - ld (sendsize),a - ld hl,cmdsend - call sendcmd - - - - jp mainloop - - - ; call when CMD (0xFF) detected, read next two bytes of command - ; IY = socket structure ptr -negotiate: - - ld bc,2 - call recv - cp 0xFF - jp z, exit_close - cp 3 - jp z, exit_close - xor a - cp c - jr nz, check_negotiate - cp b - jr z,negotiate ; keep looping, want a reply. Could do other stuff here! - - -check_negotiate: - - ld a,(iy+6) - cp 0xFD ; DO - jr nz, will_not - ld a,(iy+7) - cp CMD_WINDOW_SIZE - jr nz, will_not - ; negotiate window size - ld a,8 - ld (cmdsend),a - ld hl,sendsize - ld (hl),3 - inc hl - ld (hl),0 - inc hl - ld (hl),0xFF ; CMD - inc hl - ld (hl),0xFB ; WILL - inc hl - ld (hl),CMD_WINDOW_SIZE - - ld hl, cmdsend - call sendcmd - - - - ld a,14 - ld (cmdsend),a - ld hl,sendsize - ld (hl),9 - inc hl - ld (hl),0 - inc hl - ld (hl),0xFF ; CMD - inc hl - ld (hl),0xFA ; SB sub negotiation - inc hl - ld (hl),CMD_WINDOW_SIZE - inc hl - ld (hl),0 - inc hl - ld (hl),80 - inc hl - ld (hl),0 - inc hl - ld (hl),24 - inc hl - ld (hl),255 - inc hl - ld (hl),240 ; End of subnegotiation parameters. -_wait_send: ld a,(ix) - cp 2 ; send in progress? - jr z,_wait_send - cp 0 - call nz,disp_error - - ld hl, cmdsend - call sendcmd - ret -will_not: - - ld a,(iy+6) - cp 0xFD ; DO - jr nz, not_do - ld a,0xFC ; WONT - jr next_telcmd -not_do: cp 0xFC ; WILL - jr nz, next_telcmd - ld a,0xFD ; DO - -next_telcmd: - - ld hl,sendsize - ld (hl),3 - inc hl - ld (hl),0 - inc hl - ld (hl),0xFF ; CMD - inc hl - ld (hl),a ; - inc hl - ld a,(iy+7) - ld (hl),a ; - - ld a,8 - ld (cmdsend),a - - ld hl, cmdsend - call sendcmd - - - ret - - -recv_noblock: - push af - push bc - push de - push hl - - ;ld bc,2048 - to do empty entire receive buffer and use index - - ld bc,1 - - call recv - cp 0xFF - jp z, exit_close - cp 3 - jp z, exit_close - xor a - cp c - jr nz, got_msg2 - cp b - jr nz, got_msg2 - pop hl - pop de - pop bc - pop af - ret -got_msg2: - ; disp received msg - push iy - pop hl - ld de,0x6 - add hl,de ; received text pointer - ld a,(hl) - cp CMD - jr nz,not_tel_cmd - call negotiate - - jp recvdone - -not_tel_cmd: - ld b,a - cp 0x1B ; escape code sequence? - jr nz, notescapeCode - ld (isEscapeCode),a - xor a - ld (EscapeCount),a - jp recvdone -notescapeCode: - ld a,(isEscapeCode) - cp 0 - jp z, not_in_escmode - ld hl, EscapeBuf - ld a, (EscapeCount) - inc a - ld e,a - ld d,0 - add hl,de - ld (EscapeCount),a - cp 1 - jp z, skip_check_esc_code ; we only want 0x1B,'[' ... for now - ld a,(hl) - - cp 'A' ; cursor up - jr nz, not_A - ld b,11 ; VT - ld a, (EscapeCount) - cp 2 - jp z,do_control_code - call escape_val - ld b,a - call txt_get_cursor ; H = col, L = line - ld a,l - sub b ; new line (should do <0 etc checks, gah) - call txt_set_row - jp isok2 -not_A: - cp 'B' ; cursor down - jr nz, not_B: - ld a, (EscapeCount) - ld b,10 ; LF - cp 2 - jp z,do_control_code - call escape_val - ld b,a - call txt_get_cursor ; H = col, L = line - ld a,l - add b ; new line - call txt_set_row - jp isok2 - jp do_control_code -not_B: - cp 'C' ; cursor forward - jr nz, not_C - ld a, (EscapeCount) - ld b,9 ; TAB - cp 2 - jp z,do_control_code - call escape_val - ld b,a - call txt_get_cursor ; H = col, L = line - ld a,h - add b ; new column, should check - call txt_set_column - jp isok2 -not_C: - cp 'D' ; cursor backwards - jr nz, not_D - ld a, (EscapeCount) - ld b,8 ; BS - cp 2 - jp z,do_control_code - call escape_val - ld b,a - call txt_get_cursor ; H = col, L = line - ld a,h - sub b ; new column, should check - call txt_set_column - jp isok2 -not_D: cp 'E' ; cursor next line - jr nz, not_E - ld a, (EscapeCount) - call escape_val - ld b,1 - cp 0 - jr z, default_1line - ld b,a -default_1line: - call txt_get_cursor ; H = col, L = line - add l - ld l,a - ld h,0 - call txt_set_cursor - jp isok2 -not_E: cp 'F' - jr nz, not_F - call escape_val - ld b,1 - cp 0 - jr z, default_1line2 - ld b,a -default_1line2: - call txt_get_cursor ; H = col, L = line - ld a,l - sub b - ld l,a - ld h,0 - call txt_set_cursor - jp isok2 -not_F: cp 'G' - jr nz, not_G - call escape_val - ld b,1 - cp 0 - jr z, default_1col - ld b,a -default_1col: - call txt_get_cursor ; H = col, L = line - ld a,h - sub b - ld h,a - call txt_set_cursor - jp isok2 -not_G: - cp 's' - jr nz, not_s - call txt_get_cursor - ld (curPos),hl - jp isok2 -not_s: - cp 'u' - jr nz, not_u - ld hl,(curPos) - call txt_set_cursor - jp isok2 -not_u: - -skip_check_esc_code: - - ; filter out unsused sequences - - ; upper case - cp 0x41 - jr c, recvdone ; less than - cp 0x5A - jr c, isok2 - ; check lower case - cp 0x61 - jr c, recvdone ; less than - cp 0x7A - jr nc, recvdone - -isok2: - xor a - ld (isEscapeCode),a - jr recvdone -do_control_code: - xor a - ld (isEscapeCode),a - -not_in_escmode: - ld a,b - call txt_output -recvdone: - - pop hl - pop de - pop bc - pop af - ret - - -exit_close: - - call disp_error - ld hl,cmdclose - call sendcmd - jp loop_ip - ret - - ; recv tcp data - ; in - ; bc = receive size - ; out - ; a = receive status - ; bc = received size - - -recv: ; connection still active - ld a,(ix) ; - cp 3 ; socket status (3 == remote closed connection) - ret z - ; check if anything in buffer ? - ld a,(ix+2) - cp 0 - jr nz,recv_cont - ld a,(ix+3) - cp 0 - jr nz,recv_cont - ld bc,0 - ld a,1 - ret -recv_cont: - ; set receive size - ld a,c - ld (rsize),a - ld a,b - ld (rsize+1),a - - ld hl,cmdrecv - call sendcmd - - ld a,(iy+3) - cp 0 ; all good ? - jr z,recv_ok - push af - call disp_error - pop af - ld bc,0 - ret - -recv_ok: - ld c,(iy+4) - ld b,(iy+5) - ret - - - ; - ; Find M4 ROM location - ; - -find_m4_rom: - ld iy,m4_rom_name ; rom identification line - ld d,127 ; start looking for from (counting downwards) - -romloop: push de - ld c,d - call kl_rom_select ; system/interrupt friendly - ld a,(0xC000) - cp 1 - jr nz, not_this_rom - ld hl,(0xC004) ; get rsxcommand_table - push iy - pop de -cmp_loop: - ld a,(de) - xor (hl) ; hl points at rom name - jr z, match_char -not_this_rom: - pop de - dec d - jr nz, romloop - ld a,255 ; not found! - ret - -match_char: - ld a,(de) - inc hl - inc de - and 0x80 - jr z,cmp_loop - - ; rom found, store the rom number - - pop de ; rom number - ld a,d - ld (m4_rom_num),a - ret - - ; - ; Send command to M4 - ; HL = packet to send - ; -sendcmd: - ld bc,0xFE00 - ld d,(hl) - inc d -sendloop: inc b - outi - dec d - jr nz,sendloop - ld bc,0xFC00 - out (c),c - ret - - ; display text - ; HL = text - ; BC = length - -disptext: xor a - cp c - jr nz, not_dispend - cp b - ret z -not_dispend: - ld a,(hl) - push bc - call txt_output - pop bc - inc hl - dec bc - jr disptext - - ; display text zero terminated - ; HL = text -disptextz: ld a,(hl) - or a - ret z - call txt_output - inc hl - jr disptextz - - ; - ; Display error code in ascii (hex) - ; - - ; a = error code -disp_error: - cp 3 - jr nz, not_rc3 - ld hl,msgconnclosed - jp disptextz -not_rc3: cp 0xFC - jr nz,notuser - ld hl,msguserabort - jp disptextz -notuser: - push af - ld hl,msgsenderror - ld bc,9 - call disptext - pop bc - ld a,b - srl a - srl a - srl a - srl a - add a,0x90 - daa - adc a,0x40 - daa - call txt_output - ld a,b - and 0x0f - add a,0x90 - daa - adc a,0x40 - daa - call txt_output - ld a,10 - call txt_output - ld a,13 - call txt_output - ret -disphex: ld b,a - srl a - srl a - srl a - srl a - add a,0x90 - daa - adc a,0x40 - daa - call txt_output - ld a,b - and 0x0f - add a,0x90 - daa - adc a,0x40 - daa - call txt_output - ld a,32 - call txt_output - ret - - ; - ; Get input text line. - ; - ; in - ; hl = dest buf - ; return - ; bc = out size -get_textinput: - ld bc,0 - call txt_cur_on -inputloop: - -re: call mc_wait_flyback - call km_read_char - jr nc,re - - cp 0x7F - jr nz, not_delkey - ld a,c - cp 0 - jr z, inputloop - push hl - push bc - call txt_get_cursor - dec h - push hl - call txt_set_cursor - ld a,32 - call txt_output - pop hl - call txt_set_cursor - pop bc - pop hl - dec hl - dec bc - jr inputloop -not_delkey: - cp 13 - jr z, terminate - cp 0xFC - ret z - cp 32 - jr c, inputloop - cp 0x7e - jr nc, inputloop - ld (hl),a - inc hl - inc bc - push hl - push bc - call txt_output - call txt_get_cursor - ;push hl - ;ld a,32 - ;call txt_output - ;pop hl - call txt_set_cursor - pop bc - pop hl - jp inputloop -terminate: ld (hl),0 - ret - - - ; - ; Get input text line, accept only neric and . - ; - ; in - ; hl = dest buf - ; return - ; bc = out size -get_textinput_ip: - ld bc,0 - call txt_cur_on -inputloop2: - -re2: call mc_wait_flyback - call km_read_char - jr nc,re2 - - cp 0x7F - jr nz, not_delkey2 - ld a,c - cp 0 - jr z, inputloop2 - push hl - push bc - call txt_get_cursor - dec h - push hl - call txt_set_cursor - ld a,32 - call txt_output - pop hl - call txt_set_cursor - pop bc - pop hl - dec hl - dec bc - jr inputloop2 -not_delkey2: - cp 13 - jr z, enterkey2 - cp 0xFC - ret z - cp 46 ; less than '.' - jr c, inputloop2 - cp 59 ; bigger than ':' ? - jr nc, inputloop2 - - - ld (hl),a - inc hl - inc bc - push hl - push bc - call txt_output - call txt_get_cursor - ;push hl - ;ld a,32 - ;call txt_output - ;pop hl - call txt_set_cursor - pop bc - pop hl - jp inputloop2 -enterkey2: ld (hl),0 - ret - - -crlf: ld a,10 - call txt_output - ld a,13 - jp txt_output - - - ; HL = point to IP addr - -disp_ip: ld bc,3 - add hl,bc - ld b,3 -disp_ip_loop: - push hl - push bc - call dispdec - pop bc - pop hl - dec hl - ld a,0x2e - call txt_output - djnz disp_ip_loop - - jp dispdec ; last digit - - -dispdec: ld e,0 - ld a,(hl) - ld l,a - ld h,0 - ld bc,-100 - call n1 - cp '0' - jr nz,notlead0 - ld e,1 -notlead0: call nz,txt_output - ld c,-10 - call n1 - cp '0' - jr z, lead0_2 - call txt_output -lead0_2_cont: - ld c,b - call n1 - jp txt_output - -n1: ld a,'0'-1 -n2: inc a - add hl,bc - jr c,n2 - sbc hl,bc - ret -lead0_2: - ld d,a - xor a - cp e - ld a,d - call z,txt_output - jr lead0_2_cont - - ; ix = points to :portnumber - ; hl = return 16 bit number - -port2dec: -count_digits: - inc ix - ld a,(ix) - cp 0 - jr nz,count_digits - dec ix - ld a,(ix) - cp 0x3A - ret z - sub 48 - ld l,a ; *1 - ld h,0 - - - dec ix - ld a,(ix) - cp 0x3A - ret z - sub 48 - - push hl - ld e,a - ld d,0 - ld bc,10 - call mul16 ; *10 - pop de - add hl,de - dec ix - ld a,(ix) - cp 0x3A - ret z - sub 48 - - push hl - ld e,a - ld d,0 - ld bc,100 - call mul16 ; *100 - pop de - add hl,de - dec ix - ld a,(ix) - cp 0x3A - ret z - sub 48 - - push hl - ld e,a - ld d,0 - ld bc,1000 - call mul16 ; *1000 - pop de - add hl,de - dec ix - ld a,(ix) - cp 0x3A - ret z - sub 48 - - push hl - ld e,a - ld d,0 - ld bc,10000 - call mul16 ; *10000 - pop de - add hl,de - ret - -ascii2dec: ld d,0 -loop2e: ld a,(hl) - cp 0 - jr z,found2e - cp 0x3A ; ':' port seperator ? - jr z,found2e - - cp 0x2e - jr z,found2e - ; convert to decimal - cp 0x41 ; a ? - jr nc,less_than_a - sub 0x30 ; - '0' - jr next_dec -less_than_a: - sub 0x37 ; - ('A'-10) -next_dec: - ld (hl),a - inc hl - inc d - dec bc - xor a - cp c - ret z - jr loop2e -found2e: - push hl - call dec2bin - pop hl - inc hl - ret -dec2bin: dec hl - ld a,(hl) - dec hl - dec d - ret z - ld b,(hl) - inc b - dec b - jr z,skipmul10 -mul10: add 10 - djnz mul10 -skipmul10: dec d - ret z - dec hl - ld b,(hl) - inc b - dec b - ret z -mul100: add 100 - djnz mul100 - ret - - ; BC*DE - -mul16: ld hl,0 - ld a,16 -mul16Loop: add hl,hl - rl e - rl d - jp nc,nomul16 - add hl,bc - jp nc,nomul16 - inc de -nomul16: - dec a - jp nz,mul16Loop - ret -escape_val: cp 2 - jr nz, has_value - xor a - ret -has_value: ld d,0 - sub 2 - ld e,a -dec_loop2: - ld a,(hl) - cp 0x41 ; a ? - jr nc,less_than_a2 - sub 0x30 ; - '0' - jr next_dec2 -less_than_a2: - sub 0x37 ; - ('A'-10) -next_dec2: inc hl - cp 0 - jr nz, do_mul - dec e - jr nz, dec_loop2 - ld a,d - ret -do_mul: ld b,a - ld a,e - cp 3 - jr nz, not_3digits - xor a -a_mul100: add 100 - djnz a_mul100 - ld d,a - dec e - jr nz, dec_loop2 - ret -not_3digits: cp 2 - jr nz, not_2digits - xor a -a_mul10: add 10 - djnz a_mul10 - add d - ld d,a - dec e - jr nz, dec_loop2 - ret - ld a,d -not_2digits: ld a,b - add d - ret - -disp_port: - ld bc,-10000 - call n16_1 - cp 48 - jr nz,not16_lead0 - ld bc,-1000 - call n16_1 - cp 48 - jr nz,not16_lead1 - ld bc,-100 - call n16_1 - cp 48 - jr nz,not16_lead2 - ld bc,-10 - call n16_1 - cp 48 - jr nz, not16_lead3 - jr not16_lead4 - -not16_lead0: - call txt_output - ld bc,-1000 - call n16_1 -not16_lead1: - call txt_output - ld bc,-100 - call n16_1 -not16_lead2: - call txt_output - ld c,-10 - call n16_1 -not16_lead3: - call txt_output -not16_lead4: - ld c,b - call n16_1 - call txt_output - ret -n16_1: - ld a,'0'-1 -n16_2: - inc a - add hl,bc - jr c,n16_2 - sbc hl,bc - - ;ld (de),a - ;inc de - - ret - -msgconnclosed: db 10,13,"Remote closed connection....",10,13,0 -msgsenderror: db 10,13,"ERROR: ",0 -msgconnect: db 10,13,"Connected.",10,13,0 -msgserverip: db 10,13,"Input server name or IP (:PORT or default to 23):",10,13,0 -msgnom4: db "No M4 board found, bad luck :/",10,13,0 -msgfoundm4: db "Found M4 Board v",0 -msgverfail: db ", you need v1.1.0 or higher.",10,13,0 -msgok: db ", OK.",10,13,0 -msgconnecting: db 10,13, "Connecting to IP ",0 -msgport: db " port ",0 -msgresolve: db 10,13, "Resolving: ",0 -msgfail: db ", failed!", 10, 13, 0 -msgtitle: db "CPC telnet client v1.0.1 beta / Duke 2018",0 -msgtitle2: db "=========================================",0 -msguserabort: db 10,13,"User aborted (ESC)", 10, 13,0 -cmdsocket: db 5 - dw C_NETSOCKET - db 0x0,0x0,0x6 ; domain, type, protocol (TCP/IP) - -cmdconnect: db 9 - dw C_NETCONNECT -csocket: db 0 -ip_addr: db 0,0,0,0 ; ip addr -port: dw 23 ; port - -cmdsend: db 0 ; we can ignore value of this byte (part of early design) - dw C_NETSEND -sendsock: db 0 -sendsize: dw 0 ; size -sendtext: ds 255 - -cmdclose: db 0x03 - dw C_NETCLOSE -clsocket: db 0x0 - -cmdlookup: db 16 - dw C_NETHOSTIP -lookup_name: ds 128 - -cmdrecv: db 5 - dw C_NETRECV ; recv -rsocket: db 0x0 ; socket -rsize: dw 2048 ; size - -m4_rom_name: db "M4 BOAR",0xC4 ; D | 0x80 -m4_rom_num: db 0xFF -curPos: dw 0 -isEscapeCode: db 0 -EscapeCount: db 0 -EscapeBuf: ds 255 -buf: ds 255 - -SAVE 'TELNETD.BIN',0x1000,$-0x1000,AMSDOS \ No newline at end of file diff --git a/orig/src/term22b.txt b/orig/src/term22b.txt deleted file mode 100644 index d889d41..0000000 --- a/orig/src/term22b.txt +++ /dev/null @@ -1,129 +0,0 @@ - nolist - - LIMIT &9700 ; Finish before &9700 or ELSE! -IF1 - PRINT "And off we go..." -ENDIF -IF2 - PRINT "Now putting it back together again!" -ENDIF -true equ 1 -false equ 0 -on equ true -off equ false -screen_depth equ 24 -; -save equ true -colour equ true -; -if save - write "a:term22b.bin" - if2 - print "Conversing with the disc drive..." - endif -endif -; -;See history.doc file for history of program -; -; ORG &6800 ; Start assembling at &7800 - ORG &7000 ; Above was for Charset. - -; READ "CHARSET .22A" ; Now loaded in at run time. - -.Characterset EQU &6800 -.HCharSet EQU &68 - -.Screen_C EQU &5800 -.Screen_A EQU &6000 -.Out_Buffer EQU &5000 ; Might as well go low... - -.top -; -; Firmware routines used by this program... -; - -;*** Keyboard -KM_READ_KEY EQU &BB1B -KM_WAIT_KEY EQU &BB18 -KM_GET_EXPAND EQU &BB12 -KM_TEST_KEY EQU &BB1E -KM_READ_CHAR EQU &BB09 -KM_WAIT_CHAR EQU &BB06 -KM_GET_TRANSLATE EQU &BB2A -KM_SET_TRANSLATE EQU &BB27 -;*** Text Screen -TXT_OUTPUT EQU &BB5A -TXT_WR_CHAR EQU &BB5D -TXT_WIN_ENABLE EQU &BB66 -TXT_GET_WINDOW EQU &BB69 -TXT_SET_COLUMN EQU &BB6F -TXT_SET_ROW EQU &BB72 -TXT_SET_CURSOR EQU &BB75 -TXT_GET_CURSOR EQU &BB78 -TXT_CUR_ON EQU &BB81 -TXT_CUR_OFF EQU &BB84 -TXT_GET_MATRIX EQU &BBA5 -;*** Screen, General -SCR_SET_OFFSET EQU &BC05 -SCR_SET_MODE EQU &BC0E -SCR_GET_MODE EQU &BC11 -SCR_CLEAR EQU &BC14 -SCR_SET_INK EQU &BC32 -SCR_GET_INK EQU &BC35 -SCR_HW_ROLL EQU &BC4D -;*** Machine pack -MC_WAIT_FLYBACK EQU &BD19 -MC_PRINT_CHAR EQU &BD2B -MC_BUSY_PRINTER EQU &BD2E -;*** Cassette/Disc -CAS_OUT_OPEN EQU &BC8C -CAS_OUT_CLOSE EQU &BC8F -CAS_OUT_CHAR EQU &BC95 -;*** Kernel - High -KL_U_ROM_DISABLE EQU &B903 -KL_ROM_RESTORE EQU &B90C -;*** Kernal - Normal -KL_LOG_EXT EQU &BCD1 -KL_FIND_COMMAND EQU &BCD4 -KL_NEW_FRAME_FLY EQU &BCD7 -KL_DEL_FRAME_FLY EQU &BCDD -KL_NEW_FAST_TICKER EQU &BCE0 -KL_DEL_FAST_TICKER EQU &BCE6 -KL_DISARM_EVENT EQU &BD0A - -89 ; Start line numbering again -; -; Logon on the three RSX's -; -; -.login LD BC,command_table - LD HL,rsx_data_area - CALL KL_LOG_EXT - RET - -.command_table - WORD rsx_names - JP term -; JP clearbuffer - JP setup -; JP captureon -; JP captureoff -; JP status -.rsx_names ; Names of the routines. - STR "TERM" ; Terminal program -; STR "CLRBUF" ; Clear readin buffer - STR "SETUP" ; Configuration program -; STR "CAPTURE" ; Turn capture, with filename. -; STR "CAPTUREOFF" ; Turn capture off. -; STR "STATS" ; Current user settings - BYTE 0 -.rsx_data_area - RMEM 4 ; 4 bytes for RSX workspace - - READ "MAINLINE.22B" - READ "ANSITERM.22B" - READ "SCREEN .22B" - READ "SETP .22B" - READ "DATA .22B" - - END