RFS repository created from software component of the MZ80A_RFS repository branch v2.1
This commit is contained in:
1
asm/include/MSBASIC_BuildVersion.asm
Normal file
1
asm/include/MSBASIC_BuildVersion.asm
Normal file
@@ -0,0 +1 @@
|
||||
BUILD_VERSION EQU 2
|
||||
1
asm/include/cpm_buildversion.asm
Normal file
1
asm/include/cpm_buildversion.asm
Normal file
@@ -0,0 +1 @@
|
||||
BUILD_VERSION EQU 1
|
||||
589
asm/include/cpm_definitions.asm
Normal file
589
asm/include/cpm_definitions.asm
Normal file
@@ -0,0 +1,589 @@
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;-
|
||||
;- Name: CPM_Definitions.asm
|
||||
;- Created: January 2020
|
||||
;- Author(s): Philip Smart
|
||||
;- Description: Sharp MZ series CPM v2.23
|
||||
;- Definitions for the Sharp MZ80A CPM v2.23 OS used in the RFS
|
||||
;-
|
||||
;- Credits:
|
||||
;- Copyright: (c) 2019-23 Philip Smart <philip.smart@net2net.org>
|
||||
;-
|
||||
;- History: Jan 2020 - Initial version.
|
||||
; May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the
|
||||
; additional and different hardware. The SPI is now onboard the PCB and
|
||||
; not using the printer interface card.
|
||||
; Mar 2021 - Changes to work with the RFS v2.1 board.
|
||||
;- Apr 2021 - Removed ROM and RAM Drive functionality as it provided no performance or
|
||||
;- use benefit over SD which are much larger and RW.
|
||||
;-
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;- This source file is free software: you can redistribute it and-or modify
|
||||
;- it under the terms of the GNU General Public License as published
|
||||
;- by the Free Software Foundation, either version 3 of the License, or
|
||||
;- (at your option) any later version.
|
||||
;-
|
||||
;- This source file is distributed in the hope that it will be useful,
|
||||
;- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;- GNU General Public License for more details.
|
||||
;-
|
||||
;- You should have received a copy of the GNU General Public License
|
||||
;- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
|
||||
;-----------------------------------------------
|
||||
; Features.
|
||||
;-----------------------------------------------
|
||||
HW_SPI_ENA EQU 1 ; Set to 1 if hardware SPI is present on the RFS PCB v2 board.
|
||||
SW_SPI_ENA EQU 0 ; Set to 1 if software SPI is present on the RFS PCB v2 board.
|
||||
PP_SPI_ENA EQU 0 ; Set to 1 if using the SPI interface via the Parallel Port, ie. for RFS PCB v1 which doesnt have SPI onboard.
|
||||
|
||||
; Build time options, only set to '1' to build, '0' to disable, only 1 can be set to '1'.
|
||||
; IF BUILD_VERSION = 0
|
||||
BUILD_80C EQU 1 ; Build for an MZ-80A with a 40/80 column card.
|
||||
BUILD_40C EQU 0 ; Build for a standard 40 column MZ-80A.
|
||||
; ENDIF
|
||||
; IF BUILD_VERSION = 1
|
||||
;BUILD_80C EQU 0 ; Build for an MZ-80A with a 40/80 column card.
|
||||
;BUILD_40C EQU 1 ; Build for a standard 40 column MZ-80A.
|
||||
; ENDIF
|
||||
|
||||
;-----------------------------------------------
|
||||
; Configurable settings.
|
||||
;-----------------------------------------------
|
||||
MAXRDRETRY EQU 002h
|
||||
MAXWRRETRY EQU 002h
|
||||
BLKSIZ EQU 4096 ; CP/M allocation size
|
||||
HSTSIZ EQU 512 ; host disk sector size
|
||||
HSTSPT EQU 32 ; host disk sectors/trk
|
||||
HSTBLK EQU HSTSIZ/128 ; CP/M sects/host buff
|
||||
CPMSPT EQU HSTBLK * HSTSPT ; CP/M sectors/track
|
||||
SECMSK EQU HSTBLK-1 ; sector mask
|
||||
WRALL EQU 0 ; write to allocated
|
||||
WRDIR EQU 1 ; write to directory
|
||||
WRUAL EQU 2 ; write to unallocated
|
||||
TMRTICKINTV EQU 5 ; Number of 0.010mSec ticks per interrupt, ie. resolution of RTC.
|
||||
MTROFFMSECS EQU 100 ; Time from last access to motor being switched off in seconds in TMRTICKINTV ticks.
|
||||
IF BUILD_80C = 1
|
||||
COLW EQU 80 ; Width of the display screen (ie. columns).
|
||||
ELSE
|
||||
COLW EQU 40 ; Width of the display screen (ie. columns).
|
||||
ENDIF
|
||||
ROW EQU 25 ; Number of rows on display screen.
|
||||
SCRNSZ EQU COLW * ROW ; Total size, in bytes, of the screen display area.
|
||||
SCRLW EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll.
|
||||
|
||||
; BIOS equates
|
||||
MAXDISKS EQU 7 ; Max number of Drives supported
|
||||
KEYBUFSIZE EQU 16 ; Ensure this is a power of 2, max size 256.
|
||||
|
||||
; Debugging
|
||||
ENADEBUG EQU 0 ; Enable debugging logic, 1 = enable, 0 = disable
|
||||
|
||||
|
||||
;-----------------------------------------------
|
||||
; Entry/compilation start points.
|
||||
;-----------------------------------------------
|
||||
CBIOSSTART EQU 0C000h
|
||||
CBIOSDATA EQU CBIOSSTART - 0400H
|
||||
UROMADDR EQU 0E800H ; Start of User ROM Address space.
|
||||
FDCROMADDR EQU 0F000H
|
||||
CBASE EQU 0A000H
|
||||
CPMCCP EQU CBASE ; CP/M System entry
|
||||
CPMBDOS EQU CPMCCP + 0806H ; BDOS entry
|
||||
CPMBIOS EQU CPMCCP + 01600H ; Original CPM22 BIOS entry
|
||||
CPMCOPYRMSG EQU CBASE+8 ; Copyright message stored in CP/M binary.
|
||||
BOOT EQU CBIOSSTART + 0
|
||||
WBOOT EQU CBIOSSTART + 3
|
||||
WBOOTE EQU CBIOSSTART + 3
|
||||
CONST EQU CBIOSSTART + 6
|
||||
CONIN EQU CBIOSSTART + 9
|
||||
CONOUT EQU CBIOSSTART + 12
|
||||
LIST EQU CBIOSSTART + 15
|
||||
PUNCH EQU CBIOSSTART + 18
|
||||
READER EQU CBIOSSTART + 21
|
||||
HOME EQU CBIOSSTART + 24
|
||||
SELDSK EQU CBIOSSTART + 27
|
||||
SETTRK EQU CBIOSSTART + 30
|
||||
SETSEC EQU CBIOSSTART + 33
|
||||
SETDMA EQU CBIOSSTART + 36
|
||||
READ EQU CBIOSSTART + 39
|
||||
WRITE EQU CBIOSSTART + 42
|
||||
FRSTAT EQU CBIOSSTART + 45
|
||||
SECTRN EQU CBIOSSTART + 48
|
||||
UNUSED EQU CBIOSSTART + 51
|
||||
BANKTOBANK EQU CBIOSSTART + 54
|
||||
CCP EQU CBASE
|
||||
CCPCLRBUF EQU CBASE + 3
|
||||
DPBASE EQU CPMBIOS
|
||||
CDIRBUF EQU CPMBIOS + (MAXDISKS * 16)
|
||||
CSVALVMEM EQU CDIRBUF + 128
|
||||
CSVALVEND EQU CBIOSDATA - 1 ;CSVALVMEM + 1253
|
||||
IOBYT EQU 00003H ; IOBYTE address
|
||||
CDISK EQU 00004H ; Address of Current drive name and user number
|
||||
CPMUSERDMA EQU 00080h ; Default CPM User DMA address.
|
||||
DPSIZE EQU 16 ; Size of a Disk Parameter Block
|
||||
DPBLOCK0 EQU SCRN - (8 * DPSIZE) ; Location of the 1st DPB in the CBIOS Rom.
|
||||
DPBLOCK1 EQU DPBLOCK0 + DPSIZE
|
||||
DPBLOCK2 EQU DPBLOCK1 + DPSIZE
|
||||
DPBLOCK3 EQU DPBLOCK2 + DPSIZE
|
||||
DPBLOCK4 EQU DPBLOCK3 + DPSIZE
|
||||
DPBLOCK5 EQU DPBLOCK4 + DPSIZE
|
||||
DPBLOCK6 EQU DPBLOCK5 + DPSIZE
|
||||
DPBLOCK7 EQU DPBLOCK6 + DPSIZE
|
||||
|
||||
;-------------------------------------------------------
|
||||
; Function entry points in the CBIOS ROMS
|
||||
;-------------------------------------------------------
|
||||
UROMJMPTBL EQU UROMADDR + 00020H ; Position at beginning of each bank of an API jump table of public methods in the bank
|
||||
|
||||
; Public functions in CBIOS User ROM Bank 1 - utility functions, ie. Audio.
|
||||
QREBOOT EQU 0 + UROMJMPTBL
|
||||
QMELDY EQU 3 + UROMJMPTBL
|
||||
QTEMP EQU 6 + UROMJMPTBL
|
||||
QMSTA EQU 9 + UROMJMPTBL
|
||||
QMSTP EQU 12 + UROMJMPTBL
|
||||
QBEL EQU 15 + UROMJMPTBL
|
||||
QMODE EQU 18 + UROMJMPTBL
|
||||
QTIMESET EQU 21 + UROMJMPTBL
|
||||
QTIMEREAD EQU 24 + UROMJMPTBL
|
||||
QCHKKY EQU 27 + UROMJMPTBL
|
||||
QGETKY EQU 30 + UROMJMPTBL
|
||||
|
||||
; Public functions in CBIOS User ROM Bank 2 - Screen / ANSI terminal functions.
|
||||
QPRNT EQU 0 + UROMJMPTBL
|
||||
QPRTHX EQU 3 + UROMJMPTBL
|
||||
QPRTHL EQU 6 + UROMJMPTBL
|
||||
QANSITERM EQU 9 + UROMJMPTBL
|
||||
|
||||
; Public functions in CBIOS User ROM Bank 3 - SD Card functions.
|
||||
SD_INIT EQU 0 + UROMJMPTBL
|
||||
SD_READ EQU 3 + UROMJMPTBL
|
||||
SD_WRITE EQU 6 + UROMJMPTBL
|
||||
SD_GETLBA EQU 9 + UROMJMPTBL
|
||||
SDC_READ EQU 12 + UROMJMPTBL
|
||||
SDC_WRITE EQU 15 + UROMJMPTBL
|
||||
|
||||
; Public functions in CBIOS User ROM Bank 4 - Floppy Disk Controller functions.
|
||||
QDSKINIT EQU 0 + UROMJMPTBL
|
||||
QSETDRVCFG EQU 3 + UROMJMPTBL
|
||||
QSETDRVMAP EQU 6 + UROMJMPTBL
|
||||
QSELDRIVE EQU 9 + UROMJMPTBL
|
||||
QGETMAPDSK EQU 12 + UROMJMPTBL
|
||||
QDSKREAD EQU 15 + UROMJMPTBL
|
||||
QDSKWRITE EQU 18 + UROMJMPTBL
|
||||
|
||||
|
||||
;-----------------------------------------------
|
||||
; Memory mapped ports in hardware.
|
||||
;-----------------------------------------------
|
||||
SCRN: EQU 0D000H
|
||||
ARAM: EQU 0D800H
|
||||
DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7)
|
||||
KEYPA: EQU 0E000h
|
||||
KEYPB: EQU 0E001h
|
||||
KEYPC: EQU 0E002h
|
||||
KEYPF: EQU 0E003h
|
||||
CSTR: EQU 0E002h
|
||||
CSTPT: EQU 0E003h
|
||||
CONT0: EQU 0E004h
|
||||
CONT1: EQU 0E005h
|
||||
CONT2: EQU 0E006h
|
||||
CONTF: EQU 0E007h
|
||||
SUNDG: EQU 0E008h
|
||||
TEMP: EQU 0E008h
|
||||
MEMSW: EQU 0E00CH
|
||||
MEMSWR: EQU 0E010H
|
||||
INVDSP: EQU 0E014H
|
||||
NRMDSP: EQU 0E015H
|
||||
SCLDSP: EQU 0E200H
|
||||
SCLBASE: EQU 0E2H
|
||||
BNKCTRLRST: EQU 0EFF8H ; Bank control reset, returns all registers to power up default.
|
||||
BNKCTRLDIS: EQU 0EFF9H ; Disable bank control registers by resetting the coded latch.
|
||||
HWSPIDATA: EQU 0EFFBH ; Hardware SPI Data register (read/write).
|
||||
HWSPISTART: EQU 0EFFCH ; Start an SPI transfer.
|
||||
BNKSELMROM: EQU 0EFFDh ; Select RFS Bank1 (MROM)
|
||||
BNKSELUSER: EQU 0EFFEh ; Select RFS Bank2 (User ROM)
|
||||
BNKCTRL: EQU 0EFFFH ; Bank Control register (read/write).
|
||||
|
||||
;
|
||||
; RFS v2 Control Register constants.
|
||||
;
|
||||
BBCLK EQU 1 ; BitBang SPI Clock.
|
||||
SDCS EQU 2 ; SD Card Chip Select, active low.
|
||||
BBMOSI EQU 4 ; BitBang MOSI (Master Out Serial In).
|
||||
CDLTCH1 EQU 8 ; Coded latch up count bit 1
|
||||
CDLTCH2 EQU 16 ; Coded latch up count bit 2
|
||||
CDLTCH3 EQU 32 ; Coded latch up count bit 3
|
||||
BK2A19 EQU 64 ; User ROM Device Select Bit 0 (or Address bit 19).
|
||||
BK2A20 EQU 128 ; User ROM Device Select Bit 1 (or Address bit 20).
|
||||
; BK2A20 : BK2A19
|
||||
; 0 0 = Flash RAM 0 (default).
|
||||
; 0 1 = Flash RAM 1.
|
||||
; 1 0 = Flasm RAM 2 or Static RAM 0.
|
||||
; 1 1 = Reserved.
|
||||
|
||||
BNKCTRLDEF EQU BBMOSI+SDCS+BBCLK ; Default on startup for the Bank Control register.
|
||||
|
||||
;-----------------------------------------------
|
||||
; IO ports in hardware and values.
|
||||
;-----------------------------------------------
|
||||
SPI_OUT EQU 0FFH
|
||||
SPI_IN EQU 0FEH
|
||||
;
|
||||
DOUT_LOW EQU 000H
|
||||
DOUT_HIGH EQU 004H
|
||||
DOUT_MASK EQU 004H
|
||||
DIN_LOW EQU 000H
|
||||
DIN_HIGH EQU 001H
|
||||
CLOCK_LOW EQU 000H
|
||||
CLOCK_HIGH EQU 002H
|
||||
CLOCK_MASK EQU 0FDH
|
||||
CS_LOW EQU 000H
|
||||
CS_HIGH EQU 001H
|
||||
|
||||
;-----------------------------------------------
|
||||
; Rom File System Header (MZF)
|
||||
;-----------------------------------------------
|
||||
RFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code.
|
||||
RFS_NAME: EQU 00001h ; Title/Name (17 bytes).
|
||||
RFS_SIZE: EQU 00012h ; Size of program.
|
||||
RFS_DTADR: EQU 00014h ; Load address of program.
|
||||
RFS_EXADR: EQU 00016h ; Exec address of program.
|
||||
RFS_COMNT: EQU 00018h ; COMMENT
|
||||
MZFHDRSZ EQU 128 ; Full MZF Header size
|
||||
MZFHDRNCSZ EQU 24 ; Only the primary MZF data, no comment field.
|
||||
RFSSECTSZ EQU 256
|
||||
MROMSIZE EQU 4096
|
||||
UROMSIZE EQU 2048
|
||||
BANKSPERTRACK EQU (ROMSECTORSIZE * ROMSECTORS) / UROMSIZE ; (8) We currently only use the UROM for disk images.
|
||||
SECTORSPERBANK EQU UROMSIZE / ROMSECTORSIZE ; (16)
|
||||
SECTORSPERBLOCK EQU RFSSECTSZ/ROMSECTORSIZE ; (2)
|
||||
ROMSECTORSIZE EQU 128
|
||||
ROMSECTORS EQU 128
|
||||
RAMDRVSECTORSIZE EQU 512
|
||||
RAMDRVMAXBANK EQU (RAMDRVSIZE * 1024)/UROMSIZE ; Maximum Bank number for the RAM drive.
|
||||
|
||||
;ROMBK1: EQU 01016H ; CURRENT MROM BANK
|
||||
;ROMBK2: EQU 01017H ; CURRENT USERROM BANK
|
||||
;WRKROMBK1: EQU 01018H ; WORKING MROM BANK
|
||||
;WRKROMBK2: EQU 01019H ; WORKING USERROM BANK
|
||||
|
||||
;-----------------------------------------------
|
||||
; ROM Banks, 0-7 are reserved for alternative
|
||||
; Monitor versions, CPM and RFS
|
||||
; code in MROM bank,
|
||||
; 0-7 are reserved for RFS code in
|
||||
; the User ROM bank.
|
||||
; 8-15 are reserved for CPM code in
|
||||
; the User ROM bank.
|
||||
;-----------------------------------------------
|
||||
MROMPAGES EQU 8
|
||||
USRROMPAGES EQU 12 ; Monitor ROM : User ROM
|
||||
ROMBANK0 EQU 0 ; MROM SA1510 40 Char : RFS Bank 0 - Main RFS Entry point and functions.
|
||||
ROMBANK1 EQU 1 ; MROM SA1510 80 Char : RFS Bank 1 - Floppy disk controller and utilities.
|
||||
ROMBANK2 EQU 2 ; CPM 2.2 CBIOS : RFS Bank 2 - SD Card controller and utilities.
|
||||
ROMBANK3 EQU 3 ; RFS Utilities : RFS Bank 3 - Cmdline tools (Memory, Printer, Help)
|
||||
ROMBANK4 EQU 4 ; Free : RFS Bank 4 - CMT Utilities.
|
||||
ROMBANK5 EQU 5 ; Free : RFS Bank 5
|
||||
ROMBANK6 EQU 6 ; Free : RFS Bank 6
|
||||
ROMBANK7 EQU 7 ; Free : RFS Bank 7 - Memory and timer test utilities.
|
||||
ROMBANK8 EQU 8 ; : CBIOS Bank 1 - Utilities
|
||||
ROMBANK9 EQU 9 ; : CBIOS Bank 2 - Screen / ANSI Terminal
|
||||
ROMBANK10 EQU 10 ; : CBIOS Bank 3 - SD Card
|
||||
ROMBANK11 EQU 11 ; : CBIOS Bank 4 - Floppy disk controller.
|
||||
|
||||
|
||||
|
||||
OBJCD EQU 001h
|
||||
|
||||
;-----------------------------------------------
|
||||
; IO Registers
|
||||
;-----------------------------------------------
|
||||
FDC EQU 0D8h ; MB8866 IO Region 0D8h - 0DBh
|
||||
FDC_CR EQU FDC + 000h ; Command Register
|
||||
FDC_STR EQU FDC + 000h ; Status Register
|
||||
FDC_TR EQU FDC + 001h ; Track Register
|
||||
FDC_SCR EQU FDC + 002h ; Sector Register
|
||||
FDC_DR EQU FDC + 003h ; Data Register
|
||||
FDC_MOTOR EQU FDC + 004h ; DS[0-3] and Motor control. 4 drives DS= BIT 0 -> Bit 2 = Drive number, 2=1,1=0,0=0 DS0, 2=1,1=0,0=1 DS1 etc
|
||||
; bit 7 = 1 MOTOR ON LOW (Active)
|
||||
FDC_SIDE EQU FDC + 005h ; Side select, Bit 0 when set = SIDE SELECT LOW
|
||||
|
||||
;-----------------------------------------------
|
||||
; Common character definitions.
|
||||
;-----------------------------------------------
|
||||
SCROLL EQU 001H ;Set scroll direction UP.
|
||||
BELL EQU 007H
|
||||
SPACE EQU 020H
|
||||
TAB EQU 009H ;TAB ACROSS (8 SPACES FOR SD-BOARD)
|
||||
CR EQU 00DH
|
||||
LF EQU 00AH
|
||||
FF EQU 00CH
|
||||
CS EQU 0CH ; Clear screen
|
||||
DELETE EQU 07FH
|
||||
BACKS EQU 008H
|
||||
SOH EQU 1 ; For XModem etc.
|
||||
EOT EQU 4
|
||||
ACK EQU 6
|
||||
NAK EQU 015H
|
||||
NUL EQU 000H
|
||||
NULL EQU 000H
|
||||
CTRL_A EQU 001H
|
||||
CTRL_B EQU 002H
|
||||
CTRL_C EQU 003H
|
||||
CTRL_D EQU 004H
|
||||
CTRL_E EQU 005H
|
||||
CTRL_F EQU 006H
|
||||
CTRL_G EQU 007H
|
||||
CTRL_H EQU 008H
|
||||
CTRL_I EQU 009H
|
||||
CTRL_J EQU 00AH
|
||||
CTRL_K EQU 00BH
|
||||
CTRL_L EQU 00CH
|
||||
CTRL_M EQU 00DH
|
||||
CTRL_N EQU 00EH
|
||||
CTRL_O EQU 00FH
|
||||
CTRL_P EQU 010H
|
||||
CTRL_Q EQU 011H
|
||||
CTRL_R EQU 012H
|
||||
CTRL_S EQU 013H
|
||||
CTRL_T EQU 014H
|
||||
CTRL_U EQU 015H
|
||||
CTRL_V EQU 016H
|
||||
CTRL_W EQU 017H
|
||||
CTRL_X EQU 018H
|
||||
CTRL_Y EQU 019H
|
||||
CTRL_Z EQU 01AH
|
||||
ESC EQU 01BH
|
||||
CTRL_SLASH EQU 01CH
|
||||
CTRL_LB EQU 01BH
|
||||
CTRL_RB EQU 01DH
|
||||
CTRL_CAPPA EQU 01EH
|
||||
CTRL_UNDSCR EQU 01FH
|
||||
CTRL_AT EQU 000H
|
||||
NOKEY EQU 0F0H
|
||||
CURSRIGHT EQU 0F1H
|
||||
CURSLEFT EQU 0F2H
|
||||
CURSUP EQU 0F3H
|
||||
CURSDOWN EQU 0F4H
|
||||
DBLZERO EQU 0F5H
|
||||
INSERT EQU 0F6H
|
||||
CLRKEY EQU 0F7H
|
||||
HOMEKEY EQU 0F8H
|
||||
BREAKKEY EQU 0FBH
|
||||
GRAPHKEY EQU 0FCH
|
||||
ALPHAKEY EQU 0FDH
|
||||
|
||||
|
||||
; MMC/SD command (SPI mode)
|
||||
CMD0 EQU 64 + 0 ; GO_IDLE_STATE
|
||||
CMD1 EQU 64 + 1 ; SEND_OP_COND
|
||||
ACMD41 EQU 0x40+41 ; SEND_OP_COND (SDC)
|
||||
CMD8 EQU 64 + 8 ; SEND_IF_COND
|
||||
CMD9 EQU 64 + 9 ; SEND_CSD
|
||||
CMD10 EQU 64 + 10 ; SEND_CID
|
||||
CMD12 EQU 64 + 12 ; STOP_TRANSMISSION
|
||||
CMD13 EQU 64 + 13 ; SEND_STATUS
|
||||
ACMD13 EQU 0x40+13 ; SD_STATUS (SDC)
|
||||
CMD16 EQU 64 + 16 ; SET_BLOCKLEN
|
||||
CMD17 EQU 64 + 17 ; READ_SINGLE_BLOCK
|
||||
CMD18 EQU 64 + 18 ; READ_MULTIPLE_BLOCK
|
||||
CMD23 EQU 64 + 23 ; SET_BLOCK_COUNT
|
||||
ACMD23 EQU 0x40+23 ; SET_WR_BLK_ERASE_COUNT (SDC)
|
||||
CMD24 EQU 64 + 24 ; WRITE_BLOCK
|
||||
CMD25 EQU 64 + 25 ; WRITE_MULTIPLE_BLOCK
|
||||
CMD32 EQU 64 + 32 ; ERASE_ER_BLK_START
|
||||
CMD33 EQU 64 + 33 ; ERASE_ER_BLK_END
|
||||
CMD38 EQU 64 + 38 ; ERASE
|
||||
CMD55 EQU 64 + 55 ; APP_CMD
|
||||
CMD58 EQU 64 + 58 ; READ_OCR
|
||||
|
||||
; Card type flags (CardType)
|
||||
CT_MMC EQU 001H ; MMC ver 3
|
||||
CT_SD1 EQU 002H ; SD ver 1
|
||||
CT_SD2 EQU 004H ; SD ver 2
|
||||
CT_SDC EQU CT_SD1|CT_SD2 ; SD
|
||||
CT_BLOCK EQU 008H ; Block addressing
|
||||
|
||||
; Disk types.
|
||||
DSKTYP_FDC EQU 0 ; Type of disk is a Floppy disk and handled by the FDC controller.
|
||||
DSKTYP_ROM EQU 1 ; Type of disk is a ROM and handled by the ROM methods.
|
||||
DSKTYP_SDC EQU 2 ; Type of disk is an SD Card and handled by the SD Card methods.
|
||||
DSKTYP_RAM EQU 3 ; Type of disk is a RAM Drive handled by ROM/RAM methods.
|
||||
|
||||
;
|
||||
; Rom Filing System constants.
|
||||
;
|
||||
RFS_DIRENT EQU 256 ; Directory entries in the RFS directory.
|
||||
RFS_DIRENTSZ EQU 32 ; Size of a directory entry.
|
||||
RFS_DIRSIZE EQU RFS_DIRENT * RFS_DIRENTSZ ; Total size of the directory.
|
||||
RFS_BLOCKSZ EQU 65536 ; Size of a file block per directory entry.
|
||||
RFS_DRIVES EQU 10 ; Number of RFS Drives (Images).
|
||||
RFS_IMGSZ EQU RFS_DIRSIZE + (RFS_DIRENT * RFS_BLOCKSZ) ; Total size of the RFS image.
|
||||
RFS_END_ADDR EQU 010000000H ; End of RFS/Start of CP/M.
|
||||
|
||||
;
|
||||
; CPM constants
|
||||
;
|
||||
CPM_SD_SEC EQU 32
|
||||
CPM_SD_TRK EQU 1024
|
||||
CPM_SD_IMGSZ EQU CPM_SD_TRK * CPM_SD_SEC * SD_SECSIZE
|
||||
|
||||
;
|
||||
; SD Card constants.
|
||||
;
|
||||
SD_SECSIZE EQU 512 ; Default size of an SD Sector
|
||||
SD_SECPTRK EQU CPM_SD_SEC ; Sectors of SD_SECSIZE per virtual track.
|
||||
SD_TRACKS EQU CPM_SD_TRK ; Number of virtual tracks per disk image.
|
||||
SD_RETRIES EQU 00100H ; Number of retries before giving up.
|
||||
|
||||
|
||||
;-----------------------------------------------
|
||||
; BIOS WORK AREA (MZ80A)
|
||||
;-----------------------------------------------
|
||||
ORG CBIOSDATA
|
||||
|
||||
; Keyboard processing, ensure starts where LSB = 0.
|
||||
VARSTART EQU $ ; Start of variables.
|
||||
KEYBUF: DS virtual KEYBUFSIZE ; Interrupt driven keyboard buffer.
|
||||
KEYCOUNT: DS virtual 1
|
||||
KEYWRITE: DS virtual 2 ; Pointer into the buffer where the next character should be placed.
|
||||
KEYREAD: DS virtual 2 ; Pointer into the buffer where the next character can be read.
|
||||
KEYLAST: DS virtual 1 ; KEY LAST VALUE
|
||||
KEYRPT: DS virtual 1 ; KEY REPEAT COUNTER
|
||||
USRBANKSAV: DS virtual 1 ; Save user bank number when calling another user bank.
|
||||
HLSAVE: DS virtual 2 ; Space to save HL register when manipulating stack.
|
||||
ROMCTL DS virtual 1 ; Rom Paging control register contents.
|
||||
;
|
||||
SPV:
|
||||
IBUFE: ; TAPE BUFFER (128 BYTES)
|
||||
ATRB: DS virtual 1 ; ATTRIBUTE
|
||||
NAME: DS virtual 17 ; FILE NAME
|
||||
SIZE: DS virtual 2 ; BYTESIZE
|
||||
DTADR: DS virtual 2 ; DATA ADDRESS
|
||||
EXADR: DS virtual 2 ; EXECUTION ADDRESS
|
||||
COMNT: DS virtual 92 ; Comment / code area of CMT header.
|
||||
SWPW: DS virtual 10 ; SWEEP WORK
|
||||
KDATW: DS virtual 2 ; KEY WORK
|
||||
KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE)
|
||||
DSPXY: DS virtual 2 ; DISPLAY COORDINATES
|
||||
;DSPXYLST: DS virtual 2 ; Last known cursor position, to compare with DSPXY to detect changes.
|
||||
MANG: DS virtual 6 ; COLUMN MANAGEMENT
|
||||
MANGE: DS virtual 1 ; COLUMN MANAGEMENT END
|
||||
PBIAS: DS virtual 1 ; PAGE BIAS
|
||||
ROLTOP: DS virtual 1 ; ROLL TOP BIAS
|
||||
MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER
|
||||
PAGETP: DS virtual 2 ; PAGE TOP
|
||||
ROLEND: DS virtual 1 ; ROLL END
|
||||
DS virtual 14 ; BIAS
|
||||
FLASH: DS virtual 1 ; FLASHING DATA
|
||||
SFTLK: DS virtual 1 ; SHIFT LOCK
|
||||
REVFLG: DS virtual 1 ; REVERSE FLAG
|
||||
FLSDT: DS virtual 1 ; CURSOR DATA
|
||||
STRGF: DS virtual 1 ; STRING FLAG
|
||||
DPRNT: DS virtual 1 ; TAB COUNTER
|
||||
FLASHCTL: DS virtual 1 ; CURSOR FLASH CONTROL. BIT 0 = Cursor On/Off, BIT 1 = Cursor displayed.
|
||||
DSPXYADDR: DS virtual 2 ; Address of last known position.
|
||||
;AMPM: DS virtual 1 ; AMPM DATA
|
||||
;TIMFG: DS virtual 1 ; TIME FLAG
|
||||
SWRK: DS virtual 1 ; KEY SOUND FLAG
|
||||
TEMPW: DS virtual 1 ; TEMPO WORK
|
||||
ONTYO: DS virtual 1 ; ONTYO WORK
|
||||
OCTV: DS virtual 1 ; OCTAVE WORK
|
||||
RATIO: DS virtual 2 ; ONPU RATIO
|
||||
;BUFER: DS virtual 81 ; GET LINE BUFFER
|
||||
;KEYBUF: DS virtual 1 ; KEY BUFFER
|
||||
DRVAVAIL DS virtual 1 ; Flag to indicate which drive controllers are available. Bit 2 = SD, Bit 1 = ROM, Bit 0 = FDC
|
||||
TIMESEC DS virtual 6 ; RTC 48bit TIME IN MILLISECONDS
|
||||
FDCCMD DS virtual 1 ; LAST FDC COMMAND SENT TO CONTROLLER.
|
||||
MOTON DS virtual 1 ; MOTOR ON = 1, OFF = 0
|
||||
INVFDCDATA: DS virtual 1 ; INVERT DATA COMING FROM FDC, 1 = INVERT, 0 = AS IS
|
||||
TRK0FD1 DS virtual 1 ; FD 1 IS AT TRACK 0 = BIT 0 set
|
||||
TRK0FD2 DS virtual 1 ; FD 2 IS AT TRACK 0 = BIT 0 set
|
||||
TRK0FD3 DS virtual 1 ; FD 3 IS AT TRACK 0 = BIT 0 set
|
||||
TRK0FD4 DS virtual 1 ; FD 4 IS AT TRACK 0 = BIT 0 set
|
||||
RETRIES DS virtual 2 ; DATA READ RETRIES
|
||||
TMPADR DS virtual 2 ; TEMPORARY ADDRESS STORAGE
|
||||
TMPSIZE DS virtual 2 ; TEMPORARY SIZE
|
||||
TMPCNT DS virtual 2 ; TEMPORARY COUNTER
|
||||
;
|
||||
CPMROMLOC: DS virtual 2 ; Upper Byte = ROM Bank, Lower Byte = Page of CPM Image.
|
||||
;CPMROMDRV0: DS virtual 2 ; Upper Byte = ROM Bank, Lower Byte = Page of CPM Rom Drive Image Disk 0.
|
||||
;CPMROMDRV1: DS virtual 2 ; Upper Byte = ROM Bank, Lower Byte = Page of CPM Rom Drive Image Disk 1.
|
||||
NDISKS: DS virtual 1 ; Dynamically calculated number of disks on boot.
|
||||
DISKMAP: DS virtual MAXDISKS ; Disk map of CPM logical to physical controller disk.
|
||||
FDCDISK: DS virtual 1 ; Physical disk number.
|
||||
SECPERTRK: DS virtual 1 ; Sectors per track for 1 head.
|
||||
SECPERHEAD: DS virtual 1 ; Sectors per head.
|
||||
SECTORCNT: DS virtual 1 ; Sector size as a count of how many sectors make 512 bytes.
|
||||
DISKTYPE: DS virtual 1 ; Disk type of current selection.
|
||||
MTROFFTIMER: DS virtual 1 ; Second down counter for FDC motor off.
|
||||
;
|
||||
SEKDSK: DS virtual 1 ; Seek disk number
|
||||
SEKTRK: DS virtual 2 ; Seek disk track
|
||||
SEKSEC: DS virtual 1 ; Seek sector number
|
||||
SEKHST: DS virtual 1 ; Seek sector host
|
||||
;
|
||||
HSTDSK: DS virtual 1 ; Host disk number
|
||||
HSTTRK: DS virtual 2 ; Host track number
|
||||
HSTSEC: DS virtual 1 ; Host sector number
|
||||
HSTWRT: DS virtual 1 ; Host write flag
|
||||
HSTACT: DS virtual 1 ;
|
||||
;
|
||||
UNACNT: DS virtual 1 ; Unalloc rec cnt
|
||||
UNADSK: DS virtual 1 ; Last unalloc disk
|
||||
UNATRK: DS virtual 2 ; Last unalloc track
|
||||
UNASEC: DS virtual 1 ; Last unalloc sector
|
||||
;
|
||||
ERFLAG: DS virtual 1 ; Error number, 0 = no error.
|
||||
READOP: DS virtual 1 ; If read operation then 1, else 0 for write.
|
||||
RSFLAG: DS virtual 1 ; Read sector flag.
|
||||
WRTYPE: DS virtual 1 ; Write operation type.
|
||||
TRACKNO: DS virtual 2 ; Host controller track number
|
||||
SECTORNO: DS virtual 1 ; Host controller sector number
|
||||
DMAADDR: DS virtual 2 ; Last DMA address
|
||||
HSTBUF: DS virtual 512 ; Host buffer for disk sector storage
|
||||
HSTBUFE:
|
||||
|
||||
SDVER: DS virtual 1 ; SD Card version.
|
||||
SDCAP: DS virtual 1 ; SD Card capabilities..
|
||||
SDSTARTSEC DS virtual 4 ; Starting sector of data to read/write from/to SD card.
|
||||
SDBUF: DS virtual 11 ; SD Card command fram buffer for the command and response storage.
|
||||
|
||||
CURSORPSAV DS virtual 2 ; Cursor save position;default 0,0
|
||||
HAVELOADED DS virtual 1 ; To show that a value has been put in for Ansi emualtor.
|
||||
ANSIFIRST DS virtual 1 ; Holds first character of Ansi sequence
|
||||
NUMBERBUF DS virtual 20 ; Buffer for numbers in Ansi
|
||||
NUMBERPOS DS virtual 2 ; Address within buffer
|
||||
CHARACTERNO DS virtual 1 ; Byte within Ansi sequence. 0=first,255=other
|
||||
CURSORCOUNT DS virtual 1 ; 1/50ths of a second since last change
|
||||
FONTSET DS virtual 1 ; Ansi font setup.
|
||||
JSW_FF DS virtual 1 ; Byte value to turn on/off FF routine
|
||||
JSW_LF DS virtual 1 ; Byte value to turn on/off LF routine
|
||||
CHARACTER DS virtual 1 ; To buffer character to be printed.
|
||||
CURSORPOS DS virtual 2 ; Cursor position, default 0,0.
|
||||
BOLDMODE DS virtual 1
|
||||
HIBRITEMODE DS virtual 1 ; 0 means on, &C9 means off
|
||||
UNDERSCMODE DS virtual 1
|
||||
ITALICMODE DS virtual 1
|
||||
INVMODE DS virtual 1
|
||||
CHGCURSMODE DS virtual 1
|
||||
ANSIMODE DS virtual 1 ; 1 = on, 0 = off
|
||||
COLOUR EQU 0
|
||||
|
||||
SPSAVE: DS virtual 2 ; CPM Stack save.
|
||||
SPISRSAVE: DS virtual 2
|
||||
; Stack space for the CBIOS.
|
||||
MSGSTRBUF: DS virtual 128 ; Lower end of the stack space is for interbank message printing, ie.space for a string to print.
|
||||
BIOSSTACK EQU $
|
||||
; Stack space for the Interrupt Service Routine.
|
||||
DS virtual 16 ; Max 8 stack pushes.
|
||||
ISRSTACK EQU $
|
||||
|
||||
DBGSTACKP: DS virtual 2
|
||||
DS virtual 36
|
||||
DBGSTACK: EQU $
|
||||
|
||||
VAREND EQU $ ; End of variables
|
||||
34
asm/include/macros.asm
Normal file
34
asm/include/macros.asm
Normal file
@@ -0,0 +1,34 @@
|
||||
; the following is only to get the original length of 2048 bytes
|
||||
ALIGN: MACRO ?boundary
|
||||
DS ?boundary - 1 - ($ + ?boundary - 1) % ?boundary, 0FFh
|
||||
ENDM
|
||||
|
||||
; the following is only to get the original length of 2048 bytes
|
||||
ALIGN_NOPS:MACRO ?boundary
|
||||
DS ?boundary - 1 - ($ + ?boundary - 1) % ?boundary, 000h
|
||||
ENDM
|
||||
|
||||
;
|
||||
; Pads up to a certain address.
|
||||
; Gives an error message if that address is already exceeded.
|
||||
;
|
||||
PAD: MACRO ?address
|
||||
IF $ > ?address
|
||||
ERROR "Alignment exceeds %s"; % ?address
|
||||
ENDIF
|
||||
ds ?address - $
|
||||
ENDM
|
||||
|
||||
;
|
||||
; Pads up to the next multiple of the specified address.
|
||||
;
|
||||
;ALIGN: MACRO ?boundary
|
||||
; ds ?boundary - 1 - ($ + ?boundary - 1) % ?boundary
|
||||
; ENDM
|
||||
|
||||
;
|
||||
; Pads to ensure a section of the given size does not cross a 100H boundary.
|
||||
;
|
||||
ALIGN_FIT8: MACRO ?size
|
||||
ds (($ + ?size - 1) >> 8) != ($ >> 8) && (100H - ($ & 0FFH)) || 0
|
||||
ENDM
|
||||
1
asm/include/msbasic_buildversion.asm
Normal file
1
asm/include/msbasic_buildversion.asm
Normal file
@@ -0,0 +1 @@
|
||||
BUILD_VERSION EQU 2
|
||||
473
asm/include/msbasic_definitions.asm
Normal file
473
asm/include/msbasic_definitions.asm
Normal file
@@ -0,0 +1,473 @@
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;-
|
||||
;- Name: MSBASIC_Definitions.asm
|
||||
;- Created: June 2020
|
||||
;- Author(s): Philip Smart
|
||||
;- Description: Sharp MZ series CPM v2.23
|
||||
;- Definitions for the Sharp MZ80A CPM v2.23 OS used in the RFS
|
||||
;-
|
||||
;- Credits:
|
||||
;- Copyright: (c) 2019-23 Philip Smart <philip.smart@net2net.org>
|
||||
;-
|
||||
;- History: Jan 2020 - Initial version.
|
||||
; May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the
|
||||
; additional and different hardware. The SPI is now onboard the PCB and
|
||||
; not using the printer interface card.
|
||||
; Jun 2020 - Copied and strpped from TZFS for BASIC.
|
||||
; Mar 2021 - Updates to run on v2.1 RFS board and provide SD card CLOAD/CSAVE and DIR
|
||||
; along with bug fixes.
|
||||
;
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;- This source file is free software: you can redistribute it and-or modify
|
||||
;- it under the terms of the GNU General Public License as published
|
||||
;- by the Free Software Foundation, either version 3 of the License, or
|
||||
;- (at your option) any later version.
|
||||
;-
|
||||
;- This source file is distributed in the hope that it will be useful,
|
||||
;- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;- GNU General Public License for more details.
|
||||
;-
|
||||
;- You should have received a copy of the GNU General Public License
|
||||
;- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
|
||||
;-----------------------------------------------
|
||||
; Features.
|
||||
;-----------------------------------------------
|
||||
|
||||
;-----------------------------------------------
|
||||
|
||||
;-----------------------------------------------
|
||||
; Configurable settings.
|
||||
;-----------------------------------------------
|
||||
; Build options. Set just one to '1' the rest to '0'.
|
||||
; NB: As there are now 4 versions and 1 or more need to be built, ie. MZ-80A and RFS version for RFS, a flag is set in the file
|
||||
; BASIC_build.asm which configures the equates below for the correct build.
|
||||
IF BUILD_VERSION = 0
|
||||
BUILD_MZ80A EQU 1 ; Build for the standard Sharp MZ80A, no lower memory. Manually change MAXMEM above.
|
||||
BUILD_RFS EQU 0 ; Build for standard RFS with SD enhancements.
|
||||
BUILD_RFSTZ EQU 0 ; Build for RFS where the tranZPUter board is available without the K64F and running under RFS.
|
||||
BUILD_TZFS EQU 0 ; Build for TZFS where extended memory is available.
|
||||
BUILD_80C EQU 0
|
||||
INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build.
|
||||
ENDIF
|
||||
IF BUILD_VERSION = 1
|
||||
BUILD_MZ80A EQU 0
|
||||
BUILD_RFS EQU 1
|
||||
BUILD_RFSTZ EQU 0
|
||||
BUILD_TZFS EQU 0
|
||||
BUILD_80C EQU 1
|
||||
INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build.
|
||||
ENDIF
|
||||
IF BUILD_VERSION = 2
|
||||
BUILD_MZ80A EQU 0
|
||||
BUILD_RFS EQU 1
|
||||
BUILD_RFSTZ EQU 0
|
||||
BUILD_TZFS EQU 0
|
||||
BUILD_80C EQU 0
|
||||
INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build.
|
||||
ENDIF
|
||||
IF BUILD_VERSION = 3
|
||||
BUILD_MZ80A EQU 0
|
||||
BUILD_RFS EQU 0
|
||||
BUILD_RFSTZ EQU 1
|
||||
BUILD_TZFS EQU 0
|
||||
BUILD_80C EQU 1
|
||||
INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build.
|
||||
ENDIF
|
||||
IF BUILD_VERSION = 4
|
||||
BUILD_MZ80A EQU 0
|
||||
BUILD_RFS EQU 0
|
||||
BUILD_RFSTZ EQU 0
|
||||
BUILD_TZFS EQU 1
|
||||
BUILD_80C EQU 1
|
||||
INCLUDE_ANSITERM EQU 1 ; Include the Ansi terminal emulation processor in the build.
|
||||
ENDIF
|
||||
IF BUILD_80C = 1
|
||||
COLW: EQU 80 ; Width of the display screen (ie. columns).
|
||||
ELSE
|
||||
COLW: EQU 40 ; Width of the display screen (ie. columns).
|
||||
ENDIF
|
||||
TMRTICKINTV EQU 5 ; Number of 0.010mSec ticks per interrupt, ie. resolution of RTC.
|
||||
ROW: EQU 25 ; Number of rows on display screen.
|
||||
SCRNSZ: EQU COLW * ROW ; Total size, in bytes, of the screen display area.
|
||||
SCRLW: EQU COLW / 8 ; Number of 8 byte regions in a line for hardware scroll.
|
||||
|
||||
; BIOS equates
|
||||
KEYBUFSIZE EQU 64 ; Ensure this is a power of 2, max size 256.
|
||||
IF BUILD_MZ80A = 1
|
||||
MAXMEM EQU 0CFFFH ; Top of RAM on a standard Sharp MZ80A.
|
||||
ENDIF
|
||||
IF BUILD_RFS = 1
|
||||
MAXMEM EQU 0CFFFH - TZSVCSECSIZE ; Top of RAM on a standard RFS equipped Sharp MZ80A. Top 512 bytes used by RFS SD sector buffer.
|
||||
ENDIF
|
||||
IF BUILD_TZFS+BUILD_RFSTZ > 0
|
||||
MAXMEM EQU 10000H - TZSVCSIZE ; Top of RAM on the tranZPUter
|
||||
ENDIF
|
||||
|
||||
; Tape load/save modes. Used as a flag to enable common code.
|
||||
TAPELOAD EQU 1
|
||||
CTAPELOAD EQU 2
|
||||
TAPESAVE EQU 3
|
||||
CTAPESAVE EQU 4
|
||||
|
||||
; Debugging
|
||||
ENADEBUG EQU 0 ; Enable debugging logic, 1 = enable, 0 = disable
|
||||
|
||||
;-----------------------------------------------
|
||||
; CMT Object types.
|
||||
;-----------------------------------------------
|
||||
ATR_OBJ EQU 1
|
||||
ATR_BASIC_PROG EQU 2
|
||||
ATR_BASIC_DATA EQU 3
|
||||
ATR_SRC_FILE EQU 4
|
||||
ATR_RELOC_FILE EQU 5
|
||||
ATR_BASIC_MSCAS EQU 07EH
|
||||
ATR_BASIC_MSTXT EQU 07FH
|
||||
ATR_PASCAL_PROG EQU 0A0H
|
||||
ATR_PASCAL_DATA EQU 0A1H
|
||||
CMTATRB EQU 010F0H
|
||||
CMTNAME EQU 010F1H
|
||||
|
||||
;-------------------------------------------------------
|
||||
; Function entry points in the standard SA-1510 Monitor.
|
||||
;-------------------------------------------------------
|
||||
QWRI EQU 00021h
|
||||
QWRD EQU 00024h
|
||||
QRDI EQU 00027h
|
||||
QRDD EQU 0002Ah
|
||||
QVRFY EQU 0002Dh
|
||||
|
||||
;-------------------------------------------------------
|
||||
; Function entry points in the RFS ROM.
|
||||
;-------------------------------------------------------
|
||||
CMT_RDINF EQU 0E886H ; UROMADDR+86H - Tape/SD intercept handler - Read Header
|
||||
CMT_RDDATA EQU 0E889H ; UROMADDR+89H - Tape/SD intercept handler - Read Data
|
||||
CMT_WRINF EQU 0E88CH ; UROMADDR+80H - Tape/SD intercept handler - Write Header
|
||||
CMT_WRDATA EQU 0E88FH ; UROMADDR+8FH - Tape/SD intercept handler - Write Data
|
||||
CMT_VERIFY EQU 0E892H ; UROMADDR+92H - Tape/SD intercept handler - Verify Data
|
||||
CMT_DIR EQU 0E895H ; UROMADDR+95H - SD directory command.
|
||||
CNV_ATOS EQU 0E898H ; UROMADDR+98H - Convert an ASCII string into Sharp ASCII
|
||||
|
||||
;-----------------------------------------------
|
||||
; BASIC ERROR CODE VALUES
|
||||
;-----------------------------------------------
|
||||
NF EQU 00H ; NEXT without FOR
|
||||
SN EQU 02H ; Syntax error
|
||||
RG EQU 04H ; RETURN without GOSUB
|
||||
OD EQU 06H ; Out of DATA
|
||||
FC EQU 08H ; Function call error
|
||||
OV EQU 0AH ; Overflow
|
||||
OM EQU 0CH ; Out of memory
|
||||
UL EQU 0EH ; Undefined line number
|
||||
BS EQU 10H ; Bad subscript
|
||||
DDA EQU 12H ; Re-DIMensioned array
|
||||
DZ EQU 14H ; Division by zero (/0)
|
||||
ID EQU 16H ; Illegal direct
|
||||
TM EQU 18H ; Type miss-match
|
||||
OS EQU 1AH ; Out of string space
|
||||
LS EQU 1CH ; String too long
|
||||
ST EQU 1EH ; String formula too complex
|
||||
CN EQU 20H ; Can't CONTinue
|
||||
UF EQU 22H ; UnDEFined FN function
|
||||
MO EQU 24H ; Missing operand
|
||||
HX EQU 26H ; HEX error
|
||||
BN EQU 28H ; BIN error
|
||||
BV EQU 2AH ; Bad Value error
|
||||
IO EQU 2CH ; IO error
|
||||
|
||||
;-----------------------------------------------
|
||||
; Memory mapped ports in hardware.
|
||||
;-----------------------------------------------
|
||||
SCRN: EQU 0D000H
|
||||
ARAM: EQU 0D800H
|
||||
DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7)
|
||||
KEYPA: EQU 0E000h
|
||||
KEYPB: EQU 0E001h
|
||||
KEYPC: EQU 0E002h
|
||||
KEYPF: EQU 0E003h
|
||||
CSTR: EQU 0E002h
|
||||
CSTPT: EQU 0E003h
|
||||
CONT0: EQU 0E004h
|
||||
CONT1: EQU 0E005h
|
||||
CONT2: EQU 0E006h
|
||||
CONTF: EQU 0E007h
|
||||
SUNDG: EQU 0E008h
|
||||
TEMP: EQU 0E008h
|
||||
MEMSW: EQU 0E00CH
|
||||
MEMSWR: EQU 0E010H
|
||||
INVDSP: EQU 0E014H
|
||||
NRMDSP: EQU 0E015H
|
||||
SCLDSP: EQU 0E200H
|
||||
SCLBASE: EQU 0E2H
|
||||
BNKCTRLRST: EQU 0EFF8H ; Bank control reset, returns all registers to power up default.
|
||||
BNKCTRLDIS: EQU 0EFF9H ; Disable bank control registers by resetting the coded latch.
|
||||
HWSPIDATA: EQU 0EFFBH ; Hardware SPI Data register (read/write).
|
||||
HWSPISTART: EQU 0EFFCH ; Start an SPI transfer.
|
||||
BNKSELMROM: EQU 0EFFDh ; Select RFS Bank1 (MROM)
|
||||
BNKSELUSER: EQU 0EFFEh ; Select RFS Bank2 (User ROM)
|
||||
BNKCTRL: EQU 0EFFFH ; Bank Control register (read/write).
|
||||
|
||||
;-----------------------------------------------
|
||||
; IO Registers
|
||||
;-----------------------------------------------
|
||||
FDC EQU 0D8h ; MB8866 IO Region 0D8h - 0DBh
|
||||
FDC_CR EQU FDC + 000h ; Command Register
|
||||
FDC_STR EQU FDC + 000h ; Status Register
|
||||
FDC_TR EQU FDC + 001h ; Track Register
|
||||
FDC_SCR EQU FDC + 002h ; Sector Register
|
||||
FDC_DR EQU FDC + 003h ; Data Register
|
||||
FDC_MOTOR EQU FDC + 004h ; DS[0-3] and Motor control. 4 drives DS= BIT 0 -> Bit 2 = Drive number, 2=1,1=0,0=0 DS0, 2=1,1=0,0=1 DS1 etc
|
||||
; bit 7 = 1 MOTOR ON LOW (Active)
|
||||
FDC_SIDE EQU FDC + 005h ; Side select, Bit 0 when set = SIDE SELECT LOW
|
||||
|
||||
;-----------------------------------------------
|
||||
; Common character definitions.
|
||||
;-----------------------------------------------
|
||||
SCROLL EQU 001H ;Set scroll direction UP.
|
||||
BELL EQU 007H
|
||||
SPACE EQU 020H
|
||||
TAB EQU 009H ;TAB ACROSS (8 SPACES FOR SD-BOARD)
|
||||
CR EQU 00DH
|
||||
LF EQU 00AH
|
||||
FF EQU 00CH
|
||||
CS EQU 0CH ; Clear screen
|
||||
DELETE EQU 07FH
|
||||
BACKS EQU 008H
|
||||
SOH EQU 1 ; For XModem etc.
|
||||
EOT EQU 4
|
||||
ACK EQU 6
|
||||
NAK EQU 015H
|
||||
NUL EQU 000H
|
||||
;NULL EQU 000H
|
||||
CTRL_A EQU 001H
|
||||
CTRL_B EQU 002H
|
||||
CTRL_C EQU 003H
|
||||
CTRL_D EQU 004H
|
||||
CTRL_E EQU 005H
|
||||
CTRL_F EQU 006H
|
||||
CTRL_G EQU 007H
|
||||
CTRL_H EQU 008H
|
||||
CTRL_I EQU 009H
|
||||
CTRL_J EQU 00AH
|
||||
CTRL_K EQU 00BH
|
||||
CTRL_L EQU 00CH
|
||||
CTRL_M EQU 00DH
|
||||
CTRL_N EQU 00EH
|
||||
CTRL_O EQU 00FH
|
||||
CTRL_P EQU 010H
|
||||
CTRL_Q EQU 011H
|
||||
CTRL_R EQU 012H
|
||||
CTRL_S EQU 013H
|
||||
CTRL_T EQU 014H
|
||||
CTRL_U EQU 015H
|
||||
CTRL_V EQU 016H
|
||||
CTRL_W EQU 017H
|
||||
CTRL_X EQU 018H
|
||||
CTRL_Y EQU 019H
|
||||
CTRL_Z EQU 01AH
|
||||
ESC EQU 01BH
|
||||
CTRL_SLASH EQU 01CH
|
||||
CTRL_LB EQU 01BH
|
||||
CTRL_RB EQU 01DH
|
||||
CTRL_CAPPA EQU 01EH
|
||||
CTRL_UNDSCR EQU 01FH
|
||||
CTRL_AT EQU 000H
|
||||
NOKEY EQU 0F0H
|
||||
CURSRIGHT EQU 0F1H
|
||||
CURSLEFT EQU 0F2H
|
||||
CURSUP EQU 0F3H
|
||||
CURSDOWN EQU 0F4H
|
||||
DBLZERO EQU 0F5H
|
||||
INSERT EQU 0F6H
|
||||
CLRKEY EQU 0F7H
|
||||
HOMEKEY EQU 0F8H
|
||||
BREAKKEY EQU 0FBH
|
||||
GRAPHKEY EQU 0FCH
|
||||
ALPHAKEY EQU 0FDH
|
||||
|
||||
|
||||
;-----------------------------------------------
|
||||
; Rom File System variable addresses.
|
||||
;-----------------------------------------------
|
||||
; Starting 1000H - Generally unused bytes not cleared by the monitor.
|
||||
ROMBK1: EQU 01016H ; CURRENT MROM BANK
|
||||
ROMBK2: EQU 01017H ; CURRENT USERROM BANK
|
||||
WRKROMBK1: EQU 01018H ; WORKING MROM BANK
|
||||
WRKROMBK2: EQU 01019H ; WORKING USERROM BANK
|
||||
ROMCTL: EQU 0101AH ; Current Bank control register setting.
|
||||
SCRNMODE: EQU 0101BH ; Mode of screen, 0 = 40 char, 1 = 80 char.
|
||||
TMPADR: EQU 0101CH ; TEMPORARY ADDRESS STORAGE
|
||||
TMPSIZE: EQU 0101EH ; TEMPORARY SIZE
|
||||
TMPCNT: EQU 01020H ; TEMPORARY COUNTER
|
||||
TMPLINECNT: EQU 01022H ; Temporary counter for displayed lines.
|
||||
TMPSTACKP: EQU 01024H ; Temporary stack pointer save.
|
||||
SDVER: EQU 01026H
|
||||
SDCAP: EQU 01027H
|
||||
SDDRIVENO EQU 01028H ; RFS SDCFS Active Drive Number
|
||||
CMTFILENO EQU 01029H ; Next Sequential file number to read when file request given without name.
|
||||
TZPU: EQU 0102AH ; Tranzputer present flag (0 = not present, > 0 = present and version number).
|
||||
; Variables sharing the BUFER buffer, normally the BUFER is only used to get keyboard input and so long as data in BUFER is processed
|
||||
; before calling the CMT/SD commands and not inbetween there shouldnt be any issue. Also the space used is at the top end of the buffer which is not used so often.
|
||||
; This frees up memory needed by the CMT and SD card.
|
||||
SECTORBUF: EQU 0CE00H ; Working buffer to place an SD card sector.
|
||||
SDSTARTSEC EQU BUFER+50+0 ; Starting sector of data to read/write from/to SD card.
|
||||
SDLOADADDR EQU BUFER+50+4 ; Address to read/write data from/to SD card.
|
||||
SDLOADSIZE EQU BUFER+50+6 ; Total remaining byte count data to read/write from/to SD card.
|
||||
SDAUTOEXEC EQU BUFER+50+8 ; Flag to indicate if a loaded image should be executed (=0xFF)
|
||||
SDBUF: EQU BUFER+50+9 ; SD Card command fram buffer for the command and response storage.
|
||||
DIRSECBUF: EQU BUFER+50+20 ; Directory sector in cache.
|
||||
DUMPADDR: EQU BUFER+50+22 ; Address used by the D(ump) command so that calls without parameters go onto the next block.
|
||||
CMTLOLOAD: EQU BUFER+50+24 ; Flag to indicate that a tape program is loaded into hi memory then shifted to low memory after ROM pageout.
|
||||
CMTCOPY: EQU BUFER+50+25 ; Flag to indicate that a CMT copy operation is taking place.
|
||||
CMTAUTOEXEC: EQU BUFER+50+26 ; Auto execution flag, run CMT program when loaded if flag clear.
|
||||
DTADRSTORE: EQU BUFER+50+27 ; Backup for load address if actual load shifts to lo memory or to 0x1200 for copy.
|
||||
SDCOPY: EQU BUFER+50+29 ; Flag to indicate an SD copy is taking place, either CMT->SD or SD->CMT.
|
||||
RESULT: EQU BUFER+50+30 ; Result variable needed for interbank calls when a result is needed.
|
||||
|
||||
;--------------------------------------------------
|
||||
; RFS ROM Banks, 0-7 are reserved for alternative
|
||||
; Monitor versions, CPM and RFS
|
||||
; code in MROM bank,
|
||||
; 0-7 are reserved for RFS code in
|
||||
; the User ROM bank.
|
||||
; 8-15 are reserved for CPM code in
|
||||
; the User ROM bank.
|
||||
;--------------------------------------------------
|
||||
MROMPAGES EQU 8
|
||||
USRROMPAGES EQU 12 ; Monitor ROM : User ROM
|
||||
ROMBANK0 EQU 0 ; MROM SA1510 40 Char : RFS Bank 0 - Main RFS Entry point and functions.
|
||||
ROMBANK1 EQU 1 ; MROM SA1510 80 Char : RFS Bank 1 - Floppy disk controller and utilities.
|
||||
ROMBANK2 EQU 2 ; CPM 2.2 CBIOS : RFS Bank 2 - SD Card controller and utilities.
|
||||
ROMBANK3 EQU 3 ; RFS Utilities : RFS Bank 3 - Cmdline tools (Memory, Printer, Help)
|
||||
ROMBANK4 EQU 4 ; MZ700 1Z-013A 40C : RFS Bank 4 - CMT Utilities.
|
||||
ROMBANK5 EQU 5 ; MZ700-1Z-013A 80C : RFS Bank 5
|
||||
ROMBANK6 EQU 6 ; MZ-80B IPL : RFS Bank 6
|
||||
ROMBANK7 EQU 7 ; Free : RFS Bank 7 - Memory and timer test utilities.
|
||||
ROMBANK8 EQU 8 ; : CBIOS Bank 1 - Utilities
|
||||
ROMBANK9 EQU 9 ; : CBIOS Bank 2 - Screen / ANSI Terminal
|
||||
ROMBANK10 EQU 10 ; : CBIOS Bank 3 - SD Card
|
||||
ROMBANK11 EQU 11 ; : CBIOS Bank 4 - Floppy disk controller.
|
||||
|
||||
;-----------------------------------------------
|
||||
; IO ports in hardware and values.
|
||||
;-----------------------------------------------
|
||||
MMCFG EQU 060H ; Memory management configuration latch.
|
||||
SETXMHZ EQU 062H ; Select the alternate clock frequency.
|
||||
SET2MHZ EQU 064H ; Select the system 2MHz clock frequency.
|
||||
CLKSELRD EQU 066H ; Read clock selected setting, 0 = 2MHz, 1 = XMHz
|
||||
SVCREQ EQU 068H ; I/O Processor service request.
|
||||
|
||||
;-----------------------------------------------
|
||||
; tranZPUter SW Memory Management modes
|
||||
;-----------------------------------------------
|
||||
TZMM_ORIG EQU 000H ; Original Sharp MZ80A mode, no tranZPUter features are selected except the I/O control registers (default: 0x60-063).
|
||||
TZMM_BOOT EQU 001H ; Original mode but E800-EFFF is mapped to tranZPUter RAM so TZFS can be booted.
|
||||
TZMM_TZFS EQU 002H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-FFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected.
|
||||
TZMM_TZFS2 EQU 003H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 1.
|
||||
TZMM_TZFS3 EQU 004H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 2.
|
||||
TZMM_TZFS4 EQU 005H ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 3.
|
||||
TZMM_CPM EQU 006H ; CPM main memory configuration, all memory on the tranZPUter board, 64K block 4 selected. Special case for F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard.
|
||||
TZMM_CPM2 EQU 007H ; CPM main memory configuration, F000-FFFF are on the tranZPUter board in block 4, 0040-CFFF and E800-EFFF are in block 5, mainboard for D000-DFFF (video), E000-E800 (Memory control) selected.
|
||||
; Special case for 0000:003F (interrupt vectors) which resides in block 4, F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard.
|
||||
TZMM_COMPAT EQU 008H ; Original mode but with main DRAM in Bank 0 to allow bootstrapping of programs from other machines such as the MZ700.
|
||||
TZMM_HOSTACCESS EQU 009H ; Mode to allow code running in Bank 0, address E800:FFFF to access host memory. Monitor ROM 0000-0FFF and Main DRAM 0x1000-0xD000, video and memory mapped I/O are on the host machine, User/Floppy ROM E800-FFFF are in tranZPUter memory.
|
||||
TZMM_MZ700_0 EQU 00AH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the mainboard.
|
||||
TZMM_MZ700_1 EQU 00BH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6.
|
||||
TZMM_MZ700_2 EQU 00CH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6.
|
||||
TZMM_MZ700_3 EQU 00DH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible.
|
||||
TZMM_MZ700_4 EQU 00EH ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible.
|
||||
TZMM_MZ800 EQU 00FH ; MZ800 Mode - Tracks original hardware mode offering MZ700/MZ800 configurations.
|
||||
TZMM_FPGA EQU 015H ; Open up access for the K64F to the FPGA resources such as memory. All other access to RAM or mainboard is blocked.
|
||||
TZMM_TZPUM EQU 016H ; Everything in on mainboard, no access to tranZPUter memory.
|
||||
TZMM_TZPU EQU 017H ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected.
|
||||
TZMM_TZPU0 EQU 018H ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected.
|
||||
TZMM_TZPU1 EQU 019H ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 1 is selected.
|
||||
TZMM_TZPU2 EQU 01AH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 2 is selected.
|
||||
TZMM_TZPU3 EQU 01BH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 3 is selected.
|
||||
TZMM_TZPU4 EQU 01CH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 4 is selected.
|
||||
TZMM_TZPU5 EQU 01DH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 5 is selected.
|
||||
TZMM_TZPU6 EQU 01EH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 6 is selected.
|
||||
TZMM_TZPU7 EQU 01FH ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 7 is selected.
|
||||
|
||||
;-----------------------------------------------
|
||||
; TZ File System Header (MZF)
|
||||
;-----------------------------------------------
|
||||
TZFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code.
|
||||
TZFS_NAME: EQU 00001h ; Title/Name (17 bytes).
|
||||
TZFS_SIZE: EQU 00012h ; Size of program.
|
||||
TZFS_DTADR: EQU 00014h ; Load address of program.
|
||||
TZFS_EXADR: EQU 00016h ; Exec address of program.
|
||||
TZFS_COMNT: EQU 00018h ; Comment
|
||||
TZFS_MZFLEN: EQU 128 ; Length of the MZF header.
|
||||
TZFS_CMTLEN: EQU 104 ; Length of the comment field
|
||||
|
||||
;-----------------------------------------------
|
||||
; BIOS WORK AREA (MZ80A)
|
||||
;-----------------------------------------------
|
||||
; Variables and control structure used by the I/O processor for service calls and requests.
|
||||
ORG TZSVCMEM
|
||||
|
||||
TZSVCMEM: EQU 0FD80H ; Start of a memory structure used to communicate with the K64F I/O processor for services such as disk access.
|
||||
TZSVCSIZE: EQU 00280H ;
|
||||
TZSVCDIRSZ: EQU 20 ; Size of the directory/file name.
|
||||
TZSVCFILESZ: EQU 17 ; Size of a Sharp filename.
|
||||
TZSVCLONGFILESZ: EQU 31 ; Size of a standard filename.
|
||||
TZSVCLONGFMTSZ: EQU 20 ; Size of a formatted standard filename for use in directory listings.
|
||||
TZSVCWILDSZ: EQU 20 ; Size of the wildcard.
|
||||
TZSVCSECSIZE: EQU 512
|
||||
TZSVCDIR_ENTSZ: EQU 32 ; Size of a directory entry.
|
||||
TZSVCWAITIORETRIES: EQU 500 ; Wait retries for IO response.
|
||||
TZSVCWAITCOUNT: EQU 65535 ; Wait retries for IO request response.
|
||||
TZSVC_FTYPE_MZF: EQU 0 ; File type being handled is an MZF
|
||||
TZSVC_FTYPE_CAS: EQU 1 ; File type being handled is an CASsette BASIC script.
|
||||
TZSVC_FTYPE_BAS: EQU 2 ; File type being handled is an BASic script
|
||||
TZSVC_FTYPE_ALL: EQU 10 ; Handle any filetype.
|
||||
TZSVC_FTYPE_ALLFMT: EQU 11 ; Special case for directory listings, all files but truncated and formatted.
|
||||
TZSVCCMD: DS virtual 1 ; Service command.
|
||||
TZSVCRESULT: DS virtual 1 ; Service command result.
|
||||
TZSVCDIRSEC: DS virtual 1 ; Storage for the directory sector number.
|
||||
TZSVC_FILE_SEC: EQU TZSVCDIRSEC ; Union of the file and directory sector as only one can be used at a time.
|
||||
TZSVC_TRACK_NO: DS virtual 2 ; Storage for the virtual drive track number.
|
||||
TZSVC_SECTOR_NO: DS virtual 2 ; Storage for the virtual drive sector number.
|
||||
TZSVC_FILE_NO: DS virtual 1 ; File number to be opened in a file service command.
|
||||
TZSVC_FILE_TYPE: DS virtual 1 ; Type of file being accessed to differentiate between Sharp MZF files and other handled files.
|
||||
TZSVC_LOADADDR: DS virtual 2 ; Dynamic load address for rom/images.
|
||||
TZSVC_SAVEADDR: EQU TZSVC_LOADADDR ; Union of the load address and the cpu frequency change value, the address of data to be saved.
|
||||
TZSVC_CPU_FREQ: EQU TZSVC_LOADADDR ; Union of the load address and the save address value, only one can be used at a time.
|
||||
TZSVC_LOADSIZE: DS virtual 2 ; Size of image to load.
|
||||
TZSVC_SAVESIZE: EQU TZSVC_LOADSIZE ; Size of image to be saved.
|
||||
TZSVC_DIRNAME: DS virtual TZSVCDIRSZ ; Service directory/file name.
|
||||
TZSVC_FILENAME: DS virtual TZSVCFILESZ ; Filename to be opened/created.
|
||||
TZSVCWILDC: DS virtual TZSVCWILDSZ ; Directory wildcard for file pattern matching.
|
||||
TZSVCSECTOR: DS virtual TZSVCSECSIZE ; Service command sector - to store directory entries, file sector read or writes.
|
||||
|
||||
TZSVC_CMD_READDIR: EQU 01H ; Service command to open a directory and return the first block of entries.
|
||||
TZSVC_CMD_NEXTDIR: EQU 02H ; Service command to return the next block of an open directory.
|
||||
TZSVC_CMD_READFILE: EQU 03H ; Service command to open a file and return the first block.
|
||||
TZSVC_CMD_NEXTREADFILE: EQU 04H ; Service command to return the next block of an open file.
|
||||
TZSVC_CMD_WRITEFILE: EQU 05H ; Service command to create a file and save the first block.
|
||||
TZSVC_CMD_NEXTWRITEFILE:EQU 06H ; Service command to write the next block to the open file.
|
||||
TZSVC_CMD_CLOSE: EQU 07H ; Service command to close any open file or directory.
|
||||
TZSVC_CMD_LOADFILE: EQU 08H ; Service command to load a file directly into tranZPUter memory.
|
||||
TZSVC_CMD_SAVEFILE: EQU 09H ; Service command to save a file directly from tranZPUter memory.
|
||||
TZSVC_CMD_ERASEFILE: EQU 0aH ; Service command to erase a file on the SD card.
|
||||
TZSVC_CMD_CHANGEDIR: EQU 0bH ; Service command to change the active directory on the SD card.
|
||||
TZSVC_CMD_LOAD40BIOS: EQU 20H ; Service command requesting that the 40 column version of the SA1510 BIOS is loaded.
|
||||
TZSVC_CMD_LOAD80BIOS: EQU 21H ; Service command requesting that the 80 column version of the SA1510 BIOS is loaded.
|
||||
TZSVC_CMD_LOAD700BIOS40:EQU 22H ; Service command requesting that the MZ700 1Z-013A 40 column BIOS is loaded.
|
||||
TZSVC_CMD_LOAD700BIOS80:EQU 23H ; Service command requesting that the MZ700 1Z-013A 80 column patched BIOS is loaded.
|
||||
TZSVC_CMD_LOAD80BIPL: EQU 24H ; Service command requesting the MZ-80B IPL is loaded.
|
||||
TZSVC_CMD_LOADBDOS: EQU 30H ; Service command to reload CPM BDOS+CCP.
|
||||
TZSVC_CMD_ADDSDDRIVE: EQU 31H ; Service command to attach a CPM disk to a drive number.
|
||||
TZSVC_CMD_READSDDRIVE: EQU 32H ; Service command to read an attached SD file as a CPM disk drive.
|
||||
TZSVC_CMD_WRITESDDRIVE: EQU 33H ; Service command to write to a CPM disk drive which is an attached SD file.
|
||||
TZSVC_CMD_CPU_BASEFREQ EQU 40H ; Service command to switch to the mainboard frequency.
|
||||
TZSVC_CMD_CPU_ALTFREQ EQU 41H ; Service command to switch to the alternate frequency provided by the K64F.
|
||||
TZSVC_CMD_CPU_CHGFREQ EQU 42H ; Service command to set the alternate frequency in hertz.
|
||||
TZSVC_CMD_CPU_SETZ80 EQU 50H ; Service command to switch to the external Z80 hard cpu.
|
||||
TZSVC_CMD_CPU_SETT80 EQU 51H ; Service command to switch to the internal T80 soft cpu.
|
||||
TZSVC_STATUS_OK: EQU 000H ; Flag to indicate the K64F processing completed successfully.
|
||||
TZSVC_STATUS_REQUEST: EQU 0FEH ; Flag to indicate the Z80 has made a request to the K64F.
|
||||
TZSVC_STATUS_PROCESSING:EQU 0FFH ; Flag to indicate the K64F is processing a command.
|
||||
563
asm/include/rfs_definitions.asm
Normal file
563
asm/include/rfs_definitions.asm
Normal file
@@ -0,0 +1,563 @@
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;-
|
||||
;- Name: RFS_Definitions.asm
|
||||
;- Created: September 2019
|
||||
;- Author(s): Philip Smart
|
||||
;- Description: Sharp MZ series Rom Filing System.
|
||||
;- Definitions for the RFS including SA1510 locations.
|
||||
;-
|
||||
;- Credits:
|
||||
;- Copyright: (c) 2019-23 Philip Smart <philip.smart@net2net.org>
|
||||
;-
|
||||
;- History: Sep 2019 - Initial version.
|
||||
;- May 2020 - Advent of the new RFS PCB v2.0, quite a few changes to accommodate the
|
||||
;- additional and different hardware. The SPI is now onboard the PCB and
|
||||
;- not using the printer interface card.
|
||||
;- July 2020 - Updated for the tranZPUter v2.1 hardware. RFS can run with a tranZPUter
|
||||
;- board with or without the K64 I/O processor. RFS wont use the K64
|
||||
;- processor all operations are done by the Z80 under RFS.
|
||||
;- March 2021- Updates to accommodate the RFS v2.1 board along with back porting TZFS
|
||||
;- developments.
|
||||
;-
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;- This source file is free software: you can redistribute it and-or modify
|
||||
;- it under the terms of the GNU General Public License as published
|
||||
;- by the Free Software Foundation, either version 3 of the License, or
|
||||
;- (at your option) any later version.
|
||||
;-
|
||||
;- This source file is distributed in the hope that it will be useful,
|
||||
;- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;- GNU General Public License for more details.
|
||||
;-
|
||||
;- You should have received a copy of the GNU General Public License
|
||||
;- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
|
||||
;-----------------------------------------------
|
||||
; Features.
|
||||
;-----------------------------------------------
|
||||
HW_SPI_ENA EQU 1 ; Set to 1 if hardware SPI is present on the RFS PCB v2 board.
|
||||
SW_SPI_ENA EQU 0 ; Set to 1 if software SPI is present on the RFS PCB v2 board.
|
||||
PP_SPI_ENA EQU 0 ; Set to 1 if using the SPI interface via the Parallel Port, ie. for RFS PCB v1 which doesnt have SPI onboard.
|
||||
FUSIONX_ENA EQU 1 ; Set to 1 if using RFS on the tranZPUter FusionX board.
|
||||
|
||||
; Debugging
|
||||
ENADEBUG EQU 0 ; Enable debugging logic, 1 = enable, 0 = disable
|
||||
|
||||
;-----------------------------------------------
|
||||
; Entry/compilation start points.
|
||||
;-----------------------------------------------
|
||||
UROMADDR EQU 0E800H ; Start of User ROM Address space.
|
||||
UROMBSTBL EQU UROMADDR + 020H ; Entry point to the bank switching table.
|
||||
RFSJMPTABLE EQU UROMADDR + 00080H ; Start of jump table.
|
||||
FDCROMADDR EQU 0F000H
|
||||
|
||||
|
||||
;-----------------------------------------------
|
||||
; Common character definitions.
|
||||
;-----------------------------------------------
|
||||
SCROLL EQU 001H ;Set scroll direction UP.
|
||||
BELL EQU 007H
|
||||
SPACE EQU 020H
|
||||
TAB EQU 009H ;TAB ACROSS (8 SPACES FOR SD-BOARD)
|
||||
CR EQU 00DH
|
||||
LF EQU 00AH
|
||||
FF EQU 00CH
|
||||
CS EQU 0CH ; Clear screen
|
||||
DELETE EQU 07FH
|
||||
BACKS EQU 008H
|
||||
SOH EQU 1 ; For XModem etc.
|
||||
EOT EQU 4
|
||||
ACK EQU 6
|
||||
NAK EQU 015H
|
||||
NUL EQU 000H
|
||||
NULL EQU 000H
|
||||
CTRL_A EQU 001H
|
||||
CTRL_B EQU 002H
|
||||
CTRL_C EQU 003H
|
||||
CTRL_D EQU 004H
|
||||
CTRL_E EQU 005H
|
||||
CTRL_F EQU 006H
|
||||
CTRL_G EQU 007H
|
||||
CTRL_H EQU 008H
|
||||
CTRL_I EQU 009H
|
||||
CTRL_J EQU 00AH
|
||||
CTRL_K EQU 00BH
|
||||
CTRL_L EQU 00CH
|
||||
CTRL_M EQU 00DH
|
||||
CTRL_N EQU 00EH
|
||||
CTRL_O EQU 00FH
|
||||
CTRL_P EQU 010H
|
||||
CTRL_Q EQU 011H
|
||||
CTRL_R EQU 012H
|
||||
CTRL_S EQU 013H
|
||||
CTRL_T EQU 014H
|
||||
CTRL_U EQU 015H
|
||||
CTRL_V EQU 016H
|
||||
CTRL_W EQU 017H
|
||||
CTRL_X EQU 018H
|
||||
CTRL_Y EQU 019H
|
||||
CTRL_Z EQU 01AH
|
||||
ESC EQU 01BH
|
||||
CTRL_SLASH EQU 01CH
|
||||
CTRL_LB EQU 01BH
|
||||
CTRL_RB EQU 01DH
|
||||
CTRL_CAPPA EQU 01EH
|
||||
CTRL_UNDSCR EQU 01FH
|
||||
CTRL_AT EQU 000H
|
||||
NOKEY EQU 0F0H
|
||||
CURSRIGHT EQU 0F1H
|
||||
CURSLEFT EQU 0F2H
|
||||
CURSUP EQU 0F3H
|
||||
CURSDOWN EQU 0F4H
|
||||
DBLZERO EQU 0F5H
|
||||
INSERT EQU 0F6H
|
||||
CLRKEY EQU 0F7H
|
||||
HOMEKEY EQU 0F8H
|
||||
BREAKKEY EQU 0FBH
|
||||
GRAPHKEY EQU 0FCH
|
||||
ALPHAKEY EQU 0FDH
|
||||
|
||||
|
||||
;-------------------------------------------------------
|
||||
; Function entry points in the standard SA-1510 Monitor.
|
||||
;-------------------------------------------------------
|
||||
GETL: EQU 00003h
|
||||
LETNL: EQU 00006h
|
||||
NL: EQU 00009h
|
||||
PRNTS: EQU 0000Ch
|
||||
PRNT: EQU 00012h
|
||||
MSG: EQU 00015h
|
||||
MSGX: EQU 00018h
|
||||
GETKY EQU 0001Bh
|
||||
BRKEY EQU 0001Eh
|
||||
?WRI EQU 00021h
|
||||
?WRD EQU 00024h
|
||||
?RDI EQU 00027h
|
||||
?RDD EQU 0002Ah
|
||||
?VRFY EQU 0002Dh
|
||||
MELDY EQU 00030h
|
||||
?TMST EQU 00033h
|
||||
MONIT: EQU 00000h
|
||||
SS: EQU 00089h
|
||||
ST1: EQU 00095h
|
||||
HLHEX EQU 00410h
|
||||
_2HEX EQU 0041Fh
|
||||
?MODE: EQU 0074DH
|
||||
?KEY EQU 008CAh
|
||||
PRNT3 EQU 0096Ch
|
||||
?ADCN EQU 00BB9h
|
||||
?DACN EQU 00BCEh
|
||||
?DSP: EQU 00DB5H
|
||||
?BLNK EQU 00DA6h
|
||||
?DPCT EQU 00DDCh
|
||||
PRTHL: EQU 003BAh
|
||||
PRTHX: EQU 003C3h
|
||||
HEX: EQU 003F9h
|
||||
DPCT: EQU 00DDCh
|
||||
DLY12: EQU 00DA7h
|
||||
DLY12A: EQU 00DAAh
|
||||
?RSTR1: EQU 00EE6h
|
||||
MOTOR: EQU 006A3H
|
||||
CKSUM: EQU 0071AH
|
||||
GAP: EQU 0077AH
|
||||
WTAPE: EQU 00485H
|
||||
MSTOP: EQU 00700H
|
||||
|
||||
;-----------------------------------------------
|
||||
; Memory mapped ports in hardware.
|
||||
;-----------------------------------------------
|
||||
SCRN: EQU 0D000H
|
||||
ARAM: EQU 0D800H
|
||||
DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7)
|
||||
KEYPA: EQU 0E000h
|
||||
KEYPB: EQU 0E001h
|
||||
KEYPC: EQU 0E002h
|
||||
KEYPF: EQU 0E003h
|
||||
CSTR: EQU 0E002h
|
||||
CSTPT: EQU 0E003h
|
||||
CONT0: EQU 0E004h
|
||||
CONT1: EQU 0E005h
|
||||
CONT2: EQU 0E006h
|
||||
CONTF: EQU 0E007h
|
||||
SUNDG: EQU 0E008h
|
||||
TEMP: EQU 0E008h
|
||||
MEMSW: EQU 0E00CH
|
||||
MEMSWR: EQU 0E010H
|
||||
INVDSP: EQU 0E014H
|
||||
NRMDSP: EQU 0E015H
|
||||
SCLDSP: EQU 0E200H
|
||||
SCLBASE: EQU 0E2H
|
||||
BNKCTRLRST: EQU 0EFF8H ; Bank control reset, returns all registers to power up default.
|
||||
BNKCTRLDIS: EQU 0EFF9H ; Disable bank control registers by resetting the coded latch.
|
||||
HWSPIDATA: EQU 0EFFBH ; Hardware SPI Data register (read/write).
|
||||
HWSPISTART: EQU 0EFFCH ; Start an SPI transfer.
|
||||
BNKSELMROM: EQU 0EFFDh ; Select RFS Bank1 (MROM)
|
||||
BNKSELUSER: EQU 0EFFEh ; Select RFS Bank2 (User ROM)
|
||||
BNKCTRL: EQU 0EFFFH ; Bank Control register (read/write).
|
||||
|
||||
;
|
||||
; RFS v2 Control Register constants.
|
||||
;
|
||||
BBCLK EQU 1 ; BitBang SPI Clock.
|
||||
SDCS EQU 2 ; SD Card Chip Select, active low.
|
||||
BBMOSI EQU 4 ; BitBang MOSI (Master Out Serial In).
|
||||
CDLTCH1 EQU 8 ; Coded latch up count bit 1
|
||||
CDLTCH2 EQU 16 ; Coded latch up count bit 2
|
||||
CDLTCH3 EQU 32 ; Coded latch up count bit 3
|
||||
BK2A19 EQU 64 ; User ROM Device Select Bit 0 (or Address bit 19).
|
||||
BK2A20 EQU 128 ; User ROM Device Select Bit 1 (or Address bit 20).
|
||||
; BK2A20 : BK2A19
|
||||
; 0 0 = Flash RAM 0 (default).
|
||||
; 0 1 = Flash RAM 1.
|
||||
; 1 0 = Flasm RAM 2 or Static RAM 0.
|
||||
; 1 1 = Reserved.`
|
||||
|
||||
BNKCTRLDEF EQU BBMOSI+SDCS+BBCLK ; Default on startup for the Bank Control register.
|
||||
|
||||
;-----------------------------------------------
|
||||
; IO ports in hardware and values.
|
||||
;-----------------------------------------------
|
||||
SPI_OUT EQU 0FFH
|
||||
SPI_IN EQU 0FEH
|
||||
;
|
||||
DOUT_LOW EQU 000H
|
||||
DOUT_HIGH EQU 004H
|
||||
DOUT_MASK EQU 004H
|
||||
DIN_LOW EQU 000H
|
||||
DIN_HIGH EQU 001H
|
||||
CLOCK_LOW EQU 000H
|
||||
CLOCK_HIGH EQU 002H
|
||||
CLOCK_MASK EQU 0FDH
|
||||
CS_LOW EQU 000H
|
||||
CS_HIGH EQU 001H
|
||||
;
|
||||
MMCFG EQU 060H ; Memory management configuration latch.
|
||||
SETXMHZ EQU 062H ; Select the alternate clock frequency.
|
||||
SET2MHZ EQU 064H ; Select the system 2MHz clock frequency.
|
||||
CLKSELRD EQU 066H ; Read clock selected setting, 0 = 2MHz, 1 = XMHz
|
||||
SVCREQ EQU 068H ; I/O Processor service request.
|
||||
CPUCFG EQU 06CH ; Version 2.2 CPU configuration register.
|
||||
CPUSTATUS EQU 06CH ; Version 2.2 CPU runtime status register.
|
||||
CPUINFO EQU 06DH ; Version 2.2 CPU information register.
|
||||
CPLDCFG EQU 06EH ; Version 2.1 CPLD configuration register.
|
||||
CPLDSTATUS EQU 06EH ; Version 2.1 CPLD status register.
|
||||
CPLDINFO EQU 06FH ; Version 2.1 CPLD version information register.
|
||||
MMIO0 EQU 0E0H ; MZ-700/MZ-800 Memory Management Set 0
|
||||
MMIO1 EQU 0E1H ; MZ-700/MZ-800 Memory Management Set 1
|
||||
MMIO2 EQU 0E2H ; MZ-700/MZ-800 Memory Management Set 2
|
||||
MMIO3 EQU 0E3H ; MZ-700/MZ-800 Memory Management Set 3
|
||||
MMIO4 EQU 0E4H ; MZ-700/MZ-800 Memory Management Set 4
|
||||
MMIO5 EQU 0E5H ; MZ-700/MZ-800 Memory Management Set 5
|
||||
MMIO6 EQU 0E6H ; MZ-700/MZ-800 Memory Management Set 6
|
||||
MMIO7 EQU 0E7H ; MZ-700/MZ-800 Memory Management Set 7
|
||||
|
||||
;-----------------------------------------------
|
||||
; CPLD Configuration constants.
|
||||
;-----------------------------------------------
|
||||
MODE_MZ80K EQU 0 ; Set to MZ-80K mode.
|
||||
MODE_MZ80C EQU 1 ; Set to MZ-80C mode.
|
||||
MODE_MZ1200 EQU 2 ; Set to MZ-1200 mode.
|
||||
MODE_MZ80A EQU 3 ; Set to MZ-80A mode (base mode on MZ-80A hardware).
|
||||
MODE_MZ700 EQU 4 ; Set to MZ-700 mode (base mode on MZ-700 hardware).
|
||||
MODE_MZ800 EQU 5 ; Set to MZ-800 mode.
|
||||
MODE_MZ80B EQU 6 ; Set to MZ-80B mode.
|
||||
MODE_MZ2000 EQU 7 ; Set to MZ-2000 mode.
|
||||
MODE_VIDEO_FPGA EQU 8 ; Bit flag (bit 3) to switch CPLD into using the new FPGA video hardware.
|
||||
|
||||
;-----------------------------------------------
|
||||
; tranZPUter SW Memory Management modes
|
||||
;-----------------------------------------------
|
||||
TZMM_ENIOWAIT EQU 020H ; Memory management IO Wait State enable - insert a wait state when an IO operation to E0-FF is executed.
|
||||
TZMM_ORIG EQU 000H ; Original Sharp MZ80A mode, no tranZPUter features are selected except the I/O control registers (default: 0x60-063).
|
||||
TZMM_BOOT EQU 001H ; Original mode but E800-EFFF is mapped to tranZPUter RAM so TZFS can be booted.
|
||||
TZMM_TZFS EQU 002H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-FFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected.
|
||||
TZMM_TZFS2 EQU 003H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 1.
|
||||
TZMM_TZFS3 EQU 004H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 2.
|
||||
TZMM_TZFS4 EQU 005H + TZMM_ENIOWAIT ; TZFS main memory configuration. all memory is in tranZPUter RAM, E800-EFFF is used by TZFS, SA1510 is at 0000-1000 and RAM is 1000-CFFF, 64K Block 0 selected, F000-FFFF is in 64K Block 3.
|
||||
TZMM_CPM EQU 006H + TZMM_ENIOWAIT ; CPM main memory configuration, all memory on the tranZPUter board, 64K block 4 selected. Special case for F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard.
|
||||
TZMM_CPM2 EQU 007H + TZMM_ENIOWAIT ; CPM main memory configuration, F000-FFFF are on the tranZPUter board in block 4, 0040-CFFF and E800-EFFF are in block 5, mainboard for D000-DFFF (video), E000-E800 (Memory control) selected.
|
||||
; Special case for 0000:003F (interrupt vectors) which resides in block 4, F3C0:F3FF & F7C0:F7FF (floppy disk paging vectors) which resides on the mainboard.
|
||||
TZMM_COMPAT EQU 008H + TZMM_ENIOWAIT ; Original mode but with main DRAM in Bank 0 to allow bootstrapping of programs from other machines such as the MZ700.
|
||||
TZMM_HOSTACCESS EQU 009H + TZMM_ENIOWAIT ; Mode to allow code running in Bank 0, address E800:FFFF to access host memory. Monitor ROM 0000-0FFF and Main DRAM 0x1000-0xD000, video and memory mapped I/O are on the host machine, User/Floppy ROM E800-FFFF are in tranZPUter memory.
|
||||
TZMM_MZ700_0 EQU 00AH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the mainboard.
|
||||
TZMM_MZ700_1 EQU 00BH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6.
|
||||
TZMM_MZ700_2 EQU 00CH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is on the tranZPUter in block 6.
|
||||
TZMM_MZ700_3 EQU 00DH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 0, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible.
|
||||
TZMM_MZ700_4 EQU 00EH + TZMM_ENIOWAIT ; MZ700 Mode - 0000:0FFF is on the tranZPUter board in block 6, 1000:CFFF is on the tranZPUter board in block 0, D000:FFFF is inaccessible.
|
||||
TZMM_MZ800 EQU 00FH + TZMM_ENIOWAIT ; MZ800 Mode - Tracks original hardware mode offering MZ700/MZ800 configurations.
|
||||
TZMM_FPGA EQU 015H + TZMM_ENIOWAIT ; Open up access for the K64F to the FPGA resources such as memory. All other access to RAM or mainboard is blocked.
|
||||
TZMM_TZPUM EQU 016H + TZMM_ENIOWAIT ; Everything in on mainboard, no access to tranZPUter memory.
|
||||
TZMM_TZPU EQU 017H + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected.
|
||||
TZMM_TZPU0 EQU 018H + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 0 is selected.
|
||||
TZMM_TZPU1 EQU 019H + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 1 is selected.
|
||||
TZMM_TZPU2 EQU 01AH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 2 is selected.
|
||||
TZMM_TZPU3 EQU 01BH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 3 is selected.
|
||||
TZMM_TZPU4 EQU 01CH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 4 is selected.
|
||||
TZMM_TZPU5 EQU 01DH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 5 is selected.
|
||||
TZMM_TZPU6 EQU 01EH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 6 is selected.
|
||||
TZMM_TZPU7 EQU 01FH + TZMM_ENIOWAIT ; Everything is in tranZPUter domain, no access to underlying Sharp mainboard unless memory management mode is switched. tranZPUter RAM 64K block 7 is selected.
|
||||
|
||||
;-----------------------------------------------
|
||||
; Rom File System Header (MZF)
|
||||
;-----------------------------------------------
|
||||
RFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code.
|
||||
RFS_NAME: EQU 00001h ; Title/Name (17 bytes).
|
||||
RFS_SIZE: EQU 00012h ; Size of program.
|
||||
RFS_DTADR: EQU 00014h ; Load address of program.
|
||||
RFS_EXADR: EQU 00016h ; Exec address of program.
|
||||
RFS_COMNT: EQU 00018h ; COMMENT
|
||||
|
||||
;-----------------------------------------------
|
||||
; Entry/compilation start points.
|
||||
;-----------------------------------------------
|
||||
TPSTART: EQU 010F0h
|
||||
MEMSTART: EQU 01200h
|
||||
MSTART: EQU 0E900h
|
||||
MZFHDRSZ EQU 128
|
||||
RFSSECTSZ EQU 256
|
||||
MROMSIZE EQU 4096
|
||||
UROMSIZE EQU 2048
|
||||
FNSIZE EQU 17
|
||||
;
|
||||
; Monitor ROM Jump Table definitions.
|
||||
;
|
||||
MROMJMPTBL: EQU 00070H
|
||||
DIRMROM: EQU MROMJMPTBL + 00000H
|
||||
MFINDMZF: EQU MROMJMPTBL + 00003H
|
||||
MROMLOAD: EQU MROMJMPTBL + 00006H
|
||||
|
||||
;-----------------------------------------------
|
||||
; ROM Banks, 0-7 are reserved for alternative
|
||||
; Monitor versions, CPM and RFS
|
||||
; code in MROM bank,
|
||||
; 0-7 are reserved for RFS code in
|
||||
; the User ROM bank.
|
||||
; 8-15 are reserved for CPM code in
|
||||
; the User ROM bank.
|
||||
;-----------------------------------------------
|
||||
MROMPAGES EQU 8
|
||||
USRROMPAGES EQU 12 ; Monitor ROM : User ROM
|
||||
ROMBANK0 EQU 0 ; MROM SA1510 40 Char : RFS Bank 0 - Main RFS Entry point and functions.
|
||||
ROMBANK1 EQU 1 ; MROM SA1510 80 Char : RFS Bank 1 - Floppy disk controller and utilities.
|
||||
ROMBANK2 EQU 2 ; CPM 2.2 CBIOS : RFS Bank 2 - SD Card controller and utilities.
|
||||
ROMBANK3 EQU 3 ; RFS Utilities : RFS Bank 3 - Cmdline tools (Memory, Printer, Help)
|
||||
ROMBANK4 EQU 4 ; MZ700 1Z-013A 40C : RFS Bank 4 - CMT Utilities.
|
||||
ROMBANK5 EQU 5 ; MZ700-1Z-013A 80C : RFS Bank 5
|
||||
ROMBANK6 EQU 6 ; MZ-80B IPL : RFS Bank 6
|
||||
ROMBANK7 EQU 7 ; Free : RFS Bank 7 - Memory and timer test utilities.
|
||||
ROMBANK8 EQU 8 ; : CBIOS Bank 1 - Utilities
|
||||
ROMBANK9 EQU 9 ; : CBIOS Bank 2 - Screen / ANSI Terminal
|
||||
ROMBANK10 EQU 10 ; : CBIOS Bank 3 - SD Card
|
||||
ROMBANK11 EQU 11 ; : CBIOS Bank 4 - Floppy disk controller.
|
||||
|
||||
|
||||
; MMC/SD command (SPI mode)
|
||||
CMD0 EQU 64 + 0 ; GO_IDLE_STATE
|
||||
CMD1 EQU 64 + 1 ; SEND_OP_COND
|
||||
ACMD41 EQU 0x40+41 ; SEND_OP_COND (SDC)
|
||||
CMD8 EQU 64 + 8 ; SEND_IF_COND
|
||||
CMD9 EQU 64 + 9 ; SEND_CSD
|
||||
CMD10 EQU 64 + 10 ; SEND_CID
|
||||
CMD12 EQU 64 + 12 ; STOP_TRANSMISSION
|
||||
CMD13 EQU 64 + 13 ; SEND_STATUS
|
||||
ACMD13 EQU 0x40+13 ; SD_STATUS (SDC)
|
||||
CMD16 EQU 64 + 16 ; SET_BLOCKLEN
|
||||
CMD17 EQU 64 + 17 ; READ_SINGLE_BLOCK
|
||||
CMD18 EQU 64 + 18 ; READ_MULTIPLE_BLOCK
|
||||
CMD23 EQU 64 + 23 ; SET_BLOCK_COUNT
|
||||
ACMD23 EQU 0x40+23 ; SET_WR_BLK_ERASE_COUNT (SDC)
|
||||
CMD24 EQU 64 + 24 ; WRITE_BLOCK
|
||||
CMD25 EQU 64 + 25 ; WRITE_MULTIPLE_BLOCK
|
||||
CMD32 EQU 64 + 32 ; ERASE_ER_BLK_START
|
||||
CMD33 EQU 64 + 33 ; ERASE_ER_BLK_END
|
||||
CMD38 EQU 64 + 38 ; ERASE
|
||||
CMD55 EQU 64 + 55 ; APP_CMD
|
||||
CMD58 EQU 64 + 58 ; READ_OCR
|
||||
SD_SECSIZE EQU 512 ; Default size of an SD Sector
|
||||
SD_RETRIES EQU 00100H ; Number of retries before giving up.
|
||||
|
||||
; Card type flags (CardType)
|
||||
CT_MMC EQU 001H ; MMC ver 3
|
||||
CT_SD1 EQU 002H ; SD ver 1
|
||||
CT_SD2 EQU 004H ; SD ver 2
|
||||
CT_SDC EQU CT_SD1|CT_SD2 ; SD
|
||||
CT_BLOCK EQU 008H ; Block addressing
|
||||
|
||||
; SD Card Directory structure. The directory entries are based on the MZF Header format and constraints.
|
||||
;
|
||||
; FLAG1 | FLAG2 | FILE NAME | START SECTOR | SIZE | LOAD ADDR | EXEC ADDR | RESERVED
|
||||
; 1 Byte | 1 Byte | 17 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 5 Bytes
|
||||
;
|
||||
; FLAG1 : BIT 7 = 1, Valid directory entry, 0 = inactive.
|
||||
; FLAG2 : MZF Execution Code, 0x01 = Binary
|
||||
; FILENAME : Standard MZF format filename.
|
||||
; START SECTOR : Sector in the SD card where the program starts. It always starts at position 0 of the sector.
|
||||
; SIZE : Size in bytes of the program. Each file block occupies 64Kbyte space (as per a tape) and this
|
||||
; parameter provides the actual space occupied by the program at the current time.
|
||||
; LOAD ADDR : Start address in memory where data should be loaded.
|
||||
; EXEC ADDR : If a binary then this parameter specifies the location to auto execute once loaded.
|
||||
; RESERVED : Not used at the moemnt.
|
||||
SDDIR_FLAG1 EQU 000H
|
||||
SDDIR_FLAG2 EQU 001H
|
||||
SDDIR_FILEN EQU 002H
|
||||
SDDIR_SSEC EQU 013H
|
||||
SDDIR_SIZE EQU 015H
|
||||
SDDIR_LOAD EQU 017H
|
||||
SDDIR_EXEC EQU 019H
|
||||
SDDIR_FNSZ EQU FNSIZE
|
||||
SDDIR_ENTSZ EQU 32
|
||||
|
||||
;
|
||||
; Rom Filing System constants for the SD Card.
|
||||
;
|
||||
SDDIR_DIRENT EQU 256 ; Directory entries in the RFS directory.
|
||||
SDDIR_DIRENTSZ EQU 32 ; Size of a directory entry.
|
||||
SDDIR_DIRSIZE EQU SDDIR_DIRENT * SDDIR_DIRENTSZ ; Total size of the directory.
|
||||
SDDIR_BLOCKSZ EQU 65536 ; Size of a file block per directory entry.
|
||||
SDDIR_IMGSZ EQU SDDIR_DIRSIZE + (SDDIR_DIRENT * SDDIR_BLOCKSZ) ; Total size of the RFS image.
|
||||
|
||||
OBJCD EQU 001H ; MZF contains a binary object.
|
||||
BTX1CD EQU 002H ; MZF contains an MZ-80K/80A BASIC program.
|
||||
BTX2CD EQU 005H ; MZF contains an MZ-700/800 BASIC program.
|
||||
BTX3CD EQU 07EH ; MZF contains a NASCOM Cassette BASIC program.
|
||||
BTX4CD EQU 07FH ; MZF contains a NASCOM ASCII TEXT BASIC program.
|
||||
TZOBJCD0 EQU 0F8H ; MZF contains a TZFS binary object for page 0.
|
||||
TZOBJCD1 EQU 0F9H
|
||||
TZOBJCD2 EQU 0FAH
|
||||
TZOBJCD3 EQU 0FBH
|
||||
TZOBJCD4 EQU 0FCH
|
||||
TZOBJCD5 EQU 0FDH
|
||||
TZOBJCD6 EQU 0FEH
|
||||
TZOBJCD7 EQU 0FFH ; MZF contains a TZFS binary object for page 7.
|
||||
|
||||
;-----------------------------------------------
|
||||
; SA-1510 MONITOR WORK AREA (MZ80A)
|
||||
;-----------------------------------------------
|
||||
STACK: EQU 010F0H
|
||||
;
|
||||
ORG STACK
|
||||
;
|
||||
SPV:
|
||||
IBUFE: ; TAPE BUFFER (128 BYTES)
|
||||
ATRB: DS virtual 1 ; ATTRIBUTE
|
||||
NAME: DS virtual FNSIZE ; FILE NAME
|
||||
SIZE: DS virtual 2 ; BYTESIZE
|
||||
DTADR: DS virtual 2 ; DATA ADDRESS
|
||||
EXADR: DS virtual 2 ; EXECUTION ADDRESS
|
||||
COMNT: DS virtual 92 ; COMMENT
|
||||
SWPW: DS virtual 10 ; SWEEP WORK
|
||||
KDATW: DS virtual 2 ; KEY WORK
|
||||
KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE)
|
||||
DSPXY: DS virtual 2 ; DISPLAY COORDINATES
|
||||
MANG: DS virtual 6 ; COLUMN MANAGEMENT
|
||||
MANGE: DS virtual 1 ; COLUMN MANAGEMENT END
|
||||
PBIAS: DS virtual 1 ; PAGE BIAS
|
||||
ROLTOP: DS virtual 1 ; ROLL TOP BIAS
|
||||
MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER
|
||||
PAGETP: DS virtual 2 ; PAGE TOP
|
||||
ROLEND: DS virtual 1 ; ROLL END
|
||||
DS virtual 14 ; BIAS
|
||||
FLASH: DS virtual 1 ; FLASHING DATA
|
||||
SFTLK: DS virtual 1 ; SHIFT LOCK
|
||||
REVFLG: DS virtual 1 ; REVERSE FLAG
|
||||
SPAGE: DS virtual 1 ; PAGE CHANGE
|
||||
FLSDT: DS virtual 1 ; CURSOR DATA
|
||||
STRGF: DS virtual 1 ; STRING FLAG
|
||||
DPRNT: DS virtual 1 ; TAB COUNTER
|
||||
TMCNT: DS virtual 2 ; TAPE MARK COUNTER
|
||||
SUMDT: DS virtual 2 ; CHECK SUM DATA
|
||||
CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA
|
||||
AMPM: DS virtual 1 ; AMPM DATA
|
||||
TIMFG: DS virtual 1 ; TIME FLAG
|
||||
SWRK: DS virtual 1 ; KEY SOUND FLAG
|
||||
TEMPW: DS virtual 1 ; TEMPO WORK
|
||||
ONTYO: DS virtual 1 ; ONTYO WORK
|
||||
OCTV: DS virtual 1 ; OCTAVE WORK
|
||||
RATIO: DS virtual 2 ; ONPU RATIO
|
||||
BUFER: DS virtual 81 ; GET LINE BUFFER
|
||||
|
||||
; Starting 1000H - Generally unused bytes not cleared by the monitor.
|
||||
ROMBK1: EQU 01016H ; CURRENT MROM BANK
|
||||
ROMBK2: EQU 01017H ; CURRENT USERROM BANK
|
||||
WRKROMBK1: EQU 01018H ; WORKING MROM BANK
|
||||
WRKROMBK2: EQU 01019H ; WORKING USERROM BANK
|
||||
ROMCTL: EQU 0101AH ; Current Bank control register setting.
|
||||
SCRNMODE: EQU 0101BH ; Mode of screen, 0 = 40 char, 1 = 80 char.
|
||||
TMPADR: EQU 0101CH ; TEMPORARY ADDRESS STORAGE
|
||||
TMPSIZE: EQU 0101EH ; TEMPORARY SIZE
|
||||
TMPCNT: EQU 01020H ; TEMPORARY COUNTER
|
||||
TMPLINECNT: EQU 01022H ; Temporary counter for displayed lines.
|
||||
TMPSTACKP: EQU 01024H ; Temporary stack pointer save.
|
||||
SDVER: EQU 01026H
|
||||
SDCAP: EQU 01027H
|
||||
SDDRIVENO EQU 01028H ; RFS SDCFS Active Drive Number
|
||||
CMTFILENO EQU 01029H ; Next Sequential file number to read when file request given without name.
|
||||
TZPU: EQU 0102AH ; Tranzputer present flag (0 = not present, > 0 = present and version number).
|
||||
; Variables sharing the BUFER buffer, normally the BUFER is only used to get keyboard input and so long as data in BUFER is processed
|
||||
; before calling the CMT/SD commands and not inbetween there shouldnt be any issue. Also the space used is at the top end of the buffer which is not used so often.
|
||||
; This frees up memory needed by the CMT and SD card.
|
||||
SECTORBUF: EQU 0CE00H ; Working buffer to place an SD card sector.
|
||||
SDSTARTSEC EQU BUFER+50+0 ; Starting sector of data to read/write from/to SD card.
|
||||
SDLOADADDR EQU BUFER+50+4 ; Address to read/write data from/to SD card.
|
||||
SDLOADSIZE EQU BUFER+50+6 ; Total remaining byte count data to read/write from/to SD card.
|
||||
SDAUTOEXEC EQU BUFER+50+8 ; Flag to indicate if a loaded image should be executed (=0xFF)
|
||||
SDBUF: EQU BUFER+50+9 ; SD Card command fram buffer for the command and response storage.
|
||||
DIRSECBUF: EQU BUFER+50+20 ; Directory sector in cache.
|
||||
DUMPADDR: EQU BUFER+50+22 ; Address used by the D(ump) command so that calls without parameters go onto the next block.
|
||||
CMTLOLOAD: EQU BUFER+50+24 ; Flag to indicate that a tape program is loaded into hi memory then shifted to low memory after ROM pageout.
|
||||
CMTCOPY: EQU BUFER+50+25 ; Flag to indicate that a CMT copy operation is taking place.
|
||||
CMTAUTOEXEC: EQU BUFER+50+26 ; Auto execution flag, run CMT program when loaded if flag clear.
|
||||
DTADRSTORE: EQU BUFER+50+27 ; Backup for load address if actual load shifts to lo memory or to 0x1200 for copy.
|
||||
SDCOPY: EQU BUFER+50+29 ; Flag to indicate an SD copy is taking place, either CMT->SD or SD->CMT.
|
||||
RESULT: EQU BUFER+50+30 ; Result variable needed for interbank calls when a result is needed.
|
||||
|
||||
; Quickdisk work area
|
||||
;QDPA EQU 01130h ; QD code 1
|
||||
;QDPB EQU 01131h ; QD code 2
|
||||
;QDPC EQU 01132h ; QD header startaddress
|
||||
;QDPE EQU 01134h ; QD header length
|
||||
;QDCPA EQU 0113Bh ; QD error flag
|
||||
;HDPT EQU 0113Ch ; QD new headpoint possition
|
||||
;HDPT0 EQU 0113Dh ; QD actual headpoint possition
|
||||
;FNUPS EQU 0113Eh
|
||||
;FNUPF EQU 01140h
|
||||
;FNA EQU 01141h ; File Number A (actual file number)
|
||||
;FNB EQU 01142h ; File Number B (next file number)
|
||||
;MTF EQU 01143h ; QD motor flag
|
||||
;RTYF EQU 01144h
|
||||
;SYNCF EQU 01146h ; SyncFlags
|
||||
;RETSP EQU 01147h
|
||||
;BUFER EQU 011A3h
|
||||
;QDIRBF EQU 0CD90h
|
||||
|
||||
|
||||
|
||||
;SPV:
|
||||
;IBUFE: ; TAPE BUFFER (128 BYTES)
|
||||
;ATRB: DS virtual 1 ; Code Type, 01 = Machine Code.
|
||||
;NAME: DS virtual 17 ; Title/Name (17 bytes).
|
||||
;SIZE: DS virtual 2 ; Size of program.
|
||||
;DTADR: DS virtual 2 ; Load address of program.
|
||||
;EXADR: DS virtual 2 ; Exec address of program.
|
||||
;COMNT: DS virtual 104 ; COMMENT
|
||||
;KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE)
|
||||
;DSPXY: DS virtual 2 ; DISPLAY COORDINATES
|
||||
;MANG: DS virtual 27 ; COLUMN MANAGEMENT
|
||||
;FLASH: DS virtual 1 ; FLASHING DATA
|
||||
;FLPST: DS virtual 2 ; FLASHING POSITION
|
||||
;FLSST: DS virtual 1 ; FLASHING STATUS
|
||||
;FLSDT: DS virtual 1 ; CURSOR DATA
|
||||
;STRGF: DS virtual 1 ; STRING FLAG
|
||||
;DPRNT: DS virtual 1 ; TAB COUNTER
|
||||
;TMCNT: DS virtual 2 ; TAPE MARK COUNTER
|
||||
;SUMDT: DS virtual 2 ; CHECK SUM DATA
|
||||
;CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA
|
||||
;AMPM: DS virtual 1 ; AMPM DATA
|
||||
;TIMFG: DS virtual 1 ; TIME FLAG
|
||||
;SWRK: DS virtual 1 ; KEY SOUND FLAG
|
||||
;TEMPW: DS virtual 1 ; TEMPO WORK
|
||||
;ONTYO: DS virtual 1 ; ONTYO WORK
|
||||
;OCTV: DS virtual 1 ; OCTAVE WORK
|
||||
;RATIO: DS virtual 2 ; ONPU RATIO
|
||||
496
asm/include/rfs_utilities.asm
Normal file
496
asm/include/rfs_utilities.asm
Normal file
@@ -0,0 +1,496 @@
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;-
|
||||
;- Name: RFS_Utilities.asm
|
||||
;- Created: September 2019
|
||||
;- Author(s): Philip Smart
|
||||
;- Description: Sharp MZ series Rom Filing System.
|
||||
;- This assembly language program is written to utilise the banked flashroms added with
|
||||
;- the MZ-80A RFS hardware upgrade.
|
||||
;-
|
||||
;- Credits:
|
||||
;- Copyright: (c) 2019-23 Philip Smart <philip.smart@net2net.org>
|
||||
;-
|
||||
;- History: September 2018 - Merged 2 utilities to create this compilation.
|
||||
;-
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
;- This source file is free software: you can redistribute it and-or modify
|
||||
;- it under the terms of the GNU General Public License as published
|
||||
;- by the Free Software Foundation, either version 3 of the License, or
|
||||
;- (at your option) any later version.
|
||||
;-
|
||||
;- This source file is distributed in the hope that it will be useful,
|
||||
;- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;- GNU General Public License for more details.
|
||||
;-
|
||||
;- You should have received a copy of the GNU General Public License
|
||||
;- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;--------------------------------------------------------------------------------------------------------
|
||||
|
||||
; Comparing Strings
|
||||
; IN HL Address of string1.
|
||||
; DE Address of string2.
|
||||
; BC Max bytes to compare, 0x00 or 0x0d will early terminate.
|
||||
; OUT zero Set if string1 = string2, reset if string1 != string2.
|
||||
; carry Set if string1 > string2, reset if string1 <= string2.
|
||||
CMPSTRING: IF USE_CMPSTRING = 1
|
||||
PUSH HL
|
||||
PUSH DE
|
||||
|
||||
CMPSTR1: LD A, (DE) ; Compare bytes.
|
||||
CP 000h ; Check for end of string.
|
||||
JR Z, CMPSTR3
|
||||
CP 00Dh
|
||||
JR Z, CMPSTR3
|
||||
CPI ; Compare bytes.
|
||||
JR NZ, CMPSTR2 ; If (HL) != (DE), abort.
|
||||
INC DE ; Update pointer.
|
||||
JP PE, CMPSTR1 ; Next byte if BC not zero.
|
||||
|
||||
CMPSTR2: DEC HL
|
||||
CP (HL) ; Compare again to affect carry.
|
||||
CMPSTR4: POP DE
|
||||
POP HL
|
||||
RET
|
||||
|
||||
CMPSTR3: LD A, (HL)
|
||||
CP 000h ; Check for end of string.
|
||||
JR Z, CMPSTR4
|
||||
CP 00Dh
|
||||
JR Z, CMPSTR4
|
||||
SCF ; String 1 greater than string 2
|
||||
JR CMPSTR4
|
||||
ENDIF
|
||||
|
||||
|
||||
; IN HL Address of source string, length-prefixed.
|
||||
; DE Address of destination string, length-prefixed.
|
||||
; B Start index. 1 = first character.
|
||||
; C Length of substring to return.
|
||||
;
|
||||
; OUT carry Set if an error condition happened:
|
||||
; If B is zero, then uses index of 1.
|
||||
; If index > source length, an empty string is returned.
|
||||
; If index + return length > source length, returns all
|
||||
; characters from index to end-of-string.
|
||||
|
||||
SUBSTRING: IF USE_SUBSTRING = 1
|
||||
PUSH DE ; It would be convenient to keep DE pointing to
|
||||
; the start of the destination string
|
||||
OR A ; Boolean OR resets carry
|
||||
PUSH AF ; Save carry
|
||||
LD A, B ; Is index beyond source length?
|
||||
CP (HL)
|
||||
DEC A ; Decrement A so NC can be used
|
||||
JR NC,SUBST3
|
||||
|
||||
ADD A, C ; If index+len is > 255, error
|
||||
JR C, SUBST1
|
||||
INC A ; Increment A so C can be used
|
||||
CP (HL) ; If index+len is beyond source length, then error
|
||||
JR C, SUBST2
|
||||
|
||||
SUBST1: POP AF ; Set carry flag
|
||||
SCF
|
||||
PUSH AF
|
||||
LD A, (HL) ; Get source length
|
||||
SUB B ; Subtract start index
|
||||
INC A ; Compensate
|
||||
LD C, A ; New size of string
|
||||
|
||||
SUBST2: LD A, C ; Size of sting to get
|
||||
LD (DE), A ; Save length index
|
||||
INC DE ; To body of string
|
||||
LD A, B ; Get index
|
||||
LD B, 0 ; Zero-extend BC for LDIR
|
||||
|
||||
ADD A, L ; This is a sneaky way to add A to HL
|
||||
LD L, A ; without using up another 16-bit register
|
||||
ADC A, H ;
|
||||
SUB L ;
|
||||
LD H, A ;
|
||||
|
||||
LDIR ; Copy substring over
|
||||
POP AF ; Restore flags
|
||||
POP DE ; Restore destination
|
||||
RET
|
||||
|
||||
SUBST3: XOR A ; Set a length index of zero
|
||||
LD (DE), A
|
||||
POP AF ; Clean off stack and set carry
|
||||
POP DE
|
||||
SCF
|
||||
RET
|
||||
ENDIF
|
||||
|
||||
; IN HL Address of string to look in, length prefixed.
|
||||
; DE Address of string to find, length prefixed.
|
||||
;
|
||||
; OUT
|
||||
; If found:
|
||||
; A Offset into look-up string where the target string was found.
|
||||
; The first byte (ignoring length prefix) is offset 1.
|
||||
; carry Reset.
|
||||
;
|
||||
; If not found:
|
||||
; A = 0
|
||||
; carry Set.
|
||||
|
||||
INDEX: IF USE_INDEX = 1
|
||||
LD A, (DE) ; Abort if string to find is too big
|
||||
CP (HL)
|
||||
INC A
|
||||
JR NC, IDXABORT
|
||||
|
||||
DEC A ; Save length of string to find
|
||||
LD IXL, A
|
||||
|
||||
LD B, 0 ; Put length of string to search in BC
|
||||
LD C, (HL)
|
||||
|
||||
INC HL ; Advance pointers
|
||||
INC DE
|
||||
PUSH HL ; Save start of search string
|
||||
|
||||
IDXRST: PUSH DE ; Save start of key string
|
||||
|
||||
LD A, IXL ; Initialize matched characters counter
|
||||
LD IXH, A
|
||||
|
||||
LD A, (DE) ; Get a character to match
|
||||
CPIR ; Look for it
|
||||
JR NZ, IDXNF ; Abort if not found
|
||||
|
||||
IDXLOOP: DEC IXH ; Update counter and see if done
|
||||
JR Z, IDXFOUND
|
||||
|
||||
INC DE ; Get next character in key string
|
||||
LD A, (DE)
|
||||
CPI ; See if it matches next char in master
|
||||
JR Z, IDXLOOP
|
||||
JP PO, IDXNF ; Abort if we ran out of characters
|
||||
|
||||
POP DE ; If a mismatch, restart from the beginning
|
||||
JR IDXRST
|
||||
|
||||
IDXNF: POP DE ; Clean stack
|
||||
POP HL
|
||||
|
||||
IDXABORT: XOR A ; Report failure
|
||||
SCF
|
||||
RET
|
||||
|
||||
IDXFOUND: POP DE
|
||||
POP BC ; BC = address of master
|
||||
|
||||
XOR A ; Put size of key string in DE
|
||||
LD D, A
|
||||
LD E, IXL
|
||||
|
||||
SBC HL, DE ; Find index
|
||||
SBC HL, BC
|
||||
LD A, L
|
||||
INC A
|
||||
RET
|
||||
ENDIF
|
||||
|
||||
; IN HL Address of string to be inserted
|
||||
; DE Address of string to receive insertion
|
||||
; C Index. Start of string is 0
|
||||
; OUT
|
||||
; If successful:
|
||||
; carry Reset
|
||||
; HL Input DE
|
||||
; If unsuccessful:
|
||||
; carry Set. If new string length is > 255.
|
||||
;
|
||||
; Notes If index > string length, string is appended.
|
||||
; Data after the string is destroyed.
|
||||
|
||||
STRINSERT: IF USE_STRINSERT = 1
|
||||
LD A, (DE)
|
||||
LD B, A
|
||||
|
||||
INC A
|
||||
CP C
|
||||
JR NC, STRINSERT1
|
||||
LD C, B
|
||||
|
||||
STRINSERT1:DEC A
|
||||
ADD A, (HL)
|
||||
RET C
|
||||
LD (DE), A ; Update length
|
||||
|
||||
PUSH DE ; Make room
|
||||
PUSH HL
|
||||
LD A, (HL)
|
||||
INC C
|
||||
|
||||
LD H, 0
|
||||
LD L, C
|
||||
ADD HL, DE
|
||||
|
||||
LD D, H
|
||||
LD E, L
|
||||
PUSH AF
|
||||
ADD A, E
|
||||
LD E, A
|
||||
ADC A, D
|
||||
SUB E
|
||||
LD D, A
|
||||
POP AF
|
||||
|
||||
LD B, 0
|
||||
LD C, A
|
||||
PUSH HL
|
||||
LDIR
|
||||
|
||||
POP DE ; Copy string over
|
||||
POP HL
|
||||
LD C, (HL)
|
||||
INC HL
|
||||
LDIR
|
||||
POP HL
|
||||
RET
|
||||
ENDIF
|
||||
|
||||
; IN HL Address of string.
|
||||
; B Index of first character to delete. First character is 0.
|
||||
; C Number of characters to kill.
|
||||
; OUT
|
||||
; If successful:
|
||||
; carry Reset
|
||||
; If unsuccessful:
|
||||
; carry Set
|
||||
;
|
||||
; Notes If B > string length, then error.
|
||||
; If B + C > string length, deletion
|
||||
; stops at end of string.
|
||||
|
||||
STRDELETE: IF USE_STRDELETE = 1
|
||||
LD A, B ; See if index is too big
|
||||
CP (HL)
|
||||
CCF ; Flip for error
|
||||
RET C
|
||||
|
||||
ADD A, C ; See if too many chars on chopping block
|
||||
CP (HL)
|
||||
JR C, STRDELETE1
|
||||
|
||||
INC B ; Set index as length
|
||||
LD (HL), B
|
||||
RET
|
||||
|
||||
STRDELETE1:PUSH HL
|
||||
LD A, (HL)
|
||||
SUB C
|
||||
LD (HL), A
|
||||
INC HL
|
||||
|
||||
LD E, C
|
||||
LD C, B
|
||||
LD B, 0
|
||||
ADD HL, BC
|
||||
|
||||
SUB C
|
||||
LD C, E
|
||||
LD D, H
|
||||
LD E, L
|
||||
ADD HL, BC
|
||||
LD C, A
|
||||
LDIR
|
||||
|
||||
POP HL
|
||||
RET
|
||||
ENDIF
|
||||
|
||||
; IN HL Address of first string.
|
||||
; DE Address of second string.
|
||||
; OUT
|
||||
; If successful:
|
||||
; carry Reset
|
||||
; If unsuccessful:
|
||||
; carry Set
|
||||
;
|
||||
; Notes If new string lenght is > 255, error.
|
||||
; HL is saved.
|
||||
|
||||
CONCAT: IF USE_CONCAT = 1
|
||||
LD A, (DE) ; Combine lengths
|
||||
ADD A, (HL)
|
||||
RET C
|
||||
LD C, (HL)
|
||||
LD (HL), A
|
||||
|
||||
LD B, 0
|
||||
INC C
|
||||
PUSH HL
|
||||
ADD HL, BC
|
||||
EX DE, HL
|
||||
LD C, (HL)
|
||||
INC HL
|
||||
LDIR
|
||||
|
||||
POP HL
|
||||
RET
|
||||
ENDIF
|
||||
|
||||
; Utility: Convert character to upper case
|
||||
; On entry: A = Character in either case
|
||||
; On exit: A = Character in upper case
|
||||
; BC DE HL IX IY I AF' BC' DE' HL' preserved
|
||||
ConvertCharToUCase: IF USE_CNVUPPER = 1
|
||||
CP 'a' ;Character less than 'a'?
|
||||
RET C ;Yes, so finished
|
||||
CP 'z'+1 ;Character greater than 'z'?
|
||||
RET NC ;Yes, so finished
|
||||
SUB 'a'-'A' ;Convert case
|
||||
RET
|
||||
ENDIF
|
||||
;
|
||||
; Utility: Convert character to numberic value
|
||||
; On entry: A = ASCII character (0-9 or A-F)
|
||||
; On exit: If character is a valid hex digit:
|
||||
; A = Numberic value (0 to 15) and Z flagged
|
||||
; If character is not a valid hex digit:
|
||||
; A = 0xFF and NZ flagged
|
||||
; BC DE HL IX IY I AF' BC' DE' HL' preserved
|
||||
; Interrupts not enabled
|
||||
ConvertCharToNumber: IF USE_CNVCHRTONUM = 1
|
||||
CALL ConvertCharToUCase
|
||||
CP '0' ;Character < '0'?
|
||||
JR C,@Bad ;Yes, so no hex character
|
||||
CP '9'+1 ;Character <= '9'?
|
||||
JR C,@OK ;Yes, got hex character
|
||||
CP 'A' ;Character < 'A'
|
||||
JR C,@Bad ;Yes, so not hex character
|
||||
CP 'F'+1 ;Character <= 'F'
|
||||
JR C,@OK ;No, not hex
|
||||
; Character is not a hex digit so return
|
||||
@Bad: LD A,0FFh ;Return status: not hex character
|
||||
OR A ; A = 0xFF and NZ flagged
|
||||
RET
|
||||
; Character is a hex digit so adjust from ASCII to number
|
||||
@OK: SUB '0' ;Subtract '0'
|
||||
CP 00Ah ;Number < 10 ?
|
||||
JR C,@Finished ;Yes, so finished
|
||||
SUB 007h ;Adjust for 'A' to 'F'
|
||||
@Finished: CP A ;Return A = number (0 to 15) and Z flagged to
|
||||
RET ; indicate character is a valid hex digital
|
||||
ENDIF
|
||||
|
||||
; Utility: Is character numeric?
|
||||
; On entry: A = ASCII character
|
||||
; On exit: Carry flag set if character is numeric (0 to 9)
|
||||
; A BC DE HL IX IY I AF' BC' DE' HL' preserved
|
||||
IsCharNumeric: IF USE_ISNUMERIC = 1
|
||||
CP '0' ;Less than '0'?
|
||||
JR C,@Not2 ;Yes, so go return NOT numeric
|
||||
CP '9'+1 ;Less than or equal to '9'?
|
||||
RET C ;Yes, so numeric (C flagged)
|
||||
@Not2: OR A ;No, so NOT numeric (NC flagged)
|
||||
RET
|
||||
ENDIF
|
||||
|
||||
; Utility: Convert hexadecimal or decimal text to number
|
||||
; On entry: DE = Pointer to start of ASCII string
|
||||
; On exit: If valid number found:
|
||||
; A = 0 and Z flagged
|
||||
; HL = Number found
|
||||
; If valid number not found:
|
||||
; A != 0 and NZ flagged
|
||||
; HL = Not specified
|
||||
; DE = Not specified
|
||||
; HL = Number
|
||||
; BC DE IX IY I AF' BC' DE' HL' preserved
|
||||
; Hexadecmal numbers can be prefixed with either "$" or "0x"
|
||||
; Decimal numbers must be prefixed with "+"
|
||||
; A number without a prefix is assumed to be hexadecimal
|
||||
; Hexadecimal number without a prefix must start with "0" to "9"
|
||||
; ... this is to stop the assembler getting confused between
|
||||
; ... register names and constants which could be fixed by
|
||||
; ... re-ordering the (dis)assebmer's instruction table
|
||||
; Numbers can be terminated with ")", space, null or control code
|
||||
; Negative numbers, preceded with "-", are not supported
|
||||
; Text must be terminated with ')', space or control char.
|
||||
ConvertStringToNumber: IF USE_CNVSTRTONUM = 1
|
||||
PUSH BC
|
||||
LD HL,0 ;Build result here
|
||||
LD A,(DE) ;Get character from string
|
||||
CP '+' ;Does string start with '+' ?
|
||||
JR Z,@Decimal ;Yes, so its decimal
|
||||
CP '$' ;Does string start with '$' ?
|
||||
JR Z,@Hdecimal ;Yes, so its hexadecimal
|
||||
CP 39 ;Does string start with apostrophe?
|
||||
JR Z,@Char ;Yes, so its a character
|
||||
CP '"' ;Does string start with '"' ?
|
||||
JR Z,@Char ;Yes, so its a character
|
||||
;; CALL IsCharNumeric ;Is first character '0' to '9' ?
|
||||
;; JR NC,@Failure ;No, so invalid number
|
||||
; CALL IsCharHex ;Is first character hexadecimal ?
|
||||
; JR NC,@Failure ;No, so invalid hex character
|
||||
CP '0' ;Is first character '0' ?
|
||||
JR NZ,@HexNext ;No, so default to hexadecimal
|
||||
; JR NZ,@DecNext ;No, so default to decimal
|
||||
INC DE ;Point to next character in string
|
||||
LD A,(DE) ;Get character from string
|
||||
CALL ConvertCharToUCase
|
||||
CP 'X' ;Is second character 'x' ?
|
||||
JR NZ,@HexNext ;No, so must be default format
|
||||
; JR NZ,@DecNext ;No, so must be default format
|
||||
; Hexadecimal number...
|
||||
@Hdecimal: INC DE ;Point to next character in string
|
||||
@HexNext: LD A,(DE) ;Get character from string
|
||||
CP ')' ;Terminated with a bracket?
|
||||
JR Z,@Success ;yes, so success
|
||||
CP 32+1 ;Space or control character?
|
||||
JR C,@Success ;Yes, so successld hl
|
||||
CALL ConvertCharToNumber ;Convert character to number
|
||||
JR NZ,@Failure ;Return if failure (NZ flagged)
|
||||
INC DE ;Point to next character in string
|
||||
ADD HL,HL ;Current result = 16 * current result..
|
||||
ADD HL,HL
|
||||
ADD HL,HL
|
||||
ADD HL,HL
|
||||
OR L ;Add new number (0 to 15)..
|
||||
LD L,A
|
||||
JR @HexNext
|
||||
; Decimal number...
|
||||
@Decimal: INC DE ;Point to next character in string
|
||||
@DecNext: LD A,(DE) ;Get character from string
|
||||
CP ')' ;Terminated with a bracket?
|
||||
JR Z,@Success ;yes, so success
|
||||
CP 32+1 ;Space or control character?
|
||||
JR C,@Success ;Yes, so success
|
||||
CALL IsCharNumeric ;Is first character '0' to '9' ?
|
||||
JR NC,@Failure ;No, so invalid number
|
||||
CALL ConvertCharToNumber ;Convert character to number
|
||||
JR NZ,@Failure ;Return if failure (NZ flagged)
|
||||
INC DE ;Point to next character in string
|
||||
PUSH DE
|
||||
LD B,9 ;Current result = 10 * current result..
|
||||
LD D,H
|
||||
LD E,L
|
||||
@DecLoop: ADD HL,DE ;Add result to itself 9 times
|
||||
DJNZ @DecLoop
|
||||
POP DE
|
||||
ADD A,L ;Add new number (0 to 15)..
|
||||
LD L,A
|
||||
JR NC,@DecNext
|
||||
INC H
|
||||
JR @DecNext
|
||||
; Character...
|
||||
@Char: INC DE ;Point to next character in string
|
||||
LD A,(DE) ;Get ASCII character
|
||||
LD L,A ;Store ASCII value as result
|
||||
LD H,0
|
||||
; JR @Success
|
||||
; Return result...
|
||||
@Success: POP BC
|
||||
XOR A ;Return success with A = 0 and Z flagged
|
||||
RET
|
||||
@Failure: POP BC
|
||||
LD A,0FFh ;Return failure with A != 0
|
||||
OR A ; and NZ flagged
|
||||
RET
|
||||
ENDIF
|
||||
Reference in New Issue
Block a user