示例#1
0
void load_sid_song(char *data, int size) {

	FILE *fp = fopen("worker.sid", "wb");
	fwrite(data, 1, size, fp);
	fclose(fp);
	//char name[size+1];
	//memcpy(name, data, size);
	//name[size] = 0;
	int ret = psid_load_file("worker.sid");
	if (ret == 0) {
		int defaultSong;
		int songs = psid_tunes(&defaultSong);
		c64_song_init();
		emscripten_worker_respond("OK", 3);
	} else
		emscripten_worker_respond("FAIL", 5);
}
void one(char *data, int size) {
  int *x = (int*)data;
  int num = size/sizeof(int);
  for (int i = 0; i < num; i++) {
    x[i] += 1234;
  }
  emscripten_worker_respond(data, size);
}
void two(char *data, int size) {
  calls++;
  Info *x = (Info*)data;
  x[0].i++;
  x[0].f--;
  x[0].c++;
  x[0].d--;
  emscripten_worker_respond(data, size);
}
// Respond with 0, 1, 2, 3 each with finalResponse=false, and 4 with
// finalResponse=true.
    void one(char *data, int size) {
        int *x = (int*)data;

        if (*x == 0) {
            // Respond 0, 1, 2, 3
            for (int i = 0; i < 4; ++i) {
                *x = i;
                emscripten_worker_respond_provisionally(data, size);
            }
        }

        // Respond 4
        *x = 4;
        emscripten_worker_respond(data, size);
    }
void four(char *data, int size) {
  assert(data == 0);
  assert(size == 0);
  emscripten_worker_respond((char*)&calls, sizeof(calls));
}
void one(char *data, int size) {
  calls++;
  emscripten_worker_respond(data, size);
}
示例#7
0
void play_sid_song(char *data, int size) {
	static char buffer[512*1024];
	int l = atoi(data);
	psid_play((short*)buffer, l/2);
	emscripten_worker_respond(buffer, l);
}
void	WorkerServer::sendMessage(char* data, int size)
{
	emscripten_worker_respond(data, size);
}
示例#9
-1
void init_sid(char *data, int size) {
/*	char name[size+1];
	memcpy(name, data, size);
	name[size] = 0;
	printf(stderr, "Setting dir to %s", name);

	FILE *fp = fopen("data/c64/kernal", "rb");
	if(!fp) {
		emscripten_worker_respond("ACCESS", 7);
		return;
	}
	fclose(fp);
*/
	mkdir("c64", 0);
	FILE *fp = fopen("c64/kernal", "wb");
	fwrite(&data[0], 1, 8192, fp);
	fclose(fp);
	fp = fopen("c64/basic", "wb");
	fwrite(&data[8192], 1, 8192, fp);
	fclose(fp);
	fp = fopen("c64/chargen", "wb");
	fwrite(&data[8192*2], 1, 4096, fp);
	fclose(fp);

	if(init("c64") == 0) {
		emscripten_worker_respond("OK", 3);
	} else {
		emscripten_worker_respond("FAIL", 5);
	}
}