From a2ef5eb88dc2265d03fdc85feb0c6fb1a3ed5d85 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Wed, 3 Jan 2018 18:40:40 +0800 Subject: [PATCH] Revise boot code. Remove MCU definitions. --- archie.c | 13 +++--- boot.c | 6 +-- boot.h | 2 + config.c | 12 +++--- debug.h | 24 +++++------ hardware.c | 12 +++--- hardware.h | 4 -- ikbd.c | 4 +- main.c | 104 ++++++++++----------------------------------- menu.c | 44 ++++++++++++------- osd.c | 9 ++-- tos.c | 28 ++++++------ user_io.c | 122 +++++++++++++++++++++++++++++------------------------ user_io.h | 2 - 14 files changed, 175 insertions(+), 211 deletions(-) diff --git a/archie.c b/archie.c index cf6a53e..52eb648 100644 --- a/archie.c +++ b/archie.c @@ -27,9 +27,9 @@ fileTYPE floppy[MAX_FLOPPY] = { 0 }; #define ARCHIE_FDC_TX_DATA 0x56 #define ARCHIE_FDC_SET_STATUS 0x57 -#define archie_debugf(a, ...) iprintf("\033[1;31mARCHIE: " a "\033[0m\n", ##__VA_ARGS__) +#define archie_debugf(a, ...) printf("\033[1;31mARCHIE: " a "\033[0m\n", ##__VA_ARGS__) // #define archie_debugf(a, ...) -#define archie_x_debugf(a, ...) iprintf("\033[1;32mARCHIE: " a "\033[0m\n", ##__VA_ARGS__) +#define archie_x_debugf(a, ...) printf("\033[1;32mARCHIE: " a "\033[0m\n", ##__VA_ARGS__) enum state { STATE_HRST, STATE_RAK1, STATE_RAK2, STATE_IDLE, @@ -125,11 +125,11 @@ void archie_send_file(unsigned char id, char *name) unsigned long time = GetTimer(0); - iprintf("["); + printf("["); unsigned short i, blocks = file.size / 512; for (i = 0; i> 20); diff --git a/boot.c b/boot.c index 5bab132..f0b45f4 100644 --- a/boot.c +++ b/boot.c @@ -448,7 +448,7 @@ void BootInit() WaitTimer(500); char rtl_ver[128]; - siprintf(rtl_ver, "MINIMIG-AGA%s v%d.%d.%d by Rok Krajnc. MiSTer port by Sorgelig.", ver_beta ? " BETA" : "", ver_major, ver_minor, ver_minion); + sprintf(rtl_ver, "MINIMIG-AGA%s v%d.%d.%d by Rok Krajnc. MiSTer port by Sorgelig.", ver_beta ? " BETA" : "", ver_major, ver_minor, ver_minion); BootPrintEx(rtl_ver); BootPrintEx(" "); BootPrintEx("Original Minimig by Dennis van Weeren"); @@ -472,8 +472,8 @@ void BootPrintEx(char * str) unsigned char i, j; unsigned char len; - iprintf(str); - iprintf("\n"); + printf(str); + printf("\n"); len = strlen(str); len = (len>80) ? 80 : len; diff --git a/boot.h b/boot.h index 54fe1fc..a574909 100644 --- a/boot.h +++ b/boot.h @@ -39,5 +39,7 @@ void BootInit(); void BootPrintEx(char * str); void BootHome(); +#define BootPrint(text) printf("%s\n", text) + #endif // __BOOT_H__ diff --git a/config.c b/config.c index 66ef14d..bd6f228 100644 --- a/config.c +++ b/config.c @@ -24,8 +24,8 @@ void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int address, in static uint8_t buf[512]; int i, j; unsigned int keyidx = 0; - iprintf("File size: %dkB\n", size >> 1); - iprintf("["); + printf("File size: %dkB\n", size >> 1); + printf("["); if (keysize) { // read header @@ -33,7 +33,7 @@ void SendFileV2(fileTYPE* file, unsigned char* key, int keysize, int address, in } for (i = 0; i> 2) & 7], config_memory_chip_msg[(config.memory >> 0) & 0x03], config_memory_fast_msg[(config.memory >> 4) & 0x03], config_memory_slow_msg[(config.memory >> 2) & 0x03] ); @@ -380,7 +380,7 @@ void ApplyConfiguration(char reloadkickstart) BootPrint("* when using large hardfiles. *"); // AMR BootPrint("***************************************************"); } - iprintf("Bootloading is complete.\n"); + printf("Bootloading is complete.\n"); #endif printf("\nExiting bootloader...\n"); diff --git a/debug.h b/debug.h index b0a11b0..a93bf3c 100644 --- a/debug.h +++ b/debug.h @@ -7,7 +7,7 @@ // ------------ generic debugging ----------- #if 0 -#define menu_debugf(...) iprintf(__VA_ARGS__) +#define menu_debugf(...) printf(__VA_ARGS__) #else #define menu_debugf(...) #endif @@ -15,7 +15,7 @@ // ----------- minimig debugging ------------- #if 0 -#define hdd_debugf(a, ...) iprintf("\033[1;32mHDD: " a "\033[0m\n", ##__VA_ARGS__) +#define hdd_debugf(a, ...) printf("\033[1;32mHDD: " a "\033[0m\n", ##__VA_ARGS__) #else #define hdd_debugf(...) #endif @@ -29,7 +29,7 @@ // -------------- TOS debugging -------------- #if 1 -#define tos_debugf(a, ...) iprintf("\033[1;32mTOS: " a "\033[0m\n", ##__VA_ARGS__) +#define tos_debugf(a, ...) printf("\033[1;32mTOS: " a "\033[0m\n", ##__VA_ARGS__) #else #define tos_debugf(...) #endif @@ -37,14 +37,14 @@ #if 1 // ikbd debug output in red #define IKBD_DEBUG -#define ikbd_debugf(a, ...) iprintf("\033[1;31mIKBD: " a "\033[0m\n", ##__VA_ARGS__) +#define ikbd_debugf(a, ...) printf("\033[1;31mIKBD: " a "\033[0m\n", ##__VA_ARGS__) #else #define ikbd_debugf(...) #endif #if 1 // 8bit debug output in blue -#define bit8_debugf(a, ...) iprintf("\033[1;34m8BIT: " a "\033[0m\n", ##__VA_ARGS__) +#define bit8_debugf(a, ...) printf("\033[1;34m8BIT: " a "\033[0m\n", ##__VA_ARGS__) #else #define bit8_debugf(...) #endif @@ -52,49 +52,49 @@ // ------------ usb debugging ----------- #if 0 -#define hidp_debugf(a, ...) iprintf("\033[1;34mHIDP: " a "\033[0m\n", ##__VA_ARGS__) +#define hidp_debugf(a, ...) printf("\033[1;34mHIDP: " a "\033[0m\n", ##__VA_ARGS__) #else #define hidp_debugf(...) #endif #if 0 // usb asix debug output in blue -#define asix_debugf(a, ...) iprintf("\033[1;34mASIX: " a "\033[0m\n", ##__VA_ARGS__) +#define asix_debugf(a, ...) printf("\033[1;34mASIX: " a "\033[0m\n", ##__VA_ARGS__) #else #define asix_debugf(...) #endif #if 1 // usb hid debug output in green -#define hid_debugf(a, ...) iprintf("\033[1;32mHID: " a "\033[0m\n", ##__VA_ARGS__) +#define hid_debugf(a, ...) printf("\033[1;32mHID: " a "\033[0m\n", ##__VA_ARGS__) #else #define hid_debugf(...) #endif #if 1 // usb mass storage debug output in purple -#define storage_debugf(a, ...) iprintf("\033[1;35mSTORAGE: " a "\033[0m\n", ##__VA_ARGS__) +#define storage_debugf(a, ...) printf("\033[1;35mSTORAGE: " a "\033[0m\n", ##__VA_ARGS__) #else #define storage_debugf(...) #endif #if 0 // usb rts debug output in blue -#define usbrtc_debugf(a, ...) iprintf("\033[1;34mUSBRTC: " a "\033[0m\n", ##__VA_ARGS__) +#define usbrtc_debugf(a, ...) printf("\033[1;34mUSBRTC: " a "\033[0m\n", ##__VA_ARGS__) #else #define usbrtc_debugf(...) #endif #if 1 // usb rts debug output in blue -#define pl2303_debugf(a, ...) iprintf("\033[1;34mPL2303: " a "\033[0m\n", ##__VA_ARGS__) +#define pl2303_debugf(a, ...) printf("\033[1;34mPL2303: " a "\033[0m\n", ##__VA_ARGS__) #else #define pl2303_debugf(...) #endif #if 1 // ini_parser debug output -#define ini_parser_debugf(a, ...) iprintf("\033[1;34mINI_PARSER : " a "\033[0m\n",## __VA_ARGS__) +#define ini_parser_debugf(a, ...) printf("\033[1;34mINI_PARSER : " a "\033[0m\n",## __VA_ARGS__) #else #define ini_parser_debugf(...) #endif diff --git a/hardware.c b/hardware.c index d9989a1..a7eb24e 100644 --- a/hardware.c +++ b/hardware.c @@ -36,14 +36,14 @@ void hexdump(void *data, uint16_t size, uint16_t offset) if (!size) return; while (size>0) { - iprintf("%04x: ", n + offset); + printf("%04x: ", n + offset); b2c = (size>16) ? 16 : size; - for (i = 0; i #include -#define iprintf(...) printf(__VA_ARGS__) -#define siprintf(...) sprintf(__VA_ARGS__) -#define BootPrint(text) iprintf("%s\n", text) - unsigned long GetTimer(unsigned long offset); unsigned long CheckTimer(unsigned long t); void WaitTimer(unsigned long time); diff --git a/ikbd.c b/ikbd.c index 970ffeb..1d0683a 100644 --- a/ikbd.c +++ b/ikbd.c @@ -475,7 +475,7 @@ void ikbd_poll(void) { if (ikbd.mouse.but & (2 >> i)) state |= 0x80; if (state != ikbd.joy[i].prev) { - // iprintf("JOY%d: %x\n", i, state); + // printf("JOY%d: %x\n", i, state); enqueue(0xfe + i); enqueue(state); ikbd.joy[i].prev = state; @@ -503,7 +503,7 @@ void ikbd_poll(void) { else if (ikbd.mouse.y > 127) y = 127; else y = ikbd.mouse.y; - // iprintf("RMOUSE: %x %x %x\n", b, x&0xff, y&0xff); + // printf("RMOUSE: %x %x %x\n", b, x&0xff, y&0xff); enqueue(0xf8 | b); enqueue(x & 0xff); enqueue(y & 0xff); diff --git a/main.c b/main.c index 1c521cd..4fd0744 100644 --- a/main.c +++ b/main.c @@ -19,78 +19,46 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#define _GNU_SOURCE #include #include #include +#include #include "string.h" -#include "hardware.h" -#include "file_io.h" -#include "osd.h" -#include "fdd.h" -#include "hdd.h" #include "menu.h" #include "user_io.h" -#include "tos.h" -#include "debug.h" -#include "mist_cfg.h" #include "input.h" #include "fpga_io.h" -#include "boot.h" const char version[] = { "$VER:HPS" VDATE }; -void HandleDisk(void) -{ - unsigned char c1, c2; - - EnableFpga(); - uint16_t tmp = spi_w(0); - c1 = (uint8_t)(tmp>>8); // cmd request and drive number - c2 = (uint8_t)tmp; // track number - spi_w(0); - spi_w(0); - DisableFpga(); - - HandleFDD(c1, c2); - HandleHDD(c1, c2); - - UpdateDriveStatus(); -} - -void core_init() -{ - user_io_detect_core_type(); - - if (user_io_core_type() == CORE_TYPE_MINIMIG2) - { - BootInit(); - - } // end of minimig setup - - if (user_io_core_type() == CORE_TYPE_MIST) - { - puts("Running mist setup"); - tos_upload(NULL); - - // end of mist setup - } - - if (user_io_core_type() == CORE_TYPE_ARCHIE) - { - puts("Running archimedes setup"); - } // end of archimedes setup -} - int main(int argc, char *argv[]) { + /* + //placeholder for CPU1 dedicated process + if (!fork()) + { + cpu_set_t set; + CPU_ZERO(&set); + CPU_SET(1, &set); + sched_setaffinity(0, sizeof(set), &set); + + while (1) + { + sleep(2); + printf("Tick\n"); + } + } + */ + fpga_io_init(); fpga_gpo_write(0); DISKLED_OFF; - iprintf("\nMinimig by Dennis van Weeren"); - iprintf("\nARM Controller by Jakub Bednarski\n\n"); - iprintf("Version %s\n\n", version + 5); + printf("\nMinimig by Dennis van Weeren"); + printf("\nARM Controller by Jakub Bednarski\n\n"); + printf("Version %s\n\n", version + 5); if (!is_fpga_ready(1)) { @@ -100,10 +68,7 @@ int main(int argc, char *argv[]) } FindStorage(); - user_io_init(); - tos_config_init(); - core_init(); while(1) { @@ -124,30 +89,7 @@ int main(int argc, char *argv[]) user_io_poll(); input_poll(0); - - switch (user_io_core_type()) - { - // MIST (atari) core supports the same UI as Minimig - case CORE_TYPE_MIST: - HandleUI(); - break; - - // call original minimig handlers if minimig core is found - case CORE_TYPE_MINIMIG2: - HandleDisk(); - HandleUI(); - break; - - // 8 bit cores can also have a ui if a valid config string can be read from it - case CORE_TYPE_8BIT: - HandleUI(); - break; - - // Archie core will get its own treatment one day ... - case CORE_TYPE_ARCHIE: - HandleUI(); - break; - } + HandleUI(); } return 0; } diff --git a/menu.c b/menu.c index 2051071..6be28b8 100644 --- a/menu.c +++ b/menu.c @@ -273,7 +273,7 @@ static void SelectFile(char* pFileExt, unsigned char Options, unsigned char Menu { // this function displays file selection menu - iprintf("%s - %s\n", pFileExt, fs_pFileExt); + printf("%s - %s\n", pFileExt, fs_pFileExt); AdjustDirectory(SelectedPath); if (strncmp(pFileExt, fs_pFileExt, 12) != 0 || !strlen(SelectedPath)) // check desired file extension @@ -296,7 +296,7 @@ static void SelectFile(char* pFileExt, unsigned char Options, unsigned char Menu } } - iprintf("pFileExt = %3s\n", pFileExt); + printf("pFileExt = %3s\n", pFileExt); strcpy(fs_pFileExt, pFileExt); fs_ExtLen = strlen(fs_pFileExt); // fs_pFileExt = pFileExt; @@ -387,7 +387,7 @@ unsigned long getStatusMask(char *opt) { if (idx2>idx1) x = ~(0xffffffff << (idx2 - idx1 + 1)); - //iprintf("grtStatusMask %d %d %x\n", idx1, idx2, x); + //printf("grtStatusMask %d %d %x\n", idx1, idx2, x); return x << idx1; } @@ -509,6 +509,20 @@ char* getIP() void HandleUI(void) { + switch (user_io_core_type()) + { + case CORE_TYPE_MIST: + case CORE_TYPE_MINIMIG2: + case CORE_TYPE_8BIT: + case CORE_TYPE_ARCHIE: + break; + + default: + // No UI in unknown cores. + return; + } + + char *p; char s[40]; unsigned char i, m, up, down, select, menu, right, left, plus, minus; @@ -978,7 +992,7 @@ void HandleUI(void) parentstate = MENU_8BIT_MAIN1; // set helptext with core display on top of basic info - siprintf(helptext_custom, HELPTEXT_SPACER); + sprintf(helptext_custom, HELPTEXT_SPACER); strcat(helptext_custom, OsdCoreName()); strcat(helptext_custom, helptexts[HELPTEXT_MAIN]); helptext = helptext_custom; @@ -1086,13 +1100,13 @@ void HandleUI(void) break; case MENU_8BIT_MAIN_FILE_SELECTED: - iprintf("File selected: %s\n", SelectedPath); + printf("File selected: %s\n", SelectedPath); user_io_file_tx(SelectedPath, user_io_ext_idx(SelectedPath, fs_pFileExt) << 6 | (menusub + 1)); menustate = MENU_NONE1; break; case MENU_8BIT_MAIN_IMAGE_SELECTED: - iprintf("Image selected: %s\n", SelectedPath); + printf("Image selected: %s\n", SelectedPath); if (is_x86_core()) { x86_set_image(drive_num, SelectedPath); @@ -1182,7 +1196,7 @@ void HandleUI(void) // Save settings char *filename = user_io_create_config_name(); unsigned long status = user_io_8bit_set_status(0, 0); - iprintf("Saving config to %s\n", filename); + printf("Saving config to %s\n", filename); FileSaveConfig(filename, &status, 4); if (is_x86_core()) x86_config_save(); menustate = MENU_8BIT_MAIN1; @@ -1503,7 +1517,7 @@ void HandleUI(void) } else if ((menusub == 4) || (!tos_get_direct_hdd() && (menusub == 5))) { char disk_idx = menusub - (tos_get_direct_hdd() ? 1 : 2); - iprintf("Select image for disk %d\n", disk_idx); + printf("Select image for disk %d\n", disk_idx); if (tos_disk_is_inserted(disk_idx)) { tos_insert_disk(disk_idx, NULL); @@ -1526,7 +1540,7 @@ void HandleUI(void) tos_insert_disk(menusub, SelectedPath); else { char disk_idx = menusub - (tos_get_direct_hdd() ? 1 : 2); - iprintf("Insert image for disk %d\n", disk_idx); + printf("Insert image for disk %d\n", disk_idx); tos_insert_disk(disk_idx, SelectedPath); } menustate = MENU_MIST_STORAGE1; @@ -1746,10 +1760,10 @@ void HandleUI(void) OsdWrite(3, "", 0, 0); - siprintf(s, " Horizontal: %d", tos_get_video_adjust(0)); + sprintf(s, " Horizontal: %d", tos_get_video_adjust(0)); OsdWrite(4, s, menusub == 2, 0); - siprintf(s, " Vertical: %d", tos_get_video_adjust(1)); + sprintf(s, " Vertical: %d", tos_get_video_adjust(1)); OsdWrite(5, s, menusub == 3, 0); OsdWrite(6, "", 0, 0); @@ -1864,7 +1878,7 @@ void HandleUI(void) OsdWrite(i+1, s, menusub == i, (i>drives) || (i>config.floppy.drives)); } } - siprintf(s, " Floppy disk turbo : %s", config.floppy.speed ? "on" : "off"); + sprintf(s, " Floppy disk turbo : %s", config.floppy.speed ? "on" : "off"); OsdWrite(5, s, menusub == 4, 0); OsdWrite(6, "", 0, 0); @@ -2170,7 +2184,7 @@ void HandleUI(void) { char *filename = user_io_create_config_name(); unsigned long status = user_io_8bit_set_status(0, 0xffffffff); - iprintf("Saving config to %s\n", filename); + printf("Saving config to %s\n", filename); FileSaveConfig(filename, &status, 4); menustate = MENU_8BIT_MAIN1; menusub = 0; @@ -2953,7 +2967,7 @@ void HandleUI(void) OsdSetTitle(is_menu_core() ? "Settings" : "FW & Core", 0); //OsdWrite(0, "", 0, 0); - siprintf(s, " ARM s/w ver. %s", version + 5); + sprintf(s, " ARM s/w ver. %s", version + 5); OsdWrite(0, "", 0, 0); OsdWrite(1, s, 0, 0); @@ -3480,7 +3494,7 @@ static void set_text(const char *message, unsigned char code) if (code && (l <= 7)) { - siprintf(s, " Code: #%d", code); + sprintf(s, " Code: #%d", code); OsdWrite(l++, s, 0, 0); } diff --git a/osd.c b/osd.c index a16219f..bf2455e 100644 --- a/osd.c +++ b/osd.c @@ -590,9 +590,12 @@ void ScrollReset() /* core currently loaded */ static char lastcorename[261 + 10] = "CORE"; -void OsdCoreNameSet(const char* str) { - siprintf(lastcorename, "%s", str); +void OsdCoreNameSet(const char* str) +{ + sprintf(lastcorename, "%s", str); } -char* OsdCoreName() { + +char* OsdCoreName() +{ return lastcorename; } diff --git a/tos.c b/tos.c index baf4b00..9fd6b77 100644 --- a/tos.c +++ b/tos.c @@ -81,7 +81,7 @@ char tos_get_video_adjust(char axis) { } static void mist_memory_set_address(unsigned long a, unsigned char s, char rw) { - // iprintf("set addr = %x, %d, %d\n", a, s, rw); + // printf("set addr = %x, %d, %d\n", a, s, rw); a |= rw ? 0x1000000 : 0; a >>= 1; @@ -291,7 +291,7 @@ static void handle_acsi(unsigned char *buffer) { buffer[14]; length = 256 * buffer[16] + buffer[17]; - // iprintf("READ(10) %d, %d\n", lba, length); + // printf("READ(10) %d, %d\n", lba, length); } if (lba + length <= blocks) { @@ -332,7 +332,7 @@ static void handle_acsi(unsigned char *buffer) { length = 256 * buffer[16] + buffer[17]; - // iprintf("WRITE(10) %d, %d\n", lba, length); + // printf("WRITE(10) %d, %d\n", lba, length); } if (lba + length <= blocks) { @@ -491,21 +491,21 @@ static void handle_fdc(unsigned char *buffer) { else if ((fdc_cmd & 0xc0) == 0xc0) { char msg[32]; - if ((fdc_cmd & 0xe0) == 0xc0) iprintf("READ ADDRESS\n"); + if ((fdc_cmd & 0xe0) == 0xc0) printf("READ ADDRESS\n"); if ((fdc_cmd & 0xf0) == 0xe0) { - iprintf("READ TRACK %d SIDE %d\n", fdc_track, drv_side); - siprintf(msg, "RD TRK %d S %d", fdc_track, drv_side); + 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) { - iprintf("WRITE TRACK %d SIDE %d\n", fdc_track, drv_side); - siprintf(msg, "WR TRK %d S %d", fdc_track, drv_side); + printf("WRITE TRACK %d SIDE %d\n", fdc_track, drv_side); + sprintf(msg, "WR TRK %d S %d", fdc_track, drv_side); InfoMessage(msg); } - iprintf("scnt = %d\n", scnt); + printf("scnt = %d\n", scnt); dma_ack(0x00); } @@ -792,7 +792,7 @@ void tos_upload(char *name) ok = j; if (ok >= 0) { - iprintf("Failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); + printf("Failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); hexdump(buffer, 512, 0); puts(""); @@ -810,11 +810,11 @@ void tos_upload(char *name) ok = j; if (ok >= 0) { - iprintf("Re-read failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); + printf("Re-read failed in block %d/%x (%x != %x)\n", i, ok, 0xff & buffer[ok], 0xff & b2[ok]); hexdump(buffer, 512, 0); } else - iprintf("Re-read ok!\n"); + printf("Re-read ok!\n"); for (;;); } @@ -822,7 +822,7 @@ void tos_upload(char *name) if (i != blocks - 1) FileNextSector(&file); } - iprintf("Verify: %s\n", ok ? "ok" : "failed"); + printf("Verify: %s\n", ok ? "ok" : "failed"); } #endif @@ -924,7 +924,7 @@ void tos_poll() { } void tos_update_sysctrl(unsigned long n) { - // iprintf(">>>>>>>>>>>> set sys %x, eth is %s\n", n, (n&TOS_CONTROL_ETHERNET)?"on":"off"); + // 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) diff --git a/user_io.c b/user_io.c index 8b9ecd7..5e011e9 100644 --- a/user_io.c +++ b/user_io.c @@ -23,6 +23,9 @@ #include "x86.h" #include "tzx2wav.h" #include "DiskImage.h" +#include "boot.h" +#include "fdd.h" +#include "hdd.h" #define BREAK 0x8000 @@ -65,12 +68,6 @@ char user_io_osd_is_visible() return osd_is_visible; } -void user_io_init() -{ - memset(sd_image, 0, sizeof(sd_image)); - ikbd_init(); -} - unsigned char user_io_core_type() { return core_type; @@ -118,9 +115,6 @@ char *user_io_get_core_name_ex() case CORE_TYPE_MINIMIG2: return "MINIMIG"; - case CORE_TYPE_PACE: - return "PACE"; - case CORE_TYPE_MIST: return "ST"; @@ -171,7 +165,7 @@ static void user_io_read_core_name() if (p && p[0]) strcpy(core_name, p); } - iprintf("Core name is \"%s\"\n", core_name); + printf("Core name is \"%s\"\n", core_name); } static void set_kbd_led(unsigned char led, bool on) @@ -301,20 +295,23 @@ void send_rtc(int type) } } -void user_io_detect_core_type() +void user_io_init() { char *name; char mainpath[32]; core_name[0] = 0; disable_osd = 0; + memset(sd_image, 0, sizeof(sd_image)); + ikbd_init(); + tos_config_init(); + core_type = (fpga_core_id() & 0xFF); fio_size = fpga_get_fio_size(); io_ver = fpga_get_io_version(); if ((core_type != CORE_TYPE_DUMB) && (core_type != CORE_TYPE_MINIMIG2) && - (core_type != CORE_TYPE_PACE) && (core_type != CORE_TYPE_MIST) && (core_type != CORE_TYPE_ARCHIE) && (core_type != CORE_TYPE_8BIT)) @@ -327,34 +324,8 @@ void user_io_detect_core_type() spi_init(core_type != CORE_TYPE_UNKNOWN); OsdSetSize(8); - switch (core_type) + if (core_type == CORE_TYPE_8BIT) { - case CORE_TYPE_UNKNOWN: - iprintf("Unable to identify core (%x)!\n", core_type); - break; - - case CORE_TYPE_DUMB: - puts("Identified core without user interface"); - break; - - case CORE_TYPE_MINIMIG2: - puts("Identified Minimig V2 core"); - break; - - case CORE_TYPE_PACE: - puts("Identified PACE core"); - break; - - case CORE_TYPE_MIST: - puts("Identified MiST core"); - break; - - case CORE_TYPE_ARCHIE: - puts("Identified Archimedes core"); - archie_init(); - break; - - case CORE_TYPE_8BIT: puts("Identified 8BIT core"); // forward SD card config to core in case it uses the local @@ -368,22 +339,49 @@ void user_io_detect_core_type() // send a reset user_io_8bit_set_status(UIO_STATUS_RESET, UIO_STATUS_RESET); + } + mist_ini_parse(); + parse_video_mode(); + user_io_send_buttons(1); + + switch (core_type) + { + case CORE_TYPE_UNKNOWN: + printf("Unable to identify core (%x)!\n", core_type); + break; + + case CORE_TYPE_DUMB: + puts("Identified core without user interface"); + break; + + case CORE_TYPE_MINIMIG2: + puts("Identified Minimig V2 core"); + BootInit(); + break; + + case CORE_TYPE_MIST: + puts("Identified MiST core"); + tos_upload(NULL); + break; + + case CORE_TYPE_ARCHIE: + puts("Identified Archimedes core"); + archie_init(); + break; + + case CORE_TYPE_8BIT: // try to load config name = user_io_create_config_name(); - mist_ini_parse(); - parse_video_mode(); - user_io_send_buttons(1); - if(strlen(name) > 0) { OsdCoreNameSet(user_io_get_core_name()); - iprintf("Loading config %s\n", name); + printf("Loading config %s\n", name); unsigned long status = 0; if (FileLoadConfig(name, &status, 4)) { - iprintf("Found config\n"); + printf("Found config\n"); user_io_8bit_set_status(status, 0xffffffff); } parse_config(); @@ -741,7 +739,7 @@ int user_io_file_tx(char* name, unsigned char index) unsigned long bytes2send = f.size; /* transmit the entire file using one transfer */ - iprintf("Selected file %s with %lu bytes to send for index %d.%d\n", name, bytes2send, index&0x3F, index>>6); + printf("Selected file %s with %lu bytes to send for index %d.%d\n", name, bytes2send, index&0x3F, index>>6); // set index byte (0=bios rom, 1-n=OSD entry index) user_io_set_index(index); @@ -773,7 +771,7 @@ int user_io_file_tx(char* name, unsigned char index) { while (bytes2send) { - iprintf("."); + printf("."); uint16_t chunk = (bytes2send > 512) ? 512 : bytes2send; @@ -820,7 +818,7 @@ char *user_io_8bit_get_string(char index) return NULL; } - // iprintf("String: "); + // printf("String: "); while ((i != 0) && (i != 0xff) && (j> 8); // cmd request and drive number + c2 = (uint8_t)tmp; // track number + spi_w(0); + spi_w(0); + DisableFpga(); + HandleFDD(c1, c2); + HandleHDD(c1, c2); + UpdateDriveStatus(); + kbd_fifo_poll(); // frequently check mouse for events @@ -1058,18 +1068,18 @@ void user_io_poll() // status byte is 1000000A with A=1 if data is available if ((f = spi_in(0)) == 0x81) { - iprintf("\033[1;36m"); + printf("\033[1;36m"); // character 0xff is returned if FPGA isn't configured while ((f == 0x81) && (c != 0xff) && (c != 0x00) && (p < 8)) { c = spi_in(); - if (c != 0xff && c != 0x00) iprintf("%c", c); + if (c != 0xff && c != 0x00) printf("%c", c); f = spi_in(); p++; } - iprintf("\033[0m"); + printf("\033[0m"); } DisableIO(); */ @@ -1094,7 +1104,7 @@ void user_io_poll() // check if core requests configuration if (c & 0x08) { - iprintf("core requests SD config\n"); + printf("core requests SD config\n"); user_io_sd_set_config(); } @@ -1787,7 +1797,7 @@ void user_io_check_reset(unsigned short modifiers, char useKeys) void user_io_osd_key_enable(char on) { - iprintf("OSD is now %s\n", on ? "visible" : "invisible"); + printf("OSD is now %s\n", on ? "visible" : "invisible"); osd_is_visible = on; } diff --git a/user_io.h b/user_io.h index 2db8cba..ff1e9e3 100644 --- a/user_io.h +++ b/user_io.h @@ -125,7 +125,6 @@ // 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_PACE 0xa2 // core from pacedev.net (joystick only) #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 @@ -159,7 +158,6 @@ typedef struct { } __attribute__((packed)) serial_status_t; void user_io_init(); -void user_io_detect_core_type(); unsigned char user_io_core_type(); char is_minimig(); char is_archie();