Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - dreamerman

Pages: 1 ... 22 23 [24] 25
346
GLBasic - en / Re: Android compiling help
« on: 2013-Mar-15 »
Erico, don't forget about second part - enable debug mode on phone.
I think that such device should have good usb debug drivers, maybe they are on cd or can be downloaded from net..
The method that I posted can be used for any kind of android based device and it's recommended on many forums - mostly in terms of rooting device - but this part is only how to make your device visible on debugger list, so does not interfere in phone, and take only a little time ;-)
About jdk version.. after successfully deployment of your app, you must sign it to publish it on market, there were some issues with that in jdk7 and normal glBasic version, so I installed jdk6, and don't know does it works now. :-)

347
GLBasic - en / Re: Android compiling help
« on: 2013-Mar-15 »
So currently app isn't automatically installed on your device?
Despite that I read some time ago that jdk6 is recommended to use - due some signing problems - I don't know current status of that issue so next thing:

1. Does your device is recognized by Google adb debugger? after pluging in, it should be visible on device list, to check it:
run cmd, navigate to your 'android-sdk\platform-tools' folder, type:
Code: (glbasic) [Select]
adb devicesIf you device doesn't have correct USB drivers for debug mode then it wont be visible. Probably most cheap Chinese based tablets (as mine :D) have such problem, so in that case you need to add it manually to debugger files.

Plug your android device to usb - don't select usb connection type on device, run system 'device manager' / Control Panel - System - Dev mgr, navigate to device entry - at this stage it can be unrecognized and visible as some mysterious txt, go to it properties - details, from combo choose  'device identy/description' or similar there should be string similar to this:
Code: (glbasic) [Select]
USB\VID_2207&PID_0010&REV_0222&MI_01 it can have different numbers of course.. copy it..
Go to 'android-sdk\extras\google\usb_driver', edit 'android_winusb.inf', in sections '[Google.NTx86]' and '[Google.NTamd64]' add two lines for your device:
Code: (glbasic) [Select]
%SingleAdbInterface% = USB_Install, copied_info_string_without_last_&
%CompositeAdbInterface%= USB_Install, copied_info_string
next go to: 'C:\Users\your_user\.android', edit 'adb_usb.ini', add first value from id string, for my device it would be: 0x2207
restart adb debugger, reconnect your device, now it should be recognized as 'google .. adb driver' or something like this, and should be visible on adb devices list..

2. have you enabled debug mode on device? -> settings - system - programming options - enable debug mode

For me auto installing apps by glBasic is stable, always installed correctly, no problems.
And you can see debugger output with this file: 'GLBasic\Compiler\platform\android\bin' -> '_Logview.bat', but edit it and check paths - they need to be correct, to print debug info on android use 'stdout' in glBasic...

348
Answer is same as for Your other topic - about sprites..
You can replace function parameters with variables so:
Code: (glbasic) [Select]
CONSTANT mykey_W% = 17
Global mykey_A% = 30

if Key(mykey_W%)
''something
endif
if Key(mykey_A%)
''something
endif

349
@mentalthink: thanks, 'bug' fixed..

@matchy: I think that we should try to use such custom ad clients as this, and t least check does it work properly.

Little update. I have added 'madvertise' network with html & xml parsers, it's working properly, on pc test banner is shown.
That provider requires our IP as parameter in body of POST request so additional php script is needed, example in source, link to temporary script on my server is in first post.

True test would be if someone will register his game on one of these networks (it does not oblige to anything), and test 'basad' with real app_id/keys and on real device.

350
I know it's Friday night, but the sooner the better.
One form of making $$ from games is in-app advertising, but so far we had no luck with it. Although there were attempts to make iads working on ios, but from what I see, now it does not work. That's why it's time to move on.
When it goes to writing custom ad network client there are several fundamental problems:
1. gif loading - this format is used for animated banners by some ad networks..
Now, thanks to the gif loader (available here), we can use this format so the problem disappeared.
2. user-agent string - such as in a default browser on the phone .. now we have to manually type it into code, and as you know, it will not be 100% correct with what is shown by browser.
3. uuid / imei - I do not know how it currently looks like - whether the uuid collecting applications are rejected? because, some networks require to pass encoded (eg md5) uuid or MAC address - which you can not currently retrieve in GLBasic.

After recently viewing different source codes  (eg 'ad mediator' for corona sdk) I stated that if they can use in-app advertising, we also should do it! ;] I have rewritten my old unfinished custom parser for one of ad networks, improved many things and now alpha code is ready to testing. Unfortunately I do not have any other device than my pc  so I ask you to help with testing.

Currently there are parsers for 3 ad networks: InnerActive, InMobi and madvertise - on the pc when setting test APP_ID for them, all these networks response with test banners showing that implementation is correct. Another ad networks can be easily added - it would be good if such network would have a Client API - not only sdk.

A lot of talk but how to test it?
We need real device testing, on some ready games/apps - check if ad providers response with real ads, does parsers work properly on them, and most important, does clicks are counted.

