Ported the cassette emulation from PCE, closes #835.

This commit is contained in:
OBattler
2021-07-27 06:12:09 +02:00
parent f79b11cd9a
commit 827065c0bc
19 changed files with 1274 additions and 75 deletions

View File

@@ -0,0 +1,173 @@
/*****************************************************************************
* pce *
*****************************************************************************/
/*****************************************************************************
* File name: src/ibmpc/cassette.h *
* Created: 2008-11-25 by Hampa Hug <hampa@hampa.ch> *
* Copyright: (C) 2008-2019 Hampa Hug <hampa@hampa.ch> *
*****************************************************************************/
/*****************************************************************************
* This program is free software. You can redistribute it and / or modify it *
* under the terms of the GNU General Public License version 2 as published *
* by the Free Software Foundation. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY, without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
* Public License for more details. *
*****************************************************************************/
#ifndef PCE_IBMPC_CASSETTE_H
#define PCE_IBMPC_CASSETTE_H 1
#include <stdio.h>
typedef struct {
char save;
char pcm;
unsigned char motor;
unsigned long position;
unsigned long position_save;
unsigned long position_load;
unsigned char data_out;
unsigned char data_inp;
int pcm_out_vol;
int pcm_out_val;
unsigned cas_out_cnt;
unsigned char cas_out_buf;
unsigned cas_inp_cnt;
unsigned char cas_inp_buf;
unsigned char cas_inp_bit;
int pcm_inp_fir[3];
unsigned long clk;
unsigned long clk_pcm;
unsigned long clk_out;
unsigned long clk_inp;
unsigned long srate;
char close;
char *fname;
FILE *fp;
pc_timer_t timer;
} pc_cassette_t;
void pc_cas_init (pc_cassette_t *cas);
void pc_cas_free (pc_cassette_t *cas);
pc_cassette_t *pc_cas_new (void);
void pc_cas_del (pc_cassette_t *cas);
/*!***************************************************************************
* @short Set the cassette file
* @return True on error, false otherwise
*****************************************************************************/
int pc_cas_set_fname (pc_cassette_t *cas, const char *fname);
/*!***************************************************************************
* @short Get the cassette mode
* @return True if in save mode, false if in load mode
*****************************************************************************/
int pc_cas_get_mode (const pc_cassette_t *cas);
/*!***************************************************************************
* @short Set the cassette mode
* @param save If true set save mode, otherwise set load mode
*****************************************************************************/
void pc_cas_set_mode (pc_cassette_t *cas, int save);
/*!***************************************************************************
* @short Get the cassette pcm mode
* @return True if in pcm mode, false if in binary mode
*****************************************************************************/
int pc_cas_get_pcm (const pc_cassette_t *cas);
/*!***************************************************************************
* @short Set the cassette pcm mode
* @param pcm If true set pcm mode, otherwise set binary mode
*****************************************************************************/
void pc_cas_set_pcm (pc_cassette_t *cas, int pcm);
/*!***************************************************************************
* @short Get the pcm sample rate
* @return The sample rate in Hz
*****************************************************************************/
unsigned long pc_cas_get_srate (const pc_cassette_t *cas);
/*!***************************************************************************
* @short Set the pcm sample rate
* @param pcm The sample rate in Hz
*****************************************************************************/
void pc_cas_set_srate (pc_cassette_t *cas, unsigned long srate);
/*!***************************************************************************
* @short Rewind the cassette
*****************************************************************************/
void pc_cas_rewind (pc_cassette_t *cas);
/*!***************************************************************************
* @short Fast forward to the end of the cassette
*****************************************************************************/
void pc_cas_append (pc_cassette_t *cas);
/*!***************************************************************************
* @short Get the current load/save position
*****************************************************************************/
unsigned long pc_cas_get_position (const pc_cassette_t *cas);
/*!***************************************************************************
* @short Set the current load/save position
*****************************************************************************/
int pc_cas_set_position (pc_cassette_t *cas, unsigned long pos);
/*!***************************************************************************
* @short Set the cassette motor status
*****************************************************************************/
void pc_cas_set_motor (pc_cassette_t *cas, unsigned char val);
/*!***************************************************************************
* @short Get the current input from the cassette
*****************************************************************************/
unsigned char pc_cas_get_inp (const pc_cassette_t *cas);
/*!***************************************************************************
* @short Set the current output to the cassette
*****************************************************************************/
void pc_cas_set_out (pc_cassette_t *cas, unsigned char val);
void pc_cas_print_state (const pc_cassette_t *cas);
void pc_cas_clock (pc_cassette_t *cas, unsigned long cnt);
void pc_cas_advance (pc_cassette_t *cas);
extern pc_cassette_t * cassette;
extern char cassette_fname[512];
extern char * cassette_mode;
extern unsigned long cassette_pos, cassette_srate;
extern int cassette_enable;
extern int cassette_append, cassette_pcm;
extern int cassette_ui_writeprot;
extern const device_t cassette_device;
#endif

