Index: common/romgen/createall
===================================================================
--- common/romgen/createall	(revision 286)
+++ common/romgen/createall	(revision 287)
@@ -4,7 +4,9 @@
 ./create_rom.pl 1 ATARIBAS.ROM basic > ../a8core/basic.vhdl
 ./create_rom.pl 1 5200.rom os_5200 > ../a8core/os_5200.vhdl
 ./create_rom.pl 4 ../../firmware/MCC216.bin zpu_rom 13 > ../../mcc216/zpu_rom.vhdl
+./create_rom.pl 4 ../../firmware/MCC216_5200.bin zpu_rom 13 > ../../mcc216_5200/zpu_rom.vhdl
 ./create_rom.pl 4 ../../firmware/MCCTV.bin zpu_rom 13 > ../../mcctv/zpu_rom.vhdl
+./create_rom.pl 4 ../../firmware/MCCTV_5200.bin zpu_rom 13 > ../../mcctv_5200/zpu_rom.vhdl
 ./create_rom.pl 4 ../../firmware/MIST.bin zpu_rom 12 > ../../mist/zpu_rom.vhdl
 ./create_rom.pl 4 ../../firmware/MIST_5200.bin zpu_rom 12 > ../../mist_5200/zpu_rom.vhdl
 ./create_rom.pl 4 ../../firmware/DE1.bin zpu_rom 12 > ../../de1/zpu_rom.vhdl
Index: firmware/Makefile
===================================================================
--- firmware/Makefile	(revision 286)
+++ firmware/Makefile	(revision 287)
@@ -32,7 +32,9 @@
 DE1_5200_DIR = de1_5200
 CHAMELEON_DIR = chameleon
 MCC_DIR = mcc
+MCC_5200_DIR = mcc_5200
 MCCTV_DIR = mcctv
+MCCTV_5200_DIR = mcctv_5200
 MIST_DIR = mist
 MIST_5200_DIR = mist_5200
 LINUXSIM_DIR = linux
@@ -43,7 +45,9 @@
 DE1_5200_BUILD_DIR = $(BUILD_DIR)/$(DE1_5200_DIR)
 CHAMELEON_BUILD_DIR = $(BUILD_DIR)/$(CHAMELEON_DIR)
 MCC_BUILD_DIR = $(BUILD_DIR)/$(MCC_DIR)
+MCC_5200_BUILD_DIR = $(BUILD_DIR)/$(MCC_5200_DIR)
 MCCTV_BUILD_DIR = $(BUILD_DIR)/$(MCCTV_DIR)
+MCCTV_5200_BUILD_DIR = $(BUILD_DIR)/$(MCCTV_5200_DIR)
 MIST_BUILD_DIR = $(BUILD_DIR)/$(MIST_DIR)
 MIST_5200_BUILD_DIR = $(BUILD_DIR)/$(MIST_5200_DIR)
 LINUXSIM_BUILD_DIR = $(BUILD_DIR)/$(LINUXSIM_DIR)
@@ -82,11 +86,19 @@
 #MCC_SRC = $(COMMON_SRC) $(SDCARD_SRC) $(A800_SRC) mcc/dirs.c
 MCC_OBJ = $(patsubst %.c,$(MCC_BUILD_DIR)/%.o,$(MCC_SRC))
 
+MCC_5200_PRJ = MCC216_5200
+MCC_5200_SRC = $(COMMON_SRC) $(SDCARD_SRC) $(5200_SRC) $(USB_SRC) mcc_5200/dirs.c
+MCC_5200_OBJ = $(patsubst %.c,$(MCC_5200_BUILD_DIR)/%.o,$(MCC_5200_SRC))
+
 MCCTV_PRJ = MCCTV
 MCCTV_SRC = $(COMMON_SRC) $(SDCARD_SRC) $(A800_SRC) $(USB_SRC) mcc/dirs.c
 #MCCTV_SRC = $(COMMON_SRC) $(SDCARD_SRC) $(A800_SRC) mcc/dirs.c
 MCCTV_OBJ = $(patsubst %.c,$(MCCTV_BUILD_DIR)/%.o,$(MCCTV_SRC))
 
+MCCTV_5200_PRJ = MCCTV_5200
+MCCTV_5200_SRC = $(COMMON_SRC) $(SDCARD_SRC) $(5200_SRC) $(USB_SRC) mcc_5200/dirs.c
+MCCTV_5200_OBJ = $(patsubst %.c,$(MCCTV_5200_BUILD_DIR)/%.o,$(MCCTV_5200_SRC))
+
 MIST_PRJ = MIST
 MIST_SRC = $(COMMON_SRC) $(SDCARD_SRC) $(A800_SRC) mist/dirs.c
 MIST_OBJ = $(patsubst %.c,$(MIST_BUILD_DIR)/%.o,$(MIST_SRC))
@@ -127,10 +139,12 @@
 CFLAGS_USB = $(CFLAGS) -DUSB -Iusb
 CFLAGS_USB2 = $(CFLAGS) -DUSB -DUSB2 -Iusb
 CFLAGS_5200 = $(CFLAGS) -DFIRMWARE_5200