Example use of code - to see test banners:
Code: (glbasic) [Select]
//remember to include gif loading routines
SETCURRENTDIR("Media")
LOCAL t1%, t2%, t3%, gif_cframe%, gif_frames%, ad_loaded%, ad_frame%
Init_Gif_loader()
SOCK_INIT()

Init_basad_ads(100, 1, 480, 800, "games", 20, "m", "http://www.dreamerman.netserwer.pl/script/check_it.php")
basad_enableInnAct("", 0)
basad_enableInMobi("", 0)
basad_enablemadvertise("")
basad_setnetorder("innact") //change to inmobi/madv, or combination "innact,inmobi,madv" - uncomment debug cmd in basad to see how networks response
basad_GetNewAd()
while (basad_sock%<>-1)
basad_recvloop()
SLEEP 100
WEND
SOCK_SHUTDOWN
DEBUG "error: " + basad_errcode% + " -> " + basad_errstr$ + "\n" //if all ok should return err=0

LOCAL done% = 1
CLEARSCREEN RGB(100, 50, 50)
WHILE done%
IF KEY(01); done% = 0; ENDIF

INC ad_frame%
IF (ad_frame% >= basad_banner_frames%); ad_frame% = 0; ENDIF

SLEEP 50
IF (basad_banner_frames% <> -1); DRAWANIM basad_spriteid%, ad_frame%, 10, 300; ENDIF //draw fancy ad banner
SHOWSCREEN
WEND
END

NOTE: 'madvertise' ad network need our IP address as parameter in POST body, so additional script is required to retrieve our ip, example code included in source.
Also this provider doesn't like some 'user-agents'  for example TouchPad isn't recognized = even test ads aren't served.

[attachment deleted by admin]

351
2D-snippets / Loading GIF files/animations...
« on: 2012-Aug-21 »
We can load jpg, png and bmp files, but whole gifs world was beyond our reach, until now.
From long time I was thinking about making gif importer, but LZW compression looked complicated, it still look strange ;d
But after long searches for most understandable code, I found some source in Java, and translation to GLB began..
Here it is, GIF loading code, with examples.

NOTE: I only 'converted' that module to GLBasic, real thanks should go to Jitsu Wan for his Java source.

GIF module:
Code: (glbasic) [Select]
// --------------------------------- //
// Project: gif_loader

// No copyright asserted on this source code. May be used for
// any purpose, however, refer TO the Unisys LZW patent FOR any additional
// restrictions. I am NOT responsible IF something will not work properly.

// GLBasic GIF load port by dreamerman[at]wp.pl
// heavily based on gif loader for Java ME by Jitsu Wan with reference to work done by Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick.
// includes c++ inline
// any other info in code
//
// --- HOW TO USE ---
// - first initialize gif vars by calling -
// Init_Gif_loader()
// - next load gif file as sprite -
// Load_gif_file("some.gif", sprite_id%, frame_count%, frame_width%, frame_height%)
// DrawSprite sprite_id%, 0, 0
// - or load directly as animation for use with DrawAnim ... -
// Load_gif_as_anim("some.gif", anim_id%, frame_count%, frame_width%, frame_height%)
// DrawAnim anim_id%, current_frame%, 0, 0
// - that's all... -

//ver: public 2
//Changelog:
//- public 2: added Redim's to clear image buffers



//two importants variables, set max sprite size - lower for compatibility with legacy gpu/mobile devices
GLOBAL gif_max_sprite_width% = 2048, gif_max_sprite_height% = 2048
//other gif loader variables
GLOBAL gif_curr_posx%, gif_curr_posy%, gif_currxlen%
GLOBAL gif_bytes%[], gif_file_size%, gif_error%, gif_rposition%, gif_tpixels%[], gif_framecount%
GLOBAL gif_width%, gif_height%, gif_gct_flag%, gif_gct_size%, gif_pixelaspect%, gif_bgindex%, gif_bgcolor%, gif_lastbgcolor%
GLOBAL gif_lctFlag%, gif_interlace%, gif_lct_size%, gif_islastimg%
GLOBAL gif_gctab%[], gif_lctab%[], gif_blockb%[], gif_block_size%
GLOBAL gif_delay%, gif_transparency%, gif_transIndex%, gif_dispose%, gif_lastDispose%
GLOBAL gif_MaxStackSize% = 4096, gif_prefix%[], gif_suffix%[], gif_pixelStack%[]
GLOBAL gif_ix%, gif_iy%, gif_iw%, gif_ih%, gif_done%, gif_loopcount%
GLOBAL gif_lastImage_id%, gif_lastRect%[], gif_image%[], gif_lastimage%[], gif_wholesprite%[]

//init function
FUNCTION Init_Gif_loader:

DIM gif_bytes%[2]
DIM gif_gctab%[256]
DIM gif_lctab%[256]
DIM gif_blockb%[256]
DIM gif_tpixels%[256]
DIM gif_prefix%[gif_MaxStackSize%]
DIM gif_suffix%[gif_MaxStackSize%]
DIM gif_pixelStack%[gif_MaxStackSize%+1]
DIM gif_lastRect%[4]
DIM gif_image%[256]
DIM gif_lastimage%[256]
DIM gif_wholesprite%[256]

