VDP commands and screen 4

Page 3/3
1 | 2 |

By ARTRAG

Enlighted (6462)

ARTRAG's picture

06-11-2005, 18:29

Hello Manuel!

the idea has become a working source!

With Magoo we have done a small vscreen level demo
you will find it very soon on vscreen web page

vscreen.hypercu.be

In order to unveil the solution for vertical scroll here follows
the CORE part of the code that is devolved to the rendering of
the screen.

Unfortunately this time you cannot just compile & run but you need
all the vscreen initializations and support routines.
Btw everything is ready and will soon appear at vscreen.hypercu.be.

Enjoy

; VDP ports
;
vdpport0    equ 098h        ; VRAM read/write
vdpport1    equ 099h        ; VDP registers read/write
vdpport2    equ 09ah        ; Palette registers write
vdpport3    equ 09bh        ; Indirect register write


;----------------------------------
Nline   equ 24
;----------------------------------


startProgram:

        di
        scr4_init
        page1
        
        vdpw    19,Nline*8-3

.loop
        call    testdir
        call    display
        ; from here preserve hl and de

        vdpw    15,1
        wait_FH
        vdpw 15,2
        wait_hbl
        scr5
        call    plotscreen
        scr4
        page1
        vdpw 15,0

        call    testesc
        jp  nz,.loop

        ei
        jp ending


