<commit_before>#include <stdio.h>
#include <stdint.h>
#ifndef _MSC_VER
#include <stdbool.h>
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <math.h>
#include <ctype.h>

#include "libretro.h"
#include "libretro_params.h"

#include "compiler.h"//required to prevent missing type errors
#include "beep.h"
#include "pccore.h"
#include "iocore.h"
#include "keystat.h"
#include "fddfile.h"
#include "newdisk.h"
#include "diskdrv.h"
#include "fontmng.h"
#include "kbdmng.h"
#include "ini.h"
#include "scrnmng.h"
#include "soundmng.h"
#include "sysmng.h"
#include "joymng.h"
#include "mousemng.h"
#include "font.h"
#include "kbtrans.h"
#include "vramhdl.h"
#include "menubase.h"
#include "palettes.h"
#include "sysmenu.h"
#include "scrndraw.h"
#include "milstr.h"
#include "strres.h"
#include "np2.h"
#include "fmboard.h"
#include "dosio.h"
#include "gdc.h"
#if defined(SUPPORT_FMGEN)
#include "fmgen_fmgwrap.h"
#endif	/* defined(SUPPORT_FMGEN) */
#if defined(SUPPORT_WAB)
#include "wab.h"
#include "cirrus_vga_extern.h"
#endif	/* defined(SUPPORT_WAB) */

extern void sdlaudio_callback(void *userdata, unsigned char *stream, int len);

signed short soundbuf[SNDSZ*2]; //16bit*2ch

char RPATH[512];
char tmppath[4096];

static retro_log_printf_t log_cb = NULL;
static retro_video_refresh_t video_cb = NULL;
static retro_input_poll_t poll_cb = NULL;
retro_input_state_t input_cb = NULL;
retro_environment_t environ_cb = NULL;

uint32_t   FrameBuffer[LR_SCREENWIDTH * LR_SCREENHEIGHT];
uint32_t   GuiBuffer[LR_SCREENWIDTH * LR_SCREENHEIGHT]; //menu surf
extern SCRNSURF	scrnsurf;

retro_audio_sample_batch_t audio_batch_cb = NULL;

static char CMDFILE[512];

bool did_reset, joy2key_arr, joy2key_kpad;
int lr_init = 0;

static char base_dir[MAX_PATH];

#ifdef _WIN32
static char slash = '\\';
#else
static char slash = '/';
#endif

static void update_variables(void);

/* media swap support */
struct retro_disk_control_callback dskcb;
static char disk_paths[50][MAX_PATH] = {0};
static unsigned drvno = 1;
static unsigned disk_index = 0;
static unsigned disk_images = 0;
static bool disk_inserted = false;

//all the fake functions used to limit swapping to 1 disk drive
bool setdskeject(bool ejected){
   disk_inserted = !ejected;
   return true;
}

bool getdskeject(){
   return !disk_inserted;
}

unsigned getdskindex(){
   return disk_index;
}

bool setdskindex(unsigned index){
   disk_index = index;
   if(disk_index == disk_images)
   {
      //retroarch is trying to set "no disk in tray"
      return true;
   }

   update_variables();
   strcpy(np2cfg.fddfile[drvno], disk_paths[disk_index]);
   diskdrv_setfdd(drvno, disk_paths[disk_index], 0);
   return true;
}

unsigned getnumimages(){
   return disk_images;
}

bool addimageindex() {
   if (disk_images >= 50)
      return false;

   disk_images++;
   return true;
}

bool replacedsk(unsigned index,const struct retro_game_info *info){
   strcpy(disk_paths[index], info->path);
   return true;
}

void attach_disk_swap_interface(){
   //these functions are unused
   dskcb.set_eject_state = setdskeject;
   dskcb.get_eject_state = getdskeject;
   dskcb.set_image_index = setdskindex;
   dskcb.get_image_index = getdskindex;
   dskcb.get_num_images  = getnumimages;
   dskcb.add_image_index = addimageindex;
   dskcb.replace_image_index = replacedsk;

   environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE,&dskcb);
}
/* end media swap support */