ENDFUNCTION

//gif loading errors:
//1 - no such file
//2 - error with opening file
//3 - not a gif file - if it's bmp/jpg/png it will be loaded
//4 - ???
//5 - to small sprite size - to many gif frames
FUNCTION Load_gif_file: filename$, sprite_id%, BYREF frame_count%, BYREF frame_width%, BYREF frame_height%
LOCAL i1%, i2%, i3%, wp%, czs1$

gif_file_size% = GETFILESIZE(filename$); gif_error% = 0
IF (gif_file_size% = 0)
DEBUG "GIF load error: wrong file size\n"
gif_error = 1; RETURN 0
ENDIF //no file size?
// DEBUG "reading start: " + GETTIMERALL() + "\n"
wp% = GENFILE()
IF (OPENFILE(wp%, filename$, 1))
REDIM gif_bytes%[gif_file_size%]
READSTR wp%, czs1$, gif_file_size%
FOR i1% = 0 TO gif_file_size%-1
gif_bytes%[i1%] = ASC(MID$(czs1$, i1%, 1))
NEXT
CLOSEFILE wp%
gif_rposition% = 6
ELSE //some error with loading file
gif_error = 2; RETURN 0
ENDIF

// DEBUG "reading end: " + GETTIMERALL() + ", file size: " + gif_file_size% + "\n"

gif_curr_posx% = 0; gif_curr_posy% = 0; gif_framecount% = 0
czs1$ = CHR$(gif_bytes%[0]) + CHR$(gif_bytes%[1]) + CHR$(gif_bytes%[2]) + CHR$(gif_bytes%[3]) + CHR$(gif_bytes%[4]) + CHR$(gif_bytes%[5])
IF (czs1$ = "GIF87a" OR czs1$ = "GIF89a")
// DEBUG "it's a gif file..\n"
//clear last image buffer
REDIM gif_image%[0]; REDIM gif_wholesprite%[0]; REDIM gif_lastimage%[0]
gif_readLSD()
IF (gif_gct_flag%); gif_readColorTable(1); ENDIF
//redim sprite array
i1% = INTEGER(gif_max_sprite_width% / gif_width%)
gif_currxlen% = i1% * gif_width%
REDIM gif_wholesprite%[gif_currxlen% * gif_max_sprite_height%]

gif_readContents()

// DEBUG "loading end: " + GETTIMERALL() + "\n"
// DEBUG "array x-size: " + gif_currxlen% + ", loop count: " + gif_loopcount% + ", delay: " + gif_delay% + " \n"
// DEBUG "frame count: " + gif_framecount% + ", in-sprite pos: " + gif_curr_posx% + "x" + gif_curr_posy% + "\n"
IF (gif_error% = 5); DEC gif_curr_posy%, gif_height%; DEC gif_framecount%; ENDIF
REDIM gif_wholesprite%[gif_currxlen% * (gif_curr_posy%+gif_height%)] //cut of unnecessary data
//create sprite from array
MEM2SPRITE(gif_wholesprite%[], sprite_id%, gif_currxlen%, gif_curr_posy%+gif_height%)

ELSE //check if it's bmp, jpg  or png for normal loading
IF (gif_bytes%[0] = 66 AND gif_bytes%[1] = 77) OR (gif_bytes%[0] = 255 AND gif_bytes%[1] = 216) OR (gif_bytes%[0] = 137 AND gif_bytes%[1] = 80 AND gif_bytes%[2] = 78 AND gif_bytes%[3] = 71)
LOADSPRITE filename$, sprite_id%
GETSPRITESIZE sprite_id%, gif_width%, gif_height%
IF (gif_width% > 0 AND gif_height% > 0)
gif_framecount% = 1
ELSE
gif_error = 3; RETURN 0
ENDIF
ELSE
gif_error = 3; RETURN 0
ENDIF
ENDIF
frame_count% = gif_framecount%; frame_width% = gif_width%; frame_height% = gif_height%
REDIM gif_bytes%[1]
REDIM gif_wholesprite%[1]

RETURN 1
ENDFUNCTION

//equivalent for LoadAnim
FUNCTION Load_gif_as_anim: filename$, anim_id%, BYREF frame_count%, BYREF frame_width%, BYREF frame_height%
LOCAL ws% = GENSPRITE(), temp%, tcount%, twidth%, theight%
temp% = Load_gif_file(filename$, anim_id%, tcount%, twidth%, theight%)
SETSPRITEANIM anim_id%, twidth%, theight%
frame_count% = tcount%; frame_width% = twidth%; frame_height% = theight%
RETURN temp%
ENDFUNCTION

//main loop
FUNCTION gif_readContents:
LOCAL i1%, code%, czs1$

