Think #46
04 августа 2000

Review System novelties - Some remarks poprogrammirovaniyu under MythOS.

<b>Review System novelties</b> - Some remarks poprogrammirovaniyu under MythOS.
         Overview System novelties



         Some observations on the

       Programming for MythOS

This section presents some of the chapters
from the project MythOS programming guide:)

- File System

- System interactions with block

  devices

- System Interrupt

- System Functions

-----------------------------------------

  Each interrupt processing program
interrupt performs these actions: - compute the new coordinates 
of the cursor according to the location of the mouse (or press 
cursor keys) and entered into the system variables. - Pressing 
the Clavey mouse (as well as relevant Clavey on your keyboard) 
noted in the system variable. - Of system variable sets the 
color curb. - Looks at the table of interrupt handlers, 
korektiruetsya counts interrupts. Performed handlers. Handler 
can be configured to the desired frequency of executions, 
specifying the number of interrupts to be missed

before executing the handler. Handler
can be set using the procedure 70,
that the output will give the number of the handler. To remove 
the handler by its number You must use 71.


-----------------------------------------

         Interaction system

        block devices


         (Zero DOS)


  Interactions with block devices
through system drivers
that will use not only standard CDs at 720 KB. but also the 
RAM-disk, and even the hard drive. The size of each block is 
strictly is fixed at 256 bytes, but

sector size is determined by the driver and can be anything.

  Appeal to any block device
going through the entry point 10, before
call should be placed in the register "A" code
character of the physical disk to which
being accessed and the register "B" Room need driver functions. 
Physical disk are denoted by the symbol A.. Z


  Table block device drivers located in the page (BlkDrvP) at
(BlkDrvA). Under each of the 26 possible
Block Device (A to Z) in table
reserved 4 bytes. The first byte indicates whether the driver 
is installed, this device (0 = not set), the remaining 3

byte is the address of the driver.


  Appeal to the block device is as follows:

LD B, 5; number of driver functions
LD A, "A"; the name of the block device

; In the remaining registers can be transmitted
 parameters for the driver

CALL CallDos

DB 10; Call Manager Block Device

Block device driver must perform the following mandatory 
functions: 

# 01 - Initializing a block device.
# 05 - Read to the bottom of the memory blocks

      device.

In: C = number of blocks (1 .. 64);

DE = number of first block;

HL = address of the boot;

# 06 - Record of blocks from the bottom of memory.

In: C = number of blocks (1 .. 64);

DE = number of first block on the disk;

HL = address of data in low memory;

-----------------------------------------

             File System


           (The first level DOS)


  Interaction with the block device
through file system driver, which in turn uses
block device drivers. For each logical device can set a
file system driver that allows you to work with both TR-DOS, 
and with ISDOS, MS-DOS disks. Logical unit can be attributed to 
any individual or logical block device. Treatment

to the file system is through the point
entry 9 with the preliminary placement of a "B"
Rooms required function, and in "A" name
logical drive (A.. Z), which
being accessed. In all other
Registers the driver may be transferred
parameters.

  Table file system driver is located just behind the driver 
table block devices, ie offset 26 * 4

bytes. In this table for each logical
device is given by 8 bytes. In the first
byte is the character code unit, with
this is associated logical device
and if this byte is equal to zero, then this
logical device is free and can be
associate with any other device
zanesya in the first byte of the character code unit, three 
bytes - address of the driver file system. And if the character 
"A" .. "Z" then linked with physical device, and

If "a" .. "z", then the logical device. The next three bytes - 
this is the address buffer of the current path for the logical 
device. The last byte in the table until reserved. Thus, this 
table will take 26 * 8 bytes. If the logical drive

associated with another logical drive, the system picks the 
current path of the disc to the top string passed as a parameter

file system driver, and calls to
another logical disk with the same parameters.

  Block device drivers and file
the system can connect from the library
However, to avoid removing them from memory
to counter the use of libraries to install one more.


  Appeal to the device file is as follows:

LD B, 1; room driver functions
LD A, "A"; logical device name, the remaining registers can be 
transmitted to the settings for the driver 

CALL CallDos

DB 9; call manager device file.


  File system driver must perform the following functions:

# 00 - create the address (CHL) list of file descriptors in the 
current directory. 


  Sign of the end of the list serves as a byte # 00 in
the first byte of the file name. Created by this
feature list has the following format:

+0 [Nb] - file name

+ N [1b] - the "."

+ N +1 [3b] - file extension

+ N +4 [1b] - # 00 + N +5 [1b] - file attribute

+ N +6 [4b] - the length of the file in bytes


  To avoid a buffer overflow is desirable to provide sufficient 
space for file list. If, for any function

required to specify the name / path, then it must be placed in 
the buffer driver file system, in the form of ASCIIZ-string. 
Between registers of letters made the difference. instead of 
"\" character is permissible to use "/". 

