Beispiel #1
0
PRIVATE CTabHandle
ctab_from_surface (SDL_Surface *surfp)
{
  CTabHandle retval;
  int n_colors;
  SDL_Color *ip;
  ColorSpec *op;
  int i;

  retval = NULL;

  n_colors = SDL_n_colors (surfp);
  retval = (CTabHandle) NewHandle (CTAB_STORAGE_FOR_SIZE (n_colors-1));
  CTAB_SIZE_X (retval) = CW (n_colors - 1);
  CTAB_SEED_X (retval) = CL (GetCTSeed ());
  CTAB_FLAGS_X (retval) = CTAB_GDEVICE_BIT_X;
  
  for (i = 0, ip = SDL_colors (surfp), op = CTAB_TABLE (retval);
       i < n_colors;
       ++i, ++ip, ++op)
    {
      op->value = CWC (0);
      op->rgb.red = MAC_COLOR_COMPONENT_FROM_SDL_CC (ip->r);
      op->rgb.green = MAC_COLOR_COMPONENT_FROM_SDL_CC (ip->g);
      op->rgb.blue = MAC_COLOR_COMPONENT_FROM_SDL_CC (ip->b);
    }

  return retval;
}
Beispiel #2
0
PUBLIC OSErr
HOpenRF (INTEGER vref, LONGINT dirid, Str255 name, SignedByte perm,
         INTEGER *refp)
{
    HParamBlockRec hpb;
    OSErr retval;

    hpb.fileParam.ioNamePtr = RM (name);
    hpb.fileParam.ioVRefNum = CW (vref);
    hpb.ioParam.ioPermssn = CB (perm);
    hpb.ioParam.ioMisc = CLC (0);
    hpb.fileParam.ioDirID = CL (dirid);
    retval = PBHOpenRF (&hpb, FALSE);
    if (retval == noErr)
        *refp = CW (hpb.ioParam.ioRefNum);
    return retval;
}
Beispiel #3
0
void testUtf8Circular(std::string const & fn)
{
	::libmaus::util::Utf8String us(fn);
	::libmaus::aio::Utf8CircularWrapper CW(fn);

	for ( uint64_t i = 0; i < 16*us.size(); ++i )
		assert ( us[i%us.size()] == static_cast<wchar_t>(CW.get()) );
}
Beispiel #4
0
P2(PUBLIC pascal trap, void, SystemClick, EventRecord *, evp, WindowPtr, wp)
{
    Point p;
    LONGINT pointaslong, val;
    Rect bounds;
    LONGINT templ;

    if (wp) {
	p.h = CW(evp->where.h);
	p.v = CW(evp->where.v);
	if (PtInRgn (p, WINDOW_STRUCT_REGION (wp)))
	  {
	    pointaslong = ((LONGINT)p.v << 16)|(unsigned short)p.h;
	    val = WINDCALL((WindowPtr) wp, wHit, pointaslong);
	    switch (val) {
	    case wInContent:
		if (WINDOW_HILITED_X (wp))
		  {
		    templ = (LONGINT) (long) RM(evp);
		    Control (WINDOW_KIND (wp), accEvent, (Ptr) &templ);
		} else
		    SelectWindow(wp);
		break;
	    case wInDrag:
		bounds.top    = CW (CW (MBarHeight) + 4);
		bounds.left   = CW (CW (GD_BOUNDS (MR (TheGDevice)).left) + 4);
		bounds.bottom = CW (CW (GD_BOUNDS (MR (TheGDevice)).bottom) - 4);
		bounds.right  = CW (CW (GD_BOUNDS (MR (TheGDevice)).right) - 4);
		DragWindow(wp, p, &bounds);
		break;
	    case wInGoAway:
		if (TrackGoAway(wp, p))
		    CloseDeskAcc (WINDOW_KIND (wp));
		break;
	    }
	} else {
	    if (DeskHook) {
		ROMlib_hook(desk_deskhooknumber);
		EM_D0 = -1;
		EM_A0 = (LONGINT) (long) US_TO_SYN68K(evp);
		CALL_EMULATOR((syn68k_addr_t) (long) CL((long) DeskHook));
	    }
	}
    }
}
Beispiel #5
0
A3(PUBLIC, OSErr, SerSetBuf, INTEGER, rn, Ptr, p, INTEGER, len)	/* IMII-251 */
{
    sersetbuf_t temp;

    temp.p = RM (p);
    temp.i = CW (len);

    return Control(rn, SERSETBUF, (Ptr) &temp);
}
Beispiel #6
0
P2 (PUBLIC pascal trap, INTEGER, FSpOpenResFile,
    FSSpecPtr, spec, SignedByte, perms)
{
    INTEGER retval;

    retval = HOpenResFile (CW (spec->vRefNum), CL (spec->parID), spec->name,
                           perms);
    return retval;
}
Beispiel #7
0
P3(PUBLIC pascal trap, LONGINT, PutScrap, LONGINT, len, ResType, rest, Ptr, p)
{
    OSErr retval;
    LONGINT l, swappedlen;
    INTEGER f;

    LONGINT *lp;

    if (Cx(ScrapState) < 0) {
        retval = ZeroScrap();
	if (retval != noErr)
/*-->*/	    return(retval);
    }
#if defined(X) || defined(NEXTSTEP) || defined (SDL)
    PutScrapX(rest, len, (char *) p, CW (ScrapCount));
#endif /* defined(X) */
    if (Cx(ScrapState) == 0) {
        retval = FSOpen(MR(ScrapName), CW (BootDrive), &f);
        if (retval != noErr)
/*-->*/     return(retval);
        SetFPos(f, fsFromStart, (LONGINT)Cx(ScrapSize));
        l = 4;
	rest = CL(rest);
        FSWriteAll(f, &l, (Ptr) &rest);
        l = 4;
	swappedlen = CL(len);
        FSWriteAll(f, &l, (Ptr) &swappedlen);
        l = len = (len + 1) & -2L;
        FSWriteAll(f, &len, p);
        FSClose(f);
    } else {
        SetHandleSize(MR(ScrapHandle), (Size)Cx(ScrapSize) + 8);
	if (MemErr != noErr)
/*-->*/	    return CW(MemErr);
	/* alignment stuff */
        lp = (LONGINT *)((char *)STARH(MR(ScrapHandle)) + Cx(ScrapSize));
        *lp++ = CL(rest);
        *lp++ = CL(len);
        len = (len + 1) & -2L;
        PtrAndHand(p, MR(ScrapHandle), (Size)len);
    }
    ScrapSize = CL(CL(ScrapSize) + 8 + len);
    return noErr;
}
void tower_tip()
{
	CW();
	//Jae
	forwardT(700,2);
	sleep(1);
	reverseT(700,4);
	sleep(1);
	//Jae
}
Beispiel #9
0
P4 (PUBLIC pascal trap, OSErr, FSpCreate,
    FSSpecPtr, spec, OSType, creator, OSType, file_type,
    ScriptCode, script)
{
    OSErr retval;

    retval = HCreate (CW (spec->vRefNum), CL (spec->parID), spec->name,
                      creator, file_type);
    return retval;
}
Beispiel #10
0
PRIVATE save_fcb_info_t *
get_fcb_info (FSSpecPtr fsp)
{
    filecontrolblock *fcbp, *efcbp;
    INTEGER total_length, fcb_size;
    save_fcb_info_t *retval;
    char *fcbsptr;
    INTEGER swapped_vrefnum;
    LONGINT swapped_fnum;


    retval = 0;

    swapped_vrefnum = fsp->vRefNum;
    swapped_fnum = CL (get_file_num (fsp));

    fcbsptr = (char *) CL (FCBSPtr);
    total_length = CW(*(short *)fcbsptr);
    fcbp = (filecontrolblock *) ((short *)CL(FCBSPtr)+1);
    efcbp = (filecontrolblock *) ((char *)CL(FCBSPtr) + total_length);
    fcb_size = CW (FSFCBLen);
    for (; fcbp < efcbp; fcbp = (filecontrolblock *) ((char *)fcbp + fcb_size))
    {
        HVCB *vptr;

        vptr = CL (fcbp->fcbVPtr);
        if (vptr && vptr->vcbVRefNum == swapped_vrefnum
                && fcbp->fcbFlNum == swapped_fnum)
        {
            save_fcb_info_t *newp;

            newp = malloc (sizeof *newp);
            newp->refnum = (char *) fcbp - fcbsptr;
            newp->fcb = *fcbp;
            newp->next = retval;
            newp->vptr = fcbp->fcbVPtr;
            fcbp->fcbVPtr = 0; /* hide this open file */
            retval = newp;
        }
    }
    return retval;
}
Beispiel #11
0
int NvEnvUpdateLCDConfig(void)
{
	int iRes;
	size_t iSize;;

	nv_lcd_config_t *pLCDConfig = (nv_lcd_config_t *)(gd->bd->bi_boot_params + 0x1980);

	iRes = CW( NvOSCfgGet( NVOS_LCD_CONFIG, pLCDConfig, sizeof( nv_lcd_config_t ), &iSize ) );

	return iRes;
}
Beispiel #12
0
P2(PUBLIC pascal trap, void, SetResFileAttrs, INTEGER, rn, INTEGER, attrs)
{
    resmaphand map;

    ROMlib_setreserr(noErr);
    map = ROMlib_rntohandl(rn, (Handle *)0);
    if (!map)
        return;               /* don't set reserr.  I kid you not, see I-127 */
    else
        HxX(map, resfatr) = CW (attrs);
}
Beispiel #13
0
void NvEnvUseDefault( void )
{
	memset( env_ptr, 0, sizeof(env_t) );
	memcpy( env_ptr->data,
                default_environment,
                CONFIG_ENV_SIZE );

	env_ptr->crc = crc32( 0, env_ptr->data, CONFIG_ENV_SIZE );
	gd->env_valid = 1;

        CW( NvEnvUpdateFromNVRAM() );
}
Beispiel #14
0
int NvEnvUpdateFromNVRAM( void )
{
        int iRes = 1;
        int i;
        nv_critical_t* pCrit;
        char szTmp[ 40 ];

        if( !CW( NvCriticalGet( &pCrit ) ) )
            return 0;

        for( i = 0; i < ARRAY_SIZE( l_axParam ); i++ ) {
                char* argvSetEnv[] = { "setenv", NULL, NULL };
                const env_param_t* pParam = &l_axParam[ i ];
                void* pvAddr;

                argvSetEnv[ 1 ] = (char*) pParam->szName;
                argvSetEnv[ 2 ] = szTmp;

                pvAddr = (char*) pCrit + pParam->iOffs;
                switch( pParam->eType ) {
                    case ENV_MAC:
                        strncpy( szTmp,
                                 NvToStringMAC( *(nv_mac_t*) pvAddr ),
                                 sizeof( szTmp ));
                        break;
                    case ENV_IP:
                    {
                            nv_ip_t ip = *(nv_ip_t*) pvAddr;
                            strncpy( szTmp,
                                     NvToStringIP( ip ),
                                     sizeof( szTmp ));
                    }
                    break;
                    case ENV_BOOL_ON:
                        sprintf( szTmp, "%s",
                                 ( *(char*) pvAddr ? "on" : "off" ) );
                        break;
                }

                DEBUG( "Adding to U-Boot from NVRAM %s=%s\n",
                       argvSetEnv[ 1 ], argvSetEnv[ 2 ] );

                _do_orig_setenv( 0, ARRAY_SIZE( argvSetEnv ), argvSetEnv );
        }

#if defined(CONFIG_CMD_UBI)
	if ( !PartSetMtdParts() ) {
		return 0;
	}
#endif

        return iRes;
}
Beispiel #15
0
P1(PUBLIC pascal trap, BOOLEAN, SystemEvent, EventRecord *, evp)
{
    BOOLEAN retval;
    WindowPeek wp;
    INTEGER rn;
    DCtlHandle dctlh;
    LONGINT templ;

    if (SEvtEnb) {
	wp = 0;
	switch (evp->what) {
	default:
	case CWC(nullEvent):
	case CWC(mouseDown):
	case CWC(networkEvt):
	case CWC(driverEvt):
	case CWC(app1Evt):
	case CWC(app2Evt):
	case CWC(app3Evt):
	case CWC(app4Evt):
	    break;
	case CWC(mouseUp):
	case CWC(keyDown):
	case CWC(keyUp):
	case CWC(autoKey):
	    wp = (WindowPeek) FrontWindow();
	    break;
	case CWC(updateEvt):
	case CWC(activateEvt):
	    wp = (WindowPeek) MR(evp->message);
	    break;
	case CWC(diskEvt):
	    /* NOTE:  I think the code around toolevent.c:277 should
		      really be here.  I'm not going to get all excited
		      about it right now though. */
	    break;
	}
	if (wp) {
	    rn = WINDOW_KIND (wp);
	    if ((retval = rn < 0)) {
		dctlh = rntodctlh(rn);
		if (Hx(dctlh, dCtlEMask) & (1 << CW(evp->what))) {
		    templ = (LONGINT) (long) RM(evp);
		    Control(rn, accEvent, (Ptr) &templ);
		}
	    }
	} else
	    retval = FALSE;

    } else
	retval = FALSE;
    return retval;
}
Beispiel #16
0
PRIVATE OSErr
raw_read_write (func_t func, our_file_info_t *op, LONGINT *lengthp,
		char buf[])
{
  OSErr retval;
  ParamBlockRec pbr;

  check_virtual_interrupt ();
  pbr.ioParam.ioVRefNum = CW (op->vref);
  pbr.ioParam.ioRefNum = CW (op->dref);
  pbr.ioParam.ioBuffer = (Ptr) RM (buf);
  pbr.ioParam.ioReqCount = CL (*lengthp);
  pbr.ioParam.ioPosMode = CWC (fsFromStart);
  pbr.ioParam.ioPosOffset = CL (op->pos);
  retval = func (&pbr, FALSE);
  if (retval == noErr)
    {
      *lengthp = CL (pbr.ioParam.ioActCount);
      op->pos += CL (pbr.ioParam.ioActCount);
    }
  return retval;
}
Beispiel #17
0
A3(PRIVATE, void, getpoint, INTEGER, angle, Rect *, r, Point *, ptp)
{
    INTEGER left  = CW(r->left),  top    = CW(r->top),
            right = CW(r->right), bottom = CW(r->bottom);
    INTEGER radh = (right - left) / 2,
            radv = (bottom - top) / 2;
    INTEGER centh = left + radh,
            centv = top  + radv;
    
    MoveTo(centh, centv);
    if (angle == 0) {
/*-->*/ returnhv(centh, top)
    } else if (angle == 90) {
/*-->*/ returnhv(right, centv)
    } else if (angle == 180) {
/*-->*/ returnhv(centh, bottom)
    } else if (angle == 270) {
/*-->*/ returnhv(left, centv)
    } else if (angle >=  45 && angle <= 135) {
/*-->*/ returnhv(right, centv - (INTEGER)(FixMul(SlopeFromAngle(90-angle),
                                    -(LONGINT) radv << 16) >> 16))
    } else if (angle >= 225 && angle <= 315) {
Beispiel #18
0
P1(PUBLIC pascal trap, void, SystemMenu, LONGINT, menu)
{
    INTEGER i;
    DCtlHandle dctlh;

    for (i = 0; i < CW(UnitNtryCnt); ++i) {
	dctlh = MR(MR(UTableBase)[i].p);
	if (HxX(dctlh, dCtlMenu) == MBarEnable) {
	    menu = CL(menu);
	    Control(itorn(i), accMenu, (Ptr) &menu);
/*-->*/	    break;
	}
    }
}
Beispiel #19
0
int saveenv( void )
{
        int iRes;
        int i;
        char* argvSetEnv[ 4 ] = { "setenv", NULL, NULL };

        /* remove environment variables used by us */
        for( i = 0; i < ARRAY_SIZE( l_axParam ); i++ ) {
                argvSetEnv[ 1 ] = (char*) l_axParam[ i ].szName;
                DEBUG( "Removing from U-Boot NVRAM %s\n",
                         argvSetEnv[ 1 ] );
                /* ignore if it works or not */
                _do_orig_setenv( 0, ARRAY_SIZE( argvSetEnv ), argvSetEnv );
        }

        iRes = CW( NvOSCfgSet( NVOS_UBOOT, env_ptr, CONFIG_ENV_SIZE ) );
        if( iRes )
                iRes &= CW( NvSave() );

        CW( NvEnvUpdateFromNVRAM() );

        return ( iRes ? 0 : -1 );
}
Beispiel #20
-1
A0(PUBLIC, LONGINT, ROMlib_ZeroScrap)
{
    OSErr retval;
    INTEGER f;
    THz saveZone;
    
    if (Cx(ScrapState) < 0) {
        ScrapCount = 0;
	saveZone = TheZone;
	TheZone = SysZone;
        ScrapHandle = RM(NewHandle((Size)0));
	TheZone = saveZone;
        ScrapState = CWC (1);
        ScrapName = RM((StringPtr) "\016Clipboard File");
    } else if (Cx(ScrapState) == 0) {
        retval = cropen(&f);
        if (retval != noErr)
            return retval;
        retval = SetEOF(f, (LONGINT)0);
        if (retval != noErr)
            return retval;
        FSClose(f);
    } else if (Cx(ScrapState) > 0)
        SetHandleSize(MR(ScrapHandle), (Size)0);
    ScrapSize = 0;
    ScrapCount = CW(CW(ScrapCount) + 1);
    return noErr;
}
Beispiel #21
-1
A3(PRIVATE, void, drawtextstring, INTEGER, id, INTEGER, offsetx,
   INTEGER, offsety)
{
    struct tdef *tp;

    if (id && (tp = (struct tdef *) findid(id))) {
        MoveTo(CW(tp->loc.h) + offsetx, CW(tp->loc.v) + offsety);
        DrawText_c_string (tp->text);
    }
}
Beispiel #22
-1
A1(PUBLIC, INTEGER, ROMlib_setreserr, INTEGER, reserr)	/* INTERNAL */
{
    ResErr = CW(reserr);
    if (ResErr != noErr && ResErrProc) {
	ROMlib_hook(res_reserrprocnumber);

	EM_D0 = (unsigned short) reserr;	/* TODO: is unsigned short
							 correct? */
	CALL_EMULATOR((syn68k_addr_t)  CL((long) ResErrProc));
    }
    return CW(ResErr);
}
Beispiel #23
-1
A1(PRIVATE, INTEGER *, findid, INTEGER, id)
{
    int i;
    INTEGER *ip;

    for (i = CW(*(INTEGER *) MR(DSAlertTab)),
            ip = (INTEGER *) MR(DSAlertTab) + 1;
            i > 0 && CW(*ip) != id;
            --i, ip = (INTEGER *) ((char *) ip + CW(ip[1]) + 2 * sizeof(INTEGER)))
        ;
    return i > 0 ? ip : (INTEGER *) 0;
}
Beispiel #24
-1
A1(PRIVATE, OSErr, cropen, INTEGER *, fp)
{
    OSErr retval;
    
    retval = FSOpen(MR(ScrapName), CW (BootDrive), fp);
    if (retval == fnfErr) {
        retval = Create(MR(ScrapName), CW (BootDrive), TICK("MACS"), TICK("CLIP"));
        if (retval != noErr)
            return(retval);
        return(FSOpen(MR(ScrapName), CW (BootDrive), fp));
    }
    return(retval);
}
Beispiel #25
-1
A3(PUBLIC, void, ROMlib_hminmax, INTEGER *, minp,		/* INTERNAL */
						 INTEGER *, maxp, ListPtr, lp)
{
    *minp = CW(lp->dataBounds.left);
    *maxp = *minp + CW(lp->dataBounds.right) - CW(lp->visible.right) +
                                               CW(lp->visible.left);
    if (CW(lp->cellSize.h) * (CW(lp->visible.right) - CW(lp->visible.left)) > 
				      CW(lp->rView.right) - CW(lp->rView.left))
	++*maxp;
}
Beispiel #26
-1
A3(PUBLIC, void, ROMlib_vminmax, INTEGER *, minp,		/* INTERNAL */
						 INTEGER *, maxp, ListPtr, lp)
{
    *minp = CW(lp->dataBounds.top);
    *maxp = *minp + CW(lp->dataBounds.bottom) - CW(lp->visible.bottom) +
                                                CW(lp->visible.top);
    if (CW(lp->cellSize.v) * (CW(lp->visible.bottom) - CW(lp->visible.top)) > 
				      CW(lp->rView.bottom) - CW(lp->rView.top))
	++*maxp;
}
Beispiel #27
-1
int
ueagle_boot(struct ueagle_softc *sc)
{
	uint16_t zero = 0; /* ;-) */
	usbd_status error;
#define CW(sc, address, offset, data) do {				\
	if ((error = ueagle_cw(sc, address, offset, data)) != 0)	\
		return error;						\
} while (0)

	ueagle_request(sc, UEAGLE_SETMODE, UEAGLE_BOOTIDMA, NULL, 0);
	ueagle_request(sc, UEAGLE_SETMODE, UEAGLE_STARTRESET, NULL, 0);

	usbd_delay_ms(sc->sc_udev, 200);

	ueagle_request(sc, UEAGLE_SETMODE, UEAGLE_ENDRESET, NULL, 0);
	ueagle_request(sc, UEAGLE_SET2183DATA, UEAGLE_MPTXMAILBOX, &zero, 2);
	ueagle_request(sc, UEAGLE_SET2183DATA, UEAGLE_MPRXMAILBOX, &zero, 2);
	ueagle_request(sc, UEAGLE_SET2183DATA, UEAGLE_SWAPMAILBOX, &zero, 2);

	usbd_delay_ms(sc->sc_udev, 1000);

	sc->pageno = 0;
	sc->ovl = 0;
	ueagle_loadpage(sc);

	/* wait until modem reaches operational state */
	error = tsleep(UEAGLE_COND_READY(sc), PZERO | PCATCH, "boot", 10 * hz);
	if (error != 0) {
		printf("%s: timeout waiting for operational state\n",
		    sc->sc_dev.dv_xname);
		return error;
	}

	CW(sc, UEAGLE_CMV_CNTL, 0, 1);

	/* send configuration options */
	CW(sc, UEAGLE_CMV_OPTN, 0, UEAGLE_OPTN0);
	CW(sc, UEAGLE_CMV_OPTN, 2, UEAGLE_OPTN2);
	CW(sc, UEAGLE_CMV_OPTN, 7, UEAGLE_OPTN7);

	/* continue with synchronization */
	CW(sc, UEAGLE_CMV_CNTL, 0, 2);

	return kthread_create(ueagle_stat_thread, sc, &sc->stat_thread,
	    sc->sc_dev.dv_xname);
#undef CW
}
Beispiel #28
-1
P0(PUBLIC pascal trap, LONGINT, LoadScrap)
{
    OSErr retval;
    INTEGER f;
    LONGINT l = Cx(ScrapSize);
    
    if (ScrapState == 0) {
        retval = FSOpen(MR(ScrapName), CW (BootDrive), &f);
        if (retval != noErr)
            return(retval);

        HUnlock(MR(ScrapHandle));
        ReallocHandle(MR(ScrapHandle), (Size)Cx(ScrapSize));
	if (MemErr != noErr)
/*-->*/	    return Cx(MemErr);
        HLock(MR(ScrapHandle));
        retval = FSReadAll(f, &l, STARH(MR(ScrapHandle)));
        HUnlock(MR(ScrapHandle));
        if (retval != noErr)
            return(retval);
        SetEOF(f, (LONGINT) 0);
        FSClose(f);
        ScrapState = CWC (1);
    }
    return(Cx(ScrapState) > 0 ? noErr : noScrapErr);
}
Beispiel #29
-1
P4 (PUBLIC pascal trap, void, FSpCreateResFile,
    FSSpecPtr, spec, OSType, creator, OSType, file_type,
    ScriptCode, script)
{
    HCreateResFile_helper (CW (spec->vRefNum), CL (spec->parID),
                           spec->name, creator, file_type, script);
}
Beispiel #30
-1
P1(PUBLIC pascal trap, INTEGER, OpenDeskAcc, Str255, acc)	/* IMI-440 */
{
    INTEGER retval;
    DCtlHandle dctlh;
    WindowPtr wp;

    if (EqualString (acc, about_box_menu_name_pstr, TRUE, TRUE))
      {
	do_about_box ();
	retval = 0;
	goto done;
      }

    if (OpenDriver(acc, &retval) == noErr) {
	retval = CW(retval);
	dctlh = GetDCtlEntry(retval);
	if (dctlh)
	  {
	    wp = HxP(dctlh, dCtlWindow);
	    if (wp)
	      {
		ShowWindow(wp);
		SelectWindow(wp);
	      }
	  }
    }

  done:

    SEvtEnb = TRUE;
    return retval;
}