Standards for driver functions of various types of devices:
Disk Systems (#00):
#00. Identify Disk:
Determines whether the disk belongs to a given system.
Login: -
Output: A=0 - the disk belongs to the system
A<>0 - the disk does not belong to the system
#01. Set system uariables:
Setting system variables to work with this
system
Login: -
Output: -
#02. Open File: Opening a file for work (writing/reading).
Input: IX - file descriptor
Output: A=0 - file is open, A<>0 - error when opening
#03. Close File:
Closing the file, adding more data to the recorded data.
Input: IX - file descriptor
Output: A - status
#04. Create File:
Create a file with zero length.
Input: HL - pointer to file name
Output: A=0 - file created
A<>0 - file not created
#05. Read N Bytes:
Read a sequence of bytes from a file.
Input: IX - file descriptor
VS - sequence lengthHL - download address
Output: -
#0b. Write N Bytes:
Write a sequence of bytes to a file.
Input: IX - file descriptor
VS - sequence length
HL - recording address
Output: -
#07. Set Offset:
Set the position in the file.
Input: IX - file descriptor
BC - position
E - positioning method: 0 - from the beginning,
1 - addition to current
Output: A=0 - everything is OK
A=1 - no such position (file is short)
#08. Delete File:
Deletes a file (takes into account the Read Only flag).
Input: HL - file name
Output: A=0 - file deleted
A=1 - no such file
A=2 - Read-Only
#09. Set File Attributes:
Setting file attributes.
Input: HL - file name
C - attributes
Output: A=0 - everything is OK
A=1 - no such file
A=2 - attributes cannot be set
#0A. Create Directory:
Creating a subdirectory.
Input: HL - directory name
Output: A=0 - everything is OK
A=1 - no space in the directory
A=2 - directory cannot be created #0B. Delete Directory:
Deleting an empty subdirectory.
Input: HL - directory name
Output: A=0 - everything is OK
A=1 - no such directory
A=2 - it is impossible to delete the directory
#0C. Change directory:
Set the current directory.
Input: HL - directory name
Output: A=0 - everything is OK
A=1 - no such directory
A=2 - it is impossible to change directory
#0D. Get File Number:
Obtaining the file number in a directory by its name.
Input: HL - file name
Output: A=#FF - no such file, other values A -
file number #0E. Get Catalog Cell:
Obtaining information about a file by its directory number
(in file descriptor format)
Input: C - file number
HL - address where to place information
Output: -
#0F. Read N sectors:
Read a specific number of sectors.
Login: HL - download address
B - number of sectors
DE - initial block number
C - sector number in the block
Output: A=0 - everything is OK
A=1 - non-existent block
A=2 - incorrect sector number
DE - block number after reading
HL - address after reading
C - sector number in the block #10. Write N sectors:
Record a specific number of sectors.
Login: HL - download address
B - number of sectors
DE - initial block number
C - sector number in the block
Output: A - status (same as Read sectors)
DE - block number after recording
HL - address after recording
C - sector number in the block
#11. Reread FAT buffer:
Update FAT buffer.
Login: -
Output: -
Character Printing Driuers (#03):
On-screen print drivers (32/42/51/64 characters per line, etc.)
Functions: #00. Init driver:
Initializing the driver and setting it to the current text
window.
Input: A=0 - driver initialization
A=1 - restoration of the original state
Output: BC - character size in base mode pixels
Spectrum (2Sbx192). Size equal to #FF
means that along this coordinate the size
fickle (B - y, C - x)
DE - maximum X and Y coordinates available
with a text window equal to the entire screen.
#01. Print character:
Input: A - character code (#0D - CR+LF)
Output: -
#02. Set coordinates:
Setting print coordinates in the driver coordinate system
faith.Positioning is carried out in the specified text window.
Input: DE - coordinates;
Output: -
Limitations for interrupt-based drivers:
The driver should not corrupt variables such as:
UNICALL
UNICDRV
TEMPFA
That is, if you want to use them, then save them
value before the start of the function and restore at the end. If
you don't use them, but your driver uses function calls
BIOS through restarts, then be sure to save those TEMPFA bytes,
which the function uses.
Format of drivers and libraries in memory:
The driver is represented in memory as follows:
┌────────┬────────┬────── ─────────────────── ───────────────────┐
│ Offset │ Length │ Description│
├────────┼────────┼───────────── ───────────────────────────────┤
│ 0 │ 2 │ Page number of the next driver │
│ 2 │ 2 │ Address of the next driver (#FFFF - end) │
│ 4 │ 1 │ Driver flag byte (see below) │
│ 5 │ 1 │ Driver name length │
│ b │ ... │ Nm drivers │
│ ... │ ... │ Driver body │
└────────┴────────┴───────────── ───────────────────────────────┘
In memory, the drivers are arranged in a chain. At the beginning of each
driver, the address of the next driver is indicated. This is how it is achieved
ability to connect an unlimited number of drivers. If
the address of the next driver is #FFFF, then the current driver is
last in the chain.
Driver flag byte:
bit 0 - whether it is a block I/O device (no/yes)
bit 1 - whether it controls the disk system (no/yes)
bit 2 - non-resident/resident
bit 3
bit 4bit 5
bit b
bit 7 - driver activity flag (reserved for the next
versions)
The driver input is the function code in the C register.
Standard driver names:
kbd.dru - keyboard
mouse.dru - mouse
trdos.dru - TR-DOS driver
isdos.dru - IS-DOS driver (bChOk)
msdos.dru - MS-DOS driver
hdd.dru - hard drive
ramdisk.dru - RAM disk
cmos.dru - CMOS (clock, date and system settings)
Standard library names:
graph.lib - graphics library neos.lib - NeOS function library
Add driuer (ADDDRV):
Installing a new driver (resident/non-resident)
Input: HL - driver address
VS - his page
Output: -
Add library (ADDLIB):
Installing a new library
Entrance: HL - library address
VS - library page
Output: -
Remoue driuer (REMDRV):
Removing the driver
Input: HL - pointer to name (in lower memory)
Output: A=0 - deleted successfully
A=1 -driver not found
Remoue library (REMLIB):
Removing a library
Input: HL - pointer to name (in lower memory)
Output: A=0 - deleted successfully
A=1 - library not found
Open driuer (OPENDRV):
Search for driver
Input: HL - pointer to name (in lower memory)
Output: HL - driver address (#FFFF - driver not found)
BC - driver page
DE - driver header length
A - driver flags
Open libray (OPENLIB):
Library search
Input: HL - pointer to library name (in lower memory)
Output: HL - library address (#FFFF - library not found)
Sun - pagelibraries
DE - library header length
Required condition:
The first driver (any) and library should be at the bottom
memory (#0000-#BFFF)!
Disk Manager section of the kernel.
Recognize disk (DISKDET):
Change Driue (CHANDR1):
Find File (FINDFM1):
File descriptor format (FD - File Descriptor):
┌──────┬────── ┬──────────────────────────┐
│Offset│Length│ Purpose │├──────┼──────┼────── ────────────────────┤
│ 0 │ 1b │ File Nm │
├──────┼──────┼────── ────────────────────┤
│ 1b │ 4 │ File extension │
├──────┼──────┼────── ────────────────────┤
│ 20 │ 1 │ File attributes │
│ │ │ bit 7=1 - sector changed │
│ │ │ bit 7=0 - sector not me- │
│ │ │ nyalas │
├──────┼──────┼────── ────────────────────┤
│ 21 │ 2 │ File download address │
│ 23 │ 2 │ File creation time │
│ 25 │ 2 │ File creation date │
│ 27 │ 2 │ Starting block of the file │
│ 29 │ 4 │ File length │
│ 33 │ 3 │ File device name │
│ 3b │ 2 │ His initial block │
│ │ │ directories │
│ 38 │ 1 │ File number in directory │
│ 39 │ 2 │ Read buffer address │
│ 41 │ 2 │ Current file block ││ 43 │ 1 │ Current sector in the block │
│ 44 │ 4 │ Position in file │
└──────┴──────┴────── ────────────────────┘
Ntoro 48 bytes.
The Get catalog cell function returns the first 33 bytes of the descriptor.
Disk device naming standards:
- Floppy Driue. Disk drive
- Hard Driue. Winchester
- CD Driue. Sidyuk
- Ram Disk. RAM disk
Basic functions of the graphics library (graph.lib):
Note: when specifying coordinates and dimensions, the leading register
couples iscoordinate/size in Y, minor - X.
#00. Clear Screen (CLS):
Clearing the screen, setting permanent attributes and border.
Input: C - attributes
B - curb
Output: -
Variable registers: HL, BC, DE, A
#01. Clear Window (CLW):
Clearing the window image (without changing attributes)
Input: BC - coordinates of the upper left corner of the window
DE - window dimensions
Output: -
Variable registers: HL, BC, A
#02. Fill Window With Attribute (FILATR):
Filling the window with an attribute
Input: BC - coordinates of the upper left corner of the window
DE - window dimensionsH - attribute
Output: -
Variable registers: HL, BC, A
#03. Put Character Initializer (PUTSINI)
Initializing and setting up symbolic output to a new one
text box
Input: A=0 - output initialization (video mode setting)
A=1 - return to basic mode
Output: BC - character dimensions in pixels of 2Sbx192 mode. If
the size of a character along any coordinate is
not constant, then the size must be #FF
DE - limiting X and Y coordinates with a text window
full screen size
#04. Put Character (PUTCH):
Output of a single character taking into account attributes.
Works in a text window.
Input: C - character code
Output: -
Variable registers: -#05. Put String (PUTS):
Outputs a string of characters. End of line code - #FF
Works in a text window.
Input: HL - line address
Output: -
Variable registers: HL, DE, A
#0b. Messager (MESGER):
Outputs a string from the string table. Line separator - #FF
Works in a text window.
Input: HL - table address
C - line number (0 is the very first line)
Output: -
Variable registers: BC, HL, DE, A
#07. Print Byte-Number (PNUM8):
Displays a number in the range 0-255
Works in a text window.
Input: C - numberOutput: -
Variable registers: HL, DE, C, A
#08. Print Word-Number (PNUM1b):
Displays a number in the range 0-b5535
Works in a text window.
Input: HL - number
Output: -
#09. Scroll Window Up (SCRLUP):
Shift the window up to a familiar location along with attributes
Input: BC - window coordinates
DE - window dimensions
Output: -
Variable registers: HL, BC, DE, A
#0A. Scroll Window Down (SCRLDW):
Shift the window down to a familiar location along with attributes
Input: BC - window coordinates
DE - window dimensionsOutput: -
Variable registers: HL, BC, DE, A
#0B. Scroll Tech Window Up (SCREUP):
Shifts the current text window up
Login: -
Output: -
Variable registers: -
#0C. Scroll Tech Window Down (SCREDW):
Shifts the current text window down
Login: -
Output: -
#0D. Draw Styled Box (DRBOX):
Drawing a rectangular stylized frame (without attributes)
Style sheet address - STYLES system variable
Input: BC - coordinates of the upper left corner of the frame
DE - window dimensions
L - style (A=0 - ROM). Output: -
Variable registers: HL, BC, DE, A
#0E. Draw Window (WINDOW):
Drawing a window
Input: IX - pointer to window handle:
IX+0 - X (7 bits=0 - no shadow needed, =1 - shadow needed)
IX+1 - Y
IX+2 - width
IX+3 - height
IX+4 - window attribute
IX+5 - shadow attribute
IX+b - window frame style
Output: -
Variable registers: HL, BC, DE, A
Variable registers: HL, DE, C, A
Variable registers: -
#0F. Vertical Menu (VMENU):
Display and select a vertical menu item.Coordinates in a text window.
Input: IX - pointer to menu descriptor:
IX+0 - X
IX+1 - Y
IX+2 - width of the selection bar
IX+3 - number of points
IX+4 - color of the unselected item
IX+5 - color of the selected item
E - starting point number
Exit: E - item number, E=#FF - Edit pressed (exit menu)
Variable registers: HL, BC, A
#10. Put sprite (PUTSPR):
Sprite output (color/black and white).
Input: HL - start of sprite
DE - sprite dimensions
BC - sprite coordinates (7 bits C=0 - black and white sprite,
7 bit C=1 - color sprite)
Output: -
Variable registers: HL, BC, A Керналь функций BIOS:
System section:
#0057: Sysinfo
#005A: Wait for keypress
#005D: Wait for keypress + click
#00б0: Click sound
#00б3: Exit from а program
#OOбб: NMI handler
Driuers and libraries section:
#0000: Add driuer
#0000: Add library
#0000: Remoue driuer
#0000: Remoue library
#0000: Open driuer
#0000: Open library
Memory manager section:
#0000:RAMinfo
#0000: Change page
#0000: Allocate high memory block
#0000: Allocate low memory block
#0000: Free high memory block
#0000: Free low memory block
#0000: Find maximal length of high memory block
#0000: Reallocate memory мар
#0000: Get page info
#0000: Select 4MB page
#0000: Change page in low memory (#4000-#7FFF,#8000-#BFFF)
Disk manager section:
#0000:
Other functions:
#0000: RBHL
#0000: DBHL
#0000: ZBHL
#0000: ABHL
#0000: DABHL#0000: AGETCEL
#0000: AGETATR
#0000: SCRTATR
#0000: STRCMP
#0000: ReadSec
#0000: WriteSec
Memory manager section of the kernel:
RAMinfo (MEMDET):
Obtaining information about upper memory
Login: -
Output: HL - total upper memory volume (in KB)
DE - free upper memory (in KB)
BC - number of upper memory pages
Change page (CHPAG):
Change page in area #c000-#cfff
Input: A - page number
Output: A=0 - OKA=1 - no such page
Allocate high memory block (ALLOCH):
Allocation of a block of upper memory
Input: C - block volume
Output: A=0 - memory allocated
A=1 - not enough contiguous memory
HL - block address
BC - block page
Allocate low memory block (ALLOCL):
Allocating a block of lower memory
Input: DE - block size in bytes
Output: HL - starting address of the block in memory
Free high memory block (FREEH):
Freeing a block of upper memory
Input: BC - page number
D - high byte of address
E -number of kilobytes freed
Output: -
Free low memory block (FREEL):
Freeing a block of lower memory
Input: DE - amount of freed memory in bytes
Output: HL - new low memory limit address
Get maximum length of high memory block (GETMAX):
Getting the largest size of the upper memory block
Login: -
Output: A - block size in kilobytes
Reallocate memory mar (MPREALC):
Moving the memory card
Input: DE - new map position
VS - new map page
Output: -
Get page info (PAGINF): Obtaining information about the page
Login: Sun - page
Output: DE - page occupancy map
Select 4MB page (HPAGCHG):
Selecting a 4 MB page (temporarily not implemented)
Login: -
Output: -
Change page in low memory (CHPAGL):
Changing the page in the lower memory (temporarily not implemented)
Login: -
Output: -
Description of the NeOS u1.0 command interpreter:
Interpreter commands:
System commands:
VER - obtaining information about the NeOS version (_VER)
MEM - obtaining information about the memory available to the system
topic (_MEM)
CLS - clearing the screen with current attributes
CLW - clearing the text window with the current attributes
COLOR n - setting the current attributes n
BORDER n - installation of border n
PAGE n - switch to logical page n
CALL n - launch the program from address n
STACK n -setting stack to n
HEX - output of numbers in HEX
DEC - output numbers in DEC
SILENCE - mute sound AY
ROKE m n - entering an 8-bit number n into cell m
PACK m - output of the contents of cell m (1 byte)
DPOKE m n - entering a 16-bit number n into cell m
DPEEK m - output of the contents of cells m and m+1 in the form of 1b-bi-
date
TEXTWIN x y w h - setting a text window
MEMMAP - memory card output
Disk commands:
LOAD "a" [n] [m] - loading file "a" to the addressn of length m
SAVE "a" n m - writing file "a" from address n with length m
RUN "a" [param] - launching file "a" passing parameters to it
param
DRIVE n - select drive n
CD ["path"] - setting the current directory "path". Without a path
shows current directory
DIR [w] - directory output, if the w key is enabled, then
wait for any key to be pressed when reached
bottom edge of the screen
REN "a" "b" - rename file "a" to "b"
DEL "a" - delete file "a". Read-only - with confirmation
niya
MKDIR "name" - creating the "name" directory
RMDIR "name" - deleting an empty directory "name"ТУРЕ "name" - вывод файла на экран
Other functions керналя:
Go lower Ьу pixel (RBHL):
Go higher Ьу pixel(DBHL):
Go lower Ьу cell (ZBHL):
Go lower ат attributes (ABHL):
Go higher ат attributes (DABHL):
Calculate screen address (AGETCEL):
Calculate attribute address (AGETATR):
Conuert screen address to attribute (SCRTATR):
String comparison (STRCMP):
Comparison of byte sequences
Input: HL - single line address
DE - address of another line
C - number of bytes to compare
Output: Z - lines are identical
NZ - strings are different
Variable registers: B
Read Sectors (READS):
Reading a block of sectors
Input: HL - starting address
DE - initial track/sector
B - length in sectors
Output: HL - final address
DE - final track/sector
Variable registers: B, CWrite Sectors (WRITES):
Input: HL - recording address
DE - track/sector
B - length of the block to be written in sectors
Output: HL - final address
DE - final track/sector
Variable registers: B, C
Other kernal functions:
Go lower pixel (RBHL):
Go higher bу pixel(DBHL):
Go lower by cell (ZBHL):
Go lower at attributes (ABHL):
Go higher at attributes (DABHL):
Calculate screen address (AGETCEL):
Calculate attribute address (AGETATR):
Conuert screen address to attribute (SCRTATR):
String comparison (STRCMP):
Comparison of byte sequences
Input: HL - single line address
DE - address of another line
C - number of bytes to compare
Output: Z - lines are identical
NZ - strings are different
Variable registers: B
Read Sectors (READS):
Reading a block of sectors
Input: HL - starting address
DE - initial track/sector
B - length in sectors
Output: HL - final address
DE - final track/sector
Variable registers: B, C
Write Sectors (WRITES):
Input: HL - recording address
DE - track/sector
B - length of the block to be written in sectors
Output: HL - final address
DE - final track/sector
Variable registers: B, C
System section of the kernel:
Sysinfo (SYSDET):
Obtaining information about the system.Login: -
Output: A - computer code
VS - version (iV.C)
HL - ID string address
Variable registers: -
Wait for keypress (KEYWAIT):
Waiting for a key press
Login: -
Output: A - key code
Variable registers: HL
Wait for keypress + click (KEYWCLC):
Wait for key press + click on press
Login: -
Output: A - key code
Variable registers: HL
Variable registers: -
Click sound (CLICK): Short click on Beeper (depends on 1 bit FLAGS1)
Login: -
Output: -
Variable registers: -
Non-Maskable Interrupt (NMI) handler (NMI_R):
Non-maskable interrupt handler.
Login: -
Output: -
Exit from a program (EXPROG):
Exit the program, restore and enable interrupts
BIOS.
The stack is restored from STACK_P, then proceed via PROGRET
Login: -
Output: -
Variable registers: SP, HL, A
NeOS system variables
Permanent system area:
HK_ERR (2b): Error handler address
HK_OS (2b): Address of the additional OS function manager
HK_USR1 (2b): User restart address RST #28
HK_USR2 (2b): User restart address RST #30
HK_NMI (2b): NMI handler address
L_GFX (2b): Address of the current graphics library
System variables
STACK_P (2b): Stack value before calling the program
PROGRET (2b): Address of transition when exiting the program
ERR_SP (2b): Stack value in case of serious error
ERR_JP(2b): Return address for serious error
DRV_BEG (4b): Pointer to the beginning of a chain of non-resident drivers
ditch
LIB_BEG (4b): Pointer to the beginning of the library chain
RES_BEG (4b): Pointer to the beginning of the chain of resident drivers
VARLEN (1b): Length of the block of moved variables
SYSRET (1b): RET command.
F_DRV (7b): Empty driver. Adapter between ROM and RAM
F_LIB (7b): Empty library
F_RES (7b): Empty resident driver
Movable block of variables:
scratr (1b): Screen Attributes
atrf (1b): Attribute mask
scrcrd (2b): Coordinates on the screen
fontadr (2b): Address of the current font
border (1b): Border color
styles (2b): Address of styles for window frames
textwin (4b): Text window parameters
limcrd (2b): Coordinate boundaries in the text window
lastkey (1b): ASCII code of the last key pressed
repwait (1b): Delay before key auto-repeat
reprate (1b): 4actota auto-repeat
repcnt (1b): Internal counter variablelastki1 (1b): Internal flag variable
pagemp (4b): Pointer to the end of the memory card
ramtop (2b): Upper limit of lower memory
curpage (2b): Current page
ports (4b): Contents of memory management ports
driue (3b): Nm of the current device
cddadr (2b): Address of the current disk system driver
fatbuf (2b): FAT buffer address
secpt (1b): Number of sectors on the track
seclen (1b): Sector length code
cblock (2b): Current block
cbsec (1b): Current sector in the block
curdbl (2b): Starting block of the current directory
secpb (1b): Number of sectors in the block
pnt_x (2b): X-coordinate of the pointing device cursor
pnt_у (2б): Y-coordinate of the cursor
brd_l (2b): Left border of the area accessible to the pointing device
army
brd_r (2b): Right border of the area
brd_u (2b): Upper boundary of the area
brd_d (2b): Lower boundary of the area
buttons (1b): Button state:
bit 0
bit 1bit 2
sens_x (1b): X sensitivity
sens_у (1b): Y sensitivity
acc_x (1b): Acceleration in X
acc_y (1b): Y acceleration
flags1 (1b): Flag variable
bit 0: Key press (no/yes)
bit 1: Sound on beeper (yes/no)
bit 2: Character printing mode (Replace/XOR)
bit 3: Current video memory page
bit 4: LAT/RUS
bit 5: Caps Lock (no/yes)
bit b: Flag for character printing procedure
bit 7: Number output mode (DEC/HEX)
flags2 (1b): Flag variablebit 0: Disk spin-up delay (no/yes)
Credits:
========
Programming:
Megus:
- BIOS, NeOS;
- a set of drivers.
MAV:
- low-level procedures for working with the disk;
- adaptation of ZASM to the NeOS environment.
Tigrr:
- BW Disk Master u1.0
Design:
Aztec Graphics (Xtrimer).
Consultations, advice, criticism:
MAV:
- advice and consultations on the BIOS concept itself.
Denis Dmitrieu:
- tips on implementing a driver system;
- constructive criticism.
Roman Milukou:
- author of the installer idea.
Andrey Isaeu:
- tips on implementing a file system.
Tim Kelly:
- tips on implementing a driver system.
Pauel Fedin:
- author of the BIOS idea;
- constructive criticism.People who will receive the full NeOS kit for free:
Roman Milukou 2:4b1b/47.8
Denis Dmitrieu 2:4b1/110.5
Roman Milukou:
- author of the installer idea.
Andrey Isaeu:
- tips on implementing a file system.
Tim Kelly:
- tips on implementing a driver system.
Pauel Fedin:
- author of the BIOS idea;
- constructive criticism.
People who will receive the full NeOS kit for free:
Roman Milukou2:4b1b/47.8
Denis Dmitrieu 2:4b1/110.5
Andrey Isaeu 2:502b/18.42
Tim Kelly 2:4b5/157.15
Pauel Fedin 2:5020/b59.55
The first historical launch of NeOS on Merycobckom Scorp:
08/22/1998 at 11:59:23
SYSTEM SOFTWARE REVIEW
Share your thoughts about the article