Files
RomWBW/Source/Images/d_bp/u15/DEBUGRCP.ASM
b1ackmai1er 78f65522b7 Dev (#108)
* added hack to handle tunes

* quiet clean

* added chmod for execution

* suppress warnings

* Multi-boot fixes

* the windows build somehow thinks that these filesystems are cpm3.

* credit and primitive instructions

* Update sd.asm

Cosmetic fix.

* make compile shut up about conditionals

* Add bin2asm for linus and update build to process font files under linix

* fixed quoted double quote bug, added tests

* added tests

* added bin2asm for font file source creation

* Revert linux bin2asm font stuff

* added rule for font source generation

* build fonts

* added directory mapping cache.  if the same directory is being hit
as last run, we don't need to rebuild the map.  will likely break if
you are running more than one at a time, in that the cache will be
ineffective.  also, if the directory contents change, this will also break.

* removed strip.  breaks osx

* added directory tag so . isn't matched all over the place

* added real cache validation

* fixed build

* this file is copied from optdsk.lib or optcmd.lib

* install to ../HBIOS

* prerequisite verbosity

* diff soft failure and casefn speedup

* added lzsa

* added lzsa

* removed strip. breaks on osx

* added clobber

* added code to handle multiple platform rom builds with rom size override

* added align and 0x55 hex syntax

* default to hd64180

* added N8 capability

* added SBC_std.rom to default build

* added support for binary diff

* diff fixes

* clean, identical build.  font source generator emitted .align.  this does not match the windows build

* Upgrade NZCOM to latest

* Misc. Cleanup

* fixed expression parser bug : ~(1|2) returned 0xfe

* added diff build option

* Update Makefile

Makefile enhancement to better handle ncurses library from Bob Dunlop.

* Update sd.asm

Back out hack for uz80as now that Curt fixed it.

* Misc. Cleanup

* UNA Catchup

UNA support was lacking some of the more recent behavior changes.  This corrects most of it.

* Add github action for building RomWBW

* Bump Pre-release Version

* Update build.yml

Added "make clean" which will remove temporary files without removing final binary outputs.

* Update Makefile

Build all ROM variants by default in Linux/Mac build.

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update Makefile

* Update for GitHub Build

Case issue in TASM includes showing up in GitHub build.  This should correct that.

* Added an gitignore files to exclude generated files

* Removed Tunes/clean.cmd and Tunes/ReadMe.txt - as make clean removes them

* Build.sh: marked as executable

chmod +x Build.sh

* Fix to HBIOS/build.sh

When adding files to rom disk, if files were missing, it would error out.

It appears the intent is to skip non-existing files.

Updated to log out correctly for missing files - and continue operation.

* Update Microsoft NASCOM BASIC.docx

Nascom manual, text version by Jan S (full name unknown)

* Fix issue with Apps/Tune not making

If dest directory does not exist, fails to make Apps

* Create ReadMe.txt

* Update Makefile

* Update Build.sh

* Make .gitignores for Tools/unix more specific

* cpmtools Update

Updated cpmtools applications (Windows only).  Removed hack in diskdefs that is no longer required.

* HBIOS Proxy Temp Stack Enhancement

Reuse the bounce buffer area as the temporary stack space required briefly in HBX_INVOKE when transitioning banks.  Increases size of temporary stack space to 64 bytes.

* Update ReadMe.txt

* HBIOS - clean up TMPSTK

* Update hbios.asm

Minor cosmetic changes.

* Build Process Updates

Minor udpates to build process to improve consistency between Windows and Mac/Linux builds.

* Update hbios.asm

Add improved interrupt protection to HBIOS PEEK, POKE, and BNKCPY functions.

* hbios - wrap hbx_bnkcpy

* hbios - adjust hbx_peek hbx_poke guards

* Update hbios.asm

Adjusted used of DI/EI for PEEK and POKE to regain a bit of INTSTK space.  Added code so that HB_INVBNK can be used as a flag indicating if HBIOS is active, $FF is inactive, anything else means active.

* Add HBIOS MuTex

* Initial Nascom basic ecb-vdu graphics

set and reset for 80x25b screen with 256 character mod

* Finalize Pre-release 34

Final support for FreeRTOS

* Update nascom.asm

Optimization, cleanup, tabs and white spaces

* IDE & PPIDE Cleanup

* Clean up

Make version include files common.

* Update Makefile

* Update Makefile

* Build Test

* Build Test

* Build Fixes

* Update nascom.asm

Cleanup

* Update nascom.asm

Optimization

* hbios - temp stack tweak

* Update hbios.asm

Comments on HBX_BUF usage.

* Update nascom.asm

Optimization

* Update nascom.asm

Setup ECB-VDU build option, remove debug code

* Update nascom.asm

Set default build. update initialization

* Update nascom.asm

Make CLS clear vdu screen

* Update nascom.asm

Fixup top screen line not showing

* Add SC131 Support

Also cleaned up some ReadMe files.

* HBIOS SCZ180 - remove mutex special files

* HBIOS SCZ180 - adjust mutex comment

* Misc. Cleanup

Includes some minor improvements to contents in some disk images.

* Delete FAT.COM

Changing case of FAT.COM extension to lowercase.

* Create FAT.com

Completing change of case in extension of FAT.com.

* Update Makefile

Remove ROM variants that just have the HBIOS MUTEX enabled.  Users can easily enable this in a custom build.

* Cleanup

Removed hack from Images Makefile.  Fixed use of DEFSERCFG in various places.

* GitHub CI Updates

Adds automation of build and release assets upon release.

* Prerelease 36

General cleanup

* Build Script Cleanups

* Config File Cleanups

* Update RomWBW Architecture

General refresh for v2.9.2

* Update vdu.asm

Removed a hack in VDU driver that has existed for 8 years.  :-)

* Fix CONSOLE Constant

Rename CIODEV_CONSOLE constant to CIO_CONSOLE because it is a unit code, not a device type code.

Retabify TastyBasic.

* Minor Bug Fixes

- Disk assignment edge case
- CP/M 3 accidental fall thru
- Cosmetic updates

* Update util.z80

* Documentation Cleanup

* Documentation Update

* Documentation Update

* Documentation Updates

* Documentation Updates

* Create Common.inc

* Documentation Updates

* Documentation Updates

* doc - a few random fixes

* Documentation Cleanup

* Fix IM 0 Build Error in ACIA

* Documentation Updates

* Documentation Cleanup

* Remove OSLDR

The OSLDR application was badly broken and almost impossible to fix with new expanded OS support.

* Bug Fixes

- Init RAM disk at boot under CP/M 3
- Fix ACR activation in TUNE

* FD Motor Timeout