int loadcmdfile(char *argv)
{
   int res=0;

   FILE *fp = fopen(argv,"r");

   if( fp != NULL )
   {
      if ( fgets (CMDFILE , 512 , fp) != NULL )
         res=1;
      fclose (fp);
   }<commit_msg>Add pre/next floppy image insert func<commit_after>#include <stdio.h>
#include <stdint.h>
#ifndef _MSC_VER
#include <stdbool.h>
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <math.h>
#include <ctype.h>

#include "libretro.h"
#include "libretro_params.h"

#include "compiler.h"//required to prevent missing type errors
#include "beep.h"
#include "pccore.h"
#include "iocore.h"
#include "keystat.h"
#include "fddfile.h"
#include "newdisk.h"
#include "diskdrv.h"
#include "fontmng.h"
#include "kbdmng.h"
#include "ini.h"
#include "scrnmng.h"
#include "soundmng.h"
#include "sysmng.h"
#include "joymng.h"
#include "mousemng.h"
#include "font.h"
#include "kbtrans.h"
#include "vramhdl.h"
#include "menubase.h"
#include "palettes.h"
#include "sysmenu.h"
#include "scrndraw.h"
#include "milstr.h"
#include "strres.h"
#include "np2.h"
#include "fmboard.h"
#include "dosio.h"
#include "gdc.h"
#if defined(SUPPORT_FMGEN)
#include "fmgen_fmgwrap.h"
#endif	/* defined(SUPPORT_FMGEN) */
#if defined(SUPPORT_WAB)
#include "wab.h"
#include "cirrus_vga_extern.h"
#endif	/* defined(SUPPORT_WAB) */

extern void sdlaudio_callback(void *userdata, unsigned char *stream, int len);

signed short soundbuf[SNDSZ*2]; //16bit*2ch

char RPATH[512];
char tmppath[4096];

static retro_log_printf_t log_cb = NULL;
static retro_video_refresh_t video_cb = NULL;
static retro_input_poll_t poll_cb = NULL;
retro_input_state_t input_cb = NULL;
retro_environment_t environ_cb = NULL;

uint32_t   FrameBuffer[LR_SCREENWIDTH * LR_SCREENHEIGHT];
uint32_t   GuiBuffer[LR_SCREENWIDTH * LR_SCREENHEIGHT]; //menu surf
extern SCRNSURF	scrnsurf;

retro_audio_sample_batch_t audio_batch_cb = NULL;

static char CMDFILE[512];

bool did_reset, joy2key_arr, joy2key_kpad;
int lr_init = 0;

static char base_dir[MAX_PATH];

#ifdef _WIN32
static char slash = '\\';
#else
static char slash = '/';
#endif

static void update_variables(void);

/* media swap support */
struct retro_disk_control_callback dskcb;
static char disk_paths[50][MAX_PATH] = {0};
static unsigned drvno = 1;
static unsigned disk_index = 0;
static unsigned disk_images = 0;
static bool disk_inserted = false;
static unsigned int lastidx = 0;

//all the fake functions used to limit swapping to 1 disk drive
bool setdskeject(bool ejected){
   disk_inserted = !ejected;
   return true;
}

bool getdskeject(){
   return !disk_inserted;
}

unsigned getdskindex(){
   return disk_index;
}

bool setdskindex(unsigned index){
   disk_index = index;
   if(disk_index == disk_images)
   {
      //retroarch is trying to set "no disk in tray"
      return true;
   }

   update_variables();
   strcpy(np2cfg.fddfile[drvno], disk_paths[disk_index]);
   diskdrv_setfdd(drvno, disk_paths[disk_index], 0);
   return true;
}

unsigned getnumimages(){
   return disk_images;
}

bool addimageindex() {
   if (disk_images >= 50)
      return false;

   disk_images++;
   return true;
}

bool replacedsk(unsigned index,const struct retro_game_info *info){
   strcpy(disk_paths[index], info->path);
   return true;
}

void attach_disk_swap_interface(){
   //these functions are unused
   dskcb.set_eject_state = setdskeject;
   dskcb.get_eject_state = getdskeject;
   dskcb.set_image_index = setdskindex;
   dskcb.get_image_index = getdskindex;
   dskcb.get_num_images  = getnumimages;
   dskcb.add_image_index = addimageindex;
   dskcb.replace_image_index = replacedsk;

   environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE,&dskcb);
}

void setnxtdskindex(void){
	if(disk_images > 2) {
		if(disk_index + 1 != disk_images) {
			setdskindex(disk_index + 1);
		} else {
			setdskindex(0);
		}
	}
}

void setpredskindex(void){
	if(disk_images > 2) {
		if(disk_index == 0) {
			setdskindex(disk_images - 1);
		} else {
			setdskindex(disk_index - 1);
		}
	}
}
/* end media swap support */

int loadcmdfile(char *argv)
{
   int res=0;

   FILE *fp = fopen(argv,"r");

   if( fp != NULL )
   {
      if ( fgets (CMDFILE , 512 , fp) != NULL )
         res=1;
      fclose (fp);
   }
{'fraction_non_alphanumeric': 0.12540192926045016, 'fraction_numerical': 0.011446945337620579, 'mean_word_length': 4.7302873986735445, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, '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': '779884', 'n_tokens_mistral': 3119, 'n_tokens_neox': 3016, 'n_words': 690}