The Accelerator

    The Accelerator is the internal device realised by PLD. Almost all configurations of Sprinter include the Accelerator with different sets of commands. Below we described the Accelerator for Sprinter Configuration.

    The Accelerator serves for acceleration of data blocks transfer as fast as possible (today, up to a physical speed limit of the RAM). The Accelerator supports data blocks transfer of RAM and Video-RAM. And it is not supports data blocks transfer of ROM and FastRAM.

    The Accelerator allows:

- fast filling of horizontal or vertical screen line of 1-256 pixels by one color (in 640x256 mode - one/double horizontal line of 1-512 pixels).
- fast copying of horizontal or vertical screen line of 1-256 pixels (in 640x256 mode - horizontal line of 1-512 pixels).
- use AND, OR and XOR operations with data blocks.

    The Accelerator has 256 bytes of memory that used for the data transfers. This Accelerator memory is a part of PLD internal memory. Data transfer begin when you load that data block to the Accelerator memory. Next that block is copying to the selected part of RAM. Last operation can be repeated as often as you need. It is a way for filling the screen by textures.

    Another mode is used for filling a screen by one color. The screen is filling by one byte from CPU bus.

    For control the Accelerator from a program use following CPU commands:

LD B, B - Switch the Accelerator off.

LD D, D - Switch the Accelerator in the mode of load a byte of block size.
Next command is "LD A, dat" where "dat" is a new block size.

LD C, C - Switch the Accelerator to filling by one byte mode for horizontal line.
Next command "LD (HL), A" will fill all bytes by value of A.

LD E, E - Switch the Accelerator to filling by one byte mode for vertical line.

LD H, H - Reserved.

LD L, L - Switch the Accelerator to copying a data block mode for horizontal line of the screen.
Next command "LD A, (HL)" will fill the Accelerator memory by value of (HL).
And the command "LD (DE), A" will copy the data from the Accelerator memory to RAM or to VideoRAM.

LD A, A - Switch the Accelerator to copying a data block mode for vertical line of the screen.

    The following program will copy data from the first screen to the second screen. It takes nearly two interrupts (1,2 INT).

        ; display page was opened from the #C000 already
        LD HL,#C000     ; Address of the beginning of a line of first screen 
        LD DE,#C180     ; Address of the beginning of a line of second screen 
        LD BC,#140      ; The width of the screen
        DI              ; Disable interrupt
        LD D,D          ; Switch the Accelerator to define block size mode
        LD A,0          ; Set block size to 256 bytes 
        LD A,A          ; Switch the Accelerator to copying a graphic data block mode
        LDIR            ; Copying
        LD B,B          ; Switch the Accelerator off
        EI              ; Enable interrupt
    Additional functions of the Accelerator (AND, OR, XOR) is available too.

    The following program is coding 256 bytes block.

        LD HL,ADRES_1
        LD DE,XOR_DAT
        DI
        LD D,D
        LD A,0     ; Number of bytes which must be encoded 
        LD L,L
        LD A,(DE)  ; Load data block to the Accelerator memory
        XOR (HL)   ; XOR
        LD (HL),A  ; Load result to RAM
        LD B,B
        EI

    The speed of the Accelerator is limited only by physical speed of RAM. To define an time of the command's work with the Accelerator it's possibleby next formula:

Time of work = time of work without the Accelerator + time of the Acelerator work.

Time of the Acelerator work = number of bytes / 7000000.

Note: disable interrupt during the Accelerator work!


    Examples of usage the Accelerator.

;**************************

; Interrupt - enable
; Stack, Program & Data - in (8000h..BFFFh)
; Video-RAM - in (C000h..FFFFh)
; Video-Data - (0000h..BFFFh)
;
;
Screen_offset EQU 0C000h        ; or 0C140h for second grafic screen

Video_Data EQU ***              ; 0000h..BFFFh
Color_for_fill EQU ***          ; 0..255

Horizontal_offset EQU ***       ; 0...319
Vertical_offset EQU ***         ; 0...255
Horizontal_size EQU ***         ; 1...256
Vertical_size EQU ***           ; 1...256

;**************************

Open_video_page:

        IN A,(PORT_Y)
        LD (SAVE_PY),A  ; save port_y
        IN A,(PAGE3)
        LD (SAVE_PG3),A ; save page3
        LD A,50h        ; Use   50h for normal mode
                        ;       54h for "no copy in main shadow RAM" mode
                        ;       58h for "FF is transparent" mode
                        ;       5Ch for "no copy in main shadow RAM" and
                        ;               "FF is transparent" mode
        OUT (PAGE3),A
        RET

SAVE_PG3: DB 0FFh
SAVE_PY:  DB 0C0h

;**************************

Close_video_page:

        LD A,(SAVE_PG3)
        OUT (PAGE3),A
        LD A,(SAVE_PY)
        OUT (PORT_Y),A
        RET

;**************************