View File

@@ -121,6 +121,8 @@
#define IDS_2145 2145 // "You are loading an unsupported..."
#define IDS_2146 2146 // "CPU type filtering based on..."
#define IDS_2147 2147 // "Continue"
#define IDS_2148 2148 // "Continue"
#define IDS_2149 2149 // "Continue"
#define IDS_4096 4096 // "Hard disk (%s)"
#define IDS_4097 4097 // "%01i:%01i"
@@ -229,7 +231,7 @@
#define IDS_LANG_ENUS IDS_7168
#define STR_NUM_2048 100
#define STR_NUM_2048 102
#define STR_NUM_3072 11
#define STR_NUM_4096 40
#define STR_NUM_4352 6

View File

@@ -131,6 +131,8 @@ extern void plat_power_off(void);
/* Platform-specific device support. */
extern void cassette_mount(char *fn, uint8_t wp);
extern void cassette_eject(void);
extern void floppy_mount(uint8_t id, char *fn, uint8_t wp);
extern void floppy_eject(uint8_t id);
extern void cdrom_mount(uint8_t id, char *fn);

View File

@@ -195,6 +195,7 @@
#define IDC_CONFIGURE_SCSI_2 1093
#define IDC_CONFIGURE_SCSI_3 1094
#define IDC_CONFIGURE_SCSI_4 1095
#define IDC_CHECK_CASSETTE 1096
#define IDC_HARD_DISKS 1100 /* hard disks config */
#define IDC_LIST_HARD_DISKS 1101
@@ -379,29 +380,36 @@
* and 5 bits for Removable Disks (5 bits for ID), so we use an
* 8bit (256 entries) space for these devices.
*/
#define IDM_FLOPPY_IMAGE_NEW 0x1200
#define IDM_FLOPPY_IMAGE_EXISTING 0x1300
#define IDM_FLOPPY_IMAGE_EXISTING_WP 0x1400
#define IDM_FLOPPY_EXPORT_TO_86F 0x1500
#define IDM_FLOPPY_EJECT 0x1600
#define IDM_CASSETTE_IMAGE_NEW 0x1200
#define IDM_CASSETTE_IMAGE_EXISTING 0x1300
#define IDM_CASSETTE_IMAGE_EXISTING_WP 0x1400
#define IDM_CASSETTE_REWIND 0x1500
#define IDM_CASSETTE_FAST_FORWARD 0x1600
#define IDM_CASSETTE_EJECT 0x1700
#define IDM_CDROM_MUTE 0x2200
#define IDM_CDROM_EMPTY 0x2300
#define IDM_CDROM_RELOAD 0x2400
#define IDM_CDROM_IMAGE 0x2500
#define IDM_CDROM_HOST_DRIVE 0x2600
#define IDM_FLOPPY_IMAGE_NEW 0x2200
#define IDM_FLOPPY_IMAGE_EXISTING 0x2300
#define IDM_FLOPPY_IMAGE_EXISTING_WP 0x2400
#define IDM_FLOPPY_EXPORT_TO_86F 0x2500
#define IDM_FLOPPY_EJECT 0x2600
#define IDM_ZIP_IMAGE_NEW 0x3200
#define IDM_ZIP_IMAGE_EXISTING 0x3300
#define IDM_ZIP_IMAGE_EXISTING_WP 0x3400
#define IDM_ZIP_EJECT 0x3500
#define IDM_ZIP_RELOAD 0x3600
#define IDM_CDROM_MUTE 0x3200
#define IDM_CDROM_EMPTY 0x3300
#define IDM_CDROM_RELOAD 0x3400
#define IDM_CDROM_IMAGE 0x3500
#define IDM_CDROM_HOST_DRIVE 0x3600
#define IDM_MO_IMAGE_NEW 0x4200
#define IDM_MO_IMAGE_EXISTING 0x4300
#define IDM_MO_IMAGE_EXISTING_WP 0x4400
#define IDM_MO_EJECT 0x4500
#define IDM_MO_RELOAD 0x4600
#define IDM_ZIP_IMAGE_NEW 0x4200
#define IDM_ZIP_IMAGE_EXISTING 0x4300
#define IDM_ZIP_IMAGE_EXISTING_WP 0x4400
#define IDM_ZIP_EJECT 0x4500
#define IDM_ZIP_RELOAD 0x4600
#define IDM_MO_IMAGE_NEW 0x5200
#define IDM_MO_IMAGE_EXISTING 0x5300
#define IDM_MO_IMAGE_EXISTING_WP 0x5400
#define IDM_MO_EJECT 0x5500
#define IDM_MO_RELOAD 0x5600
/* Next default values for new objects */

