English Amiga Board    


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

Reply
 
Thread Tools
Old 01 April 2007, 19:06   #1
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
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?
pmc is offline   Reply With Quote
Old 01 April 2007, 20:07   #2
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
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 ?

Last edited by bobbybearing; 01 April 2007 at 20:49.
bobbybearing is offline   Reply With Quote
Old 01 April 2007, 20:41   #3
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 31
Posts: 2,245
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
musashi5150 is offline   Reply With Quote
Old 01 April 2007, 20:48   #4
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
?! a DYCP is a sinus scroller Width-of-char pixels !
bobbybearing is offline   Reply With Quote
Old 01 April 2007, 21:44   #5
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 31
Posts: 2,245
Quote:
Originally Posted by bobbybearing
?! a DYCP is a sinus scroller Width-of-char pixels !
Yes it is. Sorry if what I said was misunderstood.
musashi5150 is offline   Reply With Quote
Old 01 April 2007, 21:56   #6
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
Nice one chaps. Appreciated.

I'll give it a try and see how I get on...
pmc is offline   Reply With Quote
Old 13 April 2007, 16:17   #7
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
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...

Last edited by pmc; 13 April 2007 at 20:46.
pmc is offline   Reply With Quote
Old 13 April 2007, 16:27   #8
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
why not ? you send the source by pm or in the zone
very interresting and hard work to start from scratch!
bobbybearing is offline   Reply With Quote
Old 13 April 2007, 20:51   #9
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
Source in the zone...

Thanks bobbybearing.

I've posted the sinescroll source to the zone.
pmc is offline   Reply With Quote
Old 13 April 2007, 22:35   #10
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
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
bobbybearing is offline   Reply With Quote
Old 13 April 2007, 22:58   #11
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
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?
pmc is offline   Reply With Quote
Old 13 April 2007, 23:07   #12
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
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...
pmc is offline   Reply With Quote
Old 13 April 2007, 23:15   #13
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
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 )

for sin, it's the idea... keep on Good work

Last edited by bobbybearing; 13 April 2007 at 23:37.
bobbybearing is offline   Reply With Quote
Old 14 April 2007, 00:01   #14
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
little error at the beginning of get_char_pos when text=255
move.l #scroll_text,scroll_ptr
move.l scroll_ptr,a0
bobbybearing is offline   Reply With Quote
Old 14 April 2007, 00:03   #15
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
I'll keep on keeping on with it... Hopefully during the next week I can improve it and come back with an updated source...
pmc is offline   Reply With Quote
Old 14 April 2007, 00:09   #16
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
Quote:
Originally Posted by bobbybearing
little error at the beginning of get_char_pos when text=255
move.l #scroll_text,scroll_ptr
move.l scroll_ptr,a0
Ahhh, I see it - well spotted!

pmc is offline   Reply With Quote
Old 14 April 2007, 23:21   #17
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
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?
pmc is offline   Reply With Quote
Old 15 April 2007, 00:15   #18
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
yes, with rte you have to initialize the interruption in another way

there are 3 ways to manage interruptions :
- simple interruption:
Code:
start:
... save Intena registers
move.l $6c.w,saveint
move.l #newint,$6c.w
move.w #$c010,$dff09a ; (intreq)
... 
move.l saveint,$6c.w ; restore old int
rts
newint:
movem.l d0/a6,-(sp)
move.w $dff01c,d0 ; intenar
btst #$e,d0
beq.s noint
and.w $dff01e,d0 ; intreqr
btst #4,d0
beq.s noint
...
move.w #$10,$dff09c ; intreq
noint:
movem.l (sp)+,d0/a6
rte
- you use this one:
Code:
start:
... save intena
move.l $6c.w,saveint
move.l #newint,$6c.w
move.w #$c010,$dff09a
...
move.l saveint,$6c.w
rts
newint:
movem.l d0/a6,-(sp)
noint:
movem.l (sp)+,d0/a6
move.l saveint,-(sp)
rts
- third:
Code:
start:
...
move.w $dff01c,d0 ; intenar
or.w #$8000,d0
move.w d0,saveintena
move.w #$7fff,$dff09a 
wait_it:
btst #4,$dff01e
beq.s wait_it
move.w #$10,$dff09c
... prog
bra wait_it
bobbybearing is offline   Reply With Quote
Old 15 April 2007, 00:27   #19
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
personaly, I initialize like that :
Code:
start:
...
move.w $10(a6),d0 ;save adkcon
ori.w #$8000,d0
move.w d0,adkcon(a5)
move.w 2(a6),d0 ;save dma
ori.w #$8000,d0
move.w d0,sDma(a5)
move.w $1c(a6),d0 ;save intena
ori.w #$8000,d0
move.w d0,intena(a5)

