예제 #1
0
/** Applies delta files to create an upgraded package file.
 *
 * All intermediate files are deleted, leaving only the starting and
 * ending package files.
 *
 * @param handle the context handle
 *
 * @return 0 if all delta files were able to be applied, 1 otherwise.
 */
static int apply_deltas(alpm_handle_t *handle)
{
	alpm_list_t *i;
	int ret = 0;
	const char *cachedir = _alpm_filecache_setup(handle);
	alpm_trans_t *trans = handle->trans;

	for(i = trans->add; i; i = i->next) {
		alpm_pkg_t *spkg = i->data;
		alpm_list_t *delta_path = spkg->delta_path;
		alpm_list_t *dlts = NULL;

		if(!delta_path) {
			continue;
		}

		for(dlts = delta_path; dlts; dlts = dlts->next) {
			alpm_delta_t *d = dlts->data;
			char *delta, *from, *to;
			char command[PATH_MAX];
			size_t len = 0;

			delta = _alpm_filecache_find(handle, d->delta);
			/* the initial package might be in a different cachedir */
			if(dlts == delta_path) {
				from = _alpm_filecache_find(handle, d->from);
			} else {
				/* len = cachedir len + from len + '/' + null */
				len = strlen(cachedir) + strlen(d->from) + 2;
				CALLOC(from, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, 1));
				snprintf(from, len, "%s/%s", cachedir, d->from);
			}
			len = strlen(cachedir) + strlen(d->to) + 2;
			CALLOC(to, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, 1));
			snprintf(to, len, "%s/%s", cachedir, d->to);

			/* build the patch command */
			if(endswith(to, ".gz")) {
				/* special handling for gzip : we disable timestamp with -n option */
				snprintf(command, PATH_MAX, "xdelta3 -d -q -R -c -s %s %s | gzip -n > %s", from, delta, to);
			} else {
				snprintf(command, PATH_MAX, "xdelta3 -d -q -s %s %s %s", from, delta, to);
			}

			_alpm_log(handle, ALPM_LOG_DEBUG, "command: %s\n", command);

			EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta);

			int retval = system(command);
			if(retval == 0) {
				EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_DONE, NULL, NULL);

				/* delete the delta file */
				unlink(delta);

				/* Delete the 'from' package but only if it is an intermediate
				 * package. The starting 'from' package should be kept, just
				 * as if deltas were not used. */
				if(dlts != delta_path) {
					unlink(from);
				}
			}
			FREE(from);
			FREE(to);
			FREE(delta);

			if(retval != 0) {
				/* one delta failed for this package, cancel the remaining ones */
				EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCH_FAILED, NULL, NULL);
				handle->pm_errno = ALPM_ERR_DLT_PATCHFAILED;
				ret = 1;
				break;
			}
		}
	}

	return ret;
}
예제 #2
0
/** Commit a transaction. */
int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
{
	alpm_trans_t *trans;
	alpm_event_any_t event;

	/* Sanity checks */
	CHECK_HANDLE(handle, return -1);

	trans = handle->trans;

	ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
	ASSERT(trans->state == STATE_PREPARED, RET_ERR(handle, ALPM_ERR_TRANS_NOT_PREPARED, -1));

	ASSERT(!(trans->flags & ALPM_TRANS_FLAG_NOLOCK), RET_ERR(handle, ALPM_ERR_TRANS_NOT_LOCKED, -1));

	/* If there's nothing to do, return without complaining */
	if(trans->add == NULL && trans->remove == NULL) {
		return 0;
	}

	if(trans->add) {
		if(_alpm_sync_load(handle, data) != 0) {
			/* pm_errno is set by _alpm_sync_load() */
			return -1;
		}
		if(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY) {
			return 0;
		}
		if(_alpm_sync_check(handle, data) != 0) {
			/* pm_errno is set by _alpm_sync_check() */
			return -1;
		}
	}

	if(_alpm_hook_run(handle, ALPM_HOOK_PRE_TRANSACTION) != 0) {
		RET_ERR(handle, ALPM_ERR_TRANS_HOOK_FAILED, -1);
	}

	trans->state = STATE_COMMITING;

	alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction started\n");
	event.type = ALPM_EVENT_TRANSACTION_START;
	EVENT(handle, (void *)&event);

	if(trans->add == NULL) {
		if(_alpm_remove_packages(handle, 1) == -1) {
			/* pm_errno is set by _alpm_remove_packages() */
			alpm_errno_t save = handle->pm_errno;
			alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction failed\n");
			handle->pm_errno = save;
			return -1;
		}
	} else {
		if(_alpm_sync_commit(handle) == -1) {
			/* pm_errno is set by _alpm_sync_commit() */
			alpm_errno_t save = handle->pm_errno;
			alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction failed\n");
			handle->pm_errno = save;
			return -1;
		}
	}

	if(trans->state == STATE_INTERRUPTED) {
		alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction interrupted\n");
	} else {
		event.type = ALPM_EVENT_TRANSACTION_DONE;
		EVENT(handle, (void *)&event);
		alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction completed\n");
		_alpm_hook_run(handle, ALPM_HOOK_POST_TRANSACTION);
	}

	trans->state = STATE_COMMITED;

	return 0;
}
예제 #3
0
int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
{
	alpm_list_t *i, *j;
	alpm_list_t *deps = NULL;
	alpm_list_t *unresolvable = NULL;
	int from_sync = 0;
	int ret = 0;
	alpm_trans_t *trans = handle->trans;
	alpm_event_t event;

	if(data) {
		*data = NULL;
	}

	for(i = trans->add; i; i = i->next) {
		alpm_pkg_t *spkg = i->data;
		if (spkg->origin == ALPM_PKG_FROM_SYNCDB){
			from_sync = 1;
			break;
		}
	}

	/* ensure all sync database are valid if we will be using them */
	for(i = handle->dbs_sync; i; i = i->next) {
		const alpm_db_t *db = i->data;
		if(db->status & DB_STATUS_INVALID) {
			RET_ERR(handle, ALPM_ERR_DB_INVALID, -1);
		}
		/* missing databases are not allowed if we have sync targets */
		if(from_sync && db->status & DB_STATUS_MISSING) {
			RET_ERR(handle, ALPM_ERR_DB_NOT_FOUND, -1);
		}
	}

	if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
		alpm_list_t *resolved = NULL;
		alpm_list_t *remove = alpm_list_copy(trans->remove);
		alpm_list_t *localpkgs;

		/* Build up list by repeatedly resolving each transaction package */
		/* Resolve targets dependencies */
		event.type = ALPM_EVENT_RESOLVEDEPS_START;
		EVENT(handle, &event);
		_alpm_log(handle, ALPM_LOG_DEBUG, "resolving target's dependencies\n");

		/* build remove list for resolvedeps */
		for(i = trans->add; i; i = i->next) {
			alpm_pkg_t *spkg = i->data;
			for(j = spkg->removes; j; j = j->next) {
				remove = alpm_list_add(remove, j->data);
			}
		}

		/* Compute the fake local database for resolvedeps (partial fix for the
		 * phonon/qt issue) */
		localpkgs = alpm_list_diff(_alpm_db_get_pkgcache(handle->db_local),
				trans->add, _alpm_pkg_cmp);

		/* Resolve packages in the transaction one at a time, in addition
		   building up a list of packages which could not be resolved. */
		for(i = trans->add; i; i = i->next) {
			alpm_pkg_t *pkg = i->data;
			if(_alpm_resolvedeps(handle, localpkgs, pkg, trans->add,
						&resolved, remove, data) == -1) {
				unresolvable = alpm_list_add(unresolvable, pkg);
			}
			/* Else, [resolved] now additionally contains [pkg] and all of its
			   dependencies not already on the list */
		}
		alpm_list_free(localpkgs);
		alpm_list_free(remove);

		/* If there were unresolvable top-level packages, prompt the user to
		   see if they'd like to ignore them rather than failing the sync */
		if(unresolvable != NULL) {
			alpm_question_remove_pkgs_t question = {
				.type = ALPM_QUESTION_REMOVE_PKGS,
				.skip = 0,
				.packages = unresolvable
			};
			QUESTION(handle, &question);
			if(question.skip) {
				/* User wants to remove the unresolvable packages from the
				   transaction. The packages will be removed from the actual
				   transaction when the transaction packages are replaced with a
				   dependency-reordered list below */
				handle->pm_errno = 0;
				if(data) {
					alpm_list_free_inner(*data,
							(alpm_list_fn_free)alpm_depmissing_free);
					alpm_list_free(*data);
					*data = NULL;
				}
			} else {
				/* pm_errno was set by resolvedeps, callback may have overwrote it */
				handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
				alpm_list_free(resolved);
				alpm_list_free(unresolvable);
				ret = -1;
				goto cleanup;
			}
		}

		/* Set DEPEND reason for pulled packages */
		for(i = resolved; i; i = i->next) {
			alpm_pkg_t *pkg = i->data;
			if(!alpm_pkg_find(trans->add, pkg->name)) {
				pkg->reason = ALPM_PKG_REASON_DEPEND;
			}
		}

		/* Unresolvable packages will be removed from the target list; set these
		 * aside in the transaction as a list we won't operate on. If we free them
		 * before the end of the transaction, we may kill pointers the frontend
		 * holds to package objects. */
		trans->unresolvable = unresolvable;

		alpm_list_free(trans->add);
		trans->add = resolved;

		event.type = ALPM_EVENT_RESOLVEDEPS_DONE;
		EVENT(handle, &event);
	}
// EGL 1.1
EGLBoolean EGLAPIENTRY BindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint buffer = %d)", dpy, surface, buffer);

    Display *display = static_cast<Display*>(dpy);
    Surface *eglSurface = static_cast<Surface*>(surface);

    Error error = ValidateSurface(display, eglSurface);
    if (error.isError())
    {
        SetGlobalError(error);
        return EGL_FALSE;
    }

    if (buffer != EGL_BACK_BUFFER)
    {
        SetGlobalError(Error(EGL_BAD_PARAMETER));
        return EGL_FALSE;
    }

    if (surface == EGL_NO_SURFACE || eglSurface->getType() == EGL_WINDOW_BIT)
    {
        SetGlobalError(Error(EGL_BAD_SURFACE));
        return EGL_FALSE;
    }

    if (eglSurface->getBoundTexture())
    {
        SetGlobalError(Error(EGL_BAD_ACCESS));
        return EGL_FALSE;
    }

    if (eglSurface->getTextureFormat() == EGL_NO_TEXTURE)
    {
        SetGlobalError(Error(EGL_BAD_MATCH));
        return EGL_FALSE;
    }

    gl::Context *context = GetGlobalContext();
    if (context)
    {
        gl::Texture *textureObject = context->getTargetTexture(GL_TEXTURE_2D);
        ASSERT(textureObject != NULL);

        if (textureObject->getImmutableFormat())
        {
            SetGlobalError(Error(EGL_BAD_MATCH));
            return EGL_FALSE;
        }

        error = eglSurface->bindTexImage(textureObject, buffer);
        if (error.isError())
        {
            SetGlobalError(error);
            return EGL_FALSE;
        }
    }

    SetGlobalError(Error(EGL_SUCCESS));
    return EGL_TRUE;
}
예제 #5
0
파일: asylum_load.c 프로젝트: GCrean/libxmp
static int asylum_load(struct module_data *m, HIO_HANDLE *f, const int start)
{
	struct xmp_module *mod = &m->mod;
	struct xmp_event *event;
	int i, j;

	LOAD_INIT();

	hio_seek(f, 32, SEEK_CUR);			/* skip magic */
	mod->spd = hio_read8(f);			/* initial speed */
	mod->bpm = hio_read8(f);			/* initial BPM */
	mod->ins = hio_read8(f);			/* number of instruments */
	mod->pat = hio_read8(f);			/* number of patterns */
	mod->len = hio_read8(f);			/* module length */
	hio_read8(f);

	hio_read(mod->xxo, 1, mod->len, f);	/* read orders */
	hio_seek(f, start + 294, SEEK_SET);

	mod->chn = 8;
	mod->smp = mod->ins;
	mod->trk = mod->pat * mod->chn;

	snprintf(mod->type, XMP_NAME_SIZE, "Asylum Music Format v1.0");

	MODULE_INFO();

	if (instrument_init(mod) < 0)
		return -1;

	/* Read and convert instruments and samples */
	for (i = 0; i < mod->ins; i++) {
		uint8 insbuf[37];

		if (subinstrument_alloc(mod, i, 1) < 0)	
			return -1;

		hio_read(insbuf, 1, 37, f);
		instrument_name(mod, i, insbuf, 22);
		mod->xxi[i].sub[0].fin = (int8)(insbuf[22] << 4);
		mod->xxi[i].sub[0].vol = insbuf[23];
		mod->xxi[i].sub[0].xpo = (int8)insbuf[24];
		mod->xxi[i].sub[0].pan = 0x80;
		mod->xxi[i].sub[0].sid = i;

		mod->xxs[i].len = readmem32l(insbuf + 25);
		mod->xxs[i].lps = readmem32l(insbuf + 29);
		mod->xxs[i].lpe = mod->xxs[i].lps + readmem32l(insbuf + 33);
		
		mod->xxs[i].flg = mod->xxs[i].lpe > 2 ? XMP_SAMPLE_LOOP : 0;

		D_(D_INFO "[%2X] %-22.22s %04x %04x %04x %c V%02x %d", i,
		   mod->xxi[i].name, mod->xxs[i].len, mod->xxs[i].lps,
		   mod->xxs[i].lpe,
		   mod->xxs[i].flg & XMP_SAMPLE_LOOP ? 'L' : ' ',
		   mod->xxi[i].sub[0].vol, mod->xxi[i].sub[0].fin);
	}

	hio_seek(f, 37 * (64 - mod->ins), SEEK_CUR);

	D_(D_INFO "Module length: %d", mod->len);

	if (pattern_init(mod) < 0)
		return -1;

	/* Read and convert patterns */
	D_(D_INFO "Stored patterns: %d", mod->pat);

	for (i = 0; i < mod->pat; i++) {
		if (pattern_tracks_alloc(mod, i, 64) < 0)
			return -1;

		for (j = 0; j < 64 * mod->chn; j++) {
			uint8 note;

			event = &EVENT(i, j % mod->chn, j / mod->chn);
			memset(event, 0, sizeof(struct xmp_event));
			note = hio_read8(f);

			if (note != 0) {
				event->note = note + 13;
			}

			event->ins = hio_read8(f);
			event->fxt = hio_read8(f);
			event->fxp = hio_read8(f);
		}
	}

	/* Read samples */
	D_(D_INFO "Stored samples: %d", mod->smp);

	for (i = 0; i < mod->ins; i++) {
		if (mod->xxs[i].len > 1) {
			if (load_sample(m, f, 0, &mod->xxs[i], NULL) < 0)
				return -1;
			mod->xxi[i].nsm = 1;
		}
	}

	return 0;
}
__eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char *procname)
{
    EVENT("(const char *procname = \"%s\")", procname);

    typedef std::map<std::string, __eglMustCastToProperFunctionPointerType> ProcAddressMap;
    auto generateProcAddressMap = []()
    {
        ProcAddressMap map;
#define INSERT_PROC_ADDRESS(ns, proc) \
    map[#ns #proc] = reinterpret_cast<__eglMustCastToProperFunctionPointerType>(ns::proc)

        // GLES2 core
        INSERT_PROC_ADDRESS(gl, ActiveTexture);
        INSERT_PROC_ADDRESS(gl, AttachShader);
        INSERT_PROC_ADDRESS(gl, BindAttribLocation);
        INSERT_PROC_ADDRESS(gl, BindBuffer);
        INSERT_PROC_ADDRESS(gl, BindFramebuffer);
        INSERT_PROC_ADDRESS(gl, BindRenderbuffer);
        INSERT_PROC_ADDRESS(gl, BindTexture);
        INSERT_PROC_ADDRESS(gl, BlendColor);
        INSERT_PROC_ADDRESS(gl, BlendEquation);
        INSERT_PROC_ADDRESS(gl, BlendEquationSeparate);
        INSERT_PROC_ADDRESS(gl, BlendFunc);
        INSERT_PROC_ADDRESS(gl, BlendFuncSeparate);
        INSERT_PROC_ADDRESS(gl, BufferData);
        INSERT_PROC_ADDRESS(gl, BufferSubData);
        INSERT_PROC_ADDRESS(gl, CheckFramebufferStatus);
        INSERT_PROC_ADDRESS(gl, Clear);
        INSERT_PROC_ADDRESS(gl, ClearColor);
        INSERT_PROC_ADDRESS(gl, ClearDepthf);
        INSERT_PROC_ADDRESS(gl, ClearStencil);
        INSERT_PROC_ADDRESS(gl, ColorMask);
        INSERT_PROC_ADDRESS(gl, CompileShader);
        INSERT_PROC_ADDRESS(gl, CompressedTexImage2D);
        INSERT_PROC_ADDRESS(gl, CompressedTexSubImage2D);
        INSERT_PROC_ADDRESS(gl, CopyTexImage2D);
        INSERT_PROC_ADDRESS(gl, CopyTexSubImage2D);
        INSERT_PROC_ADDRESS(gl, CreateProgram);
        INSERT_PROC_ADDRESS(gl, CreateShader);
        INSERT_PROC_ADDRESS(gl, CullFace);
        INSERT_PROC_ADDRESS(gl, DeleteBuffers);
        INSERT_PROC_ADDRESS(gl, DeleteFramebuffers);
        INSERT_PROC_ADDRESS(gl, DeleteProgram);
        INSERT_PROC_ADDRESS(gl, DeleteRenderbuffers);
        INSERT_PROC_ADDRESS(gl, DeleteShader);
        INSERT_PROC_ADDRESS(gl, DeleteTextures);
        INSERT_PROC_ADDRESS(gl, DepthFunc);
        INSERT_PROC_ADDRESS(gl, DepthMask);
        INSERT_PROC_ADDRESS(gl, DepthRangef);
        INSERT_PROC_ADDRESS(gl, DetachShader);
        INSERT_PROC_ADDRESS(gl, Disable);
        INSERT_PROC_ADDRESS(gl, DisableVertexAttribArray);
        INSERT_PROC_ADDRESS(gl, DrawArrays);
        INSERT_PROC_ADDRESS(gl, DrawElements);
        INSERT_PROC_ADDRESS(gl, Enable);
        INSERT_PROC_ADDRESS(gl, EnableVertexAttribArray);
        INSERT_PROC_ADDRESS(gl, Finish);
        INSERT_PROC_ADDRESS(gl, Flush);
        INSERT_PROC_ADDRESS(gl, FramebufferRenderbuffer);
        INSERT_PROC_ADDRESS(gl, FramebufferTexture2D);
        INSERT_PROC_ADDRESS(gl, FrontFace);
        INSERT_PROC_ADDRESS(gl, GenBuffers);
        INSERT_PROC_ADDRESS(gl, GenerateMipmap);
        INSERT_PROC_ADDRESS(gl, GenFramebuffers);
        INSERT_PROC_ADDRESS(gl, GenRenderbuffers);
        INSERT_PROC_ADDRESS(gl, GenTextures);
        INSERT_PROC_ADDRESS(gl, GetActiveAttrib);
        INSERT_PROC_ADDRESS(gl, GetActiveUniform);
        INSERT_PROC_ADDRESS(gl, GetAttachedShaders);
        INSERT_PROC_ADDRESS(gl, GetAttribLocation);
        INSERT_PROC_ADDRESS(gl, GetBooleanv);
        INSERT_PROC_ADDRESS(gl, GetBufferParameteriv);
        INSERT_PROC_ADDRESS(gl, GetError);
        INSERT_PROC_ADDRESS(gl, GetFloatv);
        INSERT_PROC_ADDRESS(gl, GetFramebufferAttachmentParameteriv);
        INSERT_PROC_ADDRESS(gl, GetIntegerv);
        INSERT_PROC_ADDRESS(gl, GetProgramiv);
        INSERT_PROC_ADDRESS(gl, GetProgramInfoLog);
        INSERT_PROC_ADDRESS(gl, GetRenderbufferParameteriv);
        INSERT_PROC_ADDRESS(gl, GetShaderiv);
        INSERT_PROC_ADDRESS(gl, GetShaderInfoLog);
        INSERT_PROC_ADDRESS(gl, GetShaderPrecisionFormat);
        INSERT_PROC_ADDRESS(gl, GetShaderSource);
        INSERT_PROC_ADDRESS(gl, GetString);
        INSERT_PROC_ADDRESS(gl, GetTexParameterfv);
        INSERT_PROC_ADDRESS(gl, GetTexParameteriv);
        INSERT_PROC_ADDRESS(gl, GetUniformfv);
        INSERT_PROC_ADDRESS(gl, GetUniformiv);
        INSERT_PROC_ADDRESS(gl, GetUniformLocation);
        INSERT_PROC_ADDRESS(gl, GetVertexAttribfv);
        INSERT_PROC_ADDRESS(gl, GetVertexAttribiv);
        INSERT_PROC_ADDRESS(gl, GetVertexAttribPointerv);
        INSERT_PROC_ADDRESS(gl, Hint);
        INSERT_PROC_ADDRESS(gl, IsBuffer);
        INSERT_PROC_ADDRESS(gl, IsEnabled);
        INSERT_PROC_ADDRESS(gl, IsFramebuffer);
        INSERT_PROC_ADDRESS(gl, IsProgram);
        INSERT_PROC_ADDRESS(gl, IsRenderbuffer);
        INSERT_PROC_ADDRESS(gl, IsShader);
        INSERT_PROC_ADDRESS(gl, IsTexture);
        INSERT_PROC_ADDRESS(gl, LineWidth);
        INSERT_PROC_ADDRESS(gl, LinkProgram);
        INSERT_PROC_ADDRESS(gl, PixelStorei);
        INSERT_PROC_ADDRESS(gl, PolygonOffset);
        INSERT_PROC_ADDRESS(gl, ReadPixels);
        INSERT_PROC_ADDRESS(gl, ReleaseShaderCompiler);
        INSERT_PROC_ADDRESS(gl, RenderbufferStorage);
        INSERT_PROC_ADDRESS(gl, SampleCoverage);
        INSERT_PROC_ADDRESS(gl, Scissor);
        INSERT_PROC_ADDRESS(gl, ShaderBinary);
        INSERT_PROC_ADDRESS(gl, ShaderSource);
        INSERT_PROC_ADDRESS(gl, StencilFunc);
        INSERT_PROC_ADDRESS(gl, StencilFuncSeparate);
        INSERT_PROC_ADDRESS(gl, StencilMask);
        INSERT_PROC_ADDRESS(gl, StencilMaskSeparate);
        INSERT_PROC_ADDRESS(gl, StencilOp);
        INSERT_PROC_ADDRESS(gl, StencilOpSeparate);
        INSERT_PROC_ADDRESS(gl, TexImage2D);
        INSERT_PROC_ADDRESS(gl, TexParameterf);
        INSERT_PROC_ADDRESS(gl, TexParameterfv);
        INSERT_PROC_ADDRESS(gl, TexParameteri);
        INSERT_PROC_ADDRESS(gl, TexParameteriv);
        INSERT_PROC_ADDRESS(gl, TexSubImage2D);
        INSERT_PROC_ADDRESS(gl, Uniform1f);
        INSERT_PROC_ADDRESS(gl, Uniform1fv);
        INSERT_PROC_ADDRESS(gl, Uniform1i);
        INSERT_PROC_ADDRESS(gl, Uniform1iv);
        INSERT_PROC_ADDRESS(gl, Uniform2f);
        INSERT_PROC_ADDRESS(gl, Uniform2fv);
        INSERT_PROC_ADDRESS(gl, Uniform2i);
        INSERT_PROC_ADDRESS(gl, Uniform2iv);
        INSERT_PROC_ADDRESS(gl, Uniform3f);
        INSERT_PROC_ADDRESS(gl, Uniform3fv);
        INSERT_PROC_ADDRESS(gl, Uniform3i);
        INSERT_PROC_ADDRESS(gl, Uniform3iv);
        INSERT_PROC_ADDRESS(gl, Uniform4f);
        INSERT_PROC_ADDRESS(gl, Uniform4fv);
        INSERT_PROC_ADDRESS(gl, Uniform4i);
        INSERT_PROC_ADDRESS(gl, Uniform4iv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix2fv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix3fv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix4fv);
        INSERT_PROC_ADDRESS(gl, UseProgram);
        INSERT_PROC_ADDRESS(gl, ValidateProgram);
        INSERT_PROC_ADDRESS(gl, VertexAttrib1f);
        INSERT_PROC_ADDRESS(gl, VertexAttrib1fv);
        INSERT_PROC_ADDRESS(gl, VertexAttrib2f);
        INSERT_PROC_ADDRESS(gl, VertexAttrib2fv);
        INSERT_PROC_ADDRESS(gl, VertexAttrib3f);
        INSERT_PROC_ADDRESS(gl, VertexAttrib3fv);
        INSERT_PROC_ADDRESS(gl, VertexAttrib4f);
        INSERT_PROC_ADDRESS(gl, VertexAttrib4fv);
        INSERT_PROC_ADDRESS(gl, VertexAttribPointer);
        INSERT_PROC_ADDRESS(gl, Viewport);

        // GL_ANGLE_framebuffer_blit
        INSERT_PROC_ADDRESS(gl, BlitFramebufferANGLE);

        // GL_ANGLE_framebuffer_multisample
        INSERT_PROC_ADDRESS(gl, RenderbufferStorageMultisampleANGLE);

        // GL_EXT_discard_framebuffer
        INSERT_PROC_ADDRESS(gl, DiscardFramebufferEXT);

        // GL_NV_fence
        INSERT_PROC_ADDRESS(gl, DeleteFencesNV);
        INSERT_PROC_ADDRESS(gl, GenFencesNV);
        INSERT_PROC_ADDRESS(gl, IsFenceNV);
        INSERT_PROC_ADDRESS(gl, TestFenceNV);
        INSERT_PROC_ADDRESS(gl, GetFenceivNV);
        INSERT_PROC_ADDRESS(gl, FinishFenceNV);
        INSERT_PROC_ADDRESS(gl, SetFenceNV);

        // GL_ANGLE_translated_shader_source
        INSERT_PROC_ADDRESS(gl, GetTranslatedShaderSourceANGLE);

        // GL_EXT_texture_storage
        INSERT_PROC_ADDRESS(gl, TexStorage2DEXT);

        // GL_EXT_robustness
        INSERT_PROC_ADDRESS(gl, GetGraphicsResetStatusEXT);
        INSERT_PROC_ADDRESS(gl, ReadnPixelsEXT);
        INSERT_PROC_ADDRESS(gl, GetnUniformfvEXT);
        INSERT_PROC_ADDRESS(gl, GetnUniformivEXT);

        // GL_EXT_occlusion_query_boolean
        INSERT_PROC_ADDRESS(gl, GenQueriesEXT);
        INSERT_PROC_ADDRESS(gl, DeleteQueriesEXT);
        INSERT_PROC_ADDRESS(gl, IsQueryEXT);
        INSERT_PROC_ADDRESS(gl, BeginQueryEXT);
        INSERT_PROC_ADDRESS(gl, EndQueryEXT);
        INSERT_PROC_ADDRESS(gl, GetQueryivEXT);
        INSERT_PROC_ADDRESS(gl, GetQueryObjectuivEXT);

        // GL_EXT_draw_buffers
        INSERT_PROC_ADDRESS(gl, DrawBuffersEXT);

        // GL_ANGLE_instanced_arrays
        INSERT_PROC_ADDRESS(gl, DrawArraysInstancedANGLE);
        INSERT_PROC_ADDRESS(gl, DrawElementsInstancedANGLE);
        INSERT_PROC_ADDRESS(gl, VertexAttribDivisorANGLE);

        // GL_OES_get_program_binary
        INSERT_PROC_ADDRESS(gl, GetProgramBinaryOES);
        INSERT_PROC_ADDRESS(gl, ProgramBinaryOES);

        // GL_OES_mapbuffer
        INSERT_PROC_ADDRESS(gl, MapBufferOES);
        INSERT_PROC_ADDRESS(gl, UnmapBufferOES);
        INSERT_PROC_ADDRESS(gl, GetBufferPointervOES);

        // GL_EXT_map_buffer_range
        INSERT_PROC_ADDRESS(gl, MapBufferRangeEXT);
        INSERT_PROC_ADDRESS(gl, FlushMappedBufferRangeEXT);

        // GL_EXT_debug_marker
        INSERT_PROC_ADDRESS(gl, InsertEventMarkerEXT);
        INSERT_PROC_ADDRESS(gl, PushGroupMarkerEXT);
        INSERT_PROC_ADDRESS(gl, PopGroupMarkerEXT);

        // GL_OES_EGL_image
        INSERT_PROC_ADDRESS(gl, EGLImageTargetTexture2DOES);
        INSERT_PROC_ADDRESS(gl, EGLImageTargetRenderbufferStorageOES);

        // GL_OES_vertex_array_object
        INSERT_PROC_ADDRESS(gl, BindVertexArrayOES);
        INSERT_PROC_ADDRESS(gl, DeleteVertexArraysOES);
        INSERT_PROC_ADDRESS(gl, GenVertexArraysOES);
        INSERT_PROC_ADDRESS(gl, IsVertexArrayOES);

        // GLES3 core
        INSERT_PROC_ADDRESS(gl, ReadBuffer);
        INSERT_PROC_ADDRESS(gl, DrawRangeElements);
        INSERT_PROC_ADDRESS(gl, TexImage3D);
        INSERT_PROC_ADDRESS(gl, TexSubImage3D);
        INSERT_PROC_ADDRESS(gl, CopyTexSubImage3D);
        INSERT_PROC_ADDRESS(gl, CompressedTexImage3D);
        INSERT_PROC_ADDRESS(gl, CompressedTexSubImage3D);
        INSERT_PROC_ADDRESS(gl, GenQueries);
        INSERT_PROC_ADDRESS(gl, DeleteQueries);
        INSERT_PROC_ADDRESS(gl, IsQuery);
        INSERT_PROC_ADDRESS(gl, BeginQuery);
        INSERT_PROC_ADDRESS(gl, EndQuery);
        INSERT_PROC_ADDRESS(gl, GetQueryiv);
        INSERT_PROC_ADDRESS(gl, GetQueryObjectuiv);
        INSERT_PROC_ADDRESS(gl, UnmapBuffer);
        INSERT_PROC_ADDRESS(gl, GetBufferPointerv);
        INSERT_PROC_ADDRESS(gl, DrawBuffers);
        INSERT_PROC_ADDRESS(gl, UniformMatrix2x3fv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix3x2fv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix2x4fv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix4x2fv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix3x4fv);
        INSERT_PROC_ADDRESS(gl, UniformMatrix4x3fv);
        INSERT_PROC_ADDRESS(gl, BlitFramebuffer);
        INSERT_PROC_ADDRESS(gl, RenderbufferStorageMultisample);
        INSERT_PROC_ADDRESS(gl, FramebufferTextureLayer);
        INSERT_PROC_ADDRESS(gl, MapBufferRange);
        INSERT_PROC_ADDRESS(gl, FlushMappedBufferRange);
        INSERT_PROC_ADDRESS(gl, BindVertexArray);
        INSERT_PROC_ADDRESS(gl, DeleteVertexArrays);
        INSERT_PROC_ADDRESS(gl, GenVertexArrays);
        INSERT_PROC_ADDRESS(gl, IsVertexArray);
        INSERT_PROC_ADDRESS(gl, GetIntegeri_v);
        INSERT_PROC_ADDRESS(gl, BeginTransformFeedback);
        INSERT_PROC_ADDRESS(gl, EndTransformFeedback);
        INSERT_PROC_ADDRESS(gl, BindBufferRange);
        INSERT_PROC_ADDRESS(gl, BindBufferBase);
        INSERT_PROC_ADDRESS(gl, TransformFeedbackVaryings);
        INSERT_PROC_ADDRESS(gl, GetTransformFeedbackVarying);
        INSERT_PROC_ADDRESS(gl, VertexAttribIPointer);
        INSERT_PROC_ADDRESS(gl, GetVertexAttribIiv);
        INSERT_PROC_ADDRESS(gl, GetVertexAttribIuiv);
        INSERT_PROC_ADDRESS(gl, VertexAttribI4i);
        INSERT_PROC_ADDRESS(gl, VertexAttribI4ui);
        INSERT_PROC_ADDRESS(gl, VertexAttribI4iv);
        INSERT_PROC_ADDRESS(gl, VertexAttribI4uiv);
        INSERT_PROC_ADDRESS(gl, GetUniformuiv);
        INSERT_PROC_ADDRESS(gl, GetFragDataLocation);
        INSERT_PROC_ADDRESS(gl, Uniform1ui);
        INSERT_PROC_ADDRESS(gl, Uniform2ui);
        INSERT_PROC_ADDRESS(gl, Uniform3ui);
        INSERT_PROC_ADDRESS(gl, Uniform4ui);
        INSERT_PROC_ADDRESS(gl, Uniform1uiv);
        INSERT_PROC_ADDRESS(gl, Uniform2uiv);
        INSERT_PROC_ADDRESS(gl, Uniform3uiv);
        INSERT_PROC_ADDRESS(gl, Uniform4uiv);
        INSERT_PROC_ADDRESS(gl, ClearBufferiv);
        INSERT_PROC_ADDRESS(gl, ClearBufferuiv);
        INSERT_PROC_ADDRESS(gl, ClearBufferfv);
        INSERT_PROC_ADDRESS(gl, ClearBufferfi);
        INSERT_PROC_ADDRESS(gl, GetStringi);
        INSERT_PROC_ADDRESS(gl, CopyBufferSubData);
        INSERT_PROC_ADDRESS(gl, GetUniformIndices);
        INSERT_PROC_ADDRESS(gl, GetActiveUniformsiv);
        INSERT_PROC_ADDRESS(gl, GetUniformBlockIndex);
        INSERT_PROC_ADDRESS(gl, GetActiveUniformBlockiv);
        INSERT_PROC_ADDRESS(gl, GetActiveUniformBlockName);
        INSERT_PROC_ADDRESS(gl, UniformBlockBinding);
        INSERT_PROC_ADDRESS(gl, DrawArraysInstanced);
        INSERT_PROC_ADDRESS(gl, DrawElementsInstanced);
        map["glFenceSync"] =
            reinterpret_cast<__eglMustCastToProperFunctionPointerType>(gl::FenceSync_);
        INSERT_PROC_ADDRESS(gl, IsSync);
        INSERT_PROC_ADDRESS(gl, DeleteSync);
        INSERT_PROC_ADDRESS(gl, ClientWaitSync);
        INSERT_PROC_ADDRESS(gl, WaitSync);
        INSERT_PROC_ADDRESS(gl, GetInteger64v);
        INSERT_PROC_ADDRESS(gl, GetSynciv);
        INSERT_PROC_ADDRESS(gl, GetInteger64i_v);
        INSERT_PROC_ADDRESS(gl, GetBufferParameteri64v);
        INSERT_PROC_ADDRESS(gl, GenSamplers);
        INSERT_PROC_ADDRESS(gl, DeleteSamplers);
        INSERT_PROC_ADDRESS(gl, IsSampler);
        INSERT_PROC_ADDRESS(gl, BindSampler);
        INSERT_PROC_ADDRESS(gl, SamplerParameteri);
        INSERT_PROC_ADDRESS(gl, SamplerParameteriv);
        INSERT_PROC_ADDRESS(gl, SamplerParameterf);
        INSERT_PROC_ADDRESS(gl, SamplerParameterfv);
        INSERT_PROC_ADDRESS(gl, GetSamplerParameteriv);
        INSERT_PROC_ADDRESS(gl, GetSamplerParameterfv);
        INSERT_PROC_ADDRESS(gl, VertexAttribDivisor);
        INSERT_PROC_ADDRESS(gl, BindTransformFeedback);
        INSERT_PROC_ADDRESS(gl, DeleteTransformFeedbacks);
        INSERT_PROC_ADDRESS(gl, GenTransformFeedbacks);
        INSERT_PROC_ADDRESS(gl, IsTransformFeedback);
        INSERT_PROC_ADDRESS(gl, PauseTransformFeedback);
        INSERT_PROC_ADDRESS(gl, ResumeTransformFeedback);
        INSERT_PROC_ADDRESS(gl, GetProgramBinary);
        INSERT_PROC_ADDRESS(gl, ProgramBinary);
        INSERT_PROC_ADDRESS(gl, ProgramParameteri);
        INSERT_PROC_ADDRESS(gl, InvalidateFramebuffer);
        INSERT_PROC_ADDRESS(gl, InvalidateSubFramebuffer);
        INSERT_PROC_ADDRESS(gl, TexStorage2D);
        INSERT_PROC_ADDRESS(gl, TexStorage3D);
        INSERT_PROC_ADDRESS(gl, GetInternalformativ);

        // EGL 1.0
        INSERT_PROC_ADDRESS(egl, ChooseConfig);
        INSERT_PROC_ADDRESS(egl, CopyBuffers);
        INSERT_PROC_ADDRESS(egl, CreateContext);
        INSERT_PROC_ADDRESS(egl, CreatePbufferSurface);
        INSERT_PROC_ADDRESS(egl, CreatePixmapSurface);
        INSERT_PROC_ADDRESS(egl, CreateWindowSurface);
        INSERT_PROC_ADDRESS(egl, DestroyContext);
        INSERT_PROC_ADDRESS(egl, DestroySurface);
        INSERT_PROC_ADDRESS(egl, GetConfigAttrib);
        INSERT_PROC_ADDRESS(egl, GetConfigs);
        INSERT_PROC_ADDRESS(egl, GetCurrentDisplay);
        INSERT_PROC_ADDRESS(egl, GetCurrentSurface);
        INSERT_PROC_ADDRESS(egl, GetDisplay);
        INSERT_PROC_ADDRESS(egl, GetError);
        INSERT_PROC_ADDRESS(egl, GetProcAddress);
        INSERT_PROC_ADDRESS(egl, Initialize);
        INSERT_PROC_ADDRESS(egl, MakeCurrent);
        INSERT_PROC_ADDRESS(egl, QueryContext);
        INSERT_PROC_ADDRESS(egl, QueryString);
        INSERT_PROC_ADDRESS(egl, QuerySurface);
        INSERT_PROC_ADDRESS(egl, SwapBuffers);
        INSERT_PROC_ADDRESS(egl, Terminate);
        INSERT_PROC_ADDRESS(egl, WaitGL);
        INSERT_PROC_ADDRESS(egl, WaitNative);

        // EGL 1.1
        INSERT_PROC_ADDRESS(egl, BindTexImage);
        INSERT_PROC_ADDRESS(egl, ReleaseTexImage);
        INSERT_PROC_ADDRESS(egl, SurfaceAttrib);
        INSERT_PROC_ADDRESS(egl, SwapInterval);

        // EGL 1.2
        INSERT_PROC_ADDRESS(egl, BindAPI);
        INSERT_PROC_ADDRESS(egl, QueryAPI);
        INSERT_PROC_ADDRESS(egl, CreatePbufferFromClientBuffer);
        INSERT_PROC_ADDRESS(egl, ReleaseThread);
        INSERT_PROC_ADDRESS(egl, WaitClient);

        // EGL 1.4
        INSERT_PROC_ADDRESS(egl, GetCurrentContext);

        // EGL 1.5
        INSERT_PROC_ADDRESS(egl, CreateSync);
        INSERT_PROC_ADDRESS(egl, DestroySync);
        INSERT_PROC_ADDRESS(egl, ClientWaitSync);
        INSERT_PROC_ADDRESS(egl, GetSyncAttrib);
        INSERT_PROC_ADDRESS(egl, CreateImage);
        INSERT_PROC_ADDRESS(egl, DestroyImage);
        INSERT_PROC_ADDRESS(egl, GetPlatformDisplay);
        INSERT_PROC_ADDRESS(egl, CreatePlatformWindowSurface);
        INSERT_PROC_ADDRESS(egl, CreatePlatformPixmapSurface);
        INSERT_PROC_ADDRESS(egl, WaitSync);

        // EGL_ANGLE_query_surface_pointer
        INSERT_PROC_ADDRESS(egl, QuerySurfacePointerANGLE);

        // EGL_NV_post_sub_buffer
        INSERT_PROC_ADDRESS(egl, PostSubBufferNV);

        // EGL_EXT_platform_base
        INSERT_PROC_ADDRESS(egl, GetPlatformDisplayEXT);

        // EGL_EXT_device_query
        INSERT_PROC_ADDRESS(egl, QueryDisplayAttribEXT);
        INSERT_PROC_ADDRESS(egl, QueryDeviceAttribEXT);
        INSERT_PROC_ADDRESS(egl, QueryDeviceStringEXT);

        // EGL_KHR_image_base/EGL_KHR_image
        INSERT_PROC_ADDRESS(egl, CreateImageKHR);
        INSERT_PROC_ADDRESS(egl, DestroyImageKHR);

#undef INSERT_PROC_ADDRESS
        return map;
    };

    static const ProcAddressMap procAddressMap = generateProcAddressMap();

    auto iter = procAddressMap.find(procname);
    if (iter != procAddressMap.end())
    {
        return iter->second;
    }
    else
    {
        return nullptr;
    }
}
EGLDisplay EGLAPIENTRY GetDisplay(EGLNativeDisplayType display_id)
{
    EVENT("(EGLNativeDisplayType display_id = 0x%0.8p)", display_id);

    return Display::getDisplay(display_id, AttributeMap());
}
예제 #8
0
static int rtm_load(struct module_data *m, HIO_HANDLE *f, const int start)
{
	struct xmp_module *mod = &m->mod;
	int i, j, r;
	struct xmp_event *event;
	struct ObjectHeader oh;
	struct RTMMHeader rh;
	struct RTNDHeader rp;
	struct RTINHeader ri;
	struct RTSMHeader rs;
	int offset, smpnum, version;
	char tracker_name[21], composer[33];

	LOAD_INIT();

	if (read_object_header(f, &oh, "RTMM") < 0)
		return -1;

	version = oh.version;

	hio_read(tracker_name, 1, 20, f);
	tracker_name[20] = 0;
	hio_read(composer, 1, 32, f);
	composer[32] = 0;
	rh.flags = hio_read16l(f);	/* bit 0: linear table, bit 1: track names */
	rh.ntrack = hio_read8(f);
	rh.ninstr = hio_read8(f);
	rh.nposition = hio_read16l(f);
	rh.npattern = hio_read16l(f);
	rh.speed = hio_read8(f);
	rh.tempo = hio_read8(f);
	hio_read(&rh.panning, 32, 1, f);
	rh.extraDataSize = hio_read32l(f);

	/* Sanity check */
	if (rh.nposition > 255 || rh.ntrack > 32 || rh.npattern > 255) {
		return -1;
	}

	if (version >= 0x0112)
		hio_seek(f, 32, SEEK_CUR);		/* skip original name */

	for (i = 0; i < rh.nposition; i++) {
		mod->xxo[i] = hio_read16l(f);
		if (mod->xxo[i] >= rh.npattern) {
			return -1;
		}
	}
	
	strncpy(mod->name, oh.name, 20);
	snprintf(mod->type, XMP_NAME_SIZE, "%s RTM %x.%02x",
				tracker_name, version >> 8, version & 0xff);
	/* strncpy(m->author, composer, XMP_NAME_SIZE); */

	mod->len = rh.nposition;
	mod->pat = rh.npattern;
	mod->chn = rh.ntrack;
	mod->trk = mod->chn * mod->pat;
	mod->ins = rh.ninstr;
	mod->spd = rh.speed;
	mod->bpm = rh.tempo;

	m->c4rate = C4_NTSC_RATE;
	m->period_type = rh.flags & 0x01 ? PERIOD_LINEAR : PERIOD_AMIGA;

	MODULE_INFO();

	for (i = 0; i < mod->chn; i++)
		mod->xxc[i].pan = rh.panning[i] & 0xff;

	if (libxmp_init_pattern(mod) < 0)
		return -1;

	D_(D_INFO "Stored patterns: %d", mod->pat);

	offset = 42 + oh.headerSize + rh.extraDataSize;

	for (i = 0; i < mod->pat; i++) {
		uint8 c;

		hio_seek(f, start + offset, SEEK_SET);

		if (read_object_header(f, &oh, "RTND") < 0) {
			D_(D_CRIT "Error reading pattern %d", i);
			return -1;
		}
	
		rp.flags = hio_read16l(f);
		rp.ntrack = hio_read8(f);
		rp.nrows = hio_read16l(f);
		rp.datasize = hio_read32l(f);

		/* Sanity check */
		if (rp.ntrack > rh.ntrack || rp.nrows > 256) {
			return -1;
		}

		offset += 42 + oh.headerSize + rp.datasize;

		if (libxmp_alloc_pattern_tracks(mod, i, rp.nrows) < 0)
			return -1;

		for (r = 0; r < rp.nrows; r++) {
			for (j = 0; /*j < rp.ntrack */; j++) {

				c = hio_read8(f);
				if (c == 0)		/* next row */
					break;

				/* Sanity check */
				if (j >= rp.ntrack) {
					return -1;
				}

				event = &EVENT(i, j, r);

				if (c & 0x01) {		/* set track */
					j = hio_read8(f);

					/* Sanity check */
					if (j >= rp.ntrack) {
						return -1;
					}

					event = &EVENT(i, j, r);
				}
				if (c & 0x02) {		/* read note */
					event->note = hio_read8(f) + 1;
					if (event->note == 0xff) {
						event->note = XMP_KEY_OFF;
					} else {
						event->note += 12;
					}
				}
				if (c & 0x04)		/* read instrument */
					event->ins = hio_read8(f);
				if (c & 0x08)		/* read effect */
					event->fxt = hio_read8(f);
				if (c & 0x10)		/* read parameter */
					event->fxp = hio_read8(f);
				if (c & 0x20)		/* read effect 2 */
					event->f2t = hio_read8(f);
				if (c & 0x40)		/* read parameter 2 */
					event->f2p = hio_read8(f);
			}
		}
	}

	/*
	 * load instruments
	 */

	D_(D_INFO "Instruments: %d", mod->ins);

	hio_seek(f, start + offset, SEEK_SET);

	/* ESTIMATED value! We don't know the actual value at this point */
	mod->smp = MAX_SAMP;

	if (libxmp_init_instrument(m) < 0)
		return -1;

	smpnum = 0;
	for (i = 0; i < mod->ins; i++) {
		struct xmp_instrument *xxi = &mod->xxi[i];

		if (read_object_header(f, &oh, "RTIN") < 0) {
			D_(D_CRIT "Error reading instrument %d", i);
			return -1;
		}

		libxmp_instrument_name(mod, i, (uint8 *)&oh.name, 32);

		if (oh.headerSize == 0) {
			D_(D_INFO "[%2X] %-26.26s %2d ", i,
						xxi->name, xxi->nsm);
			ri.nsample = 0;
			continue;
		}

		ri.nsample = hio_read8(f);
		ri.flags = hio_read16l(f);	/* bit 0 : default panning enabled */
		if (hio_read(&ri.table, 1, 120, f) != 120)
			return -1;

		ri.volumeEnv.npoint = hio_read8(f);

		/* Sanity check */
		if (ri.volumeEnv.npoint >= 12)
			return -1;

		for (j = 0; j < 12; j++) {
			ri.volumeEnv.point[j].x = hio_read32l(f);
			ri.volumeEnv.point[j].y = hio_read32l(f);
		}
		ri.volumeEnv.sustain = hio_read8(f);
		ri.volumeEnv.loopstart = hio_read8(f);
		ri.volumeEnv.loopend = hio_read8(f);
		ri.volumeEnv.flags = hio_read16l(f); /* bit 0:enable 1:sus 2:loop */
		
		ri.panningEnv.npoint = hio_read8(f);

		/* Sanity check */
		if (ri.panningEnv.npoint >= 12)
			return -1;

		for (j = 0; j < 12; j++) {
			ri.panningEnv.point[j].x = hio_read32l(f);
			ri.panningEnv.point[j].y = hio_read32l(f);
		}
		ri.panningEnv.sustain = hio_read8(f);
		ri.panningEnv.loopstart = hio_read8(f);
		ri.panningEnv.loopend = hio_read8(f);
		ri.panningEnv.flags = hio_read16l(f);

		ri.vibflg = hio_read8(f);
		ri.vibsweep = hio_read8(f);
		ri.vibdepth = hio_read8(f);
		ri.vibrate = hio_read8(f);
		ri.volfade = hio_read16l(f);

		if (version >= 0x0110) {
			ri.midiPort = hio_read8(f);
			ri.midiChannel = hio_read8(f);
			ri.midiProgram = hio_read8(f);
			ri.midiEnable = hio_read8(f);
		}
		if (version >= 0x0112) {
			ri.midiTranspose = hio_read8(f);
			ri.midiBenderRange = hio_read8(f);
			ri.midiBaseVolume = hio_read8(f);
			ri.midiUseVelocity = hio_read8(f);
		}

		xxi->nsm = ri.nsample;

		D_(D_INFO "[%2X] %-26.26s %2d", i, xxi->name, xxi->nsm);

		if (xxi->nsm > 16)
			xxi->nsm = 16;

		if (libxmp_alloc_subinstrument(mod, i, xxi->nsm) < 0)
			return -1;

		for (j = 0; j < 120; j++)
			xxi->map[j].ins = ri.table[j];

		/* Envelope */
		xxi->rls = ri.volfade;
		xxi->aei.npt = ri.volumeEnv.npoint;
		xxi->aei.sus = ri.volumeEnv.sustain;
		xxi->aei.lps = ri.volumeEnv.loopstart;
		xxi->aei.lpe = ri.volumeEnv.loopend;
		xxi->aei.flg = ri.volumeEnv.flags;
		xxi->pei.npt = ri.panningEnv.npoint;
		xxi->pei.sus = ri.panningEnv.sustain;
		xxi->pei.lps = ri.panningEnv.loopstart;
		xxi->pei.lpe = ri.panningEnv.loopend;
		xxi->pei.flg = ri.panningEnv.flags;

		for (j = 0; j < xxi->aei.npt; j++) {
			xxi->aei.data[j * 2 + 0] = ri.volumeEnv.point[j].x;
			xxi->aei.data[j * 2 + 1] = ri.volumeEnv.point[j].y / 2;
		}
		for (j = 0; j < xxi->pei.npt; j++) {
			xxi->pei.data[j * 2 + 0] = ri.panningEnv.point[j].x;
			xxi->pei.data[j * 2 + 1] = 32 + ri.panningEnv.point[j].y / 2;
		}

		/* For each sample */
		for (j = 0; j < xxi->nsm; j++, smpnum++) {
			struct xmp_subinstrument *sub = &xxi->sub[j];
			struct xmp_sample *xxs;

			if (read_object_header(f, &oh, "RTSM") < 0) {
				D_(D_CRIT "Error reading sample %d", j);
				return -1;
			}

			rs.flags = hio_read16l(f);
			rs.basevolume = hio_read8(f);
			rs.defaultvolume = hio_read8(f);
			rs.length = hio_read32l(f);
			rs.loop = hio_read32l(f);
			rs.loopbegin = hio_read32l(f);
			rs.loopend = hio_read32l(f);
			rs.basefreq = hio_read32l(f);
			rs.basenote = hio_read8(f);
			rs.panning = hio_read8(f);

			libxmp_c2spd_to_note(rs.basefreq, &sub->xpo, &sub->fin);
			sub->xpo += 48 - rs.basenote;
			sub->vol = rs.defaultvolume * rs.basevolume / 0x40;
			sub->pan = 0x80 + rs.panning * 2;
			sub->vwf = ri.vibflg;
			sub->vde = ri.vibdepth << 2;
			sub->vra = ri.vibrate;
			sub->vsw = ri.vibsweep;
			sub->sid = smpnum;

			if (smpnum >= mod->smp) {
				 mod->xxs = libxmp_realloc_samples(mod->xxs,
						&mod->smp, mod->smp * 3 / 2);
				if (mod->xxs == NULL)
					return -1;
			}
 			xxs = &mod->xxs[smpnum];

			libxmp_copy_adjust(xxs->name, (uint8 *)oh.name, 31);

			xxs->len = rs.length;
			xxs->lps = rs.loopbegin;
			xxs->lpe = rs.loopend;

			xxs->flg = 0;
			if (rs.flags & 0x02) {
				xxs->flg |= XMP_SAMPLE_16BIT;
				xxs->len >>= 1;
				xxs->lps >>= 1;
				xxs->lpe >>= 1;
			}

			xxs->flg |= rs.loop & 0x03 ?  XMP_SAMPLE_LOOP : 0;
			xxs->flg |= rs.loop == 2 ? XMP_SAMPLE_LOOP_BIDIR : 0;

			D_(D_INFO "  [%1x] %05x%c%05x %05x %c "
						"V%02x F%+04d P%02x R%+03d",
				j, xxs->len,
				xxs->flg & XMP_SAMPLE_16BIT ? '+' : ' ',
				xxs->lps, xxs->lpe,
				xxs->flg & XMP_SAMPLE_LOOP_BIDIR ? 'B' :
				xxs->flg & XMP_SAMPLE_LOOP ? 'L' : ' ',
				sub->vol, sub->fin, sub->pan, sub->xpo);

			if (libxmp_load_sample(m, f, SAMPLE_FLAG_DIFF, xxs, NULL) < 0)
				return -1;
		}
	}
예제 #9
0
EGLSurface __stdcall eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativeWindowType win = 0x%0.8p, "
          "const EGLint *attrib_list = 0x%0.8p)", dpy, config, win, attrib_list);

    try
    {
        egl::Display *display = static_cast<egl::Display*>(dpy);

        if (!validate(display, config))
        {
            return EGL_NO_SURFACE;
        }

        HWND window = (HWND)win;

        if (!IsWindow(window))
        {
            return error(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
        }

        if (attrib_list)
        {
            while (*attrib_list != EGL_NONE)
            {
                switch (attrib_list[0])
                {
                  case EGL_RENDER_BUFFER:
                    switch (attrib_list[1])
                    {
                      case EGL_BACK_BUFFER:
                        break;
                      case EGL_SINGLE_BUFFER:
                        return error(EGL_BAD_MATCH, EGL_NO_SURFACE);   // Rendering directly to front buffer not supported
                      default:
                        return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
                    }
                    break;
                  case EGL_VG_COLORSPACE:
                    return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
                  case EGL_VG_ALPHA_FORMAT:
                    return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
                  default:
                    return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
                }

                attrib_list += 2;
            }
        }

        if (display->hasExistingWindowSurface(window))
        {
            return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
        }

        EGLSurface surface = (EGLSurface)display->createWindowSurface(window, config);

        return success(surface);
    }
    catch(std::bad_alloc&)
    {
        return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
    }

    return EGL_NO_SURFACE;
}
예제 #10
0
파일: CCM_Events_T.cpp 프로젝트: SEDS/CUTS
CUTS_CCM_Event_T <EVENT>::CUTS_CCM_Event_T (void)
{
  _ptr_type ev = 0;
  ACE_NEW_THROW_EX (ev, EVENT (), ::CORBA::NO_MEMORY ());
  this->event_ = ev;
}
예제 #11
0
static int mod_load(struct module_data *m, FILE *f, const int start)
{
    struct xmp_module *mod = &m->mod;
    int i, j;
    int smp_size, pat_size, wow, ptsong = 0;
    struct xmp_event *event;
    struct mod_header mh;
    uint8 mod_event[4];
    char *x, pathname[PATH_MAX] = "", *tracker = "";
    int detected = 0;
    char magic[8], idbuffer[32];
    int ptkloop = 0;			/* Protracker loop */

    LOAD_INIT();

    mod->ins = 31;
    mod->smp = mod->ins;
    mod->chn = 0;
    smp_size = 0;
    pat_size = 0;

    m->quirk |= QUIRK_MODRNG;

    fread(&mh.name, 20, 1, f);
    for (i = 0; i < 31; i++) {
	fread(&mh.ins[i].name, 22, 1, f);	/* Instrument name */
	mh.ins[i].size = read16b(f);		/* Length in 16-bit words */
	mh.ins[i].finetune = read8(f);		/* Finetune (signed nibble) */
	mh.ins[i].volume = read8(f);		/* Linear playback volume */
	mh.ins[i].loop_start = read16b(f);	/* Loop start in 16-bit words */
	mh.ins[i].loop_size = read16b(f);	/* Loop size in 16-bit words */

	smp_size += 2 * mh.ins[i].size;
    }
    mh.len = read8(f);
    mh.restart = read8(f);
    fread(&mh.order, 128, 1, f);
    memset(magic, 0, 8);
    fread(magic, 4, 1, f);

    for (i = 0; mod_magic[i].ch; i++) {
	if (!(strncmp (magic, mod_magic[i].magic, 4))) {
	    mod->chn = mod_magic[i].ch;
	    tracker = mod_magic[i].tracker;
	    detected = mod_magic[i].flag;
	    ptkloop = mod_magic[i].ptkloop;
	    break;
	}
    }

    if (!mod->chn) {
	if (!strncmp(magic + 2, "CH", 2) &&
	    isdigit(magic[0]) && isdigit(magic[1])) {
	    if ((mod->chn = (*magic - '0') *
		10 + magic[1] - '0') > 32)
		return -1;
	} else if (!strncmp(magic + 1, "CHN", 3) &&
	    isdigit(*magic)) {
	    if (!(mod->chn = (*magic - '0')))
		return -1;
	} else
	    return -1;
	tracker = "TakeTracker/FastTracker II";
	detected = 1;
	m->quirk &= ~QUIRK_MODRNG;
    }

    strncpy (mod->name, (char *) mh.name, 20);

    mod->len = mh.len;
    /* mod->rst = mh.restart; */

    if (mod->rst >= mod->len)
	mod->rst = 0;
    memcpy(mod->xxo, mh.order, 128);

    for (i = 0; i < 128; i++) {
	/* This fixes dragnet.mod (garbage in the order list) */
	if (mod->xxo[i] > 0x7f)
		break;
	if (mod->xxo[i] > mod->pat)
	    mod->pat = mod->xxo[i];
    }
    mod->pat++;

    pat_size = 256 * mod->chn * mod->pat;

    INSTRUMENT_INIT();

    for (i = 0; i < mod->ins; i++) {
	mod->xxi[i].sub = calloc(sizeof (struct xmp_subinstrument), 1);
	mod->xxs[i].len = 2 * mh.ins[i].size;
	mod->xxs[i].lps = 2 * mh.ins[i].loop_start;
	mod->xxs[i].lpe = mod->xxs[i].lps + 2 * mh.ins[i].loop_size;
	if (mod->xxs[i].lpe > mod->xxs[i].len)
		mod->xxs[i].lpe = mod->xxs[i].len;
	mod->xxs[i].flg = (mh.ins[i].loop_size > 1 && mod->xxs[i].lpe > 8) ?
		XMP_SAMPLE_LOOP : 0;
	mod->xxi[i].sub[0].fin = (int8)(mh.ins[i].finetune << 4);
	mod->xxi[i].sub[0].vol = mh.ins[i].volume;
	mod->xxi[i].sub[0].pan = 0x80;
	mod->xxi[i].sub[0].sid = i;
	mod->xxi[i].nsm = !!(mod->xxs[i].len);
	copy_adjust(mod->xxi[i].name, mh.ins[i].name, 22);
    }

    /*
     * Experimental tracker-detection routine
     */ 

    if (detected)
	goto skip_test;

    /* Test for Flextrax modules
     *
     * FlexTrax is a soundtracker for Atari Falcon030 compatible computers.
     * FlexTrax supports the standard MOD file format (up to eight channels)
     * for compatibility reasons but also features a new enhanced module
     * format FLX. The FLX format is an extended version of the standard
     * MOD file format with support for real-time sound effects like reverb
     * and delay.
     */

    if (0x43c + mod->pat * 4 * mod->chn * 0x40 + smp_size < m->size) {
	int pos = ftell(f);
	fseek(f, start + 0x43c + mod->pat * 4 * mod->chn * 0x40 + smp_size, SEEK_SET);
	fread(idbuffer, 1, 4, f);
	fseek(f, start + pos, SEEK_SET);

	if (!memcmp(idbuffer, "FLEX", 4)) {
	    tracker = "Flextrax";
	    ptkloop = 0;
	    goto skip_test;
	}
    }

    /* Test for Mod's Grave WOW modules
     *
     * Stefan Danes <*****@*****.**> said:
     * This weird format is identical to '8CHN' but still uses the 'M.K.' ID.
     * You can only test for WOW by calculating the size of the module for 8 
     * channels and comparing this to the actual module length. If it's equal, 
     * the module is an 8 channel WOW.
     */

    if ((wow = (!strncmp(magic, "M.K.", 4) &&
		(0x43c + mod->pat * 32 * 0x40 + smp_size == m->size)))) {
	mod->chn = 8;
	tracker = "Mod's Grave";
	ptkloop = 0;
	goto skip_test;
    }

    /* Test for Protracker song files
     */
    else if ((ptsong = (!strncmp((char *)magic, "M.K.", 4) &&
		(0x43c + mod->pat * 0x400 == m->size)))) {
	tracker = "Protracker";
	goto skip_test;
    }

    /* Test Protracker-like files
     */
    if (mod->chn == 4 && mh.restart == mod->pat) {
	tracker = "Soundtracker";
    } else if (mod->chn == 4 && mh.restart == 0x78) {
	tracker = "Noisetracker" /*" (0x78)"*/;
	ptkloop = 1;
    } else if (mh.restart < 0x7f) {
	if (mod->chn == 4) {
	    tracker = "Noisetracker";
	    ptkloop = 1;
	} else {
	    tracker = "unknown tracker";
	    ptkloop = 0;
	}
	mod->rst = mh.restart;
    }

    if (mod->chn != 4 && mh.restart == 0x7f) {
	tracker = "Scream Tracker 3 MOD";
	ptkloop = 0;
	m->quirk &= ~QUIRK_MODRNG;
	m->read_event_type = READ_EVENT_ST3;
    }

    if (mod->chn == 4 && mh.restart == 0x7f) {
	for (i = 0; i < 31; i++) {
	    if (mh.ins[i].loop_size == 0)
		break;
	}
	if (i < 31) {
	    tracker = "Protracker clone";
	    ptkloop = 0;
	}
    }

    if (mh.restart != 0x78 && mh.restart < 0x7f) {
	for (i = 0; i < 31; i++) {
	    if (mh.ins[i].loop_size == 0)
		break;
	}
	if (i == 31) {	/* All loops are size 2 or greater */
	    for (i = 0; i < 31; i++) {
		if (mh.ins[i].size == 1 && mh.ins[i].volume == 0) {
		    tracker = "Probably converted";
		    ptkloop = 0;
		    goto skip_test;
		}
	    }

	    for (i = 0; i < 31; i++) {
	        if (is_st_ins((char *)mh.ins[i].name))
		    break;
	    }
	    if (i == 31) {	/* No st- instruments */
	        for (i = 0; i < 31; i++) {
		    if (mh.ins[i].size == 0 && mh.ins[i].loop_size == 1) {
			switch (mod->chn) {
			case 4:
		            tracker = "Noisetracker";	/* or Octalyzer */
			    break;
			case 6:
			case 8:
		            tracker = "Octalyser";
		    	    ptkloop = 0;
			    break;
			default:
		            tracker = "unknown tracker";
		    	    ptkloop = 0;
			}
		        goto skip_test;
		    }
	        }

		if (mod->chn == 4) {
	    	    tracker = "Protracker";
printf("asd\n");
		} else if (mod->chn == 6 || mod->chn == 8) {
	    	    tracker = "FastTracker 1.01?";
		    ptkloop = 0;
		    m->quirk &= ~QUIRK_MODRNG;
		} else {
	    	    tracker = "unknown tracker";
		    ptkloop = 0;
		}
	    }
	} else {	/* Has loops with 0 size */
	    for (i = 15; i < 31; i++) {
	        if (strlen((char *)mh.ins[i].name) || mh.ins[i].size > 0)
		    break;
	    }
	    if (i == 31 && is_st_ins((char *)mh.ins[14].name)) {
		tracker = "converted 15 instrument";
		ptkloop = 0;
		goto skip_test;
	    }

	    /* Assume that Fast Tracker modules won't have ST- instruments */
	    for (i = 0; i < 31; i++) {
	        if (is_st_ins((char *)mh.ins[i].name))
		    break;
	    }
	    if (i < 31) {
		tracker = "unknown/converted";
		ptkloop = 0;
		goto skip_test;
	    }

	    if (mod->chn == 4 || mod->chn == 6 || mod->chn == 8) {
	    	tracker = "Fast Tracker";
		ptkloop = 0;
	        m->quirk &= ~QUIRK_MODRNG;
		goto skip_test;
	    }

	    tracker = "unknown tracker";		/* ??!? */
	    ptkloop = 0;
	}
    }

skip_test:


    mod->trk = mod->chn * mod->pat;

    snprintf(mod->type, XMP_NAME_SIZE, "%s (%s)", tracker, magic);
    MODULE_INFO();

    for (i = 0; i < mod->ins; i++) {
	D_(D_INFO "[%2X] %-22.22s %04x %04x %04x %c V%02x %+d %c\n",
		i, mod->xxi[i].name,
		mod->xxs[i].len, mod->xxs[i].lps, mod->xxs[i].lpe,
		(mh.ins[i].loop_size > 1 && mod->xxs[i].lpe > 8) ?
			'L' : ' ', mod->xxi[i].sub[0].vol,
		mod->xxi[i].sub[0].fin >> 4,
		ptkloop && mod->xxs[i].lps == 0 && mh.ins[i].loop_size > 1 &&
			mod->xxs[i].len > mod->xxs[i].lpe ? '!' : ' ');
    }

    PATTERN_INIT();

    /* Load and convert patterns */
    D_(D_INFO "Stored patterns: %d", mod->pat);

    for (i = 0; i < mod->pat; i++) {
	PATTERN_ALLOC (i);
	mod->xxp[i]->rows = 64;
	TRACK_ALLOC (i);
	for (j = 0; j < (64 * mod->chn); j++) {
	    event = &EVENT (i, j % mod->chn, j / mod->chn);
	    fread (mod_event, 1, 4, f);

	    cvt_pt_event(event, mod_event);
	}
    }

    /* Load samples */

    if ((x = strrchr(m->filename, '/')))
	strncpy(pathname, m->filename, x - m->filename);

    D_(D_INFO "Stored samples: %d", mod->smp);

    for (i = 0; i < mod->smp; i++) {
	int flags;

	if (!mod->xxs[i].len)
	    continue;

	flags = ptkloop ? SAMPLE_FLAG_FULLREP : 0;

	if (ptsong) {
	    FILE *s;
	    char sn[256];
	    snprintf(sn, XMP_NAME_SIZE, "%s%s", pathname, mod->xxi[i].name);
	
	    if ((s = fopen (sn, "rb"))) {
	        load_sample(s, flags, &mod->xxs[mod->xxi[i].sub[0].sid], NULL);
	    }
	} else {
	    load_sample(f, flags, &mod->xxs[mod->xxi[i].sub[0].sid], NULL);
	}
    }

    if (mod->chn > 4) {
	m->quirk &= ~QUIRK_MODRNG;
	m->quirk |= QUIRKS_FT2;
	m->read_event_type = READ_EVENT_FT2;
    } else if (strcmp(tracker, "Protracker") == 0) {
	m->quirk |= QUIRK_INVLOOP;
    }

    return 0;
}
예제 #12
0
파일: stc_load.c 프로젝트: rikolous/gideros
static int stc_load(struct module_data *m, HIO_HANDLE * f, const int start)
{
    struct xmp_module *mod = &m->mod;
    struct xmp_event *event /*, *noise*/;
    int i, j;
    uint8 buf[100];
    int pos_ptr, orn_ptr, pat_ptr;
    struct stc_ord stc_ord[256];
    struct stc_pat stc_pat[MAX_PAT];
    int num, flag, orn;
    int *decoded;
    struct spectrum_extra *se;

    LOAD_INIT();

    mod->spd = hio_read8(f);		/* Speed */
    pos_ptr = hio_read16l(f);		/* Positions pointer */
    orn_ptr = hio_read16l(f);		/* Ornaments pointer */
    pat_ptr = hio_read16l(f);		/* Patterns pointer */

    hio_read(buf, 18, 1, f);		/* Title */
    copy_adjust(mod->name, (uint8 *)buf, 18);
    set_type(m, "ZX Spectrum Sound Tracker");

    hio_read16l(f);			/* Size */

    /* Read orders */

    hio_seek(f, pos_ptr, SEEK_SET);
    mod->len = hio_read8(f) + 1;

    for (num = i = 0; i < mod->len; i++) {
        stc_ord[i].pattern = hio_read8(f);
        stc_ord[i].height = hio_read8s(f);
        //printf("%d %d -- ", stc_ord[i].pattern, stc_ord[i].height);

        for (flag = j = 0; j < i; j++) {
            if (stc_ord[i].pattern == stc_ord[j].pattern &&
                    stc_ord[i].height == stc_ord[j].height)
            {
                mod->xxo[i] = mod->xxo[j];
                flag = 1;
                break;
            }
        }
        if (!flag) {
            mod->xxo[i] = num++;
        }
        //printf("%d\n", mod->xxo[i]);
    }

    mod->chn = 3;
    mod->pat = num;
    mod->trk = mod->pat * mod->chn;
    mod->ins = 15;
    mod->smp = mod->ins;
    orn = (pat_ptr - orn_ptr) / 33;

    MODULE_INFO();

    /* Read patterns */

    if (pattern_init(mod) < 0)
        return -1;

    hio_seek(f, pat_ptr, SEEK_SET);
    decoded = calloc(mod->pat, sizeof(int));
    D_(D_INFO "Stored patterns: %d ", mod->pat);

    for (i = 0; i < MAX_PAT; i++) {
        if (hio_read8(f) == 0xff)
            break;
        stc_pat[i].ch[0] = hio_read16l(f);
        stc_pat[i].ch[1] = hio_read16l(f);
        stc_pat[i].ch[2] = hio_read16l(f);
    }

    for (i = 0; i < mod->len; i++) {		/* pattern */
        int src = stc_ord[i].pattern - 1;
        int dest = mod->xxo[i];
        int trans = stc_ord[i].height;

        if (decoded[dest])
            continue;

        //printf("%d/%d) Read pattern %d -> %d\n", i, mod->len, src, dest);

        if (pattern_tracks_alloc(mod, dest, 64) < 0)
            return -1;

        for (j = 0; j < 3; j++) {		/* row */
            int row = 0;
            int x;
            int rowinc = 0;

            hio_seek(f, stc_pat[src].ch[j], SEEK_SET);

            do {
                for (;;) {
                    x = hio_read8(f);

                    if (x == 0xff)
                        break;

//printf("pat %d, channel %d, row %d, x = %02x\n", dest, j, row, x);
                    event = &EVENT(dest, j, row);

                    if (x <= 0x5f) {
                        event->note = x + 18 + trans;
                        row += 1 + rowinc;
                        break;
                    }

                    if (x <= 0x6f) {
                        event->ins = x - 0x5f - 1;
                    } else if (x <= 0x7f) {
                        /* ornament*/
                        event->fxt = FX_SYNTH_0;
                        event->fxp = x - 0x70;
                    } else if (x == 0x80) {
                        event->note = XMP_KEY_OFF;
                        row += 1 + rowinc;
                        break;
                    } else if (x == 0x81) {
                        /* ? */
                        row += 1 + rowinc;
                    } else if (x == 0x82) {
                        /* disable ornament/envelope */
                        event->fxt = FX_SYNTH_0;
                        event->fxp = 0;
                        event->f2t = FX_SYNTH_2;
                        event->f2p = 0;
                    } else if (x <= 0x8e) {
                        /* envelope */
                        event->fxt = FX_SYNTH_0 +
                                     x - 0x80;      /* R13 */
                        event->fxp = hio_read8(f); /* R11 */
                        event->f2t = FX_SYNTH_1;
                        event->f2p = hio_read8(f); /* R12 */
                    } else {
                        rowinc = x - 0xa1;
                    }
                }
            } while (x != 0xff);
        }

        decoded[dest] = 1;
    }

    free(decoded);

    /* Read instruments */

    if (instrument_init(mod) < 0)
        return -1;

    hio_seek(f, 27, SEEK_SET);

    D_(D_INFO "Instruments: %d", mod->ins);
    for (i = 0; i < mod->ins; i++) {
        struct spectrum_sample ss;

        memset(&ss, 0, sizeof (struct spectrum_sample));
        if (subinstrument_alloc(mod, i, 1) < 0)
            return -1;
        mod->xxi[i].nsm = 1;
        mod->xxi[i].sub[0].vol = 0x40;
        mod->xxi[i].sub[0].pan = 0x80;
        mod->xxi[i].sub[0].xpo = -1;
        mod->xxi[i].sub[0].sid = i;

        hio_read(buf, 1, 99, f);

        if (buf[97] == 0) {
            ss.loop = 32;
            ss.length = 33;
        } else {
            ss.loop = buf[97] - 1;
            if (ss.loop > 31)
                ss.loop = 31;
            ss.length = buf[97] + buf[98];
            if (ss.length > 32)
                ss.length = 32;
            if (ss.length == 0)
                ss.length = 1;
            if (ss.loop >= ss.length)
                ss.loop = ss.length - 1;

            if (ss.length < 32) {
                ss.length += 33 - (ss.loop + 1);
                ss.loop = 32;
            }
        }

        /* Read sample ticks */

        for (j = 0; j < 31; j++) {
            struct spectrum_stick *sst = &ss.stick[j];
            uint8 *chdata = &buf[1 + j * 3];

            memset(sst, 0, sizeof (struct spectrum_stick));

            if (~chdata[1] & 0x80) {
                sst->flags |= SPECTRUM_FLAG_MIXNOISE;
                sst->noise_env_inc = chdata[1] & 0x1f;

                if (sst->noise_env_inc & 0x10)
                    sst->noise_env_inc |= 0xf0;
            }

            if (~chdata[1] & 0x40)
                sst->flags |= SPECTRUM_FLAG_MIXTONE;

            sst->vol = chdata[0] & 0x0f;

            sst->tone_inc = (((int)(chdata[0] & 0xf0)) << 4) |
                            chdata[2];

            if (~chdata[1] & 0x20)
                sst->tone_inc = -sst->tone_inc;

            sst->flags |= SPECTRUM_FLAG_ENVELOPE;

            /*if (j != 0) {
            	reportv(ctx, 1, "               ");
            }
            reportv(ctx, 1, "%02X %c%c%c %c%03x %x\n", j,
            	sst->flags & SPECTRUM_FLAG_MIXTONE ? 'T' : 't',
            	sst->flags & SPECTRUM_FLAG_MIXNOISE ? 'N' : 'n',
            	sst->flags & SPECTRUM_FLAG_ENVELOPE ? 'E' : 'e',
            	sst->tone_inc >= 0 ? '+' : '-',
            	sst->tone_inc >= 0 ?
            		sst->tone_inc : -sst->tone_inc,
            	sst->vol);*/

        }

        if (load_sample(m, f, SAMPLE_FLAG_SPECTRUM, &mod->xxs[i],
                        (char *)&ss) < 0) {
            return -1;
        }
    }

    /* Read ornaments */

    hio_seek(f, orn_ptr, SEEK_SET);
    m->extra = calloc(1, sizeof (struct spectrum_extra));
    se = m->extra;

    D_(D_INFO "Ornaments: %d", orn);
    for (i = 0; i < orn; i++) {
        int index;
        struct spectrum_ornament *so;

        index = hio_read8(f);

        so = &se->ornament[index];
        so->length = 32;
        so->loop = 31;

        for (j = 0; j < 32; j++) {
            so->val[j] = hio_read8s(f);
        }
    }

    for (i = 0; i < 4; i++) {
        mod->xxc[i].pan = 0x80;
        mod->xxc[i].flg = XMP_CHANNEL_SYNTH;
    }

    m->synth = &synth_spectrum;

    return 0;
}
예제 #13
0
int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
{
	alpm_list_t *i;
	alpm_list_t *deltas = NULL;
	size_t numtargs, current = 0, replaces = 0;
	int errors;
	alpm_trans_t *trans = handle->trans;

	if(download_files(handle, &deltas)) {
		alpm_list_free(deltas);
		return -1;
	}

	if(validate_deltas(handle, deltas, data)) {
		alpm_list_free(deltas);
		return -1;
	}
	alpm_list_free(deltas);

	/* Check integrity of packages */
	numtargs = alpm_list_count(trans->add);
	EVENT(trans, ALPM_TRANS_EVT_INTEGRITY_START, NULL, NULL);

	errors = 0;

	for(i = trans->add; i; i = i->next, current++) {
		alpm_pkg_t *spkg = i->data;
		int percent = (current * 100) / numtargs;
		const char *filename;
		char *filepath;
		alpm_siglevel_t level;

		PROGRESS(trans, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", percent,
				numtargs, current);
		if(spkg->origin == PKG_FROM_FILE) {
			continue; /* pkg_load() has been already called, this package is valid */
		}

		filename = alpm_pkg_get_filename(spkg);
		filepath = _alpm_filecache_find(handle, filename);
		alpm_db_t *sdb = alpm_pkg_get_db(spkg);
		level = alpm_db_get_siglevel(sdb);

		/* load the package file and replace pkgcache entry with it in the target list */
		/* TODO: alpm_pkg_get_db() will not work on this target anymore */
		_alpm_log(handle, ALPM_LOG_DEBUG,
				"replacing pkgcache entry with package file for target %s\n",
				spkg->name);
		alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1, spkg->md5sum,
				spkg->base64_sig, level);
		if(!pkgfile) {
			errors++;
			*data = alpm_list_add(*data, strdup(filename));
			FREE(filepath);
			continue;
		}
		FREE(filepath);
		pkgfile->reason = spkg->reason; /* copy over install reason */
		i->data = pkgfile;
		_alpm_pkg_free_trans(spkg); /* spkg has been removed from the target list */
	}

	PROGRESS(trans, ALPM_TRANS_PROGRESS_INTEGRITY_START, "", 100,
			numtargs, current);
	EVENT(trans, ALPM_TRANS_EVT_INTEGRITY_DONE, NULL, NULL);


	if(errors) {
		RET_ERR(handle, ALPM_ERR_PKG_INVALID, -1);
	}

	if(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY) {
		return 0;
	}

	trans->state = STATE_COMMITING;

	replaces = alpm_list_count(trans->remove);

	/* fileconflict check */
	if(!(trans->flags & ALPM_TRANS_FLAG_FORCE)) {
		EVENT(trans, ALPM_TRANS_EVT_FILECONFLICTS_START, NULL, NULL);

		_alpm_log(handle, ALPM_LOG_DEBUG, "looking for file conflicts\n");
		alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle,
				trans->add, trans->remove);
		if(conflict) {
			if(data) {
				*data = conflict;
			} else {
				alpm_list_free_inner(conflict, (alpm_list_fn_free)_alpm_fileconflict_free);
				alpm_list_free(conflict);
			}
			RET_ERR(handle, ALPM_ERR_FILE_CONFLICTS, -1);
		}

		EVENT(trans, ALPM_TRANS_EVT_FILECONFLICTS_DONE, NULL, NULL);
	}

	/* check available disk space */
	if(handle->checkspace) {
		EVENT(trans, ALPM_TRANS_EVT_DISKSPACE_START, NULL, NULL);

		_alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space\n");
		if(_alpm_check_diskspace(handle) == -1) {
			_alpm_log(handle, ALPM_LOG_ERROR, "%s\n", _("not enough free disk space"));
			return -1;
		}

		EVENT(trans, ALPM_TRANS_EVT_DISKSPACE_DONE, NULL, NULL);
	}

	/* remove conflicting and to-be-replaced packages */
	if(replaces) {
		_alpm_log(handle, ALPM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n");
		/* we want the frontend to be aware of commit details */
		if(_alpm_remove_packages(handle) == -1) {
			_alpm_log(handle, ALPM_LOG_ERROR, _("could not commit removal transaction\n"));
			return -1;
		}
	}

	/* install targets */
	_alpm_log(handle, ALPM_LOG_DEBUG, "installing packages\n");
	if(_alpm_upgrade_packages(handle) == -1) {
		_alpm_log(handle, ALPM_LOG_ERROR, _("could not commit transaction\n"));
		return -1;
	}

	return 0;
}
예제 #14
0
static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
{
	const char *cachedir;
	alpm_list_t *i, *j;
	alpm_list_t *files = NULL;
	int errors = 0;

	cachedir = _alpm_filecache_setup(handle);
	handle->trans->state = STATE_DOWNLOADING;

	/* Total progress - figure out the total download size if required to
	 * pass to the callback. This function is called once, and it is up to the
	 * frontend to compute incremental progress. */
	if(handle->totaldlcb) {
		off_t total_size = (off_t)0;
		/* sum up the download size for each package and store total */
		for(i = handle->trans->add; i; i = i->next) {
			alpm_pkg_t *spkg = i->data;
			total_size += spkg->download_size;
		}
		handle->totaldlcb(total_size);
	}

	/* group sync records by repository and download */
	for(i = handle->dbs_sync; i; i = i->next) {
		alpm_db_t *current = i->data;

		for(j = handle->trans->add; j; j = j->next) {
			alpm_pkg_t *spkg = j->data;

			if(spkg->origin != PKG_FROM_FILE && current == spkg->origin_data.db) {
				alpm_list_t *delta_path = spkg->delta_path;
				if(delta_path) {
					/* using deltas */
					alpm_list_t *dlts;
					for(dlts = delta_path; dlts; dlts = dlts->next) {
						alpm_delta_t *delta = dlts->data;
						if(delta->download_size != 0) {
							struct dload_payload *dpayload;

							CALLOC(dpayload, 1, sizeof(*dpayload), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
							STRDUP(dpayload->filename, delta->delta, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
							dpayload->max_size = delta->download_size;

							files = alpm_list_add(files, dpayload);
						}
						/* keep a list of all the delta files for md5sums */
						*deltas = alpm_list_add(*deltas, delta);
					}

				} else if(spkg->download_size != 0) {
					struct dload_payload *payload;

					ASSERT(spkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
					CALLOC(payload, 1, sizeof(*payload), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
					STRDUP(payload->filename, spkg->filename, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
					payload->max_size = alpm_pkg_get_size(spkg);

					files = alpm_list_add(files, payload);
				}

			}
		}

		if(files) {
			EVENT(handle->trans, ALPM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
			for(j = files; j; j = j->next) {
				struct dload_payload *payload = j->data;
				alpm_list_t *server;
				int ret = -1;
				for(server = current->servers; server; server = server->next) {
					const char *server_url = server->data;
					size_t len;

					/* print server + filename into a buffer */
					len = strlen(server_url) + strlen(payload->filename) + 2;
					CALLOC(payload->fileurl, len, sizeof(char), RET_ERR(handle, ALPM_ERR_MEMORY, -1));
					snprintf(payload->fileurl, len, "%s/%s", server_url, payload->filename);
					payload->handle = handle;
					payload->allow_resume = 1;

					ret = _alpm_download(payload, cachedir, NULL);
					if(ret != -1) {
						break;
					}
				}
				if(ret == -1) {
					errors++;
				}
			}

			alpm_list_free_inner(files, (alpm_list_fn_free)_alpm_dload_payload_free);
			alpm_list_free(files);
			files = NULL;
			if(errors) {
				_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files from %s\n"),
						current->treename);
				if(handle->pm_errno == 0) {
					handle->pm_errno = ALPM_ERR_RETRIEVE;
				}
				return -1;
			}
		}
	}

	for(j = handle->trans->add; j; j = j->next) {
		alpm_pkg_t *pkg = j->data;
		pkg->infolevel &= ~INFRQ_DSIZE;
		pkg->download_size = 0;
	}

	/* clear out value to let callback know we are done */
	if(handle->totaldlcb) {
		handle->totaldlcb(0);
	}
	return 0;
}
예제 #15
0
// EGL_EXT_platform_base
EGLDisplay EGLAPIENTRY GetPlatformDisplayEXT(EGLenum platform, void *native_display, const EGLint *attrib_list)
{
    EVENT("(EGLenum platform = %d, void* native_display = 0x%0.8p, const EGLint* attrib_list = 0x%0.8p)",
          platform, native_display, attrib_list);

    const ClientExtensions &clientExtensions = Display::getClientExtensions();

    switch (platform)
    {
      case EGL_PLATFORM_ANGLE_ANGLE:
        if (!clientExtensions.platformANGLE)
        {
            SetGlobalError(Error(EGL_BAD_PARAMETER));
            return EGL_NO_DISPLAY;
        }
        break;

      default:
        SetGlobalError(Error(EGL_BAD_CONFIG));
        return EGL_NO_DISPLAY;
    }

    EGLint platformType = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
    EGLint deviceType = EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE;
    bool majorVersionSpecified = false;
    bool minorVersionSpecified = false;
    bool enableAutoTrimSpecified = false;
    bool deviceTypeSpecified = false;

    bool requestedAllowRenderToBackBuffer = false;
#if defined(ANGLE_ENABLE_WINDOWS_STORE)
    requestedAllowRenderToBackBuffer = true;
#endif

    if (attrib_list)
    {
        for (const EGLint *curAttrib = attrib_list; curAttrib[0] != EGL_NONE; curAttrib += 2)
        {
            switch (curAttrib[0])
            {
              case EGL_PLATFORM_ANGLE_TYPE_ANGLE:
                switch (curAttrib[1])
                {
                  case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
                    break;

                  case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
                  case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
                    if (!clientExtensions.platformANGLED3D)
                    {
                        SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
                        return EGL_NO_DISPLAY;
                    }
                    break;

                  case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
                  case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
                    if (!clientExtensions.platformANGLEOpenGL)
                    {
                        SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
                        return EGL_NO_DISPLAY;
                    }
                    break;

                  default:
                    SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
                    return EGL_NO_DISPLAY;
                }
                platformType = curAttrib[1];
                break;

              case EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE:
                if (curAttrib[1] != EGL_DONT_CARE)
                {
                    majorVersionSpecified = true;
                }
                break;

              case EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE:
                if (curAttrib[1] != EGL_DONT_CARE)
                {
                    minorVersionSpecified = true;
                }
                break;

              case EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE:
                switch (curAttrib[1])
                {
                  case EGL_TRUE:
                  case EGL_FALSE:
                    break;
                  default:
                    SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
                    return EGL_NO_DISPLAY;
                }
                enableAutoTrimSpecified = true;
                break;

              case EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE:
                switch (curAttrib[1])
                {
                  case EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE:
                  case EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE:
                  case EGL_PLATFORM_ANGLE_DEVICE_TYPE_REFERENCE_ANGLE:
                    deviceTypeSpecified = true;
                    break;

                  case EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE:
                    // This is a hidden option, accepted by the OpenGL back-end.
                    break;

                  default:
                    SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
                    return EGL_NO_DISPLAY;
                }
                deviceType = curAttrib[1];
                break;

              case EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER:
                switch (curAttrib[1])
                {
                case EGL_FALSE:
                case EGL_TRUE:
                    break;

                default:
                    SetGlobalError(egl::Error(EGL_SUCCESS));
                    return EGL_NO_DISPLAY;
                }

                requestedAllowRenderToBackBuffer = (curAttrib[1] == EGL_TRUE);
                break;

              default:
                break;
            }
        }
    }

    if (!majorVersionSpecified && minorVersionSpecified)
    {
        SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
        return EGL_NO_DISPLAY;
    }

    if (deviceType == EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE &&
        platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
    {
        SetGlobalError(Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE requires a device type of "
                                                "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
        return EGL_NO_DISPLAY;
    }

    if (platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE && requestedAllowRenderToBackBuffer)
    {
        SetGlobalError(egl::Error(EGL_BAD_ATTRIBUTE));
        return EGL_NO_DISPLAY;
    }

    if (enableAutoTrimSpecified &&
        platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
    {
        SetGlobalError(Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE requires a device type of "
                                                "EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE."));
        return EGL_NO_DISPLAY;
    }

    if (deviceTypeSpecified &&
        platformType != EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE &&
        platformType != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE)
    {
        SetGlobalError(Error(EGL_BAD_ATTRIBUTE, "EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE requires a device type of "
                                                "EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE or EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE."));
        return EGL_NO_DISPLAY;
    }

    SetGlobalError(Error(EGL_SUCCESS));

    EGLNativeDisplayType displayId = static_cast<EGLNativeDisplayType>(native_display);
    return Display::getDisplay(displayId, AttributeMap(attrib_list));
}
예제 #16
0
EGLSurface __stdcall eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p)",
          dpy, config, attrib_list);

    try
    {
        egl::Display *display = static_cast<egl::Display*>(dpy);
        EGLint width = 0, height = 0;

        if (!validate(display, config))
        {
            return EGL_NO_SURFACE;
        }

        if (attrib_list)
        {
            while (*attrib_list != EGL_NONE)
            {
                switch (attrib_list[0])
                {
                  case EGL_WIDTH:
                    width = attrib_list[1];
                    break;
                  case EGL_HEIGHT:
                    height = attrib_list[1];
                    break;
                  case EGL_LARGEST_PBUFFER:
                    if (attrib_list[1] != EGL_FALSE)
                      UNIMPLEMENTED(); // FIXME
                    break;
                  case EGL_TEXTURE_FORMAT:
                  case EGL_TEXTURE_TARGET:
                    switch (attrib_list[1])
                    {
                      case EGL_NO_TEXTURE:
                        break;
                      default:
                        return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
                    }
                    break;
                  case EGL_MIPMAP_TEXTURE:
                    if (attrib_list[1] != EGL_FALSE)
                      return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
                    break;
                  case EGL_VG_COLORSPACE:
                    return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
                  case EGL_VG_ALPHA_FORMAT:
                    return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
                  default:
                    return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
                }

                attrib_list += 2;
            }
        }

        if (width == 0 || height == 0)
          return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);

        EGLSurface surface = (EGLSurface)display->createOffscreenSurface(width, height, config);

        return success(surface);
    }
    catch(std::bad_alloc&)
    {
        return error(EGL_BAD_ALLOC, EGL_NO_SURFACE);
    }

    return EGL_NO_SURFACE;
}
예제 #17
0
static int polly_load(struct module_data *m, FILE *f, const int start)
{
	struct xmp_module *mod = &m->mod;
	struct xmp_event *event;
	uint8 *buf;
	int i, j, k;

	LOAD_INIT();

	read8(f);			/* skip 0xae */
	/*
	 * File is RLE-encoded, escape is 0xAE (Aleksi Eeben's initials).
	 * Actual 0xAE is encoded as 0xAE 0x01
	 */
	if ((buf = calloc(1, 0x10000)) == NULL)
		return -1;

	decode_rle(buf, f, 0x10000);

	for (i = 0; buf[ORD_OFS + i] != 0 && i < 128; i++)
		mod->xxo[i] = buf[ORD_OFS + i] - 0xe0;
	mod->len = i;

	memcpy(mod->name, buf + ORD_OFS + 160, 16);
	/* memcpy(m->author, buf + ORD_OFS + 176, 16); */
	set_type(m, "Polly Tracker");
	MODULE_INFO();

	mod->spd = 0x03;
	mod->bpm = 0x7d * buf[ORD_OFS + 193] / 0x88;
#if 0
	for (i = 0; i < 1024; i++) {
		if ((i % 16) == 0) printf("\n");
		printf("%02x ", buf[ORD_OFS + i]);
	}
#endif

	mod->pat = 0;
	for (i = 0; i < mod->len; i++) {
		if (mod->xxo[i] > mod->pat)
			mod->pat = mod->xxo[i];
	}
	mod->pat++;
	
	mod->chn = 4;
	mod->trk = mod->pat * mod->chn;

	PATTERN_INIT();

	D_(D_INFO "Stored patterns: %d", mod->pat);

	for (i = 0; i < mod->pat; i++) {
		PATTERN_ALLOC(i);
		mod->xxp[i]->rows = 64;
		TRACK_ALLOC(i);

		for (j = 0; j < 64; j++) {
			for (k = 0; k < 4; k++) {
				uint8 x = buf[i * PAT_SIZE + j * 4 + k];
				event = &EVENT(i, k, j);
				if (x == 0xf0) {
					event->fxt = FX_BREAK;
					event->fxp = 0;
					continue;
				}
				event->note = LSN(x);
				if (event->note)
					event->note += 48;
				event->ins = MSN(x);
			}
		}
	}

	mod->ins = mod->smp = 15;
	INSTRUMENT_INIT();

	for (i = 0; i < 15; i++) {
		mod->xxi[i].sub = calloc(sizeof (struct xmp_subinstrument), 1);
		mod->xxs[i].len = buf[ORD_OFS + 129 + i] < 0x10 ? 0 :
					256 * buf[ORD_OFS + 145 + i];
		mod->xxi[i].sub[0].fin = 0;
		mod->xxi[i].sub[0].vol = 0x40;
		mod->xxs[i].lps = 0;
		mod->xxs[i].lpe = 0;
		mod->xxs[i].flg = 0;
		mod->xxi[i].sub[0].pan = 0x80;
		mod->xxi[i].sub[0].sid = i;
		mod->xxi[i].nsm = !!(mod->xxs[i].len);
		mod->xxi[i].rls = 0xfff;

                D_(D_INFO "[%2X] %04x %04x %04x %c V%02x",
                       		i, mod->xxs[i].len, mod->xxs[i].lps,
                        	mod->xxs[i].lpe, ' ', mod->xxi[i].sub[0].vol);
	}

	/* Convert samples from 6 to 8 bits */
	for (i = SMP_OFS; i < 0x10000; i++)
		buf[i] = buf[i] << 2;

	/* Read samples */
	D_(D_INFO "Loading samples: %d", mod->ins);

	for (i = 0; i < mod->ins; i++) {
		if (mod->xxs[i].len == 0)
			continue;
		load_sample(NULL, SAMPLE_FLAG_NOLOAD | SAMPLE_FLAG_UNS,
				&mod->xxs[mod->xxi[i].sub[0].sid],
				(char*)buf + ORD_OFS + 256 +
					256 * (buf[ORD_OFS + 129 + i] - 0x10));
	}

	free(buf);

	/* make it mono */
	for (i = 0; i < mod->chn; i++)
		mod->xxc[i].pan = 0x80;

	m->quirk |= QUIRK_MODRNG;

	return 0;
}
예제 #18
0
static int coco_load(struct module_data *m, HIO_HANDLE *f, const int start)
{
	struct xmp_module *mod = &m->mod;
	struct xmp_event *event;
	int i, j;
	int seq_ptr, pat_ptr, smp_ptr[100];

	LOAD_INIT();

	mod->chn = hio_read8(f) & 0x3f;
	libxmp_read_title(f, mod->name, 20);

	for (i = 0; i < 20; i++) {
		if (mod->name[i] == 0x0d)
			mod->name[i] = 0;
	}

	libxmp_set_type(m, "Coconizer");

	mod->ins = mod->smp = hio_read8(f);
	mod->len = hio_read8(f);
	mod->pat = hio_read8(f);
	mod->trk = mod->pat * mod->chn;

	seq_ptr = hio_read32l(f);
	pat_ptr = hio_read32l(f);

	MODULE_INFO();

	if (libxmp_init_instrument(m) < 0)
		return -1;

	m->vol_table = (int *)arch_vol_table;
	m->volbase = 0xff;

	for (i = 0; i < mod->ins; i++) {
		if (libxmp_alloc_subinstrument(mod, i, 1) < 0)
			return -1;

		smp_ptr[i] = hio_read32l(f);
		mod->xxs[i].len = hio_read32l(f);
		mod->xxi[i].sub[0].vol = 0xff - hio_read32l(f);
		mod->xxi[i].sub[0].pan = 0x80;
		mod->xxs[i].lps = hio_read32l(f);
                mod->xxs[i].lpe = mod->xxs[i].lps + hio_read32l(f);
		if (mod->xxs[i].lpe)
			mod->xxs[i].lpe -= 1;
		mod->xxs[i].flg = mod->xxs[i].lps > 0 ?  XMP_SAMPLE_LOOP : 0;
		hio_read(mod->xxi[i].name, 1, 11, f);
		for (j = 0; j < 11; j++) {
			if (mod->xxi[i].name[j] == 0x0d)
				mod->xxi[i].name[j] = 0;
		}
		hio_read8(f);	/* unused */
		mod->xxi[i].sub[0].sid = i;

		if (mod->xxs[i].len > 0)
			mod->xxi[i].nsm = 1;

		D_(D_INFO "[%2X] %-10.10s  %05x %05x %05x %c V%02x",
				i, mod->xxi[i].name,
				mod->xxs[i].len, mod->xxs[i].lps, mod->xxs[i].lpe,
				mod->xxs[i].flg & XMP_SAMPLE_LOOP ? 'L' : ' ',
				mod->xxi[i].sub[0].vol);
	}

	/* Sequence */

	hio_seek(f, start + seq_ptr, SEEK_SET);
	for (i = 0; ; i++) {
		uint8 x = hio_read8(f);
		if (x == 0xff)
			break;
		mod->xxo[i] = x;
	}
	for (i++; i % 4; i++)	/* for alignment */
		hio_read8(f);


	/* Patterns */

	if (libxmp_init_pattern(mod) < 0)
		return -1;

	D_(D_INFO "Stored patterns: %d", mod->pat);

	for (i = 0; i < mod->pat; i++) {
		if (libxmp_alloc_pattern_tracks(mod, i, 64) < 0)
			return -1;

		for (j = 0; j < (64 * mod->chn); j++) {
			event = &EVENT (i, j % mod->chn, j / mod->chn);
			event->fxp = hio_read8(f);
			event->fxt = hio_read8(f);
			event->ins = hio_read8(f);
			event->note = hio_read8(f);
			if (event->note)
				event->note += 12;

			fix_effect(event);
		}
	}

	/* Read samples */

	D_(D_INFO "Stored samples : %d", mod->smp);

	for (i = 0; i < mod->ins; i++) {
		if (mod->xxi[i].nsm == 0)
			continue;

		hio_seek(f, start + smp_ptr[i], SEEK_SET);
		if (libxmp_load_sample(m, f, SAMPLE_FLAG_VIDC, &mod->xxs[i], NULL) < 0)
			return -1;
	}

	for (i = 0; i < mod->chn; i++) {
		mod->xxc[i].pan = DEFPAN((((i + 3) / 2) % 2) * 0xff);
	}

	return 0;
}
EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
          dpy, surface, attribute, value);

    Display *display = static_cast<Display*>(dpy);
    Surface *eglSurface = (Surface*)surface;

    Error error = ValidateSurface(display, eglSurface);
    if (error.isError())
    {
        SetGlobalError(error);
        return EGL_FALSE;
    }

    if (surface == EGL_NO_SURFACE)
    {
        SetGlobalError(Error(EGL_BAD_SURFACE));
        return EGL_FALSE;
    }

    switch (attribute)
    {
      case EGL_VG_ALPHA_FORMAT:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_VG_COLORSPACE:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_CONFIG_ID:
        *value = eglSurface->getConfig()->configID;
        break;
      case EGL_HEIGHT:
        *value = eglSurface->getHeight();
        break;
      case EGL_HORIZONTAL_RESOLUTION:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_LARGEST_PBUFFER:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_MIPMAP_TEXTURE:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_MIPMAP_LEVEL:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_MULTISAMPLE_RESOLVE:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_PIXEL_ASPECT_RATIO:
        *value = eglSurface->getPixelAspectRatio();
        break;
      case EGL_RENDER_BUFFER:
        *value = eglSurface->getRenderBuffer();
        break;
      case EGL_SWAP_BEHAVIOR:
        *value = eglSurface->getSwapBehavior();
        break;
      case EGL_TEXTURE_FORMAT:
        *value = eglSurface->getTextureFormat();
        break;
      case EGL_TEXTURE_TARGET:
        *value = eglSurface->getTextureTarget();
        break;
      case EGL_VERTICAL_RESOLUTION:
        UNIMPLEMENTED();   // FIXME
        break;
      case EGL_WIDTH:
        *value = eglSurface->getWidth();
        break;
      case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
        if (!display->getExtensions().postSubBuffer)
        {
            SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
            return EGL_FALSE;
        }
        *value = eglSurface->isPostSubBufferSupported();
        break;
      case EGL_FIXED_SIZE_ANGLE:
        if (!display->getExtensions().windowFixedSize)
        {
            SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
            return EGL_FALSE;
        }
        *value = eglSurface->isFixedSize();
        break;
      default:
        SetGlobalError(Error(EGL_BAD_ATTRIBUTE));
        return EGL_FALSE;
    }

    SetGlobalError(Error(EGL_SUCCESS));
    return EGL_TRUE;
}
예제 #20
0
EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
          dpy, surface, attribute, value);

    ANGLE_TRY
    {
        egl::Display *display = static_cast<egl::Display*>(dpy);
        egl::Surface *eglSurface = (egl::Surface*)surface;

        if (!validateSurface(display, eglSurface))
        {
            return EGL_FALSE;
        }

        if (surface == EGL_NO_SURFACE)
        {
            return egl::error(EGL_BAD_SURFACE, EGL_FALSE);
        }

        switch (attribute)
        {
          case EGL_VG_ALPHA_FORMAT:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_VG_COLORSPACE:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_CONFIG_ID:
            *value = eglSurface->getConfigID();
            break;
          case EGL_HEIGHT:
            *value = eglSurface->getHeight();
            break;
          case EGL_HORIZONTAL_RESOLUTION:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_LARGEST_PBUFFER:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_MIPMAP_TEXTURE:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_MIPMAP_LEVEL:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_MULTISAMPLE_RESOLVE:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_PIXEL_ASPECT_RATIO:
            *value = eglSurface->getPixelAspectRatio();
            break;
          case EGL_RENDER_BUFFER:
            *value = eglSurface->getRenderBuffer();
            break;
          case EGL_SWAP_BEHAVIOR:
            *value = eglSurface->getSwapBehavior();
            break;
          case EGL_TEXTURE_FORMAT:
            *value = eglSurface->getTextureFormat();
            break;
          case EGL_TEXTURE_TARGET:
            *value = eglSurface->getTextureTarget();
            break;
          case EGL_VERTICAL_RESOLUTION:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_WIDTH:
            *value = eglSurface->getWidth();
            break;
          case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
            *value = eglSurface->isPostSubBufferSupported();
            break;
          case EGL_FIXED_SIZE_ANGLE:
            *value = eglSurface->isFixedSize();
            break;
          default:
            return egl::error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
        }

        return egl::success(EGL_TRUE);
    }
    ANGLE_CATCH_ALL
    {
        return egl::error(EGL_BAD_ALLOC, EGL_FALSE);
    }
}
EGLBoolean EGLAPIENTRY MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface draw = 0x%0.8p, EGLSurface read = 0x%0.8p, EGLContext ctx = 0x%0.8p)",
          dpy, draw, read, ctx);

    Display *display = static_cast<Display*>(dpy);
    gl::Context *context = static_cast<gl::Context*>(ctx);

    // If ctx is EGL_NO_CONTEXT and either draw or read are not EGL_NO_SURFACE, an EGL_BAD_MATCH
    // error is generated.
    if (ctx == EGL_NO_CONTEXT && (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE))
    {
        SetGlobalError(Error(EGL_BAD_MATCH));
        return EGL_FALSE;
    }

    if (ctx != EGL_NO_CONTEXT && draw == EGL_NO_SURFACE && read == EGL_NO_SURFACE)
    {
        SetGlobalError(Error(EGL_BAD_MATCH));
        return EGL_FALSE;
    }

    // If either of draw or read is a valid surface and the other is EGL_NO_SURFACE, an
    // EGL_BAD_MATCH error is generated.
    if ((read == EGL_NO_SURFACE) != (draw == EGL_NO_SURFACE))
    {
        SetGlobalError(Error(
            EGL_BAD_MATCH, "read and draw must both be valid surfaces, or both be EGL_NO_SURFACE"));
        return EGL_FALSE;
    }

    if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display))
    {
        SetGlobalError(Error(EGL_BAD_DISPLAY, "'dpy' not a valid EGLDisplay handle"));
        return EGL_FALSE;
    }

    // EGL 1.5 spec: dpy can be uninitialized if all other parameters are null
    if (!display->isInitialized() && (ctx != EGL_NO_CONTEXT || draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE))
    {
        SetGlobalError(Error(EGL_NOT_INITIALIZED, "'dpy' not initialized"));
        return EGL_FALSE;
    }

    if (ctx != EGL_NO_CONTEXT)
    {
        Error error = ValidateContext(display, context);
        if (error.isError())
        {
            SetGlobalError(error);
            return EGL_FALSE;
        }
    }

    if (display->isInitialized())
    {
        if (display->testDeviceLost())
        {
            display->notifyDeviceLost();
            return EGL_FALSE;
        }

        if (display->isDeviceLost())
        {
            SetGlobalError(Error(EGL_CONTEXT_LOST));
            return EGL_FALSE;
        }
    }

    Surface *drawSurface = static_cast<Surface*>(draw);
    if (draw != EGL_NO_SURFACE)
    {
        Error error = ValidateSurface(display, drawSurface);
        if (error.isError())
        {
            SetGlobalError(error);
            return EGL_FALSE;
        }
    }

    Surface *readSurface = static_cast<Surface*>(read);
    if (read != EGL_NO_SURFACE)
    {
        Error error = ValidateSurface(display, readSurface);
        if (error.isError())
        {
            SetGlobalError(error);
            return EGL_FALSE;
        }
    }

    if (readSurface)
    {
        Error readCompatError = ValidateCompatibleConfigs(readSurface->getConfig(), context->getConfig(), readSurface->getType());
        if (readCompatError.isError())
        {
            SetGlobalError(readCompatError);
            return EGL_FALSE;
        }
    }

    if (draw != read)
    {
        UNIMPLEMENTED();   // FIXME

        if (drawSurface)
        {
            Error drawCompatError = ValidateCompatibleConfigs(drawSurface->getConfig(), context->getConfig(), drawSurface->getType());
            if (drawCompatError.isError())
            {
                SetGlobalError(drawCompatError);
                return EGL_FALSE;
            }
        }
    }

    Error makeCurrentError = display->makeCurrent(drawSurface, readSurface, context);
    if (makeCurrentError.isError())
    {
        SetGlobalError(makeCurrentError);
        return EGL_FALSE;
    }

    gl::Context *previousContext = GetGlobalContext();

    SetGlobalDisplay(display);
    SetGlobalDrawSurface(drawSurface);
    SetGlobalReadSurface(readSurface);
    SetGlobalContext(context);

    // Release the surface from the previously-current context, to allow
    // destroyed surfaces to delete themselves.
    if (previousContext != nullptr && context != previousContext)
    {
        previousContext->releaseSurface();
    }

    SetGlobalError(Error(EGL_SUCCESS));
    return EGL_TRUE;
}
예제 #22
0
EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = 0x%0.8p, "
          "const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list);

    ANGLE_TRY
    {
        // Get the requested client version (default is 1) and check it is 2 or 3.
        EGLint client_version = 1;
        bool reset_notification = false;
        bool robust_access = false;

        if (attrib_list)
        {
            for (const EGLint* attribute = attrib_list; attribute[0] != EGL_NONE; attribute += 2)
            {
                switch (attribute[0])
                {
                  case EGL_CONTEXT_CLIENT_VERSION:
                    client_version = attribute[1];
                    break;
                  case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
                    if (attribute[1] == EGL_TRUE)
                    {
                        return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);   // Unimplemented
                        // robust_access = true;
                    }
                    else if (attribute[1] != EGL_FALSE)
                        return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
                    break;
                  case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
                    if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT)
                        reset_notification = true;
                    else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT)
                        return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
                    break;
                  default:
                    return egl::error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
                }
            }
        }

        if (client_version != 2 && client_version != 3)
        {
            return egl::error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
        }

        egl::Display *display = static_cast<egl::Display*>(dpy);

        if (share_context)
        {
            gl::Context* sharedGLContext = static_cast<gl::Context*>(share_context);

            if (sharedGLContext->isResetNotificationEnabled() != reset_notification)
            {
                return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
            }

            if (sharedGLContext->getClientVersion() != client_version)
            {
                return egl::error(EGL_BAD_CONTEXT, EGL_NO_CONTEXT);
            }

            // Can not share contexts between displays
            if (sharedGLContext->getRenderer() != display->getRenderer())
            {
                return egl::error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
            }
        }

        if (!validateConfig(display, config))
        {
            return EGL_NO_CONTEXT;
        }

        return display->createContext(config, client_version, static_cast<gl::Context*>(share_context), reset_notification, robust_access);
    }
    ANGLE_CATCH_ALL
    {
        return egl::error(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
    }
}
예제 #23
0
파일: mod_load.c 프로젝트: Nlcke/gideros
static int mod_load(struct module_data *m, HIO_HANDLE *f, const int start)
{
    struct xmp_module *mod = &m->mod;
    int i, j;
    struct xmp_event *event;
    struct mod_header mh;
    uint8 mod_event[4];
    char magic[8];
    int ptkloop = 0;			/* Protracker loop */

    LOAD_INIT();

    mod->ins = 31;
    mod->smp = mod->ins;
    mod->chn = 0;

    m->quirk |= QUIRK_MODRNG;

    hio_read(&mh.name, 20, 1, f);
    for (i = 0; i < 31; i++) {
	hio_read(&mh.ins[i].name, 22, 1, f);	/* Instrument name */
	mh.ins[i].size = hio_read16b(f);	/* Length in 16-bit words */
	mh.ins[i].finetune = hio_read8(f);	/* Finetune (signed nibble) */
	mh.ins[i].volume = hio_read8(f);	/* Linear playback volume */
	mh.ins[i].loop_start = hio_read16b(f);	/* Loop start in 16-bit words */
	mh.ins[i].loop_size = hio_read16b(f);	/* Loop size in 16-bit words */
    }
    mh.len = hio_read8(f);
    mh.restart = hio_read8(f);
    hio_read(&mh.order, 128, 1, f);
    memset(magic, 0, 8);
    hio_read(magic, 4, 1, f);

    if (!memcmp(magic, "M.K.", 4)) {
	mod->chn = 4;
    } else if (!strncmp(magic + 2, "CH", 2) &&
	isdigit((int)magic[0]) && isdigit((int)magic[1])) {
	mod->chn = (*magic - '0') * 10 + magic[1] - '0';
    } else if (!strncmp(magic + 1, "CHN", 3) && isdigit((int)*magic)) {
	mod->chn = *magic - '0';
    } else {
	return -1;
    }

    strncpy(mod->name, (char *) mh.name, 20);

    mod->len = mh.len;
    /* mod->rst = mh.restart; */

    if (mod->rst >= mod->len)
	mod->rst = 0;
    memcpy(mod->xxo, mh.order, 128);

    for (i = 0; i < 128; i++) {
	/* This fixes dragnet.mod (garbage in the order list) */
	if (mod->xxo[i] > 0x7f)
		break;
	if (mod->xxo[i] > mod->pat)
	    mod->pat = mod->xxo[i];
    }
    mod->pat++;

    if (instrument_init(mod) < 0)
	return -1;

    for (i = 0; i < mod->ins; i++) {
	if (subinstrument_alloc(mod, i, 1) < 0)
	    return -1;

	mod->xxs[i].len = 2 * mh.ins[i].size;
	mod->xxs[i].lps = 2 * mh.ins[i].loop_start;
	mod->xxs[i].lpe = mod->xxs[i].lps + 2 * mh.ins[i].loop_size;
	if (mod->xxs[i].lpe > mod->xxs[i].len)
		mod->xxs[i].lpe = mod->xxs[i].len;
	mod->xxs[i].flg = (mh.ins[i].loop_size > 1 && mod->xxs[i].lpe >= 4) ?
		XMP_SAMPLE_LOOP : 0;
	mod->xxi[i].sub[0].fin = (int8)(mh.ins[i].finetune << 4);
	mod->xxi[i].sub[0].vol = mh.ins[i].volume;
	mod->xxi[i].sub[0].pan = 0x80;
	mod->xxi[i].sub[0].sid = i;
	instrument_name(mod, i, mh.ins[i].name, 22);

	if (mod->xxs[i].len > 0)
		mod->xxi[i].nsm = 1;
    }

    mod->trk = mod->chn * mod->pat;

    set_type(m, mod->chn == 4 ? "Protracker" : "Fasttracker");

    MODULE_INFO();

    for (i = 0; i < mod->ins; i++) {
	D_(D_INFO "[%2X] %-22.22s %04x %04x %04x %c V%02x %+d %c\n",
		i, mod->xxi[i].name,
		mod->xxs[i].len, mod->xxs[i].lps, mod->xxs[i].lpe,
		(mh.ins[i].loop_size > 1 && mod->xxs[i].lpe > 8) ?
			'L' : ' ', mod->xxi[i].sub[0].vol,
		mod->xxi[i].sub[0].fin >> 4,
		ptkloop && mod->xxs[i].lps == 0 && mh.ins[i].loop_size > 1 &&
			mod->xxs[i].len > mod->xxs[i].lpe ? '!' : ' ');
    }

    if (pattern_init(mod) < 0)
	return -1;

    /* Load and convert patterns */
    D_(D_INFO "Stored patterns: %d", mod->pat);

    for (i = 0; i < mod->pat; i++) {
	if (pattern_tracks_alloc(mod, i, 64) < 0)
	    return -1;

	for (j = 0; j < (64 * mod->chn); j++) {
	    event = &EVENT (i, j % mod->chn, j / mod->chn);
	    hio_read (mod_event, 1, 4, f);
	    decode_protracker_event(event, mod_event);
	}
    }

    /* Load samples */

    D_(D_INFO "Stored samples: %d", mod->smp);

    for (i = 0; i < mod->smp; i++) {
	int flags;

	if (!mod->xxs[i].len)
	    continue;

	flags = ptkloop ? SAMPLE_FLAG_FULLREP : 0;

	if (load_sample(m, f, flags, &mod->xxs[i], NULL) < 0)
	    return -1;
    }

    if (mod->chn > 4) {
	m->quirk &= ~QUIRK_MODRNG;
	m->quirk |= QUIRKS_FT2;
	m->read_event_type = READ_EVENT_FT2;
    }

    return 0;
}
예제 #24
0
파일: hsc_load.c 프로젝트: bithorder/libxmp
static int hsc_load(struct module_data *m, xmp_file f, const int start)
{
    struct xmp_module *mod = &m->mod;
    int pat, i, r, c;
    struct xmp_event *event;
    uint8 *x, *sid, e[2], buf[128 * 12];

    LOAD_INIT();

    xmp_fread(buf, 1, 128 * 12, f);

    x = buf;
    for (i = 0; i < 128; i++, x += 12) {
	if (x[9] & ~0x3 || x[10] & ~0x3)	/* Test waveform register */
	    break;
	if (x[8] & ~0xf)			/* Test feedback & algorithm */
	    break;
    }

    mod->ins = i;

    xmp_fseek(f, start + 0, SEEK_SET);

    mod->chn = 9;
    mod->bpm = 135;
    mod->spd = 6;
    mod->smp = mod->ins;

    m->quirk |= QUIRK_LINEAR;

    set_type(m, "HSC-Tracker");

    MODULE_INFO();

    /* Read instruments */
    INSTRUMENT_INIT();

    xmp_fread (buf, 1, 128 * 12, f);
    sid = buf;
    for (i = 0; i < mod->ins; i++, sid += 12) {
	mod->xxi[i].sub = calloc(sizeof (struct xmp_subinstrument), 1);
	mod->xxi[i].nsm = 1;
	mod->xxi[i].sub[0].vol = 0x40;
	mod->xxi[i].sub[0].fin = (int8)sid[11] / 4;
	mod->xxi[i].sub[0].pan = 0x80;
	mod->xxi[i].sub[0].xpo = 0;
	mod->xxi[i].sub[0].sid = i;
	mod->xxi[i].rls = LSN(sid[7]) * 32;	/* carrier release */

	load_sample(m, f, SAMPLE_FLAG_ADLIB | SAMPLE_FLAG_HSC,
					&mod->xxs[i], (char *)sid);
    }

    /* Read orders */
    for (pat = i = 0; i < 51; i++) {
	xmp_fread (&mod->xxo[i], 1, 1, f);
	if (mod->xxo[i] & 0x80)
	    break;			/* FIXME: jump line */
	if (mod->xxo[i] > pat)
	    pat = mod->xxo[i];
    }
    xmp_fseek(f, 50 - i, SEEK_CUR);
    mod->len = i;
    mod->pat = pat + 1;
    mod->trk = mod->pat * mod->chn;

    D_(D_INFO "Module length: %d", mod->len);
    D_(D_INFO "Instruments: %d", mod->ins);
    D_(D_INFO "Stored patterns: %d", mod->pat);

    PATTERN_INIT();

    /* Read and convert patterns */
    for (i = 0; i < mod->pat; i++) {
	int ins[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

	PATTERN_ALLOC (i);
	mod->xxp[i]->rows = 64;
	TRACK_ALLOC (i);
        for (r = 0; r < mod->xxp[i]->rows; r++) {
            for (c = 0; c < 9; c++) {
	        xmp_fread (e, 1, 2, f);
	        event = &EVENT (i, c, r);
		if (e[0] & 0x80) {
		    ins[c] = e[1] + 1;
		} else if (e[0] == 0x7f) {
		    event->note = XMP_KEY_OFF;
		} else if (e[0] > 0) {
		    event->note = e[0] + 25;
		    event->ins = ins[c];
		}

		event->fxt = 0;
		event->fxp = 0;

		if (e[1] == 0x01) {
		    event->fxt = 0x0d;
		    event->fxp = 0;
		}
	    }
	}
    }

    for (i = 0; i < mod->chn; i++) {
	mod->xxc[i].pan = 0x80;
	mod->xxc[i].flg = XMP_CHANNEL_SYNTH;
    }

    m->synth = &synth_adlib;

    return 0;
}
예제 #25
0
파일: stx_load.c 프로젝트: bithorder/libxmp
static int stx_load(struct module_data *m, xmp_file f, const int start)
{
    struct xmp_module *mod = &m->mod;
    int c, r, i, broken = 0;
    struct xmp_event *event = 0, dummy;
    struct stx_file_header sfh;
    struct stx_instrument_header sih;
    uint8 n, b;
    uint16 x16;
    int bmod2stm = 0;
    uint16 *pp_ins;		/* Parapointers to instruments */
    uint16 *pp_pat;		/* Parapointers to patterns */

    LOAD_INIT();

    xmp_fread(&sfh.name, 20, 1, f);
    xmp_fread(&sfh.magic, 8, 1, f);
    sfh.psize = read16l(f);
    sfh.unknown1 = read16l(f);
    sfh.pp_pat = read16l(f);
    sfh.pp_ins = read16l(f);
    sfh.pp_chn = read16l(f);
    sfh.unknown2 = read16l(f);
    sfh.unknown3 = read16l(f);
    sfh.gvol = read8(f);
    sfh.tempo = read8(f);
    sfh.unknown4 = read16l(f);
    sfh.unknown5 = read16l(f);
    sfh.patnum = read16l(f);
    sfh.insnum = read16l(f);
    sfh.ordnum = read16l(f);
    sfh.unknown6 = read16l(f);
    sfh.unknown7 = read16l(f);
    sfh.unknown8 = read16l(f);
    xmp_fread(&sfh.magic2, 4, 1, f);

    /* BMOD2STM does not convert pitch */
    if (!strncmp ((char *) sfh.magic, "BMOD2STM", 8))
	bmod2stm = 1;

#if 0
    if ((strncmp ((char *) sfh.magic, "!Scream!", 8) &&
	!bmod2stm) || strncmp ((char *) sfh.magic2, "SCRM", 4))
	return -1;
#endif

    mod->ins = sfh.insnum;
    mod->pat = sfh.patnum;
    mod->trk = mod->pat * mod->chn;
    mod->len = sfh.ordnum;
    mod->spd = MSN (sfh.tempo);
    mod->smp = mod->ins;
    m->c4rate = C4_NTSC_RATE;

    /* STM2STX 1.0 released with STMIK 0.2 converts STMs with the pattern
     * length encoded in the first two bytes of the pattern (like S3M).
     */
    xmp_fseek(f, start + (sfh.pp_pat << 4), SEEK_SET);
    x16 = read16l(f);
    xmp_fseek(f, start + (x16 << 4), SEEK_SET);
    x16 = read16l(f);
    if (x16 == sfh.psize)
	broken = 1;

    strncpy(mod->name, (char *)sfh.name, 20);
    if (bmod2stm)
	set_type(m, "BMOD2STM STX");
    else
	snprintf(mod->type, XMP_NAME_SIZE, "STM2STX 1.%d", broken ? 0 : 1);

    MODULE_INFO();
 
    pp_pat = calloc (2, mod->pat);
    pp_ins = calloc (2, mod->ins);

    /* Read pattern pointers */
    xmp_fseek(f, start + (sfh.pp_pat << 4), SEEK_SET);
    for (i = 0; i < mod->pat; i++)
	pp_pat[i] = read16l(f);

    /* Read instrument pointers */
    xmp_fseek(f, start + (sfh.pp_ins << 4), SEEK_SET);
    for (i = 0; i < mod->ins; i++)
	pp_ins[i] = read16l(f);

    /* Skip channel table (?) */
    xmp_fseek(f, start + (sfh.pp_chn << 4) + 32, SEEK_SET);

    /* Read orders */
    for (i = 0; i < mod->len; i++) {
	mod->xxo[i] = read8(f);
	xmp_fseek(f, 4, SEEK_CUR);
    }
 
    INSTRUMENT_INIT();

    /* Read and convert instruments and samples */

    for (i = 0; i < mod->ins; i++) {
	mod->xxi[i].sub = calloc(sizeof (struct xmp_subinstrument), 1);
	xmp_fseek(f, start + (pp_ins[i] << 4), SEEK_SET);

	sih.type = read8(f);
	xmp_fread(&sih.dosname, 13, 1, f);
	sih.memseg = read16l(f);
	sih.length = read32l(f);
	sih.loopbeg = read32l(f);
	sih.loopend = read32l(f);
	sih.vol = read8(f);
	sih.rsvd1 = read8(f);
	sih.pack = read8(f);
	sih.flags = read8(f);
	sih.c2spd = read16l(f);
	sih.rsvd2 = read16l(f);
	xmp_fread(&sih.rsvd3, 4, 1, f);
	sih.int_gp = read16l(f);
	sih.int_512 = read16l(f);
	sih.int_last = read32l(f);
	xmp_fread(&sih.name, 28, 1, f);
	xmp_fread(&sih.magic, 4, 1, f);

	mod->xxi[i].nsm = !!(mod->xxs[i].len = sih.length);
	mod->xxs[i].lps = sih.loopbeg;
	mod->xxs[i].lpe = sih.loopend;
	if (mod->xxs[i].lpe == 0xffff)
	    mod->xxs[i].lpe = 0;
	mod->xxs[i].flg = mod->xxs[i].lpe > 0 ? XMP_SAMPLE_LOOP : 0;
	mod->xxi[i].sub[0].vol = sih.vol;
	mod->xxi[i].sub[0].pan = 0x80;
	mod->xxi[i].sub[0].sid = i;

	copy_adjust(mod->xxi[i].name, sih.name, 12);

	D_(D_INFO "[%2X] %-14.14s %04x %04x %04x %c V%02x %5d\n", i,
		mod->xxi[i].name, mod->xxs[i].len, mod->xxs[i].lps, mod->xxs[i].lpe,
		mod->xxs[i].flg & XMP_SAMPLE_LOOP ? 'L' : ' ',
		mod->xxi[i].sub[0].vol, sih.c2spd);

	sih.c2spd = 8363 * sih.c2spd / 8448;
	c2spd_to_note(sih.c2spd, &mod->xxi[i].sub[0].xpo, &mod->xxi[i].sub[0].fin);
    }

    PATTERN_INIT();

    /* Read and convert patterns */
    D_(D_INFO "Stored patterns: %d", mod->pat);

    for (i = 0; i < mod->pat; i++) {
	PATTERN_ALLOC (i);
	mod->xxp[i]->rows = 64;
	TRACK_ALLOC (i);

	if (!pp_pat[i])
	    continue;

	xmp_fseek(f, start + (pp_pat[i] << 4), SEEK_SET);
	if (broken)
	    xmp_fseek(f, 2, SEEK_CUR);

	for (r = 0; r < 64; ) {
	    b = read8(f);

	    if (b == S3M_EOR) {
		r++;
		continue;
	    }

	    c = b & S3M_CH_MASK;
	    event = c >= mod->chn ? &dummy : &EVENT (i, c, r);

	    if (b & S3M_NI_FOLLOW) {
		n = read8(f);

		switch (n) {
		case 255:
		    n = 0;
		    break;	/* Empty note */
		case 254:
		    n = XMP_KEY_OFF;
		    break;	/* Key off */
		default:
		    n = 37 + 12 * MSN (n) + LSN (n);
		}

		event->note = n;
		event->ins = read8(f);;
	    }

	    if (b & S3M_VOL_FOLLOWS) {
		event->vol = read8(f) + 1;
	    }

	    if (b & S3M_FX_FOLLOWS) {
		event->fxt = fx[read8(f)];
		event->fxp = read8(f);
		switch (event->fxt) {
		case FX_SPEED:
		    event->fxp = MSN (event->fxp);
		    break;
		case FX_NONE:
		    event->fxp = event->fxt = 0;
		    break;
		}
	    }
	}

    }

    free (pp_pat);
    free (pp_ins);

    /* Read samples */
    D_(D_INFO "Stored samples: %d", mod->smp);

    for (i = 0; i < mod->ins; i++) {
	load_sample(m, f, 0, &mod->xxs[mod->xxi[i].sub[0].sid], NULL);
    }

    m->quirk |= QUIRK_VSALL | QUIRKS_ST3;
    m->read_event_type = READ_EVENT_ST3;

    return 0;
}
예제 #26
0
EGLBoolean __stdcall eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint *value = 0x%0.8p)",
          dpy, surface, attribute, value);

    try
    {
        egl::Display *display = static_cast<egl::Display*>(dpy);
        egl::Surface *eglSurface = (egl::Surface*)surface;

        if (!validateSurface(display, eglSurface))
        {
            return EGL_FALSE;
        }

        if (surface == EGL_NO_SURFACE)
        {
            return error(EGL_BAD_SURFACE, EGL_FALSE);
        }

        switch (attribute)
        {
          case EGL_VG_ALPHA_FORMAT:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_VG_COLORSPACE:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_CONFIG_ID:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_HEIGHT:
            *value = eglSurface->getHeight();
            break;
          case EGL_HORIZONTAL_RESOLUTION:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_LARGEST_PBUFFER:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_MIPMAP_TEXTURE:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_MIPMAP_LEVEL:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_MULTISAMPLE_RESOLVE:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_PIXEL_ASPECT_RATIO:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_RENDER_BUFFER:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_SWAP_BEHAVIOR:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_TEXTURE_FORMAT:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_TEXTURE_TARGET:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_VERTICAL_RESOLUTION:
            UNIMPLEMENTED();   // FIXME
            break;
          case EGL_WIDTH:
            *value = eglSurface->getWidth();
            break;
          case EGL_POST_SUB_BUFFER_SUPPORTED_NV:
            *value = eglSurface->isPostSubBufferSupported();
            break;
          default:
            return error(EGL_BAD_ATTRIBUTE, EGL_FALSE);
        }

        return success(EGL_TRUE);
    }
    catch(std::bad_alloc&)
    {
        return error(EGL_BAD_ALLOC, EGL_FALSE);
    }

    return EGL_FALSE;
}
예제 #27
0
#include <string.h>