+CFLAGS_5200_USB = $(CFLAGS) -DFIRMWARE_5200 -DUSB -Iusb
+CFLAGS_5200_USB2 = $(CFLAGS) -DFIRMWARE_5200  -DUSB -DUSB2 -Iusb
 HOST_CFLAGS_5200 = $(HOST_CFLAGS) -DFIRMWARE_5200
 
 # Our target.
-all: mcc mcctv mist de1 aeon_lite chameleon  de1_5200 mist_5200
+all: mcc mcctv mist de1 aeon_lite chameleon  de1_5200 mist_5200 mcc_5200 mcctv_5200
 
 install:
 	cd ../common/romgen && ./createall && cd ../../firmware
@@ -145,8 +159,12 @@
 
 mcc: $(BUILD_DIR) $(MCC_PRJ).bin $(MCC_PRJ).rpt
 
+mcc_5200: $(BUILD_DIR) $(MCC_5200_PRJ).bin $(MCC_5200_PRJ).rpt
+
 mcctv: $(BUILD_DIR) $(MCCTV_PRJ).bin $(MCCTV_PRJ).rpt
 
+mcctv_5200: $(BUILD_DIR) $(MCCTV_5200_PRJ).bin $(MCCTV_5200_PRJ).rpt
+
 mist: $(BUILD_DIR) $(MIST_PRJ).bin $(MIST_PRJ).rpt
 
 mist_5200: $(BUILD_DIR) $(MIST_5200_PRJ).bin $(MIST_5200_PRJ).rpt
@@ -192,9 +210,15 @@
 	$(LD) $(LFLAGS) -T $(LINKMAP_LARGE) -o $@ $+ $(LIBS)
 #	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
 
+$(MCC_5200_PRJ).elf: $(MINSTARTUP_OBJ) $(MCC_5200_OBJ)
+	$(LD) $(LFLAGS_5200) -T $(LINKMAP_LARGE) -o $@ $+ $(LIBS)
+
 $(MCCTV_PRJ).elf: $(MINSTARTUP_OBJ) $(MCCTV_OBJ)
 	$(LD) $(LFLAGS) -T $(LINKMAP_LARGE) -o $@ $+ $(LIBS)
 
+$(MCCTV_5200_PRJ).elf: $(MINSTARTUP_OBJ) $(MCCTV_5200_OBJ)
+	$(LD) $(LFLAGS_5200) -T $(LINKMAP_LARGE) -o $@ $+ $(LIBS)
+
 $(MIST_PRJ).elf: $(MINSTARTUP_OBJ) $(MIST_OBJ)
 	$(LD) $(LFLAGS) -T $(LINKMAP) -o $@ $+ $(LIBS)
 
@@ -227,10 +251,18 @@
 	mkdir -p `dirname $@`
 	$(CC) -I$(MCC_DIR) $(CFLAGS_USB)  -o $@ -c $<
 
+$(MCC_5200_BUILD_DIR)/%.o: %.c Makefile
+	mkdir -p `dirname $@`
+	$(CC) -I$(MCC_5200_DIR) $(CFLAGS_5200_USB)  -o $@ -c $<
+
 $(MCCTV_BUILD_DIR)/%.o: %.c Makefile
 	mkdir -p `dirname $@`
 	$(CC) -I$(MCCTV_DIR) $(CFLAGS_USB2)  -o $@ -c $<
 
+$(MCCTV_5200_BUILD_DIR)/%.o: %.c Makefile
+	mkdir -p `dirname $@`
+	$(CC) -I$(MCCTV_5200_DIR) $(CFLAGS_5200_USB2)  -o $@ -c $<
+
 $(MIST_BUILD_DIR)/%.o: %.c Makefile
 	mkdir -p `dirname $@`
 	$(CC) -I$(MIST_DIR) $(CFLAGS)  -o $@ -c $<
Index: firmware/usb/hid.c
===================================================================
--- firmware/usb/hid.c	(revision 286)
+++ firmware/usb/hid.c	(revision 287)
@@ -521,11 +521,20 @@
     uint8_t key_code;      // usb keycodes to be sent for all joysticks
     uint8_t button_bit;  
   } button_map[] = {
+#ifndef FIRMWARE_5200
     { 13, 13, 0x3f, 0 }, /* start -> f6 */
     { 12, 12, 0x40, 0 }, /* select -> f7 */
     { 10, 10, 0x41, 0 }, /* l2 -> f8 */
     { 11, 11, 0x41, 0 }, /* r2 -> f8 */
     { 7, 7, 0x41, 0 }, /* 4 -> f8 */
+#endif
+#ifdef FIRMWARE_5200
+    { 13, 13, 0x3a, 0 }, /* start -> f1 (start) */
+    { 12, 12, 0x3b, 0 }, /* select -> f2 (pause) */
+    { 10, 10, 0x00, 8 }, /* l2 -> fire2 */
+    { 11, 11, 0x00, 8 }, /* r2 -> fire2 */
+    { 7, 7, 0x00, 8 }, /* 4 -> fire2 */
+#endif
     { 10, 11, 0x43, 0 }, /* l2&r2 -> f10 */
     { 8, 11, 0x42, 0 }, /* l1&r2 -> f9 */
     { 4, 4, 0x45, 0 }, /* 1 -> f12 */
