Smooth scrolling text like C64/Amiga how to do it in basic?

Everything else that doesn't fall into one of the other PB categories.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Kaeru Gaman wrote:@Kale
regarding your Font... is it your work?
do you set it free, I mean, could everybody use it just for putting a thnx in the credits?
it's not my work, i think its by an artist called 'Made'.
--Kale

Image
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

Kale wrote:
Kaeru Gaman wrote:@Kale
regarding your Font... is it your work?
do you set it free, I mean, could everybody use it just for putting a thnx in the credits?
it's not my work, i think its by an artist called 'Made'.
do you remember how it was licensed?
if not, don't bother, just was interested.
but I can make Spritefonts myself...


@fusion_400

you should not mix up drawing commands with other output.
within a start/stop-drawing block only shopuld be drawing commands,
other display commands like DisplaySprite and RenderMovieFrame should be outside a drawing block.
oh... and have a nice day.
fusion_400
User
User
Posts: 22
Joined: Sun Jun 15, 2008 2:34 pm

Post by fusion_400 »

Ok i have managed to get the movie going smoothly and even rotating smoothly without any flickering or tearing but the speed of the text scroller goes way down. Is there anything i can do to speed it up ? Btw if i use 2d sprite the scrolling is still way slow.

What i am trying to do here is somewhat similar to some oldschool demos where u could control the text position and other neat stuff. I also use gamma to change colours over the whole screen but it does not work very well if changed more then once. with the buttons 3 and 4.

Text positions changes with 5 and 6 buttons.

Also i noticed that the movie has to be an MPEG1 movie or else the sprite wont display but the music will play.

Code: Select all

a$ = "Amiga and "
a$ + "C64 rulez for scrolling =)"
InitKeyboard()
InitMovie()
InitSprite()
InitSprite3D()

