Dark Bit Factory & Gravity
GENERAL => Projects => Topic started by: KrazyK 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. . . . . . . :-[
-
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.
-
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]
-
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.
-
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!!!)
-
(hi pad!)
(hi jace! *giggles*)
-
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
-
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
-
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
-
Yep I used degree cos it was "simple" to change the value ::)
hope to see this great remake soon on Retro!
-
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.
-
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!
-
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:
-
Hehe, no problem! And remember (Pad said it to me!!!) : Sprite3D are better than Sprite2D!!!
:updance:
-
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.
-
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...
-
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... ;)
-
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.
-
Attachment missing. :whisper:
-
Attachment missing. :whisper:
Ehehe, it's not missing, it's just ultimately compressed ;)
-
Attachment missing. :whisper:
Good point, it's there now.... ;D
-
LOL that guitar player is brilliant! K+ for that. The rest is extremely slow on my machine though. :-\ (XP, Celeron 2,66Ghz, GeForceFX5200 - and yep it's crap, I know. ;D ) Honestly you should try Sprite3D. It's faaaaaaast, even on lousy computers. ;)
-
LOL that guitar player is brilliant! K+ for that. The rest is extremely slow on my machine though. :-\ (XP, Celeron 2,66Ghz, GeForceFX5200 - and yep it's crap, I know. ;D ) Honestly you should try Sprite3D. It's faaaaaaast, even on lousy computers. ;)
I though it would be too slow on some systems so i'm already re-coding it for Sprite3D.
btw. The sprite is from the Transbeuace I Demo I ripped years ago. Attached here if you want to use it.
-
Hey thanks! :) I'm sure I can use it some time. I was in need for band sprites so badly when making this. (http://www.dbfinteractive.com/forum/index.php?topic=4538.msg61395#msg61395) But all I found was Mario. Didn't even think of these then. So, maybe I'll use them for my next Xmas demo. I'll credit you for ripping them of course. ;)
-
Yep you should use Sprite3D. You got too much "sprites" to display!
on my machine, the 3 background scrolls seem to run in 2 frames, but not the big blue one on top ??? They should all runs in 2 or 1 frames...
By the way, really cool remake!!! :clap:
-
Really good work :)
I love all those scrollers.
-
Fantastic, that was great despite a few hiccups! :clap:
-
Fantastic, that was great despite a few hiccups! :clap:
Thanks guys,
Looking back at it now it's hard to believe it was originally on an 8mhz machine with 512k ram !!
-
Looking back at it now it's hard to believe it was originally on an 8mhz machine with 512k ram !!
Most remakes of Atari ST effects prove that this machine was fantastic. When you see all the code you have to do just for simple rasters, or bitplanes transparency...
And when you think even with a Pentium (wich is more than 100 time faster thant a 68000!) and a simple gfx card on PC, it is you have to make some optimisation to make all work in 1 frame... :bfuck2:
-
Ok, i've dug out my code again and added lots of Sprite3d functions and removed a few glitches in the multi-scroller now and got it running from 40fps to 60fps in both modes on my Win7 x86 laptop. Specs are :Dual Core, 2,2Ghz, 3GB ram, Onboard 1GB Intel video just as a comparison.
It's still in 640x480 but that's another step to take if I want to convert it all to 800x600 as that's a lot of font resizing and other headaches.
I haven't had a chance to test it on any other systems yet so it will be interesting to see if it works at all anywhere else.
Voluteers please ? ;)
Best run under Win7, XP on my PC runs it pretty crap.
-
very nice, works fine here. winxp, c2duo, 2gig ram, gt440 nvidia.
screen got quite hectic with all those scrollers but still ran fairly smooth, and the tune is nice also.
-
Nice one, glad to see it works on WinXp smoothly too. I'll try it on my test PCs at work on monday which are also WinXP and Win7 x64 to see what happens. Thanks for testing. :cheers:
-
Great to run this again, it works fine on Win 7 64 bit.
That music is excellent.
-
Still working fine here ;) what about Padman??? Paddddddddddd!!!!!
-
Made some slight fixes to make is faster on WinXP and fixed some odd sprite anomolies. Original link updated a few posts below
-
Runs fine here on my new laptop with Win7 x64 and Radeon Gfx. Can't test it on my old XP PC, since it refuses to boot atm... :whack: Does this still use DX 7, since it turns off some visual stuff on Win7 in order to run?
-
There are no directx7 routines used as such but the subsytem is included as it ran like crap without it included in the compiler options. With only directx9 it ran really badly on win7. Its still slow on xp but who has xp now eh? :-X
-
Yeah, nice scroller inferno ;-) ... works great on my laptop!
Wel done - love the music btw!
-
KrazyK, as I told you in PM, here is the code for the multiscroll. I put it here for everyone ;D. I will use it also for my Empire remake, as soon as I will get time to rip the wave sine for the scrolls and also put off my finger from my ass... :boxer:
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
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
Global xres.w , yres.w , loop.w ,xp.w , yp.w , tptr.w , sco.b
xres = 800
yres = 600
deportx = (xres-640)/2
deporty = (yres-480)/2
InitSprite()
InitSprite3D()
InitKeyboard()
If fullscreen=#PB_Checkbox_Checked
window = OpenScreen( xres , yres , 32 , "MultiScroll effect")
If window = 0
MessageRequester("Error", "This is fucked up, I can't open the window", 0)
End
EndIf
Else
If OpenWindow(0,0,0,xres,yres, "MultiScroll effect",#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
EndIf
;text.s = " ! #$%&' ()*+ ,-./0 1 2 3 4 5 6 7 8 8 9 :;<=>?@ a bcdefghijklmnopqrstuvwxyz"
text.s = " THE EMPIRE PRESENT YOU A NEW INTRO BLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLABLA"
Dim gfxfont(60) ; buffer for the fonts' pointers
font = CatchImage (#PB_Any, ?fontes)
For loop =0 To 59
gfxfont(loop) = GrabImage(font,#PB_Any,loop*8,0,8,7) ;grab an image for each letter
Next
sizeScroll = Len(text)*8 ;total size of the "scroll sprite"
CreateSprite(2,sizeScroll,7,#PB_Sprite_Texture)
CreateSprite3D(21,2)
ZoomSprite3D(21,sizeScroll,7) ; have to zoom it, overwise ther is a bug at display
; this part is the "scroll sprite" creation. In PureBasic, you can't make sprite into a sprite with the StartDrawing(SpriteOutPut()) method
; so we have to draw into it ! That why we created a font for each letter.
StartDrawing (SpriteOutput(2))
For cc.w = 1 To Len(text)
letter = (Asc(UCase(Mid(text, cc, 1)))-32) ; get letter index
DrawImage (ImageID(gfxfont(letter)), (cc-1)*8, 0) ; draw into sprite at letter position
Next
StopDrawing()
xScroll = 0
Repeat
ClearScreen(0)
StartDrawing(ScreenOutput())
Start3D()
angPos = 0
For yscroll = 0 To 24
xClip = xScroll+4*yscroll ; position to clip the "scroll sprite"
If (sizeScroll - xClip) < 320 ; if the part left is too small (less than 320 pixels), it will zoom instead
lClip = sizeScroll - xClip ; so we have to correct it
Else
lClip = 320 ; when the part left is over 320 pixel, not problems.
EndIf
ClipSprite3D(21,xClip,0,lClip,7) ; clipping the sprite
ZoomSprite3D(21,lClip*2,14) ;zooming at the good size
DisplaySprite3D(21,deportx,deporty+yscroll*16) ;displaying at the good position :D
Next
xScroll = xScroll + 1 ; moving stuff
If xScroll > sizeScroll
xScroll = 0
EndIf
Stop3D()
StopDrawing()
Gosub fps:
FlipBuffers()
If fullscreen<>#PB_Checkbox_Checked
Event = WindowEvent()
EndIf
ExamineKeyboard() :
Until KeyboardPushed (#PB_Key_Escape)
End
fps:
If Val ( FormatDate ( "%ss" , Date ()))=sek ; regardez pas là, c'est trop compliqué. Arrêtez j'vous dis! Bon ben, je
; vous aurez prévenu...
fps+1
Else
FPS$= Str (fps)
fps=0
EndIf
sek= Val ( FormatDate ( "%ss" , Date ()))
StartDrawing ( ScreenOutput ())
DrawingMode (1)
FrontColor ( RGB (255,255,255))
DrawText (1,1, "FPS: " +FPS$+", "+Str((B-A)*100)+"->"+StrF(angleY))
StopDrawing ()
Return
DataSection
fontes: IncludeBinary "font.bmp"
-
Big thanks Jace. I'l see if I can use it in any of my future projects (and credit you obviously) to speed things up.
:cheers: