Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: Pot Noodle on September 03, 2011

Title: Old Amiga Effect Please
Post by: Pot Noodle on September 03, 2011
Hi Guys, was wondering if anyone can help with this effect I have been trying to produce.
I can remember doing this years ago with AMOS Pro and it was easy to do then
But now I am using BlitzMax and I am wondering if it is even possible with Blitz!
I have attached a pic to show you what I mean, It's the colour in the background showing through the font
I have tried SetMaskcolor() but it kind of works but I can still see the background on screen.
Thanks
Title: Re: Old Amiga Effect Please
Post by: va!n on September 03, 2011
You mean the scroller with the tinted background copperlist effect, right? I am not really sure how to code, but if you draw the font pixel by pixel, i would use a mask layer (black == background black, 1 == your font (white)... On Another buffer i would create/use the copperlist (gradient)... if you draw now pixel by pixel, you have just to check on the mask if there is the color white and save its pixel coordinate .... Now just pick the color from the given pixel coordinate on the gradient and draw it to your final screen.

If you want do this effect without drawing pixel by pixel, i have no real idea for good performance. I have one idea but that would really suxx. Good luck
Title: Re: Old Amiga Effect Please
Post by: Hotshot on September 03, 2011
I used to do AMOS Pro back in 1992  ;D and Old Amiga Effect is Great  ;D
Title: Re: Old Amiga Effect Please
Post by: zawran on September 03, 2011
I have used the method that Vain mentions where you have an array with the "copper" colors and depending on where on y-axis you are plotting pixels in the characters you pick the color from that array. It worked just fine and I cannot really think of another smarter way of doing it right now.
Title: Re: Old Amiga Effect Please
Post by: Pot Noodle on September 03, 2011
Cheers guys for your speedy replies, But I have sorted it now works great  :bananaphallus:
Title: Re: Old Amiga Effect Please
Post by: Shockwave on September 03, 2011
How did you manaeg to do it mate?
Title: Re: Old Amiga Effect Please
Post by: Jim on September 04, 2011
On my CDI demo, if I'd checked the row colour for every pixel I plotted it would have been tricky and probably slow.  Instead, I plotted everything (the stars) in white, then applied the colouring as a second pass over the pixels. In fact, that is what the Amiga programmers did with the copper effectively supplying the second pass.

Jim
Title: Re: Old Amiga Effect Please
Post by: Pot Noodle on September 04, 2011
Thats what I was thinking Jim, Here is the source so anyone play around with it, have fun.

Code: [Select]
' // Sine Wave Scroller by Shockwave, Adapted by P0T N00DLE.

SetGraphicsDriver (GLMax2DDriver(), GRAPHICS_BACKBUFFER | GRAPHICS_STENCILBUFFER | GRAPHICS_ALPHABUFFER)

Const xRes = 800' Screen Width
Const yRes = 600' Screen Height

    Graphics xRes, yRes, 32, 60

'// Setup our mask color Black.
SetMaskColor(0, 0, 0)

'// Load the font
Global Font = LoadAnimImage("sfont16.bmp", 1, 16, 0, 944, MASKEDIMAGE)

'// Load the background image.
Global Background:TImage = LoadImage("background.png")

Global ScrollText:String           ' // String to hold the text.
Global Tpos:Int   ' // Position in text string.
Global ScrlPos:Int   ' // Scroll Offset.
Global Sineadd:Int

ScrollText ="                                                      "
ScrollText = ScrollText + "Just a small example of how to make a colourfull scroll routine...      "
ScrollText = ScrollText + "The Scroll routine was done by shockwave, the rest was my fault!      Wrap! "
ScrollText=ScrollText+"                                                     "

ScrollText = Upper(ScrollText)     ' // Convert to uppercase
        Tpos = 1   ' // Position in string
ScrlPos = 0   ' // ScrollOffset
Sineadd = 0

' // Start of the Opengl stuff.
' // Look these up on the net as thay can be a bit long winded.
glEnable(GL_STENCIL_TEST)
glDepthMask(GL_FALSE)
glStencilMask($ffffff)
SetBlend SOLIDBLEND
   
' // Main loop.
Repeat

Cls
' // more Opengl
glClearStencil(0)
glClear(GL_STENCIL_BUFFER_BIT)
glDisable(GL_STENCIL_TEST)

Sineadd:-2

glEnable(GL_ALPHA_TEST)
glEnable(GL_STENCIL_TEST)
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE)
glStencilFunc(GL_ALWAYS, $ffffff, $ffffff)

Do_Scroller()   ' // Call scroll function

glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)
glStencilFunc(GL_EQUAL, $ffffff, $ffffff)
glDisable(GL_ALPHA_TEST)

DrawImage Background, 0, 0' // Draw the background.

Flip(-1)       ' // Swap buffers

Until KeyDown(KEY_ESCAPE)
   
EndGraphics
End

Function Do_Scroller()
ScrlPos:+2            ' // Move the scroll offset.
If ScrlPos > 16 Then            ' // If the text has scrolled more than the char width, ..
   ' // reset scroll pointer and advance text pointer
ScrlPos:-16
Tpos:+1
   ' // Make sure that the text pointer hasn't gone out of bounds
If Tpos > Len(ScrollText) - 52 Then Tpos = 1
End If
Local DrawPos:Int
Local TextAdd: Int
Local Letter:  Int
Local IL: Int
TextAdd = 0    ' // Step to different letters
DrawPos = (-16) - ScrlPos    ' // This is the current drawing position

        Repeat    ' // Draw letters until we go off the screen.
Letter = (Asc(Mid(ScrollText, (Tpos + TextAdd), 1)) - 32) * 16
For IL = 0 To 15
DrawImage Font, DrawPos + IL, 250 + (40 * Sin(Sineadd + Drawpos + IL)), Letter + IL
Next
TextAdd:+1
DrawPos:+16
Until DrawPos >= xRes

End Function

[Edit - Code tags added - Shockwave]
Title: Re: Old Amiga Effect Please
Post by: Hotshot on September 04, 2011
Good Karma 1+ for showing how it made but there is two things missing....Fonts and Background pic :)
Title: Re: Old Amiga Effect Please
Post by: Shockwave on September 04, 2011
Thanks for posting your solution :)

using blending and stencils is a really nice way of doing it.
Title: Re: Old Amiga Effect Please
Post by: Pot Noodle on September 04, 2011
HotShot The font + Background pic, Remember these are only for testing the pic could made smaller.
Title: Re: Old Amiga Effect Please
Post by: Hotshot on September 04, 2011
Thanks Pot Noodle and when I run the program and it gone way Faster as it is impossible to read it.....I guess it need Delta Timing to make sure it run the same on every pc otherwise on one pc will go too fast and other might have different speed pc....


It is very good on what You have done :)
Title: Re: Old Amiga Effect Please
Post by: Pot Noodle on September 05, 2011
Ya no problem, Like I said it was just a test to see if I could reproduce the effect, whats more I now know how to
Reproduce another effect that I was after from the same code, I will be using it in my next intro.
Title: Re: Old Amiga Effect Please
Post by: Hotshot on September 05, 2011
To slow the scolling fonts down and I would do this

delay 25 ; which slow the fonts down :) but not sure about on every computer thought :)


Title: Re: Old Amiga Effect Please
Post by: Pot Noodle on September 06, 2011
No that's no good, all you are doing is pausing the program take a look at delta timing.