bsr waitvbl
move.w #$7fff,d0
move.w d0,$9a(a6) ; disable interrupts
move.w d0,$96(a6) ; stop dma channels
move.w d0,$9c(a6) ; stop int requests
	
move.l	$6c.w,saveintvbl ; or $6c(a1) with a1=VBR if you get vbr
lea interrupt(pc),a0
move.l a0,$6c.w

move.w	#$8000|$4000|$20,$9a(a6) ; start vbl interrupt
move.w	#$8200|$100|$80|$40,$96(a6) ; init dma

bsr Main
; restore
bsr waitvbl
move.w #$7fff,d0
move.w d0,$96(a6)
move.w d0,$9a(a6)
move.w d0,$9c(a6)
	
move.l	saveintvbl,$6c.w
move.w	intena(a5),$9a(a6)
move.w	sDma(a5),$96(a6)
move.w	adkcon(a5),$9e(a6)
...
rts
------------------
interrupt:
movem.l d0/a6,-(sp)
lea $dff000,a6
andi.w #$20,$1e(a6) ; it's possible to skip test
beq noint
...
move.w #$20,$dff09c ; twice (a4000 bug)
move.w #$20,$dff09c
noint
movem.l (sp)+,d0/a6
rte

Last edited by bobbybearing; 15 April 2007 at 00:37.
bobbybearing is offline   Reply With Quote
Old 15 April 2007, 00:29   #20
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
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!
pmc is offline   Reply With Quote
Old 17 April 2007, 15:44   #21
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
Another update...

After trying several different things and getting pretty frustrated at times, the sinecopy routine is now working.

I had to add a clear display routine so that the sinecopy didn't leave trails and also I don't think my routine is the fastest ever cos I've only been able to get it working by using four blits per word - the sinwave copy breaks display screen words into chunks of four rather than into individual pixels or pairs of pixels.

There's a big flickering problem at the moment though! From what was said earlier, I think that'll mean double buffering is needed!

Time to work on that...
pmc is offline   Reply With Quote
Old 17 April 2007, 18:49   #22
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
Success!

Scratch what I said in the previous post - the scroller wasn't flickering - there was an error in my code! No suprise there!

Now that I've fixed that it's working fine, and without double buffering too!

I've added a copper colour affect so that the scrolltext isn't plain white anymore and I'm happy with the way it looks so I think I'm gonna call my first ever proper demo effect routine in assembler complete.

Big big thanks to bobbybearing for all his patience and advice!

I need to tidy some stuff up in the way the text of the code is laid out and complete the commenting, after that I can post the completed version in the zone if anyone wants a copy?
pmc is offline   Reply With Quote
Old 17 April 2007, 18:51   #23
bippym
Global Moderator
 
bippym's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 37
Posts: 8,141
sure sounds like a good learning tool for me
bippym is online now   Reply With Quote
Old 17 April 2007, 20:30   #24
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162

wouaou ! you're a master
"without double buffering" : for now! depends of what you want to do after...
the problem is on A1200 and some winuae config : the sinscroll can be awfull.

now, you can take a look at the tuto on http://www.flashtro.com !
using tiny startup (no system friendly); 9 tutos : 1.copper, 2.bitplan, 3.text with cpu, 4.copperbar, 5.scrolltext with cpu, 6.picture, 7.sinus scroll (new char with cpu, without double buffering), 8.music, 9.final intro

you already have done...err...almost all! but you can compare with your work

Last edited by bobbybearing; 17 April 2007 at 21:07.
bobbybearing is offline   Reply With Quote
Old 17 April 2007, 23:35   #25
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
@bippym - hope it's OK

@bobbybearing - now you tell me there's a tutorial! Seriously though, thanks for all your help. I'll check out the tutorials you've pointed me at.

