13 December 2013, 14:55 | #1 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
shift pattern
Hello,
I am filling a rectangle with a pattern. The pattern starts always in the left top corner of my rectangular block. Now, when I move the block, the pattern moves with it. What I would like to get is, that the pattern stays fixed, but is only visible within my block. I did this with this pattern and it worked: Code:
vscrollpattern dc.w %1010101010101010 dc.w %0101010101010101 vscrollpattern_shifted dc.w %0101010101010101 dc.w %1010101010101010 But now I would like to do the same with a pattern that does NOT repeat after two pixels: Code:
.ghostpattern dc.w %1000100010001000 dc.w %0010001000100010 Thanks in advance, ags |
13 December 2013, 15:13 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Divide the x coordinate of the left edge of your block by the width of the pattern and use the remainder as the number of bits you have to shift the pattern horizontally.
Do the same with the top edge of your block and the height of the pattern to shift the pattern vertically. |
13 December 2013, 16:16 | #3 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
That's a good idea. I am trying to calc and apply the x-shift for a pattern that is 16 pixels wide and 2 pixels high:
Code:
lea .ghostpattern(pc),a0 .y move.w oxNB_top(a3),d0 btst #0,d0 beq .x addq.l #2,a0 .x movem.w (a0),d0/d1 ; read pattern move.w oxNB_left(a3),d2 move.w d2,d3 lsr.w #4,d3 lsl.w #4,d3 sub.w d3,d2 rol.w d2,d0 ; shift pattern horizontally rol.w d2,d1 movem.w d0/d1,-(a7) ; put pattern on stack move.l a7,rp_AreaPtrn(a2) ... ... .ghostpattern dc.w %1000100010001000 dc.w %0010001000100010 dc.w %1000100010001000 For x I think I divide by 16, multiply by 16, then substract the result from the left coordiante to get the remainder and then shift the pattern by that. For y it works, but for x not. What now? ags EDIT: I found it! Must be ROR. not ROL. lol |
13 December 2013, 16:39 | #4 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
What about this to get the remainder for x:
Code:
moveq #15,d2 and.w oxNB_left(a3),d2 |
13 December 2013, 16:48 | #5 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
LOL, it works!
|
16 December 2013, 15:29 | #6 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,959
|
Writing Amiga GUI slowest than MUI has no big sense, especially in ASM.
You can try to use next code, if you want: Code:
lea .ghostpattern(pc),a0 .y move.w oxNB_top(a3),d0 btst #0,d0 beq .x addq.l #2,a0 .x move.l (a0),d0 ; read pattern moveq #15,D1 and.w oxNB_left(a3),d1 ror.w d1,d0 ; shift pattern horizontally move.w d0,-(a7) ; put pattern on stack swap d0 ror.w d1,d0 ; shift pattern horizontally move.w d0,-(a7) ; put pattern on stack move.l a7,rp_AreaPtrn(a2) ... ... .ghostpattern dc.w %1000100010001000 dc.w %0010001000100010 dc.w %1000100010001000 |
16 December 2013, 16:58 | #7 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
Why not simply put the pattern data into rp_AreaPtrn(a2) directly?
Code:
.x move.l (a0),d0 moveq #15,d1 and.w oxNB_left(a3),d1 rol.w d1,d0 swap d0 rol.w d1,d0 move.l d0,rp_AreaPtrn(a2) Last edited by Thorham; 16 December 2013 at 18:07. |
16 December 2013, 17:28 | #8 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Because rp_AreaPtrn is an address (a pointer), not a value.
|
16 December 2013, 18:03 | #9 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
That's quite obvious, of course. The question is why you should point to the pattern when you can store it directly? If the pointer always points to two words (or a long word), then you can store it directly. This also avoids putting the stack pointer into this member. It's about avoiding indirection if you don't have to go to lengths to avoid it, and this seems to be such a case.
|
16 December 2013, 18:07 | #10 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
To AGS:
You can also do it like this (uses the stack as in your code): Code:
.y moveq #1,d0 and.w oxNB_top(a3),d0 add.w d0,d0 lea .ghostpattern(pc,d0.w),a0 move.l (a0),d0 moveq #15,d1 and.w oxNB_left(a3),d1 rol.w d1,d0 swap d0 rol.w d1,d0 move.l d0,-(sp) move.l sp,rp_AreaPtrn(a2) ... ... ... .ghostpattern dc.w %1000100010001000 dc.w %0010001000100010 dc.w %1000100010001000 |
16 December 2013, 18:35 | #11 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Thanks Thorham, now I use your code. I think it is faster but did not count it. Actually this piece of code is only called when a button is drawn in ghost-state. This is seldom. There are core routines in my lib that eat up most of the valuable time. Optimizing these would be fine, but I don't think it is possible. Please look into the GUI thread.
|
16 December 2013, 18:38 | #12 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
|
16 December 2013, 18:39 | #13 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Yes.
|
16 December 2013, 19:11 | #14 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
Good
|
16 December 2013, 20:10 | #15 | |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Quote:
Furthermore the pattern can have any height, as long as it is a power of 2. |
|
16 December 2013, 20:43 | #16 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,751
|
|
16 December 2013, 21:27 | #17 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Thorham, just to let you know, in your source it must be ROR, not ROL.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
TAR with file name pattern handling | pintcat | support.Apps | 5 | 25 February 2013 18:32 |
Workbench PAttern Image | robpotts | New to Emulation or Amiga scene | 3 | 06 June 2011 18:47 |
Right Shift+Right Amiga works, but not Left shift+Left Amiga | Photon | support.WinUAE | 13 | 22 November 2010 21:43 |
Sector fill pattern | absence | Coders. General | 7 | 21 March 2009 21:50 |
Error on setting Magic Workbench Pattern | fc.studio | support.Apps | 7 | 17 September 2008 16:39 |
|
|