gif_done% = 0
WHILE (gif_done% = 0)
code% = gif_read()
SELECT code%
CASE 44 //0x2C - image separator
gif_readImage()
// DEBUG "new image: " + gif_framecount% + "\n"
CASE 33 //0x21 - extension
code% = gif_read()
// DEBUG "extension: " + "\n"
SELECT code%
CASE 0xf9 //graphic control extension
gif_readGraphicControlExt()
// DEBUG "graphic ext: dispose: " + gif_dispose% + " \n"
CASE 0xff //application extension
gif_readBlock()
// DEBUG "netscape ext \n"
czs1$ = ""
FOR i1%=0 TO 10; INC czs1$, CHR$(gif_blockb%[i1%]); NEXT
IF (czs1$ = "NETSCAPE2.0")
gif_readNetscapeExt()
ELSE
gif_skipblock()
ENDIF
DEFAULT
gif_skipblock()
ENDSELECT
CASE 59 //0x3b - terminator
gif_done% = 1
CASE 0 //0x00 - bad byte
//continue
DEFAULT
//raise error - format error?
ENDSELECT
WEND

ENDFUNCTION


// original comment
// Decodes LZW image data into pixel array.
// Adapted from John Cristy's ImageMagick.
FUNCTION gif_decodeImageData:
LOCAL NullCode% = -1, npix% = gif_iw% * gif_ih%
LOCAL available%, clear%, code_mask%, code_size%, end_of_information%, in_code%, old_code%, bits%, code%, count%, i%, datum%, data_size%, first%, top%, bi%, pi%

IF (LEN(gif_tpixels%[]) < npix); REDIM gif_tpixels%[npix]; ENDIF

data_size% = gif_read() //  Initialize GIF data stream decoder.
clear% = ASL(1, data_size%)
end_of_information% = clear% + 1
available% = clear% + 2
old_code% = NullCode%
code_size% = data_size% + 1
code_mask% = ASL(1, code_size) - 1
FOR code% = 0 TO clear%-1
gif_prefix%[code%] = 0
gif_suffix%[code%] = code%
NEXT

INLINE
         //  Decode GIF pixel stream.
         datum = bits = count = first = top = pi = bi = 0;

         while (i < npix)
         {
             if (top == 0)
             {
                 if (bits < code_size)
                 {
                     //  Load bytes until there are enough bits for a code.
                     if (count == 0)
                     {
                         // Read a new data block.
                         count = gif_readBlock();
                         if (count <= 0) {
                 break;
             }
                         bi = 0;
                     }
                     datum += ((gif_blockb(bi)) & 0xff) << bits; //(((int) gif_blockb(bi)) & 0xff) << bits;
                     bits += 8;
                     bi++;
                     count--;
                     continue;
                 }

                 //  Get the next code.

                 code = datum & code_mask;
                 datum >>= code_size;
                 bits -= code_size;

                 //  Interpret the code

                 if ((code > available) || (code == end_of_information)) {
                     break;
                 }
                 if (code == clear)
                 {
                     //  Reset decoder.
                     code_size = data_size + 1;
                     code_mask = (1 << code_size) - 1;
                     available = clear + 2;
                     old_code = NullCode;
                     continue;
                 }
                 if (old_code == NullCode)
                 {
                     gif_pixelStack(top++) = gif_suffix(code);
                     old_code = code;
                     first = code;
                     continue;
                 }
                 in_code = code;
                 if (code == available)
                 {
                     gif_pixelStack(top++) = first; //(byte) first
                     code = old_code;
                 }
                 while (code > clear)
                 {
                     gif_pixelStack(top++) = gif_suffix(code);
                     code = gif_prefix(code);
                 }
                 first = (gif_suffix(code)) & 0xff; //((int) gif_suffix(code)) & 0xff;

                 //  Add a new string to the string table,

                 if (available >= gif_MaxStackSize) {
                     break;
                 }
                 gif_pixelStack(top++) = first; //(byte) first
                 gif_prefix(available) = old_code; //(short) old_code
                 gif_suffix(available) = first; //(byte) first
                 available++;
                 if (((available & code_mask) == 0) && (available < gif_MaxStackSize))
                 {
                     code_size++;
                     code_mask += available;
                 }
                 old_code = in_code;
             }

             //  Pop a pixel off the pixel stack.

             top--;
             gif_tpixels(pi++) = gif_pixelStack(top);
             i++;
         }

         for (i = pi; i < npix; i++)
         {
             gif_tpixels(i) = 0; // clear missing pixels
         }
ENDINLINE

ENDFUNCTION


FUNCTION gif_readImage:

gif_ix% = gif_readShort()
gif_iy% = gif_readShort()
gif_iw% = gif_readShort()
gif_ih% = gif_readShort()

LOCAL packed% = gif_read(), save%
gif_lctFlag% = bAND(packed%, 0x80) //1 - local color table flag
gif_interlace% = bAND(packed%, 0x40) //2 - interlace flag
//3 - sort flag, 4-5 - reserved
gif_lct_size% = ASL(2, bAND(packed%, 7)) //6-8 - local color table size
IF (gif_lctFlag%) //use local table
gif_readColorTable(0)
ELSE
FOR i1% = 0 TO gif_gct_size%-1
gif_lctab%[i1%] = gif_gctab%[i1%]
NEXT
IF (gif_bgindex% = gif_transIndex%); gif_bgcolor% = 0; ENDIF
ENDIF

