Normalize line endings, remove trailing spaces.

This commit is contained in:
sorgelig
2019-06-29 00:57:18 +08:00
parent 5d7d82392e
commit f056480a07
36 changed files with 2247 additions and 2247 deletions

View File

@@ -2084,7 +2084,7 @@ void TDiskImage::readSCL(int hfile, bool readonly)
for (i = 0; i < FileCount; i++) for (i = 0; i < FileCount; i++)
{ {
if (TRK >= (MaxTrack + 1)*(MaxSide + 1)) break; // disk full ? if (TRK >= (MaxTrack + 1)*(MaxSide + 1)) break; // disk full ?
memcpy(&trdosde, fileinfo[i], 14); memcpy(&trdosde, fileinfo[i], 14);
trdosde.FirstSec = SEC; trdosde.FirstSec = SEC;

View File

@@ -70,10 +70,10 @@ public:
bool FindTrack(unsigned char CYL, unsigned char SIDE, VGFIND_TRACK *vgft); bool FindTrack(unsigned char CYL, unsigned char SIDE, VGFIND_TRACK *vgft);
bool FindADMark(unsigned char CYL, unsigned char SIDE, bool FindADMark(unsigned char CYL, unsigned char SIDE,
unsigned int FromOffset, unsigned int FromOffset,
VGFIND_ADM *vgfa); VGFIND_ADM *vgfa);
bool FindSector(unsigned char CYL, unsigned char SIDE, bool FindSector(unsigned char CYL, unsigned char SIDE,
unsigned char SECT, unsigned char SECT,
VGFIND_SECTOR *vgfs, unsigned int FromOffset=0); VGFIND_SECTOR *vgfs, unsigned int FromOffset=0);
void ApplySectorCRC(VGFIND_SECTOR vgfs); void ApplySectorCRC(VGFIND_SECTOR vgfs);
@@ -123,7 +123,7 @@ struct TD0_MAIN_HEADER // 12 bytes
struct TD0_INFO_DATA // 10 ¡ ©â ¡¥§ áâப¨ ª®¬¥­â à¨ï... struct TD0_INFO_DATA // 10 ¡ ©â ¡¥§ áâப¨ ª®¬¥­â à¨ï...
{ {
unsigned short CRC; // +0: CRC ¤«ï áâàãªâãàë COMMENT_DATA (¡¥§ ¡ ©â®¢ CRC) unsigned short CRC; // +0: CRC ¤«ï áâàãªâãàë COMMENT_DATA (¡¥§ ¡ ©â®¢ CRC)
unsigned short strLen; // +2: „«¨­  áâப¨ ª®¬¥­â à¨ï unsigned short strLen; // +2: „«¨­  áâப¨ ª®¬¥­â à¨ï
unsigned char Year; // +4: „ â  á®§¤ ­¨ï - £®¤ (1900 + X) unsigned char Year; // +4: „ â  á®§¤ ­¨ï - £®¤ (1900 + X)
unsigned char Month; // +5: „ â  á®§¤ ­¨ï - ¬¥áïæ (Ÿ­¢ àì=0, ”¥¢à «ì=1,...) unsigned char Month; // +5: „ â  á®§¤ ­¨ï - ¬¥áïæ (Ÿ­¢ àì=0, ”¥¢à «ì=1,...)
unsigned char Day; // +6: „ â  á®§¤ ­¨ï - ç¨á«® unsigned char Day; // +6: „ â  á®§¤ ­¨ï - ç¨á«®
@@ -146,7 +146,7 @@ struct TD0_SECT_HEADER // 8 bytes
unsigned short DataLength; unsigned short DataLength;
}; };
struct FDD_MAIN_HEADER struct FDD_MAIN_HEADER
{ {
char ID[30]; /* ᨣ­ âãà  */ char ID[30]; /* ᨣ­ âãà  */
unsigned char MaxTracks; /* ç¨á«® â४®¢ (樫¨­¤à®¢) */ unsigned char MaxTracks; /* ç¨á«® â४®¢ (樫¨­¤à®¢) */

View File

@@ -3,25 +3,25 @@
* battery.c * battery.c
* display pi-top battery status * display pi-top battery status
* *
* Copyright 2016, 2017 rricharz * Copyright 2016, 2017 rricharz
* MiSTer port. Copyright 2018 Sorgelig * MiSTer port. Copyright 2018 Sorgelig
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA. * MA 02110-1301, USA.
* *
* *
*/ */
#include <time.h> #include <time.h>
@@ -33,7 +33,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/types.h> #include <linux/types.h>
#include "battery.h" #include "battery.h"
#define MAX_COUNT 20 // Maximum number of trials #define MAX_COUNT 20 // Maximum number of trials
@@ -52,7 +52,7 @@
#define I2C_SMBUS_QUICK 0 #define I2C_SMBUS_QUICK 0
#define I2C_SMBUS_BYTE 1 #define I2C_SMBUS_BYTE 1
#define I2C_SMBUS_BYTE_DATA 2 #define I2C_SMBUS_BYTE_DATA 2
#define I2C_SMBUS_WORD_DATA 3 #define I2C_SMBUS_WORD_DATA 3
#define I2C_SMBUS_PROC_CALL 4 #define I2C_SMBUS_PROC_CALL 4
#define I2C_SMBUS_BLOCK_DATA 5 #define I2C_SMBUS_BLOCK_DATA 5
@@ -62,7 +62,7 @@
// SMBus messages // SMBus messages
#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ #define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */ #define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
// Structures used in the ioctl() calls // Structures used in the ioctl() calls
@@ -82,7 +82,7 @@ struct i2c_smbus_ioctl_data
uint8_t command; uint8_t command;
int size; int size;
union i2c_smbus_data *data; union i2c_smbus_data *data;
}; };
static int i2c_smbus_access (int fd, char rw, uint8_t command, int size, union i2c_smbus_data *data) static int i2c_smbus_access (int fd, char rw, uint8_t command, int size, union i2c_smbus_data *data)
{ {
@@ -93,7 +93,7 @@ static int i2c_smbus_access (int fd, char rw, uint8_t command, int size, union i
args.size = size; args.size = size;
args.data = data; args.data = data;
return ioctl (fd, I2C_SMBUS, &args); return ioctl (fd, I2C_SMBUS, &args);
} }
static int i2c_smbus_write_quick(int fd, uint8_t value) static int i2c_smbus_write_quick(int fd, uint8_t value)
{ {
@@ -129,7 +129,7 @@ static int smbus_open(int dev_address)
close(fd); close(fd);
return 0; return 0;
} }
i2c_handle = fd; i2c_handle = fd;
} }
return 1; return 1;
@@ -161,7 +161,7 @@ static int getReg(int reg, int min, int max)
{ {
if (smbus_get(reg, &value)) if (smbus_get(reg, &value))
{ {
if ((value > max) || (value < min)) value = -1; // out of limits if ((value > max) || (value < min)) value = -1; // out of limits
} }
usleep(SLEEP_TIME); usleep(SLEEP_TIME);
} }

View File

@@ -96,7 +96,7 @@ char* loadLastcore()
sprintf(full_path, "%s/%s", getRootDir(), path); sprintf(full_path, "%s/%s", getRootDir(), path);
FILE *fd = fopen(full_path, "r"); FILE *fd = fopen(full_path, "r");
if (!fd) if (!fd)
{ {
return NULL; return NULL;
} }
fseek(fd, 0L, SEEK_END); fseek(fd, 0L, SEEK_END);
@@ -113,7 +113,7 @@ char* loadLastcore()
} }
delete[] lastcore; delete[] lastcore;
return NULL; return NULL;
} }
char *findCore(const char *name, char *coreName, int indent) char *findCore(const char *name, char *coreName, int indent)
@@ -149,7 +149,7 @@ char *findCore(const char *name, char *coreName, int indent)
spl = strrchr(path, '.'); spl = strrchr(path, '.');
if (spl && !strcmp(spl, ".rbf")) if (spl && !strcmp(spl, ".rbf"))
{ {
closedir(dir); closedir(dir);
return path; return path;
} }
} }
@@ -161,7 +161,7 @@ char *findCore(const char *name, char *coreName, int indent)
} }
void bootcore_init(const char *path) void bootcore_init(const char *path)
{ {
char *auxpointer; char *auxpointer;
char auxstr[256]; char auxstr[256];
char bootcore[256]; char bootcore[256];
@@ -170,9 +170,9 @@ void bootcore_init(const char *path)
cfg.bootcore_timeout = cfg.bootcore_timeout * 10; cfg.bootcore_timeout = cfg.bootcore_timeout * 10;
btimeout = cfg.bootcore_timeout; btimeout = cfg.bootcore_timeout;
strcpy(bootcore, cfg.bootcore); strcpy(bootcore, cfg.bootcore);
is_lastcore = (!strcmp(cfg.bootcore, "lastcore") || !strcmp(cfg.bootcore, "lastexactcore")); is_lastcore = (!strcmp(cfg.bootcore, "lastcore") || !strcmp(cfg.bootcore, "lastexactcore"));
if (is_lastcore) if (is_lastcore)
{ {
strcpy(bootcoretype, cfg.bootcore); strcpy(bootcoretype, cfg.bootcore);
@@ -187,7 +187,7 @@ void bootcore_init(const char *path)
{ {
strcpy(bootcoretype, isExactcoreName(cfg.bootcore) ? "exactcorename" : "corename"); strcpy(bootcoretype, isExactcoreName(cfg.bootcore) ? "exactcorename" : "corename");
} }
auxpointer = findCore(rootdir, bootcore, 0); auxpointer = findCore(rootdir, bootcore, 0);
if (auxpointer != NULL) if (auxpointer != NULL)
{ {
@@ -207,7 +207,7 @@ void bootcore_init(const char *path)
{ {
fpga_load_rbf(bootcore); fpga_load_rbf(bootcore);
} }
strcpy(cfg.bootcore, strcmp(bootcore, "menu.rbf") ? bootcore : ""); strcpy(cfg.bootcore, strcmp(bootcore, "menu.rbf") ? bootcore : "");
return; return;
} }
@@ -216,7 +216,7 @@ void bootcore_init(const char *path)
if (is_lastcore && path[0] != '\0') if (is_lastcore && path[0] != '\0')
{ {
strcpy(auxstr, path); strcpy(auxstr, path);
auxpointer = !strcmp(cfg.bootcore, "lastexactcore") ? getcoreExactName(auxstr) : getcoreName(auxstr); auxpointer = !strcmp(cfg.bootcore, "lastexactcore") ? getcoreExactName(auxstr) : getcoreName(auxstr);
@@ -229,6 +229,6 @@ void bootcore_init(const char *path)
} }
} }
strcpy(cfg.bootcore, ""); strcpy(cfg.bootcore, "");
} }

View File

@@ -1,6 +1,6 @@
/* /*
* brightness.c * brightness.c
* *
* Copyright 2016 rricharz * Copyright 2016 rricharz
* MiSTer port. Copyright 2018 Sorgelig * MiSTer port. Copyright 2018 Sorgelig
* *
@@ -8,18 +8,18 @@
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA. * MA 02110-1301, USA.
* *
* *
*/ */
#include <stdint.h> #include <stdint.h>
@@ -101,7 +101,7 @@ static int spi_open(int speed, int mode)
{ {
printf ("SPI Mode Change failure: %s\n", strerror (errno)); printf ("SPI Mode Change failure: %s\n", strerror (errno));
} }
close(fd); close(fd);
fd = -1; fd = -1;
return -1; return -1;
@@ -145,9 +145,9 @@ static int analyze(unsigned char data)
parity = (data & PARITYMASK) != 0; parity = (data & PARITYMASK) != 0;
brightness = (data & BRIGHTNESSMASK) >> 3; brightness = (data & BRIGHTNESSMASK) >> 3;
shutdown = (data & SHUTDOWNMASK) != 0; shutdown = (data & SHUTDOWNMASK) != 0;
// printf("lid = %d, screen = %d, parity = %d, shutdown = %d, brightness = %d\n", lidbit, screenoffbit, parity, shutdown, brightness); // printf("lid = %d, screen = %d, parity = %d, shutdown = %d, brightness = %d\n", lidbit, screenoffbit, parity, shutdown, brightness);
return (parity7(data) == parity); return (parity7(data) == parity);
} }
@@ -162,20 +162,20 @@ static int calculate()
if (shutdown) data += SHUTDOWNMASK; if (shutdown) data += SHUTDOWNMASK;
if (screenoffbit) data += SCREENOFFMASK; if (screenoffbit) data += SCREENOFFMASK;
if (parity7(data & 3)) data += LIDBITMASK; // parity ofthe two state bits if (parity7(data & 3)) data += LIDBITMASK; // parity ofthe two state bits
return data; return data;
} }
void setBrightness(int cmd, int val) void setBrightness(int cmd, int val)
{ {
unsigned char data, new_data; unsigned char data, new_data;
int count, ok; int count, ok;
if (spi_open(9600, 0) < 0) if (spi_open(9600, 0) < 0)
{ {
printf("Cannot initialize spi driver\n"); printf("Cannot initialize spi driver\n");
return; return;
} }
// send 0xFF and receive current status of pi-top-hub // send 0xFF and receive current status of pi-top-hub
count = 0; count = 0;
data = 0xff; data = 0xff;
@@ -188,7 +188,7 @@ void setBrightness(int cmd, int val)
} }
while ((!ok) && (count++ < MAXCOUNT)); while ((!ok) && (count++ < MAXCOUNT));
// printf("count = %d\n", count); // printf("count = %d\n", count);
if (ok) if (ok)
{ {
printf("Brighntess receiving: 0x%X - ", data); printf("Brighntess receiving: 0x%X - ", data);
@@ -196,7 +196,7 @@ void setBrightness(int cmd, int val)
//force to 0 as set to 1 if rebooted while in screenbitoff=0 //force to 0 as set to 1 if rebooted while in screenbitoff=0
//the state is stored on pi-top-hub, but isn't reinitialised on reboot //the state is stored on pi-top-hub, but isn't reinitialised on reboot
screenoffbit=0; screenoffbit=0;
if(cmd == BRIGHTNESS_UP) if(cmd == BRIGHTNESS_UP)
{ {
brightness++; brightness++;
} }
@@ -216,11 +216,11 @@ void setBrightness(int cmd, int val)
printf("Requested brightness = %d, ", brightness); printf("Requested brightness = %d, ", brightness);
printf("Requested off = %d\n", screenoffbit); printf("Requested off = %d\n", screenoffbit);
// calculate data to send // calculate data to send
shutdown = 0; shutdown = 0;
new_data = calculate(); new_data = calculate();
// send new data until accepted // send new data until accepted
count = 0; count = 0;
data = new_data; data = new_data;

View File

@@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>

View File

@@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>
#include <vector> #include <vector>
@@ -247,7 +247,7 @@ void cheats_scroll_name()
name[1] = cheats[iSelectedEntry].enabled ? 0x1a : 0x1b; name[1] = cheats[iSelectedEntry].enabled ? 0x1a : 0x1b;
name[2] = 32; name[2] = 32;
strcpy(name + 3, cheats[iSelectedEntry].name); strcpy(name + 3, cheats[iSelectedEntry].name);
len = strlen(name); // get name length len = strlen(name); // get name length
if (len > 3 && !strncasecmp(name + len - 3, ".gg", 3)) len -= 3; if (len > 3 && !strncasecmp(name + len - 3, ".gg", 3)) len -= 3;

View File

@@ -1038,7 +1038,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons
de = &_de; de = &_de;
} }
else else
// Handle (possible) symbolic link type in the directory entry // Handle (possible) symbolic link type in the directory entry
if (de->d_type == DT_LNK || de->d_type == DT_REG) if (de->d_type == DT_LNK || de->d_type == DT_REG)
{ {
sprintf(full_path+path_len, "/%s", de->d_name); sprintf(full_path+path_len, "/%s", de->d_name);

View File

@@ -135,7 +135,7 @@ static int fpgamgr_test_fpga_ready(void)
} }
/* /*
// Poll until FPGA is ready to be accessed or timeout occurred // Poll until FPGA is ready to be accessed or timeout occurred
static int fpgamgr_poll_fpga_ready(void) static int fpgamgr_poll_fpga_ready(void)
{ {
unsigned long i; unsigned long i;

1498
input.cpp

File diff suppressed because it is too large Load Diff

View File

@@ -57,6 +57,6 @@ void input_lightgun_cal(uint16_t *cal);
void input_switch(int grab); void input_switch(int grab);
int input_state(); int input_state();
void input_uinp_destroy(); void input_uinp_destroy();
#endif #endif

View File

@@ -116,7 +116,7 @@
#include "miniz_tdef.h" #include "miniz_tdef.h"
#include "miniz_tinfl.h" #include "miniz_tinfl.h"
/* Defines to completely disable specific portions of miniz.c: /* Defines to completely disable specific portions of miniz.c:
If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. */ If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. */
/* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */ /* Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O. */
@@ -139,7 +139,7 @@
/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. */ /* Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib. */
/*#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES */ /*#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES */
/* Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc. /* Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc.
Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc
callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user
functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */ functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work. */

