English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Asm / Hardware (https://eab.abime.net/forumdisplay.php?f=112)
-   -   BPLCON1 Scroll Left & Right (https://eab.abime.net/showthread.php?t=100847)

DanielAllsopp 10 February 2020 21:57

BPLCON1 Scroll Left & Right
 
Good Evening!

I'm slowly getting there with my ASM, but something cropped up today that I can get my head around.

So I'm adjusting the scroll value in BPLCON1 to smoothly scroll my bitplanes around. I start with a value of $0000 and increate that by $11 until we get to a value of $00ff.

This seems to work, and it's scrolling just fine. However, that is only one way. The view slides off to the right, bringing in the hidden tiles on the left of the screen.

I have one column either side of 16 pixels, and my display window is 288 pixels wide, so my aim is to scroll left and right after blotting into those columns but I can't figure out how I would go about scrolling in the opposite direction.

Can you have negative values in BPLCON1? It doesn't sound right having signed words. Or does it?

Bit of a head scratcher this one.

Thanks again for any help, as you know by now I really appreciate it :-)

mcgeezer 10 February 2020 22:24

So when you are scrolling right you are increasing BPLCON1 by $11. if BPLCON1= $11 then you plot a tile to the right border by multiplying the value you have by 16.

So if this is frame n+1, BPLCON1=$11 and you are scrolling right then you would have

Code:

TILE_ADDRESS=(SCREEN_ORIGIN+38)+(1*16)*SCANLINE_LENGTH.
If you are scrolling left and you decrease BPLCON1 and say it's value is 8 then...

Code:

TILE_ADDRESS=(SCREEN_ORIGIN)+81*16)*SCANLINE_LENGTH.
Don't forget to increase and decrease your bitplane pointers as you go from $f>0 and 0<$f when moving.

If you're still stuck then I can give you example code.
Geezer

DanielAllsopp 11 February 2020 00:22

Thanks for the info Graeme. I think I'm gonna need some more info if you'd be so kind.

I've got my tiles plotting code sorted, I think, where I can just pass an X and Y grid position and it gets blitted in the correct location.

A picture may very well tell a thousand words though:

https://www.the-snakepit.co.uk/assets/eab/bplcon.png

So here I've got tiles blitted into positions [0,0], [1,0] and [2,0] for the top row, and in position [17,13], [18,13] and [19,13] for the bottom row.

Now because of the display window, the tiles in position [0,0] and [19,13] are blitted into the left and right columns which aren't visible.

With BPLCON1 as $0000 then that all works out as a centered display.

If I have BPLCON1 as $00ff then quite rightly, the display is shifted from left to right and the tiles in the left hand column become visible.

What I don't understand, and probably because I don't fully understand how BPLCON1 works, at all, is how on earth do I scroll in the opposite direction (example C) so the display is shifted from right to left and the tiles in the right hand column are scrolled onto the display?

Any source code would be appreciated too, so many thanks for that.

----

So, I think I've figured something out. If I start BPLCON1 as $00ff and then decrement down to $00 then I get the scroll the other way. Just I'm offset by one block when I first start!

I'm getting there, just thinking out loud here. I'll probably end up dreaming about bitplanes and scrolling tonight and something will pop into my head in the morning.

Antiriad_UK 11 February 2020 09:04

You can only scroll right with bplcon1 :). If you are at bplcon1 as $0000 and you want to scroll left by 1 pixel you reduce your bitplane pointers by 1 word and then scroll right by 15 in bplcon1.

mcgeezer 11 February 2020 09:27

Here's some example routines of how I might do it.

This routine just takes a simple x coordinate and divides it by 16 with the remainder being used for BPLCON1.

Code:

; Updates a screen structure with an x/y value.
; d0 = screen structure
; d1 = xpos
; d2 = ypos
agdUpdateScreenPosition:
        movem.l        d0-d3/a0-a1,-(a7)
        move.l        d0,a0
        moveq        #0,d3
        move.w        d1,d3
        not.w        d1
        and.w        #$f,d1
        lsr.w        #3,d3
        move.w        d3,hScreenOffset(a0)
        move.w        d1,hScreenHScroll(a0)
        movem.l        (a7)+,d0-d3/a0-a1       
        rts

And this routine takes in the values from the previous routine and updates the bitplane pointers and BPLCON1.

Code:

; Update the selected screen parameters with a copper.
; d0 = screen structure
agdUpdateCopperParameters:
        movem.l        d0/d1/d3/d5/d7-a0,-(a7)
        move.l        d0,a0
        moveq        #0,d0
        move.w        hScreenHScroll(a0),d0
        move.w        d0,d1
        lsl.w        #4,d1
        or.w        d1,d0
        move.l        COPPTR_BPLCON1,a1
        move.w        d0,(a1)
       
        moveq        #0,d5
        move.w        hScreenOffset(a0),d5
       
        moveq        #0,d7
        move.w        hScreenPlanes(a0),d7                        ; d7 = Number of planes
        subq.w        #1,d7       
        lea        hScreenPointers(a0),a0
       
        move.l        COPPTR_BPL0PTH,a1
        move.l        #BPL0PTH<<16,d3
.bp:        move.l        (a0)+,d1
        add.l        d5,d1
        swap        d1
        move.w        d1,d3
        move.l        d3,(a1)+
        add.l        #$2<<16,d3
        swap        d1
        move.w        d1,d3
        move.l        d3,(a1)+
        add.l        #$2<<16,d3       
        dbf        d7,.bp
       
        movem.l        (a7)+,d0/d1/d3/d5/d7-a0
        rts

As said above, you need to adjust the bitplane pointers by 1 word, BPLCON1 can only have the smooth scroll values of 0-15.

Graeme

roondar 11 February 2020 09:43

Just to save you some potential trouble: my number one error in making in right-to-left scroller is forgetting to allocate space on the left side of the bitmap. Or rather: allocating it just fine, but forgetting to add some offset to the bitplane pointers before I start scrolling.

So don't make my mistakes and add enough of an offset to the bitplane pointers to actually be able to scroll to the left without overwriting all sorts of unallocated memory. Turns out doing overwriting random bits of memory 'may' crash the Amiga quite quickly ;)

DanielAllsopp 13 February 2020 15:01

As always, thanks a lot for your help guys, I really appreciate it. I'm busy using all this knowledge right now to work things out.


All times are GMT +2. The time now is 09:24.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.14790 seconds with 11 queries