IF (gif_transparency%)
save% = gif_lctab%[gif_transIndex%]
gif_lctab%[gif_transIndex%] = 0
ENDIF

gif_decodeImageData()
gif_skipblock()

INC gif_framecount%
//check for space
IF (gif_curr_posy% + gif_height% >= gif_max_sprite_height%)
gif_error% = 5; gif_done% = 1
ENDIF
IF (gif_error% = 0)
gif_setPixels() // transfer pixel data to image
IF (gif_transparency%); gif_lctab%[gif_transIndex%] = save%; ENDIF
gif_resetFrame()
ENDIF

//calculate new position in our sprite
INC gif_curr_posx%, gif_width%
IF (gif_curr_posx% >= gif_currxlen%)
gif_curr_posx% = 0
INC gif_curr_posy%, gif_height%
IF (gif_curr_posy% >= gif_max_sprite_height%)
gif_error% = 5
gif_done% = 1
ENDIF
ENDIF
// DEBUG "new position in sprite: " + gif_curr_posx% + "x" + gif_curr_posy% + "\n"

ENDFUNCTION


FUNCTION gif_setPixels:
LOCAL n%, i1%, i2%, i3%, i4%, i5%, i6%, dlug% = gif_width% * gif_height%, ccolor%

IF (gif_lastDispose% > 0)
IF (gif_lastDispose% = 3)
n% = gif_framecount% - 2 //use image before last
IF (n% > 0)
i1% = (n - 1) * gif_width%; i2% = 0 //x & y pos of that frame on sprite array
WHILE (i1% > gif_currxlen%)
DEC i1%, gif_currxlen%; INC i2%, gif_height%
WEND

FOR i4% = i2% TO i2% + gif_height%
i5% = gif_height% * i4%
FOR i3% = i1% TO i1% + gif_width%
gif_image%[i6%] = gif_wholesprite%[i5% + i3%]
INC i6%
NEXT
NEXT
ENDIF
ELSEIF (gif_lastDispose% = 2)
IF (gif_transparency%)
ccolor% = INTEGER(0x00000000)
ELSE
ccolor% = gif_lastbgcolor%
ENDIF
FOR i1% = 0 TO dlug%-1
gif_image%[i1%] = ccolor%
NEXT
//should be: g.fillRect(lastRect[0],lastRect[1],lastRect[2],lastRect[3]);
ELSE
FOR i1% = 0 TO dlug% - 1
gif_image%[i1%] = gif_lastimage%[i1%]
NEXT
ENDIF
ENDIF


INLINE
         // copy each source line to the appropriate place in the destination
         int pass = 1;
         int incr = 8;
         int iline = 0;
         for (int i = 0; i < gif_ih; i++) {
             int line = i;
             if (gif_interlace) {
                 if (iline >= gif_ih) {
                     pass++;
                     switch (pass) {
                         case 2 :
                             iline = 4;
                             break;
                         case 3 :
                             iline = 2;
                             incr = 4;
                             break;
                         case 4 :
                             iline = 1;
                             incr = 2;
                     }
                 }
                 line = iline;
                 iline += incr;
             }
             line += gif_iy;
             if (line < gif_height) {
                 int k = line * gif_width;
                 int dx = k + gif_ix; // start of line in dest
                 int dlim = dx + gif_iw; // end of dest line
                 if ((k + gif_width) < dlim) {
                     dlim = k + gif_width; // past dest edge
                 }
                 int sx = i * gif_iw; // start of line in source
                 while (dx < dlim) {
                     // map color and insert in destination
                     int index = (gif_tpixels(sx++)) & 0xff;
                     int c = gif_lctab(index);
                     if (c != 0) {
                         gif_image(dx) = c;
                     }
                     dx++;
                 }
             }
         }

ENDINLINE

//paste current frame to our sprite
i2% = 0; i3% = gif_curr_posy% * gif_currxlen% + gif_curr_posx%
FOR i1% = 0 TO gif_height% * gif_width% - 1
gif_wholesprite%[i3%+i2%] = gif_image%[i1%]
INC i2%
IF (i2%>=gif_width%); i2% = 0; INC i3%, gif_currxlen%; ENDIF
NEXT

ENDFUNCTION


FUNCTION gif_readGraphicControlExt:
gif_read() //block size
LOCAL packed% = gif_read() //packed fields
gif_dispose% = ASR(bAND(packed%, 0x1c), 2) //disposal method -> dispose = (packed & 0x1c) >> 2
IF (gif_dispose% = 0); gif_dispose% = 1; ENDIF
gif_transparency% = bAND(packed%, 1) //transparency = (packed & 1) != 0;
gif_delay% = gif_readShort() * 10 //delay in miliseconds
gif_transIndex% = gif_read() //transparent color index
gif_read() //block terminator
ENDFUNCTION

