Spectrum Progress #01
30 сентября 1996

Notes programmer - univkrsalnaya library for working with graphics from Vyacheslav Mednonogova - Graphic Library v1.1

<b>Notes programmer</b> - univkrsalnaya library for working with graphics from Vyacheslav Mednonogova - Graphic Library v1.1
            Graphic Library v1.1


  (C), Vyacheslav Mednonogov, 1991.1992.

  (C) a description - Vyacheslav Mednonogov, 1996.



  The growing popularity has led to the ZX Spectrum
the fact that many of those who see this
computer only as a toy, now be happy to learn it as a powerful 
tool programming. And if a year or two ago it

could only go about BASIC, but now interest
causes the assembler. It is not too complicated language
However, for some, especially novice programmers obstacle is 
the output of graphics developed in their system and application

programs.



  To help them, I offer my graphics
library, which became the core of the game "Tankodrom. She
also came into play and "Pinocchio." With some modifications, 
this library is included, as auxiliary, a game of "UFO. The 
enemy is unknown." 


  Hallmarks Graphic Library
(GrLib1.1) are small size (880 bytes)
versatility, ability to work with all the usual procedures and 
shadow screens, sprites and output attributes in all possible 
ways overlay, building points and segments. In addition, it 
included the procedure of integer multiplication and division. 


  Another important advantage is
that all procedures (except GETSIM and GETSCR) work properly 
with any input parameters, so even if you make a mistake in 
setting the coordinates of points, lines, sprites, or the size 
of primitives, through my fault your program does not fly 
(although in that case, if properly used the setup screen 
SELSCR). 


  The disadvantages is that, as
and any universal and compact Library
She has speed, insufficient for writing serious dynamic games 
(like "ELITE" or "UFO"). Yet her performance menie more than 
enough to repeat most of currently existing games.



  So, what is included in GrLib1.1:


  a) The mathematical sub-library:


    MULB2 HL * E-> DE Multiplication

    MULB L * E-> DE Flag C-overflow

    MUL HL * DE-> DE


    DIVB E/L-> E Division

    DIVB2 DE/L-> E D-residue.

                           Overflow

                           or division by zero

                           E-> D; 255 -> E



  b) Vector Graphics:


   LINE - the line between (X1 = E; Y1 = D) and (X2 = L; Y2 = H)

   PLOT - output point (X = E; Y = D)


  c) Printing of characters:


   PRINT - output drains of characters:

           A - number of

           D - initial coordinate along the vertical
             whether (in the familiarity).

           E - Horizontal

           HL-address of the beginning of the text

           BC-address table used by Sim
             oxen.


   SIMBOL - print a single character multiple times

            A - number of repetitions

            L - character code

            BC and DE - in PRINT


   STRLEN - string length to find a separator

            0 or 13

            HL - beginning of line

            Output:

            A - number of characters per line


  Example: LD HL, TEXT

            PUSH HL

            CALL STRLEN

            POP HL

            LD BC, # 3C00; character set in ROM

            LD DE, # 0502

            CALL PRINT

            RET

     TEXT DEFM "Hello, World"

            DEFB 0


  d) Work with sprites:


       for the following listed procedures

        H - Y coordinate

        L - X coordinate

        B - width of familiarity

        C - height of familiarity

       DE - address of the image in memory

 - Output sprites XY

     PUTSPR in pixels in the familiarity

     PUTSCR in pixels, in pixels

     PUTSIM in familiarity, in pixels

 - Filling in the window of bytes from the register A

    SIMBAR X and Y coordinates of familiarity

 - Save the image in the sprite memory

     DE - buffer address to save the sprite

    GETSIM X and Y coordinates of familiarity

 - Display the attributes of the sprite on the screen

    PUTATR (parameters as in PUTSIM)

 - Set recording attributes of the sprite in the buffer address

     Register DE

    GETATR (parameters as in GETSIM)

 - Fill out the window attributes of one color from

     register A

    ATRBAR (parameters as in SIMBAR)


  e) Establish a way to overlay primitives


     Call:

       LD A, <mode>

       CALL CHNGRG


     where <modename> has the following mnemonics:


   * NOP_ - Up

     OR_ - sanctioned by PRINCIPLE OR

     XOR_ - on PRINCIPLE "XOR"

   * AND_ - on PRINCIPLE AND

   * INV_ - inversion


     * - Only for PRINT, PUTSIM, PUTSPR

 - Select the screen (SELSCR)


    In all their games, I rarely form IMAGE
    reflection on the main screen: first, I build

    it in the "shadow" screen, then quickly

    forwards it to the core.

      Shadow screen - any region in the parameter
    myati length 6 KB (6,912 bytes).

      GrLib imposes restrictions, according to

    which the address of the beginning of the "shadow" screen

    must be a multiple of # 0800 (2048).


  Selecting the screen is carried out as follows:


      LD A, 
CALL SELSCR To display a normal screen, use: LD A, # 40 CALL SELSCR If you do not call SELSCR, by default, all procedure output in the main screen. If you do not call CHNGRG, the default mode OR_. The remaining procedures are complementary. GrLib 1.1 in games "Tankodrom and "Pinocchio" (in "Pinocchio" - after decompression address 64640). You are able to see how they are used in these games with a debugger, or the shadow of the monitor. Over three years of operation, I found only two facts: MULB, MULB2, MUL - not always correctly expose the carry flag, so if you want to build on their basis multiplication 04.08 byte numbers, they should be changed. PUTATR, GETATR - work only with the attributes of the main screen. Before the advent of games on the 128K it does not matter much. As workshop on programming you can try yourself to remove this shortcoming. Compile and run GrDemo and you get some idea of ​​GrLib 1.1. All the best, success in the writing game Dear Colleagues, From the Editor SP: The annex to the magazine you will find the graphics library and demonstration program. We remind you of the need to initialize Applications for free access to the files.



Other articles:

From the Editor - We invite you, dear readers, in a world of creativity to the world of the Spectrum.

From the Editor - a description of the shell magazine.

Game room - the passage of the famous game Prince of Persia.

Game room - description of a unique non-deterministic game Soldiers of the Future.

Game room - description of the game about the mafia and the FBI - The Movie.

Notes programmer - Extended opertivnost memory for ZX Spectrum.

Notes programmer - univkrsalnaya library for working with graphics from Vyacheslav Mednonogova - Graphic Library v1.1

Notes programmer - a program of Russification (Russian translation).

Notes programmer - bug monitor debugger ZS Scorpion 256.

Toolkit - We offer to meet with the new operating system Domen OS!

Toolkit - description of a new editor-font FONT EDITOR.

Toolkit - a program to work with the modem on the ZX Spectrum - Macro Modem (MMD).

piece of iron - The company "Peters presents his new development of a home computer, "Sprinter".

piece of iron - the story of creation and development firm Peters. "

piece of iron - The scheme modem for c program Macro Modem.

Contest - a better name for a new home computer for the modern user!

News - for new projects on the Spectrum: The Legend of Kirandii, Dune 2, Modem Chess, Sprtnter, Domain OS, new graphical editor for sprinters.

News - a brief report and results from Enlight'96.

Aquarius - open the last secret of the legendary game ELITE!

Forum - Dear readers - write letters!

Advertising - free advertising and announcements.


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

Similar articles:
Miscellaneous - OUR beggary. Essay on Chekhov.
Humor - Once a Register new year. Nonsense.
Schedule - rasspianie work Grodnenskiyh BBS.

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