10 October 2019, 04:24 | #1 |
Registered User
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
|
Show BOB
I have a question concerning blitting a bob (raw normal, 4 bitplanes) into a destination (also 4 bitplanes, 320x256 pixels). My BOB has 16x16 pixels. I use a cookie cut blitter logic function ( $ca ). I thought I should set the following parameters:
Modulo for channel a (mask) : 0 Modulo for channel b (bob) : 0 Modulo for channel c (background) : 38 bytes Modulo for channel d (dest.) : 38 bytes. BLTSIZE: (64×16)+1 Using these parameters, no BOB is shown on the screen. But, it works if i set the modulo for a and b to -2, and the BLTSIZE to (64x16)+2. Why? Greetings Christian |
10 October 2019, 07:02 | #2 |
Registered User
Join Date: Jan 2019
Location: Brisbane
Posts: 99
|
Ensure width is in words, and modulo is in bytes. It should look clear then.
Are you using barrel roll/shifting? Adding one additional word (requires -2 bytes to modulo and +1 word to blitWidth) |
10 October 2019, 08:16 | #3 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
You'll need to set BLTFWM and BLTLWM to -1.
This is the First and last word masks of the rectangle... in your case you only have one word and if it is 0 then no bits will be passed through. A quick snippet of how I do it with barrel shifter. Code:
WAIT_FOR_BLITTER move.w d4,BLTCON0(a5) move.w d3,BLTCON1(a5) move.l #$ffff0000,BLTAFWM(a5) ; Only want the first word ;move.w #$0,BLTALWM(a5) ; Dump the last word move.w #SPRITE_ASSETS_SIZE_X-4,BLTAMOD(a5) move.w #SPRITE_ASSETS_SIZE_X-4,BLTBMOD(a5) move.w #PLAYFIELD_SIZE_X-4,BLTCMOD(a5) move.w #PLAYFIELD_SIZE_X-4,BLTDMOD(a5) move.w #(16*5)<<6+2,d3 move.w d3,(a0) ; Store Blit Size move.l a3,BLTAPTH(a5) ; Load the mask address move.l a2,BLTBPTH(a5) ; Sprite address move.l a1,BLTCPTH(a5) ; Destination background move.l a1,BLTDPTH(a5) move.w d3,BLTSIZE(a5) |
10 October 2019, 08:16 | #4 | |
Inviyya Dude!
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
|
Quote:
|
|
10 October 2019, 22:23 | #5 |
Registered User
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
|
Ah....ok. Thanks. Yes, I use the barrel roll for setting the bob at a position (x,y). Thus, I can understand why the code is written that way. But the routines for buffering and clearing the bob don't work properly now. Maybe someone could have a look at the code. The Bob appears nicely at position (x,y), but it does not disapper when the bob is moved.
Set_Bob: * d1 = x, d3 = y move.l BITPLANE,a0 move.w d3,d0 mulu.w #40,d0 add.w d0,a0 move.w d1,d0 move.w d0,d1 and.w #$000f,d0 lsl.w #8,d0 lsl.w #4,d0 move.w d0,d2 or.w #$0FCA,d0 lsr.w #3,d1 and.w #$fffe,d1 add.w d1,a0 lea BOB,a1 ; 16x16 (4 Bitplanes) Raw-Normal moveq #4-1,d7 PlaneLoop: btst #6,2(a5) WBlit2: btst #6,2(a5) bne.s WBlit2 move.l #$ffff0000,$44(a5) move.w d0,$40(a5) move.w d2,$42(a5) move.w #40-4,$60(a5) move.w #-2,$62(a5) move.w #-2,$64(a5) move.w #40-4,$66(a5) move.l #Mask,$50(a5) move.l a0,$54(a5) move.l a0,$48(a5) move.l a1,$4c(a5) move.w #(16*64)+2,$58(a5) lea 2*16(a1),a1 lea 40*256(a0),a0 dbra d7,PlaneLoop rts *************************************************** Buffer_Bob: * d1 = x, d0 = y move.l BITPLANE,a0 ; mulu.w #40,d0 add.w d0,a0 lsr.w #3,d1 and.w #$fffe,d1 add.w d1,a0 lea Buffer,a1 moveq #4-1,d7 PlaneLoop2: btst #6,2(a5) WBlit3: btst #6,2(a5) bne.s WBlit3 move.l #$ffffffff,$44(a5) move.l #$09f00000,$40(a5) move.w #40-4,$64(a5) move.w #0,$66(a5) move.l a0,$50(a5) move.l a1,$54(a5) move.w #(64*16)+2,$58(a5) lea 40*256(a0),a0 lea 4*16(a1),a1 dbra d7,PlaneLoop2 rts **************************************************** Clear_Bob: * d1 = x, d0 = y move.l BITPLANE,a0 mulu.w #40,d0 add.w d0,a0 lsr.w #3,d1 and.w #$fffe,d1 add.w d1,a0 lea Buffer,a1 moveq #4-1,d7 PlaneLoop3: btst #6,2(a5) WBlit4: btst #6,2(a5) bne.s WBlit4 move.l #$ffffffff,$44(a5) move.l #$09f00000,$40(a5) move.w #40-4,$66(a5) move.w #0,$64(a5) move.l a1,$50(a5) move.l a0,$54(a5) move.w #(64*16)+2,$58(a5) lea 40*256(a0),a0 lea 4*16(a1),a1 dbra d7,PlaneLoop3 rts *********************************** Mask: dc.w %0000001111000000 dc.w %0000111111111000 dc.w %0001111111111100 dc.w %0011111111111110 dc.w %0011111111111110 dc.w %0111111111111111 dc.w %0111111111111111 dc.w %0111111111111111 dc.w %0111111111111111 dc.w %0111111111111111 dc.w %0011111111111110 dc.w %0011111111111110 dc.w %0001111111111100 dc.w %0000111111111000 dc.w %0000001111000000 dc.w %0000000000000000 ******************************** SECTION BUFF,BSS_C Buffer: ds.w 16*2*4 |
11 October 2019, 07:57 | #6 |
Inviyya Dude!
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
|
Of course it doesn't disappear.
This is not a sprite. A BOB is being blitted, which means you are copying data into your bitplanes. It doesn't magically disappear just because you are copying the same data into some other location there... You need to restore that part of the bitplane. There are different approaches to this. Check out "triple buffering", for instance... edit: it's early in the morning, I didn't read your whole text.. Will have a look at it now... |
11 October 2019, 09:15 | #7 |
Registered User
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
|
Unfortunately. Sprites already work in my game (for which i started coding 10 years ago or so....and ended coding 9 years ago ) I'd like to continue my work now, and for that I need to know how the blitter works. I have taken this code from an asm tutorial. Maybe you can tell me what's wrong with it. I have to say, I don't understand that barrel roll completely. Computing the x and y and shifting values....ok. But when I use the shifting for a 16x16 BOB, do I rather have to use a BOB of width 32 then, containing an empty area, where the BOB can be shifted in? |
11 October 2019, 09:28 | #8 |
Inviyya Dude!
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
|
Yep. That's how it works..
Also, personally I prefer to have some constants for the custom chip Adresses (i.e. "BLTSIZE" or "DMACON"). Seems a lot more readable to me than those offsets that you are using.. |
11 October 2019, 09:42 | #9 |
Registered User
Join Date: Oct 2012
Location: Wolfach / Germany
Posts: 152
|
|
11 October 2019, 09:50 | #10 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
When i’m in the airport lounge i will take another look at the code...
But be aware that doing a Add.w d0,a0 Is suicide. You want to make that an add.l Address regs can be treated as data regs as well. Geezer |
11 October 2019, 09:56 | #11 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
|
|
11 October 2019, 10:00 | #12 |
Registered User
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
|
Well...maybe the whole thing did not work because I did not use a 16*32 BOB, but a 16x16 BOB. But it looked like the BOB was shown correctly on the screen.....
|
11 October 2019, 10:09 | #13 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
11 October 2019, 10:15 | #14 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
It's very difficult to help you without context. |
|
11 October 2019, 11:10 | #15 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
Yup, and here be the tale. My screen buffers were $AF00 (44Kb) in size (40 bytes wide x by 224 scan lines of 5 bitplanes). When I plot a sprite I typically save an offset from the top of the buffer, so much to my surprise of not knowing how add <dn>,<an> really worked whenever a sprite was being plot or restored toward the bottom of the buffer it was wrapping and shitting over a lower memory segments. And of course, the problem was that when the word value had the MSB set then this odd bug surfaced. It took me a while to figure it out, but... it was a lesson learned for me... don't use add.w <dn>,<an> EVER unless I have cause to. |
|
11 October 2019, 16:22 | #16 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,410
|
Am I missing something here?
I thought adding a 16 bit signed value to an address register using add.w was safe? Or is the lesson here that you can forget that the value needs to be in that range for it to work and therefore need to be very careful? |
11 October 2019, 16:49 | #17 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
Before the add.w there is a mulu.w that span the unsigned result over 32 bit in selected data register. adda.w or adda.l to Ax take the same cycles because of the sign extension. Furthermore, nothing prevents you from having bit 15 = 1 as a valid result in Dx, and if this the case you have a negative value added to register Ax... Yes, this is a controlled case given the limited values of y, but it is the best way to have future unexpected behaviors from your code. |
|
11 October 2019, 16:56 | #18 |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,410
|
Huh, I thought adda.w was ever so slightly faster...
Anyway, thanks for the explanation. Makes sense to use .l in all cases if they're the same speed anyway (unless you are naughty and don't clear the top bits of Dx first ). I know mulu.w does that, but I have had some code misbehave on several occasions because I did a word calculation and assumes a zero top word for a later add.l. |
11 October 2019, 17:06 | #19 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
It depends.
For the data direct cycles are the same but for register indirect. For example, take this LUT access code: adda.w (a0)+,a1 adda.l (a0)+,a1 Two advantages for the first case: faster (you have a single access when 16 bit memory) smaller (table is half in memory) |
11 October 2019, 21:28 | #20 |
Registered User
Join Date: Oct 2019
Location: Eydelstedt / Germany
Age: 44
Posts: 114
|
My BOB buffer/set/clear works now! There was one line, where a "bsr.w Clear_Bob" was written as "lsr.w Clear_Bob"
Anyway.....I tested again using only 16x16 Bob size, without an empty area to the right where i can shft in the Bob. But it works, when setting the modulos in the Set_Bob method to -2. Thus, I do not have to use a width of 32 for using the barrel shift?! The Bob is perfectly shown on any x,y combination. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
tile and bob size | aszu | Coders. AMOS | 2 | 07 February 2016 23:15 |
Who want rippoff Bob Morane? | Chain | MarketPlace | 3 | 09 May 2010 20:29 |
Bob's Bad Day - ... no Bob. | AB Positive | support.Games | 5 | 16 May 2009 01:45 |
Bob's Bad | Twistin'Ghost | Retrogaming General Discussion | 3 | 06 February 2002 13:50 |
Bomber Bob | Tim Janssen | request.Old Rare Games | 2 | 07 January 2002 16:16 |
|
|