I'd like to have a go at doing a copper / plasma type effect next - like the one in Crusader's 'Space Deliria' demo...

At least now that this one's done I can sleep properly at night - I've been so obsessed with getting this sinescroller working that I've actually had dreams about source code!! How sad is that?!

Anyway, I've uploaded the final source to the zone...
pmc is offline   Reply With Quote
Old 18 April 2007, 02:04   #26
AGN
Registered User
 
Join Date: Aug 2004
Location: Poland
Posts: 142
here are some diffs to make code more portable (from vasm point of view)

this might be fixed in vasm
Code:
@@ -235,12 +235,12 @@
 ** Equates - Library offsets **

 execbase       equ      4
-openlibrary:   equ     -552
-closelibrary:  equ     -414
-forbid:        equ     -132
-permit:        equ     -138
-sys_cop_offset:        equ      38
-cop_int_vect:  equ     $6c
+openlibrary    equ     -552
+closelibrary   equ     -414
+forbid equ     -132
+permit equ     -138
+sys_cop_offset equ      38
+cop_int_vect   equ     $6c

 ** Code **
we should use local labels there - temporary hack
just read about these labels and add them
Code:
@@ -346,17 +346,17 @@

 * First routine grabs the characters from the scroll_text and converts their ASCII character codes into positions to correctly take them out the font bitmap and passes these to the blitter to do the actual copy **

-get_char_pos:
+get_char_pos_1:
        cmp.b   #0,scroll_count                 ;has one character width been scrolled?
-       bne     shift_scroll_it                 ;nope - keep scrolling
+       bne     shift_scroll_it_1                       ;nope - keep scrolling
        move.b  #15,scroll_count                        ;yep - reset scroll counter (using half the character width cos the blitter scoll routine shifts two bits at a time)
        move.l  scroll_ptr,a0                   ;move the mem position of the current scrolltext character into a0
        cmp.b   #255,(a0)                       ;have we reached the end of the scrolltext?
-       bne.s   not_end_of_scrtxt                       ;nope - read in the next character
+       bne.s   not_end_of_scrtxt_1                     ;nope - read in the next character
        move.l  #scroll_text,scroll_ptr         ;yep - reset the scrollpointer back to the start and read in the next character
        move.l  scroll_ptr,a0                   ;put the reset scroll_ptr back in a0 - well spotted bobbybearing!

-not_end_of_scrtxt:
+not_end_of_scrtxt_1:
        moveq.l #0,d0                   ;clear d0
        move.b  (a0)+,d0                        ;grab the next character from the scrolltext
        move.l  a0,scroll_ptr                   ;update the scrollpointer to point at the next char in scrolltext
@@ -366,9 +366,9 @@
        add.l   d0,a1                   ;now add the calculated offset to the required character
        move.l  a1,char_source                  ;and store that location into the char_source longword

-blit_char:
+blit_char_1:
        btst    #6,dmaconr(a5)                  ;as previous, wait for the blitter to be ready before blitting
-       bne.s   blit_char                       ;blit not ready? then keep waiting
+       bne.s   blit_char_1                     ;blit not ready? then keep waiting
        move.l  char_source,bltapth(a5)         ;set the blitter a channel to point at the memory address of the first line of the required character
        move.l  #scroll_screen+40,bltdpth(a5)           ;load in the scroll screen, we want to put the character into the rightmost four bytes
        move.w  #%1111111111111111,bltafwm(a5)          ;as previous, no first word mask
@@ -382,9 +382,9 @@

 * Second routine scrolls the characters along the scrollplane bitmap by doing a copy and restore of the scrollplane but shifting all the data left two bits in between **

-shift_scroll_it:
+shift_scroll_it_1:
        btst    #6,dmaconr(a5)                  ;as previous, wait for the blitter to be ready before blitting
-       bne.s   shift_scroll_it                 ;blit not ready? then keep waiting
+       bne.s   shift_scroll_it_1                       ;blit not ready? then keep waiting
        move.w  #%0010100111110000,bltcon0(a5)          ;shift two bits, use a channel, use d channel, straight copy minterm
        move.w  #%0000000000000010,bltcon1(a5)          ;set for use descending mode, cos we want the shift to go right to left
        move.l  #scroll_screen+702,bltapth(a5)          ;blitter descending mode so point at last (rather then first) word of scroll_screen
