[futurebasic] Re: [FB] suggestion sought

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2011 : Group Archive : Group : All Groups

From: Michele Neri <nerimic@...>
Date: Tue, 1 Mar 2011 21:49:30 +0100
Edwards,
 try the following code, based on an old example. It fails on Intel
machine but it's fine on my PPC "lamp" iMac.
It seems that the undocumented IOFBBeamPosition function is not
working on Intel.

Michele.




include "Rntm Lite.incl"

include library "IOKit/graphics/IOGraphicsLib.h"

#if ndef _DEFINEDINCARBON

#define io_connect_t as ptr
#define IOReturn as kern_return_t

toolbox fn IOPSAllocateBlitEngine( io_connect_t framebuffer, ptr
blitterRef, int * quality) = kern_return_t
toolbox fn IOFBBeamPosition( ptr blitterRef, UInt32 options, SInt32 *
position ) = kern_return_t
toolbox fn IOPSBlitFill( ptr blitterRef, int dst_x, int dst_y, int
width, int height, int data ) = kern_return_t
toolbox fn IOPSBlitIdle( ptr blitterRef) = kern_return_t

#endif

local fn GetIterator(serviceName as str255, ikey$, ivalue$,
matchingServices as ^io_iterator_t )

dim as kern_return_t          kernResult
dim as mach_port_t           masterPort
dim as CFMutableDictionaryRef classesToMatch
dim as CFStringRef            key, value

// Returns the mach port used to initiate communication with IOKit.
kernResult = fn IOMasterPort( _MACHPORTNULL, @masterPort )
long if ( _KERNSUCCESS != kernResult )
print "IOMasterPort failed"
exit fn
end if

'setting of the Service Name
fn FBPStr2CStr( serviceName ) // -> CString
classesToMatch = fn IOServiceMatching( @serviceName )

// filter of the list  with the service's class name to match
long if ( classesToMatch == _nil )
kernResult = _KERNFAILURE
print "IOServiceMatching returned NULL dictionary"
exit fn
xelse
key   = fn CFStringCreateWithPascalString( 0, ikey$,   _kCFStringEncodingASCII )

value = fn CFStringCreateWithPascalString( 0, ivalue$, _kCFStringEncodingASCII )
long if ( key == 0 ) or ( value == 0 )
kernResult = _KERNFAILURE
print "CFStringCreateWithPascalString failed"
exit fn
end if

fn CFDictionarySetValue( classesToMatch, key, value )
fn CFRelease( key )
fn CFRelease( value )
end if

// This creates an io_iterator_t of all instances of our drivers class
that exist in the IORegistry.
kernResult = fn IOServiceGetMatchingServices( masterPort,
classesToMatch, #matchingServices )
if ( _KERNSUCCESS != kernResult ) then print
"IOServiceGetMatchingServices failed"

end fn = kernResult
'~'1

dim as long   loop
dim as SInt32 position

dim as io_iterator_t  Iterator
dim as io_object_t    Service
dim as int            quality
dim as ptr            blitterRef

dim as kern_return_t    kernResult
dim as long w, h, bps, i

long if ( fn GetIterator( "IOFramebuffer", "IONameMatched", "display",
@Iterator ) == _noErr )

// Get the first item in the iterator.
Service = fn IOIteratorNext( Iterator )

while ( Service != 0 )

print "Service: "; Service
kernResult = fn IOPSAllocateBlitEngine( Service, @blitterRef, @quality)
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "IOPSAllocateBlitEngine failed"
xelse
print "Accelerator Service Blitter Ref: "; blitterRef
print "Accelerator Service Quality: "; quality


'blocks the access to the display from other applications
kernResult = fn CGDisplayCapture(0)
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "CGDisplayCapture failed"
end if

w = fn CGDisplayPixelsWide(0)
h = fn CGDisplayPixelsHigh(0)
bps = fn CGDisplayBitsPerSample(0)

for i = 0 to 2^bps
loop = 0
do
kernResult = fn IOFBBeamPosition( blitterRef, 0, @position )
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "IOFBBeamPosition failed"
end if
loop++
until (position > h) or ( loop > 10000 )
// IOFBBeamPosition doesn't seem working on Intel we need a way to
escape the loop

kernResult = fn IOPSBlitFill( blitterRef, 0 , 0, w, h, i * (1 + 2^bps
+ 4^bps) * (i mod 2) )
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "IOPSBlitFill failed"
end if

kernResult = fn IOPSBlitIdle( blitterRef )
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "IOPSBlitIdle failed"
end if

next i

kernResult = fn CGDisplayRelease(0)
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "CGDisplayRelease failed"
end if
end if


// Release the io_iterator_t now that we're done with it.
kernResult = fn IOObjectRelease( Service )
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "IOObjectRelease failed"
end if

// Get the NEXT item in the iterator.
Service = fn IOIteratorNext( Iterator )
print "----------------------"

wend

// Release the io_service_t now that we're done with it.
kernResult = fn IOObjectRelease( Iterator )
long if ( _KERNSUCCESS != kernResult )
print hex$( kernResult )
print "IOObjectRelease failed"
end if

xelse
print "GetIterator failed"
end if

stop




2011/2/28 Edwards, Waverly <Waverly.Edwards@...>:
>
> I really meant to warn everyone not to perform experiments with flashing if they are seizure prone.  That was an important thing that I should have stated.  Interesting, in the papers I have read over the years, I had not seen healthy adults being susceptible to seizures due to photic stimulation.
>
> Yes, 60Hz is the upper limit.  It is pretty demanding on a machine to update a large portion of the screen.  In practice, I have been able to update the 70% of the screen by width at 18.5Hz consistently.  I still need to get to 22Hz as another threshold.  As I reach 80% of the screen, I can no longer maintain that refresh rate on my 2GHz Macbook.  I will be forced to use less screen real estate if I am to get to 22Hz.
>
> Thanks Herbie for looking out.
>
>
> W.
>
> -----Original Message-----
> From: futurebasic@... [mailto:futurebasic@...] On Behalf Of H. Gluender
> Sent: Monday, February 28, 2011 4:40 AM
> To: FB Mailing List
> Subject: Re: [FB] suggestion sought
>
> Waverly wrote:
>
> "The basic idea behind this experiment was drawn
> from research such as this.  My experiments do
> not follow
> these experiments precisely but are drawn from them.
>
> http://www.biomedcentral.com/1471-2202/7/21
> "
>
> Two remarks:
>
> 1.
> Please be extremely cautious with alpha-rhythm
> whole field flicker because it can provoke
> epileptic seizures even in healthy persons.
>
> 2.
> In general your temporal resolution is limited by
> the refresh rate of your LCD-display which
> generally is 16.67 milliseconds (60Hz).
>
> HTH
> --
>
>
>                 H. Glünder
>
>          ------------------------
>
>          <http://www.gluender.de>
>
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
> To access the list archives, go to:  http://freegroups.net/groups/futurebasic/
>
>
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
> To access the list archives, go to:  http://freegroups.net/groups/futurebasic/
>
>