src/mess/includes/amstrad.h
| r1949 | r1950 | |
| 24 | 24 | |
| 25 | 25 | /*----------- defined in drivers/amstrad.c -----------*/ |
| 26 | 26 | |
| 27 | | void amstrad_reset_machine(void); |
| 28 | | void amstrad_GateArray_write(int); |
| 27 | void amstrad_reset_machine(running_machine *); |
| 28 | void amstrad_GateArray_write(running_machine *,int); |
| 29 | 29 | void amstrad_rethinkMemory(void); |
| 30 | 30 | void amstrad_setLowerRom(void); |
| 31 | 31 | void amstrad_setUpperRom(void); |
| r1949 | r1950 | |
| 36 | 36 | |
| 37 | 37 | /*----------- defined in machine/amstrad.c -----------*/ |
| 38 | 38 | |
| 39 | | void amstrad_setup_machine(void); |
| 39 | void amstrad_setup_machine(running_machine *); |
| 40 | 40 | |
| 41 | 41 | SNAPSHOT_LOAD( amstrad ); |
| 42 | 42 | |
| r1949 | r1950 | |
| 46 | 46 | |
| 47 | 47 | /*----------- defined in video/amstrad.c -----------*/ |
| 48 | 48 | |
| 49 | | void amstrad_plus_setspritecolour(unsigned int off, int r, int g, int b); |
| 49 | void amstrad_plus_setspritecolour(running_machine *machine, unsigned int off, int r, int g, int b); |
| 50 | 50 | void amstrad_plus_setsplitline(unsigned int line, unsigned int address); |
| 51 | 51 | |
| 52 | 52 | /* On the Amstrad, any part of the 64k memory can be access by the video |
| r1949 | r1950 | |
| 81 | 81 | extern VIDEO_START( aleste ); |
| 82 | 82 | extern VIDEO_UPDATE( amstrad ); |
| 83 | 83 | void amstrad_vh_execute_crtc_cycles(int); |
| 84 | | void amstrad_vh_update_colour(int, int); |
| 84 | void amstrad_vh_update_colour(running_machine *machine, int, int); |
| 85 | 85 | void amstrad_vh_update_mode(int); |
| 86 | 86 | |
| 87 | 87 | /* The VSYNC signal of the CRTC */ |
| r1949 | r1950 | |
| 105 | 105 | |
| 106 | 106 | /**** ALESTE SPECIFIC ***/ |
| 107 | 107 | extern PALETTE_INIT( aleste ); |
| 108 | | void aleste_vh_update_colour(int, int); |
| 108 | void aleste_vh_update_colour(running_machine *machine, int, int); |
| 109 | 109 | |
| 110 | 110 | #endif /* AMSTRAD_H_ */ |
src/mess/video/amstrad.c
| r1949 | r1950 | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | #include "driver.h" |
| 11 | | #include "deprecat.h" |
| 12 | 11 | #include "devices/snapquik.h" |
| 13 | 12 | #include "includes/amstrad.h" |
| 14 | 13 | |
| r1949 | r1950 | |
| 302 | 301 | } |
| 303 | 302 | } |
| 304 | 303 | |
| 305 | | void amstrad_plus_setspritecolour(unsigned int off, int r, int g, int b) |
| 304 | void amstrad_plus_setspritecolour(running_machine *machine, unsigned int off, int r, int g, int b) |
| 306 | 305 | { |
| 307 | | palette_set_color_rgb(Machine, (off/2) + 33, r, g, b); |
| 306 | palette_set_color_rgb(machine, (off/2) + 33, r, g, b); |
| 308 | 307 | } |
| 309 | 308 | |
| 310 | 309 | static void amstrad_init_lookups(void) |
| r1949 | r1950 | |
| 336 | 335 | } |
| 337 | 336 | } |
| 338 | 337 | /* Set the new colour from the GateArray */ |
| 339 | | void amstrad_vh_update_colour(int PenIndex, int hw_colour_index) |
| 338 | void amstrad_vh_update_colour(running_machine *machine, int PenIndex, int hw_colour_index) |
| 340 | 339 | { |
| 341 | 340 | int val; |
| 342 | 341 | /* int cpu_cycles = ((cycles_currently_ran()>>2)-1) & 63; |
| 343 | 342 | |
| 344 | | logerror("color is changed(%d,%d) = %d\n",PenIndex, cpu_cycles, Machine->pens[hw_colour_index]); |
| 343 | logerror("color is changed(%d,%d) = %d\n",PenIndex, cpu_cycles, machine->pens[hw_colour_index]); |
| 345 | 344 | amstrad_GateArray_colours_ischanged++; |
| 346 | | amstrad_GateArray_changed_colours[cpu_cycles][PenIndex] = Machine->pens[hw_colour_index]; |
| 345 | amstrad_GateArray_changed_colours[cpu_cycles][PenIndex] = machine->pens[hw_colour_index]; |
| 347 | 346 | */ |
| 348 | | amstrad_GateArray_render_colours[PenIndex] = Machine->pens[hw_colour_index]; |
| 347 | amstrad_GateArray_render_colours[PenIndex] = machine->pens[hw_colour_index]; |
| 349 | 348 | if(amstrad_system_type != 0) |
| 350 | 349 | { // CPC+/GX4000 - normal palette changes through the Gate Array also makes the corresponding change in the ASIC palette |
| 351 | 350 | val = (amstrad_palette[hw_colour_index] & 0xf00000) >> 16; // red |
| r1949 | r1950 | |
| 356 | 355 | } |
| 357 | 356 | } |
| 358 | 357 | |
| 359 | | void aleste_vh_update_colour(int PenIndex, int hw_colour_index) |
| 358 | void aleste_vh_update_colour(running_machine *machine, int PenIndex, int hw_colour_index) |
| 360 | 359 | { |
| 361 | 360 | /* int cpu_cycles = ((cycles_currently_ran()>>2)-1) & 63; |
| 362 | 361 | |
| 363 | | logerror("color is changed(%d,%d) = %d\n",PenIndex, cpu_cycles, Machine->pens[hw_colour_index]); |
| 362 | logerror("color is changed(%d,%d) = %d\n",PenIndex, cpu_cycles, machine->pens[hw_colour_index]); |
| 364 | 363 | amstrad_GateArray_colours_ischanged++; |
| 365 | | amstrad_GateArray_changed_colours[cpu_cycles][PenIndex] = Machine->pens[hw_colour_index]; |
| 364 | amstrad_GateArray_changed_colours[cpu_cycles][PenIndex] = machine->pens[hw_colour_index]; |
| 366 | 365 | */ |
| 367 | | amstrad_GateArray_render_colours[PenIndex] = Machine->pens[hw_colour_index+32]; |
| 366 | amstrad_GateArray_render_colours[PenIndex] = machine->pens[hw_colour_index+32]; |
| 368 | 367 | } |
| 369 | 368 | |
| 370 | 369 | /* Set the new screen mode (0,1,2,4) from the GateArray */ |
| r1949 | r1950 | |
| 920 | 919 | |
| 921 | 920 | &6422 - &643f Sprite palette, 12-bit, xxxxGGGGRRRRBBBB, sprite pens 1-15 (0 is always transparent) |
| 922 | 921 | */ |
| 923 | | static void amstrad_plus_sprite_draw(bitmap_t* scr_bitmap) |
| 922 | static void amstrad_plus_sprite_draw(running_machine *machine, bitmap_t* scr_bitmap) |
| 924 | 923 | { |
| 925 | 924 | int spr; // sprite number |
| 926 | 925 | int xloc,yloc; |
| r1949 | r1950 | |
| 947 | 946 | xloc += rect.min_x; |
| 948 | 947 | yloc = amstrad_plus_asic_ram[sprptr+2] + (amstrad_plus_asic_ram[sprptr+3] << 8); |
| 949 | 948 | yloc += rect.min_y; |
| 950 | | decodechar(Machine->gfx[0],spr,amstrad_plus_asic_ram); |
| 951 | | drawgfxzoom(scr_bitmap,Machine->gfx[0],spr,0,0,0,xloc,yloc,&rect, |
| 949 | decodechar(machine->gfx[0],spr,amstrad_plus_asic_ram); |
| 950 | drawgfxzoom(scr_bitmap,machine->gfx[0],spr,0,0,0,xloc,yloc,&rect, |
| 952 | 951 | TRANSPARENCY_PEN,0,xmag,ymag); |
| 953 | 952 | } |
| 954 | 953 | } |
| r1949 | r1950 | |
| 979 | 978 | static void amstrad_plus_dma_parse(int channel, int *addr) |
| 980 | 979 | { |
| 981 | 980 | unsigned short command; |
| 982 | | running_machine *machine = Machine; |
| 981 | running_machine *machine = machine; |
| 983 | 982 | |
| 984 | 983 | if(*addr & 0x01) |
| 985 | 984 | (*addr)++; // align to even address |
| r1949 | r1950 | |
| 1135 | 1134 | /* CRTC - Set new Horizontal Sync Status */ |
| 1136 | 1135 | static void amstrad_Set_HS(int offset, int data) |
| 1137 | 1136 | { |
| 1138 | | running_machine *machine = Machine; |
| 1137 | running_machine *machine = machine; |
| 1139 | 1138 | |
| 1140 | 1139 | if (data != 0) |
| 1141 | 1140 | { |
| r1949 | r1950 | |
| 1284 | 1283 | #endif |
| 1285 | 1284 | copybitmap(bitmap, amstrad_bitmap, 0,0,0,0,&rect); |
| 1286 | 1285 | if(amstrad_plus_asic_enabled != 0) |
| 1287 | | amstrad_plus_sprite_draw(bitmap); |
| 1286 | amstrad_plus_sprite_draw(machine, bitmap); |
| 1288 | 1287 | amstrad_scanline = y_screen_pos - 32; |
| 1289 | 1288 | return 0; |
| 1290 | 1289 | } |
src/mess/drivers/amstrad.c
| r1949 | r1950 | |
| 702 | 702 | b = (amstrad_plus_asic_ram[offset+0x1fff] & 0x0f) << 4; |
| 703 | 703 | offset--; |
| 704 | 704 | } |
| 705 | | amstrad_plus_setspritecolour((offset - 0x422), r, g, b); |
| 705 | amstrad_plus_setspritecolour(machine, (offset - 0x422), r, g, b); |
| 706 | 706 | } |
| 707 | 707 | if(offset == 0x0800) // Programmable raster interrupt |
| 708 | 708 | { |
| r1949 | r1950 | |
| 975 | 975 | |
| 976 | 976 | Note 1 : This function is not available in the Gate-Array, but is performed by a device at the same I/O port address location. In the CPC464,CPC664 and KC compact, this function is performed in a memory-expansion (e.g. Dk'Tronics 64K Ram Expansion), if this expansion is not present then the function is not available. In the CPC6128, this function is performed by a PAL located on the main PCB, or a memory-expansion. In the 464+ and 6128+ this function is performed by the ASIC or a memory expansion. Please read the document on Ram Management for more information.*/ |
| 977 | 977 | |
| 978 | | void amstrad_GateArray_write(int dataToGateArray) |
| 978 | void amstrad_GateArray_write(running_machine *machine, int dataToGateArray) |
| 979 | 979 | { |
| 980 | 980 | /* Get Bit 7 and 6 of the dataToGateArray = Gate Array function selected */ |
| 981 | 981 | switch ((dataToGateArray & 0xc0)>>6) { |
| r1949 | r1950 | |
| 1013 | 1013 | #ifdef AMSTRAD_VIDEO_EVENT_LIST |
| 1014 | 1014 | EventList_AddItemOffset((EVENT_LIST_CODE_GA_COLOUR<<6) | PenIndex, AmstradCPC_PenColours[PenIndex], TIME_TO_CYCLES(0,video_screen_get_vpos(0)*video_screen_get_scan_period(0))); |
| 1015 | 1015 | #else |
| 1016 | | amstrad_vh_update_colour(amstrad_GateArray_PenSelected, (dataToGateArray & 0x1F)); |
| 1016 | amstrad_vh_update_colour(machine, amstrad_GateArray_PenSelected, (dataToGateArray & 0x1F)); |
| 1017 | 1017 | #endif |
| 1018 | 1018 | } break; |
| 1019 | 1019 | /* Select screen mode and rom configuration |
| r1949 | r1950 | |
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | | static void aleste_msx_mapper(int offset, int data) |
| 1107 | static void aleste_msx_mapper(running_machine *machine, int offset, int data) |
| 1108 | 1108 | { |
| 1109 | 1109 | int page = (offset & 0x0300) >> 8; |
| 1110 | 1110 | int ramptr = (data & 0x1f) * 0x4000; |
| r1949 | r1950 | |
| 1115 | 1115 | switch(function) |
| 1116 | 1116 | { |
| 1117 | 1117 | case 0: // Pen select (same as Gate Array?) |
| 1118 | | amstrad_GateArray_write(data); |
| 1118 | amstrad_GateArray_write(machine, data); |
| 1119 | 1119 | break; |
| 1120 | 1120 | case 1: // Colour select (6-bit palette) |
| 1121 | | aleste_vh_update_colour(amstrad_GateArray_PenSelected,data & 0x3f); |
| 1121 | aleste_vh_update_colour(machine, amstrad_GateArray_PenSelected,data & 0x3f); |
| 1122 | 1122 | break; |
| 1123 | 1123 | case 2: // Screen mode, Upper/Lower ROM select |
| 1124 | | amstrad_GateArray_write(data); |
| 1124 | amstrad_GateArray_write(machine, data); |
| 1125 | 1125 | break; |
| 1126 | 1126 | case 3: // RAM banks |
| 1127 | 1127 | switch(page) |
| r1949 | r1950 | |
| 1342 | 1342 | { |
| 1343 | 1343 | if(aleste_mode & 0x04) // Aleste mode |
| 1344 | 1344 | { |
| 1345 | | aleste_msx_mapper(offset,data); |
| 1345 | aleste_msx_mapper(machine, offset,data); |
| 1346 | 1346 | } |
| 1347 | 1347 | else |
| 1348 | 1348 | { |
| 1349 | 1349 | /* if b15 = 0 and b14 = 1 : Gate-Array Write Selected*/ |
| 1350 | 1350 | if ((offset & (1<<14)) != 0) |
| 1351 | | amstrad_GateArray_write(data); |
| 1351 | amstrad_GateArray_write(machine, data); |
| 1352 | 1352 | /* if b15 = 0 : RAM Configuration Write Selected*/ |
| 1353 | 1353 | AmstradCPC_GA_SetRamConfiguration(); |
| 1354 | 1354 | } |
| r1949 | r1950 | |
| 1837 | 1837 | All hardware is reset and the firmware is completely initialized |
| 1838 | 1838 | Once all tables and jumpblocks have been set up, |
| 1839 | 1839 | control is passed to the default entry in rom 0*/ |
| 1840 | | void amstrad_reset_machine(void) |
| 1840 | void amstrad_reset_machine(running_machine *machine) |
| 1841 | 1841 | { |
| 1842 | 1842 | /* enable lower rom (OS rom) */ |
| 1843 | | amstrad_GateArray_write(0x089); |
| 1843 | amstrad_GateArray_write(machine, 0x089); |
| 1844 | 1844 | |
| 1845 | 1845 | /* set ram config 0 */ |
| 1846 | | amstrad_GateArray_write(0x0c0); |
| 1846 | amstrad_GateArray_write(machine, 0x0c0); |
| 1847 | 1847 | |
| 1848 | 1848 | // Get manufacturer name and TV refresh rate from PCB link (dipswitch for mess emulation) |
| 1849 | 1849 | ppi_port_inputs[amstrad_ppi_PortB] = (((readinputportbytag("solder_links")&MANUFACTURER_NAME)<<1) | (readinputportbytag("solder_links")&TV_REFRESH_RATE)); |
| r1949 | r1950 | |
| 1854 | 1854 | multiface_reset(); |
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | | static void kccomp_reset_machine(void) |
| 1857 | static void kccomp_reset_machine(running_machine *machine) |
| 1858 | 1858 | { |
| 1859 | 1859 | /* enable lower rom (OS rom) */ |
| 1860 | | amstrad_GateArray_write(0x089); |
| 1860 | amstrad_GateArray_write(machine, 0x089); |
| 1861 | 1861 | |
| 1862 | 1862 | /* set ram config 0 */ |
| 1863 | | amstrad_GateArray_write(0x0c0); |
| 1863 | amstrad_GateArray_write(machine, 0x0c0); |
| 1864 | 1864 | } |
| 1865 | 1865 | |
| 1866 | 1866 | /* the following timings have been measured! */ |
| r1949 | r1950 | |
| 2087 | 2087 | |
| 2088 | 2088 | Amstrad_ROM_Table[7] = &memory_region(REGION_CPU1)[0x018000]; |
| 2089 | 2089 | amstrad_common_init(); |
| 2090 | | amstrad_reset_machine(); |
| 2090 | amstrad_reset_machine(machine); |
| 2091 | 2091 | |
| 2092 | 2092 | multiface_init(); |
| 2093 | 2093 | |
| r1949 | r1950 | |
| 2130 | 2130 | amstrad_plus_irq_cause = 6; |
| 2131 | 2131 | |
| 2132 | 2132 | amstrad_common_init(); |
| 2133 | | amstrad_reset_machine(); |
| 2133 | amstrad_reset_machine(machine); |
| 2134 | 2134 | amstrad_plus_asic_ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 2135 | 2135 | AmstradCPC_GA_SetRamConfiguration(); |
| 2136 | 2136 | amstrad_plus_setsplitline(0,0); |
| r1949 | r1950 | |
| 2179 | 2179 | amstrad_plus_irq_cause = 6; |
| 2180 | 2180 | |
| 2181 | 2181 | amstrad_common_init(); |
| 2182 | | amstrad_reset_machine(); |
| 2182 | amstrad_reset_machine(machine); |
| 2183 | 2183 | amstrad_plus_asic_ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 2184 | 2184 | AmstradCPC_GA_SetRamConfiguration(); |
| 2185 | 2185 | amstrad_plus_setsplitline(0,0); |
| r1949 | r1950 | |
| 2198 | 2198 | } |
| 2199 | 2199 | |
| 2200 | 2200 | amstrad_common_init(); |
| 2201 | | kccomp_reset_machine(); |
| 2201 | kccomp_reset_machine(machine); |
| 2202 | 2202 | |
| 2203 | 2203 | /* bit 1 = /TEST. When 0, KC compact will enter data transfer |
| 2204 | 2204 | sequence, where another system using the expansion port signals |
| r1949 | r1950 | |
| 2228 | 2228 | Amstrad_ROM_Table[3] = &memory_region(REGION_CPU1)[0x01c000]; // MSX-DOS / BIOS |
| 2229 | 2229 | Amstrad_ROM_Table[7] = &memory_region(REGION_CPU1)[0x018000]; // AMSDOS |
| 2230 | 2230 | amstrad_common_init(); |
| 2231 | | amstrad_reset_machine(); |
| 2231 | amstrad_reset_machine(machine); |
| 2232 | 2232 | |
| 2233 | 2233 | nec765_init(&aleste_8272_interface,NEC765A); |
| 2234 | 2234 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80); |