@@ -398,17 +398,17 @@

 * First routine grabs the characters from the scroll_text and converts their ASCII character codes into positions to correctly take them out the font bitmap and passes these to the blitter to do the actual copy

-get_char_pos:
+get_char_pos_2:
        cmp.b   #0,scroll_count                 ;has one character width been scrolled?
-       bne     shift_scroll_it                 ;nope - keep scrolling
+       bne     shift_scroll_it_2                       ;nope - keep scrolling
        move.b  #15,scroll_count                        ;yep - reset scroll counter (using half the character width cos the blitter scoll routine shifts two bits at a time)
        move.l  scroll_ptr,a0                   ;move the mem position of the current scrolltext character into a0
        cmp.b   #255,(a0)                       ;have we reached the end of the scrolltext?
-       bne.s   not_end_of_scrtxt                       ;nope - read in the next character
+       bne.s   not_end_of_scrtxt_2                     ;nope - read in the next character
        move.l  #scroll_text,scroll_ptr         ;yep - reset the scrollpointer back to the start and read in the next character
        move.l  scroll_ptr,a0                   ;put the reset scroll_ptr back in a0 - well spotted bobbybearing!

-not_end_of_scrtxt:
+not_end_of_scrtxt_2:
        moveq.l #0,d0                   ;clear d0
        move.b  (a0)+,d0                        ;grab the next character from the scrolltext
        move.l  a0,scroll_ptr                   ;update the scrollpointer to point at the next char in scrolltext
@@ -418,9 +418,9 @@
        add.l   d0,a1                   ;now add the calculated offset to the required character
        move.l  a1,char_source                  ;and store that location into the char_source longword

-blit_char:
+blit_char_2:
        btst    #6,dmaconr(a5)                  ;as previous, wait for the blitter to be ready before blitting
-       bne.s   blit_char                       ;blit not ready? then keep waiting
+       bne.s   blit_char_2                     ;blit not ready? then keep waiting
        move.l  char_source,bltapth(a5)         ;set the blitter a channel to point at the memory address of the first line of the required character
        move.l  #scroll_screen+40,bltdpth(a5)           ;load in the scroll screen, we want to put the character into the rightmost four bytes
        move.w  #%1111111111111111,bltafwm(a5)          ;as previous, no first word mask
@@ -434,9 +434,9 @@

 * Second routine scrolls the characters along the scrollplane bitmap by doing a copy and restore of the scrollplane but shifting all the data left two bits in between

-shift_scroll_it:
+shift_scroll_it_2:
        btst    #6,dmaconr(a5)                  ;as previous, wait for the blitter to be ready before blitting
-       bne.s   shift_scroll_it                 ;blit not ready? then keep waiting
+       bne.s   shift_scroll_it_2                       ;blit not ready? then keep waiting
        move.w  #%0010100111110000,bltcon0(a5)          ;shift two bits, use a channel, use d channel, straight copy minterm
        move.w  #%0000000000000010,bltcon1(a5)          ;set for use descending mode, cos we want the shift to go right to left
        move.l  #scroll_screen+702,bltapth(a5)          ;blitter descending mode so point at last (rather then first) word of scroll_screen
"illegal opcode extension" - moveq is always long
Code:
@@ -469,7 +469,7 @@
 sin_copy_setup:
        lea     scroll_screen,a0                        ;first word of the scrollplane as the source
        lea     displayed_screen,a1                     ;first word of the displayed screen as the destination
-       moveq.b #19,d2                  ;display is 320 bits wide, which is 40 bytes which, is 20 words. 20 words need to be blitted to complete one display. Set counter to number required minus one cos this is a dbra loop
+       moveq   #19,d2                  ;display is 320 bits wide, which is 40 bytes which, is 20 words. 20 words need to be blitted to complete one display. Set counter to number required minus one cos this is a dbra loop

 sin_blits:
        bsr     get_offset                      ;first we need to use a sin value to offset where we start copying into the displayed screen
now, when i disable sine (by placing 255 at second position in sine table) scroll looks strange