Horizontal_Line_copy:

        LD HL,Video_Data
        LD DE,Screen_Offset+Horizontal_Offset
        LD A,Vertical_Offset
        OUT (PORT_Y),A          ; Set vertical offset
        DI
        LD D,D                  ; Switch the Accelerator to define block size mode
        LD A,Horizontal_size    ; Use direct data or (HL),(BC),(DE) only!
                                ; !!! not ld A,C !!!
        LD B,B                  ; Stop the Accelerator
        LD L,L                  ; Switch the Accelerator to copying a data block mode
        LD A,(HL)               ; Get data line
        LD (DE),A               ; Put data line
        LD B,B                  ; Stop the Accelerator
        EI
        RET

;**************************

Vertical_Line_copy:

        LD HL,Video_Data
        LD DE,Screen_Offset+Horizontal_Offset
        LD A,Vertical_Offset
        OUT (PORT_Y),A          ; Set vertical offset
        DI
        LD D,D                  ; Switch the Accelerator to define block size mode
        LD A,Vertical_size      ; Use direct data or (HL),(BC),(DE) only!
                                ; !!! not ld A,C !!!
        LD B,B                  ; Stop the Accelerator
        LD A,A                  ; Switch the Accelerator to copying a graphic data block mode
        LD A,(HL)               ; Get data line
        LD (DE),A               ; Put data line
        LD B,B                  ; Stop the Accelerator
        EI
        RET

;**************************

Horizontal_Line_Fill:

        LD DE,Screen_Offset+Horizontal_Offset
        LD A,Vertical_Offset
        OUT (PORT_Y),A          ; Set vertical offset
        DI
        LD D,D                  ; Switch the Accelerator to define block size mode
        LD A,Horizontal_size    ; Use direct data or (HL),(BC),(DE) only!
                                ; !!! not ld A,C !!!
        LD B,B                  ; Stop the Accelerator
        LD A,Color_for_fill
        LD C,C                  ; Switch the Accelerator to filling by one byte mode
        LD (DE),A               ; Put line of color
        LD B,B                  ; Stop the Accelerator
        EI
        RET

;**************************

Vertical_Line_Fill:

        LD DE,Screen_Offset+Horizontal_Offset
        LD A,Vertical_Offset
        OUT (PORT_Y),A          ; Set vertical offset
        DI
        LD D,D                  ; Switch the Accelerator to define block size mode
        LD A,Vertical_size      ; Use direct data or (HL),(BC),(DE) only!
                                ; !!! not ld A,C !!!
        LD B,B                  ; Stop the Accelerator
        LD A,Color_for_fill
        LD E,E                  ; Switch the Accelerator to filling by one byte mode
        LD (DE),A               ; Put line of color
        LD B,B                  ; Stop the Accelerator
        EI
        RET

;**************************

Draw_Restangle_Data:

        LD HL,Video_Data
        LD DE,Screen_Offset+Horizontal_Offset
        LD A,Vertical_Offset
        OUT (PORT_Y),A          ; Set vertical offset
        LD B,Vertical_size      ; 0 is 256
        LD C,Horizontal_Size    ; 0 is 256

        DI
        LD D,D                  ; Switch the Accelerator to define block size mode
        LD A,Horizontal_Size    ; Use direct data or (HL),(BC),(DE) only!
                                ; !!! not ld A,C !!!
        LD B,B                  ; Stop the Accelerator
        EI

drd_loop:
        DI
        LD L,L                  ; Switch the Accelerator to copying a data block mode
        LD A,(HL)               ; Get data line
        LD (DE),A               ; Put data line
        LD B,B                  ; Stop the Accelerator
        EI

        LD A,C                  ; Next line data
        AND A
        JR Z,drd_inc
        ADD A,L
        LD L,A
        JR NC,drd_no_inc
drd_inc:
        INC H
drd_no_inc:

        IN A,(PORT_Y)           ; Next line
        INC A
        OUT (PORT_Y),A

        DJNZ drd_loop           ; Loop

        RET

;**************************

Draw_Restangle_Fill:

        LD HL,Screen_Offset+Horizontal_Offset
        LD A,Vertical_Offset
        OUT (PORT_Y),A          ; Set vertical offset
        LD B,Vertical_size      ; 0 is 256

        DI
        LD D,D                  ; Switch the Accelerator to define block size mode
        LD A,Horizontal_Size    ; Use direct data or (HL),(BC),(DE) only!
                                ; !!! not ld A,C !!!
        LD B,B                  ; Stop the Accelerator
        EI

        LD C,Color_for_fill

        IN A,(PORT_Y)
drf_loop:
        DI
        LD L,L                  ; Switch the Accelerator to copying a data block mode
        LD (HL),C               ; Put data line
        LD B,B                  ; Stop the Accelerator
        EI
        INC A
        OUT (PORT_Y),A
        DJNZ drf_loop           ; Loop

        RET

;**************************
;**************************