sexta-feira, 28 de fevereiro de 2014

Exemplos de usos de cp8vid

Na postagem passada apresentei a rotina cp8vid e um exemplo de seu uso, em que uma tela surgia no sentido de cima para baixo. Pode-se fazer algo semelhante com essa rotina, imprimindo a tela coluna por coluna, de esquerda para a direita. 


O programa assembly que faz isso é:
;
;-------------------------------------------------------------------------------
; cps_wip90 (copy screen wipe 90 deg)
; Wipe screen with vertical (90 degrees) line. 
;-------------------------------------------------------------------------------
;
cps_wip90
    LD C,0              ; Column 0.
cps_wip90.l0
    HALT                ; Delay before copying one column.
    LD B,0              ; Line 0.
cps_wip90.l1
    CALL cp8vid         ; Copy 8 bytes to video RAM.
    INC B               ; Increment to next line.
    LD A,24             ; Repeat until all 24 lines were copied.
    CP B
    JR NZ,cps_wip90.l1
    INC C               ; Increment to next column.
    BIT 5,C             ; Bit 5 is high if last column was transferred.
    JR Z,cps_wip90.l0     ; Repeat until 32 columns were transferred.
    RET                 ; End of routine.

Um outro efeito possível é apresentar a tela em formato diagonal.


Pode ser feito com o programa:
;
;-------------------------------------------------------------------------------
; cps_wip45 (copy screen wipe 45 deg)
; Wipe screen with 45 degree angle line.
;-------------------------------------------------------------------------------
;
cps_wip45
; Print first half (upper left) triangular area.
    LD C,0
cps_wip45.l0
    HALT                ; Delay before copying one slanted column.
    LD B,0
    PUSH BC
cps_wip45.l1
    CALL cp8vid         ; Copy 8 bytes at given coordinates.
    INC B
    LD A,B
    CP 24
    JR Z,cps_wip45.s0
    DEC C
    LD A,C
    INC A
    JR NZ,cps_wip45.l1
cps_wip45.s0
    POP BC
    INC C               ; Increment to next column.
    BIT 5,C             ; Bit 5 is high if last column was transferred.
    JR Z,cps_wip45.l0    ; Repeat until column 31 was transferred.
; Print second half (upper left) of triangular area.
    INC B               ; B=1.
cps_wip45.l2
    HALT                ; Delay before copying one slanted column.
    LD C,31
    PUSH BC
cps_wip45.l3
    CALL cp8vid         ; Copy 8 bytes at given coordinates.
    DEC C
    INC B
    LD A,B
    CP 24
    JR NZ,cps_wip45.l3
    POP BC
    INC B               ; Increment to next line.
    LD A,24             ; Repeat until all 24 lines are copied.
    CP B
    JR NZ,cps_wip45.l2
    RET                 ; End of routine.

O efeito seguinte é o surgimento da tela em formato de tiras que correm horizontalmente, alternando a direção.


A listagem assembly correspondente é:
;
;-------------------------------------------------------------------------------
; cps_hs (copy screen in horizontal strips)
;-------------------------------------------------------------------------------
; Screen is copied in alternating horizontal strips. Even lines are copied from
;left to right, odd lines are copied from right to left.
;
cps_hs
    LD C,0              ; Columns 0.
cps_hs.l0
    HALT                ; Delay before copying pair of lines.
    LD B,0              ; Line 0.
    LD A,12             ; Counter for 12 pair of lines.
cps_hs.l1
    PUSH AF             ; Save counter.
    CALL cp8vid         ; Copy 8 bytes at given coordinates.
    INC B               ; Increment line number (odd line).
    PUSH BC             ; Save coordinates.
    LD A,31             ; Calculate odd line column number; in these lines,
    SUB C               ;columns must raise from right to left.
    LD C,A
    CALL cp8vid         ; Copy 8 bytes at given coordinates.
    POP BC              ; Recover coordinates.
    INC B               ; Increment line number.
    POP AF              ; Recover counter.
    DEC A               ; Repeat until all 12 even and 12 odd lines are
    JR NZ,cps_hs.l1     ;copied.
    INC C               ; Increment column number. 
    BIT 5,C             ; Bit 5 is high if last column was transferred.
    JR Z,cps_hs.l0      ; Repeat until 32 columns are transferred.
    RET                 ; End of routine

O último efeito é parecido com o acima, mas no sentido vertical. A figura ilustrando o efeito e a respectiva listagem seguem abaixo.

;
;-------------------------------------------------------------------------------
; cps_vs (copy screen in vertical strips)
;-------------------------------------------------------------------------------
; Screen is copied in alternating vertical strips. Even columns are copied from
;top to bottom, odd columns are copied from bottom to top.
;
cps_vs
    LD B,0              ; Line 0.
cps_vs.l0
    HALT                ; Delay before copying pair of lines.
    LD C,0              ; Column 0.
    LD A,16             ; Counter for 16 pair of lines.
cps_vs.l1
    PUSH AF             ; Save counter.
    CALL cp8vid         ; Copy 8 bytes at given coordinates.
    INC C               ; Increment column number.
    PUSH BC             ; Save coordinates.
    LD A,23             ; Calculate odd column line number; in these
    SUB B               ;columns, line number raises from bottom to top.
    LD B,A
    CALL cp8vid         ; Copy 8 bytes at given coordinates.
    POP BC              ; Recover coordinates.
    INC C               ; Increment column number.
    POP AF              ; Recover counter.
    DEC A               ; Repeat until all pair of lines were copied.
    JR NZ,cps_vs.l1
    INC B               ; Increment line number.
    LD A,24             ; Repeat until all lines were copied.
    CP B
    JR NZ,cps_vs.l0
    RET                 ; End of routine.

Nenhum comentário:

Postar um comentário

Seu comentário é bem vindo, mas peço que use este espaço adequadamente.