Author Topic: Vertical scrolling of 2 pictures  (Read 1839 times)

0 Members and 1 Guest are viewing this topic.

Offline demoniak

  • CPC664
  • ***
  • Posts: 98
  • Country: fr
  • Liked: 110
  • Likes Given: 53
Vertical scrolling of 2 pictures
« on: 12:46, 05 April 11 »
Hello,

I want to display 2 pictures of maximum resolution (384x272 mode 1) and do a vertical scrolling to display the entire picture, so using the entire 64K of the video memory.

My code is placed in bank 7 at address #C000 (with out #7F00,#C1).
I do a rupture every line by setting CRTC reg4 to 0, and re-adressing vram for each line.
My code is calculated to run at 19986 µs for each frame.
By the way, the first picture is stored at address #0200, and the second at address #8000


But this seems to work only with CRTC type 0...
Any way to make this code running on all crtc ?

Here is my code :
Code: [Select]
        ORG     #C000,#4000

        DI
        LD      BC,#7FC1
        OUT     (C),C
        LD      SP,#200
        JP      Start

Start:
        LD      B,#F5
Sync:
        IN      A,(C)
        RRA
        JR      NC,Sync
        LD      HL,#C9FB
        LD      (#38),HL
        EI
        HALT
        HALT
        LD      BC,#BC01
        OUT     (C),C
        LD      BC,#BD30
        OUT     (C),C
        LD      BC,#BC02
        OUT     (C),C
        LD      BC,#BD32
        OUT     (C),C
        LD      BC,#BC04
        OUT     (C),C
        LD      BC,#BD00
        OUT     (C),C
        LD      IY,TabActions
        HALT
        DI
;
; Boucle principale du programme
;
Prog:
        LD      B,10+4
Loop1:
        CALL    WaitLigne
        DJNZ    Loop1

        LD      A,39
Loop2:
        DEC     A
        JR      NZ,Loop2

        LD      BC,#BC07
        OUT     (C),C
        LD      BC,#BD00
        OUT     (C),C

        LD      B,21-4
Loop3:
        CALL    WaitLigne
        DJNZ    Loop3

        CALL    Ordonanceur

        LD      BC,#BC07
        OUT     (C),C
        LD      BC,#BDFF
        OUT     (C),C

        LD      E,34
StartRupt:
        LD      IX,AdrEcr
BclLigne:
        CALL    SetLigne
        DEC     E
        JR      NZ,BclLigne
        JP      Prog

WaitLigne:
        LD      A,12
WaitLigne1:
        DEC     A
        JR      NZ,WaitLigne1
        ADD     HL,BC                   ; = 3 Nops
        RET

SetLigne:
        LD      BC,#BC0C
        OUT     (C),C
        LD      A,(IX+1)
        INC     B
        OUT     (C),A
        DEC     B
        INC     C
        OUT     (C),C
        LD      A,(IX+0)
        INC     B
        OUT     (C),A
        INC     IX
        INC     IX
        LD      A,#72
SetLigneWait:
        DEC     A
        JR      NZ,SetLigneWait
        NOP
        RET

Ordonanceur:
        LD      A,(IY+0)
        AND     A
        JR      NZ,Ordonanceur2
        LD      IY,RestartActions
        LD      A,(IY+0)
Ordonanceur3:
        LD      C,A
        LD      B,0
        LD      HL,CodeAction
        ADD     HL,BC
        LD      A,(HL)
        INC     HL
        LD      H,(HL)
        LD      L,A
        NOP
        JP      (HL)
Ordonanceur2:
        LD      B,(IY+2)
        JR      Ordonanceur3


Wait3:
        LD      A,106
Wait3_1:
        DEC     A
        JR      NZ,Wait3_1
Wait3_2:
        LD      A,0
        INC     A
        CP      3
        JR      C,Wait3_4
        XOR     A
        INC     IY
Wait3_3:
        LD      (Wait3_2+1),A
        RET
Wait3_4:
        JR  Wait3_3
       
Wait48:
        LD      A,106
Wait48_1:
        DEC     A
        JR      NZ,Wait48_1
Wait48_2:
        LD      A,0
        INC     A
        CP      48
        JR      C,Wait48_4
        XOR     A
        INC     IY
Wait48_3:
        LD      (Wait48_2+1),A
        RET
Wait48_4:
        JR      Wait48_3

ScrollUp:
        LD      HL,(StartRupt+2)
        INC     HL
        INC     HL
        LD      (StartRupt+2),HL
        LD      A,#69
ScrollUpWait:
        DEC     A
        JR      NZ,ScrollUpWait
        INC     HL                      ; 2 Nops
        INC     IY
        RET

ScrollUpUp:
        LD      HL,(StartRupt+2)
        LD      BC,4
        ADD     HL,BC
        LD      (StartRupt+2),HL
        LD      A,#69
ScrollUpUpWait:
        DEC     A
        JR      NZ,ScrollUpUpWait
        INC     IY
        RET

ScrollDn:
        LD      HL,(StartRupt+2)        ; 5 Nops
        DEC     HL                      ; 2 Nops
        DEC     HL                      ; 2 Nops
        LD      (StartRupt+2),HL        ; 5 Nops
        LD      A,#69
ScrollDnWait:
        DEC     A
        JR      NZ,ScrollDnWait
        INC     HL                      ; 2 Nops
        INC     IY
        RET

ScrollDnDn:
        LD      HL,(StartRupt+2)        ; 5 Nops
        LD      BC,-4                   ; 3 Nops
        ADD     HL,BC                   ; 3 Nops
        LD      (StartRupt+2),HL        ; 5 Nops
        LD      A,#69
ScrollDnDnWait:
        DEC     A
        JR      NZ,ScrollDnDnWait
        INC     IY
        RET

ActWait3    EQU     0
ActWait48   EQU     2
ActScrUp    EQU     4
ActScrDn    EQU     6
ActScrUpUp  EQU     8
ActScrDnDn  EQU     10

; Relations entre Numéro action et fonction action
CodeAction
        DW      Wait3                    ; Normalement pas d'action 0
        DW      Wait48                  ; Action 1
        DW      ScrollUp                ; Action 2
        DW      ScrollDn                ; Action 3
        DW      ScrollUpUp
        DW      ScrollDnDn

TabActions:
        DB      ActWait48
RestartActions:
        DB      ActScrUpUp,ActScrUpUp,ActScrUpUp,ActScrUpUp
        DB      ActScrUpUp,ActScrUpUp,ActScrUpUp,ActScrUpUp
        DB      ActScrUpUp,ActScrUpUp,ActScrUpUp,ActScrUpUp
        DB      ActScrUp,ActScrUp,ActScrUp,ActScrUp
        DB      ActScrUp,ActScrUp,ActScrUp,ActScrUp
        DB      ActScrUp
        DB      ActScrUp
        DB      ActWait48
        DB      ActScrDnDn,ActScrDnDn,ActScrDnDn,ActScrDnDn
        DB      ActScrDnDn,ActScrDnDn,ActScrDnDn,ActScrDnDn
        DB      ActScrDnDn,ActScrDnDn,ActScrDnDn,ActScrDnDn
        DB      ActScrDn,ActScrDn,ActScrDn,ActScrDn
        DB      ActScrDn,ActScrDn,ActScrDn,ActScrDn
        DB      ActScrDn
        DB      ActScrDn
        DB      0       ; Fin des actions

AdrEcr:
        DW      #0D00, #0D30, #0D60, #0D90, #0DC0, #0DF0, #0E20, #0E50
        DW      #0E80, #0EB0, #0EE0, #0F10, #0F40, #0F70, #0FA0, #0FD0
        DW      #1000, #1030, #1060, #1090, #10C0, #10F0, #1120, #1150
        DW      #1180, #11B0, #11E0, #1210, #1240, #1270, #12A0, #12D0
        DW      #1300, #1330
        DW      #2D00, #2D30, #2D60, #2D90, #2DC0, #2DF0, #2E20, #2E50
        DW      #2E80, #2EB0, #2EE0, #2F10, #2F40, #2F70, #2FA0, #2FD0
        DW      #3000, #3030, #3060, #3090, #30C0, #30F0, #3120, #3150
        DW      #3180, #31B0, #31E0, #3210, #3240, #3270, #32A0, #32D0
        DW      #3300, #3330


Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2278
  • Likes Given: 3478
Re: Vertical scrolling of 2 pictures
« Reply #1 on: 23:29, 05 April 11 »
Well the only 100% way is to test it on the other crtc types and modify the code to work.
You *may* need to have some crtc detection code in order to setup the code, if you can't make it the same for all.
Do you have any other cpcs?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline demoniak

  • CPC664
  • ***
  • Posts: 98
  • Country: fr
  • Liked: 110
  • Likes Given: 53
Re: Vertical scrolling of 2 pictures
« Reply #2 on: 12:10, 06 April 11 »
I've only one cpc...

But if there is a more simple method to do vertical scroll between the 2 pictures, I will be happy to learn it :-)

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1983
  • Likes Given: 4650
Re: Vertical scrolling of 2 pictures
« Reply #3 on: 23:33, 07 April 11 »
If you want to scroll again and again through all the V-RAM then you can't use overscan (= having more than 16 KB V-RAM). As long as you use 16 KB V-RAM it will work. The problem in this case is that the CRTC is not connected with ALL his address pins.
 
To check different CRTCs, you just can use a CPC emulator, that allows you to select different CRTC types.

 
Edit: Here an example...
 
Video:
http://www.youtube.com/watch?v=l3lqJ60pQr4
 
DSK..: http://www.colorado-boys-muenchen.de/users/futureos/files/NGC4650A.zip
 
 
« Last Edit: 01:44, 08 April 11 by TFM/FS »
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2278
  • Likes Given: 3478
Re: Vertical scrolling of 2 pictures
« Reply #4 on: 20:04, 11 May 12 »
I've only one cpc...

But if there is a more simple method to do vertical scroll between the 2 pictures, I will be happy to learn it :-)
I think this may work:

split the screen into 2 sections, each 20 char lines tall.

use 32k screen trick (r12 bit 3,2 are 1). If split is bigger it will repeat the bottom part after some scrolling.. but if you make it smaller and do the split, you can change the address of the 2nd part. Done in the right way and you can scroll the screen, it will work on all crtcs and you do only 1 split.

I will write some example code that does this and I think it will work.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource