├── .github └── workflows │ ├── build-check.yml │ └── release.yml ├── .gitignore ├── .version ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── apps ├── 3rd-party │ ├── kermit │ │ ├── MLOAD25.COM │ │ ├── bin │ │ │ └── kermit.com │ │ ├── build.sh │ │ ├── cpscmd.asm │ │ ├── cpscom.asm │ │ ├── cpscpm.asm │ │ ├── cpsdat.asm │ │ ├── cpsdef.asm │ │ ├── cpsker.asm │ │ ├── cpsmit.asm │ │ ├── cpspk1.asm │ │ ├── cpspk2.asm │ │ ├── cpsrem.asm │ │ ├── cpsser.asm │ │ ├── cpstt.asm │ │ ├── cpsutl.asm │ │ ├── cpswld.asm │ │ ├── cpxapp.asm │ │ ├── cpxbbi.asm │ │ ├── cpxbee.asm │ │ ├── cpxcif.asm │ │ ├── cpxcom.asm │ │ ├── cpxgni.asm │ │ ├── cpxhea.asm │ │ ├── cpxlnk.asm │ │ ├── cpxmrl.asm │ │ ├── cpxnor.asm │ │ ├── cpxpcw.asm │ │ ├── cpxpro.asm │ │ ├── cpxsb.asm │ │ ├── cpxswt.asm │ │ ├── cpxsy2.asm │ │ ├── cpxsyo.asm │ │ ├── cpxsys.asm │ │ ├── cpxtm4.asm │ │ ├── cpxtor.asm │ │ ├── cpxtyp.asm │ │ ├── cpxvdu.asm │ │ ├── cpxz80.asm │ │ ├── lasm.com │ │ └── readme.txt │ └── z80asm │ │ └── z80asm.com └── esp8266 │ ├── README.md │ ├── bin │ ├── dial.com │ └── esprst.com │ └── src │ ├── dial.z80 │ └── esprst.z80 ├── ci-build ├── Dockerfile └── build-macos.sh └── src ├── mos.asm ├── zinc-setup ├── uart-setup.asm └── zinc-setup.asm └── zinc ├── config.asm ├── cpm-data.asm ├── edos ├── buffers.asm ├── console.asm ├── core.asm ├── disk.asm ├── ebios │ ├── console.asm │ ├── disk.asm │ ├── index.asm │ └── macro.asm ├── edos.asm └── fcb.asm ├── options.asm ├── terminal.asm ├── uart.asm └── zinc.asm /.github/workflows/build-check.yml: -------------------------------------------------------------------------------- 1 | name: build-check 2 | run-name: Dry run of building ZINC 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | - '!main' 8 | jobs: 9 | ci-build-check: 10 | runs-on: [ubuntu-latest] 11 | container: nihirash/ez80asm:x64 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Fix ownership 16 | run: chown -R $(id -u):$(id -g) $PWD 17 | 18 | - name: Build OS from sources using dockerized ez80asm 19 | run: make -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: build-system 2 | run-name: Build and release ZINC with ez80asm 3 | on: 4 | push: 5 | branches: [ main ] 6 | jobs: 7 | create-release: 8 | runs-on: [ubuntu-latest] 9 | container: nihirash/ez80asm:x64 10 | steps: 11 | - uses: actions/checkout@v4 12 | 13 | - name: Fix ownership 14 | run: chown -R $(id -u):$(id -g) $PWD 15 | 16 | - name: Build OS from sources using dockerized sjasmplus 17 | run: make 18 | 19 | - name: Read version 20 | id: version 21 | run: echo "version=$(cat .version)" >> $GITHUB_OUTPUT 22 | 23 | - name: Pack release 24 | run: zip -j zinc.zip zinc.bin zinc-setup.bin 25 | 26 | - name: Release 27 | id: create_release 28 | uses: actions/create-release@v1 29 | with: 30 | draft: false 31 | prerelease: false 32 | release_name: CI build ${{ steps.version.outputs.version }} 33 | tag_name: ${{ steps.version.outputs.version }} 34 | body_path: CHANGELOG.md 35 | env: 36 | GITHUB_TOKEN: ${{ github.token }} 37 | 38 | - name: Upload artifact 39 | uses: actions/upload-release-asset@v1 40 | env: 41 | GITHUB_TOKEN: ${{ github.token }} 42 | with: 43 | upload_url: ${{ steps.create_release.outputs.upload_url }} 44 | asset_path: "zinc.zip" 45 | asset_name: "zinc.zip" 46 | asset_content_type: "application/octet-stream" 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.lst 2 | *.bin 3 | *.hex 4 | *.prn 5 | emul/ 6 | tmp/ 7 | emul.sh 8 | src/zinc-shell/ -------------------------------------------------------------------------------- /.version: -------------------------------------------------------------------------------- 1 | 2024.07.06 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 2024.07.26 4 | 5 | * Preserving DE in BDOS calls - very small count of applications waits for this 6 | 7 | * UART can be configured for 300 Bauds 8 | 9 | ## 2024.07.03 10 | 11 | * ez80asm updated to 1.8 version 12 | 13 | * Buffered read input can be interrupted with ESC key(with application shutdown) 14 | 15 | * Applications directory added(added kermit sources and binary, z80asm and UART1 usage examples) 16 | 17 | * Set color control code 18 | 19 | * Terminal emulation minor fixes 20 | 21 | ## 2024.06.22 22 | 23 | * BBC Basic partly working with files but still have issues 24 | 25 | * Tracing of DOS calls removed 26 | 27 | * All API calls implemented 28 | 29 | * Fixed WordStar 3 file operations 30 | 31 | ## 2024.06.16 32 | 33 | * Uart parameters can be configured with "zinc-setup" configuration utility 34 | 35 | * EDOS now handles CTRL-C via console status call 36 | 37 | * LU310 was fixed 38 | 39 | * Disable VDP commands via keypresses for more correct terminal emulation 40 | 41 | * All terminal code moved out of BIOS 42 | 43 | * UART1 is accessible via IOByte 44 | 45 | ## 2024.06.09 46 | 47 | * Better ADM-3a terminal emulation 48 | 49 | * Possibility disable it and use VDP commands 50 | 51 | ## 2024.05.04 52 | 53 | * Very basic ADM-3 terminal emulation 54 | 55 | * "Update random access pointer" call implemented 56 | 57 | * "Printer" now outputs to VPD's printer 58 | 59 | * Console status and reading working fine now 60 | 61 | ## 2024.05.02 62 | 63 | * File leak fixed 64 | 65 | * Compute file size call implemented 66 | 67 | * More correct error handling(allows Turbo Pascal execution) 68 | 69 | ## 2024.04.27 70 | 71 | * First public build(system version call returns version 2.9) 72 | 73 | * Basic console and file operations implemented(Mike's Enhanced Small C Compiler works, Microsoft Basic, Tasty Basic, Zork and many other utils working) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | If you are using ZINC, I'd love to hear about it. 2 | Let me(Aleksandr Sharikhin) know by sending email to anihirash@gmail.com. 3 | 4 | I'm crazy about coffee. If you treat me to delicious coffee - it will be awesome. 5 | 6 | You may use all data from this project as you want. 7 | 8 | But if you will use parts of this project - please keep this info about my love to 9 | coffee(or buy me a cup of coffee at least). -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ASM=ez80asm 2 | ASM_FLAGS:=-i -l -v 3 | SOURCES:=$(shell find src/zinc -type f -iname "*.asm") 4 | BINARY=zinc.bin 5 | EDOS=src/zinc/edos/edos.bin 6 | 7 | SETUP_SOURCES:=$(shell find src/zinc-setup -type f -iname "*.asm") 8 | SETUP_BINARY:=zinc-setup.bin 9 | 10 | 11 | all: $(BINARY) $(SETUP_BINARY) 12 | 13 | $(BINARY): $(EDOS) $(SOURCES) 14 | (cd src/zinc && $(ASM) $(ASM_FLAGS) zinc.asm ../../$(BINARY)) 15 | 16 | $(EDOS): $(SOURCES) 17 | date '+%Y.%m.%d' >.version 18 | (cd src/zinc/edos && $(ASM) $(ASM_FLAGS) edos.asm) 19 | 20 | $(SETUP_BINARY): $(SETUP_SOURCES) 21 | (cd src/zinc-setup && $(ASM) $(ASM_FLAGS) zinc-setup.asm ../../$(SETUP_BINARY)) 22 | 23 | clean: 24 | rm -rf $(EDOS) $(BINARY) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ZINC - ZINC is Not CP/M 2 | ======================= 3 | 4 | CP/M compatibility layer for Agon's MOS. 5 | 6 | ## Usage 7 | 8 | Download from releases page `zinc.bin`(use only latest release) and copy it to `mos/` directory of your sd card. 9 | 10 | After this you'll have possibility run CP/M applications with `zinc` command like: 11 | 12 | ``` 13 | zinc mbasic test 14 | ``` 15 | 16 | You shouldn't specify file extension for executable file(`.com` will be added automatically) and directory should no contain files with long file names. 17 | 18 | **NB!** Please don't specify file names with path. It should be executed in directory where CP/M files are(current directory will be used as emulated disk drive). 19 | 20 | ### Using UART1 from CP/M Applications 21 | 22 | UART1 is accessible via IOBYTE(you can switch character input/output from terminal emulator to UART1 just changing one byte in RAM). 23 | 24 | Before using UART use `zinc-setup` utility - it's interactive tool for setting UART parameters. 25 | 26 | ## Terminal emulation layer 27 | 28 | Currently, it supports "ADM-3a"-like compatible terminal emulation routines(like KayPro or some other computers). 29 | 30 | It also allows disable(and re-enable terminal emulation routines) with `27, 255`(two bytes, 27 in decimal first, 255 in decimal secord) character sequence. If you disable terminal emulation routines you'll have possibility use all Agon's VDP commands, including graphics, sounds etc. Also you can get back to terminal emulation mode by same sequence. 31 | 32 | ### Control sequences and codes 33 | 34 | * `0x01` - Home cursor 35 | 36 | * `0x07` - Bell(makes single beep) 37 | 38 | * `0x08` - move cursor left on one character 39 | 40 | * `0x0C` - move cursor right on one character 41 | 42 | * `0x14` - move cursor up on one character 43 | 44 | * `0x16` - move cursor left on one character 45 | 46 | * `0x17` - move cursor right on one character 47 | 48 | * `0x18` - clean current line(after current cursor position) 49 | 50 | * `0x1A` - clean screen 51 | 52 | * `0x1B` - ESCAPE control sequences: 53 | 54 | - `ESC`+`=` - load cursor position(`ESC`+`=`+`y-coordinate`+`x-coordinate`) 55 | 56 | - `ESC` + `f` - load foreground color(`ESC` + `f` + `color number as byte`) 57 | 58 | - `ESC` + `b` - load background color(`ESC` + `b` + `color number as byte`) 59 | 60 | - `ESC`+`0xFF` - toggle terminal emulation(enable or disable it) 61 | 62 | ## Known incompatibilities 63 | 64 | * BBCBasic V - produces CP/M error on almost any non vanilla BDOS implementation(source code shows that it was developed mostly for runinng under RunCPM). 65 | 66 | Honestly, I think It will be easier port it to MOS than fix execution under ZINC. 67 | 68 | * Buffered input can be interrupted with ESC with application termination(instead CTRL+C in vanilla CP/M) 69 | 70 | ## Development 71 | 72 | You should use fresh version of [agon-ez80asm](https://github.com/envenomator/agon-ez80asm) for building system. 73 | 74 | Sources splitted by two parts: loader(also replaces CCP) and EDOS(BDOS+BIOS replacement). 75 | 76 | ## Support me 77 | 78 | You can support me via my [Ko-Fi page](https://ko-fi.com/nihirash). 79 | 80 | ## License 81 | 82 | This project licensed with [Nihirash's Coffeeware License](LICENSE). 83 | 84 | It isn't hard to respect it. 85 | 86 | All third-party projects covered with their own licenses. -------------------------------------------------------------------------------- /apps/3rd-party/kermit/MLOAD25.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/ZINC/9df58126ae1ba1c47122792b479ef43ad7c550bd/apps/3rd-party/kermit/MLOAD25.COM -------------------------------------------------------------------------------- /apps/3rd-party/kermit/bin/kermit.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/ZINC/9df58126ae1ba1c47122792b479ef43ad7c550bd/apps/3rd-party/kermit/bin/kermit.com -------------------------------------------------------------------------------- /apps/3rd-party/kermit/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | zxcc lasm cpsker 3 | zxcc lasm cpxtyp 4 | zxcc mload25 kermit=CPSKER,CPXTYP 5 | mv kermit.com bin/ -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpsdef.asm: -------------------------------------------------------------------------------- 1 | ; KERMIT - (Celtic for "FREE") 2 | ; 3 | ; This is the CP/M-80 implementation of the Columbia University 4 | ; KERMIT file transfer protocol. 5 | ; 6 | ; Version 4.0 7 | ; 8 | ; Copyright June 1981,1982,1983,1984,1985 9 | ; Columbia University 10 | ; 11 | ; Originally written by Bill Catchings of the Columbia University Center for 12 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 13 | ; 14 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 15 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 16 | ; others. 17 | ; 18 | ; This file contains definitions used by both modules of Kermit. 19 | ; 20 | ; revision history: 21 | ; 22 | ;edit 9, 30-Nov-1990 by MF. Make "fairness" count "prfair" be 50 so 23 | ; console gets checked a bit more often. 24 | ; edit 8, 11-Sep-1990 by MF. Make default RECEIVE and SEND packet-size 25 | ; 80 (per Kermit standard) as packet size is adjustable in Version 26 | ; 4.10. 27 | ; edit 7 16-Jun-86 OBSchou. Added cmnum in the command opcodes. This gets a 28 | ; number from the user inot variable number. No checking on overflow. 29 | ; 30 | ; edit 6 13-May-86 OBSchou. BDOS calls trapped to check for console use 31 | ; as we want to substitute in commands from a TAKE file. Trapping 32 | ; means I dont have to go through an check ever BDOS call... 33 | ; 34 | ; edit 5: 22-Apr-86 by Bertil Schou, Loughborough University, UK 35 | ; moved some definitions from the CP4SYS.ASM file to here for 36 | ; Kermit version 4.06 37 | ; 38 | ; edit 4: 6-Feb-85 by Charles Carvalho 39 | ; modify pcc007: replace ffussy assembly switch with runtime test. 40 | ; add "getvnm" - get CP/M version number. 41 | ; 42 | ; edit 3: 13-Jan-85 by Vanya J.Cooper Pima Commun. College Tel: 602-884-6809 43 | ; 44 | ;pcc007 2-Jan-85 vjc modules:cp4def,cp4cmd 45 | ; Cmifil is too fussy about what characters to accept in a 46 | ; filespec. My CP/M manual says any printable character is ok 47 | ; except <>.,;:?*[], and lower case. In practice, even those work 48 | ; sometimes. Kermit itself uses '&' if file warning is on, 49 | ; and then won't let you reference the file. Allow all 50 | ; printable characters except those above. Add conditional 51 | ; ffussy, so that if not ffussy, all special characters will be 52 | ; allowed, just convert lower to upper-case. 53 | ; 54 | ;pcc008 2-Jan-85 vjc modules:cp4def,cp4tt,cp4utl 55 | ; Keyboard input during CONNECT mode can get locked out if 56 | ; there is enough input from the modem port to keep prtchr 57 | ; busy. This can happen for example, if the printer is running 58 | ; at the same speed as the modem line, leaving you helpless to 59 | ; turn it off or abort the host. Add a fairness count, so that 60 | ; at least every prfair characters we look at console input. 61 | ; 62 | ; edit 2: July 10, 1984 (CJC) 63 | ; Remove defines for TRUE and FALSE, during reorganization for LASM 64 | ; compatibility. If we're using LASM, this file is linked by CP4KER 65 | ; or CP4TYP, and links to CP4MIT or CP4LNK. Also, push comments around 66 | ; a little. 67 | ; 68 | ; edit 1: May, 1984 (CJC) 69 | ; extracted from CPMBASE.M80 version 3.9; modifications are described 70 | ; in the accompanying .UPD file. 71 | ; 72 | 73 | ;Symbolic Definitions for some ASCII characters 74 | ; 75 | soh EQU 01O ;ASCII SOH (Control-A) 76 | cntlc EQU 03O ;ASCII ETX (Control-C) 77 | ctrlc EQU 03O ;ASCII ETX (Control-C) 78 | bell EQU 07O ;ASCII BEL (Control-G) 79 | bs EQU 10O ;ASCII backspace (Control-H) 80 | tab EQU 11O ;ASCII Tab (Control-I) 81 | lf EQU 12O ;ASCII Line Feed (CTRL-J) 82 | ff EQU 14O ;ASCII Form Feed (CTRL-L) 83 | cr EQU 15O ;ASCII Carriage Return (CTRL-M) 84 | space EQU 20h ;ASCII Space 85 | xon EQU 21O ;ASCII XON (Control-Q) 86 | xoff EQU 23O ;ASCII XOFF (Control-S) 87 | esc EQU 33O ;ASCII ESCape 88 | semico EQU 3bh ;ASCII Semicolon 89 | subt EQU 32O ;ASCII SUB (CTRL-Z) 90 | cntlz EQU subt ;ASCII SUB (Control-z) [6] 91 | ctrlz EQU subt ;ASCII SUB (Control-z) 92 | del EQU 177O ;ASCII DELete (rubout) 93 | ; 94 | ;BDOS calls 95 | IF NOT cpsker ;[6] If CPSKER is truem then system indep. stuff. We want 96 | ;to trap BDOS calls and test for console activity 97 | bdos EQU 0005H ;BDOS entry point, for the following functions: 98 | ENDIF ;NOT cpsker [6] 99 | ; 100 | ;Function Name Function Input Parameters Output Parameter 101 | ;============= ======== ================ ================ 102 | ; (ALL Function Numbers are passed in Register C) 103 | conin EQU 01H ;Read Console NONE ASCII Char in A 104 | conout EQU 02H ;Write Console ASCII Char in E NONE 105 | auxin EQU 03H ;Auxiliary input 106 | rdrin EQU 03H ;Read Reader NONE ASCII Char in A 107 | lstout EQU 05H ;Write List ASCII Char in E NONE 108 | dconio EQU 06H ;Direct Con I/O ASCII Char in E I/O Status in A 109 | ; if E=0FEH, 110 | ; Input if E=0FFH 111 | prstr EQU 09H ;Print String String-Address NONE 112 | ; in DE (term=$) 113 | rdstr EQU 0AH ;Read Buffer Buffer-Address Read Buffer filled 114 | ; in DE 115 | ; Read Buffer Byte Function 116 | ; 1 Maximum Buffer Length 117 | ; 2 Current Buffer Length (returned value) 118 | ; 3-n Data (returned values) 119 | ; 120 | consta EQU 0BH ;Console Stat NONE LSB(A)=1 if char ready 121 | getvnm EQU 0CH ;Version Number NONE H=0 (CP/M), L=BDOS ver 122 | inbdos EQU 0DH ;Init BDOS NONE NONE 123 | logdsk EQU 0EH ;LOG-In disk Value in E NONE 124 | ; A=0,B=1,... 125 | openf EQU 0FH ;Open File FCB-Addr in DE Byte Addr.of FCB, 126 | ; or 0FFH if not 127 | closf EQU 10H ;Close File FCB-Addr in DE Byte Addr.of FCB, 128 | ; or 0FFH if not 129 | sfirst EQU 11H ;Search File FCB-Addr in DE Byte Addr.of FCB(0-3), 130 | ; or 0FFH if not 131 | snext EQU 12H ;Search next FCB-Addr in DE Byte Addr.of next FCB, 132 | ; or 0FFH if not 133 | delf EQU 13H ;Delete File FCB-Addr in DE Byte Addr.of FCB(0-3), 134 | ; or 0FFH if not 135 | readf EQU 14H ;Read Record FCB-Addr in DE 0=successful read 136 | ; 1=read past EOF 137 | ; 2=reading random data 138 | writef EQU 15H ;Write Record FCB-Addr in DE 0=successful write 139 | ; 1=ERROR extending 140 | ; 2=End of disk data 141 | ; 255=No more DIR space 142 | makef EQU 16H ;Make File FCB-Addr in DE 0-3= success, 143 | ; 255= no more dir space 144 | renam EQU 17H ;Rename File FCB-Addr in DE 0-3= success, 145 | ; 255= file not found 146 | rdlog EQU 18H ;Ret. Log Code NONE Login Vector in HL 147 | rddrv EQU 19H ;Read Drive # NONE # of logged in drive in 148 | ; (A=0,B=1,C=2....) 149 | setdma EQU 1AH ;Set DMA Addr. Addr. of 128 NONE 150 | ; byte buffer in DE 151 | wrtprt EQU 1CH ;Write prot dsk NONE NONE 152 | getrov EQU 1DH ;Get R/O Vect. NONE HL= R/O Vect. value 153 | setfat EQU 1EH ;Set File Attr. FCB-Addr.in DE Dir. code in A 154 | gtdpar EQU 1FH ;Get DSK par. NONE HL=DPB Address 155 | usrcod EQU 20H ;Get/Set Usr.Cd E=0FFH (get) A=current code (get) 156 | ; E-code (set) A=no value (set) 157 | rrand EQU 21H ;Read Random FCB-Addr in DE A=Return code 158 | wrand EQU 22H ;Write Random FCB-Addr in DE 1=read'g unwritten data 159 | ; 2=(not used) 160 | ; 3=can't close curr. ext 161 | ; 4=seek to unwr. ext. 162 | ; 5=dir overflow(write) 163 | ; 6=seek past End of DSK 164 | cflsz EQU 23H ;Comp File Sz. FCB Addr.in DE Rand.Rec.field set to 165 | ; File size 166 | setrar EQU 24H ;Set Rand. Rec. FCB-Addr.in DE Rand.Rec.field set 167 | 168 | ; CPM 2 only: 169 | punout EQU 04H ;Write Punch ASCII Char in E NONE 170 | gtiob EQU 07H ;Get I/O status NONE I/O Status in A 171 | ptiob EQU 08H ;Put I/O status I/O Status in E NONE 172 | getalv EQU 1BH ;Get All.Vect. NONE All.Vect in HL 173 | 174 | ; CPM 3 only: 175 | auxout EQU 04H ;Auxiliary output 176 | auxist EQU 07H ;Get AUXIN: status A=FF if character 177 | ; ready, A=0 if none 178 | auxost EQU 08H ;Get AUXOUT: status A=FF if ready, A=0 179 | ; if not ready 180 | getfs EQU 2EH ;Get free space E=drive # rec free in dma addr 181 | ; 182 | parevn EQU 00H ;Even parity. 183 | parmrk EQU 03H ;Mark parity. 184 | parnon EQU 06H ;No parity (eighth bit is data). 185 | parodd EQU 09H ;Odd parity. 186 | parspc EQU 0CH ;Space parity. 187 | 188 | defpar EQU parnon ;Default parity. 189 | ibmpar EQU parmrk ;IBM COMTEN's parity. 190 | 191 | fcb EQU 5CH ;Location of File Control Block. 192 | fcbext equ fcb+12 193 | fcbrno equ fcb+33 194 | buff EQU 80H ;Location of file output buffer (DMA). 195 | bufsiz EQU 80H ;Size of DMA. 196 | 197 | maxfcb equ 64 ; maximum of 64 fcbs to be stored in multiple fcb bock 198 | 199 | maxpkt EQU '~'-' '+2O;Maximum size of a packet. 200 | maxtry EQU 05O ; Number of retries on a packet. 201 | imxtry EQU 20O ; Number of retries send initiate. 202 | prfair EQU 50 ;[pcc008] Prtchr fairness count 203 | 204 | ; opcodes for command parser 205 | cmkey EQU 01H ;Parse a keyword. 206 | cmifi EQU 02H ;Parse an input file spec (can be wild). 207 | cmofi EQU 03H ;Parse an output file spec. 208 | cmcfm EQU 04H ;Parse a confirm. 209 | cmtxt EQU 05H ;Parse text. 210 | cmnum EQU 06h ;Parse a number 211 | cmifin EQU 10H ;Parse an input file spec (but no 212 | ;Error output 213 | 214 | ;[4] from CP4SYS.ASM 215 | ; 216 | ;========================================================================= 217 | ; I/O Byte assignments (2-bit fields for 4 devices at loc 3) 218 | ; 219 | ;bits 6+7 LIST field 220 | ; 0 LIST is Teletype device (TTY:) 221 | ; 1 LIST is CRT device (CRT:) 222 | ; 2 LIST is Lineprinter (LPT:) 223 | ; 3 LIST is user defined (UL1:) 224 | ; 225 | ;bits 4+5 PUNCH field 226 | ; 0 PUNCH is Teletype device (TTY:) 227 | ; 1 PUNCH is high speed punch (PUN:) 228 | ; 2 PUNCH is user defined #1 (UP1:) 229 | ; 3 PUNCH is user defined #2 (UP2:) 230 | ; 231 | ;bits 2+3 READER field 232 | ; 0 READER is Teletype device (TTY:) 233 | ; 1 READER is high speed reader (RDR:) 234 | ; 2 READER is user defined #1 (UR1:) 235 | ; 3 READER is user defined #2 (UR2:) 236 | ; 237 | ;bits 0+1 CONSOLE field 238 | ; 0 CONSOLE is console printer (TTY:) 239 | ; 1 CONSOLE is CRT device (CRT:) 240 | ; 2 CONSOLE is in Batch-mode (BAT:);READER = Input, 241 | ; LIST = Output 242 | ; 3 CONSOLE is user defined (UC1:) 243 | ; 244 | ;========================================================================= 245 | 246 | iobyte EQU 03H ;Location of I/O byte 247 | 248 | ;[4] From CP4SYS.ASM 249 | ; 250 | ; 251 | ; 252 | ; Protocol parameters. Some of these can be changed with commands. 253 | ; 254 | 255 | drpsiz SET 50H ;Default receive packet size. (maximum is 5EH) 256 | dspsiz SET 50H ;Default send packet size. (maximum is 5EH) 257 | dstime SET 08H ;Default send time out interval. 258 | drtime SET 05 ;Default receive time out interval 259 | 260 | dspad EQU 00H ;Default send padding. 261 | drpad EQU 00H ;Default receive padding. 262 | dspadc EQU 00H ;Default send padding char. 263 | drpadc EQU 00H ;Default receive padding char. 264 | dseol EQU CR ;Default send EOL char. 265 | dreol EQU CR ;Default receive EOL char. 266 | dsquot EQU '#' ;Default send quote char. 267 | drquot EQU '#' ;Default receive quote char. 268 | dschkt EQU '1' ;Default checksum type 269 | ; 270 | 271 | ; Define VT or Terminal type values 272 | vtdefo EQU 0 ;VT52 emulation by terminal itself. 273 | vtdefv EQU 1 ;VT52 emulation by ttab tables in CPXVDU.ASM etc 274 | vtdefd EQU 2 ;Dumb Terminal (Just prints) 275 | vtdefe EQU 3 ;Termianl emulation done outside (in overlay) 276 | 277 | 278 | ; If this is being assembled by LASM, we need to LINK to one of two modules; 279 | ; if we're not using LASM, no problem. 280 | ; CPSKER.ASM defines "cpsker" TRUE, and CPXTYP.ASM defines it FALSE, so we can 281 | ; determine what's going on. 282 | IF lasm AND cpsker ; building CP4KER with LASM? 283 | LINK CPSMIT ; yes, chain to next piece. 284 | ENDIF;lasm AND cpsker 285 | IF lasm AND NOT cpsker ; LASM, but not building CP4KER? 286 | LINK CPXLNK ; yes, chain to different piece. 287 | ENDIF;lasm AND NOT cpsker 288 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpsker.asm: -------------------------------------------------------------------------------- 1 | ; CPSKER.ASM 2 | ; KERMIT - (Celtic for "FREE") 3 | ; 4 | ; This is the CP/M-80 implementation of the Columbia University 5 | ; KERMIT file transfer protocol. 6 | ; 7 | ; Version 4.0 8 | ; 9 | ; Copyright June 1981,1982,1983,1984 10 | ; Columbia University 11 | ; 12 | ; Originally written by Bill Catchings of the Columbia University Center for 13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 14 | ; 15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 17 | ; others. 18 | ; 19 | ; 20 | ; This is the header for the system-independent portion of KERMIT, which 21 | ; consists of the following files (in this order): 22 | ; 23 | ; CPSKER.ASM - this file 24 | ; CPSDEF.ASM - definitions for both KERMIT and KERSYS 25 | ; CPSMIT.ASM - \initialization, main loop, miscellaneous commands 26 | ; CPSCOM.ASM - /(BYE, EXIT, LOG, SET, SHOW, and STATUS) (Part1 of 2) 27 | ; CPSPK1.ASM - \the KERMIT protocol handler (SEND, RECEIVE, LOGOUT, 28 | ; CPSPK2.ASM - / and FINISH commands) (In two parts) 29 | ; CPSREM.ASM - REMOTE commands etc 30 | ; CPSSER.ASM - SERVER commands etc (Empty as yet) 31 | ; CPSTT.ASM - the transparent commands (TRANSMIT, CONNECT) 32 | ; CPSCPM.ASM - CP/M commands (DIR, ERA) 33 | ; CPSWLD.ASM - the wildcard handler 34 | ; CPSCMD.ASM - the command parser 35 | ; CPSUTL.ASM - utility routines 36 | ; CPSDAT.ASM - Data space and the overlay link space 37 | ; 38 | ; When building the system-independent part with M80 or MAC80, CPSKER 39 | ; INCLUDEs the other files; when building with LASM, each file LINKs to 40 | ; the next file. 41 | ; 42 | ; For now, the system-dependent routines are all in CPSSYS.ASM, with 43 | ; the actual configuration defined in CPSTYP.ASM. 44 | ; 45 | ; revision history (latest first): 46 | ; 47 | ; Begin CP/M Kermit-80 version 4.11. 48 | ;edit 32, 1-Apr-1991 by MF. Official release of work to date as CP/M Kermit 49 | ; (Kermit-80) Version 4.11. 50 | ; Modified edit level of cpscpm.asm to reflect a bug fix for the TYPE 51 | ; command introduced with edit 13. 52 | ;edit 31, 29-Mar-1991 by MF. Modified edit levels of cpsker.asm, 53 | ; cpscom.asm and cpsdat.asm to reflect rename of parameter vermin to 54 | ; revno (revision level) and change of SET COLLISION REPLACE to 55 | ; SET COLLISION OVERWRITE to conform with C-Kermit. Modified 56 | ; edit level of cpsrem.asm to reflect change from REMOTE SET FILE 57 | ; COLLISION REPLACE to REMOTE SET FILE COLLISION OVERWRITE. 58 | ; Modified edit level of cpsutl.asm to reflect code tightening and 59 | ; edit levels of cpsmit.asm and cpspk2.asm to close any open TAKE-file 60 | ; and abort take-file processing if ^C is typed from the console 61 | ; Also corrected ^Z test in cpsmit.asm in INPUT command ("inp2b") 62 | ; Implement "file not found" complaint if a TAKE command can't find 63 | ; the TAKE-file and it's not the initial TAKE (KERMIT.INI) 64 | ; Modified edit level of cpscpm.asm to reflect modification of the 65 | ; TYPE and PRINT commands to cancel file typeout/printout completely 66 | ; if ^C is entered on the console (either immediately or after a key 67 | ; has been pressed to induce a pause) and to immediately begin 68 | ; typeout/printout of the next file (if the filespec was wild-carded) 69 | ; if ^X is entered (either immediately or after a key has been pressed 70 | ; to induce a pause). 71 | ; Modified edit levels of cpsmit.asm and cpscom.asm to reflect addition 72 | ; of the STAY command as a synonym for SET NO-EXIT. 73 | ;edit 30, 27-Feb-1991 by MF. Modified edit levels of cpscom.asm, 74 | ; cpsmit.asm, cpsutl.asm and cpsdat.asm to reflect provision for 75 | ; a "revision level" field (1-26=A-Z), addition of QUIT as a synonym 76 | ; for the EXIT command, recognition of C, R and S as abbreviations 77 | ; for the CONNECT, RECEIVE and SEND commands, respectively, display 78 | ; of Kermit version in the VERSION command and a fix to the TAKE-file 79 | ; input routine "r1tchr" to prevent semicolons from being interpreted 80 | ; as command separators during TAKE-file execution. This last fix 81 | ; allows such commands as REMOTE DELETE *.*;* to Kermit-32 to 82 | ; operate as expected. 83 | ;edit 29, 14-Feb-1991 by MF. Updated edit levels of cpscom.asm, 84 | ; cpscpm.asm, cpsdat.asm and cpsrem.asm to reflect bug fixes, 85 | ; code tightening and simplified routine "remcli" (in cpsrem.asm) 86 | ; which gets text to be passed on to a remote Kermit in REMOTE 87 | ; Kermit commands. 88 | ;edit 28, 8-Feb-1991 by MF. Changed edit level of cpscpm.asm to reflect 89 | ; a bug fix to make TAKE-files work properly with commands such as 90 | ; INPUT which check the keyboard for input. 91 | ;edit 27, 30-Jan-1991 by MF. Changed edit levels of cpscpm.asm, cpsrem.asm, 92 | ; cpstt.asm and cpsutl.asm to reflect bug fixes and enhancements 93 | ;edit 26, 17-Jan-1991 by MF. Changed edit level of cpscmd.asm to 94 | ; reflect fixes to allow leading spaces/tabs to be ignored when 95 | ; parsing keywords (this was the intent but the code never worked 96 | ; correctly) and to blank the entire fcb in "cmifil" to allow successive 97 | ; COPY commands to function properly. Also changed edit level of 98 | ; cpspk1.asm to reflect further work on "disk full" error reporting. 99 | ;edit 25, 14-Jan-1991 by MF. Incremented edit level of cpspk1.asm to 100 | ; reflect bug fix to "disk full" error reporting code so 101 | ; is not sent directly to the Remote Kermit. This per a report from 102 | ; Russell Lang of Australia's Monash University. 103 | ;edit 24, 10-Jan-1991 by MF. Modified edit level of cpxtyp.asm to 104 | ; reflect addition of "terminal required" message for some. 105 | ; machines. 106 | ;edit 23, 7-Jan-1991 by MF. Modified edit levels of cpxtyp.asm, cpxswt.asm, 107 | ; cpxbbi.asm to reflect addition of Ampro Little Board support. 108 | ;edit 22, 3-Jan-1991 by MF. Incremented edit levels of cpspk1.asm/cpspk2.asm 109 | ; to reflect further mods to "sdata" and "inchr" routines. 110 | ;edit 21, 2-Jan-1991 by MF. Incremented edit level of cpspk1.asm to reflect 111 | ; code cleanup in "sdata" routine. 112 | ;edit 20, 26-Dec-1990 by MF. Modified edit level of CPSCMD.ASM to reflect 113 | ; fix to allow leading white space to be skipped in lines from 114 | ; TAKE-files as well as from the CP/M command-line tail; this per a 115 | ; phoned-in bug-report to Dr. Martin J. Carter of Nottingham 116 | ; University in the U.K. (PPZMAJOC@vax.ccc.nottingham.ac.uk) 117 | ;edit 19, 14-Dec-1990 by MF. Modified edit level of cpspk2.asm to reflect 118 | ; modification to "gofil" to allow drive specifications in 2nd 119 | ; filename of GET and RECEIVE commands; also modified edit levels of 120 | ; cpspk1.asm and cpsrem.asm to reflect addition of "<<>>" around 121 | ; "X" or "F" packets coming as a reply to a REMOTE command and 122 | ; deletion of an unnecessary instruction before label remc2d 123 | ; in cpsrem.asm. 124 | ;edit 18, 9-Dec-1990 by MF. Modified edit levels for Version 4.10 125 | ; yet another time to reflect changes in CPSDAT.ASM to clarify 126 | ; "File size on DIR" status message. 127 | ;edit 17, 4-Dec-1990 by MF. Adjusted edit levels of cpscom.asm/cpsdat.asm 128 | ; to reflect addition of Autoreceive status to SHOW/STATUS display. 129 | ;edit 16, 30-Nov-1990 by MF. Adjusted edit levels of cpscom.asm/cpsdat.asm 130 | ; to reflect fix to SHOW/STATUS routines to show terminal display 131 | ; mode (quiet/regular). Also adjusted edit level of cpsutl.asm to reflect 132 | ; change to routine "p20ln" to use "pausit" to save code space. 133 | ; Adjusted edit level of cpsdef.asm to reflect change in "fairness" 134 | ; counter prfair from 100 to 50 to make terminal a bit more responsive 135 | ; during CONNECTs. 136 | ;edit 15, 27-Nov-1990 by MF. Adjusted edit level of cpspk1.asm to reflect 137 | ; a bug fix. 138 | ;edit 14, 27-Nov-1990 by MF. Again adjusted edit level of cpspk1.asm to 139 | ; reflect modifications of "disk-full"and SET INCOMPLETE-FILES behavior. 140 | ;edit 13, 23 Nov-1990 by MF. Adjusted edit level of cpspk1.asm to reflect 141 | ; code changes for "disk full" processing. 142 | ;edit 12, 8-Nov-1990 by MF. 143 | ; Adjusted edit levels shown for cpscom.asm/cpspk1.asm/cpsdat.asm to 144 | ; reflect bug fixes and code revisions. 145 | ;edit 11, 5-Nov-1990 by MF. 146 | ; Cosmetic changes for main help text for COPY and RENAME commands. 147 | ; Begin CP/M Kermit-80 version 4.10. 148 | ;edit 10, 2-Nov-1990 by MF. Moved Overlay address to 7000H (cpsdat.asm). 149 | ;edit 9, 1-Nov-1990 by Mike Freeman (BPA). Cosmetic changes (command-name 150 | ; changes: SET BAUD-RATE==>SET SPEED, FCOPY==>COPY, FRENAME==>RENAME, 151 | ; STRING==>OUTPUT, REMOTE CWD==>REMOTE CD per suggestions of FDC 152 | ; to aid in uniformity of nomenclature for various Kermits. 153 | ;edit 8, 30-Oct-1990 by Michael Freeman; 301 N.E. 107th Street; 154 | ; Vancouver, WA 98685 USA; Telephone (206)574-8221. 155 | ; Work: Bonneville Power Administration 156 | ; P.O. Box 491 M/S MORF 157 | ; Vancouver, WA USA 98666 158 | ; Telephone (206)690-2307 159 | ; Implemented FRENAME command to rename a CP/M file. 160 | ; Implemented many Remote commands, variable-length packets up thru 161 | ; 94 characters in length. Fixed a bug in CPSCOM.ASM in the 162 | ; routine "getnp" and a bug in CPSCOM.ASM which caused garbage to appear 163 | ; on the screen when PRTSTR was called with QUIETD flag set. 164 | ; Modified code in module CPSCMD.ASM to skip leading spaces and tabs 165 | ; when getting Kermit commands from the CP/M command line. This also 166 | ; obviates the necessity to type a leading semicolon to separate the 167 | ; Kermit command from the Kermit commands on the CP/M command line. 168 | ; Fixed code in CPSPK2.ASM which handles file collision detection 169 | ; and resulting file rename per my entries in CPKERM.BWR. 170 | ; and included fix by Russell Lang of Dept. of Electrical and Computer 171 | ; Engineering, Monash University, Australia, to prevent renamed 172 | ; files with SET WARNING ON from having the attributes (e.g., R/O) 173 | ; copied from original file. Mr. Lang's E-mail address is: 174 | ; Russell Lang Email: rjl@monu1.cc.monash.edu.au Phone: (03) 565 3460 175 | ; Department of Electrical and Computer Systems Engineering 176 | ; Monash University, Australia 177 | ; Also fixed a bug in CPSPK2.ASM which prevented completion messages 178 | ; from being displayed if terminal was set to QUIET. 179 | ; Implemented most proposed SET FILE-COLLISION (COLLISION) commands. 180 | ; Implemented SET INCOMPLETE file disposition command. 181 | ; Implemented a few of the proposed REMOTE SET commands. 182 | ; Implemented other fixes suggested in CPKERM.BWR. 183 | ; Moved overlay address to 6C00H. 184 | ; Changed location of .printx in this file so LASM doesn't complain. 185 | ; In system-dependent modules, included HP-125 support. 186 | ; Also modified Telcon Zorba code in CPXHEA.ASM to enable setting 187 | ; of baud-rates and sending of a break. 188 | ; Included Russell Lang of Monash Univ. Australia's implementation 189 | ; for the Microbee series of computers (CPXBEE.ASM). 190 | ; Fixed COMPUPRO version of Kermit to compile correctly and to 191 | ; conform to current syntax for setting baud-rate. 192 | ; edit 7, September, 1987. Added files for SERVER and REMOTE 193 | ; modules (CPSSER/CPSREM). SERVER is still empty, and may be 194 | ; only wishfull thinking. I have ideas, but I dont think I 195 | ; will have the time to implement it. 196 | ; 197 | ; edit 6: 30 March, 1987 by OBSchou. Start Kermit-80 V4.09 with the 198 | ; overlay address at 6000h. Also adjusted the INCLUDEs to allow 199 | ; M80 to assmeble these files. 200 | ; 201 | ; edit 5: 20 June, 1986. Have added so much code etc that the overlay had to 202 | ; be moved again.. give it to 5000h. This starts off Kermit-80 V4.08 203 | ; 204 | ; edit 4 22 April 1986 205 | ; Start work on 4.06. This should clear up a couple of bugs, add in 206 | ; a few features, and split the system dependent stuff into 207 | ; smaller units. 208 | ; 209 | ; edit 3a 7 March 86 OBSchou Loughborough england. Minor additions 210 | ; to cpsker.asm, cpscmd.asm and cpspkt.asm. 211 | ; 212 | ; edit 3: February 10, 1985 (CJC) 213 | ; Update for v4.05; add "verno" so CPSUTL doesn't have to change 214 | ; just because some other module did. 215 | ; 216 | ; edit 2: September 10, 1984 (CJC) 217 | ; Update for v4.03. 218 | ; 219 | ; edit 1: July 27, 1984 (CJC) 220 | ; Created to allow assembly of Kermit by LASM as well as MAC80 and M80. 221 | 222 | verno EQU 11 ; minor version number 223 | revno EQU 0 ;[MF]Revision level 224 | ;[MF]0-26 yields A-Z 225 | 226 | ; Version 4.10 of Kermit consists of the following edit levels: 227 | ; cpsker.asm edit 32 228 | ; cpsdef.asm edit 9 229 | ; cpsmit.asm edit 30 230 | ; cpscom.asm edit 13 231 | ; cpspk1.asm edit 23 232 | ; cpspk2.asm edit 11 233 | ; cpsrem.asm edit 13 234 | ; cpsser.asm edit 1 235 | ; cpstt.asm edit 12 236 | ; cpscpm.asm edit 14 237 | ; cpswld.asm edit 4 238 | ; cpscmd.asm edit 13 239 | ; cpsutl.asm edit 30 240 | ; cpsdat.asm edit 19 241 | ; cpxlnk.asm edit 8 (cpslnk.asm is not assembled with cpsker, but it 242 | ; defines the linkage area expected by cpsker, and so must 243 | ; match the description in cpsutl.asm) 244 | ; cpxswt.asm edit 10 245 | ; 246 | ; Version 4.10 of Kermit has been tested with the following edit levels of 247 | ; the system-dependent files: 248 | ; cpxtyp.asm edit 34 249 | ; cpxsys.asm edit 40 250 | ; cpxhea.asm edit 4 251 | ; cpxtor.asm edit 4 252 | ; cpxbbi.asm edit 4 (Ampro Little Board) 253 | ; 254 | ; Version 4.10 of Kermit is still to be tested fully against all known systems 255 | ; so far included in the system dependent overlays. 256 | ; 257 | 258 | 259 | FALSE equ 0 260 | TRUE equ NOT FALSE 261 | 262 | cpsker equ TRUE ; building system-independent part 263 | debug equ FALSE ; set false for running system. True => does some 264 | ; unusual or unexpected things. 265 | ; 266 | ; Assembler type. Define the appropriate one TRUE, the rest FALSE. (We can't 267 | ; use ASM, because it cannot handle multiple input files) 268 | mac80 EQU FALSE ; For assembly via MAC80 cross-assembler. 269 | m80 EQU false ; For assembly via Microsoft's M80. 270 | lasm EQU true ; For assembly via LASM, a public-domain 271 | ; assembler. 272 | ; 273 | ; Get the other modules... 274 | 275 | IF lasm ; If we're linking, go on to the next file. 276 | LINK CPSDEF 277 | ENDIF;lasm 278 | 279 | ; If we're still here, we must be using M80 or MAC80. M80 doesn't 280 | ; like ENDs inside conditionals, but the END statement has to be 281 | ; in CPSUTL for LASM (otherwise, we'd need a file containing just an 282 | ; END statement). So, we leave off the IF m80 OR mac80 conditional 283 | ; that ought to be around these INCLUDEs. No problem until the next 284 | ; incompatible assembler comes along... 285 | ; Let's first say where we are: 286 | ; 287 | .printx * CPSKER.ASM (or nearest offer) * 288 | ; 289 | .printx * CPSDEF.ASM * 290 | INCLUDE CPSDEF.ASM ; definitions 291 | .printx * CPSMIT.ASM * 292 | INCLUDE CPSMIT.ASM ; initialization, main loop, some commands 293 | .printx * CPSCOM.ASM * 294 | INCLUDE CPSCOM.ASM ; part of command/status/set etc 295 | .printx * CPSPK1.ASM * 296 | INCLUDE CPSPK1.ASM ; KERMIT protocol handler (Part 1) 297 | .printx * CPSPK2.ASM * 298 | INCLUDE CPSPK2.ASM ; KERMIT protocol handler (Part 2) 299 | .printx * CPSREM.ASM * 300 | INCLUDE CPSREM.ASM ; Kermit REMOTE code (little in it, as yet) 301 | .printx * CPSSER.ASM * 302 | INCLUDE CPSSER.ASM ; Kermit SERVER code (As yet, empty) 303 | .printx * CPSTT.ASM * 304 | INCLUDE CPSTT.ASM ; transparent communication handler 305 | .printx * CPSCPM.ASM * 306 | INCLUDE CPSCPM.ASM ; CP/M command support (DIR, ERA) 307 | .printx * CPSWLD.ASM * 308 | INCLUDE CPSWLD.ASM ; wildcard handler 309 | .printx * CPSCMD.ASM * 310 | INCLUDE CPSCMD.ASM ; command parser 311 | .printx * CPSUTL.ASM * 312 | INCLUDE CPSUTL.ASM ; Various utilities and data, and END [ToadHall] 313 | .printx * CPSDAT.ASM * 314 | INCLUDE CPSDAT.ASM 315 | END ; MAC80 ignores END's in included files... 316 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpsser.asm: -------------------------------------------------------------------------------- 1 | ; CPSSER.ASM 2 | ; KERMIT - (Celtic for "FREE") 3 | ; 4 | ; This is the CP/M-80 implementation of the Columbia University 5 | ; KERMIT file transfer protocol. 6 | ; 7 | ; Version 4.0 8 | ; 9 | ; Copyright June 1981,1982,1983,1984 10 | ; Columbia University 11 | ; 12 | ; Originally written by Bill Catchings of the Columbia University Center for 13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 14 | ; 15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 17 | ; others. 18 | ; 19 | ; This file contains the (system-independent) routines that implement 20 | ; the SERVER part of the KERMIT protocol. 21 | ; 22 | ; revision history: 23 | ; 24 | ; 25 | ; edit 1: September, 1987. Created CPSSER.ASM from bits from the two CPSPK? 26 | ; files. 27 | ; The code herein is to allow remote systems to communicate to 28 | ; this Kermit running in SERVER mode. Note that not every server 29 | ; command will be supported, mind... 30 | ; 31 | server: db 'CPSSER.ASM (1) 8-SEP-87$' ; name, edit number, date 32 | 33 | 34 | 35 | ; Little code to allow some expansion of code without changing 36 | ; every futher address, only up to the end of this file. 37 | ; TO BE REMOVED FOR RELEASE! 38 | 39 | ; org ($+100h) AND 0FF00H 40 | 41 | 42 | IF lasm 43 | LINK CPSTT 44 | ENDIF;lasm 45 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpswld.asm: -------------------------------------------------------------------------------- 1 | ; CPSWLD.ASM 2 | ; KERMIT - (Celtic for "FREE") 3 | ; 4 | ; This is the CP/M-80 implementation of the Columbia University 5 | ; KERMIT file transfer protocol. 6 | ; 7 | ; Version 4.0 8 | ; 9 | ; Copyright June 1981,1982,1983,1984 10 | ; Columbia University 11 | ; 12 | ; Originally written by Bill Catchings of the Columbia University Center for 13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 14 | ; 15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 17 | ; others. 18 | ; 19 | ; Multi-file access subroutine. Allows processing of multiple files 20 | ; (i.e., *.ASM) from disk. This routine builds the proper name in the 21 | ; FCB each time it is called. This command would be used in such pro- 22 | ; grams such as modem transfer, tape save, etc. in which you want to 23 | ; process single or multiple files. 24 | ; Note that it will fail if more than 256 entries match the wildcard. 25 | ; 26 | ; revision history: 27 | ; edit 4: June 20, 1986, by OBSchou. Added stuff at top and tail of routine 28 | ; to support multiple FCBs. If the routine get to mfn01 (Search for next) 29 | ; then the next file found gets its fcb added to the buffer. Once no 30 | ; more files have been found, the mfflg3 flag is set non-zero. 31 | ; The first thing to test on entry is whether a disk access 32 | ; is needed. Either way, the routine should return the next file name 33 | ; in the fcb, or return with the carry flag set if there are no more 34 | ; files to do. Once there is a carry flag set for the return, all 35 | ; temporary flags are reset. Get all that? 36 | ; 37 | ; edit 3: July 27, 1984 38 | ; support LASM: remove exclamation points, link to CP4CMD. 39 | ; 40 | ; edit 2: June 7, 1984 (CJC) 41 | ; formatting and documentation; add module version string; redo movfcb, 42 | ; in preparation for moving DMA buffer (later...). 43 | ; 44 | ; edit 1: May, 1984 (CJC) 45 | ; extracted from CPMBASE.M80 version 3.9; modifications are described 46 | ; in the accompanying .UPD file. 47 | ; 48 | wldver: db 'CPSWLD.ASM (4) 20-Jun-86$' 49 | 50 | ; The FCB will be set up with the next name, ready to do normal 51 | ; processing (OPEN, READ, etc.) when routine is called. 52 | ; 53 | ; Carry is set if no more names can be found 54 | ; 55 | ; MFFLG1 is count/switch [0 for first time thru, pos for all others] 56 | ; MFFLG2 is counted down for each successive GETNEXT file call 57 | ; MFFLG3 is set to the last remaining FCBs buffered once Search for next 58 | ; file fails with files in the buffer. 59 | ; 60 | ; Technique used is to repeat SFIRST/SNEXT sequence N+1 times for each 61 | ; successive call, till sequence fails. CP/M does NOT allow disk-handling 62 | ; between SFIRST and SNEXT. 63 | ; called by: send, seof, dir 64 | 65 | mfname: ora a ; clear carry 66 | push b ;Save registers 67 | push d 68 | push h 69 | jmp mfnam0 ; skip over the next bit (which is entered from elsewhere) 70 | 71 | ;[4] Get the FCB counter and see if we have any fcbs already. 72 | mfnam1: lxi h,fcb0 73 | shld xfcbptr ; reset the pointer if we are to return an FCB 74 | 75 | mfnam0: lda fcbcnt 76 | ana a ; if none, then we may have to get some from disk 77 | jz mfn00 ; see later on 78 | lhld xfcbptr ; we have some, so give the next one to the user 79 | lxi d,fcb ; move from (hl) to (de) for length bc 80 | lxi b,12 81 | call mover 82 | xra a 83 | sta fcbext ; clear fcb extents and such 84 | sta fcbrno ; like record number 85 | lhld xfcbptr ; point to next fcb 86 | lxi d,fcblen 87 | dad d ; yup 88 | shld xfcbptr 89 | lda fcbcnt 90 | dcr a 91 | sta fcbcnt ; decrease the number of fcbs we have 92 | xra a ; clear carry 93 | jmp mffix1 ; and exit as if were all done 94 | 95 | mfn00: lda mfflg3 ; no more FCBs for the user, any more on disk? 96 | ana a 97 | jnz mffix2 ; no, then set the carry flag to say so. 98 | lxi h,fcb0 ; now reset the fcb pointers and counter 99 | shld xfcbptr 100 | xra a 101 | sta fcbcnt 102 | ;[4] end of this addition. See below as well. 103 | 104 | 105 | mvi c,setdma ;Init DMA addr, FCB 106 | lxi d,80H 107 | call bdos 108 | xra a ;A = 0 109 | sta fcbext ;clear extension 110 | lda mfflg1 ;find out if "second" call in row 111 | ora a 112 | jnz mfn01 ;Were here before 113 | sta mfflg2 114 | lxi h,fcb 115 | lxi d,mfreq 116 | lxi b,12 117 | call mover ;.from FCB to MFREQ 118 | mvi c,SFIRST ;Search first 119 | lxi d,fcb 120 | call bdos 121 | jmp mfn02 ;and check results 122 | 123 | mfn01: dcr a 124 | sta mfflg2 ;store down-counter 125 | lxi h,mfreq ;SFIRST REQ name 126 | lxi d,fcb 127 | lxi b,12 128 | call mover ;.from MFREQ to FCB 129 | mvi c,sfirst ;Search first old one,we got it before 130 | lxi d,fcb 131 | call bdos ;no error's expected -we got that before 132 | mfn01a: 133 | mvi c,snext ;Search next 134 | call bdos 135 | mfn02: push psw 136 | lda mfflg2 ;get "repeat file counter" 137 | ora a 138 | jz mfn02a ;if zero, check if SNEXT had ERROR 139 | dcr a ;count down 140 | sta mfflg2 ;store back 141 | pop psw ;no error-check, we got it before 142 | jmp mfn01a ;next SNEXT 143 | 144 | mfn02a: pop psw 145 | ora a 146 | jm mffi2a ;No (more) found 147 | call movfcb ;move data to fcb 148 | lda mfreq ;the original disk-designator 149 | sta fcb ;back into fcb 150 | lda mfflg1 ;get file-flag 151 | inr a ;increment 152 | sta mfflg1 ;and store for next go-around 153 | mvi a,0 ;Setup FCB 154 | sta fcbext ;clean up FCB for OPEN etc 155 | sta fcbrno 156 | lhld xfcbptr ;[4] like here 157 | xchg 158 | lxi h,fcb ;[4] from fcb space 159 | lxi b,12 160 | call mover 161 | lhld xfcbptr ;[4] now lets update the pointers 162 | lxi d,fcblen 163 | dad d 164 | shld xfcbptr ;[4] new pointer 165 | lda fcbcnt ;[4] now the fcb counter 166 | inr a 167 | sta fcbcnt 168 | cpi maxfcb ;[4] any more spare space? 169 | jp mfnam1 ;[4] nope, so get first fcb and return 170 | lxi d,fcb ; else restore the file to serach for 171 | lxi h,mfreq 172 | lxi b,12 ; copy the original fcb to fcb 173 | call mover 174 | jmp mfn01a ; and look for next match. 175 | 176 | mffix1: pop h ;restore registers 177 | pop d 178 | pop b 179 | ret ;and return 180 | 181 | mffi2a: 182 | sta mfflg3 ;[4] no more FCBs from disks to be had, but 183 | lda fcbcnt ;[4]we have some in the buffer, havet we? 184 | ana a 185 | jnz mfnam1 ;[4] yes, so all's ok. Get an fcb and return, 186 | 187 | mffix2: xra a 188 | sta mfflg3 ;[4] clear the new flag (=no more fcbs at all) 189 | sta mfflg2 ;[4] may as well do the others, as we're not comming again 190 | sta mfflg1 ;[4] 191 | stc ;set carry 192 | jmp mffix1 ;return with CARRY set 193 | 194 | ; copy directory entry to FCB 195 | ; called with A/ entry number in directory (0-3) 196 | ; directory block in DMA buffer (buff) 197 | 198 | movfcb: add a 199 | add a 200 | add a 201 | add a 202 | add a ;* 32 203 | mov c,a ; copy offset to bc 204 | mvi b,0 ; (high byte is zero) 205 | lxi h,buff ; get start of disk buffer 206 | dad b ; calculate start of directory entry 207 | lxi d,fcb 208 | lxi b,12 209 | call mover 210 | ret 211 | 212 | ; Data storage for MFNAME (multi-file access) 213 | mfreq: DS 12 ;Requested name 214 | mfflg1: DB 0 ;First time thru flag for MFNAME 215 | mfflg2: DB 0 ;Down counter for MFNAME 216 | mfflg3: DB 0 ;[4] Non zero if no more FCBs from disk, 217 | ;[4] but we still have some in buffer 218 | ; 219 | IF lasm 220 | LINK CPSCMD 221 | ENDIF;lasm 222 | 223 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxcom.asm: -------------------------------------------------------------------------------- 1 | IF NOT lasm 2 | .printx * CPXCOM.ASM * 3 | ENDIF ; NOT lasm 4 | ; KERMIT - (Celtic for "FREE") 5 | ; 6 | ; This is the CP/M-80 implementation of the Columbia University 7 | ; KERMIT file transfer protocol. 8 | ; 9 | ; Version 4.0 10 | ; 11 | ; Copyright June 1981,1982,1983,1984,1985 12 | ; Columbia University 13 | ; 14 | ; Originally written by Bill Catchings of the Columbia University Center for 15 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 16 | ; 17 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 18 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 19 | ; others. 20 | ; 21 | ; This file contains part common code required for most if not all 22 | ; systems. Specifiacally, SYSINIT, INIADR, MOVER, and DELAY to name 23 | ; the most important ones. 24 | ; 25 | ; revision history: 26 | ; 27 | ; edit 1, 21st July 1987 by OBSchou. Regretably, I have had to include 28 | ; some system dependent IFs, mainly for CRT, TORCH and OSI. Inclusion 29 | ; here means simpler family files later on. (Regrettably, the delay 30 | ; loop for APMMDM differs too.) 31 | ; 32 | ; Set the fuzzy timeout value. Range is 1 (VERY short) through 0ffffH to zero 33 | ; (maximum). The actual duration is a function of the loop length and the 34 | ; processor speed. For now, we'll make it zero for everybody, but feel free 35 | ; to change it for your system. 36 | ; [OBS] make it a little less than max, say 1000H. More useful. 37 | fuzval EQU 1000H 38 | 39 | ; 40 | ; System-dependent initialization 41 | ; Called once at program start. 42 | sysinit: 43 | ; 44 | ; [13] Had to move this call to here, as the prtstr routine needs this 45 | ; before the config message is sent out. It has only been moved. 46 | ; 47 | call iniadr ;Initialize the BIOS addresses 48 | mvi c,gtiob ;Get current I/O byte 49 | call bdos ;From CP/M 50 | sta coniob ;Remember where console is 51 | mvi c,getvnm ; get the BDOS version number (e.g. 22H, 31H) 52 | call bdos 53 | mov a,l 54 | sta bdosvr ; and store it away for future reference 55 | lxi d,cfgmsg ; "configured for " 56 | call prtstr 57 | lxi d,sysver ; get configuration we're configured for 58 | call prtstr ; print it. 59 | ; 60 | ; If we're set up to do special terminal handling, say what kind 61 | ; of terminal we expect... (unless it's the generic 'crt') 62 | IF termin 63 | lxi d,witmsg ; " with " 64 | call prtstr 65 | lxi d,ttytyp ; terminal type 66 | call prtstr 67 | ENDIF;termin 68 | call prcrlf ; print CR/LF 69 | ; 70 | ; now, to work... 71 | ; 72 | ; locate large buffer for multi-sector I/O 73 | ; What we want to do here is find the ccp. Space between ovlend and the ccp 74 | ; is available for buffering, except we don't want to use more than maxsec 75 | ; buffers (if we use too many, the remote end could time out while we're 76 | ; writing to disk). maxsec is system-dependent, but for now we'll just 77 | ; use 8Kbytes. If you get retransmissions and other protocol errors after 78 | ; transferring the first maxsec sectors, lower maxsec. 79 | 80 | maxsec EQU (8*1024)/bufsiz ; 8K / number of bytes per sector 81 | 82 | lxi h,ovlend ; get start of buffer 83 | shld bufadr ; store in linkage section 84 | mvi a,maxsec ; get size of buffer, in sectors 85 | sta bufsec ; store that, too. 86 | 87 | call sysxin ; call system specific init code 88 | 89 | ret ; return from system-dependent routine 90 | 91 | bdosvr: ds 1 ; space to save the BDOS version number 92 | IF NOT iobyt 93 | coniob: ds 1 ; space to save copy of IO byte 94 | ENDIF ;NOT iobyt 95 | ; 96 | ; This one is hopefully the last "improvement" in view of GENERIC 97 | ;Kermit. It uses for Character-I/O the BIOS-routines ( instead of the 98 | ;"normal" BDOS routines. What does it give us (hopefully) : More speed, 99 | ;higher chance of success ( I/O byte implemented in BIOS [if at all]), 100 | ;but no "extra" device handling - that's done by BDOS. 101 | ; 102 | ; How do we "get" the call-adresses? Location 0 has a JMP Warm-Boot 103 | ;in CP/M which points into the second location of the BIOS JMP-Vector. The 104 | ;next three locations of the JMP-Vector point to the CONSTAT,CONIN,CONOUT 105 | ;BIOS-routines. CONOUT wants the character in C. 106 | ; 107 | ;- Bernie Eiben 108 | 109 | iniadr: lhld 1 ;get BIOS Warmstart-address 110 | lxi d,3 ;next adress is CONSTAT in BIOS 111 | dad d 112 | shld bconst+1 ;stuff it into the call-instruction 113 | lxi d,3 ;next adress is CONIN in BIOS 114 | dad d 115 | shld bconin+1 ; 116 | lxi d,3 ;next adress is CONOUT in BIOS 117 | dad d 118 | shld bcnout+1 119 | lxi d,3 ;next address is LIST in BIOS 120 | dad d 121 | shld blsout+1 122 | lxi d,10*3 ; get printer status routine 123 | dad d 124 | shld bprtst 125 | ret ;And return 126 | 127 | bconst: jmp $-$ ;Call BIOS directly (filled in by iniadr) 128 | 129 | bconin: jmp $-$ ;Call BIOS directly (filled in by iniadr) 130 | 131 | bcnout: jmp $-$ ;Call BIOS directly (filled in by iniadr) 132 | 133 | blsout: jmp $-$ ; .... 134 | 135 | bprtst: jmp $-$ ; Call BIOS directly for printer status 136 | 137 | IF NOT apmmdm ; Shame about this, but the Apple needs a different delay 138 | ; 139 | ;[cjc] Delay routine. Called with time (hundredths of seconds) in A. 140 | ; The inner loop delays 1001 T-states, assuming no wait states are 141 | ; inserted; this is repeated CPUSPD times, for a total delay of just 142 | ; over 0.01 second. (CPUSPD should be set to the system clock rate, 143 | ; in units of 100KHz: for an unmodified Kaypro II, that's 25 for 144 | ; 2.5 MHz. Some enterprising soul could determine whether or not the 145 | ; Kaypro actually inserts a wait state on instruction fetch (a common 146 | ; practice); if so, the magic number at delay2 needs to be decreased. 147 | ; (We also neglect to consider time spent at interrupt level). 148 | ; 149 | ; called by: sendbr 150 | ; destroys BC 151 | 152 | delay: mvi c,cpuspd ; Number of times to wait 1000 T-states to 153 | ; make .01 second delay 154 | delay2: mvi b,70 ; Number of times to execute inner loop to 155 | ; make 1000 T-state delay 156 | delay3: dcr b ; 4 T-states (* 70 * cpuspd) 157 | jnz delay3 ; 10 T-states (* 70 * cpuspd) 158 | dcr c ; 4 T-states (* cpuspd) 159 | jnz delay2 ; 10 T-states (* cpuspd) 160 | ; total delay: ((14 * 70) + 14) * cpuspd 161 | ; = 1001 * cpuspd 162 | dcr a ; 4 T-states 163 | jnz delay ; 10 T-states 164 | ret ; grand total: ((1001 * cpuspd) + 14) * a 165 | ENDIF ; NOT apmmdm 166 | ; 167 | ; 168 | ; Set up screen display for file transfer 169 | ; called with kermit version in DE 170 | ; 171 | sysscr: push d ; save version for a bit 172 | lxi d,outlin ; clear screen, position cursor 173 | call prtstr ; do it 174 | pop d ; get Kermit's version 175 | IF NOT (osi OR crt) ; got cursor control? 176 | call prtstr ; print it 177 | mvi e,'[' ; open bracket 178 | call outcon ; print it (close bracket is in outln2) 179 | lxi d,sysver ; get name and version of system module 180 | call prtstr 181 | lxi d,outln2 ; yes, print field names 182 | call prtstr 183 | lda dbgflg ; is debugging enabled? 184 | ora a 185 | rz ; finished if no debugging 186 | lxi d,outln3 ; set up debugging fields 187 | call prtstr 188 | ENDIF;NOT (osi OR crt) 189 | ret 190 | ; 191 | ; Calculate free space for current drive 192 | ; returns value in HL 193 | sysspc: 194 | lda bdosvr ;cpm3's alloc vect may be in another bank 195 | cpi 30H ;cpm3 or later? 196 | jm cp2spc ;no: use cp/m 2 algorithm 197 | lda fcb ;If no drive, get 198 | ora a ; logged in drive 199 | jz dir180 200 | dcr a ;FCB drive A=1 normalize to be A=0 201 | jmp dir18a 202 | 203 | dir180: mvi c,rddrv 204 | call bdos 205 | dir18a: mov e,a ;drive in e 206 | mvi c,getfs ;get free space BDOS funct 207 | call bdos ;returns free recs (3 bytes in buff..buff+2) 208 | mvi b,3 ;conv recs to K by 3 bit shift 209 | dir18b: xra a ;clear carry 210 | mvi c,3 ;for 3 bytes 211 | lxi h,buff+3 ;point to addr + 1 212 | dir18c: dcx h ;point to less sig. byte 213 | mov a,m ;get byte 214 | rar ;carry -> A -> carry 215 | mov m,a ;put back byte 216 | dcr c ;for all bytes (carry not mod) 217 | jnz dir18c 218 | dcr b ;shift 1 bit 3 times 219 | jnz dir18b 220 | mov e,m ;get least sig byte 221 | inx h 222 | mov d,m ;get most sig byte 223 | xchg ;get K free in HL 224 | ret 225 | 226 | ; the rest are CP/M 2.2 systems, so use the alloc vector 227 | cp2spc: mvi c,getalv ;Address of CP/M Allocation Vector 228 | call bdos 229 | xchg ;Get its length 230 | lhld bmax 231 | inx h 232 | lxi b,0 ;Initialize Block count to zero 233 | dir19: push d ;Save allocation address 234 | ldax d 235 | mvi e,8 ;set to process 8 blocks 236 | dir20: ral ;Test bit 237 | jc dir20a 238 | inx b 239 | dir20a: mov d,a ;Save bits 240 | dcx h 241 | mov a,l 242 | ora h 243 | jz dir21 ;Quit if out of blocks 244 | mov a,d ;Restore bits 245 | dcr e ;count down 8 bits 246 | jnz dir20 ;do another bit 247 | pop d ;Bump to next count of Allocation Vector 248 | inx d 249 | jmp dir19 ;process it 250 | 251 | dir21: pop d ;Clear Allocation vector from stack 252 | mov l,c ;Copy block to 'HL' 253 | mov h,b 254 | lda bshiftf ;Get Block Shift Factor 255 | sui 3 ;Convert from records to thousands 256 | rz ;Skip shifts if 1K blocks 257 | dir22: dad h ;Multiply blocks by 'K per Block' 258 | dcr a 259 | jnz dir22 260 | ret 261 | 262 | ; +----|----|----|----|----|----|----|... 263 | ; 1 | 264 | ; 2 | Kermit-80 v4.0 [system] 265 | ; 3 | 266 | ; 4 |Number of packets: ____ 267 | ; 5 |Number of retries: ____ 268 | ; 6 |File name: ____________ 269 | ; 7 |... 270 | ; 8 |... 271 | ; 9 |RPack: ___(if debugging)... 272 | ; 10 | 273 | ; 11 |SPack: ___(if debugging)... 274 | ; 12 | 275 | ; 13 |Kermit-80 A:> (when finished) 276 | ; 277 | ; For the PX-8, the display looks like: 278 | ; 5 10 15 20 25 30 35 40 45 50 55 279 | ; +----|----|----|----|----|----|----|----|----|----|----|----|---- 280 | ; 1 |Kermit-80 v4.05 [Epson PX-8] Number of retries: ____ 281 | ; 2 |Number of packets: ____ File name: ________.___ 282 | ; 3 |... 283 | ; 4 |... 284 | ; 5 |RPack: ___ (if debugging)... 285 | ; 6 | 286 | ; 7 |SPack: ___ (if debugging)... 287 | ; 8 | 288 | ; 9 |Kermit-80 A:> (when finished) 289 | ; 290 | 291 | IF NOT px8 ; [29] 292 | nppos EQU 4*100h+20 293 | rtpos EQU 5*100h+20 294 | fnpos EQU 6*100h+12 295 | errlin EQU 7 296 | stlin EQU 8 297 | rplin EQU 9 298 | splin EQU 11 299 | prplin EQU 13 300 | ENDIF ; NOT px8 301 | 302 | IF px8 303 | nppos EQU 2*100h+20 304 | rtpos EQU 1*100h+59 305 | fnpos EQU 2*100h+51 306 | errlin EQU 3 307 | stlin EQU 4 308 | rplin EQU 5 309 | splin EQU 7 310 | prplin EQU 9 311 | ENDIF ; px8 [29] 312 | 313 | 314 | IF NOT (osi OR crt );[26] 315 | scrnp: lxi b,nppos 316 | jmp csrpos 317 | 318 | scrnrt: lxi b,rtpos 319 | jmp csrpos 320 | 321 | scrfln: lxi b,fnpos 322 | call csrpos 323 | clreol: 324 | lxi d,tk 325 | jmp prtstr 326 | 327 | screrr: lxi b,errlin*100H+1 328 | call csrpos 329 | jmp clreol 330 | 331 | scrst: lxi b,stlin*100H+1 332 | call csrpos 333 | jmp clreol 334 | 335 | rppos: lxi b,rplin*100H+8 336 | call csrpos 337 | jmp clreol 338 | 339 | sppos: lxi b,splin*100H+8 340 | call csrpos 341 | jmp clreol 342 | 343 | ; [29] Modify scrend to make the cursor line conditional on use of debugging 344 | ; This means that in most cases the entire file transfer will fit on PX-8 lcd 345 | scrend: lda dbgflg 346 | ora a 347 | jz scr1nd 348 | lxi b,prplin*100H+1 ; debugging in use [29] 349 | jmp scr2nd 350 | scr1nd: lxi b,rplin*100H+1 ; no debugging 351 | scr2nd: call csrpos 352 | clreos: lxi d,tj 353 | jmp prtstr 354 | ; [29] and nop out the rest for now... 355 | ; 356 | ;scrend: lxi b,prplin*100H+1 357 | ; call csrpos 358 | ;clreos: lxi d,tj 359 | ; jmp prtstr 360 | ENDIF;NOT (osi OR crt ) [26] 361 | 362 | 363 | IF osi OR crt ; no cursor control 364 | scrnp: mvi e,' ' 365 | jmp outcon 366 | 367 | scrnrt: mvi e,' ' 368 | call outcon 369 | mvi e,'%' 370 | jmp outcon 371 | 372 | scrfln: 373 | screrr: 374 | scrst: 375 | scrend: jmp prcrlf ;Print CR/LF [Toad Hall] 376 | 377 | rppos: lxi d,prpack 378 | jmp prtstr 379 | 380 | sppos: lxi d,pspack 381 | jmp prtstr 382 | ENDIF;osi OR crt 383 | 384 | ; Some frequently-used routines (duplicates of those in CPSMIT): 385 | ; prcrlf - output a CR/LF 386 | ; prtstr - output string in DE 387 | ; rskp - return, skipping over error return 388 | prcrlf: lxi d,crlf 389 | prtstr: 390 | ; [17] added this to avoid prtstr.. emulate function 9 call. 391 | ; Works on most machines. 392 | IF (torch OR px8 OR z80mu) 393 | ; 394 | ; Modified print string as the CP/N (for Nut) system traps control 395 | ; characters in a function 9 call.. rot its cotton socks. 396 | push h 397 | push d 398 | push b 399 | prtst1: 400 | ldax d 401 | inx d 402 | cpi '$' ; if a dollar then end of string 403 | jz prtst2 404 | push d 405 | mov e,a 406 | mov c,a ; also to c if its via conout in BIOS 407 | call outcon ; send it to the screen 408 | pop d 409 | jmp prtst1 410 | 411 | prtst2: pop b 412 | pop d 413 | pop h 414 | ret ; regs restored.. just in case 415 | ENDIF ;(torch OR px8 OR z80mu) 416 | 417 | IF NOT (torch OR px8 or z80mu) ;ie any machine that can send ctrl chrs via dos call 9 418 | PUSH H 419 | PUSH D 420 | push b 421 | mvi c,9 ; Dos call 9 (print a string) 422 | call bdos 423 | pop b 424 | POP D 425 | POP H 426 | ret ; all done for good machines 427 | ENDIF ;NOT (torch OR px8 OR z80mu) 428 | 429 | ; 430 | ; rskp - return to calling address + 3. 431 | rskp: pop h ; Get the return address 432 | inx h ; Increment by three 433 | inx h 434 | inx h 435 | pchl 436 | 437 | ; Copy block of data 438 | ; source in HL, destination in DE, byte count in BC 439 | ; called by: cpxsys, mfname 440 | ; 441 | mover: 442 | ;IF NOT z80 ; 8080's have to do it the hard way 443 | ;OBS assume its an 8080 for now - this will work on Z80s anyway. 444 | mov a,m 445 | stax d 446 | inx h 447 | inx d 448 | dcx b 449 | mov a,b 450 | ora c 451 | jnz mover 452 | ;ENDIF;NOT z80 453 | ;IF z80 454 | ; db 0EDh,0B0h ; Z80 LDIR instruction 455 | ;ENDIF;z80 456 | ret 457 | 458 | ; 459 | ; Miscellaneous messages 460 | ; 461 | crlf: db cr,lf,'$' 462 | cfgmsg: db 'configured for $' 463 | witmsg: db ' with $' ; Its included if we get here ('with terminal') 464 | 465 | IF NOT (osi OR crt OR px8) ; [29] got cursor control? 466 | outln2: db ']',cr,lf,cr,lf,'Number of packets:' 467 | db cr,lf,'Number of retries:' 468 | db cr,lf,'File name:$' 469 | ENDIF;NOT (osi OR crt OR px8) 470 | 471 | IF px8 ; [29] 472 | outln2: db '] Number of retries:', cr, lf 473 | db 'Number of packets: File name:$' 474 | ENDIF ; px8 [29] 475 | 476 | IF NOT (osi OR crt) ; [29] 477 | outln3: db cr,lf,cr,lf ; debugging messages 478 | db cr,lf,'Rpack:' 479 | db cr,lf ; Blank line in case of long packet 480 | db cr,lf,'Spack:$' 481 | ENDIF ; NOT (osi OR crt) [29] 482 | 483 | IF lasm 484 | LINK CPXSWT.ASM 485 | ENDIF ;lasm 486 | 487 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxgni.asm: -------------------------------------------------------------------------------- 1 | ; CPXGNI.ASM 2 | ; KERMIT - (Celtic for "FREE") 3 | ; 4 | ; This is the CP/M-80 implementation of the Columbia University 5 | ; KERMIT file transfer protocol. 6 | ; 7 | ; Version 4.0 8 | ; 9 | ; Copyright June 1981,1982,1983,1984,1985 10 | ; Columbia University 11 | ; 12 | ; Originally written by Bill Catchings of the Columbia University Center for 13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 14 | ; 15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 17 | ; others. 18 | ; 19 | ; This file contains the system-dependent code and data for various 20 | ; Genie 3 CPM kermit 21 | ; 22 | ; This has the Family name of CPXGNI.ASM. 23 | ; 24 | ; revision history (last edit first) 25 | ; edit 3: 27 October, a987 by OBSchou. Massaged file to suit V4.09 structure. 26 | ; 27 | ; Edit 2: Aug 27 1987 GDS Put in code for BREAK and fillited out 28 | ; a lot of unnecessary IF's 29 | ; 30 | ;Edit 1: Nov. 28, 1986 Geof Smith Clinical Research centre Harrow UK. 31 | 32 | .printx * Assembling for Eaca Genie 3 * 33 | ; 34 | drtime EQU 05H ;Default receive time out interval. 35 | ; 36 | ; the basics... 37 | ; 38 | mnport EQU 0E8H 39 | mnprts EQU 0EDH 40 | output EQU 20H 41 | input EQU 01H 42 | lctrl EQU 0EBH 43 | divlsb EQU 0E8H 44 | divmsb EQU 0E9H 45 | z80 EQU TRUE 46 | brkval EQU 40H 47 | 48 | defesc EQU ']'-100O ;The default escape character. 49 | 50 | 51 | ;Select initial setting for VT-52 emulation flag. 52 | 53 | ; default to VT52-EMULATION ON. 54 | ; 55 | vtval EQU 1 56 | ; 57 | ; 58 | 59 | ; Family is the string used in VERSION to say which of several 60 | ; smaller overlay files are used. These are (will be) derived from 61 | ; the huge CP4SYS.ASM file, in which case we will never get here. 62 | ; Just a Dollar, but put a sting in for a family of machines. 63 | ; 64 | family:db 'CPXGNI.ASM (3) 27-Oct-87$' ; Used for family versions.... 65 | 66 | 67 | 68 | ; 69 | ; System-dependent initialization 70 | ; Called once at program start. 71 | sysxin: 72 | ; 73 | ;Set up 9600 bd, 8bit words, no parity 1stop bit 74 | 75 | mvi a,83H ;enable DLAB by setting bit 7 76 | out lctrl ;and outputting to control port 77 | mvi a,14H ;get word = 20 decimal 78 | out divlsb ;and put it out 79 | mvi a,00H ;as two separate 80 | out divmsb ;bytes 81 | lda pstore ;get parity etc 82 | out lctrl ;do it resetting DLAB at same time 83 | 84 | ret ; return from system-dependent routine 85 | 86 | 87 | ; 88 | ; system-dependent termination processing 89 | ; If we've changed anything, this is our last chance to put it back. 90 | sysexit: 91 | 92 | ret 93 | 94 | ; 95 | ; system-dependent processing for start of CONNECT command 96 | ; 97 | syscon: 98 | ret 99 | 100 | conmsg: ; Messages printed when entering transparent (CONNECT) mode: 101 | ; 102 | 103 | 104 | ; 105 | ; syscls - system-dependent close routine 106 | ; called when exiting transparent session. 107 | ; 108 | syscls: 109 | ret 110 | ; 111 | 112 | 113 | ; 114 | ; sysinh - help for system-dependent special functions. 115 | ; called in response to ?, after listing all the 116 | ; system-independent escape sequences. 117 | ; 118 | sysinh: 119 | lxi d,inhlps ; we got options... 120 | call prtstr ; print them. 121 | ret 122 | 123 | 124 | ;additional, system-dependent help for transparent mode 125 | ; (two-character escape sequences) 126 | inhlps: 127 | 128 | db cr,lf,'B Transmit a BREAK' 129 | 130 | db '$' ;[hh] table terminator 131 | 132 | ; 133 | ; sysint - system dependent special functions 134 | ; called when transparent escape character has been typed; 135 | ; the second character of the sequence is in A (and in B). 136 | ; returns: 137 | ; non-skip: sequence has been processed 138 | ; skip: sequence was not recognized 139 | sysint: ani 137O ; convert lower case to upper, for testing... 140 | cpi 'B' ; send break? 141 | jz sendbr ; yes, go do it. return nonskip when through. 142 | 143 | jmp rskp ; take skip return - command not recognized. 144 | 145 | 146 | ;------------------------------------------------------------------------------- 147 | sendbr: 148 | ; 149 | ; Ensure that the transmitter has finished sending buffered chars 150 | sndbr1: in mnprts ; get UART status 151 | ani output ; everything sent? 152 | jz sndbr1 ; no, wait a bit more 153 | ; 154 | ; Begin sending a break by setting bit in UART command register 155 | mvi a,brkval ; SBreak, 156 | out lctrl 157 | ; 158 | ; Wait for 250 milliseconds (using hundredths second delay routine) 159 | mvi a,25 160 | call delay 161 | ; 162 | ; Resume normal operation by clearing the SendBreak command bit 163 | lda pstore ;and restoring value from parity store 164 | out mnprts 165 | ; 166 | ret ;done 167 | 168 | ; 169 | ; 170 | 171 | ; 172 | ; sysflt - system-dependent filter 173 | ; called with character in E. 174 | ; if this character should not be printed, return with A = zero. 175 | ; preserves bc, de, hl. 176 | ; note: ,,, and are always discarded. 177 | sysflt: 178 | mov a,e ; get character for testing 179 | ret 180 | 181 | ; mdmflt - modem filter [30] 182 | ; called with character to be sent to modem in E 183 | ; with parity set as appropriate. 184 | ; return with accumulator = 0 do do nothing, 185 | ; <> 0 to send char in E. 186 | mdmflt: mov a,e ; get character to a 187 | ret 188 | 189 | 190 | 191 | ; prtflt - printer filter [30] 192 | ; called with character to be sent to printer in E 193 | ; returns with a = 0 to do nothing 194 | ; a <> 0 to print it. 195 | ; 196 | ; this routine for those printer that automatically insert 197 | ; a lf on cr, or cr for lf. Should this be shifted to 198 | ; the system indep. stuff, in say 4.06? 199 | prtflt: 200 | mov a,e ; [30] get character to test 201 | ret 202 | 203 | 204 | ; 205 | 206 | 207 | ; 208 | ; system-dependent processing for BYE command. 209 | ; for apmmdm, heath, and lobo, hang up the phone. 210 | sysbye: 211 | ret 212 | ; 213 | 214 | 215 | ; This is the system-dependent command to change the baud rate. 216 | ; DE contains the two-byte value from the baud rate table; this 217 | ; value is also stored in 'speed'. 218 | sysspd: 219 | 220 | ;Set up baud rate 8bit words, no parity 1stop bit 221 | mvi a,83H ;enable DLAB by setting bit 7 222 | out lctrl ;and outputting to control port 223 | mov a,d ;get LSB 224 | out divlsb ;and put it out 225 | mov a,e ;get MSB 226 | out divmsb ;output it as well 227 | lda pstore ;get parity etc 228 | out lctrl ;do it resetting DLAB at same time 229 | ret 230 | 231 | pstore: db 03H ;Default value for parity word length and stop bits 232 | 233 | spdtbl: db 11h ;17 entries 234 | db 03h,'110$', 06H,0D1H 235 | db 04h,'1200$', 00H,0A0H 236 | db 05h,'134.5$', 05H,94H 237 | db 03h,'150$', 05H,00H 238 | db 04h,'1800$', 00H,6BH 239 | db 05h,'19200$', 00H,0AH 240 | db 04h,'2000$', 00H,60H 241 | db 04h,'2400$', 00H,50H 242 | db 03h,'300$', 02H,80H 243 | db 04h,'3600$', 00H,35H 244 | db 05h,'38400$', 00H,05H 245 | db 04h,'4800$', 00H,28H 246 | db 02h,'50$', 0FH,00H 247 | db 03h,'600$', 01H,40H 248 | db 04h,'7200$', 00H,1BH 249 | db 02h,'75$', 0AH,00H 250 | db 04h,'9600$', 00H,14H 251 | 252 | sphtbl: db cr,lf,' 50 75 110 134.5 150 300 600 1200' 253 | db cr,lf,' 1800 2000 2400 3600 4800 7200 9600 19200 38400$' 254 | 255 | ; This is the system-dependent SET PORT command. 256 | ; HL contains the argument from the command table. 257 | sysprt: 258 | 259 | ret 260 | ; 261 | prttbl equ 0 ; SET PORT not supported 262 | prhtbl equ 0 263 | 264 | ; 265 | 266 | ; 267 | ; selmdm - select modem port 268 | ; selcon - select console port 269 | ; selmdm is called before using inpmdm or outmdm; 270 | ; selcon is called before using inpcon or outcon. 271 | ; For iobyt systems, diddle the I/O byte to select console or comm port; 272 | ; For Decision I, switches Multi I/O board to console or modem serial 273 | ; port. [Toad Hall] 274 | ; For the rest, does nothing. 275 | ; preserves bc, de, hl. 276 | selmdm: 277 | ret 278 | 279 | selcon: 280 | ret 281 | ; 282 | 283 | 284 | ; Get character from console, or return zero. 285 | ; result is returned in A. destroys bc, de, hl. 286 | ; 287 | inpcon: 288 | mvi c,dconio ;Direct console I/O BDOS call. 289 | mvi e,0FFH ;Input. 290 | call BDOS 291 | 292 | ret 293 | ; 294 | ; Output character in E to the console. 295 | ; destroys bc, de, hl 296 | ; 297 | outcon: 298 | 299 | mvi c,dconio ;Console output bdos call. 300 | call bdos ;Output the char to the console. 301 | 302 | ret 303 | ; 304 | ; 305 | ; outmdm - output a char from E to the modem. 306 | ; the parity bit has been set as necessary. 307 | ; returns nonskip; bc, de, hl preserved. 308 | outmdm: 309 | 310 | in mnprts ;Get the output done flag. 311 | ani output ;Is it set? 312 | jz outmdm ;If not, loop until it is. 313 | mov a,e 314 | out mnport ;Output it. 315 | ret 316 | 317 | ;-------------------------------------------------------------------------- 318 | ; 319 | ; get character from modem; return zero if none available. 320 | ; for IOBYT systems, the modem port has already been selected. 321 | ; destroys bc, de, hl. 322 | inpmdm: 323 | ;Note: modem port should already be selected for mdI. [Toad Hall] 324 | in mnprts ;Get the port status into A. 325 | ani input ;See if the input ready bit is on. 326 | rz ;If not then return. 327 | in mnport ;If so, get the char. 328 | ret ; return with character in A 329 | 330 | 331 | ; 332 | ; flsmdm - flush comm line. 333 | ; Modem is selected. 334 | ; Currently, just gets characters until none are available. 335 | 336 | flsmdm: call inpmdm ; Try to get a character 337 | ora a ; Got one? 338 | jnz flsmdm ; If so, try for another 339 | ret ; Receiver is drained. Return. 340 | ;----------------------------------------------------------------------------- 341 | ; 342 | ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not. 343 | lptstat: 344 | xra a ; assume it is ok.. this may not be necessary 345 | ret 346 | 347 | ; 348 | ; outlpt - output character in E to printer 349 | ; console is selected. 350 | ; preserves de. 351 | outlpt: 352 | push d ; save DE in either case 353 | call prtflt ; go through printer filter [30] 354 | ana a ; if A = 0 do nothing, 355 | jz outlp1 ; [30] if a=0 do nothing 356 | 357 | mvi c,lstout 358 | call bdos ;Char to printer 359 | outlp1: pop d ; restore saved register pair 360 | ret 361 | ;------------------------------------------------------------------------------ 362 | ; 363 | ; Screen manipulation routines 364 | ; csrpos - move to row B, column C 365 | ; 366 | ; csrpos for terminals that use a leadin sequence followed 367 | ; by (row + 31.) and (column + 31.) 368 | ; 369 | csrpos: push b ; save coordinates 370 | lxi d,curldn ; get cursor leadin sequence 371 | call prtstr ; print it 372 | pop h ; restore coordinates 373 | mov a,h ; get row 374 | adi (' '-1) ; space is row one 375 | mov e,a 376 | push h 377 | call outcon ; output row 378 | pop h 379 | mov a,l ; get column 380 | adi (' '-1) ; space is column one 381 | mov e,a 382 | jmp outcon ; output it and return 383 | 384 | ; 385 | ; delchr - make delete look like a backspace. Unless delete is a printing 386 | ; character, we just need to print a backspace. (we'll output clrspc 387 | ; afterwards) 388 | ; For Kaypro and Vector General, delete puts a blotch on the screen. 389 | ; For Apple and Osborne 1, delete moves but doesn't print. 390 | delchr: 391 | 392 | mvi e,bs ;get a backspace 393 | jmp outcon 394 | 395 | ; erase the character at the current cursor position 396 | clrspc: mvi e,' ' 397 | call outcon 398 | mvi e,bs ;get a backspace 399 | jmp outcon 400 | 401 | ; erase the current line 402 | clrlin: lxi d,eralin 403 | jmp prtstr 404 | 405 | ; erase the whole screen, and go home. preserves b (but not c) 406 | clrtop: lxi d,erascr 407 | jmp prtstr 408 | 409 | ;[2] I see no real saving in having all screens in separate file and 410 | ;therefore have included screen definition here and commented out 411 | ;the link to VDU file 412 | ; 413 | ;Specific definitions for the Genie III screen 414 | ; 415 | sysver: db 'Eaca Genie III$' 416 | outlin: db 1aH,cr,lf,' $' 417 | erascr: db 1AH,'$' 418 | eralin: db cr,18H,'$' 419 | curldn: db esc,'=$' 420 | ttab: 421 | ta: db 0BH,'$',0,0 ;Cursor up 422 | tb: db 0AH,'$',0,0 ;Cursor down 423 | tc: db 0CH,'$',0,0 ;Cursor right 424 | td: db 08H,'$',0,0 ;Cursor left 425 | te: db 1AH,'$',0,0 ;Clear display 426 | tf: db esc,'R$',0 ;Reverse on 427 | tg: db esc,'S$',0 ;Reverse off 428 | th: db 1EH,'$',0,0 ;Cursor home 429 | ti: db 0BH,'$',0,0 ;Reverse linefeed 430 | tj: db 19H,'$',0,0 ;Clear to end of screen 431 | tk: db 18H,'$',0,0 ;Clear to end of line 432 | 433 | ovlend equ $ ;End of overlay 434 | 435 | END 436 |  437 |  438 |  439 |  440 | 441 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxlnk.asm: -------------------------------------------------------------------------------- 1 | ; CPXLNK.ASM 2 | ; KERMIT - (Celtic for "FREE") 3 | ; 4 | ; This is the CP/M-80 implementation of the Columbia University 5 | ; KERMIT file transfer protocol. 6 | ; 7 | ; Version 4.0 8 | ; 9 | ; Copyright June 1981,1982,1983,1984 10 | ; Columbia University 11 | ; 12 | ; Originally written by Bill Catchings of the Columbia University Center for 13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 14 | ; 15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 17 | ; others. 18 | ; 19 | ; This file describes the areas used to communicate between KERMIT 20 | ; and the customizing overlay. It is included by the overlay. 21 | ; This file should be changed only to reflect changes in the 22 | ; system-independent portion of Kermit (enhancements, I hope). 23 | ; 24 | ; revision history: 25 | ;edit 8, 14-Sep-1990 by MF. Added variable "incflg" to hold incomplete- 26 | ; file status for SET INCOMPLETE-FILES command. 27 | ; edit 7: 8 April, 1987 by OBSchou. Added a new entry EXTERN to leap off to 28 | ; code written by the user to emulate any terminal they want. All 29 | ; characters are sent here in stead of conout during connect state. 30 | ; In due course, Ill trap all prtstrs and dconio as well. 31 | ; 32 | ; edit 6: May 30, 1986 by OBSchou. Added two more entries to the link area: 33 | ; first to point to a "family" string giving the family name of the 34 | ; system. If the older CP4SYS.ASM still has the code, then the 35 | ; string is null. Secondly, a JMP to give printer status (should be 36 | ; a BIOS function). If 0 then printer is ready, if 0ffh then printer 37 | ; busy. This makes version 4.07 incompatable with 4.05 38 | ; 39 | ; edit 5: February 6, 1985 40 | ; Added a storage variable, "PORT", for the port-in-use value 41 | ; required for the port status routine (same purpose as SPEED). 42 | ; Also moved the printer copy flag (PRNFLG:) into the commun- 43 | ; ications storage area so machine dependant overlay can access it. 44 | ; [Hal Hostetler] 45 | ; Also, replace assembly-time conditional "ffussy" with run-time 46 | ; switch (CJC). 47 | ; 48 | ; edit 4: August 21, 1984 (CJC) 49 | ; Define a use for the third word of the linkage section: it points 50 | ; to the version string for CP4SYS.ASM. Add flsmdm, to flush comm line 51 | ; on startup. Add bufadr and bufsec for multiple-sector buffer support. 52 | ; Shift the entry section up two bytes so we can exit cleanly from DDT. 53 | ; 54 | ; edit 3: August 3, 1984 (CJC) 55 | ; put "mover" in CP4SYS, so we can do a Z80 block move if so inclined. 56 | ; 57 | ; edit 2: July 10, 1984 (CJC) 58 | ; integrate Toad Hall changes for LASM compatibility: CP4LNK is linked 59 | ; by CP4DEF, and links CP4SYS. 60 | ; 61 | ; edit 1: May, 1984 (CJC) 62 | ; extracted from CPMBASE.M80 version 3.9; modifications are described 63 | ; in the accompanying .UPD file. 64 | ; 65 | 66 | ; Define the entry section. These addresses contain jumps to 67 | ; useful routines in KERMIT. To show we know what we're doing, 68 | ; we store the length of this section (entsiz) in our linkage 69 | ; section. I didn't use ORG and DS because I don't want zeroes 70 | ; generated for all the space between here and the actual start 71 | ; of cp4sys. 72 | entry equ 105H ; start of entry section 73 | kermit equ entry+0 ; reentry address 74 | nout equ entry+3 ; output HL in decimal 75 | entsiz equ 2*3 ; 2 entries, so far. 76 | ; 77 | ; End of entry section. 78 | ; 79 | ; Linkage section. This block (through the definition of lnksiz) 80 | ; is used by Kermit to reach the routines and data in the overlay. 81 | ; The section length is stored at the beginning of the overlay 82 | ; area so Kermit can verify that the overlay section is (a) present, 83 | ; (b) in the right place, and (c) the same size as (and therefore 84 | ; presumably the same as) the linkage section Kermit is expecting. 85 | ; 86 | ASEG 87 | ORG OVLADR 88 | ; 89 | lnkflg: dw lnksiz ; linkage information for consistency check. 90 | dw entsiz ; length of entry table, for same. 91 | dw swtver ; address of switcher. CPXSYS now a family 92 | dw family ;*NEW* for V4.08. Address of the family string 93 | ; 94 | ; hooks for system-dependent routines: 95 | ; 96 | ; Input/output routines. 97 | ; 98 | jmp selmdm ; select modem for I/O 99 | jmp outmdm ; output character in E to modem 100 | jmp inpmdm ; read character from modem. return character or 0 in A. 101 | jmp flsmdm ; flush pending input from modem 102 | jmp selcon ; select console for I/O 103 | jmp outcon ; output character in E to console 104 | jmp inpcon ; read char from console. return character or 0 in A 105 | jmp outlpt ; output character in E to printer 106 | jmp lptstat ;*NEW* get the status for the printer. 107 | ; 0=>ok, 0ffh=> not ok 108 | jmp 0 ;*NEW for 4.09* Terminal Emulation code (optional) 109 | ; If terminal is set to EXTERNAL and this address 110 | ; has been filled, then user uses their own code. 111 | xbdos: jmp 0 ;*NEW* Address of the BDOS trap in the independent 112 | ; code. Use this enty for BDOS calls if you want 113 | ; the printer handler to work properly. 114 | 115 | ; screen formatting routines 116 | jmp clrlin ; erase current line 117 | jmp clrspc ; erase current position (after backspace) 118 | jmp delchr ; make delete look like backspace 119 | jmp clrtop ; erase screen and go home 120 | ; 121 | ; these routines are called to display a field on the screen. 122 | jmp scrend ; move to prompt field 123 | jmp screrr ; move to error message field 124 | jmp scrfln ; move to filename field 125 | jmp scrnp ; move to packet count field 126 | jmp scrnrt ; move to retry count field 127 | jmp scrst ; move to status field 128 | jmp rppos ; move to receive packet field (debug) 129 | jmp sppos ; move to send packet field (debug) 130 | ; 131 | jmp sysinit ; program initialization 132 | jmp sysexit ; program termination 133 | jmp syscon ; remote session initialization 134 | jmp syscls ; return to local command level 135 | jmp sysinh ; help text for interrupt (escape) extensions 136 | jmp sysint ; interrupt (escape) extensions, including break 137 | jmp sysflt ; filter for incoming characters. 138 | ; called with character in E. 139 | jmp sysbye ; terminate remote session 140 | jmp sysspd ; baud rate change routine. 141 | ; called with value from table in DE 142 | jmp sysprt ; port change routine. 143 | ; called with value from table in HL 144 | jmp sysscr ; screen setup for file transfer 145 | ; called with Kermit's version string in DE 146 | jmp csrpos ; move cursor to row B, column C 147 | jmp sysspc ; calculate free space for current drive 148 | jmp mover ; do block move 149 | jmp prtstr ; *** NEW *** Link from system indep equivalent 150 | ; 151 | ; Local parameter values 152 | ; 153 | pttab: dw ttab ; points to local equivalents to VT52 escape sequences 154 | spdtab: dw spdtbl ; address of baud rate command table, or zero 155 | spdhlp: dw sphtbl ; address of baud rate help table, or zero 156 | prttab: dw prttbl ; address of port command table, or zero 157 | prthlp: dw prhtbl ; address of port help table, or zero 158 | timout: dw fuzval ; Fuzzy timeout. 159 | vtflg: db vtval ; VT52 emulation flag 160 | escchr: db defesc ; Storage for the escape character. 161 | speed: dw 0FFFFH ; storage for the baud rate (initially unknown) 162 | port: dw 0FFFFH ; storage for port value (initially unknown) [hh] 163 | prnflg: db 0 ; printer copy flag [hh] 164 | dbgflg: db 0 ; debugging flag 165 | ecoflg: db 0 ; Local echo flag (default off). 166 | flwflg: db 1 ; File warning flag (default on). 167 | ibmflg: db 0 ; IBM flag (default off). 168 | cpmflg: db 0 ;[bt] file-mode flag (default is DEFAULT) 169 | incflg: db 0 ;[MF]incomplete-file flag (default is DISCARD) 170 | parity: db defpar ; Parity. 171 | spsiz: db dspsiz ; Send packet size. 172 | rpsiz: db drpsiz ; Receive packet size. 173 | stime: db dstime ; Send time out. 174 | rtime: db drtime ; Receive time out. 175 | spad: db dspad ; Send padding. 176 | rpad: db drpad ; Receive padding. 177 | spadch: db dspadc ; Send padding char. 178 | rpadch: db drpadc ; Receive padding char. 179 | seol: db dseol ; Send EOL char. 180 | reol: db dreol ; Receive EOL char. 181 | squote: db dsquot ; Send quote char. 182 | rquote: db drquot ; Receive quote char. 183 | chktyp: db dschkt ; Checksum type desired 184 | tacflg: ; TACtrap status: 185 | IF tac 186 | db tacval ; when non-zero, is current TAC intercept character; 187 | ENDIF;tac 188 | IF NOT tac 189 | db 0 ; when zero, TACtrap is off. 190 | ENDIF;tac 191 | tacchr: db tacval ; Desired TAC intercept character (even when off) 192 | bufadr: dw buff ; Address of possibly multi-sector buffer for I/O 193 | bufsec: db 1 ; Number of sectors big buffer can hold (0 means 256) 194 | ffussy: db 1 ; if nonzero, don't permit <>.,;?*[] in CP/M filespec. 195 | ; space used by directory command; here because space calculation is 196 | ; (operating) system-dependent 197 | bmax: ds 2 ; highest block number on drive 198 | bmask: ds 1 ; (records/block)-1 199 | bshiftf: ds 1 ; number of shifts to multiply by rec/block 200 | nnams: ds 1 ; counter for filenames per line 201 | 202 | lnksiz equ $-lnkflg ; length of linkage section, for consistency check. 203 | 204 | IF lasm ; If we're assembling with LASM, 205 | LINK CPXCOM ; get the next section. 206 | ENDIF;lasm 207 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxmrl.asm: -------------------------------------------------------------------------------- 1 | IF NOT lasm 2 | .printx * CPXMRL.ASM * 3 | ENDIF ; NOT lasm 4 | ; KERMIT - (Celtic for "FREE") 5 | ; 6 | ; This is the CP/M-80 implementation of the Columbia University 7 | ; KERMIT file transfer protocol. 8 | ; 9 | ; Version 4.0 10 | ; 11 | ; Copyright June 1981,1982,1983,1984,1985 12 | ; Columbia University 13 | ; 14 | ; Originally written by Bill Catchings of the Columbia University Center for 15 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 16 | ; 17 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 18 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 19 | ; others. 20 | ; 21 | ; CPXMRL.ASM created 16 July, 1987 from submitted code by William Rose. 22 | ; 23 | ; Kermit system dependent file for Rair Black Box (British Telecom 24 | ; Merlin, ICL PC etc) originally submitted by William Rose, and 25 | ; modified by OBSchou to work with the Kermit-80 V4.08 and later 26 | ; files. Wills original overlay file a stripped down CPXSYS.ASM 27 | ; file. 28 | ; 29 | ; KERSYS.ASM - version 0.6A dated 17 Jun 87. 30 | ; 31 | ; Cutdown CP4SYS.ASM for Telecom Merlin M2215 only. (ICL PC, Rair Black Box) 32 | ; 33 | ; This uses TTY1: only, and cannot alter it's parameters. It resets the 34 | ; interrupt flag to prevent use of the buffer, and is generally a kludge. 35 | ; However it runs at 4800 baud, and tidying the code might get 9600. 36 | ; 37 | ; Revision History (Last entry first) 38 | ; 39 | ; edit 2, 22 July by OBSchou to massage frile to fit with CPXCOM.ASM 40 | ; 41 | ; edit 1, 17 July by OBSchou for Will Rose, to make file suitable for V4.08 42 | ; overlay etc. 43 | ; 44 | ; Keep module name, edit number, and last revision date in memory. 45 | ; 46 | family: db 'CPXMRL.ASM (2) 22-Jun-87 $' ; Telecom Merlin added 47 | 48 | ; 49 | ; Assembly time message to let me know I'm building the right version. 50 | ; 51 | 52 | IF m2215 53 | .printx * Assembling Kermit-80 for Merlin M2215 * 54 | ENDIF 55 | 56 | IF m2215 ;equates removed because interrupts stopped port access 57 | ;iobase equ 14h ; base address of TTY1 58 | ;mnport equ iobase ; rx and tx data ports 59 | ;mnprts equ iobase+1 ; status port 60 | ;mnmode equ iobase+2 ; mode port 61 | ;mncmd equ iobase+3 ; PCI command port 62 | ;txrdy equ 1 ; tx ready bit set if free 63 | ;output equ txrdy 64 | ;rxrdy equ 2 ; RX ready bit 65 | ;input equ rxrdy 66 | z80 equ false ; For Merlin M2215 67 | ENDIF 68 | 69 | 70 | sysxin: ; Continue system initialisation fro sysinit 71 | 72 | IF FALSE ; unable to penetrate the 8085 interrupts 73 | in mncmd ; clear command register counter 74 | mvi a,4eh ; 0100$1110 - 1 stop bit, 8 data bits, 75 | ; / by 16 counter 76 | out mnmode 77 | mvi a,30h+7 ; 0011$0000 - select internal rate generator 78 | ; use 1200 baud by default 79 | out mnmode 80 | mvi a,27h ; 0010$0111 - enable tx and rx, RTS and DTR low 81 | out mncmd 82 | mvi h, 12 83 | mvi l, 12 84 | shld speed ; to show its been set up 85 | 86 | ENDIF 87 | 88 | ret 89 | 90 | porbuf: ds 3 ; original port settings 91 | 92 | ; 93 | ; system-dependent KERMIT termination processing 94 | ; If we've changed anything, this is our last chance to put it back. 95 | ; 96 | sysexit: 97 | ret 98 | 99 | ; 100 | ; system-dependent processing for start of CONNECT command 101 | ; 102 | syscon: 103 | ret 104 | 105 | conmsg: ; Messages printed when entering transparent (CONNECT) mode: 106 | 107 | db '$' 108 | 109 | ; 110 | ; syscls - system-dependent close routine 111 | ; called when exiting transparent session. 112 | ; 113 | syscls: 114 | ret 115 | 116 | ; 117 | ; sysinh - help for system-dependent special functions. 118 | ; called in response to ?, after listing all the 119 | ; system-independent escape sequences. 120 | ; 121 | sysinh: 122 | ; still can't pentrate interrupts 123 | ret 124 | 125 | ; Additional, system-dependent help for transparent mode 126 | ; (two-character escape sequences) 127 | ; 128 | inhlps: 129 | 130 | IF m2215 131 | db cr, lf, 'B Transmit a BREAK' 132 | ENDIF 133 | 134 | db '$' ; string terminator 135 | 136 | ; 137 | ; sysint - system dependent special functions 138 | ; called when transparent escape character has been typed; 139 | ; the second character of the sequence is in A (and in B). 140 | ; returns: 141 | ; non-skip: sequence has been processed 142 | ; skip: seqence was not recognized 143 | ; 144 | sysint: ani 137O ; convert lower case to upper, for testing... 145 | 146 | IF FALSE ; as always 147 | cpi 'B' ; send break ? 148 | jz sendbr 149 | ENDIF 150 | jmp rskp ; take skip return - command not recognised 151 | 152 | ; Actual commands 153 | 154 | IF FALSE ;as always 155 | sendbr: 156 | in mnprts 157 | ani 04h ; make sure shift reg is clear 158 | jz sendbr 159 | 160 | mvi a,2fh ; set for a break 161 | out mncmd 162 | mvi a,100 ; wait a bit 163 | call delay 164 | mvi a,27h ; restore mode 165 | out mncmd 166 | 167 | ret 168 | ENDIF 169 | 170 | ret 171 | 172 | ; 173 | ; sysflt - system-dependent filter 174 | ; called with character in E. 175 | ; if this character should not be printed, return with A = zero. 176 | ; preserves bc, de, hl. 177 | ; note: ,,, and are always discarded. 178 | ; 179 | sysflt: 180 | mov a,e ; get character for testing 181 | ret 182 | 183 | ; 184 | ; mdmflt - modem filter 185 | ; called with character to be sent to printer in E 186 | ; with parity set as appropriate. 187 | ; return with accumulator = 0 do do nothing, 188 | ; <> 0 to send char in E. 189 | mdmflt: 190 | mov a,e ; get character to test 191 | ret 192 | 193 | ; 194 | ; prtflt - printer filter 195 | ; called with character to be sent to printer in E 196 | ; returns with a = 0 to do nothing 197 | ; a <> 0 to print it. 198 | ; 199 | ; this routine for those printer that automatically insert 200 | ; a lf on cr, or cr for lf. Should this be shifted to 201 | ; the system indep. stuff, in say 4.06? 202 | ; 203 | prtflt: 204 | mov a,e ; get character to test 205 | 206 | IF FALSE ; strip out lf from printer stream 207 | ani 7fh ; make sure it is parity less 208 | cpi lf ; is it a line feed? 209 | rnz ; no, print it 210 | ; xra a ; yes, don't. 211 | 212 | ENDIF 213 | 214 | ret 215 | 216 | ; 217 | ; system-dependent processing for BYE command. 218 | ; 219 | sysbye: 220 | ret 221 | 222 | ; 223 | ; This is the system-dependent command to change the baud rate. 224 | ; DE contains the two-byte value from the baud rate table; both 225 | ; bytes of this value are also stored in 'speed'. 226 | ; 227 | sysspd: 228 | 229 | IF FALSE ; as always 230 | in mncmd ; clear register counter 231 | mvi a,4eh ; set for 1 stop, 8 data bits 232 | out mnmode ; save in mode 1 port 233 | mvi a,30h ; set bits for rate etc.. 234 | add e ; add baud rate (bits 0 - 3) 235 | out mnmode ; set mode port 2 236 | mvi a,27h ; set tx/rx ready, RTS CTS active 237 | out mncmd 238 | ret 239 | ENDIF 240 | ret ; if routine not supported 241 | ; 242 | ; Speed tables 243 | ; (Note that speed tables MUST be in alphabetical order for later 244 | ; lookup procedures, and must begin with a value showing the total 245 | ; number of entries. The speed help tables are just for us poor 246 | ; humans. 247 | ; 248 | ; db string length, string, divisor (2 bytes or 1 word, ab) 249 | ; the data byte a is return in A and E, and b in D 250 | ; only byte 'a' is the key for the table 251 | 252 | IF FALSE ; as always 253 | spdtbl: db 16 ; sixteen entries for PCI 254 | db 3,'110$', 2,2 255 | db 4,'1200$', 7,7 256 | db 3,'134$', 3,3 257 | db 3,'150$', 4,4 258 | db 4,'1800$', 8,8 259 | db 5,'19200$', 15,15 260 | db 4,'2000$', 9,9 261 | db 4,'2400$', 10,10 262 | db 3,'300$', 5,5 263 | db 4,'3600$', 11,11 264 | db 4,'4800$', 12,12 265 | db 2,'50$', 0,0 266 | db 3,'600$', 6,6 267 | db 4,'7200$', 13,13 268 | db 2,'75$', 1,1 269 | db 4,'9600$', 14,14 270 | 271 | sphtbl: db ' 50 75 110 134 150 300 600 1200 ' 272 | db cr,lf,'1800 2000 2400 3600 4800 7200 9600 19200$' 273 | ENDIF 274 | 275 | IF m2215 276 | spdtbl equ 0 ; routine unsupported 277 | sphtbl equ 0 278 | ENDIF 279 | 280 | ; 281 | ; This is the system-dependent SET PORT command. 282 | ; HL contains the argument from the command table. 283 | ; 284 | sysprt: 285 | 286 | IF m2215 287 | prttbl equ 0 ; SET PORT is not supported 288 | prhtbl equ 0 ; Merlin M2215 could, I suppose 289 | ENDIF 290 | 291 | ; 292 | ; selmdm - select modem port 293 | ; selcon - select console port 294 | ; selmdm is called before using inpmdm or outmdm; 295 | ; selcon is called before using inpcon or outcon. 296 | ; For iobyt systems, diddle the I/O byte to select console or comm port; 297 | ; For the rest, does nothing. 298 | ; preserves bc, de, hl. 299 | ; 300 | selmdm: 301 | ret 302 | 303 | selcon: 304 | ret 305 | 306 | ; 307 | ; Get character from console, or return zero. 308 | ; result is returned in A. destroys bc, de, hl. 309 | ; 310 | inpcon: 311 | call 0f55dh ;CONST BIOS vector 312 | ora a ;set flags 313 | rz 314 | call 0f56eh ;CONIN BIOS vector 315 | ret 316 | 317 | ; 318 | ; Output character in E to the console. 319 | ; destroys bc, de, hl 320 | ; 321 | outcon: 322 | mov c, e 323 | call 0f57fh ;CONOUT BIOS vector 324 | ret 325 | 326 | ; 327 | ; outmdm - output a char from E to the modem. 328 | ; the parity bit has been set as necessary. 329 | ; returns nonskip; bc, de, hl preserved. 330 | ; 331 | outmdm: 332 | 333 | IF m2215 334 | push psw 335 | push h 336 | push d 337 | push b 338 | 339 | mov c, e 340 | mvi a, 1 ; ie: tty1: 341 | mov d, a 342 | call 0f6a2h ;PUN BIOS vector 343 | 344 | pop b 345 | pop d 346 | pop h 347 | pop psw 348 | ENDIF 349 | 350 | ret 351 | 352 | ; 353 | ; for IOBYT systems, the modem port has already been selected. 354 | ; destroys bc, de, hl. 355 | ; 356 | inpmdm: 357 | 358 | IF m2215 359 | ; check status 360 | lda 0fa32h ; ie. tty1: 361 | ora a 362 | rz 363 | 364 | mvi a, 1 ; RDR BIOS vector 365 | mov d, a 366 | call 0f651h 367 | ; ani 7fh 368 | 369 | push a 370 | di 371 | mvi a, 0 372 | sta 0fa32h ; remove interrupt flag 373 | sta 0f2d3h ; zero buffer counter 374 | lda 0f2d4h 375 | sta 0f2d5h 376 | ei 377 | nop 378 | pop a 379 | 380 | ret 381 | ENDIF 382 | 383 | ; 384 | ; flsmdm - flush comm line. 385 | ; Modem is selected. 386 | ; Currently, just gets characters until none are available. 387 | ; 388 | flsmdm: 389 | 390 | call inpmdm ; Try to get a character 391 | ora a ; Got one? 392 | jnz flsmdm ; If so, try for another 393 | ret ; Receiver is drained. Return. 394 | 395 | 396 | ; 397 | 398 | ; 399 | ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not. 400 | lptstat: 401 | IF iobyte ;[33] 402 | call bprtst ; get status 403 | ENDIF ;iobyte[33] 404 | 405 | IF NOT iobyte ;[33] 406 | xra a ; assume it is ok.. this may not be necessary 407 | ENDIF ;iobyte [33] 408 | ret 409 | ; 410 | ; outlpt - output character in E to printer 411 | ; console is selected. 412 | ; preserves de. 413 | ; 414 | outlpt: 415 | push d ; save DE in either case 416 | call prtflt ; go through printer filter [30] 417 | ana a ; if A = 0 do nothing, 418 | jz outlp1 ; if a=0 do nothing 419 | 420 | outlp1: pop d ; restore saved register pair 421 | ret 422 | 423 | ; delchr - make delete look like a backspace. Unless delete is a printing 424 | ; character, we just need to print a backspace. (we'll output clrspc 425 | ; afterwards) 426 | delchr: 427 | 428 | mvi e,bs ;get a backspace 429 | jmp outcon 430 | 431 | ; erase the character at the current cursor position 432 | clrspc: mvi e,' ' 433 | call outcon 434 | mvi e,bs ;get a backspace 435 | jmp outcon 436 | 437 | ; erase the current line 438 | clrlin: lxi d,eralin 439 | jmp prtstr 440 | 441 | ; erase the whole screen, and go home. preserves b (but not c) 442 | clrtop: lxi d,erascr 443 | jmp prtstr 444 | 445 | 446 | IF m2215 447 | sysver: db 'BT Merlin M2215, port TTY1:, settings unchanged.$' 448 | ENDIF 449 | 450 | tstmsg: db 'Test message',cr,lf,'$' 451 | 452 | IF lasm 453 | LINK CPXVDU.ASM ; link to the Terminal definition tables 454 | ENDIF ;lasm 455 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxswt.asm: -------------------------------------------------------------------------------- 1 | IF NOT lasm 2 | .printx * CPXSWT.ASM * 3 | ENDIF ; NOT lasm 4 | ; KERMIT - (Celtic for "FREE") 5 | ; 6 | ; This is the CP/M-80 implementation of the Columbia University 7 | ; KERMIT file transfer protocol. 8 | ; 9 | ; Version 4.0 10 | ; 11 | ; Copyright June 1981,1982,1983,1984,1985 12 | ; Columbia University 13 | ; 14 | ; Originally written by Bill Catchings of the Columbia University Center for 15 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 16 | ; 17 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 18 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 19 | ; others. 20 | ; 21 | ; This file is a simple family or system file switcher, selecting 22 | ; one of several family files, or selectin CPXSYS.ASM (now modified) 23 | ; if a family file does not exist. 24 | ; 25 | ; 26 | ; revision history: 27 | ; 28 | ;edit 10, 7-Jan-1991 by MF. Added code by Jay S. Rouman to support the 29 | ; Ampro Little Board (see CPXBBI.ASM) and PRINTX for the HP-125. 30 | ; edit 9, 1st September 1990 by Russell Lang, rjl@monu1.cc.monash.edu.au. 31 | ; Added Microbee support. 32 | ; edit 8, 2 December by OBSchou. Added Z80MU "system" to allow kermit-80 33 | ; debugging on a PC! 34 | ; 35 | ; edit 7, 27 October, 1987 by OBSchou. Added bits for Sanyo, Compupro, 36 | ; Genie and TRS-80 M4. 37 | ; 38 | ; edit 6, 16 July, 1987 for Will Rose, who has submitted code for 39 | ; Micromint SB180 (6 and 9 Mhz) and a BT Merlin (alias RAIR) 40 | ; 41 | ; edit 5, 15 July, 1987 by OBSchou for David Moore, who has submitted 42 | ; code for a Teletek SYSTEMASTER and for ADM22 terminals. 43 | ; 44 | ; edit 4, 14 July 1987 by OBSchou for JA Shearwood of Birmingham University, 45 | ; Chris Miles of Manchester University. Added a Cifer family file 46 | ; for John, and added a BigBoard-Kaypro-Xerox family file for Chris 47 | ; Finally, added in new family file for Heath, telcon, z100 and scntpr 48 | ; systems for Martin Carter of Nottingham University. 49 | ; 50 | ; edit 3, 6 April, 1986 by OBSchou. 51 | ; Added in switching for NCR Desision Mate V and Amstrad CPC 664/6128 52 | ; systems. 53 | ; 54 | ; edit 2, March 16, 1987 by OBSchou. 55 | ; added in support for m80 macro assembler. 56 | ; 57 | ; edit 1 28 January, 1987 by OBSchou. 58 | ; Take out the series of printx etx and selection of systems and 59 | ; leave this with only the system dep. code for systems without 60 | ; a family file. Hopefully, this file will go alltogether in time. 61 | ; 62 | ; Keep module name, edit number, and last revision date in memory. 63 | swtver: db 'CPXSWT.ASM (10) 7-Jan-1991 $' 64 | ; 65 | ; Assembly time message to let me know I'm building the right version. 66 | ; LASM generates an 'S' error along with the message, which is messy, but 67 | ; better than trying to put everything inside a IF m80 OR mac80 conditional, 68 | ; because LASM doesn't like nested IF's, either. 69 | 70 | 71 | IF (torfam AND lasm) 72 | ;Link to the module with the code for Superbrains, Torch, Cifer and pci2651 73 | LINK CPXTOR.ASM ; also NCR DMV systems 74 | ENDIF;(torfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 75 | 76 | IF (ciffam AND LASM) 77 | ; Link to the Cifer family file. (Cifer code previously on CPXTOR.ASM) 78 | LINK CPXCIF.ASM ; Cifer family file 79 | ENDIF ;(ciffam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 80 | 81 | IF (appfam AND lasm) ;[33] apple frogs as a separate family.. 82 | ; Link to the APPLE family... 83 | LINK CPXAPP.ASM 84 | ENDIF ;(appfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 85 | 86 | IF (norfam AND lasm); Link to the Northstar family (and Comart) 87 | ; Link to the NorthStar family file 88 | LINK CPXNOR.ASM 89 | ENDIF; (norfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 90 | 91 | IF (pcwfam AND lasm) ;[35] Amstrad PCW 8256/8512 or CPC systems 92 | ; Link to the Amstrad PCW family 93 | LINK CPXPCW.ASM 94 | ENDIF ;(cpwfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 95 | 96 | IF (bbifam AND lasm) ;Bigboard, Kaypro and Xerox 820 file 97 | ; Link to the Bigboard family 98 | .printx * Linking to the BigBoard family * 99 | LINK CPXBBI.ASM 100 | ENDIF ;(bbifam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 101 | 102 | IF (heafam AND lasm) ; heath, z100, telcon, and scntpr systems 103 | ; Link to the Heath-telcon-screentyper family 104 | .printx * Linking to the Heath-telcon-screentyper family * 105 | LINK CPXHEA.ASM 106 | ENDIF ;(heafam) - m80 use: INCLUDE from CPXTYP.ASM 107 | 108 | IF (sbfam AND lasm) 109 | ; Link to the SB180 Family file 110 | ,printx * Linking to the SB180 Family file * 111 | LINK CPXSB.ASM 112 | ENDIF ; (sbfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 113 | 114 | IF (m2215 AND lasm) 115 | ; Link to the RAIR/ BT Merlin code 116 | .printx * Linking to the Merlin/Rair code * 117 | LINK CPXMRL.ASM 118 | ENDIF ; (m2215 AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 119 | 120 | IF (sanfam AND lasm) 121 | ; Link to the Sanyo code 122 | .printx * linking to the sanyo code * 123 | LINK CPXSYO.ASM 124 | ENDIF ; (sanfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 125 | 126 | IF (comfam AND lasm) 127 | ; Link to the compupro code 128 | .printx * linking to the Compupro code * 129 | LINK CPXPRO.ASM 130 | ENDIF ; (comfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 131 | 132 | IF (genfam AND lasm) 133 | ; Link to the Genie family code 134 | .printx * linking to the Genie code * 135 | LINK CPXGNI.ASM 136 | ENDIF ; (genfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 137 | 138 | IF (trsfam AND lasm) 139 | ; Link to the TRS-80 family file 140 | .printx * linking to the TRS family file* 141 | LINK CPXTM4.ASM 142 | ENDIF ; (trsfam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 143 | 144 | IF (z80fam AND lasm) 145 | ; Link to the Z80MU family file 146 | .printx * linking to the Z80MU family file* 147 | LINK CPXZ80.ASM 148 | ENDIF ; (z80fam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 149 | 150 | IF (beefam AND lasm) 151 | ; Link to the Microbee family file 152 | .printx * linking to the Microbee family file * 153 | LINK CPXBEE.ASM 154 | ENDIF ; (beefam AND lasm) - m80 use: INCLUDE from CPXTYP.ASM 155 | 156 | 157 | ; If we have come here, we are assembling the CPXSYS.ASM file 158 | 159 | IF robin 160 | .printx * Assembling KERMIT-80 for the DEC VT180 * 161 | ENDIF 162 | 163 | IF vector 164 | .printx * Assembling KERMIT-80 for the Vector Graphics * 165 | ENDIF 166 | 167 | IF osi 168 | .printx * Assembling KERMIT-80 for the Ohio Scientific * 169 | ENDIF 170 | 171 | IF heath 172 | .printx * Assembling KERMIT-80 for the Heath/Zenith 89 * 173 | ENDIF 174 | 175 | IF z100 176 | .printx * Assembling KERMIT-80 for the Heath/Zenith Z100 * 177 | ENDIF 178 | 179 | IF trs80 180 | .printx * Assembling KERMIT-80 for the TRS-80 II * 181 | ENDIF 182 | 183 | IF osbrn1 184 | .printx * Assembling KERMIT-80 for the Osborne 1 * 185 | ENDIF 186 | 187 | IF telcon 188 | .printx * Assembling KERMIT-80 for the Telcon Zorba * 189 | ENDIF 190 | 191 | IF dmII 192 | .printx * Assembling KERMIT-80 for the DECmate II * 193 | ENDIF 194 | 195 | IF gener 196 | .printx * Assembling Generic KERMIT-80 * 197 | ENDIF 198 | 199 | IF cpm3 200 | .printx * Assembling Generic KERMIT-80 for CP/M 3.0 * 201 | ENDIF 202 | 203 | IF hp125 204 | .printx * Assembling Kermit-80 for the HP-125 Series 100 * 205 | ENDIF ;hp125 206 | 207 | IF kpii 208 | .printx * Assembling Kaypro II KERMIT-80 * 209 | ENDIF 210 | 211 | IF xer820 ;[pcc001] 212 | .printx * Assembling Xerox 820 KERMIT-80 * 213 | ENDIF ;[pcc001] 214 | 215 | IF bbII 216 | .printx * Assembling BigBoard II KERMIT-80 * 217 | ENDIF 218 | 219 | IF ampro 220 | .printx * Assembling Ampro Little Board KERMIT-80 * 221 | ENDIF 222 | 223 | IF mdI 224 | .printx * Assembling for Morrow Decision I * 225 | ENDIF ;mdI [Toad Hall] 226 | 227 | IF mmdI 228 | .printx * Assembling for Morrow Micro Decision I * 229 | ENDIF ;mmdI 230 | 231 | IF mikko 232 | .printx * Assembling MikroMikko Kermit-80 * 233 | ENDIF 234 | 235 | IF delphi ;[7] 236 | .printx * Assembling Digicomp Delphi 100 Kermit-80 * 237 | ENDIF ;[7] 238 | 239 | IF cpt85xx 240 | .printx * Assembling CPT-85xx (under CompuPak CP/M) Kermit-80 * 241 | ENDIF 242 | 243 | IF cmemco ;[25] 244 | .printx * Assembling KERMIT-80 for the Cromemco (TU-ART) * 245 | ENDIF;cmemco 246 | 247 | IF bbc ;[22] 248 | .printx * Assembling Kermit-80 for BBC with Z80 co-processor * 249 | ENDIF ;[22] 250 | 251 | IF rm380z ;[22] 252 | .printx * Assembling Kermit-80 for Research Machines 380Z * 253 | ENDIF ;[22] 254 | 255 | IF px8 ;[29] 256 | .printx * Assembling Kermit-80 for Epson PX-8 * 257 | ENDIF ;px8 [29] 258 | 259 | IF mmate ;[29] 260 | .printx * Assembling KERMIT-80 for the PMC MicroMate * 261 | ENDIF ;mmate [29] 262 | 263 | IF disc ;[29] 264 | .printx * Assembling KERMIT-80 for the A. C. E. Discovery * 265 | ENDIF ;disc [29] 266 | 267 | IF s1008 ;[29] 268 | .printx * Assembling KERMIT-80 for the MicroSales s1008 * 269 | ENDIF ;s1008 [29] 270 | 271 | IF access ;[29] 272 | .printx * Assembling Kermit-80 for the ACCESS-MATRIX computer * 273 | ENDIF ;access [29] 274 | 275 | IF lobo ;[hh] 276 | .printx * Assembling Kermit-80 for the Lobo MAX-80 * 277 | ENDIF;lobo [hh] 278 | 279 | IF teletek 280 | .printx * Assembling Kermit-80 for the Teletek * 281 | ENDIF ;teletek 282 | 283 | ; 284 | ; 285 | ; If here, we have not linked to a family, so link to CPXSYS.ASM 286 | IF lasm 287 | LINK CPXSYS.ASM 288 | ENDIF ;lasm 289 | ; 290 | ; If we are using m80, then the CPXSYS.ASM file will be INCLUDED from CPXTYP 291 | ; 292 | 293 | 294 | 295 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxsyo.asm: -------------------------------------------------------------------------------- 1 | IF NOT lasm 2 | .printx * CPXSYO.ASM * 3 | ENDIF ;NOT lasm 4 | ; KERMIT - (Celtic for "FREE") 5 | ; 6 | ; This is the CP/M-80 implementation of the Columbia University 7 | ; KERMIT file transfer protocol. 8 | ; 9 | ; Version 4.0 10 | ; 11 | ; Copyright June 1981,1982,1983,1984,1985 12 | ; Columbia University 13 | ; 14 | ; Originally written by Bill Catchings of the Columbia University Center for 15 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 16 | ; 17 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 18 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 19 | ; others. 20 | ; 21 | ; This file contains the system dependent part for Sanyo MBC 1100 22 | ; systems, and has been extracted from the CPMSYO.ASM code (kermit 23 | ; version 3.5) 24 | ; 25 | ; revision history: 26 | ; 27 | ; edit 1, 27 October, 1987, by OBSchou. Extracted Sanyo code from CPMSYO.ASM 28 | ; and massaged fort CP/M kermit V4.09 29 | ; 30 | ; Keep module name, edit number, and last revision date in memory. 31 | family: db 'CPXSYO.ASM (1) 27-Oct-87 $' 32 | ; 33 | 34 | ; Assembly time message to let me know I'm building the right version. 35 | ; LASM generates an 'S' error along with the message, which is messy, but 36 | ; better than trying to put everything inside a IF m80 OR mac80 conditional, 37 | ; because LASM doesn't like nested IF's, either. 38 | 39 | IF sanyo 40 | .printx * Assembling Kermit-80 for Sanyo MBC 1100 * 41 | ENDIF 42 | 43 | iobyte EQU 03H ;Location of I/O byte 44 | 45 | if sanyo 46 | baudrt EQU 0DAH ;BAUD RATE MEMORY LOCATION 47 | MNPORT EQU 0DCH ;COMMUNICATIONS PORT 48 | MNPRTS EQU 0DDH ;COMMUNICATIONS PORT STATUS 49 | OUTPUT EQU 01H ;OUTPUT READY BIT 50 | INPUT EQU 02H ;INPUT READY BIT 51 | ENDIF;SANYO 52 | 53 | defesc EQU '\'-100O ;The default escape character. 54 | 55 | ; Select initial setting for VT-52 emulation flag. 56 | vtval EQU 1 57 | 58 | 59 | sysxin: ;system initialisation not covered by sysinit 60 | ret ; return from system-dependent routine 61 | 62 | ; 63 | 64 | ; 65 | ; system-dependent termination processing 66 | ; If we've changed anything, this is our last chance to put it back. 67 | sysexit: 68 | ret 69 | 70 | ; 71 | ; system-dependent processing for start of CONNECT command 72 | ; 73 | syscon: 74 | ret 75 | 76 | ; 77 | 78 | ; 79 | ; syscls - system-dependent close routine 80 | ; called when exiting transparent session. 81 | ; 82 | syscls: 83 | ret 84 | ; 85 | 86 | ; 87 | ; sysinh - help for system-dependent special functions. 88 | ; called in response to ?, after listing all the 89 | ; system-independent escape sequences. 90 | ; 91 | sysinh: 92 | lxi d,inhlps ; we got options... 93 | call prtstr ; print them. 94 | ret 95 | inhlps: 96 | db '$' ;[hh] table terminator 97 | 98 | ; 99 | ; sysint - system dependent special functions 100 | ; called when transparent escape character has been typed; 101 | ; the second character of the sequence is in A (and in B). 102 | ; returns: 103 | ; non-skip: sequence has been processed 104 | ; skip: sequence was not recognized 105 | sysint: 106 | ani 137O ; convert lower case to upper, for testing... 107 | ret 108 | 109 | ; sysflt - system-dependent filter. 110 | ; called with the character in E. 111 | ; preserves bc, de, hl. 112 | ; note: ,,, and are always discarded. 113 | sysflt: 114 | mov a,e ; get character for testing 115 | ret 116 | 117 | ; mdmflt - modem filter [30] 118 | ; called with character to be sent to printer in E 119 | ; with parity set as appropriate. 120 | ; return with accumulator = 0 do do nothing, 121 | ; <> 0 to send char in E. 122 | mdmflt: 123 | mov a,e ;[30] get character to test 124 | ret 125 | 126 | 127 | ; prtflt - printer filter [30] 128 | ; called with character to be sent to printer in E 129 | ; returns with a = 0 to do nothing 130 | ; a <> 0 to print it. 131 | ; 132 | ; this routine for those printer that automatically insert 133 | ; a lf on cr, or cr for lf. Should this be shifted to 134 | ; the system indep. stuff, in say 4.06? 135 | prtflt: 136 | mov a,e ; [30] get character to test 137 | ret 138 | 139 | 140 | ; 141 | 142 | ; 143 | ; system-dependent processing for BYE command. 144 | ; for apmmdm, heath, and lobo, hang up the phone. 145 | sysbye: 146 | ret 147 | ; 148 | 149 | ; This is the system-dependent command to change the baud rate. 150 | ; DE contains the two-byte value from the baud rate table; this 151 | ; value is also stored in 'speed'. 152 | sysspd: 153 | ret 154 | 155 | ; 156 | 157 | ; Speed tables 158 | ; (Note that speed tables MUST be in alphabetical order for later 159 | ; lookup procedures, and must begin with a value showing the total 160 | ; number of entries. The speed help tables are just for us poor 161 | ; humans. 162 | 163 | ; db string length,string,divisor (2 identical bytes or 1 word) 164 | ; [Toad Hall] 165 | 166 | IF sanyo 167 | spdtbl EQU 0 ; No speed table for the Sanyo 168 | sphtbl EQU 0 ; ditto help for speed. 169 | 170 | ; The following conditionals were once a huge if not statement. There 171 | ; wasn't enough room to add the lobo to the list, so it had to be broken 172 | ; into 2, which you can't do with an if not. I redid it as two ifs and 173 | ; applied them to those that wouldn't set baud. [Hal Hostetler] 174 | ; 175 | 176 | ; This is the system-dependent SET PORT command. 177 | ; HL contains the argument from the command table. 178 | sysprt: 179 | ret 180 | ; 181 | 182 | ; 183 | ; Port table not applicable tot he Sanyo... 184 | prttbl EQU 0 185 | prhtbl EQU 0 ; 186 | 187 | ; 188 | 189 | ; 190 | ; selmdm - select modem port 191 | ; selcon - select console port 192 | ; selmdm is called before using inpmdm or outmdm; 193 | ; selcon is called before using inpcon or outcon. 194 | ; For iobyt systems, diddle the I/O byte to select console or comm port; 195 | ; For Decision I, switches Multi I/O board to console or modem serial 196 | ; port. [Toad Hall] 197 | ; For the rest, does nothing. 198 | ; preserves bc, de, hl. 199 | selmdm: 200 | ret 201 | 202 | selcon: 203 | ret 204 | ; 205 | 206 | ; Get character from console, or return zero. 207 | ; result is returned in A. destroys bc, de, hl. 208 | ; 209 | inpcon: 210 | mvi c,dconio ;Direct console I/O BDOS call. 211 | mvi e,0FFH ;Input. 212 | call BDOS 213 | ret 214 | ; 215 | 216 | ; 217 | ; Output character in E to the console. 218 | ; destroys bc, de, hl 219 | ; 220 | outcon: 221 | mvi c,dconio ;Console output bdos call. 222 | call bdos ;Output the char to the console. 223 | ret 224 | ; 225 | 226 | ; 227 | ; outmdm - output a char from E to the modem. 228 | ; the parity bit has been set as necessary. 229 | ; returns nonskip; bc, de, hl preserved. 230 | outmdm: 231 | IF inout 232 | in mnprts ;Get the output done flag. 233 | ani output ;Is it set? 234 | jz outmdm ;If not, loop until it is. 235 | mov a,e 236 | out mnport ;Output it. 237 | ret 238 | ENDIF;inout 239 | 240 | ; 241 | 242 | ; 243 | ; get character from modem; return zero if none available. 244 | ; for IOBYT systems, the modem port has already been selected. 245 | ; destroys bc, de, hl. 246 | inpmdm: 247 | IF inout 248 | ;Note: modem port should already be selected for mdI. [Toad Hall] 249 | in mnprts ;Get the port status into A. 250 | ani input ;See if the input ready bit is on. 251 | rz ;If not then return. 252 | in mnport ;If so, get the char. 253 | ENDIF;inout 254 | ret ; return with character in A 255 | 256 | 257 | ; 258 | ; flsmdm - flush comm line. 259 | ; Modem is selected. 260 | ; Currently, just gets characters until none are available. 261 | 262 | flsmdm: call inpmdm ; Try to get a character 263 | ora a ; Got one? 264 | jnz flsmdm ; If so, try for another 265 | ret ; Receiver is drained. Return. 266 | 267 | 268 | ; 269 | 270 | ; 271 | ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not. 272 | lptstat: 273 | xra a ; assume it is ok.. this may not be necessary 274 | ret 275 | ; 276 | 277 | ; 278 | ; outlpt - output character in E to printer 279 | ; console is selected. 280 | ; preserves de. 281 | outlpt: 282 | push d ; save DE in either case 283 | call prtflt ; go through printer filter [30] 284 | ana a ; if A = 0 do nothing, 285 | jz outlp1 ; [30] if a=0 do nothing 286 | mvi c,lstout 287 | call bdos ;Char to printer 288 | outlp1: pop d ; restore saved register pair 289 | ret 290 | ; 291 | 292 | ; 293 | ; Screen manipulation routines 294 | ; csrpos - move to row B, column C 295 | ; 296 | ; csrpos for terminals that use a leadin sequence followed 297 | ; by (row + 31.) and (column + 31.) 298 | ; 299 | csrpos: push b ; save coordinates 300 | lxi d,curldn ; get cursor leadin sequence 301 | call prtstr ; print it 302 | pop h ; restore coordinates 303 | mov a,h ; get row 304 | adi (' '-1) ; space is row one 305 | mov e,a 306 | push h 307 | call outcon ; output row 308 | pop h 309 | mov a,l ; get column 310 | adi (' '-1) ; space is column one 311 | mov e,a 312 | jmp outcon ; output it and return 313 | ENDIF;NOT (robin OR dmII OR osi OR vector OR termin) 314 | 315 | ret ; Can the Sany do cursor opsitioning?? 316 | 317 | ; 318 | ; 319 | ; delchr - make delete look like a backspace. Unless delete is a printing 320 | ; character, we just need to print a backspace. (we'll output clrspc 321 | ; afterwards) 322 | ; For Kaypro and Vector General, delete puts a blotch on the screen. 323 | ; For Apple and Osborne 1, delete moves but doesn't print. 324 | delchr: 325 | mvi e,bs 326 | call outcon 327 | 328 | ; erase the character at the current cursor position 329 | clrspc: mvi e,' ' 330 | call outcon 331 | mvi e,bs ;get a backspace 332 | jmp outcon 333 | 334 | ; erase the current line 335 | clrlin: lxi d,eralin 336 | jmp prtstr 337 | 338 | ; erase the whole screen, and go home. preserves b (but not c) 339 | clrtop: lxi d,erascr 340 | jmp prtstr 341 | 342 | 343 | 344 | IF SANYO 345 | outlin: DB ESC,'E',ESC,'H',CR,LF,TAB ;WHATEVER 346 | sysver: DB 'KERMIT-80 V3.9 [SANYO MBC-1100]',CR,LF,'$' ;VERSION HEADING 347 | DELSTR: DB ESC,'K','$' ;WHATS A STRING? 348 | eralin: DB ESC,'P','$' ;CLEAR SPACE 349 | ;CLRLIN: DB ESC,'K','$' ;CLEAR LINE 350 | erascr: DB ESC,'E',ESC,'H','$' ;CLEAR SCREEN AND CURSOR HOME 351 | curldn: db esc,'=','$',0 ;cursor lead in 352 | ;SCRNP: DB ESC,'=',24H,25H,'$' ;SPOT FOR SCREEN PACKETS 353 | ;SCRNRT: DB ESC,'=',25H,25H,'$' ;SPOT FOR # OF RETRIES 354 | ;SCRFLN: DB ESC,'=',26H,25H,'$' ;SPOT FOR FILE NAME 355 | ;SCRST: DB ESC,'=',28H,25H,'$' ;SPOT FOR STATUS 356 | ;SCREND: DB ESC,'=',2AH,25H,'$' ;SPOT FOR PROMPT 357 | ;SCRERR: DB ESC,'=',2DH,25H,'$' ;SPOT FOR ERRORS 358 | ttab: ;NO TRANSLATION TABLE 359 | ta: DB ESC,'A',0,0 ;CURSOR UP 360 | tb: DB ESC,'B',0,0 ;CURSOR DOWN 361 | tc: DB ESC,'D',0,0 ;CURSOR RIGHT 362 | td: DB ESC,'C',0,0 ;CURSOR LEFT 363 | te: DB ESC,'E',0,0 ;CLEAR SCREEN 364 | tf: DB 0,0,0,0 ;WHAT??? 365 | tg: DB 0,0,0,0 ;WHAT??? 366 | th: DB ESC,'H',0,0 ;CURSOR HOME 367 | ti: DB ESC,'A',ESC,'C',0,0 ;REVERSE LINEFEED?? 368 | tj: DB ESC,'J',0,0 ;CLEAR TO END OF SCREEN 369 | tk: DB ESC,'K',0,0 ;CLEAR TO END OF LINE 370 | ENDIF;SANYO 371 | 372 | ovlend equ $ ; End of overlay 373 | 374 | END 375 |  376 |  377 |  378 |  379 |  380 |  381 |  382 |  383 |  384 |  385 |  386 |  387 |  388 |  389 | 390 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxtm4.asm: -------------------------------------------------------------------------------- 1 | ;CPXTM4.ASM 2 | ; KERMIT - (Celtic for "FREE") 3 | ; 4 | ; This is the CP/M-80 implementation of the Columbia University 5 | ; KERMIT file transfer protocol. 6 | ; 7 | ; Version 4.0 8 | ; 9 | ; Copyright June 1981,1982,1983,1984,1985 10 | ; Columbia University 11 | ; 12 | ; Originally written by Bill Catchings of the Columbia University Center for 13 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 14 | ; 15 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 16 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 17 | ; others. 18 | ; 19 | ; This file contains the system-dependent code and data for various 20 | ; Tandy Model 4 running under Montezuma Micro CPM 21 | ; 22 | ; This has the Family name of CPXTM4.ASM. 23 | ; 24 | ; revision history (last edit first) 25 | ; 26 | ; edit 5, 8-Feb-1991 by Lance Tagliapietra of the University of Wisconsin- 27 | ; Platteville. Corrected error in the VT52 translation table for 28 | ; clearing from the cursor to the end of the line. 29 | ; 30 | ; edit 4, 27 October, 1987 by OBSchou. Massaged into format suitable 31 | ; for overlay version 4.09 32 | ; 33 | ; Edit 3: Sept 5 1987 GDS Transformed code from Genie III to Tandy Model 4 34 | ; 35 | ; Edit 2: Aug 27 1987 GDS Put in code for BREAK and fillited out 36 | ; a lot of unnecessary IF's 37 | ; 38 | ;Edit 1: Nov. 28, 1986 Geof Smith Clinical Research centre Harrow UK. 39 | 40 | 41 | .printx * Assembling for Tandy Model 4* 42 | ; 43 | drtime EQU 05H ;Default receive time out interval. 44 | ; 45 | ; the basics... 46 | ; 47 | mnport EQU 0EBH 48 | mnprts EQU 0EAH 49 | output EQU 40H 50 | input EQU 80H 51 | lctrl EQU 0E8H 52 | baudpt EQU 0E9H 53 | z80 EQU TRUE 54 | brkval EQU 0H 55 | inout EQU TRUE 56 | 57 | defesc EQU 'X'-100O ;The default escape character. 58 | 59 | 60 | ;Select initial setting for VT-52 emulation flag. 61 | 62 | ; default to VT52-EMULATION ON. 63 | ; 64 | vtval EQU 1 65 | ; 66 | ; 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | ; Family is the string used in VERSION to say which of several 77 | ; smaller overlay files are used. These are (will be) derived from 78 | ; the huge CP4SYS.ASM file, in which case we will never get here. 79 | ; Just a Dollar, but put a sting in for a family of machines. 80 | ; 81 | family: db 'CPXTM4.ASM (5) 8-Feb-91$' ; Used for family versions.... 82 | 83 | 84 | ; 85 | ; System-dependent initialization 86 | ; Called once at program start. 87 | sysxin: 88 | ; 89 | ;Set up 9600 bd, 8bit words, no parity 1stop bit 90 | 91 | mvi a,0EEH ;Get byte for desired baud (9600 = CC) and 92 | out baudpt ;and put it out of baud port 93 | out lctrl ;latch control port with anything 94 | lda pstore ;get parity etc and put it out of 95 | out mnprts ;port 96 | ret ; return from system-dependent routine 97 | 98 | ; 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | ; 109 | ; system-dependent termination processing 110 | ; If we've changed anything, this is our last chance to put it back. 111 | sysexit: 112 | ret 113 | ; 114 | ; system-dependent processing for start of CONNECT command 115 | ; 116 | syscon: 117 | ret 118 | 119 | conmsg: ; Messages printed when entering transparent (CONNECT) mode: 120 | ;------------------------------------------------------------------------------- 121 | ; -- 122 | ; 123 | ; syscls - system-dependent close routine 124 | ; called when exiting transparent session. 125 | ; 126 | syscls: 127 | ret 128 | ;------------------------------------------------------------------------------- 129 | ; --- 130 | ; 131 | ; sysinh - help for system-dependent special functions. 132 | ; called in response to ?, after listing all the 133 | ; system-independent escape sequences. 134 | ; 135 | sysinh: 136 | lxi d,inhlps ; we got options... 137 | call prtstr ; print them. 138 | ret 139 | 140 | 141 | ;additional, system-dependent help for transparent mode 142 | ; (two-character escape sequences) 143 | inhlps: 144 | 145 | db cr,lf,'B Transmit a BREAK' 146 | 147 | db '$' ;[hh] table terminator 148 | 149 | ; 150 | ; sysint - system dependent special functions 151 | ; called when transparent escape character has been typed; 152 | ; the second character of the sequence is in A (and in B). 153 | ; returns: 154 | ; non-skip: sequence has been processed 155 | ; skip: sequence was not recognized 156 | sysint: ani 137O ; convert lower case to upper, for testing... 157 | cpi 'B' ; send break? 158 | jz sendbr ; yes, go do it. return nonskip when through. 159 | 160 | jmp rskp ; take skip return - command not recognized. 161 | 162 | 163 | ;------------------------------------------------------------------------------- 164 | sendbr: 165 | ; 166 | ; Ensure that the transmitter has finished sending buffered chars 167 | sndbr1: in mnprts ; get UART status 168 | ani output ; everything sent? 169 | jz sndbr1 ; no, wait a bit more 170 | ; 171 | ; Begin sending a break by setting bit in UART command register 172 | mvi a,brkval ; SBreak, 173 | out lctrl 174 | out mnprts 175 | ; 176 | 177 | ; Wait for 250 milliseconds (using hundredths second delay routine) 178 | mvi a,25 179 | call delay 180 | ; 181 | ; Resume normal operation by clearing the SendBreak command bit 182 | lda pstore ;get parity etc value 183 | out lctrl ;latch control port 184 | out mnprts ;and set values 185 | ; 186 | ret ;done 187 | 188 | ; 189 | ; 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | ; 200 | ; sysflt - system-dependent filter 201 | ; called with character in E. 202 | ; if this character should not be printed, return with A = zero. 203 | ; preserves bc, de, hl. 204 | ; note: ,,, and are always discarded. 205 | sysflt: 206 | mov a,e ; get character for testing 207 | ret 208 | 209 | ; mdmflt - modem filter [30] 210 | ; called with character to be sent to modem in E 211 | ; with parity set as appropriate. 212 | ; return with accumulator = 0 do do nothing, 213 | ; <> 0 to send char in E. 214 | mdmflt: mov a,e 215 | ret 216 | 217 | 218 | 219 | ; prtflt - printer filter [30] 220 | ; called with character to be sent to printer in E 221 | ; returns with a = 0 to do nothing 222 | ; a <> 0 to print it. 223 | ; 224 | ; this routine for those printer that automatically insert 225 | ; a lf on cr, or cr for lf. Should this be shifted to 226 | ; the system indep. stuff, in say 4.06? 227 | prtflt: 228 | mov a,e ; [30] get character to test 229 | ret 230 | 231 | 232 | ; 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | ; 244 | ; system-dependent processing for BYE command. 245 | ; for apmmdm, heath, and lobo, hang up the phone. 246 | sysbye: 247 | ret 248 | ; 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | ; This is the system-dependent command to change the baud rate. 260 | ; DE contains the two-byte value from the baud rate table; this 261 | ; value is also stored in 'speed'. 262 | sysspd: 263 | ;Set up baud rate 8bit words, no parity 1stop bit 264 | 265 | mov a,e ;get get speed into a 266 | out baudpt ;output it as well 267 | lda pstore ;get parity etc 268 | out lctrl ;do it resetting DLAB at same time 269 | out mnprts 270 | ret 271 | 272 | pstore: db 6CH ;Default value for parity word length and stop bits 273 | 274 | spdtbl: db 10h ;17 entries 275 | db 03h,'110$', 22H,22H 276 | db 04h,'1200$', 77H,77H 277 | db 05h,'134.5$', 33H,33H 278 | db 03h,'150$', 44H,44H 279 | db 04h,'1800$', 88H,88H 280 | db 05h,'19200$', 0FFH,0FFH 281 | db 04h,'2000$', 99H,99H 282 | db 04h,'2400$', 0AAH,0AAH 283 | db 03h,'300$', 55H,55H 284 | db 04h,'3600$', 0BBH,0BBH 285 | db 04h,'4800$', 0CCH,0CCH 286 | db 02h,'50$', 00H,00H 287 | db 03h,'600$', 66H,66H 288 | db 04h,'7200$', 0DDH,0DDH 289 | db 02h,'75$', 11H,11H 290 | db 04h,'9600$', 0EEH,0EEH 291 | 292 | sphtbl: db cr,lf,' 50 75 110 134.5 150 300 600 1200' 293 | db cr,lf,' 1800 2000 2400 3600 4800 7200 9600 19200 $' 294 | 295 | ; This is the system-dependent SET PORT command. 296 | ; HL contains the argument from the command table. 297 | sysprt: 298 | ret 299 | ; 300 | prttbl equ 0 ; SET PORT not supported 301 | prhtbl equ 0 302 | 303 | ; 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | ; 314 | ; selmdm - select modem port 315 | ; selcon - select console port 316 | ; selmdm is called before using inpmdm or outmdm; 317 | ; selcon is called before using inpcon or outcon. 318 | ; For iobyt systems, diddle the I/O byte to select console or comm port; 319 | ; For Decision I, switches Multi I/O board to console or modem serial 320 | ; port. [Toad Hall] 321 | ; For the rest, does nothing. 322 | ; preserves bc, de, hl. 323 | selmdm: 324 | ret 325 | 326 | selcon: 327 | ret 328 | ; 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | ; Get character from console, or return zero. 339 | ; result is returned in A. destroys bc, de, hl. 340 | ; 341 | inpcon: 342 | mvi c,dconio ;Direct console I/O BDOS call. 343 | mvi e,0FFH ;Input. 344 | call BDOS 345 | 346 | ret 347 | ; 348 | ; Output character in E to the console. 349 | ; destroys bc, de, hl 350 | ; 351 | outcon: 352 | 353 | mvi c,dconio ;Console output bdos call. 354 | call bdos ;Output the char to the console. 355 | 356 | ret 357 | ; 358 | ; 359 | ; outmdm - output a char from E to the modem. 360 | ; the parity bit has been set as necessary. 361 | ; returns nonskip; bc, de, hl preserved. 362 | outmdm: 363 | 364 | in mnprts ;Get the output done flag. 365 | ani output ;Is it set? 366 | jz outmdm ;If not, loop until it is. 367 | mov a,e 368 | out mnport ;Output it. 369 | ret 370 | 371 | ;-------------------------------------------------------------------------- 372 | ; 373 | ; get character from modem; return zero if none available. 374 | ; for IOBYT systems, the modem port has already been selected. 375 | ; destroys bc, de, hl. 376 | inpmdm: 377 | ;Note: modem port should already be selected for mdI. [Toad Hall] 378 | in mnprts ;Get the port status into A. 379 | ani input ;See if the input ready bit is on. 380 | rz ;If not then return. 381 | in mnport ;If so, get the char. 382 | ret ; return with character in A 383 | 384 | 385 | ; 386 | ; flsmdm - flush comm line. 387 | ; Modem is selected. 388 | ; Currently, just gets characters until none are available. 389 | 390 | flsmdm: call inpmdm ; Try to get a character 391 | ora a ; Got one? 392 | jnz flsmdm ; If so, try for another 393 | ret ; Receiver is drained. Return. 394 | ;----------------------------------------------------------------------------- 395 | ; 396 | ; lptstat - get the printer status. Return a=0 if ok, or 0ffh if not. 397 | lptstat: 398 | xra a ; assume it is ok.. this may not be necessary 399 | ret 400 | 401 | ; 402 | ; outlpt - output character in E to printer 403 | ; console is selected. 404 | ; preserves de. 405 | outlpt: 406 | push d ; save DE in either case 407 | call prtflt ; go through printer filter [30] 408 | ana a ; if A = 0 do nothing, 409 | jz outlp1 ; [30] if a=0 do nothing 410 | 411 | mvi c,lstout 412 | call bdos ;Char to printer 413 | outlp1: pop d ; restore saved register pair 414 | ret 415 | ;------------------------------------------------------------------------------ 416 | ; 417 | ; Screen manipulation routines 418 | ; csrpos - move to row B, column C 419 | ; 420 | ; csrpos for terminals that use a leadin sequence followed 421 | ; by (row + 31.) and (column + 31.) 422 | ; 423 | csrpos: push b ; save coordinates 424 | lxi d,curldn ; get cursor leadin sequence 425 | call prtstr ; print it 426 | pop h ; restore coordinates 427 | mov a,h ; get row 428 | adi (' '-1) ; space is row one 429 | mov e,a 430 | push h 431 | call outcon ; output row 432 | pop h 433 | mov a,l ; get column 434 | adi (' '-1) ; space is column one 435 | mov e,a 436 | jmp outcon ; output it and return 437 | 438 | ; 439 | ; delchr - make delete look like a backspace. Unless delete is a printing 440 | ; character, we just need to print a backspace. (we'll output clrspc 441 | ; afterwards) 442 | ; For Kaypro and Vector General, delete puts a blotch on the screen. 443 | ; For Apple and Osborne 1, delete moves but doesn't print. 444 | delchr: 445 | 446 | mvi e,bs ;get a backspace 447 | jmp outcon 448 | 449 | ; erase the character at the current cursor position 450 | clrspc: mvi e,' ' 451 | call outcon 452 | mvi e,bs ;get a backspace 453 | jmp outcon 454 | 455 | ; erase the current line 456 | clrlin: lxi d,eralin 457 | jmp prtstr 458 | 459 | ; erase the whole screen, and go home. preserves b (but not c) 460 | clrtop: lxi d,erascr 461 | jmp prtstr 462 | 463 | ;[2] I see no real saving in having all screens in separate file and 464 | ;therefore have included screen definition here and commented out 465 | ;the link to VDU file 466 | ; 467 | ; 468 | ;Specific definitions for the Model IV screen 469 | ; 470 | sysver: db 'Tandy Model IV$' 471 | outlin: db 1aH,cr,lf,' $' 472 | erascr: db 1AH,'$' 473 | eralin: db cr,15H,'$' 474 | curldn: db esc,'=$' 475 | ttab: 476 | ta: db 0BH,'$',0,0 ;Cursor up 477 | tb: db 0AH,'$',0,0 ;Cursor down 478 | tc: db 0CH,'$',0,0 ;Cursor right 479 | td: db 08H,'$',0,0 ;Cursor left 480 | te: db 1AH,'$',0,0 ;Clear display 481 | tf: db 0FH,'$',0,0 ;Reverse on 482 | tg: db 0EH,'$',0,0 ;Reverse off 483 | th: db 1EH,'$',0,0 ;Cursor home 484 | ti: db 0BH,'$',0,0 ;Reverse linefeed 485 | tj: db 19H,'$',0,0 ;Clear to end of screen 486 | tk: db 15H,'$',0,0 ;Clear to end of line 487 | 488 | ovlend equ $ ;End of overlay 489 | 490 | END 491 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/cpxz80.asm: -------------------------------------------------------------------------------- 1 | IF NOT LASM 2 | .printx * CPXZ80.ASM * 3 | ENDIF ;NOT lasm 4 | ; KERMIT - (Celtic for "FREE") 5 | ; 6 | ; This is the CP/M-80 implementation of the Columbia University 7 | ; KERMIT file transfer protocol. 8 | ; 9 | ; Version 4.0 10 | ; 11 | ; Copyright June 1981,1982,1983,1984,1985 12 | ; Columbia University 13 | ; 14 | ; Originally written by Bill Catchings of the Columbia University Center for 15 | ; Computing Activities, 612 W. 115th St., New York, NY 10025. 16 | ; 17 | ; Contributions by Frank da Cruz, Daphne Tzoar, Bernie Eiben, 18 | ; Bruce Tanner, Nick Bush, Greg Small, Kimmo Laaksonen, Jeff Damens, and many 19 | ; others. 20 | ; 21 | ; This file contains the system-dependent code and data for 22 | ; Kermit-80 emulated on an IBM PC or clone running Z80MU. 23 | ; 24 | ; revision history (last edit first) 25 | ; 26 | ; edit 1, 2 December, 1987. Built code for Z80MU emulation. Uses BIOS 27 | ; calls to 0FF12-15 to read/write from/to the PC COM1 port. 28 | ; 29 | 30 | .printx * Assembling for Z80MU system * 31 | 32 | ; 33 | ; Family is the string used in VERSION to say which of several 34 | ; smaller overlay files are used. These are (will be) derived from 35 | ; the juge CP4SYS.ASM file, in which case we will never get here. 36 | ; Just a Dollar, but put a sting in for a family of machines. 37 | ; 38 | family: db 'CPXZ80.ASM (1) 2-Dec-87$' ; Used for family versions.... 39 | 40 | 41 | 42 | sysxin: ; continuation of system dependent initialisation code 43 | ret ; return from system-dependent routine 44 | ; 45 | ; 46 | ; system-dependent termination processing 47 | ; If we've changed anything, this is our last chance to put it back. 48 | sysexit: 49 | ret 50 | 51 | ; 52 | ; system-dependent processing for start of CONNECT command 53 | ; 54 | syscon: 55 | ret 56 | 57 | conmsg: ; Messages printed when entering transparent (CONNECT) mode: 58 | ; 59 | ; 60 | ; syscls - system-dependent close routine 61 | ; called when exiting transparent session. 62 | ; 63 | syscls: 64 | ret 65 | ; 66 | ; sysinh - help for system-dependent special functions. 67 | ; called in response to ?, after listing all the 68 | ; system-independent escape sequences. 69 | ; 70 | sysinh: 71 | ret 72 | 73 | ; 74 | ; sysint - system dependent special functions 75 | ; called when transparent escape character has been typed; 76 | ; the second character of the sequence is in A (and in B). 77 | ; returns: 78 | ; non-skip: sequence has been processed 79 | ; skip: sequence was not recognized 80 | sysint: ani 137O ; convert lower case to upper, for testing... 81 | jmp rskp ; take skip return - command not recognized. 82 | 83 | 84 | ; 85 | ; 86 | ; sysflt - system-dependent filter 87 | ; called with character in E. 88 | ; if this character should not be printed, return with A = zero. 89 | ; preserves bc, de, hl. 90 | ; note: ,,, and are always discarded. 91 | sysflt: 92 | mov a,e ; get character for testing 93 | ret 94 | 95 | ; mdmflt - modem filter [30] 96 | ; called with character to be sent to printer in E 97 | ; with parity set as appropriate. 98 | ; return with accumulator = 0 do do nothing, 99 | ; <> 0 to send char in E. 100 | mdmflt: 101 | mov a,e ;[30] get character to test 102 | ret 103 | 104 | 105 | 106 | ; prtflt - printer filter [30] 107 | ; called with character to be sent to printer in E 108 | ; returns with a = 0 to do nothing 109 | ; a <> 0 to print it. 110 | ; 111 | ; this routine for those printer that automatically insert 112 | ; a lf on cr, or cr for lf. Should this be shifted to 113 | ; the system indep. stuff, in say 4.06? 114 | prtflt: 115 | mov a,e ; [30] get character to test 116 | ret 117 | 118 | 119 | ; 120 | ; system-dependent processing for BYE command. 121 | ; for apmmdm, heath, and lobo, hang up the phone. 122 | sysbye: 123 | ret 124 | ; 125 | ; 126 | ; This is the system-dependent command to change the baud rate. 127 | ; DE contains the two-byte value from the baud rate table; this 128 | ; value is also stored in 'speed'. 129 | sysspd: 130 | ret 131 | ; 132 | ; 133 | ; The following conditionals were once a huge if not statement. There 134 | ; wasn't enough room to add the lobo to the list, so it had to be broken 135 | ; into 2, which you can't do with an if not. I redid it as two ifs and 136 | ; applied them to those that wouldn't set baud. [Hal Hostetler] 137 | spdtbl EQU 0 ;[hh] SET BAUD not supported. 138 | sphtbl EQU 0 ;[hh] ran out of room above... 139 | ; 140 | ; 141 | ; This is the system-dependent SET PORT command. 142 | ; HL contains the argument from the command table. 143 | sysprt: 144 | ret 145 | 146 | prttbl equ 0 ; SET PORT not supported 147 | prhtbl equ 0 148 | ; 149 | 150 | ; 151 | ; selmdm - select modem port 152 | ; selcon - select console port 153 | ; selmdm is called before using inpmdm or outmdm; 154 | ; selcon is called before using inpcon or outcon. 155 | ; For iobyt systems, diddle the I/O byte to select console or comm port; 156 | ; For Decision I, switches Multi I/O board to console or modem serial 157 | ; port. [Toad Hall] 158 | ; For the rest, does nothing. 159 | ; preserves bc, de, hl. 160 | selmdm: 161 | selcon: 162 | ret 163 | ; 164 | 165 | ; Get character from console, or return zero. 166 | ; result is returned in A. destroys bc, de, hl. 167 | ; 168 | inpcon: 169 | mvi c,dconio ;Direct console I/O BDOS call. 170 | mvi e,0FFH ;Input. 171 | call BDOS 172 | ret 173 | ; 174 | 175 | ; 176 | ; Output character in E to the console. 177 | ; destroys bc, de, hl 178 | ; 179 | outcon: 180 | mov c,e ;Console output via BIOS 181 | jmp bcnout 182 | ; 183 | 184 | ; 185 | ; outmdm - output a char from E to the modem. 186 | ; the parity bit has been set as necessary. 187 | ; returns nonskip; bc, de, hl preserved. 188 | outmdm: 189 | mov c,e ; get char to c 190 | call 0ff12h ; send to com1 via PC BIOS 191 | ret 192 | ; 193 | ; 194 | ; get character from modem; return zero if none available. 195 | ; for IOBYT systems, the modem port has already been selected. 196 | ; destroys bc, de, hl. 197 | inpmdm: 198 | ;Note: modem port should already be selected for mdI. [Toad Hall] 199 | call 0ff15h ;Get the port status into A. 200 | ana a ;See if the is non-null. 201 | ret ; return with character or NULL in A. 202 | 203 | 204 | ; 205 | ; flsmdm - flush comm line. 206 | ; Modem is selected. 207 | ; Currently, just gets characters until none are available. 208 | 209 | flsmdm: call inpmdm ; Try to get a character 210 | ora a ; Got one? 211 | jnz flsmdm ; If so, try for another 212 | ret ; Receiver is drained. Return. 213 | ; 214 | 215 | ; 216 | ; lptstat - get the printer status. Return a=0ffh if ok, or 0 if not. 217 | lptstat: 218 | xra a ; assume it is ok.. this may not be necessary 219 | ret 220 | 221 | ; 222 | ; outlpt - output character in E to printer 223 | ; console is selected. 224 | ; preserves de. 225 | outlpt: 226 | push d ; save DE in either case 227 | call prtflt ; go through printer filter [30] 228 | ana a ; if A = 0 do nothing, 229 | jz outlp1 ; [30] if a=0 do nothing 230 | mvi c,lstout 231 | call bdos ;Char to printer 232 | outlp1: pop d ; restore saved register pair 233 | ret 234 | 235 | ; 236 | ; delchr - make delete look like a backspace. Unless delete is a printing 237 | ; character, we just need to print a backspace. (we'll output clrspc 238 | ; afterwards) 239 | ; For Kaypro and Vector General, delete puts a blotch on the screen. 240 | ; For Apple and Osborne 1, delete moves but doesn't print. 241 | delchr: 242 | mvi e,bs ;get a backspace 243 | jmp outcon 244 | 245 | ; erase the character at the current cursor position 246 | clrspc: mvi e,' ' 247 | call outcon 248 | mvi e,bs ;get a backspace 249 | jmp outcon 250 | 251 | ; erase the current line 252 | clrlin: lxi d,eralin 253 | jmp prtstr 254 | 255 | ; erase the whole screen, and go home. preserves b (but not c) 256 | clrtop: lxi d,erascr 257 | jmp prtstr 258 | 259 | 260 | sysver: db 'Z80MU on IBM PC $' 261 | IF lasm 262 | LINK CPXVDU.ASM 263 | ENDIF ;lasm - m80 will INCLUDE CPXVDU.ASM 264 |  265 |  266 |  267 |  268 |  269 |  270 |  271 |  272 |  273 |  274 |  275 |  276 |  277 |  278 |  279 |  280 |  281 |  282 |  283 |  284 |  285 |  286 |  287 |  288 |  289 |  290 |  291 |  292 |  293 |  294 |  295 |  296 |  297 |  298 |  299 |  300 |  301 |  302 |  303 |  304 |  305 |  306 |  307 |  308 |  309 |  310 |  311 |  312 |  313 |  314 |  315 |  316 |  317 |  318 |  319 |  320 |  321 |  322 |  323 |  324 |  325 |  326 |  327 |  328 |  329 |  330 |  331 |  332 |  333 |  334 |  335 |  336 |  337 |  338 |  339 |  340 |  341 |  342 |  343 |  344 |  345 |  346 |  347 |  348 |  349 |  350 | 351 | -------------------------------------------------------------------------------- /apps/3rd-party/kermit/lasm.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/ZINC/9df58126ae1ba1c47122792b479ef43ad7c550bd/apps/3rd-party/kermit/lasm.com -------------------------------------------------------------------------------- /apps/3rd-party/z80asm/z80asm.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/ZINC/9df58126ae1ba1c47122792b479ef43ad7c550bd/apps/3rd-party/z80asm/z80asm.com -------------------------------------------------------------------------------- /apps/esp8266/README.md: -------------------------------------------------------------------------------- 1 | # Tools for ESP8266 with default AT-firmware 2 | 3 | It's important setup your UART speed settings to same mode as ESP8266 module via `zinc-setup`. 4 | 5 | All tools working via IOBYTE. 6 | 7 | Examples are built with Z80ASM(can be found in `3rd-party` directory). 8 | 9 | ## esprst.com - resets your ESP8266 module 10 | 11 | Just resets your module and closes all opened connections. 12 | 13 | Simplest example - how to work with UART1 via ZINC. 14 | 15 | ## dial.com 16 | 17 | Dialer that allows use your ESP8266 module with usual BBSes and tools like kermit/ZMP etc. 18 | 19 | Just run it as: 20 | ```shell 21 | zinc dial kayprobbs.org 23 22 | ``` 23 | 24 | Where `kayprobbs.org` is host name and `23` is port(replace with any values that you want). 25 | 26 | Connection will be opened with direct streaming mode and every transmitted byte TO uart will be send to socket and every received from socket byte will be send to uart. 27 | 28 | Only one issue - if remote host will close connection - it will be re-established automatically, so for closing socket you should call esprst tool: 29 | 30 | ```shell 31 | zinc esprst 32 | ``` 33 | 34 | -------------------------------------------------------------------------------- /apps/esp8266/bin/dial.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/ZINC/9df58126ae1ba1c47122792b479ef43ad7c550bd/apps/esp8266/bin/dial.com -------------------------------------------------------------------------------- /apps/esp8266/bin/esprst.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nihirash/ZINC/9df58126ae1ba1c47122792b479ef43ad7c550bd/apps/esp8266/bin/esprst.com -------------------------------------------------------------------------------- /apps/esp8266/src/dial.z80: -------------------------------------------------------------------------------- 1 | ORG 100H 2 | BDOS EQU 5 3 | TTY EQU 0 4 | CRT EQU 1 5 | 6 | USE_MODEM EQU 1 7 | 8 | MAIN: 9 | LD HL, 81H 10 | LD A, (HL) 11 | AND A 12 | JP Z, DESCR ; IF NO INFO ABOUT HOST/PORT 13 | CALL SKIP_SPACE 14 | LD DE, HOST 15 | ARG1 16 | LD A, (HL) 17 | AND A 18 | JP Z, DESCR 19 | CP 13 20 | JP Z, DESCR 21 | INC HL 22 | CP ' ' 23 | JR Z, ARG2 24 | LD (DE), A 25 | INC DE 26 | JP ARG1 27 | ARG2 28 | LD A, '$' 29 | LD (DE), A 30 | CALL SKIP_SPACE 31 | LD DE, PORT 32 | ARG21 33 | LD A,(HL) 34 | INC HL 35 | AND A 36 | JR Z, WORK 37 | CP ' ' 38 | JR Z, WORK 39 | LD (DE), A 40 | INC DE 41 | JR ARG21 42 | WORK 43 | LD A, '$' 44 | LD (DE), A 45 | 46 | LD DE, C_AT 47 | CALL AT_CMD 48 | AND A 49 | JP Z, ERROR 50 | 51 | LD DE, C_MODE 52 | CALL AT_CMD 53 | AND A 54 | JP Z, ERROR 55 | 56 | CALL SET_TTY 57 | LD DE,C_CON1 58 | CALL PRINTS 59 | LD DE,HOST 60 | CALL PRINTS 61 | LD DE,C_CON2 62 | CALL PRINTS 63 | LD DE,PORT 64 | CALL PRINTS 65 | LD DE,C_CON3 66 | CALL AT_CMD 67 | AND A 68 | JR Z, ERROR 69 | 70 | LD DE, C_SND 71 | CALL AT_CMD 72 | 73 | RST 0 74 | ERROR 75 | LD DE,ERR 76 | CALL PRINTS 77 | RST 0 78 | ERR DEFB 13,10,"Initialization error happens",13,10,"$" 79 | 80 | SKIP_SPACE 81 | LD A,(HL) 82 | AND A 83 | RET Z 84 | CP ' ' 85 | RET NZ 86 | INC HL 87 | JR SKIP_SPACE 88 | 89 | DESCR 90 | LD DE, DESCR_MSG 91 | CALL PRINTS 92 | RST 0 93 | DESCR_MSG DB 13,10,"USAGE: DIAL ",13,10,"$" 94 | 95 | PRINTS 96 | LD C, 09H 97 | JP BDOS 98 | 99 | SET_TTY: 100 | IF USE_MODEM 101 | PUSH DE 102 | LD C, 8 103 | LD E, TTY 104 | CALL BDOS 105 | POP DE 106 | ENDIF 107 | RET 108 | 109 | SET_CRT: 110 | IF USE_MODEM 111 | PUSH AF 112 | LD C, 8 113 | LD E, CRT 114 | CALL BDOS 115 | POP AF 116 | ENDIF 117 | RET 118 | 119 | AT_CMD: 120 | CALL SET_TTY 121 | CALL PRINTS 122 | CALL OK_ERR 123 | CALL SET_CRT 124 | RET 125 | 126 | OK_ERR: 127 | CALL READ_RESP 128 | ; CHECK FOR RESPONSES 129 | CALL IS_OK 130 | LD A, 0FFH 131 | RET Z 132 | 133 | CALL IS_ERR 134 | LD A, 00H 135 | RET Z 136 | JR OK_ERR 137 | 138 | IS_OK: 139 | LD HL, R_OK 140 | LD DE, DATA 141 | JP STRCMP 142 | 143 | IS_ERR: 144 | LD HL, R_ERR 145 | LD DE, DATA 146 | JP STRCMP 147 | 148 | STRCMP: 149 | LD A,(HL) 150 | LD B, A 151 | LD A, (DE) 152 | CP B 153 | RET NZ 154 | OR A 155 | RET Z 156 | 157 | INC HL 158 | INC DE 159 | JR STRCMP 160 | 161 | READ_RESP: 162 | ; CLEAN UP BUFFER 163 | LD HL, DATA-1 164 | LD DE, DATA 165 | LD BC, 80 166 | XOR A 167 | LD (HL), A 168 | LDIR 169 | ; READ 170 | LD DE, DATA 171 | READ_LOOP 172 | PUSH DE 173 | READZERO 174 | LD C, 6 175 | LD E, 0FFH 176 | CALL BDOS 177 | AND A 178 | JR Z, READZERO 179 | POP DE 180 | CP 13 181 | RET Z 182 | CP 10 183 | RET Z 184 | LD (DE), A 185 | INC DE 186 | JR READ_LOOP 187 | 188 | 189 | C_AT DEFB "ATE0",13,10,"$" 190 | 191 | C_MODE DEFB "AT+CIPMODE=1",13,10,"$" 192 | 193 | C_CON1 DEFB 'AT+CIPSTART="TCP","$' 194 | C_CON2 DEFB '",$' 195 | C_CON3 DEFB 13,10,'$' 196 | 197 | C_SND DEFB "AT+CIPSEND",13,10,"$" 198 | 199 | ; AWAITED RESPONSES 200 | R_OK DEFB "OK",0 201 | R_ERR DEFB "ERROR",0 202 | 203 | ; RESPONSE BUFFER 204 | DATA: 205 | DEFS 80 206 | 207 | HOST: 208 | DEFS 40 209 | PORT: 210 | DEFS 6 211 | DEFB "HERE ENDS ALL MY DATA" 212 | -------------------------------------------------------------------------------- /apps/esp8266/src/esprst.z80: -------------------------------------------------------------------------------- 1 | ORG 100H 2 | TTY EQU 0 3 | CRT EQU 1 4 | BDOS EQU 5 5 | 6 | START: 7 | ; Step 1 8 | LD DE, MSG1 9 | CALL PRINTS 10 | CALL SET_TTY 11 | LD DE, CMD1 12 | CALL PRINTS 13 | EI 14 | HALT 15 | HALT 16 | HALT 17 | HALT 18 | ; Step 2 19 | CALL SET_CRT 20 | LD DE, MSG2 21 | CALL PRINTS 22 | CALL SET_TTY 23 | LD DE, CMD2 24 | CALL PRINTS 25 | 26 | CALL SET_CRT 27 | RET 28 | 29 | PRINTS: 30 | LD C,9 31 | JP BDOS 32 | 33 | SET_CRT: 34 | LD E,CRT 35 | JR SET_IO 36 | SET_TTY: 37 | LD E,TTY 38 | SET_IO: 39 | LD C,8 40 | JP BDOS 41 | 42 | MSG1 DEFB "Switching to command mode", 13, 10, "$" 43 | MSG2 DEFB "Resetting chip",13,10,"$" 44 | 45 | CMD1 DEFB "+++$" 46 | CMD2 DEFB "AT+RST",13,10,"$" 47 | -------------------------------------------------------------------------------- /ci-build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | ENV DEBIAN_FRONTEND=noninteractive 3 | 4 | RUN apt-get update && apt install -y build-essential git zip && rm -rf /var/lib/apt/lists/* 5 | RUN git clone https://github.com/envenomator/agon-ez80asm && (cd agon-ez80asm && make -j8 && cp bin/ez80asm /bin/ && cd .. && rm -rf agon-ez80asm) 6 | 7 | WORKDIR /src 8 | 9 | CMD ["ez80asm"] -------------------------------------------------------------------------------- /ci-build/build-macos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script rebuilds docker image with ez80asm 4 | 5 | docker rmi nihirash/ez80asm:x64 6 | docker build . -t nihirash/ez80asm:x64 7 | docker push nihirash/ez80asm:x64 -------------------------------------------------------------------------------- /src/mos.asm: -------------------------------------------------------------------------------- 1 | ;; ZINC is Not CP/M 2 | ;; 3 | ;; CP/M compatibility layer for Agon's MOS 4 | ;; (c) 2024 Aleksandr Sharikhin 5 | ;; 6 | ;; All rights are reserved 7 | 8 | macro MOSCALL func 9 | ld a, func 10 | rst.lil $08 11 | endmacro 12 | 13 | macro PRINTZ ptr 14 | ld hl, ptr 15 | ld bc, 0 16 | xor a 17 | rst.lil $18 18 | endmacro 19 | 20 | ;; API CALLS 21 | MOS_GET_KEY: equ $00 22 | MOS_LOAD: equ $01 23 | MOS_SAVE: equ $02 24 | MOS_DELETE: equ $05 25 | MOS_RENAME: equ $06 26 | MOS_SYS_VARS: equ $08 27 | MOS_EDIT_LINE: equ $09 28 | MOS_FOPEN: equ $0a 29 | MOS_FCLOSE: equ $0b 30 | MOS_UOPEN: equ $15 31 | MOS_UCLOSE: equ $16 32 | MOS_UGETC: equ $17 33 | MOS_UPUTC: equ $18 34 | MOS_GETFIL: equ $19 35 | MOS_FREAD: equ $1a 36 | MOS_FWRITE: equ $1b 37 | MOS_FSEEK: equ $1c 38 | 39 | 40 | MOS_OPENDIR: equ $91 41 | MOS_CLOSEDIR: equ $92 42 | MOS_READDIR: equ $93 43 | 44 | MOS_FSTAT: equ $96 45 | 46 | MOS_CWD: equ $9e 47 | 48 | ;; File Modes 49 | FA_READ: equ $01 50 | FA_WRITE: equ $02 51 | FA_CREATE: equ $04 52 | FA_CREATE_ALW: equ $08 53 | FA_OPEN_ALW: equ $10 54 | 55 | VAR_VDP_DONE: equ $04 56 | VAR_KEYASCII: equ $05 57 | VAR_CURSORX: equ $07 58 | VAR_CURSORY: equ $08 59 | VAR_SCRWIDTH: equ $13 60 | VAR_KEYDOWN: equ $18 61 | VAR_VKEYCOUNT: equ $19 62 | -------------------------------------------------------------------------------- /src/zinc-setup/uart-setup.asm: -------------------------------------------------------------------------------- 1 | ;; ZINC is Not CP/M 2 | ;; 3 | ;; CP/M compatibility layer for Agon's MOS 4 | ;; (c) 2024 Aleksandr Sharikhin 5 | ;; 6 | ;; All rights are reserved 7 | 8 | uart_setup: 9 | PRINTZ should_setup_uart 10 | call yes_no 11 | ret z ;; Don't want setup UART 12 | 13 | PRINTZ uart_speed_msg 14 | 15 | speed_conf: 16 | MOSCALL MOS_GET_KEY 17 | 18 | cp '1' 19 | jr c, speed_conf 20 | 21 | cp '9' + 1 22 | jr nc, speed_conf 23 | 24 | sub '0' 25 | 26 | cp 1 27 | ld hl, uart_speed1 + 4 28 | ld de, 115200 29 | jp z, @speed_ok 30 | 31 | cp 2 32 | ld hl, uart_speed2 + 4 33 | ld de, 57600 34 | jp z, @speed_ok 35 | 36 | cp 3 37 | ld hl, uart_speed3 + 4 38 | ld de, 38400 39 | jp z, @speed_ok 40 | 41 | cp 4 42 | ld hl, uart_speed4 + 4 43 | ld de, 19200 44 | jp z, @speed_ok 45 | 46 | cp 5 47 | ld hl, uart_speed5 + 4 48 | ld de, 9600 49 | jp z, @speed_ok 50 | 51 | cp 6 52 | ld hl, uart_speed6 + 4 53 | ld de, 4800 54 | jp z, @speed_ok 55 | 56 | cp 7 57 | ld hl, uart_speed7 + 4 58 | ld de, 2400 59 | jp z, @speed_ok 60 | 61 | cp 8 62 | ld hl, uart_speed8 + 4 63 | ld de, 1200 64 | jp z, @speed_ok 65 | 66 | ld hl, uart_speed9 + 4 67 | ld de, 300 68 | 69 | @speed_ok: 70 | ld (serial_speed), de 71 | ld bc, 0 72 | ld a, ' ' 73 | rst.lil $18 74 | 75 | PRINTZ uart_bits_msg 76 | bits_conf: 77 | MOSCALL MOS_GET_KEY 78 | 79 | cp '1' 80 | jr c, bits_conf 81 | 82 | cp '4' 83 | jr nc, bits_conf 84 | 85 | sub '0' 86 | 87 | cp 1 88 | ld c, 8 89 | ld hl, uart_bits1 + 4 90 | jr z, @bits_ok 91 | 92 | cp 2 93 | ld c, 7 94 | ld hl, uart_bits2 + 4 95 | jr z, @bits_ok 96 | 97 | ld c, 5 98 | ld hl, uart_bits3 + 4 99 | 100 | @bits_ok: 101 | ld a, c 102 | ld (serial_bits), a 103 | 104 | ld bc, 0 105 | ld a, ' ' 106 | rst.lil $18 107 | 108 | PRINTZ uart_stopbits_msg 109 | uart_stopbits_conf: 110 | MOSCALL MOS_GET_KEY 111 | 112 | cp '1' 113 | jr c, uart_stopbits_conf 114 | 115 | cp '3' 116 | jr nc, uart_stopbits_conf 117 | 118 | sub '0' 119 | 120 | ld hl, uart_stop_bits1 + 4 121 | cp 1 122 | jr z, @uart_stopok 123 | 124 | ld hl, uart_stop_bits2 + 4 125 | @uart_stopok: 126 | ld (serial_stop_bits), a 127 | 128 | ld bc, 0 129 | ld a, ' ' 130 | rst.lil $18 131 | 132 | PRINTZ uart_parity_msg 133 | uart_parity_conf: 134 | MOSCALL MOS_GET_KEY 135 | 136 | cp '1' 137 | jr c, uart_parity_conf 138 | 139 | cp '4' 140 | jr nc, uart_parity_conf 141 | 142 | sub '1' 143 | 144 | ld hl, uart_parity1 + 4 145 | or a 146 | jr z, @parity_ok 147 | 148 | ld hl, uart_parity2 + 4 149 | cp 1 150 | jr z, @parity_ok 151 | 152 | ld hl, uart_parity3 + 4 153 | 154 | @parity_ok: 155 | ld (serial_parity_control), a 156 | 157 | ld bc, 0 158 | ld a, ' ' 159 | rst.lil $18 160 | 161 | PRINTZ uart_done 162 | 163 | call yes_no 164 | ret nz 165 | 166 | jp uart_setup 167 | 168 | should_setup_uart: 169 | db 13, 10 170 | db "Do you want configure UART parameters? (Y/N) ", 0 171 | 172 | uart_speed_msg: 173 | db 13, 10 174 | db "Select UART speed:", 13, 10 175 | uart_speed1: 176 | db " 1) 115200", 13, 10 177 | uart_speed2: 178 | db " 2) 57600", 13, 10 179 | uart_speed3: 180 | db " 3) 38400", 13, 10 181 | uart_speed4: 182 | db " 4) 19200", 13, 10 183 | uart_speed5: 184 | db " 5) 9600", 13, 10 185 | uart_speed6: 186 | db " 6) 4800", 13, 10 187 | uart_speed7: 188 | db " 7) 2400", 13, 10 189 | uart_speed8: 190 | db " 8) 1200", 13, 10 191 | uart_speed9: 192 | db " 9) 300", 13, 10 193 | 194 | db 13, 10 195 | db "Selected speed: " 196 | db 0 197 | 198 | uart_bits_msg: 199 | db 13, 10, 13, 10 200 | db "Select UART data bits count:", 13, 10 201 | uart_bits1: 202 | db " 1) 8", 13, 10 203 | uart_bits2: 204 | db " 2) 7", 13, 10 205 | uart_bits3: 206 | db " 3) 5", 13, 10 207 | db 13, 10 208 | db "Selected data bits count: " 209 | db 0 210 | 211 | 212 | uart_stopbits_msg: 213 | db 13, 10, 13, 10 214 | db "Select UART stop bits count: ", 13, 10 215 | 216 | uart_stop_bits1: 217 | db " 1) 1", 13, 10 218 | uart_stop_bits2: 219 | db " 2) 2", 13, 10 220 | 221 | db 13, 10 222 | db "Selected stop bits count: " 223 | db 0 224 | 225 | uart_parity_msg: 226 | db 13, 10, 13, 10 227 | db "Select UART parity bits count:", 13, 10 228 | uart_parity1: 229 | db " 1) None", 13, 10 230 | uart_parity2: 231 | db " 2) Odd", 13, 10 232 | uart_parity3: 233 | db " 3) Even", 13, 10 234 | db 13, 10 235 | db "Selected parity bits count: " 236 | db 0 237 | 238 | uart_done: 239 | db 13, 10, 13, 10 240 | db "UART settings was configured!", 13, 10 241 | db 13, 10 242 | db "Do you want keep them? (Y/N) " 243 | db 0 -------------------------------------------------------------------------------- /src/zinc-setup/zinc-setup.asm: -------------------------------------------------------------------------------- 1 | ;; ZINC is Not CP/M 2 | ;; 3 | ;; CP/M compatibility layer for Agon's MOS 4 | ;; (c) 2024 Aleksandr Sharikhin 5 | ;; 6 | ;; All rights are reserved 7 | 8 | 9 | ASSUME ADL=1 10 | 11 | include "../mos.asm" 12 | 13 | org $B0000 14 | jp _start 15 | 16 | align 64 17 | db "MOS" ;; HEADER 18 | db 0 ;; VERSION 19 | db 1 ;; ADL 20 | 21 | 22 | ;; ---------------------------------------------------------------------------- 23 | 24 | _start: 25 | push ix 26 | push iy 27 | 28 | PRINTZ banner 29 | 30 | ld hl, config_file 31 | ld de, options 32 | ld bc, options_end - options 33 | MOSCALL MOS_LOAD 34 | 35 | call uart_setup 36 | 37 | ld hl, config_file 38 | MOSCALL MOS_DELETE 39 | 40 | ld hl, config_file 41 | ld de, options 42 | ld bc, options_end - options 43 | MOSCALL MOS_SAVE 44 | 45 | PRINTZ all_done 46 | 47 | ld hl, 0 48 | pop iy 49 | pop ix 50 | ret 51 | 52 | yes_no: 53 | MOSCALL MOS_GET_KEY 54 | cp 'y' 55 | jr z, @yes 56 | 57 | cp 'Y' 58 | jr z, @yes 59 | 60 | cp 'n' 61 | jr z, @no 62 | 63 | cp 'N' 64 | jr z, @no 65 | 66 | jr yes_no 67 | @no: 68 | ld hl, @no_msg 69 | ld bc, 0 70 | xor a 71 | rst.lil $18 72 | 73 | xor a 74 | ret 75 | 76 | @yes: 77 | ld hl, @yes_msg 78 | ld bc, 0 79 | xor a 80 | rst.lil $18 81 | 82 | ld a, 1 83 | or a 84 | ret 85 | @yes_msg: 86 | db "Yes", 13, 10, 0 87 | @no_msg: 88 | db "No", 13, 10, 0 89 | 90 | banner: 91 | db 13,10 92 | db "ZINC Setup Utility ", 13, 10 93 | db "Version built: " 94 | incbin "../../.version" 95 | db 13, 10 96 | db 0 97 | 98 | all_done: 99 | db 13, 10 100 | db "All done!", 13, 10 101 | db "Configuration file updated!", 13, 10 102 | db 0 103 | 104 | config_file: 105 | db "/mos/zinc.cfg", 0 106 | 107 | include "uart-setup.asm" 108 | 109 | include "../zinc/options.asm" -------------------------------------------------------------------------------- /src/zinc/config.asm: -------------------------------------------------------------------------------- 1 | ;; ZINC is Not CP/M 2 | ;; 3 | ;; CP/M compatibility layer for Agon's MOS 4 | ;; (c) 2024 Aleksandr Sharikhin 5 | ;; 6 | ;; All rights are reserved 7 | 8 | ;; ---------------------------------------------------------------------------- 9 | ;; This configuration file will affect executable and EDOS parts both 10 | ;; 11 | ;; Don't modify this values if you don't really know what you want get. 12 | ;; 13 | ;; All this values affects all system 14 | ;; ---------------------------------------------------------------------------- 15 | 16 | 17 | ;; Replace ZINC_BASE to $40000 for using it from `/bin` path or as standalone application 18 | ;; Or keep it as usual moslet - emulator is really tiny and works fine here 19 | ZINC_BASE: equ $B0000 20 | ZINC_EXIT: equ ZINC_BASE + 4 21 | ZINC_TERMOUT: equ ZINC_EXIT + 4 22 | ZINC_TERMST: equ ZINC_TERMOUT + 4 23 | ZINC_TERMIN: equ ZINC_TERMST + 4 24 | 25 | ;; By changing this value you can change used memory page for CP/M application 26 | EDOS_BASE: equ $A0000 27 | ;; Origin address for EDOS(BDOS equivalent in ZINC) 28 | EDOS_ORG: equ EDOS_BASE + $F500 29 | ;; TPA area starts here 30 | EDOS_TPA: equ EDOS_BASE + $100 31 | ;; MB pointer 32 | EDOS_PAGE: equ EDOS_BASE / $10000 33 | 34 | ;; CP/M 2.2 is $22 35 | ;; Personal CP/M-80 is $28 36 | ;; Let be ZINC is $29. 37 | ;; Cause compatibility target will be 2.x line but it's totally new version 38 | DOSVER: equ $29 39 | 40 | ;; CP/M variables 41 | TDRIVE: equ $04 42 | IOBYTE: equ $03 43 | TFCB: equ $5c 44 | DEFDMA: equ $80 45 | 46 | NFUNC: equ 40 47 | 48 | TPA: equ $100 49 | 50 | CNTRLC: equ $03 51 | CNTRLE: equ $05 52 | BS: equ $7F 53 | TAB: equ $09 54 | LF: equ $0A 55 | CNTRLL: equ $0C 56 | CR: equ $0D -------------------------------------------------------------------------------- /src/zinc/cpm-data.asm: -------------------------------------------------------------------------------- 1 | ;; ZINC is Not CP/M 2 | ;; 3 | ;; CP/M compatibility layer for Agon's MOS 4 | ;; (c) 2024 Aleksandr Sharikhin 5 | ;; 6 | ;; All rights are reserved 7 | 8 | 9 | ;; ---------------------------------------------------------------------------- 10 | 11 | FCB: equ EDOS_BASE + $5c ; default FCB placement 12 | BUFF: equ EDOS_BASE + $80 13 | 14 | ;; Prepare system vars on start application 15 | ;; Reimplements CCP behavior 16 | prepare_vars: 17 | ;; Preparing FCB entities 18 | ld hl, fcb_template 19 | 20 | push hl 21 | ld de, FCB 22 | ld bc, 16 23 | ldir 24 | pop hl 25 | 26 | ld bc, 16 27 | ldir 28 | 29 | ld a, (argc) 30 | dec a 31 | ret z 32 | ;; Filling FCB with masked filenames 33 | ld hl, (argv + 3) 34 | ld de, FCB 35 | call ascciz_to_fcb 36 | 37 | ld a, (argc) 38 | dec a 39 | dec a 40 | jr z, @skip_fcb2 41 | 42 | ld hl, (argv + 6) 43 | ld de, FCB + 16 44 | call ascciz_to_fcb 45 | 46 | @skip_fcb2: 47 | ld a, (argc) 48 | dec a 49 | ld b, a 50 | 51 | ;; Preparing input line in DMA buffer 52 | ld de, BUFF 53 | xor a 54 | ld (de), a 55 | inc de 56 | 57 | ld ix, argv + 3 58 | @copy1: 59 | ld hl, (ix) 60 | @copy2: 61 | ld a, (hl) 62 | or a 63 | jr z, @endcopy 64 | 65 | call uppercase 66 | ld (de), a 67 | 68 | push hl 69 | ld hl, BUFF 70 | inc (hl) 71 | pop hl 72 | 73 | inc hl 74 | inc de 75 | jr @copy2 76 | @endcopy: 77 | ld a, ' ' 78 | ld (de), a 79 | inc de 80 | 81 | push hl 82 | ld hl, BUFF 83 | inc (hl) 84 | pop hl 85 | 86 | inc ix 87 | inc ix 88 | inc ix 89 | djnz @copy1 90 | dec de 91 | xor a 92 | ld (de), a 93 | 94 | ld hl, BUFF 95 | dec (hl) 96 | ret 97 | 98 | 99 | ; Converts ASCIIz to FCB 100 | ; HL - ASCIIz name 101 | ; DE - fcb ptr 102 | ascciz_to_fcb: 103 | xor a 104 | ld (de), a 105 | 106 | inc de 107 | ld b, 8 108 | @loop_name: 109 | ld a, (hl) 110 | 111 | and #7f 112 | jr z, @fill_zeros 113 | 114 | cp '.' 115 | jr z, @fill_zeros 116 | 117 | cp '*' 118 | jp z, @fill_mask 119 | 120 | cp ':' 121 | ret z 122 | 123 | call uppercase 124 | ld (de), a 125 | 126 | inc hl 127 | inc de 128 | djnz @loop_name 129 | @fill_zeros: 130 | ld a, b 131 | and a 132 | jr z, @ext_copy 133 | ld a, ' ' 134 | @zeros_loop: 135 | ld (de), a 136 | inc de 137 | djnz @zeros_loop 138 | @ext_copy: 139 | ld a, (hl) 140 | cp '.' 141 | jr nz, @do_copy 142 | inc hl 143 | @do_copy: 144 | ld b, 3 145 | @ext_loop: 146 | ld a, (hl) 147 | 148 | and #7f 149 | jr z, @fin 150 | 151 | cp '*' 152 | jr z, @fill_mask2 153 | 154 | call uppercase 155 | ld (de), a 156 | inc hl 157 | inc de 158 | djnz @ext_loop 159 | @fin: 160 | ld a, b 161 | and a 162 | ret z 163 | ld a, ' ' 164 | @fin_loop: 165 | ld (de), a 166 | inc de 167 | djnz @fin_loop 168 | ret 169 | 170 | @fill_mask: 171 | inc hl 172 | ld a, b 173 | or a 174 | jr z, @ext_copy 175 | ld a, '?' 176 | @mask_loop: 177 | ld (de), a 178 | inc de 179 | djnz @mask_loop 180 | jr @ext_copy 181 | 182 | @fill_mask2: 183 | ld a, b 184 | or a 185 | jr z, @ext_copy 186 | ld a, '?' 187 | @mask_loop2: 188 | ld (de), a 189 | inc de 190 | djnz @mask_loop2 191 | ret 192 | 193 | 194 | uppercase: 195 | cp 'a' 196 | jr c, @skip 197 | cp 'z' + 1 198 | jr nc, @skip 199 | and %01011111 200 | @skip: 201 | ret 202 | 203 | fcb_template: 204 | db 0 ; Drive 205 | db " " 206 | db 0, 0, 0, 0 207 | 208 | -------------------------------------------------------------------------------- /src/zinc/edos/buffers.asm: -------------------------------------------------------------------------------- 1 | ;; EDOS - Emulation DOS. BDOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | ;; This file contains internal variables and buffers for ZINC 7 | ;; They shouldn't be included in final binary and they all undefined by default 8 | 9 | dir: 10 | ds 128 11 | 12 | dos_name: 13 | ds 12 14 | 15 | ;; Used for renaming 16 | old_dos_name: 17 | ds 12 18 | 19 | tmp_fcb: 20 | ds $10 21 | 22 | path_buffer: 23 | ds $7f 24 | 25 | DS_LEN: equ 31 26 | dir_struct: 27 | ds DS_LEN 28 | 29 | ffs_file_struct: 30 | ffs_size: ds 4 31 | ffs_date: ds 2 32 | ffs_time: ds 2 33 | ffs_attr: ds 1 34 | ffs_name: ds 13 35 | ffs_lfn: ds 256 36 | 37 | ds 32 38 | bios_stack: 39 | 40 | ds 36 41 | stack: -------------------------------------------------------------------------------- /src/zinc/edos/console.asm: -------------------------------------------------------------------------------- 1 | ;; EDOS - Emulation DOS. BDOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | ;; Works similar to real BDOS 7 | console_in: 8 | call CONIN 9 | ld l, a 10 | 11 | call check 12 | ret c 13 | 14 | cp BS 15 | ret z 16 | 17 | push af 18 | ld c, a 19 | call CONOUT 20 | pop af 21 | 22 | ret 23 | 24 | check: 25 | cp CR 26 | ret z 27 | 28 | cp LF 29 | ret z 30 | 31 | cp TAB 32 | ret z 33 | 34 | cp ' ' 35 | ret 36 | 37 | ;; I think we can here skip a bit complex things 38 | console_out: 39 | jp CONOUT 40 | 41 | 42 | console_status: 43 | call CONST 44 | and a 45 | jr z, @exit 46 | 47 | CALL CONIN 48 | 49 | cp CNTRLC 50 | ld a, $ff 51 | jr nz, @exit 52 | 53 | ld hl, @msg 54 | ld bc, 0 55 | xor a 56 | rst.lil $18 57 | 58 | jp bye 59 | @msg: 60 | db 13, 10, "CTRL-C pressed, aborting execution", 13, 10, 0 61 | 62 | @exit: 63 | xor a 64 | ld b, a 65 | ret 66 | 67 | raw_io: 68 | ld a, (args) 69 | inc a 70 | jr nz, @out 71 | 72 | call CONST 73 | or a 74 | ret z 75 | 76 | jp CONIN 77 | @out: 78 | ld a, (args) 79 | ld c, a 80 | call CONOUT 81 | 82 | xor a 83 | ld b, a 84 | ret 85 | 86 | get_io_byte: 87 | ld a, (IOBYTE) 88 | ret 89 | 90 | set_io_byte: 91 | ld a, c 92 | ld (IOBYTE), a 93 | ret 94 | 95 | ;; Why not use MOS function? 96 | ;; Cause IOBYTE - this function can be used for UART too 97 | write_str: 98 | ld b, d 99 | ld c, e 100 | @w: 101 | ld a, (bc) 102 | cp '$' 103 | ret z 104 | inc bc 105 | 106 | push bc 107 | ld c,a 108 | call console_out 109 | pop bc 110 | 111 | jr @w 112 | 113 | ;; Using MOS routines for line editing 114 | read_buf: 115 | ld a, d 116 | or e 117 | jr nz, @read 118 | 119 | ld de, (dma_ptr) 120 | @read: 121 | ex de, hl 122 | ld a, (hl) 123 | 124 | ld bc, 2 125 | add hl, bc 126 | 127 | ld b, 0 128 | ld c, a 129 | 130 | ld e, 1 131 | MOSCALL MOS_EDIT_LINE 132 | cp 27 133 | jr z, @err 134 | 135 | push hl 136 | ld a, CR 137 | rst.lil $10 138 | pop hl 139 | 140 | push hl 141 | ld e, 0 142 | @strlen: 143 | ld a, (hl) 144 | or a 145 | jr z, @done 146 | inc e 147 | inc hl 148 | jr @strlen 149 | @done: 150 | ld a, e 151 | pop hl 152 | 153 | dec hl 154 | ld (hl), a 155 | 156 | ld d, 0 157 | xor a 158 | ld b, a 159 | ret 160 | @err: 161 | ld hl, @msg 162 | ld bc, 0 163 | xor a 164 | rst.lil $18 165 | 166 | jp bye 167 | @msg: 168 | db 13, 10, "Input interrupted, aborting execution", 13, 10, 0 -------------------------------------------------------------------------------- /src/zinc/edos/core.asm: -------------------------------------------------------------------------------- 1 | ;; EDOS - Emulation DOS. BDOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | include "../../mos.asm" 7 | entrypoint: 8 | jp edos 9 | jp init 10 | 11 | ;; "BDOS" entrypoint - routing functions 12 | edos: 13 | ld a, c 14 | ld (fun), a 15 | cp NFUNC + 1 16 | ret nc 17 | 18 | di 19 | ld (user_stk), sp 20 | ld sp, stack 21 | ei 22 | push ix 23 | push iy 24 | push de 25 | 26 | ld hl, bdos_return 27 | push hl 28 | 29 | ld (args), de 30 | 31 | ld b, 0 32 | ld hl, fun_table 33 | add hl, bc 34 | add hl, bc 35 | 36 | ld e, (hl) 37 | inc hl 38 | ld d, (hl) 39 | 40 | ld hl, (args) 41 | ex de, hl 42 | 43 | ld c, e 44 | jp (hl) 45 | 46 | 47 | bdos_return: 48 | di 49 | pop de 50 | pop iy 51 | pop ix 52 | ld sp, (user_stk) 53 | ei 54 | 55 | ld h, b 56 | ld l, a 57 | ret 58 | 59 | fun_table: 60 | dw bye ; 00 Reset 61 | dw console_in ; 01 Console in 62 | dw console_out ; 02 Console out 63 | 64 | dw READER ; 03 Aux read 65 | dw print ; 04 Aux write 66 | dw print ; 05 Printer write 67 | 68 | dw raw_io ; 06 Raw IO 69 | dw get_io_byte ; 07 Get IO Byte 70 | dw set_io_byte ; 08 Set IO Byte 71 | dw write_str ; 09 PrintStr$ 72 | dw read_buf ; 10 Buffered read 73 | dw console_status ; 11 Console status 74 | dw dos_ver ; 12 CP/M Version 75 | dw do_nothing ; 13 Reset disks 76 | dw do_nothing ; 14 Set drive 77 | dw fopen ; 15 fopen 78 | dw fclose ; 16 fclose 79 | dw catalog_get_first ; 17 First in directory 80 | dw catalog_scan_next ; 18 Next record in directory 81 | dw fdelete ; 19 Delete file 82 | dw fread ; 20 fread 83 | dw fwrite ; 21 fwrite 84 | dw fcreate ; 22 fcreate 85 | dw frename ; 23 frename 86 | dw get_drives ; 24 bitmap of drives 87 | dw get_drive ; 25 current drive 88 | dw set_dma ; 26 set DMA 89 | dw do_nothing ; 27 Get alloc bitmap 90 | dw do_nothing ; 28 Write protect drive 91 | dw do_nothing ; 29 Get read only drives vector 92 | dw do_nothing ; 30 Set file attributes 93 | dw get_dpb ; 31 Get DPB address 94 | dw do_nothing ; 32 Get user area 95 | dw fread_rnd ; 33 Random read 96 | dw fwrite_rnd ; 34 Random write 97 | dw calc_size ; 35 Compute file size 98 | dw calc_random_offset ; 36 Update random access pointer 99 | dw do_nothing ; 37 reset selected disks 100 | dw do_nothing ; 38 not used in CP/M 2.2 101 | dw do_nothing ; 39 not used in CP/M 2.2 102 | dw fwrite_rnd ; 40 fill random access block with zeros 103 | dw do_nothing ; 41 104 | 105 | bye: 106 | jp.lil ZINC_EXIT 107 | 108 | ;; Just send byte to VDP "Printer" 109 | print: 110 | ld c, e 111 | jp list 112 | 113 | do_nothing: 114 | xor a 115 | ld hl, 0 116 | ret 117 | 118 | dos_ver: 119 | xor a 120 | ld h, a 121 | ld b, a 122 | ld a, DOSVER 123 | ld l, a 124 | ld c, a 125 | ret 126 | 127 | include "console.asm" 128 | include "fcb.asm" 129 | include "disk.asm" 130 | 131 | fun: db $00 132 | args: dw $00 133 | dma_ptr: dl EDOS_BASE + $80 134 | 135 | user_stk: dw $00 136 | 137 | align $100 138 | 139 | include "ebios/index.asm" 140 | include "buffers.asm" 141 | -------------------------------------------------------------------------------- /src/zinc/edos/disk.asm: -------------------------------------------------------------------------------- 1 | ;; EDOS - Emulation DOS. BDOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | get_drives: 7 | ld hl,1 8 | 9 | xor a 10 | ld b, a 11 | ret 12 | 13 | get_drive: 14 | xor a 15 | 16 | ld b, a 17 | ret 18 | 19 | set_dma: 20 | ld (dma_ptr), de 21 | 22 | xor a 23 | ld b, a 24 | ret 25 | 26 | get_dpb: 27 | ld hl, dpb 28 | 29 | xor a 30 | ld b, a 31 | ret 32 | 33 | catalog_get_first: 34 | ld hl, mask 35 | ex de, hl 36 | ld bc, 12 37 | ldir 38 | 39 | ld hl, dir_struct 40 | MOSCALL MOS_CLOSEDIR 41 | 42 | call init_dir 43 | catalog_scan_next: 44 | ld hl, dir_struct 45 | ld de, ffs_file_struct 46 | MOSCALL MOS_READDIR 47 | 48 | ld a, (ffs_lfn) 49 | or a 50 | jp z, nope 51 | 52 | ld a, (ffs_attr) 53 | and $10 ;; ATTR_DIR 54 | jr nz, catalog_scan_next 55 | 56 | ld hl, mask 57 | ld a, (hl) 58 | cp '?' 59 | jr z, scan_ok 60 | 61 | ld de, tmp_fcb 62 | ld hl, ffs_lfn 63 | call ascciz_to_fcb 64 | 65 | ;; Mask check 66 | ld hl, mask + 1 67 | ld de, tmp_fcb + 1 68 | 69 | ld b, 11 70 | @chk_msk: 71 | ld a, (hl) 72 | and $7f 73 | cp '?' 74 | jr z, @masked 75 | 76 | ld c, a 77 | ld a, (de) 78 | cp c 79 | 80 | jr nz, catalog_scan_next 81 | @masked: 82 | inc hl 83 | inc de 84 | djnz @chk_msk 85 | 86 | jr scan_ok 87 | 88 | nope: 89 | ld a, -1 90 | ld b, a 91 | ld hl, -1 92 | ret 93 | 94 | scan_ok: 95 | ld de, (dma_ptr) 96 | ld hl, ffs_lfn 97 | call ascciz_to_fcb 98 | 99 | xor a 100 | ld b, a 101 | ret 102 | 103 | ;; Calculation file lenght 104 | ;; Routine works not very correct, but many CP/M emulators skip this step 105 | ;; Honestly, not most necessary part of this project :-) 106 | xor a 107 | ld b, a 108 | 109 | ld ix, (dma_ptr) 110 | 111 | ld hl, (ffs_size) 112 | 113 | ld a, h 114 | and $3f ;; Limit with 16k 115 | ld h, a 116 | 117 | add hl, hl 118 | ld a, h 119 | 120 | and $7f 121 | 122 | ld (ix + FCB_RC), a 123 | 124 | ld hl, (ffs_size + 1) 125 | ld a, (ffs_size) 126 | add a, a 127 | adc hl, hl 128 | 129 | add a, a 130 | adc hl, hl 131 | 132 | ld a, h 133 | and 31 134 | ld (ix + FCB_EX), a 135 | 136 | xor a 137 | ld b, a 138 | ret 139 | 140 | mask: 141 | db "????????????" 142 | 143 | init_dir: 144 | ld hl, path_buffer 145 | ld bc, $7f 146 | MOSCALL MOS_CWD 147 | 148 | ld hl, dir_struct 149 | ld de, dir_struct + 1 150 | ld bc, DS_LEN - 1 151 | xor a 152 | ld (hl), a 153 | ldir 154 | 155 | ld hl, dir_struct 156 | ld de, path_buffer 157 | MOSCALL MOS_OPENDIR 158 | ret 159 | 160 | _open: 161 | ld c, 0 162 | MOSCALL MOS_FCLOSE 163 | 164 | ld hl, (args) 165 | call fcb_to_asciiz_name 166 | 167 | ld hl, dos_name 168 | ld c, FA_READ + FA_WRITE 169 | MOSCALL MOS_FOPEN 170 | 171 | ;; Store file pointer 172 | ld de, (args) 173 | ld hl, FCB_FP 174 | add hl, de 175 | ld (hl), a 176 | ld c, a 177 | 178 | ret 179 | 180 | fopen: 181 | call _open 182 | 183 | or a 184 | jp z, err 185 | 186 | xor a 187 | ld b, a 188 | ret 189 | 190 | frename: 191 | ld hl, (args) 192 | call fcb_to_asciiz_name 193 | 194 | ld hl, dos_name 195 | ld de, old_dos_name 196 | ld bc, 12 197 | ldir 198 | 199 | ld hl, (args) 200 | ld de, 16 201 | add hl, de 202 | call fcb_to_asciiz_name 203 | 204 | ld.lil hl, old_dos_name 205 | ld.lil de, dos_name 206 | MOSCALL MOS_RENAME 207 | or a 208 | ld b, a 209 | ret z 210 | 211 | ld a, #ff 212 | ret 213 | 214 | fcreate: 215 | ld hl, (args) 216 | call fcb_to_asciiz_name 217 | 218 | ld hl, dos_name 219 | ld c, FA_READ + FA_WRITE + FA_CREATE 220 | MOSCALL MOS_FOPEN 221 | 222 | or a 223 | jp z, err 224 | 225 | ld de, (args) 226 | ld hl, FCB_FP 227 | add hl, de 228 | ld a, (hl) 229 | ld c, a 230 | 231 | xor a 232 | ret 233 | 234 | ;; Not it's just dummy implementation - all files will be closed on any file operations 235 | ;; And exit from CP/M emulator 236 | fclose: 237 | ld c, 0 238 | MOSCALL MOS_FCLOSE 239 | 240 | xor a 241 | ret 242 | 243 | fdelete: 244 | ex de, hl 245 | call fcb_to_asciiz_name 246 | ld hl, dos_name 247 | MOSCALL MOS_DELETE 248 | 249 | xor a 250 | ret 251 | 252 | ;; Random write 253 | fwrite_rnd: 254 | call _open 255 | or a 256 | jr z, err 257 | call set_rnd_offset 258 | jr do_write 259 | 260 | ;; Sequental write 261 | fwrite: 262 | call _open 263 | or a 264 | jr z, err 265 | 266 | call fcb_calc_offset 267 | do_write: 268 | MOSCALL MOS_FSEEK 269 | 270 | ld.lil hl, (dma_ptr) 271 | do_write_pointer: 272 | ld de, $80 273 | MOSCALL MOS_FWRITE 274 | 275 | call fcb_next_record 276 | 277 | xor a 278 | ret 279 | err: 280 | ld a, #ff 281 | ld b, a 282 | ret 283 | 284 | clean_dma: 285 | ld de, (dma_ptr) 286 | ld hl, 1 287 | add hl, de 288 | ex de, hl 289 | 290 | ld bc, $7f 291 | ld a, $1a 292 | ld (hl), a 293 | ldir 294 | 295 | ret 296 | 297 | set_rnd_offset: 298 | ld de, (args) 299 | ld hl, FCB_FP 300 | add hl, de 301 | ld a, (hl) 302 | ld c, a 303 | 304 | ld de, (args) 305 | ld hl, FCB_RN 306 | add hl, de 307 | ld hl, (hl) 308 | 309 | add.lil hl, hl ; *2 310 | add.lil hl, hl ; *4 311 | add.lil hl, hl ; *8 312 | add.lil hl, hl ; *16 313 | add.lil hl, hl ; *32 314 | add.lil hl, hl ; *64 315 | add.lil hl, hl ; *128 316 | ld de, 0 317 | ret 318 | 319 | ;; Random read 320 | fread_rnd: 321 | call _open 322 | or a 323 | jp z, err 324 | 325 | call clean_dma 326 | call set_rnd_offset 327 | 328 | jr read_offset 329 | 330 | ;; Sequental read 331 | fread: 332 | call clean_dma 333 | 334 | call _open 335 | or a 336 | jp z, err 337 | 338 | call fcb_calc_offset 339 | read_offset: 340 | MOSCALL MOS_FSEEK 341 | 342 | ld.lil hl, (dma_ptr) 343 | ld de, $80 344 | MOSCALL MOS_FREAD 345 | 346 | ld a, d 347 | or e 348 | ld a, $01 349 | ret z 350 | 351 | call fcb_next_record 352 | 353 | xor a 354 | ld b, a 355 | ret 356 | 357 | ;; DE - FCB 358 | calc_size: 359 | ex de, hl 360 | call fcb_to_asciiz_name 361 | 362 | ld.lil de, dos_name 363 | ld.lil hl, ffs_file_struct 364 | MOSCALL MOS_FSTAT 365 | or a 366 | jr nz, @nope 367 | 368 | ld.lil hl, (ffs_size) 369 | add.lil hl, hl 370 | 371 | ld a, l 372 | and $7f 373 | jr z, @skip 374 | 375 | ld de, $100 376 | add.lil hl, de 377 | @skip: 378 | ld.lil (@buff), hl 379 | 380 | ld hl, (args) 381 | ld de, FCB_RN 382 | add hl, de 383 | 384 | ld de, (@buff + 1) 385 | ld (hl), de 386 | 387 | xor a 388 | ld b, a 389 | ret 390 | @nope: 391 | ld a, $ff 392 | ret 393 | @buff: 394 | dl 0 395 | -------------------------------------------------------------------------------- /src/zinc/edos/ebios/console.asm: -------------------------------------------------------------------------------- 1 | ;; EBIOS - Emulation BIOS. BIOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | 7 | bios_const: 8 | LOCALSP 9 | call.lil ZINC_TERMST 10 | RESTORESP 11 | ret 12 | 13 | bios_in: 14 | LOCALSP 15 | call.lil ZINC_TERMIN 16 | RESTORESP 17 | ret 18 | 19 | bios_out: 20 | LOCALSP 21 | call.lil ZINC_TERMOUT 22 | RESTORESP 23 | ret -------------------------------------------------------------------------------- /src/zinc/edos/ebios/disk.asm: -------------------------------------------------------------------------------- 1 | ;; EBIOS - Emulation BIOS. BIOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | bios_seldsk: 7 | ld hl, dph 8 | ret 9 | 10 | bios_dma: 11 | ld (dma_ptr), bc 12 | ret 13 | 14 | dph: 15 | dw 0, 0, 0, 0, dir, dpb, 0, 0 16 | 17 | ;; Almost random data - no direct disk operations will be allowed anyway 18 | ;; I've used from Agon's CP/M 2.2 19 | dpb: 20 | dw 64 ;sectors per track 21 | db 6 ;block shift factor 22 | db 63 ;block mask 23 | db 3 ;null mask 24 | dw 1023 ;disk size-1 25 | dw 2047 ;directory max 26 | db $ff ;alloc 0 27 | db 0 ;alloc 1 28 | dw 0 ;check size - don't care about it - SD card isn't removable 29 | dw 0 ;track offset 30 | -------------------------------------------------------------------------------- /src/zinc/edos/ebios/index.asm: -------------------------------------------------------------------------------- 1 | ;; EBIOS - Emulation BIOS. BIOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | include "ebios/macro.asm" 7 | 8 | ;; BIOS have same layout as usual CP/M BIOS 9 | ;; It's required cause a lot of applications making direct calls 10 | ;; to BIOS. And this is reason why it should be aligned. 11 | 12 | BOOT: JP bye 13 | WBOOT: JP bye 14 | CONST: JP bios_const 15 | CONIN: JP bios_in 16 | CONOUT: JP bios_out 17 | 18 | LIST: JP list 19 | PUNCH: JP nothing 20 | READER: JP reader 21 | 22 | HOME: JP nothing 23 | SELDSK: JP bios_seldsk 24 | SETTRK: JP nothing 25 | SETSEC: JP nothing 26 | SETDMA: JP bios_dma 27 | READ: JP direct ;; Your app shouldn't call this function directly. NEVER 28 | WRITE: JP direct ;; Your app shouldn't call this function directly. NEVER 29 | PRSTAT: JP nothing 30 | SECTRN: JP nothing 31 | 32 | nothing: 33 | ld a, $ff 34 | ret 35 | 36 | list: 37 | LOCALSP 38 | 39 | ld a, c 40 | ld (@char), a 41 | ld hl, @vdu 42 | ld bc, 4 43 | rst.lil $18 44 | 45 | RESTORESP 46 | ret 47 | @vdu: 48 | db 2, 1 49 | @char: 50 | db 0 51 | db 3 52 | 53 | reader: 54 | ld a, 26 55 | ret 56 | 57 | direct: 58 | ld hl, @msg 59 | ld bc, 0 60 | xor a 61 | rst.lil $18 62 | jp bye 63 | @msg: 64 | db 13, 10 65 | db "Direct disk reading/writing via BIOS aren't supported!", 13, 10 66 | db "Execution stopped", 13, 10, 0 67 | 68 | 69 | init: 70 | ld sp, $ffff 71 | 72 | call init_dir 73 | 74 | ld hl, banner 75 | ld bc, 0 76 | xor a 77 | rst.lil $18 78 | 79 | ;; Cleaning last keypress on start - no waiting for key on start of some apps 80 | xor a 81 | ld.lil (hl), a 82 | ld (TDRIVE), a 83 | 84 | ld a, $c3 ;; JP instruction 85 | 86 | ld (0), a 87 | ld hl, WBOOT 88 | ld (1), hl 89 | 90 | ld (5), a 91 | ld hl, entrypoint 92 | ld (6), hl 93 | 94 | ld bc, DEFDMA 95 | ld (dma_ptr), bc 96 | 97 | ld a, 1 98 | ld (IOBYTE), a 99 | 100 | call TPA 101 | jp bye 102 | 103 | banner: 104 | db 4 105 | db 13,10, 17, 1 106 | db "ZINC is Not CP/M", 13, 10, 17, 2 107 | db "(c) 2024 Aleksandr Sharikhin", 13, 10, 17, 15 108 | db "This version was built: " 109 | incbin "../../../.version" 110 | db 13, 10, 0 111 | 112 | include "ebios/console.asm" 113 | include "ebios/disk.asm" 114 | 115 | 116 | user_sp_ptr: 117 | dw $00 118 | 119 | 120 | -------------------------------------------------------------------------------- /src/zinc/edos/ebios/macro.asm: -------------------------------------------------------------------------------- 1 | ;; EBIOS - Emulation BIOS. BIOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | macro LOCALSP 7 | di 8 | ld (user_sp_ptr), sp 9 | ld sp, bios_stack 10 | push ix 11 | push iy 12 | ei 13 | endmacro 14 | 15 | macro RESTORESP 16 | di 17 | pop iy 18 | pop ix 19 | ld sp, (user_sp_ptr) 20 | ei 21 | endmacro 22 | -------------------------------------------------------------------------------- /src/zinc/edos/edos.asm: -------------------------------------------------------------------------------- 1 | ;; EDOS - Emulation DOS. BDOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | include "../config.asm" 7 | ASSUME ADL=1 8 | org EDOS_ORG 9 | ASSUME ADL=0 10 | 11 | include "core.asm" -------------------------------------------------------------------------------- /src/zinc/edos/fcb.asm: -------------------------------------------------------------------------------- 1 | ;; EDOS - Emulation DOS. BDOS emulation layer for ZINC 2 | ;; (c) 2024 Aleksandr Sharikhin 3 | ;; 4 | ;; All rights are reserved 5 | 6 | ;; ---------------------------------------------------------------------------- 7 | 8 | FCB_CR: equ $20 ; Current record 9 | FCB_RC: equ $0F 10 | FCB_EX: equ $0c ; Current record extend 11 | FCB_S2: equ $0e ; Extend high byte 12 | FCB_S1: equ $0d ; Reserved :-) 13 | FCB_RN: equ $21 14 | 15 | FCB_FP: equ $19 16 | 17 | FCB_MAX_CR: equ $81 18 | FCB_MAX_EX: equ $32 19 | FCB_MAX_S2: equ $15 20 | 21 | fcb_calc_offset: 22 | push ix 23 | ld ix, (args) 24 | 25 | ld c, (IX + FCB_FP) 26 | ld h, $80 27 | ld l, (IX + FCB_CR) 28 | mlt hl 29 | 30 | ld a, (IX + FCB_EX) 31 | ld de, $4000 32 | or a 33 | @check: 34 | jr z, @exit 35 | add.lil hl, de 36 | dec a 37 | jr @check 38 | ;; TODO: Calc S2 too 39 | @exit: 40 | ld e, 0 41 | pop ix 42 | ret 43 | 44 | calc_random_offset: 45 | push ix 46 | ld ix, (args) 47 | 48 | ld l, (IX + FCB_EX) 49 | ld h, $80 50 | mlt hl 51 | 52 | ld d, 0 53 | ld e, (IX + FCB_CR) 54 | 55 | add hl, de 56 | 57 | ld (ix + FCB_RN), hl 58 | 59 | pop ix 60 | xor a 61 | ret 62 | 63 | ; IX - FCB 64 | fcb_next_record: 65 | push ix 66 | ld ix, (args) 67 | ld a, (ix + FCB_CR) 68 | inc a 69 | cp FCB_MAX_CR 70 | jr c, @write_cr 71 | 72 | ld a, 1 73 | @write_cr: 74 | ld (ix + FCB_CR), a 75 | jr c, @exit 76 | 77 | ld a, (ix + FCB_EX) 78 | inc a 79 | cp FCB_MAX_EX 80 | jr c, @write_ex 81 | 82 | xor a 83 | @write_ex: 84 | ld (ix + FCB_EX), a 85 | jr c, @exit 86 | 87 | ld a, (ix + FCB_S2) 88 | inc a 89 | and FCB_MAX_S2 90 | ld (ix + FCB_S2), a 91 | @exit: 92 | pop ix 93 | ret 94 | 95 | ; Converts FCB to ASCIIz filename 96 | ; HL - FCB pointer 97 | ; Output will be in 'dos_name' var 98 | fcb_to_asciiz_name: 99 | inc hl 100 | push hl 101 | ld de, dos_name 102 | ld b, 8 103 | @loop_name: 104 | ld a, (hl) 105 | and #7f 106 | cp ' ' 107 | jr z, @ext 108 | ld (de), a 109 | inc hl 110 | inc de 111 | djnz @loop_name 112 | @ext: 113 | pop hl 114 | ld bc, 8 115 | add hl, bc 116 | 117 | ld a, (hl) 118 | and #7f 119 | jr z, @fin 120 | 121 | ld a, '.' 122 | ld (de), a 123 | inc de 124 | ld b, 3 125 | @loop_ext: 126 | ld a, (hl) 127 | and #7f 128 | cp ' ' 129 | jr z, @fin 130 | ld (de), a 131 | inc hl 132 | inc de 133 | djnz @loop_ext 134 | @fin: 135 | xor a 136 | ld (de), a 137 | ret 138 | 139 | ; Converts ASCIIz to FCB 140 | ; HL - ASCIIz name 141 | ; DE - fcb ptr 142 | ascciz_to_fcb: 143 | xor a 144 | ld (de), a 145 | 146 | inc de 147 | ld b, 8 148 | @loop_name: 149 | ld a, (hl) 150 | 151 | and #7f 152 | jr z, @fill_zeros 153 | 154 | cp '.' 155 | jr z, @fill_zeros 156 | 157 | call uppercase 158 | ld (de), a 159 | 160 | inc hl 161 | inc de 162 | djnz @loop_name 163 | @fill_zeros: 164 | ld a, b 165 | and a 166 | jr z, @ext_copy 167 | ld a, ' ' 168 | @zeros_loop: 169 | ld (de), a 170 | inc de 171 | djnz @zeros_loop 172 | @ext_copy: 173 | ld a, (hl) 174 | cp '.' 175 | jr nz, @do_copy 176 | inc hl 177 | @do_copy: 178 | ld b, 3 179 | @ext_loop: 180 | ld a, (hl) 181 | 182 | and #7f 183 | jr z, @fin 184 | 185 | call uppercase 186 | ld (de), a 187 | inc hl 188 | inc de 189 | djnz @ext_loop 190 | @fin: 191 | ld a, b 192 | and a 193 | ret z 194 | ld a, ' ' 195 | @fin_loop: 196 | ld (de), a 197 | inc de 198 | djnz @fin_loop 199 | ret 200 | 201 | uppercase: 202 | cp 'a' 203 | jr c, @skip 204 | 205 | cp 'z' + 1 206 | jr nc, @skip 207 | 208 | and %01011111 209 | @skip: 210 | ret -------------------------------------------------------------------------------- /src/zinc/options.asm: -------------------------------------------------------------------------------- 1 | options: 2 | 3 | serial_speed: 4 | dl 57600 5 | serial_bits: 6 | db 8 7 | serial_stop_bits: 8 | db 1 9 | serial_parity_control: 10 | db 0 11 | 12 | db 0 13 | db 0 14 | 15 | options_end: -------------------------------------------------------------------------------- /src/zinc/terminal.asm: -------------------------------------------------------------------------------- 1 | ;; ZINC is Not CP/M 2 | ;; 3 | ;; CP/M compatibility layer for Agon's MOS 4 | ;; (c) 2024 Aleksandr Sharikhin 5 | ;; 6 | ;; All rights are reserved 7 | 8 | ;; Terminal emulation layer 9 | 10 | ;; Emulates simple ADM-3a like terminal 11 | ;; It's good enough and fast 12 | 13 | TERM_HOME: equ $01 14 | TERM_BELL: equ $07 15 | TERM_LEFT: equ $08 16 | TERM_FF: equ $0C 17 | TERM_UP: equ $14 18 | TERM_LEFT2: equ $16 19 | TERM_RIGHT: equ $17 20 | TERM_CLINE: equ $18 21 | TERM_CLS2: equ $1A 22 | TERM_ESC: equ $1B 23 | TERM_RS: equ $1E 24 | 25 | TERM_COORDS: equ '=' 26 | TERM_SWITCH: equ $ff 27 | TERM_FG: equ 'f' 28 | TERM_BG: equ 'b' 29 | 30 | macro VDU byte 31 | ld a, byte 32 | rst.lil $10 33 | endmacro 34 | 35 | ;; Little preparation for work - setting variables and other things 36 | term_init: 37 | MOSCALL MOS_SYS_VARS 38 | 39 | lea hl, ix + VAR_CURSORX 40 | ld (term_pos), hl 41 | 42 | lea hl, ix + VAR_SCRWIDTH 43 | ld (term_size), hl 44 | 45 | lea hl, ix + VAR_VDP_DONE 46 | ld (cmd_done), hl 47 | 48 | lea hl, ix + VAR_KEYASCII ;; ASCII KEYCODE 49 | ld (keycode_ptr), hl 50 | 51 | lea hl, ix + VAR_KEYDOWN ;; VKEYDOWN 52 | ld (keydown_ptr), hl 53 | 54 | lea hl, ix + VAR_VKEYCOUNT ;; VKEYCOUNT 55 | ld (keycount_ptr), hl 56 | 57 | ld hl, @cmd 58 | ld bc, 4 59 | rst.lil $18 60 | 61 | jp uart_init 62 | @cmd: 63 | db 23, 0, $98, 0 64 | 65 | 66 | term_free: 67 | MOSCALL MOS_UCLOSE 68 | 69 | ld hl, @cmd 70 | ld bc, @end - @cmd 71 | rst.lil $18 72 | 73 | ret 74 | @cmd: 75 | db 23, 0, $98, 1 76 | @end: 77 | 78 | termstatus: 79 | ld a, (IOBYTE + EDOS_BASE) 80 | and 3 81 | jp z, uart_status 82 | console_status: 83 | ld hl, (keycount_ptr) 84 | ld a, (hl) 85 | and a 86 | ret.lil z 87 | 88 | ld hl, (keydown_ptr) 89 | ld a, (hl) 90 | and a 91 | ret.lil z 92 | 93 | ld hl, (keycode_ptr) 94 | ld a, (hl) 95 | and $7f 96 | ld (keycode), a 97 | ret.lil z 98 | 99 | ld a, $ff 100 | ret.lil 101 | 102 | termin: 103 | ld a, (IOBYTE + EDOS_BASE) 104 | and 3 105 | jp z, uart_in 106 | console_in: 107 | @rep: 108 | ld hl, (keycount_ptr) 109 | ld a, (hl) 110 | and a 111 | jr z, @rep 112 | 113 | ld hl, (keydown_ptr) 114 | ld a, (hl) 115 | and a 116 | jr z, @rep 117 | 118 | ld hl, (keycode_ptr) 119 | ld a, (hl) 120 | and $7f 121 | ld (keycode), a 122 | jr z, @rep 123 | 124 | xor a 125 | ld hl, (keydown_ptr) 126 | ld (hl), a 127 | 128 | ld a, (keycode) 129 | cp $15 130 | jr nz, @ok 131 | ld a, CNTRLL 132 | 133 | @ok: 134 | ret.lil 135 | 136 | termout: 137 | ld a, (IOBYTE + EDOS_BASE) 138 | and 3 139 | ld a, c 140 | jp z, uart_out 141 | console_out: 142 | call _putc 143 | term_fsm: equ $ - 3 144 | ret.lil 145 | 146 | _cls: 147 | VDU 12 148 | ret 149 | 150 | _home: 151 | VDU 30 152 | ret 153 | 154 | _left: 155 | VDU 8 156 | ret 157 | _up: 158 | VDU 11 159 | ret 160 | _right: 161 | VDU 9 162 | ret 163 | 164 | _bell: 165 | VDU 7 166 | ret 167 | 168 | _esc: 169 | ;; Load coordinates 170 | cp TERM_COORDS 171 | jr z, @load_coords 172 | 173 | ;; Disable terminal emulation routine 174 | cp TERM_SWITCH 175 | jr z, @term_switch 176 | ;; Load foreground color 177 | cp TERM_FG 178 | jr z, @term_fg 179 | ;; Load background color 180 | cp TERM_BG 181 | jr z, @term_bg 182 | 183 | ;; You can add some ESC codes here 184 | jp exit_fsm 185 | @load_coords: 186 | ld hl, _loadx 187 | ld (term_fsm), hl 188 | ret 189 | @term_switch: 190 | ld hl, _vdp 191 | ld (term_fsm), hl 192 | ret 193 | @term_fg: 194 | ld hl, _fg 195 | ld (term_fsm), hl 196 | ret 197 | @term_bg: 198 | ld hl, _bg 199 | ld (term_fsm), hl 200 | ret 201 | 202 | 203 | _fg: 204 | and 63 205 | jr set_color 206 | 207 | jp exit_fsm 208 | 209 | _bg: 210 | and 63 211 | xor $80 212 | set_color: 213 | ld c, a 214 | 215 | ld a, 17 216 | rst.lil $10 217 | 218 | ld a, c 219 | rst.lil $10 220 | 221 | jp exit_fsm 222 | _vdp: 223 | cp TERM_ESC 224 | jr z, @vpd_esc 225 | 226 | rst.lil $10 227 | ret 228 | @vpd_esc: 229 | ld hl, _vdp_esc 230 | ld (term_fsm), hl 231 | ret 232 | 233 | _vdp_esc: 234 | cp TERM_SWITCH 235 | jr z, @back_to_emul 236 | 237 | push af 238 | ld a, TERM_ESC 239 | rst.lil $10 240 | pop af 241 | rst.lil $10 242 | 243 | ld hl, _vdp 244 | ld (term_fsm), hl 245 | ret 246 | @back_to_emul: 247 | ld hl, _putc 248 | ld (term_fsm), hl 249 | ret 250 | 251 | _loadx: 252 | sub 32 253 | ld (term_x), a 254 | 255 | ld hl, _loady 256 | ld (term_fsm), hl 257 | ret 258 | 259 | _loady: 260 | sub 32 261 | ld (term_y), a 262 | 263 | xor a 264 | ld mb, a 265 | 266 | ld hl, set_pos_cmd 267 | ld bc, 3 268 | rst.lil $18 269 | 270 | ld a, EDOS_PAGE 271 | ld mb, a 272 | 273 | exit_fsm: 274 | ld hl, _putc 275 | ld (term_fsm), hl 276 | ret 277 | 278 | _putc: 279 | cp TERM_FF 280 | jp z, _right 281 | 282 | cp ' ' 283 | jr nc, @draw 284 | 285 | cp TAB 286 | jp z, _tab 287 | 288 | cp CR 289 | jr z, @draw 290 | 291 | cp LF 292 | jr z, @draw 293 | 294 | cp TERM_BELL 295 | jp z, _bell 296 | 297 | ;; Move cursor 298 | cp TERM_LEFT 299 | jp z, _left 300 | cp TERM_LEFT2 301 | jp z, _left 302 | cp TERM_UP 303 | jp z, _up 304 | cp TERM_RIGHT 305 | jp z, _right 306 | 307 | 308 | ;; Home cursor 309 | cp TERM_HOME 310 | jp z, _home 311 | cp TERM_RS 312 | jp z, _home 313 | 314 | ;; Clear screen 315 | cp TERM_CLS2 316 | jp z, _cls 317 | 318 | cp TERM_CLINE 319 | jp z, _clear_line 320 | 321 | ;; ESC control sequences 322 | cp TERM_ESC 323 | jr z, @set_esc 324 | 325 | ;; Isolate rest things 326 | ret 327 | 328 | @draw: 329 | rst.lil $10 330 | ret 331 | 332 | @set_esc: 333 | ld hl, _esc 334 | ld (term_fsm), hl 335 | ret 336 | 337 | _tab: 338 | xor a 339 | ld mb, a 340 | 341 | call load_pos 342 | ld hl, (term_pos) 343 | ld a, (hl) 344 | @loop: 345 | and 15 346 | jr z, @exit 347 | push af 348 | VDU ' ' 349 | pop af 350 | inc a 351 | jr @loop 352 | 353 | @exit: 354 | ld a, EDOS_PAGE 355 | ld mb, a 356 | ret 357 | 358 | 359 | ;; Clear current line. Mostly cause KayPro - many softwares except that this command is implemented 360 | ;; Even if original ADM-3A haven't it 361 | _clear_line: 362 | xor a 363 | ld mb, a 364 | 365 | call load_pos 366 | call load_size 367 | 368 | ld hl, (term_pos) 369 | ld a, (hl) 370 | ld (@coords), a 371 | inc hl 372 | ld a, (hl) 373 | ld (@coords + 1), a 374 | 375 | ld hl, @cmd 376 | ld bc, 3 377 | rst.lil $18 378 | 379 | ld hl, (term_size) 380 | ld a, (hl) 381 | ld c, a 382 | ld a, (@coords) 383 | ld b, a 384 | ld a, c 385 | sub b 386 | ld b, a 387 | @loop: 388 | push bc 389 | VDU ' ' 390 | pop bc 391 | djnz @loop 392 | 393 | ld hl, @cmd 394 | ld bc, 3 395 | rst.lil $18 396 | 397 | ld a, EDOS_PAGE 398 | ld mb, a 399 | ret 400 | @cmd: 401 | db 31 402 | @coords: 403 | db 0 404 | db 0 405 | ;; It's more robust way be sure that our fetch command was executed 406 | cmd_result: 407 | ld hl, (cmd_done) 408 | @wait: 409 | ld a, (hl) 410 | and a 411 | jr z, @wait 412 | ret 413 | 414 | 415 | load_size: 416 | ld hl, (cmd_done) 417 | xor a 418 | ld (hl), a 419 | 420 | ld hl, @cmd 421 | ld bc, 3 422 | rst.lil $18 423 | jr cmd_result 424 | @cmd: 425 | db 23, 0, $86 426 | 427 | load_pos: 428 | ld hl, (cmd_done) 429 | xor a 430 | ld (hl), a 431 | 432 | ld hl, @cmd 433 | ld bc, 3 434 | rst.lil $18 435 | jr cmd_result 436 | @cmd: 437 | db 23, 0, $82 438 | 439 | set_pos_cmd: 440 | db 31 441 | term_y: 442 | db 0 443 | term_x: 444 | db 0 445 | 446 | cmd_done: 447 | dl 0 448 | term_pos: 449 | dl 0 450 | term_size: 451 | dl 0 452 | 453 | 454 | keycount_ptr: 455 | dl 0 456 | keydown_ptr: 457 | dl 0 458 | keycode_ptr: 459 | dl 0 460 | keycode: 461 | db 0 -------------------------------------------------------------------------------- /src/zinc/uart.asm: -------------------------------------------------------------------------------- 1 | UART_LSR_ETX: EQU $40 2 | UART_LSR_ETH: EQU $20 3 | UART_LSR_RDY: EQU $01 4 | 5 | UART_STATUS_REG: EQU $D5 6 | UART_DATA_REG: EQU $D0 7 | 8 | uart_init: 9 | ld ix, serial_speed 10 | MOSCALL MOS_UOPEN 11 | ret 12 | 13 | uart_status: 14 | in0 a, (UART_STATUS_REG) 15 | and UART_LSR_RDY 16 | ret.lil z 17 | 18 | ld a, $ff 19 | ret.lil 20 | 21 | uart_in: 22 | in0 a, (UART_STATUS_REG) 23 | and UART_LSR_RDY 24 | jr z, uart_in 25 | 26 | in0 a, (UART_DATA_REG) 27 | ret.lil 28 | 29 | uart_out: 30 | in0 a, (UART_STATUS_REG) 31 | and UART_LSR_ETX 32 | jr z, uart_out 33 | 34 | ld a, c 35 | out0 (UART_DATA_REG), a 36 | 37 | xor a 38 | ret.lil 39 | 40 | -------------------------------------------------------------------------------- /src/zinc/zinc.asm: -------------------------------------------------------------------------------- 1 | ;; ZINC is Not CP/M 2 | ;; 3 | ;; CP/M compatibility layer for Agon's MOS 4 | ;; (c) 2024 Aleksandr Sharikhin 5 | ;; 6 | ;; All rights are reserved 7 | 8 | 9 | ;; This file is entry point from MOS 10 | 11 | ;; ---------------------------------------------------------------------------- 12 | 13 | include "config.asm" 14 | include "../mos.asm" 15 | 16 | ASSUME ADL=1 17 | MAX_ARGS: EQU 15 18 | 19 | org ZINC_BASE 20 | jp _start 21 | bye_ptr: 22 | jp exit 23 | jp termout 24 | jp termstatus 25 | jp termin 26 | 27 | argc: 28 | db 0 29 | argv: 30 | dl 0 31 | 32 | 33 | align 64 34 | db "MOS" ;; HEADER 35 | db 0 ;; VERSION 36 | db 1 ;; ADL 37 | 38 | 39 | ;; ---------------------------------------------------------------------------- 40 | 41 | _start: 42 | push ix 43 | push iy 44 | ld (stack_save), sp 45 | 46 | ld ix,argv 47 | call _parse_args 48 | ld a,c 49 | ld (argc), a 50 | or a 51 | jp z, no_args 52 | 53 | ld hl, config_file 54 | ld de, options 55 | ld bc, options_end - options 56 | MOSCALL MOS_LOAD 57 | 58 | ;; building file name for executable 59 | ld hl, (argv) 60 | ld de, path_buffer 61 | @copy: 62 | ld a, (hl) 63 | or a 64 | jr z, @ext 65 | 66 | cp '.' 67 | jr z, @ext 68 | 69 | ld (de), a 70 | inc hl 71 | inc de 72 | 73 | jr @copy 74 | 75 | ;; Appending '.com' extension 76 | @ext: 77 | ld hl, ext 78 | ldi 79 | ldi 80 | ldi 81 | ldi 82 | ldi 83 | 84 | ;; Cleanup CP/M memory 85 | xor a 86 | ld hl, EDOS_BASE 87 | ld de, EDOS_BASE + 1 88 | ld bc, $fffe 89 | ld (hl), a 90 | ldir 91 | 92 | ;; Loading executable 93 | ld de, EDOS_TPA 94 | ld hl, path_buffer 95 | MOSCALL MOS_LOAD 96 | or a 97 | jp nz, open_error 98 | 99 | ;; Forming FCBs and DMA buffer with arguments 100 | call prepare_vars 101 | 102 | ;; Coping EDOS to selected 64K window 103 | ld hl, os 104 | ld de, EDOS_ORG 105 | ld bc, end_of_os - os 106 | ldir 107 | 108 | call close_all 109 | call term_init 110 | 111 | ;; Setting base address for legacy mode 112 | ld a, EDOS_PAGE 113 | ld mb, a 114 | ;; Jumping into EDOS 115 | jp.sis EDOS_ORG + $3 116 | 117 | ;; ---------------------------------------------------------------------------- 118 | 119 | close_all: 120 | ;; Close all opened files 121 | ld c, 0 122 | ld a, 0x0b 123 | rst.lil $08 124 | ret 125 | 126 | exit: 127 | call close_all 128 | di 129 | xor a 130 | ld mb, a 131 | 132 | call term_free 133 | ;; Restoring stack 134 | ld sp, (stack_save) 135 | 136 | pop iy 137 | pop ix 138 | 139 | ;; Cause we're in ADL mode - MB should be restored to zero value 140 | 141 | ld hl, exit_msg 142 | ld bc, 0 143 | xor a 144 | rst.lil $18 145 | 146 | ;; No errors happens, I wish 147 | ld hl, 0 148 | ei 149 | ret 150 | exit_msg: 151 | db 13, 10 152 | db "Returning to MOS..." 153 | db 13, 10, 13, 10, 0 154 | 155 | no_args: 156 | ld hl, @msg 157 | jr error 158 | @msg: 159 | db 13, 10, "Usage: ", 13, 10 160 | db " zinc ", 13, 10, 0 161 | 162 | open_error: 163 | ld hl, @msg 164 | jr error 165 | @msg: 166 | db 13, 10, 17, 1 167 | db "Cannot read executable file!", 17, 15 168 | db 13, 10, 0 169 | 170 | error: 171 | ld bc, 0 172 | xor a 173 | rst.lil $18 174 | jp exit 175 | 176 | _parse_args: 177 | call _skip_spaces 178 | ld bc,0 179 | ld b,MAX_ARGS 180 | _parse1: 181 | push bc 182 | push hl 183 | call _get_token 184 | ld a,c 185 | pop de 186 | pop bc 187 | and a 188 | ret z 189 | 190 | ld (ix+0),de 191 | push hl 192 | pop de 193 | call _skip_spaces 194 | xor a 195 | ld (de),a 196 | inc ix 197 | inc ix 198 | inc ix 199 | inc c 200 | ld a, c 201 | cp b 202 | jr c,_parse1 203 | ret 204 | 205 | _get_token: 206 | ld c,0 207 | @loop: 208 | ld a,(hl) 209 | or a 210 | ret z 211 | 212 | cp 13 213 | ret z 214 | 215 | cp 32 216 | ret z 217 | 218 | inc hl 219 | inc c 220 | 221 | jr @loop 222 | 223 | _skip_spaces: 224 | ld a,(hl) 225 | cp 32 226 | ret nz 227 | inc hl 228 | jr _skip_spaces 229 | 230 | ext: 231 | db ".com",0 232 | 233 | config_file: 234 | db "/mos/zinc.cfg", 0 235 | 236 | path_buffer: 237 | ds 13 238 | 239 | stack_save: dl 0 240 | 241 | include "cpm-data.asm" 242 | include "terminal.asm" 243 | include "uart.asm" 244 | 245 | os: 246 | incbin "edos/edos.bin" 247 | end_of_os: 248 | 249 | include "options.asm" --------------------------------------------------------------------------------