# 01 - File Download up to 64 blocks in length
upper memory area. In

In: the name of the buffer.

DE = Offset from the beginning of the file in blocks.
HY = number of load blocks, if
= 0, then loaded the entire file (but not more than 64
block).

LY, IX = address in upper memory, on which
need to download the file.

Out: "Z" = File not found. "NZ" = Ok.

# 02 - Give information about the file.

In: the name of the buffer.

Out: A = the file attributes (for a regular file
= 0);

BCDE = length of the file in bytes;

IXHL = number of the first block of the file on disk;

"Z" = File not found; "NZ" = Ok;

# 03 - driver initialization.

# 04 - Reserve space for file
disk

In: IImya file extension in the buffer

BC, DE = length of the file in bytes
Out:

A = 0 Ok

A = 1 The file already exists

A = 2 disk is

A = 3 127 files on disk

# 05 - Write to file up to 64 units of upper memory

In: The name and file extension in the buffer

DE = offset from the beginning of the file in blocks

HY = number of recordable units, if = 0,

   is taken from the catalog.

LY, IX = Address of data to be written.

Out:

NZ = all recorded.

Z = File not found. (Before writing to
to reserve a place in the file! By default, the file is 
overwritten.) 

# 06 - Rename File

In: buffer the old file name

(CHL) = pointer to ASCIIZ string, a new
filename

# 07 - Delete the file.

IN: name and file extension in a buffer


-----------------------------------------
            Kernel functions MythOS

          (Description is not complete)


       currently 90 functions.

Windows system

OpenWin (15) Open the window, a pointer to
descriptor in AIX

CloseTopWindow (17) Close the top window.

GetLastWinInStack (1953), EnableWinFocus (54)
EnablePassiveFocus (55)
RePaintTopWindow (1959), ReCreateWindow (68)
CloseWindow (1976), RePaintVisible (82)
ReSolveWinStack (1986), MinimizeWindow (89)
RestoreWindow (90).

Conclusion of the window, work with the window.

OutText (19) Output text at at (AHL)
the window handle to the sprite is passed in registers LY, IX. 
Important! Indicate should it handle the sprite, not the handle 
the window! 

OutChar (27) character output from the battery
the window, the address of the descriptor in which the sprite
LY, IX

SetOutPos (41) Set the position of O
window is set to C = X (pixels), B = Y (familiarity). 
Descriptor sprite window LY, IX. 

GetCursorPos (1948), ChkClickOnObject (49)
OutSprite (88).

Service Event

SendWinMessage (20) Submit an event ID in the register A with 
the parameter in register In all of the window object, the 
address of the descriptor is in the registers LY, IX. 
SendMessage (22) Submit an event ID in register A with a 
parameter in a register in all windows and objects.


SetIntHandler (1970), ResIntHandler (71)
SetGlobalHandler (1977), ResGlobalHandler (78)
SendGMessage (79).

Working with memory

ReadMem (23) Reading from memory at CHL
byte into the accumulator.

WriteMem (24) Storing at CHL
bytes from the battery.

MemAlloc (28) Select a single page in
contiguous blocks of memory, marking them
number A. The output ZeroFlag = 0, A = Page, H = high byte of 
the address, where it begins allocated memory, if memory 
allocated, and ZeroFlag = 1, if the memory was not allocated.


CaptureBuffer (36) to seize additional
buffer. After this call the system
ceases to use the main screen,
Located in a page # 05, # 4000 providing his program.

FreeBuffer (37) Release the buffer, as requested by the 
previous function. 

FindMemory (39) Find the first group of free memory blocks and 
returned to the register A their number or # 00 if no memory.

By a group of free blocks is understood
continuous region of memory in a single page.

CopyBlock (40) transfer of small arrays
memory between the pages. source address
indicated in the AHL, the receiver BDE, the number of bytes to 
send to C. 

RecodeMemTable (1916), CopyOPBlock (35)
CopyPBlock (1938), FreeLBlock (45)
FreeMemory (1946), TuneLibPointer (47)
GetPageMap (1960), ReadMapStatus (61)
WriteMapStatus (1962), GetMemoryNum (65)
FreeMemoryNum (1966), GetTotalPages (67).

 Architecture and construction principles MythOS

- General principles of

- Memory Allocation

- Outline applications

- Libraries
-----------------------------------------
Type of system - psevdomnogozadachnaya (cooperative 
multitasking), with a monolithic kernel is extended by 
connecting external object libraries and procedures.

 For communication between applications using
mechanism of events and common areas of memory.
 Planned to implement a preemptive multitasking, planning for 
the predictable amount of CPU time on a single task.


-----------------------------------------
 Available system memory is divided into segments of 256 bytes 
and in this form distributed by an application.

Total permitted up to 254 applications, so
as an element of distribution table is
dimension of 1 byte, code # FF is reserved for system 
processes, code # 00 indicates a free block. When you run each 
application is allocated a unique number in the table memory. 
If you want to use the data in more than one application, it is 
desirable to query the system for a single block identifier and 
use it as a random failure a single application all of the 
allocated memory block, marked with its code will be released, 
which could lead to interesting effects. 


To date, the kernel memory map looks like this:

# 6000 - # 8500 Lower part of the nucleus. Provides memory 
management and some system programs. 

# C000, Page # 04 Manager kernel functions,
GUI objects.

# C000, Page # 06 What does not fit into page # 04:)

-----------------------------------------



  Each application MythOS may use the top one-page table memory
continuous part of their code. If you need more memory for the 
code - it should be allocated to the library and load Library 
Manager, and the library can be split among all active

system applications.

  All code and all application data is stored in upper memory, 
which imposes some restrictions on the program, and slightly 
inconvenient to use:) Attachment should be compiled only by 
address # C000, and therefore the system with 128K memory

be able to run three applications - the number of free pages. 
From lack of, damages caused to the fixation location in the

memory, free libraries - they
configured to address allocation at startup. To use the 
mechanism of libraries, the application must be compiled into 
executable file format console and properly take into account 
the rules of uploading and release libraries, in order to avoid

linings.

  The principle of building applications - you
open a window, declaring objects
interface and the corresponding procedures
handling of user interaction -
everything else the system is doing.
-----------------------------------------
  Library MythOS are
fully autonomous system components,
who may share between multiple applications. If an application 
requests access to the library or it is loaded with

disk or the counter of its use, if the library is already in 
memory. After the liberation of the library counter decreases 
and if it becomes zero - the library is removed from memory.

Note: For console applications, which also use the tuner 
libraries, you must remember that after working the function 
call # 02 Library Manager console removes the library, so if 
your console application opens any window or reserve for 
themselves system resources, you must release them or to exit 
the # 02 program, or forced to leave the library memory by 
re-opening itself. 

Feature of libraries - they
always loaded into memory for the identifier of the block # FF 
(system) so you must always call the release of the library at 
the end of the program, otherwise the memory will stay busy. 
Another nuance - when using the library

GUI system open windows
close to the corresponding x 70 mm
0.6 kg. Scope of supply: BP, ilozheniyah,
as will inevitably arise glitches memory allocation.
; Example 01

; Analysis of "bones" to write simple, our application under 
MythOS, which the mind, exists only to open the window. (And 
what you ; Want from an application in which only

, 15 bytes of code).
; After compiling, you must install
; Extension "exe"

; Here are some useful constants.
; Recommended their placement at the beginning of any, for any 
application. (I promise not to change to yes; lneyshem their 
values) 

STACK equ # 5FFF
Ker equ # 5B00
OPg equ 4
OAd equ # C000
Temp equ # 6000
ZadN equ Temp +3; number of the current problem
Border equ Temp +6; current color border
PageN equ Temp +8; Current page
CallFn equ Ker +6
CallDos equ Ker +9
CallPg equ Ker +12
Return equ Ker +15
Ret equ Ker +18
ReturnF equ Ker +21; Exit without redrawing
Zero equ 0
Page equ # 5B21

; Application is always loaded at
; # C000 and runs with it though.

        org # c000


        jp Start

        db "Coded by Stels / Myth corp.", 0
; ASCIIZ-string with the name of the application.
;----------------------------------------; Actually the 
application itself Start


      ; In AIX put the address of the main description
       satel window

        ld a, (PageN)

        ld ix, MainWnd
, Open the window

        call CallFn

        db 15; OpenWindow (AIX)
, Return to the system

        jp Return

, This procedure will be called before the closed and tiem 
application click "Close" 

AppClose

         ret
;----------------------------------------; Main window handle 
(not to be confused with the description ; satellite sprite). 
All addresses in the descriptor ; Three-byte. The first byte - 
this page. ; If the first byte is equal to # FF, then

, Then as the page number is taken
; The current page.
MainWnd

        db 1,1; +0 X, Y box on the screen (in

   ; Familiarity) changes when you move
   The windows on the user's screen.


        db 16,10; +2 Len, Hgt window values
                  ; COMEST

        db 0; 4 offset, under which
 ; In the window stack is a reference to this
 ; Descriptor. (Set by the system)


        db # ff: dw MainWndSpr
 ; 5 Address Descriptor sprite

        db # ff: dw MainWndObjects
 ; 8 Address object table

        db # ff: dw MainWndLight
 ; 11 Address Table Light

        db # ff: dw MainWndText
 ; 14 Address text window decoration

        db # ff: dw MainWndHotKey
 ; 17 address table hot Clavey

        db # ff
 , 20 (set by the system)

