Author Topic: Scroller wavelength  (Read 18030 times)

0 Members and 1 Guest are viewing this topic.

Offline KrazyK

  • Amiga 1200
  • ****
  • Posts: 390
  • Karma: 131
    • View Profile
    • KrazyK Remakes
Scroller wavelength
« on: September 06, 2011 »
Hi all,
I've been remaking an ST demo by The Lost Boys , their famous 'Scoll Massacre' screen, and i've completed everything except the waveform of the top/bottom green scroller.  It has had me puzzled for ages now and it's the only part of the demo I need to complete.
It appears to be a long wobbly wavelength and when slowed down in STeem it looks chopped up into sections rather than every letter plotted on it's sine axis.
I've attached the rough rip of the font, which I still need to align properly for the final version,  (if anyone has this font then I would be grateful too  ;) )and the unpacked demo in the msa file for STeem if anyone can give me a clue on how to do this in PB???
My mind has gone blank after looking at it for so long now. . . . . . . :-[

« Last Edit: March 05, 2012 by KrazyK »
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: Scroller wavelength
« Reply #1 on: September 06, 2011 »
Do you know if there is a video of this demo somewhere online? I do not have the option of messing about with emulators from this computer right now, but if I could see the effect in a video I might be able to guess as to how it could be done in a basic language.

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 990
  • Karma: 260
    • View Profile
Re: Scroller wavelength
« Reply #2 on: September 06, 2011 »
I can't help you here, I really suck when it comes to such things.  :-\ That's why I haven't remade many sine scrollers yet. But maybe Jace can help you if Zawran can't guess it.  He's God when it comes to ripping sine tables and garbled fonts ( I had a quick look and couldn't find the font anywhere in Ram too... ::) )

Anyway here's a video:

[youtube]http://www.youtube.com/watch?v=CsUvBE5gYwM[/youtube]
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: Scroller wavelength
« Reply #3 on: September 06, 2011 »
Quote
It appears to be a long wobbly wavelength and when slowed down in STeem it looks chopped up into sections rather than every letter plotted on it's sine axis.

Yes it looks like they render the scroller into a buffer and then takes that buffer and draw it onto the screen in 16 pixel bits and only changes the y position for each bit. I think it is the same sinus curve when it is slow as when it is fast, it is just a matter of changing how quickly it changes for each bit down the line. I might have some code somewhere for something like that, but I will have to look through some backup harddrives and it would be either blitzplus or blitzmax code. But if I find some time I might have a look see.

It could also be done on modern pcs by scrolling the text through a texture and then have a mesh which is made from a number of quads equal to the number of bits on the screen width and then manipulate the vertices up and down. But for PB you are probably looking at replicating this using some kind of software render technique I would think.

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Scroller wavelength
« Reply #4 on: September 06, 2011 »
I will give you a working source tomorow.  ;D

But as I told you in private message, it would better to know what is your actual display technique! sprite? sprite3D? peek and poke? (hi pad!)

I will use the Sprite3D, with Clipping.

Just have to got sleep and wake up early tomorow: got lotsa work these days! (fucking times after hollydays!!!)
Challenge Trophies Won:

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 990
  • Karma: 260
    • View Profile
Re: Scroller wavelength
« Reply #5 on: September 06, 2011 »
Quote
(hi pad!)
(hi jace! *giggles*)

Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Scroller wavelength
« Reply #6 on: September 07, 2011 »
Okay as promised, here it is! I think it will help you!

You just have to make some tuneup: change the font (sorry, I am a bit too busy these days), and also change to speed value.

Code: [Select]
Global  xres.w , yres.w , loop.w , t.s , tptr.w , sco.b
Define.f PI = 3.141593


Structure D3DTLVERTEX
  x.f
  y.f
  z.f
  rhw.f
  Color.l
  tu.f
  tv.f
EndStructure

Structure PB_DX9Sprite3D
  TexRes.l ; TexRes
  Vertice.D3DTLVERTEX[4] ; The 4 vertices for the rectangle sprite
  TmpVertice.D3DTLVERTEX[4] ; The 4 vertices for the rectangle sprite
  Width.l ; width set with ZoomSprite3D()
  Height.l ; height set with ZoomSprite3D()
  RealWidth.l
  RealHeight.l
  Angle.f
  Transformed.l
