aboutsummaryrefslogtreecommitdiff
path: root/Scripting/Perl/EmFunctions.pm
blob: 4454ff7c4f748efe9d3ecfdf0fbab4d7a593f46d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
########################################################################
#
#	File:			EmFunctions.pm
#
#	Purpose:		Perl wrappers for Palm OS functions
#
#	Description:	This file contains Perl equivalents of Palm OS
#					functions like DmNumDatabases, FrmGetActiveForm,
#					etc.  Currently, the functions here are generated
#					by hand, and so only a small subset of Palm OS
#					functions are wrapped.  In the future, this file
#					(or files) may be automatically generated by
#					a script that converts the SDK headers.
#
#					In general, functions follow the calling
#					conventions in the SDK headers.  However, there
#					are exceptions.  See the comments before each
#					subroutine for details.
#
########################################################################

package EmFunctions;

use EmRPC;
use EmSysTraps;

use strict;
use vars qw(@ISA @EXPORT);

use Exporter;
@ISA = qw(Exporter);

@EXPORT = qw(
	CtlGetLabel

	DmNumDatabases DmFindDatabase DmGetDatabase DmDatabaseInfo
	DmNextOpenDatabase DmOpenDatabaseInfo

	EvtEnqueuePenPoint EvtEnqueueKey

	FrmGetActiveForm FrmGetLabel FrmGetNumberOfObjects FrmGetObjectBounds
	FrmGetObjectId FrmGetObjectIndex FrmGetObjectPtr FrmGetObjectType FrmGetTitle

	FtrGet

	HwrDisplayAttributes

	MemChunkFree MemPtrFree MemPtrNew MemPtrSetOwner MemStoreInfo MemCardInfo
	MemNumCards MemNumHeaps MemNumRAMHeaps
	MemHeapID MemHeapDynamic MemHeapFlags MemHeapSize

	SysUIAppSwitch SysCurAppDatabase

	WinDisplayToWindowPt WinWindowToDisplayPt

	dmModeReadOnly dmModeWrite dmModeReadWrite
	dmModeLeaveOpen dmModeExclusive dmModeShowSecret

	frmFieldObj frmControlObj frmListObj frmTableObj frmBitmapObj frmLineObj
	frmFrameObj frmRectangleObj frmLabelObj frmTitleObj frmPopupObj
	frmGraffitiStateObj frmGadgetObj frmScrollBarObj

	hwrDispType			hwrDispRev			hwrDispVers			hwrDispAllDepths	hwrDispMaxDepth
	hwrDispBootDepth	hwrDispMaxGrays		hwrDispHorizontal	hwrDispVertical		hwrDispVRAMBaseAddr
	hwrDispVRAMSize		hwrDispColor		hwrDispName			hwrDispBaseAddr		hwrDispDepth
	hwrDispWidth		hwrDispHeight		hwrDispRowBytes		hwrDispBacklight	hwrDispBrightness
	hwrDispContrast		hwrDispDbgIndicator	hwrDispEndAddr		hwrDispBufferMask	hwrDispResolutionX
	hwrDispResolutionY	hwrDispMemAccessOK
);

use constant dmModeReadOnly			=> 0x01;
use constant dmModeWrite			=> 0x02;
use constant dmModeReadWrite		=> 0x03;
use constant dmModeLeaveOpen		=> 0x04;
use constant dmModeExclusive		=> 0x08;
use constant dmModeShowSecret		=> 0x10;

use constant frmFieldObj			=> 0;
use constant frmControlObj			=> 1;
use constant frmListObj				=> 2;
use constant frmTableObj			=> 3;
use constant frmBitmapObj			=> 4;
use constant frmLineObj				=> 5;
use constant frmFrameObj			=> 6;
use constant frmRectangleObj		=> 7;
use constant frmLabelObj			=> 8;
use constant frmTitleObj			=> 9;
use constant frmPopupObj			=> 10;
use constant frmGraffitiStateObj	=> 11;
use constant frmGadgetObj			=> 12;
use constant frmScrollBarObj		=> 13;

use constant hwrDispType			=> 0;	# (4) Get 4-char code for controller/display combination.
use constant hwrDispRev				=> 1;	# (2) Get Hardware Revision
use constant hwrDispVers			=> 2;	# (2) Get Display driver HAL version.
use constant hwrDispAllDepths		=> 3;	# (2) Get All display depths in bitmap format.
use constant hwrDispMaxDepth		=> 4;	# (2) Get Maximum supported bit depth.
use constant hwrDispBootDepth		=> 5;	# (2) The preset boot depth of the device.
use constant hwrDispMaxGrays		=> 6;	# (2) Get Maximum number of grays supported by HW.
use constant hwrDispHorizontal		=> 7;	# (2) Get Maximum hortizontal pixels supported by Display.
use constant hwrDispVertical		=> 8;	# (2) Get Maximum vertical pixels supported by Display.
use constant hwrDispVRAMBaseAddr	=> 9;	# (4) Get Base address of video memory if any (if 0, no VRAM)
use constant hwrDispVRAMSize		=> 10;	# (4) Get Size of VRAM (if 0, no VRAM)
use constant hwrDispColor			=> 11;	# (2) Get True if controller AND display supprt color.
use constant hwrDispName			=> 12;	#(32) Get 32 character string for controller and Hardware.
	
use constant hwrDispBaseAddr		=> 13;	# (4) Get/Set Base Address for current screen memory (somewhere in VRAM or main RAM)
use constant hwrDispDepth			=> 14;	# (2) Get/Set Depth of display
use constant hwrDispWidth			=> 15;	# (2) Get/Set current display width
use constant hwrDispHeight			=> 16;	# (2) Get/Set current display height
use constant hwrDispRowBytes		=> 17;	# (2) Get/Set bytes in a row of display (changed when depth or width change)
use constant hwrDispBacklight		=> 18;	# (1) Get/Set Backlight status: 0 = off, 1 = on (returns 0 on Austin)
use constant hwrDispBrightness		=> 19;	# (1) Get/Set Brightness level: 0(min/off)...255(max)
use constant hwrDispContrast		=> 20;	# (1) Get/Set Contrast Level: 0(min)...255(max)
use constant hwrDispDbgIndicator	=> 21;	# (2) Turn Debug Indicator on/off
use constant hwrDispEndAddr			=> 22;	# (4) Get last byte of screen memory
use constant hwrDispBufferMask		=> 23;	# (4) Mask for determining required display address alignment
use constant hwrDispResolutionX		=> 24;	# (?) Screen resolution
use constant hwrDispResolutionY		=> 25;	# (?) Screen resolution
use constant hwrDispMemAccessOK		=> 26;	# (1) true if controller can be accessed when bus clock disabled


########################################################################
#
#	FUNCTION:		CtlGetLabel
#
#	DESCRIPTION:	Return a string pointer to the control's text label.
#
#	PARAMETERS:		Memory address on the remote device of the control
#					object.  Usually the result of something like
#					FrmGetObjectPtr on a control object.
#
#	RETURNED:		A list containing the memory address on the remote
#					device of the label, and the label string itself.
#
########################################################################

sub CtlGetLabel
{
	# const Char* CtlGetLabel (const ControlType * ctlP)

	my ($return, $format) = ("string", "rptr");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapCtlGetLabel, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		DmNumDatabases
#
#	DESCRIPTION:	Returns the number of databases on a card
#
#	PARAMETERS:		card number
#
#	RETURNS:		Number of databases found
#
########################################################################

sub DmNumDatabases
{
	# UInt DmNumDatabases (UInt cardNo)

	my ($return, $format) = ("int16", "int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapDmNumDatabases, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		DmDatabaseInfo
#
#	DESCRIPTION:	Retrieves database information
#
#	PARAMETERS:		Card number, database LocalID
#
#	RETURNS:		Result code from function, as well as the components
#					of a hash.  To get the result, assign the result
#					of this function to ($err, %results).  You can
#					then extract individual values from %results using
#					hash operators and the following keys: name
#					attributes, version, crDate, modDate, bckUpDate,
#					modNum, appInfoID, sortInfoID, type, and creator.
#					Example: $name = $results{name}.
#
########################################################################

sub DmDatabaseInfo
{
	# Err DmDatabaseInfo (UInt cardNo, LocalID	dbID, const CharPtr nameP,
	#				UIntPtr attributesP, UIntPtr versionP, ULongPtr crDateP,
	#				ULongPtr modDateP, ULongPtr bckUpDateP,
	#				ULongPtr modNumP, LocalID* appInfoIDP,
	#				LocalID* sortInfoIDP, ULongPtr typeP,
	#				ULongPtr creatorP)

	my ($cardNo, $dbID) = @_;

	my ($format) = "int16 LocalID string32 int16* int16* int32* int32* " .
					"int32* int32* LocalID* LocalID* int32* int32*";
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapDmDatabaseInfo, $format,
						$cardNo, $dbID, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

	($D0,	name		=> $params[2],
			attributes	=> $params[3],
			version		=> $params[4],
			crDate		=> $params[5],
			modDate		=> $params[6],
			bckUpDate	=> $params[7],
			modNum		=> $params[8],
			appInfoID	=> $params[9],
			sortInfoID	=> $params[10],
			type		=> $params[11],
			creator		=> $params[12]);
}


########################################################################
#
#	FUNCTION:		DmFindDatabase
#
#	DESCRIPTION:	Searches for a database by name
#
#	PARAMETERS:		card number, database name
#
#	RETURNS:		LocalID of database header
#
########################################################################

sub DmFindDatabase
{
	# LocalID DmFindDatabase (UInt cardNo, const CharPtr nameP)

	my ($return, $format) = ("LocalID", "int16 string");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapDmFindDatabase, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		DmGetDatabase
#
#	DESCRIPTION:	Finds the nth database on the card
#
#	PARAMETERS:		card number, database index
#
#	RETURNS:		LocalID of database header
#
########################################################################

sub DmGetDatabase
{
	# LocalID DmGetDatabase (UInt16 cardNo, Uint16 index)

	my ($return, $format) = ("LocalID", "int16 int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapDmGetDatabase, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		DmNextOpenDatabase
#
#	DESCRIPTION:	Returns the next open database
#
#	PARAMETERS:		A DmOpenRef (or 0 the first time)
#
#	RETURNS:		The next DmOpenRef, or 0 at the end of the chain
#
########################################################################

sub DmNextOpenDatabase
{
	# DmOpenRef DmNextOpenDatabase (DmOpenRef currentP)

	my ($return, $format) = ("rptr", "rptr");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapDmNextOpenDatabase, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		DmOpenDatabaseInfo
#
#	DESCRIPTION:	Retrieves database information
#
#	PARAMETERS:		DmOpenRef
#
#	RETURNS:		Result code from function, as well as the components
#					of a hash.  To get the result, assign the result
#					of this function to ($err, %results).  You can
#					then extract individual values from %results using
#					hash operators and the following keys: cardNo, dbID,
#					openCount, mode, resDB.
#					Example: $name = $results{name}.
#
########################################################################

sub DmOpenDatabaseInfo
{
	# Err DmOpenDatabaseInfo (DmOpenRef dbP, LocalID *dbIDP,
	#				UInt16 *openCountP, UInt16 *modeP, UInt16 *cardNoP,
	#				Boolean *resDBP)

	my ($format) = "rptr LocalID* int16* int16* int16* int16*";
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapDmOpenDatabaseInfo, $format, @_, 0, 0, 0, 0, 0);

	($D0,	dbID		=> $params[1],
			openCount	=> $params[2],
			mode		=> $params[3],
			cardNo		=> $params[4],
			resDB		=> $params[5]);
}


########################################################################
#
#	FUNCTION:		EvtEnqueuePenPoint
#
#	DESCRIPTION:	Called by the digitizer interrupt routine to enqueue
#					a pen coordinate into the pen queue.
#
#	PARAMETERS:		x and y coordinates, subtracted from 256.
#					Example: EvtEnqueuePoint (256 - 100, 256 - 80)
#					Pass in (-1, -1) to enqueue a Pen Up.
#
#	RETURNS:		size of queue in bytes
#
########################################################################

sub EvtEnqueuePenPoint
{
	# Err EvtEnqueuePenPoint (PointType* ptP)

	my ($return, $format) = ("Err", "point");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapEvtEnqueuePenPoint, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		EvtEnqueueKey
#
#	DESCRIPTION:	Called by the digitizer interrupt routine to enqueue
#					a key into the key queue.
#
#	PARAMETERS:		WChar ascii, UInt16 keycode, UInt16 modifiers
#
#	RETURNS:		size of queue in bytes
#
########################################################################

sub EvtEnqueueKey
{
	# Err EvtEnqueueKey (WChar ascii, UInt16 keycode, UInt16 modifiers)

	my ($return, $format) = ("Err", "int16 int16 int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapEvtEnqueueKey, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetActiveForm
#
#	DESCRIPTION:	This routine returns the currently active form.
#
#	PARAMETERS:		nothing
#
#	RETURNED:		Memory address on the remote device of the form.
#
########################################################################

sub FrmGetActiveForm
{
	# FormPtr FrmGetActiveForm (void)

	my ($return, $format) = ("rptr", "");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetActiveForm, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetLabel
#
#	DESCRIPTION:	This routine return the text of the specified label object
#					in the specified form.
#
#	PARAMETERS:		formP		- memory block that contains the form.
#					labelID		- id of the label object.
#
#	RETURNED:		A list containing the memory address on the remote
#					device of the label, and the label string itself.
#
########################################################################

sub FrmGetLabel
{
	# CharPtr FrmGetLabel (const FormPtr frm, const Word lableID)

	my ($return, $format) = ("string", "rptr int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetLabel, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetNumberOfObjects
#
#	DESCRIPTION:	This routine returns the number of objects in a form.
#
#	PARAMETERS:		formP		memory block that contains the form.
#
#	RETURNED:		number of object in the form specified
#
########################################################################

sub FrmGetNumberOfObjects
{
	# Word FrmGetNumberOfObjects (const FormPtr frm)

	my ($return, $format) = ("int16", "rptr");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetNumberOfObjects, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetObjectBounds
#
#	DESCRIPTION:	This routine returns the bounds of the specified form object
#
#	PARAMETERS:		formP		memory block that contains the form.
#					objIndex	index of the object
#
#	RETURNS:		The components of a hash.  To get the result, assign
#					the result of this function to %results.  You can
#					then extract individual values from %results using
#					hash operators and the following keys: top, left
#					bottom, right, width, height.
#					Example: $top = $results{top}.
#
########################################################################

sub FrmGetObjectBounds
{
	# void FrmGetObjectBounds (const FormPtr frm, const Word pObjIndex, const RectanglePtr r)

	my ($form, $obj_index) = @_;

	my ($return, $format) = ("", "rptr int16 rect");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetObjectBounds, $format,
											$form, $obj_index, {});

	my ($foo) = $params[2];
	%$foo;
}


########################################################################
#
#	FUNCTION:		FrmGetObjectId
#
#	DESCRIPTION:	This routine returns the id of the object specified.  
#					An id is a value specified by the application developer 
#					that uniquely identifies an object.
#
#	PARAMETERS:		formP		memory block that contains the form.
#					objIndex	item number of the object
#
#	RETURNED:		Object ID.
#
########################################################################

sub FrmGetObjectId
{
	# UInt16 FrmGetObjectId (const FormType * formP, UInt16 objIndex)

	my ($return, $format) = ("int16", "rptr int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetObjectId, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetObjectIndex
#
#	DESCRIPTION:	This routine returns the item number of an object, the
#					item number is the position of the object in the objects
#					list.
#
#	PARAMETERS:		formP		memory block that contains the form.
#					objId		id of an object in the form.
#
#	RETURNED:		item number of an object (the first item number is 0).
#
########################################################################

sub FrmGetObjectIndex
{
	# UInt16 FrmGetObjectIndex (const FormType * formP, UInt16 objId)

	my ($return, $format) = ("int16", "rptr int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetObjectIndex, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetObjectPtr
#
#	DESCRIPTION:	This routine returns a pointer to the data structure of an 
#					object in a form.
#
#	PARAMETERS:		formP		memory block that contains the form.
#					objIndex	item number of the object
#
#	RETURNED:		Memory address on the remote device of the object.
#					The contents of the object depend on the object type.
#
########################################################################

sub FrmGetObjectPtr
{
	# VoidPtr FrmGetObjectPtr (const FormPtr frm, const Word objIndex)

	my ($return, $format) = ("rptr", "rptr int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetObjectPtr, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetObjectType
#
#	DESCRIPTION:	This routine returns the type of an object.
#
#	PARAMETERS:		formP		memory block that contains the form.
#					objIndex	item number of the object
#
#	RETURNED:		FormObjectType of the item specified
#
########################################################################

sub FrmGetObjectType
{
	# FormObjectKind FrmGetObjectType (const FormPtr frm, const Word objIndex)

	my ($return, $format) = ("int16", "rptr int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetObjectType, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FrmGetTitle
#
#	DESCRIPTION:	This routine returns a pointer to the title string of a 
#					form.
#
#	PARAMETERS:		formP	  - memory block that contains the form.
#
#	RETURNED:		A list containing the memory address on the remote
#					device of the title, and the title string itself.
#
########################################################################

sub FrmGetTitle
{
	# const Char * FrmGetTitle (const FormType * formP)

	my ($return, $format) = ("string", "rptr");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFrmGetTitle, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		FtrGet
#
#	DESCRIPTION:	Get a PalmOS feature setting
#
#	PARAMETERS:		creator - creator id
#					featureNum - number of feature requested
#
#	RETURNS:		Result code and value of feature
#
########################################################################

sub FtrGet
{
	# Err FtrGet(UInt32 creator, UInt16 featureNum, UInt32 *valueP)

	my ($creator, $featureNum) = @_;

	my ($return, $format) = ("Err", "int32 int16 int32*");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapFtrGet, $format, $creator, $featureNum, 0);
	($D0, $params[2]);
}


########################################################################
#
#	FUNCTION:		HwrDisplayAttributes
#
#	DESCRIPTION:	Get or set Info about the Hwr display and controller
#
#	PARAMETERS:		set - true to set, false to get.  Ignored for read-only attributes
#					attr - HwrDisplayAttrType
#					dataP - data to get or set.  Must be non-NULL, as read-only
#						attributes are always read, regardless of 'set' param.
#
#	RETURNS:		
#
########################################################################

sub HwrDisplayAttributes
{
	# Err HwrDisplayAttributes(Boolean set, HwrDisplayAttrType attr, void* dataP)

	my ($set, $attr, $data) = @_;

	my ($return, $format) = ("Err", "int8 int8 block");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapHwrDisplayAttributes, $format, $set, $attr, $data);
	($D0, $params[2]);
}


########################################################################
#
#	FUNCTION:		MemChunkFree
#
#	DESCRIPTION:	Disposes of a chunk
#
#	PARAMETERS:		Pointer to chunk
#
#	RETURNS:		0 if no error
#
########################################################################

sub MemChunkFree
{
	my ($return, $format) = ("Err", "rptr");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemChunkFree, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		MemPtrFree
#
#	DESCRIPTION:	Disposes of a chunk
#
#	PARAMETERS:		Pointer to chunk
#
#	RETURNS:		0 if no error
#
########################################################################

sub MemPtrFree
{
	MemChunkFree (@_);
}


########################################################################
#
#	FUNCTION:		MemPtrNew
#
#	DESCRIPTION:	Allocates a non-movable chunk in the dynamic heap
#
#	PARAMETERS:		requested size of chunk
#
#	RETURNS:		Ptr to chunk, or 0 if error
#
########################################################################

sub MemPtrNew
{
	my ($return, $format) = ("rptr", "int32");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemPtrNew, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		MemPtrSetOwner
#
#	DESCRIPTION:	Sets the owner ID of a chunk
#
#	PARAMETERS:		chunk data pointer
#
#	RETURNS:		0 if no error
#
########################################################################

sub MemPtrSetOwner
{
	#	Err  MemPtrSetOwner (void* p, UInt16 owner)

	my ($return, $format) = ("Err", "rptr int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemPtrSetOwner, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


#/*******************************************************************
#
#	FUNCTION:		MemStoreInfo
#
#	DESCRIPTION:	Returns information on either the RAM store or
#                      the ROM store for a memory card.
#
#	PARAMETERS:		1) cardNo - either 0 or 1
#                   2) storeNumber - 0 for ROM, 1 for RAM
#                   3) versionP - Pointer to version variable, or 0.
#                   4) flagsP - Pointer to flags variable, or 0.
#                   5) nameP - Pointer to character array (32 bytes), or 0.
#                   6) crDateP - Pointer to creation date variable, or 0.
#                   7) bckUpDateP - Pointer to backup date variable, or 0.
#                   8) heapListOffsetP - Pointer to heapListOffset variable, or 0.
#                   9) initCodeOffset1P - Pointer to initCodeOffset1 variable, or 0.
#                   10) initCodeOffset2P - Pointer to initCodeOffset2 variable, or 0.
#                   11) databaseDirIDP - Pointer to database directory chunk ID variable, or 0.
#
#	RETURNS:		0 if no error, error number otherwise
#
#*******************************************************************/
sub MemStoreInfo
{
	my ($cardNo, $storeNumber) = @_;
	my ($return, $format) = ("Err", "int16 int16 int16* int16* string int32* int32* int32* int32* int32* LocalID*");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemStoreInfo, $format, $cardNo, $storeNumber, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	($D0,	version			=> $params[2],
			flags			=> $params[3],
			name			=> $params[4],
			crDate			=> $params[5],
			bckUpDate		=> $params[6],
			heapListOffset	=> $params[7],
			initCodeOffset1	=> $params[8],
			initCodeOffset2	=> $params[9],
			databaseDirID	=> $params[10]);
}


#/*******************************************************************
#
#	FUNCTION:		MemCardInfo
#
#	DESCRIPTION:	Returns information on either the RAM store or
#                      the ROM store for a memory card.
#
#	PARAMETERS:		
#
#	RETURNS:		0 if no error, error number otherwise
#
#*******************************************************************/
sub MemCardInfo
{
	my ($cardNo) = @_;
	my ($return, $format) = ("Err", "int16 string32 string32 int16* int32* int32* int32* int32*");
	my ($D0, $A0, @params) = EmRPC::DoRPC(EmSysTraps::sysTrapMemCardInfo, $format, $cardNo, 0, 0, 0, 0, 0, 0, 0);

	($D0, 	cardName		=> $params[1],
			manufName		=> $params[2],
			version			=> $params[3],
			crDate			=> $params[4],
			romSize			=> $params[5],
			ramSize			=> $params[6],
			freeBytes		=> $params[7]);
}


########################################################################
#
#	FUNCTION:		MemNumCards
#
#	DESCRIPTION:	Counts the cards on the device.
#
#	PARAMETERS:		none
#
#	RETURNS:		Usually 1.  :-)
#
########################################################################
sub MemNumCards
{
	my ($return, $format) = ("int16", "");
	my ($D0, $A0) = EmRPC::DoRPC (EmSysTraps::sysTrapMemNumCards, $format);
	EmRPC::ReturnValue ($return, $D0, $A0);
}


########################################################################
#
#	FUNCTION:		MemNumHeaps
#
#	DESCRIPTION:	Counts the heaps on the given card.
#
#	PARAMETERS:		Card number
#
#	RETURNS:		How many
#
########################################################################
sub MemNumHeaps
{
	my ($return, $format) = ("int16", "int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemNumHeaps, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		MemNumRAMHeaps
#
#	DESCRIPTION:	Counts the RAM heaps on the given card.
#
#	PARAMETERS:		Card number
#
#	RETURNS:		How many
#
########################################################################
sub MemNumRAMHeaps
{
	my ($return, $format) = ("int16", "int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemNumRAMHeaps, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		MemHeapID
#
#	DESCRIPTION:	Returns the heap ID of the j'th heap on the i'th card.
#
#	PARAMETERS:		Card number, heap index
#
#	RETURNS:		A heap ID
#
########################################################################
sub MemHeapID
{
	my ($return, $format) = ("int16", "int16 int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemHeapID, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		MemHeapDynamic
#
#	DESCRIPTION:	Returns whether the given heap is dynamic.
#
#	PARAMETERS:		A heap ID
#
#	RETURNS:		Boolean
#
########################################################################
sub MemHeapDynamic
{
	my ($return, $format) = ("int16", "int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemHeapDynamic, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		MemHeapFlags
#
#	DESCRIPTION:	Returns the given heap's flags.
#
#	PARAMETERS:		A heap ID
#
#	RETURNS:		The flags
#
########################################################################
sub MemHeapFlags
{
	my ($return, $format) = ("int16", "int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemHeapFlags, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		MemHeapSize
#
#	DESCRIPTION:	Returns the size of the given heap.
#
#	PARAMETERS:		A heap ID
#
#	RETURNS:		The size
#
########################################################################
sub MemHeapSize
{
	my ($return, $format) = ("int32", "int16");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapMemHeapSize, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


########################################################################
#
#	FUNCTION:		SysUIAppSwitch
#
#	DESCRIPTION:	Tries to make the current UI application quit and
#					then launches the given UI application by card
#					number and database ID.
#
#	PARAMETERS:		cardNo, dbID, launchCmd, cmdPBP
#
#					Note that in order to utilize the cmdPBP, you need
#					to first create a buffer on the remote side with
#					MemPtrNew and fill in its contents with
#					EmRPC::WriteBlock.  If you want to pass NULL for
#					cmdPBP, specify zero for the last parameter.
#
#	RETURNS:		errNone if no err
#
########################################################################

sub SysUIAppSwitch
{
	# Err SysUIAppSwitch(UInt16 cardNo, LocalID dbID, UInt16 cmd, MemPtr cmdPBP)

	my ($return, $format) = ("Err", "int16 LocalID int16 rptr");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapSysUIAppSwitch, $format, @_);
	EmRPC::ReturnValue ($return, $D0, $A0, @params);
}


#/*******************************************************************
#
#	FUNCTION:		SysCurAppDatabase
#
#	DESCRIPTION:	
#
#	PARAMETERS:		
#
#	RETURNS:		
#
#*******************************************************************/
sub SysCurAppDatabase {
	my ($return, $format) = ("Err", "int16* LocalID*");
	my ($D0, $A0, @params) = EmRPC::DoRPC(EmSysTraps::sysTrapSysCurAppDatabase, $format, 0, 0);

	($D0, 	cardNum		=> $params[0],
			databaseID	=> $params[1]);
}


########################################################################
#
#	FUNCTION:		WinDisplayToWindowPt
#
#	DESCRIPTION:	This routine converts a display-relative coordinate to
#					a window-relative coordinate.  The coordinate returned is 
#					relative to the draw window.
#
#	PARAMETERS:		xP	<->	x coordinate to convert
#					yP	<->	y coordinate to convert
#
#	RETURNED:		nothing
#
########################################################################

sub WinDisplayToWindowPt
{
	# void WinDisplayToWindowPt (Coord * xP, Coord * yP)

	my ($return, $format) = ("void", "Coord* Coord*");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapWinDisplayToWindowPt, $format, @_);
	($params[0], $params[1]);
}


########################################################################
#
#	FUNCTION:		WinWindowToDisplayPt
#
#	DESCRIPTION:	This routine converts a window-relative coordinate to
#					a display-relative coordinate.  The coordinate passed is 
#					assumed to be relative to the draw window.
#
#	PARAMETERS:		xP	<->	x coordinate to convert
#					yP	<->	y coordinate to convert
#
#	RETURNED:		nothing
#
########################################################################

sub WinWindowToDisplayPt
{
	# void WinWindowToDisplayPt (Coord * xP, Coord * yP)

	my ($return, $format) = ("void", "Coord* Coord*");
	my ($D0, $A0, @params) = EmRPC::DoRPC (EmSysTraps::sysTrapWinWindowToDisplayPt, $format, @_);
	($params[0], $params[1]);
}

1;