Programming - Procedures for obtaining the values necessary for creating something on the boarder or multicolor.

Adventurer #12
     (C) Deadie / HorrorSoft / CPU


     Generally I say the following. While I kodil,
as if he were going HorrorFasTest, my
seditious thought crept into my head about
autoconfig'e for everyone there multicolor'ov
and border'nyh effects. For me so
remains a mystery why demomaker'y
such fixed effects only (mostly)
under two models of the Spectrum (Pentagon and
Scorpion). As many know, for creating something on the boarder 
or multicolor need to know the number of rows (lines) of the 
screen / tpl / and the number of cycles per line (line) / lps 
/. Naturally, based on of these values ​​and constants are 
defined for procedures to display. Here are the most

values ​​can be obtained by using protsedurki stated below. I 
note that the true value you will get only if off turbo mode. 
For a start, give procedure that determines enabled

or off turbo mode:


               ATTENTION!!

  On the authorship of the following procedures

              Do not pretend!

, Identification of the state turbo mode
; Input: -
; O: A = 0 - disabled, A = 1 - on
TURBO CALL INT_TRB

        LD A, B

        CP # 00

        JR Z, TURBOFF

        CP # 02

        JR NC, TURBON

        LD A, C

        CP # 41

        JR NC, TURBON
TURBOFF XOR A

        RET
TURBON LD A, 1

        RET
TRB_INT DI

        LD A, # C3

        LD (# BCBC), A

        LD HL, INT_TR1

        LD (# BCBD), HL

        LD A, # BA

        LD I, A

        IM 2

        LD DE, # 0000

        EI

        HALT

        LD HL, INT_TR2

        LD (# BCBD), HL
TRB_IN3 INC DE

        LD B, # 0F

        DJNZ $

        LD A, R

        JR INT_TR3
TRB_IN1 EI

        RET
TRB_IN2 POP HL

        LD C, E

        LD B, D

        IM 1

        EI

        RET


     And now the most important thing - the procedure
calculation of lps and tpl:

; Calculating count of rows of the raster
, (The lines in the screen)
; Input: -
; O: DE - lps
CLC_LPS CALL IM2SET

        LD A, # C3

        LD (# FEFE), A

        LD HL, LPS2

        LD (# FEFF), HL

        LD DE, 0

        EI

        HALT

        LD HL, LPS3

        LD (# FEFF), HL
LPS1 INC DE

        LD B, # 0F

        DJNZ $

        LD A, R

        JR LPS1
LPS2 EI

        RET
LPS3 POP HL

        CALL IM1SET

        EI

        RET


     Almost all done with Spectrum 312
or 320 lines (for example: in the company
312, at the Pentagon - 320). Extend:

; Calculating count cycles in a row ruling
, (Line screen)
; Input: -
; O: A - tpl
CLC_TPL CALL IM2SET

        LD A, # C3

        LD (# FEFE), A

        LD HL, TPL1

        LD (# FEFF), HL

        LD DE, 0

        LD HL, TPL2

        EI

        HALT
TPL1 LD (# FEFF), HL

        LD HL, TPL3

        EI

        HALT
TPL2 LD (# FEFF), HL

        NOP

        NOP

        NOP

        INC HL

        EI

        INC DE

        JP $ -1
TPL3 POP HL

        POP HL

        EX DE, HL

        ADD HL, HL

        ADD HL, HL

        ADD HL, HL

        LD A, N; N = 0 -312, N <> 0 -320 lines

        OR A; ^ here puts the number of

        LD BC, 156

        JR Z, TPL4; 156 (312) and 160 (320)

        LD BC, 160

        XOR A
TPL4 OR A

        SBC HL, BC

        INC A

        JR NC, TPL4

        CALL IM1SET

        EI

        RET

; Protsedurki install interrupt
IM2SET DI

        LD HL, # FE00

        LD A, H

        LD B, L
IM2SETL LD (HL), A

        DEC HL

        DJNZ IM2SETL

        LD (HL), A

        LD A, H

        LD I, A

        IM 2

        RET

IM1SET DI

        LD A, # 3F

        LD I, A

        IM 1

        RET



     A length INT'a in measures calculated even simpler: tpl * 
lps (only noWAIT SPEC) and all!




       lps 312 320 tpl tpl


       216 67392 69120

       220 68640 70400

       224 69888 71680

       228 71136 72960

       232 72384 74240



     Actually, for the set up
INT'a know the position with respect to the
frame, but more on that in the next episode ...


     Instead, PS: I'm not a coder, so my
speculation about the need autoconfig'a
taken as a theorem, which must still be proved. I hope that my 
guesses all the same and become an axiom, and this information

you are somehow going to help.