English Amiga Board


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

 
 
Thread Tools
Old 17 April 2007, 15:44   #21
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
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  
Old 17 April 2007, 18:49   #22
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
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  
Old 17 April 2007, 18:51   #23
BippyM
Global Moderator
 
BippyM's Avatar
 
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
sure sounds like a good learning tool for me
BippyM is offline  
Old 17 April 2007, 20:30   #24
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 51
Posts: 161

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  
Old 17 April 2007, 23:35   #25
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
@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  
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  
Old 18 April 2007, 08:22   #27
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
@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  
Old 18 April 2007, 08:49   #28
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
@bobbybearing - just visited flashtro.com. Time to start checking those tutorials!

Last edited by pmc; 18 April 2007 at 09:11.
pmc is offline  
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  
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  
Old 18 April 2007, 11:32   #31
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 51
Posts: 161
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  
Old 18 April 2007, 13:49   #32
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 51
Posts: 161
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  
Old 18 April 2007, 14:24   #33
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
@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  
Old 18 April 2007, 14:37   #34
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 51
Posts: 161
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  
Old 18 April 2007, 15:08   #35
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
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  
Old 18 April 2007, 15:31   #36
bobbybearing
Zone Friend
 
bobbybearing's Avatar
 
Join Date: Oct 2003
Location: France
Age: 51
Posts: 161
now you can improve it : make a 2 pixels sinus and after that, a 1 pixel sinus
bobbybearing is offline  
Old 19 April 2007, 10:24   #37
korruptor
TDI
 
korruptor's Avatar
 
Join Date: Feb 2007
Location: Blitter Town
Posts: 124
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  
Old 19 April 2007, 15:08   #38
musashi5150
move.w #$4489,$dff07e
 
musashi5150's Avatar
 
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
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  
Old 19 April 2007, 18:07   #39
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
@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  
Old 20 April 2007, 13:24   #40
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
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  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a sine effect bobster Coders. Tutorials 16 17 October 2012 12:11
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 20:24.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10369 seconds with 13 queries