English Amiga Board Amiga Lore


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 23 August 2012, 13:15   #1
bobster
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.
bobster is offline  
AdSense AdSense  
Old 23 August 2012, 16:25   #2
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
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
StingRay is offline  
Old 23 August 2012, 18:08   #3
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 694
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 ;-)
hooverphonique is offline  
Old 23 August 2012, 19:33   #4
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Quote:
Originally Posted by hooverphonique View Post
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 ;-)
Yes, it's a 4 bit value of course. Fixed, thanks.
StingRay is offline  
Old 24 August 2012, 10:43   #5
bobster
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.
bobster is offline  
Old 24 August 2012, 11:10   #6
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 5,531
Quote:
Originally Posted by bobster View Post
The hardware reference says that all 6 bits should be set
8 bits (4+4).

Quote:
Originally Posted by bobster View Post
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.
Add a 2nd check but instead of looping if the line is not reached you'll loop if you're still in the same line. In your case:

Code:
.loop    cmp.b    #255,$dff006
        bne.b    .loop
.still255
        cmp.b    #255,$dff006
        beq.b    .still255
StingRay is offline  
Old 24 August 2012, 11:29   #7
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Quote:
Originally Posted by bobster
I also read that DDFSTRT must start one word sooner at $38 instead of $30 for horisontal scrolling.
In my experience this only applies if you want to horizontal scroll more than one word (16 pixels).

If you're only using the fine scroll regs in bplcon1 (ie. scrolling 1 - 15 pixels) you shouldn't need to change ddfstrt.
pmc is offline  
Old 26 August 2012, 12:36   #8
bobster
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.
bobster is offline  
Old 26 August 2012, 13:21   #9
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
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.
pmc is offline  
Old 09 September 2012, 20:56   #10
bobster
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?
bobster is offline  
Old 09 September 2012, 21:12   #11
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
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.
pmc is offline  
Old 11 September 2012, 13:30   #12
bobster
Registered User
 
Join Date: Feb 2012
Location: Sweden
Posts: 14
Quote:
Originally Posted by pmc View Post
A sine wave is a sine wave is a sine wave. It's all the same, you can then use it however you like.
Ok, i was thinking since no biplanes are needed to create a copperbar a different technique might be used to make them sine.

Quote:
Originally Posted by pmc View Post
Are you sure the starting wait value of your initscroll routine is correct? How could you check to make sure?
I dont now how make sure, therefor im unsure Maybe horisontal position should be ignored to make it work?

Quote:
Originally Posted by pmc View Post
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?
No i got that wrong, should be enough to have A1 pointing to the scroll label, dont need to add the 2 bytes. Then the rest of the loop should be ok starting with an offset of three words.

Quote:
Originally Posted by pmc View Post
Also, how many lines of the graphic are you trying to sinus?
Ok, that was a obvious bug, 16 lines so #15 should be put in D7 for the initscroll loop.
bobster is offline  
Old 11 September 2012, 18:47   #13
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
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.
pmc is offline  
Old 12 September 2012, 15:35   #14
bobster
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
bobster is offline  
Old 12 September 2012, 15:46   #15
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
Heh heh

Nice one
pmc is offline  
Old 17 October 2012, 10:19   #16
bobster
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?
bobster is offline  
Old 17 October 2012, 12:11   #17
pmc
rebooting...
pmc's Avatar
 
Join Date: Apr 2007
Location: Elsewhere
Posts: 1,595
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?
pmc is offline  
AdSense AdSense  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:26.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.22722 seconds with 12 queries