Systems - iS-DOS/TASiS: Working with the palette and switching graphics modes in TASiS (part 3).

Info Guide #11
iS-DOS/TASiS part 3
 Working with the palette and switching
       graphics modes in TASiS

   The previous section contains examples
universal for all types of iS-DOS. This one
and the next sections will be devoted to additional
native capabilities of TASiS. Yes, in the system─
I support working with graphic modes─
mother and palette at the level of system rest─
mouths, and we don't have to access ports,
to switch it all up.
   All procedures for working with additional
TASiS system calls can be issued
in the form of subroutines with conditional jump
system type check results.
   For example:

LD A,I;checking location in TASiS by
 OR A;CP 0;interrupt vector value
CALL Z,scrpal;switch to "graphic"
                ;subroutine if we are there

   Restart$pal (register C=#79 ). Working with
palette. Input data depends on registry─
traA:
A=#00 - set the standard palette.
A=#FF - update the user's palette. On
input in the registerHLthen - address 16
      bytes (numbers from 0 to 63) of the palette
      user to install.
   A different register value A palette does not
changes, but returns:
   In the alternative registerHL'- decree─
tel to the address of the system palette, using─ 
in the shell, or rather -special block─
TASiS system variables, first 16
byte of which is the system palette. 
   In the alternative registerDE'- decree─
Tel to the standard address ("Spectrum─ 
skoy") of the palette located outside the sys block─ 
dark variables TASiS in immutable cha─ 
system (in a block of codes in RAM at address─ 
itself #0000-#ЗFFF). 
   The system palette is forcibly installed─
appears when exiting the user program
back to the shell so you can change
palette as you like, without worrying about preservation─
original research. In our case, for
game we need to do the following:

XOR A;standard palette
LD C,$pal;or LD C,#79
RST #10

   Cgraphic modes are a bit complicated─
her. Separate restart for management
no graphics. But the graphic mode (or rather
here, the value of the shadow system port
#FF77 ATM Turbo 2/2+) is registered in the mention─
volume aboveblock of special system transfers
variable TASiS by offsets:
 +54 (1 byte) - sysscr variable. Byte
system port for system needs. Namely
This byte is used to restore the screen
default mode when exiting the program
user to the shell. Standard value─
nie=#AE(%10101110). Bits 7..4 must be
always like this. Bit3 - turbo mode is enabled.
Bits2..0 - screen type. In this case here
value 6 - text console 80x25. B
current versions of TASiS this value is constant─
obviously, however, in the future, during the development
other graphic environments may be subject to change.
 +55 (1 byte) - usescr variable. Bits
2..0 system port for use in
user programs. If there is 0 here - use─
use sysscr. All using systems─
port restarts are guided by this
sign.When exiting the program, the user─
the body is forcibly dumped into the shell
to 0. Bits 7..3 are ignored (taken from
variable sysscr ). Values to select
screen types are as follows:
 #08(ignored bit 3 is set for
non-zero value) - EGA screen 320x200, 
 #02 -hardware multicolor 640x200,
 #03 -256x192 (6912),
 #06 -text console 80x25.

   Other bit combinations2..0 are also possible─
are possible and will lead to the inclusion of nonlinear,
so-called "technological" screens. In reality─
tions in the hardware of additional screen displays─
presses, you can call them through these add-ons
telny combinations.
   To change the graphics mode, you need
enter the corresponding value in the re─
variable sysscr or usescr, and then call
one of the TASiS restarts usingsis─
dark port. Re─ is suitable for our needs
start SET_PG (#7B) - dispatch configurator─
memory black. Let's call him so that I don't
Take the memory configuration:

XOR A;system recovery
          ;TASiS RAM pages
LD B,A;0 ;in area #0000
LD C,#7B;really without additional
            ;data (in system
           ;variables) nothing changes
 RST #10;only needed to change the screen

   To summarize, let's write a subroutine include─
palette and screen settings for use in
loaded toy:

scrpal
 XOR A;standard palette attribute
LD C,$pal;or LD C,#79
RST #10
 XOR A
 INC A ;A!=#00 and !=#FF
LD C,$pal;to obtain
RST #10;TASiS variable addressesin HL'
 EXX
 PUSH HL; transfer the address
 POP IX ;in IX for convenience
LD (IX+55),#03;install 6912 screen
                   ;to the usescr variable
 XOR A
 LD B,A;0
LD C,#7B;you can immediately LD BC,#007B
RST #10
 RET

   In the end, everything turns out not simply, but
very simple.

    Managing RAM pages in TASiS

   The previous sections provide exhaustive information─
useful information in order to benefit─
the reader could safely take up the assembler and
write a bootloader for your toy.Here
information beyond this is quickly covered─
go - after all, they remained away from attention
the most powerful capabilities of the TASiS OS for software─
control of the memory manager, but in fact,
page me created in this system─
nejer, which opens up the broadest prospects─
Tips for developing software applications
and building a multitasking environment. This is the topic
separate large study. In the meantime
I'll just give a brief overviewrestarts with mi─
a minimum of comments, giving the reader
the opportunity to evaluate the scale of the discovery for yourself─
emerging opportunities.

   Restartpage (#7A) will allow the user─
I (and in the future, the system) work
with all RAM pages.
   Input parameters:
B - page number
A=0 - free page,
A=#FF - occupy page.
 Output:
Sign NC - O.K.
Sign C - already occupied (HL'=address in the tab─
 face, normally located in the same position─
   part of the system kernel in RAM at the address
   #3800)
---------- 
   Otherwise at the input:
A - page number (any except 0 and #FF),
B - offset in it (block address) in bits
5..0and command in bit6:
 0=read, 1=write
   (bit7- reserve for byte modifications),
HL - from/toDE - how many bytes.
 In other words, you don’t have to re─
turn on pages, just specify a block
codes in the main memory field and country number─
prostrate and cause a restart, which itself is everything
will copy.

   Page table - 32 bytes per bit per
page (total 256 pages) - located in
is_dos.rom and can be modifiedto ne─
downloads. By default, it is occupied0.2, 
3, 5, 7, #1F, #1E, #1D,#1C,#1B pages, and
when you try to occupy them, you will receive an address in
table (#3800 so far) and signC. Last─
4 pages reserved for residency─
volume and the bottom page of the system. Work with
You can use them, but you don’t need to free them!
   In general, for the future, it is advisable to use
use at least the minimum "proto─
count" - page busy check, search
free memory page usage
her and release, if occupied. This is a pose─
wills to work correctly in the future, when─
yes the system (or programs) will occupy when
need additional pages or
for the manager to work correctly─
applications in the future multitasking
environment.
   In thisversion page availability ogre─
small RAM size of 1024 KB - 64 pages─
tsy, but when adapting the system to ZX Evolu─
tion nothing prevents you from organizing support─
ku all 4 MB of its RAM and control via
this restart with all 256 pages.
   It is clear that the latest restart will allow
write new procedures for copiers,
packers, loaders, etc. He's free─
awaits the need to control the port─
mi. And in general, with him the ideology of working with pa─
wrinkles can change radically.

   And another restart of working with pages
RAM:
 SET_PG (#7B) - page setup, restore
becoming a system page, calling from
pages. Previously mentioned in examples with
switching screen modes.
   At the entrance:
A - command
B - page or area,
HL - address (if needed).

   There are only four teams:
A=#00 - restore system page
 B: bits 7 and 6 - area (#4000, #8000).
 The 2nd or 5th are put in place as standard
   RAM page from values stored in
   previously mentioned block of system pe─
   belt TASiS. But having entered into these systems─
   newvariables have their own values, you can "on─
   mean" other pages are system.
      It is also possible to restore the system─
   dark page 0th area (ROM2=0) and
   ROM system page (ROM2=1). For
   this with the system restore command─
   many pages bits7 and 6 of register B dol─
 must be reset (system recovery─
   dark RAM) or raised (recovery
   system ROM). Now to switch
   on eXtra ROM (for example, to enter not into
   TR-DOS, and in vTR-DOS) it is enough to replace
   byte of system ROM page (#83 by
default) to#87 and call restore─
 fixing it through restart (according to the scheme given─
   given when switching screens). For
   third-party coders who don’t know the intricacies
   and hardware features of the computer,
   this option is optimal.
A=#80 - set the page in the area pa─
print #8000-#BFFF,B - page number.
A=#40 - set the page in the area pa─
print #4000-#7FFF,B - page number.
A=#FF - the most interesting thing: call the procedure─ru from the page at the address inHL, in B -
 page number. The procedure is called from
   pages and upon returnRET restored─
 there is a (!) system page.  Any
   another number in the accumulator - return
   with signC - error. When calling pro─
 the procedure from the page restart is oriented
   at the address in HL.  If there is an address error
 (#4000-#BFFF) in the battery return─
   ts0 and sign C, otherwise - code (and flag)
 user error.

   Values for installed pages
lie in the TASiS variable area in the block
from 8 bytessyspg at offset +32 and get─
via restartPAL (#79) in exactly the same way,
as well as screen variables. The structure of this
block:
 +32 (8 bytes) - syspg variables. 8 bytes
page numbers in system areas. First─
there are 4 bytes for BASIC-128 mode
(ROM2=0), then 4 bytes for BASIC-48
(ROM2=1). In each of these fours the first
byte - a copy of the value output in the page
pristineport (i.e. with all the necessary inverters─
tings), the rest are just numbers
pages. Standard (default) values
the following:
   For BASIC-128:
+32 - byte#62(RAM #1D) for #0000 -
 just a value for the port
+33 - page5for #4000 (page number)
+34 - page2for #8000 (page number)
+35 - page0for #C000 (page number)
 For BASIC-48:
+36 - byte#83(BAS-48 ROM) for #0000 -
 just a value for the port
+37 - page5for #4000 (page number)
+38 - page2for #8000 (page number)
+39 - page0for #C000 (page number)

                Conclusion

   Some final comments:

   As you can see, you can put the page and
work with its procedures and call pro─
procedures in it, without worrying about restoration
in place of the system page. About the lesson and
It’s also better not to forget about freeing up pages─
vat. Essentially, we have come to free software─
using all available memory, and that’s it
this is by staying logged in!!! And the system itself─
ma has turned into a convenient "springboard" for
loading another environment. Who knows, maybe in
in the future, some kind of WINiS will appear, to─
the second, like the first versions of Windows, will be
boot from under the system. But that comes later.
And to begin with, based on this work, not─
it would be bad to overcome yourself, your ste─
reotypes and phobias and take the first step into
programming for the System, so that
finally escape the curse of Spectrum -
TR-DOS.  For what?  - back to the beginning
articles, you ask. Yes, at least because
it's just interesting - it's still there
an unexplored area on the Spectrum where
high-quality development is possible. The same thing
development, which is at the same "amateur" level
enthusiasm and interest led to great
progress in agricultural construction - and I’m not talking about
old man CP/M and others like him. In the back
spektrumists really breathe multitasking
and graphical operating system SymbOS, written for
computers with Z80 processors. She starts─
repents on MSX2 and AmstradCPC. Quite true─
It is clear that one day there will be a version for ATM
Turbo 2/2+ - parameters of these Spect clones─
The room completely allows this. But that means
that again developments and standards will come to
Spectrum from the outside, from the outside. And not Spectrum─
ties will determine the direction of development
software environment. Which will be very disappointing
and it’s a shame, considering what a huge backlog there is in
The 90s and “zeros” were left behind by spec enthusiasts─
Trump community, in particular in the form of iS-DOS
and TASiS. I think we are all quite happy
the strength to move things forward. A
while the TASiS project remains open to
all interested coders and users.

Share your thoughts about the article