is this possible ??

BlitzMax Forums/BlitzMax Programming/is this possible ??

wad(Posted 2014) [#1]
i am looking for a way to flash text but leave it flashing whilst the program does other things a bit like the old Spectrum used to do

i know the spectrum flash was run under interrupt via the rom but could this be possible in blitzmax ???

Lee


dan_upright(Posted 2014) [#2]
Probably doable by hooking flip. From the docs:
'This function will be automagically called every Flip
Function MyHook:Object( id,data:Object,context:Object )
	Global count
	
	count:+1
	If count Mod 10=0 Print "Flips="+count
	
End Function

'Add our hook to the system
AddHook FlipHook,MyHook

'Some simple graphics
Graphics 640,480,0

While Not KeyHit( KEY_ESCAPE )

	Cls
	DrawText MouseX()+","+MouseY(),0,0
	Flip

Wend



wad(Posted 2014) [#3]
cheers for that dan :)

i see where your coming from but i know its like a nostalgia thing but like the speccy it also used inverse to flash the text like a on / off idea

thats what i mean

:)


dan_upright(Posted 2014) [#4]
Yeah, just put your text drawing code in the hook function, have it draw a rectangle and then some text on top and every second or so, swap the rectangle/text colours.


wad(Posted 2014) [#5]
your idea worked a treat but as the program progressed the flips speed-ed up its not constant nearly what i want but not quite there

someone actually wrote a spectrum emulator on blitz i wonder how they emulated the the flash aspect

would be interesting to see

lee


dan_upright(Posted 2014) [#6]
Don't swap the colours based on how many flips have happened, when you swap the colours, use Millisecs().
'start of program
FlashTime = Millisecs()
FlashInterval = 1000 * 2 'replace the 2 with the number of seconds between flashes

'every flip
if Millisecs() > FlashTime + FlashInterval then
    'swap colours and do
    FlashTime = Millisecs()
endif



Derron(Posted 2014) [#7]
Also take care of having a constant "flip amount per second" (aka "FPS") - else you will have dynamically adjusted flash times.

You could also have a timer based approach - this changes values according to a timer ticking ("labelOn = true/off"). Each time you draw the scene you then "if labelOn then Drawtext(label,...)".


bye
Ron


Kryzon(Posted 2014) [#8]
I agree with Derron, though I would add that you need to use a modified timer for toggling the cursor "draw" flag, as you usually have a standard timer used for emitting rendering events.

You can use this...
http://www.blitzbasic.com/codearcs/codearcs.php?code=3138

...in the following manner:




wad(Posted 2014) [#9]
wow guys cheers for the response , i will look into it and see what i can come up with

its a shame i cant just create a gif and let blitz display it in the main loop i am in

but that seems long winded for one little gif

lol

cheers

lee


wad(Posted 2014) [#10]
i tried the above code only to get this

Unable to convert from '<unknown>' to 'TTimer'

that was from the Tcallbacktimer file

lee


Kryzon(Posted 2014) [#11]
On what line is that happening? It doesn't happen on mine.

Are you sure that the example code is one separate file that imports 'TCallbackTimer.bmx?' Because no usage of TTimer is made in that import.


wad(Posted 2014) [#12]
its in here

'; ID: 3138
'; Author: Kryzon
'; Date: 2014-07-20 02:26:53
'; Title: Callback Timer
'; Description: A modified BRL.Timer Object that on each tick calls a BlitzMax Function that you specify.

Import BRL.Timer

Type TCallbackTimer

	Method Ticks:Int()
		Return _ticks
	End Method
	
	Method Stop()
		If Not _handle Return
		bbTimerStop _handle,Self
		_handle=0
		_func=Null
		_data=Null
	End Method


it stops on the line bbtimerstop _handle,self when compiling

cheers


wad(Posted 2014) [#13]
i am using a mac pro (but i don't think that will make a difference )

will it ??

Lee


Kryzon(Posted 2014) [#14]
Oh, I realized what is the error. This was my oversight, I apologize.

You need to modify your BlitzMax/mod/brl.mod/timer.mod/timer.bmx file.
There's the following:
Extern
Function bbTimerStart( hertz#,timer:TTimer )
Function bbTimerStop( handle,timer:TTimer )
End Extern
Change the "timer:TTimer" parameter to this:
Extern
Function bbTimerStart( hertz#,timer:Object )
Function bbTimerStop( handle,timer:Object )
End Extern
You changed it to be of type "Object." It still works the same, but now it will accept other types of object (such as that "callback timer").


wad(Posted 2014) [#15]
yes it worked great cheers

Lee B