UsePNGImageDecoder() 
UseJPEGImageDecoder()
;OpenWindow(0, #PB_Ignore, #PB_Ignore, 1366, 768, "Scrolltext")
;OpenWindowedScreen(WindowID(0), 0,0,1366,768,0,0,0)
OpenScreen(1360, 768, 32, "Display System")
ChangeGamma(0,0,0,1) 
LoadMovie(0, "Procol.mpg")

LoadFont(0,"Arial",109)
LoadFont(1,"Impact",30)
result = LoadImage(#PB_Any,"Untitled3.png")
result2 = LoadImage(#PB_Any,"nclogo.jpg")
result3 = LoadImage(#PB_Any,"Untitled2.png")

Surface = CreateSprite(0, 256, 256, #PB_Sprite_Texture)
Surface2 = CreateSprite3D(0 , 0)

TextX = 1366
TextY = 0
Bild1 = 0
Bild2 = 0
Bild3 = 0
Bild4 = 0
Gamma = 0
TextRed = 1
Gam1 = 0 
Gam2 = 0  
Gam3 = 0
Gam4 = 1
box1 = 0
box2 = 0
PlayMovie(0, #PB_Movie_Rendered)
    
Sprite3DQuality(1)



Repeat
  
  TextRed = 1
  ClearScreen($402010)
  
    StartDrawing(ScreenOutput())
    
    ;StartDrawing(SpriteOutput(Surface))
    DrawImage(ImageID(result),0,0)
    DrawImage(ImageID(result),Bild1,Bild2)
    DrawImage(ImageID(result2),10+Bild3,20+Bild4)
    
    ;DrawImage(ImageID(result3),0,120)
     
      DrawingMode(#PB_2DDrawing_Transparent)
      DrawingFont(FontID(0))
      ChangeGamma(Gam1,Gam2,Gam3,Gam4)
      DrawText(TextX, 540+TextY, a$, RGB( 255, 255, 255 ) )
      DrawingFont(FontID(1))
      DrawText(10, 720,"Display System Version 0.1", RGB( 0, 0, 0 ) )
      
    Box(1366,705,0+Box1,10,RGB((255),(255),(255)))    
    ;Box(0,705,0+Box2,10,RGB((0),(0),(0))) 
    Box(0,540,0+Box2,10,RGB((0),(0),(0)))   
    StopDrawing()
    TextX -2
    Box1 -4
    Box2 +4
 
    
    If TextX < -2500
      TextX = 1366
    EndIf
    ExamineKeyboard()
    
    If KeyboardPushed(#PB_Key_D)
    Bild1 +2
    EndIf
    
    If KeyboardPushed(#PB_Key_A)
    Bild1 -2
    EndIf
    
    If KeyboardPushed(#PB_Key_W)
    Bild2 -2
    EndIf
    
    If KeyboardPushed(#PB_Key_S)
    Bild2 +2
    EndIf
    
     If KeyboardPushed(#PB_Key_Right)
    Bild3 +2
    EndIf
    
    If KeyboardPushed(#PB_Key_Up)
    Bild4 -2
    EndIf
     
    If KeyboardPushed(#PB_Key_Left)
    Bild3 -2
    EndIf
    
    If KeyboardPushed(#PB_Key_Down)
    Bild4 +2
 
    EndIf
    If KeyboardPushed(#PB_Key_1)
    Gamma +2
    ChangeGamma(Gamma,Gamma,Gamma,0)
    EndIf
    If KeyboardPushed(#PB_Key_2)
    Gamma -2
    ChangeGamma(Gamma,Gamma,Gamma,0)
    EndIf
    If KeyboardPushed(#PB_Key_3)
    Gam1 = 0 
  Gam2 = 255  
  Gam3 = 0
  Gam4 = 0
    EndIf
    If KeyboardPushed(#PB_Key_4)
    Gam1 = 0 
  Gam2 = 0 
  Gam3 = 255
  Gam4 = 0
    EndIf
    If KeyboardPushed(#PB_Key_5)
    TextY -2
    EndIf
    If KeyboardPushed(#PB_Key_6)
    TextY +2
    EndIf
    
      ;DisplaySprite(0, 0, 0)
      
Start3D() 

      RenderMovieFrame(0,Surface)
    DisplaySprite3D(0, 100, 100, 255)
    RotateSprite3D(0, x, 0)
    x+1
  ; ...
  Stop3D()
  FlipBuffers()

Until KeyboardPushed(#PB_Key_Escape)
Last edited by fusion_400 on Wed Jun 18, 2008 7:45 am, edited 1 time in total.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Smooth scrolling text like C64/Amiga how to do it in ba

Post by PB »

> the old Amiga and C64 demos where the textscroller was incredibly smooth

Don't forget that those demos were written in Assembly, and not Basic.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

I guess the prime reason was that they were tied into vertical sync, not that they were programmed in assembly.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

That too. :) My point was that you don't see demos like that done in Basic.
fusion_400
User
User
Posts: 22
Joined: Sun Jun 15, 2008 2:34 pm

Post by fusion_400 »

Do u people know if it is possible to get a simple mpeg1 320x240 movie and some scrolling text to run in fullspeed in purebasic. I have eliminated the flickering issue and the movie and the rotation is in full speed but the text is slowed down dramatically.

I supplied the code in a previous posting.
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

Depends on a lot of factors:

MPEG1/2/3/4 and other lossy modes are quite processor intensive (or video processor intensive in some cases), so it depends on the nature of the end user's hardware etc.

Remember that in the case of the c64 (and others, let's not forget!) they had absolute control of the video hardware, something that is almost impossible in a modern multitasking OS.

That being said, there are cases where it can be done (look at MAME running on a decent computer or even a C64 being emulated with CCS64, etc). Luckily, PB allows you to inject pure asm into your code if you have the knowledge to do so ;)

Russell
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

Have you ever looked what is available on this forum and on the purebasic, purearea, codearchiv... sites?

In lethal judgment for example, there's sometime more than three fullscreen parallal scrolls. What is a simple scrolltext in comparison?

In Purebasic, you have to find the right functions to do the job. Try between drawimage/drawsprite. Drawtext is slow! I've never used such a function for realtime fx!
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Post by Foz »

It very simple:
Use DrawText onto an image, and then scroll that image.

Rendering the text once is a lot less processor intensive than doing it every frame.
fusion_400
User
User
Posts: 22
Joined: Sun Jun 15, 2008 2:34 pm

Post by fusion_400 »

Foz wrote:It very simple:
Use DrawText onto an image, and then scroll that image.

Rendering the text once is a lot less processor intensive than doing it every frame.
Ok how do i convert DrawText to an image ? I am very new at this i am not a seasoned pro at programming. So i really appreciate any help i can get.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Smooth scrolling text like C64/Amiga how to do it in ba

Post by PB »

@fusion_400: See this thread for a smooth horizontal scroll:

http://www.purebasic.fr/english/viewtopic.php?t=19767

The demo is 404 from there though, but perhaps va!n can re-upload it for
you, if you PM him. I still have it but am not sure if I can redistribute it.
I don't really see why not though, so if he doesn't respond then I'll put it
somewhere for you.
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Post by Foz »

fusion_400 wrote:
Foz wrote:It very simple:
Use DrawText onto an image, and then scroll that image.

Rendering the text once is a lot less processor intensive than doing it every frame.
Ok how do i convert DrawText to an image ? I am very new at this i am not a seasoned pro at programming. So i really appreciate any help i can get.

Code: Select all

    StartDrawing(ImageOutput(ImageToDrawOn))
    DrawText(0, 0, stringtodraw$, RGB( 255, 255, 255 ) )
    StopDrawing()
fusion_400
User
User
Posts: 22
Joined: Sun Jun 15, 2008 2:34 pm

Post by fusion_400 »

I tried to get this to work with using imageoutput but i get a black screen only. When i used it in the other code the only thing that displayed was the sprite.

Code: Select all

InitSprite()
InitKeyboard()
ImageToDrawOn = CreateImage(#PB_Any, 1360, 768, 32)
OpenScreen(1360, 768, 32, "Display System")
LoadFont(0,"Arial",109)
Repeat
StartDrawing(ImageOutput(ImageToDrawOn))
 LineXY(10, 10, 490, 90 ,RGB(Random(255),Random(255),Random(255)))
DrawText(10, 720,"Display System Version 0.1", RGB( 0, 0, 0 ) )
;DrawImage(ImageToDrawOn,20,200)     
StopDrawing()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

You'll need a flipbuffers() in there somewhere and also need to display the image as well.
Post Reply