View File

@@ -50,14 +50,15 @@ extern void ui_check_menu_item(int id, int checked);
/* Status Bar functions. */
#define SB_ICON_WIDTH 24
#define SB_FLOPPY 0x00
#define SB_CDROM 0x10
#define SB_ZIP 0x20
#define SB_MO 0x30
#define SB_HDD 0x40
#define SB_NETWORK 0x50
#define SB_SOUND 0x60
#define SB_TEXT 0x70
#define SB_CASSETTE 0x00
#define SB_FLOPPY 0x10
#define SB_CDROM 0x20
#define SB_ZIP 0x30
#define SB_MO 0x40
#define SB_HDD 0x50
#define SB_NETWORK 0x60
#define SB_SOUND 0x70
#define SB_TEXT 0x80
extern wchar_t *ui_window_title(wchar_t *s);
extern void ui_status_update(void);

View File

@@ -58,6 +58,7 @@ DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
#define SDL_CLASS_NAME L"86BoxSDLWnd"
#define SDL_SUB_CLASS_NAME L"86BoxSDLSubWnd"
#define CASSETTE_SUBMENU_NAME L"CassetteSubmenu"
#define FLOPPY_SUBMENU_NAME L"FloppySubmenu"
#define CDROM_SUBMENU_NAME L"CdromSubmenu"
#define ZIP_SUBMENU_NAME L"ZIPSubmenu"
@@ -220,10 +221,12 @@ extern wchar_t *BrowseFolder(wchar_t *saved_path, wchar_t *title);
extern void media_menu_init();
extern void media_menu_reset();
extern int media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
extern HMENU media_menu_get_cassette(void);
extern HMENU media_menu_get_floppy(int id);
extern HMENU media_menu_get_cdrom(int id);
extern HMENU media_menu_get_zip(int id);
extern HMENU media_menu_get_mo(int id);
extern void media_menu_update_cassette(void);
extern void media_menu_update_floppy(int id);
extern void media_menu_update_cdrom(int id);
extern void media_menu_update_zip(int id);