1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-02-13 19:14:05 +00:00

Merge pull request #32 from gyurco/master

MIST2 core type
This commit is contained in:
Till Harbaum
2019-07-29 21:19:24 +02:00
committed by GitHub
9 changed files with 188 additions and 43 deletions

2
fpga.c
View File

@@ -933,7 +933,7 @@ void fpga_init(char *name, unsigned long currentdirectory) {
} // end of minimig setup
if(user_io_core_type() == CORE_TYPE_MIST) {
if((user_io_core_type() == CORE_TYPE_MIST) || (user_io_core_type() == CORE_TYPE_MIST2)) {
puts("Running mist setup");
tos_upload(NULL);

View File

@@ -170,6 +170,7 @@ char *get_core_name()
return "PACE";
case CORE_TYPE_MIST:
case CORE_TYPE_MIST2:
return "ST";
case CORE_TYPE_ARCHIE:

3
main.c
View File

@@ -180,7 +180,8 @@ int main(void)
usb_poll();
// MIST (atari) core supports the same UI as Minimig
if(user_io_core_type() == CORE_TYPE_MIST) {
if((user_io_core_type() == CORE_TYPE_MIST) ||
(user_io_core_type() == CORE_TYPE_MIST2)) {
if(!fat_medium_present())
tos_eject_all();

7
menu.c
View File

@@ -505,6 +505,7 @@ char* get_keycode_table()
return "Amiga";
case CORE_TYPE_MIST:
case CORE_TYPE_MIST2:
return " ST";
case CORE_TYPE_ARCHIE:
@@ -693,7 +694,8 @@ void HandleUI(void)
if((user_io_core_type() == CORE_TYPE_MINIMIG) ||
(user_io_core_type() == CORE_TYPE_MINIMIG2))
menustate = MENU_MAIN1;
else if(user_io_core_type() == CORE_TYPE_MIST)
else if((user_io_core_type() == CORE_TYPE_MIST) ||
(user_io_core_type() == CORE_TYPE_MIST2))
menustate = MENU_MIST_MAIN1;
else if(user_io_core_type() == CORE_TYPE_ARCHIE)
menustate = MENU_ARCHIE_MAIN1;
@@ -1129,6 +1131,7 @@ void HandleUI(void)
menustate = MENU_MAIN2_1;
break;
case CORE_TYPE_MIST:
case CORE_TYPE_MIST2:
menusub = 5;
menustate = MENU_MIST_MAIN1;
break;
@@ -3329,6 +3332,7 @@ void HandleUI(void)
if (menu) {
switch(user_io_core_type()) {
case CORE_TYPE_MIST:
case CORE_TYPE_MIST2:
menusub = 5;
menustate = MENU_MIST_MAIN1;
break;
@@ -3357,6 +3361,7 @@ void HandleUI(void)
else if (menusub == fat_uses_mmc()?2:1) {
switch(user_io_core_type()) {
case CORE_TYPE_MIST:
case CORE_TYPE_MIST2:
menusub = 5;
menustate = MENU_MIST_MAIN1;
break;

1
osd.c
View File

@@ -609,6 +609,7 @@ unsigned char OsdGetCtrl(void)
// mist/atari, archie and 8bit cores use local queue
if((user_io_core_type() == CORE_TYPE_MIST) ||
(user_io_core_type() == CORE_TYPE_MIST2) ||
(user_io_core_type() == CORE_TYPE_ARCHIE) ||
(user_io_core_type() == CORE_TYPE_8BIT))
c1 = OsdKeyGet();

132
tos.c
View File

@@ -672,34 +672,30 @@ static void tos_font_load() {
}
}
void tos_load_cartridge(char *name) {
void tos_load_cartridge_mist1(char *name) {
fileTYPE file;
if(name)
strncpy(config.cart_img, name, 11);
// upload cartridge
// upload cartridge
if(config.cart_img[0] && FileOpen(&file, config.cart_img)) {
int i;
char buffer[512];
tos_debugf("%s:\n size = %d", config.cart_img, file.size);
int blocks = file.size / 512;
tos_debugf(" blocks = %d", blocks);
DISKLED_ON;
for(i=0;i<blocks;i++) {
FileRead(&file, buffer);
if(!(i&0x7f))
mist_memory_set_address(CART_BASE_ADDRESS+512*i, 128, 0);
mist_memory_set_address(CART_BASE_ADDRESS+512*i, 128, 0);
mist_memory_write_block(buffer);
if(i != blocks-1)
FileNextSector(&file);
FileNextSector(&file);
}
DISKLED_OFF;
@@ -714,6 +710,35 @@ void tos_load_cartridge(char *name) {
mist_memory_set(0, 64*1024/2);
mist_memory_set_address(CART_BASE_ADDRESS+128*512, 128, 0);
mist_memory_set(0, 64*1024/2);
}
void tos_load_cartridge_mist2(char *name) {
fileTYPE file;
// upload cartridge
if(config.cart_img[0] && FileOpen(&file, config.cart_img)) {
user_io_file_tx(&file, 0x02);
tos_debugf("%s uploaded", config.cart_img);
return;
}
// erase that ram area to remove any previously uploaded
// image
tos_debugf("Erasing cart memory");
user_io_fill_tx(0, 128*1024, 0x02);
}
void tos_load_cartridge(char *name) {
if(name)
strncpy(config.cart_img, name, 11);
if(user_io_core_type() == CORE_TYPE_MIST) {
tos_load_cartridge_mist1(name);
} else {
tos_load_cartridge_mist2(name);
}
}
char tos_cartridge_is_inserted() {
@@ -721,10 +746,8 @@ char tos_cartridge_is_inserted() {
}
void tos_upload(char *name) {
fileTYPE file;
// set video offset in fpga
tos_set_video_adjust(0, 0);
tos_debugf("Uploading TOS");
if(name)
strncpy(config.tos_img, name, 11);
@@ -732,6 +755,79 @@ void tos_upload(char *name) {
// put cpu into reset
config.system_ctrl |= TOS_CONTROL_CPU_RESET;
mist_set_control(config.system_ctrl);
if(user_io_core_type() == CORE_TYPE_MIST) {
tos_upload_mist1(name);
} else {
tos_upload_mist2(name);
}
// let cpu run (release reset)
config.system_ctrl &= ~TOS_CONTROL_CPU_RESET;
mist_set_control(config.system_ctrl);
}
void tos_upload_mist2(char *name) {
fileTYPE file;
// clear first 16k
tos_debugf("Clear first 16k");
user_io_fill_tx(0, 16*1024, 0x03);
// upload and verify tos image
if(FileOpen(&file, config.tos_img)) {
tos_debugf("TOS.IMG:\n size = %d", file.size);
if(file.size >= 256*1024)
user_io_file_tx(&file, 0x00);
else if(file.size == 192*1024)
user_io_file_tx(&file, 0x01);
else
tos_debugf("WARNING: Unexpected TOS size!");
} else {
tos_debugf("Unable to find tos.img");
return;
}
// 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 name[] = "DISK_A ST ";
name[5] = 'A'+i;
fileTYPE file;
if(FileOpen(&file, name)) {
tos_insert_disk(i, &file);
}
}
if(config.sd_direct) {
tos_set_direct_hdd(1);
} else {
// try to open harddisk image
for(i=0;i<2;i++) {
if(FileOpen(&file, config.acsi_img[i])) {
tos_select_hdd_image(i, &file);
}
}
}
}
ikbd_reset();
}
void tos_upload_mist1(char *name) {
fileTYPE file;
int i;
// set video offset in fpga
tos_set_video_adjust(0, 0);
tos_font_load();
tos_clr();
@@ -740,8 +836,6 @@ void tos_upload(char *name) {
tos_write("\x0e\x0f MIST core \x0e\x0f ");
tos_write("Uploading TOS ... ");
tos_debugf("Uploading TOS ...");
DISKLED_ON;
// upload and verify tos image
@@ -963,9 +1057,6 @@ void tos_upload(char *name) {
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) {
@@ -1008,7 +1099,8 @@ void tos_update_sysctrl(unsigned long n) {
// 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) {
if((user_io_core_type() == CORE_TYPE_MIST) ||
(user_io_core_type() == CORE_TYPE_MIST2)) {
config.system_ctrl = n;
mist_set_control(config.system_ctrl);
}

4
tos.h
View File

@@ -82,6 +82,8 @@
unsigned long tos_system_ctrl(void);
void tos_upload_mist1(char *);
void tos_upload_mist2(char *);
void tos_upload(char *);
void tos_poll();
void tos_update_sysctrl(unsigned long);
@@ -96,6 +98,8 @@ void tos_reset(char cold);
char *tos_get_image_name();
char *tos_get_cartridge_name();
char tos_cartridge_is_inserted();
void tos_load_cartridge_mist1(char *);
void tos_load_cartridge_mist2(char *);
void tos_load_cartridge(char *);
void tos_set_video_adjust(char axis, char value);

View File

@@ -226,6 +226,7 @@ void user_io_detect_core_type() {
(core_type != CORE_TYPE_MINIMIG2) &&
(core_type != CORE_TYPE_PACE) &&
(core_type != CORE_TYPE_MIST) &&
(core_type != CORE_TYPE_MIST2) &&
(core_type != CORE_TYPE_ARCHIE) &&
(core_type != CORE_TYPE_8BIT))
core_type = CORE_TYPE_UNKNOWN;
@@ -252,6 +253,7 @@ void user_io_detect_core_type() {
break;
case CORE_TYPE_MIST:
case CORE_TYPE_MIST2:
puts("Identified MiST core");
break;
@@ -380,7 +382,7 @@ void user_io_digital_joystick(unsigned char joystick, unsigned char map) {
// atari ST handles joystick 0 and 1 through the ikbd emulated by the io controller
// but only for joystick 1 and 2
if((core_type == CORE_TYPE_MIST) && (joystick < 2)) {
ikbd_joystick(joystick, map);
ikbd_joystick(joystick, map);
return;
}
@@ -414,7 +416,10 @@ void user_io_joystick(unsigned char joystick, unsigned char map) {
// transmit serial/rs232 data into core
void user_io_serial_tx(char *chr, uint16_t cnt) {
spi_uio_cmd_cont(UIO_SERIAL_OUT);
if (core_type == CORE_TYPE_MIST)
spi_uio_cmd_cont(UIO_SERIAL_OUT);
else
spi_uio_cmd_cont(UIO_SERIAL_OUT2);
while(cnt--) spi8(*chr++);
DisableIO();
}
@@ -700,12 +705,30 @@ static void user_io_file_tx_done(void) {
iprintf("\n");
}
static void user_io_file_tx_fill(unsigned char fill, unsigned int len) {
EnableFpga();
SPI(UIO_FILE_TX_DAT);
while(len--) {
SPI(fill);
}
DisableFpga();
}
void user_io_file_tx(fileTYPE *file, unsigned char index) {
user_io_file_tx_prepare(index);
user_io_file_tx_send(file);
user_io_file_tx_done();
}
// send 'fill' byte 'len' times
void user_io_fill_tx(unsigned char fill, unsigned int len, unsigned char index) {
user_io_file_tx_prepare(index);
user_io_file_tx_fill(fill, len);
user_io_file_tx_done();
}
// 8 bit cores have a config string telling the firmware how
// to treat it
char *user_io_8bit_get_string(char index) {
@@ -872,15 +895,17 @@ void user_io_poll() {
(core_type != CORE_TYPE_MINIMIG2) &&
(core_type != CORE_TYPE_PACE) &&
(core_type != CORE_TYPE_MIST) &&
(core_type != CORE_TYPE_MIST2) &&
(core_type != CORE_TYPE_ARCHIE) &&
(core_type != CORE_TYPE_8BIT)) {
return; // no user io for the installed core
}
if(core_type == CORE_TYPE_MIST) {
if((core_type == CORE_TYPE_MIST) ||
(core_type == CORE_TYPE_MIST2)) {
char redirect = tos_get_cdc_control_redirect();
ikbd_poll();
if (core_type == CORE_TYPE_MIST) ikbd_poll();
// check for input data on usart
USART_Poll();
@@ -891,7 +916,11 @@ void user_io_poll() {
// arm rs232 and mixes with debug output. Useful for debugging only of
// e.g. the diagnostic cartridge
if(!pl2303_is_blocked()) {
spi_uio_cmd_cont(UIO_SERIAL_IN);
if (core_type == CORE_TYPE_MIST)
spi_uio_cmd_cont(UIO_SERIAL_IN);
else
spi_uio_cmd_cont(UIO_SERIAL_IN2);
while(spi_in() && !pl2303_is_blocked()) {
c = spi_in();
@@ -1027,7 +1056,8 @@ void user_io_poll() {
}
}
if(core_type == CORE_TYPE_MIST) {
if((core_type == CORE_TYPE_MIST) ||
(core_type == CORE_TYPE_MIST2)) {
// do some tos specific monitoring here
tos_poll();
}
@@ -1210,7 +1240,8 @@ void user_io_poll() {
}
}
if(core_type == CORE_TYPE_8BIT) {
if((core_type == CORE_TYPE_8BIT) ||
(core_type == CORE_TYPE_MIST2)) {
// frequently check ps2 mouse for events
if(CheckTimer(mouse_timer)) {
@@ -1371,13 +1402,13 @@ static void send_keycode(unsigned short code) {
}
if(core_type == CORE_TYPE_MIST) {
// atari has "break" marker in msb
if(code & BREAK) code = (code & 0xff) | 0x80;
ikbd_keyboard(code);
// atari has "break" marker in msb
ikbd_keyboard((code & BREAK) ? ((code & 0xff) | 0x80) : code);
}
if(core_type == CORE_TYPE_8BIT) {
if((core_type == CORE_TYPE_8BIT) ||
(core_type == CORE_TYPE_MIST2)) {
// send ps2 keycodes for those cores that prefer ps2
spi_uio_cmd_cont(UIO_KEYBOARD);
@@ -1431,7 +1462,8 @@ void user_io_mouse(unsigned char b, char x, char y) {
}
// 8 bit core expects ps2 like data
if(core_type == CORE_TYPE_8BIT) {
if((core_type == CORE_TYPE_8BIT) ||
(core_type == CORE_TYPE_MIST2)) {
mouse_pos[X] += x;
mouse_pos[Y] -= y; // ps2 y axis is reversed over usb
mouse_flags |= 0x08 | (b&3);
@@ -1488,16 +1520,15 @@ unsigned short keycode(unsigned char in) {
if((core_type == CORE_TYPE_MINIMIG) ||
(core_type == CORE_TYPE_MINIMIG2))
return usb2amiga(in);
// atari st and the 8 bit core (currently only used for atari 800)
// use the same key codes
if(core_type == CORE_TYPE_MIST)
return usb2atari[in];
if(core_type == CORE_TYPE_ARCHIE)
return usb2archie[in];
if(core_type == CORE_TYPE_8BIT)
if((core_type == CORE_TYPE_8BIT) ||
(core_type == CORE_TYPE_MIST2))
return usb2ps2code(in);
return MISS;
@@ -1552,11 +1583,12 @@ unsigned short modifier_keycode(unsigned char index) {
return amiga_modifier[index];
}
if(core_type == CORE_TYPE_MIST) {
if((core_type == CORE_TYPE_MIST) ||
(core_type == CORE_TYPE_MIST2)) {
static const unsigned short atari_modifier[] =
{ 0x1d, 0x2a, 0x38, MISS, 0x1d, 0x36, 0x38, MISS };
return atari_modifier[index];
}
}
if(core_type == CORE_TYPE_8BIT) {
static const unsigned short ps2_modifier[] =
@@ -1589,6 +1621,7 @@ static char key_used_by_osd(unsigned short s) {
// else none as it's up to the core to forward keys
// to the OSD
return((core_type == CORE_TYPE_MIST) ||
(core_type == CORE_TYPE_MIST2) ||
(core_type == CORE_TYPE_ARCHIE) ||
(core_type == CORE_TYPE_8BIT));
}
@@ -1722,6 +1755,7 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority, unsigned s
if( (core_type == CORE_TYPE_MINIMIG) ||
(core_type == CORE_TYPE_MINIMIG2) ||
(core_type == CORE_TYPE_MIST) ||
(core_type == CORE_TYPE_MIST2) ||
(core_type == CORE_TYPE_ARCHIE) ||
(core_type == CORE_TYPE_8BIT))
{

View File

@@ -23,8 +23,8 @@
// directions (in/out) are from an io controller view
#define UIO_IKBD_OUT 0x02
#define UIO_IKBD_IN 0x03
#define UIO_SERIAL_OUT 0x04
#define UIO_SERIAL_IN 0x05
#define UIO_SERIAL_OUT 0x04 // Warning! same as UIO_MOUSE
#define UIO_SERIAL_IN 0x05 // Warning! same as UIO_KEYBOARD
#define UIO_PARALLEL_IN 0x06
#define UIO_MIDI_OUT 0x07
#define UIO_MIDI_IN 0x08
@@ -34,6 +34,11 @@
#define UIO_ETH_FRM_OUT 0x0c
#define UIO_SERIAL_STAT 0x0d
// codes as used by MiST2 (atari)
// directions (in/out) are from an io controller view
#define UIO_SERIAL_OUT2 0x24
#define UIO_SERIAL_IN2 0x25
#define UIO_JOYSTICK2 0x10 // also used by minimig and 8 bit
#define UIO_JOYSTICK3 0x11 // -"-
#define UIO_JOYSTICK4 0x12 // -"-
@@ -125,6 +130,7 @@
#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
#define CORE_TYPE_MIST2 0xa7 // New MiST core
// user io status bits (currently only used by 8bit)
#define UIO_STATUS_RESET 0x01
@@ -166,6 +172,7 @@ void user_io_osd_key_enable(char);
void user_io_serial_tx(char *, uint16_t);
char *user_io_8bit_get_string(char);
unsigned long user_io_8bit_set_status(unsigned long, unsigned long);
void user_io_fill_tx(unsigned char, unsigned int, unsigned char);
void user_io_file_tx(fileTYPE *, unsigned char);
void user_io_sd_set_config(void);
char user_io_dip_switch1(void);