- Made FDC motor timeout smaller and more consistent across different speed CPUs
- Added "boot" messaging to RTC

* Cleanup

* Cleanup

- Fix SuperZAP to work under NZCOM and ZPM3
- Finalize standard config files

* Minor Changes

- Slight change to ZAP configuration
- Added ZSDOS.ZRL to NZCOM image

* ZDE Upgrade

- Upgraded ZDE 1.6 -> 1.6a

* Config File Tuning

* Pre-release for Testing

* cfg - mutex consistent config language

* Bump to Version 3.0

* Update SD Card How-To

Thanks David!

* update ReadMe.md

Remove some odd `\`.

* Update ReadMe.txt

* Update ReadMe.md

* Update Generated Doc Files

* Improve XModem Startup

- Extended startup timeout for XM.COM so that it doesn't timeout so quickly while host is selecing a file to send.
- Updated SD Card How-To from David Reese.

* XModem Timing Refinements

* TMS Driver Z180 Improvements

- TMS driver udpated to insert Z180 I/O waitstates internally so other code can run at full speed.
- Updated How-To documents from David.
- Fixed TUNE app to properly restore Z180 I/O waitstates after manipulating them.

* CLRDIR and ZDE updates

- CLRDIR has been updated by Max Scane for CP/M 3 compatibility.
- A minor issue in the preconfigured ZDE VT100 terminal escape sequences was corrected.

* Fix Auto CRT Console Switch on CP/M 3

* Handle lack of RTC better

DSRTC driver now correctly returns an error if there is no RTC present.

* Minor RTC Updates

* Finalize v3.0.1

Cleanup release for v3.0

* New ROMLDR and INTRTC driver

- Refactored romldr.asm
- Added new periodic timer based RTC driver

* CP/M 3 Date Hack

- Hack to allow INTRTC to increment time without destroying the date

* Update romldr.asm

Work around minor Linux build inconsistency

* Update Apps for New Version

* Revert "Update Apps for New Version"

This reverts commit ad80432252.

* Revert "Update romldr.asm"

This reverts commit 4a9825cd57.

* Revert "CP/M 3 Date Hack"

This reverts commit 153b494e61.

* Revert "New ROMLDR and INTRTC driver"

This reverts commit d9bed4563e.

* Start v3.1 Development

* Update FDISK80.COM

Updated FDISK80 to allow reserving up to 256 slices.

* Update sd.asm

For Z180 CSIO, ensure that xmit is finished, before asserting CS for next transaction.

* Add RC2014 UART, Improve SD protocol fix

- RC2014 and related platforms will autodetect a UART at 0xA0 and 0xA8
- Ensure that CS fully brackets all SD I/O

* ROMLDR Improvements

.com files can now be started from CP/M and size of .com files has been reduced so they always fit.

* Update commit.yml

Run commit build in all branches

* Update commit.yml

Run commit build for master and dev branches

* Improved clock driver auto-detect/fallback

* SIO driver now CTC aware

The SIO driver can now use a CTC (if available) to provide much more flexible baud rate programming.

* CTC driver fine tuning

* Update xmdm125.asm

Fixed a small issue in core XM125 code that caused a file write error message to not be displayed when it should be.

* CF Card compatibility improvement

Older CF Cards did not reset IDE registers to defaults values when reset.  Implemented a work around.

* Update ACIA detection

ACIA should no longer be detected if there is also a UART module in the system.

* Handle CTC anomaly

Small update to accommodate CTC behavior that occurs when the CTC trigger is more than half the CTC clock.

* Update acia.asm

Updated ACIA detection to use primary ACIA port instead of phantom port.

* Update acia.asm

Fix bug in ACIA detection.

Thanks Alan!

* MacOS Build Improvement

Build script updated to improve compatibility with MacOS.

Credit to Fredrik Axtelius for this.

* HBIOS Makefile - use env vars for target

Allow build ROM targets to be restricted to just one platform thru use of ENV vars:

ROM_PLATFORM - if defined to a known platform, only this platform is build - defaults to std config
ROM_CONFIG - sets the desired platform config - defaults to std

if the above ENVs are not defined, builds all ROMs

* Added some more gitignores

* Whitespace changes (crlf)

* HBIOS: Force the assembly to fail for vdu drivers if function table count is not correct

* Whitespace: trailing whitespaces

* makefile: updated some make scripts to use  when calling subdir makefiles

* linux build: update to Build.sh fix for some platforms

The initialization of the Rom dat file used the pipe (|) operator to build an initial empty file.

But the pipe operator | may sometimes return a non-zero exit code for some linux platforms, if the
the streams are closed before dd has fully processed the stream.

This issue occured on a travis linux ubuntu image.

Solution was to change to redirection.

* Bump version

* Enhance CTC periodic timer

Add ability to use TIMER mode in CTC driver to generate priodic interrupts.

* HBIOS: Added support for sound drivers

New sound driver support with initial support for the SN76489 chip

New build configuration entry:
* SN76489ENABLE

Ports are currently locked in with:
* SN76489_PORT_LEFT       .EQU    $FC     ; PORTS FOR ACCESSING THE SN76489 CHIP (LEFT)
* SN76489_PORT_RIGHT      .EQU    $F8     ; PORTS FOR ACCESSING THE SN76489 CHIP (LEFT)

* Miscellaneous Cleanup

No functional changes.

Co-authored-by: curt mayer <curt@zen-room.org>
Co-authored-by: Wayne Warthen <wwarthen@gmail.com>
Co-authored-by: ed <linux@maidavale.org>
Co-authored-by: Dean Netherton <dnetherton@dius.com.au>
Co-authored-by: ed <ed@maidavale.org>
Co-authored-by: Phillip Stevens <phillip.stevens@gmail.com>
Co-authored-by: Dean Netherton <dean.netherton@gmail.com>
2020-04-24 06:17:22 +08:00

1587 lines
27 KiB
NASM
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
; SYSTEM SEGMENT: DEBUG.RCP
; SYSTEM: ARIES-1
; CUSTOMIZED BY: RICHARD CONN
;
; PROGRAM: DEBUGRCP.ASM
; AUTHOR: RICHARD CONN
; VERSION: 1.0
; DATE: 30 JUNE 84
; PREVIOUS VERSIONS: NONE
;
VERS EQU 10
RCPID EQU 'A'
;
; DEBUGRCP is a resident debug command package for ZCPR3. As with
; all resident command processors, DEBUGRCP performs the following functions:
;
; 1. Assuming that the EXTFCB contains the name of the
; command, DEBUGRCP looks to see if the first character
; of the file name field in the EXTFCB is a question
; mark; if so, it returns with the Zero Flag Set and
; HL pointing to the internal routine which prints
; its list of commands
; 2. The resident command list in DEBUGRCP is scanned for
; the entry contained in the file name field of
; EXTFCB; if found, DEBUGRCP returns with the Zero Flag
; Set and HL pointing to the internal routine which
; implements the function; if not found, DEBUGRCP returns
; with the Zero Flag Reset (NZ)
;
;
; Global Library which Defines Addresses for DEBUGRCP
;
MACLIB Z3BASE
;
CTRLC EQU 'C'-'@'
BS EQU 08H
TAB EQU 09H
LF EQU 0AH
FF EQU 0CH
CR EQU 0DH
CTRLX EQU 'X'-'@'
;
WBOOT EQU BASE+0000H ;CP/M WARM BOOT ADDRESS
UDFLAG EQU BASE+0004H ;USER NUM IN HIGH NYBBLE, DISK IN LOW
BDOS EQU BASE+0005H ;BDOS FUNCTION CALL ENTRY PT
TFCB EQU BASE+005CH ;DEFAULT FCB BUFFER
FCB1 EQU TFCB ;1st and 2nd FCBs
FCB2 EQU TFCB+16
TBUFF EQU BASE+0080H ;DEFAULT DISK I/O BUFFER
TPA EQU BASE+0100H ;BASE OF TPA
;
; SYSTEM Entry Point
;
org rcp ; passed for Z3BASE
db 'Z3RCP' ; Flag for Package Loader
;
; **** Command Table for RCP ****
; This table is RCP-dependent!
;
; The command name table is structured as follows:
;
; ctable:
; DB 'CMNDNAME' ; Table Record Structure is
; DW cmndaddress ; 8 Chars for Name and 2 Bytes for Adr
; ...
; DB 0 ; End of Table
;
cnsize equ 4 ; NUMBER OF CHARS IN COMMAND NAME
db cnsize ; size of text entries
ctab:
db 'H ' ; Help for RCP
dw clist
ctab1:
db 'MU ' ; Memory Utility
dw mu
;
db 0
;
; BANNER NAME OF RCP
;
rcp$name:
db 'DEBUG '
db (vers/10)+'0','.',(vers mod 10)+'0'
db RCPID
db 0
;
; Command List Routine
;
clist:
lxi h,rcp$name ; print RCP Name
call print1
lxi h,ctab1 ; print table entries
mvi c,1 ; set count for new line
clist1:
mov a,m ; done?
ora a
rz
dcr c ; count down
jnz clist1a
call crlf ; new line
mvi c,4 ; set count
clist1a:
lxi d,entryname ; copy command name into message buffer
mvi b,cnsize ; number of chars
clist2:
mov a,m ; copy
stax d
inx h ; pt to next
inx d
dcr b
jnz clist2
inx h ; skip to next entry
inx h
push h ; save ptr
lxi h,entrymsg ; print message
call print1
pop h ; get ptr
jmp clist1
;
; Print String (terminated in 0 or MSB Set) at Return Address
;
vprint:
eprint:
xthl ; get address
call print1
xthl ; put address
ret
;
; Print String (terminated in 0 or MSB Set) pted to by HL
;
print1:
mov a,m ; done?
inx h ; pt to next
ora a ; 0 terminator
rz
cpi dim ; standout?
jz print1d
cpi bright ; standend?
jz print1b
call cout ; print char
ora a ; set MSB
rm ; MSB terminator
jmp print1
print1d:
call stndout ; dim
jmp print1
print1b:
call stndend ; bright
jmp print1
;
; New Line
;
crlf:
mvi a,cr
call cout
mvi a,lf ;fall thru
;
; Character Output
;
cout:
push psw
push b
push d
push h
mov e,a
mvi c,2 ; use BDOS
call bdos
pop h
pop d
pop b
pop psw
ret
;
; Get char in A
;
cin:
push h
push d
push b
mvi c,1
call bdos
ani 7fh
push psw
mvi a,bs ;overwrite
call cout
pop psw
pop b
pop d
pop h
ret
;
; CLIST Messages
;
entrymsg:
db ' ' ; command name prefix
entryname:
ds cnsize ; command name
db 0 ; terminator
;
; General Equates
;
bel equ 07h
bs equ 08h
cr equ 0dh
lf equ 0ah
fcb equ 5ch
DIM EQU 1
BRIGHT EQU 2
EOLCH EQU 0 ;END OF LINE CHAR
SEPCH EQU ',' ;SEPARATOR CHAR
EROW EQU 6 ;FIRST ROW OF EDITOR DISPLAY
ECOL EQU 4 ;FIRST COL OF EDITOR DISPLAY
ECOLC EQU ECOL+16*3+8 ;FIRST COL OF EDITOR CHAR DISPLAY
ECURS EQU '>' ;EDITOR CURSOR
PRROW EQU 22 ;PROMPT ROW
PRCOL EQU 10 ;PROMPT COLUMN
PRCOLI EQU PRCOL+15 ;PROMPT INPUT COL
ERROW EQU 23 ;ERROR MESSAGE ROW
ERCOL EQU 15 ;ERROR MESSAGE COLUMN
;
; DEFINE FREE SPACE
;
MU:
LXI H,TBUFF ;DETERMINE ADDRESS
MVI M,126 ;126 CHARS INPUT ALLOWED
SHLD BUFFER ;SET PTR
;
; SET UP ARROW KEYS
;
LXI H,Z3ENV ;PT TO ENVIRONMENT DESCRIPTOR
LXI D,80H+10H ;PT TO ARROW KEY INFO
DAD D
LXI D,EDCURT ;PT TO CURSOR TABLE
MVI B,4 ;4 ARROW KEYS
ARROW:
MOV A,M ;GET CHAR
STAX D ;STORE CHAR
INX H ;PT TO NEXT
INX D ;PT TO NEXT ENTRY
INX D
INX D
DCR B ;COUNT DOWN
JNZ ARROW
;
; Initialize Terminal
;
call tinit
;
; Check for Command Line Parameter
;
lxi h,fcb+1 ;pt to first char
mov a,m ;get char
cpi ' ' ;no param?
jnz pcheck
lxi h,tpa ;pt to TPA
jmp mu3
;
; We have a parameter
;
pcheck:
call hexin ;convert to binary
xchg ;HL=value
jmp mu3
;
; Erase to EOL
; If fct not supported, send out B spaces and B backspaces
;
vereol:
call ereol ;try erase
rnz
push b ;save B
mvi a,' ' ;send spaces
call vereol1
pop b ;get B
mvi a,bs ;send backspaces
vereol1:
call cout ;send char in A
dcr b
jnz vereol1
ret
;
; Clear Screen
; If fct not supported, write 24 CRLFs
;
vcls:
call cls ;try clear
rnz
push b ;save B
mvi b,24 ;count
vcls1:
call crlf
dcr b
jnz vcls1
pop b
ret
;
; Run MU3
; HL contains starting address
;
mu3:
SHLD BLOCK ;SAVE PTR TO BLOCK
;
; REFRESH EDIT SCREEN
;
EDIT0:
CALL VCLS ;NEW SCREEN
CALL AT
DB 2,35 ;ROW 2, COL 35
CALL VPRINT ;BANNER
DB 'MU RCP '
DB (VERS/10)+'0','.',(VERS MOD 10)+'0',RCPID
DB 0
;
; REENTER MU3 WITH PTRS RESET
;
MU3R:
XRA A ;A=0
STA EINDEX ;SET INDEX TO 0 (FIRST ELEMENT)
CALL EDPLOT ;PLOT BUFFER DATA
;
; INPUT EDITOR COMMAND
;
EDITCMD:
CALL PRMSG ;POSITION AT PROMPT MESSAGE
DB 'MU Command?',0
CALL PRINP ;POSITION AT PROMPT INPUT
DB 0
CALL CIN ;GET CHAR
CALL CAPS ;CAPITALIZE
MOV B,A ;COMMAND IN B
LXI H,EDCURT ;PROCESS CURSOR COMMANDS FIRST
CALL CMD ;PROCESS COMMAND
LXI H,ECMDTBL ;EDITOR COMMAND TABLE
CALL CMD ;PROCESS COMMAND
CALL VPRINT ;ERROR MESSAGE
DB BEL,0
JMP EDITCMD
;
; Position at Prompt Message and Print it
;
PRMSG:
CALL AT ;POSITION
DB PRROW,PRCOL
JMP VPRINT ;PRINT IT
;
; Position at Prompt Input and Print Prompt
;
PRINP:
CALL AT ;POSITION
DB PRROW,PRCOLI
JMP VPRINT ;PRINT IT
;
;INPUT ERROR
;
WHAT:
CALL VPRINT
DB BEL,0
JMP EDITCMD
;
;Command Table Search and Execute
;
CMD:
MOV A,M ;CHECK FOR END OF TABLE
ORA A
RZ ;COMMAND NOT FOUND
CMP B ;MATCH?
JZ CMDRUN
INX H ;SKIP TO NEXT ENTRY IN TABLE
INX H
INX H
JMP CMD
;
;RUN COMMAND
;
CMDRUN:
INX H ;PT TO LOW ADDRESS
MOV E,M
INX H ;PT TO HIGH ADDRESS
MOV D,M
XCHG
POP PSW ;CLEAR STACK
PCHL ;RUN ROUTINE
;
;PLOT BUFFER DATA
;
EDPLOT:
MVI H,EROW-1 ;SET ROW
MVI L,ECOL ;SET COLUMN
CALL GOTOXY ;POSITION CURSOR
CALL VPRINT
DB DIM
DB ' 0 1 2 3 4 5 6 7 8 9 A B C D E F'
DB BRIGHT,0
INR H ;NEXT ROW
CALL GOTOXY ;POSITION CURSOR
XCHG ;POSITION IN DE
LHLD BLOCK ;PT TO DATA
MVI B,8 ;8 LINES
;
;Print Next Line on Screen
;
EDIT00:
CALL STNDOUT ;GO DIM
MOV A,H ;OUTPUT ADDRESS
CALL PA2HC
MOV A,L
CALL PA2HC
CALL VPRINT
DB ':',BRIGHT,' ',0
MVI C,16 ;16 ELEMENTS
EDIT01:
MOV A,M ;GET BYTE
CALL PA2HC ;PRINT AS HEX
CALL SPACE ;PRINT 1 SPACE
INX H ;PT TO NEXT
DCR C ;COUNT DOWN
JNZ EDIT01
XCHG ;POSITION AGAIN
INR H ;NEXT ROW
CALL GOTOXY
XCHG
DCR B ;COUNT DOWN
JNZ EDIT00
MVI H,EROW ;RESET ROW
MVI L,ECOLC ;RESET COL
CALL GOTOXY ;POSITION CURSOR
XCHG ;POSITION IN DE
LHLD BLOCK ;PT TO DATA
MVI B,8 ;8 LINES
EDIT02:
CALL BAR ;PRINT BAR
MVI C,16 ;16 ELEMENTS
EDIT03:
MOV A,M ;GET BYTE
ANI 7FH ;MASK MSB
CPI 7FH ;DON'T PRINT 7FH
JZ EDIT7F
CPI ' ' ;SPACE OR MORE?
JNC EDIT04
EDIT7F:
MVI A,'.' ;PRINT DOT
EDIT04:
CALL COUT ;PRINT BYTE
INX H ;PT TO NEXT
DCR C ;COUNT DOWN
JNZ EDIT03
CALL BAR ;PRINT ENDING BAR
XCHG ;POSITION AGAIN
INR H ;NEXT ROW
CALL GOTOXY
XCHG
DCR B ;COUNT DOWN
JNZ EDIT02
CALL EDCUR ;POSITION CURSOR
RET
;
;EDITOR COMMAND TABLE
;
ECMDTBL:
DB CR ;NOP
DW EDITCMD
DB 'C'-'@' ;^C = EXIT MU3
DW EDCC
DB 'R'-'@' ;^R = REFRESH
DW EDIT0
DB 'E'-'@' ;^E=UP
DW EDUP
DB 'X'-'@' ;^X=DOWN
DW EDDOWN
DB 'D'-'@' ;^D=RIGHT
DW EDRIGHT
DB 'S'-'@' ;^S=LEFT
DW EDLEFT
DB ' ' ;NOP
DW EDITCMD
DB '+' ;ADVANCE
DW EDITPLUS
DB '-' ;BACKUP
DW EDITMINUS
DB 'A' ;ADDRESS
DW EDITADR
DB 'C' ;COMMAND LINE
DW EDITCL
DB 'N' ;CHANGE NUMBERS
DW EDITHEX
DB 'T' ;CHANGE TEXT
DW EDITALP
DB 0 ;END OF TABLE
;
; ARROW KEY DEFINITONS FROM TCAP
;
EDCURT:
DB 0 ;0 INDICATES NO ARROW KEYS
DW EDUP
DB 0
DW EDDOWN
DB 0
DW EDRIGHT
DB 0
DW EDLEFT
DB 0 ;END OF TABLE
;
;Enter Command Line
;
EDITCL:
CALL VPRINT ;PROMPT INPUT
DB CR,LF,'Command Line? ',0
CALL RDBUF ;INPUT TEXT
CALL PUTCL ;STORE COMMAND LINE
JMP CRLF ;NEW LINE
;
; STORE COMMAND LINE
;
PUTCL:
XCHG ;PTR TO NEW LINE IN DE
CALL GETCL1 ;GET COMMAND LINE DATA
MOV B,A ;CHAR COUNT IN B
XCHG ;HL PTS TO NEW LINE
PUSH H ;SAVE PTR TO NEXT LINE
PCL1:
MOV A,M ;GO TO END OF LINE
ORA A ;AT END?
JZ PCL2
INX H ;PT TO NEXT
DCR B ;COUNT DOWN
JNZ PCL1
POP H ;CLEAR STACK
RET ;COMMAND LINE TOO LONG - ABORT
;
; AT END OF NEW COMMAND LINE
; PTR TO FIRST CHAR OF NEW COMMAND LINE ON STACK
; HL PTS TO ENDING 0 OF NEW COMMAND LINE
; B = NUMBER OF CHARS REMAINING BEFORE COMMAND LINE OVERFLOW
;
PCL2:
XCHG ;DE PTS TO LAST BYTE
PUSH D ;SAVE PTR IN CASE OF ERROR
CALL GETCL2 ;PT TO TAIL OF COMMAND LINE BUFFER
MOV A,M ;GET FIRST CHAR OF TAIL
CPI ';' ;CONTINUATION?
JZ PCL3
ORA A ;DONE?
JZ PCL3
MVI A,';' ;SET CONTINUATION CHAR
STAX D
INX D
DCR B ;COUNT DOWN
JZ PCL4 ;OVERFLOW
;
; COPY TAIL ONTO END OF NEW COMMAND LINE
;
PCL3:
MOV A,M ;GET NEXT CHAR
STAX D ;STORE IT
INX H ;PT TO NEXT
INX D
ORA A ;DONE?
JZ PCL5
DCR B ;COUNT DOWN
JNZ PCL3
;
; COMMAND LINE TOO LONG
;
PCL4:
POP H ;GET PTR TO END OF OLD LINE
MVI M,0 ;STORE ENDING 0
POP PSW ;CLEAR STACK
RET
;
; NEW COMMAND LINE OK
;
PCL5:
POP PSW ;CLEAR STACK
CALL GETCL1 ;GET PTR TO BUFFER
LXI D,4 ;PT TO FIRST CHAR IN BUFFER
XCHG
DAD D
XCHG
MOV M,E ;STORE ADDRESS
INX H
MOV M,D
POP H ;HL PTS TO FIRST CHAR OF NEW LINE
;
; COPY COMMAND LINE INTO BUFFER
;
PCL6:
MOV A,M ;COPY
STAX D
INX H
INX D
ORA A ;DONE?
JNZ PCL6
RET
;
; GETCL1
;
GETCL1:
LHLD Z3ENV+18H ;GET ADDRESS OF COMMAND LINE BUFFER
PUSH H ;SAVE IT
INX H ;GET SIZE IN A
INX H
MOV A,M
POP H
RET
;
; GETCL2
;
GETCL2:
LHLD Z3ENV+18H ;GET ADDRESS OF COMMAND LINE BUFFER
MOV A,M ;GET ADDRESS OF NEXT CHAR
INX H
MOV H,M
MOV L,A ;HL PTS TO NEXT CHAR
MOV A,M ;GET IT
RET
;
;Enter ASCII Chars
;
EDITALP:
CALL PRINP ;PROMPT INPUT
DB DIM,'Enter Text',BRIGHT
DB CR,LF,' --> ',0
CALL RDBUF ;INPUT TEXT WITHOUT PROMPT
CALL EDPRCL ;CLEAR PROMPT LINE
LDA EINDEX ;PT TO POSITION
XCHG
LHLD BLOCK ;COMPUTE OFFSET
XCHG
ADD E
MOV E,A
MOV A,D
ACI 0
MOV D,A ;DE PTS TO BYTE, HL PTS TO TEXT
EDITA1:
MOV A,M ;GET CHAR
CPI EOLCH ;EOL?
JZ EDITA2 ;REFRESH SCREEN
CALL GETAHV ;GET ASCII OR <HEX> VALUE
STAX D ;UPDATE BYTE
INX H ;PT TO NEXT INPUT CHAR
INR E ;PT TO NEXT BUFFER BYTE
JNZ EDITA1
EDITA2:
CALL EDPLOT ;REPLOT
JMP EDITCMD ;DONE-REFRESH SCREEN
;
;Enter Numbers
;
EDITHEX:
CALL PRINP ;PROMPT INPUT
DB DIM,'Enter Hex Numbers'
DB BRIGHT
DB CR,LF,' --> ',0
CALL RDBUF ;INPUT TEXT WITHOUT PROMPT
CALL EDPRCL ;CLEAR PROMPT LINE
LDA EINDEX ;PT TO POSITION
XCHG
LHLD BLOCK ;COMPUTE OFFSET
XCHG
ADD E
MOV E,A
MOV A,D
ACI 0
MOV D,A ;DE PTS TO BYTE, HL PTS TO TEXT
EDITH1:
MOV A,M ;GET HEX DIGIT
CPI EOLCH ;EOL?
JZ EDITA2 ;REFRESH SCREEN
CPI ' ' ;SKIP SPACES
JNZ EDITH2
INX H ;SKIP SPACE
JMP EDITH1
EDITH2:
PUSH D ;SAVE PTR
CALL HEXIN ;GET VALUE AND POSITION HL
MOV A,E ;... IN A
POP D ;GET PTR
STAX D ;PUT BYTE
INR E ;ADVANCE TO NEXT BYTE
JNZ EDITH1
JMP EDITA2 ;DONE-REFRESH
;
;CLEAR PROMPT LINE
;
EDPRCL:
CALL PRINP ;PROMPT LINE
DB 0
MVI B,40 ;40 POSITIONS
CALL VEREOL ;CLEAR TO EOL OR 40 CHARS
CALL AT ;USER INPUT
DB ERROW,1
MVI B,79 ;79 POSITIONS
JMP VEREOL
;
;Input Address
;
EDITADR:
CALL VPRINT
DB 'Address? ',0
CALL RDBUF ;GET USER INPUT
CALL SKSP ;SKIP LEADING SPACES
MOV A,M ;EMPTY LINE?
ORA A
JZ EDIT0
CALL HEXIN ;CONVERT FROM HEX
XCHG ;HL = ADDRESS
SHLD BLOCK
JMP EDIT0 ;REENTER
;
;Advance to Next Block
;
EDITPLUS:
LHLD BLOCK ;ADVANCE TO NEXT BLOCK
LXI D,128 ;128 BYTES
DAD D
SHLD BLOCK
JMP MU3R
;
;Backup to Last Block
;
EDITMINUS:
LHLD BLOCK ;BACKUP TO LAST BLOCK
LXI D,-128 ;128 BYTES
DAD D
SHLD BLOCK
JMP MU3R
;
;Exit MU3
;
EDCC:
CALL DINIT ;DEINIT TERM
JMP CRLF ;NEW LINE
;
;EDIT MOVE: UP
;
EDUP:
CALL EDCCUR ;CLEAR CURSOR
LDA EINDEX ;BACKUP INDEX BY 16
SUI 16
;
;Common EDIT MOVE Routine - on input, A=new index
;
EDMOVE:
ANI 7FH ;MOD 128
STA EINDEX
CALL EDCUR ;SET CURSOR
JMP EDITCMD
;
;EDIT MOVE: DOWN
;
EDDOWN:
CALL EDCCUR ;CLEAR CURSOR
LDA EINDEX ;INCREMENT INDEX BY 16
ADI 16
JMP EDMOVE ;COMMON ROUTINE
;
;EDIT MOVE: RIGHT
;
EDRIGHT:
CALL EDCCUR ;CLEAR CURSOR
LDA EINDEX ;INCREMENT INDEX BY 1
INR A
JMP EDMOVE ;COMMON ROUTINE
;
;EDIT MOVE: LEFT
;
EDLEFT:
CALL EDCCUR ;CLEAR CURSOR
LDA EINDEX ;DECREMENT INDEX BY 1
DCR A
JMP EDMOVE ;COMMON ROUTINE
;
;EDIT SUBROUTINE: EDCUR
; Position Editor Cursor at EINDEX
;EDIT SUBROUTINE: EDCCUR
; Clear Editor Cursor at EINDEX
;
EDCUR:
PUSH H ;SAVE HL
MVI C,ECURS ;CURSOR CHAR
CALL EDSETCUR
CALL AT ;UPDATE DATA
DB 3,74
LDA EINDEX ;PT TO BYTE AT CURSOR
LHLD BLOCK
ADD L
MOV L,A
MOV A,H
ACI 0
MOV H,A ;HL PTS TO BYTE AT CURSOR
MOV A,M ;GET BYTE
CALL PA2HC ;PRINT AS HEX
CALL SPACE
MOV A,M ;GET BYTE
POP H ;RESTORE HL
ANI 7FH ;MASK
CPI 7FH ;7FH AS DOT
JZ EDC7F
CPI ' ' ;OUTPUT CHAR OR DOT
JNC COUT
EDC7F:
MVI A,'.' ;DOT
JMP COUT
EDCCUR:
MVI C,' ' ;CLEAR CURSOR
EDSETCUR:
CALL EDROW ;COMPUTE ROW
ANI 0FH ;COMPUTE COL MOD 16
MOV B,A ;RESULT IN B
ADD A ;*2
ADD B ;*3
ADI ECOL+6 ;ADD IN COL
DCR A ;SUBTRACT 1
MOV L,A ;COL POSITION SET
CALL GOTOXY ;POSITION CURSOR
MOV A,C ;OUTPUT CHAR
JMP COUT
;
;Compute Row from EINDEX
;
EDROW:
LDA EINDEX ;GET INDEX
MOV B,A ;SAVE IN B
RRC ;DIVIDE BY 16
RRC
RRC
RRC
ANI 0FH ;MASK FOR LSB ONLY
ADI EROW ;COMPUTE ROW
MOV H,A ;ROW SET
MOV A,B ;GET INDEX
RET
;
;PRINT A SPACE
;
SPACE:
MVI A,' '
JMP COUT
;
;PRINT AN BARISK IN REV VIDEO
;
BAR:
CALL VPRINT
DB DIM,'|',BRIGHT,0
RET
;
;Get value from input buffer
;
GETAHV:
MOV A,M ;GET NEXT CHAR
CPI '<' ;HEX ESCAPE?
RNZ ;NO, RETURN
;"<<" means one "<"
INX H
MOV A,M
CPI '<'
RZ
;Got hex
PUSH D
CALL HEXIN ;GET VALUE
CPI '>' ;PROPER DELIM?
MOV A,E ;GET VALUE
POP D
RZ
;
;ERROR CONDITION IN SUBROUTINE - CLEAR STACK AND FLAG ERROR
;
SERR:
POP PSW ;CLEAR STACK
JMP WHAT ;ERROR
;
;Input Number from Command Line -- Assume it to be Hex
; Number returned in DE
;
HEXIN:
LXI D,0 ;INIT VALUE
MOV A,M
CPI '#' ;DECIMAL?
JZ HDIN ;MAKE DECIMAL
;
HINLP:
MOV A,M ;GET CHAR
CALL CAPS ;CAPITALIZE
CPI CR ;EOL?
RZ
CPI EOLCH ;EOL?
RZ
CPI SEPCH
RZ
CPI ' ' ;SPACE?
RZ
CPI '-' ;'THRU'?
RZ
CPI '>'
RZ
INX H ;PT TO NEXT CHAR
CPI '0' ;RANGE?
JC SERR
CPI '9'+1 ;RANGE?
JC HINNUM
CPI 'A' ;RANGE?
JC SERR
CPI 'F'+1 ;RANGE?
JNC SERR
SUI 7 ;ADJUST FROM A-F TO 10-15
;
HINNUM:
SUI '0' ;CONVERT FROM ASCII TO BINARY
XCHG
DAD H ;MULT PREVIOUS VALUE BY 16
DAD H
DAD H
DAD H
ADD L ;ADD IN NEW DIGIT
MOV L,A
XCHG
JMP HINLP
;
HDIN:
INX H ;SKIP '#'
;
;Input Number in Command Line as Decimal
; Number is returned in DE
;
DECIN:
LXI D,0
MOV A,M ; GET 1ST CHAR
CPI '#' ; HEX?
JNZ DINLP
INX H ; PT TO DIGIT
JMP HINLP ; DO HEX PROCESSING
;
DINLP:
MOV A,M ;GET DIGIT
CALL CAPS ;CAPITALIZE
CPI '0' ;RANGE?
RC
CPI '9'+1 ;RANGE?
RNC
SUI '0' ;CONVERT TO BINARY
INX H ;PT TO NEXT
PUSH H
MOV H,D
MOV L,E
DAD H ;X2
DAD H ;X4
DAD D ;X5
DAD H ;X10
ADD L ;ADD IN DIGIT
MOV L,A
MOV A,H
ACI 0
MOV H,A
XCHG ;RESULT IN DE
POP H
JMP DINLP
;
; READ LINE FROM USER INTO INPUT LINE BUFFER
;
RDBUF:
LHLD BUFFER ;PT TO BUFFER
XCHG ;SET DE AS PTR TO BUFFER
MVI C,10 ;BDOS READLN
PUSH D ;SAVE PTR
CALL BDOS
POP H ;PT TO CHAR COUNT
INX H
MOV E,M ;GET CHAR COUNT
MVI D,0
INX H ;PT TO FIRST CHAR
PUSH H ;SAVE PTR
DAD D ;PT TO AFTER LAST CHAR
MVI M,0 ;STORE ENDING 0
POP H ;PT TO FIRST CHAR
RET
;
; Capitalize char in A
;
caps:
ani 7fh
cpi 'a' ;range?
rc
cpi 'z'+1
rnc
ani 5fh ;mask to caps
ret
;
; CLEAR SCREEN ON TERMINAL
;
cls:
push h ;save regs
push d
lxi h,z3env+80H ;pt to environment
mov a,m ;no terminal?
cpi ' '+1
jc clserr
lxi d,14h ;pt to cls delay
dad d
mov d,m ;get it
inx h ;pt to cls string
inx h
inx h
mov a,m ;get first char of string
ora a ;if no string, error
jz clserr
call vidout ;output string with delay
pop d ;done
pop h
xra a ;return NZ
dcr a
ret
clserr:
pop d ;done
pop h
xra a ;return Z
ret
;
; Erase to End of Line
; Return with A=0 and Zero Flag Set if not done
;
ereol:
push b ;save regs
push d
push h
lxi h,z3env+80h ;pt to environment
mov a,m ;no terminal?
cpi ' '+1
jc err
lxi d,16h ;pt to ereol delay
dad d
mov d,m ;get it
inx h ;pt to cls string
call vidskp ;skip over it
call vidskp ;skip over CM string
mov a,m ;get first char of ereol string
ora a ;if no string, error
jz err
call vidout ;output string with delay
jmp noerr
;
; GOTO XY
; HL = Row/Col, with Home=1/1
; Return with A=0 and Zero Flag Set if not done
;
gotoxy:
push b ;save regs
push d
push h
lxi h,z3env+80h ;pt to environment
mov a,m ;no terminal?
cpi ' '+1
jc err
lxi d,15h ;pt to CM delay
dad d
mov a,m ;get it
sta cmdelay ;save it
inx h ;pt to CL string
inx h
call vidskp ;skip CL string
mov a,m ;get first char of CM string
ora a ;if no string, error
jz err
xchg ;DE=address of CM string
pop h ;get coordinates in HL
push h
call gxy ;output xy string with delay
lda cmdelay ;pause
call videlay
noerr:
pop h ;done
pop d
pop b
xra a ;return NZ
dcr a
ret
err:
pop h ;done
pop d
pop b
xra a ;return Z
ret
;
; Position Cursor at Location Specified by Return Address
; Usage:
; call at
; db row,col ;location
;
at:
xthl ;pt to address
push d ;save DE
mov d,m ;get row
inx h
mov e,m
inx h ;HL pts to return byte
xchg ;DE pts to return byte, HL contains screen loc
call gotoxy ;position cursor
xchg ;HL pts to return byte
pop d ;restore registers
xthl ;restore stack ptr
ret
;
; GOTOXY
; On input, H=Row and L=Column to Position To (1,1 is Home)
; On input, DE=address of CM string
;
gxy:
dcr h ;adjust to 0,0 for home
dcr l
xra a ;set row/column
sta rcorder ;row before column
sta rcbase ;add 0 to base
;
; Cycle thru string
;
gxyloop:
ldax d ;get next char
inx d ;pt to next
ora a ;done?
rz
cpi '%' ;command?
jz gxycmd
cpi '\' ;escape?
jz gxyesc
call cout ;send char
jmp gxyloop
;
; Escape - output following byte literally
;
gxyesc:
ldax d ;get next char
call cout ;output literally
inx d ;pt to next
jmp gxyloop
;
; Interpret next character as a command character
;
gxycmd:
ldax d ;get command char
inx d ;pt to next
cpi 'd' ;%d
jz gxyout1
cpi '2' ;%2
jz gxyout2
cpi '3' ;%3
jz gxyout3
cpi '.' ;%.
jz gxyout4
cpi '+' ;%+v
jz gxyout5
cpi '>' ;%>xy
jz gxygt
cpi 'r' ;%r
jz gxyrev
cpi 'i' ;%i
jz gxyinc
call cout ;output char if nothing else
jmp gxyloop
;
; Set row/col home to 1,1 rather than 0,0
;
gxyinc:
mvi a,1 ;set rcbase to 1
sta rcbase
jmp gxyloop
;
; Reverse order of output to column then row (default is row then column)
;
gxyrev:
mvi a,1 ;set column and row order
sta rcorder
jmp gxyloop
;
; Command: >xy
; If value of row/col is greater than x, add y to it
;
gxygt:
call getval ;get value
mov c,a ;save value
ldax d ;get value to test
inx d ;pt to next
cmp c ;if carry, value>x
jnc gxygt1
ldax d ;get value to add
add c
call putval ;put value back
gxygt1:
inx d ;pt to next
jmp gxyloop ;resume
;
; Command: +n
; Add n to next value and output
;
gxyout5:
ldax d ;get value to add
inx d ;pt to next
mov b,a ;save in B
call getval ;get value
add b ;add in B
call cout ;output value
rcmark:
lda rcorder ;mark output
ori 80h
sta rcorder
jmp gxyloop
;
; Command: .
; Output next value
;
gxyout4:
call getval ;get value
call cout ;output value
jmp rcmark
;
; Command: 3
; Output next value as 3 decimal digits
;
gxyout3:
call getval ;get value
mvi b,100 ;output 100's
mvi c,1 ;leading zeroes
call digout
gxyot3:
mvi b,10 ;output 10's
mvi c,1 ;leading zeroes
gxyot2:
call digout
adi '0' ;output 1's
call cout
jmp rcmark
;
; Command: 2
; Output next value as 2 decimal digits
;
gxyout2:
call getval ;get value
jmp gxyot3
;
; Command: d
; Output next value as n decimal digits with no leading zeroes
;
gxyout1:
call getval ;get value
mvi b,100 ;output 100's
mvi c,0 ;no leading zeroes
call digout
mvi b,10 ;output 10's
mvi c,0 ;no leading zeroes
jmp gxyot2
;
; Return next value in A
;
getval:
lda rcorder ;get order flag
ora a ;already output the first value?
jm getval2
ani 1 ;look at lsb
jz getvalr ;if 0, row first
getvalc:
lda rcbase ;get base offset
add l ;get column
ret
getvalr:
lda rcbase ;get base offset
add h ;get row
ret
getval2:
ani 1 ;look at lsb
jz getvalc
jmp getvalr
;
; Store A as next value
;
putval:
mov c,a ;save value
lda rcorder ;get order flag
ora a ;already output the first value?
jm putval2
ani 1 ;look at lsb
jz putvalr ;if 0, row first
putvalc:
mov l,c ;set column
ret
putvalr:
mov h,c ;set row
ret
putval2:
ani 1 ;look at lsb
jz putvalc
jmp putvalr
;
; Output A as decimal digit char
; B=Quantity to Subtract from A, C=0 if no leading zero
;
digout:
push d ;save DE
mvi d,'0' ;char
decot1:
sub b ;subtract
jc decot2
inr d ;increment char
jmp decot1
decot2:
add b ;add back in
push psw ;save result
mov a,d ;get digit
cpi '0' ;zero?
jnz decot3
mov a,c ;get zero flag
ora a ;0=no zero
jz decot4
decot3:
mov a,d ;get digit
call cout ;print it
decot4:
pop psw ;get A
pop d ;restore DE
ret
;
; GXY Buffers
;
rcorder:
ds 1 ;0=row/col, else col/row
rcbase:
ds 1 ;0=org is 0,0, else org is 1,1
cmdelay:
ds 1 ;number of milliseconds to delay for CM
;
; Begin Standout Mode
; Return with A=0 and Zero Flag Set if not done
;
stndout:
push b
push d
push h ;save regs
lxi h,z3env+80h ;pt to environment
mov a,m ;no terminal?
cpi ' '+1
jc err
lxi d,17h ;pt to cls string
dad d
mvi d,0 ;no delay
call vidskp ;skip over CL string
call vidskp ;skip over CM string
call vidskp ;skip over CE string
mov a,m ;get first char of SO string
ora a ;if no string, error
jz err
call vidout ;output string with delay
jmp noerr
;
; Terminate Standout Mode
; Return with A=0 and Zero Flag Set if not done
;
stndend:
push b
push d
push h ;save regs
lxi h,z3env+80h ;pt to environment
mov a,m ;no terminal?
cpi ' '+1
jc err
lxi d,17h ;pt to cls string
dad d
mvi d,0 ;no delay
call vidskp ;skip over CL string
call vidskp ;skip over CM string
call vidskp ;skip over CE string
call vidskp ;skip over SO string
mov a,m ;get first char of SE string
ora a ;if no string, error
jz err
call vidout ;output string with delay
jmp noerr
;
; Initialize Terminal
; Affect No Registers
;
tinit:
push h ;save regs
push d
push psw
lxi h,z3env+80h ;pt to environment
mov a,m ;no terminal?
cpi ' '+1
jc tid
lxi d,17h ;pt to cls string
dad d
mvi d,0 ;no delay
call vidskp ;skip over CL string
call vidskp ;skip over CM string
call vidskp ;skip over CE string
call vidskp ;skip over SO string
call vidskp ;skip over SE string
mov a,m ;get first char of TI string
ora a ;if no string, error
jz tid
call vidout ;output string with delay
tid:
pop psw ;done
pop d
pop h
ret
;
; De-Initialize Terminal
; Affect No Registers
;
dinit:
push h ;save regs
push d
push psw
lxi h,z3env+80h ;pt to environment
mov a,m ;no terminal?
cpi ' '+1
jc tid
lxi d,17h ;pt to cls string
dad d
mvi d,0 ;no delay
call vidskp ;skip over CL string
call vidskp ;skip over CM string
call vidskp ;skip over CE string
call vidskp ;skip over SO string
call vidskp ;skip over SE string
call vidskp ;skip over TI string
mov a,m ;get first char of TE string
ora a ;if no string, error
jz tid
call vidout ;output string with delay
jmp tid
;
; VIDOUT - Output video string pted to by HL
; Output also a delay contained in the D register
;
vidout:
mov a,m ;get next char
ora a ;done if zero
jz vid2
inx h ;pt to next
cpi '\' ;literal value?
jnz vid1
mov a,m ;get literal char
inx h ;pt to after it
vid1:
call cout ;output char
jmp vidout
vid2:
mov a,d ;output delay and fall thru to VIDELAY
;
; VIDELAY pauses for the number of milliseconds indicated by the A
; register. VIDELAY assumes a ZCPR3 environment and uses it to determine
; processor speed.
;
videlay:
push psw ;save regs
push b
push d
push h
mov c,a ;save count in C
ora a ;no delay?
jz done
lxi h,z3env ;pt to environment
lxi d,2Bh ;offset to processor speed
dad d
mov a,m ;get processor speed
ora a ;zero?
jnz vidl1
mvi a,4 ;assume 4 MHz
vidl1:
mov b,a ;processor speed in B
vidl2:
push b ;delay 1 ms
call delay
pop b
dcr c ;count down
jnz vidl2
done:
pop h ;restore regs
pop d
pop b
pop psw
ret
;
; Delay 1 ms at Clock speed
;
delay:
call del1 ;delay 1 ms at 1MHz
dcr b ;count down clock speed
jnz delay
ret
;
; Delay 1 ms at 1MHz
;
del1:
mvi c,20 ;20 loops of 51 cycles each ~ 1000 cycles
del1a:
xthl ;18 cycles
xthl ;+18 = 36 cycles
dcr c ;+ 5 = 41 cycles
jnz del1a ;+10 = 51 cycles
ret
;
; VIDSKP - Skip over video string pted to by HL; pt to byte after string
;
vidskp:
mov a,m ;get next char
inx h ;pt to next
ora a ;done if zero
rz
cpi '\' ;literal value?
jnz vidskp ;continue if not
inx h ;pt to after literal value
jmp vidskp
;
; Print A as 2 Hex Chars
;
pa2hc:
push psw
push b
mov b,a ;value in B
rlc
rlc
rlc
rlc
call pa2hc1
mov a,b ;get value
call pa2hc1
pop b
pop psw
ret
pa2hc1:
ani 0fh
adi '0' ;to ASCII
cpi '9'+1
jc pa2hc2
adi 7 ;to letter
pa2hc2:
jmp cout
;
; Skip Spaces
;
sksp:
mov a,m ;skip to non-space
cpi ' '
rnz
inx h
jmp sksp
;
;EDITOR BUFFERS
;
BLOCK:
DS 2 ;ADDRESS OF CURRENT BLOCK
BUFFER:
DS 2 ;PTR TO FREE SPACE
EINDEX:
DS 1 ;INDEX ENTRY
EDRUN:
DS 1 ;FLAG SAYING THAT EDITOR IS RUNNING
end