Extended screen “Profi”, what is it and how to work with it. View from 2003

This statI was written in 2003 for the newspaper “Abzats” and was published in Room 16. This is my first article on the topic of the extended computer screen “Profi”.


When I started working with CP/M, I faced the problem of the absence of any specific data on this system, and, in particular, on the extended screen. Then the situation changed for the better, but the Pro screen remained a black spot: almost everything had to be learned experimentally. Perhaps someone has encountered the same problem. I would like to share my developments with these people.

The extended screen “Profi” has a size of 512*240(h) pixels, and takes up 32Kb (16Kb of pixel information and 16Kb of color). You could say these are two independent screens with the same structure, only one stores pixel information (page 6), and the other stores color information (page 3A). Therefore, now I will focus only on processing pixel information (so to speak, a black and white screen). I think it will not be difficult to figure out the rest on your own.

The CP/M memory card is fundamentally different from the usual Spectrum one. It has no ROM, and the system occupies the upper addresses. It is very important to have a clear idea of ​​the structure of the lower 64Kb, in the future this will help to correctly organize the work of the program. You can see what the memory card looks like at Figure 1.

Where:

  • BIOS – Basic Input/Output System conventions. These conventions underlie the operation of BDOS.

  • BDOS – basic functions of the disk operating system.

  • Additional Commands Area – additional system programs can be loaded here: debugger, command language interpreters, etc.

  • Transit Programs Area – this is where the command interpreter loads application programs for execution.

  • Basic memory page – includes several code and data segments that provide entry into the BDOS and contain some system parameters.

As you can see from the picture, the screen opens between two windows in place of the second page. Any page of memory (including 6 and 3A) can be opened in each window. An important feature of CP/M is that the files being executed do not have a starting address, they are all loaded and begin to be executed immediately after the base page, from address #100. This should also be taken into account.

What is the structure of the extended screen? Vertically, it is identical to the Spectrum screen, only not 192, but 240 pixels in height. And here everything written for the standard screen is true for it.

Its main difference is horizontal. It should be noted that the screen is not presented as a single “piece”, but as if cut into two parts. This can be compared to the presence of two vertically elongated standard screens located in memory one after another and output simultaneously. The first screen starts with address #A000, the second with address #8000. Working with them separately is no different from working with a standard screen. Everything would be fine, but on the monitor they alternate in a line: a byte from the first, a byte from the second, from the first, from the second… The extended screen will be divided into columns the width of one character place. And an attempt to work with only one part will lead to the image being cut into vertical stripes. To make it clearer, I will provide maps of the extended screen by character places and by pixel lines.

The map of the extended screen by character places looks as shown in Figure 2.

The columns then continue to alternate. The pixel map of the extended screen looks like the one shown in Figure 3.

As you can see, the structure of the extended screen is not very complicated, problems arise only with horizontal transition, here the INC L command is not enough. How to implement the necessary transition? To solve this problem, let's look at the initial addresses of the two halves of the screen in binary form:

Первое знакоместо #A000 = 10100000 00000000
Второе знакоместо #8000 = 10000000 00000000
Третье знакоместо #A001 = 10100000 00000001

It is clear that to move from the first character place to the second, it is enough to turn off the 5th bit in the senior register. To move to the third character place, it is necessary not only to turn on the 5th bit, but also to execute the INC L command. Since turning on the bit will return us only to the other half of the extended screen, and to the first character place. This is where the alternation of the halves comes into play, which allows us to move to the third character place. As an example, I will give the procedure for calculating the address of the character place to the right of the current one.

RIGHT:  PUSH AF
        BIT 5,H
        JR NZ,RIGHT1
        INC L
        SET 5,H
        POP AF
        RET
RIGHT1: RES 5,H
        POP AF
        RET

At the input to it in the register pair HL is the address of the current character place, at the output in HL is the address of the character place on the right.

Now we know everything about the structure of the extended screen, but how to turn it on? After all, usually there is a second page in place of the screen. This can be done by directly accessing the ports. But in CP/M, if possible, such a solution should be avoided. Almost everything is already provided for in advance inside the system. This applies not only to the extended screen. Accessing the BIOS will allow you to avoid conflicts between different versions of CP/M and, when using peripheral devices, to work with them through drivers. Here are two small procedures for turning the screen on and off, using the BIOS in their work:

; Включение экрана
SCRON:  LD DE,1AFFH 
        CALL 0F82DH
        RET
; Выключение экрана
SCROFF: LD DE,09B8H 
        CALL 0F82DH
        RET

After switching on, the screen occupies addresses from #8000 to #C000, replacing the information located there. This should not be forgotten and not placed in this area the procedures and data needed in this case. And this, you must agree, is not very convenient, especially if the program does not use extended memory.

If necessary, you can sacrifice speed and use the capabilities of the DSPK.DRV display driver (of course, it must be loaded).

It has a wide range of commands, the use of which will allow you to work without problems not only with pixel information, but also with color. You can learn more about them in the “DSPK.DRV Display Driver User Guide”, but now I will focus on only one of its commands. Here is an excerpt from the manual:

ESC+i Draw an icon. The icon itself is described from address 80H:

ORG 80H
DB позиция, строка верхнего левого угла;
DB длина, ширина пиктограммы в знакоместах;
DW указатель на битовую карту точек;
DW указатель на битовую карту палитр.
; При вызове параметры портятся. Структура карт: знакоместа описываются последовательно 
; слева направо, строки - сверху вниз. 
; Описание одного знакоместа в битовой карте - 8 байт, по байту на строку растра, 
; аналогично и в карте палитры.
LD HL,ICON ; желтая стрелка на красном поле
LD DE,80H
LD BC,8
LDIR
.OUTCHAR ESC
.OUTCHAR «i»
ICON:
  DB 3,7 - позиция (7,3)
  DB 2,1 - размеры 1х2
  DW POINTS
  DW PALLETS
POINTS:
  DB 0,0,0,0FH,0FH,0,0,0
  DB 0,40H,60H,0F0H
  DB 0F0H,60H,40H,0
PALLETS:
  REPT 16
  DB 8*red*yellow
  ENDM

As you can see, everything is quite elementary. These examples are designed for use with the M80+ assembler, so they contain constructions specific to it.

.OUTCHAR is a macro that is defined in the DEVICE.H file.

REPT X - все что находится между этими командами 
         (в данном случае yyyyy) будет повторено X раз.
yyyyy    
ENDM

Below I will give a simplified version of .OUTCHAR, which you can use in simple programs. In large projects it is better to work with DEVICE.H and other similar files, this will save you from many problems in the future.

.OUTCHAR MACRO CHR 
    IF CHR 
    LD C,CHR 
    ENDIF 
    LD D,02 
    CALL 0FB06H 
    ENDM

It is important to remember that a macro must be declared before it can be used. You may need some standard constants in your work:

black   EQU 0
blue    EQU 1
red     EQU 2
magenta EQU 3
green   EQU 4
cyan    EQU 5
yellow  EQU 6
white   EQU 7
ESC     EQU 1BH

That's probably all I wanted to tell you. The topic is far from exhausted, but this is enough for initial independent work. If anyone is interested in it, or you have other questions about CP/M, write to: tae1980@yandex.ru

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *