Example #1
0
void vblank_handler() {
	//printf("vblank\n");
	if (fbready) {
		video_flip();
		fbready = false;
	}
}
Example #2
0
static int gui_RunMenu(MENU *menu)
{
	MENUITEM *mi;
	u32 keys;

	for (;;) {
		mi = menu->m + menu->cur;
		keys = key_read();

		video_clear();

		// check keys
		if (keys & KEY_SELECT) {
			key_reset();
			return 0;
		} else if (keys & KEY_UP) {
			do {
				if (--menu->cur < 0)
					menu->cur = menu->num - 1;
			} while (!(menu->m + menu->cur)->name); // Skip over an empty menu entry.

		} else if (keys & KEY_DOWN) {
			do {
				if (++menu->cur == menu->num)
					menu->cur = 0;
			} while (!(menu->m + menu->cur)->name); // Skip over an empty menu entry.
		} else if (keys & KEY_A) {
			if (mi->on_press_a) {
				key_reset();
				int result = (*mi->on_press_a)();
				if (result)
					return result;
			}
		} else if (keys & KEY_B) {
			menu->cur = menu->num - 1;
			key_reset();
		}

		if ((keys & (KEY_LEFT | KEY_RIGHT)) && mi->on_press) {
			int result = (*mi->on_press)(keys);
			if (result)
				return result;
		}

		// diplay menu
		ShowMenu(menu);

		video_flip();
		timer_delay(75);

		if (keys & (KEY_A | KEY_B | KEY_X | KEY_Y | KEY_L | KEY_R |
			    KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN))
			timer_delay(50);
	}

	return 0;
}
Example #3
0
//Called via callback when handlepbp() in cdriso.cpp detects a multi-CD
// .pbp image is being loaded, so user can choose CD to boot from.
// This is necessary because we do not know if a given CD image is
// a multi-CD image until after cdrom plugin has gone through many
// steps and verifications.
static CALLBACK void gui_select_multicd_to_boot_from(void)
{
	if (cdrIsoMultidiskSelect >= cdrIsoMultidiskCount)
		cdrIsoMultidiskSelect = 0;

	//Pass false to indicate a CD is not being swapped through front-end menu
	gui_select_multicd(false);

	//Before return to emu, clear/flip once more in case we're triple-buffered
	video_clear();
	video_flip();
}
Example #4
0
int main(int argc, char* argv[]) {
  int i,j = 0;
  unsigned int frame = 0;
  char *rom_file = NULL;
  int rom_size = 0;
  double z80_cycles = 0;

  if (argc < 2) {
    fprintf(stderr, "Usage: %s ROM_FILE\n", argv[0]);
    return 1;
  }

  rom_file = argv[1];
  memory_init();
  rom_size = memory_load(rom_file);

  if (rom_size < 0) {
    fprintf(stderr, "Couldn't read ROM file %s\n", rom_file);
    return 1;
  }

  printf("Read ROM %s (%d bytes)\n", rom_file, rom_size);

  io_init();
  video_init();
  input_init();
  vpu_init();

  Z80Reset(&z80_state);
  z80_state.pc = 0;

  while (input_quit() == 0) {
    z80_cycles += Z80Emulate(&z80_state, Z80_CYCLES_PER_STEP);

    vpu_draw_screen();

    video_flip();
    video_wait_frame();

    input_process();

    Z80NonMaskableInterrupt (&z80_state);

    frame++;
  }

  printf("Ran %d frames and %f Z80 cycles.\n", frame, z80_cycles);

  return 0;
}
Example #5
0
static int gui_state_save(int slot)
{
	if (sshot_img) {
		free(sshot_img);
		sshot_img = NULL;
	}

	// Remember which saveslot was accessed last
	saveslot = slot;

	video_clear();
	port_printf(160-(6*8/2), 120-(8/2), "SAVING");
	video_flip();

	if (state_save(slot) < 0) {
		// Error saving

		for (;;) {
			u32 keys = key_read();
			video_clear();
			// check keys
			if (keys) {
				key_reset();
				return 0;
			}

			port_printf(160-(11*8/2), 120-12, "SAVE FAILED");
			port_printf(160-(18*8/2), 120+12, "Out of disk space?");
			video_flip();
			timer_delay(75);
		}
	}

	// Return -1 to gui_StateSave() caller menu, so it knows
	//  to tell main menu to return back to main menu.
	return -1;
}
Example #6
0
static int gui_Credits()
{
	for (;;) {
		u32 keys = key_read();

		video_clear();

		// check keys
		if (keys) {
			key_reset();
			return 0;
		}

		// diplay menu
		port_printf(15 * 8 + 4, 10, "CREDITS:");
		port_printf( 2 * 8, 30, "pcsx team, pcsx-df team, pcsx-r team");

		port_printf( 6 * 8, 50, "Franxis and Chui - PCSX4ALL");
		port_printf( 4 * 8, 60, "Unai - fast PCSX4ALL GPU plugin");

		port_printf( 5 * 8, 80, "Ulrich Hecht - psx4all-dingoo");

		port_printf(10 * 8, 90, "notaz - PCSX-ReArmed");

		port_printf( 0 * 8, 110, "Dmitry Smagin - porting and optimizing");
		port_printf( 0 * 8, 120, "                of mips recompiler,");
		port_printf( 0 * 8, 130, "                gui coding");

		port_printf( 0 * 8, 150, "senquack - fixing polygons in gpu_unai,");
		port_printf( 0 * 8, 160, "           porting spu and other stuff");
		port_printf( 0 * 8, 170, "           from pcsx_rearmed and pcsx-r,");
		port_printf( 0 * 8, 180, "           many fixes and improvements");

		port_printf( 0 * 8, 195, "JohnnyonFlame   - gpu_unai dithering");
		port_printf( 0 * 8, 205, "                  and other fixes");

		port_printf( 0 * 8, 220, "zear         - gui fixing and testing");

		video_flip();
		timer_delay(75);
	}

	return 0;
}
Example #7
0
void text_flip(void)
{
#ifndef DREAMCAST
	SDL_Delay(10);
#endif
#ifdef MENU_ALPHA
	{
		unsigned i;
		for(i=0;i<screen->h;i++)
			memcpy(
				screen->pixels + (screen->pitch * i),
				text_screen->pixels + (text_screen->pitch * i),
				screen->w * screen->format->BytesPerPixel
			);
	}
#else
	SDL_BlitSurface(text_screen,NULL,screen,NULL);
#endif
	video_flip(screen);
}
Example #8
0
//To choose which of a multi-CD image should be used. Can be called
// from front-end 'Swap CD' menu item, in which case parameter
// 'swapping_cd' is true. Or, can be called via callback function
// gui_select_multicd_to_boot_from() inside cdriso.cpp, in which
// case swapping_cd parameter is false.
static int gui_select_multicd(bool swapping_cd)
{
	if (cdrIsoMultidiskCount <= 1)
		return 0;

	// Only max of 8 ISO images inside an Eboot multi-disk .pbp are supported
	//  by cdriso.cpp PBP code, but enforce it here to be sure:
	int num_rows = (cdrIsoMultidiskCount > 8) ? 8 : cdrIsoMultidiskCount;

	int cursor_pos = cdrIsoMultidiskSelect;
	if ((cursor_pos >= num_rows) || (cursor_pos < 0))
		cursor_pos = 0;

	for (;;) {
		video_clear();
		u32 keys = key_read();

		if ((swapping_cd) && (keys & KEY_SELECT)) {
			key_reset();
			return 0;
		}

		if (!swapping_cd)
			port_printf(MENU_X, MENU_Y, "Multi-CD image detected:");

		char tmp_string[41];
		for (int row=0; row < num_rows; ++row) {
			if (row == cursor_pos) {
				// draw cursor
				port_printf(MENU_X + 16, MENU_LS + 10 + (10 * row), "-->");
			}

			sprintf(tmp_string, "CD %d", (row+1));

			if (swapping_cd && (row == cdrIsoMultidiskSelect)) {
				// print indication of which CD is already inserted
				strcat(tmp_string, " (inserted)");
			}

			port_printf(MENU_X + (8 * 5), MENU_LS + 10 + (10 * row), tmp_string);
		}

		if (keys & KEY_DOWN) { //down
			if (++cursor_pos >= num_rows)
				cursor_pos = 0;
		} else if (keys & KEY_UP) { // up
			if (--cursor_pos < 0)
				cursor_pos = num_rows - 1;
		} else if (keys & KEY_LEFT) { //left
			cursor_pos = 0;
		} else if (keys & KEY_RIGHT) { //right
			cursor_pos = num_rows - 1;
		} else if (keys & KEY_A) { // button 1
			key_reset();
			cdrIsoMultidiskSelect = cursor_pos;
			video_clear();
			video_flip();
			// Forget last used save slot
			saveslot = -1;
			return 1;
		}

		video_flip();
		timer_delay(75);

		if (keys & (KEY_A | KEY_B | KEY_X | KEY_Y | KEY_L | KEY_R |
			    KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN))
			timer_delay(50);
	}

}
Example #9
0
char *FileReq(char *dir, const char *ext, char *result)
{
	static char *cwd = NULL;
	static s32 cursor_pos = 1;
	static s32 first_visible;
	static s32 num_items = 0;
	DIR *dirstream;
	struct dirent *direntry;
	static s32 row;
	char tmp_string[41];
	u32 keys;

	if (dir)
		ChDir(dir);

	cwd = GetCwd();

	for (;;) {
		keys = key_read();

		video_clear();

		if (keys & KEY_SELECT) {
			FREE_LIST();
			key_reset();
			return NULL;
		}

		if (num_items == 0) {
			dirstream = opendir(cwd);
			if (dirstream == NULL) {
				port_printf(0, 20, "error opening directory");
				return NULL;
			}
			// read directory entries
			while ((direntry = readdir(dirstream))) {
				s32 type = get_entry_type(cwd, direntry->d_name);

				// this is a very ugly way of only accepting a certain extension
				if ((type == 0 && strcmp(direntry->d_name, ".")) ||
				     check_ext(direntry->d_name) ||
				    (ext && (strlen(direntry->d_name) > 4 &&0 == strncasecmp(direntry->d_name + (strlen(direntry->d_name) - strlen(ext)), ext, strlen(ext))))) {
					// Hide ".." if at Unix root dir. Don't display Unix hidden files (.file).
					if ((!strcmp(direntry->d_name, "..") && strcmp(cwd, "/")) || direntry->d_name[0] != '.')
					{
						filereq_dir_items[num_items].name = (char *)malloc(strlen(direntry->d_name) + 1);
						strcpy(filereq_dir_items[num_items].name, direntry->d_name);
						filereq_dir_items[num_items].type = type;
						num_items++;
						if (num_items > 1024) break;
					}
				}
			}
			closedir(dirstream);

			sort_dir(filereq_dir_items, num_items);
			cursor_pos = 0;
			first_visible = 0;
		}

		// display current directory
		int len = strlen(cwd);

		if (len > 40) {
			strcpy(tmp_string, "..");
			strcat(tmp_string, cwd + len - 38);
			port_printf(0, MENU_Y, tmp_string);
		} else
			port_printf(0, MENU_Y, cwd);

		if (keys & KEY_DOWN) { //down
			if (++cursor_pos >= num_items) {
				cursor_pos = 0;
				first_visible = 0;
			}
			if ((cursor_pos - first_visible) >= MENU_HEIGHT) first_visible++;
		} else if (keys & KEY_UP) { // up
			if (--cursor_pos < 0) {
				cursor_pos = num_items - 1;
				first_visible = cursor_pos - MENU_HEIGHT + 1;
				if (first_visible < 0) first_visible = 0;
			}
			if (cursor_pos < first_visible) first_visible--;
		} else if (keys & KEY_LEFT) { //left
			if (cursor_pos >= 10) cursor_pos -= 10;
			else cursor_pos = 0;
			if (cursor_pos < first_visible) first_visible = cursor_pos;
		} else if (keys & KEY_RIGHT) { //right
			if (cursor_pos < (num_items - 11)) cursor_pos += 10;
			else cursor_pos = num_items - 1;
			if ((cursor_pos - first_visible) >= MENU_HEIGHT)
				first_visible = cursor_pos - (MENU_HEIGHT - 1);
		} else if (keys & KEY_A) { // button 1
			// directory selected
			if (filereq_dir_items[cursor_pos].type == 0) {
				strcat(cwd, "/");
				strcat(cwd, filereq_dir_items[cursor_pos].name);

				ChDir(cwd);
				cwd = GetCwd();

				FREE_LIST();
				key_reset();
			} else {
				sprintf(result, "%s/%s", cwd, filereq_dir_items[cursor_pos].name);
				if (dir)
					strcpy(dir, cwd);

				video_clear();
				port_printf(16 * 8, 120, "LOADING");
				video_flip();

				FREE_LIST();
				key_reset();
				return result;
			}
		} else if (keys & KEY_B) {
			cursor_pos = 0;
			first_visible = 0;
			key_reset();
		}

		// display directory contents
		row = 0;
		while (row < num_items && row < MENU_HEIGHT) {
			if (row == (cursor_pos - first_visible)) {
				// draw cursor
				port_printf(MENU_X + 16, MENU_LS + (10 * row), "-->");
			}

			if (filereq_dir_items[row + first_visible].type == 0)
				port_printf(MENU_X, MENU_LS + (10 * row), "DIR");
			int len = strlen(filereq_dir_items[row + first_visible].name);
			if (len > 32) {
				snprintf(tmp_string, 16, "%s", filereq_dir_items[row + first_visible].name);
				strcat(tmp_string, "..");
				strcat(tmp_string, &filereq_dir_items[row + first_visible].name[len - 15]);
			} else
			snprintf(tmp_string, 33, "%s", filereq_dir_items[row + first_visible].name);
			port_printf(MENU_X + (8 * 5), MENU_LS + (10 * row), tmp_string);
			row++;
		}
		while (row < MENU_HEIGHT)
			row++;

		video_flip();
		timer_delay(75);

		if (keys & (KEY_A | KEY_B | KEY_X | KEY_Y | KEY_L | KEY_R |
			    KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN))
			timer_delay(50);
	}

	return NULL;
}
Example #10
0
int main(int argc, char *argv[])
{
    SDL_Event event;

    atexit(main_exit);

    process_configfile();
    process_options(argc, argv);

    // use g_nports if specified, otherwise use the number of port arguments.
    // if neither is given, create just one port
    int nportargs = argc - optind;
    g_nports = max(1, g_nports ? : nportargs);

    // now that we know the actual number of ports, repeat the last color/scale/height value
    // as often as necessary
    if (g_colors) {
        g_colors = (Uint32*)realloc(g_colors, g_nports * sizeof(Uint32));
        for (int n = ncolors; n < g_nports; ++n) {
            g_colors[n] = g_colors[ncolors - 1];
        }
    }

    if (g_scales) {
        g_scales = (float*)realloc(g_scales, g_nports * sizeof(float));
        for (int n = nscales; n < g_nports; ++n) {
            g_scales[n] = g_scales[nscales - 1];
        }
    }

    if (g_heights) {
        g_heights = (int*)realloc(g_heights, g_nports * sizeof(int));
        for (int n = nheights; n < g_nports; ++n) {
            g_heights[n] = g_heights[nheights - 1];
        }
        // g_heights overrides g_height
        g_height = 0;
        for (int n = 0; n < g_nports; ++n) {
            g_height += g_heights[n];
        }
        g_total_height = g_height;
    }


    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        fprintf(stderr, "can't init SDL: %s\n", SDL_GetError());
        exit(EXIT_FAILURE);
    }
    atexit(SDL_Quit);

    audio_init(g_client_name, (const char * const *)&argv[optind]);

    video_init();
    SDL_WM_SetCaption(audio_get_client_name(), NULL);

    waves_init();

    g_run = true;

    while (g_run)
    {
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
                case SDL_VIDEORESIZE:
                    video_resize(event.resize.w, event.resize.h);
                    audio_adjust();
                    waves_adjust();
                    break;
                case SDL_QUIT:
                    g_run = false;
                    break;
            }
        }

        waves_draw();
        video_flip();
    }

    return 0;
}