Check using devpac so we could classify it as 'broken labels by above patch' or 'vasm wiredness'
AGN is offline   Reply With Quote
Old 18 April 2007, 08:22   #27
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
@AGN - thanks for taking the time to have a look through my sourcecode!

Devpac didn't complain about the bad .b extension to my moveq - it must correct those errors on assembly - but I've changed it in my source code listing now.

As per what you said about disabling the sine by changing the second value to a 255, I tried it in Devpac and it works OK - I just got a standard flat scrolltext again. Perhaps your assembler did something weird...

I'll dig out my Devpac manual and have a read about local labels - what advantages do they give?
pmc is offline   Reply With Quote
Old 18 April 2007, 08:49   #28
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
@bobbybearing - just visited flashtro.com. Time to start checking those tutorials!

Last edited by pmc; 18 April 2007 at 09:11.
pmc is offline   Reply With Quote
Old 18 April 2007, 10:58   #29
AGN
Registered User
 
Join Date: Aug 2004
Location: Poland
Posts: 142
Quote:
Originally Posted by pmc
As per what you said about disabling the sine by changing the second value to a 255, I tried it in Devpac and it works OK - I just got a standard flat scrolltext again. Perhaps your assembler did something weird...
with/without my label patch?
Quote:
Originally Posted by pmc
I'll dig out my Devpac manual and have a read about local labels - what advantages do they give?
Exact definition of local labels will stop other asseblers from complain about "symbol <my_label> redefined"
Looks like devpac thinks for user - nice, but this leads to pain.
AGN is offline   Reply With Quote
Old 18 April 2007, 11:10   #30
AGN
Registered User
 
Join Date: Aug 2004
Location: Poland
Posts: 142
Quote:
Originally Posted by pmc
Perhaps your assembler did something weird...
Perhaps mine and Your assembler should yell that "Word is at odd address" just like phxass do :)
Code:
@@ -584,6 +584,7 @@
 scroll_ptr:    dc.l    scroll_text
 char_source:   dc.l    0
 scroll_count:  dc.b    15
+       even
 scroll_scrn_ofst:      dc.l    0
 display_scrn_ofst:     dc.l    0
AGN is offline   Reply With Quote
Old 18 April 2007, 11:32   #31
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
Quote:
Originally Posted by pmc
@bobbybearing - now you tell me there's a tutorial! Seriously though, thanks for all your help. I'll check out the tutorials you've pointed me at.
sorry for that, but It's better to learn alone : excellent work guy

Quote:
I've been so obsessed with getting this sinescroller working that I've actually had dreams about source code!! How sad is that?!
hmm...normal : same for me 15 years ago...I coded many intros in my dreams
bobbybearing is offline   Reply With Quote
Old 18 April 2007, 13:49   #32
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
I'm agree with AGN about devpac labels : I use devpac 2, and I have same errors. If you want to use same label in other sub routine, try to call it .label or _label
example:
Code:
rout1:
...
.blit_char:
...
bne.s .blitchar
...

rout2:
...
.blit_char:
...
bne.s .blit_char
2nd point : your sinus don't move like wave ?!? add only 1 line at "next_word" after dbra:
Code:
dbra d2,sin_blits
addq.l #1,mstr_sin_ptr ;<----
bra.s interrupt_done
3rd : you can put some datas in code, and not in "data_c", like variables system and variables mine, and also the text and sintab. no need to be in chip "video" ram.
and when your variables are in same hunk than your code, you can call them with the Program Counter, avoid your code to be better relocatable:
Code:
move.l scroll_ptr(pc),a0
you can take a look at some sources code here. using 2 types of my personal startup code and differents ways of sinscroller from wellknown cracktros. (main sources menu)

Last edited by bobbybearing; 18 April 2007 at 14:02.
bobbybearing is offline   Reply With Quote
Old 18 April 2007, 14:24   #33
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
@AGN - sorry, only tried it with the source as was - didn't try with the label patch. Can't believe I forgot to put an even after a dc.b! Well spotted!

@bobbybearing - from what you've found it looks like my code still needs some tweaking in places to be right. I'm not sure I'm gonna leave the source as it is now after all - perhaps there's more to learn by adding some other things like scroll speed changes and scroll pauses while the text carries on waving etc. Think I'll spend some more time improving it...


