From f056480a07b4f9f065cb9680cd1d14098bcaaf82 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Sat, 29 Jun 2019 00:57:18 +0800 Subject: [PATCH] Normalize line endings, remove trailing spaces. --- DiskImage.cpp | 2 +- DiskImage.h | 8 +- battery.cpp | 26 +- bootcore.cpp | 20 +- brightness.cpp | 32 +- charrom.cpp | 2 +- cheats.cpp | 4 +- file_io.cpp | 2 +- fpga_io.cpp | 2 +- input.cpp | 1498 +++++++++--------- input.h | 2 +- lib/miniz/miniz.h | 4 +- lib/miniz/miniz_zip.c | 6 +- main.cpp | 2 +- menu.cpp | 30 +- scaler.cpp | 20 +- scaler.h | 2 +- support/archie/archie.cpp | 2 +- support/minimig/minimig_boot.cpp | 2 +- support/minimig/minimig_boot.h | 2 +- support/minimig/minimig_config.cpp | 2 +- support/minimig/minimig_fdd.cpp | 2 +- support/minimig/minimig_hdd.cpp | 2 +- support/minimig/minimig_hdd.h | 2 +- support/sharpmz/sharpmz.cpp | 222 +-- support/sharpmz/sharpmz.h | 22 +- support/snes/snes.cpp | 2 +- support/st/st_ikbd.cpp | 2 +- support/st/st_tos.cpp | 2314 ++++++++++++++-------------- support/x86/x86.cpp | 16 +- support/x86/x86.h | 2 +- sxmlc.c | 200 +-- sxmlc.h | 4 +- user_io.cpp | 14 +- user_io.h | 10 +- video.cpp | 10 +- 36 files changed, 2247 insertions(+), 2247 deletions(-) diff --git a/DiskImage.cpp b/DiskImage.cpp index 35caab5..164a1e0 100644 --- a/DiskImage.cpp +++ b/DiskImage.cpp @@ -2084,7 +2084,7 @@ void TDiskImage::readSCL(int hfile, bool readonly) for (i = 0; i < FileCount; i++) { if (TRK >= (MaxTrack + 1)*(MaxSide + 1)) break; // disk full ? - + memcpy(&trdosde, fileinfo[i], 14); trdosde.FirstSec = SEC; diff --git a/DiskImage.h b/DiskImage.h index 8feae4a..e2ee29e 100644 --- a/DiskImage.h +++ b/DiskImage.h @@ -70,10 +70,10 @@ public: bool FindTrack(unsigned char CYL, unsigned char SIDE, VGFIND_TRACK *vgft); bool FindADMark(unsigned char CYL, unsigned char SIDE, - unsigned int FromOffset, + unsigned int FromOffset, VGFIND_ADM *vgfa); bool FindSector(unsigned char CYL, unsigned char SIDE, - unsigned char SECT, + unsigned char SECT, VGFIND_SECTOR *vgfs, unsigned int FromOffset=0); void ApplySectorCRC(VGFIND_SECTOR vgfs); @@ -123,7 +123,7 @@ struct TD0_MAIN_HEADER // 12 bytes struct TD0_INFO_DATA // 10 байт без строки коментария... { unsigned short CRC; // +0: CRC для структуры COMMENT_DATA (без байтов CRC) - unsigned short strLen; // +2: Длина строки коментария + unsigned short strLen; // +2: Длина строки коментария unsigned char Year; // +4: Дата создания - год (1900 + X) unsigned char Month; // +5: Дата создания - месяц (Январь=0, Февраль=1,...) unsigned char Day; // +6: Дата создания - число @@ -146,7 +146,7 @@ struct TD0_SECT_HEADER // 8 bytes unsigned short DataLength; }; -struct FDD_MAIN_HEADER +struct FDD_MAIN_HEADER { char ID[30]; /* сигнатура */ unsigned char MaxTracks; /* число треков (цилиндров) */ diff --git a/battery.cpp b/battery.cpp index 8041aa8..cc17b52 100644 --- a/battery.cpp +++ b/battery.cpp @@ -3,25 +3,25 @@ * battery.c * display pi-top battery status * - * Copyright 2016, 2017 rricharz + * Copyright 2016, 2017 rricharz * MiSTer port. Copyright 2018 Sorgelig - * + * * 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 * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ #include @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include "battery.h" #define MAX_COUNT 20 // Maximum number of trials @@ -52,7 +52,7 @@ #define I2C_SMBUS_QUICK 0 #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_PROC_CALL 4 #define I2C_SMBUS_BLOCK_DATA 5 @@ -62,7 +62,7 @@ // 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 */ // Structures used in the ioctl() calls @@ -82,7 +82,7 @@ struct i2c_smbus_ioctl_data 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.data = data; return ioctl (fd, I2C_SMBUS, &args); -} +} static int i2c_smbus_write_quick(int fd, uint8_t value) { @@ -129,7 +129,7 @@ static int smbus_open(int dev_address) close(fd); return 0; } - + i2c_handle = fd; } return 1; @@ -161,7 +161,7 @@ static int getReg(int reg, int min, int max) { 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); } diff --git a/bootcore.cpp b/bootcore.cpp index 8cc5d29..49bc447 100644 --- a/bootcore.cpp +++ b/bootcore.cpp @@ -96,7 +96,7 @@ char* loadLastcore() sprintf(full_path, "%s/%s", getRootDir(), path); FILE *fd = fopen(full_path, "r"); if (!fd) - { + { return NULL; } fseek(fd, 0L, SEEK_END); @@ -113,7 +113,7 @@ char* loadLastcore() } delete[] lastcore; return NULL; - + } 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, '.'); if (spl && !strcmp(spl, ".rbf")) { - closedir(dir); + closedir(dir); return path; } } @@ -161,7 +161,7 @@ char *findCore(const char *name, char *coreName, int indent) } void bootcore_init(const char *path) -{ +{ char *auxpointer; char auxstr[256]; char bootcore[256]; @@ -170,9 +170,9 @@ void bootcore_init(const char *path) cfg.bootcore_timeout = cfg.bootcore_timeout * 10; btimeout = cfg.bootcore_timeout; strcpy(bootcore, cfg.bootcore); - + is_lastcore = (!strcmp(cfg.bootcore, "lastcore") || !strcmp(cfg.bootcore, "lastexactcore")); - + if (is_lastcore) { strcpy(bootcoretype, cfg.bootcore); @@ -187,7 +187,7 @@ void bootcore_init(const char *path) { strcpy(bootcoretype, isExactcoreName(cfg.bootcore) ? "exactcorename" : "corename"); } - + auxpointer = findCore(rootdir, bootcore, 0); if (auxpointer != NULL) { @@ -207,7 +207,7 @@ void bootcore_init(const char *path) { fpga_load_rbf(bootcore); } - + strcpy(cfg.bootcore, strcmp(bootcore, "menu.rbf") ? bootcore : ""); return; } @@ -216,7 +216,7 @@ void bootcore_init(const char *path) if (is_lastcore && path[0] != '\0') { - + strcpy(auxstr, path); auxpointer = !strcmp(cfg.bootcore, "lastexactcore") ? getcoreExactName(auxstr) : getcoreName(auxstr); @@ -229,6 +229,6 @@ void bootcore_init(const char *path) } } strcpy(cfg.bootcore, ""); - + } diff --git a/brightness.cpp b/brightness.cpp index 74e4df9..17e2763 100644 --- a/brightness.cpp +++ b/brightness.cpp @@ -1,6 +1,6 @@ /* * brightness.c - * + * * Copyright 2016 rricharz * MiSTer port. Copyright 2018 Sorgelig * @@ -8,18 +8,18 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. - * - * + * + * */ #include @@ -101,7 +101,7 @@ static int spi_open(int speed, int mode) { printf ("SPI Mode Change failure: %s\n", strerror (errno)); } - + close(fd); fd = -1; return -1; @@ -145,9 +145,9 @@ static int analyze(unsigned char data) parity = (data & PARITYMASK) != 0; brightness = (data & BRIGHTNESSMASK) >> 3; shutdown = (data & SHUTDOWNMASK) != 0; - + // printf("lid = %d, screen = %d, parity = %d, shutdown = %d, brightness = %d\n", lidbit, screenoffbit, parity, shutdown, brightness); - + return (parity7(data) == parity); } @@ -162,20 +162,20 @@ static int calculate() if (shutdown) data += SHUTDOWNMASK; if (screenoffbit) data += SCREENOFFMASK; if (parity7(data & 3)) data += LIDBITMASK; // parity ofthe two state bits - return data; + return data; } void setBrightness(int cmd, int val) { unsigned char data, new_data; int count, ok; - + if (spi_open(9600, 0) < 0) { printf("Cannot initialize spi driver\n"); return; } - + // send 0xFF and receive current status of pi-top-hub count = 0; data = 0xff; @@ -188,7 +188,7 @@ void setBrightness(int cmd, int val) } while ((!ok) && (count++ < MAXCOUNT)); // printf("count = %d\n", count); - + if (ok) { 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 //the state is stored on pi-top-hub, but isn't reinitialised on reboot screenoffbit=0; - if(cmd == BRIGHTNESS_UP) + if(cmd == BRIGHTNESS_UP) { brightness++; } @@ -216,11 +216,11 @@ void setBrightness(int cmd, int val) printf("Requested brightness = %d, ", brightness); printf("Requested off = %d\n", screenoffbit); - + // calculate data to send - shutdown = 0; + shutdown = 0; new_data = calculate(); - + // send new data until accepted count = 0; data = new_data; diff --git a/charrom.cpp b/charrom.cpp index 0f21717..53b1b90 100644 --- a/charrom.cpp +++ b/charrom.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include diff --git a/cheats.cpp b/cheats.cpp index be4e2cf..a47566f 100644 --- a/cheats.cpp +++ b/cheats.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -247,7 +247,7 @@ void cheats_scroll_name() name[1] = cheats[iSelectedEntry].enabled ? 0x1a : 0x1b; name[2] = 32; strcpy(name + 3, cheats[iSelectedEntry].name); - + len = strlen(name); // get name length if (len > 3 && !strncasecmp(name + len - 3, ".gg", 3)) len -= 3; diff --git a/file_io.cpp b/file_io.cpp index c5e2786..184c4f1 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -1038,7 +1038,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons de = &_de; } 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) { sprintf(full_path+path_len, "/%s", de->d_name); diff --git a/fpga_io.cpp b/fpga_io.cpp index b2c094a..d0ca54d 100644 --- a/fpga_io.cpp +++ b/fpga_io.cpp @@ -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) { unsigned long i; diff --git a/input.cpp b/input.cpp index e4434a4..21d8101 100644 --- a/input.cpp +++ b/input.cpp @@ -31,783 +31,783 @@ static int ev2amiga[] = { - NONE, //0 KEY_RESERVED - 0x45, //1 KEY_ESC - 0x01, //2 KEY_1 - 0x02, //3 KEY_2 - 0x03, //4 KEY_3 - 0x04, //5 KEY_4 - 0x05, //6 KEY_5 - 0x06, //7 KEY_6 - 0x07, //8 KEY_7 - 0x08, //9 KEY_8 - 0x09, //10 KEY_9 - 0x0a, //11 KEY_0 - 0x0b, //12 KEY_MINUS - 0x0c, //13 KEY_EQUAL - 0x41, //14 KEY_BACKSPACE - 0x42, //15 KEY_TAB - 0x10, //16 KEY_Q - 0x11, //17 KEY_W - 0x12, //18 KEY_E - 0x13, //19 KEY_R - 0x14, //20 KEY_T - 0x15, //21 KEY_Y - 0x16, //22 KEY_U - 0x17, //23 KEY_I - 0x18, //24 KEY_O - 0x19, //25 KEY_P - 0x1a, //26 KEY_LEFTBRACE - 0x1b, //27 KEY_RIGHTBRACE - 0x44, //28 KEY_ENTER - 0x63, //29 KEY_LEFTCTRL - 0x20, //30 KEY_A - 0x21, //31 KEY_S - 0x22, //32 KEY_D - 0x23, //33 KEY_F - 0x24, //34 KEY_G - 0x25, //35 KEY_H - 0x26, //36 KEY_J - 0x27, //37 KEY_K - 0x28, //38 KEY_L - 0x29, //39 KEY_SEMICOLON - 0x2a, //40 KEY_APOSTROPHE - 0x00, //41 KEY_GRAVE - 0x60, //42 KEY_LEFTSHIFT - 0x0d, //43 KEY_BACKSLASH - 0x31, //44 KEY_Z - 0x32, //45 KEY_X - 0x33, //46 KEY_C - 0x34, //47 KEY_V - 0x35, //48 KEY_B - 0x36, //49 KEY_N - 0x37, //50 KEY_M - 0x38, //51 KEY_COMMA - 0x39, //52 KEY_DOT - 0x3a, //53 KEY_SLASH - 0x61, //54 KEY_RIGHTSHIFT - 0x5d, //55 KEY_KPASTERISK - 0x64, //56 KEY_LEFTALT - 0x40, //57 KEY_SPACE - 0x62 | CAPS_TOGGLE, //58 KEY_CAPSLOCK - 0x50, //59 KEY_F1 - 0x51, //60 KEY_F2 - 0x52, //61 KEY_F3 - 0x53, //62 KEY_F4 - 0x54, //63 KEY_F5 - 0x55, //64 KEY_F6 - 0x56, //65 KEY_F7 - 0x57, //66 KEY_F8 - 0x58, //67 KEY_F9 - 0x59, //68 KEY_F10 - NONE, //69 KEY_NUMLOCK - NONE, //70 KEY_SCROLLLOCK - 0x3d, //71 KEY_KP7 - 0x3e, //72 KEY_KP8 - 0x3f, //73 KEY_KP9 - 0x4a, //74 KEY_KPMINUS - 0x2d, //75 KEY_KP4 - 0x2e, //76 KEY_KP5 - 0x2f, //77 KEY_KP6 - 0x5e, //78 KEY_KPPLUS - 0x1d, //79 KEY_KP1 - 0x1e, //80 KEY_KP2 - 0x1f, //81 KEY_KP3 - 0x0f, //82 KEY_KP0 - 0x3c, //83 KEY_KPDOT - NONE, //84 ??? - NONE, //85 KEY_ZENKAKU + NONE, //0 KEY_RESERVED + 0x45, //1 KEY_ESC + 0x01, //2 KEY_1 + 0x02, //3 KEY_2 + 0x03, //4 KEY_3 + 0x04, //5 KEY_4 + 0x05, //6 KEY_5 + 0x06, //7 KEY_6 + 0x07, //8 KEY_7 + 0x08, //9 KEY_8 + 0x09, //10 KEY_9 + 0x0a, //11 KEY_0 + 0x0b, //12 KEY_MINUS + 0x0c, //13 KEY_EQUAL + 0x41, //14 KEY_BACKSPACE + 0x42, //15 KEY_TAB + 0x10, //16 KEY_Q + 0x11, //17 KEY_W + 0x12, //18 KEY_E + 0x13, //19 KEY_R + 0x14, //20 KEY_T + 0x15, //21 KEY_Y + 0x16, //22 KEY_U + 0x17, //23 KEY_I + 0x18, //24 KEY_O + 0x19, //25 KEY_P + 0x1a, //26 KEY_LEFTBRACE + 0x1b, //27 KEY_RIGHTBRACE + 0x44, //28 KEY_ENTER + 0x63, //29 KEY_LEFTCTRL + 0x20, //30 KEY_A + 0x21, //31 KEY_S + 0x22, //32 KEY_D + 0x23, //33 KEY_F + 0x24, //34 KEY_G + 0x25, //35 KEY_H + 0x26, //36 KEY_J + 0x27, //37 KEY_K + 0x28, //38 KEY_L + 0x29, //39 KEY_SEMICOLON + 0x2a, //40 KEY_APOSTROPHE + 0x00, //41 KEY_GRAVE + 0x60, //42 KEY_LEFTSHIFT + 0x0d, //43 KEY_BACKSLASH + 0x31, //44 KEY_Z + 0x32, //45 KEY_X + 0x33, //46 KEY_C + 0x34, //47 KEY_V + 0x35, //48 KEY_B + 0x36, //49 KEY_N + 0x37, //50 KEY_M + 0x38, //51 KEY_COMMA + 0x39, //52 KEY_DOT + 0x3a, //53 KEY_SLASH + 0x61, //54 KEY_RIGHTSHIFT + 0x5d, //55 KEY_KPASTERISK + 0x64, //56 KEY_LEFTALT + 0x40, //57 KEY_SPACE + 0x62 | CAPS_TOGGLE, //58 KEY_CAPSLOCK + 0x50, //59 KEY_F1 + 0x51, //60 KEY_F2 + 0x52, //61 KEY_F3 + 0x53, //62 KEY_F4 + 0x54, //63 KEY_F5 + 0x55, //64 KEY_F6 + 0x56, //65 KEY_F7 + 0x57, //66 KEY_F8 + 0x58, //67 KEY_F9 + 0x59, //68 KEY_F10 + NONE, //69 KEY_NUMLOCK + NONE, //70 KEY_SCROLLLOCK + 0x3d, //71 KEY_KP7 + 0x3e, //72 KEY_KP8 + 0x3f, //73 KEY_KP9 + 0x4a, //74 KEY_KPMINUS + 0x2d, //75 KEY_KP4 + 0x2e, //76 KEY_KP5 + 0x2f, //77 KEY_KP6 + 0x5e, //78 KEY_KPPLUS + 0x1d, //79 KEY_KP1 + 0x1e, //80 KEY_KP2 + 0x1f, //81 KEY_KP3 + 0x0f, //82 KEY_KP0 + 0x3c, //83 KEY_KPDOT + NONE, //84 ??? + NONE, //85 KEY_ZENKAKU 0x30, //86 KEY_102ND, '<' on most keyboards - 0x5f, //87 KEY_F11 - NONE, //88 KEY_F12 - NONE, //89 KEY_RO - NONE, //90 KEY_KATAKANA - NONE, //91 KEY_HIRAGANA - NONE, //92 KEY_HENKAN - NONE, //93 KEY_KATAKANA - NONE, //94 KEY_MUHENKAN - NONE, //95 KEY_KPJPCOMMA - 0x43, //96 KEY_KPENTER - 0x63, //97 KEY_RIGHTCTRL - 0x5c, //98 KEY_KPSLASH - NONE, //99 KEY_SYSRQ - 0x65, //100 KEY_RIGHTALT - NONE, //101 KEY_LINEFEED - 0x6a, //102 KEY_HOME - 0x4c, //103 KEY_UP + 0x5f, //87 KEY_F11 + NONE, //88 KEY_F12 + NONE, //89 KEY_RO + NONE, //90 KEY_KATAKANA + NONE, //91 KEY_HIRAGANA + NONE, //92 KEY_HENKAN + NONE, //93 KEY_KATAKANA + NONE, //94 KEY_MUHENKAN + NONE, //95 KEY_KPJPCOMMA + 0x43, //96 KEY_KPENTER + 0x63, //97 KEY_RIGHTCTRL + 0x5c, //98 KEY_KPSLASH + NONE, //99 KEY_SYSRQ + 0x65, //100 KEY_RIGHTALT + NONE, //101 KEY_LINEFEED + 0x6a, //102 KEY_HOME + 0x4c, //103 KEY_UP 0x5b, //104 KEY_PAGEUP - 0x4f, //105 KEY_LEFT - 0x4e, //106 KEY_RIGHT - NONE, //107 KEY_END - 0x4d, //108 KEY_DOWN + 0x4f, //105 KEY_LEFT + 0x4e, //106 KEY_RIGHT + NONE, //107 KEY_END + 0x4d, //108 KEY_DOWN 0x5a, //109 KEY_PAGEDOWN - 0x0d, //110 KEY_INSERT - 0x46, //111 KEY_DELETE - NONE, //112 KEY_MACRO - NONE, //113 KEY_MUTE - NONE, //114 KEY_VOLUMEDOWN - NONE, //115 KEY_VOLUMEUP - NONE, //116 KEY_POWER - NONE, //117 KEY_KPEQUAL - NONE, //118 KEY_KPPLUSMINUS - NONE, //119 KEY_PAUSE - NONE, //120 KEY_SCALE - NONE, //121 KEY_KPCOMMA - NONE, //122 KEY_HANGEUL - NONE, //123 KEY_HANJA - NONE, //124 KEY_YEN - 0x66, //125 KEY_LEFTMETA - 0x67, //126 KEY_RIGHTMETA - NONE, //127 KEY_COMPOSE - NONE, //128 KEY_STOP - NONE, //129 KEY_AGAIN - NONE, //130 KEY_PROPS - NONE, //131 KEY_UNDO - NONE, //132 KEY_FRONT - NONE, //133 KEY_COPY - NONE, //134 KEY_OPEN - NONE, //135 KEY_PASTE - NONE, //136 KEY_FIND - NONE, //137 KEY_CUT - NONE, //138 KEY_HELP - NONE, //139 KEY_MENU - NONE, //140 KEY_CALC - NONE, //141 KEY_SETUP - NONE, //142 KEY_SLEEP - NONE, //143 KEY_WAKEUP - NONE, //144 KEY_FILE - NONE, //145 KEY_SENDFILE - NONE, //146 KEY_DELETEFILE - NONE, //147 KEY_XFER - NONE, //148 KEY_PROG1 - NONE, //149 KEY_PROG2 - NONE, //150 KEY_WWW - NONE, //151 KEY_MSDOS - NONE, //152 KEY_SCREENLOCK - NONE, //153 KEY_DIRECTION + 0x0d, //110 KEY_INSERT + 0x46, //111 KEY_DELETE + NONE, //112 KEY_MACRO + NONE, //113 KEY_MUTE + NONE, //114 KEY_VOLUMEDOWN + NONE, //115 KEY_VOLUMEUP + NONE, //116 KEY_POWER + NONE, //117 KEY_KPEQUAL + NONE, //118 KEY_KPPLUSMINUS + NONE, //119 KEY_PAUSE + NONE, //120 KEY_SCALE + NONE, //121 KEY_KPCOMMA + NONE, //122 KEY_HANGEUL + NONE, //123 KEY_HANJA + NONE, //124 KEY_YEN + 0x66, //125 KEY_LEFTMETA + 0x67, //126 KEY_RIGHTMETA + NONE, //127 KEY_COMPOSE + NONE, //128 KEY_STOP + NONE, //129 KEY_AGAIN + NONE, //130 KEY_PROPS + NONE, //131 KEY_UNDO + NONE, //132 KEY_FRONT + NONE, //133 KEY_COPY + NONE, //134 KEY_OPEN + NONE, //135 KEY_PASTE + NONE, //136 KEY_FIND + NONE, //137 KEY_CUT + NONE, //138 KEY_HELP + NONE, //139 KEY_MENU + NONE, //140 KEY_CALC + NONE, //141 KEY_SETUP + NONE, //142 KEY_SLEEP + NONE, //143 KEY_WAKEUP + NONE, //144 KEY_FILE + NONE, //145 KEY_SENDFILE + NONE, //146 KEY_DELETEFILE + NONE, //147 KEY_XFER + NONE, //148 KEY_PROG1 + NONE, //149 KEY_PROG2 + NONE, //150 KEY_WWW + NONE, //151 KEY_MSDOS + NONE, //152 KEY_SCREENLOCK + NONE, //153 KEY_DIRECTION NONE, //154 KEY_CYCLEWINDOWS - NONE, //155 KEY_MAIL - NONE, //156 KEY_BOOKMARKS - NONE, //157 KEY_COMPUTER - NONE, //158 KEY_BACK - NONE, //159 KEY_FORWARD - NONE, //160 KEY_CLOSECD - NONE, //161 KEY_EJECTCD + NONE, //155 KEY_MAIL + NONE, //156 KEY_BOOKMARKS + NONE, //157 KEY_COMPUTER + NONE, //158 KEY_BACK + NONE, //159 KEY_FORWARD + NONE, //160 KEY_CLOSECD + NONE, //161 KEY_EJECTCD NONE, //162 KEY_EJECTCLOSECD - NONE, //163 KEY_NEXTSONG - NONE, //164 KEY_PLAYPAUSE + NONE, //163 KEY_NEXTSONG + NONE, //164 KEY_PLAYPAUSE NONE, //165 KEY_PREVIOUSSONG - NONE, //166 KEY_STOPCD - NONE, //167 KEY_RECORD - NONE, //168 KEY_REWIND - NONE, //169 KEY_PHONE - NONE, //170 KEY_ISO - NONE, //171 KEY_CONFIG - NONE, //172 KEY_HOMEPAGE - NONE, //173 KEY_REFRESH - NONE, //174 KEY_EXIT - NONE, //175 KEY_MOVE - NONE, //176 KEY_EDIT - NONE, //177 KEY_SCROLLUP - NONE, //178 KEY_SCROLLDOWN - NONE, //179 KEY_KPLEFTPAREN + NONE, //166 KEY_STOPCD + NONE, //167 KEY_RECORD + NONE, //168 KEY_REWIND + NONE, //169 KEY_PHONE + NONE, //170 KEY_ISO + NONE, //171 KEY_CONFIG + NONE, //172 KEY_HOMEPAGE + NONE, //173 KEY_REFRESH + NONE, //174 KEY_EXIT + NONE, //175 KEY_MOVE + NONE, //176 KEY_EDIT + NONE, //177 KEY_SCROLLUP + NONE, //178 KEY_SCROLLDOWN + NONE, //179 KEY_KPLEFTPAREN NONE, //180 KEY_KPRIGHTPAREN - NONE, //181 KEY_NEW - NONE, //182 KEY_REDO - 0x5a, //183 KEY_F13 - 0x5b, //184 KEY_F14 - NONE, //185 KEY_F15 - 0x5f, //186 KEY_F16 - NONE, //187 KEY_F17 - NONE, //188 KEY_F18 - NONE, //189 KEY_F19 - NONE, //190 KEY_F20 - NONE, //191 KEY_F21 - NONE, //192 KEY_F22 - NONE, //193 KEY_F23 + NONE, //181 KEY_NEW + NONE, //182 KEY_REDO + 0x5a, //183 KEY_F13 + 0x5b, //184 KEY_F14 + NONE, //185 KEY_F15 + 0x5f, //186 KEY_F16 + NONE, //187 KEY_F17 + NONE, //188 KEY_F18 + NONE, //189 KEY_F19 + NONE, //190 KEY_F20 + NONE, //191 KEY_F21 + NONE, //192 KEY_F22 + NONE, //193 KEY_F23 0x2b, //194 # on German keyboard, was 0x63 (CTRL on Amiga), 194 KEY_F24 - NONE, //195 ??? - NONE, //196 ??? - NONE, //197 ??? - NONE, //198 ??? - NONE, //199 ??? - NONE, //200 KEY_PLAYCD - NONE, //201 KEY_PAUSECD - NONE, //202 KEY_PROG3 - NONE, //203 KEY_PROG4 - NONE, //204 KEY_DASHBOARD - NONE, //205 KEY_SUSPEND - NONE, //206 KEY_CLOSE - NONE, //207 KEY_PLAY - NONE, //208 KEY_FASTFORWARD - NONE, //209 KEY_BASSBOOST - NONE, //210 KEY_PRINT - NONE, //211 KEY_HP - NONE, //212 KEY_CAMERA - NONE, //213 KEY_SOUND - NONE, //214 KEY_QUESTION - NONE, //215 KEY_EMAIL - NONE, //216 KEY_CHAT - NONE, //217 KEY_SEARCH - NONE, //218 KEY_CONNECT - NONE, //219 KEY_FINANCE - NONE, //220 KEY_SPORT - NONE, //221 KEY_SHOP - NONE, //222 KEY_ALTERASE - NONE, //223 KEY_CANCEL - NONE, //224 KEY_BRIGHT_DOWN - NONE, //225 KEY_BRIGHT_UP - NONE, //226 KEY_MEDIA - NONE, //227 KEY_SWITCHVIDEO + NONE, //195 ??? + NONE, //196 ??? + NONE, //197 ??? + NONE, //198 ??? + NONE, //199 ??? + NONE, //200 KEY_PLAYCD + NONE, //201 KEY_PAUSECD + NONE, //202 KEY_PROG3 + NONE, //203 KEY_PROG4 + NONE, //204 KEY_DASHBOARD + NONE, //205 KEY_SUSPEND + NONE, //206 KEY_CLOSE + NONE, //207 KEY_PLAY + NONE, //208 KEY_FASTFORWARD + NONE, //209 KEY_BASSBOOST + NONE, //210 KEY_PRINT + NONE, //211 KEY_HP + NONE, //212 KEY_CAMERA + NONE, //213 KEY_SOUND + NONE, //214 KEY_QUESTION + NONE, //215 KEY_EMAIL + NONE, //216 KEY_CHAT + NONE, //217 KEY_SEARCH + NONE, //218 KEY_CONNECT + NONE, //219 KEY_FINANCE + NONE, //220 KEY_SPORT + NONE, //221 KEY_SHOP + NONE, //222 KEY_ALTERASE + NONE, //223 KEY_CANCEL + NONE, //224 KEY_BRIGHT_DOWN + NONE, //225 KEY_BRIGHT_UP + NONE, //226 KEY_MEDIA + NONE, //227 KEY_SWITCHVIDEO NONE, //228 KEY_DILLUMTOGGLE - NONE, //229 KEY_DILLUMDOWN - NONE, //230 KEY_DILLUMUP - NONE, //231 KEY_SEND - NONE, //232 KEY_REPLY - NONE, //233 KEY_FORWARDMAIL - NONE, //234 KEY_SAVE - NONE, //235 KEY_DOCUMENTS - NONE, //236 KEY_BATTERY - NONE, //237 KEY_BLUETOOTH - NONE, //238 KEY_WLAN - NONE, //239 KEY_UWB - NONE, //240 KEY_UNKNOWN - NONE, //241 KEY_VIDEO_NEXT - NONE, //242 KEY_VIDEO_PREV + NONE, //229 KEY_DILLUMDOWN + NONE, //230 KEY_DILLUMUP + NONE, //231 KEY_SEND + NONE, //232 KEY_REPLY + NONE, //233 KEY_FORWARDMAIL + NONE, //234 KEY_SAVE + NONE, //235 KEY_DOCUMENTS + NONE, //236 KEY_BATTERY + NONE, //237 KEY_BLUETOOTH + NONE, //238 KEY_WLAN + NONE, //239 KEY_UWB + NONE, //240 KEY_UNKNOWN + NONE, //241 KEY_VIDEO_NEXT + NONE, //242 KEY_VIDEO_PREV NONE, //243 KEY_BRIGHT_CYCLE - NONE, //244 KEY_BRIGHT_AUTO - NONE, //245 KEY_DISPLAY_OFF - NONE, //246 KEY_WWAN - NONE, //247 KEY_RFKILL - NONE, //248 KEY_MICMUTE - NONE, //249 ??? - NONE, //250 ??? - NONE, //251 ??? - NONE, //252 ??? - NONE, //253 ??? - NONE, //254 ??? - NONE //255 ??? + NONE, //244 KEY_BRIGHT_AUTO + NONE, //245 KEY_DISPLAY_OFF + NONE, //246 KEY_WWAN + NONE, //247 KEY_RFKILL + NONE, //248 KEY_MICMUTE + NONE, //249 ??? + NONE, //250 ??? + NONE, //251 ??? + NONE, //252 ??? + NONE, //253 ??? + NONE, //254 ??? + NONE //255 ??? }; static const int ev2ps2[] = { - NONE, //0 KEY_RESERVED - 0x76, //1 KEY_ESC - 0x16, //2 KEY_1 - 0x1e, //3 KEY_2 - 0x26, //4 KEY_3 - 0x25, //5 KEY_4 - 0x2e, //6 KEY_5 - 0x36, //7 KEY_6 - 0x3d, //8 KEY_7 - 0x3e, //9 KEY_8 - 0x46, //10 KEY_9 - 0x45, //11 KEY_0 - 0x4e, //12 KEY_MINUS - 0x55, //13 KEY_EQUAL - 0x66, //14 KEY_BACKSPACE - 0x0d, //15 KEY_TAB - 0x15, //16 KEY_Q - 0x1d, //17 KEY_W - 0x24, //18 KEY_E - 0x2d, //19 KEY_R - 0x2c, //20 KEY_T - 0x35, //21 KEY_Y - 0x3c, //22 KEY_U - 0x43, //23 KEY_I - 0x44, //24 KEY_O - 0x4d, //25 KEY_P - 0x54, //26 KEY_LEFTBRACE - 0x5b, //27 KEY_RIGHTBRACE - 0x5a, //28 KEY_ENTER - LCTRL | 0x14, //29 KEY_LEFTCTRL - 0x1c, //30 KEY_A - 0x1b, //31 KEY_S - 0x23, //32 KEY_D - 0x2b, //33 KEY_F - 0x34, //34 KEY_G - 0x33, //35 KEY_H - 0x3b, //36 KEY_J - 0x42, //37 KEY_K - 0x4b, //38 KEY_L - 0x4c, //39 KEY_SEMICOLON - 0x52, //40 KEY_APOSTROPHE - 0x0e, //41 KEY_GRAVE - LSHIFT | 0x12, //42 KEY_LEFTSHIFT - 0x5d, //43 KEY_BACKSLASH - 0x1a, //44 KEY_Z - 0x22, //45 KEY_X - 0x21, //46 KEY_C - 0x2a, //47 KEY_V - 0x32, //48 KEY_B - 0x31, //49 KEY_N - 0x3a, //50 KEY_M - 0x41, //51 KEY_COMMA - 0x49, //52 KEY_DOT - 0x4a, //53 KEY_SLASH - RSHIFT | 0x59, //54 KEY_RIGHTSHIFT - 0x7c, //55 KEY_KPASTERISK - LALT | 0x11, //56 KEY_LEFTALT - 0x29, //57 KEY_SPACE - 0x58, //58 KEY_CAPSLOCK - 0x05, //59 KEY_F1 - 0x06, //60 KEY_F2 - 0x04, //61 KEY_F3 - 0x0c, //62 KEY_F4 - 0x03, //63 KEY_F5 - 0x0b, //64 KEY_F6 - 0x83, //65 KEY_F7 - 0x0a, //66 KEY_F8 - 0x01, //67 KEY_F9 - 0x09, //68 KEY_F10 - EMU_SWITCH_2 | 0x77, //69 KEY_NUMLOCK - EMU_SWITCH_1 | 0x7E, //70 KEY_SCROLLLOCK - 0x6c, //71 KEY_KP7 - 0x75, //72 KEY_KP8 - 0x7d, //73 KEY_KP9 - 0x7b, //74 KEY_KPMINUS - 0x6b, //75 KEY_KP4 - 0x73, //76 KEY_KP5 - 0x74, //77 KEY_KP6 - 0x79, //78 KEY_KPPLUS - 0x69, //79 KEY_KP1 - 0x72, //80 KEY_KP2 - 0x7a, //81 KEY_KP3 - 0x70, //82 KEY_KP0 - 0x71, //83 KEY_KPDOT - NONE, //84 ??? - NONE, //85 KEY_ZENKAKU - NONE, //86 KEY_102ND - 0x78, //87 KEY_F11 - 0x07, //88 KEY_F12 - NONE, //89 KEY_RO - NONE, //90 KEY_KATAKANA - NONE, //91 KEY_HIRAGANA - NONE, //92 KEY_HENKAN - NONE, //93 KEY_KATAKANA - NONE, //94 KEY_MUHENKAN - NONE, //95 KEY_KPJPCOMMA - EXT | 0x5a, //96 KEY_KPENTER - RCTRL | EXT | 0x14, //97 KEY_RIGHTCTRL - EXT | 0x4a, //98 KEY_KPSLASH - 0xE2, //99 KEY_SYSRQ - RALT | EXT | 0x11, //100 KEY_RIGHTALT - NONE, //101 KEY_LINEFEED - EXT | 0x6c, //102 KEY_HOME - EXT | 0x75, //103 KEY_UP - EXT | 0x7d, //104 KEY_PAGEUP - EXT | 0x6b, //105 KEY_LEFT - EXT | 0x74, //106 KEY_RIGHT - EXT | 0x69, //107 KEY_END - EXT | 0x72, //108 KEY_DOWN - EXT | 0x7a, //109 KEY_PAGEDOWN - EXT | 0x70, //110 KEY_INSERT - EXT | 0x71, //111 KEY_DELETE - NONE, //112 KEY_MACRO - NONE, //113 KEY_MUTE - NONE, //114 KEY_VOLUMEDOWN - NONE, //115 KEY_VOLUMEUP - NONE, //116 KEY_POWER - NONE, //117 KEY_KPEQUAL - NONE, //118 KEY_KPPLUSMINUS - 0xE1, //119 KEY_PAUSE - NONE, //120 KEY_SCALE - NONE, //121 KEY_KPCOMMA - NONE, //122 KEY_HANGEUL - NONE, //123 KEY_HANJA - NONE, //124 KEY_YEN - LGUI | EXT | 0x1f, //125 KEY_LEFTMETA - RGUI | EXT | 0x27, //126 KEY_RIGHTMETA - NONE, //127 KEY_COMPOSE - NONE, //128 KEY_STOP - NONE, //129 KEY_AGAIN - NONE, //130 KEY_PROPS - NONE, //131 KEY_UNDO - NONE, //132 KEY_FRONT - NONE, //133 KEY_COPY - NONE, //134 KEY_OPEN - NONE, //135 KEY_PASTE - NONE, //136 KEY_FIND - NONE, //137 KEY_CUT - NONE, //138 KEY_HELP - NONE, //139 KEY_MENU - NONE, //140 KEY_CALC - NONE, //141 KEY_SETUP - NONE, //142 KEY_SLEEP - NONE, //143 KEY_WAKEUP - NONE, //144 KEY_FILE - NONE, //145 KEY_SENDFILE - NONE, //146 KEY_DELETEFILE - NONE, //147 KEY_XFER - NONE, //148 KEY_PROG1 - NONE, //149 KEY_PROG2 - NONE, //150 KEY_WWW - NONE, //151 KEY_MSDOS - NONE, //152 KEY_SCREENLOCK - NONE, //153 KEY_DIRECTION + NONE, //0 KEY_RESERVED + 0x76, //1 KEY_ESC + 0x16, //2 KEY_1 + 0x1e, //3 KEY_2 + 0x26, //4 KEY_3 + 0x25, //5 KEY_4 + 0x2e, //6 KEY_5 + 0x36, //7 KEY_6 + 0x3d, //8 KEY_7 + 0x3e, //9 KEY_8 + 0x46, //10 KEY_9 + 0x45, //11 KEY_0 + 0x4e, //12 KEY_MINUS + 0x55, //13 KEY_EQUAL + 0x66, //14 KEY_BACKSPACE + 0x0d, //15 KEY_TAB + 0x15, //16 KEY_Q + 0x1d, //17 KEY_W + 0x24, //18 KEY_E + 0x2d, //19 KEY_R + 0x2c, //20 KEY_T + 0x35, //21 KEY_Y + 0x3c, //22 KEY_U + 0x43, //23 KEY_I + 0x44, //24 KEY_O + 0x4d, //25 KEY_P + 0x54, //26 KEY_LEFTBRACE + 0x5b, //27 KEY_RIGHTBRACE + 0x5a, //28 KEY_ENTER + LCTRL | 0x14, //29 KEY_LEFTCTRL + 0x1c, //30 KEY_A + 0x1b, //31 KEY_S + 0x23, //32 KEY_D + 0x2b, //33 KEY_F + 0x34, //34 KEY_G + 0x33, //35 KEY_H + 0x3b, //36 KEY_J + 0x42, //37 KEY_K + 0x4b, //38 KEY_L + 0x4c, //39 KEY_SEMICOLON + 0x52, //40 KEY_APOSTROPHE + 0x0e, //41 KEY_GRAVE + LSHIFT | 0x12, //42 KEY_LEFTSHIFT + 0x5d, //43 KEY_BACKSLASH + 0x1a, //44 KEY_Z + 0x22, //45 KEY_X + 0x21, //46 KEY_C + 0x2a, //47 KEY_V + 0x32, //48 KEY_B + 0x31, //49 KEY_N + 0x3a, //50 KEY_M + 0x41, //51 KEY_COMMA + 0x49, //52 KEY_DOT + 0x4a, //53 KEY_SLASH + RSHIFT | 0x59, //54 KEY_RIGHTSHIFT + 0x7c, //55 KEY_KPASTERISK + LALT | 0x11, //56 KEY_LEFTALT + 0x29, //57 KEY_SPACE + 0x58, //58 KEY_CAPSLOCK + 0x05, //59 KEY_F1 + 0x06, //60 KEY_F2 + 0x04, //61 KEY_F3 + 0x0c, //62 KEY_F4 + 0x03, //63 KEY_F5 + 0x0b, //64 KEY_F6 + 0x83, //65 KEY_F7 + 0x0a, //66 KEY_F8 + 0x01, //67 KEY_F9 + 0x09, //68 KEY_F10 + EMU_SWITCH_2 | 0x77, //69 KEY_NUMLOCK + EMU_SWITCH_1 | 0x7E, //70 KEY_SCROLLLOCK + 0x6c, //71 KEY_KP7 + 0x75, //72 KEY_KP8 + 0x7d, //73 KEY_KP9 + 0x7b, //74 KEY_KPMINUS + 0x6b, //75 KEY_KP4 + 0x73, //76 KEY_KP5 + 0x74, //77 KEY_KP6 + 0x79, //78 KEY_KPPLUS + 0x69, //79 KEY_KP1 + 0x72, //80 KEY_KP2 + 0x7a, //81 KEY_KP3 + 0x70, //82 KEY_KP0 + 0x71, //83 KEY_KPDOT + NONE, //84 ??? + NONE, //85 KEY_ZENKAKU + NONE, //86 KEY_102ND + 0x78, //87 KEY_F11 + 0x07, //88 KEY_F12 + NONE, //89 KEY_RO + NONE, //90 KEY_KATAKANA + NONE, //91 KEY_HIRAGANA + NONE, //92 KEY_HENKAN + NONE, //93 KEY_KATAKANA + NONE, //94 KEY_MUHENKAN + NONE, //95 KEY_KPJPCOMMA + EXT | 0x5a, //96 KEY_KPENTER + RCTRL | EXT | 0x14, //97 KEY_RIGHTCTRL + EXT | 0x4a, //98 KEY_KPSLASH + 0xE2, //99 KEY_SYSRQ + RALT | EXT | 0x11, //100 KEY_RIGHTALT + NONE, //101 KEY_LINEFEED + EXT | 0x6c, //102 KEY_HOME + EXT | 0x75, //103 KEY_UP + EXT | 0x7d, //104 KEY_PAGEUP + EXT | 0x6b, //105 KEY_LEFT + EXT | 0x74, //106 KEY_RIGHT + EXT | 0x69, //107 KEY_END + EXT | 0x72, //108 KEY_DOWN + EXT | 0x7a, //109 KEY_PAGEDOWN + EXT | 0x70, //110 KEY_INSERT + EXT | 0x71, //111 KEY_DELETE + NONE, //112 KEY_MACRO + NONE, //113 KEY_MUTE + NONE, //114 KEY_VOLUMEDOWN + NONE, //115 KEY_VOLUMEUP + NONE, //116 KEY_POWER + NONE, //117 KEY_KPEQUAL + NONE, //118 KEY_KPPLUSMINUS + 0xE1, //119 KEY_PAUSE + NONE, //120 KEY_SCALE + NONE, //121 KEY_KPCOMMA + NONE, //122 KEY_HANGEUL + NONE, //123 KEY_HANJA + NONE, //124 KEY_YEN + LGUI | EXT | 0x1f, //125 KEY_LEFTMETA + RGUI | EXT | 0x27, //126 KEY_RIGHTMETA + NONE, //127 KEY_COMPOSE + NONE, //128 KEY_STOP + NONE, //129 KEY_AGAIN + NONE, //130 KEY_PROPS + NONE, //131 KEY_UNDO + NONE, //132 KEY_FRONT + NONE, //133 KEY_COPY + NONE, //134 KEY_OPEN + NONE, //135 KEY_PASTE + NONE, //136 KEY_FIND + NONE, //137 KEY_CUT + NONE, //138 KEY_HELP + NONE, //139 KEY_MENU + NONE, //140 KEY_CALC + NONE, //141 KEY_SETUP + NONE, //142 KEY_SLEEP + NONE, //143 KEY_WAKEUP + NONE, //144 KEY_FILE + NONE, //145 KEY_SENDFILE + NONE, //146 KEY_DELETEFILE + NONE, //147 KEY_XFER + NONE, //148 KEY_PROG1 + NONE, //149 KEY_PROG2 + NONE, //150 KEY_WWW + NONE, //151 KEY_MSDOS + NONE, //152 KEY_SCREENLOCK + NONE, //153 KEY_DIRECTION NONE, //154 KEY_CYCLEWINDOWS - NONE, //155 KEY_MAIL - NONE, //156 KEY_BOOKMARKS - NONE, //157 KEY_COMPUTER - NONE, //158 KEY_BACK - NONE, //159 KEY_FORWARD - NONE, //160 KEY_CLOSECD - NONE, //161 KEY_EJECTCD + NONE, //155 KEY_MAIL + NONE, //156 KEY_BOOKMARKS + NONE, //157 KEY_COMPUTER + NONE, //158 KEY_BACK + NONE, //159 KEY_FORWARD + NONE, //160 KEY_CLOSECD + NONE, //161 KEY_EJECTCD NONE, //162 KEY_EJECTCLOSECD - NONE, //163 KEY_NEXTSONG - NONE, //164 KEY_PLAYPAUSE + NONE, //163 KEY_NEXTSONG + NONE, //164 KEY_PLAYPAUSE NONE, //165 KEY_PREVIOUSSONG - NONE, //166 KEY_STOPCD - NONE, //167 KEY_RECORD - NONE, //168 KEY_REWIND - NONE, //169 KEY_PHONE - NONE, //170 KEY_ISO - NONE, //171 KEY_CONFIG - NONE, //172 KEY_HOMEPAGE - NONE, //173 KEY_REFRESH - NONE, //174 KEY_EXIT - NONE, //175 KEY_MOVE - NONE, //176 KEY_EDIT - NONE, //177 KEY_SCROLLUP - NONE, //178 KEY_SCROLLDOWN - NONE, //179 KEY_KPLEFTPAREN + NONE, //166 KEY_STOPCD + NONE, //167 KEY_RECORD + NONE, //168 KEY_REWIND + NONE, //169 KEY_PHONE + NONE, //170 KEY_ISO + NONE, //171 KEY_CONFIG + NONE, //172 KEY_HOMEPAGE + NONE, //173 KEY_REFRESH + NONE, //174 KEY_EXIT + NONE, //175 KEY_MOVE + NONE, //176 KEY_EDIT + NONE, //177 KEY_SCROLLUP + NONE, //178 KEY_SCROLLDOWN + NONE, //179 KEY_KPLEFTPAREN NONE, //180 KEY_KPRIGHTPAREN - NONE, //181 KEY_NEW - NONE, //182 KEY_REDO - NONE, //183 KEY_F13 - NONE, //184 KEY_F14 - NONE, //185 KEY_F15 - NONE, //186 KEY_F16 - EMU_SWITCH_1 | 1, //187 KEY_F17 - EMU_SWITCH_1 | 2, //188 KEY_F18 - EMU_SWITCH_1 | 3, //189 KEY_F19 - EMU_SWITCH_1 | 4, //190 KEY_F20 - NONE, //191 KEY_F21 - NONE, //192 KEY_F22 - NONE, //193 KEY_F23 + NONE, //181 KEY_NEW + NONE, //182 KEY_REDO + NONE, //183 KEY_F13 + NONE, //184 KEY_F14 + NONE, //185 KEY_F15 + NONE, //186 KEY_F16 + EMU_SWITCH_1 | 1, //187 KEY_F17 + EMU_SWITCH_1 | 2, //188 KEY_F18 + EMU_SWITCH_1 | 3, //189 KEY_F19 + EMU_SWITCH_1 | 4, //190 KEY_F20 + NONE, //191 KEY_F21 + NONE, //192 KEY_F22 + NONE, //193 KEY_F23 0x5D, //194 U-mlaut on DE mapped to backslash - NONE, //195 ??? - NONE, //196 ??? - NONE, //197 ??? - NONE, //198 ??? - NONE, //199 ??? - NONE, //200 KEY_PLAYCD - NONE, //201 KEY_PAUSECD - NONE, //202 KEY_PROG3 - NONE, //203 KEY_PROG4 - NONE, //204 KEY_DASHBOARD - NONE, //205 KEY_SUSPEND - NONE, //206 KEY_CLOSE - NONE, //207 KEY_PLAY - NONE, //208 KEY_FASTFORWARD - NONE, //209 KEY_BASSBOOST - NONE, //210 KEY_PRINT - NONE, //211 KEY_HP - NONE, //212 KEY_CAMERA - NONE, //213 KEY_SOUND - NONE, //214 KEY_QUESTION - NONE, //215 KEY_EMAIL - NONE, //216 KEY_CHAT - NONE, //217 KEY_SEARCH - NONE, //218 KEY_CONNECT - NONE, //219 KEY_FINANCE - NONE, //220 KEY_SPORT - NONE, //221 KEY_SHOP - NONE, //222 KEY_ALTERASE - NONE, //223 KEY_CANCEL - NONE, //224 KEY_BRIGHT_DOWN - NONE, //225 KEY_BRIGHT_UP - NONE, //226 KEY_MEDIA - NONE, //227 KEY_SWITCHVIDEO + NONE, //195 ??? + NONE, //196 ??? + NONE, //197 ??? + NONE, //198 ??? + NONE, //199 ??? + NONE, //200 KEY_PLAYCD + NONE, //201 KEY_PAUSECD + NONE, //202 KEY_PROG3 + NONE, //203 KEY_PROG4 + NONE, //204 KEY_DASHBOARD + NONE, //205 KEY_SUSPEND + NONE, //206 KEY_CLOSE + NONE, //207 KEY_PLAY + NONE, //208 KEY_FASTFORWARD + NONE, //209 KEY_BASSBOOST + NONE, //210 KEY_PRINT + NONE, //211 KEY_HP + NONE, //212 KEY_CAMERA + NONE, //213 KEY_SOUND + NONE, //214 KEY_QUESTION + NONE, //215 KEY_EMAIL + NONE, //216 KEY_CHAT + NONE, //217 KEY_SEARCH + NONE, //218 KEY_CONNECT + NONE, //219 KEY_FINANCE + NONE, //220 KEY_SPORT + NONE, //221 KEY_SHOP + NONE, //222 KEY_ALTERASE + NONE, //223 KEY_CANCEL + NONE, //224 KEY_BRIGHT_DOWN + NONE, //225 KEY_BRIGHT_UP + NONE, //226 KEY_MEDIA + NONE, //227 KEY_SWITCHVIDEO NONE, //228 KEY_DILLUMTOGGLE - NONE, //229 KEY_DILLUMDOWN - NONE, //230 KEY_DILLUMUP - NONE, //231 KEY_SEND - NONE, //232 KEY_REPLY - NONE, //233 KEY_FORWARDMAIL - NONE, //234 KEY_SAVE - NONE, //235 KEY_DOCUMENTS - NONE, //236 KEY_BATTERY - NONE, //237 KEY_BLUETOOTH - NONE, //238 KEY_WLAN - NONE, //239 KEY_UWB - NONE, //240 KEY_UNKNOWN - NONE, //241 KEY_VIDEO_NEXT - NONE, //242 KEY_VIDEO_PREV + NONE, //229 KEY_DILLUMDOWN + NONE, //230 KEY_DILLUMUP + NONE, //231 KEY_SEND + NONE, //232 KEY_REPLY + NONE, //233 KEY_FORWARDMAIL + NONE, //234 KEY_SAVE + NONE, //235 KEY_DOCUMENTS + NONE, //236 KEY_BATTERY + NONE, //237 KEY_BLUETOOTH + NONE, //238 KEY_WLAN + NONE, //239 KEY_UWB + NONE, //240 KEY_UNKNOWN + NONE, //241 KEY_VIDEO_NEXT + NONE, //242 KEY_VIDEO_PREV NONE, //243 KEY_BRIGHT_CYCLE - NONE, //244 KEY_BRIGHT_AUTO - NONE, //245 KEY_DISPLAY_OFF - NONE, //246 KEY_WWAN - NONE, //247 KEY_RFKILL - NONE, //248 KEY_MICMUTE - NONE, //249 ??? - NONE, //250 ??? - NONE, //251 ??? - NONE, //252 ??? - NONE, //253 ??? - NONE, //254 ??? - NONE //255 ??? + NONE, //244 KEY_BRIGHT_AUTO + NONE, //245 KEY_DISPLAY_OFF + NONE, //246 KEY_WWAN + NONE, //247 KEY_RFKILL + NONE, //248 KEY_MICMUTE + NONE, //249 ??? + NONE, //250 ??? + NONE, //251 ??? + NONE, //252 ??? + NONE, //253 ??? + NONE, //254 ??? + NONE //255 ??? }; static int ev2archie[] = { - NONE, //0 KEY_RESERVED - 0x00, //1 KEY_ESC - 0x11, //2 KEY_1 - 0x12, //3 KEY_2 - 0x13, //4 KEY_3 - 0x14, //5 KEY_4 - 0x15, //6 KEY_5 - 0x16, //7 KEY_6 - 0x17, //8 KEY_7 - 0x18, //9 KEY_8 - 0x19, //10 KEY_9 - 0x1a, //11 KEY_0 - 0x1b, //12 KEY_MINUS - 0x1c, //13 KEY_EQUAL - 0x1e, //14 KEY_BACKSPACE - 0x26, //15 KEY_TAB - 0x27, //16 KEY_Q - 0x28, //17 KEY_W - 0x29, //18 KEY_E - 0x2a, //19 KEY_R - 0x2b, //20 KEY_T - 0x2c, //21 KEY_Y - 0x2d, //22 KEY_U - 0x2e, //23 KEY_I - 0x2f, //24 KEY_O - 0x30, //25 KEY_P - 0x31, //26 KEY_LEFTBRACE - 0x32, //27 KEY_RIGHTBRACE - 0x47, //28 KEY_ENTER - 0x3b, //29 KEY_LEFTCTRL - 0x3c, //30 KEY_A - 0x3d, //31 KEY_S - 0x3e, //32 KEY_D - 0x3f, //33 KEY_F - 0x40, //34 KEY_G - 0x41, //35 KEY_H - 0x42, //36 KEY_J - 0x43, //37 KEY_K - 0x44, //38 KEY_L - 0x45, //39 KEY_SEMICOLON - 0x46, //40 KEY_APOSTROPHE - 0x10, //41 KEY_GRAVE - 0x4c, //42 KEY_LEFTSHIFT - 0x33, //43 KEY_BACKSLASH - 0x4e, //44 KEY_Z - 0x4f, //45 KEY_X - 0x50, //46 KEY_C - 0x51, //47 KEY_V - 0x52, //48 KEY_B - 0x53, //49 KEY_N - 0x54, //50 KEY_M - 0x55, //51 KEY_COMMA - 0x56, //52 KEY_DOT - 0x57, //53 KEY_SLASH - 0x58, //54 KEY_RIGHTSHIFT - 0x24, //55 KEY_KPASTERISK - 0x5e, //56 KEY_LEFTALT - 0x5f, //57 KEY_SPACE - 0x5d, //58 KEY_CAPSLOCK - 0x01, //59 KEY_F1 - 0x02, //60 KEY_F2 - 0x03, //61 KEY_F3 - 0x04, //62 KEY_F4 - 0x05, //63 KEY_F5 - 0x06, //64 KEY_F6 - 0x07, //65 KEY_F7 - 0x08, //66 KEY_F8 - 0x09, //67 KEY_F9 - 0x0a, //68 KEY_F10 - 0x22, //69 KEY_NUMLOCK - NONE, //70 KEY_SCROLLLOCK - 0x37, //71 KEY_KP7 - 0x38, //72 KEY_KP8 - 0x39, //73 KEY_KP9 - 0x3a, //74 KEY_KPMINUS - 0x48, //75 KEY_KP4 - 0x49, //76 KEY_KP5 - 0x4a, //77 KEY_KP6 - 0x4b, //78 KEY_KPPLUS - 0x5a, //79 KEY_KP1 - 0x5b, //80 KEY_KP2 - 0x5c, //81 KEY_KP3 - 0x65, //82 KEY_KP0 - 0x66, //83 KEY_KPDOT - NONE, //84 ??? - NONE, //85 KEY_ZENKAKU - NONE, //86 KEY_102ND - 0x0b, //87 KEY_F11 - 0x0c, //88 KEY_F12 - NONE, //89 KEY_RO - NONE, //90 KEY_KATAKANA - NONE, //91 KEY_HIRAGANA - NONE, //92 KEY_HENKAN - NONE, //93 KEY_KATAKANA - NONE, //94 KEY_MUHENKAN - NONE, //95 KEY_KPJPCOMMA - 0x67, //96 KEY_KPENTER - 0x61, //97 KEY_RIGHTCTRL - 0x23, //98 KEY_KPSLASH - 0x0D, //99 KEY_SYSRQ - 0x60, //100 KEY_RIGHTALT - NONE, //101 KEY_LINEFEED - 0x20, //102 KEY_HOME - 0x59, //103 KEY_UP - 0x21, //104 KEY_PAGEUP - 0x62, //105 KEY_LEFT - 0x64, //106 KEY_RIGHT - 0x35, //107 KEY_END - 0x63, //108 KEY_DOWN - 0x36, //109 KEY_PAGEDOWN - 0x1f, //110 KEY_INSERT - 0x34, //111 KEY_DELETE - NONE, //112 KEY_MACRO - NONE, //113 KEY_MUTE - NONE, //114 KEY_VOLUMEDOWN - NONE, //115 KEY_VOLUMEUP - NONE, //116 KEY_POWER - NONE, //117 KEY_KPEQUAL - NONE, //118 KEY_KPPLUSMINUS - 0x0f, //119 KEY_PAUSE - NONE, //120 KEY_SCALE - NONE, //121 KEY_KPCOMMA - NONE, //122 KEY_HANGEUL - NONE, //123 KEY_HANJA - NONE, //124 KEY_YEN - NONE, //125 KEY_LEFTMETA - NONE, //126 KEY_RIGHTMETA - 0x71, //127 KEY_COMPOSE - NONE, //128 KEY_STOP - NONE, //129 KEY_AGAIN - NONE, //130 KEY_PROPS - NONE, //131 KEY_UNDO - NONE, //132 KEY_FRONT - NONE, //133 KEY_COPY - NONE, //134 KEY_OPEN - NONE, //135 KEY_PASTE - NONE, //136 KEY_FIND - NONE, //137 KEY_CUT - NONE, //138 KEY_HELP - NONE, //139 KEY_MENU - NONE, //140 KEY_CALC - NONE, //141 KEY_SETUP - NONE, //142 KEY_SLEEP - NONE, //143 KEY_WAKEUP - NONE, //144 KEY_FILE - NONE, //145 KEY_SENDFILE - NONE, //146 KEY_DELETEFILE - NONE, //147 KEY_XFER - NONE, //148 KEY_PROG1 - NONE, //149 KEY_PROG2 - NONE, //150 KEY_WWW - NONE, //151 KEY_MSDOS - NONE, //152 KEY_SCREENLOCK - NONE, //153 KEY_DIRECTION + NONE, //0 KEY_RESERVED + 0x00, //1 KEY_ESC + 0x11, //2 KEY_1 + 0x12, //3 KEY_2 + 0x13, //4 KEY_3 + 0x14, //5 KEY_4 + 0x15, //6 KEY_5 + 0x16, //7 KEY_6 + 0x17, //8 KEY_7 + 0x18, //9 KEY_8 + 0x19, //10 KEY_9 + 0x1a, //11 KEY_0 + 0x1b, //12 KEY_MINUS + 0x1c, //13 KEY_EQUAL + 0x1e, //14 KEY_BACKSPACE + 0x26, //15 KEY_TAB + 0x27, //16 KEY_Q + 0x28, //17 KEY_W + 0x29, //18 KEY_E + 0x2a, //19 KEY_R + 0x2b, //20 KEY_T + 0x2c, //21 KEY_Y + 0x2d, //22 KEY_U + 0x2e, //23 KEY_I + 0x2f, //24 KEY_O + 0x30, //25 KEY_P + 0x31, //26 KEY_LEFTBRACE + 0x32, //27 KEY_RIGHTBRACE + 0x47, //28 KEY_ENTER + 0x3b, //29 KEY_LEFTCTRL + 0x3c, //30 KEY_A + 0x3d, //31 KEY_S + 0x3e, //32 KEY_D + 0x3f, //33 KEY_F + 0x40, //34 KEY_G + 0x41, //35 KEY_H + 0x42, //36 KEY_J + 0x43, //37 KEY_K + 0x44, //38 KEY_L + 0x45, //39 KEY_SEMICOLON + 0x46, //40 KEY_APOSTROPHE + 0x10, //41 KEY_GRAVE + 0x4c, //42 KEY_LEFTSHIFT + 0x33, //43 KEY_BACKSLASH + 0x4e, //44 KEY_Z + 0x4f, //45 KEY_X + 0x50, //46 KEY_C + 0x51, //47 KEY_V + 0x52, //48 KEY_B + 0x53, //49 KEY_N + 0x54, //50 KEY_M + 0x55, //51 KEY_COMMA + 0x56, //52 KEY_DOT + 0x57, //53 KEY_SLASH + 0x58, //54 KEY_RIGHTSHIFT + 0x24, //55 KEY_KPASTERISK + 0x5e, //56 KEY_LEFTALT + 0x5f, //57 KEY_SPACE + 0x5d, //58 KEY_CAPSLOCK + 0x01, //59 KEY_F1 + 0x02, //60 KEY_F2 + 0x03, //61 KEY_F3 + 0x04, //62 KEY_F4 + 0x05, //63 KEY_F5 + 0x06, //64 KEY_F6 + 0x07, //65 KEY_F7 + 0x08, //66 KEY_F8 + 0x09, //67 KEY_F9 + 0x0a, //68 KEY_F10 + 0x22, //69 KEY_NUMLOCK + NONE, //70 KEY_SCROLLLOCK + 0x37, //71 KEY_KP7 + 0x38, //72 KEY_KP8 + 0x39, //73 KEY_KP9 + 0x3a, //74 KEY_KPMINUS + 0x48, //75 KEY_KP4 + 0x49, //76 KEY_KP5 + 0x4a, //77 KEY_KP6 + 0x4b, //78 KEY_KPPLUS + 0x5a, //79 KEY_KP1 + 0x5b, //80 KEY_KP2 + 0x5c, //81 KEY_KP3 + 0x65, //82 KEY_KP0 + 0x66, //83 KEY_KPDOT + NONE, //84 ??? + NONE, //85 KEY_ZENKAKU + NONE, //86 KEY_102ND + 0x0b, //87 KEY_F11 + 0x0c, //88 KEY_F12 + NONE, //89 KEY_RO + NONE, //90 KEY_KATAKANA + NONE, //91 KEY_HIRAGANA + NONE, //92 KEY_HENKAN + NONE, //93 KEY_KATAKANA + NONE, //94 KEY_MUHENKAN + NONE, //95 KEY_KPJPCOMMA + 0x67, //96 KEY_KPENTER + 0x61, //97 KEY_RIGHTCTRL + 0x23, //98 KEY_KPSLASH + 0x0D, //99 KEY_SYSRQ + 0x60, //100 KEY_RIGHTALT + NONE, //101 KEY_LINEFEED + 0x20, //102 KEY_HOME + 0x59, //103 KEY_UP + 0x21, //104 KEY_PAGEUP + 0x62, //105 KEY_LEFT + 0x64, //106 KEY_RIGHT + 0x35, //107 KEY_END + 0x63, //108 KEY_DOWN + 0x36, //109 KEY_PAGEDOWN + 0x1f, //110 KEY_INSERT + 0x34, //111 KEY_DELETE + NONE, //112 KEY_MACRO + NONE, //113 KEY_MUTE + NONE, //114 KEY_VOLUMEDOWN + NONE, //115 KEY_VOLUMEUP + NONE, //116 KEY_POWER + NONE, //117 KEY_KPEQUAL + NONE, //118 KEY_KPPLUSMINUS + 0x0f, //119 KEY_PAUSE + NONE, //120 KEY_SCALE + NONE, //121 KEY_KPCOMMA + NONE, //122 KEY_HANGEUL + NONE, //123 KEY_HANJA + NONE, //124 KEY_YEN + NONE, //125 KEY_LEFTMETA + NONE, //126 KEY_RIGHTMETA + 0x71, //127 KEY_COMPOSE + NONE, //128 KEY_STOP + NONE, //129 KEY_AGAIN + NONE, //130 KEY_PROPS + NONE, //131 KEY_UNDO + NONE, //132 KEY_FRONT + NONE, //133 KEY_COPY + NONE, //134 KEY_OPEN + NONE, //135 KEY_PASTE + NONE, //136 KEY_FIND + NONE, //137 KEY_CUT + NONE, //138 KEY_HELP + NONE, //139 KEY_MENU + NONE, //140 KEY_CALC + NONE, //141 KEY_SETUP + NONE, //142 KEY_SLEEP + NONE, //143 KEY_WAKEUP + NONE, //144 KEY_FILE + NONE, //145 KEY_SENDFILE + NONE, //146 KEY_DELETEFILE + NONE, //147 KEY_XFER + NONE, //148 KEY_PROG1 + NONE, //149 KEY_PROG2 + NONE, //150 KEY_WWW + NONE, //151 KEY_MSDOS + NONE, //152 KEY_SCREENLOCK + NONE, //153 KEY_DIRECTION NONE, //154 KEY_CYCLEWINDOWS - NONE, //155 KEY_MAIL - NONE, //156 KEY_BOOKMARKS - NONE, //157 KEY_COMPUTER - NONE, //158 KEY_BACK - NONE, //159 KEY_FORWARD - NONE, //160 KEY_CLOSECD - NONE, //161 KEY_EJECTCD + NONE, //155 KEY_MAIL + NONE, //156 KEY_BOOKMARKS + NONE, //157 KEY_COMPUTER + NONE, //158 KEY_BACK + NONE, //159 KEY_FORWARD + NONE, //160 KEY_CLOSECD + NONE, //161 KEY_EJECTCD NONE, //162 KEY_EJECTCLOSECD - NONE, //163 KEY_NEXTSONG - NONE, //164 KEY_PLAYPAUSE + NONE, //163 KEY_NEXTSONG + NONE, //164 KEY_PLAYPAUSE NONE, //165 KEY_PREVIOUSSONG - NONE, //166 KEY_STOPCD - NONE, //167 KEY_RECORD - NONE, //168 KEY_REWIND - NONE, //169 KEY_PHONE - NONE, //170 KEY_ISO - NONE, //171 KEY_CONFIG - NONE, //172 KEY_HOMEPAGE - NONE, //173 KEY_REFRESH - NONE, //174 KEY_EXIT - NONE, //175 KEY_MOVE - NONE, //176 KEY_EDIT - NONE, //177 KEY_SCROLLUP - NONE, //178 KEY_SCROLLDOWN - NONE, //179 KEY_KPLEFTPAREN + NONE, //166 KEY_STOPCD + NONE, //167 KEY_RECORD + NONE, //168 KEY_REWIND + NONE, //169 KEY_PHONE + NONE, //170 KEY_ISO + NONE, //171 KEY_CONFIG + NONE, //172 KEY_HOMEPAGE + NONE, //173 KEY_REFRESH + NONE, //174 KEY_EXIT + NONE, //175 KEY_MOVE + NONE, //176 KEY_EDIT + NONE, //177 KEY_SCROLLUP + NONE, //178 KEY_SCROLLDOWN + NONE, //179 KEY_KPLEFTPAREN NONE, //180 KEY_KPRIGHTPAREN - NONE, //181 KEY_NEW - NONE, //182 KEY_REDO - NONE, //183 KEY_F13 - NONE, //184 KEY_F14 - NONE, //185 KEY_F15 - NONE, //186 KEY_F16 - NONE, //187 KEY_F17 - NONE, //188 KEY_F18 - NONE, //189 KEY_F19 - NONE, //190 KEY_F20 - NONE, //191 KEY_F21 - NONE, //192 KEY_F22 - NONE, //193 KEY_F23 - NONE, //194 KEY_F24 - NONE, //195 ??? - NONE, //196 ??? - NONE, //197 ??? - NONE, //198 ??? - NONE, //199 ??? - NONE, //200 KEY_PLAYCD - NONE, //201 KEY_PAUSECD - NONE, //202 KEY_PROG3 - NONE, //203 KEY_PROG4 - NONE, //204 KEY_DASHBOARD - NONE, //205 KEY_SUSPEND - NONE, //206 KEY_CLOSE - NONE, //207 KEY_PLAY - NONE, //208 KEY_FASTFORWARD - NONE, //209 KEY_BASSBOOST - NONE, //210 KEY_PRINT - NONE, //211 KEY_HP - NONE, //212 KEY_CAMERA - NONE, //213 KEY_SOUND - NONE, //214 KEY_QUESTION - NONE, //215 KEY_EMAIL - NONE, //216 KEY_CHAT - NONE, //217 KEY_SEARCH - NONE, //218 KEY_CONNECT - NONE, //219 KEY_FINANCE - NONE, //220 KEY_SPORT - NONE, //221 KEY_SHOP - NONE, //222 KEY_ALTERASE - NONE, //223 KEY_CANCEL - NONE, //224 KEY_BRIGHT_DOWN - NONE, //225 KEY_BRIGHT_UP - NONE, //226 KEY_MEDIA - NONE, //227 KEY_SWITCHVIDEO + NONE, //181 KEY_NEW + NONE, //182 KEY_REDO + NONE, //183 KEY_F13 + NONE, //184 KEY_F14 + NONE, //185 KEY_F15 + NONE, //186 KEY_F16 + NONE, //187 KEY_F17 + NONE, //188 KEY_F18 + NONE, //189 KEY_F19 + NONE, //190 KEY_F20 + NONE, //191 KEY_F21 + NONE, //192 KEY_F22 + NONE, //193 KEY_F23 + NONE, //194 KEY_F24 + NONE, //195 ??? + NONE, //196 ??? + NONE, //197 ??? + NONE, //198 ??? + NONE, //199 ??? + NONE, //200 KEY_PLAYCD + NONE, //201 KEY_PAUSECD + NONE, //202 KEY_PROG3 + NONE, //203 KEY_PROG4 + NONE, //204 KEY_DASHBOARD + NONE, //205 KEY_SUSPEND + NONE, //206 KEY_CLOSE + NONE, //207 KEY_PLAY + NONE, //208 KEY_FASTFORWARD + NONE, //209 KEY_BASSBOOST + NONE, //210 KEY_PRINT + NONE, //211 KEY_HP + NONE, //212 KEY_CAMERA + NONE, //213 KEY_SOUND + NONE, //214 KEY_QUESTION + NONE, //215 KEY_EMAIL + NONE, //216 KEY_CHAT + NONE, //217 KEY_SEARCH + NONE, //218 KEY_CONNECT + NONE, //219 KEY_FINANCE + NONE, //220 KEY_SPORT + NONE, //221 KEY_SHOP + NONE, //222 KEY_ALTERASE + NONE, //223 KEY_CANCEL + NONE, //224 KEY_BRIGHT_DOWN + NONE, //225 KEY_BRIGHT_UP + NONE, //226 KEY_MEDIA + NONE, //227 KEY_SWITCHVIDEO NONE, //228 KEY_DILLUMTOGGLE - NONE, //229 KEY_DILLUMDOWN - NONE, //230 KEY_DILLUMUP - NONE, //231 KEY_SEND - NONE, //232 KEY_REPLY - NONE, //233 KEY_FORWARDMAIL - NONE, //234 KEY_SAVE - NONE, //235 KEY_DOCUMENTS - NONE, //236 KEY_BATTERY - NONE, //237 KEY_BLUETOOTH - NONE, //238 KEY_WLAN - NONE, //239 KEY_UWB - NONE, //240 KEY_UNKNOWN - NONE, //241 KEY_VIDEO_NEXT - NONE, //242 KEY_VIDEO_PREV + NONE, //229 KEY_DILLUMDOWN + NONE, //230 KEY_DILLUMUP + NONE, //231 KEY_SEND + NONE, //232 KEY_REPLY + NONE, //233 KEY_FORWARDMAIL + NONE, //234 KEY_SAVE + NONE, //235 KEY_DOCUMENTS + NONE, //236 KEY_BATTERY + NONE, //237 KEY_BLUETOOTH + NONE, //238 KEY_WLAN + NONE, //239 KEY_UWB + NONE, //240 KEY_UNKNOWN + NONE, //241 KEY_VIDEO_NEXT + NONE, //242 KEY_VIDEO_PREV NONE, //243 KEY_BRIGHT_CYCLE - NONE, //244 KEY_BRIGHT_AUTO - NONE, //245 KEY_DISPLAY_OFF - NONE, //246 KEY_WWAN - NONE, //247 KEY_RFKILL - NONE, //248 KEY_MICMUTE - NONE, //249 ??? - NONE, //250 ??? - NONE, //251 ??? - NONE, //252 ??? - NONE, //253 ??? - NONE, //254 ??? - NONE //255 ??? + NONE, //244 KEY_BRIGHT_AUTO + NONE, //245 KEY_DISPLAY_OFF + NONE, //246 KEY_WWAN + NONE, //247 KEY_RFKILL + NONE, //248 KEY_MICMUTE + NONE, //249 ??? + NONE, //250 ??? + NONE, //251 ??? + NONE, //252 ??? + NONE, //253 ??? + NONE, //254 ??? + NONE //255 ??? }; /* @@ -1300,7 +1300,7 @@ static char kr_fn_table[] = KEY_F5, KEY_F19, // EMU_JOY1 KEY_F6, KEY_F20, // EMU_NONE - //Emulate keypad for A600 + //Emulate keypad for A600 KEY_1, KEY_KP1, KEY_2, KEY_KP2, KEY_3, KEY_KP3, @@ -1707,7 +1707,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int int sub_dev = dev; - //check if device is a part of multifunctional device + //check if device is a part of multifunctional device if (input[dev].bind >= 0) dev = input[dev].bind; //mouse @@ -1813,7 +1813,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int if (mapping_dev < 0) mapping_dev = dev; if (mapping_dev == dev && ev->code < 1024) mapping_button = ev->code; } - + if (ev->value == 0 && mapping_dev >= 0 && (ev->code<256 || mapping_dev == dev) && mapping_button && mapping_button != ev->code) { // Technically it's hard to map the key to button as keyboards @@ -1917,7 +1917,7 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int mapping_button++; key_mapped = 0; } - + if(!ev->value && mapping_dev == dev && ((ev->code == last_axis) || (ev->code == last_axis+1))) { last_axis = 0; diff --git a/input.h b/input.h index 4e58d55..df670c5 100644 --- a/input.h +++ b/input.h @@ -57,6 +57,6 @@ void input_lightgun_cal(uint16_t *cal); void input_switch(int grab); int input_state(); -void input_uinp_destroy(); +void input_uinp_destroy(); #endif diff --git a/lib/miniz/miniz.h b/lib/miniz/miniz.h index 685589f..7830e6a 100644 --- a/lib/miniz/miniz.h +++ b/lib/miniz/miniz.h @@ -116,7 +116,7 @@ #include "miniz_tdef.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. */ /* 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_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 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. */ diff --git a/lib/miniz/miniz_zip.c b/lib/miniz/miniz_zip.c index b96f6ea..8aa5ce2 100644 --- a/lib/miniz/miniz_zip.c +++ b/lib/miniz/miniz_zip.c @@ -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) { /* 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 + archive_name_size + comment_size + user_extra_data_len + + 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 + user_extra_data_central_len + 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) { /* 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 + MZ_ZIP_DATA_DESCRIPTER_SIZE32 + user_extra_data_central_len) > 0xFFFFFFFF) { diff --git a/main.cpp b/main.cpp index 6e58a26..d49bc26 100644 --- a/main.cpp +++ b/main.cpp @@ -64,7 +64,7 @@ int main(int argc, char *argv[]) exit(0); } - FindStorage(); + FindStorage(); user_io_init((argc > 1) ? argv[1] : ""); scheduler_init(); diff --git a/menu.cpp b/menu.cpp index 77a16bb..56a7ea5 100644 --- a/menu.cpp +++ b/menu.cpp @@ -594,7 +594,7 @@ static char* getNet(int spec) strcpy(host, "IP: "); getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host + strlen(host), NI_MAXHOST - strlen(host), NULL, 0, NI_NUMERICHOST); } - + freeifaddrs(ifaddr); return spec ? (ifa ? host : 0) : (char*)netType; } @@ -728,7 +728,7 @@ const char* get_rbf_name_bootcore(char *str) if (!strlen(cfg.bootcore)) return ""; char *p = strrchr(str, '/'); if (!p) return str; - + char *spl = strrchr(p + 1, '.'); if (spl && !strcmp(spl, ".rbf")) { @@ -933,7 +933,7 @@ void HandleUI(void) // 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 - // 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: // react on break code instead of make code case KEY_ESC | UPSTROKE: @@ -1463,7 +1463,7 @@ void HandleUI(void) { p = user_io_8bit_get_string(i++); if (!p) continue; - + h = 0; d = 0; @@ -1714,11 +1714,11 @@ void HandleUI(void) menusub = ((mode != 3 && mode != 4) || !stat("/dev/midi", &filestat)) ? 0 : 2; } break; - + case 5: video_set_scaler_flt(video_get_scaler_flt() ? 0 : 1); menustate = MENU_8BIT_SYSTEM1; - break; + break; case 6: if (video_get_scaler_flt()) @@ -1842,7 +1842,7 @@ void HandleUI(void) OsdWrite(3, s, menusub == 1, m); sprintf(s, " Type: %s", (midilink & 2) ? ((midilink & 1) ? " UDP" : " TCP") : ((midilink & 1) ? " MUNT" : "FluidSynth")); OsdWrite(4, s, menusub == 2, m); - + OsdWrite(5); OsdWrite(6, " Reset UART connection", menusub == 3, mode?0:1); OsdWrite(7); @@ -1889,8 +1889,8 @@ void HandleUI(void) menustate = MENU_UART1; } break; - case 3: - { + case 3: + { int mode = GetUARTMode(); if(mode != 0) { @@ -2448,7 +2448,7 @@ void HandleUI(void) break; case MENU_MIST_STORAGE_FILE_SELECTED: // file successfully selected - // floppy/hdd + // floppy/hdd if (menusub < 2) tos_insert_disk(menusub, SelectedPath); else { @@ -3288,7 +3288,7 @@ void HandleUI(void) strncat(minimig_config.info, p, sizeof(minimig_config.info) - strlen(minimig_config.info) - 1); minimig_config.info[sizeof(minimig_config.info) - 1] = 0; - + if (menusub<10) minimig_cfg_save(menusub); menustate = MENU_MAIN1; menusub = 9; @@ -4173,7 +4173,7 @@ void HandleUI(void) OsdWrite(3, " Press key to remap", 0, 0); s[0] = 0; if(flag) - { + { sprintf(s, " on keyboard %04x:%04x", get_map_vid(), get_map_pid()); } OsdWrite(5, s, 0, 0); @@ -4263,7 +4263,7 @@ void HandleUI(void) char straux[64]; if (cfg.bootcore[0] != '\0') - { + { if (btimeout >= 10) { sprintf(str, " Bootcore -> %s", bootcoretype); @@ -4284,7 +4284,7 @@ void HandleUI(void) OsdWrite(15, str, 1, 0); fpga_load_rbf(cfg.bootcore); } - } + } } if (init_wait < 1) @@ -4368,7 +4368,7 @@ void PrintFileName(char *name, int row, int maxinv) { int len; - char s[40]; + char s[40]; s[32] = 0; // set temporary string length to OSD line length len = strlen(name); // get name length diff --git a/scaler.cpp b/scaler.cpp index 939018d..3ece5e6 100644 --- a/scaler.cpp +++ b/scaler.cpp @@ -1,6 +1,6 @@ /* Copyright 2019 alanswx -with help from the MiSTer contributors including Grabulosaure +with help from the MiSTer contributors including Grabulosaure */ #include @@ -49,12 +49,12 @@ mister_scaler * mister_scaler_init() mister_scaler_free(ms); return NULL; } - + ms->header=buffer[2]<<8 | buffer[3]; ms->width =buffer[6]<<8 | buffer[7]; ms->height=buffer[8]<<8 | buffer[9]; 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 (" 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]); */ - 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; 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 *outbufy; 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)]; outbufV=&bufV[y*(lineV)]; for (int x = 0; x < ms->width ; x++) - { + { int R,G,B; R = *pixbuf++; G = *pixbuf++; @@ -104,7 +104,7 @@ int mister_scaler_read_yuv(mister_scaler *ms,int lineY,unsigned char *bufY, int *outbufV++ = V; } } - + return 0; } @@ -112,19 +112,19 @@ int mister_scaler_read(mister_scaler *ms,unsigned char *gbuf) { unsigned char *buffer; buffer = (unsigned char *)(ms->map+ms->map_off); - + // do this slow way for now.. - could use a memcpy? unsigned char *pixbuf; unsigned char *outbuf; for (int y=0; y< ms->height ; y++) { pixbuf=&buffer[ms->header + y*ms->line]; 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++; } } - + return 0; } diff --git a/scaler.h b/scaler.h index 9103e92..00b67aa 100644 --- a/scaler.h +++ b/scaler.h @@ -1,6 +1,6 @@ /* Copyright 2019 alanswx -with help from the MiSTer contributors including Grabulosaure +with help from the MiSTer contributors including Grabulosaure */ #ifndef SCALER_H diff --git a/support/archie/archie.cpp b/support/archie/archie.cpp index 35511d6..9e8a7c9 100644 --- a/support/archie/archie.cpp +++ b/support/archie/archie.cpp @@ -138,7 +138,7 @@ void archie_save_config(void) void archie_set_rom(char *name) { if (!name) return; - + printf("archie_set_rom(%s)\n", name); // save file name diff --git a/support/minimig/minimig_boot.cpp b/support/minimig/minimig_boot.cpp index 13fe2bf..bec6898 100644 --- a/support/minimig/minimig_boot.cpp +++ b/support/minimig/minimig_boot.cpp @@ -392,7 +392,7 @@ static void BootCustomInit() mem_write16(0x000a); 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_write16(0x0000); mem_upload_fini(); diff --git a/support/minimig/minimig_boot.h b/support/minimig/minimig_boot.h index e2ab0d9..5861882 100644 --- a/support/minimig/minimig_boot.h +++ b/support/minimig/minimig_boot.h @@ -39,7 +39,7 @@ void BootInit(); void BootPrintEx(const char * str); void BootHome(); -#define BootPrint(text) printf("%s\n", text) +#define BootPrint(text) printf("%s\n", text) #endif // __BOOT_H__ diff --git a/support/minimig/minimig_config.cpp b/support/minimig/minimig_config.cpp index 3e9d6da..b69cd0c 100644 --- a/support/minimig/minimig_config.cpp +++ b/support/minimig/minimig_config.cpp @@ -83,7 +83,7 @@ static void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int addr printf("]\n"); } - + static char UploadKickstart(char *name) { diff --git a/support/minimig/minimig_fdd.cpp b/support/minimig/minimig_fdd.cpp index 0b1fb8f..adb2678 100644 --- a/support/minimig/minimig_fdd.cpp +++ b/support/minimig/minimig_fdd.cpp @@ -159,7 +159,7 @@ void SendGap(void) // read a track from disk void ReadTrack(adfTYPE *drive) -{ +{ // track number is updated in drive struct before calling this function unsigned char sector; diff --git a/support/minimig/minimig_hdd.cpp b/support/minimig/minimig_hdd.cpp index 93e80ae..82d7b8d 100644 --- a/support/minimig/minimig_hdd.cpp +++ b/support/minimig/minimig_hdd.cpp @@ -319,7 +319,7 @@ static void IdentifyDevice(uint16_t *pBuffer, hdfTYPE *hdf) } p = (char*)&pBuffer[27]; - for (i = 0; i < 40; i += 2) + for (i = 0; i < 40; i += 2) { char c = p[i]; p[i] = p[i + 1]; diff --git a/support/minimig/minimig_hdd.h b/support/minimig/minimig_hdd.h index e4259a9..bdd23e6 100644 --- a/support/minimig/minimig_hdd.h +++ b/support/minimig/minimig_hdd.h @@ -3,7 +3,7 @@ #ifndef __MINIMIG_HDD_H__ #define __MINIMIG_HDD_H__ -#include "minimig_hdd_internal.h" +#include "minimig_hdd_internal.h" // functions void HandleHDD(uint8_t c1, uint8_t c2); diff --git a/support/sharpmz/sharpmz.cpp b/support/sharpmz/sharpmz.cpp index 6f17e34..cc68270 100644 --- a/support/sharpmz/sharpmz.cpp +++ b/support/sharpmz/sharpmz.cpp @@ -7,8 +7,8 @@ // 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 // emulation. -// -// Credits: +// +// Credits: // Copyright: (c) 2018 Philip Smart // // 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].loadSize = MZLOADSIZE[FDCROM_IDX][i]; } - + // Set the status values. // if(setStatus) { user_io_8bit_set_status(config.system_ctrl, 0xffffffff); - + // Set the registers. // for(int i=0; i < MAX_REGISTERS; i++) @@ -213,13 +213,13 @@ int sharpmz_reload_config(short setStatus) sharpmz_reset_config(0); sharpmz_save_config(); } - + // Set the status values and control registers as requested.. // if(setStatus && success) { user_io_8bit_set_status(config.system_ctrl, 0xffffffff); - + // Set the registers. // 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. // usleep(50000); - + // Try and load the SD config. // if(sharpmz_reload_config(0) == 0) @@ -338,7 +338,7 @@ void sharpmz_poll(void) sharpmz_save_tape_from_cmt((const char *)0); } } - + // Reset the timer. time = GetTimer(0); } @@ -377,7 +377,7 @@ char *sharpmz_pop_filename(void) static char fileName[MAX_FILENAME_SIZE]; // Queue empty, just return. - if(tapeQueue.bottom == NULL) + if(tapeQueue.bottom == NULL) { return 0; } @@ -406,7 +406,7 @@ char *sharpmz_get_next_filename(char reset) static tape_queue_node_t *ptr = NULL; // Queue empty, just return. - if(tapeQueue.bottom == NULL) + if(tapeQueue.bottom == NULL) { return 0; } @@ -438,7 +438,7 @@ void sharpmz_clear_filelist(void) tape_queue_node_t *ptr; // Queue empty, just return. - if(tapeQueue.bottom == NULL) + if(tapeQueue.bottom == NULL) { return; } @@ -453,7 +453,7 @@ void sharpmz_clear_filelist(void) 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) { @@ -599,7 +599,7 @@ void sharpmz_set_display_type(short displayType, short setStatus) // Sanity check. if(displayType > 3) displayType = 0; //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] |= (displayType & 0x07); @@ -1304,7 +1304,7 @@ void sharpmz_set_custom_rom_enabled(short machineModel, short romType, short on) case KEYMAP_IDX: config.romKeyMap[machineModel].romEnabled = (on == 1); break; - + case USERROM_IDX: config.romUser[machineModel].romEnabled = (on == 1); break; @@ -1410,7 +1410,7 @@ sharpmz_tape_header_t *sharpmz_get_tape_header(void) 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. // 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 value; - + EnableFpga(); spi8(SHARPMZ_CONFIG_RX); spi8(addr); // Address of register to change. @@ -1523,7 +1523,7 @@ void sharpmz_send_file(romData_t &image, char *dirPrefix) DISKLED_OFF; // If we encountered an error, then bad file or eof, so exit. - // + // if(actualReadSize != 0) { spi_write(sector_buffer, actualReadSize, 0); @@ -1557,7 +1557,7 @@ short sharpmz_read_ram(const char *memDumpFile, short bank) { unsigned int actualWriteSize; fileTYPE file = {}; - + // Open the memory image debug file for writing. 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); return(1); } - + // Some sanity checks. // 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; 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); if(actualReadSize > 0) { @@ -1796,7 +1796,7 @@ short sharpmz_load_tape_to_ram(const char *tapeFile, unsigned char dstCMT) time = GetTimer(0) - time; sharpmz_debugf("Uploaded in %lu ms", time >> 20); - + // Debug, show registers. 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. FileClose(&file); - + // Dump out the memory if needed (generally for debug purposes). 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; } - + // Debug, show registers. 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); } - + // Open the memory image debug file for writing. if (!sharpmz_file_write(&file, fileName)) { @@ -1978,7 +1978,7 @@ void sharpmz_ui(int idleState, int idle2State, int system short itemCount; char sBuf[40]; char *fileName; - + (void)plus; (void)minus; @@ -2004,16 +2004,16 @@ void sharpmz_ui(int idleState, int idle2State, int system /******************************************************************/ case MENU_SHARPMZ_MAIN1: - + menuItem = 0; subItem = 0; *menumask = 0; - + OsdSetTitle(user_io_get_core_name(), 0); - + OsdWrite(menuItem++, " Main Menu", 0, 0); OsdWrite(menuItem++, "", 0, 0); - + OsdWrite(menuItem++, " Tape Storage \x16", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; @@ -2023,21 +2023,21 @@ void sharpmz_ui(int idleState, int idle2State, int system OsdWrite(menuItem++, " Machine \x16", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + OsdWrite(menuItem++, " Display \x16", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + OsdWrite(menuItem++, " Debug \x16", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; OsdWrite(menuItem++, " System \x16", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + for (; menuItem < 10; menuItem++) { OsdWrite(menuItem, "", 0, 0); } - + OsdWrite(menuItem++, " Reset", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; 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, " exit", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + // Set menu states, parent is the root menu, next is the processing menu 2. // *parentstate = MENU_SHARPMZ_MAIN1; *menustate = MENU_SHARPMZ_MAIN2; - + // set helptext with core display on top of basic info sprintf(helptext_custom, " "); strcat(helptext_custom, OsdCoreName()); @@ -2068,12 +2068,12 @@ void sharpmz_ui(int idleState, int idle2State, int system strcat(helptext_custom, SHARPMZ_HELPTEXT[0]); *helptext = helptext_custom; break; - + case MENU_SHARPMZ_MAIN2: // menu key closes menu if (menu) *menustate = idleState; - + if (select || right) { switch (*menusub) @@ -2098,21 +2098,21 @@ void sharpmz_ui(int idleState, int idle2State, int system *menusub = 0; if(right) select = true; break; - + case 2: // Display *menustate = MENU_SHARPMZ_DISPLAY1; *menusub_last = *menusub; *menusub = 0; if(right) select = true; break; - + case 3: // Debug *menustate = MENU_SHARPMZ_DEBUG1; *menusub_last = *menusub; *menusub = 0; if(right) select = true; break; - + case 4: // System *menustate = systemState; *menusub_last = *menusub; @@ -2127,7 +2127,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *menustate = idleState; } break; - + case 6: // Reload Settings if(select) { @@ -2143,7 +2143,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *menustate = MENU_SHARPMZ_MAIN1; } break; - + case 8: // Reset Settings if(select) { @@ -2159,25 +2159,25 @@ void sharpmz_ui(int idleState, int idle2State, int system } } break; - + case MENU_SHARPMZ_TAPE_STORAGE1: menuItem = 0; subItem = 0; *menumask = 0; - + OsdSetTitle("Tape Storage", OSD_ARROW_LEFT); - + OsdWrite(menuItem++, "", 0, 0); - + OsdWrite(menuItem++, " Load direct to RAM: *.MZF", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + OsdWrite(menuItem++, " Queue Tape: *.MZF", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; OsdWrite(menuItem++, " Clear Queue ", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + // List out the current tape queue. itemCount = 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()); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + for (; menuItem < 15; menuItem++) { OsdWrite(menuItem, "", 0, 0); } - + OsdWrite(menuItem, " exit", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + *parentstate = *menustate; *menustate = MENU_SHARPMZ_TAPE_STORAGE2; break; - - + + case MENU_SHARPMZ_TAPE_STORAGE2: if (menu) { *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); *menustate = MENU_SHARPMZ_TAPE_STORAGE1; break; - + case 7: *menustate = MENU_SHARPMZ_MAIN1; *menusub = *menusub_last; @@ -2284,7 +2284,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *menusub = *menusub_last; } break; - + 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); *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); sharpmz_tape_header_t *tapeHeader = sharpmz_get_tape_header(); - + if(!fail) OsdSetTitle("Tape Details", OSD_ARROW_LEFT); else OsdSetTitle(" Tape Error", OSD_ARROW_LEFT); - + *menumask = 0x01; // Exit. *parentstate = *menustate; menuItem = 0; - + if(!fail) OsdWrite(menuItem++, " Tape Details", 0, 0); else @@ -2320,7 +2320,7 @@ void sharpmz_ui(int idleState, int idle2State, int system sprintf(sBuf, " Exec Addr: %04x", tapeHeader->execAddress); OsdWrite(menuItem++, sBuf, 0, 0); OsdWrite(menuItem++, "", 0, 0); - + if(!fail) OsdWrite(menuItem++, "", 0, 0); else @@ -2347,7 +2347,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *menustate = MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2; } break; - + case MENU_SHARPMZ_TAPE_STORAGE_LOAD_TAPE_TO_RAM2: if (menu || select || left || up) { @@ -2355,7 +2355,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *menusub = *menusub_last; } break; - + case MENU_SHARPMZ_TAPE_STORAGE_QUEUE_TAPE_TO_CMT: sharpmz_debugf("File added to Queue: %s, for menu option:%04x\n", selectedPath, *menumask); *menustate = MENU_SHARPMZ_TAPE_STORAGE1; @@ -2376,11 +2376,11 @@ void sharpmz_ui(int idleState, int idle2State, int system { OsdSetTitle("Queue Error", OSD_ARROW_LEFT); } - + *menumask = 0x01; // Exit. *parentstate = *menustate; menuItem = 0; - + if(!fail) { OsdWrite(menuItem++, " Tape Details", 0, 0); @@ -2455,19 +2455,19 @@ void sharpmz_ui(int idleState, int idle2State, int system menuItem = 0; subItem = 0; *menumask = 0; - + OsdSetTitle("Floppy Storage", OSD_ARROW_LEFT); - + OsdWrite(menuItem++, "", 0, 0); - + for (; menuItem < 15; menuItem++) { OsdWrite(menuItem, "", 0, 0); } - + OsdWrite(menuItem, " exit", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + *parentstate = *menustate; *menustate = MENU_SHARPMZ_FLOPPY_STORAGE2; break; @@ -2503,16 +2503,16 @@ void sharpmz_ui(int idleState, int idle2State, int system menuItem = 0; subItem = 0; *menumask = 0; - + OsdSetTitle("Machine", OSD_ARROW_LEFT); - + OsdWrite(menuItem++, "", 0, 0); - + strcpy(sBuf, " Machine Model: "); strcat(sBuf, sharpmz_get_machine_model_string()); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + strcpy(sBuf, " CPU Speed: "); strcat(sBuf, sharpmz_get_cpu_speed_string()); 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, " exit", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + *parentstate = *menustate; *menustate = MENU_SHARPMZ_MACHINE2; break; - - + + case MENU_SHARPMZ_MACHINE2: if (menu) { *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); *menustate = MENU_SHARPMZ_MACHINE1; break; - + case 1: // CPU Speed sharpmz_set_cpu_speed((sharpmz_get_cpu_speed() + 1) & 0x07, 1); *menustate = MENU_SHARPMZ_MACHINE1; @@ -2608,7 +2608,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *menusub = 1; //*menusub_last; } break; - + case MENU_SHARPMZ_ROMS1: if(*menusub == 0) @@ -2621,11 +2621,11 @@ void sharpmz_ui(int idleState, int idle2State, int system menuItem = 0; subItem = 0; *menumask = 0; - + OsdSetTitle("Rom Management", OSD_ARROW_LEFT); - + OsdWrite(menuItem++, "", 0, 0); - + if(scrollPos == 0) { strcpy(sBuf, " Machine Model: "); @@ -2679,7 +2679,7 @@ void sharpmz_ui(int idleState, int idle2State, int system OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; } - + romEnabled = sharpmz_get_custom_rom_enabled(machineModel, CGROM_IDX); strcpy(sBuf, " Char Generator "); 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); *menumask = (*menumask << 1) | 1; } - + romEnabled = sharpmz_get_custom_rom_enabled(machineModel, KEYMAP_IDX); strcpy(sBuf, " Key Mapping "); 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); *menumask = (*menumask << 1) | 1; - + *parentstate = *menustate; *menustate = MENU_SHARPMZ_ROMS2; break; - - + + case MENU_SHARPMZ_ROMS2: if (menu) { *menustate = MENU_SHARPMZ_MACHINE1; @@ -2830,7 +2830,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *fs_MenuCancel = MENU_SHARPMZ_ROMS1; *menustate = selectFile; break; - + case 15: *menustate = MENU_SHARPMZ_MACHINE1; *menusub = *menusub_last; @@ -2843,24 +2843,24 @@ void sharpmz_ui(int idleState, int idle2State, int system *menusub = *menusub_last; } break; - + case MENU_SHARPMZ_ROM_FILE_SELECTED: 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_set_rom_file(machineModel, romType, selectedPath); *menustate = MENU_SHARPMZ_ROMS1; break; - + // DISPLAY Menu case MENU_SHARPMZ_DISPLAY1: menuItem = 0; subItem = 0; *menumask = 0; - + OsdSetTitle("Display", OSD_ARROW_LEFT); - + OsdWrite(menuItem++, "", 0, 0); - + strcpy(sBuf, " Display Type: "); strcat(sBuf, sharpmz_get_display_type_string()); 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()); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + for (; menuItem < 15; menuItem++) { OsdWrite(menuItem, "", 0, 0); } - + OsdWrite(menuItem, " exit", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + *parentstate = *menustate; *menustate = MENU_SHARPMZ_DISPLAY2; break; - + case MENU_SHARPMZ_DISPLAY2: if (menu) { *menustate = MENU_SHARPMZ_MAIN1; @@ -2964,17 +2964,17 @@ void sharpmz_ui(int idleState, int idle2State, int system *menusub = *menusub_last; } break; - + // Debug options. case MENU_SHARPMZ_DEBUG1: menuItem = 0; subItem = 0; *menumask = 0; - + OsdSetTitle("Debug", OSD_ARROW_LEFT); - + OsdWrite(menuItem++, "", 0, 0); - + strcpy(sBuf, " Select Memory Bank: "); strcat(sBuf, sharpmz_get_memory_bank_string(memoryBank)); 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()); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + // Display the debug menu only when enabled. // 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()); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + strcpy(sBuf, " Debug LEDS: "); strcat(sBuf, sharpmz_get_debug_leds_string()); 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()); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + strcpy(sBuf, " Signal Block: "); strcat(sBuf, sharpmz_get_debug_leds_bank_string()); OsdWrite(menuItem++, sBuf, *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + strcpy(sBuf, " Bank: "); strcat(sBuf, sharpmz_get_debug_leds_subbank_string()); 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, " exit", *menusub == subItem++, 0); *menumask = (*menumask << 1) | 1; - + *parentstate = *menustate; *menustate = MENU_SHARPMZ_DEBUG2; break; @@ -3073,7 +3073,7 @@ void sharpmz_ui(int idleState, int idle2State, int system *menustate = MENU_SHARPMZ_DEBUG1; break; - case 3: // CPU Frequency + case 3: // CPU Frequency debugCPUFrequency = sharpmz_get_next_debug_cpufreq(); sharpmz_set_debug_cpufreq(debugCPUFrequency, 1); *menustate = MENU_SHARPMZ_DEBUG1; @@ -3084,12 +3084,12 @@ void sharpmz_ui(int idleState, int idle2State, int system *menustate = MENU_SHARPMZ_DEBUG1; break; - case 5: // Sample Frequency + case 5: // Sample Frequency debugLedsSampleFrequency = sharpmz_get_next_debug_leds_smpfreq(); sharpmz_set_debug_leds_smpfreq(debugLedsSampleFrequency, 1); *menustate = MENU_SHARPMZ_DEBUG1; break; - + case 6: // Signal Block debugLedsBank = sharpmz_get_next_debug_leds_bank(); 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); *menustate = MENU_SHARPMZ_DEBUG1; break; - + case 8: // Exit *menustate = MENU_SHARPMZ_MAIN1; *menusub = *menusub_last; diff --git a/support/sharpmz/sharpmz.h b/support/sharpmz/sharpmz.h index 532371a..7cc6594 100644 --- a/support/sharpmz/sharpmz.h +++ b/support/sharpmz/sharpmz.h @@ -7,8 +7,8 @@ // 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 // emulation. -// -// Credits: +// +// Credits: // Copyright: (c) 2018 Philip Smart // // History: July 2018 - Initial module written. @@ -137,12 +137,12 @@ #define REGISTER_FDCROM 7 #define REGISTER_8 8 #define REGISTER_9 9 -#define REGISTER_10 10 -#define REGISTER_11 11 -#define REGISTER_12 12 +#define REGISTER_10 10 +#define REGISTER_11 11 +#define REGISTER_12 12 #define REGISTER_13 13 #define REGISTER_DEBUG 14 -#define REGISTER_DEBUG2 15 +#define REGISTER_DEBUG2 15 #define MAX_REGISTERS 16 // 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. // -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 80C @@ -191,7 +191,7 @@ const char *SHARPMZ_FAST_TAPE[] = { "Off", "2x", "4x", "8x", "16x", "32 "Off", "2x", "4x", "8x", "16x", "Off", "Off", "Off" }; 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" }; 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_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_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", "A23-16", "A15-8", "A7-0", "Signals", "", "", "", "Auto", "Config 1", "Config 2", "Config 3", "Config 4", "Config 5", "", "", @@ -344,7 +344,7 @@ enum SHARPMZ_MENU MENU_SHARPMZ_ROMS2 = 0xb5, MENU_SHARPMZ_ROM_FILE_SELECTED = 0xb6, MENU_SHARPMZ_DEBUG1 = 0xb7, - MENU_SHARPMZ_DEBUG2 = 0xb8 + MENU_SHARPMZ_DEBUG2 = 0xb8 }; // Prototypes. @@ -396,7 +396,7 @@ void sharpmz_set_machine_model(short, short); void sharpmz_set_cpu_speed(short, short); void sharpmz_set_audio_source(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_leds(short, short); void sharpmz_set_debug_leds_bank(short, short); diff --git a/support/snes/snes.cpp b/support/snes/snes.cpp index 7e33840..d232686 100644 --- a/support/snes/snes.cpp +++ b/support/snes/snes.cpp @@ -245,7 +245,7 @@ uint8_t* snes_get_header(fileTYPE *f) //PAL Regions if ((buf[addr + CartRegion] >= 0x02 && buf[addr + CartRegion] <= 0x0C) || buf[addr + CartRegion] == 0x11) - { + { hdr[3] |= 1; } diff --git a/support/st/st_ikbd.cpp b/support/st/st_ikbd.cpp index ce81c86..8a966ec 100644 --- a/support/st/st_ikbd.cpp +++ b/support/st/st_ikbd.cpp @@ -319,7 +319,7 @@ struct ikbd_command_handler_t { unsigned char length; void(*handler)(void); }; - + ikbd_command_handler_t ikbd_command_handler[] = { { 0x07, 2, ikbd_handler_mouse_button_action }, diff --git a/support/st/st_tos.cpp b/support/st/st_tos.cpp index f35c3a0..bd55179 100644 --- a/support/st/st_tos.cpp +++ b/support/st/st_tos.cpp @@ -1,1161 +1,1161 @@ -#include -#include -#include - -#include "../../hardware.h" -#include "../../menu.h" -#include "st_tos.h" -#include "../../file_io.h" -#include "../../debug.h" -#include "../../user_io.h" -#include "st_ikbd.h" -#include "../../fpga_io.h" - -#define CONFIG_FILENAME "MIST.CFG" - -typedef struct { - unsigned long system_ctrl; // system control word - char tos_img[1024]; - char cart_img[1024]; - char acsi_img[2][1024]; - char video_adjust[2]; - char sd_direct; -} tos_config_t; - -static tos_config_t config; - -#define TOS_BASE_ADDRESS_192k 0xfc0000 -#define TOS_BASE_ADDRESS_256k 0xe00000 -#define CART_BASE_ADDRESS 0xfa0000 -#define VIDEO_BASE_ADDRESS 0x010000 - -static unsigned char font[2048]; // buffer for 8x16 atari font - - // two floppies -static struct { - fileTYPE file; - unsigned char sides; - unsigned char spt; -} fdd_image[2] = {}; - -// one harddisk -fileTYPE hdd_image[2] = {}; -unsigned long hdd_direct = 0; - -static unsigned char dma_buffer[512]; - -static const char *acsi_cmd_name(int cmd) { - static const char *cmdname[] = { - "Test Drive Ready", "Restore to Zero", "Cmd $2", "Request Sense", - "Format Drive", "Read Block limits", "Reassign Blocks", "Cmd $7", - "Read Sector", "Cmd $9", "Write Sector", "Seek Block", - "Cmd $C", "Cmd $D", "Cmd $E", "Cmd $F", - "Cmd $10", "Cmd $11", "Inquiry", "Verify", - "Cmd $14", "Mode Select", "Cmd $16", "Cmd $17", - "Cmd $18", "Cmd $19", "Mode Sense", "Start/Stop Unit", - "Cmd $1C", "Cmd $1D", "Cmd $1E", "Cmd $1F", - // extended commands supported by ICD feature: - "Cmd $20", "Cmd $21", "Cmd $22", - "Read Format Capacities", "Cmd $24", "Read Capacity (10)", - "Cmd $26", "Cmd $27", "Read (10)", "Read Generation", - "Write (10)", "Seek (10)" - }; - - if (cmd > 0x2b) return NULL; - - return cmdname[cmd]; -} - -void tos_set_video_adjust(int axis, char value) { - config.video_adjust[axis] += value; - - EnableFpga(); - spi8(MIST_SET_VADJ); - spi8(config.video_adjust[0]); - spi8(config.video_adjust[1]); - DisableFpga(); -} - -char tos_get_video_adjust(int axis) { - return config.video_adjust[axis]; -} - -static void mist_memory_set_address(unsigned long a, unsigned char s, char rw) { - // printf("set addr = %x, %d, %d\n", a, s, rw); - - a |= rw ? 0x1000000 : 0; - a >>= 1; - - EnableFpga(); - spi8(MIST_SET_ADDRESS); - spi8(s); - spi8((a >> 16) & 0xff); - spi8((a >> 8) & 0xff); - spi8((a >> 0) & 0xff); - DisableFpga(); -} - -static void mist_set_control(unsigned long ctrl) { - EnableFpga(); - spi8(MIST_SET_CONTROL); - spi8((ctrl >> 24) & 0xff); - spi8((ctrl >> 16) & 0xff); - spi8((ctrl >> 8) & 0xff); - spi8((ctrl >> 0) & 0xff); - DisableFpga(); -} - -/* -static void mist_memory_read(char *data, unsigned long words) { - EnableFpga(); - spi8(MIST_READ_MEMORY); - - // transmitted bytes must be multiple of 2 (-> words) - while (words--) { - *data++ = spi_in(); - *data++ = spi_in(); - } - - DisableFpga(); -} -*/ - -static void mist_memory_write(unsigned char *data, unsigned long words) { - EnableFpga(); - spi8(MIST_WRITE_MEMORY); - - while (words--) { - spi8(*data++); - spi8(*data++); - } - - DisableFpga(); -} - -static void mist_memory_read_block(unsigned char *data) { - EnableFpga(); - spi8(MIST_READ_MEMORY); - - spi_block_read(data,0); - - DisableFpga(); -} - -static void mist_memory_write_block(unsigned char *data) { - EnableFpga(); - spi8(MIST_WRITE_MEMORY); - - spi_block_write(data,0); - - DisableFpga(); -} - -void mist_memory_set(char data, unsigned long words) { - EnableFpga(); - spi8(MIST_WRITE_MEMORY); - - while (words--) { - spi8(data); - spi8(data); - } - - DisableFpga(); -} - -// enable direct sd card access on acsi0 -void tos_set_direct_hdd(char on) { - (void)on; - config.sd_direct = 0; - - tos_debugf("ACSI: disable direct sd access"); - config.system_ctrl &= ~TOS_ACSI0_ENABLE; - hdd_direct = 0; - - // check if image access should be enabled instead - if (hdd_image[0].size) { - tos_debugf("ACSI: re-enabling image on ACSI0"); - config.system_ctrl |= TOS_ACSI0_ENABLE; - } - - mist_set_control(config.system_ctrl); -} - -char tos_get_direct_hdd() { - return 0; -} - -static void dma_ack(unsigned char status) { - EnableFpga(); - spi8(MIST_ACK_DMA); - spi8(status); - DisableFpga(); -} - -static void dma_nak(void) { - EnableFpga(); - spi8(MIST_NAK_DMA); - DisableFpga(); -} - +#include +#include +#include + +#include "../../hardware.h" +#include "../../menu.h" +#include "st_tos.h" +#include "../../file_io.h" +#include "../../debug.h" +#include "../../user_io.h" +#include "st_ikbd.h" +#include "../../fpga_io.h" + +#define CONFIG_FILENAME "MIST.CFG" + +typedef struct { + unsigned long system_ctrl; // system control word + char tos_img[1024]; + char cart_img[1024]; + char acsi_img[2][1024]; + char video_adjust[2]; + char sd_direct; +} tos_config_t; + +static tos_config_t config; + +#define TOS_BASE_ADDRESS_192k 0xfc0000 +#define TOS_BASE_ADDRESS_256k 0xe00000 +#define CART_BASE_ADDRESS 0xfa0000 +#define VIDEO_BASE_ADDRESS 0x010000 + +static unsigned char font[2048]; // buffer for 8x16 atari font + + // two floppies +static struct { + fileTYPE file; + unsigned char sides; + unsigned char spt; +} fdd_image[2] = {}; + +// one harddisk +fileTYPE hdd_image[2] = {}; +unsigned long hdd_direct = 0; + +static unsigned char dma_buffer[512]; + +static const char *acsi_cmd_name(int cmd) { + static const char *cmdname[] = { + "Test Drive Ready", "Restore to Zero", "Cmd $2", "Request Sense", + "Format Drive", "Read Block limits", "Reassign Blocks", "Cmd $7", + "Read Sector", "Cmd $9", "Write Sector", "Seek Block", + "Cmd $C", "Cmd $D", "Cmd $E", "Cmd $F", + "Cmd $10", "Cmd $11", "Inquiry", "Verify", + "Cmd $14", "Mode Select", "Cmd $16", "Cmd $17", + "Cmd $18", "Cmd $19", "Mode Sense", "Start/Stop Unit", + "Cmd $1C", "Cmd $1D", "Cmd $1E", "Cmd $1F", + // extended commands supported by ICD feature: + "Cmd $20", "Cmd $21", "Cmd $22", + "Read Format Capacities", "Cmd $24", "Read Capacity (10)", + "Cmd $26", "Cmd $27", "Read (10)", "Read Generation", + "Write (10)", "Seek (10)" + }; + + if (cmd > 0x2b) return NULL; + + return cmdname[cmd]; +} + +void tos_set_video_adjust(int axis, char value) { + config.video_adjust[axis] += value; + + EnableFpga(); + spi8(MIST_SET_VADJ); + spi8(config.video_adjust[0]); + spi8(config.video_adjust[1]); + DisableFpga(); +} + +char tos_get_video_adjust(int axis) { + return config.video_adjust[axis]; +} + +static void mist_memory_set_address(unsigned long a, unsigned char s, char rw) { + // printf("set addr = %x, %d, %d\n", a, s, rw); + + a |= rw ? 0x1000000 : 0; + a >>= 1; + + EnableFpga(); + spi8(MIST_SET_ADDRESS); + spi8(s); + spi8((a >> 16) & 0xff); + spi8((a >> 8) & 0xff); + spi8((a >> 0) & 0xff); + DisableFpga(); +} + +static void mist_set_control(unsigned long ctrl) { + EnableFpga(); + spi8(MIST_SET_CONTROL); + spi8((ctrl >> 24) & 0xff); + spi8((ctrl >> 16) & 0xff); + spi8((ctrl >> 8) & 0xff); + spi8((ctrl >> 0) & 0xff); + DisableFpga(); +} + +/* +static void mist_memory_read(char *data, unsigned long words) { + EnableFpga(); + spi8(MIST_READ_MEMORY); + + // transmitted bytes must be multiple of 2 (-> words) + while (words--) { + *data++ = spi_in(); + *data++ = spi_in(); + } + + DisableFpga(); +} +*/ + +static void mist_memory_write(unsigned char *data, unsigned long words) { + EnableFpga(); + spi8(MIST_WRITE_MEMORY); + + while (words--) { + spi8(*data++); + spi8(*data++); + } + + DisableFpga(); +} + +static void mist_memory_read_block(unsigned char *data) { + EnableFpga(); + spi8(MIST_READ_MEMORY); + + spi_block_read(data,0); + + DisableFpga(); +} + +static void mist_memory_write_block(unsigned char *data) { + EnableFpga(); + spi8(MIST_WRITE_MEMORY); + + spi_block_write(data,0); + + DisableFpga(); +} + +void mist_memory_set(char data, unsigned long words) { + EnableFpga(); + spi8(MIST_WRITE_MEMORY); + + while (words--) { + spi8(data); + spi8(data); + } + + DisableFpga(); +} + +// enable direct sd card access on acsi0 +void tos_set_direct_hdd(char on) { + (void)on; + config.sd_direct = 0; + + tos_debugf("ACSI: disable direct sd access"); + config.system_ctrl &= ~TOS_ACSI0_ENABLE; + hdd_direct = 0; + + // check if image access should be enabled instead + if (hdd_image[0].size) { + tos_debugf("ACSI: re-enabling image on ACSI0"); + config.system_ctrl |= TOS_ACSI0_ENABLE; + } + + mist_set_control(config.system_ctrl); +} + +char tos_get_direct_hdd() { + return 0; +} + +static void dma_ack(unsigned char status) { + EnableFpga(); + spi8(MIST_ACK_DMA); + spi8(status); + DisableFpga(); +} + +static void dma_nak(void) { + EnableFpga(); + spi8(MIST_NAK_DMA); + DisableFpga(); +} + static char user_io_dip_switch1() { return 0; } - -static void handle_acsi(unsigned char *buffer) { - static unsigned char asc[2] = { 0,0 }; - unsigned char target = buffer[19] >> 5; - unsigned char device = buffer[10] >> 5; - unsigned char cmd = buffer[9]; - unsigned int dma_address = 256 * 256 * buffer[0] + - 256 * buffer[1] + (buffer[2] & 0xfe); - unsigned char scnt = buffer[3]; - unsigned long lba = 256 * 256 * (buffer[10] & 0x1f) + - 256 * buffer[11] + buffer[12]; - unsigned short length = buffer[13]; - if (length == 0) length = 256; - - if (user_io_dip_switch1()) { - tos_debugf("ACSI: target %u.%u, \"%s\" (%02x)", target, device, acsi_cmd_name(cmd), cmd); - tos_debugf("ACSI: lba %lu (%lx), length %u", lba, lba, length); - tos_debugf("DMA: scnt %u, addr %X", scnt, dma_address); - - if (buffer[20] == 0xa5) { - tos_debugf("DMA: fifo %u/%u %x %s", - (buffer[21] >> 4) & 0x0f, buffer[21] & 0x0f, - buffer[22], (buffer[2] & 1) ? "OUT" : "IN"); - tos_debugf("DMA stat=%x, mode=%x, fdc_irq=%d, acsi_irq=%d", - buffer[23], buffer[24], buffer[25], buffer[26]); - } - } - - // only a harddisk on ACSI 0/1 is supported - // ACSI 0/1 is only supported if a image is loaded - // ACSI 0 is only supported for direct IO - if (((target < 2) && (hdd_image[target].size != 0)) || - ((target == 0) && hdd_direct)) { - unsigned long blocks = hdd_image[target].size / 512; - - // if in hdd direct mode then hdd_direct contains device sizee - if (hdd_direct && target == 0) blocks = hdd_direct; - - // only lun0 is fully supported - switch (cmd) { - case 0x25: - if (device == 0) { - bzero(dma_buffer, 512); - dma_buffer[0] = (blocks - 1) >> 24; - dma_buffer[1] = (blocks - 1) >> 16; - dma_buffer[2] = (blocks - 1) >> 8; - dma_buffer[3] = (blocks - 1) >> 0; - dma_buffer[6] = 2; // 512 bytes per block - - mist_memory_write(dma_buffer, 4); - - dma_ack(0x00); - asc[target] = 0x00; - } - else { - dma_ack(0x02); - asc[target] = 0x25; - } - break; - - case 0x00: // test drive ready - case 0x04: // format - if (device == 0) { - asc[target] = 0x00; - dma_ack(0x00); - } - else { - asc[target] = 0x25; - dma_ack(0x02); - } - break; - - case 0x03: // request sense - if (device != 0) - asc[target] = 0x25; - - bzero(dma_buffer, 512); - dma_buffer[7] = 0x0b; - if (asc[target] != 0) { - dma_buffer[2] = 0x05; - dma_buffer[12] = asc[target]; - } - mist_memory_write(dma_buffer, 9); // 18 bytes - dma_ack(0x00); - asc[target] = 0x00; - break; - - case 0x08: // read sector - case 0x28: // read (10) - if (device == 0) { - if (cmd == 0x28) { - lba = - 256 * 256 * 256 * buffer[11] + - 256 * 256 * buffer[12] + - 256 * buffer[13] + - buffer[14]; - - length = 256 * buffer[16] + buffer[17]; - // printf("READ(10) %d, %d\n", lba, length); - } - - if (lba + length <= blocks) { - DISKLED_ON; - while (length) { - FileSeekLBA(&hdd_image[target], lba++); - FileReadSec(&hdd_image[target], dma_buffer); - // hexdump(dma_buffer, 32, 0); - mist_memory_write_block(dma_buffer); - length--; - } - DISKLED_OFF; - dma_ack(0x00); - asc[target] = 0x00; - } - else { - tos_debugf("ACSI: read (%lu+%u) exceeds device limits (%lu)", - lba, length, blocks); - dma_ack(0x02); - asc[target] = 0x21; - } - } - else { - dma_ack(0x02); - asc[target] = 0x25; - } - break; - - case 0x0a: // write sector - case 0x2a: // write (10) - if (device == 0) { - if (cmd == 0x2a) { - lba = - 256 * 256 * 256 * buffer[11] + - 256 * 256 * buffer[12] + - 256 * buffer[13] + - buffer[14]; - - length = 256 * buffer[16] + buffer[17]; - - // printf("WRITE(10) %d, %d\n", lba, length); - } - - if (lba + length <= blocks) { - DISKLED_ON; - while (length) { - mist_memory_read_block(dma_buffer); - FileSeekLBA(&hdd_image[target], lba++); - FileWriteSec(&hdd_image[target], dma_buffer); - length--; - } - DISKLED_OFF; - dma_ack(0x00); - asc[target] = 0x00; - } - else { - tos_debugf("ACSI: write (%lu+%u) exceeds device limits (%lu)", - lba, length, blocks); - dma_ack(0x02); - asc[target] = 0x21; - } - } - else { - dma_ack(0x02); - asc[target] = 0x25; - } - break; - - case 0x12: // inquiry - if (hdd_direct && target == 0) tos_debugf("ACSI: Inquiry DIRECT"); - else tos_debugf("ACSI: Inquiry %s", hdd_image[target].name); - bzero(dma_buffer, 512); - dma_buffer[2] = 2; // SCSI-2 - dma_buffer[4] = length - 5; // len - memcpy(dma_buffer + 8, "MIST ", 8); // Vendor - memcpy(dma_buffer + 16, " ", 16); // Clear device entry - if (hdd_direct && target == 0) memcpy(dma_buffer + 16, "SD DIRECT", 9);// Device - else memcpy(dma_buffer + 16, hdd_image[target].name, 11); - memcpy(dma_buffer + 32, "ATH ", 4); // Product revision - memcpy(dma_buffer + 36, VDATE " ", 8); // Serial number - if (device != 0) dma_buffer[0] = 0x7f; - mist_memory_write(dma_buffer, length / 2); - dma_ack(0x00); - asc[target] = 0x00; - break; - - case 0x1a: // mode sense - if (device == 0) { - tos_debugf("ACSI: mode sense, blocks = %lu", blocks); - bzero(dma_buffer, 512); - dma_buffer[3] = 8; // size of extent descriptor list - dma_buffer[5] = blocks >> 16; - dma_buffer[6] = blocks >> 8; - dma_buffer[7] = blocks; - dma_buffer[10] = 2; // byte 1 of block size in bytes (512) - mist_memory_write(dma_buffer, length / 2); - dma_ack(0x00); - asc[target] = 0x00; - } - else { - asc[target] = 0x25; - dma_ack(0x02); - } - break; - -#if 0 - case 0x1f: // ICD command? - tos_debugf("ACSI: ICD command %s ($%02x)", - acsi_cmd_name(buffer[10] & 0x1f), buffer[10] & 0x1f); - asc[target] = 0x05; - dma_ack(0x02); - break; -#endif - - default: - tos_debugf("ACSI: >>>>>>>>>>>> Unsupported command <<<<<<<<<<<<<<<<"); - asc[target] = 0x20; - dma_ack(0x02); - break; - } - } - else { - tos_debugf("ACSI: Request for unsupported target"); - - // tell acsi state machine that io controller is done - // but don't generate a acsi irq - dma_nak(); - } -} - -static void handle_fdc(unsigned char *buffer) { - // extract contents - unsigned int dma_address = 256 * 256 * buffer[0] + - 256 * buffer[1] + (buffer[2] & 0xfe); - unsigned char scnt = buffer[3]; - unsigned char fdc_cmd = buffer[4]; - unsigned char fdc_track = buffer[5]; - unsigned char fdc_sector = buffer[6]; - //unsigned char fdc_data = buffer[7]; - unsigned char drv_sel = 3 - ((buffer[8] >> 2) & 3); - unsigned char drv_side = 1 - ((buffer[8] >> 1) & 1); - - // tos_debugf("FDC: sel %d, cmd %x", drv_sel, fdc_cmd); - - // check if a matching disk image has been inserted - if (drv_sel && fdd_image[drv_sel - 1].file.size) { - // if the fdc has been asked to write protect the disks, then - // write sector commands should never reach the oi controller - - // read/write sector command - if ((fdc_cmd & 0xc0) == 0x80) { - // convert track/sector/side into disk offset - unsigned int offset = drv_side; - offset += fdc_track * fdd_image[drv_sel - 1].sides; - offset *= fdd_image[drv_sel - 1].spt; - offset += fdc_sector - 1; - - if (user_io_dip_switch1()) { - tos_debugf("FDC %s req %d sec (%c, SD:%d, T:%d, S:%d = %d) -> %X", - (fdc_cmd & 0x10) ? "multi" : "single", scnt, - 'A' + drv_sel - 1, drv_side, fdc_track, fdc_sector, offset, - dma_address); - } - - while (scnt) { - // check if requested sector is in range - if ((fdc_sector > 0) && (fdc_sector <= fdd_image[drv_sel - 1].spt)) { - - DISKLED_ON; - - FileSeek(&fdd_image[drv_sel - 1].file, offset, SEEK_SET); - - if ((fdc_cmd & 0xe0) == 0x80) { - // read from disk ... - FileReadSec(&fdd_image[drv_sel - 1].file, dma_buffer); - // ... and copy to ram - mist_memory_write_block(dma_buffer); - } - else { - // read from ram ... - mist_memory_read_block(dma_buffer); - // ... and write to disk - FileWriteSec(&(fdd_image[drv_sel - 1].file), dma_buffer); - } - - DISKLED_OFF; - } - else - tos_debugf("sector out of range"); - - scnt--; - dma_address += 512; - offset += 1; - } - dma_ack(0x00); - } - else if ((fdc_cmd & 0xc0) == 0xc0) { - char msg[32]; - - if ((fdc_cmd & 0xe0) == 0xc0) printf("READ ADDRESS\n"); - - if ((fdc_cmd & 0xf0) == 0xe0) { - printf("READ TRACK %d SIDE %d\n", fdc_track, drv_side); - sprintf(msg, "RD TRK %d S %d", fdc_track, drv_side); - InfoMessage(msg); - } - - if ((fdc_cmd & 0xf0) == 0xf0) { - printf("WRITE TRACK %d SIDE %d\n", fdc_track, drv_side); - sprintf(msg, "WR TRK %d S %d", fdc_track, drv_side); - InfoMessage(msg); - } - - printf("scnt = %d\n", scnt); - - dma_ack(0x00); - } - } -} - -static void mist_get_dmastate() { - unsigned char buffer[32]; - - EnableFpga(); - spi8(MIST_GET_DMASTATE); - spi_read(buffer, 32,0); - DisableFpga(); - - // check if acsi is busy - if (buffer[19] & 0x01) - handle_acsi(buffer); - - // check if fdc is busy - if (buffer[8] & 0x01) - handle_fdc(buffer); -} - -// color test, used to test the shifter without CPU/TOS -#define COLORS 20 -#define PLANES 4 - -static void tos_write(const char *str); -/* -static void tos_color_test() { - unsigned short buffer[COLORS][PLANES]; - - int y; - for (y = 0; y<13; y++) { - int i, j; - for (i = 0; i> n; - - *(d + 1) = *d; - } - } -} - -void tos_load_cartridge(const char *name) -{ - fileTYPE file = {}; - - if (name) - strncpy(config.cart_img, name, 11); - - // upload cartridge - if (config.cart_img[0] && FileOpen(&file, config.cart_img)) { - int i; - unsigned char buffer[512]; - - tos_debugf("%s:\n size = %llu", config.cart_img, file.size); - - int blocks = file.size / 512; - tos_debugf(" blocks = %d", blocks); - - - DISKLED_ON; - for (i = 0; i= 256 * 1024) - tos_base = TOS_BASE_ADDRESS_256k; - else if (file.size != 192 * 1024) - tos_debugf("WARNING: Unexpected TOS size!"); - - int blocks = file.size / 512; - tos_debugf(" blocks = %d", blocks); - - tos_debugf(" address = $%08lx", tos_base); - - // clear first 16k - mist_memory_set_address(0, 16384 / 512, 0); - mist_memory_set(0x00, 8192); - - time = GetTimer(0); - tos_debugf("Uploading ..."); - - for (i = 0; i= 0) { - printf("Failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); - - hexdump(buffer, 512, 0); - puts(""); - hexdump(b2, 512, 0); - - // re-read to check whether read or write failed - bzero(buffer, 512); - mist_memory_set_address(tos_base + i * 512, 1, 1); - mist_memory_read_block(buffer); - - ok = -1; - for (j = 0; j<512; j++) - if (buffer[j] != b2[j]) - if (ok < 0) - ok = j; - - if (ok >= 0) { - printf("Re-read failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); - hexdump(buffer, 512, 0); - } - else - printf("Re-read ok!\n"); - - for (;;); - } - } - printf("Verify: %s\n", ok ? "ok" : "failed"); - } -#endif - - time = GetTimer(0) - time; - tos_debugf("TOS.IMG uploaded in %lu ms (%llu kB/s / %llu kBit/s)", - time >> 20, file.size / (time >> 20), 8 * file.size / (time >> 20)); - - FileClose(&file); - - } - else { - tos_debugf("Unable to find tos.img"); - tos_write("Unable to find tos.img"); - - DISKLED_OFF; - return; - } - - DISKLED_OFF; - - // This is the initial boot if no name was given. Otherwise the - // user reloaded a new os - if (!name) { - // load - tos_load_cartridge(NULL); - - // try to open both floppies - int i; - for (i = 0; i<2; i++) { - //char msg[] = "Found floppy disk image for drive X: "; - char name[] = "DISK_A.ST"; - //msg[34] = name[5] = 'A' + i; - - tos_insert_disk(i, name); - } - - if (config.sd_direct) { - tos_set_direct_hdd(1); - tos_write("Enabling direct SD card access via ACSI0"); - } - else { - // try to open harddisk image - for (i = 0; i<2; i++) { - if (FileOpen(&file, config.acsi_img[i])) - { - FileClose(&file); - char msg[] = "Found hard disk image for ACSIX"; - msg[30] = '0' + i; - tos_write(msg); - tos_select_hdd_image(i, config.acsi_img[i]); - } - } - } - } - - tos_write("Booting ... "); - - // clear sector count register -> stop DMA - mist_memory_set_address(0, 0, 0); - - ikbd_reset(); - - // let cpu run (release reset) - config.system_ctrl &= ~TOS_CONTROL_CPU_RESET; - mist_set_control(config.system_ctrl); -} - -/* -static unsigned long get_long(char *buffer, int offset) { - unsigned long retval = 0; - int i; - - for (i = 0; i<4; i++) - retval = (retval << 8) + *(unsigned char*)(buffer + offset + i); - - return retval; -} -*/ - -void tos_poll() { - // 1 == button not pressed, 2 = 1 sec exceeded, else timer running - static unsigned long timer = 1; - - mist_get_dmastate(); - - // check the user button - if (user_io_user_button()) { - if (timer == 1) - timer = GetTimer(1000); - else if (timer != 2) - if (CheckTimer(timer)) { - tos_reset(1); - timer = 2; - } - } - else { - // released while still running (< 1 sec) - if (!(timer & 3)) - tos_reset(0); - - timer = 1; - } -} - -void tos_update_sysctrl(unsigned long n) { - // printf(">>>>>>>>>>>> set sys %x, eth is %s\n", n, (n&TOS_CONTROL_ETHERNET)?"on":"off"); - - // some of the usb drivers also call this without knowing which - // core is running. So make sure this only happens if the Atari ST (MIST) - // core is running - if (user_io_core_type() == CORE_TYPE_MIST) { - config.system_ctrl = n; - mist_set_control(config.system_ctrl); - } -} - -static void nice_name(char *dest, char *src) { - char *c; - - // copy and append nul - strncpy(dest, src, 8); - for (c = dest + 7; *c == ' '; c--); c++; - *c++ = '.'; - strncpy(c, src + 8, 3); - for (c += 2; *c == ' '; c--); c++; - *c++ = '\0'; -} - -static char buffer[17]; // local buffer to assemble file name (8+3+2) - -char *tos_get_disk_name(int index) { - fileTYPE file; - - if (index <= 1) - file = fdd_image[index].file; - else - file = hdd_image[index - 2]; - - if (!file.size) { - strcpy(buffer, "* no disk *"); - return buffer; - } - - nice_name(buffer, file.name); - - return buffer; -} - -char *tos_get_image_name() { - nice_name(buffer, config.tos_img); - return buffer; -} - -char *tos_get_cartridge_name() { - if (!config.cart_img[0]) // no cart name set - strcpy(buffer, "* no cartridge *"); - else - nice_name(buffer, config.cart_img); - - return buffer; -} - -char tos_disk_is_inserted(int index) { - if (index <= 1) - return (fdd_image[index].file.size != 0); - - return hdd_image[index - 2].size != 0; -} - -void tos_select_hdd_image(int i, const char *name) -{ - tos_debugf("Select ACSI%c image %s", '0' + i, name); - - if(name) strcpy(config.acsi_img[i], name); - else config.acsi_img[i][0] = 0; - - if (!name) - { - FileClose(&hdd_image[i]); - hdd_image[i].size = 0; - config.system_ctrl &= ~(TOS_ACSI0_ENABLE << i); - } - else - { - if (FileOpen(&hdd_image[i], name)) - { - config.system_ctrl |= (TOS_ACSI0_ENABLE << i); - } - } - - // update system control - mist_set_control(config.system_ctrl); -} - -void tos_insert_disk(int i, const char *name) -{ - if (i > 1) - { - tos_select_hdd_image(i - 2, name); - return; - } - - tos_debugf("%c: eject", i + 'A'); - - // toggle write protect bit to help tos detect a media change - int wp_bit = (!i) ? TOS_CONTROL_FDC_WR_PROT_A : TOS_CONTROL_FDC_WR_PROT_B; - - // any disk ejected is "write protected" (as nothing covers the write protect mechanism) - mist_set_control(config.system_ctrl | wp_bit); - - // first "eject" disk - fdd_image[i].file.size = 0; - fdd_image[i].sides = 1; - fdd_image[i].spt = 0; - FileClose(&fdd_image[i].file); - - // no new disk given? - if (!name) return; - - // open floppy - if (!FileOpen(&fdd_image[i].file, name)) return; - - tos_debugf("%c: insert %s", i + 'A', name); - - // check image size and parameters - - // check if image size suggests it's a two sided disk - if (fdd_image[i].file.size > 85 * 11 * 512) - fdd_image[i].sides = 2; - - // try common sector/track values - int m, s, t; - for (m = 0; m <= 2; m++) // multiplier for hd/ed disks - for (s = 9; s <= 12; s++) - for (t = 78; t <= 85; t++) - if (512 * (1 << m)*s*t*fdd_image[i].sides == fdd_image[i].file.size) - fdd_image[i].spt = s*(1 << m); - - - - if (!fdd_image[i].spt) { - // read first sector from disk - /* - if (MMC_Read(0, dma_buffer)) { - fdd_image[i].spt = dma_buffer[24] + 256 * dma_buffer[25]; - fdd_image[i].sides = dma_buffer[26] + 256 * dma_buffer[27]; - } - else - */ - fdd_image[i].file.size = 0; - } - - if (fdd_image[i].file.size) { - // restore state of write protect bit - tos_update_sysctrl(config.system_ctrl); - tos_debugf("%c: detected %d sides with %d sectors per track", - i + 'A', fdd_image[i].sides, fdd_image[i].spt); - } -} - -// force ejection of all disks (SD card has been removed) -void tos_eject_all() { - int i; - for (i = 0; i<2; i++) - tos_insert_disk(i, NULL); - - // ejecting an SD card while a hdd image is mounted may be a bad idea - for (i = 0; i<2; i++) { - if (hdd_direct) - hdd_direct = 0; - - if (hdd_image[i].size) { - InfoMessage("Card removed:\nDisabling Harddisk!"); - hdd_image[i].size = 0; - } - } -} - -void tos_reset(char cold) { - ikbd_reset(); - - tos_update_sysctrl(config.system_ctrl | TOS_CONTROL_CPU_RESET); // set reset - - if (cold) { -#if 0 // clearing mem should be sifficient. But currently we upload TOS as it may be damaged - // clear first 16k - mist_memory_set_address(8); - mist_memory_set(0x00, 8192 - 4); -#else - tos_upload(NULL); -#endif - } - - tos_update_sysctrl(config.system_ctrl & ~TOS_CONTROL_CPU_RESET); // release reset -} - -unsigned long tos_system_ctrl(void) -{ - return config.system_ctrl; -} - -void tos_config_init(void) -{ - // set default values - config.system_ctrl = TOS_MEMCONFIG_4M | TOS_CONTROL_BLITTER; - strcpy(config.tos_img, "TOS.IMG"); - config.cart_img[0] = 0; - strcpy(config.acsi_img[0], "HARDDISK.HD"); - config.acsi_img[1][0] = 0; - config.video_adjust[0] = config.video_adjust[1] = 0; - - // try to load config - int size = FileLoadConfig(CONFIG_FILENAME, 0, 0); - if (size>0) - { - tos_debugf("Configuration file size: %u (should be %u)", size, sizeof(tos_config_t)); - if (size == sizeof(tos_config_t)) - { - FileLoadConfig(CONFIG_FILENAME, &config, size); - } - } - - // ethernet is auto detected later - config.system_ctrl &= ~TOS_CONTROL_ETHERNET; -} - -// save configuration -void tos_config_save(void) -{ - FileSaveConfig(CONFIG_FILENAME, &config, sizeof(tos_config_t)); -} + +static void handle_acsi(unsigned char *buffer) { + static unsigned char asc[2] = { 0,0 }; + unsigned char target = buffer[19] >> 5; + unsigned char device = buffer[10] >> 5; + unsigned char cmd = buffer[9]; + unsigned int dma_address = 256 * 256 * buffer[0] + + 256 * buffer[1] + (buffer[2] & 0xfe); + unsigned char scnt = buffer[3]; + unsigned long lba = 256 * 256 * (buffer[10] & 0x1f) + + 256 * buffer[11] + buffer[12]; + unsigned short length = buffer[13]; + if (length == 0) length = 256; + + if (user_io_dip_switch1()) { + tos_debugf("ACSI: target %u.%u, \"%s\" (%02x)", target, device, acsi_cmd_name(cmd), cmd); + tos_debugf("ACSI: lba %lu (%lx), length %u", lba, lba, length); + tos_debugf("DMA: scnt %u, addr %X", scnt, dma_address); + + if (buffer[20] == 0xa5) { + tos_debugf("DMA: fifo %u/%u %x %s", + (buffer[21] >> 4) & 0x0f, buffer[21] & 0x0f, + buffer[22], (buffer[2] & 1) ? "OUT" : "IN"); + tos_debugf("DMA stat=%x, mode=%x, fdc_irq=%d, acsi_irq=%d", + buffer[23], buffer[24], buffer[25], buffer[26]); + } + } + + // only a harddisk on ACSI 0/1 is supported + // ACSI 0/1 is only supported if a image is loaded + // ACSI 0 is only supported for direct IO + if (((target < 2) && (hdd_image[target].size != 0)) || + ((target == 0) && hdd_direct)) { + unsigned long blocks = hdd_image[target].size / 512; + + // if in hdd direct mode then hdd_direct contains device sizee + if (hdd_direct && target == 0) blocks = hdd_direct; + + // only lun0 is fully supported + switch (cmd) { + case 0x25: + if (device == 0) { + bzero(dma_buffer, 512); + dma_buffer[0] = (blocks - 1) >> 24; + dma_buffer[1] = (blocks - 1) >> 16; + dma_buffer[2] = (blocks - 1) >> 8; + dma_buffer[3] = (blocks - 1) >> 0; + dma_buffer[6] = 2; // 512 bytes per block + + mist_memory_write(dma_buffer, 4); + + dma_ack(0x00); + asc[target] = 0x00; + } + else { + dma_ack(0x02); + asc[target] = 0x25; + } + break; + + case 0x00: // test drive ready + case 0x04: // format + if (device == 0) { + asc[target] = 0x00; + dma_ack(0x00); + } + else { + asc[target] = 0x25; + dma_ack(0x02); + } + break; + + case 0x03: // request sense + if (device != 0) + asc[target] = 0x25; + + bzero(dma_buffer, 512); + dma_buffer[7] = 0x0b; + if (asc[target] != 0) { + dma_buffer[2] = 0x05; + dma_buffer[12] = asc[target]; + } + mist_memory_write(dma_buffer, 9); // 18 bytes + dma_ack(0x00); + asc[target] = 0x00; + break; + + case 0x08: // read sector + case 0x28: // read (10) + if (device == 0) { + if (cmd == 0x28) { + lba = + 256 * 256 * 256 * buffer[11] + + 256 * 256 * buffer[12] + + 256 * buffer[13] + + buffer[14]; + + length = 256 * buffer[16] + buffer[17]; + // printf("READ(10) %d, %d\n", lba, length); + } + + if (lba + length <= blocks) { + DISKLED_ON; + while (length) { + FileSeekLBA(&hdd_image[target], lba++); + FileReadSec(&hdd_image[target], dma_buffer); + // hexdump(dma_buffer, 32, 0); + mist_memory_write_block(dma_buffer); + length--; + } + DISKLED_OFF; + dma_ack(0x00); + asc[target] = 0x00; + } + else { + tos_debugf("ACSI: read (%lu+%u) exceeds device limits (%lu)", + lba, length, blocks); + dma_ack(0x02); + asc[target] = 0x21; + } + } + else { + dma_ack(0x02); + asc[target] = 0x25; + } + break; + + case 0x0a: // write sector + case 0x2a: // write (10) + if (device == 0) { + if (cmd == 0x2a) { + lba = + 256 * 256 * 256 * buffer[11] + + 256 * 256 * buffer[12] + + 256 * buffer[13] + + buffer[14]; + + length = 256 * buffer[16] + buffer[17]; + + // printf("WRITE(10) %d, %d\n", lba, length); + } + + if (lba + length <= blocks) { + DISKLED_ON; + while (length) { + mist_memory_read_block(dma_buffer); + FileSeekLBA(&hdd_image[target], lba++); + FileWriteSec(&hdd_image[target], dma_buffer); + length--; + } + DISKLED_OFF; + dma_ack(0x00); + asc[target] = 0x00; + } + else { + tos_debugf("ACSI: write (%lu+%u) exceeds device limits (%lu)", + lba, length, blocks); + dma_ack(0x02); + asc[target] = 0x21; + } + } + else { + dma_ack(0x02); + asc[target] = 0x25; + } + break; + + case 0x12: // inquiry + if (hdd_direct && target == 0) tos_debugf("ACSI: Inquiry DIRECT"); + else tos_debugf("ACSI: Inquiry %s", hdd_image[target].name); + bzero(dma_buffer, 512); + dma_buffer[2] = 2; // SCSI-2 + dma_buffer[4] = length - 5; // len + memcpy(dma_buffer + 8, "MIST ", 8); // Vendor + memcpy(dma_buffer + 16, " ", 16); // Clear device entry + if (hdd_direct && target == 0) memcpy(dma_buffer + 16, "SD DIRECT", 9);// Device + else memcpy(dma_buffer + 16, hdd_image[target].name, 11); + memcpy(dma_buffer + 32, "ATH ", 4); // Product revision + memcpy(dma_buffer + 36, VDATE " ", 8); // Serial number + if (device != 0) dma_buffer[0] = 0x7f; + mist_memory_write(dma_buffer, length / 2); + dma_ack(0x00); + asc[target] = 0x00; + break; + + case 0x1a: // mode sense + if (device == 0) { + tos_debugf("ACSI: mode sense, blocks = %lu", blocks); + bzero(dma_buffer, 512); + dma_buffer[3] = 8; // size of extent descriptor list + dma_buffer[5] = blocks >> 16; + dma_buffer[6] = blocks >> 8; + dma_buffer[7] = blocks; + dma_buffer[10] = 2; // byte 1 of block size in bytes (512) + mist_memory_write(dma_buffer, length / 2); + dma_ack(0x00); + asc[target] = 0x00; + } + else { + asc[target] = 0x25; + dma_ack(0x02); + } + break; + +#if 0 + case 0x1f: // ICD command? + tos_debugf("ACSI: ICD command %s ($%02x)", + acsi_cmd_name(buffer[10] & 0x1f), buffer[10] & 0x1f); + asc[target] = 0x05; + dma_ack(0x02); + break; +#endif + + default: + tos_debugf("ACSI: >>>>>>>>>>>> Unsupported command <<<<<<<<<<<<<<<<"); + asc[target] = 0x20; + dma_ack(0x02); + break; + } + } + else { + tos_debugf("ACSI: Request for unsupported target"); + + // tell acsi state machine that io controller is done + // but don't generate a acsi irq + dma_nak(); + } +} + +static void handle_fdc(unsigned char *buffer) { + // extract contents + unsigned int dma_address = 256 * 256 * buffer[0] + + 256 * buffer[1] + (buffer[2] & 0xfe); + unsigned char scnt = buffer[3]; + unsigned char fdc_cmd = buffer[4]; + unsigned char fdc_track = buffer[5]; + unsigned char fdc_sector = buffer[6]; + //unsigned char fdc_data = buffer[7]; + unsigned char drv_sel = 3 - ((buffer[8] >> 2) & 3); + unsigned char drv_side = 1 - ((buffer[8] >> 1) & 1); + + // tos_debugf("FDC: sel %d, cmd %x", drv_sel, fdc_cmd); + + // check if a matching disk image has been inserted + if (drv_sel && fdd_image[drv_sel - 1].file.size) { + // if the fdc has been asked to write protect the disks, then + // write sector commands should never reach the oi controller + + // read/write sector command + if ((fdc_cmd & 0xc0) == 0x80) { + // convert track/sector/side into disk offset + unsigned int offset = drv_side; + offset += fdc_track * fdd_image[drv_sel - 1].sides; + offset *= fdd_image[drv_sel - 1].spt; + offset += fdc_sector - 1; + + if (user_io_dip_switch1()) { + tos_debugf("FDC %s req %d sec (%c, SD:%d, T:%d, S:%d = %d) -> %X", + (fdc_cmd & 0x10) ? "multi" : "single", scnt, + 'A' + drv_sel - 1, drv_side, fdc_track, fdc_sector, offset, + dma_address); + } + + while (scnt) { + // check if requested sector is in range + if ((fdc_sector > 0) && (fdc_sector <= fdd_image[drv_sel - 1].spt)) { + + DISKLED_ON; + + FileSeek(&fdd_image[drv_sel - 1].file, offset, SEEK_SET); + + if ((fdc_cmd & 0xe0) == 0x80) { + // read from disk ... + FileReadSec(&fdd_image[drv_sel - 1].file, dma_buffer); + // ... and copy to ram + mist_memory_write_block(dma_buffer); + } + else { + // read from ram ... + mist_memory_read_block(dma_buffer); + // ... and write to disk + FileWriteSec(&(fdd_image[drv_sel - 1].file), dma_buffer); + } + + DISKLED_OFF; + } + else + tos_debugf("sector out of range"); + + scnt--; + dma_address += 512; + offset += 1; + } + dma_ack(0x00); + } + else if ((fdc_cmd & 0xc0) == 0xc0) { + char msg[32]; + + if ((fdc_cmd & 0xe0) == 0xc0) printf("READ ADDRESS\n"); + + if ((fdc_cmd & 0xf0) == 0xe0) { + printf("READ TRACK %d SIDE %d\n", fdc_track, drv_side); + sprintf(msg, "RD TRK %d S %d", fdc_track, drv_side); + InfoMessage(msg); + } + + if ((fdc_cmd & 0xf0) == 0xf0) { + printf("WRITE TRACK %d SIDE %d\n", fdc_track, drv_side); + sprintf(msg, "WR TRK %d S %d", fdc_track, drv_side); + InfoMessage(msg); + } + + printf("scnt = %d\n", scnt); + + dma_ack(0x00); + } + } +} + +static void mist_get_dmastate() { + unsigned char buffer[32]; + + EnableFpga(); + spi8(MIST_GET_DMASTATE); + spi_read(buffer, 32,0); + DisableFpga(); + + // check if acsi is busy + if (buffer[19] & 0x01) + handle_acsi(buffer); + + // check if fdc is busy + if (buffer[8] & 0x01) + handle_fdc(buffer); +} + +// color test, used to test the shifter without CPU/TOS +#define COLORS 20 +#define PLANES 4 + +static void tos_write(const char *str); +/* +static void tos_color_test() { + unsigned short buffer[COLORS][PLANES]; + + int y; + for (y = 0; y<13; y++) { + int i, j; + for (i = 0; i> n; + + *(d + 1) = *d; + } + } +} + +void tos_load_cartridge(const char *name) +{ + fileTYPE file = {}; + + if (name) + strncpy(config.cart_img, name, 11); + + // upload cartridge + if (config.cart_img[0] && FileOpen(&file, config.cart_img)) { + int i; + unsigned char buffer[512]; + + tos_debugf("%s:\n size = %llu", config.cart_img, file.size); + + int blocks = file.size / 512; + tos_debugf(" blocks = %d", blocks); + + + DISKLED_ON; + for (i = 0; i= 256 * 1024) + tos_base = TOS_BASE_ADDRESS_256k; + else if (file.size != 192 * 1024) + tos_debugf("WARNING: Unexpected TOS size!"); + + int blocks = file.size / 512; + tos_debugf(" blocks = %d", blocks); + + tos_debugf(" address = $%08lx", tos_base); + + // clear first 16k + mist_memory_set_address(0, 16384 / 512, 0); + mist_memory_set(0x00, 8192); + + time = GetTimer(0); + tos_debugf("Uploading ..."); + + for (i = 0; i= 0) { + printf("Failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); + + hexdump(buffer, 512, 0); + puts(""); + hexdump(b2, 512, 0); + + // re-read to check whether read or write failed + bzero(buffer, 512); + mist_memory_set_address(tos_base + i * 512, 1, 1); + mist_memory_read_block(buffer); + + ok = -1; + for (j = 0; j<512; j++) + if (buffer[j] != b2[j]) + if (ok < 0) + ok = j; + + if (ok >= 0) { + printf("Re-read failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); + hexdump(buffer, 512, 0); + } + else + printf("Re-read ok!\n"); + + for (;;); + } + } + printf("Verify: %s\n", ok ? "ok" : "failed"); + } +#endif + + time = GetTimer(0) - time; + tos_debugf("TOS.IMG uploaded in %lu ms (%llu kB/s / %llu kBit/s)", + time >> 20, file.size / (time >> 20), 8 * file.size / (time >> 20)); + + FileClose(&file); + + } + else { + tos_debugf("Unable to find tos.img"); + tos_write("Unable to find tos.img"); + + DISKLED_OFF; + return; + } + + DISKLED_OFF; + + // This is the initial boot if no name was given. Otherwise the + // user reloaded a new os + if (!name) { + // load + tos_load_cartridge(NULL); + + // try to open both floppies + int i; + for (i = 0; i<2; i++) { + //char msg[] = "Found floppy disk image for drive X: "; + char name[] = "DISK_A.ST"; + //msg[34] = name[5] = 'A' + i; + + tos_insert_disk(i, name); + } + + if (config.sd_direct) { + tos_set_direct_hdd(1); + tos_write("Enabling direct SD card access via ACSI0"); + } + else { + // try to open harddisk image + for (i = 0; i<2; i++) { + if (FileOpen(&file, config.acsi_img[i])) + { + FileClose(&file); + char msg[] = "Found hard disk image for ACSIX"; + msg[30] = '0' + i; + tos_write(msg); + tos_select_hdd_image(i, config.acsi_img[i]); + } + } + } + } + + tos_write("Booting ... "); + + // clear sector count register -> stop DMA + mist_memory_set_address(0, 0, 0); + + ikbd_reset(); + + // let cpu run (release reset) + config.system_ctrl &= ~TOS_CONTROL_CPU_RESET; + mist_set_control(config.system_ctrl); +} + +/* +static unsigned long get_long(char *buffer, int offset) { + unsigned long retval = 0; + int i; + + for (i = 0; i<4; i++) + retval = (retval << 8) + *(unsigned char*)(buffer + offset + i); + + return retval; +} +*/ + +void tos_poll() { + // 1 == button not pressed, 2 = 1 sec exceeded, else timer running + static unsigned long timer = 1; + + mist_get_dmastate(); + + // check the user button + if (user_io_user_button()) { + if (timer == 1) + timer = GetTimer(1000); + else if (timer != 2) + if (CheckTimer(timer)) { + tos_reset(1); + timer = 2; + } + } + else { + // released while still running (< 1 sec) + if (!(timer & 3)) + tos_reset(0); + + timer = 1; + } +} + +void tos_update_sysctrl(unsigned long n) { + // printf(">>>>>>>>>>>> set sys %x, eth is %s\n", n, (n&TOS_CONTROL_ETHERNET)?"on":"off"); + + // some of the usb drivers also call this without knowing which + // core is running. So make sure this only happens if the Atari ST (MIST) + // core is running + if (user_io_core_type() == CORE_TYPE_MIST) { + config.system_ctrl = n; + mist_set_control(config.system_ctrl); + } +} + +static void nice_name(char *dest, char *src) { + char *c; + + // copy and append nul + strncpy(dest, src, 8); + for (c = dest + 7; *c == ' '; c--); c++; + *c++ = '.'; + strncpy(c, src + 8, 3); + for (c += 2; *c == ' '; c--); c++; + *c++ = '\0'; +} + +static char buffer[17]; // local buffer to assemble file name (8+3+2) + +char *tos_get_disk_name(int index) { + fileTYPE file; + + if (index <= 1) + file = fdd_image[index].file; + else + file = hdd_image[index - 2]; + + if (!file.size) { + strcpy(buffer, "* no disk *"); + return buffer; + } + + nice_name(buffer, file.name); + + return buffer; +} + +char *tos_get_image_name() { + nice_name(buffer, config.tos_img); + return buffer; +} + +char *tos_get_cartridge_name() { + if (!config.cart_img[0]) // no cart name set + strcpy(buffer, "* no cartridge *"); + else + nice_name(buffer, config.cart_img); + + return buffer; +} + +char tos_disk_is_inserted(int index) { + if (index <= 1) + return (fdd_image[index].file.size != 0); + + return hdd_image[index - 2].size != 0; +} + +void tos_select_hdd_image(int i, const char *name) +{ + tos_debugf("Select ACSI%c image %s", '0' + i, name); + + if(name) strcpy(config.acsi_img[i], name); + else config.acsi_img[i][0] = 0; + + if (!name) + { + FileClose(&hdd_image[i]); + hdd_image[i].size = 0; + config.system_ctrl &= ~(TOS_ACSI0_ENABLE << i); + } + else + { + if (FileOpen(&hdd_image[i], name)) + { + config.system_ctrl |= (TOS_ACSI0_ENABLE << i); + } + } + + // update system control + mist_set_control(config.system_ctrl); +} + +void tos_insert_disk(int i, const char *name) +{ + if (i > 1) + { + tos_select_hdd_image(i - 2, name); + return; + } + + tos_debugf("%c: eject", i + 'A'); + + // toggle write protect bit to help tos detect a media change + int wp_bit = (!i) ? TOS_CONTROL_FDC_WR_PROT_A : TOS_CONTROL_FDC_WR_PROT_B; + + // any disk ejected is "write protected" (as nothing covers the write protect mechanism) + mist_set_control(config.system_ctrl | wp_bit); + + // first "eject" disk + fdd_image[i].file.size = 0; + fdd_image[i].sides = 1; + fdd_image[i].spt = 0; + FileClose(&fdd_image[i].file); + + // no new disk given? + if (!name) return; + + // open floppy + if (!FileOpen(&fdd_image[i].file, name)) return; + + tos_debugf("%c: insert %s", i + 'A', name); + + // check image size and parameters + + // check if image size suggests it's a two sided disk + if (fdd_image[i].file.size > 85 * 11 * 512) + fdd_image[i].sides = 2; + + // try common sector/track values + int m, s, t; + for (m = 0; m <= 2; m++) // multiplier for hd/ed disks + for (s = 9; s <= 12; s++) + for (t = 78; t <= 85; t++) + if (512 * (1 << m)*s*t*fdd_image[i].sides == fdd_image[i].file.size) + fdd_image[i].spt = s*(1 << m); + + + + if (!fdd_image[i].spt) { + // read first sector from disk + /* + if (MMC_Read(0, dma_buffer)) { + fdd_image[i].spt = dma_buffer[24] + 256 * dma_buffer[25]; + fdd_image[i].sides = dma_buffer[26] + 256 * dma_buffer[27]; + } + else + */ + fdd_image[i].file.size = 0; + } + + if (fdd_image[i].file.size) { + // restore state of write protect bit + tos_update_sysctrl(config.system_ctrl); + tos_debugf("%c: detected %d sides with %d sectors per track", + i + 'A', fdd_image[i].sides, fdd_image[i].spt); + } +} + +// force ejection of all disks (SD card has been removed) +void tos_eject_all() { + int i; + for (i = 0; i<2; i++) + tos_insert_disk(i, NULL); + + // ejecting an SD card while a hdd image is mounted may be a bad idea + for (i = 0; i<2; i++) { + if (hdd_direct) + hdd_direct = 0; + + if (hdd_image[i].size) { + InfoMessage("Card removed:\nDisabling Harddisk!"); + hdd_image[i].size = 0; + } + } +} + +void tos_reset(char cold) { + ikbd_reset(); + + tos_update_sysctrl(config.system_ctrl | TOS_CONTROL_CPU_RESET); // set reset + + if (cold) { +#if 0 // clearing mem should be sifficient. But currently we upload TOS as it may be damaged + // clear first 16k + mist_memory_set_address(8); + mist_memory_set(0x00, 8192 - 4); +#else + tos_upload(NULL); +#endif + } + + tos_update_sysctrl(config.system_ctrl & ~TOS_CONTROL_CPU_RESET); // release reset +} + +unsigned long tos_system_ctrl(void) +{ + return config.system_ctrl; +} + +void tos_config_init(void) +{ + // set default values + config.system_ctrl = TOS_MEMCONFIG_4M | TOS_CONTROL_BLITTER; + strcpy(config.tos_img, "TOS.IMG"); + config.cart_img[0] = 0; + strcpy(config.acsi_img[0], "HARDDISK.HD"); + config.acsi_img[1][0] = 0; + config.video_adjust[0] = config.video_adjust[1] = 0; + + // try to load config + int size = FileLoadConfig(CONFIG_FILENAME, 0, 0); + if (size>0) + { + tos_debugf("Configuration file size: %u (should be %u)", size, sizeof(tos_config_t)); + if (size == sizeof(tos_config_t)) + { + FileLoadConfig(CONFIG_FILENAME, &config, size); + } + } + + // ethernet is auto detected later + config.system_ctrl &= ~TOS_CONTROL_ETHERNET; +} + +// save configuration +void tos_config_save(void) +{ + FileSaveConfig(CONFIG_FILENAME, &config, sizeof(tos_config_t)); +} diff --git a/support/x86/x86.cpp b/support/x86/x86.cpp index 0221352..aa696fd 100644 --- a/support/x86/x86.cpp +++ b/support/x86/x86.cpp @@ -1,17 +1,17 @@ /* * Copyright (c) 2014, Aleksander Osman * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include @@ -535,7 +535,7 @@ void x86_init() //-------------------------------------------------------------------------- floppy fdd_set(config.fdd_name); - + //-------------------------------------------------------------------------- hdd hdd_set(0); @@ -597,7 +597,7 @@ void x86_init() 0x00, //0x20: hd 0 configuration 6/9; retries/bad map/heads>8 0x00, //0x21: hd 0 configuration 7/9; landing zone low 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, //0x25: hd 1 configuration 2/9; cylinders high 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, //0x2A: hd 1 configuration 7/9; landing zone low 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 diff --git a/support/x86/x86.h b/support/x86/x86.h index 8bb15f7..cc05bba 100644 --- a/support/x86/x86.h +++ b/support/x86/x86.h @@ -2,7 +2,7 @@ #define X86_H void x86_init(); -void x86_poll(); +void x86_poll(); void x86_set_image(int num, char *filename); diff --git a/sxmlc.c b/sxmlc.c index f753d4f..a3f86fe 100644 --- a/sxmlc.c +++ b/sxmlc.c @@ -124,7 +124,7 @@ int XML_unregister_user_tag(int i_tag) if (pt == NULL) return -1; } - + if (pt != NULL) { 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)); @@ -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) { XMLNode** pt = (XMLNode**)__realloc(*children_array, (*len_array+1) * sizeof(XMLNode*)); - + if (pt == NULL) return -1; - + pt[*len_array] = node; *children_array = pt; - + return (*len_array)++; } @@ -177,20 +177,20 @@ int XMLNode_init(XMLNode* node) { if (node == NULL) return false; - + if (node->init_value == XML_INIT_DONE) return true; /*(void)XMLNode_free(node);*/ node->tag = NULL; node->text = NULL; - + node->attributes = NULL; node->n_attributes = 0; - + node->father = NULL; node->children = NULL; node->n_children = 0; - + node->tag_type = TAG_NONE; node->active = true; @@ -203,17 +203,17 @@ XMLNode* XMLNode_allocN(int n) { int i; XMLNode* p; - + if (n <= 0) return NULL; - + p = (XMLNode*)__calloc(n, sizeof(XMLNode)); if (p == NULL) return NULL; for (i = 0; i < n; i++) (void)XMLNode_init(&p[i]); - + return p; } @@ -242,7 +242,7 @@ int XMLNode_free(XMLNode* node) { if (node == NULL || node->init_value != XML_INIT_DONE) return false; - + if (node->tag != NULL) { __free(node->tag); node->tag = NULL; @@ -251,7 +251,7 @@ int XMLNode_free(XMLNode* node) XMLNode_remove_text(node); XMLNode_remove_all_attributes(node); XMLNode_remove_children(node); - + node->tag_type = TAG_NONE; return true; @@ -260,16 +260,16 @@ int XMLNode_free(XMLNode* node) int XMLNode_copy(XMLNode* dst, const XMLNode* src, int copy_children) { int i; - + if (dst == NULL || (src != NULL && src->init_value != XML_INIT_DONE)) return false; - + (void)XMLNode_free(dst); /* 'dst' is freed first */ - + /* NULL 'src' resets 'dst' */ if (src == NULL) return true; - + /* Tag */ if (src->tag != NULL) { 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->user = src->user; dst->active = src->active; - + /* Copy children if required (and there are any) */ if (copy_children && src->n_children > 0) { 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; } } - + return true; - + copy_err: (void)XMLNode_free(dst); - + return false; } @@ -333,7 +333,7 @@ int XMLNode_set_tag(XMLNode* node, const SXML_CHAR* tag) SXML_CHAR* newtag; if (node == NULL || tag == NULL || node->init_value != XML_INIT_DONE) return false; - + newtag = sx_strdup(tag); if (newtag == NULL) return false; @@ -365,10 +365,10 @@ int XMLNode_set_attribute(XMLNode* node, const SXML_CHAR* attr_name, const SXML_ { XMLAttribute* pt; int i; - + if (node == NULL || attr_name == NULL || attr_name[0] == NULC || node->init_value != XML_INIT_DONE) return -1; - + i = XMLNode_search_attribute(node, attr_name, 0); if (i >= 0) { /* Attribute found: update it */ SXML_CHAR* value = NULL; @@ -411,10 +411,10 @@ int XMLNode_get_attribute_with_default(XMLNode* node, const SXML_CHAR* attr_name { XMLAttribute* pt; int i; - + if (node == NULL || attr_name == NULL || attr_name[0] == NULC || attr_value == NULL || node->init_value != XML_INIT_DONE) return false; - + i = XMLNode_search_attribute(node, attr_name, 0); if (i >= 0) { 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 i; - + if (node == NULL || attr_name == NULL || attr_name[0] == NULC || i_search < 0 || i_search >= node->n_attributes) return -1; - + for (i = i_search; i < node->n_attributes; i++) if (node->attributes[i].active && !sx_strcmp(node->attributes[i].name, attr_name)) return i; - + return -1; } @@ -466,7 +466,7 @@ int XMLNode_remove_attribute(XMLNode* node, int i_attr) XMLAttribute* pt; if (node == NULL || node->init_value != XML_INIT_DONE || i_attr < 0 || i_attr >= node->n_attributes) return -1; - + /* Before modifying first see if we run out of memory */ if (node->n_attributes == 1) pt = NULL; @@ -479,7 +479,7 @@ int XMLNode_remove_attribute(XMLNode* node, int i_attr) /* Can't fail anymore, free item */ 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 (pt != NULL) { 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)); @@ -488,7 +488,7 @@ int XMLNode_remove_attribute(XMLNode* node, int i_attr) __free(node->attributes); node->attributes = pt; 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) return false; - + if (_add_node(&node->children, &node->n_children, child) >= 0) { node->tag_type = TAG_FATHER; child->father = node; @@ -561,24 +561,24 @@ int XMLNode_get_children_count(const XMLNode* node) for (i = n = 0; i < node->n_children; i++) if (node->children[i]->active) n++; - + return n; } XMLNode* XMLNode_get_child(const XMLNode* node, int i_child) { int i; - + if (node == NULL || node->init_value != XML_INIT_DONE || i_child < 0 || i_child >= node->n_children) return NULL; - + for (i = 0; i < node->n_children; i++) { if (!node->children[i]->active) i_child++; else if (i == i_child) return node->children[i]; } - + 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) return -1; - + /* Lookup 'i_child'th active child */ for (i = 0; i < node->n_children; i++) { 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]); if (free_child) __free(node->children[i_child]); - + if (pt != NULL) { 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*)); @@ -624,7 +624,7 @@ int XMLNode_remove_child(XMLNode* node, int i_child, int free_child) node->n_children--; if (node->n_children == 0) node->tag_type = TAG_SELF; - + return node->n_children; } @@ -645,7 +645,7 @@ int XMLNode_remove_children(XMLNode* node) node->children = NULL; } node->n_children = 0; - + return true; } @@ -748,7 +748,7 @@ int XMLDoc_init(XMLDoc* doc) int XMLDoc_free(XMLDoc* doc) { int i; - + if (doc == NULL || doc->init_value != XML_INIT_DONE) 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) return false; - + doc->i_root = i_root; - + 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) return -1; - + if (_add_node(&doc->nodes, &doc->n_nodes, node) < 0) return -1; @@ -806,7 +806,7 @@ int XMLDoc_remove_node(XMLDoc* doc, int i_node, int free_node) /* Can't fail anymore, free item */ (void)XMLNode_free(doc->nodes[i_node]); if (free_node) __free(doc->nodes[i_node]); - + if (pt != NULL) { 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*)); @@ -834,7 +834,7 @@ static int _count_new_char_line(const SXML_CHAR* str, int nb_char_tab, int cur_s else 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) @@ -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); } } - + 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) return -1; - + /* Special handling of 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 '>' */ @@ -886,7 +886,7 @@ static int _XMLNode_print_header(const XMLNode* node, FILE* f, const SXML_CHAR* return cur_sz_line; } } - + /* Print tag name */ 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); } else sx_fprintf(f, C2SX(" %s="), node->attributes[i].name); - + /* Attribute value */ (void)sx_fputc(XML_DEFAULT_QUOTE, f); cur_sz_line += fprintHTML(f, node->attributes[i].value) + 2; (void)sx_fputc(XML_DEFAULT_QUOTE, f); } - + /* End the tag if there are no children and no text */ if (node->n_children == 0 && (node->text == NULL || node->text[0] == NULC)) { 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; SXML_CHAR* p; - + if (node != NULL && node->tag_type==TAG_TEXT) { /* Text has to be printed: check if it is only 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 */ @@ -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) return -1; - + if (nb_char_tab <= 0) nb_char_tab = 1; - + /* 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) */ depth = 0; else 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); 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); } else if (node->n_children <= 0) /* Everything has already been printed */ return cur_sz_line; - + /* Recursively print children */ 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); - + /* Print tag end after children */ /* Print formatting */ 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 i, depth, cur_sz_line; - + if (doc == NULL || f == NULL || doc->init_value != XML_INIT_DONE) return false; - + #ifdef SXMLC_UNICODE /* Write BOM if it exist */ 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 ret = 1; SXML_CHAR quote = '\0'; - + if (str == NULL || xmlattr == NULL) return 0; if (to < 0) to = sx_strlen(str) - 1; - + /* Search for the '=' */ /* '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 */ @@ -1038,7 +1038,7 @@ int XML_parse_attribute_to(const SXML_CHAR* str, int to, XMLAttribute* xmlattr) quote = str[n1]; remQ = 1; } - + xmlattr->name = (SXML_CHAR*)__malloc((n0+1)*sizeof(SXML_CHAR)); xmlattr->value = (SXML_CHAR*)__malloc((to+1 - n1 - remQ + 1) * sizeof(SXML_CHAR)); 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! */ } else ret = 0; - + if (ret == 0) { if (xmlattr->name != NULL) { __free(xmlattr->name); @@ -1068,7 +1068,7 @@ int XML_parse_attribute_to(const SXML_CHAR* str, int to, XMLAttribute* xmlattr) xmlattr->value = NULL; } } - + return ret; } @@ -1100,11 +1100,11 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode) SXML_CHAR *p; XMLAttribute* pt; int n, nn, len, rc, tag_end = 0; - + if (str == NULL || xmlnode == NULL) return TAG_ERROR; len = sx_strlen(str); - + /* Check for malformed string */ if (str[0] != C2SX('<') || str[len-1] != C2SX('>')) return TAG_ERROR; @@ -1138,7 +1138,7 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode) return TAG_DOCTYPE; } } - + /* Test user tags */ for (nn = 0; nn < _user_tags.n_tags; nn++) { 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('/')) tag_end = 1; - + /* 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++) ; 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; return TAG_END; } - + /* Here, 'n' is the position of the first space after tag name */ while (n < len) { /* Skips spaces */ while (sx_isspace(str[n])) n++; - + /* Check for XML end ('>' or '/>') */ if (str[n] == C2SX('>')) { /* Tag with children */ int type = (str[n-1] == '/' ? TAG_SELF : TAG_FATHER); // TODO: Find something better to cope with @@ -1179,13 +1179,13 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode) xmlnode->tag_type = TAG_SELF; return TAG_SELF; } - + /* New attribute found */ p = sx_strchr(str+n, C2SX('=')); if (p == NULL) goto parse_err; pt = (XMLAttribute*)__realloc(xmlnode->attributes, (xmlnode->n_attributes + 1) * sizeof(XMLAttribute)); if (pt == NULL) goto parse_err; - + pt[xmlnode->n_attributes].name = NULL; pt[xmlnode->n_attributes].value = NULL; 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 */ 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 */ /* 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]); @@ -1208,12 +1208,12 @@ TagType XML_parse_1string(const SXML_CHAR* str, XMLNode* xmlnode) XMLNode_remove_attribute(xmlnode, xmlnode->n_attributes - 1); return TAG_PARTIAL; } - + n = nn + 1; } - + sx_fprintf(stderr, C2SX("\nWE SHOULD NOT BE HERE!\n[%s]\n\n"), str); - + parse_err: (void)XMLNode_free(xmlnode); @@ -1298,7 +1298,7 @@ static int _parse_data_SAX(void* in, const DataSourceType in_type, const SAX_Cal break; } break; - + case TAG_NONE: /* Syntax error */ ret = false; p = sx_strchr(txt_end, C2SX('\n')); @@ -1420,7 +1420,7 @@ int DOMXMLDoc_node_start(const XMLNode* node, SAX_Data* sd) 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 (dom->current == NULL) { 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; return false; } - + dom->current->text = p; } @@ -1580,7 +1580,7 @@ int XMLDoc_parse_file_SAX(const SXML_CHAR* filename, const SAX_Callbacks* sax, v FILE* f; int ret; SAX_Data sd; - SXML_CHAR* fmode = + SXML_CHAR* fmode = #ifndef SXMLC_UNICODE C2SX("rt"); #else @@ -1774,7 +1774,7 @@ int _bgetc(DataSourceBuffer* ds) { if (ds == NULL || ds->buf[ds->cur_pos] == NULC) return EOF; - + 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 (*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); - + if (in == NULL || line == NULL) return 0; - + if (to == NULC) to = C2SX('\n'); /* 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) break; } - + if (sz_line == NULL) sz_line = &init_sz; - + if (*line == NULL || *sz_line == 0) { if (*sz_line == 0) *sz_line = MEM_INCR_RLA; *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; if (i0 > *sz_line) return 0; - + n = i0; if (c == CSXEOF) { /* EOF reached before 'to' char => return the empty string */ (*line)[n] = NULC; @@ -1867,14 +1867,14 @@ int read_line_alloc(void* in, DataSourceType in_type, SXML_CHAR** line, int* sz_ break; } } - + #if 0 /* Automatic buffer resize is deactivated */ /* Resize line to the exact size */ pt = (SXML_CHAR*)__realloc(*line, (n+1)*sizeof(SXML_CHAR)); if (pt != NULL) *line = pt; #endif - + return ret; } @@ -1909,7 +1909,7 @@ SXML_CHAR* strip_spaces(SXML_CHAR* str, SXML_CHAR repl_sq) { SXML_CHAR* p; int i, len; - + /* '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 */ 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 */ i++; str[i+1] = NULC; /* New end of string to last non-space */ - + if (repl_sq == NULC) { if (p == str && i == len) return str; /* Nothing to do */ for (i = 0; (str[i] = *p) != NULC; i++, p++) ; /* Copy 'p' to 'str' */ return str; } - + /* Squeeze all spaces with 'repl_sq' */ i = 0; while (*p != NULC) { @@ -1938,7 +1938,7 @@ SXML_CHAR* strip_spaces(SXML_CHAR* str, SXML_CHAR repl_sq) } } str[i] = NULC; - + return str; } @@ -2136,7 +2136,7 @@ SXML_CHAR* html2str(SXML_CHAR* html, SXML_CHAR* str) if (html == NULL) return NULL; if (str == NULL) str = html; - + /* Look for '&' and matches it to any of the recognized HTML pattern. */ /* If found, replaces the '&' by the corresponding char. */ /* '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; continue; } - + for (i = 0; HTML_SPECIAL_DICT[i].chr; i++) { if (sx_strncmp(ps, HTML_SPECIAL_DICT[i].html, HTML_SPECIAL_DICT[i].html_len)) continue; - + *pd = HTML_SPECIAL_DICT[i].chr; ps += HTML_SPECIAL_DICT[i].html_len-1; break; @@ -2160,7 +2160,7 @@ SXML_CHAR* html2str(SXML_CHAR* html, SXML_CHAR* str) *pd = *ps; } *pd = NULC; - + return str; } @@ -2201,7 +2201,7 @@ SXML_CHAR* str2html(SXML_CHAR* str, SXML_CHAR* html) int strlen_html(SXML_CHAR* str) { int i, j, n; - + if (str == NULL) return 0; @@ -2224,7 +2224,7 @@ int fprintHTML(FILE* f, SXML_CHAR* str) { SXML_CHAR* p; int i, n; - + for (p = str, n = 0; *p != NULC; p++) { for (i = 0; HTML_SPECIAL_DICT[i].chr; i++) { if (*p != HTML_SPECIAL_DICT[i].chr) @@ -2238,7 +2238,7 @@ int fprintHTML(FILE* f, SXML_CHAR* str) n++; } } - + return n; } diff --git a/sxmlc.h b/sxmlc.h index a693ac7..eec0c9a 100644 --- a/sxmlc.h +++ b/sxmlc.h @@ -178,11 +178,11 @@ typedef struct _XMLNode { SXML_CHAR* text; /* Text inside the node */ XMLAttribute* attributes; int n_attributes; - + struct _XMLNode* father; /* NULL if root */ struct _XMLNode** children; int n_children; - + 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' */ diff --git a/user_io.cpp b/user_io.cpp index f0acf60..14d666c 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include @@ -693,7 +693,7 @@ void user_io_init(const char *path) char cmd[32]; system("uartmode 0"); - + SetMidiLinkMode((mode >> 8) & 0xFF); sprintf(cmd, "uartmode %d", mode & 0xFF); system(cmd); @@ -1277,7 +1277,7 @@ static void send_pcolchr(const char* name, unsigned char index, int type) char *p = strrchr(full_path, '.'); if (!p) p = full_path + strlen(full_path); strcpy(p, type ? ".chr" : ".col"); - + if (type) { 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; - // if mask is 0 just return the current status + // if mask is 0 just return the current status if (mask) { // keep everything not masked status &= ~mask; @@ -1624,7 +1624,7 @@ void user_io_poll() // check for incoming serial data. this is directly forwarded to the // 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); while (spi_in()) { @@ -1924,7 +1924,7 @@ void user_io_poll() { unsigned char ps2_mouse[3]; - // PS2 format: + // PS2 format: // YOvfl, XOvfl, dy8, dx8, 1, mbtn, rbtn, lbtn // dx[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 (press == 1 && hasAPI1_5()) set_volume(0); diff --git a/user_io.h b/user_io.h index ab251cf..7429a42 100644 --- a/user_io.h +++ b/user_io.h @@ -48,7 +48,7 @@ #define UIO_SET_SDCONF 0x19 // send SD card configuration (CSD, CID) #define UIO_ASTICK 0x1a #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_STATUS2 0x1e // 32bit status #define UIO_GET_KBD_LED 0x1f // keyboard LEDs control @@ -106,7 +106,7 @@ #define JOY_L3 0x4000 #define JOY_R3 0x8000 -// keyboard LEDs control +// keyboard LEDs control #define KBD_LED_CAPS_CONTROL 0x01 #define KBD_LED_CAPS_STATUS 0x02 #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 #define CORE_TYPE_UNKNOWN 0x55 #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_MINIMIG2 0xa5 // new Minimig with AGA #define CORE_TYPE_ARCHIE 0xa6 // Acorn Archimedes @@ -163,7 +163,7 @@ #define UIO_PARITY_MARK 3 #define UIO_PARITY_SPACE 4 -#define UIO_PRIORITY_KEYBOARD 0 +#define UIO_PRIORITY_KEYBOARD 0 #define UIO_PRIORITY_GAMEPAD 1 #define EMU_NONE 0 @@ -171,7 +171,7 @@ #define EMU_JOY0 2 #define EMU_JOY1 3 -// serial status data type returned from the core +// serial status data type returned from the core typedef struct { uint32_t bitrate; // 300, 600 ... 115200 uint8_t datasize; // 5,6,7,8 ... diff --git a/video.cpp b/video.cpp index f10b2be..b4d9483 100644 --- a/video.cpp +++ b/video.cpp @@ -7,10 +7,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "hardware.h" #include "user_io.h" @@ -846,7 +846,7 @@ static void vs_wait() close(fb); return; } - + t1 = getus(); ioctl(fb, FBIO_WAITFORVSYNC, &zero); t2 = getus();