View File

@@ -3210,8 +3210,8 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
if (!pState->m_zip64) if (!pState->m_zip64)
{ {
/* Bail early if the archive would obviously become too large */ /* Bail early if the archive would obviously become too large */
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size
+ MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + user_extra_data_len + + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + user_extra_data_len +
pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + user_extra_data_central_len pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + user_extra_data_central_len
+ MZ_ZIP_DATA_DESCRIPTER_SIZE32) > 0xFFFFFFFF) + MZ_ZIP_DATA_DESCRIPTER_SIZE32) > 0xFFFFFFFF)
{ {
@@ -3469,7 +3469,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
if (!pState->m_zip64) if (!pState->m_zip64)
{ {
/* Bail early if the archive would obviously become too large */ /* Bail early if the archive would obviously become too large */
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE
+ archive_name_size + comment_size + user_extra_data_len + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 1024 + archive_name_size + comment_size + user_extra_data_len + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 1024
+ MZ_ZIP_DATA_DESCRIPTER_SIZE32 + user_extra_data_central_len) > 0xFFFFFFFF) + MZ_ZIP_DATA_DESCRIPTER_SIZE32 + user_extra_data_central_len) > 0xFFFFFFFF)
{ {

View File

@@ -64,7 +64,7 @@ int main(int argc, char *argv[])
exit(0); exit(0);
} }
FindStorage(); FindStorage();
user_io_init((argc > 1) ? argv[1] : ""); user_io_init((argc > 1) ? argv[1] : "");
scheduler_init(); scheduler_init();

View File