#include "timestamp.h"

struct event_name {
	const char* 	name;
	cmd_t	 	id;
};

#define EVENT(name)					\
	{#name "_START", TS_ ## name ## _START},	\
	{#name "_END", TS_ ## name ## _END}

static struct event_name event_table[] =
{
	EVENT(SCHED),
	EVENT(SCHED2),
	EVENT(TICK),
	EVENT(RELEASE),
	EVENT(PLUGIN_SCHED),
	EVENT(PLUGIN_TICK),
	EVENT(CXS),
	EVENT(SEND_RESCHED),
	{"RELEASE_LATENCY", TS_RELEASE_LATENCY},

	EVENT(SYSCALL_IN),
	EVENT(SYSCALL_OUT),
	EVENT(LOCK),
	EVENT(UNLOCK),
	{"LOCK_SUSPEND", TS_LOCK_SUSPEND},
	{"LOCK_RESUME", TS_LOCK_RESUME},
예제 #28
0
EGLContext __stdcall eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
{
    EVENT("(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = 0x%0.8p, "
          "const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list);

    try
    {
        // Get the requested client version (default is 1) and check it is two.
        EGLint client_version = 1;
        bool reset_notification = false;
        bool robust_access = false;

        if (attrib_list)
        {
            for (const EGLint* attribute = attrib_list; attribute[0] != EGL_NONE; attribute += 2)
            {
                switch (attribute[0])
                {
                  case EGL_CONTEXT_CLIENT_VERSION:
                    client_version = attribute[1];
                    break;
                  case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
                    if (attribute[1] == EGL_TRUE)
                    {
                        return error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);   // Unimplemented
                        robust_access = true;
                    }
                    else if (attribute[1] != EGL_FALSE)
                        return error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
                    break;
                  case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
                    if (attribute[1] == EGL_LOSE_CONTEXT_ON_RESET_EXT)
                        reset_notification = true;
                    else if (attribute[1] != EGL_NO_RESET_NOTIFICATION_EXT)
                        return error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
                    break;
                  default:
                    return error(EGL_BAD_ATTRIBUTE, EGL_NO_CONTEXT);
                }
            }
        }

        if (client_version != 2)
        {
            return error(EGL_BAD_CONFIG, EGL_NO_CONTEXT);
        }

        if (share_context && static_cast<gl::Context*>(share_context)->isResetNotificationEnabled() != reset_notification)
        {
            return error(EGL_BAD_MATCH, EGL_NO_CONTEXT);
        }

        egl::Display *display = static_cast<egl::Display*>(dpy);

        if (!validateConfig(display, config))
        {
            return EGL_NO_CONTEXT;
        }

        EGLContext context = display->createContext(config, static_cast<gl::Context*>(share_context), reset_notification, robust_access);

        if (context)
            return success(context);
        else
            return error(EGL_CONTEXT_LOST, EGL_NO_CONTEXT);
    }
    catch(std::bad_alloc&)
    {
        return error(EGL_BAD_ALLOC, EGL_NO_CONTEXT);
    }

    return EGL_NO_CONTEXT;
}
예제 #29
0
static int ptm_load(struct xmp_context *ctx, FILE *f, const int start)
{
    struct xmp_player_context *p = &ctx->p;
    struct xmp_mod_context *m = &p->m;
    int c, r, i, smp_ofs[256];
    struct xxm_event *event;
    struct ptm_file_header pfh;
    struct ptm_instrument_header pih;
    uint8 n, b;

    LOAD_INIT();

    /* Load and convert header */

    fread(&pfh.name, 28, 1, f);		/* Song name */
    pfh.doseof = read8(f);		/* 0x1a */
    pfh.vermin = read8(f);		/* Minor version */
    pfh.vermaj = read8(f);		/* Major type */
    pfh.rsvd1 = read8(f);		/* Reserved */
    pfh.ordnum = read16l(f);		/* Number of orders (must be even) */
    pfh.insnum = read16l(f);		/* Number of instruments */
    pfh.patnum = read16l(f);		/* Number of patterns */
    pfh.chnnum = read16l(f);		/* Number of channels */
    pfh.flags = read16l(f);		/* Flags (set to 0) */
    pfh.rsvd2 = read16l(f);		/* Reserved */
    pfh.magic = read32b(f); 		/* 'PTMF' */

#if 0
    if (pfh.magic != MAGIC_PTMF)
	return -1;
#endif

    fread(&pfh.rsvd3, 16, 1, f);	/* Reserved */
    fread(&pfh.chset, 32, 1, f);	/* Channel settings */
    fread(&pfh.order, 256, 1, f);	/* Orders */
    for (i = 0; i < 128; i++)
	pfh.patseg[i] = read16l(f);

    m->xxh->len = pfh.ordnum;
    m->xxh->ins = pfh.insnum;
    m->xxh->pat = pfh.patnum;
    m->xxh->chn = pfh.chnnum;
    m->xxh->trk = m->xxh->pat * m->xxh->chn;
    m->xxh->smp = m->xxh->ins;
    m->xxh->tpo = 6;
    m->xxh->bpm = 125;
    memcpy (m->xxo, pfh.order, 256);

    m->c4rate = C4_NTSC_RATE;

    copy_adjust((uint8 *)m->name, pfh.name, 28);
    sprintf(m->type, "PTMF %d.%02x (Poly Tracker)",
	pfh.vermaj, pfh.vermin);

    MODULE_INFO();

    INSTRUMENT_INIT();

    /* Read and convert instruments and samples */

    reportv(ctx, 1, "     Instrument name              Len   LBeg  LEnd  L Vol C4Spd\n");

    for (i = 0; i < m->xxh->ins; i++) {
	m->xxi[i] = calloc (sizeof (struct xxm_instrument), 1);

	pih.type = read8(f);			/* Sample type */
	fread(&pih.dosname, 12, 1, f);		/* DOS file name */
	pih.vol = read8(f);			/* Volume */
	pih.c4spd = read16l(f);			/* C4 speed */
	pih.smpseg = read16l(f);		/* Sample segment (not used) */
	pih.smpofs = read32l(f);		/* Sample offset */
	pih.length = read32l(f);		/* Length */
	pih.loopbeg = read32l(f);		/* Loop begin */
	pih.loopend = read32l(f);		/* Loop end */
	pih.gusbeg = read32l(f);		/* GUS begin address */
	pih.guslps = read32l(f);		/* GUS loop start address */
	pih.guslpe = read32l(f);		/* GUS loop end address */
	pih.gusflg = read8(f);			/* GUS loop flags */
	pih.rsvd1 = read8(f);			/* Reserved */
	fread(&pih.name, 28, 1, f);		/* Instrument name */
	pih.magic = read32b(f);			/* 'PTMS' */

	if ((pih.type & 3) != 1)
	    continue;

	smp_ofs[i] = pih.smpofs;
	m->xxih[i].nsm = !!(m->xxs[i].len = pih.length);
	m->xxs[i].lps = pih.loopbeg;
	m->xxs[i].lpe = pih.loopend;
	if (m->xxs[i].lpe)
		m->xxs[i].lpe--;
	m->xxs[i].flg = pih.type & 0x04 ? WAVE_LOOPING : 0;
	m->xxs[i].flg |= pih.type & 0x08 ? WAVE_LOOPING | WAVE_BIDIR_LOOP : 0;
	m->xxs[i].flg |= pih.type & 0x10 ? WAVE_16_BITS : 0;
	m->xxi[i][0].vol = pih.vol;
	m->xxi[i][0].pan = 0x80;
	m->xxi[i][0].sid = i;
	pih.magic = 0;

	copy_adjust(m->xxih[i].name, pih.name, 28);

	if ((V(1)) && (strlen((char *)m->xxih[i].name) || m->xxs[i].len))
	    report ("[%2X] %-28.28s %05x%c%05x %05x %c V%02x %5d\n",
		i, m->xxih[i].name, m->xxs[i].len, pih.type & 0x10 ? '+' : ' ',
		m->xxs[i].lps, m->xxs[i].lpe, m->xxs[i].flg & WAVE_LOOPING ? 'L' : ' ',
		m->xxi[i][0].vol, pih.c4spd);

	/* Convert C4SPD to relnote/finetune */
	c2spd_to_note (pih.c4spd, &m->xxi[i][0].xpo, &m->xxi[i][0].fin);
    }

    PATTERN_INIT();

    /* Read patterns */
    reportv(ctx, 0, "Stored patterns: %d ", m->xxh->pat);

    for (i = 0; i < m->xxh->pat; i++) {
	if (!pfh.patseg[i])
	    continue;
	PATTERN_ALLOC (i);
	m->xxp[i]->rows = 64;
	TRACK_ALLOC (i);
	fseek(f, start + 16L * pfh.patseg[i], SEEK_SET);
	r = 0;
	while (r < 64) {
	    fread (&b, 1, 1, f);
	    if (!b) {
		r++;
		continue;
	    }

	    c = b & PTM_CH_MASK;
	    if (c >= m->xxh->chn)
		continue;

	    event = &EVENT (i, c, r);
	    if (b & PTM_NI_FOLLOW) {
		fread (&n, 1, 1, f);
		switch (n) {
		case 255:
		    n = 0;
		    break;	/* Empty note */
		case 254:
		    n = XMP_KEY_OFF;
		    break;	/* Key off */
		}
		event->note = n;
		fread (&n, 1, 1, f);
		event->ins = n;
	    }
	    if (b & PTM_FX_FOLLOWS) {
		event->fxt = read8(f);
		event->fxp = read8(f);

		if (event->fxt > 0x17)
			event->fxt = event->fxp = 0;

		switch (event->fxt) {
		case 0x0e:	/* Extended effect */
		    if (MSN(event->fxp) == 0x8) {	/* Pan set */
			event->fxt = FX_SETPAN;
			event->fxp = LSN (event->fxp) << 4;
		    }
		    break;
		case 0x10:	/* Set global volume */
		    event->fxt = FX_GLOBALVOL;
		    break;
		case 0x11:	/* Multi retrig */
		    event->fxt = FX_MULTI_RETRIG;
		    break;
		case 0x12:	/* Fine vibrato */
		    event->fxt = FX_FINE4_VIBRA;
		    break;
		case 0x13:	/* Note slide down */
		    event->fxt = FX_NSLIDE_DN;
		    break;
		case 0x14:	/* Note slide up */
		    event->fxt = FX_NSLIDE_UP;
		    break;
		case 0x15:	/* Note slide down + retrig */
		    event->fxt = FX_NSLIDE_R_DN;
		    break;
		case 0x16:	/* Note slide up + retrig */
		    event->fxt = FX_NSLIDE_R_UP;
		    break;
		case 0x17:	/* Reverse sample */
		    event->fxt = event->fxp = 0;
		    break;
		}
	    }
	    if (b & PTM_VOL_FOLLOWS) {
		event->vol = read8(f) + 1;
	    }
	}
	reportv(ctx, 0, ".");
    }

    reportv(ctx, 0, "\nStored samples : %d ", m->xxh->smp);

    for (i = 0; i < m->xxh->smp; i++) {
	if (!m->xxs[i].len)
	    continue;
	fseek(f, start + smp_ofs[m->xxi[i][0].sid], SEEK_SET);
	xmp_drv_loadpatch(ctx, f, m->xxi[i][0].sid, m->c4rate,
			XMP_SMP_8BDIFF, &m->xxs[m->xxi[i][0].sid], NULL);
	reportv(ctx, 0, ".");
    }
    reportv(ctx, 0, "\n");

    m->vol_xlat = ptm_vol;

    for (i = 0; i < m->xxh->chn; i++)
	m->xxc[i].pan = pfh.chset[i] << 4;

    return 0;
}
예제 #30
0
int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
{
	alpm_list_t *i, *j;
	alpm_list_t *deps = NULL;
	alpm_list_t *unresolvable = NULL;
	alpm_list_t *remove = NULL;
	int ret = 0;
	alpm_trans_t *trans = handle->trans;

	if(data) {
		*data = NULL;
	}

	/* ensure all sync database are valid since we will be using them */
	for(i = handle->dbs_sync; i; i = i->next) {
		const alpm_db_t *db = i->data;
		if(!(db->status & DB_STATUS_VALID)) {
			RET_ERR(handle, ALPM_ERR_DB_INVALID, -1);
		}
	}

	if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
		alpm_list_t *resolved = NULL; /* target list after resolvedeps */

		/* Build up list by repeatedly resolving each transaction package */
		/* Resolve targets dependencies */
		EVENT(trans, ALPM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
		_alpm_log(handle, ALPM_LOG_DEBUG, "resolving target's dependencies\n");

		/* build remove list for resolvedeps */
		for(i = trans->add; i; i = i->next) {
			alpm_pkg_t *spkg = i->data;
			for(j = spkg->removes; j; j = j->next) {
				remove = alpm_list_add(remove, j->data);
			}
		}

		/* Compute the fake local database for resolvedeps (partial fix for the
		 * phonon/qt issue) */
		alpm_list_t *localpkgs = alpm_list_diff(_alpm_db_get_pkgcache(handle->db_local),
				trans->add, _alpm_pkg_cmp);

		/* Resolve packages in the transaction one at a time, in addition
		   building up a list of packages which could not be resolved. */
		for(i = trans->add; i; i = i->next) {
			alpm_pkg_t *pkg = i->data;
			if(_alpm_resolvedeps(handle, localpkgs, pkg, trans->add,
						&resolved, remove, data) == -1) {
				unresolvable = alpm_list_add(unresolvable, pkg);
			}
			/* Else, [resolved] now additionally contains [pkg] and all of its
			   dependencies not already on the list */
		}
		alpm_list_free(localpkgs);

		/* If there were unresolvable top-level packages, prompt the user to
		   see if they'd like to ignore them rather than failing the sync */
		if(unresolvable != NULL) {
			int remove_unresolvable = 0;
			QUESTION(trans, ALPM_TRANS_CONV_REMOVE_PKGS, unresolvable,
					NULL, NULL, &remove_unresolvable);
			if(remove_unresolvable) {
				/* User wants to remove the unresolvable packages from the
				   transaction. The packages will be removed from the actual
				   transaction when the transaction packages are replaced with a
				   dependency-reordered list below */
				handle->pm_errno = 0; /* pm_errno was set by resolvedeps */
				if(data) {
					alpm_list_free_inner(*data, (alpm_list_fn_free)_alpm_depmiss_free);
					alpm_list_free(*data);
					*data = NULL;
				}
			} else {
				/* pm_errno is set by resolvedeps */
				alpm_list_free(resolved);
				ret = -1;
				goto cleanup;
			}
		}

		/* Set DEPEND reason for pulled packages */
		for(i = resolved; i; i = i->next) {
			alpm_pkg_t *pkg = i->data;
			if(!_alpm_pkg_find(trans->add, pkg->name)) {
				pkg->reason = ALPM_PKG_REASON_DEPEND;
			}
		}

		/* Unresolvable packages will be removed from the target list, so
		   we free the transaction specific fields */
		alpm_list_free_inner(unresolvable, (alpm_list_fn_free)_alpm_pkg_free_trans);

		/* re-order w.r.t. dependencies */
		alpm_list_free(trans->add);
		trans->add = _alpm_sortbydeps(handle, resolved, 0);
		alpm_list_free(resolved);

		EVENT(trans, ALPM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
	}

	if(!(trans->flags & ALPM_TRANS_FLAG_NOCONFLICTS)) {
		/* check for inter-conflicts and whatnot */
		EVENT(trans, ALPM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);

		_alpm_log(handle, ALPM_LOG_DEBUG, "looking for conflicts\n");

		/* 1. check for conflicts in the target list */
		_alpm_log(handle, ALPM_LOG_DEBUG, "check targets vs targets\n");
		deps = _alpm_innerconflicts(handle, trans->add);

		for(i = deps; i; i = i->next) {
			alpm_conflict_t *conflict = i->data;
			alpm_pkg_t *rsync, *sync, *sync1, *sync2;

			/* have we already removed one of the conflicting targets? */
			sync1 = _alpm_pkg_find(trans->add, conflict->package1);
			sync2 = _alpm_pkg_find(trans->add, conflict->package2);
			if(!sync1 || !sync2) {
				continue;
			}

			_alpm_log(handle, ALPM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
					conflict->package1, conflict->package2);

			/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
			alpm_depend_t *dep1 = _alpm_splitdep(conflict->package1);
			alpm_depend_t *dep2 = _alpm_splitdep(conflict->package2);
			if(_alpm_depcmp(sync1, dep2)) {
				rsync = sync2;
				sync = sync1;
			} else if(_alpm_depcmp(sync2, dep1)) {
				rsync = sync1;
				sync = sync2;
			} else {
				_alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
				handle->pm_errno = ALPM_ERR_CONFLICTING_DEPS;
				ret = -1;
				if(data) {
					alpm_conflict_t *newconflict = _alpm_conflict_dup(conflict);
					if(newconflict) {
						*data = alpm_list_add(*data, newconflict);
					}
				}
				alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
				alpm_list_free(deps);
				_alpm_dep_free(dep1);
				_alpm_dep_free(dep2);
				goto cleanup;
			}
			_alpm_dep_free(dep1);
			_alpm_dep_free(dep2);

			/* Prints warning */
			_alpm_log(handle, ALPM_LOG_WARNING,
					_("removing '%s' from target list because it conflicts with '%s'\n"),
					rsync->name, sync->name);
			trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL);
			_alpm_pkg_free_trans(rsync); /* rsync is not transaction target anymore */
			continue;
		}

		alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
		alpm_list_free(deps);
		deps = NULL;

		/* 2. we check for target vs db conflicts (and resolve)*/
		_alpm_log(handle, ALPM_LOG_DEBUG, "check targets vs db and db vs targets\n");
		deps = _alpm_outerconflicts(handle->db_local, trans->add);

		for(i = deps; i; i = i->next) {
			alpm_conflict_t *conflict = i->data;

			/* if conflict->package2 (the local package) is not elected for removal,
			   we ask the user */
			int found = 0;
			for(j = trans->add; j && !found; j = j->next) {
				alpm_pkg_t *spkg = j->data;
				if(_alpm_pkg_find(spkg->removes, conflict->package2)) {
					found = 1;
				}
			}
			if(found) {
				continue;
			}

			_alpm_log(handle, ALPM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
					conflict->package1, conflict->package2);

			alpm_pkg_t *sync = _alpm_pkg_find(trans->add, conflict->package1);
			alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, conflict->package2);
			int doremove = 0;
			QUESTION(trans, ALPM_TRANS_CONV_CONFLICT_PKG, conflict->package1,
							conflict->package2, conflict->reason, &doremove);
			if(doremove) {
				/* append to the removes list */
				_alpm_log(handle, ALPM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2);
				sync->removes = alpm_list_add(sync->removes, local);
			} else { /* abort */
				_alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
				handle->pm_errno = ALPM_ERR_CONFLICTING_DEPS;
				ret = -1;
				if(data) {
					alpm_conflict_t *newconflict = _alpm_conflict_dup(conflict);
					if(newconflict) {
						*data = alpm_list_add(*data, newconflict);
					}
				}
				alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
				alpm_list_free(deps);
				goto cleanup;
			}
		}
		EVENT(trans, ALPM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
		alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_conflict_free);
		alpm_list_free(deps);
	}

	/* Build trans->remove list */
	for(i = trans->add; i; i = i->next) {
		alpm_pkg_t *spkg = i->data;
		for(j = spkg->removes; j; j = j->next) {
			alpm_pkg_t *rpkg = j->data;
			if(!_alpm_pkg_find(trans->remove, rpkg->name)) {
				_alpm_log(handle, ALPM_LOG_DEBUG, "adding '%s' to remove list\n", rpkg->name);
				trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(rpkg));
			}
		}
	}

	if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
		_alpm_log(handle, ALPM_LOG_DEBUG, "checking dependencies\n");
		deps = alpm_checkdeps(handle, _alpm_db_get_pkgcache(handle->db_local),
				trans->remove, trans->add, 1);
		if(deps) {
			handle->pm_errno = ALPM_ERR_UNSATISFIED_DEPS;
			ret = -1;
			if(data) {
				*data = deps;
			} else {
				alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_depmiss_free);
				alpm_list_free(deps);
			}
			goto cleanup;
		}
	}
	for(i = trans->add; i; i = i->next) {
		/* update download size field */
		alpm_pkg_t *spkg = i->data;
		if(compute_download_size(spkg) != 0) {
			ret = -1;
			goto cleanup;
		}
	}

cleanup:
	alpm_list_free(unresolvable);
	alpm_list_free(remove);

	return ret;
}