• Welcome to Dark Bit Factory & Gravity.
 

Scroller wavelength

Started by KrazyK, September 06, 2011

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

KrazyK

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. . . . . . . :-[

Challenge Trophies Won:

zawran

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.

padman

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:

Challenge Trophies Won:

zawran

QuoteIt 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.

jace_stknights

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:

padman

Quote(hi pad!)
(hi jace! *giggles*)

Challenge Trophies Won:

jace_stknights

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.


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:

jace_stknights

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:

padman

#8
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... ;)

Procedure.d Radian(degreeAngle.d)
ProcedureReturn ASin(1) / 90 * degreeAngle
EndProcedure
Challenge Trophies Won:

jace_stknights

Yep I used degree cos it was "simple" to change the value ::)

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

KrazyK

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:

jace_stknights

#11
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!
Challenge Trophies Won:

KrazyK

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:

jace_stknights

Hehe, no problem! And remember (Pad said it to me!!!) : Sprite3D are better than Sprite2D!!!

:updance:
Challenge Trophies Won:

va!n

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:

jace_stknights

Quote from: va!n 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.

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:

padman

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:

KrazyK

#17
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.
Challenge Trophies Won:

padman

Attachment missing.  :whisper:
Challenge Trophies Won:

Raizor

Quote from: padman on September 08, 2011
Attachment missing.  :whisper:

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

Challenge Trophies Won: