Changes
Caruh
,/* Caruh's GUI and OS functions */
* Testing the content of address &7FFB on &7x allows integrity tests. Since the E-RAM status (high byte) is read here, the upper nibble must be '7'. If it's not equal to '7', the task E-RAM has been corrupted!
= Examples =
== Set a regular Background Task as the Foreground Task ==
If any Background Task is made the only Foreground Task, then control of the
screen and keyboard scanning is passed to that new Foreground Task.
This is done either using the Task function 'Switch <t>o' of Caruh's menu or by clicking on one of the four Task names in the task bar (at the bottom of the screen).
This process cannot be initiated by the Task itself. However, if the user wants to switch a Task to the Foreground, this Task must also be able to react to it!
== Process log: A Background Task becomes a Foreground Task ==
* Caruh reads and evaluates byte at memory location &7FF8 (TCON8) of the task:
If bit 1 is cleared, the task cannot become a Foreground Task!
If bit 1 is set, however, the task can be switched as a Foreground Task
* Caruh now sets bit 0 of memory location &7FF8 (TCON8) in the E-RAM of the Task to '1'. This tells the Task that it has now become the Foreground Task. The Task must now take control of the screen and the keyboard scanning.
* To inform Caruh that the Task has taken over screen control, the Task must set bit 0 in memory location &BE02 (CCON2). As soon as this bit is set, Caruh will relinquish screen control.
* At this point Caruh is now waiting for bit 0 to be set to '1' at address &BE02 (CCON2)! If that does not happen, Caruh will take over control again after a while (90 * DI: RST 7), as the Task appears incapable of doing so.
* As soon as bit 0 at address &BE02 (CCON2) is set to '1', Caruh waits for it to be reset in order to take control back again. See next paragraph
* The screen and keyboard are now available to the newly baked Foreground Task. Now it makes sense to first clear the screen, set the screen MODE 0-2 and possibly the screen format.
* The foreground task takes its course ...
* It's essential to test for 'ESCape' being pressed and to give control back to Caruh when the user's using the 'ESCape' key.
How does it work?
Continue reading please ... ;-)
== How can a Foreground Task return control to Caruh? ==
When a Task has taken control of the screen and keyboard, it must also test whether the ESC key is pressed. If this is the case, control must be returned to Caruh.
The same applies if the Task simply wants to give back control.
* The Task deletes bit 0 at address &7FF8 (TCON8) in its own E-RAM. This turns the Task into a Background Task (regular state). But the Task also has to tell Caruh! This is how it happens ...
* The Foreground Task also deletes bit 0 at address &BE02 (CCON2)!
* As soon as bit 0 at address &BE02 (CCON2) is cleared, Caruh takes control of the screen and keyboard (as before). The former Foreground Task is now working in the Background again.
* Caruh is in the Foreground again :-)
Note: If the newly appointed Foreground Task is not able to set bit 0 of memory address &BE02 (CCON2) to 1, the Foreground status will be withdrawn after 192 cycles (192 times 'DI: RST 7')!
That means nothing else than that Caruh will take control again.
== Reserve parts of the common screen ==
It's possible for each task to use certain parts of the general screen.
The position and extent of the claimed area are transferred. This request can be approved or rejected, depending on whether the claimed area is available.
This way it's possible for each task to always reserve the same sections for itself, since it can remember the coordinates of the first-time selection.
Either by saving the Task, using nvRAM or a configuration file.
The screen is divided into 80 columns (0-79) and 25 lines (0-24).
The table begins with the leftmost character on the top line.
When the Caruh system is started, Caruh reserves the first four lines (0-3) and
the bottom line (24).
This is how a Task can reserve a part of the general screen:
Entry (from the Task) at address &0003
Parameter:
The number of the reserving Task is stored in TTNS3 = address &BE03
The number of MODE 2 columns is transferred in register YL
The number of lines is transferred in register YH
The command 'LD IY, &0309' would therefore display 3 rows and 9 columns
* The current table is now graphically displayed on the screen. Only every 'empty' position can be assigned. A box - consisting of lines - can now be moved using the cursor keys and pressing Copy reserves the corresponding area of the screen and enters the position in the multi-screen Table.
* If the frame can't be set at the current position, the BORDER is shown in orange color (15). Either a valid area is found or the process can be canceled using the 'ESC' key.
* The Task is finally informed whether the setting of the frame was successful.
Furthermore, X (0-79 in XL) and Y (4-23 in XH) coordinates are transferred. These correspond to the left (XL) and upper (XH) corner on the screen. Register IX contains these two values.
In addition, the corresponding screen address of the top left corner is transferred (in RAM variable C_POS).