The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hfheatherfox07 on May 18, 2011, 09:04:04 PM

Title: Scrolling text flickers?
Post by: hfheatherfox07 on May 18, 2011, 09:04:04 PM
Hi,
When I tried to add Scrolling text to star-filed or star-burst the scrolling text flickers...any ideas why?

I tried both vertical and horizontal text scrolls , as well as with a static and with out....

P.S

I have lots of scrolling text examples but I still can't get the "Start trek"  effect were the scrolling text goes into space (comes to one point).... If anybody has an example like that ...I would appropriate it...   :bg
Title: Re: Scrolling text flickers?
Post by: qWord on May 18, 2011, 09:13:31 PM
write the text to the back buffer hmainDC after the stars has been drawn.
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on May 21, 2011, 04:15:22 PM
Quote from: qWord on May 18, 2011, 09:13:31 PM
write the text to the back buffer hmainDC after the stars has been drawn.


I am not so sure that I understand , but I will give it a try...
Title: Re: Scrolling text flickers?
Post by: dedndave on May 21, 2011, 11:59:27 PM
http://www.masm32.com/board/index.php?topic=16066.0

there are a number of forum threads that cover this
search for "flicker" or "CreateCompatibleDC"
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on May 22, 2011, 01:28:08 AM
Thanks,
It looks like "Flicker" is a common problem  :lol
I came a cross 4 pages on this issue

I also came across this for back buffer:
http://www.madwizard.org/programming/tutorials/mosaic/7

I will give these things a try....
Title: Re: Scrolling text flickers?
Post by: qWord on May 22, 2011, 01:39:25 AM
Quote from: hfheatherfox07 on May 22, 2011, 01:28:08 AMIt looks like "Flicker" is a common problem  :lol
...
I also came across this for back buffer:
exactly this technique is used by the program YOU have shown in your first post in this thread! All you need to change is the order of drawing, so that the text is drawn after the 'stars' has been drawn (to the back buffer hmainDC).
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on May 22, 2011, 08:39:19 PM
I understand what you are saying but I think I have 2 Problems that I do not know how to solve:

1. There are 2 "SetTimer" , even though they are written different I still can not get them to separate, the timing for the stars is faster than the scrolling text.... How can I separate the two? what I mean is if I erase one of them the whole thing still works??? If I erase the faster timer for the stars than both the stars and the text run at the slower speed of the scrolling text and vise versa ...

SetTimer for text:
mov TimerID,FUNC(SetTimer,hWnd,IDC_TIMER,SCROLLSPEED,NULL)

SetTimer for Stars:

invoke SetTimer, hWnd, TIMER1, 10, NULL

see : attempts  of starfield with dialog rsrc & Scroll Text.zip

2. here is the original text scroll that I used for this,  in line 201:
invoke FillRect,hmainDC,ADDR rScroll,rv(GetStockObject,TRANSPARENT) ; OPAQUE VS BLACK_BRUSH VS TRANSPARENT

I took out the black brush so you can see that the text does not copy transparent onto the screen ... how do I fix that....????

in line 171 of starfield2.asm I can fix that by changing "mov hdc,FUNC(GetDC,hWnd)"  to " mov chdc,FUNC(GetDC,hWnd)"  but than the scrolling text hits the top of the window and scrolls right back down ....  :dazzled:

