¾ Starfield Affect Routine ² By · Dad of Quadriga ¾ ; DAD of Quadriga presents a simple little routine to produce ; a starfield efffect in your demos.By the way, It is not copyright DAD ; because I am only learning code and I can't understand it.I didn't write ; it, I spread it.ok?LATERS MEN....... ² ;If your doing this then please give CREDIT to the original authour · * Star Field * * This code will try and produce a spectactular scrolling * Starfield effect on the current screen. * * Please call it every 50th of a second * ² plot_pixel ; Given an X-cord (0-320 ish) in D0 ; and a Y-cord (0-256 ish) in D1, plot ; a teensy pixel at that point. ; Assume screen starts at A0 and is 40 bytes wide ; ¾ move.l #SCREEN1+220,a0 ;Axl here.This line causes problems,wheres Screen1.Big boo boo. ;Sorry Dad but ive had no time to fix this.when i get time ill ;fix it (I hope) ² mulu.w #44,d1 add.l d1,a0 moveq #0,d2 moveq #0,d3 move.l #$8000,d4 ;this is the pixel pattern move.w d0,d2 ;copy X cord lsr.w #4,d2 ;divide d2 by 16 to get word offset move.w d2,d3 ;copy x/16 into d3 (now the word offset) lsl.w #1,d3 ;make word offset a byte offset (x2) add.l d3,a0 ;now a0 points to screen word in question lsl.w #4,d2 ;multiply d2 by 16. sub.w d2,d0 ;now d0 = bit number lsr.w d0,d4 ;now d4 = the correct pixel pattern move.w d4,(a0) ;sub.w #15,d0 ;bset d0,(a0) rts ¾ unplot_pixel ; Given an X-cord (0-320 ish) in D0 ; and a Y-cord (0-256 ish) in D1, plot ; a teensy pixel at that point. ; Assume screen starts at A0 and is 40 bytes wide ; · move.l #SCREEN1+220,a0 ;Same probs again.Axl ² mulu.w #44,d1 add.l d1,a0 ¾ moveq #0,d2 moveq #0,d3 move.l #$8000,d4 ;this is the pixel pattern move.w d0,d2 ;copy X cord lsr.w #4,d2 ;divide d2 by 16 to get word offset move.w d2,d3 ;copy x/16 into d3 (now the word offset) lsl.w #1,d3 ;make word offset a byte offset (x2) add.l d3,a0 ;now a0 points to screen word in question lsl.w #4,d2 ;multiply d2 by 16. sub.w d2,d0 ;now d0 = bit number lsr.w d0,d4 ;now d4 = the correct pixel pattern ¾ not.w d4 and.w d4,(a0) rts · Star_field ;Animate a star field from left to right to left ² move.w star_timer,d0 add.w #1,d0 move.w d0,star_timer cmp.w #300,d0 blt Star_field_left_to_right cmp.w #600,d0 bne Star_field_right_to_left move.w #0,star_timer rts ¾ Star_field_left_to_right · move.l #star_table,a1 move.l #15,d5 ;Sixteen stars (0 to 15) star_loop1 move.w (a1),d0 ; X cord move.w 2(a1),d1 ; Y cord bsr unplot_pixel move.w (a1),d0 ; Get X cord for updating move.w d5,d1 ;calculate number to add to x by and.w #7,d1 ;playing with star index number add.w #1,d1 sub.w d1,d0 ;Subtract the number and store move.w d0,(a1) ;back in star table cmp.w #0,d0 ;Is star at far left if screen? bgt not_at_left_end ¾ move.w #320,d0 ;If it is, reset it to be 320 move.w d0,(a1) ;and insert into table not_at_left_end move.w (a1)+,d0 ; X cord move.w (a1)+,d1 ; Y cord bsr plot_pixel dbf d5,star_loop1 rts Star_field_right_to_left move.l #star_table,a1 move.l #15,d5 ;Sixteen stars (0 to 15) star_loop2 move.w (a1),d0 ; X cord move.w 2(a1),d1 ; Y cord bsr unplot_pixel move.w (a1),d0 ; Get X cord for updating · move.w d5,d1 ; calculate number to add to x by and.w #7,d1 ; playing with star index number add.w #1,d1 add.w d1,d0 ;Subtract the number and store move.w d0,(a1) ;back in star table cmp.w #320,d0 ;Is star at far left if screen? blt not_at_right_end move.w #0,d0 ;If it is, reset it to be 320 move.w d0,(a1) ;and insert into table ² not_at_right_end ¾ move.w (a1)+,d0 ; X cord move.w (a1)+,d1 ; Y cord bsr plot_pixel dbf d5,star_loop2 rts ¾ star_timer ;count to decide when to change direction of scrolling stars dc.w 0 ² star_table ;Table of stars' X and Y co-ordinates. dc.w 320,0 dc.w 240,10 dc.w 100,20 dc.w 20,30 dc.w 140,40 dc.w 200,50 dc.w 20,60 dc.w 240,70 dc.w 20,80 dc.w 320,90 dc.w 50,100 dc.w 200,110 dc.w 70,120 dc.w 10,130 dc.w 230,140 dc.w 200,150 ¾End.