;;************************************************************
;; Test if esc key is pressed.
;; If pressed, z flag is positioned to 0
;;************************************************************
;testesc:
;        in a,(#aa)
;        and %11110000
;        add a,7
;        out (#aa),a
;        in a,(#a9)
;        and 4
;        ret

;*********************************************************
;       I/O
;*********************************************************

testdir
        ld  a,8
        out (#aa),a
        in  a,(#a9)

        ld  hl,X
.ri     bit 7,a
        jp  nz,.le
        inc (hl)
        jp  .up
.le     bit 4,a
        jp  nz,.up
        dec (hl)

.up     ld  hl,Y
        bit 5,a
        jp  nz,.dw
        dec (hl)
.dw     bit   6,a
        jp  nz,.fire
        inc (hl)
.fire               ;bit 0,a

        ret

;*********************************************************
;
;Set VDP port #98 to start writing at address AHL (17-bit)
;
SetVdp_Write: rlc     h
              rla
              rlc     h
              rla
              srl     h
              srl     h
              vdp       14          ;set bits 15-17
              ld      a,l           ;set bits 0-7
              out     (vdpport1),a
              ld      a,h           ;set bits 8-14
              or      64            ; + write access
              out     (vdpport1),a
              ret

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

X:      db  0
Y:      db  0



;Input: D = Dividend, E = Divisor, A = 0
;Output: D = Quotient, A = Remainder

Div8:
        xor a
        rept    8
            sla d
            rla
            cp  e
            jr  c,$+4
            sub e
            inc d
        endm
        ret

;*********************************************************
;
; display the screen at coordinate X,Y in the logical map
;
; logical map   : 128x256 stored in VRAM at #8000 (scr5 page 1)
; screen        : 32x24   stored in VRAM at #1800 (scr4)
;
display
    ;   e := (Y) mod 24
    ;   a := (Y) / 24

        ld  a,(Y)
        ld  d,a
        ld  e,24
        call    Div8

        ld  c,a
        ld  b,0

    ;   hl := offset[2*bc]

        sla bc
        ld  hl,offset
        add hl,bc
        ldi bc,(hl)
        ld  hl,bc

    ;   a: = d*24

        ld  a,d
        add a,d
        add a,d
        rept    3
            add a,a
        endm

        ld  d,a
        ld  a,(X)
        ld  e,a
        ret



offset
        dw  l01
        dw  l11
        dw  l21
        dw  l31
        dw  l41
        dw  l51
        dw  l61
        dw  l71
        dw  l81
        dw  l91
        dw  l101
        dw  l111
        dw  l121
        dw  l131
        dw  l141
        dw  l151
        dw  l161
        dw  l171
        dw  l181
        dw  l191
        dw  l201
        dw  l211
        dw  l221
        dw  l231


plotscreen:

        ld  c,vdpport3
        rept    8
            ld     a,(hl)
            cp     -1
            ret    z
            vdpw 17,32
            out    (c),e           ; Xorg
            out    (c),0

            ldi    a,(hl)
            add    a,d             ; multiplo di 24
            out    (vdpport3),a    ; Yorg
            ld     a,1
            out    (vdpport3),a    ; Yorgpage

            outi                   ; Xdst
            out    (c),0
            ldi     a,(hl)
            add     a,48
            out    (vdpport3),a    ; #1800  Ydst
            out    (c),0
            outi                   ; DX
            out    (c),0
            outi                   ; DY
            out    (c),0
            out    (c),0
            out    (c),0
            ld     a,#D0
            out    (vdpport3),a
            wait_CE
        endm
        ret
l01

    db  0,0,0,64,6
    db  6,64,0,64,6
    db  12,128,0,64,6
    db  18,192,0,64,6
    db  -1



l11
    db  1,192,0,64,5
    db  6,0,0,64,6
    db  12,64,0,64,6
    db  18,128,0,64,6
    db  24,192,5,64,1
    db  -1
l21

    db  1,128,0,64,5
    db  7,192,0,64,5
    db  12,0,0,64,6
    db  18,64,0,64,6
    db  24,128,5,64,1
    db  30,192,5,64,1
    db  -1
l31
    db  1,64,0,64,5
    db  7,128,0,64,5
    db  13,192,0,64,5
    db  18,0,0,64,6
    db  24,64,5,64,1
    db  30,128,5,64,1
    db  36,192,5,64,1
    db  -1
l41
    db  1,0,0,64,5
    db  7,64,0,64,5
    db  13,128,0,64,5
    db  19,192,0,64,5
    db  24,0,5,64,1
    db  30,64,5,64,1
    db  36,128,5,64,1
    db  42,192,5,64,1
l51
    db  2,192,0,64,4
    db  7,0,0,64,5
    db  13,64,0,64,5
    db  19,128,0,64,5
    db  24,192,4,64,2
    db  30,0,5,64,1
    db  36,64,5,64,1
    db  42,128,5,64,1
l61
    db  2,128,0,64,4
    db  8,192,0,64,4
    db  13,0,0,64,5
    db  19,64,0,64,5
    db  24,128,4,64,2
    db  30,192,4,64,2
    db  36,0,5,64,1
    db  42,64,5,64,1
l71
    db  2,64,0,64,4
    db  8,128,0,64,4
    db  14,192,0,64,4
    db  19,0,0,64,5
    db  24,64,4,64,2
    db  30,128,4,64,2
    db  36,192,4,64,2
    db  42,0,5,64,1
l81
    db  2,0,0,64,4
    db  8,64,0,64,4
    db  14,128,0,64,4
    db  20,192,0,64,4
    db  24,0,4,64,2
    db  30,64,4,64,2
    db  36,128,4,64,2
    db  42,192,4,64,2
l91
    db  3,192,0,64,3
    db  8,0,0,64,4
    db  14,64,0,64,4
    db  20,128,0,64,4
    db  24,192,3,64,3
    db  30,0,4,64,2
    db  36,64,4,64,2
    db  42,128,4,64,2
l101
    db  3,128,0,64,3
    db  9,192,0,64,3
    db  14,0,0,64,4
    db  20,64,0,64,4
    db  24,128,3,64,3
    db  30,192,3,64,3
    db  36,0,4,64,2
    db  42,64,4,64,2
l111
    db  3,64,0,64,3
    db  9,128,0,64,3
    db  15,192,0,64,3
    db  20,0,0,64,4
    db  24,64,3,64,3
    db  30,128,3,64,3
    db  36,192,3,64,3
    db  42,0,4,64,2
l121
    db  3,0,0,64,3
    db  9,64,0,64,3
    db  15,128,0,64,3
    db  21,192,0,64,3
    db  24,0,3,64,3
    db  30,64,3,64,3
    db  36,128,3,64,3
    db  42,192,3,64,3
l131
    db  4,192,0,64,2
    db  9,0,0,64,3
    db  15,64,0,64,3
    db  21,128,0,64,3
    db  24,192,2,64,4
    db  30,0,3,64,3
    db  36,64,3,64,3
    db  42,128,3,64,3
l141
    db  4,128,0,64,2
    db  10,192,0,64,2
    db  15,0,0,64,3
    db  21,64,0,64,3
    db  24,128,2,64,4
    db  30,192,2,64,4
    db  36,0,3,64,3
    db  42,64,3,64,3
l151
    db  4,64,0,64,2
    db  10,128,0,64,2
    db  16,192,0,64,2
    db  21,0,0,64,3
    db  24,64,2,64,4
    db  30,128,2,64,4
    db  36,192,2,64,4
    db  42,0,3,64,3
l161
    db  4,0,0,64,2
    db  10,64,0,64,2
    db  16,128,0,64,2
    db  22,192,0,64,2
    db  24,0,2,64,4
    db  30,64,2,64,4
    db  36,128,2,64,4
    db  42,192,2,64,4
l171
    db  5,192,0,64,1
    db  10,0,0,64,2
    db  16,64,0,64,2
    db  22,128,0,64,2
    db  24,192,1,64,5
    db  30,0,2,64,4
    db  36,64,2,64,4
    db  42,128,2,64,4
l181
    db  5,128,0,64,1
    db  11,192,0,64,1
    db  16,0,0,64,2
    db  22,64,0,64,2
    db  24,128,1,64,5
    db  30,192,1,64,5
    db  36,0,2,64,4
    db  42,64,2,64,4
l191
    db  5,64,0,64,1
    db  11,128,0,64,1
    db  17,192,0,64,1
    db  22,0,0,64,2
    db  24,64,1,64,5
    db  30,128,1,64,5
    db  36,192,1,64,5
    db  42,0,2,64,4
l201
    db  5,0,0,64,1
    db  11,64,0,64,1
    db  17,128,0,64,1
    db  23,192,0,64,1
    db  24,0,1,64,5
    db  30,64,1,64,5
    db  36,128,1,64,5
    db  42,192,1,64,5
l211
    db  11,0,0,64,1
    db  17,64,0,64,1
    db  23,128,0,64,1
    db  24,192,0,64,6
    db  30,0,1,64,5
    db  36,64,1,64,5
    db  42,128,1,64,5
    db  -1
l221
    db  17,0,0,64,1
    db  23,64,0,64,1
    db  24,128,0,64,6
    db  30,192,0,64,6
    db  36,0,1,64,5
    db  42,64,1,64,5
    db  -1
l231
    db  23,0,0,64,1
    db  24,64,0,64,6
    db  30,128,0,64,6
    db  36,192,0,64,6
    db  42,0,1,64,5
    db  -1

endProgram

Page 3/3
1 | 2 |