Ahh (http://images.txtagif.com/gifs/0mNFIeMItuU.gif)
Title: Re: Scrolling text flickers?
Post by: qWord on May 22, 2011, 10:30:43 PM
there are several methods of solving your problem. However, in the attachment you will find the best solution (IMO) for displaying different animations in one graphic: it creates three memory DCs, where one is used for drawing the text and one for drawing the stars (=this is our background). This two layers are merged in the third DC using Alpha/Transparent blt. This DC is then copyed to the screen. Using this technique allows to quickly combine differently timed animations - However, as you surly can see, it need more system resources (not really hard for nowadays systems/graphic-cards)
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on May 22, 2011, 11:08:05 PM
Thanks I will take it apart tonight.... it seems to have the same problem too fast of a scroll and stars have the speed of the scroll, but I have not assembled it yet so That might be changeable ....

I was toying with the idea of creating a thread proc for the text like in the horizontal text scroll example that I posted
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on May 23, 2011, 12:11:32 AM
Any ideas how to fix the  Scroll Text Up Example_2a.zip   :(...just the scroll example?
Title: Re: Scrolling text flickers?
Post by: qWord on May 23, 2011, 12:55:54 AM
- erase hmainDC with some color and not with an hollow brush!
- invoke SetBkMode,hmainDC,TRANSPARENT
- draw the text and Blt it to the screen
- you are the owner of hmainDC: there is no need to endless reselect the font - the same applies for settings like the BkMode/Color
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on May 23, 2011, 01:22:59 AM
Quote from: qWord on May 23, 2011, 12:55:54 AM
- erase hmainDC with some color and not with an hollow brush!
- invoke SetBkMode,hmainDC,TRANSPARENT
- draw the text and Blt it to the screen
- you are the owner of hmainDC: there is no need to endless reselect the font - the same applies for settings like the BkMode/Color


I will give that a try , buy I purposely put Null brush instead of some color(so you can see the error), If you take that example and use "BLACK_BRUSH" every thing looks perfect , but when you add a picture to the background , you get that black (or what ever color was used to erase the background) scrolling on top of the picture (the text is not transparent on top of the picture)
I don't think I understated "- draw the text and Blt it to the screen"
isn't that what is done here:

BitBlt,hdc,0,0,WindowRect.right,WindowRect.bottom,hmainDC,0,0,SRCCOPY
invoke EndPaint,hWnd,addr ps


I am not clear with what you mean but I will mess with it tonight
Title: Re: Scrolling text flickers?
Post by: qWord on May 23, 2011, 01:43:55 AM
for me it works:
invoke SelectObject,hmainDC,rv(GetStockObject,BLACK_BRUSH)
.....
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
; erase DC
invoke BitBlt,hmainDC,0,0,WindowRect.right,WindowRect.bottom,hmainDC,0,0,PATCOPY

; draw something for testing purpose
invoke DrawFrameControl,hmainDC,ADDR WindowRect,DFC_BUTTON,DFCS_BUTTONPUSH
invoke SetTextColor,hmainDC,0ffh
invoke SetBkColor,hmainDC,0
invoke SetBkMode,hmainDC,TRANSPARENT
invoke DrawText,hmainDC,ADDR szWindowMsg,-1,ADDR rScroll,DT_CENTER + DT_TOP + DT_NOPREFIX + DT_NOCLIP 
invoke BitBlt,hdc,0,0,WindowRect.right,WindowRect.bottom,hmainDC,0,0,SRCCOPY
invoke EndPaint,hWnd,addr ps
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on May 27, 2011, 12:18:33 AM
Sorry about the late reply, yes you are right it works amazing .....( I did it a little different) :U

I also managed messing with the speeds of the scrolling text that you posted, that worked amazing too....

Thank you for all your help  :bg

Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 01, 2011, 07:25:42 PM
Hi qWord,

Any Idea how to make my scrolling text example that I posted in this thread  "Scroll Text Up Example_2a.zip"  do this:

http://www.megaupload.com/?d=5KJFUP0X

just click on the .HTML to view the video  :P

....and that assembly  you are right about it does crashes... I downloaded it the same day , and on this computer it worked...How ever when I got home on my computer it did not... Strange.... This computer on which it works is an XP as well , however  I have no admin privilege here I am a guest... I wonder if that makes a difference?

Appreciate all your help ....


Later on I plan on adding a moon an the star ship Enterprise to it all, so far I can not get the stars to go over the bitmaps, even if I use WM_PAINT to add the images.... :U
Title: Re: Scrolling text flickers?
Post by: ragdog on June 02, 2011, 12:26:56 PM
It crashed here under Win7
loc_401405:                             ; CODE XREF: sub_401329+113j
                         fist    [ebp+var_58]
                         fadd    st, st(1)
                         cmp     [ebp+var_58], edx
                         jnb     short loc_40143E
                         push    eax
                         push    edx
                         push    ecx
                         add     eax, [ebp+var_58]
                         cmp     eax, [ebp+var_70]
                         jnb     short loc_401446
                         mov     ecx, [ebp+var_6C]
                         add     eax, ecx
                         mov     al, [eax] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


DS:[00000257]=???
AL=57 ('W')
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 02, 2011, 10:24:59 PM
I was actually wondering what are the commands to make the scrolling text do that( appear to go off into the distance instead of up)....
Title: Re: Scrolling text flickers?
Post by: qWord on June 02, 2011, 11:04:52 PM
In the attachment an quick (and dirty) example using gdi+, which is an adaption from this C# example (http://www.codeproject.com/KB/GDI-plus/StarWarsStyleTextScroller.aspx). The magic function, that does the required matrix transformation, is GdipWarpPath() (http://msdn.microsoft.com/en-us/library/ms534039(v=vs.85).aspx).

qWord
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 02, 2011, 11:07:23 PM
Thanks I will have a look at it....  :bg
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 02, 2011, 11:14:44 PM
Also I found a collection in C++ for demo effects....Here:

http://demo-effects.sourceforge.net/

I would love to know how to do the "Jumping Scroller" and "Sine Scroller Variations" in MASM....

I have a sine scroll example in MASM but I do not like it http://comrade.ownz.com/sources/scroller.zip   :(
Title: Re: Scrolling text flickers?
Post by: qWord on June 03, 2011, 05:00:59 PM
Using gdi+ path-objects, you can create such effect by placing and transforming characters path's on arbitrary curves. What you need is some basic knowledge on vector and matrix calculations.
Some years back I've played a bit with it, and create an function allowing to place an string on an given path. However, currently I cant share this code and is also a bit buggy -  maybe I will step in again and create an lib or dll these days.
In the attachment an application showing this function in action.
Title: Re: Scrolling text flickers?
Post by: dedndave on June 04, 2011, 12:57:27 AM
i have a question along a related line...
each time WM_PAINT is recieved, i am using the following functions:
SetTextColor
SetBkColor
SetBkMode
SetTextAlign
SelectObject (font)
i am wondering if i need to do them each time, or only of one changes

the problem is that i am lacking a strong understanding of exactly what a device context is
may it be a different handle on different passes ?
once a setting or an object is selected for a device context, does it stay the same ?
the MSDN documents are not very clear on this subject   :P
Title: Re: Scrolling text flickers?
Post by: qWord on June 04, 2011, 01:33:22 AM
A DC is an structure that holds the current state of an drawing. So a DC have a current (selected) pen,brush,region,font,... and settings/attributes (BkColor,...)
The most importand member is the associated bitmap/display-area. For memory DC's (CreateDC/CompatibleDC) there is a bit map in what ever format - the DCs passed with WM_PAINT are mostly (according to the class style) so called display DCs, which represent a portion of screen.  There also printer and  information DC's.
AFAIK there is no guarantee, that the DC passed with WM_PAINT is allways the same. Also these DC is used by Windows, so that the configuration changes (selected objects). For memory DC's, which you own, you can select the objects once times.
Maybe also interesting in this context: Driver Development Part 6: Introduction to Display Drivers (http://www.codeproject.com/KB/system/driverdev6asp.aspx)
Title: Re: Scrolling text flickers?
Post by: Siekmanski on June 04, 2011, 05:15:15 AM
Hi hfheatherfox07

Just found an example of a sinescroller i did some years ago.
If you want the sources let me know.
Give me a week or so to find my old MASM DirectX7 sources of this sinus scroller.

Title: Re: Scrolling text flickers?
Post by: qWord on June 04, 2011, 10:44:17 AM
here some other very simple effect (GDI). It use BitBlt to move pixel-columns vertically from their original position according to current sine value.
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 04, 2011, 08:16:33 PM
Quote from: Siekmanski on June 04, 2011, 05:15:15 AM
Hi hfheatherfox07

Just found an example of a sinescroller i did some years ago.
If you want the sources let me know.
Give me a week or so to find my old MASM DirectX7 sources of this sinus scroller.



Please...  :P
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 04, 2011, 08:26:04 PM
Quote from: qWord on June 04, 2011, 10:44:17 AM
here some other very simple effect (GDI). It use BitBlt to move pixel-columns vertically from their original position according to current sine value.


I am trying to do examples that use rsrc.rc ....

any ways I was back on the Stanfield today... I got Starfield_rotation to work ... although you still need to define WindowH, and WindowW as numbers.... although if you have it as a secondary window (invoked off a button) ...it works perfect  :bg

I keep going back and forth between projects LOL....

I am starting SFX.EXE  I would like to create the same thing that Hutch used on his older versions of MASM installation.exe
I figured how to create .cab files using CABARC.EXE and CREATECAB.EXE but I can not create .cab file with actuall folders in it only .exe's and .dll's for some reason

I appreciate all these examples .... I will see how they work with rsrc.rc.....

Still no idea how to create the jumping sine .....

Title: Re: Scrolling text flickers?
Post by: Siekmanski on June 05, 2011, 03:45:04 PM
YES !! found it...  :bg

Here are the complete sources of "HTMLencoder".
changed the music for a smaller piece else it wouldn't fit in the file.
Most of the labels are written in Dutch, if there's something you don't understand you can always ask me.
( Or you can take a course in dutch language, hahahahaha  :lol )

Veel plezier.
Title: Re: Scrolling text flickers?
Post by: qWord on June 05, 2011, 08:45:06 PM
Quote from: hfheatherfox07 on June 04, 2011, 08:26:04 PMStill no idea how to create the jumping sine .....
what did you mean with jumping sine? (See the attachment).
Is your problem the mathematics or measuring and placement of characters (or both)?
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 05, 2011, 10:10:10 PM
Quote from: Siekmanski on June 05, 2011, 03:45:04 PM
YES !! found it...  :bg

Here are the complete sources of "HTMLencoder".
changed the music for a smaller piece else it wouldn't fit in the file.
Most of the labels are written in Dutch, if there's something you don't understand you can always ask me.
( Or you can take a course in dutch language, hahahahaha  :lol )

Veel plezier.

Thank you .... I will have a look at it...

And I always use Google translate http://translate.google.com/#

I always find sources in other languages, and then I translate it  :U
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 05, 2011, 10:12:12 PM
Quote from: qWord on June 05, 2011, 08:45:06 PM
Quote from: hfheatherfox07 on June 04, 2011, 08:26:04 PMStill no idea how to create the jumping sine .....
what did you mean with jumping sine? (See the attachment).
Is your problem the mathematics or measuring and placement of characters (or both)?

That is what I was looking to do.... If you don't mind me saying ...you seem like a very very good programmer, it will be many many years before I even catch up slightly..... ::)
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 06, 2011, 12:05:42 AM
Quote from: qWord on June 05, 2011, 08:45:06 PM
Quote from: hfheatherfox07 on June 04, 2011, 08:26:04 PMStill no idea how to create the jumping sine .....
what did you mean with jumping sine? (See the attachment).
Is your problem the mathematics or measuring and placement of characters (or both)?

Any chance of a source?  :(
Title: Re: Scrolling text flickers?
Post by: qWord on June 06, 2011, 03:25:07 AM
in the attachment an lib holding the function JmpSine(). A short description can be found in the include file.
(take care of used data types  :U)

qWord
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 07, 2011, 12:33:39 AM
Quote from: qWord on June 06, 2011, 03:25:07 AM
in the attachment an lib holding the function JmpSine(). A short description can be found in the include file.
(take care of used data types  :U)

qWord


Thanks this should keep me plenty busy trying to really understand the concept of what is making the sine jump and wave....  :dazzled:
Title: Re: Scrolling text flickers?
Post by: qWord on June 07, 2011, 01:22:46 AM
Quote from: hfheatherfox07 on June 07, 2011, 12:33:39 AMreally understand the concept of what is making the sine jump and wave....  :dazzled:
Sinusoidal waves (http://en.wikipedia.org/wiki/Wave#Sinusoidal_waves)
or
Sine wave (http://en.wikipedia.org/wiki/Sine_wave)
Title: Re: Scrolling text flickers?
Post by: dedndave on June 07, 2011, 08:16:05 AM
also good.....
http://en.wikipedia.org/wiki/Conic_section
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 09, 2011, 10:18:23 PM
Quote from: Siekmanski on June 05, 2011, 03:45:04 PM
YES !! found it...  :bg

Here are the complete sources of "HTMLencoder".
changed the music for a smaller piece else it wouldn't fit in the file.
Most of the labels are written in Dutch, if there's something you don't understand you can always ask me.
( Or you can take a course in dutch language, hahahahaha  :lol )

Veel plezier.

Thanks a lot...here is a translated version to English
Title: Re: Scrolling text flickers?
Post by: Siekmanski on June 10, 2011, 12:44:59 PM
Funny translation, hahaha  :bg :bg

QuoteInsert Quote
Quote from: Siekmanski on June 05, 2011, 05:45:04 pm
YES !! found it... 

Here are the complete sources of "HTMLencoder".
changed the music for a smaller piece else it wouldn't fit in the file.
Most of the labels are written in Dutch, if there's something you don't understand you can always ask me.
( Or you can take a course in dutch language, hahahahaha   )

Veel plezier.


Thanks a lot...here is a translated version to English
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 18, 2011, 07:02:16 PM
Quote from: Siekmanski on June 10, 2011, 12:44:59 PM
Funny translation, hahaha  :bg :bg

QuoteInsert Quote
Quote from: Siekmanski on June 05, 2011, 05:45:04 pm
YES !! found it... 

Here are the complete sources of "HTMLencoder".
changed the music for a smaller piece else it wouldn't fit in the file.
Most of the labels are written in Dutch, if there's something you don't understand you can always ask me.
( Or you can take a course in dutch language, hahahahaha   )

Veel plezier.


Thanks a lot...here is a translated version to English

It is all Google Translate ......
http://translate.google.com/#   

By the Way here is the version with your original song... I managed compressing the song a little..... and took out 21 instruments that were not used ......

http://www.megaupload.com/?d=1S3ZWV2Q
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 20, 2011, 08:41:54 PM
Quote from: Siekmanski on June 05, 2011, 03:45:04 PM
YES !! found it...  :bg

Here are the complete sources of "HTMLencoder".
changed the music for a smaller piece else it wouldn't fit in the file.
Most of the labels are written in Dutch, if there's something you don't understand you can always ask me.
( Or you can take a course in dutch language, hahahahaha  :lol )

Veel plezier.


Here is a poor attempt to get just the sinescroller... I don't know what to do to initialize the scrolling??? any Ideas???...what don't I need In there???
Also I have a bunch of fonts ... that If I ever get this thing going I would like to use....but I can not find were you set the RGB (255,0,255) as the Transparent color for the font picture, also were did you set the font picture order??? what I mean is not all fonts will have certain Characters in them  If you try to use any of the fonts that I have you get misspellings .... where did you set:

fonts db " ? " ' ! # @% $ ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890", 0

mine are in a different order ...are they in one of the libs??
Title: Re: Scrolling text flickers?
Post by: Siekmanski on June 22, 2011, 12:18:49 PM
Hi hfheatherfox07

The format is just "ASCII" format starting with "space" == (dec)32
In RadAsm you can find an "ASCII Table" on the right side of the toolbar.
Compare it with the picture and you'll understand it.

In the routine "Sinus_scroller" you can find this piece of code:


    sub    eax,32        ; ASCII value - 32   ( all values below 32 are used to control the speed etc. )
    shl    eax,5         ; chacracters are 32 pixels ( width and higth ) picture is 256 pixels  by 256 pixels ( so, 256/32=8 characters in one row )
    mov    ecx,eax       ; copy character start
    and    ecx,0ffh      ; calculate X pos
    and    eax,0ff00h    ; calculate Y pos
    shr    eax,3         ; 8 characters in one row to the next row

    mov    rcScrollFont.left,ecx  ; postion in font picture
    mov    rcScrollFont.top,eax


So, if you want to write a character just substract the value of the character with 32 and you get the right position in de font picture.

This is a fast way of getting the right position in the fontpicture.  :bg
But it only works on 256 pixel wide pictures with 32 pixel wide fonts.
( you can change the code to 8*8, 16*16 wide fonts if you want.)

The function "Set_TransparantColor" is in "common\DD_util.asm" and sets that color as the transparent color.

greetings Siekmanski
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 23, 2011, 07:11:40 PM
Quote from: Siekmanski on June 22, 2011, 12:18:49 PM
Hi hfheatherfox07

The format is just "ASCII" format starting with "space" == (dec)32
In RadAsm you can find an "ASCII Table" on the right side of the toolbar.
Compare it with the picture and you'll understand it.

In the routine "Sinus_scroller" you can find this piece of code:


    sub    eax,32        ; ASCII value - 32   ( all values below 32 are used to control the speed etc. )
    shl    eax,5         ; chacracters are 32 pixels ( width and higth ) picture is 256 pixels  by 256 pixels ( so, 256/32=8 characters in one row )
    mov    ecx,eax       ; copy character start
    and    ecx,0ffh      ; calculate X pos
    and    eax,0ff00h    ; calculate Y pos
    shr    eax,3         ; 8 characters in one row to the next row

    mov    rcScrollFont.left,ecx  ; postion in font picture
    mov    rcScrollFont.top,eax


So, if you want to write a character just substract the value of the character with 32 and you get the right position in de font picture.

This is a fast way of getting the right position in the fontpicture.  :bg
But it only works on 256 pixel wide pictures with 32 pixel wide fonts.
( you can change the code to 8*8, 16*16 wide fonts if you want.)

The function "Set_TransparantColor" is in "common\DD_util.asm" and sets that color as the transparent color.

greetings Siekmanski


Sorry no clue how to initiate "Sinus_scroller proc" with out crashing.... it seems that this little demo is very intertwined .... you almost need all the procs that you wrote including size window, why is that needed ??... No luck getting just a black screen with scrolling text :(
Title: Re: Scrolling text flickers?
Post by: Siekmanski on June 24, 2011, 05:50:23 PM
Your wish is my command.............  :bdg

OK, stripped the source at your wishes.
Now it's your turn to change the font, and it's size.

Quoteyou almost need all the procs that you wrote including size window, why is that needed ??...

It has no need but,  the user can stretch the screensize to the size they like.  ( you can remove it if you want. )

Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 27, 2011, 02:23:51 AM
Quote from: Siekmanski on June 24, 2011, 05:50:23 PM
Your wish is my command.............  :bdg

OK, stripped the source at your wishes.
Now it's your turn to change the font, and it's size.

Quoteyou almost need all the procs that you wrote including size window, why is that needed ??...

It has no need but,  the user can stretch the screensize to the size they like.  ( you can remove it if you want. )



Thank you so much ....
but I am at a loss about the 2 things still....

1. the ASCII table ( I am well familiar with ASCII to HEX to DEC conversion) but I do not see any were where you added the character order...
how did you declare the character pattern?...most pictures of fonts are not 8 rows by 8 columns
also I realize from your
2.previous post that the transparent color is set in :
The function "Set_TransparantColor" is in "common\DD_util.asm" and sets that color as the transparent color.

but I do not see a reference there for (255,0,255)  there.... ???

at the risk of looking dumb I just don't see it  :(

were in the program would I change the picture-font background to black as transparent for example??

and were would I declare the character order and how.... ????

Thank you and sorry again that I don't see it
Title: Re: Scrolling text flickers?
Post by: Siekmanski on June 27, 2011, 07:42:23 AM
You have to rearrange your fontpicture according to the "ASCII TABLE"

ASCII TABLE 32 - 96 ( values used in the font picture )
8 characters per row as in the "ASCII TABLE" starting with space ( value 32 )

   ! " # $ % & '   ; 32 - 39
( ) * + , - . /   ; 40 - 47
0 1 2 3 4 5 6 7   ; 48 - 55
8 9 : ; < = > ?   ; 56 - 63
@ A B C D E F G   ; 64 - 71
H I J K L M N O   ; 72 - 79
P Q R S T U V W   ; 80 - 87
X Y Z [ \ ] ^ _   ; 88 - 95

All characters are 32 * 32 pixels ( fontpicture has to be 256 * 256 )

Let's say we want to write "M"
"M" has the value 77

We need to calculate the offset of "M" in the fontpicture to cut it out and copy it in
the scrollscreen.

First substract 32 from 77 because our characters start with "SPACE" which is equal to 32

Let's do the calculations:

77 - 32 = 45
45 * 32 (character width) = 1440 ( keep a copy of 1440 to calc X position )
Y position == 1440 and 0ff00h = 1280 / 8 (characters in a row) = 160
X position == 1440 and 0ffh = 160

Cut out the M at left-top pixelposition 160,160 in the font picture ( 32 * 32 pixels )

all is done in this piece of code:

    sub    eax,32        ; ASCII value - 32   ( all values below 32 are used to control the speed etc. )
    shl    eax,5         ; chacracters are 32 pixels ( width and higth ) picture is 256 pixels  by 256 pixels ( so, 256/32=8 characters in one row )
    mov    ecx,eax       ; copy character start
    and    ecx,0ffh      ; calculate X pos
    and    eax,0ff00h    ; calculate Y pos
    shr    eax,3         ; 8 characters in one row to the next row

    mov    rcScrollFont.left,ecx  ; postion in font picture
    mov    rcScrollFont.top,eax

   etc......


; Initialisation of the background color and de tranparent color are done here:

Load_AllPictures proc

   invoke   Load_Picture,SinusFont,addr g_pSinusFont

   mov      eax,dwWindow_Width
   add      eax,32
   invoke   Create_Surface,eax,32,addr g_pDDSScrollScherm

   mov      ddBack_bltfx.dwFillColor,RGB(0,0,64) ; set the background color of the scrollscreen and the backbufferscreen ( they use the same struct )
   coinvoke g_pDDSScrollScherm,IDirectDrawSurface7,Blt,NULL,NULL,NULL,DDBLT_COLORFILL or DDBLT_WAIT,addr ddBack_bltfx

   invoke   Set_TransparantColor,g_pDDSScrollScherm,RGB(255,0,255) ; set the transparent fontcolor ( in this case it's pink )

   etc......

RenderDD proc hwnd:DWORD

;  clear backbuffer with your background color....
   coinvoke g_pDDSBack,IDirectDrawSurface7,Blt,NULL,NULL,NULL,DDBLT_COLORFILL or DDBLT_WAIT,addr ddBack_bltfx

   invoke   Sinus_scroller

   etc......




If you want to use other fonts with other offsets you need to make a look up table.....
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 28, 2011, 12:47:28 AM
Thank you Siekmanski ....and I really appreciate the time that you took to explain this to me.... but what I was asking is were do you put the order of the font pictures???

it is not going to look like the ASCII table .... If you look at my previous post on the same page you will see a fonts.zip , the fonts pictures are 10 rows by 6 columns , and others are different again.... you can not calculate that... were is the order ???

http://www.masm32.com/board/index.php?action=dlattach;topic=16710.0;id=9383
Title: Re: Scrolling text flickers?
Post by: Siekmanski on June 28, 2011, 11:15:25 AM
As I told you, I don't put the order of the font pictures anyware.
You have to rearrange your fontpicture according to the "ASCII TABLE"
( cut and paste your font order in a paint program to the ASCII order )

Or make a look up table of the offsets in your fontpicture and make your own orders.

PICTURE THIS !!!  :bg
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on June 28, 2011, 07:45:24 PM
Quote from: Siekmanski on June 28, 2011, 11:15:25 AM

You have to rearrange your fontpicture according to the "ASCII TABLE"
( cut and paste your font order in a paint program to the ASCII order )


OK thank you....
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on July 03, 2011, 05:00:12 PM
Quote from: qWord on May 22, 2011, 10:30:43 PM
there are several methods of solving your problem. However, in the attachment you will find the best solution (IMO) for displaying different animations in one graphic: it creates three memory DCs, where one is used for drawing the text and one for drawing the stars (=this is our background). This two layers are merged in the third DC using Alpha/Transparent blt. This DC is then copyed to the screen. Using this technique allows to quickly combine differently timed animations - However, as you surly can see, it need more system resources (not really hard for nowadays systems/graphic-cards)


I have a quick question..... I love your idea with the layers, it is the best ..... does it have to be only 2 layers or can you add more for a bitmap for example?

Here we merge 2 layers .... are more possible or is there a limit?

;/* merge layer 1 & 2 */
;/* copy stars to main-buffer */
invoke BitBlt,hmainDC,ps.rcPaint.left,ps.rcPaint.top,esi,edi,hLayerDC2,ps.rcPaint.left,ps.rcPaint.top,SRCCOPY
 
Title: Re: Scrolling text flickers?
Post by: qWord on July 03, 2011, 05:23:47 PM
Quote from: hfheatherfox07 on July 03, 2011, 05:00:12 PMdoes it have to be only 2 layers or can you add more for a bitmap for example?

Here we merge 2 layers .... are more possible or is there a limit?
the number of layers is limit by available memory. However, each additional layer increase the time, needed for merging the final image. Also, if there are many animations, you should think about a strategy where and when to merge the layers. The simplyest would be to merge the corresponding region immediately before copying to the screen, but this increase the CPU usage. An other technique is to merge the final image using an timer e.g. 100 timers per second (this may also required to record all regions that need to be update/merge).
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on July 03, 2011, 05:25:41 PM
I will give it a try, I want to add image by loading it to a different layer ....
Title: Re: Scrolling text flickers?
Post by: Siekmanski on July 04, 2011, 07:58:50 AM
Why don't you do it all with Direct3D or OpenGL ?
You can switch between 2D and 3D in a snap ( or only use it for 2D ), paint everything in a backbuffer at once and then present it all in the frontbuffer.
You can make use of all the tricks then such as Alpha, Depth buffer etc.
And it's as difficult as you make it yourself ......
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on July 06, 2011, 02:03:14 AM
@ Siekmanski

Now I remember when I was asking you about font structure were I saw it ... It goes like this ....

fTable db ' ABCDEFGHIJKLMNOPQRSTUVWXYZ'
       DB '0123456789:;/-().,?!"',27H,'#@',0
t_sz =$-fTable 


I realized Today while looking through my codes that I had this LOL  :dazzled:


Do you think your sine scroller  would work like this ( I have not tried yet)? here is a text scroller....
Check this out....

Title: Re: Scrolling text flickers?
Post by: Twister on July 06, 2011, 02:24:45 AM
Use Triple Buffering!

http://www.anandtech.com/show/2794 (http://www.anandtech.com/show/2794)
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on July 06, 2011, 03:09:34 AM
Quote from: Horton on July 06, 2011, 02:24:45 AM
Use Triple Buffering!

http://www.anandtech.com/show/2794 (http://www.anandtech.com/show/2794)


Never seen a Triple buffering example used this way....never even seen a triple buffering example
Title: Re: Scrolling text flickers?
Post by: Siekmanski on July 06, 2011, 03:31:52 PM
Yes, you can make my routine working with a font table but,
why use a lookup table and a parser if the fonts have the same height and width ?
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on July 17, 2011, 12:47:36 AM
Quote from: qWord on June 06, 2011, 03:25:07 AM
in the attachment an lib holding the function JmpSine(). A short description can be found in the include file.
(take care of used data types  :U)

qWord


HI, I just realized , did you make the LibSinText.lib and LibSinText.inc your self?

do you have the asm?
Title: Re: Scrolling text flickers?
Post by: qWord on July 17, 2011, 01:35:27 AM
Quote from: hfheatherfox07 on July 17, 2011, 12:47:36 AMdid you make the LibSinText.lib and LibSinText.inc your self?
yes
Quote from: hfheatherfox07 on July 17, 2011, 12:47:36 AMdo you have the asm?
you won't be happy with it, because I used my own macros for the mathematics. (I'm currently working on realeasing them here)
Title: Re: Scrolling text flickers?
Post by: qWord on July 17, 2011, 03:54:02 AM
source attached - as said, I'm currently working on a release of the macros, which will come the next days (or weeks).
Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on August 12, 2011, 11:37:27 PM
Quote from: qWord on May 22, 2011, 10:30:43 PM
there are several methods of solving your problem. However, in the attachment you will find the best solution (IMO) for displaying different animations in one graphic: it creates three memory DCs, where one is used for drawing the text and one for drawing the stars (=this is our background). This two layers are merged in the third DC using Alpha/Transparent blt. This DC is then copyed to the screen. Using this technique allows to quickly combine differently timed animations - However, as you surly can see, it need more system resources (not really hard for nowadays systems/graphic-cards)


I like your idea and I have being using it since on different stuff .... here is one that I am stuck with .... inside TEMPORARY.zip

you will find 5 folder ... in the one called TEMPORARY WORK... if you run that you will find that the scrolling text only works if you hold the cursor down on the window frame???  :'(

example 4 the scrolling text works but the rest freezes ???

any ideas???? :(

Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on August 13, 2011, 02:40:59 AM
@ qWord I am beginning to think that the problem is with the dialog -WndProc PROC ... your method seems to work fine with every thing that I tried using just a WndProc PROC dialog ...
This starfiled if you remember I converted from a full screen, and I use a different method a WinMain proc and a WndProc... I was unsuccessful in just using a WndProc and a simple:
INVOKE DialogBoxParam, hInstance, IDD_DLG1 , NULL, ADDR WndProc, 0
INVOKE ExitProcess, 0

Do you think you can give that a try? I think that would solve this problem ... I tried for days and this was the only way to get this starfiled to work with a rsrc.rc  ::)

Title: Re: Scrolling text flickers?
Post by: qWord on August 13, 2011, 03:39:26 PM
hi,

it is really disappointing to see such code ...
- there was a lot of useless code
- useless/unused global variables
- global variables that could (and should) be local
- handle leaks
- usage of uninitialized variables (hDlg) -> AFAIKS this was the reason why the text doesn't scroll.
- the stars are only visible because you invalidate the window in each iteration of the message loop (!) and because they are drawn while handling WM_PAINT. This is not the idea of using timers and layers: you drawing interval is controlled by a timer (WM_TIMER, timer-ID)  and the layers are only combined while handling WM_PAINT.

(I've used a resource ID in the call to CreateDialogParam -> you must change this to get it work)

Title: Re: Scrolling text flickers?
Post by: hfheatherfox07 on August 14, 2011, 05:31:37 PM
Thanks qWord ...

I had no idea how to handle the actual star creation.... did not realize that you can put them in a DrawStars proc .....I kept adding them to WM_TIMER

I am going to have to compare the one you made with my bad once to figure out  all the mistakes that I made and understand them.....

Thank you again  :bg