EndStructure

CompilerIf Defined(PB_MirrorSprite3D_None, #PB_Constant)=0
   #MirrorSprite3D_None=0
   #MirrorSprite3D_Horizontal=1
   #MirrorSprite3D_Vertical=2
   #MirrorSprite3D_Both=#MirrorSprite3D_Horizontal | #MirrorSprite3D_Vertical
CompilerEndIf

Procedure MirrorSprite3D(Sprite3D, MirrorMode) ;Mirror 3D sprite image (returns TRUE if any changes)
   Protected *Sprite3D.PB_DX9Sprite3D=IsSprite3D(Sprite3D)
   Protected MirroringChanges.b=0
   Protected IsMirrored.b
   Protected DoMirroring.b
   
   IsMirrored=*Sprite3D\Vertice[0]\tu>*Sprite3D\Vertice[1]\tu
   DoMirroring=1 And MirrorMode & #MirrorSprite3D_Horizontal
   If (DoMirroring And IsMirrored=0) Or (DoMirroring=0 And IsMirrored)
      MirroringChanges=1
      Swap *Sprite3D\Vertice[0]\tu, *Sprite3D\Vertice[1]\tu
      Swap *Sprite3D\Vertice[2]\tu, *Sprite3D\Vertice[3]\tu
   EndIf
   
   IsMirrored=*Sprite3D\Vertice[0]\tv>*Sprite3D\Vertice[3]\tv
   DoMirroring=1 And MirrorMode & #MirrorSprite3D_Vertical
   If (DoMirroring And IsMirrored=0) Or (DoMirroring=0 And IsMirrored)
      MirroringChanges=1
      Swap *Sprite3D\Vertice[0]\tv, *Sprite3D\Vertice[3]\tv
      Swap *Sprite3D\Vertice[1]\tv, *Sprite3D\Vertice[2]\tv
   EndIf
   
   ProcedureReturn MirroringChanges
 EndProcedure
 
Procedure ClipSprite3D(Sprite3D,ClipX,ClipY,ClipWidth,ClipHeight)
  Protected *ptr.PB_DX9Sprite3D = IsSprite3D(Sprite3D)
 
  If *ptr = 0 : ProcedureReturn #False : EndIf
 
  If ClipX < 0 : ClipX = 0 : EndIf
  If ClipY < 0 : ClipY = 0 : EndIf
 
  If ClipWidth < 0 : ClipWidth = 0 : EndIf
  If ClipHeight < 0 : ClipHeight = 0 : EndIf
 
  If ClipX > *ptr\RealWidth : ClipX = *ptr\RealWidth : EndIf
  If ClipY > *ptr\RealHeight : ClipY = *ptr\RealHeight : EndIf
 
  If ClipX + ClipWidth > *ptr\RealWidth : ClipWidth = *ptr\RealWidth - ClipX : EndIf
  If ClipY + ClipHeight > *ptr\RealHeight : ClipHeight = *ptr\RealHeight - ClipY : EndIf
 
  *ptr\Vertice[0]\tu = ClipX / *ptr\RealWidth
  *ptr\Vertice[0]\tv = ClipY / *ptr\RealHeight
 
  *ptr\Vertice[1]\tu = (ClipX + ClipWidth) / *ptr\RealWidth
  *ptr\Vertice[1]\tv = ClipY / *ptr\RealHeight
 
  *ptr\Vertice[2]\tu = ClipX / *ptr\RealWidth
  *ptr\Vertice[2]\tv = (ClipY + ClipHeight) / *ptr\RealHeight
 
  *ptr\Vertice[3]\tu = (ClipX + ClipWidth) / *ptr\RealWidth
  *ptr\Vertice[3]\tv = (ClipY + ClipHeight) / *ptr\RealHeight
 
  ProcedureReturn #True
EndProcedure




t.s ="       HI THIS IS A NEW REMAKE AND I HOPE IT IS GOOD!      "
xres  = 800       
yres  = 600         
sco   = 0
tptr  = 1
FPS = 60
TimerDuration = 1000 / FPS

InitSprite()
InitSprite3D()
;InitDisplay()
InitKeyboard()
;InitMouse()



If OpenWindow(0,0,0,xres,yres, "TCB Replicants Intro",#PB_Window_BorderLess | #PB_Window_ScreenCentered   )
    ;ButtonGadget(0, 170, 135, 45, 20, "Quitter")
   If OpenWindowedScreen(WindowID(0), 0, 0,  xres , yres,false,0,0,#PB_Screen_SmartSynchronization) =0   
      MessageRequester("Error", "This is fucked up, I can't open the window", 0)       
      End                                                   
    EndIf
Else
     MessageRequester("Error", "This is fucked up, I can't create the window", 0)       
EndIf

; Creating the Sprite texture and the sprite 3D associated
CreateSprite(1,640,50,#PB_Sprite_Texture)
CreateSprite3D(11,1)
ZoomSprite3D(11,32,50) ; have to zoom on the final display size :  blocks of 32*50 pixels

;catching the font into a sprite
CatchSprite(2, ?fontes)


;wave
angle2 = 0
speed = 6  ; change to 4, 6 , 8

;buffer for the scrolling font
Dim tScroll.c(11)
For i=0 To 10
  tScroll(i) = 32
Next



Repeat
 
  ;begin of the frame, we are going to make the scolltext sprite!
  StartDrawing (ScreenOutput())
 
  cco = 0

  For cc = 0 To 10
    letter = tScroll(cc)
    x = (letter % 10)*64
    y = (letter - (letter%10))/10*50
    ClipSprite(2,x,y,64,50)
    DisplayTransparentSprite(2, cco+sco, 0)
    cco = cco + 64
  Next
  StopDrawing()
 
  ; ok we got a line onto the screen, have to grab it into a sprite texture!
  GrabSprite(1,64,0,640,50,#PB_Sprite_Texture)

  sco = sco - 4
  If sco <= 0
    For i= 0 To 9
      tScroll(i) = tScroll(i+1)
    Next
    tptr = tptr + 1
    tScroll(10) = (Asc(UCase(Mid(t.s, tptr, 1)))-32)
    sco= 32*2
  EndIf
 
  If tptr > (Len(t.s)- 10)
    tptr = 1
  EndIf
 
  ;now the "displayed" frame begin
  ClearScreen(0)
 
  StartDrawing (ScreenOutput())
 
  ;put here all the other effects...
 
  ;at the end, I'm displaying the sine scroll mirrored!
  Start3D()
  For i = 0 To 19
    ClipSprite3D(11,i*32,0,32,50)
    DisplaySprite3D(11,64+i*32,100+10*Sin(Radian(angle2+i*speed))*2)
    MirrorSprite3D(11, #MirrorSprite3D_Vertical)
    DisplaySprite3D(11,64+i*32,400+10*-Sin(Radian(angle2+i*speed))*2)   
  Next
  Stop3D()
 
  angle2 = angle2 + speed
  If angle2 >= 360
    angle2 = angle2 - 360
  EndIf

  StopDrawing()
 
  FlipBuffers()
 
  If fullscreen<>#PB_Checkbox_Checked
    Event = WaitWindowEvent(0)
    ;WindowEventDispatcher()
  EndIf
  timer = ElapsedMilliseconds()   
  ExamineKeyboard()
 
Until KeyboardPushed (#PB_Key_Escape)           
             

End

 
DataSection
fontes: IncludeBinary "fontes.bmp"
EndDataSection

Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Scroller wavelength
« Reply #7 on: September 07, 2011 »
Forgot to add this: the sine wave changing to several values in the speed option and radius!

DisplaySprite3D(11,64+i*32,100+10*Sin(Radian(angle2+i*speed))*2)
10 = radius
100 = text position
Challenge Trophies Won:

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 990
  • Karma: 260
    • View Profile
Re: Scroller wavelength
« Reply #8 on: September 07, 2011 »
Very nice! Thanks for sharing. K+  :clap:

For all with a Purebasic version prior to v4.50: just add the following procedure to the code and the compiler will stop to complain about the missing radian function... ;)

Code: [Select]
Procedure.d Radian(degreeAngle.d)
ProcedureReturn ASin(1) / 90 * degreeAngle
EndProcedure
« Last Edit: September 07, 2011 by padman »
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Scroller wavelength
« Reply #9 on: September 07, 2011 »
Yep I used degree cos it was "simple" to change the value ::)

hope to see this great remake soon on Retro!
Challenge Trophies Won:

Offline KrazyK

  • Amiga 1200
  • ****
  • Posts: 390
  • Karma: 131
    • View Profile
    • KrazyK Remakes
Re: Scroller wavelength
« Reply #10 on: September 07, 2011 »
Wow, thanks for the code.  8) I'll incorporate it into my demo sometime this week when I get more time.  Never used Sprite3D very much and it's definitely faster then plain old Sprite.
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Scroller wavelength
« Reply #11 on: September 07, 2011 »
Hehe, yep sprite3d are really faster! But I don't use them all time, coz I want to make some PEEK and POKE :D

But you should use sprite3D for all your scrolls!
« Last Edit: September 07, 2011 by jace_stknights »
Challenge Trophies Won:

Offline KrazyK

  • Amiga 1200
  • ****
  • Posts: 390
  • Karma: 131
    • View Profile
    • KrazyK Remakes
Re: Scroller wavelength
« Reply #12 on: September 07, 2011 »
Well I couldn't wait so I tried out the code in my lunch hour today.  With some slight changes i've got it how I want it now. Cut up into 32 pixel chunks looks nice and smooth even though the screenshot might look otherwise.
Just need to add a little intro later tomorrow and it will be finished - yeah right!
Many thanks for the code again jace.  :cheers:
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Scroller wavelength
« Reply #13 on: September 07, 2011 »
Hehe, no problem! And remember (Pad said it to me!!!) : Sprite3D are better than Sprite2D!!!

 :updance:
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1431
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Scroller wavelength
« Reply #14 on: September 07, 2011 »
You guys are working with PureBasic under XP, right? Because i tried to compile your source under Windows7 x64 and it doesnt works. Afaik PureBasic DX is made for the very old and outdated DX7. So it may no longer work, esp under Windows7. Btw, i have tried to compile it using OpenGL... PB OpenGL does not support 3D.
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Scroller wavelength
« Reply #15 on: September 08, 2011 »
You guys are working with PureBasic under XP, right? Because i tried to compile your source under Windows7 x64 and it doesnt works. Afaik PureBasic DX is made for the very old and outdated DX7. So it may no longer work, esp under Windows7. Btw, i have tried to compile it using OpenGL... PB OpenGL does not support 3D.

Yep, I've made this on WinXP. But all my codes are working on win7 64, with DX9 (it's my main machine)!!! And even with a demoversion of PureBasic! Got several machines with each used version of Windows (Xp, Vista, 7).
You should take a look at your graphic card drivers...
Challenge Trophies Won:

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 990
  • Karma: 260
    • View Profile
Re: Scroller wavelength
« Reply #16 on: September 08, 2011 »
What Jace said. Sometimes it helps to change the screen depth to 16 to make things work on Win7. And I wouldn't diss a language just because some codes don't work on my machine... ;)
Challenge Trophies Won:

Offline KrazyK

  • Amiga 1200
  • ****
  • Posts: 390
  • Karma: 131
    • View Profile
    • KrazyK Remakes
Re: Scroller wavelength
« Reply #17 on: September 08, 2011 »
Ok, here's a newly compiled version on the scroll massacre to check speeds on different systems.  This version still uses Sprite instead of Sprite3D but runs absolutely fine on Win7 x86/64 and on XP with a decent video card.  My XP work pc struggles with it's crappy intel card though.
I will get around to re-coding it all usig Sprite3D, eventually.
« Last Edit: September 08, 2011 by KrazyK »
Challenge Trophies Won:

Offline padman

  • Senior Member
  • Pentium
  • ********
  • Posts: 990
  • Karma: 260
    • View Profile
Re: Scroller wavelength
« Reply #18 on: September 08, 2011 »
Attachment missing.  :whisper:
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Scroller wavelength
« Reply #19 on: September 08, 2011 »
Attachment missing.  :whisper:

Ehehe, it's not missing, it's just ultimately compressed ;)
raizor

Challenge Trophies Won: