linking

Philip Ludlam philip at philipnet.com
Tue May 20 18:58:04 BST 2003


On 20 May, in message <Marcel-1.53-0520102240-0b0EaaH at freeserve.net>
  nex <nex at moose.co.uk> wrote:

>On Tue 20 May, Philip Ludlam wrote:
>> 
>> On 19 May, in message <Marcel-1.53-0519153429-b49EaaH at freeserve.net>
>>   nex <nex at moose.co.uk> wrote:
>> 
>> >
>> >i dont seem to be able to get acorn/castle c/c++ to link osspriteop.h
>> >
>> >anyone help me out?
>> 
>> You need to #include "oslib/osspriteop.h" in the C file.
>> And you need to have -IOSLib: in the cc command line
>> And you need to have the OSLib:o.OSlib32 object file in the link command
>> line.
>
>i'm pretty sure i tried this, but what i ended up doing was moving the dir h
>out of the oslib dir inside OSlib dir and altering all the h files removing
>the oslib/ from them all, this will probably have disatarous effects at some
>point :)

Probably. OSLib isn't designed to be used like that. 

>what I could use is a bit of help with setting up sprite areas, i'm not
>sure on how i would do this using osspriteop.h, also i'm unsure about
>the difference between osspriteop calls and xospriteop calls

OK.
I suggest you read <path to OSLib>.Docs.OSLib_API
Simply: X... calls the X form of the SWI, otherwise it doesn't.
The former is understandably preferred.

>In my games that use OSSpritOp do this :

I would be something like the follow (which is totally untested, not
complete and is highly likely not to compile the first time!).
I haven't done any work with osspriteop and OSLib so some aspects I'm
not sure about until I sit down with a compiler and some code I want to
write.
So here goes:

#define E(a) if ((a)!=NULL) {wimp_error(a,1);}
#define TASKNAME Task
// Calls Wimp_ReportError and then quits if a SWI fails.
int wimp_error (os_error * err, int flags) {
  int click;
  if ((xwimp_report_error (err, flags, TASKNAME, &click)) != 0) {
    printf ("error_wimp_error failed\n");
      exit (EXIT_FAILURE);
  }
  return click;
}

> DEF PROCsprites
void sprites () {
os_error * err;
>sprs%=7
int sprs = 7;
>DIM spx% &30000:!spx%=&30000:spx%!4=0:spx%!8=16:spx%!12=16
ossprite_area *spx,
spx = (void) malloc (0x30000);
spx->size=0x30000
> DIM sp% &30000:!sp%=&30000:sp%!4=0:sp%!8=16:sp%!12=16
ossprite_area *sp;
sp = (void) malloc (0x30000);
sp->size=0x30000
// I don't think you need to setup the rest of the sprite area but I
// always call initialise:
err = xosspriteop_clear_sprites (osspriteop_USER_AREA, spx);
E (err);
err = xosspriteop_clear_sprites (osspriteop_USER_AREA, sp);
E (err);
> SYS "OS_SpriteOp",266,sp%,"<range$dir>.sprites"
err = xosspriteop_load_sprite_file (osspriteop_USER_AREA, sp,
  "<range$dir>.sprites");
E (err);
> DIM T%(sprs%)
int t[sprs];
> FOR I%=0TOsprs%
for (i = 0; i<=sprs; i++) {
> SYS "OS_SpriteOp",256+24,sp%,STR$(I%) TO ,,T%(I%)
err = xosspriteop_select_sprite (osspriteop_USER_AREA, sp,
  Œ, Œ);
E (err);
> NEXT
}
>DIM Tx%(1)
int tx[1];
>I$="1"       // Are these two
char i = '1'; // really required?
>SYS &2e,&f+256,spx%,"1",0,256,320,28
err = xosspriteop_create_sprite (osspriteop_USER_AREA, spx,
  "1", FALSE, 256, 320, 28);
E (err);
>SYS "OS_SpriteOp",256+24,spx%,"1" TO ,,Tx%(1)
err = xosspriteop_select_sprite (osspriteop_USER_AREA, spx,
  Œ, Œ);
E (err);
> ENDPROC
}
> I'm not sure about using osspriteop_USER_AREA flags either

Does that example help?
(they're used to represent the 256 in above).

Yours,

Phil L.
-- 
http://www.philipnet.com




More information about the oslib-user mailing list