src/mess/machine/comx35.c
| r7643 | r7644 | |
| 134 | 134 | PRINTER_PLOTTER |
| 135 | 135 | }; |
| 136 | 136 | |
| 137 | | enum |
| 138 | | { |
| 139 | | COMX_TYPE_BINARY = 1, |
| 140 | | COMX_TYPE_BASIC, |
| 141 | | COMX_TYPE_BASIC_FM, |
| 142 | | COMX_TYPE_RESERVED, |
| 143 | | COMX_TYPE_DATA |
| 144 | | }; |
| 145 | | |
| 146 | 137 | static UINT8 read_expansion(running_machine *machine) |
| 147 | 138 | { |
| 148 | 139 | UINT8 result; |
| r7643 | r7644 | |
| 707 | 698 | MACHINE_RESET_CALL(comx35); |
| 708 | 699 | } |
| 709 | 700 | } |
| 710 | | |
| 711 | | /* Quickload */ |
| 712 | | |
| 713 | | static void image_fread_memory(running_device *image, UINT16 addr, UINT32 count) |
| 714 | | { |
| 715 | | void *ptr = memory_get_write_ptr(cputag_get_address_space(image->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM), addr); |
| 716 | | |
| 717 | | image_fread(image, ptr, count); |
| 718 | | } |
| 719 | | |
| 720 | | QUICKLOAD_LOAD( comx35 ) |
| 721 | | { |
| 722 | | const address_space *program = cputag_get_address_space(image->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM); |
| 723 | | |
| 724 | | UINT8 header[16] = {0}; |
| 725 | | int size = image_length(image); |
| 726 | | |
| 727 | | if (size > messram_get_size(devtag_get_device(image->machine, "messram"))) |
| 728 | | { |
| 729 | | return INIT_FAIL; |
| 730 | | } |
| 731 | | |
| 732 | | image_fread(image, header, 5); |
| 733 | | |
| 734 | | if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' ) |
| 735 | | { |
| 736 | | return INIT_FAIL; |
| 737 | | } |
| 738 | | |
| 739 | | switch (header[0]) |
| 740 | | { |
| 741 | | case COMX_TYPE_BINARY: |
| 742 | | /* |
| 743 | | |
| 744 | | Type 1: pure machine code (i.e. no basic) |
| 745 | | |
| 746 | | Byte 0 to 4: 1 - 'COMX' |
| 747 | | Byte 5 and 6: Start address (1802 way; see above) |
| 748 | | Byte 6 and 7: End address |
| 749 | | Byte 9 and 10: Execution address |
| 750 | | |
| 751 | | Byte 11 to Eof, should be stored in ram from start to end; execution address |
| 752 | | 'xxxx' for the CALL (@xxxx) basic statement to actually run the code. |
| 753 | | |
| 754 | | */ |
| 755 | | { |
| 756 | | UINT16 start_address, end_address, run_address; |
| 757 | | |
| 758 | | image_fread(image, header, 6); |
| 759 | | |
| 760 | | start_address = header[0] << 8 | header[1]; |
| 761 | | end_address = header[2] << 8 | header[3]; |
| 762 | | run_address = header[4] << 8 | header[5]; |
| 763 | | |
| 764 | | image_fread_memory(image, start_address, end_address - start_address); |
| 765 | | |
| 766 | | popmessage("Type CALL (@%04x) to start program", run_address); |
| 767 | | } |
| 768 | | break; |
| 769 | | |
| 770 | | case COMX_TYPE_BASIC: |
| 771 | | /* |
| 772 | | |
| 773 | | Type 2: Regular basic code or machine code followed by basic |
| 774 | | |
| 775 | | Byte 0 to 4: 2 - 'COMX' |
| 776 | | Byte 5 and 6: DEFUS value, to be stored on 0x4281 and 0x4282 |
| 777 | | Byte 7 and 8: EOP value, to be stored on 0x4283 and 0x4284 |
| 778 | | Byte 9 and 10: End array, start string to be stored on 0x4292 and 0x4293 |
| 779 | | Byte 11 and 12: start array to be stored on 0x4294 and 0x4295 |
| 780 | | Byte 13 and 14: EOD and end string to be stored on 0x4299 and 0x429A |
| 781 | | |
| 782 | | Byte 15 to Eof to be stored on 0x4400 and onwards |
| 783 | | |
| 784 | | Byte 0x4281-0x429A (or at least the ones above) should be set otherwise |
| 785 | | BASIC won't 'see' the code. |
| 786 | | |
| 787 | | */ |
| 788 | | |
| 789 | | image_fread_memory(image, 0x4281, 4); |
| 790 | | image_fread_memory(image, 0x4292, 4); |
| 791 | | image_fread_memory(image, 0x4299, 2); |
| 792 | | image_fread_memory(image, 0x4400, size); |
| 793 | | break; |
| 794 | | |
| 795 | | case COMX_TYPE_BASIC_FM: |
| 796 | | /* |
| 797 | | |
| 798 | | Type 3: F&M basic load |
| 799 | | |
| 800 | | Not the most important! But we designed our own basic extension, you can |
| 801 | | find it in the F&M basic folder as F&M Basic.comx. When you run this all |
| 802 | | basic code should start at address 0x6700 instead of 0x4400 as from |
| 803 | | 0x4400-0x6700 the F&M basic stuff is loaded. So format is identical to Type |
| 804 | | 2 except Byte 15 to Eof should be stored on 0x6700 instead. .comx files of |
| 805 | | this format can also be found in the same folder as the F&M basic.comx file. |
| 806 | | |
| 807 | | */ |
| 808 | | |
| 809 | | image_fread_memory(image, 0x4281, 4); |
| 810 | | image_fread_memory(image, 0x4292, 4); |
| 811 | | image_fread_memory(image, 0x4299, 2); |
| 812 | | image_fread_memory(image, 0x6700, size); |
| 813 | | break; |
| 814 | | |
| 815 | | case COMX_TYPE_RESERVED: |
| 816 | | /* |
| 817 | | |
| 818 | | Type 4: Incorrect DATA format, I suggest to forget this one as it won't work |
| 819 | | in most cases. Instead I left this one reserved and designed Type 5 instead. |
| 820 | | |
| 821 | | */ |
| 822 | | break; |
| 823 | | |
| 824 | | case COMX_TYPE_DATA: |
| 825 | | /* |
| 826 | | |
| 827 | | Type 5: Data load |
| 828 | | |
| 829 | | Byte 0 to 4: 5 - 'COMX' |
| 830 | | Byte 5 and 6: Array length |
| 831 | | Byte 7 to Eof: Basic 'data' |
| 832 | | |
| 833 | | To load this first get the 'start array' from the running COMX, i.e. address |
| 834 | | 0x4295/0x4296. Calculate the EOD as 'start array' + length of the data (i.e. |
| 835 | | file length - 7). Store the EOD back on 0x4299 and ox429A. Calculate the |
| 836 | | 'Start String' as 'start array' + 'Array length' (Byte 5 and 6). Store the |
| 837 | | 'Start String' on 0x4292/0x4293. Load byte 7 and onwards starting from the |
| 838 | | 'start array' value fetched from 0x4295/0x4296. |
| 839 | | |
| 840 | | */ |
| 841 | | { |
| 842 | | UINT16 start_array, end_array, start_string, array_length; |
| 843 | | |
| 844 | | image_fread(image, header, 2); |
| 845 | | |
| 846 | | array_length = (header[0] << 8) | header[1]; |
| 847 | | start_array = (memory_read_byte(program, 0x4295) << 8) | memory_read_byte(program, 0x4296); |
| 848 | | end_array = start_array + (size - 7); |
| 849 | | |
| 850 | | memory_write_byte(program, 0x4299, end_array >> 8); |
| 851 | | memory_write_byte(program, 0x429a, end_array & 0xff); |
| 852 | | |
| 853 | | start_string = start_array + array_length; |
| 854 | | |
| 855 | | memory_write_byte(program, 0x4292, start_string >> 8); |
| 856 | | memory_write_byte(program, 0x4293, start_string & 0xff); |
| 857 | | |
| 858 | | image_fread_memory(image, start_array, size); |
| 859 | | } |
| 860 | | break; |
| 861 | | } |
| 862 | | |
| 863 | | return INIT_PASS; |
| 864 | | } |
src/mess/formats/comx35_comx.c
| r0 | r7644 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | formats/comx35_comx.c |
| 4 | |
| 5 | Quickload code for COMX-35 comx files |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #include "emu.h" |
| 10 | #include "formats/comx35_comx.h" |
| 11 | #include "cpu/cdp1802/cdp1802.h" |
| 12 | #include "devices/messram.h" |
| 13 | |
| 14 | /*************************************************************************** |
| 15 | PARAMETERS |
| 16 | ***************************************************************************/ |
| 17 | |
| 18 | #define LOG 1 |
| 19 | |
| 20 | enum |
| 21 | { |
| 22 | COMX_TYPE_BINARY = 1, |
| 23 | COMX_TYPE_BASIC, |
| 24 | COMX_TYPE_BASIC_FM, |
| 25 | COMX_TYPE_RESERVED, |
| 26 | COMX_TYPE_DATA |
| 27 | }; |
| 28 | |
| 29 | /*************************************************************************** |
| 30 | IMPLEMENTATION |
| 31 | ***************************************************************************/ |
| 32 | |
| 33 | static void image_fread_memory(running_device *image, UINT16 addr, UINT32 count) |
| 34 | { |
| 35 | void *ptr = memory_get_write_ptr(cpu_get_address_space(image->machine->firstcpu, ADDRESS_SPACE_PROGRAM), addr); |
| 36 | |
| 37 | image_fread(image, ptr, count); |
| 38 | } |
| 39 | |
| 40 | QUICKLOAD_LOAD( comx35_comx ) |
| 41 | { |
| 42 | const address_space *program = cpu_get_address_space(image->machine->firstcpu, ADDRESS_SPACE_PROGRAM); |
| 43 | |
| 44 | UINT8 header[16] = {0}; |
| 45 | int size = image_length(image); |
| 46 | |
| 47 | if (size > messram_get_size(devtag_get_device(image->machine, "messram"))) |
| 48 | { |
| 49 | return INIT_FAIL; |
| 50 | } |
| 51 | |
| 52 | image_fread(image, header, 5); |
| 53 | |
| 54 | if (header[1] != 'C' || header[2] != 'O' || header[3] != 'M' || header[4] != 'X' ) |
| 55 | { |
| 56 | return INIT_FAIL; |
| 57 | } |
| 58 | |
| 59 | switch (header[0]) |
| 60 | { |
| 61 | case COMX_TYPE_BINARY: |
| 62 | /* |
| 63 | |
| 64 | Type 1: pure machine code (i.e. no basic) |
| 65 | |
| 66 | Byte 0 to 4: 1 - 'COMX' |
| 67 | Byte 5 and 6: Start address (1802 way; see above) |
| 68 | Byte 6 and 7: End address |
| 69 | Byte 9 and 10: Execution address |
| 70 | |
| 71 | Byte 11 to Eof, should be stored in ram from start to end; execution address |
| 72 | 'xxxx' for the CALL (@xxxx) basic statement to actually run the code. |
| 73 | |
| 74 | */ |
| 75 | { |
| 76 | UINT16 start_address, end_address, run_address; |
| 77 | |
| 78 | image_fread(image, header, 6); |
| 79 | |
| 80 | start_address = header[0] << 8 | header[1]; |
| 81 | end_address = header[2] << 8 | header[3]; |
| 82 | run_address = header[4] << 8 | header[5]; |
| 83 | |
| 84 | image_fread_memory(image, start_address, end_address - start_address); |
| 85 | |
| 86 | popmessage("Type CALL (@%04x) to start program", run_address); |
| 87 | } |
| 88 | break; |
| 89 | |
| 90 | case COMX_TYPE_BASIC: |
| 91 | /* |
| 92 | |
| 93 | Type 2: Regular basic code or machine code followed by basic |
| 94 | |
| 95 | Byte 0 to 4: 2 - 'COMX' |
| 96 | Byte 5 and 6: DEFUS value, to be stored on 0x4281 and 0x4282 |
| 97 | Byte 7 and 8: EOP value, to be stored on 0x4283 and 0x4284 |
| 98 | Byte 9 and 10: End array, start string to be stored on 0x4292 and 0x4293 |
| 99 | Byte 11 and 12: start array to be stored on 0x4294 and 0x4295 |
| 100 | Byte 13 and 14: EOD and end string to be stored on 0x4299 and 0x429A |
| 101 | |
| 102 | Byte 15 to Eof to be stored on 0x4400 and onwards |
| 103 | |
| 104 | Byte 0x4281-0x429A (or at least the ones above) should be set otherwise |
| 105 | BASIC won't 'see' the code. |
| 106 | |
| 107 | */ |
| 108 | |
| 109 | image_fread_memory(image, 0x4281, 4); |
| 110 | image_fread_memory(image, 0x4292, 4); |
| 111 | image_fread_memory(image, 0x4299, 2); |
| 112 | image_fread_memory(image, 0x4400, size); |
| 113 | break; |
| 114 | |
| 115 | case COMX_TYPE_BASIC_FM: |
| 116 | /* |
| 117 | |
| 118 | Type 3: F&M basic load |
| 119 | |
| 120 | Not the most important! But we designed our own basic extension, you can |
| 121 | find it in the F&M basic folder as F&M Basic.comx. When you run this all |
| 122 | basic code should start at address 0x6700 instead of 0x4400 as from |
| 123 | 0x4400-0x6700 the F&M basic stuff is loaded. So format is identical to Type |
| 124 | 2 except Byte 15 to Eof should be stored on 0x6700 instead. .comx files of |
| 125 | this format can also be found in the same folder as the F&M basic.comx file. |
| 126 | |
| 127 | */ |
| 128 | |
| 129 | image_fread_memory(image, 0x4281, 4); |
| 130 | image_fread_memory(image, 0x4292, 4); |
| 131 | image_fread_memory(image, 0x4299, 2); |
| 132 | image_fread_memory(image, 0x6700, size); |
| 133 | break; |
| 134 | |
| 135 | case COMX_TYPE_RESERVED: |
| 136 | /* |
| 137 | |
| 138 | Type 4: Incorrect DATA format, I suggest to forget this one as it won't work |
| 139 | in most cases. Instead I left this one reserved and designed Type 5 instead. |
| 140 | |
| 141 | */ |
| 142 | break; |
| 143 | |
| 144 | case COMX_TYPE_DATA: |
| 145 | /* |
| 146 | |
| 147 | Type 5: Data load |
| 148 | |
| 149 | Byte 0 to 4: 5 - 'COMX' |
| 150 | Byte 5 and 6: Array length |
| 151 | Byte 7 to Eof: Basic 'data' |
| 152 | |
| 153 | To load this first get the 'start array' from the running COMX, i.e. address |
| 154 | 0x4295/0x4296. Calculate the EOD as 'start array' + length of the data (i.e. |
| 155 | file length - 7). Store the EOD back on 0x4299 and ox429A. Calculate the |
| 156 | 'Start String' as 'start array' + 'Array length' (Byte 5 and 6). Store the |
| 157 | 'Start String' on 0x4292/0x4293. Load byte 7 and onwards starting from the |
| 158 | 'start array' value fetched from 0x4295/0x4296. |
| 159 | |
| 160 | */ |
| 161 | { |
| 162 | UINT16 start_array, end_array, start_string, array_length; |
| 163 | |
| 164 | image_fread(image, header, 2); |
| 165 | |
| 166 | array_length = (header[0] << 8) | header[1]; |
| 167 | start_array = (memory_read_byte(program, 0x4295) << 8) | memory_read_byte(program, 0x4296); |
| 168 | end_array = start_array + (size - 7); |
| 169 | |
| 170 | memory_write_byte(program, 0x4299, end_array >> 8); |
| 171 | memory_write_byte(program, 0x429a, end_array & 0xff); |
| 172 | |
| 173 | start_string = start_array + array_length; |
| 174 | |
| 175 | memory_write_byte(program, 0x4292, start_string >> 8); |
| 176 | memory_write_byte(program, 0x4293, start_string & 0xff); |
| 177 | |
| 178 | image_fread_memory(image, start_array, size); |
| 179 | } |
| 180 | break; |
| 181 | } |
| 182 | |
| 183 | return INIT_PASS; |
| 184 | } |
src/mess/drivers/comx35.c
| r7643 | r7644 | |
| 17 | 17 | #include "sound/wave.h" |
| 18 | 18 | #include "devices/flopdrv.h" |
| 19 | 19 | #include "formats/comx35_dsk.h" |
| 20 | #include "formats/comx35_comx.h" |
| 20 | 21 | #include "devices/cassette.h" |
| 21 | 22 | #include "devices/printer.h" |
| 22 | 23 | #include "devices/snapquik.h" |
| r7643 | r7644 | |
| 413 | 414 | /* peripheral hardware */ |
| 414 | 415 | MDRV_CDP1871_ADD(CDP1871_TAG, comx35_cdp1871_intf, CDP1869_CPU_CLK_PAL / 8) |
| 415 | 416 | MDRV_WD1770_ADD(WD1770_TAG, comx35_wd17xx_interface ) |
| 416 | | MDRV_QUICKLOAD_ADD("quickload", comx35, "comx", 0) |
| 417 | MDRV_QUICKLOAD_ADD("quickload", comx35_comx, "comx", 0) |
| 417 | 418 | MDRV_CASSETTE_ADD(CASSETTE_TAG, comx35_cassette_config) |
| 418 | 419 | MDRV_PRINTER_ADD("printer") |
| 419 | 420 | |
| r7643 | r7644 | |
| 443 | 444 | /* peripheral hardware */ |
| 444 | 445 | MDRV_CDP1871_ADD(CDP1871_TAG, comx35_cdp1871_intf, CDP1869_CPU_CLK_NTSC / 8) |
| 445 | 446 | MDRV_WD1770_ADD(WD1770_TAG, comx35_wd17xx_interface ) |
| 446 | | MDRV_QUICKLOAD_ADD("quickload", comx35, "comx", 0) |
| 447 | MDRV_QUICKLOAD_ADD("quickload", comx35_comx, "comx", 0) |
| 447 | 448 | MDRV_CASSETTE_ADD(CASSETTE_TAG, comx35_cassette_config) |
| 448 | 449 | MDRV_PRINTER_ADD("printer") |
| 449 | 450 | |