//how many loops/repeats - does we care about it? ;]
FUNCTION gif_readNetscapeExt:
LOCAL b1%, b2%
REPEAT
gif_readBlock()
IF (gif_blockb%[0] = 1)
b1% = bAND(gif_blockb%[1], 256)
b2% = bAND(gif_blockb%[2], 256)
gif_loopcount% = bOR(ASL(b2%, 8), b1%)
ENDIF
UNTIL (gif_block_size% = 0 OR gif_error% <> 0)
ENDFUNCTION

//read Logical Screen Descriptor
FUNCTION gif_readLSD:
gif_width% = gif_readShort()
gif_height% = gif_readShort()
LOCAL packed% = gif_read(), dlug% = gif_width% * gif_height%
gif_gct_flag% = bAND(packed%, 128) // = (packed & 0x80) != 0
gif_gct_size% = ASL(2, bAND(packed%, 7))
//bits:
// 1   : global color table flag
// 2-4 : color resolution
// 5   : gct sort flag
// 6-8 : gct size

gif_bgindex% = gif_read()
gif_pixelaspect% = gif_read()
//redim our image tables
REDIM gif_image%[dlug%]
REDIM gif_lastimage%[dlug%]

//DEBUG "info: " + gif_width% + "x" + gif_height% + ", colors count: " + gif_gct_size% + "\n"

ENDFUNCTION

//read one byte from gif file array
FUNCTION gif_read:
LOCAL i1% = 0
i1% = gif_bytes%[gif_rposition]
INC gif_rposition
RETURN i1%
ENDFUNCTION

FUNCTION gif_readShort:
RETURN gif_read() + ASL(gif_read(), 8)
ENDFUNCTION

//block reading
FUNCTION gif_readBlock:
LOCAL i1%
gif_block_size% = gif_read()
IF (gif_block_size% > 0)
LOCAL count% = 0
FOR i2%=0 TO gif_block_size%-1
gif_blockb%[i2%] = gif_bytes%[gif_rposition+i2%]
NEXT
INC gif_rposition%, gif_block_size%
ENDIF
RETURN gif_block_size%
ENDFUNCTION

FUNCTION gif_skipblock:
REPEAT
gif_readBlock()
UNTIL (gif_block_size%=0 OR gif_error%<>0)
ENDFUNCTION

FUNCTION gif_readColorTable: is_global%
LOCAL i1%
IF (is_global% = 1)
FOR i1%=0 TO gif_gct_size%-1
gif_gctab%[i1%] = 0xff000000 + ASL(gif_bytes%[gif_rposition+2], 16) + ASL(gif_bytes%[gif_rposition+1], 8) + gif_bytes%[gif_rposition]
INC gif_rposition, 3
NEXT
ELSE
FOR i1%=0 TO gif_lct_size%-1
gif_lctab%[i1%] = 0xff000000 + ASL(gif_bytes%[gif_rposition+2], 16) + ASL(gif_bytes%[gif_rposition+1], 8) + gif_bytes%[gif_rposition]
INC gif_rposition, 3
NEXT
ENDIF
ENDFUNCTION

FUNCTION gif_resetFrame:
gif_lastDispose% = gif_dispose%
gif_lastRect%[0] = gif_ix%
gif_lastRect%[1] = gif_iy%
gif_lastRect%[2] = gif_iw%
gif_lastRect%[3] = gif_ih%

//lastImage = image
LOCAL dlug% = LEN(gif_image%[]), i1%
FOR i1% = 0 TO dlug%-1
gif_lastimage%[i1%] = gif_image%[i1%]
NEXT
gif_islastimg% = 1

gif_lastbgcolor% = gif_bgcolor%
gif_dispose% = 0
gif_transparency% = 0
//gif_delay% = 0
gif_lct_size% = 0

ENDFUNCTION

example - load as sprite:
Code: (glbasic) [Select]
SETCURRENTDIR("Media") // go to media files
LOCAL t1%, t2%, t3%
Init_Gif_loader()
Load_gif_file("some_animation.gif", 1, t1%, t2%, t3%)
SAVESPRITE "test.png", 1
MOUSEWAIT
END

example - load as animation:
Code: (glbasic) [Select]
SETCURRENTDIR("Media") // go to media files
LOCAL t1%, t2%, t3%, gif_cframe%, gif_frames%, done% = 1

Init_Gif_loader()
Load_gif_as_anim("earth.gif", 3, gif_frames%, t2%, t3%)

CLEARSCREEN RGB(100, 50, 50)
WHILE done%
IF KEY(01); done% = 0; ENDIF
INC gif_cframe%
IF (gif_cframe% >= gif_frames%); gif_cframe% = 0; ENDIF
SLEEP gif_delay% //var from gif loading module
IF (gif_frames%>0); DRAWANIM 3, gif_cframe%, 10, 10; ENDIF
SHOWSCREEN
WEND
END

:-)

Edit: little update, fixed issue with not clearing image buffers..

