Sine scroller
Can anyone explain the method used to apply sine effects to scrollers?
I don't want a source code cos I want to code a routine myself but I don't understand the way they're created. How do I go about creating a sine table for my code and then use this sine data to effect the displayed bitplane? |
you can create a sin tab 0 to 360 degree with a simple BASIC program or use a sintab creator on Amiga (or on Windows: sincreator by the gang http://www.thegang.nu/ )
there are 2 types of sine scrollers Y (and 2 with X -vertical scroller) DYCP (Different Y Character Position) : a line of text where each character is displayed in a Y position following a sintab. More simple to do. use a character matrix to save y pos of each char. DYPP (Different Y Pixel Position) : the scrollbuffer (the line of text) is broken apart at every pixel ("One Pixel"), and each strip is displayed in a different Y position following a sintab. more difficult to code and more Blitter used. many sin scrollers are in 2 pixels (skidrow lemmings intro). (in dycp, the width of strip is = width of char) there are also DXCP, DXPP, and DXYCP now, which other infos you need ? |
The DYPP method above is what I think of as a sinus scroller :)
All you need to do is plot a vertical strip of your scrollbuffer on the screen every 1 pixel (or 2,3,4..x pixels). You can use the Blitter for this. You may have trouble using 3+ planes due to the amount of Blitter work needed if you want to keep it running in 1 frame ;) |
?! a DYCP is a sinus scroller Width-of-char pixels !
|
Quote:
|
Nice one chaps. Appreciated.
I'll give it a try and see how I get on... |
Quick update...
Thought I'd let you know how I'm getting on with my sinescroll routine.
Things are moving VERY slowly because I'm in no way, shape or form a very experienced coder! I've only ever done a few routines so this is by far the biggest thing I've attempted and is therefore taxing my ageing brain quite heavily! I've got all my data defined now (font, logo, sine table etc.) and all the various parts of the routine are there - some working, some in embryo. I try to break the code into smaller tasks and then have an educated stab at writing a routine to perform each task, test it, tweak it, get it working and write the next one. So far my code forbids multitasking, saves the system copper list, installs my own copper list, opens a 1 bitmap screen with a couple of border copper bars, blits my logo into that screen, and then sits there waiting for the left mouse button before restoring all the system stuff and quitting back to the OS. I've also successfully tested the routine that grabs the characters from my scrolltext and translates their ASCII character codes into positions in my font bitmap to grab the correct character image from before blitting into the scrollplane. Next I need to do the scrolling, probably using the blitter and shifting (not 100% sure how to do this yet so the routine is embryo currently), and the routine that copies the scroll plane data to the displayed bitmap using the sine values as y-offsets - again I've only currently got this routine in embryo form. Once it's all (should I say if I can ever get it all...!) working I'm gonna try to stick the main routine in a copper interrupt too. If anyone's interested in checking the current source code I'm more than happy to share / discuss / get told how wrong I'm doing it! It's commented and all the data is self contained, font and logo etc. are all defined as dc.w lists... |
why not ? you send the source by pm or in the zone
very interresting and hard work to start from scratch! |
Source in the zone...
Thanks bobbybearing.
I've posted the sinescroll source to the zone. |
wooo
you seems to want make all in one step! have you tested each routine, step by step, before put the whole routs in interrupt ? first test if text appear on main screen, to see if modulos or addresses are good. then make a scroll routine and test it in the main loop with a wait vbl wait_lmb: move.l $dff004,d0 and.l #$1ff00,d0 cmpi.l #256<<8,d0 bne.s wait_lmb bsr get_char_pos btst #6,mouse bne.s wait_lmb and if these 2 routs run fine, you can start the sinus copy. it's more simple to detect bug. /!\ : in case of animation, you have to use the double buffering for a good result ! start your code with : movem.l d0-d7/a0-a6,-(sp) and end the code with: movem.l (sp)+,d0-d7/a0-a6 moveq #0,d0 ; no error rts try to use decimal value for some registers like modulos, bltsize... you can write expressions. more simple to read about the interrupt, you miss to save and restore intreq/intena registers. Terminate your interrupt with rte, and not the old address and rts about scroll : more smooth 8! sin rout : stay in loop => freeze |
Thanks for taking the time to go through my undoubtedly amateur source code - all your help & advice is appreciated!
I have had a version of the code running where I tested the get_char routine and proved it grabs the characters from the font bitmap properly cos I blitted into the displayed screen so I could see the result. I also did the same thing with the scoll part (I scrolled a chunk of the displayed bitplane) but my code as it is did weird things so I need give that part some more thought. I'll try to pick apart all the bits of advice you've noted down and see if I can get the code edited accordingly... Even though there are big errors in the code that need to be corrected, am I on the right track as far as the actual method for getting a sinescoller working goes? In particular I wasn't sure about the sine copy part, the way my thinking went on this was to grab a word width chunk of the scrollplane, mask off 15 bits of this word, so I could blit just one line of the data into the displayed screen, and repeat this blit of the same word 16 times, each time masking off different bits and adding the next y value from the sine table before moving onto the next word of the scrollplane and repeating. Is that in the right ball park? |
Ooops, nearly forgot, just a couple more questions:
Do you need double buffering to make everything smooth even if the routine runs in 1 frame - ie. all the screen updates are done during the vertical blank? Also, I didn't quite follow what you meant when you said about the scroll : more smooth 8... |
yes, to make everything smooth, you need double buf, and more in the case of sinscroller (because of flickering)!
Edit: Oooops... sorry about the scroll, It's OK, very smooth (I made a little error in my test :laughing ) for sin, it's the idea... keep on Good work |
little error at the beginning of get_char_pos when text=255
move.l #scroll_text,scroll_ptr move.l scroll_ptr,a0 |
I'll keep on keeping on with it... Hopefully during the next week I can improve it and come back with an updated source...
|
Quote:
:great |
Another step forward...
I've been tweaking with my source code again this evening - I've posted the updated version in the zone...
Following your advice about testing, I made some changes: I made the displayed screen 4 bytes wider so that I could blit the scrolltext characters off screen to the right and then scroll them on screen. After playing with my blitter shift scrolling routine for a bit it now works properly and scrolls the scrolltext across the middle of the displayed bitplane in a continuous loop. First, I did this within the wait for vertical blank code you gave me and got it working that way. Next I put it all into the copper interrupt and got it working that way too. One quick thing about the copper interrupt. You recommended using rte instead of putting the old address on the stack and doing an rts. So I changed the interrupt_done code from: movem.l (sp)+,d0-d7/a0-a6 move.l cop_int_address,-(sp) rts to: movem.l (sp)+,d0-d7/a0-a6 rte but then the program didn't work properly, the scrolly still scrolled but it didn't quit when I pressed the left mouse button - am I missing something? |
yes, with rte you have to initialize the interruption in another way
there are 3 ways to manage interruptions : - simple interruption: Code:
start: Code:
start: Code:
start: |
personaly, I initialize like that :
Code:
start: |
OK, thanks. Interrupts are something I've never played with before and are definitely something I'm still trying to get my head fully around.
Now I think it's time to try and get the sine copy routine working! |
All times are GMT +2. The time now is 06:49. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.