Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Class or struct, possible?

Class or struct, possible?

Discuss PocketC for Palm OS (including Desktop Edition)

Postby Smoother on Tue Feb 10, 2004 12:17 pm

Is it possible to handle classes or structs with PocketC? If so, how to?
Smoother
 
Posts: 59
Joined: Thu Aug 02, 2001 11:26 am
Location: Sweden

Postby dewey on Wed Feb 11, 2004 4:19 am

PocketC doesn't currently have support for structs or classes.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby Smoother on Wed Feb 11, 2004 3:45 pm

Ok, I thought so too but until I found these 2 memos on my Palm. I dont know for how long they've been there. So what do they actually do?

<font size="2">
/# graphics
// Till oopC, classes in PocketC

class GO

//this is structure for PTB Sprite()
public x_pos, y_pos,
cmd,bmp,msk,buf,
cbk,cmsk,
x_move, y_move
xpo,ypo;

// buffering technique draw method
draw(){
TransBmp(x_pos,y_pos,5,5);
}

// sprite technique draw method
sprite() {
Sprite(1, this.publics);
}

//non-buffering technique restore background method
restore(){
/*
use callback function from Sprite structure for recalc position of the object. this.public - is a pointer to public variables block
*/
(*cbk)(0,this.publics);
//Restore background
CopyRect(buf, xpo, ypo,0,0,
16,16,0,0,-1);
CopyRect(0,0,0,xpo=x_pos,
ypo=y_pos
,16,16,0,buf,-1);
}

//class constructor
GO (
int x_p, int y_p,
int x_m, int y_m, pointer func)
{
//object initialization
x_pos=x_p; y_pos=y_p;
cmd=1;bmp=5;msk=5;
cbk=func; cmsk=1;
x_move=x_m; y_move=y_m;
CustomBuf(
buf=(this.index+3),16,16);
//this.index -unique index of this object in _class_GO
CopyRect(0,
0,0,x_pos,y_pos,
16,16,0,buf,-1);
}


// --------------------------------------------------------



// graphics(oo).c
// Till oopC, classes in PocketC

library "PToolboxLib"

// lets oopC functions work using PTB
#define _PToolboxLib_

include "graphics.ch"

#define RER 100
int t;

start() { t=ticks(); }
stop(string a) {
text(10,10,a);
puts(a+": "+(ticks()-t)+"\n"); }

recalc(int i, pointer sp){
sp[0]= sp[0]+ sp:?:;
if(sp[0]<0 || sp[0]>144) {
sp:?: = -sp:?: ;
sp[0]= sp[0]+ sp:?:;
}
sp[1]= sp[1] + sp[9];
if(sp[1]<0 || sp[1]>144) {
sp[9]= -sp[9];
sp[1]= sp[1]+ sp[9];
}
}

newpos(object o,int n){
recalc(0,o.publics);
}

main() {
int i;

if(!OpenBmpDb("test_bitmap")) {
alert("Failed to find test_bitmap.prc!");
return;
}
SetDepth(8);
graph_on();

//Setup buffers
SetDrawBuf(1);
SetDrawBuf(2);
ClearBuf();
line(1,0,40,160,40);
line(1,0,120,160,120);
line(1,40,0,40,160);
line(1,120,0,120,160);
SetDrawBuf(0);
CopyBuf(0,2);

//setup objects
GO(10,10,-1,-1,recalc);
GO(120,40,1,-1,recalc);
GO(40,120,1,1,recalc);

//"Old" sprite technique (use sprite function instead)

start();
i=RER; while(i--) {
forin _class_GO .restore;
forin _class_GO .draw;
}
stop("Old Sprite");

start();
i=RER; while(i--) {
foreach( _class_GO, newpos,0); //recalc position for all objects
CopyBuf(0,2);//Copy background to main display
forin _class_GO .draw;
}
stop("Double Buffered");

SetDrawBuf(1);
ClearBuf();

start();
i=RER; while(i--) {
foreach( _class_GO, newpos,0);
CopyBuf(1,2);
forin _class_GO .draw;
CopyBuf(0,1);
}
stop("Triple Buffered");

CopyBuf(0,2);
SetDrawBuf(0);

start();
i=RER; while(i--) {
forin _class_GO .sprite;
}
stop("Sprite");


event(1);
graph_off();
SetDepth(0);
}</font id="size2">
Smoother
 
Posts: 59
Joined: Thu Aug 02, 2001 11:26 am
Location: Sweden

Postby jstadolnik on Sun Feb 15, 2004 3:58 am

You can fake structures in PocketC pretty easily. See the following link: http://pocketc.net/forum/topic.asp?TOPI ... =structure

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby Smoother on Sun Feb 15, 2004 11:47 am

Ok. Thanks. I will take a closer look on that soon.
Smoother
 
Posts: 59
Joined: Thu Aug 02, 2001 11:26 am
Location: Sweden


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 4 guests

cron