352
GLBasic - en / Re: Quick request
« on: 2012-Jul-25 »
I'm from Poland, and I get German/Deutsch. Checked in Opera and Chrome, before and after deleting paypal/glbasic site cookies.
What more interesting, once, after login to paypal account and logout I have got that checkout page in Polisch, but next time again it was in German :D and still it is..

There is 'lc' parameter for setting user language:
Quote from: PayPal
The locale of the login or sign-up page, which may have the specific country's language available, depending on localization. If unspecified, PayPal determines the locale by using a cookie in the subscriber’s browser. If there is no PayPal cookie, the default locale is US.
but it isn't set on glBasic site so everyone should get his default language or at least US English.
Strange problem..

Maybe you should force some lc with info gathered from php user-agent or something like this..

353
But does it still consume so much cpu/gpu power on pc? First extensively test your code on pc, with all possible trick's then, check how much speed it gained on emulator/real devices. Use 'LimitFps -1' to unlock fps limiter, and see how many fps you will get on pc with particular changes.
'StrechSprite' shoudn't be used many times, specially on mobile devices. There can be also other small issues, for example float calculations # are of course slower than integer %, so they should be used only when necessary.
When it comes to drawing, you probably should use other commands than strechsprite for example:
Code: (glbasic) [Select]
1. draw all graphic at desired res (let say 320x480) to offscreen texture (UseScreen cmd)
2. render that texture (with all game graphic) to screen with one strechsprite/polyvector
Of course also mouse position should be recalculated also..
Or use some already made custom functions like these from 'Z Project' by Ampos -> LINK

354
That isn't problem of Android but more likely not properly written code. On my dual-core pc, controls are responsive but game takes 50% of cpu power, it shouldn't happen.
You should use at least Limitfps and Sleep commands:
Code: (glbasic) [Select]
sub play:
Limitfps 30
   while quit=0
       gosub checkinput
       gosub showgraphics
       sleep 25
   wend
endsub

Or your main loop can be more sophisticated:
Code: (glbasic) [Select]
sub play:
Limitfps 30
   while quit=0
curr_time# = GETTIMERALL()
IF (curr_time# - last_time# >= 33)
              gosub checkinput
              gosub showgraphics
   last_time# = curr_time#
ENDIF
       sleep 20
   wend
endsub

I don't have experience with current version of Android emulator, but add these changes and test how it will work.

Edit: Or maybe your drawing routines are messed up.. for example If your graphic covers whole screen don't use 'clearscreen' command, just draw new graphic over previous.

355
It's not a manner of memory but more likely display resolution..
That Archos tablet and Palm Pre have similar SoCs, Cortex A8 + SGX530.. but:
Palm Pre resolution: 320x480=153600 pts
Archos 70: 480x800=384000 pts
so gpu in that tablet needs to copy 3x times more pixels info.. in phone that PoverVR ship is sufficient but for tablet device is to slow.. I have looked into Antutu/Nenamark scores and even chinese based ~100$ tablets are ~2 times faster in graphic operations than this tablet..

You shouldn't trouble about Kindle Fire speed, because it has dual core cpu, newer gpu, and even better memory - ddr2..

356
Off Topic / Re: Android, the worst market?
« on: 2012-Mar-04 »
The issue of earnings and popularity of the games in various markets appears in several topics but I think that this will be the best for further discussion ..
What amazes me is very small number of downloads games for Android Market, not everyone wrote about their results but in general it's hard to stand out. Have you tried some form of advertising? I don't mean 'normal' campaigns in the advertising networks but even some cheap campaigns in the various accounts on facebook, such services can be purchased on auction sites.
Or maybe actually, people do not want to pay for little games and easier would be to make money from ads in games.

357
GLBasic - en / Re: Array speeds
« on: 2012-Feb-28 »
Interesting topic, so just for comparison same code in FreeBasic:

Code: (glbasic) [Select]
dim as double TimeStart, TimeEnd, TimeTaken, DummyVar
dim as integer n,n2, i, j, k
n=250
n2=10000
reDIM as integer TestData3d(n,n,n)

cls
sleep 1000
PRINT "Writing Data to the 3d array"

'' Fill 3d array in Column order
TimeStart = timer()
FOR k=0 TO n-1
FOR j=0 TO n-1
FOR i=0 TO n-1
TestData3d(i,j,k)=0
NEXT
NEXT
NEXT
TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+str(TimeTaken)

'' Fill 3d array in Row order
TimeStart = timer()
FOR i=0 TO n-1
FOR j=0 TO n-1
FOR k=0 TO n-1
TestData3d(i,j,k)=0
NEXT
NEXT
NEXT
TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+str(TimeTaken)

sleep 1000
PRINT "Reading Data from the 3d array"

'' Read 3d array in Column order
TimeStart = timer()
FOR k=0 TO n-1
FOR j=0 TO n-1
FOR i=0 TO n-1
DummyVar=TestData3d(i,j,k)
NEXT
NEXT
NEXT
TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+str(TimeTaken)

'' Read 3d array in Row order
TimeStart = timer()
FOR i=0 TO n-1
FOR j=0 TO n-1
FOR k=0 TO n-1
DummyVar=TestData3d(i,j,k)
NEXT
NEXT
NEXT
TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+str(TimeTaken)

'' Clear 3d array from mem & create 2d one
redim TestData3d(0,0,0)
reDIM as integer TestData2d(n2,n2)

sleep 1000
PRINT "Writing Data to the 2d array"

'' Fill 2d array in Column order
TimeStart = timer()
FOR j=0 TO n2-1
FOR i=0 TO n2-1
TestData2d(i,j)=0
NEXT
NEXT

TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+str(TimeTaken)

'' Fill 2d array IN Row order
TimeStart = timer()
FOR i=0 TO n2-1
FOR j=0 TO n2-1
TestData2d(i,j)=0
NEXT
NEXT

TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+str(TimeTaken)

sleep 1000
PRINT "Reading Data from the 2d array"

'' Read 2d array in Column order
TimeStart = timer()
FOR j=0 TO n2-1
FOR i=0 TO n2-1
DummyVar=TestData2d(i,j)
NEXT
NEXT

TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Column order took = "+str(TimeTaken)

'' Read 2d array in Row order
TimeStart = timer()
FOR i=0 TO n2-1
FOR j=0 TO n2-1
DummyVar=TestData2d(i,j)
NEXT
NEXT

TimeEnd = timer()
TimeTaken = TimeEnd - TimeStart
PRINT "Row order took = "+str(TimeTaken)

sleep

And my results on P E2180 (repeated several times):
Code: (glbasic) [Select]
GLB FB
writing to 3d array
column order: 0.170 sec - 0.703 sec
row order: 0.699 sec - 0.089 sec
reading from 3d array
colum order: 0.137 sec - 0.65 sec
row order: 0.120 sec - 0.086 sec
writing to 2d array
column order: 0.986 sec - 8.092 sec
row order: 6.791 sec - 0.808 sec
reading from 2d array
column order: 0.656 sec - 5.20 sec
row order: 0.684 sec - 0.455 sec

So basically in GLB is better to use column order :)

