<commit_before>//
// cen64.c: CEN64 entry point.
//
// CEN64: Cycle-Accurate Nintendo 64 Simulator.
// Copyright (C) 2014, <NAME>.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//

#include "common.h"
#include "device.h"
#include "os/rom_file.h"
#include <setjmp.h>

static int load_roms(const char *pifrom_path, const char *cart_path,
  struct rom_file *pifrom, struct rom_file *cart);

static int setup_and_run_device(struct cen64_device *device,
  const char *pifrom_path, const char *cart_path);

// Called when a simulation instance is terminating.
void cen64_cleanup(struct cen64_device *device) {
  destroy_gl_window(&device->vi.gl_window);
  device_destroy(device);
}

// Called when another simulation instance is desired.
int cen64_main(struct cen64_device *device, int argc, const char *argv[]) {
  struct gl_window_hints hints;
  int status;

  // Prevent debugging tools from raising warnings
  // about uninitialized memory being read, etc.
  memset(device, 0, sizeof(*device));
  get_default_gl_window_hints(&hints);

  if (argc < 3) {
    printf("%s <pifrom.bin> <rom>\n", argv[0]);
    return 255;
  }

  if (create_gl_window(&device->vi.gl_window, &hints)) {
    printf("Failed to create a window.\n");
    return 1;
  }

  // Start simulation.
  if (!(status = setup_and_run_device(device, argv[1], argv[2]))) {
    destroy_gl_window(&device->vi.gl_window);
    return 2;
  }

  return status;
}

// Called to temporary (or permanently) leave simulation.
// After calling this function, we return to device_run.
void cen64_return(struct bus_controller *bus) {
  longjmp(bus->unwind_data, 1);
}

// Load any ROM images required for simulation.
int load_roms(const char *pifrom_path, const char *cart_path,
  struct rom_file *pifrom, struct rom_file *cart) {
  if (open_rom_file(pifrom_path, pifrom)) {<commit_msg>Fix bug that produced false-positive error codes.<commit_after>//
// cen64.c: CEN64 entry point.
//
// CEN64: Cycle-Accurate Nintendo 64 Simulator.
// Copyright (C) 2014, <NAME>.
//
// This file is subject to the terms and conditions defined in
// 'LICENSE', which is part of this source code package.
//

#include "common.h"
#include "device.h"
#include "os/rom_file.h"
#include <setjmp.h>

static int load_roms(const char *pifrom_path, const char *cart_path,
  struct rom_file *pifrom, struct rom_file *cart);

static int setup_and_run_device(struct cen64_device *device,
  const char *pifrom_path, const char *cart_path);

// Called when a simulation instance is terminating.
void cen64_cleanup(struct cen64_device *device) {
  destroy_gl_window(&device->vi.gl_window);
  device_destroy(device);
}

// Called when another simulation instance is desired.
int cen64_main(struct cen64_device *device, int argc, const char *argv[]) {
  struct gl_window_hints hints;
  int status;

  // Prevent debugging tools from raising warnings
  // about uninitialized memory being read, etc.
  memset(device, 0, sizeof(*device));
  get_default_gl_window_hints(&hints);

  if (argc < 3) {
    printf("%s <pifrom.bin> <rom>\n", argv[0]);
    return 255;
  }

  if (create_gl_window(&device->vi.gl_window, &hints)) {
    printf("Failed to create a window.\n");
    return 1;
  }

  // Start simulation.
  if ((status = setup_and_run_device(device, argv[1], argv[2])))
    destroy_gl_window(&device->vi.gl_window);

  return status;
}

// Called to temporary (or permanently) leave simulation.
// After calling this function, we return to device_run.
void cen64_return(struct bus_controller *bus) {
  longjmp(bus->unwind_data, 1);
}

// Load any ROM images required for simulation.
int load_roms(const char *pifrom_path, const char *cart_path,
  struct rom_file *pifrom, struct rom_file *cart) {
  if (open_rom_file(pifrom_path, pifrom)) {
{'fraction_non_alphanumeric': 0.12007308796658836, 'fraction_numerical': 0.018010963194988253, 'mean_word_length': 4.270976616231087, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6823203', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1281, 'n_words': 388}