Move to C++. Use C++14 as it adds binary literals -> HDL friendly.

This commit is contained in:
sorgelig
2018-02-28 01:58:21 +08:00
parent 52cbd96d2e
commit d235e806b2
38 changed files with 309 additions and 372 deletions

View File

@@ -3002,7 +3002,7 @@ unsigned unpack_lzh(unsigned char *src, unsigned size, unsigned char *buf)
}
//--------------------------------------------------------------------------
extern "C" int x2trd(char *name, fileTYPE *f)
int x2trd(const char *name, fileTYPE *f)
{
TDiskImage *img = new TDiskImage;
img->Open(getFullPath(name), true);
@@ -3033,7 +3033,7 @@ extern "C" int x2trd(char *name, fileTYPE *f)
return 1;
}
extern "C" int x2trd_ext_supp(char *name)
int x2trd_ext_supp(const char *name)
{
const char *ext = "";
if (strlen(name) > 4) ext = name + strlen(name) - 4;

View File

@@ -1,8 +1,9 @@
#ifndef __DISKIMAGE_H
#define __DISKIMAGE_H
//-----------------------------------------------------------------------------
#ifdef __cplusplus
#include "file_io.h"
enum TDiskImageType { DIT_UNK, DIT_SCL, DIT_FDI, DIT_TD0, DIT_UDI, DIT_HOB, DIT_FDD };
@@ -184,12 +185,8 @@ struct TRDOS_DIR_ELEMENT // 16 bytes
};
#pragma pack()
#else
int x2trd(char *name, fileTYPE *f);
int x2trd_ext_supp(char *name);
#endif
int x2trd(const char *name, fileTYPE *f);
int x2trd_ext_supp(const char *name);
//-----------------------------------------------------------------------------
#endif

View File

@@ -36,7 +36,7 @@ clean:
%.o: %.cpp
@$(info $<)
@$(CC) $(CFLAGS) -o $@ -c $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'
@$(CC) $(CFLAGS) -std=gnu++14 -o $@ -c $< 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):\([0-9]\+\):/\1(\2,\ \3):/g'
-include $(DEP)
%.d: %.c

View File

@@ -34,7 +34,7 @@ dvi_mode=0 ; set to 1 for DVI mode. Audio won't be transmitted throu
; 1,1280,48,112,248,1024,1,3,38,108
video_mode=0
; set to 1-10 to display video info on startup/change
; set to 1-10 (seconds) to display video info on startup/change
video_info=0
; set to 1 for automatic HDMI VSync rate adjust to match original VSync.

View File

@@ -39,29 +39,29 @@
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="archie.c" />
<ClCompile Include="battery.c" />
<ClCompile Include="brightness.c" />
<ClCompile Include="cfg.c" />
<ClCompile Include="archie.cpp" />
<ClCompile Include="battery.cpp" />
<ClCompile Include="brightness.cpp" />
<ClCompile Include="cfg.cpp" />
<ClCompile Include="DiskImage.cpp" />
<ClCompile Include="file_io.c" />
<ClCompile Include="fpga_io.c" />
<ClCompile Include="hardware.c" />
<ClCompile Include="ini_parser.c" />
<ClCompile Include="input.c" />
<ClCompile Include="main.c" />
<ClCompile Include="menu.c" />
<ClCompile Include="minimig_boot.c" />
<ClCompile Include="minimig_config.c" />
<ClCompile Include="minimig_fdd.c" />
<ClCompile Include="minimig_hdd.c" />
<ClCompile Include="osd.c" />
<ClCompile Include="spi.c" />
<ClCompile Include="st_ikbd.c" />
<ClCompile Include="st_tos.c" />
<ClCompile Include="tzx2wav.c" />
<ClCompile Include="user_io.c" />
<ClCompile Include="x86.c" />
<ClCompile Include="file_io.cpp" />
<ClCompile Include="fpga_io.cpp" />
<ClCompile Include="hardware.cpp" />
<ClCompile Include="ini_parser.cpp" />
<ClCompile Include="input.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="menu.cpp" />
<ClCompile Include="minimig_boot.cpp" />
<ClCompile Include="minimig_config.cpp" />
<ClCompile Include="minimig_fdd.cpp" />
<ClCompile Include="minimig_hdd.cpp" />
<ClCompile Include="osd.cpp" />
<ClCompile Include="spi.cpp" />
<ClCompile Include="st_ikbd.cpp" />
<ClCompile Include="st_tos.cpp" />
<ClCompile Include="tzx2wav.cpp" />
<ClCompile Include="user_io.cpp" />
<ClCompile Include="x86.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="archie.h" />

View File

@@ -11,73 +11,73 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="archie.c">
<ClCompile Include="archie.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="fpga_io.c">
<ClCompile Include="fpga_io.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="hardware.c">
<ClCompile Include="hardware.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ini_parser.c">
<ClCompile Include="ini_parser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="input.c">
<ClCompile Include="input.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.c">
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="menu.c">
<ClCompile Include="menu.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="osd.c">
<ClCompile Include="osd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="spi.c">
<ClCompile Include="spi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="user_io.c">
<ClCompile Include="user_io.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="file_io.c">
<ClCompile Include="file_io.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="x86.c">
<ClCompile Include="x86.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tzx2wav.c">
<ClCompile Include="tzx2wav.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DiskImage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cfg.c">
<ClCompile Include="cfg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="minimig_boot.c">
<ClCompile Include="minimig_boot.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="minimig_config.c">
<ClCompile Include="minimig_config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="minimig_fdd.c">
<ClCompile Include="minimig_fdd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="minimig_hdd.c">
<ClCompile Include="minimig_hdd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="st_ikbd.c">
<ClCompile Include="st_ikbd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="st_tos.c">
<ClCompile Include="st_tos.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="brightness.c">
<ClCompile Include="brightness.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="battery.c">
<ClCompile Include="battery.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>

View File

@@ -73,9 +73,9 @@ static unsigned char flags;
static unsigned long hold_off_timer;
#endif
static char sector_buffer[1024];
static uint8_t sector_buffer[1024];
char *archie_get_rom_name(void)
const char *archie_get_rom_name(void)
{
char *p = strrchr(config.rom_img, '/');
if (!p) p = config.rom_img; else p++;
@@ -83,7 +83,7 @@ char *archie_get_rom_name(void)
return p;
}
char *archie_get_floppy_name(char i)
const char *archie_get_floppy_name(char i)
{
if (!floppy[i].size) return "* no disk *";
@@ -229,7 +229,7 @@ static void archie_kbd_tx(unsigned char state, unsigned char byte)
spi8(byte);
DisableIO();
kbd_state = state;
kbd_state = (enum state)state;
ack_timeout = GetTimer(10); // 10ms timeout
}