@@ -594,7 +594,7 @@ static char* getNet(int spec)
strcpy(host, "IP: "); strcpy(host, "IP: ");
getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host + strlen(host), NI_MAXHOST - strlen(host), NULL, 0, NI_NUMERICHOST); getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host + strlen(host), NI_MAXHOST - strlen(host), NULL, 0, NI_NUMERICHOST);
} }
freeifaddrs(ifaddr); freeifaddrs(ifaddr);
return spec ? (ifa ? host : 0) : (char*)netType; return spec ? (ifa ? host : 0) : (char*)netType;
} }
@@ -728,7 +728,7 @@ const char* get_rbf_name_bootcore(char *str)
if (!strlen(cfg.bootcore)) return ""; if (!strlen(cfg.bootcore)) return "";
char *p = strrchr(str, '/'); char *p = strrchr(str, '/');
if (!p) return str; if (!p) return str;
char *spl = strrchr(p + 1, '.'); char *spl = strrchr(p + 1, '.');
if (spl && !strcmp(spl, ".rbf")) if (spl && !strcmp(spl, ".rbf"))
{ {
@@ -933,7 +933,7 @@ void HandleUI(void)
// Within the menu the esc key acts as the menu key. problem: // Within the menu the esc key acts as the menu key. problem:
// if the menu is left with a press of ESC, then the follwing // if the menu is left with a press of ESC, then the follwing
// break code for the ESC key when the key is released will // break code for the ESC key when the key is released will
// reach the core which never saw the make code. Simple solution: // reach the core which never saw the make code. Simple solution:
// react on break code instead of make code // react on break code instead of make code
case KEY_ESC | UPSTROKE: case KEY_ESC | UPSTROKE:
@@ -1463,7 +1463,7 @@ void HandleUI(void)
{ {
p = user_io_8bit_get_string(i++); p = user_io_8bit_get_string(i++);
if (!p) continue; if (!p) continue;
h = 0; h = 0;
d = 0; d = 0;
@@ -1714,11 +1714,11 @@ void HandleUI(void)
menusub = ((mode != 3 && mode != 4) || !stat("/dev/midi", &filestat)) ? 0 : 2; menusub = ((mode != 3 && mode != 4) || !stat("/dev/midi", &filestat)) ? 0 : 2;
} }
break; break;
case 5: case 5:
video_set_scaler_flt(video_get_scaler_flt() ? 0 : 1); video_set_scaler_flt(video_get_scaler_flt() ? 0 : 1);
menustate = MENU_8BIT_SYSTEM1; menustate = MENU_8BIT_SYSTEM1;
break; break;
case 6: case 6:
if (video_get_scaler_flt()) if (video_get_scaler_flt())
@@ -1842,7 +1842,7 @@ void HandleUI(void)
OsdWrite(3, s, menusub == 1, m); OsdWrite(3, s, menusub == 1, m);
sprintf(s, " Type: %s", (midilink & 2) ? ((midilink & 1) ? " UDP" : " TCP") : ((midilink & 1) ? " MUNT" : "FluidSynth")); sprintf(s, " Type: %s", (midilink & 2) ? ((midilink & 1) ? " UDP" : " TCP") : ((midilink & 1) ? " MUNT" : "FluidSynth"));
OsdWrite(4, s, menusub == 2, m); OsdWrite(4, s, menusub == 2, m);
OsdWrite(5); OsdWrite(5);
OsdWrite(6, " Reset UART connection", menusub == 3, mode?0:1); OsdWrite(6, " Reset UART connection", menusub == 3, mode?0:1);
OsdWrite(7); OsdWrite(7);
@@ -1889,8 +1889,8 @@ void HandleUI(void)
menustate = MENU_UART1; menustate = MENU_UART1;
} }
break; break;
case 3: case 3:
{ {
int mode = GetUARTMode(); int mode = GetUARTMode();
if(mode != 0) if(mode != 0)
{ {
@@ -2448,7 +2448,7 @@ void HandleUI(void)
break; break;
case MENU_MIST_STORAGE_FILE_SELECTED: // file successfully selected case MENU_MIST_STORAGE_FILE_SELECTED: // file successfully selected
// floppy/hdd // floppy/hdd
if (menusub < 2) if (menusub < 2)
tos_insert_disk(menusub, SelectedPath); tos_insert_disk(menusub, SelectedPath);
else { else {
@@ -3288,7 +3288,7 @@ void HandleUI(void)
strncat(minimig_config.info, p, sizeof(minimig_config.info) - strlen(minimig_config.info) - 1); strncat(minimig_config.info, p, sizeof(minimig_config.info) - strlen(minimig_config.info) - 1);
minimig_config.info[sizeof(minimig_config.info) - 1] = 0; minimig_config.info[sizeof(minimig_config.info) - 1] = 0;
if (menusub<10) minimig_cfg_save(menusub); if (menusub<10) minimig_cfg_save(menusub);
menustate = MENU_MAIN1; menustate = MENU_MAIN1;
menusub = 9; menusub = 9;
@@ -4173,7 +4173,7 @@ void HandleUI(void)
OsdWrite(3, " Press key to remap", 0, 0); OsdWrite(3, " Press key to remap", 0, 0);
s[0] = 0; s[0] = 0;
if(flag) if(flag)
{ {
sprintf(s, " on keyboard %04x:%04x", get_map_vid(), get_map_pid()); sprintf(s, " on keyboard %04x:%04x", get_map_vid(), get_map_pid());
} }
OsdWrite(5, s, 0, 0); OsdWrite(5, s, 0, 0);
@@ -4263,7 +4263,7 @@ void HandleUI(void)
char straux[64]; char straux[64];
if (cfg.bootcore[0] != '\0') if (cfg.bootcore[0] != '\0')
{ {
if (btimeout >= 10) if (btimeout >= 10)
{ {
sprintf(str, " Bootcore -> %s", bootcoretype); sprintf(str, " Bootcore -> %s", bootcoretype);
@@ -4284,7 +4284,7 @@ void HandleUI(void)
OsdWrite(15, str, 1, 0); OsdWrite(15, str, 1, 0);
fpga_load_rbf(cfg.bootcore); fpga_load_rbf(cfg.bootcore);
} }
} }
} }
if (init_wait < 1) if (init_wait < 1)
@@ -4368,7 +4368,7 @@ void PrintFileName(char *name, int row, int maxinv)
{ {
int len; int len;
char s[40]; char s[40];
s[32] = 0; // set temporary string length to OSD line length s[32] = 0; // set temporary string length to OSD line length
len = strlen(name); // get name length len = strlen(name); // get name length

View File

@@ -1,6 +1,6 @@
/* /*
Copyright 2019 alanswx Copyright 2019 alanswx
with help from the MiSTer contributors including Grabulosaure with help from the MiSTer contributors including Grabulosaure
*/ */
#include <stdlib.h> #include <stdlib.h>
@@ -49,12 +49,12 @@ mister_scaler * mister_scaler_init()
mister_scaler_free(ms); mister_scaler_free(ms);
return NULL; return NULL;
} }
ms->header=buffer[2]<<8 | buffer[3]; ms->header=buffer[2]<<8 | buffer[3];
ms->width =buffer[6]<<8 | buffer[7]; ms->width =buffer[6]<<8 | buffer[7];
ms->height=buffer[8]<<8 | buffer[9]; ms->height=buffer[8]<<8 | buffer[9];
ms->line =buffer[10]<<8 | buffer[11]; ms->line =buffer[10]<<8 | buffer[11];
printf ("Image: Width=%i Height=%i Line=%i Header=%i\n",ms->width,ms->height,ms->line,ms->header); printf ("Image: Width=%i Height=%i Line=%i Header=%i\n",ms->width,ms->height,ms->line,ms->header);
/* /*
printf (" 1: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", printf (" 1: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
@@ -62,7 +62,7 @@ mister_scaler * mister_scaler_init()
buffer[8],buffer[9],buffer[10],buffer[11],buffer[12],buffer[13],buffer[14],buffer[15]); buffer[8],buffer[9],buffer[10],buffer[11],buffer[12],buffer[13],buffer[14],buffer[15]);
*/ */
return ms; return ms;
} }
@@ -78,7 +78,7 @@ int mister_scaler_read_yuv(mister_scaler *ms,int lineY,unsigned char *bufY, int
unsigned char *buffer; unsigned char *buffer;
buffer = (unsigned char *)(ms->map+ms->map_off); buffer = (unsigned char *)(ms->map+ms->map_off);
// do this slow way for now.. // do this slow way for now..
unsigned char *pixbuf; unsigned char *pixbuf;
unsigned char *outbufy; unsigned char *outbufy;
unsigned char *outbufU; unsigned char *outbufU;
@@ -90,7 +90,7 @@ int mister_scaler_read_yuv(mister_scaler *ms,int lineY,unsigned char *bufY, int
outbufU=&bufU[y*(lineU)]; outbufU=&bufU[y*(lineU)];
outbufV=&bufV[y*(lineV)]; outbufV=&bufV[y*(lineV)];
for (int x = 0; x < ms->width ; x++) for (int x = 0; x < ms->width ; x++)
{ {
int R,G,B; int R,G,B;
R = *pixbuf++; R = *pixbuf++;
G = *pixbuf++; G = *pixbuf++;
@@ -104,7 +104,7 @@ int mister_scaler_read_yuv(mister_scaler *ms,int lineY,unsigned char *bufY, int
*outbufV++ = V; *outbufV++ = V;
} }
} }
return 0; return 0;
} }
@@ -112,19 +112,19 @@ int mister_scaler_read(mister_scaler *ms,unsigned char *gbuf)
{ {
unsigned char *buffer; unsigned char *buffer;
buffer = (unsigned char *)(ms->map+ms->map_off); buffer = (unsigned char *)(ms->map+ms->map_off);
// do this slow way for now.. - could use a memcpy? // do this slow way for now.. - could use a memcpy?
unsigned char *pixbuf; unsigned char *pixbuf;
unsigned char *outbuf; unsigned char *outbuf;
for (int y=0; y< ms->height ; y++) { for (int y=0; y< ms->height ; y++) {
pixbuf=&buffer[ms->header + y*ms->line]; pixbuf=&buffer[ms->header + y*ms->line];
outbuf=&gbuf[y*(ms->width*3)]; outbuf=&gbuf[y*(ms->width*3)];
for (int x = 0; x < ms->width ; x++) { for (int x = 0; x < ms->width ; x++) {
*outbuf++ = *pixbuf++; *outbuf++ = *pixbuf++;
*outbuf++ = *pixbuf++; *outbuf++ = *pixbuf++;
*outbuf++ = *pixbuf++; *outbuf++ = *pixbuf++;
} }
} }
return 0; return 0;
} }

View File

@@ -1,6 +1,6 @@
/* /*
Copyright 2019 alanswx Copyright 2019 alanswx
with help from the MiSTer contributors including Grabulosaure with help from the MiSTer contributors including Grabulosaure
*/ */
#ifndef SCALER_H #ifndef SCALER_H

View File

@@ -138,7 +138,7 @@ void archie_save_config(void)
void archie_set_rom(char *name) void archie_set_rom(char *name)
{ {
if (!name) return; if (!name) return;
printf("archie_set_rom(%s)\n", name); printf("archie_set_rom(%s)\n", name);
// save file name // save file name

View File

@@ -392,7 +392,7 @@ static void BootCustomInit()
mem_write16(0x000a); mem_write16(0x000a);
mem_upload_fini(); mem_upload_fini();
//move.w #$0000,$dff088 ; COPJMP1, restart copper at location 1 //move.w #$0000,$dff088 ; COPJMP1, restart copper at location 1
mem_upload_init(0xdff088); mem_upload_init(0xdff088);
mem_write16(0x0000); mem_write16(0x0000);
mem_upload_fini(); mem_upload_fini();

View File

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

View File

@@ -83,7 +83,7 @@ static void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int addr
printf("]\n"); printf("]\n");
} }
static char UploadKickstart(char *name) static char UploadKickstart(char *name)
{ {

View File

@@ -159,7 +159,7 @@ void SendGap(void)
// read a track from disk // read a track from disk
void ReadTrack(adfTYPE *drive) void ReadTrack(adfTYPE *drive)
{ {
// track number is updated in drive struct before calling this function // track number is updated in drive struct before calling this function
unsigned char sector; unsigned char sector;

View File

@@ -319,7 +319,7 @@ static void IdentifyDevice(uint16_t *pBuffer, hdfTYPE *hdf)
} }
p = (char*)&pBuffer[27]; p = (char*)&pBuffer[27];
for (i = 0; i < 40; i += 2) for (i = 0; i < 40; i += 2)
{ {
char c = p[i]; char c = p[i];
p[i] = p[i + 1]; p[i] = p[i + 1];

View File

@@ -3,7 +3,7 @@
#ifndef __MINIMIG_HDD_H__ #ifndef __MINIMIG_HDD_H__
#define __MINIMIG_HDD_H__ #define __MINIMIG_HDD_H__
#include "minimig_hdd_internal.h" #include "minimig_hdd_internal.h"
// functions // functions
void HandleHDD(uint8_t c1, uint8_t c2); void HandleHDD(uint8_t c1, uint8_t c2);

View File

@@ -7,8 +7,8 @@
// This module is an extension to the MiSTer control program. It adds extensions to // This module is an extension to the MiSTer control program. It adds extensions to
// the menu system and additional I/O control specific to the Sharp MZ series // the menu system and additional I/O control specific to the Sharp MZ series
// emulation. // emulation.
// //
// Credits: // Credits:
// Copyright: (c) 2018 Philip Smart <philip.smart@net2net.org> // Copyright: (c) 2018 Philip Smart <philip.smart@net2net.org>
// //
// History: July 2018 - Initial module written. // History: July 2018 - Initial module written.
@@ -172,13 +172,13 @@ int sharpmz_reset_config(short setStatus)
config.romFDC[i].loadAddr = MZLOADADDR[FDCROM_IDX][i]; config.romFDC[i].loadAddr = MZLOADADDR[FDCROM_IDX][i];
config.romFDC[i].loadSize = MZLOADSIZE[FDCROM_IDX][i]; config.romFDC[i].loadSize = MZLOADSIZE[FDCROM_IDX][i];
} }
// Set the status values. // Set the status values.
// //
if(setStatus) if(setStatus)
{ {
user_io_8bit_set_status(config.system_ctrl, 0xffffffff); user_io_8bit_set_status(config.system_ctrl, 0xffffffff);
// Set the registers. // Set the registers.
// //
for(int i=0; i < MAX_REGISTERS; i++) for(int i=0; i < MAX_REGISTERS; i++)
@@ -213,13 +213,13 @@ int sharpmz_reload_config(short setStatus)
sharpmz_reset_config(0); sharpmz_reset_config(0);
sharpmz_save_config(); sharpmz_save_config();
} }
// Set the status values and control registers as requested.. // Set the status values and control registers as requested..
// //
if(setStatus && success) if(setStatus && success)
{ {
user_io_8bit_set_status(config.system_ctrl, 0xffffffff); user_io_8bit_set_status(config.system_ctrl, 0xffffffff);
// Set the registers. // Set the registers.
// //
for(int i=0; i < MAX_REGISTERS; i++) for(int i=0; i < MAX_REGISTERS; i++)
@@ -244,7 +244,7 @@ void sharpmz_init(void)
// Necessary sleep to allow the reset to complete and the registers to become available. // Necessary sleep to allow the reset to complete and the registers to become available.
// //
usleep(50000); usleep(50000);
// Try and load the SD config. // Try and load the SD config.
// //
if(sharpmz_reload_config(0) == 0) if(sharpmz_reload_config(0) == 0)
@@ -338,7 +338,7 @@ void sharpmz_poll(void)
sharpmz_save_tape_from_cmt((const char *)0); sharpmz_save_tape_from_cmt((const char *)0);
} }
} }
// Reset the timer. // Reset the timer.
time = GetTimer(0); time = GetTimer(0);
} }
@@ -377,7 +377,7 @@ char *sharpmz_pop_filename(void)
static char fileName[MAX_FILENAME_SIZE]; static char fileName[MAX_FILENAME_SIZE];
// Queue empty, just return. // Queue empty, just return.
if(tapeQueue.bottom == NULL) if(tapeQueue.bottom == NULL)
{ {
return 0; return 0;
} }
@@ -406,7 +406,7 @@ char *sharpmz_get_next_filename(char reset)
static tape_queue_node_t *ptr = NULL; static tape_queue_node_t *ptr = NULL;
// Queue empty, just return. // Queue empty, just return.
if(tapeQueue.bottom == NULL) if(tapeQueue.bottom == NULL)
{ {
return 0; return 0;
} }
@@ -438,7 +438,7 @@ void sharpmz_clear_filelist(void)
tape_queue_node_t *ptr; tape_queue_node_t *ptr;
// Queue empty, just return. // Queue empty, just return.
if(tapeQueue.bottom == NULL) if(tapeQueue.bottom == NULL)
{ {
return; return;
} }
@@ -453,7 +453,7 @@ void sharpmz_clear_filelist(void)
tapeQueue.elements = 0; tapeQueue.elements = 0;
} }
// Return fast tape status bits. Bit 0,1 of system_reg, 0 = Off, 1 = 2x, 2 = 4x, 3 = 16x // Return fast tape status bits. Bit 0,1 of system_reg, 0 = Off, 1 = 2x, 2 = 4x, 3 = 16x
// //
int sharpmz_get_fasttape(void) int sharpmz_get_fasttape(void)
{ {
@@ -599,7 +599,7 @@ void sharpmz_set_display_type(short displayType, short setStatus)
// Sanity check. // Sanity check.
if(displayType > 3) displayType = 0; if(displayType > 3) displayType = 0;
//if(displayType == 1) displayType = 3; // Skip unassigned hardware. //if(displayType == 1) displayType = 3; // Skip unassigned hardware.
//if(displayType == 2) displayType = 3; //if(displayType == 2) displayType = 3;
config.system_reg[REGISTER_DISPLAY] &= ~(0x07); config.system_reg[REGISTER_DISPLAY] &= ~(0x07);
config.system_reg[REGISTER_DISPLAY] |= (displayType & 0x07); config.system_reg[REGISTER_DISPLAY] |= (displayType & 0x07);
@@ -1304,7 +1304,7 @@ void sharpmz_set_custom_rom_enabled(short machineModel, short romType, short on)
case KEYMAP_IDX: case KEYMAP_IDX:
config.romKeyMap[machineModel].romEnabled = (on == 1); config.romKeyMap[machineModel].romEnabled = (on == 1);
break; break;
case USERROM_IDX: case USERROM_IDX:
config.romUser[machineModel].romEnabled = (on == 1); config.romUser[machineModel].romEnabled = (on == 1);
break; break;
@@ -1410,7 +1410,7 @@ sharpmz_tape_header_t *sharpmz_get_tape_header(void)
return(&tapeHeader); return(&tapeHeader);
} }
// Local version of File Read so that we can read exact number of bytes required // Local version of File Read so that we can read exact number of bytes required
// and return parameter specifies number of bytes actually read. // and return parameter specifies number of bytes actually read.
// //
int sharpmz_file_read(fileTYPE *file, void *pBuffer, int nSize) int sharpmz_file_read(fileTYPE *file, void *pBuffer, int nSize)
@@ -1455,7 +1455,7 @@ void sharpmz_set_config_register(short addr, unsigned char value)
unsigned char sharpmz_read_config_register(short addr) unsigned char sharpmz_read_config_register(short addr)
{ {
unsigned char value; unsigned char value;
EnableFpga(); EnableFpga();
spi8(SHARPMZ_CONFIG_RX); spi8(SHARPMZ_CONFIG_RX);
spi8(addr); // Address of register to change. spi8(addr); // Address of register to change.
@@ -1523,7 +1523,7 @@ void sharpmz_send_file(romData_t &image, char *dirPrefix)
DISKLED_OFF; DISKLED_OFF;
// If we encountered an error, then bad file or eof, so exit. // If we encountered an error, then bad file or eof, so exit.
// //
if(actualReadSize != 0) if(actualReadSize != 0)
{ {
spi_write(sector_buffer, actualReadSize, 0); spi_write(sector_buffer, actualReadSize, 0);
@@ -1557,7 +1557,7 @@ short sharpmz_read_ram(const char *memDumpFile, short bank)
{ {
unsigned int actualWriteSize; unsigned int actualWriteSize;
fileTYPE file = {}; fileTYPE file = {};
// Open the memory image debug file for writing. // Open the memory image debug file for writing.
if (!sharpmz_file_write(&file, memDumpFile)) if (!sharpmz_file_write(&file, memDumpFile))
{ {
@@ -1633,7 +1633,7 @@ short sharpmz_read_tape_header(const char *tapeFile)
sharpmz_debugf("Only read:%d bytes of header, aborting.\n", actualReadSize); sharpmz_debugf("Only read:%d bytes of header, aborting.\n", actualReadSize);
return(1); return(1);
} }
// Some sanity checks. // Some sanity checks.
// //
if(tapeHeader.dataType == 0 || tapeHeader.dataType > 5) return(4); if(tapeHeader.dataType == 0 || tapeHeader.dataType > 5) return(4);
@@ -1752,7 +1752,7 @@ short sharpmz_load_tape_to_ram(const char *tapeFile, unsigned char dstCMT)
{ {
actualReadSize -= MZ_TAPE_HEADER_SIZE; actualReadSize -= MZ_TAPE_HEADER_SIZE;
memmove(sector_buffer, sector_buffer+MZ_TAPE_HEADER_SIZE, actualReadSize); memmove(sector_buffer, sector_buffer+MZ_TAPE_HEADER_SIZE, actualReadSize);
} }
//sharpmz_debugf("Bytes to read, actual:%d, index:%d, sizeHeader:%d", actualReadSize, i, tapeHeader.fileSize); //sharpmz_debugf("Bytes to read, actual:%d, index:%d, sizeHeader:%d", actualReadSize, i, tapeHeader.fileSize);
if(actualReadSize > 0) if(actualReadSize > 0)
{ {
@@ -1796,7 +1796,7 @@ short sharpmz_load_tape_to_ram(const char *tapeFile, unsigned char dstCMT)
time = GetTimer(0) - time; time = GetTimer(0) - time;
sharpmz_debugf("Uploaded in %lu ms", time >> 20); sharpmz_debugf("Uploaded in %lu ms", time >> 20);
// Debug, show registers. // Debug, show registers.
for(unsigned int i=0; i < MAX_REGISTERS; i++) for(unsigned int i=0; i < MAX_REGISTERS; i++)
{ {
@@ -1805,7 +1805,7 @@ short sharpmz_load_tape_to_ram(const char *tapeFile, unsigned char dstCMT)
// Tidy up. // Tidy up.
FileClose(&file); FileClose(&file);
// Dump out the memory if needed (generally for debug purposes). // Dump out the memory if needed (generally for debug purposes).
if(dstCMT == 0) // Load to emulators RAM if(dstCMT == 0) // Load to emulators RAM
{ {
@@ -1822,7 +1822,7 @@ short sharpmz_load_tape_to_ram(const char *tapeFile, unsigned char dstCMT)
{ {
if(tapeHeader.fileName[i] == 0x0d) tapeHeader.fileName[i] = 0x00; if(tapeHeader.fileName[i] == 0x0d) tapeHeader.fileName[i] = 0x00;
} }
// Debug, show registers. // Debug, show registers.
for(unsigned int i=0; i < MAX_REGISTERS; i++) for(unsigned int i=0; i < MAX_REGISTERS; i++)
{ {
@@ -1897,7 +1897,7 @@ short sharpmz_save_tape_from_cmt(const char *tapeFile)
{ {
memcpy(fileName, tapeHeader.fileName, 17); memcpy(fileName, tapeHeader.fileName, 17);
} }
// Open the memory image debug file for writing. // Open the memory image debug file for writing.
if (!sharpmz_file_write(&file, fileName)) if (!sharpmz_file_write(&file, fileName))
{ {
@@ -1978,7 +1978,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
short itemCount; short itemCount;
char sBuf[40]; char sBuf[40];
char *fileName; char *fileName;
(void)plus; (void)plus;
(void)minus; (void)minus;
@@ -2004,16 +2004,16 @@ void sharpmz_ui(int idleState, int idle2State, int system
/******************************************************************/ /******************************************************************/
case MENU_SHARPMZ_MAIN1: case MENU_SHARPMZ_MAIN1:
menuItem = 0; menuItem = 0;
subItem = 0; subItem = 0;
*menumask = 0; *menumask = 0;
OsdSetTitle(user_io_get_core_name(), 0); OsdSetTitle(user_io_get_core_name(), 0);
OsdWrite(menuItem++, " Main Menu", 0, 0); OsdWrite(menuItem++, " Main Menu", 0, 0);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
OsdWrite(menuItem++, " Tape Storage \x16", *menusub == subItem++, 0); OsdWrite(menuItem++, " Tape Storage \x16", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
@@ -2023,21 +2023,21 @@ void sharpmz_ui(int idleState, int idle2State, int system
OsdWrite(menuItem++, " Machine \x16", *menusub == subItem++, 0); OsdWrite(menuItem++, " Machine \x16", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
OsdWrite(menuItem++, " Display \x16", *menusub == subItem++, 0); OsdWrite(menuItem++, " Display \x16", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
OsdWrite(menuItem++, " Debug \x16", *menusub == subItem++, 0); OsdWrite(menuItem++, " Debug \x16", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
OsdWrite(menuItem++, " System \x16", *menusub == subItem++, 0); OsdWrite(menuItem++, " System \x16", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
for (; menuItem < 10; menuItem++) for (; menuItem < 10; menuItem++)
{ {
OsdWrite(menuItem, "", 0, 0); OsdWrite(menuItem, "", 0, 0);
} }
OsdWrite(menuItem++, " Reset", *menusub == subItem++, 0); OsdWrite(menuItem++, " Reset", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
OsdWrite(menuItem++, " Reload config", *menusub == subItem++, 0); OsdWrite(menuItem++, " Reload config", *menusub == subItem++, 0);
@@ -2051,16 +2051,16 @@ void sharpmz_ui(int idleState, int idle2State, int system
{ {
OsdWrite(menuItem, "", 0, 0); OsdWrite(menuItem, "", 0, 0);
} }
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
OsdWrite(menuItem, " exit", *menusub == subItem++, 0); OsdWrite(menuItem, " exit", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
// Set menu states, parent is the root menu, next is the processing menu 2. // Set menu states, parent is the root menu, next is the processing menu 2.
// //
*parentstate = MENU_SHARPMZ_MAIN1; *parentstate = MENU_SHARPMZ_MAIN1;
*menustate = MENU_SHARPMZ_MAIN2; *menustate = MENU_SHARPMZ_MAIN2;
// set helptext with core display on top of basic info // set helptext with core display on top of basic info
sprintf(helptext_custom, " "); sprintf(helptext_custom, " ");
strcat(helptext_custom, OsdCoreName()); strcat(helptext_custom, OsdCoreName());
@@ -2068,12 +2068,12 @@ void sharpmz_ui(int idleState, int idle2State, int system
strcat(helptext_custom, SHARPMZ_HELPTEXT[0]); strcat(helptext_custom, SHARPMZ_HELPTEXT[0]);
*helptext = helptext_custom; *helptext = helptext_custom;
break; break;
case MENU_SHARPMZ_MAIN2: case MENU_SHARPMZ_MAIN2:
// menu key closes menu // menu key closes menu
if (menu) if (menu)
*menustate = idleState; *menustate = idleState;
if (select || right) if (select || right)
{ {
switch (*menusub) switch (*menusub)
@@ -2098,21 +2098,21 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menusub = 0; *menusub = 0;
if(right) select = true; if(right) select = true;
break; break;
case 2: // Display case 2: // Display
*menustate = MENU_SHARPMZ_DISPLAY1; *menustate = MENU_SHARPMZ_DISPLAY1;
*menusub_last = *menusub; *menusub_last = *menusub;
*menusub = 0; *menusub = 0;
if(right) select = true; if(right) select = true;
break; break;
case 3: // Debug case 3: // Debug
*menustate = MENU_SHARPMZ_DEBUG1; *menustate = MENU_SHARPMZ_DEBUG1;
*menusub_last = *menusub; *menusub_last = *menusub;
*menusub = 0; *menusub = 0;
if(right) select = true; if(right) select = true;
break; break;
case 4: // System case 4: // System
*menustate = systemState; *menustate = systemState;
*menusub_last = *menusub; *menusub_last = *menusub;
@@ -2127,7 +2127,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menustate = idleState; *menustate = idleState;
} }
break; break;
case 6: // Reload Settings case 6: // Reload Settings
if(select) if(select)
{ {
@@ -2143,7 +2143,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menustate = MENU_SHARPMZ_MAIN1; *menustate = MENU_SHARPMZ_MAIN1;
} }
break; break;
case 8: // Reset Settings case 8: // Reset Settings
if(select) if(select)
{ {
@@ -2159,25 +2159,25 @@ void sharpmz_ui(int idleState, int idle2State, int system
} }
} }
break; break;
case MENU_SHARPMZ_TAPE_STORAGE1: case MENU_SHARPMZ_TAPE_STORAGE1:
menuItem = 0; menuItem = 0;
subItem = 0; subItem = 0;
*menumask = 0; *menumask = 0;
OsdSetTitle("Tape Storage", OSD_ARROW_LEFT); OsdSetTitle("Tape Storage", OSD_ARROW_LEFT);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
OsdWrite(menuItem++, " Load direct to RAM: *.MZF", *menusub == subItem++, 0); OsdWrite(menuItem++, " Load direct to RAM: *.MZF", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
OsdWrite(menuItem++, " Queue Tape: *.MZF", *menusub == subItem++, 0); OsdWrite(menuItem++, " Queue Tape: *.MZF", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
OsdWrite(menuItem++, " Clear Queue ", *menusub == subItem++, 0); OsdWrite(menuItem++, " Clear Queue ", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
// List out the current tape queue. // List out the current tape queue.
itemCount = 0; itemCount = 0;
while((fileName = sharpmz_get_next_filename(0)) != 0) while((fileName = sharpmz_get_next_filename(0)) != 0)
@@ -2207,20 +2207,20 @@ void sharpmz_ui(int idleState, int idle2State, int system
strcat(sBuf, sharpmz_get_fasttape_string()); strcat(sBuf, sharpmz_get_fasttape_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
for (; menuItem < 15; menuItem++) for (; menuItem < 15; menuItem++)
{ {
OsdWrite(menuItem, "", 0, 0); OsdWrite(menuItem, "", 0, 0);
} }
OsdWrite(menuItem, " exit", *menusub == subItem++, 0); OsdWrite(menuItem, " exit", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
*parentstate = *menustate; *parentstate = *menustate;
*menustate = MENU_SHARPMZ_TAPE_STORAGE2; *menustate = MENU_SHARPMZ_TAPE_STORAGE2;
break; break;
case MENU_SHARPMZ_TAPE_STORAGE2: case MENU_SHARPMZ_TAPE_STORAGE2:
if (menu) { if (menu) {
*menustate = MENU_SHARPMZ_MAIN1; *menustate = MENU_SHARPMZ_MAIN1;
@@ -2271,7 +2271,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
sharpmz_set_fasttape(sharpmz_get_fasttape()+1, 1); sharpmz_set_fasttape(sharpmz_get_fasttape()+1, 1);
*menustate = MENU_SHARPMZ_TAPE_STORAGE1; *menustate = MENU_SHARPMZ_TAPE_STORAGE1;
break; break;
case 7: case 7:
*menustate = MENU_SHARPMZ_MAIN1; *menustate = MENU_SHARPMZ_MAIN1;
*menusub = *menusub_last; *menusub = *menusub_last;
@@ -2284,7 +2284,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menusub = *menusub_last; *menusub = *menusub_last;
} }
break; break;
case MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM: case MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM:
sharpmz_debugf("File selected to send to RAM: %s, for menu option:%04x\n", selectedPath, *menumask); sharpmz_debugf("File selected to send to RAM: %s, for menu option:%04x\n", selectedPath, *menumask);
*menustate = MENU_SHARPMZ_TAPE_STORAGE1; *menustate = MENU_SHARPMZ_TAPE_STORAGE1;
@@ -2292,16 +2292,16 @@ void sharpmz_ui(int idleState, int idle2State, int system
{ {
int fail=sharpmz_load_tape_to_ram(selectedPath, 0); int fail=sharpmz_load_tape_to_ram(selectedPath, 0);
sharpmz_tape_header_t *tapeHeader = sharpmz_get_tape_header(); sharpmz_tape_header_t *tapeHeader = sharpmz_get_tape_header();
if(!fail) if(!fail)
OsdSetTitle("Tape Details", OSD_ARROW_LEFT); OsdSetTitle("Tape Details", OSD_ARROW_LEFT);
else else
OsdSetTitle(" Tape Error", OSD_ARROW_LEFT); OsdSetTitle(" Tape Error", OSD_ARROW_LEFT);
*menumask = 0x01; // Exit. *menumask = 0x01; // Exit.
*parentstate = *menustate; *parentstate = *menustate;
menuItem = 0; menuItem = 0;
if(!fail) if(!fail)
OsdWrite(menuItem++, " Tape Details", 0, 0); OsdWrite(menuItem++, " Tape Details", 0, 0);
else else
@@ -2320,7 +2320,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
sprintf(sBuf, " Exec Addr: %04x", tapeHeader->execAddress); sprintf(sBuf, " Exec Addr: %04x", tapeHeader->execAddress);
OsdWrite(menuItem++, sBuf, 0, 0); OsdWrite(menuItem++, sBuf, 0, 0);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
if(!fail) if(!fail)
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
else else
@@ -2347,7 +2347,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menustate = MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2; *menustate = MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2;
} }
break; break;
case MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2: case MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2:
if (menu || select || left || up) if (menu || select || left || up)
{ {
@@ -2355,7 +2355,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menusub = *menusub_last; *menusub = *menusub_last;
} }
break; break;
case MENU_SHARPMZ_TAPE_STORAGE_QUEUE_TAPE_TO_CMT: case MENU_SHARPMZ_TAPE_STORAGE_QUEUE_TAPE_TO_CMT:
sharpmz_debugf("File added to Queue: %s, for menu option:%04x\n", selectedPath, *menumask); sharpmz_debugf("File added to Queue: %s, for menu option:%04x\n", selectedPath, *menumask);
*menustate = MENU_SHARPMZ_TAPE_STORAGE1; *menustate = MENU_SHARPMZ_TAPE_STORAGE1;
@@ -2376,11 +2376,11 @@ void sharpmz_ui(int idleState, int idle2State, int system
{ {
OsdSetTitle("Queue Error", OSD_ARROW_LEFT); OsdSetTitle("Queue Error", OSD_ARROW_LEFT);
} }
*menumask = 0x01; // Exit. *menumask = 0x01; // Exit.
*parentstate = *menustate; *parentstate = *menustate;
menuItem = 0; menuItem = 0;
if(!fail) if(!fail)
{ {
OsdWrite(menuItem++, " Tape Details", 0, 0); OsdWrite(menuItem++, " Tape Details", 0, 0);
@@ -2455,19 +2455,19 @@ void sharpmz_ui(int idleState, int idle2State, int system
menuItem = 0; menuItem = 0;
subItem = 0; subItem = 0;
*menumask = 0; *menumask = 0;
OsdSetTitle("Floppy Storage", OSD_ARROW_LEFT); OsdSetTitle("Floppy Storage", OSD_ARROW_LEFT);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
for (; menuItem < 15; menuItem++) for (; menuItem < 15; menuItem++)
{ {
OsdWrite(menuItem, "", 0, 0); OsdWrite(menuItem, "", 0, 0);
} }
OsdWrite(menuItem, " exit", *menusub == subItem++, 0); OsdWrite(menuItem, " exit", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
*parentstate = *menustate; *parentstate = *menustate;
*menustate = MENU_SHARPMZ_FLOPPY_STORAGE2; *menustate = MENU_SHARPMZ_FLOPPY_STORAGE2;
break; break;
@@ -2503,16 +2503,16 @@ void sharpmz_ui(int idleState, int idle2State, int system
menuItem = 0; menuItem = 0;
subItem = 0; subItem = 0;
*menumask = 0; *menumask = 0;
OsdSetTitle("Machine", OSD_ARROW_LEFT); OsdSetTitle("Machine", OSD_ARROW_LEFT);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
strcpy(sBuf, " Machine Model: "); strcpy(sBuf, " Machine Model: ");
strcat(sBuf, sharpmz_get_machine_model_string()); strcat(sBuf, sharpmz_get_machine_model_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
strcpy(sBuf, " CPU Speed: "); strcpy(sBuf, " CPU Speed: ");
strcat(sBuf, sharpmz_get_cpu_speed_string()); strcat(sBuf, sharpmz_get_cpu_speed_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
@@ -2543,15 +2543,15 @@ void sharpmz_ui(int idleState, int idle2State, int system
{ {
OsdWrite(menuItem, "", 0, 0); OsdWrite(menuItem, "", 0, 0);
} }
OsdWrite(menuItem, " exit", *menusub == subItem++, 0); OsdWrite(menuItem, " exit", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
*parentstate = *menustate; *parentstate = *menustate;
*menustate = MENU_SHARPMZ_MACHINE2; *menustate = MENU_SHARPMZ_MACHINE2;
break; break;
case MENU_SHARPMZ_MACHINE2: case MENU_SHARPMZ_MACHINE2:
if (menu) { if (menu) {
*menustate = MENU_SHARPMZ_MAIN1; *menustate = MENU_SHARPMZ_MAIN1;
@@ -2566,7 +2566,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
sharpmz_set_machine_model(sharpmz_get_machine_model() + 1, 1); sharpmz_set_machine_model(sharpmz_get_machine_model() + 1, 1);
*menustate = MENU_SHARPMZ_MACHINE1; *menustate = MENU_SHARPMZ_MACHINE1;
break; break;
case 1: // CPU Speed case 1: // CPU Speed
sharpmz_set_cpu_speed((sharpmz_get_cpu_speed() + 1) & 0x07, 1); sharpmz_set_cpu_speed((sharpmz_get_cpu_speed() + 1) & 0x07, 1);
*menustate = MENU_SHARPMZ_MACHINE1; *menustate = MENU_SHARPMZ_MACHINE1;
@@ -2608,7 +2608,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menusub = 1; //*menusub_last; *menusub = 1; //*menusub_last;
} }
break; break;
case MENU_SHARPMZ_ROMS1: case MENU_SHARPMZ_ROMS1:
if(*menusub == 0) if(*menusub == 0)
@@ -2621,11 +2621,11 @@ void sharpmz_ui(int idleState, int idle2State, int system
menuItem = 0; menuItem = 0;
subItem = 0; subItem = 0;
*menumask = 0; *menumask = 0;
OsdSetTitle("Rom Management", OSD_ARROW_LEFT); OsdSetTitle("Rom Management", OSD_ARROW_LEFT);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
if(scrollPos == 0) if(scrollPos == 0)
{ {
strcpy(sBuf, " Machine Model: "); strcpy(sBuf, " Machine Model: ");
@@ -2679,7 +2679,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
} }
romEnabled = sharpmz_get_custom_rom_enabled(machineModel, CGROM_IDX); romEnabled = sharpmz_get_custom_rom_enabled(machineModel, CGROM_IDX);
strcpy(sBuf, " Char Generator "); strcpy(sBuf, " Char Generator ");
strcat(sBuf, sharpmz_get_custom_rom_enabled_string(romEnabled)); strcat(sBuf, sharpmz_get_custom_rom_enabled_string(romEnabled));
@@ -2693,7 +2693,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
} }
romEnabled = sharpmz_get_custom_rom_enabled(machineModel, KEYMAP_IDX); romEnabled = sharpmz_get_custom_rom_enabled(machineModel, KEYMAP_IDX);
strcpy(sBuf, " Key Mapping "); strcpy(sBuf, " Key Mapping ");
strcat(sBuf, sharpmz_get_custom_rom_enabled_string(romEnabled)); strcat(sBuf, sharpmz_get_custom_rom_enabled_string(romEnabled));
@@ -2742,12 +2742,12 @@ void sharpmz_ui(int idleState, int idle2State, int system
} }
OsdWrite(menuItem, " exit", *menusub == subItem++, 0); OsdWrite(menuItem, " exit", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
*parentstate = *menustate; *parentstate = *menustate;
*menustate = MENU_SHARPMZ_ROMS2; *menustate = MENU_SHARPMZ_ROMS2;
break; break;
case MENU_SHARPMZ_ROMS2: case MENU_SHARPMZ_ROMS2:
if (menu) { if (menu) {
*menustate = MENU_SHARPMZ_MACHINE1; *menustate = MENU_SHARPMZ_MACHINE1;
@@ -2830,7 +2830,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*fs_MenuCancel = MENU_SHARPMZ_ROMS1; *fs_MenuCancel = MENU_SHARPMZ_ROMS1;
*menustate = selectFile; *menustate = selectFile;
break; break;
case 15: case 15:
*menustate = MENU_SHARPMZ_MACHINE1; *menustate = MENU_SHARPMZ_MACHINE1;
*menusub = *menusub_last; *menusub = *menusub_last;
@@ -2843,24 +2843,24 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menusub = *menusub_last; *menusub = *menusub_last;
} }
break; break;
case MENU_SHARPMZ_ROM_FILE_SELECTED: case MENU_SHARPMZ_ROM_FILE_SELECTED:
if(!strncasecmp(selectedPath, SHARPMZ_CORE_NAME, 7)) strcpy(selectedPath, (char *) & selectedPath[8]); if(!strncasecmp(selectedPath, SHARPMZ_CORE_NAME, 7)) strcpy(selectedPath, (char *) & selectedPath[8]);
sharpmz_debugf("File selected: %s, model:%d, for option:%04x\n", selectedPath, machineModel, romType); sharpmz_debugf("File selected: %s, model:%d, for option:%04x\n", selectedPath, machineModel, romType);
sharpmz_set_rom_file(machineModel, romType, selectedPath); sharpmz_set_rom_file(machineModel, romType, selectedPath);
*menustate = MENU_SHARPMZ_ROMS1; *menustate = MENU_SHARPMZ_ROMS1;
break; break;
// DISPLAY Menu // DISPLAY Menu
case MENU_SHARPMZ_DISPLAY1: case MENU_SHARPMZ_DISPLAY1:
menuItem = 0; menuItem = 0;
subItem = 0; subItem = 0;
*menumask = 0; *menumask = 0;
OsdSetTitle("Display", OSD_ARROW_LEFT); OsdSetTitle("Display", OSD_ARROW_LEFT);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
strcpy(sBuf, " Display Type: "); strcpy(sBuf, " Display Type: ");
strcat(sBuf, sharpmz_get_display_type_string()); strcat(sBuf, sharpmz_get_display_type_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
@@ -2895,19 +2895,19 @@ void sharpmz_ui(int idleState, int idle2State, int system
strcat(sBuf, sharpmz_get_scandoubler_fx_string()); strcat(sBuf, sharpmz_get_scandoubler_fx_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
for (; menuItem < 15; menuItem++) for (; menuItem < 15; menuItem++)
{ {
OsdWrite(menuItem, "", 0, 0); OsdWrite(menuItem, "", 0, 0);
} }
OsdWrite(menuItem, " exit", *menusub == subItem++, 0); OsdWrite(menuItem, " exit", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
*parentstate = *menustate; *parentstate = *menustate;
*menustate = MENU_SHARPMZ_DISPLAY2; *menustate = MENU_SHARPMZ_DISPLAY2;
break; break;
case MENU_SHARPMZ_DISPLAY2: case MENU_SHARPMZ_DISPLAY2:
if (menu) { if (menu) {
*menustate = MENU_SHARPMZ_MAIN1; *menustate = MENU_SHARPMZ_MAIN1;
@@ -2964,17 +2964,17 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menusub = *menusub_last; *menusub = *menusub_last;
} }
break; break;
// Debug options. // Debug options.
case MENU_SHARPMZ_DEBUG1: case MENU_SHARPMZ_DEBUG1:
menuItem = 0; menuItem = 0;
subItem = 0; subItem = 0;
*menumask = 0; *menumask = 0;
OsdSetTitle("Debug", OSD_ARROW_LEFT); OsdSetTitle("Debug", OSD_ARROW_LEFT);
OsdWrite(menuItem++, "", 0, 0); OsdWrite(menuItem++, "", 0, 0);
strcpy(sBuf, " Select Memory Bank: "); strcpy(sBuf, " Select Memory Bank: ");
strcat(sBuf, sharpmz_get_memory_bank_string(memoryBank)); strcat(sBuf, sharpmz_get_memory_bank_string(memoryBank));
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
@@ -2999,7 +2999,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
strcat(sBuf, sharpmz_get_debug_enable_string()); strcat(sBuf, sharpmz_get_debug_enable_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
// Display the debug menu only when enabled. // Display the debug menu only when enabled.
// //
if(sharpmz_get_debug_enable()) if(sharpmz_get_debug_enable())
@@ -3008,7 +3008,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
strcat(sBuf, sharpmz_get_debug_cpufreq_string()); strcat(sBuf, sharpmz_get_debug_cpufreq_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
strcpy(sBuf, " Debug LEDS: "); strcpy(sBuf, " Debug LEDS: ");
strcat(sBuf, sharpmz_get_debug_leds_string()); strcat(sBuf, sharpmz_get_debug_leds_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
@@ -3022,12 +3022,12 @@ void sharpmz_ui(int idleState, int idle2State, int system
strcat(sBuf, sharpmz_get_debug_leds_smpfreq_string()); strcat(sBuf, sharpmz_get_debug_leds_smpfreq_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
strcpy(sBuf, " Signal Block: "); strcpy(sBuf, " Signal Block: ");
strcat(sBuf, sharpmz_get_debug_leds_bank_string()); strcat(sBuf, sharpmz_get_debug_leds_bank_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
strcpy(sBuf, " Bank: "); strcpy(sBuf, " Bank: ");
strcat(sBuf, sharpmz_get_debug_leds_subbank_string()); strcat(sBuf, sharpmz_get_debug_leds_subbank_string());
OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0);
@@ -3039,10 +3039,10 @@ void sharpmz_ui(int idleState, int idle2State, int system
{ {
OsdWrite(menuItem, "", 0, 0); OsdWrite(menuItem, "", 0, 0);
} }
OsdWrite(menuItem, " exit", *menusub == subItem++, 0); OsdWrite(menuItem, " exit", *menusub == subItem++, 0);
*menumask = (*menumask << 1) | 1; *menumask = (*menumask << 1) | 1;
*parentstate = *menustate; *parentstate = *menustate;
*menustate = MENU_SHARPMZ_DEBUG2; *menustate = MENU_SHARPMZ_DEBUG2;
break; break;
@@ -3073,7 +3073,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menustate = MENU_SHARPMZ_DEBUG1; *menustate = MENU_SHARPMZ_DEBUG1;
break; break;
case 3: // CPU Frequency case 3: // CPU Frequency
debugCPUFrequency = sharpmz_get_next_debug_cpufreq(); debugCPUFrequency = sharpmz_get_next_debug_cpufreq();
sharpmz_set_debug_cpufreq(debugCPUFrequency, 1); sharpmz_set_debug_cpufreq(debugCPUFrequency, 1);
*menustate = MENU_SHARPMZ_DEBUG1; *menustate = MENU_SHARPMZ_DEBUG1;
@@ -3084,12 +3084,12 @@ void sharpmz_ui(int idleState, int idle2State, int system
*menustate = MENU_SHARPMZ_DEBUG1; *menustate = MENU_SHARPMZ_DEBUG1;
break; break;
case 5: // Sample Frequency case 5: // Sample Frequency
debugLedsSampleFrequency = sharpmz_get_next_debug_leds_smpfreq(); debugLedsSampleFrequency = sharpmz_get_next_debug_leds_smpfreq();
sharpmz_set_debug_leds_smpfreq(debugLedsSampleFrequency, 1); sharpmz_set_debug_leds_smpfreq(debugLedsSampleFrequency, 1);
*menustate = MENU_SHARPMZ_DEBUG1; *menustate = MENU_SHARPMZ_DEBUG1;
break; break;
case 6: // Signal Block case 6: // Signal Block
debugLedsBank = sharpmz_get_next_debug_leds_bank(); debugLedsBank = sharpmz_get_next_debug_leds_bank();
sharpmz_set_debug_leds_bank(debugLedsBank, 1); sharpmz_set_debug_leds_bank(debugLedsBank, 1);
@@ -3102,7 +3102,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
sharpmz_set_debug_leds_subbank(sharpmz_get_next_debug_leds_subbank(0), 1); sharpmz_set_debug_leds_subbank(sharpmz_get_next_debug_leds_subbank(0), 1);
*menustate = MENU_SHARPMZ_DEBUG1; *menustate = MENU_SHARPMZ_DEBUG1;
break; break;
case 8: // Exit case 8: // Exit
*menustate = MENU_SHARPMZ_MAIN1; *menustate = MENU_SHARPMZ_MAIN1;
*menusub = *menusub_last; *menusub = *menusub_last;

View File

@@ -7,8 +7,8 @@
// This module is an extension to the MiSTer control program. It adds extensions to // This module is an extension to the MiSTer control program. It adds extensions to
// the menu system and additional I/O control specific to the Sharp MZ series // the menu system and additional I/O control specific to the Sharp MZ series
// emulation. // emulation.
// //
// Credits: // Credits:
// Copyright: (c) 2018 Philip Smart <philip.smart@net2net.org> // Copyright: (c) 2018 Philip Smart <philip.smart@net2net.org>
// //
// History: July 2018 - Initial module written. // History: July 2018 - Initial module written.
@@ -137,12 +137,12 @@
#define REGISTER_FDCROM 7 #define REGISTER_FDCROM 7
#define REGISTER_8 8 #define REGISTER_8 8
#define REGISTER_9 9 #define REGISTER_9 9
#define REGISTER_10 10 #define REGISTER_10 10
#define REGISTER_11 11 #define REGISTER_11 11
#define REGISTER_12 12 #define REGISTER_12 12
#define REGISTER_13 13 #define REGISTER_13 13
#define REGISTER_DEBUG 14 #define REGISTER_DEBUG 14
#define REGISTER_DEBUG2 15 #define REGISTER_DEBUG2 15
#define MAX_REGISTERS 16 #define MAX_REGISTERS 16
// Numeric id of bit for a given CMT register flag. // Numeric id of bit for a given CMT register flag.
@@ -171,7 +171,7 @@ static const unsigned int MZLOADADDR[MAX_IMAGE_TYPES][MAX_MZMACHINES] =
// Default size of roms. // Default size of roms.
// //
static const unsigned int MZLOADSIZE[MAX_IMAGE_TYPES][MAX_MZMACHINES] = static const unsigned int MZLOADSIZE[MAX_IMAGE_TYPES][MAX_MZMACHINES] =
{ {
{ 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM
{ 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM 80C { 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0800, 0x0800 }, // MROM 80C
@@ -191,7 +191,7 @@ const char *SHARPMZ_FAST_TAPE[] = { "Off", "2x", "4x", "8x", "16x", "32
"Off", "2x", "4x", "8x", "16x", "Off", "Off", "Off" "Off", "2x", "4x", "8x", "16x", "Off", "Off", "Off"
}; };
const char *SHARPMZ_CPU_SPEED[] = { "2MHz", "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "2MHz", "2MHz", const char *SHARPMZ_CPU_SPEED[] = { "2MHz", "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "2MHz", "2MHz",
"3.5MHz", "7MHz", "14MHz", "28MHz", "56MHz", "112MHz", "3.5MHz", "3.5MHz", "3.5MHz", "7MHz", "14MHz", "28MHz", "56MHz", "112MHz", "3.5MHz", "3.5MHz",
"4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "4MHz", "4MHz", "4MHz" "4MHz", "8MHz", "16MHz", "32MHz", "64MHz", "4MHz", "4MHz", "4MHz"
}; };
const char *SHARPMZ_TAPE_BUTTONS[] = { "Off", "Play", "Record", "Auto" }; const char *SHARPMZ_TAPE_BUTTONS[] = { "Off", "Play", "Record", "Auto" };
@@ -213,7 +213,7 @@ const char *SHARPMZ_MACHINE_MODEL[] = { "MZ80K", "MZ80C", "MZ1200", "MZ80A"
const char *SHARPMZ_DEBUG_ENABLE[] = { "Off", "On" }; const char *SHARPMZ_DEBUG_ENABLE[] = { "Off", "On" };
const char *SHARPMZ_DEBUG_LEDS[] = { "Off", "On" }; const char *SHARPMZ_DEBUG_LEDS[] = { "Off", "On" };
const char *SHARPMZ_DEBUG_LEDS_BANK[] = { "T80", "I/O", "IOCTL", "Config", "MZ80C I", "MZ80C II", "MZ80B I", "MZ80B II" }; const char *SHARPMZ_DEBUG_LEDS_BANK[] = { "T80", "I/O", "IOCTL", "Config", "MZ80C I", "MZ80C II", "MZ80B I", "MZ80B II" };
const char *SHARPMZ_DEBUG_LEDS_SUBBANK[] = { "Auto", "A7-0", "A15-8", "DI", "Signals", "", "", "", const char *SHARPMZ_DEBUG_LEDS_SUBBANK[] = { "Auto", "A7-0", "A15-8", "DI", "Signals", "", "", "",
"Auto", "Video", "PS2Key", "Signals", "", "", "", "", "Auto", "Video", "PS2Key", "Signals", "", "", "", "",
"Auto", "A23-16", "A15-8", "A7-0", "Signals", "", "", "", "Auto", "A23-16", "A15-8", "A7-0", "Signals", "", "", "",
"Auto", "Config 1", "Config 2", "Config 3", "Config 4", "Config 5", "", "", "Auto", "Config 1", "Config 2", "Config 3", "Config 4", "Config 5", "", "",
@@ -344,7 +344,7 @@ enum SHARPMZ_MENU
MENU_SHARPMZ_ROMS2 = 0xb5, MENU_SHARPMZ_ROMS2 = 0xb5,
MENU_SHARPMZ_ROM_FILE_SELECTED = 0xb6, MENU_SHARPMZ_ROM_FILE_SELECTED = 0xb6,
MENU_SHARPMZ_DEBUG1 = 0xb7, MENU_SHARPMZ_DEBUG1 = 0xb7,
MENU_SHARPMZ_DEBUG2 = 0xb8 MENU_SHARPMZ_DEBUG2 = 0xb8
}; };
// Prototypes. // Prototypes.
@@ -396,7 +396,7 @@ void sharpmz_set_machine_model(short, short);
void sharpmz_set_cpu_speed(short, short); void sharpmz_set_cpu_speed(short, short);
void sharpmz_set_audio_source(short, short); void sharpmz_set_audio_source(short, short);
void sharpmz_set_audio_volume(short, short); void sharpmz_set_audio_volume(short, short);
void sharpmz_set_audio_mute(short, short); void sharpmz_set_audio_mute(short, short);
void sharpmz_set_debug_enable(short, short); void sharpmz_set_debug_enable(short, short);
void sharpmz_set_debug_leds(short, short); void sharpmz_set_debug_leds(short, short);
void sharpmz_set_debug_leds_bank(short, short); void sharpmz_set_debug_leds_bank(short, short);

View File

@@ -245,7 +245,7 @@ uint8_t* snes_get_header(fileTYPE *f)
//PAL Regions //PAL Regions
if ((buf[addr + CartRegion] >= 0x02 && buf[addr + CartRegion] <= 0x0C) || buf[addr + CartRegion] == 0x11) if ((buf[addr + CartRegion] >= 0x02 && buf[addr + CartRegion] <= 0x0C) || buf[addr + CartRegion] == 0x11)
{ {
hdr[3] |= 1; hdr[3] |= 1;
} }

View File

@@ -319,7 +319,7 @@ struct ikbd_command_handler_t {
unsigned char length; unsigned char length;
void(*handler)(void); void(*handler)(void);
}; };
ikbd_command_handler_t ikbd_command_handler[] = ikbd_command_handler_t ikbd_command_handler[] =
{ {
{ 0x07, 2, ikbd_handler_mouse_button_action }, { 0x07, 2, ikbd_handler_mouse_button_action },

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,17 @@
/* /*
* Copyright (c) 2014, Aleksander Osman * Copyright (c) 2014, Aleksander Osman
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* * Redistributions of source code must retain the above copyright notice, this * * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. * list of conditions and the following disclaimer.
* *
* * Redistributions in binary form must reproduce the above copyright notice, * * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -28,7 +28,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
@@ -535,7 +535,7 @@ void x86_init()
//-------------------------------------------------------------------------- floppy //-------------------------------------------------------------------------- floppy
fdd_set(config.fdd_name); fdd_set(config.fdd_name);
//-------------------------------------------------------------------------- hdd //-------------------------------------------------------------------------- hdd
hdd_set(0); hdd_set(0);
@@ -597,7 +597,7 @@ void x86_init()
0x00, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 0x00, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8
0x00, //0x21: hd 0 configuration 7/9; landing zone low 0x00, //0x21: hd 0 configuration 7/9; landing zone low
0x00, //0x22: hd 0 configuration 8/9; landing zone high 0x00, //0x22: hd 0 configuration 8/9; landing zone high
0x00, //0x23: hd 0 configuration 9/9; sectors/track 0x00, //0x23: hd 0 configuration 9/9; sectors/track
0x00, //0x24: hd 1 configuration 1/9; cylinders low 0x00, //0x24: hd 1 configuration 1/9; cylinders low
0x00, //0x25: hd 1 configuration 2/9; cylinders high 0x00, //0x25: hd 1 configuration 2/9; cylinders high
0x00, //0x26: hd 1 configuration 3/9; heads 0x00, //0x26: hd 1 configuration 3/9; heads
@@ -606,7 +606,7 @@ void x86_init()
0x00, //0x29: hd 1 configuration 6/9; retries/bad map/heads>8 0x00, //0x29: hd 1 configuration 6/9; retries/bad map/heads>8
0x00, //0x2A: hd 1 configuration 7/9; landing zone low 0x00, //0x2A: hd 1 configuration 7/9; landing zone low
0x00, //0x2B: hd 1 configuration 8/9; landing zone high 0x00, //0x2B: hd 1 configuration 8/9; landing zone high
0x00, //0x2C: hd 1 configuration 9/9; sectors/track 0x00, //0x2C: hd 1 configuration 9/9; sectors/track
(boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence (boot_from_floppy)? 0x20u : 0x00u, //0x2D: boot sequence

View File

@@ -2,7 +2,7 @@
#define X86_H #define X86_H
void x86_init(); void x86_init();
void x86_poll(); void x86_poll();
void x86_set_image(int num, char *filename); void x86_set_image(int num, char *filename);

200
sxmlc.c
View File

@@ -124,7 +124,7 @@ int XML_unregister_user_tag(int i_tag)
if (pt == NULL) if (pt == NULL)
return -1; return -1;
} }
if (pt != NULL) { if (pt != NULL) {
memcpy(pt, _user_tags.tags, i_tag * sizeof(_TAG)); memcpy(pt, _user_tags.tags, i_tag * sizeof(_TAG));
memcpy(&pt[i_tag], &_user_tags.tags[i_tag + 1], (_user_tags.n_tags - i_tag - 1) * sizeof(_TAG)); memcpy(&pt[i_tag], &_user_tags.tags[i_tag + 1], (_user_tags.n_tags - i_tag - 1) * sizeof(_TAG));
@@ -163,13 +163,13 @@ int XML_get_registered_user_tag(TagType tag_type)
static int _add_node(XMLNode*** children_array, int* len_array, XMLNode* node) static int _add_node(XMLNode*** children_array, int* len_array, XMLNode* node)
{ {
XMLNode** pt = (XMLNode**)__realloc(*children_array, (*len_array+1) * sizeof(XMLNode*)); XMLNode** pt = (XMLNode**)__realloc(*children_array, (*len_array+1) * sizeof(XMLNode*));
if (pt == NULL) if (pt == NULL)
return -1; return -1;
pt[*len_array] = node; pt[*len_array] = node;
*children_array = pt; *children_array = pt;
return (*len_array)++; return (*len_array)++;
} }
@@ -177,20 +177,20 @@ int XMLNode_init(XMLNode* node)
{ {
if (node == NULL) if (node == NULL)
return false; return false;
if (node->init_value == XML_INIT_DONE) if (node->init_value == XML_INIT_DONE)
return true; /*(void)XMLNode_free(node);*/ return true; /*(void)XMLNode_free(node);*/
node->tag = NULL; node->tag = NULL;
node->text = NULL; node->text = NULL;
node->attributes = NULL; node->attributes = NULL;
node->n_attributes = 0; node->n_attributes = 0;
node->father = NULL; node->father = NULL;
node->children = NULL; node->children = NULL;
node->n_children = 0; node->n_children = 0;
node->tag_type = TAG_NONE; node->tag_type = TAG_NONE;
node->active = true; node->active = true;
@@ -203,17 +203,17 @@ XMLNode* XMLNode_allocN(int n)
{ {
int i; int i;
XMLNode* p; XMLNode* p;
if (n <= 0) if (n <= 0)
return NULL; return NULL;
p = (XMLNode*)__calloc(n, sizeof(XMLNode)); p = (XMLNode*)__calloc(n, sizeof(XMLNode));
if (p == NULL) if (p == NULL)
return NULL; return NULL;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
(void)XMLNode_init(&p[i]); (void)XMLNode_init(&p[i]);
return p; return p;
} }
@@ -242,7 +242,7 @@ int XMLNode_free(XMLNode* node)
{ {
if (node == NULL || node->init_value != XML_INIT_DONE) if (node == NULL || node->init_value != XML_INIT_DONE)
return false; return false;
if (node->tag != NULL) { if (node->tag != NULL) {
__free(node->tag); __free(node->tag);
node->tag = NULL; node->tag = NULL;
@@ -251,7 +251,7 @@ int XMLNode_free(XMLNode* node)
XMLNode_remove_text(node); XMLNode_remove_text(node);
XMLNode_remove_all_attributes(node); XMLNode_remove_all_attributes(node);
XMLNode_remove_children(node); XMLNode_remove_children(node);
node->tag_type = TAG_NONE; node->tag_type = TAG_NONE;
return true; return true;
@@ -260,16 +260,16 @@ int XMLNode_free(XMLNode* node)
int XMLNode_copy(XMLNode* dst, const XMLNode* src, int copy_children) int XMLNode_copy(XMLNode* dst, const XMLNode* src, int copy_children)
{ {
int i; int i;
if (dst == NULL || (src != NULL && src->init_value != XML_INIT_DONE)) if (dst == NULL || (src != NULL && src->init_value != XML_INIT_DONE))
return false; return false;
(void)XMLNode_free(dst); /* 'dst' is freed first */ (void)XMLNode_free(dst); /* 'dst' is freed first */
/* NULL 'src' resets 'dst' */ /* NULL 'src' resets 'dst' */
if (src == NULL) if (src == NULL)
return true; return true;
/* Tag */ /* Tag */
if (src->tag != NULL) { if (src->tag != NULL) {
dst->tag = sx_strdup(src->tag); dst->tag = sx_strdup(src->tag);
@@ -299,7 +299,7 @@ int XMLNode_copy(XMLNode* dst, const XMLNode* src, int copy_children)
dst->father = src->father; dst->father = src->father;
dst->user = src->user; dst->user = src->user;
dst->active = src->active; dst->active = src->active;
/* Copy children if required (and there are any) */ /* Copy children if required (and there are any) */
if (copy_children && src->n_children > 0) { if (copy_children && src->n_children > 0) {
dst->children = (XMLNode**)__calloc(src->n_children, sizeof(XMLNode*)); dst->children = (XMLNode**)__calloc(src->n_children, sizeof(XMLNode*));
@@ -309,12 +309,12 @@ int XMLNode_copy(XMLNode* dst, const XMLNode* src, int copy_children)
if (!XMLNode_copy(dst->children[i], src->children[i], true)) goto copy_err; if (!XMLNode_copy(dst->children[i], src->children[i], true)) goto copy_err;
} }
} }
return true; return true;
copy_err: copy_err:
(void)XMLNode_free(dst); (void)XMLNode_free(dst);
return false; return false;
} }
@@ -333,7 +333,7 @@ int XMLNode_set_tag(XMLNode* node, const SXML_CHAR* tag)
SXML_CHAR* newtag; SXML_CHAR* newtag;
if (node == NULL || tag == NULL || node->init_value != XML_INIT_DONE) if (node == NULL || tag == NULL || node->init_value != XML_INIT_DONE)
return false; return false;
newtag = sx_strdup(tag); newtag = sx_strdup(tag);
if (newtag == NULL) if (newtag == NULL)
return false; return false;
@@ -365,10 +365,10 @@ int XMLNode_set_attribute(XMLNode* node, const SXML_CHAR* attr_name, const SXML_
{ {
XMLAttribute* pt; XMLAttribute* pt;
int i; int i;
if (node == NULL || attr_name == NULL || attr_name[0] == NULC || node->init_value != XML_INIT_DONE) if (node == NULL || attr_name == NULL || attr_name[0] == NULC || node->init_value != XML_INIT_DONE)
return -1; return -1;
i = XMLNode_search_attribute(node, attr_name, 0); i = XMLNode_search_attribute(node, attr_name, 0);
if (i >= 0) { /* Attribute found: update it */ if (i >= 0) { /* Attribute found: update it */
SXML_CHAR* value = NULL; SXML_CHAR* value = NULL;
@@ -411,10 +411,10 @@ int XMLNode_get_attribute_with_default(XMLNode* node, const SXML_CHAR* attr_name
{ {
XMLAttribute* pt; XMLAttribute* pt;
int i; int i;
if (node == NULL || attr_name == NULL || attr_name[0] == NULC || attr_value == NULL || node->init_value != XML_INIT_DONE) if (node == NULL || attr_name == NULL || attr_name[0] == NULC || attr_value == NULL || node->init_value != XML_INIT_DONE)
return false; return false;
i = XMLNode_search_attribute(node, attr_name, 0); i = XMLNode_search_attribute(node, attr_name, 0);
if (i >= 0) { if (i >= 0) {
pt = node->attributes; pt = node->attributes;
@@ -450,14 +450,14 @@ int XMLNode_get_attribute_count(const XMLNode* node)
int XMLNode_search_attribute(const XMLNode* node, const SXML_CHAR* attr_name, int i_search) int XMLNode_search_attribute(const XMLNode* node, const SXML_CHAR* attr_name, int i_search)
{ {
int i; int i;
if (node == NULL || attr_name == NULL || attr_name[0] == NULC || i_search < 0 || i_search >= node->n_attributes) if (node == NULL || attr_name == NULL || attr_name[0] == NULC || i_search < 0 || i_search >= node->n_attributes)
return -1; return -1;
for (i = i_search; i < node->n_attributes; i++) for (i = i_search; i < node->n_attributes; i++)
if (node->attributes[i].active && !sx_strcmp(node->attributes[i].name, attr_name)) if (node->attributes[i].active && !sx_strcmp(node->attributes[i].name, attr_name))
return i; return i;
return -1; return -1;
} }
@@ -466,7 +466,7 @@ int XMLNode_remove_attribute(XMLNode* node, int i_attr)
XMLAttribute* pt; XMLAttribute* pt;
if (node == NULL || node->init_value != XML_INIT_DONE || i_attr < 0 || i_attr >= node->n_attributes) if (node == NULL || node->init_value != XML_INIT_DONE || i_attr < 0 || i_attr >= node->n_attributes)
return -1; return -1;
/* Before modifying first see if we run out of memory */ /* Before modifying first see if we run out of memory */
if (node->n_attributes == 1) if (node->n_attributes == 1)
pt = NULL; pt = NULL;
@@ -479,7 +479,7 @@ int XMLNode_remove_attribute(XMLNode* node, int i_attr)
/* Can't fail anymore, free item */ /* Can't fail anymore, free item */
if (node->attributes[i_attr].name != NULL) __free(node->attributes[i_attr].name); if (node->attributes[i_attr].name != NULL) __free(node->attributes[i_attr].name);
if (node->attributes[i_attr].value != NULL) __free(node->attributes[i_attr].value); if (node->attributes[i_attr].value != NULL) __free(node->attributes[i_attr].value);
if (pt != NULL) { if (pt != NULL) {
memcpy(pt, node->attributes, i_attr * sizeof(XMLAttribute)); memcpy(pt, node->attributes, i_attr * sizeof(XMLAttribute));
memcpy(&pt[i_attr], &node->attributes[i_attr + 1], (node->n_attributes - i_attr - 1) * sizeof(XMLAttribute)); memcpy(&pt[i_attr], &node->attributes[i_attr + 1], (node->n_attributes - i_attr - 1) * sizeof(XMLAttribute));
@@ -488,7 +488,7 @@ int XMLNode_remove_attribute(XMLNode* node, int i_attr)
__free(node->attributes); __free(node->attributes);
node->attributes = pt; node->attributes = pt;
node->n_attributes--; node->n_attributes--;
return node->n_attributes; return node->n_attributes;
} }
@@ -543,7 +543,7 @@ int XMLNode_add_child(XMLNode* node, XMLNode* child)
{ {
if (node == NULL || child == NULL || node->init_value != XML_INIT_DONE || child->init_value != XML_INIT_DONE) if (node == NULL || child == NULL || node->init_value != XML_INIT_DONE || child->init_value != XML_INIT_DONE)
return false; return false;
if (_add_node(&node->children, &node->n_children, child) >= 0) { if (_add_node(&node->children, &node->n_children, child) >= 0) {
node->tag_type = TAG_FATHER; node->tag_type = TAG_FATHER;
child->father = node; child->father = node;
@@ -561,24 +561,24 @@ int XMLNode_get_children_count(const XMLNode* node)
for (i = n = 0; i < node->n_children; i++) for (i = n = 0; i < node->n_children; i++)
if (node->children[i]->active) n++; if (node->children[i]->active) n++;
return n; return n;
} }
XMLNode* XMLNode_get_child(const XMLNode* node, int i_child) XMLNode* XMLNode_get_child(const XMLNode* node, int i_child)
{ {
int i; int i;
if (node == NULL || node->init_value != XML_INIT_DONE || i_child < 0 || i_child >= node->n_children) if (node == NULL || node->init_value != XML_INIT_DONE || i_child < 0 || i_child >= node->n_children)
return NULL; return NULL;
for (i = 0; i < node->n_children; i++) { for (i = 0; i < node->n_children; i++) {
if (!node->children[i]->active) if (!node->children[i]->active)
i_child++; i_child++;
else if (i == i_child) else if (i == i_child)
return node->children[i]; return node->children[i];
} }
return NULL; return NULL;
} }
@@ -589,7 +589,7 @@ int XMLNode_remove_child(XMLNode* node, int i_child, int free_child)
if (node == NULL || node->init_value != XML_INIT_DONE || i_child < 0 || i_child >= node->n_children) if (node == NULL || node->init_value != XML_INIT_DONE || i_child < 0 || i_child >= node->n_children)
return -1; return -1;
/* Lookup 'i_child'th active child */ /* Lookup 'i_child'th active child */
for (i = 0; i < node->n_children; i++) { for (i = 0; i < node->n_children; i++) {
if (!node->children[i]->active) if (!node->children[i]->active)
@@ -613,7 +613,7 @@ int XMLNode_remove_child(XMLNode* node, int i_child, int free_child)
(void)XMLNode_free(node->children[i_child]); (void)XMLNode_free(node->children[i_child]);
if (free_child) if (free_child)
__free(node->children[i_child]); __free(node->children[i_child]);
if (pt != NULL) { if (pt != NULL) {
memcpy(pt, node->children, i_child * sizeof(XMLNode*)); memcpy(pt, node->children, i_child * sizeof(XMLNode*));
memcpy(&pt[i_child], &node->children[i_child + 1], (node->n_children - i_child - 1) * sizeof(XMLNode*)); memcpy(&pt[i_child], &node->children[i_child + 1], (node->n_children - i_child - 1) * sizeof(XMLNode*));
@@ -624,7 +624,7 @@ int XMLNode_remove_child(XMLNode* node, int i_child, int free_child)
node->n_children--; node->n_children--;
if (node->n_children == 0) if (node->n_children == 0)
node->tag_type = TAG_SELF; node->tag_type = TAG_SELF;
return node->n_children; return node->n_children;
} }
@@ -645,7 +645,7 @@ int XMLNode_remove_children(XMLNode* node)
node->children = NULL; node->children = NULL;
} }
node->n_children = 0; node->n_children = 0;
return true; return true;
} }
@@ -748,7 +748,7 @@ int XMLDoc_init(XMLDoc* doc)
int XMLDoc_free(XMLDoc* doc) int XMLDoc_free(XMLDoc* doc)
{ {
int i; int i;
if (doc == NULL || doc->init_value != XML_INIT_DONE) if (doc == NULL || doc->init_value != XML_INIT_DONE)
return false; return false;
@@ -768,9 +768,9 @@ int XMLDoc_set_root(XMLDoc* doc, int i_root)
{ {
if (doc == NULL || doc->init_value != XML_INIT_DONE || i_root < 0 || i_root >= doc->n_nodes) if (doc == NULL || doc->init_value != XML_INIT_DONE || i_root < 0 || i_root >= doc->n_nodes)
return false; return false;
doc->i_root = i_root; doc->i_root = i_root;
return true; return true;
} }
@@ -778,7 +778,7 @@ int XMLDoc_add_node(XMLDoc* doc, XMLNode* node)
{ {
if (doc == NULL || node == NULL || doc->init_value != XML_INIT_DONE) if (doc == NULL || node == NULL || doc->init_value != XML_INIT_DONE)
return -1; return -1;
if (_add_node(&doc->nodes, &doc->n_nodes, node) < 0) if (_add_node(&doc->nodes, &doc->n_nodes, node) < 0)
return -1; return -1;
@@ -806,7 +806,7 @@ int XMLDoc_remove_node(XMLDoc* doc, int i_node, int free_node)
/* Can't fail anymore, free item */ /* Can't fail anymore, free item */
(void)XMLNode_free(doc->nodes[i_node]); (void)XMLNode_free(doc->nodes[i_node]);
if (free_node) __free(doc->nodes[i_node]); if (free_node) __free(doc->nodes[i_node]);
if (pt != NULL) { if (pt != NULL) {
memcpy(pt, &doc->nodes[i_node], i_node * sizeof(XMLNode*)); memcpy(pt, &doc->nodes[i_node], i_node * sizeof(XMLNode*));
memcpy(&pt[i_node], &doc->nodes[i_node + 1], (doc->n_nodes - i_node - 1) * sizeof(XMLNode*)); memcpy(&pt[i_node], &doc->nodes[i_node + 1], (doc->n_nodes - i_node - 1) * sizeof(XMLNode*));
@@ -834,7 +834,7 @@ static int _count_new_char_line(const SXML_CHAR* str, int nb_char_tab, int cur_s
else else
cur_sz_line++; cur_sz_line++;
} }
return cur_sz_line; return cur_sz_line;
} }
static int _print_formatting(const XMLNode* node, FILE* f, const SXML_CHAR* tag_sep, const SXML_CHAR* child_sep, int nb_char_tab, int cur_sz_line) static int _print_formatting(const XMLNode* node, FILE* f, const SXML_CHAR* tag_sep, const SXML_CHAR* child_sep, int nb_char_tab, int cur_sz_line)
@@ -849,7 +849,7 @@ static int _print_formatting(const XMLNode* node, FILE* f, const SXML_CHAR* tag_
cur_sz_line = _count_new_char_line(child_sep, nb_char_tab, cur_sz_line); cur_sz_line = _count_new_char_line(child_sep, nb_char_tab, cur_sz_line);
} }
} }
return cur_sz_line; return cur_sz_line;
} }
@@ -860,7 +860,7 @@ static int _XMLNode_print_header(const XMLNode* node, FILE* f, const SXML_CHAR*
if (node == NULL || f == NULL || !node->active || node->tag == NULL || node->tag[0] == NULC) if (node == NULL || f == NULL || !node->active || node->tag == NULL || node->tag[0] == NULC)
return -1; return -1;
/* Special handling of DOCTYPE */ /* Special handling of DOCTYPE */
if (node->tag_type == TAG_DOCTYPE) { if (node->tag_type == TAG_DOCTYPE) {
/* Search for an unescaped '[' in the DOCTYPE definition, in which case the end delimiter should be ']>' instead of '>' */ /* Search for an unescaped '[' in the DOCTYPE definition, in which case the end delimiter should be ']>' instead of '>' */
@@ -886,7 +886,7 @@ static int _XMLNode_print_header(const XMLNode* node, FILE* f, const SXML_CHAR*
return cur_sz_line; return cur_sz_line;
} }
} }
/* Print tag name */ /* Print tag name */
cur_sz_line += sx_fprintf(f, C2SX("<%s"), node->tag); cur_sz_line += sx_fprintf(f, C2SX("<%s"), node->tag);
@@ -910,13 +910,13 @@ static int _XMLNode_print_header(const XMLNode* node, FILE* f, const SXML_CHAR*
sx_fprintf(f, C2SX("%s="), node->attributes[i].name); sx_fprintf(f, C2SX("%s="), node->attributes[i].name);
} else } else
sx_fprintf(f, C2SX(" %s="), node->attributes[i].name); sx_fprintf(f, C2SX(" %s="), node->attributes[i].name);
/* Attribute value */ /* Attribute value */
(void)sx_fputc(XML_DEFAULT_QUOTE, f); (void)sx_fputc(XML_DEFAULT_QUOTE, f);
cur_sz_line += fprintHTML(f, node->attributes[i].value) + 2; cur_sz_line += fprintHTML(f, node->attributes[i].value) + 2;
(void)sx_fputc(XML_DEFAULT_QUOTE, f); (void)sx_fputc(XML_DEFAULT_QUOTE, f);
} }
/* End the tag if there are no children and no text */ /* End the tag if there are no children and no text */
if (node->n_children == 0 && (node->text == NULL || node->text[0] == NULC)) { if (node->n_children == 0 && (node->text == NULL || node->text[0] == NULC)) {
cur_sz_line += sx_fprintf(f, C2SX("/>")); cur_sz_line += sx_fprintf(f, C2SX("/>"));
@@ -937,7 +937,7 @@ static int _XMLNode_print(const XMLNode* node, FILE* f, const SXML_CHAR* tag_sep
{ {
int i; int i;
SXML_CHAR* p; SXML_CHAR* p;
if (node != NULL && node->tag_type==TAG_TEXT) { /* Text has to be printed: check if it is only spaces */ if (node != NULL && node->tag_type==TAG_TEXT) { /* Text has to be printed: check if it is only spaces */
if (!keep_text_spaces) { if (!keep_text_spaces) {
for (p = node->text; *p != NULC && sx_isspace(*p); p++) ; /* 'p' points to first non-space character, or to '\0' if only spaces */ for (p = node->text; *p != NULC && sx_isspace(*p); p++) ; /* 'p' points to first non-space character, or to '\0' if only spaces */
@@ -950,16 +950,16 @@ static int _XMLNode_print(const XMLNode* node, FILE* f, const SXML_CHAR* tag_sep
if (node == NULL || f == NULL || !node->active || node->tag == NULL || node->tag[0] == NULC) if (node == NULL || f == NULL || !node->active || node->tag == NULL || node->tag[0] == NULC)
return -1; return -1;
if (nb_char_tab <= 0) if (nb_char_tab <= 0)
nb_char_tab = 1; nb_char_tab = 1;
/* Print formatting */ /* Print formatting */
if (depth < 0) /* UGLY HACK: 'depth' forced negative on very first line so we don't print an extra 'tag_sep' (usually "\n" when pretty-printing) */ if (depth < 0) /* UGLY HACK: 'depth' forced negative on very first line so we don't print an extra 'tag_sep' (usually "\n" when pretty-printing) */
depth = 0; depth = 0;
else else
cur_sz_line = _print_formatting(node, f, tag_sep, child_sep, nb_char_tab, cur_sz_line); cur_sz_line = _print_formatting(node, f, tag_sep, child_sep, nb_char_tab, cur_sz_line);
_XMLNode_print_header(node, f, tag_sep, child_sep, attr_sep, sz_line, cur_sz_line, nb_char_tab); _XMLNode_print_header(node, f, tag_sep, child_sep, attr_sep, sz_line, cur_sz_line, nb_char_tab);
if (node->text != NULL && node->text[0] != NULC) { if (node->text != NULL && node->text[0] != NULC) {
@@ -971,11 +971,11 @@ static int _XMLNode_print(const XMLNode* node, FILE* f, const SXML_CHAR* tag_sep
if (*p != NULC) cur_sz_line += fprintHTML(f, node->text); if (*p != NULC) cur_sz_line += fprintHTML(f, node->text);
} else if (node->n_children <= 0) /* Everything has already been printed */ } else if (node->n_children <= 0) /* Everything has already been printed */
return cur_sz_line; return cur_sz_line;
/* Recursively print children */ /* Recursively print children */
for (i = 0; i < node->n_children; i++) for (i = 0; i < node->n_children; i++)
(void)_XMLNode_print(node->children[i], f, tag_sep, child_sep, attr_sep, keep_text_spaces, sz_line, cur_sz_line, nb_char_tab, depth+1); (void)_XMLNode_print(node->children[i], f, tag_sep, child_sep, attr_sep, keep_text_spaces, sz_line, cur_sz_line, nb_char_tab, depth+1);
/* Print tag end after children */ /* Print tag end after children */
/* Print formatting */ /* Print formatting */
if (node->n_children > 0) if (node->n_children > 0)
@@ -993,10 +993,10 @@ int XMLNode_print_attr_sep(const XMLNode* node, FILE* f, const SXML_CHAR* tag_se
int XMLDoc_print_attr_sep(const XMLDoc* doc, FILE* f, const SXML_CHAR* tag_sep, const SXML_CHAR* child_sep, const SXML_CHAR* attr_sep, int keep_text_spaces, int sz_line, int nb_char_tab) int XMLDoc_print_attr_sep(const XMLDoc* doc, FILE* f, const SXML_CHAR* tag_sep, const SXML_CHAR* child_sep, const SXML_CHAR* attr_sep, int keep_text_spaces, int sz_line, int nb_char_tab)
{ {
int i, depth, cur_sz_line; int i, depth, cur_sz_line;
if (doc == NULL || f == NULL || doc->init_value != XML_INIT_DONE) if (doc == NULL || f == NULL || doc->init_value != XML_INIT_DONE)
return false; return false;
#ifdef SXMLC_UNICODE #ifdef SXMLC_UNICODE
/* Write BOM if it exist */ /* Write BOM if it exist */
if (doc->sz_bom > 0) fwrite(doc->bom, sizeof(unsigned char), doc->sz_bom, f); if (doc->sz_bom > 0) fwrite(doc->bom, sizeof(unsigned char), doc->sz_bom, f);
@@ -1020,13 +1020,13 @@ int XML_parse_attribute_to(const SXML_CHAR* str, int to, XMLAttribute* xmlattr)
int i, n0, n1, remQ = 0; int i, n0, n1, remQ = 0;
int ret = 1; int ret = 1;
SXML_CHAR quote = '\0'; SXML_CHAR quote = '\0';
if (str == NULL || xmlattr == NULL) if (str == NULL || xmlattr == NULL)
return 0; return 0;
if (to < 0) if (to < 0)
to = sx_strlen(str) - 1; to = sx_strlen(str) - 1;
/* Search for the '=' */ /* Search for the '=' */
/* 'n0' is where the attribute name stops, 'n1' is where the attribute value starts */ /* 'n0' is where the attribute name stops, 'n1' is where the attribute value starts */
for (n0 = 0; n0 != to && str[n0] != C2SX('=') && !sx_isspace(str[n0]); n0++) ; /* Search for '=' or a space */ for (n0 = 0; n0 != to && str[n0] != C2SX('=') && !sx_isspace(str[n0]); n0++) ; /* Search for '=' or a space */
@@ -1038,7 +1038,7 @@ int XML_parse_attribute_to(const SXML_CHAR* str, int to, XMLAttribute* xmlattr)
quote = str[n1]; quote = str[n1];
remQ = 1; remQ = 1;
} }
xmlattr->name = (SXML_CHAR*)__malloc((n0+1)*sizeof(SXML_CHAR)); xmlattr->name = (SXML_CHAR*)__malloc((n0+1)*sizeof(SXML_CHAR));
xmlattr->value = (SXML_CHAR*)__malloc((to+1 - n1 - remQ + 1) * sizeof(SXML_CHAR)); xmlattr->value = (SXML_CHAR*)__malloc((to+1 - n1 - remQ + 1) * sizeof(SXML_CHAR));
xmlattr->active = true; xmlattr->active = true;
@@ -1057,7 +1057,7 @@ int XML_parse_attribute_to(const SXML_CHAR* str, int to, XMLAttribute* xmlattr)
ret = 2; /* Quote at the beginning but not at the end: probable presence of '>' inside attribute value, so we need to read more data! */ ret = 2; /* Quote at the beginning but not at the end: probable presence of '>' inside attribute value, so we need to read more data! */
} else } else
ret = 0; ret = 0;
if (ret == 0) { if (ret == 0) {
if (xmlattr->name != NULL) { if (xmlattr->name != NULL) {
__free(xmlattr->name); __free(xmlattr->name);
@@ -1068,7 +1068,7 @@ int XML_parse_attribute_to(const SXML_CHAR* str, int to, XMLAttribute* xmlattr)
xmlattr->value = NULL; xmlattr->value = NULL;
} }
} }
return ret; return ret;
} }
@@ -1100,11 +1100,11 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode)
SXML_CHAR *p; SXML_CHAR *p;
XMLAttribute* pt; XMLAttribute* pt;
int n, nn, len, rc, tag_end = 0; int n, nn, len, rc, tag_end = 0;
if (str == NULL || xmlnode == NULL) if (str == NULL || xmlnode == NULL)
return TAG_ERROR; return TAG_ERROR;
len = sx_strlen(str); len = sx_strlen(str);
/* Check for malformed string */ /* Check for malformed string */
if (str[0] != C2SX('<') || str[len-1] != C2SX('>')) if (str[0] != C2SX('<') || str[len-1] != C2SX('>'))
return TAG_ERROR; return TAG_ERROR;
@@ -1138,7 +1138,7 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode)
return TAG_DOCTYPE; return TAG_DOCTYPE;
} }
} }
/* Test user tags */ /* Test user tags */
for (nn = 0; nn < _user_tags.n_tags; nn++) { for (nn = 0; nn < _user_tags.n_tags; nn++) {
n = _parse_special_tag(str, len, &_user_tags.tags[nn], xmlnode); n = _parse_special_tag(str, len, &_user_tags.tags[nn], xmlnode);
@@ -1151,7 +1151,7 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode)
if (str[1] == C2SX('/')) if (str[1] == C2SX('/'))
tag_end = 1; tag_end = 1;
/* tag starts at index 1 (or 2 if tag end) and ends at the first space or '/>' */ /* tag starts at index 1 (or 2 if tag end) and ends at the first space or '/>' */
for (n = 1 + tag_end; str[n] != NULC && str[n] != C2SX('>') && str[n] != C2SX('/') && !sx_isspace(str[n]); n++) ; for (n = 1 + tag_end; str[n] != NULC && str[n] != C2SX('>') && str[n] != C2SX('/') && !sx_isspace(str[n]); n++) ;
xmlnode->tag = (SXML_CHAR*)__malloc((n - tag_end)*sizeof(SXML_CHAR)); xmlnode->tag = (SXML_CHAR*)__malloc((n - tag_end)*sizeof(SXML_CHAR));
@@ -1163,12 +1163,12 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode)
xmlnode->tag_type = TAG_END; xmlnode->tag_type = TAG_END;
return TAG_END; return TAG_END;
} }
/* Here, 'n' is the position of the first space after tag name */ /* Here, 'n' is the position of the first space after tag name */
while (n < len) { while (n < len) {
/* Skips spaces */ /* Skips spaces */
while (sx_isspace(str[n])) n++; while (sx_isspace(str[n])) n++;
/* Check for XML end ('>' or '/>') */ /* Check for XML end ('>' or '/>') */
if (str[n] == C2SX('>')) { /* Tag with children */ if (str[n] == C2SX('>')) { /* Tag with children */
int type = (str[n-1] == '/' ? TAG_SELF : TAG_FATHER); // TODO: Find something better to cope with <tag attr=v/> int type = (str[n-1] == '/' ? TAG_SELF : TAG_FATHER); // TODO: Find something better to cope with <tag attr=v/>
@@ -1179,13 +1179,13 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode)
xmlnode->tag_type = TAG_SELF; xmlnode->tag_type = TAG_SELF;
return TAG_SELF; return TAG_SELF;
} }
/* New attribute found */ /* New attribute found */
p = sx_strchr(str+n, C2SX('=')); p = sx_strchr(str+n, C2SX('='));
if (p == NULL) goto parse_err; if (p == NULL) goto parse_err;
pt = (XMLAttribute*)__realloc(xmlnode->attributes, (xmlnode->n_attributes + 1) * sizeof(XMLAttribute)); pt = (XMLAttribute*)__realloc(xmlnode->attributes, (xmlnode->n_attributes + 1) * sizeof(XMLAttribute));
if (pt == NULL) goto parse_err; if (pt == NULL) goto parse_err;
pt[xmlnode->n_attributes].name = NULL; pt[xmlnode->n_attributes].name = NULL;
pt[xmlnode->n_attributes].value = NULL; pt[xmlnode->n_attributes].value = NULL;
pt[xmlnode->n_attributes].active = false; pt[xmlnode->n_attributes].active = false;
@@ -1199,7 +1199,7 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode)
} else { /* Attribute value stops at first space or end of XML string */ } else { /* Attribute value stops at first space or end of XML string */
for (nn = p-str+1; str[nn] != NULC && !sx_isspace(str[nn]) && str[nn] != C2SX('/') && str[nn] != C2SX('>'); nn++) ; /* Go to the end of the attribute value */ // CHECK UNICODE for (nn = p-str+1; str[nn] != NULC && !sx_isspace(str[nn]) && str[nn] != C2SX('/') && str[nn] != C2SX('>'); nn++) ; /* Go to the end of the attribute value */ // CHECK UNICODE
} }
/* Here 'str[nn]' is the character after value */ /* Here 'str[nn]' is the character after value */
/* the attribute definition ('attrName="attrVal"') is between 'str[n]' and 'str[nn]' */ /* the attribute definition ('attrName="attrVal"') is between 'str[n]' and 'str[nn]' */
rc = XML_parse_attribute_to(&str[n], nn - n, &xmlnode->attributes[xmlnode->n_attributes - 1]); rc = XML_parse_attribute_to(&str[n], nn - n, &xmlnode->attributes[xmlnode->n_attributes - 1]);
@@ -1208,12 +1208,12 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode)
XMLNode_remove_attribute(xmlnode, xmlnode->n_attributes - 1); XMLNode_remove_attribute(xmlnode, xmlnode->n_attributes - 1);
return TAG_PARTIAL; return TAG_PARTIAL;
} }
n = nn + 1; n = nn + 1;
} }
sx_fprintf(stderr, C2SX("\nWE SHOULD NOT BE HERE!\n[%s]\n\n"), str); sx_fprintf(stderr, C2SX("\nWE SHOULD NOT BE HERE!\n[%s]\n\n"), str);
parse_err: parse_err:
(void)XMLNode_free(xmlnode); (void)XMLNode_free(xmlnode);
@@ -1298,7 +1298,7 @@ static int _parse_data_SAX(void* in, const DataSourceType in_type, const SAX_Cal
break; break;
} }
break; break;
case TAG_NONE: /* Syntax error */ case TAG_NONE: /* Syntax error */
ret = false; ret = false;
p = sx_strchr(txt_end, C2SX('\n')); p = sx_strchr(txt_end, C2SX('\n'));
@@ -1420,7 +1420,7 @@ int DOMXMLDoc_node_start(const XMLNode* node, SAX_Data* sd)
int i; int i;
if ((new_node = XMLNode_dup(node, true)) == NULL) goto node_start_err; /* No real need to put 'true' for 'XMLNode_dup', but cleaner */ if ((new_node = XMLNode_dup(node, true)) == NULL) goto node_start_err; /* No real need to put 'true' for 'XMLNode_dup', but cleaner */
if (dom->current == NULL) { if (dom->current == NULL) {
if ((i = _add_node(&dom->doc->nodes, &dom->doc->n_nodes, new_node)) < 0) goto node_start_err; if ((i = _add_node(&dom->doc->nodes, &dom->doc->n_nodes, new_node)) < 0) goto node_start_err;
@@ -1515,7 +1515,7 @@ int DOMXMLDoc_node_text(SXML_CHAR* text, SAX_Data* sd)
dom->line_error = sd->line_num; dom->line_error = sd->line_num;
return false; return false;
} }
dom->current->text = p; dom->current->text = p;
} }
@@ -1580,7 +1580,7 @@ int XMLDoc_parse_file_SAX(const SXML_CHAR* filename, const SAX_Callbacks* sax, v
FILE* f; FILE* f;
int ret; int ret;
SAX_Data sd; SAX_Data sd;
SXML_CHAR* fmode = SXML_CHAR* fmode =
#ifndef SXMLC_UNICODE #ifndef SXMLC_UNICODE
C2SX("rt"); C2SX("rt");
#else #else
@@ -1774,7 +1774,7 @@ int _bgetc(DataSourceBuffer* ds)
{ {
if (ds == NULL || ds->buf[ds->cur_pos] == NULC) if (ds == NULL || ds->buf[ds->cur_pos] == NULC)
return EOF; return EOF;
return (int)(ds->buf[ds->cur_pos++]); return (int)(ds->buf[ds->cur_pos++]);
} }
@@ -1795,10 +1795,10 @@ int read_line_alloc(void* in, DataSourceType in_type, SXML_CHAR** line, int* sz_
int n, ret; int n, ret;
int (*mgetc)(void* ds) = (in_type == DATA_SOURCE_BUFFER ? (int(*)(void*))_bgetc : (int(*)(void*))sx_fgetc); int (*mgetc)(void* ds) = (in_type == DATA_SOURCE_BUFFER ? (int(*)(void*))_bgetc : (int(*)(void*))sx_fgetc);
int (*meos)(void* ds) = (in_type == DATA_SOURCE_BUFFER ? (int(*)(void*))_beob : (int(*)(void*))sx_feof); int (*meos)(void* ds) = (in_type == DATA_SOURCE_BUFFER ? (int(*)(void*))_beob : (int(*)(void*))sx_feof);
if (in == NULL || line == NULL) if (in == NULL || line == NULL)
return 0; return 0;
if (to == NULC) if (to == NULC)
to = C2SX('\n'); to = C2SX('\n');
/* Search for character 'from' */ /* Search for character 'from' */
@@ -1816,10 +1816,10 @@ int read_line_alloc(void* in, DataSourceType in_type, SXML_CHAR** line, int* sz_
if (ch == from || from == NULC) if (ch == from || from == NULC)
break; break;
} }
if (sz_line == NULL) if (sz_line == NULL)
sz_line = &init_sz; sz_line = &init_sz;
if (*line == NULL || *sz_line == 0) { if (*line == NULL || *sz_line == 0) {
if (*sz_line == 0) *sz_line = MEM_INCR_RLA; if (*sz_line == 0) *sz_line = MEM_INCR_RLA;
*line = (SXML_CHAR*)__malloc(*sz_line*sizeof(SXML_CHAR)); *line = (SXML_CHAR*)__malloc(*sz_line*sizeof(SXML_CHAR));
@@ -1830,7 +1830,7 @@ int read_line_alloc(void* in, DataSourceType in_type, SXML_CHAR** line, int* sz_
i0 = 0; i0 = 0;
if (i0 > *sz_line) if (i0 > *sz_line)
return 0; return 0;
n = i0; n = i0;
if (c == CSXEOF) { /* EOF reached before 'to' char => return the empty string */ if (c == CSXEOF) { /* EOF reached before 'to' char => return the empty string */
(*line)[n] = NULC; (*line)[n] = NULC;
@@ -1867,14 +1867,14 @@ int read_line_alloc(void* in, DataSourceType in_type, SXML_CHAR** line, int* sz_
break; break;
} }
} }
#if 0 /* Automatic buffer resize is deactivated */ #if 0 /* Automatic buffer resize is deactivated */
/* Resize line to the exact size */ /* Resize line to the exact size */
pt = (SXML_CHAR*)__realloc(*line, (n+1)*sizeof(SXML_CHAR)); pt = (SXML_CHAR*)__realloc(*line, (n+1)*sizeof(SXML_CHAR));
if (pt != NULL) if (pt != NULL)
*line = pt; *line = pt;
#endif #endif
return ret; return ret;
} }
@@ -1909,7 +1909,7 @@ SXML_CHAR* strip_spaces(SXML_CHAR* str, SXML_CHAR repl_sq)
{ {
SXML_CHAR* p; SXML_CHAR* p;
int i, len; int i, len;
/* 'p' to the first non-space */ /* 'p' to the first non-space */
for (p = str; *p != NULC && sx_isspace(*p); p++) ; /* No need to search for 'protect' as it is not a space */ for (p = str; *p != NULC && sx_isspace(*p); p++) ; /* No need to search for 'protect' as it is not a space */
len = sx_strlen(str); len = sx_strlen(str);
@@ -1917,14 +1917,14 @@ SXML_CHAR* strip_spaces(SXML_CHAR* str, SXML_CHAR repl_sq)
if (str[i] == C2SX('\\')) /* If last non-space is the protection, keep the last space */ if (str[i] == C2SX('\\')) /* If last non-space is the protection, keep the last space */
i++; i++;
str[i+1] = NULC; /* New end of string to last non-space */ str[i+1] = NULC; /* New end of string to last non-space */
if (repl_sq == NULC) { if (repl_sq == NULC) {
if (p == str && i == len) if (p == str && i == len)
return str; /* Nothing to do */ return str; /* Nothing to do */
for (i = 0; (str[i] = *p) != NULC; i++, p++) ; /* Copy 'p' to 'str' */ for (i = 0; (str[i] = *p) != NULC; i++, p++) ; /* Copy 'p' to 'str' */
return str; return str;
} }
/* Squeeze all spaces with 'repl_sq' */ /* Squeeze all spaces with 'repl_sq' */
i = 0; i = 0;
while (*p != NULC) { while (*p != NULC) {
@@ -1938,7 +1938,7 @@ SXML_CHAR* strip_spaces(SXML_CHAR* str, SXML_CHAR repl_sq)
} }
} }
str[i] = NULC; str[i] = NULC;
return str; return str;
} }
@@ -2136,7 +2136,7 @@ SXML_CHAR* html2str(SXML_CHAR* html, SXML_CHAR* str)
if (html == NULL) return NULL; if (html == NULL) return NULL;
if (str == NULL) str = html; if (str == NULL) str = html;
/* Look for '&' and matches it to any of the recognized HTML pattern. */ /* Look for '&' and matches it to any of the recognized HTML pattern. */
/* If found, replaces the '&' by the corresponding char. */ /* If found, replaces the '&' by the corresponding char. */
/* 'p2' is the char to analyze, 'p1' is where to insert it */ /* 'p2' is the char to analyze, 'p1' is where to insert it */
@@ -2146,11 +2146,11 @@ SXML_CHAR* html2str(SXML_CHAR* html, SXML_CHAR* str)
*pd = *ps; *pd = *ps;
continue; continue;
} }
for (i = 0; HTML_SPECIAL_DICT[i].chr; i++) { for (i = 0; HTML_SPECIAL_DICT[i].chr; i++) {
if (sx_strncmp(ps, HTML_SPECIAL_DICT[i].html, HTML_SPECIAL_DICT[i].html_len)) if (sx_strncmp(ps, HTML_SPECIAL_DICT[i].html, HTML_SPECIAL_DICT[i].html_len))
continue; continue;
*pd = HTML_SPECIAL_DICT[i].chr; *pd = HTML_SPECIAL_DICT[i].chr;
ps += HTML_SPECIAL_DICT[i].html_len-1; ps += HTML_SPECIAL_DICT[i].html_len-1;
break; break;
@@ -2160,7 +2160,7 @@ SXML_CHAR* html2str(SXML_CHAR* html, SXML_CHAR* str)
*pd = *ps; *pd = *ps;
} }
*pd = NULC; *pd = NULC;
return str; return str;
} }
@@ -2201,7 +2201,7 @@ SXML_CHAR* str2html(SXML_CHAR* str, SXML_CHAR* html)
int strlen_html(SXML_CHAR* str) int strlen_html(SXML_CHAR* str)
{ {
int i, j, n; int i, j, n;
if (str == NULL) if (str == NULL)
return 0; return 0;
@@ -2224,7 +2224,7 @@ int fprintHTML(FILE* f, SXML_CHAR* str)
{ {
SXML_CHAR* p; SXML_CHAR* p;
int i, n; int i, n;
for (p = str, n = 0; *p != NULC; p++) { for (p = str, n = 0; *p != NULC; p++) {
for (i = 0; HTML_SPECIAL_DICT[i].chr; i++) { for (i = 0; HTML_SPECIAL_DICT[i].chr; i++) {
if (*p != HTML_SPECIAL_DICT[i].chr) if (*p != HTML_SPECIAL_DICT[i].chr)
@@ -2238,7 +2238,7 @@ int fprintHTML(FILE* f, SXML_CHAR* str)
n++; n++;
} }
} }
return n; return n;
} }

View File

@@ -178,11 +178,11 @@ typedef struct _XMLNode {
SXML_CHAR* text; /* Text inside the node */ SXML_CHAR* text; /* Text inside the node */
XMLAttribute* attributes; XMLAttribute* attributes;
int n_attributes; int n_attributes;
struct _XMLNode* father; /* NULL if root */ struct _XMLNode* father; /* NULL if root */
struct _XMLNode** children; struct _XMLNode** children;
int n_children; int n_children;
TagType tag_type; /* Node type ('TAG_FATHER', 'TAG_SELF' or 'TAG_END') */ TagType tag_type; /* Node type ('TAG_FATHER', 'TAG_SELF' or 'TAG_END') */
int active; /* 'true' to tell that node is active and should be displayed by 'XMLDoc_print' */ int active; /* 'true' to tell that node is active and should be displayed by 'XMLDoc_print' */

View File

@@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>
@@ -693,7 +693,7 @@ void user_io_init(const char *path)
char cmd[32]; char cmd[32];
system("uartmode 0"); system("uartmode 0");
SetMidiLinkMode((mode >> 8) & 0xFF); SetMidiLinkMode((mode >> 8) & 0xFF);
sprintf(cmd, "uartmode %d", mode & 0xFF); sprintf(cmd, "uartmode %d", mode & 0xFF);
system(cmd); system(cmd);
@@ -1277,7 +1277,7 @@ static void send_pcolchr(const char* name, unsigned char index, int type)
char *p = strrchr(full_path, '.'); char *p = strrchr(full_path, '.');
if (!p) p = full_path + strlen(full_path); if (!p) p = full_path + strlen(full_path);
strcpy(p, type ? ".chr" : ".col"); strcpy(p, type ? ".chr" : ".col");
if (type) if (type)
{ {
memcpy(col_attr, defchars, sizeof(defchars)); memcpy(col_attr, defchars, sizeof(defchars));
@@ -1509,7 +1509,7 @@ uint32_t user_io_8bit_set_status(uint32_t new_status, uint32_t mask)
{ {
static uint32_t status = 0; static uint32_t status = 0;
// if mask is 0 just return the current status // if mask is 0 just return the current status
if (mask) { if (mask) {
// keep everything not masked // keep everything not masked
status &= ~mask; status &= ~mask;
@@ -1624,7 +1624,7 @@ void user_io_poll()
// check for incoming serial data. this is directly forwarded to the // check for incoming serial data. this is directly forwarded to the
// arm rs232 and mixes with debug output. Useful for debugging only of // arm rs232 and mixes with debug output. Useful for debugging only of
// e.g. the diagnostic cartridge // e.g. the diagnostic cartridge
spi_uio_cmd_cont(UIO_SERIAL_IN); spi_uio_cmd_cont(UIO_SERIAL_IN);
while (spi_in()) while (spi_in())
{ {
@@ -1924,7 +1924,7 @@ void user_io_poll()
{ {
unsigned char ps2_mouse[3]; unsigned char ps2_mouse[3];
// PS2 format: // PS2 format:
// YOvfl, XOvfl, dy8, dx8, 1, mbtn, rbtn, lbtn // YOvfl, XOvfl, dy8, dx8, 1, mbtn, rbtn, lbtn
// dx[7:0] // dx[7:0]
// dy[7:0] // dy[7:0]
@@ -2554,7 +2554,7 @@ void user_io_kbd(uint16_t key, int press)
} }
} }
else else
if (key == KEY_MUTE) if (key == KEY_MUTE)
{ {
if (press == 1 && hasAPI1_5()) set_volume(0); if (press == 1 && hasAPI1_5()) set_volume(0);

View File

@@ -48,7 +48,7 @@
#define UIO_SET_SDCONF 0x19 // send SD card configuration (CSD, CID) #define UIO_SET_SDCONF 0x19 // send SD card configuration (CSD, CID)
#define UIO_ASTICK 0x1a #define UIO_ASTICK 0x1a
#define UIO_SIO_IN 0x1b // serial in #define UIO_SIO_IN 0x1b // serial in
#define UIO_SET_SDSTAT 0x1c // set sd card status #define UIO_SET_SDSTAT 0x1c // set sd card status
#define UIO_SET_SDINFO 0x1d // send info about mounted image #define UIO_SET_SDINFO 0x1d // send info about mounted image
#define UIO_SET_STATUS2 0x1e // 32bit status #define UIO_SET_STATUS2 0x1e // 32bit status
#define UIO_GET_KBD_LED 0x1f // keyboard LEDs control #define UIO_GET_KBD_LED 0x1f // keyboard LEDs control
@@ -106,7 +106,7 @@
#define JOY_L3 0x4000 #define JOY_L3 0x4000
#define JOY_R3 0x8000 #define JOY_R3 0x8000
// keyboard LEDs control // keyboard LEDs control
#define KBD_LED_CAPS_CONTROL 0x01 #define KBD_LED_CAPS_CONTROL 0x01
#define KBD_LED_CAPS_STATUS 0x02 #define KBD_LED_CAPS_STATUS 0x02
#define KBD_LED_CAPS_MASK (KBD_LED_CAPS_CONTROL | KBD_LED_CAPS_STATUS) #define KBD_LED_CAPS_MASK (KBD_LED_CAPS_CONTROL | KBD_LED_CAPS_STATUS)
@@ -133,7 +133,7 @@
// core type value should be unlikely to be returned by broken cores // core type value should be unlikely to be returned by broken cores
#define CORE_TYPE_UNKNOWN 0x55 #define CORE_TYPE_UNKNOWN 0x55
#define CORE_TYPE_DUMB 0xa0 // core without any io controller interaction #define CORE_TYPE_DUMB 0xa0 // core without any io controller interaction
#define CORE_TYPE_MIST 0xa3 // mist atari st core #define CORE_TYPE_MIST 0xa3 // mist atari st core
#define CORE_TYPE_8BIT 0xa4 // atari 800/c64 like core #define CORE_TYPE_8BIT 0xa4 // atari 800/c64 like core
#define CORE_TYPE_MINIMIG2 0xa5 // new Minimig with AGA #define CORE_TYPE_MINIMIG2 0xa5 // new Minimig with AGA
#define CORE_TYPE_ARCHIE 0xa6 // Acorn Archimedes #define CORE_TYPE_ARCHIE 0xa6 // Acorn Archimedes
@@ -163,7 +163,7 @@
#define UIO_PARITY_MARK 3 #define UIO_PARITY_MARK 3
#define UIO_PARITY_SPACE 4 #define UIO_PARITY_SPACE 4
#define UIO_PRIORITY_KEYBOARD 0 #define UIO_PRIORITY_KEYBOARD 0
#define UIO_PRIORITY_GAMEPAD 1 #define UIO_PRIORITY_GAMEPAD 1
#define EMU_NONE 0 #define EMU_NONE 0
@@ -171,7 +171,7 @@
#define EMU_JOY0 2 #define EMU_JOY0 2
#define EMU_JOY1 3 #define EMU_JOY1 3
// serial status data type returned from the core // serial status data type returned from the core
typedef struct { typedef struct {
uint32_t bitrate; // 300, 600 ... 115200 uint32_t bitrate; // 300, 600 ... 115200
uint8_t datasize; // 5,6,7,8 ... uint8_t datasize; // 5,6,7,8 ...

View File

@@ -7,10 +7,10 @@
#include <errno.h> #include <errno.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/vt.h> #include <linux/vt.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include "hardware.h" #include "hardware.h"
#include "user_io.h" #include "user_io.h"
@@ -846,7 +846,7 @@ static void vs_wait()
close(fb); close(fb);
return; return;
} }
t1 = getus(); t1 = getus();
ioctl(fb, FBIO_WAITFORVSYNC, &zero); ioctl(fb, FBIO_WAITFORVSYNC, &zero);
t2 = getus(); t2 = getus();