358
There are two basic issues with in-app ads. Maybe there are some methods to show webview/browser window with ad but it requires to wrote some crazy code in c++. Ads system could be made in pure GLB but app need to display animated gif-s correctly (some ads are normal banners but other include animations), so someone need to wrote gif to sprite loader or something like this.
Secondly, when app sends request for new ad it also passes 'User Agent' string as parameter, and it should be at least similar to 'user agent' that will be passed by browser used to open ad link, of course there are also other parameters but they are not a problem. This problem can be bypassed with for example build in ua strings for particular platform.
On other hand probably all banner/text based ad request are simple get/post request that could be done in glb, so main problem is gif loading, at least for me.

359
I think that Bada would be a better option.

The problem with Symbian is such that the most of devices (even now sold with this system) are old type old phones - nontouch small screen, keyboard/numpad, and are intended for 'emerging markets', and most common used dev language is Java - due to differences in phones and issues with publishing. Of course there are normal touch phones, but only few models have hardware acceleration and support for OpenGL (around a dozen models). When it goes to numbers, Nokia informs that there is around 155 milions of QT devices (not all Symbian just newer -> Symbian S60 and MeeGo.. 3 categories: new touch with OpenGL - N8/N9, older touch without gpu like Nokia 5800 and classic models like E65) but in true there is probably more classic phones than a touch devices. As a reminder I will say that Samsung in 2011 has sold more over 300 milions smartphones (mostly on android).
But on other hand for better devices most of top games is made by 'big companies', small dev studios are mainly focused on java games that will work on older phones, and many such games have crazy prices like $3 for tic tac toe. But to get really big impact our games should work on all touch devices not only these with gpu, that would be hard to do :/ For devices with gpu there is QtGameEnabler solution that as they said make developing simpler. Never tried cause I have Nokia 5530 without gpu :>
Aaa.. I almost forgot about it.. in Ovi/Nokia Store you can't publish games to South Korea Oo.. and self publish to China - you need some intermediary or as they tell an 'accumulator', that takes most of you earnings from that market ;]

About Bada. it's growing market, but also here not all devices have gpu so I don't know how fast games work on such phones (on Symbian phones without gpu you can't run opengl games, they just dosn't start). But there are also Smart Tv based on bada or something similar and they also could be the market for us.. Bada is more uniform system than Symbian

360
Code Snippets / Re: new QSIN (QQSIN)
« on: 2011-Jun-09 »
Don't forget about 'Lookup-table based SIN' by Ocean: http://www.glbasic.com/forum/index.php?topic=2855.msg20951#msg20951

on my pc:
m_qsin (Ampos) -> 564ms
Sin GlBasic -> 1772ms
QQSin -> 488ms
QSin -> 996ms
tSin (Ocean) -> 538ms

QQSin isn't so precise as tSin but for most calculations it would be ok..
Good job :]

Pages: 1 ... 22 23 [24] 25