View File

@@ -7,8 +7,8 @@ void archie_init(void);
void archie_poll(void);
void archie_kbd(unsigned short code);
void archie_mouse(unsigned char b, int16_t x, int16_t y);
char *archie_get_rom_name(void);
char *archie_get_floppy_name(char b);
const char *archie_get_rom_name(void);
const char *archie_get_floppy_name(char b);
void archie_set_rom(char *);
void archie_set_floppy(char i, char *);
char archie_floppy_is_inserted(char i);

View File

@@ -27,7 +27,7 @@ const ini_var_t ini_vars[] = {
{ "COMPOSITE_SYNC", (void*)(&(cfg.csync)), UINT8, 0, 1, 1 },
{ "FORCED_SCANDOUBLER", (void*)(&(cfg.forced_scandoubler)), UINT8, 0, 1, 1 },
{ "VGA_SCALER", (void*)(&(cfg.vga_scaler)), UINT8, 0, 1, 1 },
{ "KEYRAH_MODE", (void*)(&(cfg.keyrah_mode)), UINT32, 0, 0xFFFFFFFF, 1 },
{ "KEYRAH_MODE", (void*)(&(cfg.keyrah_mode)), UINT32, 0, (int)0xFFFFFFFF, 1 },
{ "RESET_COMBO", (void*)(&(cfg.reset_combo)), UINT8, 0, 3, 1 },
{ "KEY_MENU_AS_RGUI", (void*)(&(cfg.key_menu_as_rgui)), UINT8, 0, 1, 1 },
{ "VIDEO_MODE", (void*)(cfg.video_conf), STRING, 0, sizeof(cfg.video_conf)-1, 1 },

View File

@@ -233,7 +233,7 @@ int FileWriteSec(fileTYPE *file, void *pBuffer)
return FileWriteAdv(file, pBuffer, 512);
}
int FileSave(char *name, void *pBuffer, int size)
int FileSave(const char *name, void *pBuffer, int size)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
int fd = open(full_path, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, S_IRWXU | S_IRWXG | S_IRWXO);
@@ -255,14 +255,14 @@ int FileSave(char *name, void *pBuffer, int size)
return ret;
}
int FileSaveConfig(char *name, void *pBuffer, int size)
int FileSaveConfig(const char *name, void *pBuffer, int size)
{
char path[256] = { CONFIG_DIR"/" };
strcat(path, name);
return FileSave(path, pBuffer, size);
}
int FileLoad(char *name, void *pBuffer, int size)
int FileLoad(const char *name, void *pBuffer, int size)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
int fd = open(full_path, O_RDONLY);
@@ -299,14 +299,14 @@ int FileLoad(char *name, void *pBuffer, int size)
return ret;
}
int FileLoadConfig(char *name, void *pBuffer, int size)
int FileLoadConfig(const char *name, void *pBuffer, int size)
{
char path[256] = { CONFIG_DIR"/" };
strcat(path, name);
return FileLoad(path, pBuffer, size);
}
int FileCanWrite(char *name)
int FileCanWrite(const char *name)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
@@ -324,7 +324,7 @@ int FileCanWrite(char *name)
static int device = 0;
static int usbnum = 0;
char *getStorageDir(int dev)
const char *getStorageDir(int dev)
{
static char path[32];
if (!dev) return "/media/fat";
@@ -332,12 +332,12 @@ char *getStorageDir(int dev)
return path;
}
char *getRootDir()
const char *getRootDir()
{
return getStorageDir(device);
}
char *getFullPath(char *name)
const char *getFullPath(const char *name)
{
sprintf(full_path, "%s/%s", getRootDir(), name);
return full_path;
@@ -480,7 +480,7 @@ void FindStorage(void)
printf("Using SD card as a root device\n");
}
sprintf(full_path, "%s/"CONFIG_DIR, getRootDir());
sprintf(full_path, "%s/" CONFIG_DIR, getRootDir());
DIR* dir = opendir(full_path);
if (dir) closedir(dir);
else if (ENOENT == errno) mkdir(full_path, S_IRWXU | S_IRWXG | S_IRWXO);
@@ -488,8 +488,8 @@ void FindStorage(void)
int de_cmp(const void *e1, const void *e2)
{
const struct dirent *de1 = e1;
const struct dirent *de2 = e2;
const struct dirent *de1 = (struct dirent *)e1;
const struct dirent *de2 = (struct dirent *)e2;
if ((de1->d_type == DT_DIR) && !strcmp(de1->d_name, "..")) return -1;
if ((de2->d_type == DT_DIR) && !strcmp(de2->d_name, "..")) return 1;
@@ -543,10 +543,10 @@ void AdjustDirectory(char *path)
}
}
int ScanDirectory(char* path, int mode, char *extension, int options)
int ScanDirectory(const char* path, int mode, const char *extension, int options)
{
int has_trd = 0;
char *ext = extension;
const char *ext = extension;
while (*ext)
{
if (!strncasecmp(ext, "TRD", 3)) has_trd = 1;
@@ -603,7 +603,7 @@ int ScanDirectory(char* path, int mode, char *extension, int options)
if (extlen > 0)
{
int len = strlen(de->d_name);
char *ext = extension;
const char *ext = extension;
int found = (has_trd && x2trd_ext_supp(de->d_name));
while(!found && *ext)

View File

@@ -6,10 +6,6 @@
#include <fcntl.h>
#include "spi.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
int fd;
@@ -62,25 +58,21 @@ int FileReadSec(fileTYPE *file, void *pBuffer);
int FileWriteAdv(fileTYPE *file, void *pBuffer, int length);
int FileWriteSec(fileTYPE *file, void *pBuffer);
int FileCanWrite(char *name);
int FileCanWrite(const char *name);
int FileSave(char *name, void *pBuffer, int size);
int FileLoad(char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
int FileSave(const char *name, void *pBuffer, int size);
int FileLoad(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
//save/load from config dir
#define CONFIG_DIR "config"
int FileSaveConfig(char *name, void *pBuffer, int size);
int FileLoadConfig(char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
int FileSaveConfig(const char *name, void *pBuffer, int size);
int FileLoadConfig(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
void AdjustDirectory(char *path);
int ScanDirectory(char* path, int mode, char *extension, int options);
int ScanDirectory(const char* path, int mode, const char *extension, int options);
char *getStorageDir(int dev);
char *getRootDir();
char *getFullPath(char *name);
#ifdef __cplusplus
}
#endif
const char *getStorageDir(int dev);
const char *getRootDir();
const char *getFullPath(const char *name);
#endif

View File

@@ -26,10 +26,10 @@
#define fatal(x) munmap((void*)map_base, FPGA_REG_SIZE); close(fd); exit(x)
static struct socfpga_reset_manager *reset_regs = (void *)SOCFPGA_RSTMGR_ADDRESS;
static struct socfpga_fpga_manager *fpgamgr_regs = (void *)SOCFPGA_FPGAMGRREGS_ADDRESS;
static struct socfpga_system_manager *sysmgr_regs = (void *)SOCFPGA_SYSMGR_ADDRESS;
static struct nic301_registers *nic301_regs = (void *)SOCFPGA_L3REGS_ADDRESS;
static struct socfpga_reset_manager *reset_regs = (socfpga_reset_manager *)SOCFPGA_RSTMGR_ADDRESS;
static struct socfpga_fpga_manager *fpgamgr_regs = (socfpga_fpga_manager *)SOCFPGA_FPGAMGRREGS_ADDRESS;
static struct socfpga_system_manager *sysmgr_regs = (socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
static struct nic301_registers *nic301_regs = (nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
static uint32_t *map_base;
static int fd;
@@ -446,7 +446,7 @@ static int save_core_name(char *name)
}
#endif
int fpga_load_rbf(char *name)
int fpga_load_rbf(const char *name)
{
char path[512];
int ret = 0;
@@ -518,7 +518,7 @@ int fpga_io_init()
{
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) return -1;
map_base = mmap(0, FPGA_REG_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, FPGA_REG_BASE);
map_base = (uint32_t*)mmap(0, FPGA_REG_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, FPGA_REG_BASE);
if (map_base == (void *)-1)
{
printf("Unable to mmap(/dev/mem)\n");

View File

@@ -28,7 +28,7 @@ int is_fpga_ready(int quick);
int fpga_get_fio_size();
int fpga_get_io_version();
int fpga_load_rbf(char *name);
int fpga_load_rbf(const char *name);
void reboot(int cold);
void app_restart();

View File

@@ -31,7 +31,7 @@ void hexdump(void *data, uint16_t size, uint16_t offset)
{
uint8_t i, b2c;
uint16_t n = 0;
char *ptr = data;
char *ptr = (char*)data;
if (!size) return;

View File

@@ -11,7 +11,7 @@
//// type definitions ////
typedef struct {
int id;
char* name;
const char* name;
} ini_section_t;
typedef enum {
@@ -22,7 +22,7 @@ typedef enum {
typedef void custom_handler_t(char*);
typedef struct {
char* name;
const char* name;
void* var;
ini_vartypes_t type;
int min;

View File

@@ -1229,7 +1229,7 @@ static int check_devs()
return result;
}
static void INThandler()
static void INThandler(int code)
{
printf("\nExiting...\n");

View File

@@ -19,7 +19,6 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@@ -30,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "input.h"
#include "fpga_io.h"
const char version[] = { "$VER:HPS" VDATE };
const char *version = "$VER:HPS" VDATE;
int main(int argc, char *argv[])
{

View File

@@ -151,7 +151,7 @@ extern adfTYPE df[4];
extern configTYPE config;
extern const char version[];
extern const char *version;
const char *config_tos_mem[] = { "512 kB", "1 MB", "2 MB", "4 MB", "8 MB", "14 MB", "--", "--" };
const char *config_tos_wrprot[] = { "none", "A:", "B:", "A: and B:" };
const char *config_tos_usb[] = { "none", "control", "debug", "serial", "parallel", "midi" };
@@ -169,11 +169,11 @@ const char *config_cpu_msg[] = { "68000", "68010", "-----","68020" };
const char *config_hdf_msg[] = { "Disabled", "Hardfile (disk img)", "MMC/SD card", "MMC/SD partition 1", "MMC/SD partition 2", "MMC/SD partition 3", "MMC/SD partition 4" };
const char *config_chipset_msg[] = { "OCS-A500", "OCS-A1000", "ECS", "---", "---", "---", "AGA", "---" };
const char *config_turbo_msg[] = { "none", "CHIPRAM", "KICK", "BOTH" };
char *config_autofire_msg[] = { " AUTOFIRE OFF", " AUTOFIRE FAST", " AUTOFIRE MEDIUM", " AUTOFIRE SLOW" };
const char *config_autofire_msg[] = { " AUTOFIRE OFF", " AUTOFIRE FAST", " AUTOFIRE MEDIUM", " AUTOFIRE SLOW" };
const char *config_cd32pad_msg[] = { "OFF", "ON" };
char *config_button_turbo_msg[] = { "OFF", "FAST", "MEDIUM", "SLOW" };
char *config_button_turbo_choice_msg[] = { "A only", "B only", "A & B" };
char *joy_button_map[] = { "RIGHT", "LEFT", "DOWN", "UP", "BUTTON 1", "BUTTON 2", "BUTTON 3", "BUTTON 4", "KBD TOGGLE", "BUTTON OSD" };
const char *config_button_turbo_msg[] = { "OFF", "FAST", "MEDIUM", "SLOW" };
const char *config_button_turbo_choice_msg[] = { "A only", "B only", "A & B" };
const char *joy_button_map[] = { "RIGHT", "LEFT", "DOWN", "UP", "BUTTON 1", "BUTTON 2", "BUTTON 3", "BUTTON 4", "KBD TOGGLE", "BUTTON OSD" };
const char *config_stereo_msg[] = { "0%", "25%", "50%", "100%" };
char joy_bnames[12][32];
@@ -270,7 +270,7 @@ int changeDir(char *dir)
return 1;
}
static void SelectFile(char* pFileExt, unsigned char Options, unsigned char MenuSelect, unsigned char MenuCancel, char chdir)
static void SelectFile(const char* pFileExt, unsigned char Options, unsigned char MenuSelect, unsigned char MenuCancel, char chdir)
{
// this function displays file selection menu
@@ -393,7 +393,7 @@ unsigned long getStatusMask(char *opt) {
return x << idx1;
}
char* get_keycode_table()
const char* get_keycode_table()
{
switch (user_io_core_type())
{
@@ -526,7 +526,7 @@ char* getNet(int spec)
}
static long sysinfo_timer;
void infowrite(int pos, char* txt)
static void infowrite(int pos, const char* txt)
{
char str[40];
memset(str, 0x20, 29);
@@ -635,7 +635,7 @@ void HandleUI(void)
char *p;
char s[40];
unsigned char i, m, up, down, select, menu, right, left, plus, minus;
unsigned char m, up, down, select, menu, right, left, plus, minus;
uint8_t mod;
unsigned long len;
static hardfileTYPE t_hardfile[2]; // temporary copy of former hardfile configuration
@@ -958,7 +958,7 @@ void HandleUI(void)
}
// add options as requested by core
i = 2;
int i = 2;
do {
char* pos;
unsigned long status = user_io_8bit_set_status(0, 0); // 0,0 gets status
@@ -1378,59 +1378,61 @@ void HandleUI(void)
break;
case MENU_JOYDIGMAP1:
p = 0;
if (get_map_button() < 4)
{
p = joy_button_map[get_map_button()];
}
else if(joy_bcount)
{
p = (get_map_button() < joy_bcount + 4) ? joy_bnames[get_map_button() - 4] : joy_button_map[8+get_map_type()];
}
else
{
p = (get_map_button() < 8) ? joy_button_map[get_map_button()] : joy_button_map[8 + get_map_type()];
}
{
s[0] = 0;
int len = (30-(strlen(p)+7))/2;
while (len > 0)
const char* p = 0;
if (get_map_button() < 4)
{
strcat(s, " ");
len--;
p = joy_button_map[get_map_button()];
}
}
strcat(s, "Press: ");
strcat(s, p);
OsdWrite(3, s, 0, 0);
if (get_map_button())
{
if(get_map_type()) OsdWrite(OsdGetSize() - 1, " finish (SPACE - skip)", menusub == 0, 0);
else OsdWrite(OsdGetSize() - 1, "", 0, 0);
sprintf(s, " %s ID: %04x:%04x", get_map_type() ? "Joystick" : "Keyboard", get_map_vid(), get_map_pid());
OsdWrite(5, s, 0, 0);
}
if (select || menu || get_map_button() >= (joy_bcount ? joy_bcount + 5 : 9))
{
finish_map_setting(menu);
if (is_menu_core())
else if (joy_bcount)
{
menustate = MENU_FIRMWARE1;
menusub = 2;
}
else if (is_archie())
{
menustate = MENU_ARCHIE_MAIN1;
menusub = 4;
p = (get_map_button() < joy_bcount + 4) ? joy_bnames[get_map_button() - 4] : joy_button_map[8 + get_map_type()];
}
else
{
menustate = MENU_8BIT_SYSTEM1;
menusub = 1;
p = (get_map_button() < 8) ? joy_button_map[get_map_button()] : joy_button_map[8 + get_map_type()];
}
{
s[0] = 0;
int len = (30 - (strlen(p) + 7)) / 2;
while (len > 0)
{
strcat(s, " ");
len--;
}
}
strcat(s, "Press: ");
strcat(s, p);
OsdWrite(3, s, 0, 0);
if (get_map_button())
{
if (get_map_type()) OsdWrite(OsdGetSize() - 1, " finish (SPACE - skip)", menusub == 0, 0);
else OsdWrite(OsdGetSize() - 1, "", 0, 0);
sprintf(s, " %s ID: %04x:%04x", get_map_type() ? "Joystick" : "Keyboard", get_map_vid(), get_map_pid());
OsdWrite(5, s, 0, 0);
}
if (select || menu || get_map_button() >= (joy_bcount ? joy_bcount + 5 : 9))
{
finish_map_setting(menu);
if (is_menu_core())
{
menustate = MENU_FIRMWARE1;
menusub = 2;
}
else if (is_archie())
{
menustate = MENU_ARCHIE_MAIN1;
menusub = 4;
}
else
{
menustate = MENU_8BIT_SYSTEM1;
menusub = 1;
}
}
}
break;
@@ -1566,7 +1568,7 @@ void HandleUI(void)
menumask = tos_get_direct_hdd() ? 0x3f : 0x7f;
OsdSetTitle("Storage", 0);
// entries for both floppies
for (i = 0; i<2; i++) {
for (int i = 0; i<2; i++) {
strcpy(s, " A: ");
strcat(s, tos_get_disk_name(i));
s[1] = 'A' + i;
@@ -1581,7 +1583,7 @@ void HandleUI(void)
strcpy(s, " ACSI0 direct SD: ");
strcat(s, tos_get_direct_hdd() ? "on" : "off");
OsdWrite(4, s, menusub == 3, 0);
for (i = 0; i<2; i++) {
for (int i = 0; i<2; i++) {
strcpy(s, " ACSI0: ");
s[5] = '0' + i;
@@ -1940,7 +1942,7 @@ void HandleUI(void)
// We display a line for each drive that's active
// in the config file, but grey out any that the FPGA doesn't think are active.
// We also print a help text in place of the last drive if it's inactive.
for (i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
{
if (i == config.floppy.drives + 1)
OsdWrite(i+1, " KP +/- to add/remove drives", 0, 1);
@@ -2079,9 +2081,7 @@ void HandleUI(void)
}
else if (c == KEY_BACKSPACE) // eject all floppies
{
for (i = 0; i <= drives; i++)
df[i].status = 0;
for (int i = 0; i <= drives; i++) df[i].status = 0;
menustate = MENU_MAIN1;
}
else if (right)
@@ -2221,11 +2221,14 @@ void HandleUI(void)
menustate = MENU_FILE_SELECT1;
}
if ((i = GetASCIIKey(c))>1)
{
// find an entry beginning with given character
ScanDirectory(SelectedPath, i, fs_pFileExt, fs_Options);
menustate = MENU_FILE_SELECT1;
{
int i;
if ((i = GetASCIIKey(c)) > 1)
{
// find an entry beginning with given character
ScanDirectory(SelectedPath, i, fs_pFileExt, fs_Options);
menustate = MENU_FILE_SELECT1;
}
}
if (select)
@@ -3366,72 +3369,6 @@ void ScrollLongName(void)
ScrollText(iSelectedEntry-iFirstEntry, DirItem[iSelectedEntry].d_name, 2, len, max_len, 1);
}
char* GetDiskInfo(char* lfn, long len)
{
// extracts disk number substring form file name
// if file name contains "X of Y" substring where X and Y are one or two digit number
// then the number substrings are extracted and put into the temporary buffer for further processing
// comparision is case sensitive
short i, k;
static char info[] = "XX/XX"; // temporary buffer
static char template[4] = " of "; // template substring to search for
char *ptr1, *ptr2, c;
unsigned char cmp;
if (len > 20) // scan only names which can't be fully displayed
{
for (i = (unsigned short)len - 1 - sizeof(template); i > 0; i--) // scan through the file name starting from its end
{
ptr1 = &lfn[i]; // current start position
ptr2 = template;
cmp = 0;
for (k = 0; k < sizeof(template); k++) // scan through template
{
cmp |= *ptr1++ ^ *ptr2++; // compare substrings' characters one by one
if (cmp)
break; // stop further comparing if difference already found
}
if (!cmp) // match found
{
k = i - 1; // no need to check if k is valid since i is greater than zero
c = lfn[k]; // get the first character to the left of the matched template substring
if (c >= '0' && c <= '9') // check if a digit
{
info[1] = c; // copy to buffer
info[0] = ' '; // clear previous character
k--; // go to the preceding character
if (k >= 0) // check if index is valid
{
c = lfn[k];
if (c >= '0' && c <= '9') // check if a digit
info[0] = c; // copy to buffer
}
k = i + sizeof(template); // get first character to the right of the mached template substring
c = lfn[k]; // no need to check if index is valid
if (c >= '0' && c <= '9') // check if a digit
{
info[3] = c; // copy to buffer
info[4] = ' '; // clear next char
k++; // go to the followwing character
if (k < len) // check if index is valid
{
c = lfn[k];
if (c >= '0' && c <= '9') // check if a digit
info[4] = c; // copy to buffer
}
return info;
}
}
}
}
}
return NULL;
}
// print directory contents
void PrintDirectory(void)
{
@@ -3610,7 +3547,7 @@ void ErrorMessage(const char *message, unsigned char code)
OsdEnable(0); // do not disable KEYBOARD
}
void InfoMessage(char *message)
void InfoMessage(const char *message)
{
if (menustate != MENU_INFO)
{
@@ -3624,13 +3561,13 @@ void InfoMessage(char *message)
menustate = MENU_INFO;
}
void InfoMessageEx(char *message, int timeout)
void InfoMessageEx(const char *message, int timeout)
{
InfoMessage(message);
menu_timer = GetTimer(timeout);
}
void InfoEx(char *message, int width, int height, int timeout)
void InfoEx(const char *message, int width, int height, int timeout)
{
if (!user_io_osd_is_visible())
{
@@ -3642,7 +3579,7 @@ void InfoEx(char *message, int width, int height, int timeout)
}
}
void Info(char *message, int width, int height)
void Info(const char *message, int width, int height)
{
InfoEx(message, width, height, 2000);
}

8
menu.h
View File

@@ -18,10 +18,10 @@ void HandleUI(void);
void PrintDirectory(void);
void ScrollLongName(void);
void ErrorMessage(const char *message, unsigned char code);
void InfoMessage(char *message);
void InfoMessageEx(char *message, int timeout);
void InfoEx(char *message, int width, int height, int timeout);
void Info(char *message, int width, int height);
void InfoMessage(const char *message);
void InfoMessageEx(const char *message, int timeout);
void InfoEx(const char *message, int width, int height, int timeout);
void Info(const char *message, int width, int height);
void ShowSplash();
void HideSplash();

View File

@@ -179,7 +179,7 @@ void BootUploadLogo()
int i = 0;
int adr;
if (FileOpen(&file, "Amiga/"LOGO_FILE) || FileOpen(&file, LOGO_FILE)) {
if (FileOpen(&file, "Amiga/" LOGO_FILE) || FileOpen(&file, LOGO_FILE)) {
FileReadSec(&file, buffer);
mem_upload_init(SCREEN_BPL1 + LOGO_OFFSET);
adr = SCREEN_BPL1 + LOGO_OFFSET;
@@ -240,7 +240,7 @@ void BootUploadBall()
int i = 0;
int adr;
if (FileOpen(&file, "Amiga/"BALL_FILE) || FileOpen(&file, BALL_FILE))
if (FileOpen(&file, "Amiga/" BALL_FILE) || FileOpen(&file, BALL_FILE))
{
FileReadSec(&file, buffer);
mem_upload_init(BALL_ADDRESS);
@@ -272,7 +272,7 @@ void BootUploadCopper()
int i = 0;
int adr;
if (FileOpen(&file, "Amiga/"COPPER_FILE) || FileOpen(&file, COPPER_FILE))
if (FileOpen(&file, "Amiga/" COPPER_FILE) || FileOpen(&file, COPPER_FILE))
{
FileReadSec(&file, buffer);
mem_upload_init(COPPER_ADDRESS);
@@ -467,7 +467,7 @@ void BootInit()
//// BootPrint() ////
void BootPrintEx(char * str)
void BootPrintEx(const char * str)
{
unsigned char i, j;
unsigned char len;

View File

@@ -36,7 +36,7 @@
//// functions ////
void BootInit();
void BootPrintEx(char * str);
void BootPrintEx(const char * str);
void BootHome();
#define BootPrint(text) printf("%s\n", text)

View File

@@ -141,7 +141,7 @@ static void rotatechar(unsigned char *in, unsigned char *out)
#define OSDHEIGHT (osd_size*8)
void OsdSetTitle(char *s, int a)
void OsdSetTitle(const char *s, int a)
{
// Compose the title, condensing character gaps
arrow = a;
@@ -198,13 +198,13 @@ void OsdSetTitle(char *s, int a)
}
}
void OsdWrite(unsigned char n, char *s, unsigned char invert, unsigned char stipple)
void OsdWrite(unsigned char n, const char *s, unsigned char invert, unsigned char stipple)
{
OsdWriteOffset(n, s, invert, stipple, 0, 0);
}
// write a null-terminated string <s> to the OSD buffer starting at line <n>
void OsdWriteOffset(unsigned char n, char *s, unsigned char invert, unsigned char stipple, char offset, char leftchar)
void OsdWriteOffset(unsigned char n, const char *s, unsigned char invert, unsigned char stipple, char offset, char leftchar)
{
//printf("OsdWriteOffset(%d)\n", n);
unsigned short i;
@@ -392,7 +392,7 @@ void OsdDrawLogo(unsigned char n, char row, char superimpose)
}
// write a null-terminated string <s> to the OSD buffer starting at line <n>
void OSD_PrintText(unsigned char line, char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert)
void OSD_PrintText(unsigned char line, const char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert)
{
// line : OSD line number (0-7)
// text : pointer to null-terminated string
@@ -461,7 +461,7 @@ void OSD_PrintText(unsigned char line, char *text, unsigned long start, unsigned
#define INFO_MAXW 32
#define INFO_MAXH 16
void OSD_PrintInfo(char *message, int width, int height, int frame)
void OSD_PrintInfo(const char *message, int width, int height, int frame)
{
static char str[INFO_MAXW * INFO_MAXH];

10
osd.h
View File

@@ -66,9 +66,9 @@
#include <inttypes.h>
/*functions*/
void OsdSetTitle(char *s, int arrow); // arrow > 0 = display right arrow in bottom right, < 0 = display left arrow
void OsdWrite(unsigned char n, char *s, unsigned char inver, unsigned char stipple);
void OsdWriteOffset(unsigned char n, char *s, unsigned char inver, unsigned char stipple, char offset, char leftchar); // Used for scrolling "Exit" text downwards...
void OsdSetTitle(const char *s, int arrow); // arrow > 0 = display right arrow in bottom right, < 0 = display left arrow
void OsdWrite(unsigned char n, const char *s, unsigned char inver, unsigned char stipple);
void OsdWriteOffset(unsigned char n, const char *s, unsigned char inver, unsigned char stipple, char offset, char leftchar); // Used for scrolling "Exit" text downwards...
void OsdClear(void);
void OsdEnable(unsigned char mode);
void InfoEnable(int x, int y, int width, int height);
@@ -81,8 +81,8 @@ void ConfigCPU(unsigned char cpu);
void ConfigChipset(unsigned char chipset);
void ConfigFloppy(unsigned char drives, unsigned char speed);
void ConfigAutofire(unsigned char autofire, unsigned char mask);
void OSD_PrintText(unsigned char line, char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert);
void OSD_PrintInfo(char *message, int width, int height, int frame);
void OSD_PrintText(unsigned char line, const char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert);
void OSD_PrintInfo(const char *message, int width, int height, int frame);
void OsdDrawLogo(unsigned char n, char row, char superimpose);
void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert);
void ScrollReset();

View File

@@ -281,7 +281,7 @@ void spi_read(uint8_t *addr, uint16_t len, int wide)
}
}
void spi_write(uint8_t *addr, uint16_t len, int wide)
void spi_write(const uint8_t *addr, uint16_t len, int wide)
{
if (wide)
{
@@ -301,12 +301,12 @@ void spi_block_read(uint8_t *addr, int wide)
spi_read(addr, 512, wide);
}
void spi_block_write(uint8_t *addr, int wide)
void spi_block_write(const uint8_t *addr, int wide)
{
spi_write(addr, 512, wide);
}
void spi_block_write_16be(uint16_t *addr)
void spi_block_write_16be(const uint16_t *addr)
{
uint16_t len = 256;
uint16_t tmp;

6
spi.h
View File

@@ -34,9 +34,9 @@ uint32_t spi32w(uint32_t parm);
/* block transfer functions */
void spi_block_read(uint8_t *addr, int wide);
void spi_read(uint8_t *addr, uint16_t len, int wide);
void spi_block_write(uint8_t *addr, int wide);
void spi_write(uint8_t *addr, uint16_t len, int wide);
void spi_block_write_16be(uint16_t *addr);
void spi_block_write(const uint8_t *addr, int wide);
void spi_write(const uint8_t *addr, uint16_t len, int wide);
void spi_block_write_16be(const uint16_t *addr);
void spi_block_read_16be(uint16_t *addr);
/* OSD related SPI functions */

View File

@@ -314,11 +314,14 @@ void ikbd_handler_reset(void) {
}
// ---- list of supported ikbd commands ----
struct {
struct ikbd_command_handler_t {
unsigned char code;
unsigned char length;
void(*handler)(void);
} ikbd_command_handler[] = {
};
ikbd_command_handler_t ikbd_command_handler[] =
{
{ 0x07, 2, ikbd_handler_mouse_button_action },
{ 0x08, 1, ikbd_handler_set_relative_mouse_pos },
{ 0x09, 5, ikbd_handler_set_abs_mouse_pos },

View File

@@ -118,7 +118,7 @@ static void mist_memory_read(char *data, unsigned long words) {
DisableFpga();
}
static void mist_memory_write(char *data, unsigned long words) {
static void mist_memory_write(unsigned char *data, unsigned long words) {
EnableFpga();
spi8(MIST_WRITE_MEMORY);
@@ -130,7 +130,7 @@ static void mist_memory_write(char *data, unsigned long words) {
DisableFpga();
}
static void mist_memory_read_block(char *data) {
static void mist_memory_read_block(unsigned char *data) {
EnableFpga();
spi8(MIST_READ_MEMORY);
@@ -139,7 +139,7 @@ static void mist_memory_read_block(char *data) {
DisableFpga();
}
static void mist_memory_write_block(char *data) {
static void mist_memory_write_block(unsigned char *data) {
EnableFpga();
spi8(MIST_WRITE_MEMORY);
@@ -533,7 +533,7 @@ static void mist_get_dmastate() {
#define COLORS 20
#define PLANES 4
static void tos_write(char *str);
static void tos_write(const char *str);
static void tos_color_test() {
unsigned short buffer[COLORS][PLANES];
@@ -546,7 +546,7 @@ static void tos_color_test() {
for (i = 0; i<16; i++) {
mist_memory_set_address(VIDEO_BASE_ADDRESS + (16 * y + i) * 160, 1, 0);
mist_memory_write((char*)buffer, COLORS*PLANES);
mist_memory_write((unsigned char*)buffer, COLORS*PLANES);
}
}
@@ -570,7 +570,7 @@ static void tos_color_test() {
#endif
}
static void tos_write(char *str) {
static void tos_write(const char *str) {
static int y = 0;
int l;
@@ -584,12 +584,13 @@ static void tos_write(char *str) {
// as dma works in 16 bytes chunks only
int c = (strlen(str) + 15) & ~15;
{
char *buffer = malloc(c);
unsigned char *buffer = (unsigned char*)malloc(c);
// 16 pixel lines
for (l = 0; l<16; l++)
{
char *p = str, *f = buffer;
const char *p = str;
unsigned char *f = buffer;
while (*p) *f++ = font[16 * *p++ + l];
while (f < buffer + c) *f++ = font[16 * ' ' + l];
@@ -645,7 +646,7 @@ static void tos_font_load() {
}
}
void tos_load_cartridge(char *name)
void tos_load_cartridge(const char *name)
{
fileTYPE file = { 0 };
@@ -655,7 +656,7 @@ void tos_load_cartridge(char *name)
// upload cartridge
if (config.cart_img[0] && FileOpen(&file, config.cart_img)) {
int i;
char buffer[512];
unsigned char buffer[512];
tos_debugf("%s:\n size = %d", config.cart_img, file.size);
@@ -694,7 +695,7 @@ char tos_cartridge_is_inserted() {
return config.cart_img[0];
}
void tos_upload(char *name)
void tos_upload(const char *name)
{
fileTYPE file = { 0 };
@@ -722,7 +723,7 @@ void tos_upload(char *name)
// upload and verify tos image
if (FileOpen(&file, config.tos_img)) {
int i;
char buffer[512];
unsigned char buffer[512];
unsigned long time;
unsigned long tos_base = TOS_BASE_ADDRESS_192k;
@@ -989,7 +990,7 @@ char tos_disk_is_inserted(char index) {
return hdd_image[index - 2].size != 0;
}
void tos_select_hdd_image(char i, char *name)
void tos_select_hdd_image(char i, const char *name)
{
tos_debugf("Select ACSI%c image %s", '0' + i, name);
@@ -1014,7 +1015,7 @@ void tos_select_hdd_image(char i, char *name)
mist_set_control(config.system_ctrl);
}
void tos_insert_disk(char i, char *name)
void tos_insert_disk(char i, const char *name)
{
if (i > 1)
{

View File

@@ -82,21 +82,21 @@
unsigned long tos_system_ctrl(void);
void tos_upload(char *);
void tos_upload(const char *);
void tos_poll();
void tos_update_sysctrl(unsigned long);
char *tos_get_disk_name(char);
char tos_disk_is_inserted(char index);
void tos_insert_disk(char i, char *name);
void tos_insert_disk(char i, const char *name);
void tos_eject_all();
void tos_select_hdd_image(char i, char *name);
void tos_select_hdd_image(char i, const char *name);
void tos_set_direct_hdd(char on);
char tos_get_direct_hdd();
void tos_reset(char cold);
char *tos_get_image_name();
char *tos_get_cartridge_name();
char tos_cartridge_is_inserted();
void tos_load_cartridge(char *);
void tos_load_cartridge(const char *);
void tos_set_video_adjust(char axis, char value);
char tos_get_video_adjust(char axis);

View File

@@ -139,9 +139,9 @@ static char tstr4[255];
static char spdstr[255];
static char pstr[255];
static void core_write(void *buf, int size)
static void core_write(const void *buf, int size)
{
char *addr = (char*)buf;
const char *addr = (const char*)buf;
while (size--)
{
spi8(*addr++);

View File

@@ -5,6 +5,7 @@
#include <stdbool.h>
#include <fcntl.h>
#include <time.h>
#include <limits.h>
#include "hardware.h"
#include "osd.h"
@@ -36,7 +37,7 @@ unsigned long vol_set_timeout = 0;
fileTYPE sd_image[4] = { 0 };
// mouse and keyboard emulation state
static emu_mode_t emu_mode = EMU_NONE;
static int emu_mode = EMU_NONE;
// keep state over core type and its capabilities
static unsigned char core_type = CORE_TYPE_UNKNOWN;
@@ -112,7 +113,7 @@ char *user_io_get_core_name()
return core_name;
}
char *user_io_get_core_name_ex()
const char *user_io_get_core_name_ex()
{
switch (user_io_core_type())
{
@@ -968,67 +969,10 @@ void user_io_rtc_reset()
rtc_timer = 0;
}
static int api1_5 = 0;
int hasAPI1_5()
{
return api1_5;
}
static int coldreset_req = 0;
static uint32_t vitems[32];
double Fpix = 0;
int adjust_video_mode(uint32_t vtime);
uint32_t show_video_info(int force)
{
static uint8_t nres = 0;
spi_uio_cmd_cont(UIO_GET_VRES);
uint8_t res = spi_in();
if ((nres != res) || force)
{
nres = res;
uint32_t width = spi_w(0) | (spi_w(0) << 16);
uint32_t height = spi_w(0) | (spi_w(0) << 16);
uint32_t htime = spi_w(0) | (spi_w(0) << 16);
uint32_t vtime = spi_w(0) | (spi_w(0) << 16);
uint32_t ptime = spi_w(0) | (spi_w(0) << 16);
uint32_t vtimeh = spi_w(0) | (spi_w(0) << 16);
DisableIO();
float vrate = 100000000;
if (vtime) vrate /= vtime; else vrate = 0;
float hrate = 100000;
if (htime) hrate /= htime; else hrate = 0;
float prate = width * 100;
prate /= ptime;
printf("\033[1;33mINFO: Video resolution: %u x %u, fHorz = %.1fKHz, fVert = %.1fHz, fPix = %.2fMHz\033[0m\n", width, height, hrate, vrate, prate);
printf("\033[1;33mINFO: Frame time (100MHz counter): VGA = %d, HDMI = %d\033[0m\n", vtime, vtimeh);
if (vtimeh) api1_5 = 1;
if (hasAPI1_5() && cfg.video_info)
{
static char str[128];
float vrateh = 100000000;
if (vtimeh) vrateh /= vtimeh; else vrateh = 0;
sprintf(str, "\n %4dx%-4d %6.2fKHz %4.1fHz" \
"\n \x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81" \
"\n %4dx%-4d %6.2fMHz %4.1fHz",
width, height, hrate, vrate, vitems[1], vitems[5], Fpix, vrateh);
InfoEx(str, 28, 5, cfg.video_info*1000);
}
if (vtime && vtimeh) return vtime;
}
else
{
DisableIO();
}
return 0;
}
static int adjust_video_mode(uint32_t vtime);
static uint32_t show_video_info(int force);
void user_io_poll()
{
@@ -1187,8 +1131,8 @@ void user_io_poll()
}
else
{
static char buffer[4][512];
static uint64_t buffer_lba[4] = { -1,-1,-1,-1 };
static uint8_t buffer[4][512];
static uint64_t buffer_lba[4] = { ULLONG_MAX,ULLONG_MAX,ULLONG_MAX,ULLONG_MAX };
uint32_t lba;
uint16_t c = user_io_sd_get_status(&lba);
//if(c&3) printf("user_io_sd_get_status: cmd=%02x, lba=%08x\n", c, lba);
@@ -2020,16 +1964,18 @@ unsigned char user_io_ext_idx(char *name, char* ext)
return 0;
}
emu_mode_t user_io_get_kbdemu()
int user_io_get_kbdemu()
{
return emu_mode;
}
struct
struct vmode_t
{
uint32_t vpar[8];
double Fpix;
} vmodes[] =
};
vmode_t vmodes[] =
{
{ { 1280, 110, 40, 220, 720, 5, 5, 20 }, 74.25 },
{ { 1024, 24, 136, 160, 768, 3, 6, 29 }, 65 },
@@ -2044,6 +1990,9 @@ struct
};
#define VMODES_NUM (sizeof(vmodes) / sizeof(vmodes[0]))
static uint32_t vitems[32];
double Fpix = 0;
static uint32_t getPLLdiv(uint32_t div)
{
if (div & 1) return 0x20000 | (((div / 2) + 1) << 8) | (div / 2);
@@ -2208,7 +2157,7 @@ void parse_video_mode()
setVideo();
}
int adjust_video_mode(uint32_t vtime)
static int adjust_video_mode(uint32_t vtime)
{
printf("Adjust VSync.\n");
@@ -2224,3 +2173,59 @@ int adjust_video_mode(uint32_t vtime)
setVideo();
user_io_send_buttons(1);
}
static int api1_5 = 0;
static uint32_t show_video_info(int force)
{
static uint8_t nres = 0;
spi_uio_cmd_cont(UIO_GET_VRES);
uint8_t res = spi_in();
if ((nres != res) || force)
{
nres = res;
uint32_t width = spi_w(0) | (spi_w(0) << 16);
uint32_t height = spi_w(0) | (spi_w(0) << 16);
uint32_t htime = spi_w(0) | (spi_w(0) << 16);
uint32_t vtime = spi_w(0) | (spi_w(0) << 16);
uint32_t ptime = spi_w(0) | (spi_w(0) << 16);
uint32_t vtimeh = spi_w(0) | (spi_w(0) << 16);
DisableIO();
float vrate = 100000000;
if (vtime) vrate /= vtime; else vrate = 0;
float hrate = 100000;
if (htime) hrate /= htime; else hrate = 0;
float prate = width * 100;
prate /= ptime;
printf("\033[1;33mINFO: Video resolution: %u x %u, fHorz = %.1fKHz, fVert = %.1fHz, fPix = %.2fMHz\033[0m\n", width, height, hrate, vrate, prate);
printf("\033[1;33mINFO: Frame time (100MHz counter): VGA = %d, HDMI = %d\033[0m\n", vtime, vtimeh);
if (vtimeh) api1_5 = 1;
if (hasAPI1_5() && cfg.video_info)
{
static char str[128];
float vrateh = 100000000;
if (vtimeh) vrateh /= vtimeh; else vrateh = 0;
sprintf(str, "\n %4dx%-4d %6.2fKHz %4.1fHz" \
"\n \x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81\x81" \
"\n %4dx%-4d %6.2fMHz %4.1fHz",
width, height, hrate, vrate, vitems[1], vitems[5], Fpix, vrateh);
InfoEx(str, 30, 5, cfg.video_info * 1000);
}
if (vtime && vtimeh) return vtime;
}
else
{
DisableIO();
}
return 0;
}
int hasAPI1_5()
{
return api1_5;
}

View File

@@ -83,9 +83,6 @@
#define JOY_BTN4 0x80
#define JOY_MOVE (JOY_RIGHT|JOY_LEFT|JOY_UP|JOY_DOWN)
#define BUTTON1 0x01
#define BUTTON2 0x02
// virtual gamepad buttons
#define JOY_A JOY_BTN1
#define JOY_B JOY_BTN2
@@ -113,12 +110,15 @@
#define KBD_LED_FLAG_MASK 0xC0
#define KBD_LED_FLAG_STATUS 0x40
#define CONF_VGA_SCALER 0x04
#define CONF_CSYNC 0x08
#define CONF_FORCED_SCANDOUBLER 0x10
#define CONF_YPBPR 0x20
#define CONF_AUDIO_96K 0x40
#define CONF_DVI 0x80
#define BUTTON1 0b00000001
#define BUTTON2 0b00000010
#define CONF_VGA_SCALER 0b00000100
#define CONF_CSYNC 0b00001000
#define CONF_FORCED_SCANDOUBLER 0b00010000
#define CONF_YPBPR 0b00100000
#define CONF_AUDIO_96K 0b01000000
#define CONF_DVI 0b10000000
#define CONF_RES_MASK 0x700
#define CONF_RES_SHIFT 8
@@ -146,7 +146,10 @@
#define UIO_PRIORITY_KEYBOARD 0
#define UIO_PRIORITY_GAMEPAD 1
typedef enum { EMU_NONE, EMU_MOUSE, EMU_JOY0, EMU_JOY1 } emu_mode_t;
#define EMU_NONE 0
#define EMU_MOUSE 1
#define EMU_JOY0 2
#define EMU_JOY1 3
// serial status data type returned from the core
typedef struct {
@@ -176,12 +179,12 @@ char user_io_dip_switch1(void);
char user_io_serial_status(serial_status_t *, uint8_t);
int user_io_file_mount(int num, char *name);
char *user_io_get_core_name();
char *user_io_get_core_name_ex();
const char *user_io_get_core_name_ex();
char is_menu_core();
char is_x86_core();
char has_menu();
emu_mode_t user_io_get_kbdemu();
int user_io_get_kbdemu();
// io controllers interface for FPGA ethernet emulation using usb ethernet
// devices attached to the io controller (ethernec emulation)

View File

@@ -109,7 +109,7 @@ static void dma_rcvbuf(uint32_t address, uint32_t length, uint32_t *data)
DisableFpga();
}
static int load_bios(char* name, uint8_t index)
static int load_bios(const char* name, uint8_t index)
{
fileTYPE f = { 0 };
static uint32_t buf[128];
@@ -563,7 +563,7 @@ void x86_init()
0x00, //0x03: ALARM MIN BCD
bin2bcd(tm.tm_hour), //0x04: HOUR BCD 24h
0x12, //0x05: ALARM HOUR BCD 24h
tm.tm_wday+1, //0x06: DAY OF WEEK Sunday=1
(uint32_t)tm.tm_wday+1, //0x06: DAY OF WEEK Sunday=1
bin2bcd(tm.tm_mday), //0x07: DAY OF MONTH BCD from 1
bin2bcd(tm.tm_mon+1), //0x08: MONTH BCD from 1
bin2bcd((tm.tm_year<117) ? 17 : tm.tm_year-100), //0x09: YEAR BCD
@@ -574,7 +574,7 @@ void x86_init()
0x00, //0x0E: REG E - POST status
0x00, //0x0F: REG F - shutdown status
CMOS_FDD_TYPE, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M
(uint32_t)CMOS_FDD_TYPE, //0x10: floppy drive type; 0-none, 1-360K, 2-1.2M, 3-720K, 4-1.44M, 5-2.88M
0x00, //0x11: configuration bits; not used
0x00, //0x12: hard disk types; 0-none, 1:E-type, F-type 16+ (unused)
0x00, //0x13: advanced configuration bits; not used