@everyone - I was thinking about what bobbybearing said that it's better to learn by doing the stuff yourself. Instead of learning by looking at the source code on flashtro.com or similar perhaps you guys who know more could get together some descriptions of how various effects are acheived at a basic level and then the rest of us who are pretty inexperienced coders could try to write routines that achieve those things and share routines / ideas / get advice as we go. Might be a better way to learn... What do you guys think?
pmc is offline   Reply With Quote
Old 18 April 2007, 14:37   #34
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
ooops...about the sinus move, I thought that you had missed something, sorry

Last edited by bobbybearing; 18 April 2007 at 14:42.
bobbybearing is offline   Reply With Quote
Old 18 April 2007, 15:08   #35
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
Quote:
Originally Posted by bobbybearing
ooops...about the sinus move, I thought that you had missed something, sorry
No need to be sorry - you're right - I DID miss something! I added your extra suggested line of code in and the sinewave instantly looked much, much better! I took your extra line out again and instead changed the existing line of my code from:

not_end_of_sin:
move.l a3,a4

addq.l #1,a3 <----this one
move.l a3,mstr_sin_ptr

to: addq.l #2,a3 to get the same result.

I'd missed to move the master sine pointer forward two bytes to adjust for the temp sin value being used in the sine blits. Adding two gets them in sequence and the sine wave works properly. Again, well spotted! You are the guru!
pmc is offline   Reply With Quote
Old 18 April 2007, 15:31   #36
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 40
Posts: 162
now you can improve it : make a 2 pixels sinus and after that, a 1 pixel sinus
bobbybearing is offline   Reply With Quote
Old 19 April 2007, 10:24   #37
korruptor
TDI
 
korruptor's Avatar
 
Join Date: Feb 2007
Location: DUNDEE
Posts: 121
Thanks for sharing your source PMC. I've been trying to learn more about copper interrupts for a while. That's helped me out a lot

I wrote a 1 pix sine scroller a month or so ago, I can upload that to the zone if you want to have a look...
korruptor is offline   Reply With Quote
Old 19 April 2007, 15:08   #38
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 31
Posts: 2,245
Hey pmc, thanks for the greet in your code - although I've gained an extra 'h'

Good to see people coding some metal banging stuff
musashi5150 is offline   Reply With Quote
Old 19 April 2007, 18:07   #39
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
@bobbybearing - I've got loads of things I want to try to improve it - new versions soon!

@korruptor - what's in my code is about all I know about interrupts! If you want to learn more then check out "The Guru's" (bobbybearing's) interrupt post earlier on in this thread. Would definitely like to check out your source code - post it up to the zone!

@musashi5150 - can't believe I spelled your name wrong - sorry! Time to edit the scrolltext - first I need to get your name right and then I need to change "special thanks to" to "greetings to" for that real old skool feel!
pmc is offline   Reply With Quote
Old 20 April 2007, 13:24   #40
pmc
is long gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: London
Posts: 1,590
New two pixel version...

I've amended my code again - there's a new version in the zone.

I made some minor amendments to how it's sectioned - data that doesn't need to be in chip ram is now sectioned as data rather than data_c.

The biggest change though is that instead of being a four pixel sine copy it's now a two pixel sine copy. I managed to get this working within the existing routine by making a couple of small changes that gives just enough of a speed increase for it to carry on working - I shortened the sin blits so that now I don't move data to registers like modulos that were already set in the previous blit. This alone increased the speed enough for a two pixel copy to work.

Also I worked out another way to calculate the sine offset instead of using a multiply, instead it now goes:

move.b <current sine val>,d3
move.b d3,d4
lsl.w #3,d3
lsl.w #5,d4
add.w d4,d3

Is getting the offset with shifting and adding quicker than using a multiply? Does anyone know could I check to see if the new offset calculation is quicker than a mulu #40,d3?
pmc is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
What level of turrican 1 has the vertical scroller? Ironclaw support.Games 6 27 March 2006 22:06
vote for best epic side-scroller JudasEZT Retrogaming General Discussion 21 28 November 2004 21:49
Arcade, 80s, Lo RES, horizontal scroller platform game redblade Looking for a game name ? 6 04 July 2004 10:24


All times are GMT +2. The time now is 04:34.

-->

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Page generated in 0.78615 seconds with 9 queries