fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation

Add MOS hex file load and save support

+382 -47
+5
Makefile.dep
··· 2740 2740 src/lib/ihex.h \ 2741 2741 src/lib/load.h \ 2742 2742 src/lib/log.h \ 2743 + src/lib/mhex.h \ 2743 2744 src/lib/path.h \ 2744 2745 src/lib/srec.h \ 2745 2746 src/libini/libini.h ··· 2747 2748 src/lib/log.o: src/lib/log.c \ 2748 2749 src/lib/log.h 2749 2750 2751 + src/lib/mhex.o: src/lib/mhex.c \ 2752 + src/lib/mhex.h 2753 + 2750 2754 src/lib/monitor.o: src/lib/monitor.c \ 2751 2755 src/lib/cmd.h \ 2752 2756 src/lib/console.h \ 2753 2757 src/lib/ihex.h \ 2758 + src/lib/mhex.h \ 2754 2759 src/lib/monitor.h \ 2755 2760 src/lib/srec.h 2756 2761
+3 -5
src/arch/atarist/Makefile.inc
··· 76 76 src/lib/inidsk.o \ 77 77 src/lib/iniram.o \ 78 78 src/lib/initerm.o \ 79 - src/lib/ihex.o \ 80 - src/lib/srec.o \ 81 - src/lib/load.o \ 82 79 src/lib/log.o \ 83 80 src/lib/monitor.o \ 84 81 src/lib/msg.o \ ··· 86 83 src/lib/path.o \ 87 84 src/lib/string.o \ 88 85 src/lib/sysdep.o \ 86 + $(LIBPCE_LOAD_OBJ) \ 87 + $(LIBINI_OBJ) \ 89 88 $(CPU_68K_OBJ) \ 90 89 $(DRV_BLK_OBJ) \ 91 90 $(DRV_PSI_OBJ) \ 92 91 $(DRV_PRI_OBJ) \ 93 92 $(DRV_CHR_OBJ) \ 94 93 $(DRV_SND_OBJ) \ 95 - $(DRV_TRM_OBJ) \ 96 - $(LIBINI_OBJ) 94 + $(DRV_TRM_OBJ) 97 95 98 96 ifeq "$(PCE_ENABLE_TUN)" "1" 99 97 PCE_ATARIST_OBJ_EXT += src/lib/tun.o
+3 -5
src/arch/cpm80/Makefile.inc
··· 41 41 src/lib/cmd.o \ 42 42 src/lib/console.o \ 43 43 src/lib/getopt.o \ 44 - src/lib/ihex.o \ 45 44 src/lib/inidsk.o \ 46 45 src/lib/iniram.o \ 47 - src/lib/load.o \ 48 46 src/lib/log.o \ 49 47 src/lib/monitor.o \ 50 48 src/lib/msg.o \ 51 49 src/lib/path.o \ 52 - src/lib/srec.o \ 53 50 src/lib/string.o \ 54 51 src/lib/sysdep.o \ 52 + $(LIBPCE_LOAD_OBJ) \ 53 + $(LIBINI_OBJ) \ 55 54 $(CPU_8080_OBJ) \ 56 55 $(DRV_BLK_OBJ) \ 57 56 $(DRV_PRI_OBJ) \ 58 57 $(DRV_PSI_OBJ) \ 59 - $(DRV_CHR_OBJ) \ 60 - $(LIBINI_OBJ) 58 + $(DRV_CHR_OBJ) 61 59 62 60 ifeq "$(PCE_ENABLE_TUN)" "1" 63 61 PCE_CPM80_OBJ_EXT += src/lib/tun.o
+3 -5
src/arch/ibmpc/Makefile.inc
··· 83 83 src/lib/inidsk.o \ 84 84 src/lib/iniram.o \ 85 85 src/lib/initerm.o \ 86 - src/lib/ihex.o \ 87 - src/lib/srec.o \ 88 - src/lib/load.o \ 89 86 src/lib/log.o \ 90 87 src/lib/monitor.o \ 91 88 src/lib/msg.o \ ··· 93 90 src/lib/path.o \ 94 91 src/lib/string.o \ 95 92 src/lib/sysdep.o \ 93 + $(LIBPCE_LOAD_OBJ) \ 94 + $(LIBINI_OBJ) \ 96 95 $(CPU_8086_OBJ) \ 97 96 $(DEV_VID_OBJ) \ 98 97 $(DRV_BLK_OBJ) \ ··· 100 99 $(DRV_PSI_OBJ) \ 101 100 $(DRV_CHR_OBJ) \ 102 101 $(DRV_SND_OBJ) \ 103 - $(DRV_TRM_OBJ) \ 104 - $(LIBINI_OBJ) 102 + $(DRV_TRM_OBJ) 105 103 106 104 ifeq "$(PCE_ENABLE_TUN)" "1" 107 105 PCE_IBMPC_OBJ_EXT += src/lib/tun.o
+3 -5
src/arch/macplus/Makefile.inc
··· 79 79 src/lib/inidsk.o \ 80 80 src/lib/iniram.o \ 81 81 src/lib/initerm.o \ 82 - src/lib/ihex.o \ 83 - src/lib/srec.o \ 84 - src/lib/load.o \ 85 82 src/lib/log.o \ 86 83 src/lib/monitor.o \ 87 84 src/lib/msg.o \ ··· 89 86 src/lib/path.o \ 90 87 src/lib/string.o \ 91 88 src/lib/sysdep.o \ 89 + $(LIBPCE_LOAD_OBJ) \ 90 + $(LIBINI_OBJ) \ 92 91 $(CPU_68K_OBJ) \ 93 92 $(DRV_BLK_OBJ) \ 94 93 $(DRV_PSI_OBJ) \ 95 94 $(DRV_PRI_OBJ) \ 96 95 $(DRV_CHR_OBJ) \ 97 96 $(DRV_SND_OBJ) \ 98 - $(DRV_TRM_OBJ) \ 99 - $(LIBINI_OBJ) 97 + $(DRV_TRM_OBJ) 100 98 101 99 ifeq "$(PCE_ENABLE_TUN)" "1" 102 100 PCE_MACPLUS_OBJ_EXT += src/lib/tun.o
+2 -4
src/arch/rc759/Makefile.inc
··· 74 74 src/lib/inidsk.o \ 75 75 src/lib/iniram.o \ 76 76 src/lib/initerm.o \ 77 - src/lib/ihex.o \ 78 - src/lib/srec.o \ 79 - src/lib/load.o \ 80 77 src/lib/log.o \ 81 78 src/lib/monitor.o \ 82 79 src/lib/msg.o \ ··· 84 81 src/lib/path.o \ 85 82 src/lib/string.o \ 86 83 src/lib/sysdep.o \ 84 + $(LIBPCE_LOAD_OBJ) \ 85 + $(LIBINI_OBJ) \ 87 86 $(CPU_8086_OBJ) \ 88 - $(LIBINI_OBJ) \ 89 87 $(DRV_BLK_OBJ) \ 90 88 $(DRV_PSI_OBJ) \ 91 89 $(DRV_PRI_OBJ) \
+3 -5
src/arch/sim405/Makefile.inc
··· 56 56 src/lib/cmd.o \ 57 57 src/lib/console.o \ 58 58 src/lib/getopt.o \ 59 - src/lib/ihex.o \ 60 59 src/lib/iniata.o \ 61 60 src/lib/inidsk.o \ 62 61 src/lib/iniram.o \ 63 - src/lib/load.o \ 64 62 src/lib/log.o \ 65 63 src/lib/monitor.o \ 66 64 src/lib/msg.o \ 67 65 src/lib/path.o \ 68 - src/lib/srec.o \ 69 66 src/lib/string.o \ 70 67 src/lib/sysdep.o \ 68 + $(LIBPCE_LOAD_OBJ) \ 69 + $(LIBINI_OBJ) \ 71 70 $(CPU_PPC405_OBJ) \ 72 71 $(DRV_BLK_OBJ) \ 73 72 $(DRV_PRI_OBJ) \ 74 73 $(DRV_PSI_OBJ) \ 75 - $(DRV_CHR_OBJ) \ 76 - $(LIBINI_OBJ) 74 + $(DRV_CHR_OBJ) 77 75 78 76 ifeq "$(PCE_ENABLE_TUN)" "1" 79 77 PCE_SIM405_OBJ_EXT += src/lib/tun.o
+3 -5
src/arch/sim6502/Makefile.inc
··· 35 35 src/lib/cfg.o \ 36 36 src/lib/cmd.o \ 37 37 src/lib/console.o \ 38 - src/lib/ihex.o \ 39 38 src/lib/iniram.o \ 40 - src/lib/load.o \ 41 39 src/lib/log.o \ 42 40 src/lib/monitor.o \ 43 41 src/lib/path.o \ 44 - src/lib/srec.o \ 45 42 src/lib/sysdep.o \ 46 - $(CPU_6502_OBJ) \ 47 - $(LIBINI_OBJ) 43 + $(LIBPCE_LOAD_OBJ) \ 44 + $(LIBINI_OBJ) \ 45 + $(CPU_6502_OBJ) 48 46 49 47 ifeq "$(PCE_BUILD_SIM6502)" "1" 50 48 BIN += $(PCE_SIM6502_BIN)
+3 -5
src/arch/simarm/Makefile.inc
··· 43 43 src/lib/cmd.o \ 44 44 src/lib/console.o \ 45 45 src/lib/getopt.o \ 46 - src/lib/ihex.o \ 47 46 src/lib/iniata.o \ 48 47 src/lib/inidsk.o \ 49 48 src/lib/iniram.o \ 50 - src/lib/load.o \ 51 49 src/lib/log.o \ 52 50 src/lib/monitor.o \ 53 51 src/lib/msg.o \ 54 52 src/lib/path.o \ 55 - src/lib/srec.o \ 56 53 src/lib/string.o \ 57 54 src/lib/sysdep.o \ 55 + $(LIBPCE_LOAD_OBJ) \ 56 + $(LIBINI_OBJ) \ 58 57 $(CPU_ARM_OBJ) \ 59 58 $(DRV_BLK_OBJ) \ 60 59 $(DRV_PRI_OBJ) \ 61 60 $(DRV_PSI_OBJ) \ 62 - $(DRV_CHR_OBJ) \ 63 - $(LIBINI_OBJ) 61 + $(DRV_CHR_OBJ) 64 62 65 63 ifeq "$(PCE_ENABLE_TUN)" "1" 66 64 PCE_SIMARM_OBJ_EXT += src/lib/tun.o
+3 -5
src/arch/sims32/Makefile.inc
··· 39 39 src/lib/cfg.o \ 40 40 src/lib/cmd.o \ 41 41 src/lib/console.o \ 42 - src/lib/ihex.o \ 43 42 src/lib/iniram.o \ 44 - src/lib/load.o \ 45 43 src/lib/log.o \ 46 44 src/lib/monitor.o \ 47 45 src/lib/path.o \ 48 - src/lib/srec.o \ 49 46 src/lib/sysdep.o \ 47 + $(LIBPCE_LOAD_OBJ) \ 48 + $(LIBINI_OBJ) \ 50 49 $(CPU_SPARC32_OBJ) \ 51 - $(DRV_CHR_OBJ) \ 52 - $(LIBINI_OBJ) 50 + $(DRV_CHR_OBJ) 53 51 54 52 ifeq "$(PCE_ENABLE_TUN)" "1" 55 53 PCE_SIMS32_OBJ_EXT += src/lib/tun.o
+4
src/lib/Makefile.inc
··· 18 18 initerm \ 19 19 load \ 20 20 log \ 21 + mhex \ 21 22 monitor \ 22 23 msg \ 23 24 msgdsk \ ··· 37 38 LIBPCE_HDR := $(foreach f,$(LIBPCE_BAS),$(rel)/$(f).h) 38 39 LIBPCE_SDP := src/config.h 39 40 41 + LIBPCE_LOAD_OBJ := $(rel)/ihex.o $(rel)/mhex.o $(rel)/srec.o $(rel)/load.o 42 + 40 43 CLN += $(LIBPCE_OBJ) 41 44 DIST += $(LIBPCE_SRC) $(LIBPCE_HDR) 42 45 ··· 51 54 $(rel)/iniram.o: $(rel)/iniram.c 52 55 $(rel)/initerm.o: $(rel)/initerm.c 53 56 $(rel)/log.o: $(rel)/log.c 57 + $(rel)/mhex.o: $(rel)/mhex.c 54 58 $(rel)/monitor.o: $(rel)/monitor.c 55 59 $(rel)/msg.o: $(rel)/msg.c 56 60 $(rel)/msgdsk.o: $(rel)/msgdsk.c
+28 -1
src/lib/load.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/lib/load.c * 7 7 * Created: 2004-08-02 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2004-2013 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2004-2020 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 28 28 29 29 #include <lib/log.h> 30 30 #include <lib/ihex.h> 31 + #include <lib/mhex.h> 31 32 #include <lib/srec.h> 32 33 #include <lib/load.h> 33 34 #include <lib/path.h> ··· 71 72 return (r); 72 73 } 73 74 75 + int pce_load_mem_mhex (memory_t *mem, const char *fname) 76 + { 77 + int r; 78 + FILE *fp; 79 + 80 + pce_log_tag (MSG_INF, "Load:", "file=%s format=mhex\n", 81 + fname 82 + ); 83 + 84 + if ((fp = fopen (fname, "rb")) == NULL) { 85 + return (1); 86 + } 87 + 88 + r = mhex_load_fp (fp, mem, (mhex_set_f) mem_set_uint8_rw); 89 + 90 + fclose (fp); 91 + 92 + return (r); 93 + } 94 + 74 95 int pce_load_mem_srec (memory_t *mem, const char *fname) 75 96 { 76 97 int r; ··· 142 163 if ((strcasecmp (ext, "ihex") == 0) || (strcasecmp (ext, "ihx") == 0)) { 143 164 fmt = "ihex"; 144 165 } 166 + else if (strcasecmp (ext, "mhex") == 0) { 167 + fmt = "mhex"; 168 + } 145 169 else if (strcasecmp (ext, "srec") == 0) { 146 170 fmt = "srec"; 147 171 } ··· 158 182 } 159 183 else if (strcmp (fmt, "ihex") == 0) { 160 184 return (pce_load_mem_ihex (mem, fname)); 185 + } 186 + else if (strcmp (fmt, "mhex") == 0) { 187 + return (pce_load_mem_mhex (mem, fname)); 161 188 } 162 189 else if (strcmp (fmt, "srec") == 0) { 163 190 return (pce_load_mem_srec (mem, fname));
+254
src/lib/mhex.c
··· 1 + /***************************************************************************** 2 + * pce * 3 + *****************************************************************************/ 4 + 5 + /***************************************************************************** 6 + * File name: src/lib/mhex.c * 7 + * Created: 2020-05-02 by Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2020 Hampa Hug <hampa@hampa.ch> * 9 + *****************************************************************************/ 10 + 11 + /***************************************************************************** 12 + * This program is free software. You can redistribute it and / or modify it * 13 + * under the terms of the GNU General Public License version 2 as published * 14 + * by the Free Software Foundation. * 15 + * * 16 + * This program is distributed in the hope that it will be useful, but * 17 + * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 + * Public License for more details. * 20 + *****************************************************************************/ 21 + 22 + 23 + #include <stdlib.h> 24 + #include <stdio.h> 25 + 26 + #include "mhex.h" 27 + 28 + 29 + static 30 + int mhex_skip_line (FILE *fp) 31 + { 32 + int c; 33 + 34 + while ((c = fgetc (fp)) != EOF) { 35 + if ((c == 0x0a) || (c == 0x0d)) { 36 + return (0); 37 + } 38 + } 39 + 40 + return (1); 41 + } 42 + 43 + static 44 + unsigned mhex_get_cksum (unsigned addr, const unsigned char *buf, unsigned cnt) 45 + { 46 + unsigned val; 47 + 48 + val = (addr & 0xff) + ((addr >> 8) & 0xff); 49 + val += cnt & 0xff; 50 + 51 + while (cnt-- > 0) { 52 + val += *(buf++) & 0xff; 53 + } 54 + 55 + return (val & 0xffff); 56 + } 57 + 58 + static 59 + int mhex_read_hex (FILE *fp, unsigned char *buf, unsigned cnt) 60 + { 61 + int c; 62 + unsigned i, j, s; 63 + 64 + cnt *= 2; 65 + 66 + for (i = 0; i < cnt; i++) { 67 + if ((c = fgetc (fp)) == EOF) { 68 + return (1); 69 + } 70 + 71 + j = i >> 1; 72 + s = (~i & 1) << 2; 73 + 74 + buf[j] &= 0xf0 << s; 75 + 76 + if ((c >= '0') && (c <= '9')) { 77 + buf[j] |= (c - '0') << s; 78 + } 79 + else if ((c >= 'A') && (c <= 'F')) { 80 + buf[j] |= (c - 'A' + 10) << s; 81 + } 82 + else if ((c >= 'a') && (c <= 'f')) { 83 + buf[j] |= (c - 'a' + 10) << s; 84 + } 85 + else { 86 + return (1); 87 + } 88 + } 89 + 90 + return (0); 91 + } 92 + 93 + static 94 + int mhex_read_record (FILE *fp, unsigned *addr, unsigned char *buf, unsigned *cnt, int *check) 95 + { 96 + int c; 97 + unsigned ck; 98 + unsigned char tmp[2]; 99 + 100 + while ((c = fgetc (fp)) != ';') { 101 + if (c == EOF) { 102 + return (1); 103 + } 104 + 105 + if ((c != 0x0a) && (c != 0x0d)) { 106 + mhex_skip_line (fp); 107 + } 108 + } 109 + 110 + if (mhex_read_hex (fp, tmp, 1)) { 111 + return (1); 112 + } 113 + 114 + *cnt = tmp[0]; 115 + 116 + if (mhex_read_hex (fp, tmp, 2)) { 117 + return (1); 118 + } 119 + 120 + *addr = ((tmp[0] & 0xff) << 8) | (tmp[1] & 0xff); 121 + 122 + if (mhex_read_hex (fp, buf, *cnt)) { 123 + return (1); 124 + } 125 + 126 + if (mhex_read_hex (fp, tmp, 2)) { 127 + return (1); 128 + } 129 + 130 + ck = ((tmp[0] & 0xff) << 8) | (tmp[1] & 0xff); 131 + 132 + *check = (mhex_get_cksum (*addr, buf, *cnt) != ck); 133 + 134 + mhex_skip_line (fp); 135 + 136 + return (0); 137 + } 138 + 139 + int mhex_load_fp (FILE *fp, void *ext, mhex_set_f set) 140 + { 141 + int check; 142 + unsigned i, addr, cnt, rcnt; 143 + unsigned char buf[256]; 144 + 145 + rcnt = 0; 146 + 147 + while (1) { 148 + if (mhex_read_record (fp, &addr, buf, &cnt, &check)) { 149 + break; 150 + } 151 + 152 + rcnt += 1; 153 + 154 + if (check) { 155 + return (1); 156 + } 157 + 158 + if (cnt == 0) { 159 + if ((addr + 1) != rcnt) { 160 + return (1); 161 + } 162 + 163 + rcnt = 0; 164 + } 165 + 166 + for (i = 0; i < cnt; i++) { 167 + set (ext, addr + i, buf[i]); 168 + } 169 + } 170 + 171 + if (rcnt > 0) { 172 + return (1); 173 + } 174 + 175 + return (0); 176 + } 177 + 178 + int mhex_load (const char *fname, void *ext, mhex_set_f set) 179 + { 180 + int r; 181 + FILE *fp; 182 + 183 + if ((fp = fopen (fname, "rb")) == NULL) { 184 + return (1); 185 + } 186 + 187 + r = mhex_load_fp (fp, ext, set); 188 + 189 + fclose (fp); 190 + 191 + return (r); 192 + } 193 + 194 + static 195 + void mhex_write_record (FILE *fp, unsigned addr, const unsigned char *buf, unsigned cnt) 196 + { 197 + unsigned ck; 198 + 199 + ck = mhex_get_cksum (addr, buf, cnt); 200 + 201 + fprintf (fp, ";%02X%04X", cnt & 0xff, addr & 0xffff); 202 + 203 + while (cnt-- > 0) { 204 + fprintf (fp, "%02X", *(buf++)); 205 + } 206 + 207 + fprintf (fp, "%04X\n", ck & 0xffff); 208 + } 209 + 210 + int mhex_save_fp (FILE *fp, unsigned long base, unsigned addr, unsigned size, void *ext, mhex_get_f get) 211 + { 212 + unsigned i, cnt, rcnt; 213 + unsigned char buf[16]; 214 + 215 + rcnt = 0; 216 + 217 + while (size > 0) { 218 + cnt = (size < 16) ? size : 16; 219 + 220 + if (((addr + cnt) & 0xffff) < (addr & 0xffff)) { 221 + cnt = -addr & 0xffff; 222 + } 223 + 224 + for (i = 0; i < cnt; i++) { 225 + buf[i] = get (ext, base + ((addr + i) & 0xffff)); 226 + } 227 + 228 + mhex_write_record (fp, addr, buf, cnt); 229 + 230 + rcnt += 1; 231 + addr += cnt; 232 + size -= cnt; 233 + } 234 + 235 + mhex_write_record (fp, rcnt, NULL, 0); 236 + 237 + return (0); 238 + } 239 + 240 + int mhex_save (const char *fname, unsigned long base, unsigned addr, unsigned size, void *ext, mhex_get_f set) 241 + { 242 + int r; 243 + FILE *fp; 244 + 245 + if ((fp = fopen (fname, "wb")) == NULL) { 246 + return (1); 247 + } 248 + 249 + r = mhex_save_fp (fp, base, addr, size, ext, set); 250 + 251 + fclose (fp); 252 + 253 + return (r); 254 + }
+38
src/lib/mhex.h
··· 1 + /***************************************************************************** 2 + * pce * 3 + *****************************************************************************/ 4 + 5 + /***************************************************************************** 6 + * File name: src/lib/mhex.h * 7 + * Created: 2020-05-02 by Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2020 Hampa Hug <hampa@hampa.ch> * 9 + *****************************************************************************/ 10 + 11 + /***************************************************************************** 12 + * This program is free software. You can redistribute it and / or modify it * 13 + * under the terms of the GNU General Public License version 2 as published * 14 + * by the Free Software Foundation. * 15 + * * 16 + * This program is distributed in the hope that it will be useful, but * 17 + * WITHOUT ANY WARRANTY, without even the implied warranty of * 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 19 + * Public License for more details. * 20 + *****************************************************************************/ 21 + 22 + 23 + #ifndef PCE_LIB_MHEX_H 24 + #define PCE_LIB_MHEX_H 1 25 + 26 + 27 + typedef void (*mhex_set_f) (void *ext, unsigned long addr, unsigned char val); 28 + typedef unsigned char (*mhex_get_f) (void *ext, unsigned long addr); 29 + 30 + 31 + int mhex_load_fp (FILE *fp, void *ext, mhex_set_f set); 32 + int mhex_load (const char *fname, void *ext, mhex_set_f set); 33 + 34 + int mhex_save_fp (FILE *fp, unsigned long base, unsigned addr, unsigned size, void *ext, mhex_get_f get); 35 + int mhex_save (const char *fname, unsigned long base, unsigned addr, unsigned size, void *ext, mhex_get_f set); 36 + 37 + 38 + #endif
+27 -2
src/lib/monitor.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/lib/monitor.c * 7 7 * Created: 2006-12-13 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2006-2019 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2006-2020 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 29 29 #include <lib/cmd.h> 30 30 #include <lib/console.h> 31 31 #include <lib/ihex.h> 32 + #include <lib/mhex.h> 32 33 #include <lib/srec.h> 33 34 34 35 35 36 #define MON_FORMAT_NONE 0 36 37 #define MON_FORMAT_BINARY 1 37 38 #define MON_FORMAT_IHEX 2 38 - #define MON_FORMAT_SREC 3 39 + #define MON_FORMAT_MHEX 3 40 + #define MON_FORMAT_SREC 4 39 41 40 42 41 43 static mon_cmd_t par_cmd[] = { ··· 233 235 else if (strcasecmp (ext, "hex") == 0) { 234 236 return (MON_FORMAT_IHEX); 235 237 } 238 + else if (strcasecmp (ext, "mhex") == 0) { 239 + return (MON_FORMAT_MHEX); 240 + } 236 241 else if (strcasecmp (ext, "srec") == 0) { 237 242 return (MON_FORMAT_SREC); 238 243 } ··· 248 253 } 249 254 else if (cmd_match (cmd, "ihex")) { 250 255 *fmt = MON_FORMAT_IHEX; 256 + } 257 + else if (cmd_match (cmd, "mhex")) { 258 + *fmt = MON_FORMAT_MHEX; 251 259 } 252 260 else if (cmd_match (cmd, "srec")) { 253 261 *fmt = MON_FORMAT_SREC; ··· 715 723 } 716 724 break; 717 725 726 + case MON_FORMAT_MHEX: 727 + if (mhex_load_fp (fp, mon, (mhex_set_f) mon_set_mem8)) { 728 + pce_printf ("loading mhex failed\n"); 729 + } 730 + break; 731 + 718 732 case MON_FORMAT_SREC: 719 733 if (srec_load_fp (fp, mon, (srec_set_f) mon_set_mem8)) { 720 734 pce_printf ("loading srec failed\n"); ··· 817 831 if (ihex_save (fp, seg, ofs, cnt, mon, (ihex_get_f) mon_get_mem8)) { 818 832 pce_printf ("saving ihex failed\n"); 819 833 } 834 + } 835 + break; 836 + 837 + case MON_FORMAT_MHEX: 838 + if (mon->memory_mode == 0) { 839 + seg = 0; 840 + ofs = addr; 841 + } 842 + 843 + if (mhex_save_fp (fp, seg, ofs, cnt, mon, (mhex_get_f) mon_get_mem8)) { 844 + pce_printf ("saving mhex failed\n"); 820 845 } 821 846 break; 822 847