; DESCRIPTORS Sprite
; (For compatibility with future versions, MI must be located 
directly behind opisate; field box) ; Sprite itself has the 
following structure: , Initially located the data bits, 
whether; linearly along the length of the sprite, the first 
row; ka, the second line, etc. then located; gayutsya 
attributes familiarity, but this And you can forget, if you do 
not work is under way with ; Sprite directly.

MainWndSpr

        db 0,0
; +21 Len, Hgt sprite
; (Set by the system)

        dw 0
, Page 23, and byte offset
; Sprite (set by the system)

        db # 41
; 25 status byte window
; Bit 0 = 0 print on the borders of the windows allowed
= 1 stamp on the borders of windows is prohibited
, Bit 1 = 0, the current system of counting DEC
= 1 HEX system
; Bit 2,3,4 = 0 (reserved)
; Bit 5 = 0 normal printing characters
= 1 align on familiarity
, (One of familiarity - one character)
, Bit 6 = 0 inversion when printing off
= 1 inversion when printing is enabled
, Bit 7 = 0 (reserved)


        dw 0
; 26 offset from the beginning of the sprite to the beginning
; Attributes sprite.
, (To calculate each time)
; (Set by the system)

        db 0
, 28 length of the sprite in the blocks
; (Set by the system)

        db # ff
; 29 Number problem (this number is marked
; Memory occupied by a sprite)
; (Set by the system)


        db # 38
; 30 Current attributes
, (Which is printed)


        db 0,0
; +31 (X, Y) coordinates of the cursor in the print window
; Relatively verhn.levogo corner of the window
; Print position for the withdrawal procedures
; Y is measured in familiarity,
; X in pixels.


        db # ff
; 33 Number window
; (Set by the system)


        db 0
; 34 Logical number of the current font ne; chati
; # 00 - print 6x8
; # 08 - print 4x8


        db 0
; 35 window style
; Bit 0 = 0 window frame
= 1 window without frame
, Bit 1 = 0, display a window in the normal pos.
; A display window always on top of the other, elastic windows
, Bit 2 = 0 window is maximized
= 1 the window is minimized
; Bits 3,4,5,6,7 = 0 (reserved)


        db 0
; 36 Here begins the table zones window
; 0 zone number (1 .. 254), if 0 then the co; Finally the table
, An X coordinate of the zone relative to vertical; hnego left 
corner of familiarity , 2 Y coordinate

; Three length zone in familiarity (1 .. 32)
; Four height zones in familiarity (1 .. 24)
, With input / output pointer in such a zone system, the system 
throws a local event with the numbers; rum 3 / 4 as a parameter 
is passed ; Room area.

; But in this case, we do not need the zone.
;----------------------------------------
; Tamblitsa objects.
They are all treated with local events
MainWndObjects
; Object button Close "


        db 7, OPg

        dw OAd +27

        db # ff
; Three-byte address of the procedure,


        dw AppClose
; That must be completed before the closed and closing the 
window. 


        db 0
; End table objects
;----------------------------------------; Table Light
MainWndLight


        db # 78
; Attributes illumination (0 - end of table)

        db 16-1,0
; (X, Y) coordinates of the rectangle of light

        db 1,1
; (Len, Hgt) dimensions of the rectangle illuminated; ki


        db 0
, End Tables Light
;----------------------------------------; Text processing 
window ; The following is a string control codes

; Print that will be printed in the TCI; rytii window

MainWndText

        db 8, # 41, 9,0, 7,8,0, 10,

           "Test Window", 8,1

        db 13,13, "any text", 13

        db 9,8, "0123456789"

        db 0
; End of line

; On the table is decorated with graphics; of the window

        db 3
; Print the symbol of the system font

        db 16-1,0
; (X, Y) coordinates of the location

        db # 11
; Code of the desired character


        db 0
; End of the table
;----------------------------------------; Table shortcuts

MainWndHotKey

        db "c"
; Hot key or 0

        db 16-1,0
; (X, Y) where the produce-clicking the left button
; Mouse when you press this button.
; In other words, clicking on this button
, Is equivalent to clicking the left mouse button
; This familiarity window.


        db 0
; End of the table

;----------------------------------------
; For the first application probably sufficient, but


   MM MM Y Y TTTTT H H OOOO SSSS

   M M M YYY T HHHH --- O O Sss

   M M Y T H H O O S

   M M Y T H H OOOO SSSS

                        , 12.07.2000

                        ; Stels / Myth corp.






Other articles:

From the Author - Summer is almost flying ...

Review System novelties - Some remarks poprogrammirovaniyu under MythOS.

Humor - Humor.

WANTED - Searching software ...

Advertising - Advertisements and announcements ...


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Advertising - rekalama and announcements of carpets and more.
Advertising - advertising and announcements.
Music Page - the song "All will pass" - Civil Defence.
Humor - a compilation of anecdotes.

В этот день...   21 November