(C) Maxim Gannutin, 1997.
Fundamentals of programming under OS API Domain
We introduce concepts:
Object - is logically isolated part of the code
having the opportunity to receive and send messages presented
on the screen An image and declared the system. In fact, we are
talking about objects of the user interface.
Message - a logical designation process
zaklyuchaeschegosya in the call object (call, jp) with the
statement in the register A number of commands that an object
must fulfill, and the remaining parameter registers.
Object.
The site consists of three sections:
Manager - the code that checks the contents of the registration
A pa and causing corresponding
method.
Techniques - codes, correct at time of reaction to one or
otherwise the message.
Data - data to be operated on an object.
Example:
EXMPLobject
cp 1; Manager
jr z, EXMPLopen
cp 1922
jr z, EXMPLlight
cp 1923
jr z, EXMPLshadow
cp 1924
jr z, EXMPLselect
ld a, 57; message is not accepted
ret
EXMPLopen; method for communication open
...
xor a
ret
EXMPLlight; method for communicating light
...
xor a
ret
...
EXMPLdstruct; data
20 defs
Message.
20 init Initialization
21 close close
22 light cursor moved to the object
23 shadow cursor left object
24 select the user clicks an object
25 parsel object came to the premise (drag'drop):
d = type of parcel
b, c data (sm.drag 'drop)
If the premise is accepted, then the object
should return in case A = 33.
26 char message from the keyboard:
d, e, b, c (sm.prots.FKEYBOARD)
To declare an object is necessary:
1. Derive the on-screen image of the object.
2. Declare an object system:
ld e, x coordinate
ld d, y coordinate
ld c, len
ld b, hgt
ld h, class
ld l, object
ld a, 90; procedure CONSTRUCTOR
call 23403
Clear object:
1. Clear the screen
2. Remove object
ld de, coordinates
ld bc, sizes
ld a, 91: procedure DESTRUCTOR
call 23403
Procedures and functions.
Disk subsystem.
Dates:
<- Pointer to ...
root: root
name: ^ field (11 bytes) 'filenameext'
You can use the "?"
pattern: the same name
handle: the file header (32 bytes)
attrib: 11th byte header
FP: file pointer
indicates the offset from the beginning of the file,
from which is read or
written information
FM: filehandle
+0 Filenameext (11)
+11 Attrib
12 record-size (2)
+16 FP (3)
22 times
24 Date
28 file length (3)
BSIZE: files larger than 65 kilobytes
DSS is logically divided into blocks
to 65535 bytes, which are called
BSIZE.
Call: ld a, nomer_funktsii
ld hl, options
ld de, options
ld bc, the parameters
call 23403
cp 0
jr nz, error
Create a CREAT file
in: hl, name
e, attrib
out: a = 24,26
2 OPEN Open a file
Creates a filehandle (FM)
procedures for 3,4,5,6,7,8.
in: hl, name
bc, the record size (Func. GET and PUT)
out: e, number of FM
a = 29
3 CLOSE Close the file
FM is released. In the handle entered a new
meaning the file size.
in: e, FM
out: a = 29
4 READ Sequential read from a file.
FP increases the value of bc.
in: e, FM
hl, where
bc, as
out: a = 29
5 GET random reads
in: e, FM
hl.kuda
d, a record number
out: a = 29
6 WRITE A consistent record in the file
in: e, FM
hl, where
bc, as
out: a = 26,27,29
7 PUT arbitrary file write
in: e, FM
hl, where
d, a record number
out: a = 26,27,29
8 MOVEFP Change FP
in: e, FM
hl, offset
d = 0 from the beginning of the file
d = 1 from tenkuschey position
d = 2 by the end of file
d = 3, go to the next BSIZE
d = 4, return to the previous BSIZE
out; a = 23,29,36
9 FINDFIST Finds the first file name
matching a pattern
in: hl, template
out: hl, ^ handle
a = 21
10 FINDNEXT Find the next matching
File
out: hl, ^ handle
a = 21
11 LOAD File Download
in: hl, name
de, where (de = 0, the parameter is taken from
file handle)
bc, as (bc = 0, the parameter is taken from
file handle)
out: a = 21,23
SAVE 12 Recording File
in: hl, name
de, where
bc, as
out: a = 24,25,26
13 DELETE Delete a file
in: hl, name
out: a = 21,27
14 RENAME Rename a file
in: hl, oldname
de, newname
out: a = 21,27
15 MOVE Move files from the current
directory to another
in: hl, name
bc, the first cluster of the new directory
(Bc = 0 root)
out: a = 21
16 ATTRIB Attribute File
in: d = 0 Reading
d = 1 record
hl, name
e, attrib
out: a = 21
e = attrib
17 TIME Time File
in: hl, name
d = 0 / 1
b; c; e = hour, minute, second
out: a = 21
b; c; e
18 DATE File date
in: hl, name
d = 0 / 1
b; c; e = year, month, day
out: a = 21
b; c; e
19 MKDIR Create a subdirectory
in: hl, name
out: a = 24,26
20 RMDIR Delete subdirectory
in: hl, name
out: a = 21,30
21 CHDIR Change directory
in: hl, ^ string
out: a = 22
bc, the first cluster of the new current
Catalog
string: defm "subdir1subdir2"
^ "" Symbol, to start from root
otherwise, the current
defb 0
22 CHNDISK Change Disk
in: e = 0 .. 4
out: a = 1
1923 VERSION DSS DSS Version
out: de = version
24 CALL_BIOS call BIOS functions
in, out, see the manual for bios
25 DSSVARS System Variables DSS
in: e, the number of variable
d = 1 / 2
c = content
out: e, content,
26 VEKTORS Vectors DSS
in: e, the number of vector
d = 0 / 1
hl = new value
out: hl = value
27 VERIFY Validation
record file
in: see LOAD
out: a = 32
28 CACHE cache disk
in: d = 1 initializing the cache
d = 2 to disable cache
d = 3, information about the cache (table)
hl, where
table: 8 entries from defb sec, trk
defw ^ buffer
29 RAMDISK Solid State Disk
in: d = a table loading banks in DSS
hl, where
e, how many banks
d = 2, unloading tables
hl, where
d = 3 a RAMD
30 FREESPACE Free disk space
out: bc, number of kilobytes (1024 bytes)
33 MASKCREAT New Template
in: hl, ^ string
de, ^ buffer
string: defm "filename.ext"
defb "."
You can use the "?" and "*"
Error Messages
1 no willingness
2 record on a secure floppy disk
3 Press 'BREAK'
4 read / write error
5.6 Seek errors
8 mismatch and floppy drive
9 unformatted disk
21 file not found
22 the wrong way
23 impossible option
24 files with that name already exists
25 overflow root
26 out of disk space
27 files 'read only'
28 no free FM
29 unreal number FM
30 in a subdirectory files
31 non-existent function
1932 error when verify
33 is not the disk
34 unplanned event
35 in TR-DOS operation is not possible
36 BSIZE already at zero
Vectors DSS
A handler function
2 BIOS
3 Appeal to clipboard
Functions and procedures of API
Abbreviations and terms:
len length of
hgt height
char symbol
class, see "Programming"
object there is the same
method method API, in the parentheses are processed
Posts
Thus, as in most procedures, there is only
input parameters, the word "in" no Specifies the.
When there are registers d, e, b, c without
descriptions, this means: e, the x coordinate
d, y coordinate of the
c, len
b, hgt
40 PUTCHAR Output symbol
Domain OS understands all the special characters
Spectrum OS.
b = char
ix, ^ desc
desc (standard text descriptor):
defb x, y, len, hgt; 8 * 8
defb 0
defb color
defb flags
defb x, y; cursor
defb "_"; char pointer
defb x; in the size of the symbol
defb 0
Flags
0 output cursor
1 to change the attributes for each character
3 ban scrolling
4 scissors
5 O ban
6, with no touch scroll attributes
7 before finding a character to clear the position of
47 PUTIMAGE Print image
d, e, b, c
hl, ^ bitmap
bitmap: defb len, hgt
defs len * hgt * 8 pixel line
defs len * hgt; attributes
48 GETIMAGE Get a screen image
d, e, b, c
hl = buffer
1951 FONT
d = 1 transfer in the system font
e, width simvlov
hl, where
52 CPIFUNC code table
in: d = 1 Download CPI
hl, where
d = 2, information on the current CPI
out: d = 2 b = type
1 alt_a
2 alt_b (main)
3 tlw2
53 TOERRWINDO W output messages in the error window OS
hl, ^ string
56 VIRTWINDOW Managing virtual window (VW)
in: h = a VW full screen
h = 2 in all the application window
h = 3 a VW with d, e, b, c in tektsuschem VW
h = 4 to restore the previous VW (only
when h = 3)
out: if h = 3
e, d, c, b physical coordinates
a = 23 (for d, e)
59 WALLPAPER Clear the screen of the application window
d, e, b, c
h = 1 in the application
h = 2 in the field of icons
Next come the graphics routines in VW
60 VWPUTLINE Conclusion Thong
hl = ^ string
ix = ^ desc
string: defm "text"
defb 0
61 VWPUTCHAR character output
b = char
ix = ^ desc
62 VWSCROLL Scrolling
63 VWCLEAR Cleaning windows
64 VWDRAW Line
65 VWBOX
66 VWIMAGE
67 VWVALFUNCT ION
68 VWATTR
69 VWGETIMAGE Get image
d, e, b, c
hl = ^ buffer
70 SELCUR Selecting an image cursor
b = number
An arrow
2 hourglass
3 cross
4 reserved
71 PUTCUR output cursor
h = x_coord
l = y_coord
73 DELTCUR Erase cursor
74 Work with CURSOR cursor
out: d, e (8 * 8)
h, l (pix)
c, flags directions
bit
0 right
A left
2 down
3 up
4 fire
76 IMGCURSOR Download image at the current cursor
hl = ^ image
image: defb pix_1, mask_1
defb pix_2, mask_2
...
defb pix_16, mask_16
77 HANDPORT Reading direction flag
out: c, flags
h, l
80 FKEYBOARD Reading Keyboard
out: e, char
d, flags modifiers
Bit 0 1
0 lat rus
1 ovr ins
2 capslock
with the physical key code (caps)
b, flags control keys
bit
0 caps shift
A symbol shift
82 GETABLE Loading table layout
Keyboard
hl, ^ table
87 BEEP beep (to AY)
88 SERVICE Some features
in: d = 2 Output Management VWDRAW
e = 0 read current mode
e = 1 or
e = 2 xor
e = 3 and
out: e = mode
90 CONSTRUCTO R Declaring an object
d, e, b, c
hl = object
91 DESTRUCTOR Clear object
d, e, b, c
1995 SESSION Transfer control system
96 SENDMESSAG E Send a message (drag'drop)
in: hl, ^ cursor image
d, the message number
bc, peredovaemaya information
out: a = 59
100 EXECUTE Launching an application
in: d, e coordinates of the main window
application to run
hl, name
ix, ^ prefix
b = 1 download and open
b = 2 download icon
out: b, number of the application descriptor
prefix: defs 64; any information
peredovaemaya application
101 TUNEEXE address configuration
ix, ^ address table
hl, the address where the tune
Table: defb flags (# 01)
defb number of addresses
defw start address of code in which
configured address
(When compiling)
defw addr1, addr2 ...
102 TERMINATE have completed the application
in: b, application number
103 FARRUN Launching an application from the application
Work FURRUN: application, call this
function svopiruetsya holds EXECUTE,
after which control returns to the original
nomu application.
in, out: similar to EXECUTE
110 READVAR System Variables
in: b, number
d = 1 read
d = 2 record
e, content,
out: e, content,
112 SETVEKTORS vector of the system
in: d, the number of vector
e = 1 read
e = 2 to write
hl, the vector
out: hl, vector
Vector: 1 APIVEKTOR procedures api
2 KEMPORT device uprav.kursorom
3 KEYBOARD keyboard driver
4 WALLPAPER wallpaper
5 EXEC EXECUTE procedure
6 CLOSE procedure TERMINATE
120 QUERYRESID ENT request to install residenta
in: d = 1 PNT Resident
d = 2 IM2 Resident
e = 1 request for memory allocation
e = 2 request for memory allocation
at a particular address
hl, e
bc, length of residence
out: hl, the desired address
b, bank
a = 53,54
121 SETRESIDEN T Set Resident
in: ix, handle resident
de, ^ the body of a resident
b, where the bank
hl, the address where
out: b, the number of residents
a = 55
handle residents:
defb 0
defb type * 1-PNT 2-IM2
defm "resiname" * name of the resident
defw length of residence *
defw count cycles (for IM2) *
defw address access
defb Bank
defw entry point address
defb flags
* Fields that must be filled manually
122 DELRESIDEN T Remove Resident
in: b, the number of residents
d, type of residence
200 VSB_INIT strip of vertical scrolling
d, e
b, hgt
h, class
201 VSB_MOVE method (24)
in: d, e
b, Number of points
h, the total number of rows
c, the current row
l = 3 up
l = 4 down
out: c, a new current row
202 HSB_INIT strip horizontal scrolling
d, e
b, len
h, class
203 HSB_MOVE method (24)
in: d, e
b, Number of points
h, the total number of columns
c, the current column
l = 7 left
l = 8 to the right
out: c, a new column
204 LISTBOX view window
d, e, c, b
h, class
l, flags
0 button close
1 frame header
2 button home
3 VSB
HSB 4
5 Button end
6 cleaning windows
205 IBOX_INIT Windows Keystroke
e, d, c
h, class
ix, ^ buffer
l, flags
0 button Rus / Lat
2 Cleaning windows
buffer:
+0 Defs 12 standard window handle
+12 Defs 4
+16 Defs? input string
206 IBOX_WORK method (24)
e, d
ix, ^ buffer
208 AWIN_INIT Main Window
e, d, c, b
h, class
l, flags
0 max
1 min
2 Cleaning windows
209 HMNU_INIT Horizontal Menu
d, e
h, class
l = 1
ix, ^ desc
desc:
+0 Defs 12; ctandart.desk.okna
+12 Defs 2
+14 Defb n; number of points
+15 Defb x_1, len_1, x_2, len_2 ,..., x_n, len_n
+ M defm "file edit ..."
defb 0
210 HMNU_INSERT method (22,23)
ix, ^ desk
l, object
212 VMNU_INIT Vertical Menu
ix, ^ desk
h, class
l = 1
b, flags
0 Window Cleaning
desk:
+0 Defs 12; stand.desk.okna
+12 Defs 2
+14 Defb n; number of points
+15 Defb y1, y2 ,..., yn
+ M defm "load"
defb 13
defm "save"
...
defb 0
213 VMNU_INSERT method (22,23)
ix, ^ desk
l, object
218 BUTN_INIT buttons
ix, ^ desk
h, class
l = 1
c = 1 radios
c = 2 independent fixation
b, flags
0 Window Cleaning
desk:
+0 Defb flags buttons, bits
+1 Defs x; desk vert.menyu 0 1 Button
February 1 button
...
219 BUTN_PRESS method (24)
in: ix, ^ desk
out: b, flags buttons
220 BUTN_INSERT method (22,23)
ix, ^ desk
c = 1 or c = 2
l, object
222 KEY_INIT Icons
d, e
hl, object
c, number
c = 1 close
2 home
3 up
4 down
5 lift
7 left
8 right
10 end
11 rus
12 lat
13 zero
15 system
16 min
17 max
18 radio_on button
19 radio_off buttonop
20 nonfixed_on button
21 nonfixed_off button
22 "O'K"
23 "REFUSAL"
225 VWCOLORS System Colors
in: c, color number
d = 1 read
d = 2 record
e color
out: e, color
number of colors:
3 LBOX
4 IBOX
5 AWIN
6 MENU
7 DBOX
228 WINMANIPUL ATIONS Management window
in: e, d, c, b
h = 1, displacement
h = 2 the size of the horizontal
h = 3 Vertical
h = 5 h = 2 + h = 3
out: d, e or c, b
Class Library
DOMEN FOUNDATION CLASSES
const - it means that these tags programmer defines itself,
and they contain data.
uses - for working class requires a specified
class.
SYSMES application message
Processing of all system messages to the application. Some of
the messages it processes and returns control to the method
defined by the programmer.
Here's the list:
An open APP_OPEN
2 start_a APP_ASTART
10 exit APP_EXIT
11 help APP_HELP
12 maximize APP_MAXIMIZE
14 reopen APP_REOPEN
Even if the programmer does not define
tag must be present.
In cell SYSMNOMER is the message number
To work SYSMES required:
APPdstruct
defb 0
defb X_pos, Y_pos, len, hgt
defb class of objects AWIN
defb flagi1, flagi2
defb 0
flagi1 flagi2 (resizing)
0 max 0
1 min 1 horizontal
2 Vertical
const APPstart EQU ^ start appbitmap
APPlenght EQU length appbitmap
APPacess EQU ^ entry point
APPtitlename defm "Application Name"
defb 0
APPiconimage defb 3,3
defs 81; application icon
Call: ld iy, APPdstruct
call SYSMES
ret nz
ERRW Window System Error Message
ERRWopen Open a window with an error message
in: a, the error number
d, e
h, class
ERRWwork method (24,26) Message handling
MENU Menu
MENUinit initialization
insert into APP_ASTART
MENUopen draw a horizontal menu
insert into APP_OPEN
MENUwork method (22,23,24,25,26)
const MENUdstruct
; Main menu
+0 Defb x, y
+2 Defb number of points (<6), class
+4 Defb length of paragraphs
+9 Defm "file edit ..."
defb 0
; First sub-
+ N1 defb number of points, the width of the window
defw (addresses methods called
when selecting menu items.
How many points as many addresses.
Method is passed: a, message
l, the number of the selected item)
defm "open"
defb 13
defm "run"
...
defb 0
MENUbuffer defs 160
SDBOX simple dialog box
SDBOXopen
in: l, the window number
Window displays in the middle of the application window
SDBOXwork method (24,26)
SDBOXspecial
in: hl, ^ window name
b, c
a, class
const SDBOXdstruct
defb len, hgt, class
; The first window
defm "name of the first window
defb 0
defw method when you click O'K
transferred to the l number of window
And the second okno1
sdboxkeys defb flags keys
0 O'K
1 Disclaimer
BUTN selection panel installations
uses SDBOX
BUTNopen
in: l, the window number
h, buttons, bits
BUTNwork method (22,23,24)
Method is invoked, at O'K in d passed
new bits keys.
const BUTNdstruct
+0 Defb len, hgt, class
; First panel
+3 Defb type of buttons, radio buttons 1-2-independent.
defb (method at O'K)
defm "the name of window 1"
defb 0
defm "paragraph 1"
defb 13
defm "paragraph 2"
...
defb 0 Number of points <9
; Second panel
....
BUTNbuffer defs 160
DLGF window input-line
uses SDBOX
DLGFopen
in: l, the window number, as described in SDBOXdstruct
de, ^ method when clicked
Attention! In the SDBOXdstruct address can be
indicate DLGFclick, then when you click on O'K
method DLGFGclick validate
input file name and will call on the de,
otherwise ignore O'K
DLGFwork method (22,23,24)
const DLGFbuffer defs 32
Application Programming
Messages sent to the application:
1 OPEN to open the application window
2 START A starting protsendury
in: hl, ^ prefix
de, coordinates raskkrytiya window
c, number of the application descriptor
out: hl, ^ Manager application
de, ^ bitmap application
bc, the length of the application
If the application does not want
start (for example, if
is an application-resident),
then a = 100.
3 START B
out: d, e, b, c windows application
4 CLOSE Close the application window
in: e, d to display the icon
5 LIGHT application becomes active
6 SHADOW application became inactive
10 EXIT to finish execution of the application
11 HELP derive context podskzku
12 MINIMIZE minimize the application window to an icon
in: e, d to display icons
13 MAXIMIZE Expand window to maximum
Size
out: b, c
14 REOPEN redraw window
15 MOVE to move a window
out: d, e
SIZE 16 resize
out: b, c
Application structure
Manager
Classes + application objects
Application Data
Classes DFC (no point in the object to
define system messages 1-19, so
use class SYSMES)
Manager
ld iy, APPdstruct
call SYSMES; sm.opisanie DFC
ld a, h; a = class
cp 1910
jr z, CLASS1work
cp 1911
jr z, CLASS2work
...
ld a, 57; message is not accepted
ret
Classes and Objects
CLASS1work
ld a, l; a = object
cp 1
jr z, OBJ11work
cp 2
jr z, OBJ12work
...
ld a, 37
ret
OBJ11work
ld a, (SYSMNOMER); a = message
cp 1923
jr z, OBJ11shadow
cp 1924
jr z, OBJ11select
...
ret
OBJ11select
...
xor a
ret
...
...
CLASS2work
ld a, l
...
ld a, 57
ret
Data
APPdstruct
defb 0,0,32,19
64 defs
Classes DFC
* F 1: SYSMES ()
* F 1: MENU ()
...
Now add the top assembly of text
tag APPS, but at the end of APPE.
Define class methods SYSMES:
APP_OPEN
call MENUopen; Output the main menu
...
xor a
ret
APP_REOPEN
call SYSM01; perform open
... , And then additional
; Action
xor a
ret
APP_HELP; other methods do not define
APP_ASTART
APP_EXIT
ld a, 37
ret
Style of programming applications in OS DOMAIN
1 Objects and Classes
Latinskme capital.
For example: BUTN
2 Methods
Lat.zaglav. the name of the object to which the method
applies, then the name of the method.
For example: BUTNopen, BUTNwork
call BUTNopen
3 The data of the object or class
Object Name + dstruct
For example: BUTNdstruct
ld ix, BUTNdstruct
4 Tags transition in the code of the object
name of the object + two digits mark
For example: butn01, butn02
jr butn01, djnz butn02
5 routines in the code of the object
Name of the object + two digits mark
For example: BUTN10, BUTN11
call BUTN10
6 Locals
name of the object + d + figure
For example: butnd1, butnd2
ld a, (butnd1), ld (butnd2), hl
In addition, there are rules for registration
labels belonging to the classes of DFC.
7 MENU
Method names, plug-in MENUdstruct
Menu + digit serial number of the item
horizontal menu + digit numbers corresponding vertical menu.