[comp.sys.m6809] gpbmap2.shar

jimomura@lsuc.uucp (Jim Omura) (06/20/88)

     Many thanks to Bob Barbato for the fix to the 'test.c' program.
Unfortunately, the system call still doesn't seem to be working,
but I'm a step closer.  At least I can get down to seeing for
certain that it's not working. :-)

     Here's a revised package for those who want to see if they
can find the problem.

Cheers! -- Jim O.

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:    Shell Archiver
#	Run the following text with /bin/sh to create:
#	ReadMe
#	makefile
#	gpbmap.a
#	test.c
# This archive created: 
# By:	Jim Omura ()
sed 's/^X//' << \SHAR_EOF > ReadMe
X88/06/20
X
X     I tried to create a C library call to control mapping
Xand unmapping of the get/put buffers.  It should work.
XFunny thing is, it doesn't.  If you can figure out why,
XI'd sure like to know.
X
X     This version of the *test* program is working better.
XThe system call still doesn't work though.
X
XCheers! -- Jim O.
SHAR_EOF
sed 's/^X//' << \SHAR_EOF > makefile
X# make.test
XCFILES = test.c
XAFILES = gpbmap.a
XLIB = -l=/dd/lib/cgfx.l -l=/dd/lib/clib.l -l=/dd/lib/sys.l
XCFLAGS = -r
X
Xtest: test.r gpbmap.r
X  rlink /dd/lib/cstart.r test.r gpbmap.r $(LIB) -o=/dd/cmds/test
X
Xtest.r: test.c
X  cc1 test.c $(CFLAGS)
X
Xgpbmap.r: gpbmap.a
X  cc1 gpbmap.a $(CFLAGS)
SHAR_EOF
sed 's/^X//' << \SHAR_EOF > gpbmap.a
X psect gpbmap_c,0,0,0,0,0
X nam gpbmap_c
X* */* gpbmap.c */
X* *
X* */* 1988 By Jim Omura
X* * * Public Domain
X* * */
X* *
X* *int
X* *gpbmap(path,group,buffer,action)
X* *int path;
X* *int group;
X* *int buffer;
X* *int action;
X* * /* Returns -1 on error */
X* *{
X ttl gpbmap
Xgpbmap:
X pshs u
X ldd #_1
X lbsr _stkcheck
X* *    path = path;
X* ldd 4,s
X* std 4,s
X* *    group = group;
X* ldd 6,s
X* std 6,s
X* *    buffer = buffer;
X* ldd 8,s
X* std 8,s
X* *    action = action;
X* ldd 10,s
X* std 10,s
X
X* /* Fast Load X register */
X lda 7,s      /* Group */
X ldb 9,s      /* Buffer */
X exg d,x      /* copy it to X */
X
X lda 5,s      /* Path */
X ldb #$84     /* SetStt option */
X ldy 10,s     /* Action */
X os9 $8e      /* I$SetStt */
X bcs errexit
X exg x,d      /* Put pointer in D */
X bra cleanexit
Xerrexit
X ldd #-1
Xcleanexit
X* *    return();
X puls u,pc
X
X* *}
X_1 equ -64
X
X* *
X endsect
SHAR_EOF
sed 's/^X//' << \SHAR_EOF > test.c
X/* test.c */
X/* tests gpbmap(path,group,buffer,action) */
X
X#include <stdio.h>
X
X#define GRPNUM 5
X#define BUFNUM 1
X
Xchar mkwin[] = { /* Make Dev Window */
X0x1b,0x20,8,0,0,40,24,15,0,0 /* 10 char */
X};
X
Xchar select[] = {
X0x1b,0x21
X};
X
Xchar mkbuf[] = {
X0x1b,0x29,GRPNUM,BUFNUM,0,0x20 /* 6 char.  Buffer = 32 bytes */
X};
X
Xchar gpld[] = {
X0x1b,0x2b,GRPNUM,BUFNUM,8,0,16,0,1,0,8 /* 11 bytes */
X};
X
Xchar messg[] = {  /* 8 Bytes */
X'H','i',' ','T','h','e','r','e'
X};
X
Xchar kilbuf[] = {
X0x1b,0x2a,GRPNUM,0 /* 4 bytes */
X};
X
Xchar dwend[] = {
X0x1b,0x24
X};
X
Xmain()
X{
X    char *buffer;
X    int path;
X    path = open("/w",3);
X    write(path,mkwin,10);
X    write(path,select,2);
X    write(path,mkbuf,6);
X    write(path,gpld,11);
X    write(path,messg,8);
X    write(path,"Message sent\n",12);
X    for(;;)
X    {
X        if(_gs_rdy(path) > 0)
X        {
X            break;
X        }
X    }
X    buffer = gpbmap(path,GRPNUM,BUFNUM,1);
X    if(buffer = -1)
X    {
X        fprintf(stderr,"Error\n");
X    }
X    else
X    {
X        fprintf(stderr,"BfAdd %1x\n",buffer);
X        write(2,buffer,8); /* Write it to STDERR */
X    }
X    gpbmap(path,GRPNUM,BUFNUM,0); /* Unmap */
X    for(;;)
X    {
X        if(_gs_rdy(path) > 0)
X        {
X            break;
X        }
X    }
X    write(path,kilbuf,4);
X/*    write(path,dwend,2); /* Not Nec. */
X    close(path);
X}
X
SHAR_EOF
#	End of shell archive
exit 0
-- 
Jim Omura, 2A King George's Drive, Toronto, (416) 652-3880
ihnp4!utzoo!lsuc!jimomura
Byte Information eXchange: jimomura