23 August 2012, 13:15 | #1 |
Registered User
Join Date: Feb 2012
Location: Sweden
Posts: 14
|
Help with a sine effect
I'm trying to create my first asm coded demo effect ever, it is supposed to be a sineffect, the idea is to write sine values into the copperlist every VB. Im not sure i got the idea right so i try to get some response here to get me right on track. The scrolltable consists of 32 values.
Here's the part of the prog creating the effect: Code:
lea.l scroll(pc), a2 ; a2 points at scroll values move.l #$2807fffe,d0 ; move.w #7, d7 ; Number of rows to be affected by the effect initscroll: move.l d0,(a2)+ move.l #$01020000, (a2)+ add.l #$01000000, d0 dbf d7,initscroll main: btst #6,$bfe001 ; Left mouse clicked ? beq.s exit ; No, continue loop! wait: cmp.b #$ff,$dff006 ; Wait for VBL bne.b wait lea.l scrolltab(pc),a0 ; scrolltable to a0 lea.l scroll+2(pc),a1; ; scrolloffset to a1 move.w scrollvalue(pc),d0 ; current scrollvalue to d0 addq.w #2,scrollvalue move.w #7,d7 movescroll: and.w #63,d0 move.w (a0,d0.w),d1 ; current sinusvalue to d1 move.w d1,6(a1) ; move to copperlist addq.l #8,a1 ; increase to next sinus value addq.w #2,d0 dbf d7, movescroll bra.s main Last edited by bobster; 24 August 2012 at 10:07. |
23 August 2012, 16:25 | #2 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Code looks OK to me at first glance. Just keep in mind that scroll value is a 4 bit number, i.e. 0-15 so remember to clip your sine values accordingly (or create a sine table with already clipped values). Also, if you want to scroll both, odd and even planes, you need to take into account that the scroll value for odd/even planes is in bits 0-3 resp. 4-7 of BPLCON1. This can also be precalculated into the sine table of course.
Other than that your routine needs not much time (less than 1 raster line) so your "WaitVBL" routine might not wait for the start of the next VBL (wait for line 255 -> your routine runs and finishes -> still in line 255 -> check for line 255 will be true -> no wait) which means your routine may run much too fast. Last edited by StingRay; 23 August 2012 at 19:33. Reason: thanks BigMama :P |
23 August 2012, 18:08 | #3 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
Looks like you're contradicting yourself.. first you say bplscrl is 3 bits, then you say it's 4. I'm pretty sure it's 4, i.e. 0-15 ;-)
|
23 August 2012, 19:33 | #4 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
|
24 August 2012, 10:43 | #5 |
Registered User
Join Date: Feb 2012
Location: Sweden
Posts: 14
|
The hardware reference says that all 6 bits should be set even though there's only one bitplane.http://amigadev.elowar.com/read/ADCD.../node008B.html
I used one bitplane and just put a single char on it, but it is just flickering, so it's proberly executing to fast as Stingray mentioned. How can i make it go slower? I also read that DDFSTRT must start one word sooner at $38 instead of $30 for horisontal scrolling. |
24 August 2012, 11:10 | #6 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
8 bits (4+4).
Quote:
Code:
.loop cmp.b #255,$dff006 bne.b .loop .still255 cmp.b #255,$dff006 beq.b .still255 |
|
24 August 2012, 11:29 | #7 | |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Quote:
If you're only using the fine scroll regs in bplcon1 (ie. scrolling 1 - 15 pixels) you shouldn't need to change ddfstrt. |
|
26 August 2012, 12:36 | #8 |
Registered User
Join Date: Feb 2012
Location: Sweden
Posts: 14
|
Ok, thanx for the info, added the second wait but the screen is still just flickering when running under winuae. Gosh! asm aint easy at all, just to find information about the commands is a challenge. Probably put something at a wrong memory location or something other lame beginners mistake.
|
26 August 2012, 13:21 | #9 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
It gets easier with lots of practice and experience - keep trying and you'll get there.
If you want, you can post your code here or drop it to me on email, whatever's easier for you and we can fix it. I won't do the code for you - too much help spoils it but I'm sure we can get it working. |
09 September 2012, 20:56 | #10 |
Registered User
Join Date: Feb 2012
Location: Sweden
Posts: 14
|
Ok, thanx for the encouragement I emailed the code. Is the same technique used for creating a sine effect for a copperbar? A general ASM question: what's the difference between moveq #54-1,d2 and moveq #53,d2?
|
09 September 2012, 21:12 | #11 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
A sine wave is a sine wave is a sine wave. It's all the same, you can then use it however you like.
No difference between #54-1 or #53 they both move #53 The reason you often see -1 is because of dbf (dbra) loops. They run until the value in the register used is -1 so many people (me included) move the number of iterations they want the loop to run for to the register and let the assembler take care of modifying the value to be one less. It just makes the code more readable is all. EDIT: OK, I now have a version of your code that's working just fine. I didn't have to change very much at all to get it to work, it's very, very close to be being right as it is already. So, a few hints / suggestions: Are you sure the starting wait value of your initscroll routine is correct? How could you check to make sure? In your main sinus routine, are you sure you're moving the sine values you grab from your sine table to the correct places in the copper list? Also, how many lines of the graphic are you trying to sinus? Last edited by pmc; 09 September 2012 at 22:15. |
11 September 2012, 13:30 | #12 | |||
Registered User
Join Date: Feb 2012
Location: Sweden
Posts: 14
|
Quote:
Quote:
Quote:
Ok, that was a obvious bug, 16 lines so #15 should be put in D7 for the initscroll loop. |
|||
11 September 2012, 18:47 | #13 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
OK, so you fixed two out of the three bugs, so onto the last...
How can you check if your wait pos is OK? Well... one way would be: in your copperlist, wait for a line and turn the background colour white and then wait for the next line and turn the background colour back to black again. Then, when you run your intro, there will be a white line on the screen. Move the white line about by waiting for different scan lines until you get it so that it touches the top of your graphic, then you know what the first wait pos should be for your scroll reg sinus and you can change your initscroll routine to be correct. Once you do that, that should be all the bugs fixed and your intro should be working. |
12 September 2012, 15:35 | #14 |
Registered User
Join Date: Feb 2012
Location: Sweden
Posts: 14
|
Cool, now it works! Thanx for the help and advice. I was pretty shure i put the character at line #100 at add.l #40*100+18,a0
Next thing to learn is how to add some scroll or other text routine. Maybe it will be an entire intro in a couple of years or so |
12 September 2012, 15:46 | #15 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Heh heh
Nice one |
17 October 2012, 10:19 | #16 |
Registered User
Join Date: Feb 2012
Location: Sweden
Posts: 14
|
one observation made, the scrolling continues after the last line of the character, even though i dont modify bplcon1 for those lines, how can i adjust that?
|
17 October 2012, 12:11 | #17 |
gone
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
|
Well... the last value you leave in the bplcon1 register when changing the values to sinus your graphic is the value that remains for the rest of the display ie. the effect of the scroll applied continues after your graphic.
So, how about waiting for the line after your graphic and hard setting the bplcon1 reg scroll values back to zero? |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sine scroller | pmc | Coders. Tutorials | 95 | 02 July 2017 16:40 |
Sine scroller - dycp | blazeb | Coders. Asm / Hardware | 6 | 02 May 2012 10:08 |
Flickering sine scroller | pmc | Coders. Tutorials | 4 | 24 June 2009 09:19 |
Help with sine regression | Ed Cruse | Coders. General | 14 | 30 June 2008 01:15 |
|
|