src/mess/video/spectrum.c
| r2516 | r2517 | |
| 19 | 19 | #include "video/border.h" |
| 20 | 20 | |
| 21 | 21 | |
| 22 | | unsigned char *spectrum_characterram; |
| 23 | | unsigned char *spectrum_colorram; |
| 24 | | static unsigned char *charsdirty; |
| 25 | | static int frame_number; /* Used for handling FLASH 1 */ |
| 26 | | static int flash_invert; |
| 22 | UINT8 *spectrum_characterram; |
| 23 | UINT8 *spectrum_colorram; |
| 27 | 24 | |
| 28 | | INLINE void spectrum_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color) |
| 29 | | { |
| 30 | | *BITMAP_ADDR16(bitmap, y, x) = (UINT16)color; |
| 31 | | } |
| 25 | int frame_number; /* Used for handling FLASH 1 */ |
| 26 | int flash_invert; |
| 32 | 27 | |
| 33 | 28 | /*************************************************************************** |
| 34 | 29 | Start the video hardware emulation. |
| r2516 | r2517 | |
| 37 | 32 | { |
| 38 | 33 | frame_number = 0; |
| 39 | 34 | flash_invert = 0; |
| 40 | | spectrum_characterram = auto_malloc(0x1800); |
| 41 | | |
| 42 | | spectrum_colorram = auto_malloc(0x300); |
| 43 | | |
| 44 | | charsdirty = auto_malloc(0x300); |
| 45 | | |
| 46 | | memset(charsdirty,1,0x300); |
| 47 | 35 | EventList_Initialise(30000); |
| 48 | 36 | } |
| 49 | 37 | |
| 50 | | /* screen is stored as: |
| 51 | | 32 chars wide. first 0x100 bytes are top scan of lines 0 to 7 */ |
| 52 | 38 | |
| 53 | | WRITE8_HANDLER (spectrum_characterram_w) |
| 54 | | { |
| 55 | | spectrum_characterram[offset] = data; |
| 56 | | |
| 57 | | charsdirty[((offset & 0x0f800)>>3) + (offset & 0x0ff)] = 1; |
| 58 | | } |
| 59 | | |
| 60 | | READ8_HANDLER (spectrum_characterram_r) |
| 61 | | { |
| 62 | | return(spectrum_characterram[offset]); |
| 63 | | } |
| 64 | | |
| 65 | | |
| 66 | | WRITE8_HANDLER (spectrum_colorram_w) |
| 67 | | { |
| 68 | | /* Will eventually be used to emulate hi-res colour effects. No point |
| 69 | | doing it now as contented memory is not emulated so timings will |
| 70 | | be way off. (eg Zynaps taking 212 cycles not 224 per scanline) |
| 71 | | */ |
| 72 | | /* EventList_AddItemOffset(machine, offset+0x5800, data, cpu_getcurrentcycles()); */ |
| 73 | | |
| 74 | | spectrum_colorram[offset] = data; |
| 75 | | charsdirty[offset] = 1; |
| 76 | | } |
| 77 | | |
| 78 | | READ8_HANDLER (spectrum_colorram_r) |
| 79 | | { |
| 80 | | return(spectrum_colorram[offset]); |
| 81 | | } |
| 82 | | |
| 83 | 39 | /* return the color to be used inverting FLASHing colors if necessary */ |
| 84 | 40 | INLINE unsigned char get_display_color (unsigned char color, int invert) |
| 85 | 41 | { |
| r2516 | r2517 | |
| 117 | 73 | } |
| 118 | 74 | |
| 119 | 75 | |
| 120 | | /* Update FLASH status for ts2068. Assumes flash update every 1/2s. */ |
| 121 | | VIDEO_EOF( ts2068 ) |
| 122 | | { |
| 123 | | EVENT_LIST_ITEM *pItem; |
| 124 | | int NumItems; |
| 125 | 76 | |
| 126 | | frame_number++; |
| 127 | | if (frame_number >= 30) |
| 128 | | { |
| 129 | | frame_number = 0; |
| 130 | | flash_invert = !flash_invert; |
| 131 | | } |
| 132 | | |
| 133 | | /* Empty event buffer for undisplayed frames noting the last border |
| 134 | | colour (in case colours are not changed in the next frame). */ |
| 135 | | NumItems = EventList_NumEvents(); |
| 136 | | if (NumItems) |
| 137 | | { |
| 138 | | pItem = EventList_GetFirstItem(); |
| 139 | | set_last_border_color ( pItem[NumItems-1].Event_Data ); |
| 140 | | EventList_Reset(); |
| 141 | | EventList_SetOffsetStartTime ( ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(machine->primary_screen), video_screen_get_vpos(machine->primary_screen))) ); |
| 142 | | logerror ("Event log reset in callback fn.\n"); |
| 143 | | } |
| 144 | | } |
| 145 | | |
| 146 | 77 | /*************************************************************************** |
| 147 | 78 | Update the spectrum screen display. |
| 148 | 79 | |
| r2516 | r2517 | |
| 174 | 105 | |
| 175 | 106 | if (full_refresh) |
| 176 | 107 | { |
| 177 | | memset(charsdirty,1,0x300); |
| 178 | 108 | last_invert = flash_invert; |
| 179 | 109 | } |
| 180 | 110 | else |
| r2516 | r2517 | |
| 182 | 112 | /* Update all flashing characters when necessary */ |
| 183 | 113 | if (last_invert != flash_invert) |
| 184 | 114 | { |
| 185 | | for (count=0;count<0x300;count++) |
| 186 | | if (spectrum_colorram[count] & 0x80) |
| 187 | | charsdirty[count] = 1; |
| 188 | 115 | last_invert = flash_invert; |
| 189 | 116 | } |
| 190 | 117 | } |
| 191 | 118 | |
| 192 | 119 | for (count=0;count<32*8;count++) |
| 193 | 120 | { |
| 194 | | if (charsdirty[count]) { |
| 195 | 121 | decodechar( screen->machine->gfx[0],count,spectrum_characterram); |
| 196 | | } |
| 197 | | |
| 198 | | if (charsdirty[count+256]) { |
| 199 | 122 | decodechar( screen->machine->gfx[1],count,&spectrum_characterram[0x800]); |
| 200 | | } |
| 201 | | |
| 202 | | if (charsdirty[count+512]) { |
| 203 | 123 | decodechar( screen->machine->gfx[2],count,&spectrum_characterram[0x1000]); |
| 204 | | } |
| 205 | 124 | } |
| 206 | 125 | |
| 207 | 126 | for (count=0;count<32*8;count++) |
| 208 | 127 | { |
| 209 | | int sx=count%32; |
| 210 | | int sy=count/32; |
| 211 | | unsigned char color; |
| 128 | int sx=count%32; |
| 129 | int sy=count/32; |
| 130 | unsigned char color; |
| 212 | 131 | |
| 213 | | if (charsdirty[count]) { |
| 214 | | color=get_display_color(spectrum_colorram[count], |
| 215 | | flash_invert); |
| 132 | color=get_display_color(spectrum_colorram[count],flash_invert); |
| 216 | 133 | drawgfx(bitmap,screen->machine->gfx[0], |
| 217 | 134 | count, |
| 218 | 135 | color+8, // use 2nd part of palette |
| 219 | 136 | 0,0, |
| 220 | | (sx*8)+SPEC_LEFT_BORDER,(sy*8)+SPEC_TOP_BORDER, |
| 137 | (sx*8)+SPEC_LEFT_BORDER,(sy*8)+SPEC_TOP_BORDER, |
| 221 | 138 | 0,TRANSPARENCY_NONE,0); |
| 222 | | charsdirty[count] = 0; |
| 223 | | } |
| 224 | 139 | |
| 225 | | if (charsdirty[count+256]) { |
| 226 | | color=get_display_color(spectrum_colorram[count+0x100], |
| 227 | | flash_invert); |
| 140 | color=get_display_color(spectrum_colorram[count+0x100],flash_invert); |
| 228 | 141 | drawgfx(bitmap,screen->machine->gfx[1], |
| 229 | 142 | count, |
| 230 | 143 | color+8, // use 2nd part of palette |
| 231 | 144 | 0,0, |
| 232 | | (sx*8)+SPEC_LEFT_BORDER,((sy+8)*8)+SPEC_TOP_BORDER, |
| 145 | (sx*8)+SPEC_LEFT_BORDER,((sy+8)*8)+SPEC_TOP_BORDER, |
| 233 | 146 | 0,TRANSPARENCY_NONE,0); |
| 234 | | charsdirty[count+256] = 0; |
| 235 | | } |
| 236 | | |
| 237 | | if (charsdirty[count+512]) { |
| 238 | | color=get_display_color(spectrum_colorram[count+0x200], |
| 239 | | flash_invert); |
| 147 | |
| 148 | color=get_display_color(spectrum_colorram[count+0x200],flash_invert); |
| 240 | 149 | drawgfx(bitmap,screen->machine->gfx[2], |
| 241 | 150 | count, |
| 242 | 151 | color+8, // use 2nd part of palette |
| 243 | 152 | 0,0, |
| 244 | | (sx*8)+SPEC_LEFT_BORDER,((sy+16)*8)+SPEC_TOP_BORDER, |
| 153 | (sx*8)+SPEC_LEFT_BORDER,((sy+16)*8)+SPEC_TOP_BORDER, |
| 245 | 154 | 0,TRANSPARENCY_NONE,0); |
| 246 | | charsdirty[count+512] = 0; |
| 247 | 155 | } |
| 248 | | } |
| 249 | 156 | |
| 250 | 157 | /* When screen refresh is called there is only one blank line |
| 251 | 158 | (synchronised with start of screen data) before the border lines. |
| r2516 | r2517 | |
| 259 | 166 | return 0; |
| 260 | 167 | } |
| 261 | 168 | |
| 262 | | VIDEO_START( spectrum_128 ) |
| 169 | const gfx_layout spectrum_charlayout = |
| 263 | 170 | { |
| 264 | | frame_number = 0; |
| 265 | | flash_invert = 0; |
| 171 | 8,8, |
| 172 | 256, |
| 173 | 1, /* 1 bits per pixel */ |
| 266 | 174 | |
| 267 | | EventList_Initialise(30000); |
| 268 | | } |
| 175 | { 0 }, /* no bitplanes; 1 bit per pixel */ |
| 269 | 176 | |
| 270 | | /* Refresh the spectrum 128 screen (code modified from COUPE.C) */ |
| 271 | | VIDEO_UPDATE( spectrum_128 ) |
| 272 | | { |
| 273 | | /* for now do a full-refresh */ |
| 274 | | int x, y, b, scrx, scry; |
| 275 | | unsigned short ink, pap; |
| 276 | | unsigned char *attr, *scr; |
| 277 | | int full_refresh = 1; |
| 177 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 178 | { 0, 8*256, 16*256, 24*256, 32*256, 40*256, 48*256, 56*256 }, |
| 278 | 179 | |
| 279 | | scr=spectrum_128_screen_location; |
| 180 | 8 /* every char takes 1 consecutive byte */ |
| 181 | }; |
| 280 | 182 | |
| 281 | | for (y=0; y<192; y++) |
| 282 | | { |
| 283 | | scrx=SPEC_LEFT_BORDER; |
| 284 | | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 285 | | attr=spectrum_128_screen_location + ((scry>>3)*32) + 0x1800; |
| 183 | #define ZX_COL_0 MAKE_RGB(0x00, 0x00, 0x00) |
| 184 | #define ZX_COL_1 MAKE_RGB(0x00, 0x00, 0xbf) |
| 185 | #define ZX_COL_2 MAKE_RGB(0xbf, 0x00, 0x00) |
| 186 | #define ZX_COL_3 MAKE_RGB(0xbf, 0x00, 0xbf) |
| 187 | #define ZX_COL_4 MAKE_RGB(0x00, 0xbf, 0x00) |
| 188 | #define ZX_COL_5 MAKE_RGB(0x00, 0xbf, 0xbf) |
| 189 | #define ZX_COL_6 MAKE_RGB(0xbf, 0xbf, 0x00) |
| 190 | #define ZX_COL_7 MAKE_RGB(0xbf, 0xbf, 0xbf) |
| 191 | #define ZX_COL_8 MAKE_RGB(0x00, 0x00, 0x00) |
| 192 | #define ZX_COL_9 MAKE_RGB(0x00, 0x00, 0xff) |
| 193 | #define ZX_COL_A MAKE_RGB(0xff, 0x00, 0x00) |
| 194 | #define ZX_COL_B MAKE_RGB(0xff, 0x00, 0xff) |
| 195 | #define ZX_COL_C MAKE_RGB(0x00, 0xff, 0x00) |
| 196 | #define ZX_COL_D MAKE_RGB(0x00, 0xff, 0xff) |
| 197 | #define ZX_COL_E MAKE_RGB(0xff, 0xff, 0x00) |
| 198 | #define ZX_COL_F MAKE_RGB(0xff, 0xff, 0xff) |
| 286 | 199 | |
| 287 | | for (x=0;x<32;x++) |
| 288 | | { |
| 289 | | /* Get ink and paper colour with bright */ |
| 290 | | if (flash_invert && (*attr & 0x80)) |
| 291 | | { |
| 292 | | ink=((*attr)>>3) & 0x0f; |
| 293 | | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 294 | | } |
| 295 | | else |
| 296 | | { |
| 297 | | ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 298 | | pap=((*attr)>>3) & 0x0f; |
| 299 | | } |
| 200 | const rgb_t spectrum_palette[256 + 16] = { |
| 201 | ZX_COL_0,ZX_COL_1,ZX_COL_2,ZX_COL_3,ZX_COL_4,ZX_COL_5,ZX_COL_6,ZX_COL_7,ZX_COL_8,ZX_COL_9,ZX_COL_A,ZX_COL_B,ZX_COL_C,ZX_COL_D,ZX_COL_E,ZX_COL_F, |
| 202 | |
| 203 | ZX_COL_0,ZX_COL_0,ZX_COL_0,ZX_COL_1,ZX_COL_0,ZX_COL_2,ZX_COL_0,ZX_COL_3,ZX_COL_0,ZX_COL_4,ZX_COL_0,ZX_COL_5,ZX_COL_0,ZX_COL_6,ZX_COL_0,ZX_COL_7, |
| 204 | ZX_COL_1,ZX_COL_0,ZX_COL_1,ZX_COL_1,ZX_COL_1,ZX_COL_2,ZX_COL_1,ZX_COL_3,ZX_COL_1,ZX_COL_4,ZX_COL_1,ZX_COL_5,ZX_COL_1,ZX_COL_6,ZX_COL_1,ZX_COL_7, |
| 205 | ZX_COL_2,ZX_COL_0,ZX_COL_2,ZX_COL_1,ZX_COL_2,ZX_COL_2,ZX_COL_2,ZX_COL_3,ZX_COL_2,ZX_COL_4,ZX_COL_2,ZX_COL_5,ZX_COL_2,ZX_COL_6,ZX_COL_2,ZX_COL_7, |
| 206 | ZX_COL_3,ZX_COL_0,ZX_COL_3,ZX_COL_1,ZX_COL_3,ZX_COL_2,ZX_COL_3,ZX_COL_3,ZX_COL_3,ZX_COL_4,ZX_COL_3,ZX_COL_5,ZX_COL_3,ZX_COL_6,ZX_COL_3,ZX_COL_7, |
| 207 | ZX_COL_4,ZX_COL_0,ZX_COL_4,ZX_COL_1,ZX_COL_4,ZX_COL_2,ZX_COL_4,ZX_COL_3,ZX_COL_4,ZX_COL_4,ZX_COL_4,ZX_COL_5,ZX_COL_4,ZX_COL_6,ZX_COL_4,ZX_COL_7, |
| 208 | ZX_COL_5,ZX_COL_0,ZX_COL_5,ZX_COL_1,ZX_COL_5,ZX_COL_2,ZX_COL_5,ZX_COL_3,ZX_COL_5,ZX_COL_4,ZX_COL_5,ZX_COL_5,ZX_COL_5,ZX_COL_6,ZX_COL_5,ZX_COL_7, |
| 209 | ZX_COL_6,ZX_COL_0,ZX_COL_6,ZX_COL_1,ZX_COL_6,ZX_COL_2,ZX_COL_6,ZX_COL_3,ZX_COL_6,ZX_COL_4,ZX_COL_6,ZX_COL_5,ZX_COL_6,ZX_COL_6,ZX_COL_6,ZX_COL_7, |
| 210 | ZX_COL_7,ZX_COL_0,ZX_COL_7,ZX_COL_1,ZX_COL_7,ZX_COL_2,ZX_COL_7,ZX_COL_3,ZX_COL_7,ZX_COL_4,ZX_COL_7,ZX_COL_5,ZX_COL_7,ZX_COL_6,ZX_COL_7,ZX_COL_7, |
| 211 | ZX_COL_8,ZX_COL_8,ZX_COL_8,ZX_COL_9,ZX_COL_8,ZX_COL_A,ZX_COL_8,ZX_COL_B,ZX_COL_8,ZX_COL_C,ZX_COL_8,ZX_COL_D,ZX_COL_8,ZX_COL_E,ZX_COL_8,ZX_COL_F, |
| 212 | ZX_COL_9,ZX_COL_8,ZX_COL_9,ZX_COL_9,ZX_COL_9,ZX_COL_A,ZX_COL_9,ZX_COL_B,ZX_COL_9,ZX_COL_C,ZX_COL_9,ZX_COL_D,ZX_COL_9,ZX_COL_E,ZX_COL_9,ZX_COL_F, |
| 213 | ZX_COL_A,ZX_COL_8,ZX_COL_A,ZX_COL_9,ZX_COL_A,ZX_COL_A,ZX_COL_A,ZX_COL_B,ZX_COL_A,ZX_COL_C,ZX_COL_A,ZX_COL_D,ZX_COL_A,ZX_COL_E,ZX_COL_A,ZX_COL_F, |
| 214 | ZX_COL_B,ZX_COL_8,ZX_COL_B,ZX_COL_9,ZX_COL_B,ZX_COL_A,ZX_COL_B,ZX_COL_B,ZX_COL_B,ZX_COL_C,ZX_COL_B,ZX_COL_D,ZX_COL_B,ZX_COL_E,ZX_COL_B,ZX_COL_F, |
| 215 | ZX_COL_C,ZX_COL_8,ZX_COL_C,ZX_COL_9,ZX_COL_C,ZX_COL_A,ZX_COL_C,ZX_COL_B,ZX_COL_C,ZX_COL_C,ZX_COL_C,ZX_COL_D,ZX_COL_C,ZX_COL_E,ZX_COL_C,ZX_COL_F, |
| 216 | ZX_COL_D,ZX_COL_8,ZX_COL_D,ZX_COL_9,ZX_COL_D,ZX_COL_A,ZX_COL_D,ZX_COL_B,ZX_COL_D,ZX_COL_C,ZX_COL_D,ZX_COL_D,ZX_COL_D,ZX_COL_E,ZX_COL_D,ZX_COL_F, |
| 217 | ZX_COL_E,ZX_COL_8,ZX_COL_E,ZX_COL_9,ZX_COL_E,ZX_COL_A,ZX_COL_E,ZX_COL_B,ZX_COL_E,ZX_COL_C,ZX_COL_E,ZX_COL_D,ZX_COL_E,ZX_COL_E,ZX_COL_E,ZX_COL_F, |
| 218 | ZX_COL_F,ZX_COL_8,ZX_COL_F,ZX_COL_9,ZX_COL_F,ZX_COL_A,ZX_COL_F,ZX_COL_B,ZX_COL_F,ZX_COL_C,ZX_COL_F,ZX_COL_D,ZX_COL_F,ZX_COL_E,ZX_COL_F,ZX_COL_F |
| 219 | }; |
| 300 | 220 | |
| 301 | | for (b=0x80;b!=0;b>>=1) |
| 302 | | { |
| 303 | | if (*scr&b) |
| 304 | | spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,ink); |
| 305 | | else |
| 306 | | spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,pap); |
| 307 | | } |
| 308 | | scr++; |
| 309 | | attr++; |
| 310 | | } |
| 311 | | } |
| 312 | 221 | |
| 313 | | draw_border(screen->machine, bitmap, full_refresh, |
| 314 | | SPEC_TOP_BORDER, SPEC_DISPLAY_YSIZE, SPEC_BOTTOM_BORDER, |
| 315 | | SPEC_LEFT_BORDER, SPEC_DISPLAY_XSIZE, SPEC_RIGHT_BORDER, |
| 316 | | SPEC_LEFT_BORDER_CYCLES, SPEC_DISPLAY_XSIZE_CYCLES, |
| 317 | | SPEC_RIGHT_BORDER_CYCLES, SPEC128_RETRACE_CYCLES, 200, 0xfe); |
| 318 | | return 0; |
| 319 | | } |
| 320 | | |
| 321 | | /******************************************************************* |
| 322 | | * |
| 323 | | * Update the TS2068 display. |
| 324 | | * |
| 325 | | * Port ff is used to set the display mode. |
| 326 | | * |
| 327 | | * bits 2..0 Video Mode Select |
| 328 | | * 000 = Primary DFILE active (at 0x4000-0x5aff) |
| 329 | | * 001 = Secondary DFILE active (at 0x6000-0x7aff) |
| 330 | | * 010 = Extended Colour Mode (chars at 0x4000-0x57ff, colors 0x6000-0x7aff) |
| 331 | | * 110 = 64 column mode (columns 0,2,4,...62 from DFILE 1 |
| 332 | | * columns 1,3,5,...63 from DFILE 2) |
| 333 | | * other = unpredictable results |
| 334 | | * |
| 335 | | * bits 5..3 64 column mode ink/paper selection (attribute value in brackets) |
| 336 | | * 000 = Black/White (56) 100 = Green/Magenta (28) |
| 337 | | * 001 = Blue/Yellow (49) 101 = Cyan/Red (21) |
| 338 | | * 010 = Red/Cyan (42) 110 = Yellow/Blue (14) |
| 339 | | * 011 = Magenta/Green (35) 111 = White/Black (7) |
| 340 | | * |
| 341 | | *******************************************************************/ |
| 342 | | |
| 343 | | /* Draw a scanline in TS2068/TC2048 hires mode (code modified from COUPE.C) */ |
| 344 | | static void ts2068_hires_scanline(bitmap_t *bitmap, int y, int borderlines) |
| 222 | /* Initialise the palette */ |
| 223 | PALETTE_INIT( spectrum ) |
| 345 | 224 | { |
| 346 | | int x,b,scrx,scry; |
| 347 | | unsigned short ink,pap; |
| 348 | | unsigned char *attr, *scr; |
| 349 | | |
| 350 | | scrx=TS2068_LEFT_BORDER; |
| 351 | | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 352 | | |
| 353 | | scr=mess_ram + y*32; |
| 354 | | attr=scr + 0x2000; |
| 355 | | |
| 356 | | for (x=0;x<32;x++) |
| 357 | | { |
| 358 | | /* Get ink and paper colour with bright */ |
| 359 | | if (flash_invert && (*attr & 0x80)) |
| 360 | | { |
| 361 | | ink=((*attr)>>3) & 0x0f; |
| 362 | | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 363 | | } |
| 364 | | else |
| 365 | | { |
| 366 | | ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 367 | | pap=((*attr)>>3) & 0x0f; |
| 368 | | } |
| 369 | | |
| 370 | | for (b=0x80;b!=0;b>>=1) |
| 371 | | { |
| 372 | | if (*scr&b) |
| 373 | | { |
| 374 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 375 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 376 | | } |
| 377 | | else |
| 378 | | { |
| 379 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 380 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 381 | | } |
| 382 | | } |
| 383 | | scr++; |
| 384 | | attr++; |
| 385 | | } |
| 225 | palette_set_colors(machine, 0, spectrum_palette, ARRAY_LENGTH(spectrum_palette)); |
| 386 | 226 | } |
| 387 | | |
| 388 | | /* Draw a scanline in TS2068/TC2048 64-column mode */ |
| 389 | | static void ts2068_64col_scanline(bitmap_t *bitmap, int y, int borderlines, unsigned short inkcolor) |
| 390 | | { |
| 391 | | int x,b,scrx,scry; |
| 392 | | unsigned char *scr1, *scr2; |
| 393 | | |
| 394 | | scrx=TS2068_LEFT_BORDER; |
| 395 | | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 396 | | |
| 397 | | scr1=mess_ram + y*32; |
| 398 | | scr2=scr1 + 0x2000; |
| 399 | | |
| 400 | | for (x=0;x<32;x++) |
| 401 | | { |
| 402 | | for (b=0x80;b!=0;b>>=1) |
| 403 | | { |
| 404 | | if (*scr1&b) |
| 405 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); |
| 406 | | else |
| 407 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); |
| 408 | | } |
| 409 | | scr1++; |
| 410 | | |
| 411 | | for (b=0x80;b!=0;b>>=1) |
| 412 | | { |
| 413 | | if (*scr2&b) |
| 414 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); |
| 415 | | else |
| 416 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); |
| 417 | | } |
| 418 | | scr2++; |
| 419 | | } |
| 420 | | } |
| 421 | | |
| 422 | | /* Draw a scanline in TS2068/TC2048 lores (normal Spectrum) mode */ |
| 423 | | static void ts2068_lores_scanline(bitmap_t *bitmap, int y, int borderlines, int screen) |
| 424 | | { |
| 425 | | int x,b,scrx,scry; |
| 426 | | unsigned short ink,pap; |
| 427 | | unsigned char *attr, *scr; |
| 428 | | |
| 429 | | scrx=TS2068_LEFT_BORDER; |
| 430 | | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 431 | | |
| 432 | | scr = mess_ram + y*32 + screen*0x2000; |
| 433 | | attr = mess_ram + ((scry>>3)*32) + screen*0x2000 + 0x1800; |
| 434 | | |
| 435 | | for (x=0;x<32;x++) |
| 436 | | { |
| 437 | | /* Get ink and paper colour with bright */ |
| 438 | | if (flash_invert && (*attr & 0x80)) |
| 439 | | { |
| 440 | | ink=((*attr)>>3) & 0x0f; |
| 441 | | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 442 | | } |
| 443 | | else |
| 444 | | { |
| 445 | | ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 446 | | pap=((*attr)>>3) & 0x0f; |
| 447 | | } |
| 448 | | |
| 449 | | for (b=0x80;b!=0;b>>=1) |
| 450 | | { |
| 451 | | if (*scr&b) |
| 452 | | { |
| 453 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 454 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 455 | | } |
| 456 | | else |
| 457 | | { |
| 458 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 459 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 460 | | } |
| 461 | | } |
| 462 | | scr++; |
| 463 | | attr++; |
| 464 | | } |
| 465 | | } |
| 466 | | |
| 467 | | VIDEO_UPDATE( ts2068 ) |
| 468 | | { |
| 469 | | /* for now TS2068 will do a full-refresh */ |
| 470 | | int count; |
| 471 | | int full_refresh = 1; |
| 472 | | |
| 473 | | if ((ts2068_port_ff_data & 7) == 6) |
| 474 | | { |
| 475 | | /* 64 Column mode */ |
| 476 | | unsigned short inkcolor = (ts2068_port_ff_data & 0x38) >> 3; |
| 477 | | for (count = 0; count < 192; count++) |
| 478 | | ts2068_64col_scanline(bitmap, count, TS2068_TOP_BORDER, inkcolor); |
| 479 | | } |
| 480 | | else if ((ts2068_port_ff_data & 7) == 2) |
| 481 | | { |
| 482 | | /* Extended Color mode */ |
| 483 | | for (count = 0; count < 192; count++) |
| 484 | | ts2068_hires_scanline(bitmap, count, TS2068_TOP_BORDER); |
| 485 | | } |
| 486 | | else if ((ts2068_port_ff_data & 7) == 1) |
| 487 | | { |
| 488 | | /* Screen 6000-7aff */ |
| 489 | | for (count = 0; count < 192; count++) |
| 490 | | ts2068_lores_scanline(bitmap, count, TS2068_TOP_BORDER, 1); |
| 491 | | } |
| 492 | | else |
| 493 | | { |
| 494 | | /* Screen 4000-5aff */ |
| 495 | | for (count = 0; count < 192; count++) |
| 496 | | ts2068_lores_scanline(bitmap, count, TS2068_TOP_BORDER, 0); |
| 497 | | } |
| 498 | | |
| 499 | | draw_border(screen->machine, bitmap, full_refresh, |
| 500 | | TS2068_TOP_BORDER, SPEC_DISPLAY_YSIZE, TS2068_BOTTOM_BORDER, |
| 501 | | TS2068_LEFT_BORDER, TS2068_DISPLAY_XSIZE, TS2068_RIGHT_BORDER, |
| 502 | | SPEC_LEFT_BORDER_CYCLES, SPEC_DISPLAY_XSIZE_CYCLES, |
| 503 | | SPEC_RIGHT_BORDER_CYCLES, SPEC_RETRACE_CYCLES, 200, 0xfe); |
| 504 | | return 0; |
| 505 | | } |
| 506 | | |
| 507 | | VIDEO_UPDATE( tc2048 ) |
| 508 | | { |
| 509 | | /* for now TS2068 will do a full-refresh */ |
| 510 | | int count; |
| 511 | | int full_refresh = 1; |
| 512 | | |
| 513 | | if ((ts2068_port_ff_data & 7) == 6) |
| 514 | | { |
| 515 | | /* 64 Column mode */ |
| 516 | | unsigned short inkcolor = (ts2068_port_ff_data & 0x38) >> 3; |
| 517 | | for (count = 0; count < 192; count++) |
| 518 | | ts2068_64col_scanline(bitmap, count, SPEC_TOP_BORDER, inkcolor); |
| 519 | | } |
| 520 | | else if ((ts2068_port_ff_data & 7) == 2) |
| 521 | | { |
| 522 | | /* Extended Color mode */ |
| 523 | | for (count = 0; count < 192; count++) |
| 524 | | ts2068_hires_scanline(bitmap, count, SPEC_TOP_BORDER); |
| 525 | | } |
| 526 | | else if ((ts2068_port_ff_data & 7) == 1) |
| 527 | | { |
| 528 | | /* Screen 6000-7aff */ |
| 529 | | for (count = 0; count < 192; count++) |
| 530 | | ts2068_lores_scanline(bitmap, count, SPEC_TOP_BORDER, 1); |
| 531 | | } |
| 532 | | else |
| 533 | | { |
| 534 | | /* Screen 4000-5aff */ |
| 535 | | for (count = 0; count < 192; count++) |
| 536 | | ts2068_lores_scanline(bitmap, count, SPEC_TOP_BORDER, 0); |
| 537 | | } |
| 538 | | |
| 539 | | draw_border(screen->machine, bitmap, full_refresh, |
| 540 | | SPEC_TOP_BORDER, SPEC_DISPLAY_YSIZE, SPEC_BOTTOM_BORDER, |
| 541 | | TS2068_LEFT_BORDER, TS2068_DISPLAY_XSIZE, TS2068_RIGHT_BORDER, |
| 542 | | SPEC_LEFT_BORDER_CYCLES, SPEC_DISPLAY_XSIZE_CYCLES, |
| 543 | | SPEC_RIGHT_BORDER_CYCLES, SPEC_RETRACE_CYCLES, 200, 0xfe); |
| 544 | | return 0; |
| 545 | | } |
src/mess/drivers/specpls3.c
| r0 | r2517 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | NOTE: ****** Specbusy: press N, R, or E to boot ************* |
| 4 | |
| 5 | |
| 6 | Spectrum/Inves/TK90X etc. memory map: |
| 7 | |
| 8 | CPU: |
| 9 | 0000-3fff ROM |
| 10 | 4000-ffff RAM |
| 11 | |
| 12 | Spectrum 128/+2/+2a/+3 memory map: |
| 13 | |
| 14 | CPU: |
| 15 | 0000-3fff Banked ROM/RAM (banked rom only on 128/+2) |
| 16 | 4000-7fff Banked RAM |
| 17 | 8000-bfff Banked RAM |
| 18 | c000-ffff Banked RAM |
| 19 | |
| 20 | TS2068 memory map: (Can't have both EXROM and DOCK active) |
| 21 | The 8K EXROM can be loaded into multiple pages. |
| 22 | |
| 23 | CPU: |
| 24 | 0000-1fff ROM / EXROM / DOCK (Cartridge) |
| 25 | 2000-3fff ROM / EXROM / DOCK |
| 26 | 4000-5fff \ |
| 27 | 6000-7fff \ |
| 28 | 8000-9fff |- RAM / EXROM / DOCK |
| 29 | a000-bfff | |
| 30 | c000-dfff / |
| 31 | e000-ffff / |
| 32 | |
| 33 | |
| 34 | Interrupts: |
| 35 | |
| 36 | Changes: |
| 37 | |
| 38 | 29/1/2000 KT - Implemented initial +3 emulation. |
| 39 | 30/1/2000 KT - Improved input port decoding for reading and therefore |
| 40 | correct keyboard handling for Spectrum and +3. |
| 41 | 31/1/2000 KT - Implemented buzzer sound for Spectrum and +3. |
| 42 | Implementation copied from Paul Daniel's Jupiter driver. |
| 43 | Fixed screen display problems with dirty chars. |
| 44 | Added support to load .Z80 snapshots. 48k support so far. |
| 45 | 13/2/2000 KT - Added Interface II, Kempston, Fuller and Mikrogen |
| 46 | joystick support. |
| 47 | 17/2/2000 DJR - Added full key descriptions and Spectrum+ keys. |
| 48 | Fixed Spectrum +3 keyboard problems. |
| 49 | 17/2/2000 KT - Added tape loading from WAV/Changed from DAC to generic |
| 50 | speaker code. |
| 51 | 18/2/2000 KT - Added tape saving to WAV. |
| 52 | 27/2/2000 KT - Took DJR's changes and added my changes. |
| 53 | 27/2/2000 KT - Added disk image support to Spectrum +3 driver. |
| 54 | 27/2/2000 KT - Added joystick I/O code to the Spectrum +3 I/O handler. |
| 55 | 14/3/2000 DJR - Tape handling dipswitch. |
| 56 | 26/3/2000 DJR - Snapshot files are now classifed as snapshots not |
| 57 | cartridges. |
| 58 | 04/4/2000 DJR - Spectrum 128 / +2 Support. |
| 59 | 13/4/2000 DJR - +4 Support (unofficial 48K hack). |
| 60 | 13/4/2000 DJR - +2a Support (rom also used in +3 models). |
| 61 | 13/4/2000 DJR - TK90X, TK95 and Inves support (48K clones). |
| 62 | 21/4/2000 DJR - TS2068 and TC2048 support (TC2048 Supports extra video |
| 63 | modes but doesn't have bank switching or sound chip). |
| 64 | 09/5/2000 DJR - Spectrum +2 (France, Spain), +3 (Spain). |
| 65 | 17/5/2000 DJR - Dipswitch to enable/disable disk drives on +3 and clones. |
| 66 | 27/6/2000 DJR - Changed 128K/+3 port decoding (sound now works in Zub 128K). |
| 67 | 06/8/2000 DJR - Fixed +3 Floppy support |
| 68 | 10/2/2001 KT - Re-arranged code and split into each model emulated. |
| 69 | Code is split into 48k, 128k, +3, tc2048 and ts2048 |
| 70 | segments. 128k uses some of the functions in 48k, +3 |
| 71 | uses some functions in 128, and tc2048/ts2048 use some |
| 72 | of the functions in 48k. The code has been arranged so |
| 73 | these functions come in some kind of "override" order, |
| 74 | read functions changed to use READ8_HANDLER and write |
| 75 | functions changed to use WRITE8_HANDLER. |
| 76 | Added Scorpion256 preliminary. |
| 77 | 18/6/2001 DJR - Added support for Interface 2 cartridges. |
| 78 | xx/xx/2001 KS - TS-2068 sound fixed. |
| 79 | Added support for DOCK cartridges for TS-2068. |
| 80 | Added Spectrum 48k Psycho modified rom driver. |
| 81 | Added UK-2086 driver. |
| 82 | 23/12/2001 KS - 48k machines are now able to run code in screen memory. |
| 83 | Programs which keep their code in screen memory |
| 84 | like monitors, tape copiers, decrunchers, etc. |
| 85 | works now. |
| 86 | Fixed problem with interrupt vector set to 0xffff (much |
| 87 | more 128k games works now). |
| 88 | A useful used trick on the Spectrum is to set |
| 89 | interrupt vector to 0xffff (using the table |
| 90 | which contain 0xff's) and put a byte 0x18 hex, |
| 91 | the opcode for JR, at this address. The first |
| 92 | byte of the ROM is a 0xf3 (DI), so the JR will |
| 93 | jump to 0xfff4, where a long JP to the actual |
| 94 | interrupt routine is put. Due to unideal |
| 95 | bankswitching in MAME this JP were to 0001 what |
| 96 | causes Spectrum to reset. Fixing this problem |
| 97 | made much more software runing (i.e. Paperboy). |
| 98 | Corrected frames per second value for 48k and 128k |
| 99 | Sincalir machines. |
| 100 | There are 50.08 frames per second for Spectrum |
| 101 | 48k what gives 69888 cycles for each frame and |
| 102 | 50.021 for Spectrum 128/+2/+2A/+3 what gives |
| 103 | 70908 cycles for each frame. |
| 104 | Remaped some Spectrum+ keys. |
| 105 | Presing F3 to reset was seting 0xf7 on keyboard |
| 106 | input port. Problem occured for snapshots of |
| 107 | some programms where it was readed as pressing |
| 108 | key 4 (which is exit in Tapecopy by R. Dannhoefer |
| 109 | for example). |
| 110 | Added support to load .SP snapshots. |
| 111 | Added .BLK tape images support. |
| 112 | .BLK files are identical to .TAP ones, extension |
| 113 | is an only difference. |
| 114 | 08/03/2002 KS - #FF port emulation added. |
| 115 | Arkanoid works now, but is not playable due to |
| 116 | completly messed timings. |
| 117 | |
| 118 | Initialisation values used when determining which model is being emulated: |
| 119 | 48K Spectrum doesn't use either port. |
| 120 | 128K/+2 Bank switches with port 7ffd only. |
| 121 | +3/+2a Bank switches with both ports. |
| 122 | |
| 123 | Notes: |
| 124 | 1. No contented memory. |
| 125 | 2. No hi-res colour effects (need contended memory first for accurate timing). |
| 126 | 3. Multiface 1 and Interface 1 not supported. |
| 127 | 4. Horace and the Spiders cartridge doesn't run properly. |
| 128 | 5. Tape images not supported: |
| 129 | .TZX, .SPC, .ITM, .PAN, .TAP(Warajevo), .VOC, .ZXS. |
| 130 | 6. Snapshot images not supported: |
| 131 | .ACH, .PRG, .RAW, .SEM, .SIT, .SNX, .ZX, .ZXS, .ZX82. |
| 132 | 7. 128K emulation is not perfect - the 128K machines crash and hang while |
| 133 | running quite a lot of games. |
| 134 | 8. Disk errors occur on some +3 games. |
| 135 | 9. Video hardware of all machines is timed incorrectly. |
| 136 | 10. EXROM and HOME cartridges are not emulated. |
| 137 | 11. The TK90X and TK95 roms output 0 to port #df on start up. |
| 138 | 12. The purpose of this port is unknown (probably display mode as TS2068) and |
| 139 | thus is not emulated. |
| 140 | |
| 141 | Very detailed infos about the ZX Spectrum +3e can be found at |
| 142 | |
| 143 | http://www.z88forever.org.uk/zxplus3e/ |
| 144 | |
| 145 | *******************************************************************************/ |
| 146 | |
| 147 | #include "driver.h" |
| 148 | #include "includes/spectrum.h" |
| 149 | #include "eventlst.h" |
| 150 | #include "devices/snapquik.h" |
| 151 | #include "devices/cartslot.h" |
| 152 | #include "devices/cassette.h" |
| 153 | #include "sound/ay8910.h" |
| 154 | #include "sound/speaker.h" |
| 155 | #include "formats/tzx_cas.h" |
| 156 | |
| 157 | /* +3 hardware */ |
| 158 | #include "machine/nec765.h" |
| 159 | #include "devices/dsk.h" |
| 160 | |
| 161 | |
| 162 | /****************************************************************************************************/ |
| 163 | /* Spectrum + 3 specific functions */ |
| 164 | /* This driver uses some of the spectrum_128 functions. The +3 is similar to a spectrum 128 |
| 165 | but with a disc drive */ |
| 166 | |
| 167 | int spectrum_plus3_port_1ffd_data = -1; |
| 168 | |
| 169 | |
| 170 | static const nec765_interface spectrum_plus3_nec765_interface = |
| 171 | { |
| 172 | NULL, |
| 173 | NULL |
| 174 | }; |
| 175 | |
| 176 | |
| 177 | static const int spectrum_plus3_memory_selections[]= |
| 178 | { |
| 179 | 0,1,2,3, |
| 180 | 4,5,6,7, |
| 181 | 4,5,6,3, |
| 182 | 4,7,6,3 |
| 183 | }; |
| 184 | |
| 185 | static WRITE8_HANDLER(spectrum_plus3_port_3ffd_w) |
| 186 | { |
| 187 | if (~input_port_read(machine, "CONFIG") & 0x20) |
| 188 | nec765_data_w(machine, 0,data); |
| 189 | } |
| 190 | |
| 191 | static READ8_HANDLER(spectrum_plus3_port_3ffd_r) |
| 192 | { |
| 193 | if (input_port_read(machine, "CONFIG") & 0x20) |
| 194 | return 0xff; |
| 195 | else |
| 196 | return nec765_data_r(machine, 0); |
| 197 | } |
| 198 | |
| 199 | |
| 200 | static READ8_HANDLER(spectrum_plus3_port_2ffd_r) |
| 201 | { |
| 202 | if (input_port_read(machine, "CONFIG") & 0x20) |
| 203 | return 0xff; |
| 204 | else |
| 205 | return nec765_status_r(machine, 0); |
| 206 | } |
| 207 | |
| 208 | |
| 209 | void spectrum_plus3_update_memory(running_machine *machine) |
| 210 | { |
| 211 | if (spectrum_128_port_7ffd_data & 8) |
| 212 | { |
| 213 | logerror("+3 SCREEN 1: BLOCK 7\n"); |
| 214 | spectrum_128_screen_location = mess_ram + (7<<14); |
| 215 | } |
| 216 | else |
| 217 | { |
| 218 | logerror("+3 SCREEN 0: BLOCK 5\n"); |
| 219 | spectrum_128_screen_location = mess_ram + (5<<14); |
| 220 | } |
| 221 | |
| 222 | if ((spectrum_plus3_port_1ffd_data & 0x01)==0) |
| 223 | { |
| 224 | int ram_page; |
| 225 | unsigned char *ram_data; |
| 226 | |
| 227 | /* ROM switching */ |
| 228 | unsigned char *ChosenROM; |
| 229 | int ROMSelection; |
| 230 | |
| 231 | /* select ram at 0x0c000-0x0ffff */ |
| 232 | ram_page = spectrum_128_port_7ffd_data & 0x07; |
| 233 | ram_data = mess_ram + (ram_page<<14); |
| 234 | |
| 235 | memory_set_bankptr(4, ram_data); |
| 236 | |
| 237 | logerror("RAM at 0xc000: %02x\n",ram_page); |
| 238 | |
| 239 | /* Reset memory between 0x4000 - 0xbfff in case extended paging was being used */ |
| 240 | /* Bank 5 in 0x4000 - 0x7fff */ |
| 241 | memory_set_bankptr(2, mess_ram + (5<<14)); |
| 242 | |
| 243 | /* Bank 2 in 0x8000 - 0xbfff */ |
| 244 | memory_set_bankptr(3, mess_ram + (2<<14)); |
| 245 | |
| 246 | |
| 247 | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) | |
| 248 | ((spectrum_plus3_port_1ffd_data>>1) & 0x02); |
| 249 | |
| 250 | /* rom 0 is editor, rom 1 is syntax, rom 2 is DOS, rom 3 is 48 BASIC */ |
| 251 | |
| 252 | ChosenROM = memory_region(REGION_CPU1) + 0x010000 + (ROMSelection<<14); |
| 253 | |
| 254 | memory_set_bankptr(1, ChosenROM); |
| 255 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_UNMAP); |
| 256 | |
| 257 | logerror("rom switch: %02x\n", ROMSelection); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | /* Extended memory paging */ |
| 262 | |
| 263 | const int *memory_selection; |
| 264 | int MemorySelection; |
| 265 | unsigned char *ram_data; |
| 266 | |
| 267 | MemorySelection = (spectrum_plus3_port_1ffd_data>>1) & 0x03; |
| 268 | |
| 269 | memory_selection = &spectrum_plus3_memory_selections[(MemorySelection<<2)]; |
| 270 | |
| 271 | ram_data = mess_ram + (memory_selection[0]<<14); |
| 272 | memory_set_bankptr(1, ram_data); |
| 273 | /* allow writes to 0x0000-0x03fff */ |
| 274 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_BANK1); |
| 275 | |
| 276 | ram_data = mess_ram + (memory_selection[1]<<14); |
| 277 | memory_set_bankptr(2, ram_data); |
| 278 | |
| 279 | ram_data = mess_ram + (memory_selection[2]<<14); |
| 280 | memory_set_bankptr(3, ram_data); |
| 281 | |
| 282 | ram_data = mess_ram + (memory_selection[3]<<14); |
| 283 | memory_set_bankptr(4, ram_data); |
| 284 | |
| 285 | logerror("extended memory paging: %02x\n",MemorySelection); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | |
| 290 | |
| 291 | static WRITE8_HANDLER(spectrum_plus3_port_7ffd_w) |
| 292 | { |
| 293 | /* D0-D2: RAM page located at 0x0c000-0x0ffff */ |
| 294 | /* D3 - Screen select (screen 0 in ram page 5, screen 1 in ram page 7 */ |
| 295 | /* D4 - ROM select - which rom paged into 0x0000-0x03fff */ |
| 296 | /* D5 - Disable paging */ |
| 297 | |
| 298 | /* disable paging? */ |
| 299 | if (spectrum_128_port_7ffd_data & 0x20) |
| 300 | return; |
| 301 | |
| 302 | /* store new state */ |
| 303 | spectrum_128_port_7ffd_data = data; |
| 304 | |
| 305 | /* update memory */ |
| 306 | spectrum_plus3_update_memory(machine); |
| 307 | } |
| 308 | |
| 309 | static WRITE8_HANDLER(spectrum_plus3_port_1ffd_w) |
| 310 | { |
| 311 | |
| 312 | /* D0-D1: ROM/RAM paging */ |
| 313 | /* D2: Affects if d0-d1 work on ram/rom */ |
| 314 | /* D3 - Disk motor on/off */ |
| 315 | /* D4 - parallel port strobe */ |
| 316 | |
| 317 | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), data & (1<<3)); |
| 318 | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 1), data & (1<<3)); |
| 319 | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1, 1); |
| 320 | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 1), 1, 1); |
| 321 | |
| 322 | spectrum_plus3_port_1ffd_data = data; |
| 323 | |
| 324 | /* disable paging? */ |
| 325 | if ((spectrum_128_port_7ffd_data & 0x20)==0) |
| 326 | { |
| 327 | /* no */ |
| 328 | spectrum_plus3_update_memory(machine); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | /* decoding as per spectrum FAQ on www.worldofspectrum.org */ |
| 333 | static READ8_HANDLER ( spectrum_plus3_port_r ) |
| 334 | { |
| 335 | if ((offset & 1)==0) |
| 336 | { |
| 337 | return spectrum_port_fe_r(machine, offset); |
| 338 | } |
| 339 | |
| 340 | if ((offset & 2)==0) |
| 341 | { |
| 342 | switch ((offset>>14) & 0x03) |
| 343 | { |
| 344 | /* +3 fdc,memory,centronics */ |
| 345 | case 0: |
| 346 | { |
| 347 | switch ((offset>>12) & 0x03) |
| 348 | { |
| 349 | /* +3 centronics */ |
| 350 | case 0: |
| 351 | break; |
| 352 | |
| 353 | /* +3 fdc status */ |
| 354 | case 2: |
| 355 | return spectrum_plus3_port_2ffd_r(machine, offset); |
| 356 | /* +3 fdc data */ |
| 357 | case 3: |
| 358 | return spectrum_plus3_port_3ffd_r(machine, offset); |
| 359 | |
| 360 | default: |
| 361 | break; |
| 362 | } |
| 363 | } |
| 364 | break; |
| 365 | |
| 366 | /* 128k AY data */ |
| 367 | case 3: |
| 368 | return spectrum_128_port_fffd_r(machine, offset); |
| 369 | |
| 370 | default: |
| 371 | break; |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff; |
| 376 | } |
| 377 | |
| 378 | static WRITE8_HANDLER ( spectrum_plus3_port_w ) |
| 379 | { |
| 380 | if ((offset & 1)==0) |
| 381 | spectrum_port_fe_w(machine, offset, data); |
| 382 | |
| 383 | /* the following is not decoded exactly, need to check |
| 384 | what is correct! */ |
| 385 | |
| 386 | if ((offset & 2)==0) |
| 387 | { |
| 388 | switch ((offset>>14) & 0x03) |
| 389 | { |
| 390 | /* +3 fdc,memory,centronics */ |
| 391 | case 0: |
| 392 | { |
| 393 | switch ((offset>>12) & 0x03) |
| 394 | { |
| 395 | /* +3 centronics */ |
| 396 | case 0: |
| 397 | { |
| 398 | |
| 399 | |
| 400 | } |
| 401 | break; |
| 402 | |
| 403 | /* +3 memory */ |
| 404 | case 1: |
| 405 | spectrum_plus3_port_1ffd_w(machine, offset, data); |
| 406 | break; |
| 407 | |
| 408 | /* +3 fdc data */ |
| 409 | case 3: |
| 410 | spectrum_plus3_port_3ffd_w(machine, offset, data); |
| 411 | break; |
| 412 | |
| 413 | default: |
| 414 | break; |
| 415 | } |
| 416 | } |
| 417 | break; |
| 418 | |
| 419 | /* 128k memory */ |
| 420 | case 1: |
| 421 | spectrum_plus3_port_7ffd_w(machine, offset, data); |
| 422 | break; |
| 423 | |
| 424 | /* 128k AY data */ |
| 425 | case 2: |
| 426 | spectrum_128_port_bffd_w(machine, offset, data); |
| 427 | break; |
| 428 | |
| 429 | /* 128K AY register */ |
| 430 | case 3: |
| 431 | spectrum_128_port_fffd_w(machine, offset, data); |
| 432 | |
| 433 | default: |
| 434 | break; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | /*logerror("Write %02x to +3 port: %04x\n", data, offset); */ |
| 439 | } |
| 440 | |
| 441 | /* ports are not decoded full. |
| 442 | The function decodes the ports appropriately */ |
| 443 | static ADDRESS_MAP_START (spectrum_plus3_io, ADDRESS_SPACE_IO, 8) |
| 444 | AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_plus3_port_r, spectrum_plus3_port_w ) |
| 445 | ADDRESS_MAP_END |
| 446 | |
| 447 | static MACHINE_RESET( spectrum_plus3 ) |
| 448 | { |
| 449 | memset(mess_ram,0,128*1024); |
| 450 | |
| 451 | nec765_init(&spectrum_plus3_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED); |
| 452 | |
| 453 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40); |
| 454 | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40); |
| 455 | |
| 456 | /* Initial configuration */ |
| 457 | spectrum_128_port_7ffd_data = 0; |
| 458 | spectrum_plus3_port_1ffd_data = 0; |
| 459 | spectrum_plus3_update_memory(machine); |
| 460 | |
| 461 | MACHINE_RESET_CALL(spectrum); |
| 462 | } |
| 463 | |
| 464 | static MACHINE_DRIVER_START( spectrum_plus3 ) |
| 465 | MDRV_IMPORT_FROM( spectrum_128 ) |
| 466 | MDRV_CPU_MODIFY("main") |
| 467 | MDRV_CPU_IO_MAP(spectrum_plus3_io, 0) |
| 468 | MDRV_SCREEN_MODIFY("main") |
| 469 | MDRV_SCREEN_REFRESH_RATE(50.01) |
| 470 | |
| 471 | MDRV_MACHINE_RESET( spectrum_plus3 ) |
| 472 | MACHINE_DRIVER_END |
| 473 | |
| 474 | /*************************************************************************** |
| 475 | |
| 476 | Game driver(s) |
| 477 | |
| 478 | ***************************************************************************/ |
| 479 | |
| 480 | ROM_START(specpl2a) |
| 481 | ROM_REGION(0x20000,REGION_CPU1,0) |
| 482 | ROM_LOAD("p2a41_0.rom",0x10000,0x4000, CRC(30c9f490) SHA1(62ec15a4af56cd1d206d0bd7011eac7c889a595d)) |
| 483 | ROM_LOAD("p2a41_1.rom",0x14000,0x4000, CRC(a7916b3f) SHA1(1a7812c383a3701e90e88d1da086efb0c033ac72)) |
| 484 | ROM_LOAD("p2a41_2.rom",0x18000,0x4000, CRC(c9a0b748) SHA1(8df145d10ff78f98138682ea15ebccb2874bf759)) |
| 485 | ROM_LOAD("p2a41_3.rom",0x1c000,0x4000, CRC(b88fd6e3) SHA1(be365f331942ec7ec35456b641dac56a0dbfe1f0)) |
| 486 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 487 | ROM_END |
| 488 | |
| 489 | ROM_START(specpls3) |
| 490 | ROM_REGION(0x20000,REGION_CPU1,0) |
| 491 | ROM_LOAD("pl3-0.rom",0x10000,0x4000, CRC(17373da2) SHA1(e319ed08b4d53a5e421a75ea00ea02039ba6555b)) |
| 492 | ROM_LOAD("pl3-1.rom",0x14000,0x4000, CRC(f1d1d99e) SHA1(c9969fc36095a59787554026a9adc3b87678c794)) |
| 493 | ROM_LOAD("pl3-2.rom",0x18000,0x4000, CRC(3dbf351d) SHA1(22e50c6ba4157a3f6a821bd9937cd26e292775c6)) |
| 494 | ROM_LOAD("pl3-3.rom",0x1c000,0x4000, CRC(04448eaa) SHA1(65f031caa8148a5493afe42c41f4929deab26b4e)) |
| 495 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 496 | ROM_END |
| 497 | |
| 498 | ROM_START(specp3sp) |
| 499 | ROM_REGION(0x20000,REGION_CPU1,0) |
| 500 | ROM_LOAD("plus3sp0.rom",0x10000,0x4000, CRC(1f86147a) SHA1(e9b0a60a1a8def511d59090b945d175bdc646346)) |
| 501 | ROM_LOAD("plus3sp1.rom",0x14000,0x4000, CRC(a8ac4966) SHA1(4e48f196427596c7990c175d135c15a039c274a4)) |
| 502 | ROM_LOAD("plus3sp2.rom",0x18000,0x4000, CRC(f6bb0296) SHA1(09fc005625589ef5992515957ce7a3167dec24b2)) |
| 503 | ROM_LOAD("plus3sp3.rom",0x1c000,0x4000, CRC(f6d25389) SHA1(ec8f644a81e2e9bcb58ace974103ea960361bad2)) |
| 504 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 505 | ROM_END |
| 506 | |
| 507 | ROM_START(specpl3e) |
| 508 | ROM_REGION(0x20000,REGION_CPU1,0) |
| 509 | ROM_LOAD("roma-en.rom",0x10000,0x8000, CRC(2d533344) SHA1(5ff2dae32eb745d87e0b54c595d1d20a866f316f)) |
| 510 | ROM_LOAD("romb-en.rom",0x18000,0x8000, CRC(ef8d5d92) SHA1(983aa53aa76e25a3af123c896016bacf6829b72b)) |
| 511 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 512 | ROM_END |
| 513 | |
| 514 | ROM_START(specp3es) |
| 515 | ROM_REGION(0x20000,REGION_CPU1,0) |
| 516 | ROM_LOAD("roma-es.rom",0x10000,0x8000, CRC(ba694b4b) SHA1(d15d9e43950483cffc79f1cfa89ecb114a88f6c2)) |
| 517 | ROM_LOAD("romb-es.rom",0x18000,0x8000, CRC(61ed94db) SHA1(935b14c13db75d872de8ad0d591aade0adbbc355)) |
| 518 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 519 | ROM_END |
| 520 | |
| 521 | static void specpls3_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 522 | { |
| 523 | /* floppy */ |
| 524 | switch(state) |
| 525 | { |
| 526 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 527 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 528 | |
| 529 | default: legacydsk_device_getinfo(devclass, state, info); break; |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | SYSTEM_CONFIG_START(specpls3) |
| 534 | CONFIG_IMPORT_FROM(spectrum_common) |
| 535 | CONFIG_DEVICE(specpls3_floppy_getinfo) |
| 536 | CONFIG_RAM_DEFAULT(128 * 1024) |
| 537 | SYSTEM_CONFIG_END |
| 538 | |
| 539 | |
| 540 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 541 | COMP( 1987, specpl2a, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +2a" , 0 ) |
| 542 | COMP( 1987, specpls3, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3" , 0 ) |
| 543 | COMP( 1987, specp3sp, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3 (Spain)" , 0 ) |
| 544 | COMP( 2000, specpl3e, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3e" , GAME_COMPUTER_MODIFIED ) |
| 545 | COMP( 2000, specp3es, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3e (Spain)" , GAME_COMPUTER_MODIFIED ) |
src/mess/drivers/scorpion.c
| r0 | r2517 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | NOTE: ****** Specbusy: press N, R, or E to boot ************* |
| 4 | |
| 5 | |
| 6 | Spectrum/Inves/TK90X etc. memory map: |
| 7 | |
| 8 | CPU: |
| 9 | 0000-3fff ROM |
| 10 | 4000-ffff RAM |
| 11 | |
| 12 | Spectrum 128/+2/+2a/+3 memory map: |
| 13 | |
| 14 | CPU: |
| 15 | 0000-3fff Banked ROM/RAM (banked rom only on 128/+2) |
| 16 | 4000-7fff Banked RAM |
| 17 | 8000-bfff Banked RAM |
| 18 | c000-ffff Banked RAM |
| 19 | |
| 20 | TS2068 memory map: (Can't have both EXROM and DOCK active) |
| 21 | The 8K EXROM can be loaded into multiple pages. |
| 22 | |
| 23 | CPU: |
| 24 | 0000-1fff ROM / EXROM / DOCK (Cartridge) |
| 25 | 2000-3fff ROM / EXROM / DOCK |
| 26 | 4000-5fff \ |
| 27 | 6000-7fff \ |
| 28 | 8000-9fff |- RAM / EXROM / DOCK |
| 29 | a000-bfff | |
| 30 | c000-dfff / |
| 31 | e000-ffff / |
| 32 | |
| 33 | |
| 34 | Interrupts: |
| 35 | |
| 36 | Changes: |
| 37 | |
| 38 | 29/1/2000 KT - Implemented initial +3 emulation. |
| 39 | 30/1/2000 KT - Improved input port decoding for reading and therefore |
| 40 | correct keyboard handling for Spectrum and +3. |
| 41 | 31/1/2000 KT - Implemented buzzer sound for Spectrum and +3. |
| 42 | Implementation copied from Paul Daniel's Jupiter driver. |
| 43 | Fixed screen display problems with dirty chars. |
| 44 | Added support to load .Z80 snapshots. 48k support so far. |
| 45 | 13/2/2000 KT - Added Interface II, Kempston, Fuller and Mikrogen |
| 46 | joystick support. |
| 47 | 17/2/2000 DJR - Added full key descriptions and Spectrum+ keys. |
| 48 | Fixed Spectrum +3 keyboard problems. |
| 49 | 17/2/2000 KT - Added tape loading from WAV/Changed from DAC to generic |
| 50 | speaker code. |
| 51 | 18/2/2000 KT - Added tape saving to WAV. |
| 52 | 27/2/2000 KT - Took DJR's changes and added my changes. |
| 53 | 27/2/2000 KT - Added disk image support to Spectrum +3 driver. |
| 54 | 27/2/2000 KT - Added joystick I/O code to the Spectrum +3 I/O handler. |
| 55 | 14/3/2000 DJR - Tape handling dipswitch. |
| 56 | 26/3/2000 DJR - Snapshot files are now classifed as snapshots not |
| 57 | cartridges. |
| 58 | 04/4/2000 DJR - Spectrum 128 / +2 Support. |
| 59 | 13/4/2000 DJR - +4 Support (unofficial 48K hack). |
| 60 | 13/4/2000 DJR - +2a Support (rom also used in +3 models). |
| 61 | 13/4/2000 DJR - TK90X, TK95 and Inves support (48K clones). |
| 62 | 21/4/2000 DJR - TS2068 and TC2048 support (TC2048 Supports extra video |
| 63 | modes but doesn't have bank switching or sound chip). |
| 64 | 09/5/2000 DJR - Spectrum +2 (France, Spain), +3 (Spain). |
| 65 | 17/5/2000 DJR - Dipswitch to enable/disable disk drives on +3 and clones. |
| 66 | 27/6/2000 DJR - Changed 128K/+3 port decoding (sound now works in Zub 128K). |
| 67 | 06/8/2000 DJR - Fixed +3 Floppy support |
| 68 | 10/2/2001 KT - Re-arranged code and split into each model emulated. |
| 69 | Code is split into 48k, 128k, +3, tc2048 and ts2048 |
| 70 | segments. 128k uses some of the functions in 48k, +3 |
| 71 | uses some functions in 128, and tc2048/ts2048 use some |
| 72 | of the functions in 48k. The code has been arranged so |
| 73 | these functions come in some kind of "override" order, |
| 74 | read functions changed to use READ8_HANDLER and write |
| 75 | functions changed to use WRITE8_HANDLER. |
| 76 | Added Scorpion256 preliminary. |
| 77 | 18/6/2001 DJR - Added support for Interface 2 cartridges. |
| 78 | xx/xx/2001 KS - TS-2068 sound fixed. |
| 79 | Added support for DOCK cartridges for TS-2068. |
| 80 | Added Spectrum 48k Psycho modified rom driver. |
| 81 | Added UK-2086 driver. |
| 82 | 23/12/2001 KS - 48k machines are now able to run code in screen memory. |
| 83 | Programs which keep their code in screen memory |
| 84 | like monitors, tape copiers, decrunchers, etc. |
| 85 | works now. |
| 86 | Fixed problem with interrupt vector set to 0xffff (much |
| 87 | more 128k games works now). |
| 88 | A useful used trick on the Spectrum is to set |
| 89 | interrupt vector to 0xffff (using the table |
| 90 | which contain 0xff's) and put a byte 0x18 hex, |
| 91 | the opcode for JR, at this address. The first |
| 92 | byte of the ROM is a 0xf3 (DI), so the JR will |
| 93 | jump to 0xfff4, where a long JP to the actual |
| 94 | interrupt routine is put. Due to unideal |
| 95 | bankswitching in MAME this JP were to 0001 what |
| 96 | causes Spectrum to reset. Fixing this problem |
| 97 | made much more software runing (i.e. Paperboy). |
| 98 | Corrected frames per second value for 48k and 128k |
| 99 | Sincalir machines. |
| 100 | There are 50.08 frames per second for Spectrum |
| 101 | 48k what gives 69888 cycles for each frame and |
| 102 | 50.021 for Spectrum 128/+2/+2A/+3 what gives |
| 103 | 70908 cycles for each frame. |
| 104 | Remaped some Spectrum+ keys. |
| 105 | Presing F3 to reset was seting 0xf7 on keyboard |
| 106 | input port. Problem occured for snapshots of |
| 107 | some programms where it was readed as pressing |
| 108 | key 4 (which is exit in Tapecopy by R. Dannhoefer |
| 109 | for example). |
| 110 | Added support to load .SP snapshots. |
| 111 | Added .BLK tape images support. |
| 112 | .BLK files are identical to .TAP ones, extension |
| 113 | is an only difference. |
| 114 | 08/03/2002 KS - #FF port emulation added. |
| 115 | Arkanoid works now, but is not playable due to |
| 116 | completly messed timings. |
| 117 | |
| 118 | Initialisation values used when determining which model is being emulated: |
| 119 | 48K Spectrum doesn't use either port. |
| 120 | 128K/+2 Bank switches with port 7ffd only. |
| 121 | +3/+2a Bank switches with both ports. |
| 122 | |
| 123 | Notes: |
| 124 | 1. No contented memory. |
| 125 | 2. No hi-res colour effects (need contended memory first for accurate timing). |
| 126 | 3. Multiface 1 and Interface 1 not supported. |
| 127 | 4. Horace and the Spiders cartridge doesn't run properly. |
| 128 | 5. Tape images not supported: |
| 129 | .TZX, .SPC, .ITM, .PAN, .TAP(Warajevo), .VOC, .ZXS. |
| 130 | 6. Snapshot images not supported: |
| 131 | .ACH, .PRG, .RAW, .SEM, .SIT, .SNX, .ZX, .ZXS, .ZX82. |
| 132 | 7. 128K emulation is not perfect - the 128K machines crash and hang while |
| 133 | running quite a lot of games. |
| 134 | 8. Disk errors occur on some +3 games. |
| 135 | 9. Video hardware of all machines is timed incorrectly. |
| 136 | 10. EXROM and HOME cartridges are not emulated. |
| 137 | 11. The TK90X and TK95 roms output 0 to port #df on start up. |
| 138 | 12. The purpose of this port is unknown (probably display mode as TS2068) and |
| 139 | thus is not emulated. |
| 140 | |
| 141 | Very detailed infos about the ZX Spectrum +3e can be found at |
| 142 | |
| 143 | http://www.z88forever.org.uk/zxplus3e/ |
| 144 | |
| 145 | *******************************************************************************/ |
| 146 | |
| 147 | #include "driver.h" |
| 148 | #include "includes/spectrum.h" |
| 149 | #include "eventlst.h" |
| 150 | #include "devices/snapquik.h" |
| 151 | #include "devices/cartslot.h" |
| 152 | #include "devices/cassette.h" |
| 153 | #include "sound/ay8910.h" |
| 154 | #include "sound/speaker.h" |
| 155 | #include "formats/tzx_cas.h" |
| 156 | |
| 157 | /* +3 hardware */ |
| 158 | #include "machine/nec765.h" |
| 159 | #include "devices/dsk.h" |
| 160 | |
| 161 | /****************************************************************************************************/ |
| 162 | /* BETADISK/TR-DOS disc controller emulation */ |
| 163 | /* microcontroller KR1818VG93 is a russian wd179x clone */ |
| 164 | #include "machine/wd17xx.h" |
| 165 | |
| 166 | /* |
| 167 | DRQ (D6) and INTRQ (D7). |
| 168 | DRQ - signal showing request of data by microcontroller |
| 169 | INTRQ - signal of completion of execution of command. |
| 170 | */ |
| 171 | |
| 172 | static int betadisk_status; |
| 173 | static int betadisk_active; |
| 174 | |
| 175 | static void betadisk_wd179x_callback(running_machine *machine, wd17xx_state_t state, void *param) |
| 176 | { |
| 177 | switch (state) |
| 178 | { |
| 179 | case WD17XX_DRQ_SET: |
| 180 | { |
| 181 | betadisk_status |= (1<<6); |
| 182 | } |
| 183 | break; |
| 184 | |
| 185 | case WD17XX_DRQ_CLR: |
| 186 | { |
| 187 | betadisk_status &=~(1<<6); |
| 188 | } |
| 189 | break; |
| 190 | |
| 191 | case WD17XX_IRQ_SET: |
| 192 | { |
| 193 | betadisk_status |= (1<<7); |
| 194 | } |
| 195 | break; |
| 196 | |
| 197 | case WD17XX_IRQ_CLR: |
| 198 | { |
| 199 | betadisk_status &=~(1<<7); |
| 200 | } |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | MACHINE_START( scorpion ) |
| 206 | { |
| 207 | betadisk_active = 0; |
| 208 | betadisk_status = 0x03f; |
| 209 | wd17xx_init(machine, WD_TYPE_179X, betadisk_wd179x_callback, NULL); |
| 210 | } |
| 211 | |
| 212 | /****************************************************************************************************/ |
| 213 | /* Zs Scorpion 256 */ |
| 214 | |
| 215 | /* |
| 216 | port 7ffd. full compatibility with Zx spectrum 128. digits are: |
| 217 | |
| 218 | D0-D2 - number of RAM page to put in C000-FFFF |
| 219 | D3 - switch of address for RAM of screen. 0 - 4000, 1 - c000 |
| 220 | D4 - switch of ROM : 0-zx128, 1-zx48 |
| 221 | D5 - 1 in this bit will block further output in port 7FFD, until reset. |
| 222 | */ |
| 223 | |
| 224 | /* |
| 225 | port 1ffd - additional port for resources of computer. |
| 226 | |
| 227 | D0 - block of ROM in 0-3fff. when set to 1 - allows read/write page 0 of RAM |
| 228 | D1 - selects ROM expansion. this rom contains main part of service monitor. |
| 229 | D2 - not used |
| 230 | D3 - used for output in RS-232C |
| 231 | D4 - extended RAM. set to 1 - connects RAM page with number 8-15 in |
| 232 | C000-FFFF. number of page is given in gidits D0-D2 of port 7FFD |
| 233 | D5 - signal of strobe for interface centronics. to form the strobe has to be |
| 234 | set to 1. |
| 235 | D6-D7 - not used. ( yet ? ) |
| 236 | */ |
| 237 | |
| 238 | /* rom 0=zx128, 1=zx48, 2 = service monitor, 3=tr-dos */ |
| 239 | |
| 240 | static int scorpion_256_port_1ffd_data = 0; |
| 241 | |
| 242 | static void scorpion_update_memory(running_machine *machine) |
| 243 | { |
| 244 | unsigned char *ChosenROM; |
| 245 | int ROMSelection; |
| 246 | read8_machine_func rh; |
| 247 | write8_machine_func wh; |
| 248 | |
| 249 | if (spectrum_128_port_7ffd_data & 8) |
| 250 | { |
| 251 | logerror("SCREEN 1: BLOCK 7\n"); |
| 252 | spectrum_128_screen_location = mess_ram + (7<<14); |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | logerror("SCREEN 0: BLOCK 5\n"); |
| 257 | spectrum_128_screen_location = mess_ram + (5<<14); |
| 258 | } |
| 259 | |
| 260 | /* select ram at 0x0c000-0x0ffff */ |
| 261 | { |
| 262 | int ram_page; |
| 263 | unsigned char *ram_data; |
| 264 | |
| 265 | ram_page = (spectrum_128_port_7ffd_data & 0x07) | ((scorpion_256_port_1ffd_data & 0x10)>>1); |
| 266 | ram_data = mess_ram + (ram_page<<14); |
| 267 | |
| 268 | memory_set_bankptr(4, ram_data); |
| 269 | |
| 270 | logerror("RAM at 0xc000: %02x\n",ram_page); |
| 271 | } |
| 272 | |
| 273 | if (scorpion_256_port_1ffd_data & 0x01) |
| 274 | { |
| 275 | /* ram at 0x0000 */ |
| 276 | logerror("RAM at 0x0000\n"); |
| 277 | |
| 278 | /* connect page 0 of ram to 0x0000 */ |
| 279 | rh = SMH_BANK1; |
| 280 | wh = SMH_BANK1; |
| 281 | memory_set_bankptr(1, mess_ram+(8<<14)); |
| 282 | } |
| 283 | else |
| 284 | { |
| 285 | /* rom at 0x0000 */ |
| 286 | logerror("ROM at 0x0000\n"); |
| 287 | |
| 288 | /* connect page 0 of rom to 0x0000 */ |
| 289 | rh = SMH_BANK1; |
| 290 | wh = SMH_NOP; |
| 291 | |
| 292 | if (scorpion_256_port_1ffd_data & 0x02) |
| 293 | { |
| 294 | ROMSelection = 2; |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | /* ROM switching */ |
| 299 | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ; |
| 300 | } |
| 301 | /* rom 0 is 128K rom, rom 1 is 48 BASIC */ |
| 302 | ChosenROM = memory_region(REGION_CPU1) + 0x010000 + (ROMSelection<<14); |
| 303 | |
| 304 | memory_set_bankptr(1, ChosenROM); |
| 305 | |
| 306 | logerror("rom switch: %02x\n", ROMSelection); |
| 307 | } |
| 308 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, rh); |
| 309 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, wh); |
| 310 | } |
| 311 | |
| 312 | |
| 313 | static WRITE8_HANDLER(scorpion_port_7ffd_w) |
| 314 | { |
| 315 | logerror("scorpion 7ffd w: %02x\n", data); |
| 316 | |
| 317 | /* disable paging? */ |
| 318 | if (spectrum_128_port_7ffd_data & 0x20) |
| 319 | return; |
| 320 | |
| 321 | /* store new state */ |
| 322 | spectrum_128_port_7ffd_data = data; |
| 323 | |
| 324 | /* update memory */ |
| 325 | scorpion_update_memory(machine); |
| 326 | } |
| 327 | |
| 328 | static WRITE8_HANDLER(scorpion_port_1ffd_w) |
| 329 | { |
| 330 | logerror("scorpion 1ffd w: %02x\n", data); |
| 331 | |
| 332 | scorpion_256_port_1ffd_data = data; |
| 333 | |
| 334 | /* disable paging? */ |
| 335 | if ((spectrum_128_port_7ffd_data & 0x20)==0) |
| 336 | { |
| 337 | scorpion_update_memory(machine); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | |
| 342 | /* not sure if decoding is full or partial on scorpion */ |
| 343 | /* TO BE CHECKED! */ |
| 344 | static READ8_HANDLER(scorpion_port_r) |
| 345 | { |
| 346 | |
| 347 | /* KT: the following is not decoded exactly, need to check what |
| 348 | is correct */ |
| 349 | if ((offset & 2)==0) |
| 350 | { |
| 351 | switch ((offset>>8) & 0xff) |
| 352 | { |
| 353 | case 0xff: return spectrum_128_port_fffd_r(machine, offset); |
| 354 | case 0x1f: return spectrum_port_1f_r(machine, offset); |
| 355 | case 0x7f: return spectrum_port_7f_r(machine, offset); |
| 356 | case 0xdf: return spectrum_port_df_r(machine, offset); |
| 357 | } |
| 358 | } |
| 359 | switch (offset & 0x0ff) |
| 360 | { |
| 361 | case 0x0fe: |
| 362 | return spectrum_port_fe_r(machine, offset); |
| 363 | /* case 0x01f: |
| 364 | return wd17xx_status_r(machine, offset); |
| 365 | case 0x03f: |
| 366 | return wd17xx_track_r(machine, offset); |
| 367 | case 0x05f: |
| 368 | return wd17xx_sector_r(machine, offset); |
| 369 | case 0x07f: |
| 370 | return wd17xx_data_r(machine, offset); |
| 371 | case 0x0ff: |
| 372 | return betadisk_status;*/ |
| 373 | } |
| 374 | return 0xff; |
| 375 | } |
| 376 | |
| 377 | |
| 378 | /* not sure if decoding is full or partial on scorpion */ |
| 379 | /* TO BE CHECKED! */ |
| 380 | static WRITE8_HANDLER(scorpion_port_w) |
| 381 | { |
| 382 | switch (offset & 0x0ff) |
| 383 | { |
| 384 | case 0xfe : spectrum_port_fe_w(machine, offset, data); |
| 385 | break; |
| 386 | default: |
| 387 | if ((offset & 2)==0) |
| 388 | { |
| 389 | switch ((offset>>8) & 0xf0) |
| 390 | { |
| 391 | case 0x70: |
| 392 | scorpion_port_7ffd_w(machine, offset, data); |
| 393 | break; |
| 394 | case 0xb0: |
| 395 | spectrum_128_port_bffd_w(machine, offset, data); |
| 396 | break; |
| 397 | case 0xf0: |
| 398 | spectrum_128_port_fffd_w(machine, offset, data); |
| 399 | break; |
| 400 | case 0x10: |
| 401 | scorpion_port_1ffd_w(machine, offset, data); |
| 402 | break; |
| 403 | default: |
| 404 | logerror("Write %02x to scorpion port: %04x\n", data, offset); |
| 405 | } |
| 406 | } |
| 407 | else |
| 408 | { |
| 409 | logerror("Write %02x to scorpion port: %04x\n", data, offset); |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | |
| 415 | |
| 416 | /* ports are not decoded full. |
| 417 | The function decodes the ports appropriately */ |
| 418 | static ADDRESS_MAP_START (scorpion_io, ADDRESS_SPACE_IO, 8) |
| 419 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(scorpion_port_r, scorpion_port_w) |
| 420 | ADDRESS_MAP_END |
| 421 | |
| 422 | |
| 423 | static MACHINE_RESET( scorpion ) |
| 424 | { |
| 425 | memset(mess_ram,0,256*1024); |
| 426 | |
| 427 | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 428 | memory_set_bankptr(2, mess_ram + (5<<14)); |
| 429 | |
| 430 | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 431 | memory_set_bankptr(3, mess_ram + (2<<14)); |
| 432 | |
| 433 | spectrum_128_port_7ffd_data = 0; |
| 434 | scorpion_256_port_1ffd_data = 0; |
| 435 | |
| 436 | scorpion_update_memory(machine); |
| 437 | } |
| 438 | |
| 439 | static MACHINE_DRIVER_START( scorpion ) |
| 440 | MDRV_IMPORT_FROM( spectrum_128 ) |
| 441 | MDRV_CPU_MODIFY("main") |
| 442 | MDRV_CPU_IO_MAP(scorpion_io, 0) |
| 443 | MDRV_MACHINE_START( scorpion ) |
| 444 | MDRV_MACHINE_RESET( scorpion ) |
| 445 | MACHINE_DRIVER_END |
| 446 | |
| 447 | |
| 448 | |
| 449 | /*************************************************************************** |
| 450 | |
| 451 | Game driver(s) |
| 452 | |
| 453 | ***************************************************************************/ |
| 454 | |
| 455 | ROM_START(scorpion) |
| 456 | ROM_REGION(0x020000, REGION_CPU1, 0) |
| 457 | ROM_LOAD("scorp0.rom",0x010000, 0x4000, CRC(0eb40a09)) |
| 458 | ROM_LOAD("scorp1.rom",0x014000, 0x4000, CRC(9d513013)) |
| 459 | ROM_LOAD("scorp2.rom",0x018000, 0x4000, CRC(fd0d3ce1)) |
| 460 | ROM_LOAD("scorp3.rom",0x01c000, 0x4000, CRC(1fe1d003)) |
| 461 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 462 | ROM_END |
| 463 | |
| 464 | |
| 465 | SYSTEM_CONFIG_EXTERN(spectrum) |
| 466 | |
| 467 | SYSTEM_CONFIG_START(scorpion) |
| 468 | CONFIG_IMPORT_FROM(spectrum) |
| 469 | CONFIG_RAM_DEFAULT(256 * 1024) |
| 470 | SYSTEM_CONFIG_END |
| 471 | |
| 472 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 473 | COMP( ????, scorpion, 0, 0, scorpion, spectrum, 0, scorpion, "Zonov and Co.", "Zs Scorpion 256", 0 ) |
src/mess/drivers/spectrum.c
| r2516 | r2517 | |
| 150 | 150 | #include "devices/snapquik.h" |
| 151 | 151 | #include "devices/cartslot.h" |
| 152 | 152 | #include "devices/cassette.h" |
| 153 | | #include "sound/ay8910.h" |
| 154 | 153 | #include "sound/speaker.h" |
| 155 | 154 | #include "formats/tzx_cas.h" |
| 156 | 155 | |
| 157 | | /* +3 hardware */ |
| 158 | | #include "machine/nec765.h" |
| 159 | | #include "devices/dsk.h" |
| 160 | 156 | |
| 161 | 157 | |
| 162 | | static const struct AY8910interface spectrum_ay_interface = |
| 163 | | { |
| 164 | | AY8910_LEGACY_OUTPUT, |
| 165 | | AY8910_DEFAULT_LOADS, |
| 166 | | NULL |
| 167 | | }; |
| 168 | | |
| 169 | | |
| 170 | 158 | /****************************************************************************************************/ |
| 171 | 159 | /* Spectrum 48k functions */ |
| 172 | 160 | |
| r2516 | r2517 | |
| 179 | 167 | |
| 180 | 168 | int PreviousFE = 0; |
| 181 | 169 | |
| 182 | | static WRITE8_HANDLER(spectrum_port_fe_w) |
| 170 | WRITE8_HANDLER(spectrum_port_fe_w) |
| 183 | 171 | { |
| 184 | 172 | unsigned char Changed; |
| 185 | 173 | |
| r2516 | r2517 | |
| 207 | 195 | PreviousFE = data; |
| 208 | 196 | } |
| 209 | 197 | |
| 210 | | |
| 211 | | |
| 212 | | |
| 213 | 198 | static ADDRESS_MAP_START (spectrum_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 214 | 199 | AM_RANGE(0x0000, 0x3fff) AM_ROM |
| 215 | | AM_RANGE(0x4000, 0x57ff) AM_READWRITE( spectrum_characterram_r, spectrum_characterram_w ) |
| 216 | | AM_RANGE(0x5800, 0x5aff) AM_READWRITE( spectrum_colorram_r, spectrum_colorram_w ) |
| 200 | AM_RANGE(0x4000, 0x57ff) AM_RAM AM_BASE(&spectrum_characterram ) |
| 201 | AM_RANGE(0x5800, 0x5aff) AM_RAM AM_BASE(&spectrum_colorram ) |
| 217 | 202 | AM_RANGE(0x5b00, 0xffff) AM_RAM |
| 218 | 203 | ADDRESS_MAP_END |
| 219 | 204 | |
| 220 | 205 | /* KT: more accurate keyboard reading */ |
| 221 | 206 | /* DJR: Spectrum+ keys added */ |
| 222 | | static READ8_HANDLER(spectrum_port_fe_r) |
| 207 | READ8_HANDLER(spectrum_port_fe_r) |
| 223 | 208 | { |
| 224 | 209 | int lines = offset>>8; |
| 225 | 210 | int data = 0xff; |
| r2516 | r2517 | |
| 288 | 273 | } |
| 289 | 274 | |
| 290 | 275 | /* kempston joystick interface */ |
| 291 | | static READ8_HANDLER(spectrum_port_1f_r) |
| 276 | READ8_HANDLER(spectrum_port_1f_r) |
| 292 | 277 | { |
| 293 | 278 | return input_port_read(machine, "KEMPSTON") & 0x1f; |
| 294 | 279 | } |
| 295 | 280 | |
| 296 | 281 | /* fuller joystick interface */ |
| 297 | | static READ8_HANDLER(spectrum_port_7f_r) |
| 282 | READ8_HANDLER(spectrum_port_7f_r) |
| 298 | 283 | { |
| 299 | 284 | return input_port_read(machine, "FULLER") | (0xff^0x8f); |
| 300 | 285 | } |
| 301 | 286 | |
| 302 | 287 | /* mikrogen joystick interface */ |
| 303 | | static READ8_HANDLER(spectrum_port_df_r) |
| 288 | READ8_HANDLER(spectrum_port_df_r) |
| 304 | 289 | { |
| 305 | 290 | return input_port_read(machine, "MIKROGEN") | (0xff^0x1f); |
| 306 | 291 | } |
| r2516 | r2517 | |
| 338 | 323 | AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_port_r, spectrum_port_w ) |
| 339 | 324 | ADDRESS_MAP_END |
| 340 | 325 | |
| 341 | | |
| 342 | 326 | /****************************************************************************************************/ |
| 343 | | /* functions and data used by spectrum 128, spectrum +2, spectrum +3 and scorpion */ |
| 344 | | static unsigned char *spectrum_ram = NULL; |
| 345 | | |
| 346 | | static void spectrum_alloc_ram(int ram_size_in_k) |
| 347 | | { |
| 348 | | spectrum_ram = (unsigned char *)auto_malloc(ram_size_in_k*1024); |
| 349 | | memset(spectrum_ram, 0, ram_size_in_k*1024); |
| 350 | | } |
| 351 | | |
| 352 | | |
| 353 | | /****************************************************************************************************/ |
| 354 | | /* Spectrum 128 specific functions */ |
| 355 | | |
| 356 | | int spectrum_128_port_7ffd_data = -1; |
| 357 | | unsigned char *spectrum_128_screen_location = NULL; |
| 358 | | |
| 359 | | static WRITE8_HANDLER(spectrum_128_port_7ffd_w) |
| 360 | | { |
| 361 | | /* D0-D2: RAM page located at 0x0c000-0x0ffff */ |
| 362 | | /* D3 - Screen select (screen 0 in ram page 5, screen 1 in ram page 7 */ |
| 363 | | /* D4 - ROM select - which rom paged into 0x0000-0x03fff */ |
| 364 | | /* D5 - Disable paging */ |
| 365 | | |
| 366 | | /* disable paging? */ |
| 367 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 368 | | return; |
| 369 | | |
| 370 | | /* store new state */ |
| 371 | | spectrum_128_port_7ffd_data = data; |
| 372 | | |
| 373 | | /* update memory */ |
| 374 | | spectrum_128_update_memory(machine); |
| 375 | | } |
| 376 | | |
| 377 | | extern void spectrum_128_update_memory(running_machine *machine) |
| 378 | | { |
| 379 | | unsigned char *ChosenROM; |
| 380 | | int ROMSelection; |
| 381 | | |
| 382 | | if (spectrum_128_port_7ffd_data & 8) |
| 383 | | { |
| 384 | | logerror("SCREEN 1: BLOCK 7\n"); |
| 385 | | spectrum_128_screen_location = spectrum_ram + (7<<14); |
| 386 | | } |
| 387 | | else |
| 388 | | { |
| 389 | | logerror("SCREEN 0: BLOCK 5\n"); |
| 390 | | spectrum_128_screen_location = spectrum_ram + (5<<14); |
| 391 | | } |
| 392 | | |
| 393 | | /* select ram at 0x0c000-0x0ffff */ |
| 394 | | { |
| 395 | | int ram_page; |
| 396 | | unsigned char *ram_data; |
| 397 | | |
| 398 | | ram_page = spectrum_128_port_7ffd_data & 0x07; |
| 399 | | ram_data = spectrum_ram + (ram_page<<14); |
| 400 | | |
| 401 | | memory_set_bankptr(4, ram_data); |
| 402 | | memory_set_bankptr(8, ram_data); |
| 403 | | |
| 404 | | logerror("RAM at 0xc000: %02x\n",ram_page); |
| 405 | | } |
| 406 | | |
| 407 | | /* ROM switching */ |
| 408 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01); |
| 409 | | |
| 410 | | /* rom 0 is 128K rom, rom 1 is 48 BASIC */ |
| 411 | | |
| 412 | | ChosenROM = memory_region(REGION_CPU1) + 0x010000 + (ROMSelection<<14); |
| 413 | | |
| 414 | | memory_set_bankptr(1, ChosenROM); |
| 415 | | |
| 416 | | logerror("rom switch: %02x\n", ROMSelection); |
| 417 | | } |
| 418 | | |
| 419 | | |
| 420 | | |
| 421 | | static WRITE8_HANDLER(spectrum_128_port_bffd_w) |
| 422 | | { |
| 423 | | AY8910_write_port_0_w(machine, 0, data); |
| 424 | | } |
| 425 | | |
| 426 | | static WRITE8_HANDLER(spectrum_128_port_fffd_w) |
| 427 | | { |
| 428 | | AY8910_control_port_0_w(machine, 0, data); |
| 429 | | } |
| 430 | | |
| 431 | | static READ8_HANDLER(spectrum_128_port_fffd_r) |
| 432 | | { |
| 433 | | return AY8910_read_port_0_r(machine, 0); |
| 434 | | } |
| 435 | | |
| 436 | | static READ8_HANDLER ( spectrum_128_port_r ) |
| 437 | | { |
| 438 | | if ((offset & 1)==0) |
| 439 | | { |
| 440 | | return spectrum_port_fe_r(machine, offset); |
| 441 | | } |
| 442 | | |
| 443 | | if ((offset & 2)==0) |
| 444 | | { |
| 445 | | switch ((offset>>14) & 0x03) |
| 446 | | { |
| 447 | | default: |
| 448 | | break; |
| 449 | | |
| 450 | | case 3: |
| 451 | | return spectrum_128_port_fffd_r(machine, offset); |
| 452 | | } |
| 453 | | } |
| 454 | | |
| 455 | | /* don't think these are correct! */ |
| 456 | | if ((offset & 0xff)==0x1f) |
| 457 | | return spectrum_port_1f_r(machine, offset); |
| 458 | | |
| 459 | | if ((offset & 0xff)==0x7f) |
| 460 | | return spectrum_port_7f_r(machine, offset); |
| 461 | | |
| 462 | | if ((offset & 0xff)==0xdf) |
| 463 | | return spectrum_port_df_r(machine, offset); |
| 464 | | |
| 465 | | return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff; |
| 466 | | } |
| 467 | | |
| 468 | | static WRITE8_HANDLER ( spectrum_128_port_w ) |
| 469 | | { |
| 470 | | if ((offset & 1)==0) |
| 471 | | spectrum_port_fe_w(machine, offset,data); |
| 472 | | |
| 473 | | /* Only decodes on A15, A14 & A1 */ |
| 474 | | else if ((offset & 2)==0) |
| 475 | | { |
| 476 | | switch ((offset>>8) & 0xc0) |
| 477 | | { |
| 478 | | case 0x40: |
| 479 | | spectrum_128_port_7ffd_w(machine, offset, data); |
| 480 | | break; |
| 481 | | case 0x80: |
| 482 | | spectrum_128_port_bffd_w(machine, offset, data); |
| 483 | | break; |
| 484 | | case 0xc0: |
| 485 | | spectrum_128_port_fffd_w(machine, offset, data); |
| 486 | | break; |
| 487 | | default: |
| 488 | | logerror("Write %02x to 128 port: %04x\n", data, offset); |
| 489 | | } |
| 490 | | } |
| 491 | | else |
| 492 | | { |
| 493 | | logerror("Write %02x to 128 port: %04x\n", data, offset); |
| 494 | | } |
| 495 | | } |
| 496 | | |
| 497 | | /* ports are not decoded full. |
| 498 | | The function decodes the ports appropriately */ |
| 499 | | static ADDRESS_MAP_START (spectrum_128_io, ADDRESS_SPACE_IO, 8) |
| 500 | | AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_128_port_r, spectrum_128_port_w ) |
| 501 | | ADDRESS_MAP_END |
| 502 | | |
| 503 | | static ADDRESS_MAP_START (spectrum_128_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 504 | | AM_RANGE( 0x0000, 0x3fff) AM_READWRITE( SMH_BANK1, SMH_BANK5 ) |
| 505 | | AM_RANGE( 0x4000, 0x7fff) AM_READWRITE( SMH_BANK2, SMH_BANK6 ) |
| 506 | | AM_RANGE( 0x8000, 0xbfff) AM_READWRITE( SMH_BANK3, SMH_BANK7 ) |
| 507 | | AM_RANGE( 0xc000, 0xffff) AM_READWRITE( SMH_BANK4, SMH_BANK8 ) |
| 508 | | ADDRESS_MAP_END |
| 509 | | |
| 510 | | static MACHINE_RESET( spectrum_128 ) |
| 511 | | { |
| 512 | | spectrum_alloc_ram(128); |
| 513 | | |
| 514 | | /* 0x0000-0x3fff always holds ROM */ |
| 515 | | |
| 516 | | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 517 | | memory_set_bankptr(2, spectrum_ram + (5<<14)); |
| 518 | | memory_set_bankptr(6, spectrum_ram + (5<<14)); |
| 519 | | |
| 520 | | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 521 | | memory_set_bankptr(3, spectrum_ram + (2<<14)); |
| 522 | | memory_set_bankptr(7, spectrum_ram + (2<<14)); |
| 523 | | |
| 524 | | /* set initial ram config */ |
| 525 | | spectrum_128_port_7ffd_data = 0; |
| 526 | | spectrum_128_update_memory(machine); |
| 527 | | |
| 528 | | MACHINE_RESET_CALL(spectrum); |
| 529 | | } |
| 530 | | |
| 531 | | /****************************************************************************************************/ |
| 532 | | /* Spectrum + 3 specific functions */ |
| 533 | | /* This driver uses some of the spectrum_128 functions. The +3 is similar to a spectrum 128 |
| 534 | | but with a disc drive */ |
| 535 | | |
| 536 | | int spectrum_plus3_port_1ffd_data = -1; |
| 537 | | |
| 538 | | |
| 539 | | static const nec765_interface spectrum_plus3_nec765_interface = |
| 540 | | { |
| 541 | | NULL, |
| 542 | | NULL |
| 543 | | }; |
| 544 | | |
| 545 | | |
| 546 | | static const int spectrum_plus3_memory_selections[]= |
| 547 | | { |
| 548 | | 0,1,2,3, |
| 549 | | 4,5,6,7, |
| 550 | | 4,5,6,3, |
| 551 | | 4,7,6,3 |
| 552 | | }; |
| 553 | | |
| 554 | | static WRITE8_HANDLER(spectrum_plus3_port_3ffd_w) |
| 555 | | { |
| 556 | | if (~input_port_read(machine, "CONFIG") & 0x20) |
| 557 | | nec765_data_w(machine, 0,data); |
| 558 | | } |
| 559 | | |
| 560 | | static READ8_HANDLER(spectrum_plus3_port_3ffd_r) |
| 561 | | { |
| 562 | | if (input_port_read(machine, "CONFIG") & 0x20) |
| 563 | | return 0xff; |
| 564 | | else |
| 565 | | return nec765_data_r(machine, 0); |
| 566 | | } |
| 567 | | |
| 568 | | |
| 569 | | static READ8_HANDLER(spectrum_plus3_port_2ffd_r) |
| 570 | | { |
| 571 | | if (input_port_read(machine, "CONFIG") & 0x20) |
| 572 | | return 0xff; |
| 573 | | else |
| 574 | | return nec765_status_r(machine, 0); |
| 575 | | } |
| 576 | | |
| 577 | | |
| 578 | | void spectrum_plus3_update_memory(running_machine *machine) |
| 579 | | { |
| 580 | | if (spectrum_128_port_7ffd_data & 8) |
| 581 | | { |
| 582 | | logerror("+3 SCREEN 1: BLOCK 7\n"); |
| 583 | | spectrum_128_screen_location = spectrum_ram + (7<<14); |
| 584 | | } |
| 585 | | else |
| 586 | | { |
| 587 | | logerror("+3 SCREEN 0: BLOCK 5\n"); |
| 588 | | spectrum_128_screen_location = spectrum_ram + (5<<14); |
| 589 | | } |
| 590 | | |
| 591 | | if ((spectrum_plus3_port_1ffd_data & 0x01)==0) |
| 592 | | { |
| 593 | | int ram_page; |
| 594 | | unsigned char *ram_data; |
| 595 | | |
| 596 | | /* ROM switching */ |
| 597 | | unsigned char *ChosenROM; |
| 598 | | int ROMSelection; |
| 599 | | |
| 600 | | /* select ram at 0x0c000-0x0ffff */ |
| 601 | | ram_page = spectrum_128_port_7ffd_data & 0x07; |
| 602 | | ram_data = spectrum_ram + (ram_page<<14); |
| 603 | | |
| 604 | | memory_set_bankptr(4, ram_data); |
| 605 | | memory_set_bankptr(8, ram_data); |
| 606 | | |
| 607 | | logerror("RAM at 0xc000: %02x\n",ram_page); |
| 608 | | |
| 609 | | /* Reset memory between 0x4000 - 0xbfff in case extended paging was being used */ |
| 610 | | /* Bank 5 in 0x4000 - 0x7fff */ |
| 611 | | memory_set_bankptr(2, spectrum_ram + (5<<14)); |
| 612 | | memory_set_bankptr(6, spectrum_ram + (5<<14)); |
| 613 | | |
| 614 | | /* Bank 2 in 0x8000 - 0xbfff */ |
| 615 | | memory_set_bankptr(3, spectrum_ram + (2<<14)); |
| 616 | | memory_set_bankptr(7, spectrum_ram + (2<<14)); |
| 617 | | |
| 618 | | |
| 619 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) | |
| 620 | | ((spectrum_plus3_port_1ffd_data>>1) & 0x02); |
| 621 | | |
| 622 | | /* rom 0 is editor, rom 1 is syntax, rom 2 is DOS, rom 3 is 48 BASIC */ |
| 623 | | |
| 624 | | ChosenROM = memory_region(REGION_CPU1) + 0x010000 + (ROMSelection<<14); |
| 625 | | |
| 626 | | memory_set_bankptr(1, ChosenROM); |
| 627 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_UNMAP); |
| 628 | | |
| 629 | | logerror("rom switch: %02x\n", ROMSelection); |
| 630 | | } |
| 631 | | else |
| 632 | | { |
| 633 | | /* Extended memory paging */ |
| 634 | | |
| 635 | | const int *memory_selection; |
| 636 | | int MemorySelection; |
| 637 | | unsigned char *ram_data; |
| 638 | | |
| 639 | | MemorySelection = (spectrum_plus3_port_1ffd_data>>1) & 0x03; |
| 640 | | |
| 641 | | memory_selection = &spectrum_plus3_memory_selections[(MemorySelection<<2)]; |
| 642 | | |
| 643 | | ram_data = spectrum_ram + (memory_selection[0]<<14); |
| 644 | | memory_set_bankptr(1, ram_data); |
| 645 | | memory_set_bankptr(5, ram_data); |
| 646 | | /* allow writes to 0x0000-0x03fff */ |
| 647 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, SMH_BANK5); |
| 648 | | |
| 649 | | ram_data = spectrum_ram + (memory_selection[1]<<14); |
| 650 | | memory_set_bankptr(2, ram_data); |
| 651 | | memory_set_bankptr(6, ram_data); |
| 652 | | |
| 653 | | ram_data = spectrum_ram + (memory_selection[2]<<14); |
| 654 | | memory_set_bankptr(3, ram_data); |
| 655 | | memory_set_bankptr(7, ram_data); |
| 656 | | |
| 657 | | ram_data = spectrum_ram + (memory_selection[3]<<14); |
| 658 | | memory_set_bankptr(4, ram_data); |
| 659 | | memory_set_bankptr(8, ram_data); |
| 660 | | |
| 661 | | logerror("extended memory paging: %02x\n",MemorySelection); |
| 662 | | } |
| 663 | | } |
| 664 | | |
| 665 | | |
| 666 | | |
| 667 | | static WRITE8_HANDLER(spectrum_plus3_port_7ffd_w) |
| 668 | | { |
| 669 | | /* D0-D2: RAM page located at 0x0c000-0x0ffff */ |
| 670 | | /* D3 - Screen select (screen 0 in ram page 5, screen 1 in ram page 7 */ |
| 671 | | /* D4 - ROM select - which rom paged into 0x0000-0x03fff */ |
| 672 | | /* D5 - Disable paging */ |
| 673 | | |
| 674 | | /* disable paging? */ |
| 675 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 676 | | return; |
| 677 | | |
| 678 | | /* store new state */ |
| 679 | | spectrum_128_port_7ffd_data = data; |
| 680 | | |
| 681 | | /* update memory */ |
| 682 | | spectrum_plus3_update_memory(machine); |
| 683 | | } |
| 684 | | |
| 685 | | static WRITE8_HANDLER(spectrum_plus3_port_1ffd_w) |
| 686 | | { |
| 687 | | |
| 688 | | /* D0-D1: ROM/RAM paging */ |
| 689 | | /* D2: Affects if d0-d1 work on ram/rom */ |
| 690 | | /* D3 - Disk motor on/off */ |
| 691 | | /* D4 - parallel port strobe */ |
| 692 | | |
| 693 | | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 0), data & (1<<3)); |
| 694 | | floppy_drive_set_motor_state(image_from_devtype_and_index(IO_FLOPPY, 1), data & (1<<3)); |
| 695 | | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 0), 1, 1); |
| 696 | | floppy_drive_set_ready_state(image_from_devtype_and_index(IO_FLOPPY, 1), 1, 1); |
| 697 | | |
| 698 | | spectrum_plus3_port_1ffd_data = data; |
| 699 | | |
| 700 | | /* disable paging? */ |
| 701 | | if ((spectrum_128_port_7ffd_data & 0x20)==0) |
| 702 | | { |
| 703 | | /* no */ |
| 704 | | spectrum_plus3_update_memory(machine); |
| 705 | | } |
| 706 | | } |
| 707 | | |
| 708 | | /* decoding as per spectrum FAQ on www.worldofspectrum.org */ |
| 709 | | static READ8_HANDLER ( spectrum_plus3_port_r ) |
| 710 | | { |
| 711 | | if ((offset & 1)==0) |
| 712 | | { |
| 713 | | return spectrum_port_fe_r(machine, offset); |
| 714 | | } |
| 715 | | |
| 716 | | if ((offset & 2)==0) |
| 717 | | { |
| 718 | | switch ((offset>>14) & 0x03) |
| 719 | | { |
| 720 | | /* +3 fdc,memory,centronics */ |
| 721 | | case 0: |
| 722 | | { |
| 723 | | switch ((offset>>12) & 0x03) |
| 724 | | { |
| 725 | | /* +3 centronics */ |
| 726 | | case 0: |
| 727 | | break; |
| 728 | | |
| 729 | | /* +3 fdc status */ |
| 730 | | case 2: |
| 731 | | return spectrum_plus3_port_2ffd_r(machine, offset); |
| 732 | | /* +3 fdc data */ |
| 733 | | case 3: |
| 734 | | return spectrum_plus3_port_3ffd_r(machine, offset); |
| 735 | | |
| 736 | | default: |
| 737 | | break; |
| 738 | | } |
| 739 | | } |
| 740 | | break; |
| 741 | | |
| 742 | | /* 128k AY data */ |
| 743 | | case 3: |
| 744 | | return spectrum_128_port_fffd_r(machine, offset); |
| 745 | | |
| 746 | | default: |
| 747 | | break; |
| 748 | | } |
| 749 | | } |
| 750 | | |
| 751 | | return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff; |
| 752 | | } |
| 753 | | |
| 754 | | static WRITE8_HANDLER ( spectrum_plus3_port_w ) |
| 755 | | { |
| 756 | | if ((offset & 1)==0) |
| 757 | | spectrum_port_fe_w(machine, offset, data); |
| 758 | | |
| 759 | | /* the following is not decoded exactly, need to check |
| 760 | | what is correct! */ |
| 761 | | |
| 762 | | if ((offset & 2)==0) |
| 763 | | { |
| 764 | | switch ((offset>>14) & 0x03) |
| 765 | | { |
| 766 | | /* +3 fdc,memory,centronics */ |
| 767 | | case 0: |
| 768 | | { |
| 769 | | switch ((offset>>12) & 0x03) |
| 770 | | { |
| 771 | | /* +3 centronics */ |
| 772 | | case 0: |
| 773 | | { |
| 774 | | |
| 775 | | |
| 776 | | } |
| 777 | | break; |
| 778 | | |
| 779 | | /* +3 memory */ |
| 780 | | case 1: |
| 781 | | spectrum_plus3_port_1ffd_w(machine, offset, data); |
| 782 | | break; |
| 783 | | |
| 784 | | /* +3 fdc data */ |
| 785 | | case 3: |
| 786 | | spectrum_plus3_port_3ffd_w(machine, offset, data); |
| 787 | | break; |
| 788 | | |
| 789 | | default: |
| 790 | | break; |
| 791 | | } |
| 792 | | } |
| 793 | | break; |
| 794 | | |
| 795 | | /* 128k memory */ |
| 796 | | case 1: |
| 797 | | spectrum_plus3_port_7ffd_w(machine, offset, data); |
| 798 | | break; |
| 799 | | |
| 800 | | /* 128k AY data */ |
| 801 | | case 2: |
| 802 | | spectrum_128_port_bffd_w(machine, offset, data); |
| 803 | | break; |
| 804 | | |
| 805 | | /* 128K AY register */ |
| 806 | | case 3: |
| 807 | | spectrum_128_port_fffd_w(machine, offset, data); |
| 808 | | |
| 809 | | default: |
| 810 | | break; |
| 811 | | } |
| 812 | | } |
| 813 | | |
| 814 | | /*logerror("Write %02x to +3 port: %04x\n", data, offset); */ |
| 815 | | } |
| 816 | | |
| 817 | | /* ports are not decoded full. |
| 818 | | The function decodes the ports appropriately */ |
| 819 | | static ADDRESS_MAP_START (spectrum_plus3_io, ADDRESS_SPACE_IO, 8) |
| 820 | | AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_plus3_port_r, spectrum_plus3_port_w ) |
| 821 | | ADDRESS_MAP_END |
| 822 | | |
| 823 | | static MACHINE_RESET( spectrum_plus3 ) |
| 824 | | { |
| 825 | | spectrum_alloc_ram(128); |
| 826 | | |
| 827 | | nec765_init(&spectrum_plus3_nec765_interface, NEC765A, NEC765_RDY_PIN_CONNECTED); |
| 828 | | |
| 829 | | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40); |
| 830 | | floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 1), FLOPPY_DRIVE_SS_40); |
| 831 | | |
| 832 | | /* Initial configuration */ |
| 833 | | spectrum_128_port_7ffd_data = 0; |
| 834 | | spectrum_plus3_port_1ffd_data = 0; |
| 835 | | spectrum_plus3_update_memory(machine); |
| 836 | | |
| 837 | | MACHINE_RESET_CALL(spectrum); |
| 838 | | } |
| 839 | | |
| 840 | | |
| 841 | | /****************************************************************************************************/ |
| 842 | | /* TS2048 specific functions */ |
| 843 | | |
| 844 | | |
| 845 | | int ts2068_port_ff_data = -1; /* Display enhancement control */ |
| 846 | | int ts2068_port_f4_data = -1; /* Horizontal Select Register */ |
| 847 | | |
| 848 | | static READ8_HANDLER(ts2068_port_f4_r) |
| 849 | | { |
| 850 | | return ts2068_port_f4_data; |
| 851 | | } |
| 852 | | |
| 853 | | static WRITE8_HANDLER(ts2068_port_f4_w) |
| 854 | | { |
| 855 | | ts2068_port_f4_data = data; |
| 856 | | ts2068_update_memory(machine); |
| 857 | | } |
| 858 | | |
| 859 | | static WRITE8_HANDLER(ts2068_port_f5_w) |
| 860 | | { |
| 861 | | AY8910_control_port_0_w(machine, 0, data); |
| 862 | | } |
| 863 | | |
| 864 | | static READ8_HANDLER(ts2068_port_f6_r) |
| 865 | | { |
| 866 | | /* TODO - Reading from register 14 reads the joystick ports |
| 867 | | set bit 8 of address to read joystick #1 |
| 868 | | set bit 9 of address to read joystick #2 |
| 869 | | if both bits are set then OR values |
| 870 | | Bit 0 up, 1 down, 2 left, 3 right, 7 fire active low. Other bits 1 |
| 871 | | */ |
| 872 | | return AY8910_read_port_0_r(machine, 0); |
| 873 | | } |
| 874 | | |
| 875 | | static WRITE8_HANDLER(ts2068_port_f6_w) |
| 876 | | { |
| 877 | | AY8910_write_port_0_w(machine, 0, data); |
| 878 | | } |
| 879 | | |
| 880 | | static READ8_HANDLER(ts2068_port_ff_r) |
| 881 | | { |
| 882 | | return ts2068_port_ff_data; |
| 883 | | } |
| 884 | | |
| 885 | | static WRITE8_HANDLER(ts2068_port_ff_w) |
| 886 | | { |
| 887 | | /* Bits 0-2 Video Mode Select |
| 888 | | Bits 3-5 64 column mode ink/paper selection |
| 889 | | (See ts2068_vh_screenrefresh for more info) |
| 890 | | Bit 6 17ms Interrupt Inhibit |
| 891 | | Bit 7 Cartridge (0) / EXROM (1) select |
| 892 | | */ |
| 893 | | ts2068_port_ff_data = data; |
| 894 | | ts2068_update_memory(machine); |
| 895 | | logerror("Port %04x write %02x\n", offset, data); |
| 896 | | } |
| 897 | | |
| 898 | | |
| 899 | | static READ8_HANDLER ( ts2068_port_r ) |
| 900 | | { |
| 901 | | switch (offset & 0xff) |
| 902 | | { |
| 903 | | /* Note: keys only decoded on port #fe not all even ports so |
| 904 | | ports #f4 & #f6 correctly read */ |
| 905 | | case 0xf4: return ts2068_port_f4_r(machine, offset); |
| 906 | | case 0xf6: return ts2068_port_f6_r(machine, offset); |
| 907 | | case 0xff: return ts2068_port_ff_r(machine, offset); |
| 908 | | |
| 909 | | case 0xfe: return spectrum_port_fe_r(machine, offset); |
| 910 | | case 0x1f: return spectrum_port_1f_r(machine, offset); |
| 911 | | case 0x7f: return spectrum_port_7f_r(machine, offset); |
| 912 | | case 0xdf: return spectrum_port_df_r(machine, offset); |
| 913 | | } |
| 914 | | logerror("Read from port: %04x\n", offset); |
| 915 | | |
| 916 | | return 0xff; |
| 917 | | } |
| 918 | | |
| 919 | | static WRITE8_HANDLER ( ts2068_port_w ) |
| 920 | | { |
| 921 | | /* Ports #fd & #fc were reserved by Timex for bankswitching and are not used |
| 922 | | by either the hardware or system software. |
| 923 | | Port #fb is the Thermal printer port and works exactly as the Sinclair |
| 924 | | Printer - ie not yet emulated. |
| 925 | | */ |
| 926 | | switch (offset & 0xff) |
| 927 | | { |
| 928 | | case 0xfe: spectrum_port_fe_w(machine, offset,data); break; |
| 929 | | case 0xf4: ts2068_port_f4_w(machine, offset,data); break; |
| 930 | | case 0xf5: ts2068_port_f5_w(machine, offset,data); break; |
| 931 | | case 0xf6: ts2068_port_f6_w(machine, offset,data); break; |
| 932 | | case 0xff: ts2068_port_ff_w(machine, offset,data); break; |
| 933 | | default: |
| 934 | | logerror("Write %02x to Port: %04x\n", data, offset); |
| 935 | | } |
| 936 | | } |
| 937 | | |
| 938 | | |
| 939 | | |
| 940 | | /******************************************************************* |
| 941 | | * |
| 942 | | * Bank switch between the 3 internal memory banks HOME, EXROM |
| 943 | | * and DOCK (Cartridges). The HOME bank contains 16K ROM in the |
| 944 | | * 0-16K area and 48K RAM fills the rest. The EXROM contains 8K |
| 945 | | * ROM and can appear in every 8K segment (ie 0-8K, 8-16K etc). |
| 946 | | * The DOCK is empty and is meant to be occupied by cartridges |
| 947 | | * you can plug into the cartridge dock of the 2068. |
| 948 | | * |
| 949 | | * The address space is divided into 8 8K chunks. Bit 0 of port |
| 950 | | * #f4 corresponds to the 0-8K chunk, bit 1 to the 8-16K chunk |
| 951 | | * etc. If the bit is 0 then the chunk is controlled by the HOME |
| 952 | | * bank. If the bit is 1 then the chunk is controlled by either |
| 953 | | * the DOCK or EXROM depending on bit 7 of port #ff. Note this |
| 954 | | * means that that the Z80 can't see chunks of the EXROM and DOCK |
| 955 | | * at the same time. |
| 956 | | * |
| 957 | | *******************************************************************/ |
| 958 | | void ts2068_update_memory(running_machine *machine) |
| 959 | | { |
| 960 | | unsigned char *ChosenROM, *ExROM, *DOCK; |
| 961 | | read8_machine_func rh; |
| 962 | | write8_machine_func wh; |
| 963 | | |
| 964 | | DOCK = timex_cart_data; |
| 965 | | |
| 966 | | ExROM = memory_region(REGION_CPU1) + 0x014000; |
| 967 | | |
| 968 | | if (ts2068_port_f4_data & 0x01) |
| 969 | | { |
| 970 | | if (ts2068_port_ff_data & 0x80) |
| 971 | | { |
| 972 | | rh = SMH_BANK1; |
| 973 | | wh = SMH_UNMAP; |
| 974 | | memory_set_bankptr(1, ExROM); |
| 975 | | logerror("0000-1fff EXROM\n"); |
| 976 | | } |
| 977 | | else |
| 978 | | { |
| 979 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 980 | | { |
| 981 | | memory_set_bankptr(1, DOCK); |
| 982 | | rh = SMH_BANK1; |
| 983 | | if (timex_cart_chunks&0x01) |
| 984 | | wh = SMH_BANK9; |
| 985 | | else |
| 986 | | wh = SMH_UNMAP; |
| 987 | | } |
| 988 | | else |
| 989 | | { |
| 990 | | rh = SMH_NOP; |
| 991 | | wh = SMH_UNMAP; |
| 992 | | } |
| 993 | | logerror("0000-1fff Cartridge\n"); |
| 994 | | } |
| 995 | | } |
| 996 | | else |
| 997 | | { |
| 998 | | ChosenROM = memory_region(REGION_CPU1) + 0x010000; |
| 999 | | memory_set_bankptr(1, ChosenROM); |
| 1000 | | rh = SMH_BANK1; |
| 1001 | | wh = SMH_UNMAP; |
| 1002 | | logerror("0000-1fff HOME\n"); |
| 1003 | | } |
| 1004 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, rh); |
| 1005 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, wh); |
| 1006 | | |
| 1007 | | if (ts2068_port_f4_data & 0x02) |
| 1008 | | { |
| 1009 | | if (ts2068_port_ff_data & 0x80) |
| 1010 | | { |
| 1011 | | memory_set_bankptr(2, ExROM); |
| 1012 | | rh = SMH_BANK2; |
| 1013 | | wh = SMH_UNMAP; |
| 1014 | | logerror("2000-3fff EXROM\n"); |
| 1015 | | } |
| 1016 | | else |
| 1017 | | { |
| 1018 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 1019 | | { |
| 1020 | | memory_set_bankptr(2, DOCK+0x2000); |
| 1021 | | rh = SMH_BANK2; |
| 1022 | | if (timex_cart_chunks&0x02) |
| 1023 | | wh = SMH_BANK10; |
| 1024 | | else |
| 1025 | | wh = SMH_UNMAP; |
| 1026 | | } |
| 1027 | | else |
| 1028 | | { |
| 1029 | | rh = SMH_NOP; |
| 1030 | | wh = SMH_UNMAP; |
| 1031 | | } |
| 1032 | | logerror("2000-3fff Cartridge\n"); |
| 1033 | | } |
| 1034 | | } |
| 1035 | | else |
| 1036 | | { |
| 1037 | | ChosenROM = memory_region(REGION_CPU1) + 0x012000; |
| 1038 | | memory_set_bankptr(2, ChosenROM); |
| 1039 | | rh = SMH_BANK2; |
| 1040 | | wh = SMH_UNMAP; |
| 1041 | | logerror("2000-3fff HOME\n"); |
| 1042 | | } |
| 1043 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, rh); |
| 1044 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, wh); |
| 1045 | | |
| 1046 | | if (ts2068_port_f4_data & 0x04) |
| 1047 | | { |
| 1048 | | if (ts2068_port_ff_data & 0x80) |
| 1049 | | { |
| 1050 | | memory_set_bankptr(3, ExROM); |
| 1051 | | rh = SMH_BANK3; |
| 1052 | | wh = SMH_UNMAP; |
| 1053 | | logerror("4000-5fff EXROM\n"); |
| 1054 | | } |
| 1055 | | else |
| 1056 | | { |
| 1057 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 1058 | | { |
| 1059 | | memory_set_bankptr(3, DOCK+0x4000); |
| 1060 | | rh = SMH_BANK3; |
| 1061 | | if (timex_cart_chunks&0x04) |
| 1062 | | wh = SMH_BANK11; |
| 1063 | | else |
| 1064 | | wh = SMH_UNMAP; |
| 1065 | | } |
| 1066 | | else |
| 1067 | | { |
| 1068 | | rh = SMH_NOP; |
| 1069 | | wh = SMH_UNMAP; |
| 1070 | | } |
| 1071 | | logerror("4000-5fff Cartridge\n"); |
| 1072 | | } |
| 1073 | | } |
| 1074 | | else |
| 1075 | | { |
| 1076 | | memory_set_bankptr(3, mess_ram); |
| 1077 | | memory_set_bankptr(11, mess_ram); |
| 1078 | | rh = SMH_BANK3; |
| 1079 | | wh = SMH_BANK11; |
| 1080 | | logerror("4000-5fff RAM\n"); |
| 1081 | | } |
| 1082 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, rh); |
| 1083 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, wh); |
| 1084 | | |
| 1085 | | if (ts2068_port_f4_data & 0x08) |
| 1086 | | { |
| 1087 | | if (ts2068_port_ff_data & 0x80) |
| 1088 | | { |
| 1089 | | memory_set_bankptr(4, ExROM); |
| 1090 | | rh = SMH_BANK4; |
| 1091 | | wh = SMH_UNMAP; |
| 1092 | | logerror("6000-7fff EXROM\n"); |
| 1093 | | } |
| 1094 | | else |
| 1095 | | { |
| 1096 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 1097 | | { |
| 1098 | | memory_set_bankptr(4, DOCK+0x6000); |
| 1099 | | rh = SMH_BANK4; |
| 1100 | | if (timex_cart_chunks&0x08) |
| 1101 | | wh = SMH_BANK12; |
| 1102 | | else |
| 1103 | | wh = SMH_UNMAP; |
| 1104 | | } |
| 1105 | | else |
| 1106 | | { |
| 1107 | | rh = SMH_NOP; |
| 1108 | | wh = SMH_UNMAP; |
| 1109 | | } |
| 1110 | | logerror("6000-7fff Cartridge\n"); |
| 1111 | | } |
| 1112 | | } |
| 1113 | | else |
| 1114 | | { |
| 1115 | | memory_set_bankptr(4, mess_ram + 0x2000); |
| 1116 | | memory_set_bankptr(12, mess_ram + 0x2000); |
| 1117 | | rh = SMH_BANK4; |
| 1118 | | wh = SMH_BANK12; |
| 1119 | | logerror("6000-7fff RAM\n"); |
| 1120 | | } |
| 1121 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, rh); |
| 1122 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, wh); |
| 1123 | | |
| 1124 | | if (ts2068_port_f4_data & 0x10) |
| 1125 | | { |
| 1126 | | if (ts2068_port_ff_data & 0x80) |
| 1127 | | { |
| 1128 | | memory_set_bankptr(5, ExROM); |
| 1129 | | rh = SMH_BANK5; |
| 1130 | | wh = SMH_UNMAP; |
| 1131 | | logerror("8000-9fff EXROM\n"); |
| 1132 | | } |
| 1133 | | else |
| 1134 | | { |
| 1135 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 1136 | | { |
| 1137 | | memory_set_bankptr(5, DOCK+0x8000); |
| 1138 | | rh = SMH_BANK5; |
| 1139 | | if (timex_cart_chunks&0x10) |
| 1140 | | wh = SMH_BANK13; |
| 1141 | | else |
| 1142 | | wh = SMH_UNMAP; |
| 1143 | | } |
| 1144 | | else |
| 1145 | | { |
| 1146 | | rh = SMH_NOP; |
| 1147 | | wh = SMH_UNMAP; |
| 1148 | | } |
| 1149 | | logerror("8000-9fff Cartridge\n"); |
| 1150 | | } |
| 1151 | | } |
| 1152 | | else |
| 1153 | | { |
| 1154 | | memory_set_bankptr(5, mess_ram + 0x4000); |
| 1155 | | memory_set_bankptr(13, mess_ram + 0x4000); |
| 1156 | | rh = SMH_BANK5; |
| 1157 | | wh = SMH_BANK13; |
| 1158 | | logerror("8000-9fff RAM\n"); |
| 1159 | | } |
| 1160 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0,rh); |
| 1161 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0,wh); |
| 1162 | | |
| 1163 | | if (ts2068_port_f4_data & 0x20) |
| 1164 | | { |
| 1165 | | if (ts2068_port_ff_data & 0x80) |
| 1166 | | { |
| 1167 | | memory_set_bankptr(6, ExROM); |
| 1168 | | rh = SMH_BANK6; |
| 1169 | | wh = SMH_UNMAP; |
| 1170 | | logerror("a000-bfff EXROM\n"); |
| 1171 | | } |
| 1172 | | else |
| 1173 | | { |
| 1174 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 1175 | | { |
| 1176 | | memory_set_bankptr(6, DOCK+0xa000); |
| 1177 | | rh = SMH_BANK6; |
| 1178 | | if (timex_cart_chunks&0x20) |
| 1179 | | wh = SMH_BANK14; |
| 1180 | | else |
| 1181 | | wh = SMH_UNMAP; |
| 1182 | | } |
| 1183 | | else |
| 1184 | | { |
| 1185 | | rh = SMH_NOP; |
| 1186 | | wh = SMH_UNMAP; |
| 1187 | | } |
| 1188 | | logerror("a000-bfff Cartridge\n"); |
| 1189 | | } |
| 1190 | | } |
| 1191 | | else |
| 1192 | | { |
| 1193 | | memory_set_bankptr(6, mess_ram + 0x6000); |
| 1194 | | memory_set_bankptr(14, mess_ram + 0x6000); |
| 1195 | | rh = SMH_BANK6; |
| 1196 | | wh = SMH_BANK14; |
| 1197 | | logerror("a000-bfff RAM\n"); |
| 1198 | | } |
| 1199 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, rh); |
| 1200 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, wh); |
| 1201 | | |
| 1202 | | if (ts2068_port_f4_data & 0x40) |
| 1203 | | { |
| 1204 | | if (ts2068_port_ff_data & 0x80) |
| 1205 | | { |
| 1206 | | memory_set_bankptr(7, ExROM); |
| 1207 | | rh = SMH_BANK7; |
| 1208 | | wh = SMH_UNMAP; |
| 1209 | | logerror("c000-dfff EXROM\n"); |
| 1210 | | } |
| 1211 | | else |
| 1212 | | { |
| 1213 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 1214 | | { |
| 1215 | | memory_set_bankptr(7, DOCK+0xc000); |
| 1216 | | rh = SMH_BANK7; |
| 1217 | | if (timex_cart_chunks&0x40) |
| 1218 | | wh = SMH_BANK15; |
| 1219 | | else |
| 1220 | | wh = SMH_UNMAP; |
| 1221 | | } |
| 1222 | | else |
| 1223 | | { |
| 1224 | | rh = SMH_NOP; |
| 1225 | | wh = SMH_UNMAP; |
| 1226 | | } |
| 1227 | | logerror("c000-dfff Cartridge\n"); |
| 1228 | | } |
| 1229 | | } |
| 1230 | | else |
| 1231 | | { |
| 1232 | | memory_set_bankptr(7, mess_ram + 0x8000); |
| 1233 | | memory_set_bankptr(15, mess_ram + 0x8000); |
| 1234 | | rh = SMH_BANK7; |
| 1235 | | wh = SMH_BANK15; |
| 1236 | | logerror("c000-dfff RAM\n"); |
| 1237 | | } |
| 1238 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, rh); |
| 1239 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, wh); |
| 1240 | | |
| 1241 | | if (ts2068_port_f4_data & 0x80) |
| 1242 | | { |
| 1243 | | if (ts2068_port_ff_data & 0x80) |
| 1244 | | { |
| 1245 | | memory_set_bankptr(8, ExROM); |
| 1246 | | rh = SMH_BANK8; |
| 1247 | | wh = SMH_UNMAP; |
| 1248 | | logerror("e000-ffff EXROM\n"); |
| 1249 | | } |
| 1250 | | else |
| 1251 | | { |
| 1252 | | if (timex_cart_type == TIMEX_CART_DOCK) |
| 1253 | | { |
| 1254 | | memory_set_bankptr(8, DOCK+0xe000); |
| 1255 | | rh = SMH_BANK8; |
| 1256 | | if (timex_cart_chunks&0x80) |
| 1257 | | wh = SMH_BANK16; |
| 1258 | | else |
| 1259 | | wh = SMH_UNMAP; |
| 1260 | | } |
| 1261 | | else |
| 1262 | | { |
| 1263 | | rh = SMH_NOP; |
| 1264 | | wh = SMH_UNMAP; |
| 1265 | | } |
| 1266 | | logerror("e000-ffff Cartridge\n"); |
| 1267 | | } |
| 1268 | | } |
| 1269 | | else |
| 1270 | | { |
| 1271 | | memory_set_bankptr(8, mess_ram + 0xa000); |
| 1272 | | memory_set_bankptr(16, mess_ram + 0xa000); |
| 1273 | | rh = SMH_BANK8; |
| 1274 | | wh = SMH_BANK16; |
| 1275 | | logerror("e000-ffff RAM\n"); |
| 1276 | | } |
| 1277 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, rh); |
| 1278 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, wh); |
| 1279 | | } |
| 1280 | | |
| 1281 | | |
| 1282 | | static ADDRESS_MAP_START (ts2068_io, ADDRESS_SPACE_IO, 8) |
| 1283 | | AM_RANGE(0x0000, 0xffff) AM_READWRITE( ts2068_port_r, ts2068_port_w ) |
| 1284 | | ADDRESS_MAP_END |
| 1285 | | |
| 1286 | | static ADDRESS_MAP_START (ts2068_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 1287 | | AM_RANGE(0x0000, 0x1fff) AM_READWRITE( SMH_BANK1, SMH_BANK9 ) |
| 1288 | | AM_RANGE(0x2000, 0x3fff) AM_READWRITE( SMH_BANK2, SMH_BANK10 ) |
| 1289 | | AM_RANGE(0x4000, 0x5fff) AM_READWRITE( SMH_BANK3, SMH_BANK11 ) |
| 1290 | | AM_RANGE(0x6000, 0x7fff) AM_READWRITE( SMH_BANK4, SMH_BANK12 ) |
| 1291 | | AM_RANGE(0x8000, 0x9fff) AM_READWRITE( SMH_BANK5, SMH_BANK13 ) |
| 1292 | | AM_RANGE(0xa000, 0xbfff) AM_READWRITE( SMH_BANK6, SMH_BANK14 ) |
| 1293 | | AM_RANGE(0xc000, 0xdfff) AM_READWRITE( SMH_BANK7, SMH_BANK15 ) |
| 1294 | | AM_RANGE(0xe000, 0xffff) AM_READWRITE( SMH_BANK8, SMH_BANK16 ) |
| 1295 | | ADDRESS_MAP_END |
| 1296 | | |
| 1297 | | |
| 1298 | | static MACHINE_RESET( ts2068 ) |
| 1299 | | { |
| 1300 | | ts2068_port_ff_data = 0; |
| 1301 | | ts2068_port_f4_data = 0; |
| 1302 | | ts2068_update_memory(machine); |
| 1303 | | |
| 1304 | | MACHINE_RESET_CALL(spectrum); |
| 1305 | | } |
| 1306 | | |
| 1307 | | |
| 1308 | | /****************************************************************************************************/ |
| 1309 | | /* TC2048 specific functions */ |
| 1310 | | |
| 1311 | | |
| 1312 | | static void tc2048_port_ff_w(int offset, int data) |
| 1313 | | { |
| 1314 | | ts2068_port_ff_data = data; |
| 1315 | | logerror("Port %04x write %02x\n", offset, data); |
| 1316 | | } |
| 1317 | | |
| 1318 | | static READ8_HANDLER ( tc2048_port_r ) |
| 1319 | | { |
| 1320 | | if ((offset & 1)==0) |
| 1321 | | return spectrum_port_fe_r(machine, offset); |
| 1322 | | switch (offset & 0xff) |
| 1323 | | { |
| 1324 | | case 0xff: return ts2068_port_ff_r(machine, offset); |
| 1325 | | case 0x1f: return spectrum_port_1f_r(machine, offset); |
| 1326 | | case 0x7f: return spectrum_port_7f_r(machine, offset); |
| 1327 | | case 0xdf: return spectrum_port_df_r(machine, offset); |
| 1328 | | } |
| 1329 | | |
| 1330 | | logerror("Read from port: %04x\n", offset); |
| 1331 | | return 0xff; |
| 1332 | | } |
| 1333 | | |
| 1334 | | static WRITE8_HANDLER ( tc2048_port_w ) |
| 1335 | | { |
| 1336 | | if ((offset & 1)==0) |
| 1337 | | spectrum_port_fe_w(machine, offset,data); |
| 1338 | | else if ((offset & 0xff)==0xff) |
| 1339 | | tc2048_port_ff_w(offset, data); |
| 1340 | | else |
| 1341 | | { |
| 1342 | | logerror("Write %02x to Port: %04x\n", data, offset); |
| 1343 | | } |
| 1344 | | } |
| 1345 | | |
| 1346 | | /* ports are not decoded full. |
| 1347 | | The function decodes the ports appropriately */ |
| 1348 | | static ADDRESS_MAP_START (tc2048_io, ADDRESS_SPACE_IO, 8) |
| 1349 | | AM_RANGE(0x0000, 0xffff) AM_READWRITE( tc2048_port_r, tc2048_port_w ) |
| 1350 | | ADDRESS_MAP_END |
| 1351 | | |
| 1352 | | static ADDRESS_MAP_START (tc2048_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 1353 | | AM_RANGE( 0x0000, 0x3fff) AM_ROM |
| 1354 | | AM_RANGE( 0x4000, 0xffff) AM_READWRITE( SMH_BANK1, SMH_BANK2 ) |
| 1355 | | ADDRESS_MAP_END |
| 1356 | | |
| 1357 | | static MACHINE_RESET( tc2048 ) |
| 1358 | | { |
| 1359 | | memory_set_bankptr(1, mess_ram); |
| 1360 | | memory_set_bankptr(2, mess_ram); |
| 1361 | | ts2068_port_ff_data = 0; |
| 1362 | | |
| 1363 | | MACHINE_RESET_CALL(spectrum); |
| 1364 | | } |
| 1365 | | |
| 1366 | | |
| 1367 | | /****************************************************************************************************/ |
| 1368 | | /* BETADISK/TR-DOS disc controller emulation */ |
| 1369 | | /* microcontroller KR1818VG93 is a russian wd179x clone */ |
| 1370 | | #include "machine/wd17xx.h" |
| 1371 | | |
| 1372 | | /* |
| 1373 | | DRQ (D6) and INTRQ (D7). |
| 1374 | | DRQ - signal showing request of data by microcontroller |
| 1375 | | INTRQ - signal of completion of execution of command. |
| 1376 | | */ |
| 1377 | | |
| 1378 | | static int betadisk_status; |
| 1379 | | static int betadisk_active; |
| 1380 | | #ifdef UNUSED_FUNCTION |
| 1381 | | static void (*betadisk_memory_update)(void); |
| 1382 | | |
| 1383 | | static OPBASE_HANDLER(betadisk_opbase_handler) |
| 1384 | | { |
| 1385 | | |
| 1386 | | int pc; |
| 1387 | | |
| 1388 | | pc = activecpu_get_pc(); |
| 1389 | | |
| 1390 | | if ((pc & 0xc000)!=0x0000) |
| 1391 | | { |
| 1392 | | /* outside rom area */ |
| 1393 | | betadisk_active = 0; |
| 1394 | | |
| 1395 | | betadisk_memory_update(); |
| 1396 | | } |
| 1397 | | else |
| 1398 | | { |
| 1399 | | /* inside rom area, switch on betadisk */ |
| 1400 | | // betadisk_active = 1; |
| 1401 | | |
| 1402 | | // betadisk_memory_update(); |
| 1403 | | } |
| 1404 | | |
| 1405 | | |
| 1406 | | return pc & 0x0ffff; |
| 1407 | | } |
| 1408 | | #endif |
| 1409 | | |
| 1410 | | static void betadisk_wd179x_callback(running_machine *machine, wd17xx_state_t state, void *param) |
| 1411 | | { |
| 1412 | | switch (state) |
| 1413 | | { |
| 1414 | | case WD17XX_DRQ_SET: |
| 1415 | | { |
| 1416 | | betadisk_status |= (1<<6); |
| 1417 | | } |
| 1418 | | break; |
| 1419 | | |
| 1420 | | case WD17XX_DRQ_CLR: |
| 1421 | | { |
| 1422 | | betadisk_status &=~(1<<6); |
| 1423 | | } |
| 1424 | | break; |
| 1425 | | |
| 1426 | | case WD17XX_IRQ_SET: |
| 1427 | | { |
| 1428 | | betadisk_status |= (1<<7); |
| 1429 | | } |
| 1430 | | break; |
| 1431 | | |
| 1432 | | case WD17XX_IRQ_CLR: |
| 1433 | | { |
| 1434 | | betadisk_status &=~(1<<7); |
| 1435 | | } |
| 1436 | | break; |
| 1437 | | } |
| 1438 | | } |
| 1439 | | |
| 1440 | | #ifdef UNUSED_FUNCTION |
| 1441 | | /* these are active only when betadisk is enabled */ |
| 1442 | | static WRITE8_HANDLER(betadisk_w) |
| 1443 | | { |
| 1444 | | |
| 1445 | | if (betadisk_active) |
| 1446 | | { |
| 1447 | | |
| 1448 | | } |
| 1449 | | } |
| 1450 | | |
| 1451 | | /* these are active only when betadisk is enabled */ |
| 1452 | | static READ8_HANDLER(betadisk_r) |
| 1453 | | { |
| 1454 | | if (betadisk_active) |
| 1455 | | { |
| 1456 | | /* decoding of these ports might be wrong - to be checked! */ |
| 1457 | | if ((offset & 0x01f)==0x01f) |
| 1458 | | { |
| 1459 | | switch (offset & 0x0ff) |
| 1460 | | { |
| 1461 | | |
| 1462 | | } |
| 1463 | | } |
| 1464 | | |
| 1465 | | } |
| 1466 | | |
| 1467 | | return 0x0ff; |
| 1468 | | } |
| 1469 | | #endif |
| 1470 | | |
| 1471 | | MACHINE_START( scorpion ) |
| 1472 | | { |
| 1473 | | betadisk_active = 0; |
| 1474 | | betadisk_status = 0x03f; |
| 1475 | | wd17xx_init(machine, WD_TYPE_179X, betadisk_wd179x_callback, NULL); |
| 1476 | | } |
| 1477 | | |
| 1478 | | /****************************************************************************************************/ |
| 1479 | | /* Zs Scorpion 256 */ |
| 1480 | | |
| 1481 | | /* |
| 1482 | | port 7ffd. full compatibility with Zx spectrum 128. digits are: |
| 1483 | | |
| 1484 | | D0-D2 - number of RAM page to put in C000-FFFF |
| 1485 | | D3 - switch of address for RAM of screen. 0 - 4000, 1 - c000 |
| 1486 | | D4 - switch of ROM : 0-zx128, 1-zx48 |
| 1487 | | D5 - 1 in this bit will block further output in port 7FFD, until reset. |
| 1488 | | */ |
| 1489 | | |
| 1490 | | /* |
| 1491 | | port 1ffd - additional port for resources of computer. |
| 1492 | | |
| 1493 | | D0 - block of ROM in 0-3fff. when set to 1 - allows read/write page 0 of RAM |
| 1494 | | D1 - selects ROM expansion. this rom contains main part of service monitor. |
| 1495 | | D2 - not used |
| 1496 | | D3 - used for output in RS-232C |
| 1497 | | D4 - extended RAM. set to 1 - connects RAM page with number 8-15 in |
| 1498 | | C000-FFFF. number of page is given in gidits D0-D2 of port 7FFD |
| 1499 | | D5 - signal of strobe for interface centronics. to form the strobe has to be |
| 1500 | | set to 1. |
| 1501 | | D6-D7 - not used. ( yet ? ) |
| 1502 | | */ |
| 1503 | | |
| 1504 | | /* rom 0=zx128, 1=zx48, 2 = service monitor, 3=tr-dos */ |
| 1505 | | |
| 1506 | | static int scorpion_256_port_1ffd_data = 0; |
| 1507 | | |
| 1508 | | static void scorpion_update_memory(running_machine *machine) |
| 1509 | | { |
| 1510 | | unsigned char *ChosenROM; |
| 1511 | | int ROMSelection; |
| 1512 | | read8_machine_func rh; |
| 1513 | | write8_machine_func wh; |
| 1514 | | |
| 1515 | | if (spectrum_128_port_7ffd_data & 8) |
| 1516 | | { |
| 1517 | | logerror("SCREEN 1: BLOCK 7\n"); |
| 1518 | | spectrum_128_screen_location = spectrum_ram + (7<<14); |
| 1519 | | } |
| 1520 | | else |
| 1521 | | { |
| 1522 | | logerror("SCREEN 0: BLOCK 5\n"); |
| 1523 | | spectrum_128_screen_location = spectrum_ram + (5<<14); |
| 1524 | | } |
| 1525 | | |
| 1526 | | /* select ram at 0x0c000-0x0ffff */ |
| 1527 | | { |
| 1528 | | int ram_page; |
| 1529 | | unsigned char *ram_data; |
| 1530 | | |
| 1531 | | ram_page = (spectrum_128_port_7ffd_data & 0x07) | ((scorpion_256_port_1ffd_data & (1<<4))>>1); |
| 1532 | | ram_data = spectrum_ram + (ram_page<<14); |
| 1533 | | |
| 1534 | | memory_set_bankptr(4, ram_data); |
| 1535 | | memory_set_bankptr(8, ram_data); |
| 1536 | | |
| 1537 | | logerror("RAM at 0xc000: %02x\n",ram_page); |
| 1538 | | } |
| 1539 | | |
| 1540 | | if (scorpion_256_port_1ffd_data & (1<<0)) |
| 1541 | | { |
| 1542 | | /* ram at 0x0000 */ |
| 1543 | | logerror("RAM at 0x0000\n"); |
| 1544 | | |
| 1545 | | /* connect page 0 of ram to 0x0000 */ |
| 1546 | | rh = SMH_BANK1; |
| 1547 | | wh = SMH_BANK5; |
| 1548 | | memory_set_bankptr(1, spectrum_ram+(8<<14)); |
| 1549 | | memory_set_bankptr(5, spectrum_ram+(8<<14)); |
| 1550 | | } |
| 1551 | | else |
| 1552 | | { |
| 1553 | | /* rom at 0x0000 */ |
| 1554 | | logerror("ROM at 0x0000\n"); |
| 1555 | | |
| 1556 | | /* connect page 0 of rom to 0x0000 */ |
| 1557 | | rh = SMH_BANK1; |
| 1558 | | wh = SMH_NOP; |
| 1559 | | |
| 1560 | | if (scorpion_256_port_1ffd_data & (1<<1)) |
| 1561 | | { |
| 1562 | | ROMSelection = 2; |
| 1563 | | } |
| 1564 | | else |
| 1565 | | { |
| 1566 | | |
| 1567 | | /* ROM switching */ |
| 1568 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01); |
| 1569 | | } |
| 1570 | | |
| 1571 | | /* rom 0 is 128K rom, rom 1 is 48 BASIC */ |
| 1572 | | ChosenROM = memory_region(REGION_CPU1) + 0x010000 + (ROMSelection<<14); |
| 1573 | | |
| 1574 | | memory_set_bankptr(1, ChosenROM); |
| 1575 | | |
| 1576 | | logerror("rom switch: %02x\n", ROMSelection); |
| 1577 | | } |
| 1578 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, rh); |
| 1579 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, wh); |
| 1580 | | } |
| 1581 | | |
| 1582 | | |
| 1583 | | static WRITE8_HANDLER(scorpion_port_7ffd_w) |
| 1584 | | { |
| 1585 | | logerror("scorpion 7ffd w: %02x\n", data); |
| 1586 | | |
| 1587 | | /* disable paging? */ |
| 1588 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 1589 | | return; |
| 1590 | | |
| 1591 | | /* store new state */ |
| 1592 | | spectrum_128_port_7ffd_data = data; |
| 1593 | | |
| 1594 | | /* update memory */ |
| 1595 | | scorpion_update_memory(machine); |
| 1596 | | } |
| 1597 | | |
| 1598 | | static WRITE8_HANDLER(scorpion_port_1ffd_w) |
| 1599 | | { |
| 1600 | | logerror("scorpion 1ffd w: %02x\n", data); |
| 1601 | | |
| 1602 | | scorpion_256_port_1ffd_data = data; |
| 1603 | | |
| 1604 | | /* disable paging? */ |
| 1605 | | if ((spectrum_128_port_7ffd_data & 0x20)==0) |
| 1606 | | { |
| 1607 | | scorpion_update_memory(machine); |
| 1608 | | } |
| 1609 | | } |
| 1610 | | |
| 1611 | | |
| 1612 | | /* not sure if decoding is full or partial on scorpion */ |
| 1613 | | /* TO BE CHECKED! */ |
| 1614 | | static READ8_HANDLER(scorpion_port_r) |
| 1615 | | { |
| 1616 | | if ((offset & 1)==0) |
| 1617 | | { |
| 1618 | | return spectrum_port_fe_r(machine, offset); |
| 1619 | | } |
| 1620 | | |
| 1621 | | /* KT: the following is not decoded exactly, need to check what |
| 1622 | | is correct */ |
| 1623 | | if ((offset & 2)==0) |
| 1624 | | { |
| 1625 | | switch ((offset>>8) & 0xff) |
| 1626 | | { |
| 1627 | | case 0xff: return spectrum_128_port_fffd_r(machine, offset); |
| 1628 | | case 0x1f: return spectrum_port_1f_r(machine, offset); |
| 1629 | | case 0x7f: return spectrum_port_7f_r(machine, offset); |
| 1630 | | case 0xdf: return spectrum_port_df_r(machine, offset); |
| 1631 | | } |
| 1632 | | } |
| 1633 | | #if 0 |
| 1634 | | switch (offset & 0x0ff) |
| 1635 | | { |
| 1636 | | case 0x01f: |
| 1637 | | return wd17xx_status_r(machine, offset); |
| 1638 | | case 0x03f: |
| 1639 | | return wd17xx_track_r(machine, offset); |
| 1640 | | case 0x05f: |
| 1641 | | return wd17xx_sector_r(machine, offset); |
| 1642 | | case 0x07f: |
| 1643 | | return wd17xx_data_r(machine, offset); |
| 1644 | | case 0x0ff: |
| 1645 | | return betadisk_status; |
| 1646 | | } |
| 1647 | | #endif |
| 1648 | | logerror("Read from scorpion port: %04x\n", offset); |
| 1649 | | |
| 1650 | | return 0xff; |
| 1651 | | } |
| 1652 | | |
| 1653 | | |
| 1654 | | /* not sure if decoding is full or partial on scorpion */ |
| 1655 | | /* TO BE CHECKED! */ |
| 1656 | | static WRITE8_HANDLER(scorpion_port_w) |
| 1657 | | { |
| 1658 | | if ((offset & 1)==0) |
| 1659 | | spectrum_port_fe_w(machine, offset, data); |
| 1660 | | |
| 1661 | | else if ((offset & 2)==0) |
| 1662 | | { |
| 1663 | | switch ((offset>>8) & 0xf0) |
| 1664 | | { |
| 1665 | | case 0x70: |
| 1666 | | scorpion_port_7ffd_w(machine, offset, data); |
| 1667 | | break; |
| 1668 | | case 0xb0: |
| 1669 | | spectrum_128_port_bffd_w(machine, offset, data); |
| 1670 | | break; |
| 1671 | | case 0xf0: |
| 1672 | | spectrum_128_port_fffd_w(machine, offset, data); |
| 1673 | | break; |
| 1674 | | case 0x10: |
| 1675 | | scorpion_port_1ffd_w(machine, offset, data); |
| 1676 | | break; |
| 1677 | | default: |
| 1678 | | logerror("Write %02x to scorpion port: %04x\n", data, offset); |
| 1679 | | } |
| 1680 | | } |
| 1681 | | else |
| 1682 | | { |
| 1683 | | logerror("Write %02x to scorpion port: %04x\n", data, offset); |
| 1684 | | } |
| 1685 | | } |
| 1686 | | |
| 1687 | | |
| 1688 | | |
| 1689 | | /* ports are not decoded full. |
| 1690 | | The function decodes the ports appropriately */ |
| 1691 | | static ADDRESS_MAP_START (scorpion_io, ADDRESS_SPACE_IO, 8) |
| 1692 | | AM_RANGE(0x0000, 0xffff) AM_READWRITE(scorpion_port_r, scorpion_port_w) |
| 1693 | | ADDRESS_MAP_END |
| 1694 | | |
| 1695 | | static MACHINE_RESET( scorpion ) |
| 1696 | | { |
| 1697 | | spectrum_alloc_ram(256); |
| 1698 | | |
| 1699 | | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 1700 | | memory_set_bankptr(2, spectrum_ram + (5<<14)); |
| 1701 | | memory_set_bankptr(6, spectrum_ram + (5<<14)); |
| 1702 | | |
| 1703 | | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 1704 | | memory_set_bankptr(3, spectrum_ram + (2<<14)); |
| 1705 | | memory_set_bankptr(7, spectrum_ram + (2<<14)); |
| 1706 | | |
| 1707 | | spectrum_128_port_7ffd_data = 0; |
| 1708 | | scorpion_256_port_1ffd_data = 0; |
| 1709 | | |
| 1710 | | scorpion_update_memory(machine); |
| 1711 | | } |
| 1712 | | |
| 1713 | | /****************************************************************************************************/ |
| 1714 | | /* pentagon */ |
| 1715 | | |
| 1716 | | static READ8_HANDLER(pentagon_port_r) |
| 1717 | | { |
| 1718 | | return 0x0ff; |
| 1719 | | } |
| 1720 | | |
| 1721 | | |
| 1722 | | static WRITE8_HANDLER(pentagon_port_w) |
| 1723 | | { |
| 1724 | | } |
| 1725 | | |
| 1726 | | |
| 1727 | | |
| 1728 | | /* ports are not decoded full. |
| 1729 | | The function decodes the ports appropriately */ |
| 1730 | | static ADDRESS_MAP_START (pentagon_io, ADDRESS_SPACE_IO, 8) |
| 1731 | | AM_RANGE(0x0000, 0xffff) AM_READWRITE( pentagon_port_r, pentagon_port_w ) |
| 1732 | | ADDRESS_MAP_END |
| 1733 | | |
| 1734 | | static MACHINE_RESET( pentagon ) |
| 1735 | | { |
| 1736 | | spectrum_alloc_ram(128); |
| 1737 | | |
| 1738 | | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 1739 | | memory_set_bankptr(2, spectrum_ram + (5<<14)); |
| 1740 | | memory_set_bankptr(6, spectrum_ram + (5<<14)); |
| 1741 | | |
| 1742 | | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 1743 | | memory_set_bankptr(3, spectrum_ram + (2<<14)); |
| 1744 | | memory_set_bankptr(7, spectrum_ram + (2<<14)); |
| 1745 | | } |
| 1746 | | |
| 1747 | | /****************************************************************************************************/ |
| 1748 | | |
| 1749 | | static const gfx_layout spectrum_charlayout = |
| 1750 | | { |
| 1751 | | 8,8, |
| 1752 | | 256, |
| 1753 | | 1, /* 1 bits per pixel */ |
| 1754 | | |
| 1755 | | { 0 }, /* no bitplanes; 1 bit per pixel */ |
| 1756 | | |
| 1757 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 1758 | | { 0, 8*256, 16*256, 24*256, 32*256, 40*256, 48*256, 56*256 }, |
| 1759 | | |
| 1760 | | 8 /* every char takes 1 consecutive byte */ |
| 1761 | | }; |
| 1762 | | |
| 1763 | 327 | static GFXDECODE_START( spectrum ) |
| 1764 | 328 | GFXDECODE_ENTRY( 0, 0x0, spectrum_charlayout, 0, 0x80 ) |
| 1765 | 329 | GFXDECODE_ENTRY( 0, 0x0, spectrum_charlayout, 0, 0x80 ) |
| 1766 | 330 | GFXDECODE_ENTRY( 0, 0x0, spectrum_charlayout, 0, 0x80 ) |
| 1767 | 331 | GFXDECODE_END |
| 1768 | 332 | |
| 1769 | | static INPUT_PORTS_START( spectrum ) |
| 333 | INPUT_PORTS_START( spectrum ) |
| 1770 | 334 | PORT_START_TAG("LINE0") /* [0] 0xFEFE */ |
| 1771 | 335 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CAPS SHIFT") PORT_CODE(KEYCODE_LSHIFT) |
| 1772 | 336 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z COPY : LN BEEP") PORT_CODE(KEYCODE_Z) |
| r2516 | r2517 | |
| 1892 | 456 | PORT_BIT(0x1f, IP_ACTIVE_LOW, IPT_UNUSED) |
| 1893 | 457 | INPUT_PORTS_END |
| 1894 | 458 | |
| 1895 | | #define ZX_COL_0 MAKE_RGB(0x00, 0x00, 0x00) |
| 1896 | | #define ZX_COL_1 MAKE_RGB(0x00, 0x00, 0xbf) |
| 1897 | | #define ZX_COL_2 MAKE_RGB(0xbf, 0x00, 0x00) |
| 1898 | | #define ZX_COL_3 MAKE_RGB(0xbf, 0x00, 0xbf) |
| 1899 | | #define ZX_COL_4 MAKE_RGB(0x00, 0xbf, 0x00) |
| 1900 | | #define ZX_COL_5 MAKE_RGB(0x00, 0xbf, 0xbf) |
| 1901 | | #define ZX_COL_6 MAKE_RGB(0xbf, 0xbf, 0x00) |
| 1902 | | #define ZX_COL_7 MAKE_RGB(0xbf, 0xbf, 0xbf) |
| 1903 | | #define ZX_COL_8 MAKE_RGB(0x00, 0x00, 0x00) |
| 1904 | | #define ZX_COL_9 MAKE_RGB(0x00, 0x00, 0xff) |
| 1905 | | #define ZX_COL_A MAKE_RGB(0xff, 0x00, 0x00) |
| 1906 | | #define ZX_COL_B MAKE_RGB(0xff, 0x00, 0xff) |
| 1907 | | #define ZX_COL_C MAKE_RGB(0x00, 0xff, 0x00) |
| 1908 | | #define ZX_COL_D MAKE_RGB(0x00, 0xff, 0xff) |
| 1909 | | #define ZX_COL_E MAKE_RGB(0xff, 0xff, 0x00) |
| 1910 | | #define ZX_COL_F MAKE_RGB(0xff, 0xff, 0xff) |
| 1911 | 459 | |
| 1912 | | const rgb_t spectrum_palette[256 + 16] = { |
| 1913 | | ZX_COL_0,ZX_COL_1,ZX_COL_2,ZX_COL_3,ZX_COL_4,ZX_COL_5,ZX_COL_6,ZX_COL_7,ZX_COL_8,ZX_COL_9,ZX_COL_A,ZX_COL_B,ZX_COL_C,ZX_COL_D,ZX_COL_E,ZX_COL_F, |
| 1914 | | |
| 1915 | | ZX_COL_0,ZX_COL_0,ZX_COL_0,ZX_COL_1,ZX_COL_0,ZX_COL_2,ZX_COL_0,ZX_COL_3,ZX_COL_0,ZX_COL_4,ZX_COL_0,ZX_COL_5,ZX_COL_0,ZX_COL_6,ZX_COL_0,ZX_COL_7, |
| 1916 | | ZX_COL_1,ZX_COL_0,ZX_COL_1,ZX_COL_1,ZX_COL_1,ZX_COL_2,ZX_COL_1,ZX_COL_3,ZX_COL_1,ZX_COL_4,ZX_COL_1,ZX_COL_5,ZX_COL_1,ZX_COL_6,ZX_COL_1,ZX_COL_7, |
| 1917 | | ZX_COL_2,ZX_COL_0,ZX_COL_2,ZX_COL_1,ZX_COL_2,ZX_COL_2,ZX_COL_2,ZX_COL_3,ZX_COL_2,ZX_COL_4,ZX_COL_2,ZX_COL_5,ZX_COL_2,ZX_COL_6,ZX_COL_2,ZX_COL_7, |
| 1918 | | ZX_COL_3,ZX_COL_0,ZX_COL_3,ZX_COL_1,ZX_COL_3,ZX_COL_2,ZX_COL_3,ZX_COL_3,ZX_COL_3,ZX_COL_4,ZX_COL_3,ZX_COL_5,ZX_COL_3,ZX_COL_6,ZX_COL_3,ZX_COL_7, |
| 1919 | | ZX_COL_4,ZX_COL_0,ZX_COL_4,ZX_COL_1,ZX_COL_4,ZX_COL_2,ZX_COL_4,ZX_COL_3,ZX_COL_4,ZX_COL_4,ZX_COL_4,ZX_COL_5,ZX_COL_4,ZX_COL_6,ZX_COL_4,ZX_COL_7, |
| 1920 | | ZX_COL_5,ZX_COL_0,ZX_COL_5,ZX_COL_1,ZX_COL_5,ZX_COL_2,ZX_COL_5,ZX_COL_3,ZX_COL_5,ZX_COL_4,ZX_COL_5,ZX_COL_5,ZX_COL_5,ZX_COL_6,ZX_COL_5,ZX_COL_7, |
| 1921 | | ZX_COL_6,ZX_COL_0,ZX_COL_6,ZX_COL_1,ZX_COL_6,ZX_COL_2,ZX_COL_6,ZX_COL_3,ZX_COL_6,ZX_COL_4,ZX_COL_6,ZX_COL_5,ZX_COL_6,ZX_COL_6,ZX_COL_6,ZX_COL_7, |
| 1922 | | ZX_COL_7,ZX_COL_0,ZX_COL_7,ZX_COL_1,ZX_COL_7,ZX_COL_2,ZX_COL_7,ZX_COL_3,ZX_COL_7,ZX_COL_4,ZX_COL_7,ZX_COL_5,ZX_COL_7,ZX_COL_6,ZX_COL_7,ZX_COL_7, |
| 1923 | | ZX_COL_8,ZX_COL_8,ZX_COL_8,ZX_COL_9,ZX_COL_8,ZX_COL_A,ZX_COL_8,ZX_COL_B,ZX_COL_8,ZX_COL_C,ZX_COL_8,ZX_COL_D,ZX_COL_8,ZX_COL_E,ZX_COL_8,ZX_COL_F, |
| 1924 | | ZX_COL_9,ZX_COL_8,ZX_COL_9,ZX_COL_9,ZX_COL_9,ZX_COL_A,ZX_COL_9,ZX_COL_B,ZX_COL_9,ZX_COL_C,ZX_COL_9,ZX_COL_D,ZX_COL_9,ZX_COL_E,ZX_COL_9,ZX_COL_F, |
| 1925 | | ZX_COL_A,ZX_COL_8,ZX_COL_A,ZX_COL_9,ZX_COL_A,ZX_COL_A,ZX_COL_A,ZX_COL_B,ZX_COL_A,ZX_COL_C,ZX_COL_A,ZX_COL_D,ZX_COL_A,ZX_COL_E,ZX_COL_A,ZX_COL_F, |
| 1926 | | ZX_COL_B,ZX_COL_8,ZX_COL_B,ZX_COL_9,ZX_COL_B,ZX_COL_A,ZX_COL_B,ZX_COL_B,ZX_COL_B,ZX_COL_C,ZX_COL_B,ZX_COL_D,ZX_COL_B,ZX_COL_E,ZX_COL_B,ZX_COL_F, |
| 1927 | | ZX_COL_C,ZX_COL_8,ZX_COL_C,ZX_COL_9,ZX_COL_C,ZX_COL_A,ZX_COL_C,ZX_COL_B,ZX_COL_C,ZX_COL_C,ZX_COL_C,ZX_COL_D,ZX_COL_C,ZX_COL_E,ZX_COL_C,ZX_COL_F, |
| 1928 | | ZX_COL_D,ZX_COL_8,ZX_COL_D,ZX_COL_9,ZX_COL_D,ZX_COL_A,ZX_COL_D,ZX_COL_B,ZX_COL_D,ZX_COL_C,ZX_COL_D,ZX_COL_D,ZX_COL_D,ZX_COL_E,ZX_COL_D,ZX_COL_F, |
| 1929 | | ZX_COL_E,ZX_COL_8,ZX_COL_E,ZX_COL_9,ZX_COL_E,ZX_COL_A,ZX_COL_E,ZX_COL_B,ZX_COL_E,ZX_COL_C,ZX_COL_E,ZX_COL_D,ZX_COL_E,ZX_COL_E,ZX_COL_E,ZX_COL_F, |
| 1930 | | ZX_COL_F,ZX_COL_8,ZX_COL_F,ZX_COL_9,ZX_COL_F,ZX_COL_A,ZX_COL_F,ZX_COL_B,ZX_COL_F,ZX_COL_C,ZX_COL_F,ZX_COL_D,ZX_COL_F,ZX_COL_E,ZX_COL_F,ZX_COL_F |
| 1931 | | }; |
| 1932 | | |
| 1933 | | const rgb_t spectrum_128_palette[16] = { |
| 1934 | | ZX_COL_0,ZX_COL_1,ZX_COL_2,ZX_COL_3,ZX_COL_4,ZX_COL_5,ZX_COL_6,ZX_COL_7,ZX_COL_8,ZX_COL_9,ZX_COL_A,ZX_COL_B,ZX_COL_C,ZX_COL_D,ZX_COL_E,ZX_COL_F |
| 1935 | | }; |
| 1936 | | |
| 1937 | | /* Initialise the palette */ |
| 1938 | | static PALETTE_INIT( spectrum ) |
| 1939 | | { |
| 1940 | | palette_set_colors(machine, 0, spectrum_palette, ARRAY_LENGTH(spectrum_palette)); |
| 1941 | | } |
| 1942 | | |
| 1943 | | static PALETTE_INIT( spectrum_128 ) |
| 1944 | | { |
| 1945 | | palette_set_colors(machine, 0, spectrum_128_palette, ARRAY_LENGTH(spectrum_128_palette)); |
| 1946 | | } |
| 1947 | | |
| 1948 | 460 | static INTERRUPT_GEN( spec_interrupt ) |
| 1949 | 461 | { |
| 1950 | 462 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 1951 | 463 | } |
| 1952 | 464 | |
| 1953 | | |
| 1954 | | |
| 1955 | | static MACHINE_DRIVER_START( spectrum ) |
| 465 | MACHINE_DRIVER_START( spectrum ) |
| 1956 | 466 | /* basic machine hardware */ |
| 1957 | 467 | MDRV_CPU_ADD_TAG("main", Z80, 3500000) /* 3.5 Mhz */ |
| 1958 | 468 | MDRV_CPU_PROGRAM_MAP(spectrum_mem, 0) |
| r2516 | r2517 | |
| 1990 | 500 | MACHINE_DRIVER_END |
| 1991 | 501 | |
| 1992 | 502 | |
| 1993 | | static MACHINE_DRIVER_START( spectrum_128 ) |
| 1994 | | MDRV_IMPORT_FROM( spectrum ) |
| 1995 | | |
| 1996 | | MDRV_CPU_REPLACE("main", Z80, 3500000) /* 3.5 Mhz */ |
| 1997 | | MDRV_CPU_PROGRAM_MAP(spectrum_128_mem, 0) |
| 1998 | | MDRV_CPU_IO_MAP(spectrum_128_io, 0) |
| 1999 | | |
| 2000 | | MDRV_MACHINE_RESET( spectrum_128 ) |
| 2001 | | |
| 2002 | | /* video hardware */ |
| 2003 | | MDRV_SCREEN_MODIFY("main") |
| 2004 | | MDRV_PALETTE_LENGTH(16) |
| 2005 | | MDRV_PALETTE_INIT( spectrum_128 ) |
| 2006 | | MDRV_SCREEN_REFRESH_RATE(50.021) |
| 2007 | | MDRV_VIDEO_START( spectrum_128 ) |
| 2008 | | MDRV_VIDEO_UPDATE( spectrum_128 ) |
| 2009 | | |
| 2010 | | /* sound hardware */ |
| 2011 | | MDRV_SOUND_ADD(AY8912, 1773400) |
| 2012 | | MDRV_SOUND_CONFIG(spectrum_ay_interface) |
| 2013 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 2014 | | MACHINE_DRIVER_END |
| 2015 | | |
| 2016 | | |
| 2017 | | static MACHINE_DRIVER_START( spectrum_plus3 ) |
| 2018 | | MDRV_IMPORT_FROM( spectrum_128 ) |
| 2019 | | MDRV_CPU_MODIFY("main") |
| 2020 | | MDRV_CPU_IO_MAP(spectrum_plus3_io, 0) |
| 2021 | | MDRV_SCREEN_MODIFY("main") |
| 2022 | | MDRV_SCREEN_REFRESH_RATE(50.01) |
| 2023 | | |
| 2024 | | MDRV_MACHINE_RESET( spectrum_plus3 ) |
| 2025 | | MACHINE_DRIVER_END |
| 2026 | | |
| 2027 | | |
| 2028 | | static MACHINE_DRIVER_START( ts2068 ) |
| 2029 | | MDRV_IMPORT_FROM( spectrum_128 ) |
| 2030 | | MDRV_CPU_REPLACE("main", Z80, 3580000) /* 3.58 Mhz */ |
| 2031 | | MDRV_CPU_PROGRAM_MAP(ts2068_mem, 0) |
| 2032 | | MDRV_CPU_IO_MAP(ts2068_io, 0) |
| 2033 | | |
| 2034 | | MDRV_MACHINE_RESET( ts2068 ) |
| 2035 | | |
| 2036 | | /* video hardware */ |
| 2037 | | MDRV_SCREEN_MODIFY("main") |
| 2038 | | MDRV_SCREEN_REFRESH_RATE(60) |
| 2039 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 2040 | | MDRV_SCREEN_SIZE(TS2068_SCREEN_WIDTH, TS2068_SCREEN_HEIGHT) |
| 2041 | | MDRV_SCREEN_VISIBLE_AREA(0, TS2068_SCREEN_WIDTH-1, 0, TS2068_SCREEN_HEIGHT-1) |
| 2042 | | |
| 2043 | | MDRV_VIDEO_UPDATE( ts2068 ) |
| 2044 | | MDRV_VIDEO_EOF( ts2068 ) |
| 2045 | | MACHINE_DRIVER_END |
| 2046 | | |
| 2047 | | |
| 2048 | | static MACHINE_DRIVER_START( uk2086 ) |
| 2049 | | MDRV_IMPORT_FROM( ts2068 ) |
| 2050 | | MDRV_SCREEN_MODIFY("main") |
| 2051 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 2052 | | MACHINE_DRIVER_END |
| 2053 | | |
| 2054 | | |
| 2055 | | static MACHINE_DRIVER_START( tc2048 ) |
| 2056 | | MDRV_IMPORT_FROM( spectrum ) |
| 2057 | | MDRV_CPU_MODIFY("main") |
| 2058 | | MDRV_CPU_PROGRAM_MAP(tc2048_mem, 0) |
| 2059 | | MDRV_CPU_IO_MAP(tc2048_io, 0) |
| 2060 | | |
| 2061 | | MDRV_SCREEN_MODIFY("main") |
| 2062 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 2063 | | |
| 2064 | | MDRV_MACHINE_RESET( tc2048 ) |
| 2065 | | |
| 2066 | | /* video hardware */ |
| 2067 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 2068 | | MDRV_SCREEN_SIZE(TS2068_SCREEN_WIDTH, SPEC_SCREEN_HEIGHT) |
| 2069 | | MDRV_SCREEN_VISIBLE_AREA(0, TS2068_SCREEN_WIDTH-1, 0, SPEC_SCREEN_HEIGHT-1) |
| 2070 | | |
| 2071 | | MDRV_VIDEO_START( spectrum_128 ) |
| 2072 | | MDRV_VIDEO_UPDATE( tc2048 ) |
| 2073 | | MACHINE_DRIVER_END |
| 2074 | | |
| 2075 | | |
| 2076 | | static MACHINE_DRIVER_START( scorpion ) |
| 2077 | | MDRV_IMPORT_FROM( spectrum_128 ) |
| 2078 | | MDRV_CPU_MODIFY("main") |
| 2079 | | MDRV_CPU_IO_MAP(scorpion_io, 0) |
| 2080 | | MDRV_MACHINE_START( scorpion ) |
| 2081 | | MDRV_MACHINE_RESET( scorpion ) |
| 2082 | | MACHINE_DRIVER_END |
| 2083 | | |
| 2084 | | |
| 2085 | | static MACHINE_DRIVER_START( pentagon ) |
| 2086 | | MDRV_IMPORT_FROM( spectrum_128 ) |
| 2087 | | MDRV_CPU_MODIFY("main") |
| 2088 | | MDRV_CPU_IO_MAP(pentagon_io, 0) |
| 2089 | | MDRV_MACHINE_START( scorpion ) |
| 2090 | | MDRV_MACHINE_RESET( pentagon ) |
| 2091 | | MACHINE_DRIVER_END |
| 2092 | | |
| 2093 | | |
| 2094 | 503 | /*************************************************************************** |
| 2095 | 504 | |
| 2096 | 505 | Game driver(s) |
| r2516 | r2517 | |
| 2133 | 542 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2134 | 543 | ROM_END |
| 2135 | 544 | |
| 2136 | | ROM_START(spec128) |
| 2137 | | ROM_REGION(0x18000,REGION_CPU1,0) |
| 2138 | | ROM_LOAD("zx128_0.rom",0x10000,0x4000, CRC(e76799d2) SHA1(4f4b11ec22326280bdb96e3baf9db4b4cb1d02c5)) |
| 2139 | | ROM_LOAD("zx128_1.rom",0x14000,0x4000, CRC(b96a36be) SHA1(80080644289ed93d71a1103992a154cc9802b2fa)) |
| 2140 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2141 | | ROM_END |
| 2142 | 545 | |
| 2143 | | ROM_START(spec128s) |
| 2144 | | ROM_REGION(0x18000,REGION_CPU1,0) |
| 2145 | | ROM_LOAD("zx128s0.rom",0x10000,0x4000, CRC(453d86b2) SHA1(968937b1c750f0ef6205f01c6db4148da4cca4e3)) |
| 2146 | | ROM_LOAD("zx128s1.rom",0x14000,0x4000, CRC(6010e796) SHA1(bea3f397cc705eafee995ea629f4a82550562f90)) |
| 2147 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2148 | | ROM_END |
| 2149 | | |
| 2150 | | ROM_START(specpls2) |
| 2151 | | ROM_REGION(0x18000,REGION_CPU1,0) |
| 2152 | | ROM_LOAD("zxp2_0.rom",0x10000,0x4000, CRC(5d2e8c66) SHA1(72703f9a3e734f3c23ec34c0727aae4ccbef9a91)) |
| 2153 | | ROM_LOAD("zxp2_1.rom",0x14000,0x4000, CRC(98b1320b) SHA1(de8b0d2d0379cfe7c39322a086ca6da68c7f23cb)) |
| 2154 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2155 | | ROM_END |
| 2156 | | |
| 2157 | | ROM_START(specpl2a) |
| 2158 | | ROM_REGION(0x20000,REGION_CPU1,0) |
| 2159 | | ROM_LOAD("p2a41_0.rom",0x10000,0x4000, CRC(30c9f490) SHA1(62ec15a4af56cd1d206d0bd7011eac7c889a595d)) |
| 2160 | | ROM_LOAD("p2a41_1.rom",0x14000,0x4000, CRC(a7916b3f) SHA1(1a7812c383a3701e90e88d1da086efb0c033ac72)) |
| 2161 | | ROM_LOAD("p2a41_2.rom",0x18000,0x4000, CRC(c9a0b748) SHA1(8df145d10ff78f98138682ea15ebccb2874bf759)) |
| 2162 | | ROM_LOAD("p2a41_3.rom",0x1c000,0x4000, CRC(b88fd6e3) SHA1(be365f331942ec7ec35456b641dac56a0dbfe1f0)) |
| 2163 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2164 | | ROM_END |
| 2165 | | |
| 2166 | | ROM_START(specpls3) |
| 2167 | | ROM_REGION(0x20000,REGION_CPU1,0) |
| 2168 | | ROM_LOAD("pl3-0.rom",0x10000,0x4000, CRC(17373da2) SHA1(e319ed08b4d53a5e421a75ea00ea02039ba6555b)) |
| 2169 | | ROM_LOAD("pl3-1.rom",0x14000,0x4000, CRC(f1d1d99e) SHA1(c9969fc36095a59787554026a9adc3b87678c794)) |
| 2170 | | ROM_LOAD("pl3-2.rom",0x18000,0x4000, CRC(3dbf351d) SHA1(22e50c6ba4157a3f6a821bd9937cd26e292775c6)) |
| 2171 | | ROM_LOAD("pl3-3.rom",0x1c000,0x4000, CRC(04448eaa) SHA1(65f031caa8148a5493afe42c41f4929deab26b4e)) |
| 2172 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2173 | | ROM_END |
| 2174 | | |
| 2175 | 546 | ROM_START(specpls4) |
| 2176 | 547 | ROM_REGION(0x10000,REGION_CPU1,0) |
| 2177 | 548 | ROM_LOAD("plus4.rom",0x0000,0x4000, CRC(7e0f47cb) SHA1(c103e89ef58e6ade0c01cea0247b332623bd9a30)) |
| r2516 | r2517 | |
| 2196 | 567 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2197 | 568 | ROM_END |
| 2198 | 569 | |
| 2199 | | ROM_START(tc2048) |
| 2200 | | ROM_REGION(0x10000,REGION_CPU1,0) |
| 2201 | | ROM_LOAD("tc2048.rom",0x0000,0x4000, CRC(f1b5fa67) SHA1(febb2d495b6eda7cdcb4074935d6e9d9f328972d)) |
| 2202 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2203 | | ROM_END |
| 2204 | 570 | |
| 2205 | | ROM_START(ts2068) |
| 2206 | | ROM_REGION(0x16000,REGION_CPU1,0) |
| 2207 | | ROM_LOAD("ts2068_h.rom",0x10000,0x4000, CRC(bf44ec3f) SHA1(1446cb2780a9dedf640404a639fa3ae518b2d8aa)) |
| 2208 | | ROM_LOAD("ts2068_x.rom",0x14000,0x2000, CRC(ae16233a) SHA1(7e265a2c1f621ed365ea23bdcafdedbc79c1299c)) |
| 2209 | | ROM_END |
| 2210 | | |
| 2211 | | ROM_START(uk2086) |
| 2212 | | ROM_REGION(0x16000,REGION_CPU1,0) |
| 2213 | | ROM_LOAD("uk2086_h.rom",0x10000,0x4000, CRC(5ddc0ca2) SHA1(1d525fe5cdc82ab46767f665ad735eb5363f1f51)) |
| 2214 | | ROM_LOAD("ts2068_x.rom",0x14000,0x2000, CRC(ae16233a) SHA1(7e265a2c1f621ed365ea23bdcafdedbc79c1299c)) |
| 2215 | | ROM_END |
| 2216 | | |
| 2217 | | ROM_START(specp2fr) |
| 2218 | | ROM_REGION(0x18000,REGION_CPU1,0) |
| 2219 | | ROM_LOAD("plus2fr0.rom",0x10000,0x4000, CRC(c684c535) SHA1(56684c4c85a616e726a50707483b9a42d8e724ed)) |
| 2220 | | ROM_LOAD("plus2fr1.rom",0x14000,0x4000, CRC(f5e509c5) SHA1(7e398f62689c9d90a36d3a101351ec9987207308)) |
| 2221 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2222 | | ROM_END |
| 2223 | | |
| 2224 | | ROM_START(specp2sp) |
| 2225 | | ROM_REGION(0x18000,REGION_CPU1,0) |
| 2226 | | ROM_LOAD("plus2sp0.rom",0x10000,0x4000, CRC(e807d06e) SHA1(8259241b28ff85441f1bedc2bee53445767c51c5)) |
| 2227 | | ROM_LOAD("plus2sp1.rom",0x14000,0x4000, CRC(41981d4b) SHA1(ec0d5a158842d20601b4fbeaefc6668db979d0e1)) |
| 2228 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2229 | | ROM_END |
| 2230 | | |
| 2231 | | ROM_START(specp3sp) |
| 2232 | | ROM_REGION(0x20000,REGION_CPU1,0) |
| 2233 | | ROM_LOAD("plus3sp0.rom",0x10000,0x4000, CRC(1f86147a) SHA1(e9b0a60a1a8def511d59090b945d175bdc646346)) |
| 2234 | | ROM_LOAD("plus3sp1.rom",0x14000,0x4000, CRC(a8ac4966) SHA1(4e48f196427596c7990c175d135c15a039c274a4)) |
| 2235 | | ROM_LOAD("plus3sp2.rom",0x18000,0x4000, CRC(f6bb0296) SHA1(09fc005625589ef5992515957ce7a3167dec24b2)) |
| 2236 | | ROM_LOAD("plus3sp3.rom",0x1c000,0x4000, CRC(f6d25389) SHA1(ec8f644a81e2e9bcb58ace974103ea960361bad2)) |
| 2237 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2238 | | ROM_END |
| 2239 | | |
| 2240 | | ROM_START(specpl3e) |
| 2241 | | ROM_REGION(0x20000,REGION_CPU1,0) |
| 2242 | | ROM_LOAD("roma-en.rom",0x10000,0x8000, CRC(2d533344) SHA1(5ff2dae32eb745d87e0b54c595d1d20a866f316f)) |
| 2243 | | ROM_LOAD("romb-en.rom",0x18000,0x8000, CRC(ef8d5d92) SHA1(983aa53aa76e25a3af123c896016bacf6829b72b)) |
| 2244 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2245 | | ROM_END |
| 2246 | | |
| 2247 | | ROM_START(specp3es) |
| 2248 | | ROM_REGION(0x20000,REGION_CPU1,0) |
| 2249 | | ROM_LOAD("roma-es.rom",0x10000,0x8000, CRC(ba694b4b) SHA1(d15d9e43950483cffc79f1cfa89ecb114a88f6c2)) |
| 2250 | | ROM_LOAD("romb-es.rom",0x18000,0x8000, CRC(61ed94db) SHA1(935b14c13db75d872de8ad0d591aade0adbbc355)) |
| 2251 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2252 | | ROM_END |
| 2253 | | |
| 2254 | | ROM_START(scorpion) |
| 2255 | | ROM_REGION(0x020000, REGION_CPU1, 0) |
| 2256 | | ROM_LOAD("scorp0.rom",0x010000, 0x4000, CRC(0eb40a09)) |
| 2257 | | ROM_LOAD("scorp1.rom",0x014000, 0x4000, CRC(9d513013)) |
| 2258 | | ROM_LOAD("scorp2.rom",0x018000, 0x4000, CRC(fd0d3ce1)) |
| 2259 | | ROM_LOAD("scorp3.rom",0x01c000, 0x4000, CRC(1fe1d003)) |
| 2260 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2261 | | ROM_END |
| 2262 | | |
| 2263 | | ROM_START(pentagon) |
| 2264 | | ROM_REGION(0x020000, REGION_CPU1, 0) |
| 2265 | | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 2266 | | ROM_END |
| 2267 | | |
| 2268 | 571 | static void spectrum_common_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 2269 | 572 | { |
| 2270 | 573 | /* cassette */ |
| r2516 | r2517 | |
| 2287 | 590 | CONFIG_DEVICE(cartslot_device_getinfo) |
| 2288 | 591 | SYSTEM_CONFIG_END |
| 2289 | 592 | |
| 2290 | | static void specpls3_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 2291 | | { |
| 2292 | | /* floppy */ |
| 2293 | | switch(state) |
| 2294 | | { |
| 2295 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2296 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 2297 | | |
| 2298 | | default: legacydsk_device_getinfo(devclass, state, info); break; |
| 2299 | | } |
| 2300 | | } |
| 2301 | | |
| 2302 | | SYSTEM_CONFIG_START(specpls3) |
| 2303 | | CONFIG_IMPORT_FROM(spectrum_common) |
| 2304 | | CONFIG_DEVICE(specpls3_floppy_getinfo) |
| 2305 | | SYSTEM_CONFIG_END |
| 2306 | | |
| 2307 | | static void ts2068_cartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 2308 | | { |
| 2309 | | /* cartslot */ |
| 2310 | | switch(state) |
| 2311 | | { |
| 2312 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2313 | | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 2314 | | |
| 2315 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2316 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(timex_cart); break; |
| 2317 | | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(timex_cart); break; |
| 2318 | | |
| 2319 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2320 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dck"); break; |
| 2321 | | |
| 2322 | | default: cartslot_device_getinfo(devclass, state, info); break; |
| 2323 | | } |
| 2324 | | } |
| 2325 | | |
| 2326 | | SYSTEM_CONFIG_START(ts2068) |
| 2327 | | CONFIG_IMPORT_FROM(spectrum_common) |
| 2328 | | CONFIG_DEVICE(ts2068_cartslot_getinfo) |
| 2329 | | CONFIG_RAM_DEFAULT(48 * 1024) |
| 2330 | | SYSTEM_CONFIG_END |
| 2331 | | |
| 2332 | | SYSTEM_CONFIG_START(tc2048) |
| 2333 | | CONFIG_IMPORT_FROM(spectrum) |
| 2334 | | CONFIG_RAM_DEFAULT(48 * 1024) |
| 2335 | | SYSTEM_CONFIG_END |
| 2336 | | |
| 2337 | 593 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 2338 | 594 | COMP( 1982, spectrum, 0, 0, spectrum, spectrum, 0, spectrum, "Sinclair Research", "ZX Spectrum" , 0) |
| 2339 | 595 | COMP( 2000, specpls4, spectrum, 0, spectrum, spectrum, 0, spectrum, "Sinclair Research", "ZX Spectrum +4", GAME_COMPUTER_MODIFIED ) |
| r2516 | r2517 | |
| 2345 | 601 | COMP( 1986, inves, spectrum, 0, spectrum, spectrum, 0, spectrum, "Investronica", "Inves Spectrum 48K+" , 0) |
| 2346 | 602 | COMP( 1985, tk90x, spectrum, 0, spectrum, spectrum, 0, spectrum, "Micro Digital", "TK-90x Color Computer" , 0) |
| 2347 | 603 | COMP( 1986, tk95, spectrum, 0, spectrum, spectrum, 0, spectrum, "Micro Digital", "TK-95 Color Computer" , 0) |
| 2348 | | COMP( 1984, tc2048, spectrum, 0, tc2048, spectrum, 0, tc2048, "Timex of Portugal", "TC-2048" , 0) |
| 2349 | | COMP( 1983, ts2068, spectrum, 0, ts2068, spectrum, 0, ts2068, "Timex Sinclair", "TS-2068" , 0) |
| 2350 | | COMP( 1986, uk2086, spectrum, 0, uk2086, spectrum, 0, ts2068, "Unipolbrit", "UK-2086 ver. 1.2" , 0) |
| 2351 | | |
| 2352 | | COMP( 1986, spec128, 0, 0, spectrum_128, spectrum, 0, spectrum, "Sinclair Research", "ZX Spectrum 128" , 0 ) |
| 2353 | | COMP( 1985, spec128s, spec128, 0, spectrum_128, spectrum, 0, spectrum, "Sinclair Research", "ZX Spectrum 128 (Spain)" , 0 ) |
| 2354 | | COMP( 1986, specpls2, spec128, 0, spectrum_128, spectrum, 0, spectrum, "Amstrad plc", "ZX Spectrum +2" , 0 ) |
| 2355 | | COMP( 1987, specpl2a, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +2a" , 0 ) |
| 2356 | | COMP( 1987, specpls3, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3" , 0 ) |
| 2357 | | |
| 2358 | | COMP( 1986, specp2fr, spec128, 0, spectrum_128, spectrum, 0, spectrum, "Amstrad plc", "ZX Spectrum +2 (France)" , 0 ) |
| 2359 | | COMP( 1986, specp2sp, spec128, 0, spectrum_128, spectrum, 0, spectrum, "Amstrad plc", "ZX Spectrum +2 (Spain)" , 0 ) |
| 2360 | | COMP( 1987, specp3sp, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3 (Spain)" , 0 ) |
| 2361 | | COMP( 2000, specpl3e, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3e" , GAME_COMPUTER_MODIFIED ) |
| 2362 | | COMP( 2000, specp3es, spec128, 0, spectrum_plus3,spectrum, 0, specpls3, "Amstrad plc", "ZX Spectrum +3e (Spain)" , GAME_COMPUTER_MODIFIED ) |
| 2363 | | |
| 2364 | | COMP( ????, scorpion, 0, 0, scorpion, spectrum, 0, specpls3, "Zonov and Co.", "Zs Scorpion 256", 0 ) |
| 2365 | | COMP( ????, pentagon, spectrum, 0, pentagon, spectrum, 0, specpls3, "???", "Pentagon", GAME_NOT_WORKING) |
src/mess/drivers/spec128.c
| r0 | r2517 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | NOTE: ****** Specbusy: press N, R, or E to boot ************* |
| 4 | |
| 5 | |
| 6 | Spectrum/Inves/TK90X etc. memory map: |
| 7 | |
| 8 | CPU: |
| 9 | 0000-3fff ROM |
| 10 | 4000-ffff RAM |
| 11 | |
| 12 | Spectrum 128/+2/+2a/+3 memory map: |
| 13 | |
| 14 | CPU: |
| 15 | 0000-3fff Banked ROM/RAM (banked rom only on 128/+2) |
| 16 | 4000-7fff Banked RAM |
| 17 | 8000-bfff Banked RAM |
| 18 | c000-ffff Banked RAM |
| 19 | |
| 20 | TS2068 memory map: (Can't have both EXROM and DOCK active) |
| 21 | The 8K EXROM can be loaded into multiple pages. |
| 22 | |
| 23 | CPU: |
| 24 | 0000-1fff ROM / EXROM / DOCK (Cartridge) |
| 25 | 2000-3fff ROM / EXROM / DOCK |
| 26 | 4000-5fff \ |
| 27 | 6000-7fff \ |
| 28 | 8000-9fff |- RAM / EXROM / DOCK |
| 29 | a000-bfff | |
| 30 | c000-dfff / |
| 31 | e000-ffff / |
| 32 | |
| 33 | |
| 34 | Interrupts: |
| 35 | |
| 36 | Changes: |
| 37 | |
| 38 | 29/1/2000 KT - Implemented initial +3 emulation. |
| 39 | 30/1/2000 KT - Improved input port decoding for reading and therefore |
| 40 | correct keyboard handling for Spectrum and +3. |
| 41 | 31/1/2000 KT - Implemented buzzer sound for Spectrum and +3. |
| 42 | Implementation copied from Paul Daniel's Jupiter driver. |
| 43 | Fixed screen display problems with dirty chars. |
| 44 | Added support to load .Z80 snapshots. 48k support so far. |
| 45 | 13/2/2000 KT - Added Interface II, Kempston, Fuller and Mikrogen |
| 46 | joystick support. |
| 47 | 17/2/2000 DJR - Added full key descriptions and Spectrum+ keys. |
| 48 | Fixed Spectrum +3 keyboard problems. |
| 49 | 17/2/2000 KT - Added tape loading from WAV/Changed from DAC to generic |
| 50 | speaker code. |
| 51 | 18/2/2000 KT - Added tape saving to WAV. |
| 52 | 27/2/2000 KT - Took DJR's changes and added my changes. |
| 53 | 27/2/2000 KT - Added disk image support to Spectrum +3 driver. |
| 54 | 27/2/2000 KT - Added joystick I/O code to the Spectrum +3 I/O handler. |
| 55 | 14/3/2000 DJR - Tape handling dipswitch. |
| 56 | 26/3/2000 DJR - Snapshot files are now classifed as snapshots not |
| 57 | cartridges. |
| 58 | 04/4/2000 DJR - Spectrum 128 / +2 Support. |
| 59 | 13/4/2000 DJR - +4 Support (unofficial 48K hack). |
| 60 | 13/4/2000 DJR - +2a Support (rom also used in +3 models). |
| 61 | 13/4/2000 DJR - TK90X, TK95 and Inves support (48K clones). |
| 62 | 21/4/2000 DJR - TS2068 and TC2048 support (TC2048 Supports extra video |
| 63 | modes but doesn't have bank switching or sound chip). |
| 64 | 09/5/2000 DJR - Spectrum +2 (France, Spain), +3 (Spain). |
| 65 | 17/5/2000 DJR - Dipswitch to enable/disable disk drives on +3 and clones. |
| 66 | 27/6/2000 DJR - Changed 128K/+3 port decoding (sound now works in Zub 128K). |
| 67 | 06/8/2000 DJR - Fixed +3 Floppy support |
| 68 | 10/2/2001 KT - Re-arranged code and split into each model emulated. |
| 69 | Code is split into 48k, 128k, +3, tc2048 and ts2048 |
| 70 | segments. 128k uses some of the functions in 48k, +3 |
| 71 | uses some functions in 128, and tc2048/ts2048 use some |
| 72 | of the functions in 48k. The code has been arranged so |
| 73 | these functions come in some kind of "override" order, |
| 74 | read functions changed to use READ8_HANDLER and write |
| 75 | functions changed to use WRITE8_HANDLER. |
| 76 | Added Scorpion256 preliminary. |
| 77 | 18/6/2001 DJR - Added support for Interface 2 cartridges. |
| 78 | xx/xx/2001 KS - TS-2068 sound fixed. |
| 79 | Added support for DOCK cartridges for TS-2068. |
| 80 | Added Spectrum 48k Psycho modified rom driver. |
| 81 | Added UK-2086 driver. |
| 82 | 23/12/2001 KS - 48k machines are now able to run code in screen memory. |
| 83 | Programs which keep their code in screen memory |
| 84 | like monitors, tape copiers, decrunchers, etc. |
| 85 | works now. |
| 86 | Fixed problem with interrupt vector set to 0xffff (much |
| 87 | more 128k games works now). |
| 88 | A useful used trick on the Spectrum is to set |
| 89 | interrupt vector to 0xffff (using the table |
| 90 | which contain 0xff's) and put a byte 0x18 hex, |
| 91 | the opcode for JR, at this address. The first |
| 92 | byte of the ROM is a 0xf3 (DI), so the JR will |
| 93 | jump to 0xfff4, where a long JP to the actual |
| 94 | interrupt routine is put. Due to unideal |
| 95 | bankswitching in MAME this JP were to 0001 what |
| 96 | causes Spectrum to reset. Fixing this problem |
| 97 | made much more software runing (i.e. Paperboy). |
| 98 | Corrected frames per second value for 48k and 128k |
| 99 | Sincalir machines. |
| 100 | There are 50.08 frames per second for Spectrum |
| 101 | 48k what gives 69888 cycles for each frame and |
| 102 | 50.021 for Spectrum 128/+2/+2A/+3 what gives |
| 103 | 70908 cycles for each frame. |
| 104 | Remaped some Spectrum+ keys. |
| 105 | Presing F3 to reset was seting 0xf7 on keyboard |
| 106 | input port. Problem occured for snapshots of |
| 107 | some programms where it was readed as pressing |
| 108 | key 4 (which is exit in Tapecopy by R. Dannhoefer |
| 109 | for example). |
| 110 | Added support to load .SP snapshots. |
| 111 | Added .BLK tape images support. |
| 112 | .BLK files are identical to .TAP ones, extension |
| 113 | is an only difference. |
| 114 | 08/03/2002 KS - #FF port emulation added. |
| 115 | Arkanoid works now, but is not playable due to |
| 116 | completly messed timings. |
| 117 | |
| 118 | Initialisation values used when determining which model is being emulated: |
| 119 | 48K Spectrum doesn't use either port. |
| 120 | 128K/+2 Bank switches with port 7ffd only. |
| 121 | +3/+2a Bank switches with both ports. |
| 122 | |
| 123 | Notes: |
| 124 | 1. No contented memory. |
| 125 | 2. No hi-res colour effects (need contended memory first for accurate timing). |
| 126 | 3. Multiface 1 and Interface 1 not supported. |
| 127 | 4. Horace and the Spiders cartridge doesn't run properly. |
| 128 | 5. Tape images not supported: |
| 129 | .TZX, .SPC, .ITM, .PAN, .TAP(Warajevo), .VOC, .ZXS. |
| 130 | 6. Snapshot images not supported: |
| 131 | .ACH, .PRG, .RAW, .SEM, .SIT, .SNX, .ZX, .ZXS, .ZX82. |
| 132 | 7. 128K emulation is not perfect - the 128K machines crash and hang while |
| 133 | running quite a lot of games. |
| 134 | 8. Disk errors occur on some +3 games. |
| 135 | 9. Video hardware of all machines is timed incorrectly. |
| 136 | 10. EXROM and HOME cartridges are not emulated. |
| 137 | 11. The TK90X and TK95 roms output 0 to port #df on start up. |
| 138 | 12. The purpose of this port is unknown (probably display mode as TS2068) and |
| 139 | thus is not emulated. |
| 140 | |
| 141 | Very detailed infos about the ZX Spectrum +3e can be found at |
| 142 | |
| 143 | http://www.z88forever.org.uk/zxplus3e/ |
| 144 | |
| 145 | *******************************************************************************/ |
| 146 | |
| 147 | #include "driver.h" |
| 148 | #include "includes/spectrum.h" |
| 149 | #include "eventlst.h" |
| 150 | #include "devices/snapquik.h" |
| 151 | #include "devices/cartslot.h" |
| 152 | #include "devices/cassette.h" |
| 153 | #include "sound/ay8910.h" |
| 154 | #include "sound/speaker.h" |
| 155 | #include "formats/tzx_cas.h" |
| 156 | |
| 157 | static const struct AY8910interface spectrum_ay_interface = |
| 158 | { |
| 159 | AY8910_LEGACY_OUTPUT, |
| 160 | AY8910_DEFAULT_LOADS, |
| 161 | NULL |
| 162 | }; |
| 163 | |
| 164 | /****************************************************************************************************/ |
| 165 | /* Spectrum 128 specific functions */ |
| 166 | |
| 167 | int spectrum_128_port_7ffd_data = -1; |
| 168 | unsigned char *spectrum_128_screen_location = NULL; |
| 169 | |
| 170 | static WRITE8_HANDLER(spectrum_128_port_7ffd_w) |
| 171 | { |
| 172 | /* D0-D2: RAM page located at 0x0c000-0x0ffff */ |
| 173 | /* D3 - Screen select (screen 0 in ram page 5, screen 1 in ram page 7 */ |
| 174 | /* D4 - ROM select - which rom paged into 0x0000-0x03fff */ |
| 175 | /* D5 - Disable paging */ |
| 176 | |
| 177 | /* disable paging? */ |
| 178 | if (spectrum_128_port_7ffd_data & 0x20) |
| 179 | return; |
| 180 | |
| 181 | /* store new state */ |
| 182 | spectrum_128_port_7ffd_data = data; |
| 183 | |
| 184 | /* update memory */ |
| 185 | spectrum_128_update_memory(machine); |
| 186 | } |
| 187 | |
| 188 | void spectrum_128_update_memory(running_machine *machine) |
| 189 | { |
| 190 | unsigned char *ChosenROM; |
| 191 | int ROMSelection; |
| 192 | |
| 193 | if (spectrum_128_port_7ffd_data & 8) |
| 194 | { |
| 195 | logerror("SCREEN 1: BLOCK 7\n"); |
| 196 | spectrum_128_screen_location = mess_ram + (7<<14); |
| 197 | } |
| 198 | else |
| 199 | { |
| 200 | logerror("SCREEN 0: BLOCK 5\n"); |
| 201 | spectrum_128_screen_location = mess_ram + (5<<14); |
| 202 | } |
| 203 | |
| 204 | /* select ram at 0x0c000-0x0ffff */ |
| 205 | { |
| 206 | int ram_page; |
| 207 | unsigned char *ram_data; |
| 208 | |
| 209 | ram_page = spectrum_128_port_7ffd_data & 0x07; |
| 210 | ram_data = mess_ram + (ram_page<<14); |
| 211 | |
| 212 | memory_set_bankptr(4, ram_data); |
| 213 | |
| 214 | logerror("RAM at 0xc000: %02x\n",ram_page); |
| 215 | } |
| 216 | |
| 217 | /* ROM switching */ |
| 218 | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01); |
| 219 | |
| 220 | /* rom 0 is 128K rom, rom 1 is 48 BASIC */ |
| 221 | |
| 222 | ChosenROM = memory_region(REGION_CPU1) + 0x010000 + (ROMSelection<<14); |
| 223 | |
| 224 | memory_set_bankptr(1, ChosenROM); |
| 225 | |
| 226 | logerror("rom switch: %02x\n", ROMSelection); |
| 227 | } |
| 228 | |
| 229 | |
| 230 | |
| 231 | WRITE8_HANDLER(spectrum_128_port_bffd_w) |
| 232 | { |
| 233 | AY8910_write_port_0_w(machine, 0, data); |
| 234 | } |
| 235 | |
| 236 | WRITE8_HANDLER(spectrum_128_port_fffd_w) |
| 237 | { |
| 238 | AY8910_control_port_0_w(machine, 0, data); |
| 239 | } |
| 240 | |
| 241 | READ8_HANDLER(spectrum_128_port_fffd_r) |
| 242 | { |
| 243 | return AY8910_read_port_0_r(machine, 0); |
| 244 | } |
| 245 | |
| 246 | static READ8_HANDLER ( spectrum_128_port_r ) |
| 247 | { |
| 248 | if ((offset & 1)==0) |
| 249 | { |
| 250 | return spectrum_port_fe_r(machine, offset); |
| 251 | } |
| 252 | |
| 253 | if ((offset & 2)==0) |
| 254 | { |
| 255 | switch ((offset>>14) & 0x03) |
| 256 | { |
| 257 | default: |
| 258 | break; |
| 259 | |
| 260 | case 3: |
| 261 | return spectrum_128_port_fffd_r(machine, offset); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | /* don't think these are correct! */ |
| 266 | if ((offset & 0xff)==0x1f) |
| 267 | return spectrum_port_1f_r(machine, offset); |
| 268 | |
| 269 | if ((offset & 0xff)==0x7f) |
| 270 | return spectrum_port_7f_r(machine, offset); |
| 271 | |
| 272 | if ((offset & 0xff)==0xdf) |
| 273 | return spectrum_port_df_r(machine, offset); |
| 274 | |
| 275 | return video_screen_get_vpos(machine->primary_screen)<193 ? spectrum_128_screen_location[0x1800|(video_screen_get_vpos(machine->primary_screen)&0xf8)<<2]:0xff; |
| 276 | } |
| 277 | |
| 278 | static WRITE8_HANDLER ( spectrum_128_port_w ) |
| 279 | { |
| 280 | if ((offset & 1)==0) |
| 281 | spectrum_port_fe_w(machine, offset,data); |
| 282 | |
| 283 | /* Only decodes on A15, A14 & A1 */ |
| 284 | else if ((offset & 2)==0) |
| 285 | { |
| 286 | switch ((offset>>8) & 0xc0) |
| 287 | { |
| 288 | case 0x40: |
| 289 | spectrum_128_port_7ffd_w(machine, offset, data); |
| 290 | break; |
| 291 | case 0x80: |
| 292 | spectrum_128_port_bffd_w(machine, offset, data); |
| 293 | break; |
| 294 | case 0xc0: |
| 295 | spectrum_128_port_fffd_w(machine, offset, data); |
| 296 | break; |
| 297 | default: |
| 298 | logerror("Write %02x to 128 port: %04x\n", data, offset); |
| 299 | } |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | logerror("Write %02x to 128 port: %04x\n", data, offset); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | /* ports are not decoded full. |
| 308 | The function decodes the ports appropriately */ |
| 309 | static ADDRESS_MAP_START (spectrum_128_io, ADDRESS_SPACE_IO, 8) |
| 310 | AM_RANGE(0x0000, 0xffff) AM_READWRITE( spectrum_128_port_r, spectrum_128_port_w ) |
| 311 | ADDRESS_MAP_END |
| 312 | |
| 313 | static ADDRESS_MAP_START (spectrum_128_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 314 | AM_RANGE( 0x0000, 0x3fff) AM_READWRITE( SMH_BANK1, SMH_BANK1 ) |
| 315 | AM_RANGE( 0x4000, 0x7fff) AM_READWRITE( SMH_BANK2, SMH_BANK2 ) |
| 316 | AM_RANGE( 0x8000, 0xbfff) AM_READWRITE( SMH_BANK3, SMH_BANK3 ) |
| 317 | AM_RANGE( 0xc000, 0xffff) AM_READWRITE( SMH_BANK4, SMH_BANK4 ) |
| 318 | ADDRESS_MAP_END |
| 319 | |
| 320 | static MACHINE_RESET( spectrum_128 ) |
| 321 | { |
| 322 | memset(mess_ram,0,128*1024); |
| 323 | /* 0x0000-0x3fff always holds ROM */ |
| 324 | |
| 325 | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 326 | memory_set_bankptr(2, mess_ram + (5<<14)); |
| 327 | |
| 328 | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 329 | memory_set_bankptr(3, mess_ram + (2<<14)); |
| 330 | |
| 331 | /* set initial ram config */ |
| 332 | spectrum_128_port_7ffd_data = 0; |
| 333 | spectrum_128_update_memory(machine); |
| 334 | |
| 335 | MACHINE_RESET_CALL(spectrum); |
| 336 | } |
| 337 | |
| 338 | MACHINE_DRIVER_START( spectrum_128 ) |
| 339 | MDRV_IMPORT_FROM( spectrum ) |
| 340 | |
| 341 | MDRV_CPU_REPLACE("main", Z80, 3500000) /* 3.5 Mhz */ |
| 342 | MDRV_CPU_PROGRAM_MAP(spectrum_128_mem, 0) |
| 343 | MDRV_CPU_IO_MAP(spectrum_128_io, 0) |
| 344 | |
| 345 | MDRV_MACHINE_RESET( spectrum_128 ) |
| 346 | |
| 347 | /* video hardware */ |
| 348 | MDRV_SCREEN_MODIFY("main") |
| 349 | MDRV_PALETTE_LENGTH(16) |
| 350 | MDRV_PALETTE_INIT( spectrum_128 ) |
| 351 | MDRV_SCREEN_REFRESH_RATE(50.021) |
| 352 | MDRV_VIDEO_START( spectrum_128 ) |
| 353 | MDRV_VIDEO_UPDATE( spectrum_128 ) |
| 354 | |
| 355 | /* sound hardware */ |
| 356 | MDRV_SOUND_ADD(AY8912, 1773400) |
| 357 | MDRV_SOUND_CONFIG(spectrum_ay_interface) |
| 358 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 359 | MACHINE_DRIVER_END |
| 360 | |
| 361 | |
| 362 | |
| 363 | |
| 364 | /*************************************************************************** |
| 365 | |
| 366 | Game driver(s) |
| 367 | |
| 368 | ***************************************************************************/ |
| 369 | |
| 370 | |
| 371 | ROM_START(spec128) |
| 372 | ROM_REGION(0x18000,REGION_CPU1,0) |
| 373 | ROM_LOAD("zx128_0.rom",0x10000,0x4000, CRC(e76799d2) SHA1(4f4b11ec22326280bdb96e3baf9db4b4cb1d02c5)) |
| 374 | ROM_LOAD("zx128_1.rom",0x14000,0x4000, CRC(b96a36be) SHA1(80080644289ed93d71a1103992a154cc9802b2fa)) |
| 375 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 376 | ROM_END |
| 377 | |
| 378 | ROM_START(spec128s) |
| 379 | ROM_REGION(0x18000,REGION_CPU1,0) |
| 380 | ROM_LOAD("zx128s0.rom",0x10000,0x4000, CRC(453d86b2) SHA1(968937b1c750f0ef6205f01c6db4148da4cca4e3)) |
| 381 | ROM_LOAD("zx128s1.rom",0x14000,0x4000, CRC(6010e796) SHA1(bea3f397cc705eafee995ea629f4a82550562f90)) |
| 382 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 383 | ROM_END |
| 384 | |
| 385 | ROM_START(specpls2) |
| 386 | ROM_REGION(0x18000,REGION_CPU1,0) |
| 387 | ROM_LOAD("zxp2_0.rom",0x10000,0x4000, CRC(5d2e8c66) SHA1(72703f9a3e734f3c23ec34c0727aae4ccbef9a91)) |
| 388 | ROM_LOAD("zxp2_1.rom",0x14000,0x4000, CRC(98b1320b) SHA1(de8b0d2d0379cfe7c39322a086ca6da68c7f23cb)) |
| 389 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 390 | ROM_END |
| 391 | |
| 392 | ROM_START(specpl2a) |
| 393 | ROM_REGION(0x20000,REGION_CPU1,0) |
| 394 | ROM_LOAD("p2a41_0.rom",0x10000,0x4000, CRC(30c9f490) SHA1(62ec15a4af56cd1d206d0bd7011eac7c889a595d)) |
| 395 | ROM_LOAD("p2a41_1.rom",0x14000,0x4000, CRC(a7916b3f) SHA1(1a7812c383a3701e90e88d1da086efb0c033ac72)) |
| 396 | ROM_LOAD("p2a41_2.rom",0x18000,0x4000, CRC(c9a0b748) SHA1(8df145d10ff78f98138682ea15ebccb2874bf759)) |
| 397 | ROM_LOAD("p2a41_3.rom",0x1c000,0x4000, CRC(b88fd6e3) SHA1(be365f331942ec7ec35456b641dac56a0dbfe1f0)) |
| 398 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 399 | ROM_END |
| 400 | |
| 401 | |
| 402 | ROM_START(specp2fr) |
| 403 | ROM_REGION(0x18000,REGION_CPU1,0) |
| 404 | ROM_LOAD("plus2fr0.rom",0x10000,0x4000, CRC(c684c535) SHA1(56684c4c85a616e726a50707483b9a42d8e724ed)) |
| 405 | ROM_LOAD("plus2fr1.rom",0x14000,0x4000, CRC(f5e509c5) SHA1(7e398f62689c9d90a36d3a101351ec9987207308)) |
| 406 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 407 | ROM_END |
| 408 | |
| 409 | ROM_START(specp2sp) |
| 410 | ROM_REGION(0x18000,REGION_CPU1,0) |
| 411 | ROM_LOAD("plus2sp0.rom",0x10000,0x4000, CRC(e807d06e) SHA1(8259241b28ff85441f1bedc2bee53445767c51c5)) |
| 412 | ROM_LOAD("plus2sp1.rom",0x14000,0x4000, CRC(41981d4b) SHA1(ec0d5a158842d20601b4fbeaefc6668db979d0e1)) |
| 413 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 414 | ROM_END |
| 415 | |
| 416 | SYSTEM_CONFIG_START(spec128) |
| 417 | CONFIG_IMPORT_FROM(spectrum) |
| 418 | CONFIG_RAM_DEFAULT(128 * 1024) |
| 419 | SYSTEM_CONFIG_END |
| 420 | |
| 421 | |
| 422 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 423 | COMP( 1986, spec128, 0, 0, spectrum_128, spectrum, 0, spec128, "Sinclair Research", "ZX Spectrum 128" , 0 ) |
| 424 | COMP( 1985, spec128s, spec128, 0, spectrum_128, spectrum, 0, spec128, "Sinclair Research", "ZX Spectrum 128 (Spain)" , 0 ) |
| 425 | COMP( 1986, specpls2, spec128, 0, spectrum_128, spectrum, 0, spec128, "Amstrad plc", "ZX Spectrum +2" , 0 ) |
| 426 | COMP( 1986, specp2fr, spec128, 0, spectrum_128, spectrum, 0, spec128, "Amstrad plc", "ZX Spectrum +2 (France)" , 0 ) |
| 427 | COMP( 1986, specp2sp, spec128, 0, spectrum_128, spectrum, 0, spec128, "Amstrad plc", "ZX Spectrum +2 (Spain)" , 0 ) |
src/mess/drivers/timex.c
| r0 | r2517 | |
| 1 | /*************************************************************************** |
| 2 | |
| 3 | NOTE: ****** Specbusy: press N, R, or E to boot ************* |
| 4 | |
| 5 | |
| 6 | Spectrum/Inves/TK90X etc. memory map: |
| 7 | |
| 8 | CPU: |
| 9 | 0000-3fff ROM |
| 10 | 4000-ffff RAM |
| 11 | |
| 12 | Spectrum 128/+2/+2a/+3 memory map: |
| 13 | |
| 14 | CPU: |
| 15 | 0000-3fff Banked ROM/RAM (banked rom only on 128/+2) |
| 16 | 4000-7fff Banked RAM |
| 17 | 8000-bfff Banked RAM |
| 18 | c000-ffff Banked RAM |
| 19 | |
| 20 | TS2068 memory map: (Can't have both EXROM and DOCK active) |
| 21 | The 8K EXROM can be loaded into multiple pages. |
| 22 | |
| 23 | CPU: |
| 24 | 0000-1fff ROM / EXROM / DOCK (Cartridge) |
| 25 | 2000-3fff ROM / EXROM / DOCK |
| 26 | 4000-5fff \ |
| 27 | 6000-7fff \ |
| 28 | 8000-9fff |- RAM / EXROM / DOCK |
| 29 | a000-bfff | |
| 30 | c000-dfff / |
| 31 | e000-ffff / |
| 32 | |
| 33 | |
| 34 | Interrupts: |
| 35 | |
| 36 | Changes: |
| 37 | |
| 38 | 29/1/2000 KT - Implemented initial +3 emulation. |
| 39 | 30/1/2000 KT - Improved input port decoding for reading and therefore |
| 40 | correct keyboard handling for Spectrum and +3. |
| 41 | 31/1/2000 KT - Implemented buzzer sound for Spectrum and +3. |
| 42 | Implementation copied from Paul Daniel's Jupiter driver. |
| 43 | Fixed screen display problems with dirty chars. |
| 44 | Added support to load .Z80 snapshots. 48k support so far. |
| 45 | 13/2/2000 KT - Added Interface II, Kempston, Fuller and Mikrogen |
| 46 | joystick support. |
| 47 | 17/2/2000 DJR - Added full key descriptions and Spectrum+ keys. |
| 48 | Fixed Spectrum +3 keyboard problems. |
| 49 | 17/2/2000 KT - Added tape loading from WAV/Changed from DAC to generic |
| 50 | speaker code. |
| 51 | 18/2/2000 KT - Added tape saving to WAV. |
| 52 | 27/2/2000 KT - Took DJR's changes and added my changes. |
| 53 | 27/2/2000 KT - Added disk image support to Spectrum +3 driver. |
| 54 | 27/2/2000 KT - Added joystick I/O code to the Spectrum +3 I/O handler. |
| 55 | 14/3/2000 DJR - Tape handling dipswitch. |
| 56 | 26/3/2000 DJR - Snapshot files are now classifed as snapshots not |
| 57 | cartridges. |
| 58 | 04/4/2000 DJR - Spectrum 128 / +2 Support. |
| 59 | 13/4/2000 DJR - +4 Support (unofficial 48K hack). |
| 60 | 13/4/2000 DJR - +2a Support (rom also used in +3 models). |
| 61 | 13/4/2000 DJR - TK90X, TK95 and Inves support (48K clones). |
| 62 | 21/4/2000 DJR - TS2068 and TC2048 support (TC2048 Supports extra video |
| 63 | modes but doesn't have bank switching or sound chip). |
| 64 | 09/5/2000 DJR - Spectrum +2 (France, Spain), +3 (Spain). |
| 65 | 17/5/2000 DJR - Dipswitch to enable/disable disk drives on +3 and clones. |
| 66 | 27/6/2000 DJR - Changed 128K/+3 port decoding (sound now works in Zub 128K). |
| 67 | 06/8/2000 DJR - Fixed +3 Floppy support |
| 68 | 10/2/2001 KT - Re-arranged code and split into each model emulated. |
| 69 | Code is split into 48k, 128k, +3, tc2048 and ts2048 |
| 70 | segments. 128k uses some of the functions in 48k, +3 |
| 71 | uses some functions in 128, and tc2048/ts2048 use some |
| 72 | of the functions in 48k. The code has been arranged so |
| 73 | these functions come in some kind of "override" order, |
| 74 | read functions changed to use READ8_HANDLER and write |
| 75 | functions changed to use WRITE8_HANDLER. |
| 76 | Added Scorpion256 preliminary. |
| 77 | 18/6/2001 DJR - Added support for Interface 2 cartridges. |
| 78 | xx/xx/2001 KS - TS-2068 sound fixed. |
| 79 | Added support for DOCK cartridges for TS-2068. |
| 80 | Added Spectrum 48k Psycho modified rom driver. |
| 81 | Added UK-2086 driver. |
| 82 | 23/12/2001 KS - 48k machines are now able to run code in screen memory. |
| 83 | Programs which keep their code in screen memory |
| 84 | like monitors, tape copiers, decrunchers, etc. |
| 85 | works now. |
| 86 | Fixed problem with interrupt vector set to 0xffff (much |
| 87 | more 128k games works now). |
| 88 | A useful used trick on the Spectrum is to set |
| 89 | interrupt vector to 0xffff (using the table |
| 90 | which contain 0xff's) and put a byte 0x18 hex, |
| 91 | the opcode for JR, at this address. The first |
| 92 | byte of the ROM is a 0xf3 (DI), so the JR will |
| 93 | jump to 0xfff4, where a long JP to the actual |
| 94 | interrupt routine is put. Due to unideal |
| 95 | bankswitching in MAME this JP were to 0001 what |
| 96 | causes Spectrum to reset. Fixing this problem |
| 97 | made much more software runing (i.e. Paperboy). |
| 98 | Corrected frames per second value for 48k and 128k |
| 99 | Sincalir machines. |
| 100 | There are 50.08 frames per second for Spectrum |
| 101 | 48k what gives 69888 cycles for each frame and |
| 102 | 50.021 for Spectrum 128/+2/+2A/+3 what gives |
| 103 | 70908 cycles for each frame. |
| 104 | Remaped some Spectrum+ keys. |
| 105 | Presing F3 to reset was seting 0xf7 on keyboard |
| 106 | input port. Problem occured for snapshots of |
| 107 | some programms where it was readed as pressing |
| 108 | key 4 (which is exit in Tapecopy by R. Dannhoefer |
| 109 | for example). |
| 110 | Added support to load .SP snapshots. |
| 111 | Added .BLK tape images support. |
| 112 | .BLK files are identical to .TAP ones, extension |
| 113 | is an only difference. |
| 114 | 08/03/2002 KS - #FF port emulation added. |
| 115 | Arkanoid works now, but is not playable due to |
| 116 | completly messed timings. |
| 117 | |
| 118 | Initialisation values used when determining which model is being emulated: |
| 119 | 48K Spectrum doesn't use either port. |
| 120 | 128K/+2 Bank switches with port 7ffd only. |
| 121 | +3/+2a Bank switches with both ports. |
| 122 | |
| 123 | Notes: |
| 124 | 1. No contented memory. |
| 125 | 2. No hi-res colour effects (need contended memory first for accurate timing). |
| 126 | 3. Multiface 1 and Interface 1 not supported. |
| 127 | 4. Horace and the Spiders cartridge doesn't run properly. |
| 128 | 5. Tape images not supported: |
| 129 | .TZX, .SPC, .ITM, .PAN, .TAP(Warajevo), .VOC, .ZXS. |
| 130 | 6. Snapshot images not supported: |
| 131 | .ACH, .PRG, .RAW, .SEM, .SIT, .SNX, .ZX, .ZXS, .ZX82. |
| 132 | 7. 128K emulation is not perfect - the 128K machines crash and hang while |
| 133 | running quite a lot of games. |
| 134 | 8. Disk errors occur on some +3 games. |
| 135 | 9. Video hardware of all machines is timed incorrectly. |
| 136 | 10. EXROM and HOME cartridges are not emulated. |
| 137 | 11. The TK90X and TK95 roms output 0 to port #df on start up. |
| 138 | 12. The purpose of this port is unknown (probably display mode as TS2068) and |
| 139 | thus is not emulated. |
| 140 | |
| 141 | Very detailed infos about the ZX Spectrum +3e can be found at |
| 142 | |
| 143 | http://www.z88forever.org.uk/zxplus3e/ |
| 144 | |
| 145 | *******************************************************************************/ |
| 146 | |
| 147 | #include "driver.h" |
| 148 | #include "includes/spectrum.h" |
| 149 | #include "eventlst.h" |
| 150 | #include "devices/snapquik.h" |
| 151 | #include "devices/cartslot.h" |
| 152 | #include "devices/cassette.h" |
| 153 | #include "sound/speaker.h" |
| 154 | #include "sound/ay8910.h" |
| 155 | #include "formats/tzx_cas.h" |
| 156 | |
| 157 | /****************************************************************************************************/ |
| 158 | /* TS2048 specific functions */ |
| 159 | |
| 160 | |
| 161 | int ts2068_port_ff_data = -1; /* Display enhancement control */ |
| 162 | int ts2068_port_f4_data = -1; /* Horizontal Select Register */ |
| 163 | |
| 164 | static READ8_HANDLER(ts2068_port_f4_r) |
| 165 | { |
| 166 | return ts2068_port_f4_data; |
| 167 | } |
| 168 | |
| 169 | static WRITE8_HANDLER(ts2068_port_f4_w) |
| 170 | { |
| 171 | ts2068_port_f4_data = data; |
| 172 | ts2068_update_memory(machine); |
| 173 | } |
| 174 | |
| 175 | static WRITE8_HANDLER(ts2068_port_f5_w) |
| 176 | { |
| 177 | AY8910_control_port_0_w(machine, 0, data); |
| 178 | } |
| 179 | |
| 180 | static READ8_HANDLER(ts2068_port_f6_r) |
| 181 | { |
| 182 | /* TODO - Reading from register 14 reads the joystick ports |
| 183 | set bit 8 of address to read joystick #1 |
| 184 | set bit 9 of address to read joystick #2 |
| 185 | if both bits are set then OR values |
| 186 | Bit 0 up, 1 down, 2 left, 3 right, 7 fire active low. Other bits 1 |
| 187 | */ |
| 188 | return AY8910_read_port_0_r(machine, 0); |
| 189 | } |
| 190 | |
| 191 | static WRITE8_HANDLER(ts2068_port_f6_w) |
| 192 | { |
| 193 | AY8910_write_port_0_w(machine, 0, data); |
| 194 | } |
| 195 | |
| 196 | static READ8_HANDLER(ts2068_port_ff_r) |
| 197 | { |
| 198 | return ts2068_port_ff_data; |
| 199 | } |
| 200 | |
| 201 | static WRITE8_HANDLER(ts2068_port_ff_w) |
| 202 | { |
| 203 | /* Bits 0-2 Video Mode Select |
| 204 | Bits 3-5 64 column mode ink/paper selection |
| 205 | (See ts2068_vh_screenrefresh for more info) |
| 206 | Bit 6 17ms Interrupt Inhibit |
| 207 | Bit 7 Cartridge (0) / EXROM (1) select |
| 208 | */ |
| 209 | ts2068_port_ff_data = data; |
| 210 | ts2068_update_memory(machine); |
| 211 | logerror("Port %04x write %02x\n", offset, data); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | static READ8_HANDLER ( ts2068_port_r ) |
| 216 | { |
| 217 | switch (offset & 0xff) |
| 218 | { |
| 219 | /* Note: keys only decoded on port #fe not all even ports so |
| 220 | ports #f4 & #f6 correctly read */ |
| 221 | case 0xf4: return ts2068_port_f4_r(machine, offset); |
| 222 | case 0xf6: return ts2068_port_f6_r(machine, offset); |
| 223 | case 0xff: return ts2068_port_ff_r(machine, offset); |
| 224 | |
| 225 | case 0xfe: return spectrum_port_fe_r(machine, offset); |
| 226 | case 0x1f: return spectrum_port_1f_r(machine, offset); |
| 227 | case 0x7f: return spectrum_port_7f_r(machine, offset); |
| 228 | case 0xdf: return spectrum_port_df_r(machine, offset); |
| 229 | } |
| 230 | logerror("Read from port: %04x\n", offset); |
| 231 | |
| 232 | return 0xff; |
| 233 | } |
| 234 | |
| 235 | static WRITE8_HANDLER ( ts2068_port_w ) |
| 236 | { |
| 237 | /* Ports #fd & #fc were reserved by Timex for bankswitching and are not used |
| 238 | by either the hardware or system software. |
| 239 | Port #fb is the Thermal printer port and works exactly as the Sinclair |
| 240 | Printer - ie not yet emulated. |
| 241 | */ |
| 242 | switch (offset & 0xff) |
| 243 | { |
| 244 | case 0xfe: spectrum_port_fe_w(machine, offset,data); break; |
| 245 | case 0xf4: ts2068_port_f4_w(machine, offset,data); break; |
| 246 | case 0xf5: ts2068_port_f5_w(machine, offset,data); break; |
| 247 | case 0xf6: ts2068_port_f6_w(machine, offset,data); break; |
| 248 | case 0xff: ts2068_port_ff_w(machine, offset,data); break; |
| 249 | default: |
| 250 | logerror("Write %02x to Port: %04x\n", data, offset); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | |
| 255 | |
| 256 | /******************************************************************* |
| 257 | * |
| 258 | * Bank switch between the 3 internal memory banks HOME, EXROM |
| 259 | * and DOCK (Cartridges). The HOME bank contains 16K ROM in the |
| 260 | * 0-16K area and 48K RAM fills the rest. The EXROM contains 8K |
| 261 | * ROM and can appear in every 8K segment (ie 0-8K, 8-16K etc). |
| 262 | * The DOCK is empty and is meant to be occupied by cartridges |
| 263 | * you can plug into the cartridge dock of the 2068. |
| 264 | * |
| 265 | * The address space is divided into 8 8K chunks. Bit 0 of port |
| 266 | * #f4 corresponds to the 0-8K chunk, bit 1 to the 8-16K chunk |
| 267 | * etc. If the bit is 0 then the chunk is controlled by the HOME |
| 268 | * bank. If the bit is 1 then the chunk is controlled by either |
| 269 | * the DOCK or EXROM depending on bit 7 of port #ff. Note this |
| 270 | * means that that the Z80 can't see chunks of the EXROM and DOCK |
| 271 | * at the same time. |
| 272 | * |
| 273 | *******************************************************************/ |
| 274 | void ts2068_update_memory(running_machine *machine) |
| 275 | { |
| 276 | unsigned char *ChosenROM, *ExROM, *DOCK; |
| 277 | read8_machine_func rh; |
| 278 | write8_machine_func wh; |
| 279 | |
| 280 | DOCK = timex_cart_data; |
| 281 | |
| 282 | ExROM = memory_region(REGION_CPU1) + 0x014000; |
| 283 | |
| 284 | if (ts2068_port_f4_data & 0x01) |
| 285 | { |
| 286 | if (ts2068_port_ff_data & 0x80) |
| 287 | { |
| 288 | rh = SMH_BANK1; |
| 289 | wh = SMH_UNMAP; |
| 290 | memory_set_bankptr(1, ExROM); |
| 291 | logerror("0000-1fff EXROM\n"); |
| 292 | } |
| 293 | else |
| 294 | { |
| 295 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 296 | { |
| 297 | memory_set_bankptr(1, DOCK); |
| 298 | rh = SMH_BANK1; |
| 299 | if (timex_cart_chunks&0x01) |
| 300 | wh = SMH_BANK9; |
| 301 | else |
| 302 | wh = SMH_UNMAP; |
| 303 | } |
| 304 | else |
| 305 | { |
| 306 | rh = SMH_NOP; |
| 307 | wh = SMH_UNMAP; |
| 308 | } |
| 309 | logerror("0000-1fff Cartridge\n"); |
| 310 | } |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | ChosenROM = memory_region(REGION_CPU1) + 0x010000; |
| 315 | memory_set_bankptr(1, ChosenROM); |
| 316 | rh = SMH_BANK1; |
| 317 | wh = SMH_UNMAP; |
| 318 | logerror("0000-1fff HOME\n"); |
| 319 | } |
| 320 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, rh); |
| 321 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x1fff, 0, 0, wh); |
| 322 | |
| 323 | if (ts2068_port_f4_data & 0x02) |
| 324 | { |
| 325 | if (ts2068_port_ff_data & 0x80) |
| 326 | { |
| 327 | memory_set_bankptr(2, ExROM); |
| 328 | rh = SMH_BANK2; |
| 329 | wh = SMH_UNMAP; |
| 330 | logerror("2000-3fff EXROM\n"); |
| 331 | } |
| 332 | else |
| 333 | { |
| 334 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 335 | { |
| 336 | memory_set_bankptr(2, DOCK+0x2000); |
| 337 | rh = SMH_BANK2; |
| 338 | if (timex_cart_chunks&0x02) |
| 339 | wh = SMH_BANK10; |
| 340 | else |
| 341 | wh = SMH_UNMAP; |
| 342 | } |
| 343 | else |
| 344 | { |
| 345 | rh = SMH_NOP; |
| 346 | wh = SMH_UNMAP; |
| 347 | } |
| 348 | logerror("2000-3fff Cartridge\n"); |
| 349 | } |
| 350 | } |
| 351 | else |
| 352 | { |
| 353 | ChosenROM = memory_region(REGION_CPU1) + 0x012000; |
| 354 | memory_set_bankptr(2, ChosenROM); |
| 355 | rh = SMH_BANK2; |
| 356 | wh = SMH_UNMAP; |
| 357 | logerror("2000-3fff HOME\n"); |
| 358 | } |
| 359 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, rh); |
| 360 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2000, 0x3fff, 0, 0, wh); |
| 361 | |
| 362 | if (ts2068_port_f4_data & 0x04) |
| 363 | { |
| 364 | if (ts2068_port_ff_data & 0x80) |
| 365 | { |
| 366 | memory_set_bankptr(3, ExROM); |
| 367 | rh = SMH_BANK3; |
| 368 | wh = SMH_UNMAP; |
| 369 | logerror("4000-5fff EXROM\n"); |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 374 | { |
| 375 | memory_set_bankptr(3, DOCK+0x4000); |
| 376 | rh = SMH_BANK3; |
| 377 | if (timex_cart_chunks&0x04) |
| 378 | wh = SMH_BANK11; |
| 379 | else |
| 380 | wh = SMH_UNMAP; |
| 381 | } |
| 382 | else |
| 383 | { |
| 384 | rh = SMH_NOP; |
| 385 | wh = SMH_UNMAP; |
| 386 | } |
| 387 | logerror("4000-5fff Cartridge\n"); |
| 388 | } |
| 389 | } |
| 390 | else |
| 391 | { |
| 392 | memory_set_bankptr(3, mess_ram); |
| 393 | memory_set_bankptr(11, mess_ram); |
| 394 | rh = SMH_BANK3; |
| 395 | wh = SMH_BANK11; |
| 396 | logerror("4000-5fff RAM\n"); |
| 397 | } |
| 398 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, rh); |
| 399 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x5fff, 0, 0, wh); |
| 400 | |
| 401 | if (ts2068_port_f4_data & 0x08) |
| 402 | { |
| 403 | if (ts2068_port_ff_data & 0x80) |
| 404 | { |
| 405 | memory_set_bankptr(4, ExROM); |
| 406 | rh = SMH_BANK4; |
| 407 | wh = SMH_UNMAP; |
| 408 | logerror("6000-7fff EXROM\n"); |
| 409 | } |
| 410 | else |
| 411 | { |
| 412 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 413 | { |
| 414 | memory_set_bankptr(4, DOCK+0x6000); |
| 415 | rh = SMH_BANK4; |
| 416 | if (timex_cart_chunks&0x08) |
| 417 | wh = SMH_BANK12; |
| 418 | else |
| 419 | wh = SMH_UNMAP; |
| 420 | } |
| 421 | else |
| 422 | { |
| 423 | rh = SMH_NOP; |
| 424 | wh = SMH_UNMAP; |
| 425 | } |
| 426 | logerror("6000-7fff Cartridge\n"); |
| 427 | } |
| 428 | } |
| 429 | else |
| 430 | { |
| 431 | memory_set_bankptr(4, mess_ram + 0x2000); |
| 432 | memory_set_bankptr(12, mess_ram + 0x2000); |
| 433 | rh = SMH_BANK4; |
| 434 | wh = SMH_BANK12; |
| 435 | logerror("6000-7fff RAM\n"); |
| 436 | } |
| 437 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, rh); |
| 438 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x7fff, 0, 0, wh); |
| 439 | |
| 440 | if (ts2068_port_f4_data & 0x10) |
| 441 | { |
| 442 | if (ts2068_port_ff_data & 0x80) |
| 443 | { |
| 444 | memory_set_bankptr(5, ExROM); |
| 445 | rh = SMH_BANK5; |
| 446 | wh = SMH_UNMAP; |
| 447 | logerror("8000-9fff EXROM\n"); |
| 448 | } |
| 449 | else |
| 450 | { |
| 451 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 452 | { |
| 453 | memory_set_bankptr(5, DOCK+0x8000); |
| 454 | rh = SMH_BANK5; |
| 455 | if (timex_cart_chunks&0x10) |
| 456 | wh = SMH_BANK13; |
| 457 | else |
| 458 | wh = SMH_UNMAP; |
| 459 | } |
| 460 | else |
| 461 | { |
| 462 | rh = SMH_NOP; |
| 463 | wh = SMH_UNMAP; |
| 464 | } |
| 465 | logerror("8000-9fff Cartridge\n"); |
| 466 | } |
| 467 | } |
| 468 | else |
| 469 | { |
| 470 | memory_set_bankptr(5, mess_ram + 0x4000); |
| 471 | memory_set_bankptr(13, mess_ram + 0x4000); |
| 472 | rh = SMH_BANK5; |
| 473 | wh = SMH_BANK13; |
| 474 | logerror("8000-9fff RAM\n"); |
| 475 | } |
| 476 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0,rh); |
| 477 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x8000, 0x9fff, 0, 0,wh); |
| 478 | |
| 479 | if (ts2068_port_f4_data & 0x20) |
| 480 | { |
| 481 | if (ts2068_port_ff_data & 0x80) |
| 482 | { |
| 483 | memory_set_bankptr(6, ExROM); |
| 484 | rh = SMH_BANK6; |
| 485 | wh = SMH_UNMAP; |
| 486 | logerror("a000-bfff EXROM\n"); |
| 487 | } |
| 488 | else |
| 489 | { |
| 490 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 491 | { |
| 492 | memory_set_bankptr(6, DOCK+0xa000); |
| 493 | rh = SMH_BANK6; |
| 494 | if (timex_cart_chunks&0x20) |
| 495 | wh = SMH_BANK14; |
| 496 | else |
| 497 | wh = SMH_UNMAP; |
| 498 | } |
| 499 | else |
| 500 | { |
| 501 | rh = SMH_NOP; |
| 502 | wh = SMH_UNMAP; |
| 503 | } |
| 504 | logerror("a000-bfff Cartridge\n"); |
| 505 | } |
| 506 | } |
| 507 | else |
| 508 | { |
| 509 | memory_set_bankptr(6, mess_ram + 0x6000); |
| 510 | memory_set_bankptr(14, mess_ram + 0x6000); |
| 511 | rh = SMH_BANK6; |
| 512 | wh = SMH_BANK14; |
| 513 | logerror("a000-bfff RAM\n"); |
| 514 | } |
| 515 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, rh); |
| 516 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa000, 0xbfff, 0, 0, wh); |
| 517 | |
| 518 | if (ts2068_port_f4_data & 0x40) |
| 519 | { |
| 520 | if (ts2068_port_ff_data & 0x80) |
| 521 | { |
| 522 | memory_set_bankptr(7, ExROM); |
| 523 | rh = SMH_BANK7; |
| 524 | wh = SMH_UNMAP; |
| 525 | logerror("c000-dfff EXROM\n"); |
| 526 | } |
| 527 | else |
| 528 | { |
| 529 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 530 | { |
| 531 | memory_set_bankptr(7, DOCK+0xc000); |
| 532 | rh = SMH_BANK7; |
| 533 | if (timex_cart_chunks&0x40) |
| 534 | wh = SMH_BANK15; |
| 535 | else |
| 536 | wh = SMH_UNMAP; |
| 537 | } |
| 538 | else |
| 539 | { |
| 540 | rh = SMH_NOP; |
| 541 | wh = SMH_UNMAP; |
| 542 | } |
| 543 | logerror("c000-dfff Cartridge\n"); |
| 544 | } |
| 545 | } |
| 546 | else |
| 547 | { |
| 548 | memory_set_bankptr(7, mess_ram + 0x8000); |
| 549 | memory_set_bankptr(15, mess_ram + 0x8000); |
| 550 | rh = SMH_BANK7; |
| 551 | wh = SMH_BANK15; |
| 552 | logerror("c000-dfff RAM\n"); |
| 553 | } |
| 554 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, rh); |
| 555 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc000, 0xdfff, 0, 0, wh); |
| 556 | |
| 557 | if (ts2068_port_f4_data & 0x80) |
| 558 | { |
| 559 | if (ts2068_port_ff_data & 0x80) |
| 560 | { |
| 561 | memory_set_bankptr(8, ExROM); |
| 562 | rh = SMH_BANK8; |
| 563 | wh = SMH_UNMAP; |
| 564 | logerror("e000-ffff EXROM\n"); |
| 565 | } |
| 566 | else |
| 567 | { |
| 568 | if (timex_cart_type == TIMEX_CART_DOCK) |
| 569 | { |
| 570 | memory_set_bankptr(8, DOCK+0xe000); |
| 571 | rh = SMH_BANK8; |
| 572 | if (timex_cart_chunks&0x80) |
| 573 | wh = SMH_BANK16; |
| 574 | else |
| 575 | wh = SMH_UNMAP; |
| 576 | } |
| 577 | else |
| 578 | { |
| 579 | rh = SMH_NOP; |
| 580 | wh = SMH_UNMAP; |
| 581 | } |
| 582 | logerror("e000-ffff Cartridge\n"); |
| 583 | } |
| 584 | } |
| 585 | else |
| 586 | { |
| 587 | memory_set_bankptr(8, mess_ram + 0xa000); |
| 588 | memory_set_bankptr(16, mess_ram + 0xa000); |
| 589 | rh = SMH_BANK8; |
| 590 | wh = SMH_BANK16; |
| 591 | logerror("e000-ffff RAM\n"); |
| 592 | } |
| 593 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, rh); |
| 594 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xffff, 0, 0, wh); |
| 595 | } |
| 596 | |
| 597 | |
| 598 | static ADDRESS_MAP_START (ts2068_io, ADDRESS_SPACE_IO, 8) |
| 599 | AM_RANGE(0x0000, 0xffff) AM_READWRITE( ts2068_port_r, ts2068_port_w ) |
| 600 | ADDRESS_MAP_END |
| 601 | |
| 602 | static ADDRESS_MAP_START (ts2068_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 603 | AM_RANGE(0x0000, 0x1fff) AM_READWRITE( SMH_BANK1, SMH_BANK9 ) |
| 604 | AM_RANGE(0x2000, 0x3fff) AM_READWRITE( SMH_BANK2, SMH_BANK10 ) |
| 605 | AM_RANGE(0x4000, 0x5fff) AM_READWRITE( SMH_BANK3, SMH_BANK11 ) |
| 606 | AM_RANGE(0x6000, 0x7fff) AM_READWRITE( SMH_BANK4, SMH_BANK12 ) |
| 607 | AM_RANGE(0x8000, 0x9fff) AM_READWRITE( SMH_BANK5, SMH_BANK13 ) |
| 608 | AM_RANGE(0xa000, 0xbfff) AM_READWRITE( SMH_BANK6, SMH_BANK14 ) |
| 609 | AM_RANGE(0xc000, 0xdfff) AM_READWRITE( SMH_BANK7, SMH_BANK15 ) |
| 610 | AM_RANGE(0xe000, 0xffff) AM_READWRITE( SMH_BANK8, SMH_BANK16 ) |
| 611 | ADDRESS_MAP_END |
| 612 | |
| 613 | |
| 614 | static MACHINE_RESET( ts2068 ) |
| 615 | { |
| 616 | ts2068_port_ff_data = 0; |
| 617 | ts2068_port_f4_data = 0; |
| 618 | ts2068_update_memory(machine); |
| 619 | |
| 620 | MACHINE_RESET_CALL(spectrum); |
| 621 | } |
| 622 | |
| 623 | |
| 624 | /****************************************************************************************************/ |
| 625 | /* TC2048 specific functions */ |
| 626 | |
| 627 | |
| 628 | static void tc2048_port_ff_w(int offset, int data) |
| 629 | { |
| 630 | ts2068_port_ff_data = data; |
| 631 | logerror("Port %04x write %02x\n", offset, data); |
| 632 | } |
| 633 | |
| 634 | static READ8_HANDLER ( tc2048_port_r ) |
| 635 | { |
| 636 | if ((offset & 1)==0) |
| 637 | return spectrum_port_fe_r(machine, offset); |
| 638 | switch (offset & 0xff) |
| 639 | { |
| 640 | case 0xff: return ts2068_port_ff_r(machine, offset); |
| 641 | case 0x1f: return spectrum_port_1f_r(machine, offset); |
| 642 | case 0x7f: return spectrum_port_7f_r(machine, offset); |
| 643 | case 0xdf: return spectrum_port_df_r(machine, offset); |
| 644 | } |
| 645 | |
| 646 | logerror("Read from port: %04x\n", offset); |
| 647 | return 0xff; |
| 648 | } |
| 649 | |
| 650 | static WRITE8_HANDLER ( tc2048_port_w ) |
| 651 | { |
| 652 | if ((offset & 1)==0) |
| 653 | spectrum_port_fe_w(machine, offset,data); |
| 654 | else if ((offset & 0xff)==0xff) |
| 655 | tc2048_port_ff_w(offset, data); |
| 656 | else |
| 657 | { |
| 658 | logerror("Write %02x to Port: %04x\n", data, offset); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | /* ports are not decoded full. |
| 663 | The function decodes the ports appropriately */ |
| 664 | static ADDRESS_MAP_START (tc2048_io, ADDRESS_SPACE_IO, 8) |
| 665 | AM_RANGE(0x0000, 0xffff) AM_READWRITE( tc2048_port_r, tc2048_port_w ) |
| 666 | ADDRESS_MAP_END |
| 667 | |
| 668 | static ADDRESS_MAP_START (tc2048_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 669 | AM_RANGE( 0x0000, 0x3fff) AM_ROM |
| 670 | AM_RANGE( 0x4000, 0xffff) AM_READWRITE( SMH_BANK1, SMH_BANK2 ) |
| 671 | ADDRESS_MAP_END |
| 672 | |
| 673 | static MACHINE_RESET( tc2048 ) |
| 674 | { |
| 675 | memory_set_bankptr(1, mess_ram); |
| 676 | memory_set_bankptr(2, mess_ram); |
| 677 | ts2068_port_ff_data = 0; |
| 678 | |
| 679 | MACHINE_RESET_CALL(spectrum); |
| 680 | } |
| 681 | |
| 682 | |
| 683 | |
| 684 | static MACHINE_DRIVER_START( ts2068 ) |
| 685 | MDRV_IMPORT_FROM( spectrum_128 ) |
| 686 | MDRV_CPU_REPLACE("main", Z80, 3580000) /* 3.58 Mhz */ |
| 687 | MDRV_CPU_PROGRAM_MAP(ts2068_mem, 0) |
| 688 | MDRV_CPU_IO_MAP(ts2068_io, 0) |
| 689 | |
| 690 | MDRV_MACHINE_RESET( ts2068 ) |
| 691 | |
| 692 | /* video hardware */ |
| 693 | MDRV_SCREEN_MODIFY("main") |
| 694 | MDRV_SCREEN_REFRESH_RATE(60) |
| 695 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 696 | MDRV_SCREEN_SIZE(TS2068_SCREEN_WIDTH, TS2068_SCREEN_HEIGHT) |
| 697 | MDRV_SCREEN_VISIBLE_AREA(0, TS2068_SCREEN_WIDTH-1, 0, TS2068_SCREEN_HEIGHT-1) |
| 698 | |
| 699 | MDRV_VIDEO_UPDATE( ts2068 ) |
| 700 | MDRV_VIDEO_EOF( ts2068 ) |
| 701 | MACHINE_DRIVER_END |
| 702 | |
| 703 | |
| 704 | static MACHINE_DRIVER_START( uk2086 ) |
| 705 | MDRV_IMPORT_FROM( ts2068 ) |
| 706 | MDRV_SCREEN_MODIFY("main") |
| 707 | MDRV_SCREEN_REFRESH_RATE(50) |
| 708 | MACHINE_DRIVER_END |
| 709 | |
| 710 | |
| 711 | static MACHINE_DRIVER_START( tc2048 ) |
| 712 | MDRV_IMPORT_FROM( spectrum ) |
| 713 | MDRV_CPU_MODIFY("main") |
| 714 | MDRV_CPU_PROGRAM_MAP(tc2048_mem, 0) |
| 715 | MDRV_CPU_IO_MAP(tc2048_io, 0) |
| 716 | |
| 717 | MDRV_SCREEN_MODIFY("main") |
| 718 | MDRV_SCREEN_REFRESH_RATE(50) |
| 719 | |
| 720 | MDRV_MACHINE_RESET( tc2048 ) |
| 721 | |
| 722 | /* video hardware */ |
| 723 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 724 | MDRV_SCREEN_SIZE(TS2068_SCREEN_WIDTH, SPEC_SCREEN_HEIGHT) |
| 725 | MDRV_SCREEN_VISIBLE_AREA(0, TS2068_SCREEN_WIDTH-1, 0, SPEC_SCREEN_HEIGHT-1) |
| 726 | |
| 727 | MDRV_VIDEO_START( spectrum_128 ) |
| 728 | MDRV_VIDEO_UPDATE( tc2048 ) |
| 729 | MACHINE_DRIVER_END |
| 730 | |
| 731 | |
| 732 | |
| 733 | /*************************************************************************** |
| 734 | |
| 735 | Game driver(s) |
| 736 | |
| 737 | ***************************************************************************/ |
| 738 | |
| 739 | ROM_START(tc2048) |
| 740 | ROM_REGION(0x10000,REGION_CPU1,0) |
| 741 | ROM_LOAD("tc2048.rom",0x0000,0x4000, CRC(f1b5fa67) SHA1(febb2d495b6eda7cdcb4074935d6e9d9f328972d)) |
| 742 | ROM_CART_LOAD(0, "rom", 0x0000, 0x4000, ROM_NOCLEAR | ROM_NOMIRROR | ROM_OPTIONAL) |
| 743 | ROM_END |
| 744 | |
| 745 | ROM_START(ts2068) |
| 746 | ROM_REGION(0x16000,REGION_CPU1,0) |
| 747 | ROM_LOAD("ts2068_h.rom",0x10000,0x4000, CRC(bf44ec3f) SHA1(1446cb2780a9dedf640404a639fa3ae518b2d8aa)) |
| 748 | ROM_LOAD("ts2068_x.rom",0x14000,0x2000, CRC(ae16233a) SHA1(7e265a2c1f621ed365ea23bdcafdedbc79c1299c)) |
| 749 | ROM_END |
| 750 | |
| 751 | ROM_START(uk2086) |
| 752 | ROM_REGION(0x16000,REGION_CPU1,0) |
| 753 | ROM_LOAD("uk2086_h.rom",0x10000,0x4000, CRC(5ddc0ca2) SHA1(1d525fe5cdc82ab46767f665ad735eb5363f1f51)) |
| 754 | ROM_LOAD("ts2068_x.rom",0x14000,0x2000, CRC(ae16233a) SHA1(7e265a2c1f621ed365ea23bdcafdedbc79c1299c)) |
| 755 | ROM_END |
| 756 | |
| 757 | |
| 758 | static void ts2068_cartslot_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 759 | { |
| 760 | /* cartslot */ |
| 761 | switch(state) |
| 762 | { |
| 763 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 764 | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 765 | |
| 766 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 767 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(timex_cart); break; |
| 768 | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(timex_cart); break; |
| 769 | |
| 770 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 771 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dck"); break; |
| 772 | |
| 773 | default: cartslot_device_getinfo(devclass, state, info); break; |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | SYSTEM_CONFIG_START(ts2068) |
| 778 | CONFIG_IMPORT_FROM(spectrum_common) |
| 779 | CONFIG_DEVICE(ts2068_cartslot_getinfo) |
| 780 | CONFIG_RAM_DEFAULT(48 * 1024) |
| 781 | SYSTEM_CONFIG_END |
| 782 | |
| 783 | SYSTEM_CONFIG_START(tc2048) |
| 784 | CONFIG_IMPORT_FROM(spectrum) |
| 785 | CONFIG_RAM_DEFAULT(48 * 1024) |
| 786 | SYSTEM_CONFIG_END |
| 787 | |
| 788 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 789 | COMP( 1984, tc2048, spectrum, 0, tc2048, spectrum, 0, tc2048, "Timex of Portugal", "TC-2048" , 0) |
| 790 | COMP( 1983, ts2068, spectrum, 0, ts2068, spectrum, 0, ts2068, "Timex Sinclair", "TS-2068" , 0) |
| 791 | COMP( 1986, uk2086, spectrum, 0, uk2086, spectrum, 0, ts2068, "Unipolbrit", "UK-2086 ver. 1.2" , 0) |