src/mess/video/spectrum.c
| r7288 | r7289 | |
| 19 | 19 | #include "video/border.h" |
| 20 | 20 | |
| 21 | 21 | |
| 22 | | unsigned char *spectrum_video_ram; |
| 23 | | static UINT8 retrace_cycles; |
| 24 | | int spectrum_frame_number; /* Used for handling FLASH 1 */ |
| 25 | | int spectrum_flash_invert; |
| 26 | | |
| 27 | 22 | /*************************************************************************** |
| 28 | 23 | Start the video hardware emulation. |
| 29 | 24 | ***************************************************************************/ |
| 30 | 25 | VIDEO_START( spectrum ) |
| 31 | 26 | { |
| 32 | | spectrum_frame_number = 0; |
| 33 | | spectrum_flash_invert = 0; |
| 27 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 28 | state->frame_number = 0; |
| 29 | state->flash_invert = 0; |
| 34 | 30 | |
| 35 | 31 | EventList_Initialise(machine, 30000); |
| 36 | 32 | |
| 37 | | retrace_cycles = SPEC_RETRACE_CYCLES; |
| 33 | state->retrace_cycles = SPEC_RETRACE_CYCLES; |
| 38 | 34 | |
| 39 | | spectrum_screen_location = spectrum_video_ram; |
| 35 | state->screen_location = state->video_ram; |
| 40 | 36 | } |
| 41 | 37 | |
| 42 | 38 | VIDEO_START( spectrum_128 ) |
| 43 | 39 | { |
| 44 | | spectrum_frame_number = 0; |
| 45 | | spectrum_flash_invert = 0; |
| 40 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 41 | state->frame_number = 0; |
| 42 | state->flash_invert = 0; |
| 46 | 43 | |
| 47 | 44 | EventList_Initialise(machine, 30000); |
| 48 | 45 | |
| 49 | | retrace_cycles = SPEC128_RETRACE_CYCLES; |
| 46 | state->retrace_cycles = SPEC128_RETRACE_CYCLES; |
| 50 | 47 | } |
| 51 | 48 | |
| 52 | 49 | |
| 53 | 50 | /* return the color to be used inverting FLASHing colors if necessary */ |
| 54 | 51 | INLINE unsigned char get_display_color (unsigned char color, int invert) |
| 55 | 52 | { |
| 56 | | if (invert && (color & 0x80)) |
| 57 | | return (color & 0xc0) + ((color & 0x38) >> 3) + ((color & 0x07) << 3); |
| 58 | | else |
| 59 | | return color; |
| 53 | if (invert && (color & 0x80)) |
| 54 | return (color & 0xc0) + ((color & 0x38) >> 3) + ((color & 0x07) << 3); |
| 55 | else |
| 56 | return color; |
| 60 | 57 | } |
| 61 | 58 | |
| 62 | 59 | /* Code to change the FLASH status every 25 frames. Note this must be |
| 63 | 60 | independent of frame skip etc. */ |
| 64 | 61 | VIDEO_EOF( spectrum ) |
| 65 | 62 | { |
| 66 | | EVENT_LIST_ITEM *pItem; |
| 67 | | int NumItems; |
| 63 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 64 | EVENT_LIST_ITEM *pItem; |
| 65 | int NumItems; |
| 68 | 66 | |
| 69 | | spectrum_frame_number++; |
| 70 | | if (spectrum_frame_number >= 25) |
| 71 | | { |
| 72 | | spectrum_frame_number = 0; |
| 73 | | spectrum_flash_invert = !spectrum_flash_invert; |
| 74 | | } |
| 67 | state->frame_number++; |
| 68 | if (state->frame_number >= 25) |
| 69 | { |
| 70 | state->frame_number = 0; |
| 71 | state->flash_invert = !state->flash_invert; |
| 72 | } |
| 75 | 73 | |
| 76 | | /* Empty event buffer for undisplayed frames noting the last border |
| 77 | | colour (in case colours are not changed in the next frame). */ |
| 78 | | NumItems = EventList_NumEvents(); |
| 79 | | if (NumItems) |
| 80 | | { |
| 81 | | pItem = EventList_GetFirstItem(); |
| 82 | | border_set_last_color ( pItem[NumItems-1].Event_Data ); |
| 83 | | EventList_Reset(); |
| 84 | | EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(video_screen_get_scan_period(machine->primary_screen), video_screen_get_vpos(machine->primary_screen))) ); |
| 85 | | logerror ("Event log reset in callback fn.\n"); |
| 86 | | } |
| 74 | /* Empty event buffer for undisplayed frames noting the last border |
| 75 | colour (in case colours are not changed in the next frame). */ |
| 76 | NumItems = EventList_NumEvents(); |
| 77 | if (NumItems) |
| 78 | { |
| 79 | pItem = EventList_GetFirstItem(); |
| 80 | border_set_last_color ( pItem[NumItems-1].Event_Data ); |
| 81 | EventList_Reset(); |
| 82 | EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(video_screen_get_scan_period(machine->primary_screen), video_screen_get_vpos(machine->primary_screen))) ); |
| 83 | logerror ("Event log reset in callback fn.\n"); |
| 84 | } |
| 87 | 85 | } |
| 88 | 86 | |
| 89 | 87 | |
| r7288 | r7289 | |
| 119 | 117 | VIDEO_UPDATE( spectrum ) |
| 120 | 118 | { |
| 121 | 119 | /* for now do a full-refresh */ |
| 122 | | int x, y, b, scrx, scry; |
| 123 | | unsigned short ink, pap; |
| 124 | | unsigned char *attr, *scr; |
| 120 | spectrum_state *state = (spectrum_state *)screen->machine->driver_data; |
| 121 | int x, y, b, scrx, scry; |
| 122 | unsigned short ink, pap; |
| 123 | unsigned char *attr, *scr; |
| 125 | 124 | int full_refresh = 1; |
| 126 | 125 | |
| 127 | | scr=spectrum_screen_location; |
| 126 | scr=state->screen_location; |
| 128 | 127 | |
| 129 | | for (y=0; y<192; y++) |
| 130 | | { |
| 131 | | scrx=SPEC_LEFT_BORDER; |
| 132 | | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 133 | | attr=spectrum_screen_location + ((scry>>3)*32) + 0x1800; |
| 128 | for (y=0; y<192; y++) |
| 129 | { |
| 130 | scrx=SPEC_LEFT_BORDER; |
| 131 | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 132 | attr=state->screen_location + ((scry>>3)*32) + 0x1800; |
| 134 | 133 | |
| 135 | | for (x=0;x<32;x++) |
| 136 | | { |
| 137 | | /* Get ink and paper colour with bright */ |
| 138 | | if (spectrum_flash_invert && (*attr & 0x80)) |
| 139 | | { |
| 140 | | ink=((*attr)>>3) & 0x0f; |
| 141 | | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 142 | | } |
| 143 | | else |
| 144 | | { |
| 145 | | ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 146 | | pap=((*attr)>>3) & 0x0f; |
| 147 | | } |
| 134 | for (x=0;x<32;x++) |
| 135 | { |
| 136 | /* Get ink and paper colour with bright */ |
| 137 | if (state->flash_invert && (*attr & 0x80)) |
| 138 | { |
| 139 | ink=((*attr)>>3) & 0x0f; |
| 140 | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 141 | } |
| 142 | else |
| 143 | { |
| 144 | ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 145 | pap=((*attr)>>3) & 0x0f; |
| 146 | } |
| 148 | 147 | |
| 149 | | for (b=0x80;b!=0;b>>=1) |
| 150 | | { |
| 151 | | if (*scr&b) |
| 152 | | spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,ink); |
| 153 | | else |
| 154 | | spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,pap); |
| 155 | | } |
| 156 | | scr++; |
| 157 | | attr++; |
| 158 | | } |
| 159 | | } |
| 148 | for (b=0x80;b!=0;b>>=1) |
| 149 | { |
| 150 | if (*scr&b) |
| 151 | spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,ink); |
| 152 | else |
| 153 | spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,pap); |
| 154 | } |
| 160 | 155 | |
| 156 | scr++; |
| 157 | attr++; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | 161 | border_draw(screen->machine, bitmap, full_refresh, |
| 162 | 162 | SPEC_TOP_BORDER, SPEC_DISPLAY_YSIZE, SPEC_BOTTOM_BORDER, |
| 163 | 163 | SPEC_LEFT_BORDER, SPEC_DISPLAY_XSIZE, SPEC_RIGHT_BORDER, |
| 164 | 164 | SPEC_LEFT_BORDER_CYCLES, SPEC_DISPLAY_XSIZE_CYCLES, |
| 165 | | SPEC_RIGHT_BORDER_CYCLES, retrace_cycles, 200, 0xfe); |
| 165 | SPEC_RIGHT_BORDER_CYCLES, state->retrace_cycles, 200, 0xfe); |
| 166 | 166 | return 0; |
| 167 | 167 | } |
| 168 | 168 | |
src/mess/video/timex.c
| r7288 | r7289 | |
| 27 | 27 | /* Update FLASH status for ts2068. Assumes flash update every 1/2s. */ |
| 28 | 28 | VIDEO_EOF( ts2068 ) |
| 29 | 29 | { |
| 30 | | EVENT_LIST_ITEM *pItem; |
| 31 | | int NumItems; |
| 30 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 31 | EVENT_LIST_ITEM *pItem; |
| 32 | int NumItems; |
| 32 | 33 | |
| 33 | | spectrum_frame_number++; |
| 34 | | if (spectrum_frame_number >= 30) |
| 35 | | { |
| 36 | | spectrum_frame_number = 0; |
| 37 | | spectrum_flash_invert = !spectrum_flash_invert; |
| 38 | | } |
| 34 | state->frame_number++; |
| 35 | if (state->frame_number >= 30) |
| 36 | { |
| 37 | state->frame_number = 0; |
| 38 | state->flash_invert = !state->flash_invert; |
| 39 | } |
| 39 | 40 | |
| 40 | | /* Empty event buffer for undisplayed frames noting the last border |
| 41 | | colour (in case colours are not changed in the next frame). */ |
| 42 | | NumItems = EventList_NumEvents(); |
| 43 | | if (NumItems) |
| 44 | | { |
| 45 | | pItem = EventList_GetFirstItem(); |
| 46 | | border_set_last_color ( pItem[NumItems-1].Event_Data ); |
| 47 | | EventList_Reset(); |
| 48 | | EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(video_screen_get_scan_period(machine->primary_screen), video_screen_get_vpos(machine->primary_screen))) ); |
| 49 | | logerror ("Event log reset in callback fn.\n"); |
| 50 | | } |
| 41 | /* Empty event buffer for undisplayed frames noting the last border |
| 42 | colour (in case colours are not changed in the next frame). */ |
| 43 | NumItems = EventList_NumEvents(); |
| 44 | if (NumItems) |
| 45 | { |
| 46 | pItem = EventList_GetFirstItem(); |
| 47 | border_set_last_color ( pItem[NumItems-1].Event_Data ); |
| 48 | EventList_Reset(); |
| 49 | EventList_SetOffsetStartTime ( cpu_attotime_to_clocks(machine->firstcpu, attotime_mul(video_screen_get_scan_period(machine->primary_screen), video_screen_get_vpos(machine->primary_screen))) ); |
| 50 | logerror ("Event log reset in callback fn.\n"); |
| 51 | } |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | 54 | |
| r7288 | r7289 | |
| 76 | 77 | /* Draw a scanline in TS2068/TC2048 hires mode (code modified from COUPE.C) */ |
| 77 | 78 | static void ts2068_hires_scanline(running_machine *machine,bitmap_t *bitmap, int y, int borderlines) |
| 78 | 79 | { |
| 80 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 79 | 81 | int x,b,scrx,scry; |
| 80 | 82 | unsigned short ink,pap; |
| 81 | | unsigned char *attr, *scr; |
| 83 | unsigned char *attr, *scr; |
| 82 | 84 | |
| 83 | | scrx=TS2068_LEFT_BORDER; |
| 85 | scrx=TS2068_LEFT_BORDER; |
| 84 | 86 | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 85 | 87 | |
| 86 | | scr=messram_get_ptr(devtag_get_device(machine, "messram")) + y*32; |
| 87 | | attr=scr + 0x2000; |
| 88 | scr=messram_get_ptr(devtag_get_device(machine, "messram")) + y*32; |
| 89 | attr=scr + 0x2000; |
| 88 | 90 | |
| 89 | | for (x=0;x<32;x++) |
| 91 | for (x=0;x<32;x++) |
| 90 | 92 | { |
| 91 | | /* Get ink and paper colour with bright */ |
| 92 | | if (spectrum_flash_invert && (*attr & 0x80)) |
| 93 | | { |
| 94 | | ink=((*attr)>>3) & 0x0f; |
| 95 | | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 96 | | } |
| 97 | | else |
| 98 | | { |
| 99 | | ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 100 | | pap=((*attr)>>3) & 0x0f; |
| 101 | | } |
| 93 | /* Get ink and paper colour with bright */ |
| 94 | if (state->flash_invert && (*attr & 0x80)) |
| 95 | { |
| 96 | ink=((*attr)>>3) & 0x0f; |
| 97 | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | ink=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| 102 | pap=((*attr)>>3) & 0x0f; |
| 103 | } |
| 102 | 104 | |
| 103 | 105 | for (b=0x80;b!=0;b>>=1) |
| 104 | 106 | { |
| 105 | | if (*scr&b) |
| 107 | if (*scr&b) |
| 106 | 108 | { |
| 107 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 108 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 109 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 110 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,ink); |
| 109 | 111 | } |
| 110 | 112 | else |
| 111 | 113 | { |
| 112 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 113 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 114 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 115 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,pap); |
| 114 | 116 | } |
| 115 | 117 | } |
| 116 | | scr++; |
| 117 | | attr++; |
| 118 | scr++; |
| 119 | attr++; |
| 118 | 120 | } |
| 119 | 121 | } |
| 120 | 122 | |
| r7288 | r7289 | |
| 122 | 124 | static void ts2068_64col_scanline(running_machine *machine,bitmap_t *bitmap, int y, int borderlines, unsigned short inkcolor) |
| 123 | 125 | { |
| 124 | 126 | int x,b,scrx,scry; |
| 125 | | unsigned char *scr1, *scr2; |
| 127 | unsigned char *scr1, *scr2; |
| 126 | 128 | |
| 127 | | scrx=TS2068_LEFT_BORDER; |
| 129 | scrx=TS2068_LEFT_BORDER; |
| 128 | 130 | scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0); |
| 129 | 131 | |
| 130 | | scr1=messram_get_ptr(devtag_get_device(machine, "messram")) + y*32; |
| 131 | | scr2=scr1 + 0x2000; |
| 132 | scr1=messram_get_ptr(devtag_get_device(machine, "messram")) + y*32; |
| 133 | scr2=scr1 + 0x2000; |
| 132 | 134 | |
| 133 | | for (x=0;x<32;x++) |
| 135 | for (x=0;x<32;x++) |
| 134 | 136 | { |
| 135 | 137 | for (b=0x80;b!=0;b>>=1) |
| 136 | 138 | { |
| 137 | | if (*scr1&b) |
| 138 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); |
| 139 | if (*scr1&b) |
| 140 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); |
| 139 | 141 | else |
| 140 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); |
| 142 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); |
| 141 | 143 | } |
| 142 | | scr1++; |
| 144 | scr1++; |
| 143 | 145 | |
| 144 | 146 | for (b=0x80;b!=0;b>>=1) |
| 145 | 147 | { |
| 146 | | if (*scr2&b) |
| 147 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); |
| 148 | if (*scr2&b) |
| 149 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,inkcolor); |
| 148 | 150 | else |
| 149 | | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); |
| 151 | spectrum_plot_pixel(bitmap,scrx++,scry+borderlines,7-inkcolor); |
| 150 | 152 | } |
| 151 | | scr2++; |
| 153 | scr2++; |
| 152 | 154 | } |
| 153 | 155 | } |
| 154 | 156 | |
| 155 | 157 | /* Draw a scanline in TS2068/TC2048 lores (normal Spectrum) mode */ |
| 156 | 158 | static void ts2068_lores_scanline(running_machine *machine,bitmap_t *bitmap, int y, int borderlines, int screen) |
| 157 | 159 | { |
| 160 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 158 | 161 | int x,b,scrx,scry; |
| 159 | 162 | unsigned short ink,pap; |
| 160 | 163 | unsigned char *attr, *scr; |
| r7288 | r7289 | |
| 168 | 171 | for (x=0;x<32;x++) |
| 169 | 172 | { |
| 170 | 173 | /* Get ink and paper colour with bright */ |
| 171 | | if (spectrum_flash_invert && (*attr & 0x80)) |
| 174 | if (state->flash_invert && (*attr & 0x80)) |
| 172 | 175 | { |
| 173 | 176 | ink=((*attr)>>3) & 0x0f; |
| 174 | 177 | pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08); |
| r7288 | r7289 | |
| 200 | 203 | VIDEO_UPDATE( ts2068 ) |
| 201 | 204 | { |
| 202 | 205 | /* for now TS2068 will do a full-refresh */ |
| 206 | spectrum_state *state = (spectrum_state *)screen->machine->driver_data; |
| 203 | 207 | int count; |
| 204 | 208 | int full_refresh = 1; |
| 205 | 209 | |
| 206 | | if ((ts2068_port_ff_data & 7) == 6) |
| 207 | | { |
| 208 | | /* 64 Column mode */ |
| 209 | | unsigned short inkcolor = (ts2068_port_ff_data & 0x38) >> 3; |
| 210 | | for (count = 0; count < 192; count++) |
| 211 | | ts2068_64col_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER, inkcolor); |
| 212 | | } |
| 213 | | else if ((ts2068_port_ff_data & 7) == 2) |
| 214 | | { |
| 215 | | /* Extended Color mode */ |
| 216 | | for (count = 0; count < 192; count++) |
| 217 | | ts2068_hires_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER); |
| 218 | | } |
| 219 | | else if ((ts2068_port_ff_data & 7) == 1) |
| 220 | | { |
| 221 | | /* Screen 6000-7aff */ |
| 222 | | for (count = 0; count < 192; count++) |
| 223 | | ts2068_lores_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER, 1); |
| 224 | | } |
| 225 | | else |
| 226 | | { |
| 227 | | /* Screen 4000-5aff */ |
| 228 | | for (count = 0; count < 192; count++) |
| 229 | | ts2068_lores_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER, 0); |
| 230 | | } |
| 210 | if ((state->port_ff_data & 7) == 6) |
| 211 | { |
| 212 | /* 64 Column mode */ |
| 213 | unsigned short inkcolor = (state->port_ff_data & 0x38) >> 3; |
| 214 | for (count = 0; count < 192; count++) |
| 215 | ts2068_64col_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER, inkcolor); |
| 216 | } |
| 217 | else if ((state->port_ff_data & 7) == 2) |
| 218 | { |
| 219 | /* Extended Color mode */ |
| 220 | for (count = 0; count < 192; count++) |
| 221 | ts2068_hires_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER); |
| 222 | } |
| 223 | else if ((state->port_ff_data & 7) == 1) |
| 224 | { |
| 225 | /* Screen 6000-7aff */ |
| 226 | for (count = 0; count < 192; count++) |
| 227 | ts2068_lores_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER, 1); |
| 228 | } |
| 229 | else |
| 230 | { |
| 231 | /* Screen 4000-5aff */ |
| 232 | for (count = 0; count < 192; count++) |
| 233 | ts2068_lores_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER, 0); |
| 234 | } |
| 231 | 235 | |
| 232 | | border_draw(screen->machine, bitmap, full_refresh, |
| 233 | | TS2068_TOP_BORDER, SPEC_DISPLAY_YSIZE, TS2068_BOTTOM_BORDER, |
| 234 | | TS2068_LEFT_BORDER, TS2068_DISPLAY_XSIZE, TS2068_RIGHT_BORDER, |
| 235 | | SPEC_LEFT_BORDER_CYCLES, SPEC_DISPLAY_XSIZE_CYCLES, |
| 236 | | SPEC_RIGHT_BORDER_CYCLES, SPEC_RETRACE_CYCLES, 200, 0xfe); |
| 236 | border_draw(screen->machine, bitmap, full_refresh, |
| 237 | TS2068_TOP_BORDER, SPEC_DISPLAY_YSIZE, TS2068_BOTTOM_BORDER, |
| 238 | TS2068_LEFT_BORDER, TS2068_DISPLAY_XSIZE, TS2068_RIGHT_BORDER, |
| 239 | SPEC_LEFT_BORDER_CYCLES, SPEC_DISPLAY_XSIZE_CYCLES, |
| 240 | SPEC_RIGHT_BORDER_CYCLES, SPEC_RETRACE_CYCLES, 200, 0xfe); |
| 237 | 241 | return 0; |
| 238 | 242 | } |
| 239 | 243 | |
| 240 | 244 | VIDEO_UPDATE( tc2048 ) |
| 241 | 245 | { |
| 242 | 246 | /* for now TS2068 will do a full-refresh */ |
| 247 | spectrum_state *state = (spectrum_state *)screen->machine->driver_data; |
| 243 | 248 | int count; |
| 244 | 249 | int full_refresh = 1; |
| 245 | 250 | |
| 246 | | if ((ts2068_port_ff_data & 7) == 6) |
| 251 | if ((state->port_ff_data & 7) == 6) |
| 247 | 252 | { |
| 248 | 253 | /* 64 Column mode */ |
| 249 | | unsigned short inkcolor = (ts2068_port_ff_data & 0x38) >> 3; |
| 254 | unsigned short inkcolor = (state->port_ff_data & 0x38) >> 3; |
| 250 | 255 | for (count = 0; count < 192; count++) |
| 251 | 256 | ts2068_64col_scanline(screen->machine,bitmap, count, SPEC_TOP_BORDER, inkcolor); |
| 252 | 257 | } |
| 253 | | else if ((ts2068_port_ff_data & 7) == 2) |
| 258 | else if ((state->port_ff_data & 7) == 2) |
| 254 | 259 | { |
| 255 | 260 | /* Extended Color mode */ |
| 256 | 261 | for (count = 0; count < 192; count++) |
| 257 | 262 | ts2068_hires_scanline(screen->machine,bitmap, count, SPEC_TOP_BORDER); |
| 258 | 263 | } |
| 259 | | else if ((ts2068_port_ff_data & 7) == 1) |
| 264 | else if ((state->port_ff_data & 7) == 1) |
| 260 | 265 | { |
| 261 | 266 | /* Screen 6000-7aff */ |
| 262 | 267 | for (count = 0; count < 192; count++) |
src/mess/formats/spec_snqk.c
| r7288 | r7289 | |
| 52 | 52 | *******************************************************************/ |
| 53 | 53 | static void spectrum_update_paging(running_machine *machine) |
| 54 | 54 | { |
| 55 | | if (spectrum_128_port_7ffd_data == -1) |
| 55 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 56 | if (state->port_7ffd_data == -1) |
| 56 | 57 | return; |
| 57 | | if (spectrum_plus3_port_1ffd_data == -1) |
| 58 | if (state->port_1ffd_data == -1) |
| 58 | 59 | spectrum_128_update_memory(machine); |
| 59 | 60 | |
| 60 | 61 | else |
| 61 | 62 | { |
| 62 | | if (spectrum_128_port_7ffd_data & 0x10) |
| 63 | if (state->port_7ffd_data & 0x10) |
| 63 | 64 | /* Page in Spec 48K basic ROM */ |
| 64 | | spectrum_plus3_port_1ffd_data = 0x04; |
| 65 | state->port_1ffd_data = 0x04; |
| 65 | 66 | else |
| 66 | | spectrum_plus3_port_1ffd_data = 0; |
| 67 | state->port_1ffd_data = 0; |
| 67 | 68 | spectrum_plus3_update_memory(machine); |
| 68 | 69 | } |
| 69 | 70 | } |
| r7288 | r7289 | |
| 71 | 72 | /* Page in the 48K Basic ROM. Used when running 48K snapshots on a 128K machine. */ |
| 72 | 73 | static void spectrum_page_basicrom(running_machine *machine) |
| 73 | 74 | { |
| 74 | | if (spectrum_128_port_7ffd_data == -1) |
| 75 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 76 | if (state->port_7ffd_data == -1) |
| 75 | 77 | return; |
| 76 | | spectrum_128_port_7ffd_data |= 0x10; |
| 78 | state->port_7ffd_data |= 0x10; |
| 77 | 79 | spectrum_update_paging(machine); |
| 78 | 80 | } |
| 79 | 81 | |
| r7288 | r7289 | |
| 156 | 158 | *******************************************************************/ |
| 157 | 159 | void spectrum_setup_sp(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 158 | 160 | { |
| 161 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 159 | 162 | int i; |
| 160 | 163 | UINT8 lo, hi, data; |
| 161 | 164 | UINT16 offset, size; |
| r7288 | r7289 | |
| 220 | 223 | logerror("Unknown meaning of word on position 32: %04x.\n", (hi << 8) | lo); |
| 221 | 224 | |
| 222 | 225 | /* Set border colour */ |
| 223 | | spectrum_PreviousFE = (spectrum_PreviousFE & 0xf8) | (pSnapshot[34] & 0x07); |
| 226 | state->port_fe_data = (state->port_fe_data & 0xf8) | (pSnapshot[34] & 0x07); |
| 224 | 227 | EventList_Reset(); |
| 225 | 228 | border_set_last_color(pSnapshot[34] & 0x07); |
| 226 | 229 | border_force_redraw(); |
| r7288 | r7289 | |
| 294 | 297 | *******************************************************************/ |
| 295 | 298 | void spectrum_setup_sna(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 296 | 299 | { |
| 300 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 297 | 301 | int i, j, usedbanks[8]; |
| 298 | 302 | long bank_offset; |
| 299 | 303 | unsigned char lo, hi, data; |
| 300 | 304 | unsigned short addr; |
| 301 | 305 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 302 | 306 | |
| 303 | | if ((SnapshotSize != 49179) && (spectrum_128_port_7ffd_data == -1)) |
| 307 | if ((SnapshotSize != 49179) && (state->port_7ffd_data == -1)) |
| 304 | 308 | { |
| 305 | 309 | logerror("Can't load 128K .SNA file into 48K machine\n"); |
| 306 | 310 | return; |
| r7288 | r7289 | |
| 349 | 353 | cpu_set_reg(devtag_get_device(machine, "maincpu"), Z80_IM, data); |
| 350 | 354 | |
| 351 | 355 | /* Set border colour */ |
| 352 | | spectrum_PreviousFE = (spectrum_PreviousFE & 0xf8) | (pSnapshot[26] & 0x07); |
| 356 | state->port_fe_data = (state->port_fe_data & 0xf8) | (pSnapshot[26] & 0x07); |
| 353 | 357 | EventList_Reset(); |
| 354 | 358 | border_set_last_color(pSnapshot[26] & 0x07); |
| 355 | 359 | border_force_redraw(); |
| r7288 | r7289 | |
| 364 | 368 | else |
| 365 | 369 | { |
| 366 | 370 | /* 128K Snapshot */ |
| 367 | | spectrum_128_port_7ffd_data = (pSnapshot[49181] & 0x0ff); |
| 371 | state->port_7ffd_data = (pSnapshot[49181] & 0x0ff); |
| 368 | 372 | spectrum_update_paging(machine); |
| 369 | 373 | } |
| 370 | 374 | |
| r7288 | r7289 | |
| 399 | 403 | |
| 400 | 404 | usedbanks[5] = 1; /* 0x4000-0x7fff */ |
| 401 | 405 | usedbanks[2] = 1; /* 0x8000-0xbfff */ |
| 402 | | usedbanks[spectrum_128_port_7ffd_data & 0x07] = 1; /* Banked memory */ |
| 406 | usedbanks[state->port_7ffd_data & 0x07] = 1; /* Banked memory */ |
| 403 | 407 | |
| 404 | 408 | for (i = 0; i < 8; i++) |
| 405 | 409 | { |
| 406 | 410 | if (!usedbanks[i]) |
| 407 | 411 | { |
| 408 | 412 | logerror("Loading bank %d from offset %ld\n", i, bank_offset); |
| 409 | | spectrum_128_port_7ffd_data &= 0xf8; |
| 410 | | spectrum_128_port_7ffd_data += i; |
| 413 | state->port_7ffd_data &= 0xf8; |
| 414 | state->port_7ffd_data += i; |
| 411 | 415 | spectrum_update_paging(machine); |
| 412 | 416 | for (j = 0; j < 16384; j++) |
| 413 | 417 | memory_write_byte(space,j + 49152, pSnapshot[bank_offset + j]); |
| r7288 | r7289 | |
| 416 | 420 | } |
| 417 | 421 | |
| 418 | 422 | /* Reset paging */ |
| 419 | | spectrum_128_port_7ffd_data = (pSnapshot[49181] & 0x0ff); |
| 423 | state->port_7ffd_data = (pSnapshot[49181] & 0x0ff); |
| 420 | 424 | spectrum_update_paging(machine); |
| 421 | 425 | |
| 422 | 426 | /* program counter */ |
| r7288 | r7289 | |
| 544 | 548 | /* now supports 48k & 128k .Z80 files */ |
| 545 | 549 | void spectrum_setup_z80(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 546 | 550 | { |
| 551 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 547 | 552 | int i; |
| 548 | 553 | unsigned char lo, hi, data; |
| 549 | 554 | SPECTRUM_Z80_SNAPSHOT_TYPE z80_type; |
| r7288 | r7289 | |
| 564 | 569 | break; |
| 565 | 570 | case SPECTRUM_Z80_SNAPSHOT_128K: |
| 566 | 571 | logerror("128K .Z80 file\n"); |
| 567 | | if (spectrum_128_port_7ffd_data == -1) |
| 572 | if (state->port_7ffd_data == -1) |
| 568 | 573 | { |
| 569 | 574 | logerror("Not a 48K .Z80 file\n"); |
| 570 | 575 | return; |
| r7288 | r7289 | |
| 611 | 616 | cpu_set_reg(devtag_get_device(machine, "maincpu"), Z80_R, data); |
| 612 | 617 | |
| 613 | 618 | /* Set border colour */ |
| 614 | | spectrum_PreviousFE = (spectrum_PreviousFE & 0xf8) | ((pSnapshot[12] & 0x0e) >> 1); |
| 619 | state->port_fe_data = (state->port_fe_data & 0xf8) | ((pSnapshot[12] & 0x0e) >> 1); |
| 615 | 620 | EventList_Reset(); |
| 616 | 621 | border_set_last_color((pSnapshot[12] & 0x0e) >> 1); |
| 617 | 622 | border_force_redraw(); |
| r7288 | r7289 | |
| 749 | 754 | if ((page >= 3) && (page <= 10)) |
| 750 | 755 | { |
| 751 | 756 | /* Page the appropriate bank into 0xc000 - 0xfff */ |
| 752 | | spectrum_128_port_7ffd_data = page - 3; |
| 757 | state->port_7ffd_data = page - 3; |
| 753 | 758 | spectrum_update_paging(machine); |
| 754 | 759 | Dest = 0x0c000; |
| 755 | 760 | } |
| r7288 | r7289 | |
| 783 | 788 | } |
| 784 | 789 | while ((pSource - pSnapshot) < SnapshotSize); |
| 785 | 790 | |
| 786 | | if ((spectrum_128_port_7ffd_data != -1) && (z80_type != SPECTRUM_Z80_SNAPSHOT_48K)) |
| 791 | if ((state->port_7ffd_data != -1) && (z80_type != SPECTRUM_Z80_SNAPSHOT_48K)) |
| 787 | 792 | { |
| 788 | 793 | /* Set up paging */ |
| 789 | | spectrum_128_port_7ffd_data = (pSnapshot[35] & 0x0ff); |
| 794 | state->port_7ffd_data = (pSnapshot[35] & 0x0ff); |
| 790 | 795 | spectrum_update_paging(machine); |
| 791 | 796 | } |
| 792 | 797 | if ((z80_type == SPECTRUM_Z80_SNAPSHOT_48K) && !strcmp(machine->gamedrv->name,"ts2068")) |
| 793 | 798 | { |
| 794 | | ts2068_port_f4_data = 0x03; |
| 795 | | ts2068_port_ff_data = 0x00; |
| 799 | state->port_f4_data = 0x03; |
| 800 | state->port_ff_data = 0x00; |
| 796 | 801 | ts2068_update_memory(machine); |
| 797 | 802 | } |
| 798 | 803 | if (z80_type == SPECTRUM_Z80_SNAPSHOT_TS2068 && !strcmp(machine->gamedrv->name,"ts2068")) |
| 799 | 804 | { |
| 800 | | ts2068_port_f4_data = pSnapshot[35]; |
| 801 | | ts2068_port_ff_data = pSnapshot[36]; |
| 805 | state->port_f4_data = pSnapshot[35]; |
| 806 | state->port_ff_data = pSnapshot[36]; |
| 802 | 807 | ts2068_update_memory(machine); |
| 803 | 808 | } |
| 804 | 809 | } |
src/mess/drivers/scorpion.c
| r7288 | r7289 | |
| 184 | 184 | |
| 185 | 185 | /* rom 0=zx128, 1=zx48, 2 = service monitor, 3=tr-dos */ |
| 186 | 186 | |
| 187 | | static int scorpion_256_port_1ffd_data = 0; |
| 188 | | |
| 189 | | static int ROMSelection; |
| 190 | | |
| 191 | | static running_device* beta; |
| 192 | | |
| 193 | | //static UINT8 *rom_pointer; |
| 194 | | |
| 195 | 187 | static void scorpion_update_memory(running_machine *machine) |
| 196 | 188 | { |
| 189 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 190 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 197 | 191 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 198 | | spectrum_screen_location = messram_get_ptr(devtag_get_device(machine, "messram")) + ((spectrum_128_port_7ffd_data & 8) ? (7<<14) : (5<<14)); |
| 199 | 192 | |
| 200 | | memory_set_bankptr(machine, "bank4", messram_get_ptr(devtag_get_device(machine, "messram")) + (((spectrum_128_port_7ffd_data & 0x07) | ((scorpion_256_port_1ffd_data & 0x10)>>1)) * 0x4000)); |
| 193 | state->screen_location = messram + ((state->port_7ffd_data & 8) ? (7<<14) : (5<<14)); |
| 201 | 194 | |
| 202 | | if ((scorpion_256_port_1ffd_data & 0x01)==0x01) |
| 195 | memory_set_bankptr(machine, "bank4", messram + (((state->port_7ffd_data & 0x07) | ((state->port_1ffd_data & 0x10)>>1)) * 0x4000)); |
| 196 | |
| 197 | if ((state->port_1ffd_data & 0x01)==0x01) |
| 203 | 198 | { |
| 204 | 199 | memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank1"); |
| 205 | | memory_set_bankptr(machine, "bank1", messram_get_ptr(devtag_get_device(machine, "messram"))+(8<<14)); |
| 200 | memory_set_bankptr(machine, "bank1", messram+(8<<14)); |
| 206 | 201 | logerror("RAM\n"); |
| 207 | 202 | } |
| 208 | 203 | else |
| 209 | 204 | { |
| 210 | | if ((scorpion_256_port_1ffd_data & 0x02)==0x02) |
| 205 | if ((state->port_1ffd_data & 0x02)==0x02) |
| 211 | 206 | { |
| 212 | | ROMSelection = 2; |
| 207 | state->ROMSelection = 2; |
| 213 | 208 | } |
| 214 | 209 | else |
| 215 | 210 | { |
| 216 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 211 | state->ROMSelection = ((state->port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 217 | 212 | } |
| 218 | 213 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 219 | | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0x010000 + (ROMSelection<<14)); |
| 214 | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0x010000 + (state->ROMSelection<<14)); |
| 220 | 215 | } |
| 221 | 216 | |
| 222 | 217 | |
| r7288 | r7289 | |
| 224 | 219 | |
| 225 | 220 | static DIRECT_UPDATE_HANDLER( scorpion_direct ) |
| 226 | 221 | { |
| 222 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 223 | running_device *beta = devtag_get_device(space->machine, BETA_DISK_TAG); |
| 227 | 224 | UINT16 pc = cpu_get_reg(devtag_get_device(space->machine, "maincpu"), REG_GENPCBASE); |
| 225 | |
| 228 | 226 | if (betadisk_is_active(beta)) |
| 229 | 227 | { |
| 230 | 228 | if (pc >= 0x4000) |
| 231 | 229 | { |
| 232 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 230 | state->ROMSelection = ((state->port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 233 | 231 | betadisk_disable(beta); |
| 234 | 232 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 235 | | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x010000 + (ROMSelection<<14)); |
| 233 | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x010000 + (state->ROMSelection<<14)); |
| 236 | 234 | } |
| 237 | | } else if (((pc & 0xff00) == 0x3d00) && (ROMSelection==1)) |
| 235 | } |
| 236 | else if (((pc & 0xff00) == 0x3d00) && (state->ROMSelection==1)) |
| 238 | 237 | { |
| 239 | | ROMSelection = 3; |
| 238 | state->ROMSelection = 3; |
| 240 | 239 | betadisk_enable(beta); |
| 241 | | |
| 242 | 240 | } |
| 243 | 241 | if((address>=0x0000) && (address<=0x3fff)) |
| 244 | 242 | { |
| 245 | 243 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 246 | | direct->raw = direct->decrypted = memory_region(space->machine, "maincpu") + 0x010000 + (ROMSelection<<14); |
| 244 | direct->raw = direct->decrypted = memory_region(space->machine, "maincpu") + 0x010000 + (state->ROMSelection<<14); |
| 247 | 245 | memory_set_bankptr(space->machine, "bank1", direct->raw); |
| 248 | 246 | return ~0; |
| 249 | 247 | } |
| r7288 | r7289 | |
| 252 | 250 | |
| 253 | 251 | static TIMER_CALLBACK(nmi_check_callback) |
| 254 | 252 | { |
| 253 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 254 | |
| 255 | 255 | if ((input_port_read(machine, "NMI") & 1)==1) |
| 256 | 256 | { |
| 257 | | scorpion_256_port_1ffd_data |= 0x02; |
| 257 | state->port_1ffd_data |= 0x02; |
| 258 | 258 | scorpion_update_memory(machine); |
| 259 | 259 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); |
| 260 | 260 | } |
| r7288 | r7289 | |
| 262 | 262 | |
| 263 | 263 | static WRITE8_HANDLER(scorpion_port_7ffd_w) |
| 264 | 264 | { |
| 265 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 266 | |
| 265 | 267 | /* disable paging */ |
| 266 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 268 | if (state->port_7ffd_data & 0x20) |
| 267 | 269 | return; |
| 268 | 270 | |
| 269 | 271 | /* store new state */ |
| 270 | | spectrum_128_port_7ffd_data = data; |
| 272 | state->port_7ffd_data = data; |
| 271 | 273 | |
| 272 | 274 | /* update memory */ |
| 273 | 275 | scorpion_update_memory(space->machine); |
| r7288 | r7289 | |
| 275 | 277 | |
| 276 | 278 | static WRITE8_HANDLER(scorpion_port_1ffd_w) |
| 277 | 279 | { |
| 280 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 281 | |
| 278 | 282 | /* if paging not disabled */ |
| 279 | | if ((spectrum_128_port_7ffd_data & 0x20)==0) |
| 283 | if ((state->port_7ffd_data & 0x20)==0) |
| 280 | 284 | { |
| 281 | | scorpion_256_port_1ffd_data = data; |
| 285 | state->port_1ffd_data = data; |
| 282 | 286 | scorpion_update_memory(space->machine); |
| 283 | 287 | } |
| 284 | 288 | } |
| r7288 | r7289 | |
| 300 | 304 | |
| 301 | 305 | static MACHINE_RESET( scorpion ) |
| 302 | 306 | { |
| 307 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 308 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 309 | running_device *beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 303 | 310 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 304 | | beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 305 | 311 | |
| 306 | 312 | memory_install_read_bank (space, 0x0000, 0x3fff, 0, 0, "bank1"); |
| 307 | 313 | |
| 308 | 314 | betadisk_disable(beta); |
| 309 | 315 | betadisk_clear_status(beta); |
| 310 | 316 | |
| 311 | | memory_set_direct_update_handler(space, scorpion_direct ); |
| 317 | memory_set_direct_update_handler(space, scorpion_direct); |
| 312 | 318 | |
| 313 | | memset(messram_get_ptr(devtag_get_device(machine, "messram")),0,256*1024); |
| 319 | memset(messram,0,256*1024); |
| 314 | 320 | |
| 315 | 321 | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 316 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(devtag_get_device(machine, "messram")) + (5<<14)); |
| 322 | memory_set_bankptr(machine, "bank2", messram + (5<<14)); |
| 317 | 323 | |
| 318 | 324 | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 319 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(devtag_get_device(machine, "messram")) + (2<<14)); |
| 325 | memory_set_bankptr(machine, "bank3", messram + (2<<14)); |
| 320 | 326 | |
| 321 | | spectrum_128_port_7ffd_data = 0; |
| 322 | | scorpion_256_port_1ffd_data = 0; |
| 323 | | |
| 327 | state->port_7ffd_data = 0; |
| 328 | state->port_1ffd_data = 0; |
| 324 | 329 | scorpion_update_memory(machine); |
| 325 | 330 | } |
| 326 | 331 | static MACHINE_START( scorpion ) |
src/mess/drivers/spec128.c
| r7288 | r7289 | |
| 170 | 170 | /****************************************************************************************************/ |
| 171 | 171 | /* Spectrum 128 specific functions */ |
| 172 | 172 | |
| 173 | | int spectrum_128_port_7ffd_data = -1; |
| 174 | | |
| 175 | 173 | static WRITE8_HANDLER(spectrum_128_port_7ffd_w) |
| 176 | 174 | { |
| 175 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 176 | |
| 177 | 177 | /* D0-D2: RAM page located at 0x0c000-0x0ffff */ |
| 178 | 178 | /* D3 - Screen select (screen 0 in ram page 5, screen 1 in ram page 7 */ |
| 179 | 179 | /* D4 - ROM select - which rom paged into 0x0000-0x03fff */ |
| 180 | 180 | /* D5 - Disable paging */ |
| 181 | 181 | |
| 182 | 182 | /* disable paging? */ |
| 183 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 183 | if (state->port_7ffd_data & 0x20) |
| 184 | 184 | return; |
| 185 | 185 | |
| 186 | 186 | /* store new state */ |
| 187 | | spectrum_128_port_7ffd_data = data; |
| 187 | state->port_7ffd_data = data; |
| 188 | 188 | |
| 189 | 189 | /* update memory */ |
| 190 | 190 | spectrum_128_update_memory(space->machine); |
| r7288 | r7289 | |
| 192 | 192 | |
| 193 | 193 | void spectrum_128_update_memory(running_machine *machine) |
| 194 | 194 | { |
| 195 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 196 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 195 | 197 | unsigned char *ChosenROM; |
| 196 | 198 | int ROMSelection; |
| 197 | 199 | |
| 198 | | if (spectrum_128_port_7ffd_data & 8) |
| 200 | if (state->port_7ffd_data & 8) |
| 199 | 201 | { |
| 200 | | spectrum_screen_location = messram_get_ptr(devtag_get_device(machine, "messram")) + (7<<14); |
| 202 | state->screen_location = messram + (7<<14); |
| 201 | 203 | } |
| 202 | 204 | else |
| 203 | 205 | { |
| 204 | | spectrum_screen_location = messram_get_ptr(devtag_get_device(machine, "messram")) + (5<<14); |
| 206 | state->screen_location = messram + (5<<14); |
| 205 | 207 | } |
| 206 | 208 | |
| 207 | 209 | /* select ram at 0x0c000-0x0ffff */ |
| 208 | 210 | { |
| 209 | | int ram_page; |
| 210 | | unsigned char *ram_data; |
| 211 | int ram_page; |
| 212 | unsigned char *ram_data; |
| 211 | 213 | |
| 212 | | ram_page = spectrum_128_port_7ffd_data & 0x07; |
| 213 | | ram_data = messram_get_ptr(devtag_get_device(machine, "messram")) + (ram_page<<14); |
| 214 | ram_page = state->port_7ffd_data & 0x07; |
| 215 | ram_data = messram + (ram_page<<14); |
| 214 | 216 | |
| 215 | | memory_set_bankptr(machine, "bank4", ram_data); |
| 217 | memory_set_bankptr(machine, "bank4", ram_data); |
| 216 | 218 | } |
| 217 | 219 | |
| 218 | 220 | /* ROM switching */ |
| 219 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01); |
| 221 | ROMSelection = ((state->port_7ffd_data>>4) & 0x01); |
| 220 | 222 | |
| 221 | 223 | /* rom 0 is 128K rom, rom 1 is 48 BASIC */ |
| 222 | 224 | |
| r7288 | r7289 | |
| 227 | 229 | |
| 228 | 230 | static READ8_HANDLER ( spectrum_128_ula_r ) |
| 229 | 231 | { |
| 230 | | return video_screen_get_vpos(space->machine->primary_screen)<193 ? spectrum_screen_location[0x1800|(video_screen_get_vpos(space->machine->primary_screen)&0xf8)<<2]:0xff; |
| 232 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 233 | int vpos = video_screen_get_vpos(space->machine->primary_screen); |
| 234 | |
| 235 | return vpos<193 ? state->screen_location[0x1800|(vpos&0xf8)<<2]:0xff; |
| 231 | 236 | } |
| 232 | 237 | |
| 233 | 238 | static ADDRESS_MAP_START (spectrum_128_io, ADDRESS_SPACE_IO, 8) |
| r7288 | r7289 | |
| 250 | 255 | |
| 251 | 256 | static MACHINE_RESET( spectrum_128 ) |
| 252 | 257 | { |
| 253 | | memset(messram_get_ptr(devtag_get_device(machine, "messram")),0,128*1024); |
| 258 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 259 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 260 | |
| 261 | memset(messram,0,128*1024); |
| 254 | 262 | /* 0x0000-0x3fff always holds ROM */ |
| 255 | 263 | |
| 256 | 264 | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 257 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(devtag_get_device(machine, "messram")) + (5<<14)); |
| 265 | memory_set_bankptr(machine, "bank2", messram + (5<<14)); |
| 258 | 266 | |
| 259 | 267 | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 260 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(devtag_get_device(machine, "messram")) + (2<<14)); |
| 268 | memory_set_bankptr(machine, "bank3", messram + (2<<14)); |
| 261 | 269 | |
| 270 | MACHINE_RESET_CALL(spectrum); |
| 271 | |
| 262 | 272 | /* set initial ram config */ |
| 263 | | spectrum_128_port_7ffd_data = 0; |
| 273 | state->port_7ffd_data = 0; |
| 274 | state->port_1ffd_data = -1; |
| 264 | 275 | spectrum_128_update_memory(machine); |
| 265 | | |
| 266 | | MACHINE_RESET_CALL(spectrum); |
| 267 | 276 | } |
| 268 | 277 | |
| 269 | 278 | /* F4 Character Displayer */ |
src/mess/drivers/atm.c
| r7288 | r7289 | |
| 10 | 10 | #include "machine/beta.h" |
| 11 | 11 | #include "devices/messram.h" |
| 12 | 12 | |
| 13 | | static int ROMSelection; |
| 14 | | static running_device* beta; |
| 15 | | |
| 16 | 13 | static DIRECT_UPDATE_HANDLER( atm_direct ) |
| 17 | 14 | { |
| 15 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 16 | running_device *beta = devtag_get_device(space->machine, BETA_DISK_TAG); |
| 18 | 17 | UINT16 pc = cpu_get_reg(devtag_get_device(space->machine, "maincpu"), REG_GENPCBASE); |
| 19 | 18 | |
| 20 | 19 | if (beta->started && betadisk_is_active(beta)) |
| 21 | 20 | { |
| 22 | 21 | if (pc >= 0x4000) |
| 23 | 22 | { |
| 24 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 23 | state->ROMSelection = ((state->port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 25 | 24 | betadisk_disable(beta); |
| 26 | 25 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 27 | | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x010000 + (ROMSelection<<14)); |
| 26 | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x010000 + (state->ROMSelection<<14)); |
| 28 | 27 | } |
| 29 | | } else if (((pc & 0xff00) == 0x3d00) && (ROMSelection==1)) |
| 28 | } |
| 29 | else if (((pc & 0xff00) == 0x3d00) && (state->ROMSelection==1)) |
| 30 | 30 | { |
| 31 | | ROMSelection = 3; |
| 31 | state->ROMSelection = 3; |
| 32 | 32 | if (beta->started) |
| 33 | 33 | betadisk_enable(beta); |
| 34 | 34 | |
| r7288 | r7289 | |
| 36 | 36 | if((address>=0x0000) && (address<=0x3fff)) |
| 37 | 37 | { |
| 38 | 38 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 39 | | if (ROMSelection == 3) { |
| 39 | if (state->ROMSelection == 3) { |
| 40 | 40 | direct->raw = direct->decrypted = memory_region(space->machine, "maincpu") + 0x018000 ; |
| 41 | 41 | } else { |
| 42 | | direct->raw = direct->decrypted = memory_region(space->machine, "maincpu") + 0x010000 + (ROMSelection<<14); |
| 42 | direct->raw = direct->decrypted = memory_region(space->machine, "maincpu") + 0x010000 + (state->ROMSelection<<14); |
| 43 | 43 | } |
| 44 | 44 | memory_set_bankptr(space->machine, "bank1", direct->raw); |
| 45 | 45 | return ~0; |
| r7288 | r7289 | |
| 49 | 49 | |
| 50 | 50 | static void atm_update_memory(running_machine *machine) |
| 51 | 51 | { |
| 52 | | spectrum_screen_location = messram_get_ptr(devtag_get_device(machine, "messram")) + ((spectrum_128_port_7ffd_data & 8) ? (7<<14) : (5<<14)); |
| 52 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 53 | running_device *beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 54 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 53 | 55 | |
| 54 | | memory_set_bankptr(machine, "bank4", messram_get_ptr(devtag_get_device(machine, "messram")) + ((spectrum_128_port_7ffd_data & 0x07) * 0x4000)); |
| 56 | state->screen_location = messram + ((state->port_7ffd_data & 8) ? (7<<14) : (5<<14)); |
| 55 | 57 | |
| 56 | | if (beta->started && betadisk_is_active(beta) && !( spectrum_128_port_7ffd_data & 0x10 ) ) |
| 58 | memory_set_bankptr(machine, "bank4", messram + ((state->port_7ffd_data & 0x07) * 0x4000)); |
| 59 | |
| 60 | if (beta->started && betadisk_is_active(beta) && !( state->port_7ffd_data & 0x10 ) ) |
| 57 | 61 | { |
| 58 | | ROMSelection = 3; |
| 62 | state->ROMSelection = 3; |
| 59 | 63 | } |
| 60 | 64 | else { |
| 61 | 65 | /* ROM switching */ |
| 62 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ; |
| 66 | state->ROMSelection = ((state->port_7ffd_data>>4) & 0x01) ; |
| 63 | 67 | } |
| 64 | 68 | /* rom 0 is 128K rom, rom 1 is 48 BASIC */ |
| 65 | | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0x010000 + (ROMSelection<<14)); |
| 69 | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0x010000 + (state->ROMSelection<<14)); |
| 66 | 70 | } |
| 67 | 71 | |
| 68 | 72 | static WRITE8_HANDLER(atm_port_7ffd_w) |
| 69 | 73 | { |
| 74 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 75 | |
| 70 | 76 | /* disable paging */ |
| 71 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 77 | if (state->port_7ffd_data & 0x20) |
| 72 | 78 | return; |
| 73 | 79 | |
| 74 | 80 | /* store new state */ |
| 75 | | spectrum_128_port_7ffd_data = data; |
| 81 | state->port_7ffd_data = data; |
| 76 | 82 | |
| 77 | 83 | /* update memory */ |
| 78 | 84 | atm_update_memory(space->machine); |
| r7288 | r7289 | |
| 93 | 99 | |
| 94 | 100 | static MACHINE_RESET( atm ) |
| 95 | 101 | { |
| 102 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 103 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 96 | 104 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 97 | | beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 105 | running_device *beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 98 | 106 | |
| 99 | 107 | memory_install_read_bank(space, 0x0000, 0x3fff, 0, 0, "bank1"); |
| 100 | 108 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| r7288 | r7289 | |
| 106 | 114 | |
| 107 | 115 | memory_set_direct_update_handler( space, atm_direct ); |
| 108 | 116 | |
| 109 | | memset(messram_get_ptr(devtag_get_device(machine, "messram")),0,128*1024); |
| 117 | memset(messram,0,128*1024); |
| 110 | 118 | |
| 111 | 119 | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 112 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(devtag_get_device(machine, "messram")) + (5<<14)); |
| 120 | memory_set_bankptr(machine, "bank2", messram + (5<<14)); |
| 113 | 121 | |
| 114 | 122 | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 115 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(devtag_get_device(machine, "messram")) + (2<<14)); |
| 123 | memory_set_bankptr(machine, "bank3", messram + (2<<14)); |
| 116 | 124 | |
| 117 | | spectrum_128_port_7ffd_data = 0; |
| 125 | state->port_7ffd_data = 0; |
| 126 | state->port_1ffd_data = -1; |
| 118 | 127 | |
| 119 | 128 | atm_update_memory(machine); |
| 120 | 129 | } |
src/mess/drivers/sord.c
| r7288 | r7289 | |
| 58 | 58 | /* PI-5 interface is required. mode 2 of the 8255 is used to communicate with the FD-5 */ |
| 59 | 59 | |
| 60 | 60 | |
| 61 | typedef struct _sord_state sord_state; |
| 62 | struct _sord_state |
| 63 | { |
| 64 | UINT8 fd5_databus; |
| 65 | int fd5_port_0x020_data; |
| 66 | int obfa; |
| 67 | int ibfa; |
| 68 | int intra; |
| 69 | }; |
| 70 | |
| 61 | 71 | static MACHINE_RESET( sord_m5 ); |
| 62 | 72 | |
| 63 | | static UINT8 fd5_databus; |
| 64 | | |
| 65 | 73 | static ADDRESS_MAP_START( sord_fd5_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 66 | 74 | AM_RANGE(0x0000, 0x03fff) AM_ROM /* internal rom */ |
| 67 | 75 | AM_RANGE(0x4000, 0x0ffff) AM_RAM |
| 68 | 76 | ADDRESS_MAP_END |
| 69 | 77 | |
| 70 | 78 | |
| 71 | | static int obfa,ibfa, intra; |
| 72 | | static int fd5_port_0x020_data; |
| 73 | | |
| 74 | 79 | /* stb and ack automatically set on read/write? */ |
| 75 | 80 | static WRITE8_HANDLER(fd5_communication_w) |
| 76 | 81 | { |
| 82 | sord_state *state = (sord_state *)space->machine->driver_data; |
| 83 | |
| 77 | 84 | cpu_yield(space->cpu); |
| 78 | 85 | |
| 79 | | fd5_port_0x020_data = data; |
| 86 | state->fd5_port_0x020_data = data; |
| 80 | 87 | LOG(("fd5 0x020: %02x %04x\n",data,cpu_get_pc(space->cpu))); |
| 81 | 88 | } |
| 82 | 89 | |
| 83 | 90 | static READ8_HANDLER(fd5_communication_r) |
| 84 | 91 | { |
| 92 | sord_state *state = (sord_state *)space->machine->driver_data; |
| 85 | 93 | int data; |
| 86 | 94 | |
| 87 | 95 | cpu_yield(space->cpu); |
| 88 | 96 | |
| 89 | | data = (obfa<<3)|(ibfa<<2)|2; |
| 97 | data = (state->obfa<<3)|(state->ibfa<<2)|2; |
| 90 | 98 | LOG(("fd5 0x030: %02x %04x\n",data, cpu_get_pc(space->cpu))); |
| 91 | 99 | |
| 92 | 100 | return data; |
| r7288 | r7289 | |
| 94 | 102 | |
| 95 | 103 | static READ8_HANDLER(fd5_data_r) |
| 96 | 104 | { |
| 105 | sord_state *state = (sord_state *)space->machine->driver_data; |
| 106 | |
| 97 | 107 | cpu_yield(space->cpu); |
| 98 | 108 | |
| 99 | | LOG(("fd5 0x010 r: %02x %04x\n",fd5_databus,cpu_get_pc(space->cpu))); |
| 109 | LOG(("fd5 0x010 r: %02x %04x\n",state->fd5_databus,cpu_get_pc(space->cpu))); |
| 100 | 110 | |
| 101 | 111 | ppi8255_set_port_c(devtag_get_device(space->machine, "ppi8255"), 0x50); |
| 102 | 112 | ppi8255_set_port_c(devtag_get_device(space->machine, "ppi8255"), 0x10); |
| 103 | 113 | ppi8255_set_port_c(devtag_get_device(space->machine, "ppi8255"), 0x50); |
| 104 | 114 | |
| 105 | | return fd5_databus; |
| 115 | return state->fd5_databus; |
| 106 | 116 | } |
| 107 | 117 | |
| 108 | 118 | static WRITE8_HANDLER(fd5_data_w) |
| 109 | 119 | { |
| 120 | sord_state *state = (sord_state *)space->machine->driver_data; |
| 121 | |
| 110 | 122 | LOG(("fd5 0x010 w: %02x %04x\n",data,cpu_get_pc(space->cpu))); |
| 111 | 123 | |
| 112 | | fd5_databus = data; |
| 124 | state->fd5_databus = data; |
| 113 | 125 | |
| 114 | 126 | /* set stb on data write */ |
| 115 | 127 | ppi8255_set_port_c(devtag_get_device(space->machine, "ppi8255"), 0x50); |
| r7288 | r7289 | |
| 185 | 197 | |
| 186 | 198 | static READ8_DEVICE_HANDLER(sord_ppi_porta_r) |
| 187 | 199 | { |
| 200 | sord_state *state = (sord_state *)device->machine->driver_data; |
| 201 | |
| 188 | 202 | cpu_yield(devtag_get_device(device->machine, "maincpu")); |
| 189 | 203 | |
| 190 | | return fd5_databus; |
| 204 | return state->fd5_databus; |
| 191 | 205 | } |
| 192 | 206 | |
| 193 | 207 | static READ8_DEVICE_HANDLER(sord_ppi_portb_r) |
| r7288 | r7289 | |
| 201 | 215 | |
| 202 | 216 | static READ8_DEVICE_HANDLER(sord_ppi_portc_r) |
| 203 | 217 | { |
| 218 | sord_state *state = (sord_state *)device->machine->driver_data; |
| 219 | |
| 204 | 220 | cpu_yield(devtag_get_device(device->machine, "maincpu")); |
| 205 | 221 | |
| 206 | 222 | LOG(("m5 read from pi5 port c %04x\n", cpu_get_pc(devtag_get_device(device->machine, "maincpu")))); |
| r7288 | r7289 | |
| 222 | 238 | /* FD5 bit 1 -> M5 bit 0 */ |
| 223 | 239 | return ( |
| 224 | 240 | /* FD5 bit 0-> M5 bit 2 */ |
| 225 | | ((fd5_port_0x020_data & 0x01)<<2) | |
| 241 | ((state->fd5_port_0x020_data & 0x01)<<2) | |
| 226 | 242 | /* FD5 bit 2-> M5 bit 1 */ |
| 227 | | ((fd5_port_0x020_data & 0x04)>>1) | |
| 243 | ((state->fd5_port_0x020_data & 0x04)>>1) | |
| 228 | 244 | /* FD5 bit 1-> M5 bit 0 */ |
| 229 | | ((fd5_port_0x020_data & 0x02)>>1) |
| 245 | ((state->fd5_port_0x020_data & 0x02)>>1) |
| 230 | 246 | ); |
| 231 | 247 | } |
| 232 | 248 | |
| 233 | 249 | static WRITE8_DEVICE_HANDLER(sord_ppi_porta_w) |
| 234 | 250 | { |
| 251 | sord_state *state = (sord_state *)device->machine->driver_data; |
| 252 | |
| 235 | 253 | cpu_yield(devtag_get_device(device->machine, "maincpu")); |
| 236 | 254 | |
| 237 | | fd5_databus = data; |
| 255 | state->fd5_databus = data; |
| 238 | 256 | } |
| 239 | 257 | |
| 240 | 258 | static WRITE8_DEVICE_HANDLER(sord_ppi_portb_w) |
| r7288 | r7289 | |
| 261 | 279 | |
| 262 | 280 | static WRITE8_DEVICE_HANDLER(sord_ppi_portc_w) |
| 263 | 281 | { |
| 264 | | obfa = (data & 0x80) ? 1 : 0; |
| 265 | | intra = (data & 0x08) ? 1 : 0; |
| 266 | | ibfa = (data & 0x20) ? 1 : 0; |
| 282 | sord_state *state = (sord_state *)device->machine->driver_data; |
| 267 | 283 | |
| 284 | state->obfa = (data & 0x80) ? 1 : 0; |
| 285 | state->intra = (data & 0x08) ? 1 : 0; |
| 286 | state->ibfa = (data & 0x20) ? 1 : 0; |
| 287 | |
| 268 | 288 | cpu_yield(devtag_get_device(device->machine, "maincpu")); |
| 269 | 289 | LOG(("m5 write to pi5 port c: %02x %04x\n", data, cpu_get_pc(devtag_get_device(device->machine, "maincpu")))); |
| 270 | 290 | } |
| r7288 | r7289 | |
| 517 | 537 | |
| 518 | 538 | |
| 519 | 539 | static MACHINE_DRIVER_START( sord_m5 ) |
| 540 | |
| 541 | MDRV_DRIVER_DATA( sord_state ) |
| 542 | |
| 520 | 543 | /* basic machine hardware */ |
| 521 | 544 | MDRV_CPU_ADD("maincpu", Z80, XTAL_14_31818MHz/4) |
| 522 | 545 | MDRV_CPU_PROGRAM_MAP(sord_m5_mem) |
src/mess/drivers/pentagon.c
| r7288 | r7289 | |
| 10 | 10 | #include "machine/beta.h" |
| 11 | 11 | #include "devices/messram.h" |
| 12 | 12 | |
| 13 | | static int ROMSelection; |
| 14 | | static running_device* beta; |
| 15 | | |
| 16 | 13 | static DIRECT_UPDATE_HANDLER( pentagon_direct ) |
| 17 | 14 | { |
| 15 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 16 | running_device *beta = devtag_get_device(space->machine, BETA_DISK_TAG); |
| 18 | 17 | UINT16 pc = cpu_get_reg(devtag_get_device(space->machine, "maincpu"), REG_GENPCBASE); |
| 19 | 18 | |
| 20 | 19 | if (beta->started && betadisk_is_active(beta)) |
| 21 | 20 | { |
| 22 | 21 | if (pc >= 0x4000) |
| 23 | 22 | { |
| 24 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 23 | state->ROMSelection = ((state->port_7ffd_data>>4) & 0x01) ? 1 : 0; |
| 25 | 24 | betadisk_disable(beta); |
| 26 | 25 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 27 | | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x010000 + (ROMSelection<<14)); |
| 26 | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x010000 + (state->ROMSelection<<14)); |
| 28 | 27 | } |
| 29 | | } else if (((pc & 0xff00) == 0x3d00) && (ROMSelection==1)) |
| 28 | } else if (((pc & 0xff00) == 0x3d00) && (state->ROMSelection==1)) |
| 30 | 29 | { |
| 31 | | ROMSelection = 3; |
| 30 | state->ROMSelection = 3; |
| 32 | 31 | if (beta->started) |
| 33 | 32 | betadisk_enable(beta); |
| 34 | 33 | |
| r7288 | r7289 | |
| 36 | 35 | if((address>=0x0000) && (address<=0x3fff)) |
| 37 | 36 | { |
| 38 | 37 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| 39 | | if (ROMSelection == 3) { |
| 38 | if (state->ROMSelection == 3) { |
| 40 | 39 | if (beta->started) |
| 41 | 40 | direct->raw = direct->decrypted = memory_region(space->machine, "beta:beta"); |
| 42 | 41 | } else { |
| 43 | | direct->raw = direct->decrypted = memory_region(space->machine, "maincpu") + 0x010000 + (ROMSelection<<14); |
| 42 | direct->raw = direct->decrypted = memory_region(space->machine, "maincpu") + 0x010000 + (state->ROMSelection<<14); |
| 44 | 43 | } |
| 45 | 44 | memory_set_bankptr(space->machine, "bank1", direct->raw); |
| 46 | 45 | return ~0; |
| r7288 | r7289 | |
| 50 | 49 | |
| 51 | 50 | static void pentagon_update_memory(running_machine *machine) |
| 52 | 51 | { |
| 53 | | spectrum_screen_location = messram_get_ptr(devtag_get_device(machine, "messram")) + ((spectrum_128_port_7ffd_data & 8) ? (7<<14) : (5<<14)); |
| 52 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 53 | running_device *beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 54 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 55 | state->screen_location = messram + ((state->port_7ffd_data & 8) ? (7<<14) : (5<<14)); |
| 54 | 56 | |
| 55 | | memory_set_bankptr(machine, "bank4", messram_get_ptr(devtag_get_device(machine, "messram")) + ((spectrum_128_port_7ffd_data & 0x07) * 0x4000)); |
| 57 | memory_set_bankptr(machine, "bank4", messram + ((state->port_7ffd_data & 0x07) * 0x4000)); |
| 56 | 58 | |
| 57 | | if (beta->started && betadisk_is_active(beta) && !( spectrum_128_port_7ffd_data & 0x10 ) ) |
| 59 | if (beta->started && betadisk_is_active(beta) && !( state->port_7ffd_data & 0x10 ) ) |
| 58 | 60 | { |
| 59 | 61 | /* GLUK */ |
| 60 | 62 | if (strcmp(machine->gamedrv->name, "pent1024")==0) { |
| 61 | | ROMSelection = 2; |
| 63 | state->ROMSelection = 2; |
| 62 | 64 | } else { |
| 63 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ; |
| 65 | state->ROMSelection = ((state->port_7ffd_data>>4) & 0x01) ; |
| 64 | 66 | } |
| 65 | 67 | } |
| 66 | 68 | else { |
| 67 | 69 | /* ROM switching */ |
| 68 | | ROMSelection = ((spectrum_128_port_7ffd_data>>4) & 0x01) ; |
| 70 | state->ROMSelection = ((state->port_7ffd_data>>4) & 0x01) ; |
| 69 | 71 | } |
| 70 | 72 | /* rom 0 is 128K rom, rom 1 is 48 BASIC */ |
| 71 | | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0x010000 + (ROMSelection<<14)); |
| 73 | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0x010000 + (state->ROMSelection<<14)); |
| 72 | 74 | } |
| 73 | 75 | |
| 74 | 76 | static WRITE8_HANDLER(pentagon_port_7ffd_w) |
| 75 | 77 | { |
| 78 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 79 | |
| 76 | 80 | /* disable paging */ |
| 77 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 81 | if (state->port_7ffd_data & 0x20) |
| 78 | 82 | return; |
| 79 | 83 | |
| 80 | 84 | /* store new state */ |
| 81 | | spectrum_128_port_7ffd_data = data; |
| 85 | state->port_7ffd_data = data; |
| 82 | 86 | |
| 83 | 87 | /* update memory */ |
| 84 | 88 | pentagon_update_memory(space->machine); |
| r7288 | r7289 | |
| 99 | 103 | |
| 100 | 104 | static MACHINE_RESET( pentagon ) |
| 101 | 105 | { |
| 106 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 107 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 108 | running_device *beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 102 | 109 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 103 | | beta = devtag_get_device(machine, BETA_DISK_TAG); |
| 104 | 110 | |
| 105 | 111 | memory_install_read_bank(space, 0x0000, 0x3fff, 0, 0, "bank1"); |
| 106 | 112 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| r7288 | r7289 | |
| 112 | 118 | |
| 113 | 119 | memory_set_direct_update_handler( space, pentagon_direct ); |
| 114 | 120 | |
| 115 | | memset(messram_get_ptr(devtag_get_device(machine, "messram")),0,128*1024); |
| 121 | memset(messram,0,128*1024); |
| 116 | 122 | |
| 117 | 123 | /* Bank 5 is always in 0x4000 - 0x7fff */ |
| 118 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(devtag_get_device(machine, "messram")) + (5<<14)); |
| 124 | memory_set_bankptr(machine, "bank2", messram + (5<<14)); |
| 119 | 125 | |
| 120 | 126 | /* Bank 2 is always in 0x8000 - 0xbfff */ |
| 121 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(devtag_get_device(machine, "messram")) + (2<<14)); |
| 127 | memory_set_bankptr(machine, "bank3", messram + (2<<14)); |
| 122 | 128 | |
| 123 | | spectrum_128_port_7ffd_data = 0; |
| 124 | | |
| 129 | state->port_7ffd_data = 0; |
| 130 | state->port_1ffd_data = -1; |
| 125 | 131 | pentagon_update_memory(machine); |
| 126 | 132 | } |
| 127 | 133 | |
src/mess/drivers/pasogo.c
| r7288 | r7289 | |
| 18 | 18 | rtc interrupt irq 2 |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | | static struct { |
| 21 | typedef struct _vg230_t vg230_t; |
| 22 | struct _vg230_t |
| 23 | { |
| 22 | 24 | UINT8 index; |
| 23 | 25 | UINT8 data[0x100]; |
| 24 | 26 | struct { |
| r7288 | r7289 | |
| 36 | 38 | struct { |
| 37 | 39 | int write_protected; |
| 38 | 40 | } pmu; |
| 39 | | } vg230; |
| 41 | }; |
| 40 | 42 | |
| 43 | typedef struct _ems_t ems_t; |
| 44 | struct _ems_t |
| 45 | { |
| 46 | UINT8 data; |
| 47 | int index; |
| 48 | struct { |
| 49 | UINT8 data[2]; |
| 50 | int address; |
| 51 | int type; |
| 52 | int on; |
| 53 | } mapper[26]; |
| 54 | }; |
| 41 | 55 | |
| 56 | typedef struct _pasogo_state pasogo_state; |
| 57 | struct _pasogo_state |
| 58 | { |
| 59 | struct _vg230_t vg230; |
| 60 | struct _ems_t ems; |
| 61 | }; |
| 62 | |
| 63 | |
| 42 | 64 | static TIMER_CALLBACK( vg230_timer ) |
| 43 | 65 | { |
| 44 | | vg230.rtc.seconds+=1; |
| 45 | | if (vg230.rtc.seconds>=60) |
| 66 | pasogo_state *state = (pasogo_state *)machine->driver_data; |
| 67 | vg230_t *vg230 = &state->vg230; |
| 68 | |
| 69 | vg230->rtc.seconds+=1; |
| 70 | if (vg230->rtc.seconds>=60) |
| 46 | 71 | { |
| 47 | | vg230.rtc.seconds=00; |
| 48 | | vg230.rtc.minutes+=1; |
| 49 | | if (vg230.rtc.minutes>=60) |
| 72 | vg230->rtc.seconds=00; |
| 73 | vg230->rtc.minutes+=1; |
| 74 | if (vg230->rtc.minutes>=60) |
| 50 | 75 | { |
| 51 | | vg230.rtc.minutes=0; |
| 52 | | vg230.rtc.hours+=1; |
| 53 | | if (vg230.rtc.hours>=24) |
| 76 | vg230->rtc.minutes=0; |
| 77 | vg230->rtc.hours+=1; |
| 78 | if (vg230->rtc.hours>=24) |
| 54 | 79 | { |
| 55 | | vg230.rtc.hours=0; |
| 56 | | vg230.rtc.days=(vg230.rtc.days+1)&0xfff; |
| 80 | vg230->rtc.hours=0; |
| 81 | vg230->rtc.days=(vg230->rtc.days+1)&0xfff; |
| 57 | 82 | } |
| 58 | 83 | } |
| 59 | 84 | } |
| 60 | 85 | |
| 61 | | if (vg230.rtc.seconds==vg230.rtc.alarm_seconds |
| 62 | | && vg230.rtc.minutes==vg230.rtc.alarm_minutes |
| 63 | | && vg230.rtc.hours==vg230.rtc.alarm_hours |
| 64 | | && (vg230.rtc.days&0x1f)==vg230.rtc.alarm_hours) |
| 86 | if (vg230->rtc.seconds==vg230->rtc.alarm_seconds |
| 87 | && vg230->rtc.minutes==vg230->rtc.alarm_minutes |
| 88 | && vg230->rtc.hours==vg230->rtc.alarm_hours |
| 89 | && (vg230->rtc.days&0x1f)==vg230->rtc.alarm_hours) |
| 65 | 90 | { |
| 66 | 91 | // generate alarm |
| 67 | 92 | } |
| r7288 | r7289 | |
| 69 | 94 | |
| 70 | 95 | static void vg230_reset(running_machine *machine) |
| 71 | 96 | { |
| 97 | pasogo_state *state = (pasogo_state *)machine->driver_data; |
| 98 | vg230_t *vg230 = &state->vg230; |
| 72 | 99 | mame_system_time systime; |
| 73 | 100 | |
| 74 | | memset(&vg230, 0, sizeof(vg230)); |
| 75 | | vg230.pmu.write_protected=TRUE; |
| 101 | memset(vg230, 0, sizeof(*vg230)); |
| 102 | vg230->pmu.write_protected=TRUE; |
| 76 | 103 | timer_pulse(machine, ATTOTIME_IN_HZ(1), NULL, 0, vg230_timer); |
| 77 | 104 | |
| 78 | 105 | |
| 79 | 106 | mame_get_base_datetime(machine, &systime); |
| 80 | 107 | |
| 81 | | vg230.rtc.seconds= systime.local_time.second; |
| 82 | | vg230.rtc.minutes= systime.local_time.minute; |
| 83 | | vg230.rtc.hours = systime.local_time.hour; |
| 84 | | vg230.rtc.days = 0; |
| 108 | vg230->rtc.seconds= systime.local_time.second; |
| 109 | vg230->rtc.minutes= systime.local_time.minute; |
| 110 | vg230->rtc.hours = systime.local_time.hour; |
| 111 | vg230->rtc.days = 0; |
| 85 | 112 | |
| 86 | | vg230.bios_timer.data=0x7200; // HACK |
| 113 | vg230->bios_timer.data=0x7200; // HACK |
| 87 | 114 | } |
| 88 | 115 | |
| 89 | 116 | static void vg230_init(running_machine *machine) |
| r7288 | r7289 | |
| 94 | 121 | |
| 95 | 122 | static READ8_HANDLER( vg230_io_r ) |
| 96 | 123 | { |
| 124 | pasogo_state *state = (pasogo_state *)space->machine->driver_data; |
| 125 | vg230_t *vg230 = &state->vg230; |
| 97 | 126 | int log=TRUE; |
| 98 | 127 | UINT8 data=0; |
| 99 | | vg230.bios_timer.data+=0x100; //HACK |
| 128 | |
| 129 | vg230->bios_timer.data+=0x100; //HACK |
| 100 | 130 | if (offset&1) |
| 101 | 131 | { |
| 102 | | data=vg230.data[vg230.index]; |
| 103 | | switch (vg230.index) |
| 132 | data=vg230->data[vg230->index]; |
| 133 | switch (vg230->index) |
| 104 | 134 | { |
| 105 | 135 | case 0x09: break; |
| 106 | 136 | case 0x0a: |
| 107 | | if (vg230.data[9]&1) |
| 137 | if (vg230->data[9]&1) |
| 108 | 138 | { |
| 109 | 139 | data=input_port_read(space->machine, "JOY"); |
| 110 | 140 | } |
| r7288 | r7289 | |
| 115 | 145 | break; |
| 116 | 146 | |
| 117 | 147 | case 0x30: |
| 118 | | data=vg230.bios_timer.data&0xff; |
| 148 | data=vg230->bios_timer.data&0xff; |
| 119 | 149 | break; |
| 120 | 150 | |
| 121 | 151 | case 0x31: |
| 122 | | data=vg230.bios_timer.data>>8; |
| 152 | data=vg230->bios_timer.data>>8; |
| 123 | 153 | log=FALSE; |
| 124 | 154 | break; |
| 125 | 155 | |
| 126 | | case 0x70: data=vg230.rtc.seconds; log=FALSE; break; |
| 127 | | case 0x71: data=vg230.rtc.minutes; log=FALSE; break; |
| 128 | | case 0x72: data=vg230.rtc.hours; log=FALSE; break; |
| 129 | | case 0x73: data=vg230.rtc.days; break; |
| 130 | | case 0x74: data=vg230.rtc.days>>8; break; |
| 156 | case 0x70: data=vg230->rtc.seconds; log=FALSE; break; |
| 157 | case 0x71: data=vg230->rtc.minutes; log=FALSE; break; |
| 158 | case 0x72: data=vg230->rtc.hours; log=FALSE; break; |
| 159 | case 0x73: data=vg230->rtc.days; break; |
| 160 | case 0x74: data=vg230->rtc.days>>8; break; |
| 131 | 161 | case 0x79: /*rtc status*/log=FALSE; break; |
| 132 | 162 | case 0x7a: |
| 133 | 163 | data&=~3; |
| 134 | | if (vg230.rtc.alarm_interrupt_request) data|=1<<1; |
| 135 | | if (vg230.rtc.onehertz_interrupt_request) data|=1<<0; |
| 164 | if (vg230->rtc.alarm_interrupt_request) data|=1<<1; |
| 165 | if (vg230->rtc.onehertz_interrupt_request) data|=1<<0; |
| 136 | 166 | break; |
| 137 | 167 | |
| 138 | 168 | case 0xc1: |
| 139 | 169 | data&=~1; |
| 140 | | if (vg230.pmu.write_protected) data|=1; |
| 141 | | vg230.pmu.write_protected=FALSE; |
| 170 | if (vg230->pmu.write_protected) data|=1; |
| 171 | vg230->pmu.write_protected=FALSE; |
| 142 | 172 | log=FALSE; |
| 143 | 173 | break; |
| 144 | 174 | } |
| 145 | 175 | |
| 146 | 176 | if (log) |
| 147 | | logerror("%.5x vg230 %02x read %.2x\n",(int) cpu_get_pc(space->cpu),vg230.index,data); |
| 177 | logerror("%.5x vg230 %02x read %.2x\n",(int) cpu_get_pc(space->cpu),vg230->index,data); |
| 148 | 178 | // data=memory_region(machine, "maincpu")[0x4000+offset]; |
| 149 | 179 | } |
| 150 | 180 | else |
| 151 | 181 | { |
| 152 | | data=vg230.index; |
| 182 | data=vg230->index; |
| 153 | 183 | } |
| 154 | 184 | return data; |
| 155 | 185 | } |
| 156 | 186 | |
| 157 | 187 | static WRITE8_HANDLER( vg230_io_w ) |
| 158 | 188 | { |
| 189 | pasogo_state *state = (pasogo_state *)space->machine->driver_data; |
| 190 | vg230_t *vg230 = &state->vg230; |
| 159 | 191 | int log=TRUE; |
| 192 | |
| 160 | 193 | if (offset&1) |
| 161 | 194 | { |
| 162 | 195 | // memory_region(machine, "maincpu")[0x4000+offset]=data; |
| 163 | | vg230.data[vg230.index]=data; |
| 164 | | switch (vg230.index) |
| 196 | vg230->data[vg230->index]=data; |
| 197 | switch (vg230->index) |
| 165 | 198 | { |
| 166 | 199 | case 0x09: break; |
| 167 | | case 0x70: vg230.rtc.seconds=data&0x3f; break; |
| 168 | | case 0x71: vg230.rtc.minutes=data&0x3f; break; |
| 169 | | case 0x72: vg230.rtc.hours=data&0x1f;break; |
| 170 | | case 0x73: vg230.rtc.days=(vg230.rtc.days&~0xff)|data; break; |
| 171 | | case 0x74: vg230.rtc.days=(vg230.rtc.days&0xff)|((data&0xf)<<8); break; |
| 172 | | case 0x75: vg230.rtc.alarm_seconds=data&0x3f; break; |
| 173 | | case 0x76: vg230.rtc.alarm_minutes=data&0x3f; break; |
| 174 | | case 0x77: vg230.rtc.alarm_hours=data&0x1f; break; |
| 175 | | case 0x78: vg230.rtc.days=data&0x1f; break; |
| 200 | case 0x70: vg230->rtc.seconds=data&0x3f; break; |
| 201 | case 0x71: vg230->rtc.minutes=data&0x3f; break; |
| 202 | case 0x72: vg230->rtc.hours=data&0x1f;break; |
| 203 | case 0x73: vg230->rtc.days=(vg230->rtc.days&~0xff)|data; break; |
| 204 | case 0x74: vg230->rtc.days=(vg230->rtc.days&0xff)|((data&0xf)<<8); break; |
| 205 | case 0x75: vg230->rtc.alarm_seconds=data&0x3f; break; |
| 206 | case 0x76: vg230->rtc.alarm_minutes=data&0x3f; break; |
| 207 | case 0x77: vg230->rtc.alarm_hours=data&0x1f; break; |
| 208 | case 0x78: vg230->rtc.days=data&0x1f; break; |
| 176 | 209 | case 0x79: |
| 177 | | vg230.rtc.onehertz_interrupt_on=data&1; |
| 178 | | vg230.rtc.alarm_interrupt_on=data&2; |
| 210 | vg230->rtc.onehertz_interrupt_on=data&1; |
| 211 | vg230->rtc.alarm_interrupt_on=data&2; |
| 179 | 212 | log=FALSE; |
| 180 | 213 | break; |
| 181 | 214 | |
| 182 | 215 | case 0x7a: |
| 183 | 216 | if (data&2) |
| 184 | 217 | { |
| 185 | | vg230.rtc.alarm_interrupt_request=FALSE; vg230.rtc.onehertz_interrupt_request=FALSE; /* update interrupt */ |
| 218 | vg230->rtc.alarm_interrupt_request=FALSE; vg230->rtc.onehertz_interrupt_request=FALSE; /* update interrupt */ |
| 186 | 219 | } |
| 187 | 220 | break; |
| 188 | 221 | } |
| 189 | 222 | |
| 190 | 223 | if (log) |
| 191 | | logerror("%.5x vg230 %02x write %.2x\n",(int)cpu_get_pc(space->cpu),vg230.index,data); |
| 224 | logerror("%.5x vg230 %02x write %.2x\n",(int)cpu_get_pc(space->cpu),vg230->index,data); |
| 192 | 225 | } |
| 193 | 226 | else |
| 194 | 227 | { |
| 195 | | vg230.index=data; |
| 228 | vg230->index=data; |
| 196 | 229 | } |
| 197 | 230 | } |
| 198 | 231 | |
| 199 | | static struct { |
| 200 | | UINT8 data; |
| 201 | | int index; |
| 202 | | struct { |
| 203 | | UINT8 data[2]; |
| 204 | | int address; |
| 205 | | int type; |
| 206 | | int on; |
| 207 | | } mapper[26]; |
| 208 | | } ems/*?*/; |
| 209 | | |
| 210 | 232 | static READ8_HANDLER( ems_r ) |
| 211 | 233 | { |
| 234 | pasogo_state *state = (pasogo_state *)space->machine->driver_data; |
| 235 | ems_t *ems = &state->ems; |
| 212 | 236 | UINT8 data=0; |
| 237 | |
| 213 | 238 | switch (offset) |
| 214 | 239 | { |
| 215 | | case 0: data=ems.data; break; |
| 216 | | case 2: case 3: data=ems.mapper[ems.index].data[offset&1]; break; |
| 240 | case 0: data=ems->data; break; |
| 241 | case 2: case 3: data=ems->mapper[ems->index].data[offset&1]; break; |
| 217 | 242 | } |
| 218 | 243 | return data; |
| 219 | 244 | } |
| 220 | 245 | |
| 221 | 246 | static WRITE8_HANDLER( ems_w ) |
| 222 | 247 | { |
| 248 | pasogo_state *state = (pasogo_state *)space->machine->driver_data; |
| 249 | ems_t *ems = &state->ems; |
| 223 | 250 | char bank[10]; |
| 251 | |
| 224 | 252 | switch (offset) |
| 225 | 253 | { |
| 226 | 254 | case 0: |
| 227 | | ems.data=data; |
| 255 | ems->data=data; |
| 228 | 256 | switch (data&~3) |
| 229 | 257 | { |
| 230 | | case 0x80: ems.index=0; break; |
| 231 | | case 0x84: ems.index=1; break; |
| 232 | | case 0x88: ems.index=2; break; |
| 233 | | case 0x8c: ems.index=3; break; |
| 234 | | case 0x90: ems.index=4; break; |
| 235 | | case 0x94: ems.index=5; break; |
| 236 | | case 0x98: ems.index=6; break; |
| 237 | | case 0x9c: ems.index=7; break; |
| 238 | | case 0xa0: ems.index=8; break; |
| 239 | | case 0xa4: ems.index=9; break; |
| 240 | | case 0xa8: ems.index=10; break; |
| 241 | | case 0xac: ems.index=11; break; |
| 242 | | case 0xb0: ems.index=12; break; |
| 243 | | case 0xb4: ems.index=13; break; |
| 244 | | // case 0xb8: ems.index=14; break; |
| 245 | | // case 0xbc: ems.index=15; break; |
| 246 | | case 0xc0: ems.index=14; break; |
| 247 | | case 0xc4: ems.index=15; break; |
| 248 | | case 0xc8: ems.index=16; break; |
| 249 | | case 0xcc: ems.index=17; break; |
| 250 | | case 0xd0: ems.index=18; break; |
| 251 | | case 0xd4: ems.index=19; break; |
| 252 | | case 0xd8: ems.index=20; break; |
| 253 | | case 0xdc: ems.index=21; break; |
| 254 | | case 0xe0: ems.index=22; break; |
| 255 | | case 0xe4: ems.index=23; break; |
| 256 | | case 0xe8: ems.index=24; break; |
| 257 | | case 0xec: ems.index=25; break; |
| 258 | case 0x80: ems->index=0; break; |
| 259 | case 0x84: ems->index=1; break; |
| 260 | case 0x88: ems->index=2; break; |
| 261 | case 0x8c: ems->index=3; break; |
| 262 | case 0x90: ems->index=4; break; |
| 263 | case 0x94: ems->index=5; break; |
| 264 | case 0x98: ems->index=6; break; |
| 265 | case 0x9c: ems->index=7; break; |
| 266 | case 0xa0: ems->index=8; break; |
| 267 | case 0xa4: ems->index=9; break; |
| 268 | case 0xa8: ems->index=10; break; |
| 269 | case 0xac: ems->index=11; break; |
| 270 | case 0xb0: ems->index=12; break; |
| 271 | case 0xb4: ems->index=13; break; |
| 272 | // case 0xb8: ems->index=14; break; |
| 273 | // case 0xbc: ems->index=15; break; |
| 274 | case 0xc0: ems->index=14; break; |
| 275 | case 0xc4: ems->index=15; break; |
| 276 | case 0xc8: ems->index=16; break; |
| 277 | case 0xcc: ems->index=17; break; |
| 278 | case 0xd0: ems->index=18; break; |
| 279 | case 0xd4: ems->index=19; break; |
| 280 | case 0xd8: ems->index=20; break; |
| 281 | case 0xdc: ems->index=21; break; |
| 282 | case 0xe0: ems->index=22; break; |
| 283 | case 0xe4: ems->index=23; break; |
| 284 | case 0xe8: ems->index=24; break; |
| 285 | case 0xec: ems->index=25; break; |
| 258 | 286 | } |
| 259 | 287 | break; |
| 260 | 288 | |
| 261 | 289 | case 2: |
| 262 | 290 | case 3: |
| 263 | | ems.mapper[ems.index].data[offset&1]=data; |
| 264 | | ems.mapper[ems.index].address=(ems.mapper[ems.index].data[0]<<14)|((ems.mapper[ems.index].data[1]&0xf)<<22); |
| 265 | | ems.mapper[ems.index].on=ems.mapper[ems.index].data[1]&0x80; |
| 266 | | ems.mapper[ems.index].type=(ems.mapper[ems.index].data[1]&0x70)>>4; |
| 267 | | logerror("%.5x ems mapper %d(%05x)on:%d type:%d address:%07x\n",(int)cpu_get_pc(space->cpu),ems.index, ems.data<<12, |
| 268 | | ems.mapper[ems.index].on, ems.mapper[ems.index].type, ems.mapper[ems.index].address ); |
| 269 | | switch (ems.mapper[ems.index].type) |
| 291 | ems->mapper[ems->index].data[offset&1]=data; |
| 292 | ems->mapper[ems->index].address=(ems->mapper[ems->index].data[0]<<14)|((ems->mapper[ems->index].data[1]&0xf)<<22); |
| 293 | ems->mapper[ems->index].on=ems->mapper[ems->index].data[1]&0x80; |
| 294 | ems->mapper[ems->index].type=(ems->mapper[ems->index].data[1]&0x70)>>4; |
| 295 | logerror("%.5x ems mapper %d(%05x)on:%d type:%d address:%07x\n",(int)cpu_get_pc(space->cpu),ems->index, ems->data<<12, |
| 296 | ems->mapper[ems->index].on, ems->mapper[ems->index].type, ems->mapper[ems->index].address ); |
| 297 | switch (ems->mapper[ems->index].type) |
| 270 | 298 | { |
| 271 | 299 | case 0: /*external*/ |
| 272 | 300 | case 1: /*ram*/ |
| 273 | | sprintf(bank,"bank%d",ems.index+1); |
| 274 | | memory_set_bankptr( space->machine, bank, memory_region(space->machine, "maincpu") + (ems.mapper[ems.index].address&0xfffff) ); |
| 301 | sprintf(bank,"bank%d",ems->index+1); |
| 302 | memory_set_bankptr( space->machine, bank, memory_region(space->machine, "maincpu") + (ems->mapper[ems->index].address&0xfffff) ); |
| 275 | 303 | break; |
| 276 | 304 | case 3: /* rom 1 */ |
| 277 | 305 | case 4: /* pc card a */ |
| r7288 | r7289 | |
| 279 | 307 | default: |
| 280 | 308 | break; |
| 281 | 309 | case 2: |
| 282 | | sprintf(bank,"bank%d",ems.index+1); |
| 283 | | memory_set_bankptr( space->machine, bank, memory_region(space->machine, "user1") + (ems.mapper[ems.index].address&0xfffff) ); |
| 310 | sprintf(bank,"bank%d",ems->index+1); |
| 311 | memory_set_bankptr( space->machine, bank, memory_region(space->machine, "user1") + (ems->mapper[ems->index].address&0xfffff) ); |
| 284 | 312 | break; |
| 285 | 313 | } |
| 286 | 314 | break; |
| r7288 | r7289 | |
| 367 | 395 | |
| 368 | 396 | static VIDEO_UPDATE( pasogo ) |
| 369 | 397 | { |
| 370 | | static int width=-1, height=-1; |
| 398 | //static int width=-1,height=-1; |
| 371 | 399 | UINT8 *rom = memory_region(screen->machine, "maincpu")+0xb8000; |
| 372 | 400 | UINT16 c[]={ 3, 0 }; |
| 373 | 401 | int x,y; |
| r7288 | r7289 | |
| 412 | 440 | } |
| 413 | 441 | } |
| 414 | 442 | } |
| 443 | #if 0 |
| 415 | 444 | if (w!=width || h!=height) |
| 416 | 445 | { |
| 417 | 446 | width=w; height=h; |
| 418 | 447 | // video_screen_set_visarea(machine->primary_screen, 0, width-1, 0, height-1); |
| 419 | 448 | video_screen_set_visarea(screen, 0, width-1, 0, height-1); |
| 420 | 449 | } |
| 450 | #endif |
| 421 | 451 | return 0; |
| 422 | 452 | } |
| 423 | 453 | |
| r7288 | r7289 | |
| 486 | 516 | } |
| 487 | 517 | |
| 488 | 518 | static MACHINE_DRIVER_START( pasogo ) |
| 519 | |
| 520 | MDRV_DRIVER_DATA( pasogo_state ) |
| 521 | |
| 489 | 522 | MDRV_CPU_ADD("maincpu", I80188/*V30HL in vadem vg230*/, 10000000/*?*/) |
| 490 | 523 | MDRV_CPU_PROGRAM_MAP(pasogo_mem) |
| 491 | 524 | MDRV_CPU_IO_MAP( pasogo_io) |
| r7288 | r7289 | |
| 527 | 560 | |
| 528 | 561 | static DRIVER_INIT( pasogo ) |
| 529 | 562 | { |
| 563 | pasogo_state *state = (pasogo_state *)machine->driver_data; |
| 530 | 564 | vg230_init(machine); |
| 531 | | memset(&ems, 0, sizeof(ems)); |
| 565 | memset(&state->ems, 0, sizeof(state->ems)); |
| 532 | 566 | memory_set_bankptr( machine, "bank27", memory_region(machine, "user1") + 0x00000 ); |
| 533 | 567 | memory_set_bankptr( machine, "bank28", memory_region(machine, "maincpu") + 0xb8000/*?*/ ); |
| 534 | 568 | } |
src/mess/drivers/specpls3.c
| r7288 | r7289 | |
| 164 | 164 | /* This driver uses some of the spectrum_128 functions. The +3 is similar to a spectrum 128 |
| 165 | 165 | but with a disc drive */ |
| 166 | 166 | |
| 167 | | int spectrum_plus3_port_1ffd_data = -1; |
| 168 | | |
| 169 | | |
| 170 | 167 | static const upd765_interface spectrum_plus3_upd765_interface = |
| 171 | 168 | { |
| 172 | 169 | DEVCB_NULL, |
| r7288 | r7289 | |
| 211 | 208 | |
| 212 | 209 | void spectrum_plus3_update_memory(running_machine *machine) |
| 213 | 210 | { |
| 211 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 214 | 212 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 213 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 215 | 214 | |
| 216 | | if (spectrum_128_port_7ffd_data & 8) |
| 215 | if (state->port_7ffd_data & 8) |
| 217 | 216 | { |
| 218 | | logerror("+3 SCREEN 1: BLOCK 7\n"); |
| 219 | | spectrum_screen_location = messram_get_ptr(devtag_get_device(machine, "messram")) + (7 << 14); |
| 217 | logerror("+3 SCREEN 1: BLOCK 7\n"); |
| 218 | state->screen_location = messram + (7 << 14); |
| 220 | 219 | } |
| 221 | 220 | else |
| 222 | 221 | { |
| 223 | | logerror("+3 SCREEN 0: BLOCK 5\n"); |
| 224 | | spectrum_screen_location = messram_get_ptr(devtag_get_device(machine, "messram")) + (5 << 14); |
| 222 | logerror("+3 SCREEN 0: BLOCK 5\n"); |
| 223 | state->screen_location = messram + (5 << 14); |
| 225 | 224 | } |
| 226 | 225 | |
| 227 | | if ((spectrum_plus3_port_1ffd_data & 0x01) == 0) |
| 226 | if ((state->port_1ffd_data & 0x01) == 0) |
| 228 | 227 | { |
| 229 | 228 | int ram_page; |
| 230 | 229 | unsigned char *ram_data; |
| r7288 | r7289 | |
| 234 | 233 | int ROMSelection; |
| 235 | 234 | |
| 236 | 235 | /* select ram at 0x0c000-0x0ffff */ |
| 237 | | ram_page = spectrum_128_port_7ffd_data & 0x07; |
| 238 | | ram_data = messram_get_ptr(devtag_get_device(machine, "messram")) + (ram_page<<14); |
| 236 | ram_page = state->port_7ffd_data & 0x07; |
| 237 | ram_data = messram + (ram_page<<14); |
| 239 | 238 | |
| 240 | 239 | memory_set_bankptr(machine, "bank4", ram_data); |
| 241 | 240 | |
| r7288 | r7289 | |
| 243 | 242 | |
| 244 | 243 | /* Reset memory between 0x4000 - 0xbfff in case extended paging was being used */ |
| 245 | 244 | /* Bank 5 in 0x4000 - 0x7fff */ |
| 246 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(devtag_get_device(machine, "messram")) + (5 << 14)); |
| 245 | memory_set_bankptr(machine, "bank2", messram + (5 << 14)); |
| 247 | 246 | |
| 248 | 247 | /* Bank 2 in 0x8000 - 0xbfff */ |
| 249 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(devtag_get_device(machine, "messram")) + (2 << 14)); |
| 248 | memory_set_bankptr(machine, "bank3", messram + (2 << 14)); |
| 250 | 249 | |
| 251 | 250 | |
| 252 | | ROMSelection = ((spectrum_128_port_7ffd_data >> 4) & 0x01) | |
| 253 | | ((spectrum_plus3_port_1ffd_data >> 1) & 0x02); |
| 251 | ROMSelection = ((state->port_7ffd_data >> 4) & 0x01) | |
| 252 | ((state->port_1ffd_data >> 1) & 0x02); |
| 254 | 253 | |
| 255 | 254 | /* rom 0 is editor, rom 1 is syntax, rom 2 is DOS, rom 3 is 48 BASIC */ |
| 256 | 255 | |
| r7288 | r7289 | |
| 269 | 268 | int MemorySelection; |
| 270 | 269 | unsigned char *ram_data; |
| 271 | 270 | |
| 272 | | MemorySelection = (spectrum_plus3_port_1ffd_data >> 1) & 0x03; |
| 271 | MemorySelection = (state->port_1ffd_data >> 1) & 0x03; |
| 273 | 272 | |
| 274 | 273 | memory_selection = &spectrum_plus3_memory_selections[(MemorySelection << 2)]; |
| 275 | 274 | |
| 276 | | ram_data = messram_get_ptr(devtag_get_device(machine, "messram")) + (memory_selection[0] << 14); |
| 275 | ram_data = messram + (memory_selection[0] << 14); |
| 277 | 276 | memory_set_bankptr(machine, "bank1", ram_data); |
| 278 | 277 | /* allow writes to 0x0000-0x03fff */ |
| 279 | 278 | memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank1"); |
| 280 | 279 | |
| 281 | | ram_data = messram_get_ptr(devtag_get_device(machine, "messram")) + (memory_selection[1] << 14); |
| 280 | ram_data = messram + (memory_selection[1] << 14); |
| 282 | 281 | memory_set_bankptr(machine, "bank2", ram_data); |
| 283 | 282 | |
| 284 | | ram_data = messram_get_ptr(devtag_get_device(machine, "messram")) + (memory_selection[2] << 14); |
| 283 | ram_data = messram + (memory_selection[2] << 14); |
| 285 | 284 | memory_set_bankptr(machine, "bank3", ram_data); |
| 286 | 285 | |
| 287 | | ram_data = messram_get_ptr(devtag_get_device(machine, "messram")) + (memory_selection[3] << 14); |
| 286 | ram_data = messram + (memory_selection[3] << 14); |
| 288 | 287 | memory_set_bankptr(machine, "bank4", ram_data); |
| 289 | 288 | |
| 290 | 289 | logerror("extended memory paging: %02x\n", MemorySelection); |
| r7288 | r7289 | |
| 300 | 299 | /* D4 - ROM select - which rom paged into 0x0000-0x03fff */ |
| 301 | 300 | /* D5 - Disable paging */ |
| 302 | 301 | |
| 303 | | /* disable paging? */ |
| 304 | | if (spectrum_128_port_7ffd_data & 0x20) |
| 305 | | return; |
| 302 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 306 | 303 | |
| 307 | | /* store new state */ |
| 308 | | spectrum_128_port_7ffd_data = data; |
| 304 | /* disable paging? */ |
| 305 | if (state->port_7ffd_data & 0x20) |
| 306 | return; |
| 309 | 307 | |
| 310 | | /* update memory */ |
| 311 | | spectrum_plus3_update_memory(space->machine); |
| 308 | /* store new state */ |
| 309 | state->port_7ffd_data = data; |
| 310 | |
| 311 | /* update memory */ |
| 312 | spectrum_plus3_update_memory(space->machine); |
| 312 | 313 | } |
| 313 | 314 | |
| 314 | 315 | static WRITE8_HANDLER(spectrum_plus3_port_1ffd_w) |
| r7288 | r7289 | |
| 318 | 319 | /* D3 - Disk motor on/off */ |
| 319 | 320 | /* D4 - parallel port strobe */ |
| 320 | 321 | |
| 322 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 323 | |
| 321 | 324 | floppy_mon_w(floppy_get_device(space->machine, 0), !BIT(data, 3)); |
| 322 | 325 | floppy_mon_w(floppy_get_device(space->machine, 1), !BIT(data, 3)); |
| 323 | 326 | floppy_drive_set_ready_state(floppy_get_device(space->machine, 0), 1, 1); |
| 324 | 327 | floppy_drive_set_ready_state(floppy_get_device(space->machine, 1), 1, 1); |
| 325 | 328 | |
| 326 | | spectrum_plus3_port_1ffd_data = data; |
| 329 | state->port_1ffd_data = data; |
| 327 | 330 | |
| 328 | 331 | /* disable paging? */ |
| 329 | | if ((spectrum_128_port_7ffd_data & 0x20)==0) |
| 332 | if ((state->port_7ffd_data & 0x20)==0) |
| 330 | 333 | { |
| 331 | 334 | /* no */ |
| 332 | 335 | spectrum_plus3_update_memory(space->machine); |
| r7288 | r7289 | |
| 349 | 352 | |
| 350 | 353 | static MACHINE_RESET( spectrum_plus3 ) |
| 351 | 354 | { |
| 352 | | memset(messram_get_ptr(devtag_get_device(machine, "messram")),0,128*1024); |
| 355 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 356 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 357 | memset(messram,0,128*1024); |
| 353 | 358 | |
| 359 | MACHINE_RESET_CALL(spectrum); |
| 360 | |
| 354 | 361 | /* Initial configuration */ |
| 355 | | spectrum_128_port_7ffd_data = 0; |
| 356 | | spectrum_plus3_port_1ffd_data = 0; |
| 362 | state->port_7ffd_data = 0; |
| 363 | state->port_1ffd_data = 0; |
| 357 | 364 | spectrum_plus3_update_memory(machine); |
| 358 | | |
| 359 | | MACHINE_RESET_CALL(spectrum); |
| 360 | 365 | } |
| 361 | 366 | |
| 362 | 367 | static const floppy_config specpls3_floppy_config = |
src/mess/drivers/timex.c
| r7288 | r7289 | |
| 159 | 159 | #include "machine/beta.h" |
| 160 | 160 | #include "devices/messram.h" |
| 161 | 161 | |
| 162 | | TIMEX_CART_TYPE timex_cart_type = TIMEX_CART_NONE; |
| 163 | | UINT8 timex_cart_chunks = 0x00; |
| 164 | | UINT8 *timex_cart_data; |
| 165 | | |
| 166 | 162 | static const ay8910_interface spectrum_ay_interface = |
| 167 | 163 | { |
| 168 | 164 | AY8910_LEGACY_OUTPUT, |
| r7288 | r7289 | |
| 174 | 170 | /* TS2048 specific functions */ |
| 175 | 171 | |
| 176 | 172 | |
| 177 | | int ts2068_port_ff_data = -1; /* Display enhancement control */ |
| 178 | | int ts2068_port_f4_data = -1; /* Horizontal Select Register */ |
| 179 | | |
| 180 | 173 | static READ8_HANDLER(ts2068_port_f4_r) |
| 181 | 174 | { |
| 182 | | return ts2068_port_f4_data; |
| 175 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 176 | |
| 177 | return state->port_f4_data; |
| 183 | 178 | } |
| 184 | 179 | |
| 185 | 180 | static WRITE8_HANDLER(ts2068_port_f4_w) |
| 186 | 181 | { |
| 187 | | ts2068_port_f4_data = data; |
| 188 | | ts2068_update_memory(space->machine); |
| 182 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 183 | |
| 184 | state->port_f4_data = data; |
| 185 | ts2068_update_memory(space->machine); |
| 189 | 186 | } |
| 190 | 187 | |
| 191 | 188 | static READ8_HANDLER(ts2068_port_ff_r) |
| 192 | 189 | { |
| 193 | | return ts2068_port_ff_data; |
| 190 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 191 | |
| 192 | return state->port_ff_data; |
| 194 | 193 | } |
| 195 | 194 | |
| 196 | 195 | static WRITE8_HANDLER(ts2068_port_ff_w) |
| r7288 | r7289 | |
| 201 | 200 | Bit 6 17ms Interrupt Inhibit |
| 202 | 201 | Bit 7 Cartridge (0) / EXROM (1) select |
| 203 | 202 | */ |
| 204 | | ts2068_port_ff_data = data; |
| 205 | | ts2068_update_memory(space->machine); |
| 206 | | logerror("Port %04x write %02x\n", offset, data); |
| 203 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 204 | |
| 205 | state->port_ff_data = data; |
| 206 | ts2068_update_memory(space->machine); |
| 207 | logerror("Port %04x write %02x\n", offset, data); |
| 207 | 208 | } |
| 208 | 209 | |
| 209 | 210 | /******************************************************************* |
| r7288 | r7289 | |
| 226 | 227 | *******************************************************************/ |
| 227 | 228 | void ts2068_update_memory(running_machine *machine) |
| 228 | 229 | { |
| 230 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 231 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 229 | 232 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 230 | 233 | unsigned char *ChosenROM, *ExROM, *DOCK; |
| 231 | 234 | |
| r7288 | r7289 | |
| 233 | 236 | |
| 234 | 237 | ExROM = memory_region(machine, "maincpu") + 0x014000; |
| 235 | 238 | |
| 236 | | if (ts2068_port_f4_data & 0x01) |
| 239 | if (state->port_f4_data & 0x01) |
| 237 | 240 | { |
| 238 | | if (ts2068_port_ff_data & 0x80) |
| 241 | if (state->port_ff_data & 0x80) |
| 239 | 242 | { |
| 240 | 243 | memory_install_read_bank(space, 0x0000, 0x1fff, 0, 0, "bank1"); |
| 241 | 244 | memory_unmap_write(space, 0x0000, 0x1fff, 0, 0); |
| r7288 | r7289 | |
| 272 | 275 | logerror("0000-1fff HOME\n"); |
| 273 | 276 | } |
| 274 | 277 | |
| 275 | | if (ts2068_port_f4_data & 0x02) |
| 278 | if (state->port_f4_data & 0x02) |
| 276 | 279 | { |
| 277 | | if (ts2068_port_ff_data & 0x80) |
| 280 | if (state->port_ff_data & 0x80) |
| 278 | 281 | { |
| 279 | 282 | memory_set_bankptr(machine, "bank2", ExROM); |
| 280 | 283 | memory_install_read_bank(space, 0x2000, 0x3fff, 0, 0, "bank2"); |
| r7288 | r7289 | |
| 310 | 313 | logerror("2000-3fff HOME\n"); |
| 311 | 314 | } |
| 312 | 315 | |
| 313 | | if (ts2068_port_f4_data & 0x04) |
| 316 | if (state->port_f4_data & 0x04) |
| 314 | 317 | { |
| 315 | | if (ts2068_port_ff_data & 0x80) |
| 318 | if (state->port_ff_data & 0x80) |
| 316 | 319 | { |
| 317 | 320 | memory_set_bankptr(machine, "bank3", ExROM); |
| 318 | 321 | memory_install_read_bank(space, 0x4000, 0x5fff, 0, 0, "bank3"); |
| r7288 | r7289 | |
| 340 | 343 | } |
| 341 | 344 | else |
| 342 | 345 | { |
| 343 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(devtag_get_device(machine, "messram"))); |
| 344 | | memory_set_bankptr(machine, "bank11", messram_get_ptr(devtag_get_device(machine, "messram"))); |
| 346 | memory_set_bankptr(machine, "bank3", messram); |
| 347 | memory_set_bankptr(machine, "bank11", messram); |
| 345 | 348 | memory_install_read_bank(space, 0x4000, 0x5fff, 0, 0, "bank3"); |
| 346 | 349 | memory_install_write_bank(space, 0x4000, 0x5fff, 0, 0, "bank11"); |
| 347 | 350 | logerror("4000-5fff RAM\n"); |
| 348 | 351 | } |
| 349 | 352 | |
| 350 | | if (ts2068_port_f4_data & 0x08) |
| 353 | if (state->port_f4_data & 0x08) |
| 351 | 354 | { |
| 352 | | if (ts2068_port_ff_data & 0x80) |
| 355 | if (state->port_ff_data & 0x80) |
| 353 | 356 | { |
| 354 | 357 | memory_set_bankptr(machine, "bank4", ExROM); |
| 355 | 358 | memory_install_read_bank(space, 0x6000, 0x7fff, 0, 0, "bank4"); |
| r7288 | r7289 | |
| 377 | 380 | } |
| 378 | 381 | else |
| 379 | 382 | { |
| 380 | | memory_set_bankptr(machine, "bank4", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x2000); |
| 381 | | memory_set_bankptr(machine, "bank12", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x2000); |
| 383 | memory_set_bankptr(machine, "bank4", messram + 0x2000); |
| 384 | memory_set_bankptr(machine, "bank12", messram + 0x2000); |
| 382 | 385 | memory_install_read_bank(space, 0x6000, 0x7fff, 0, 0, "bank4"); |
| 383 | 386 | memory_install_write_bank(space, 0x6000, 0x7fff, 0, 0, "bank12"); |
| 384 | 387 | logerror("6000-7fff RAM\n"); |
| 385 | 388 | } |
| 386 | 389 | |
| 387 | | if (ts2068_port_f4_data & 0x10) |
| 390 | if (state->port_f4_data & 0x10) |
| 388 | 391 | { |
| 389 | | if (ts2068_port_ff_data & 0x80) |
| 392 | if (state->port_ff_data & 0x80) |
| 390 | 393 | { |
| 391 | 394 | memory_set_bankptr(machine, "bank5", ExROM); |
| 392 | 395 | memory_install_read_bank(space, 0x8000, 0x9fff, 0, 0, "bank5"); |
| r7288 | r7289 | |
| 414 | 417 | } |
| 415 | 418 | else |
| 416 | 419 | { |
| 417 | | memory_set_bankptr(machine, "bank5", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x4000); |
| 418 | | memory_set_bankptr(machine, "bank13", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x4000); |
| 420 | memory_set_bankptr(machine, "bank5", messram + 0x4000); |
| 421 | memory_set_bankptr(machine, "bank13", messram + 0x4000); |
| 419 | 422 | memory_install_read_bank(space, 0x8000, 0x9fff, 0, 0,"bank5"); |
| 420 | 423 | memory_install_write_bank(space, 0x8000, 0x9fff, 0, 0,"bank13"); |
| 421 | 424 | logerror("8000-9fff RAM\n"); |
| 422 | 425 | } |
| 423 | 426 | |
| 424 | | if (ts2068_port_f4_data & 0x20) |
| 427 | if (state->port_f4_data & 0x20) |
| 425 | 428 | { |
| 426 | | if (ts2068_port_ff_data & 0x80) |
| 429 | if (state->port_ff_data & 0x80) |
| 427 | 430 | { |
| 428 | 431 | memory_set_bankptr(machine, "bank6", ExROM); |
| 429 | 432 | memory_install_read_bank(space, 0xa000, 0xbfff, 0, 0, "bank6"); |
| r7288 | r7289 | |
| 452 | 455 | } |
| 453 | 456 | else |
| 454 | 457 | { |
| 455 | | memory_set_bankptr(machine, "bank6", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x6000); |
| 456 | | memory_set_bankptr(machine, "bank14", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x6000); |
| 458 | memory_set_bankptr(machine, "bank6", messram + 0x6000); |
| 459 | memory_set_bankptr(machine, "bank14", messram + 0x6000); |
| 457 | 460 | memory_install_read_bank(space, 0xa000, 0xbfff, 0, 0, "bank6"); |
| 458 | 461 | memory_install_write_bank(space, 0xa000, 0xbfff, 0, 0, "bank14"); |
| 459 | 462 | logerror("a000-bfff RAM\n"); |
| 460 | 463 | } |
| 461 | 464 | |
| 462 | | if (ts2068_port_f4_data & 0x40) |
| 465 | if (state->port_f4_data & 0x40) |
| 463 | 466 | { |
| 464 | | if (ts2068_port_ff_data & 0x80) |
| 467 | if (state->port_ff_data & 0x80) |
| 465 | 468 | { |
| 466 | 469 | memory_set_bankptr(machine, "bank7", ExROM); |
| 467 | 470 | memory_install_read_bank(space, 0xc000, 0xdfff, 0, 0, "bank7"); |
| r7288 | r7289 | |
| 489 | 492 | } |
| 490 | 493 | else |
| 491 | 494 | { |
| 492 | | memory_set_bankptr(machine, "bank7", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x8000); |
| 493 | | memory_set_bankptr(machine, "bank15", messram_get_ptr(devtag_get_device(machine, "messram")) + 0x8000); |
| 495 | memory_set_bankptr(machine, "bank7", messram + 0x8000); |
| 496 | memory_set_bankptr(machine, "bank15", messram + 0x8000); |
| 494 | 497 | memory_install_read_bank(space, 0xc000, 0xdfff, 0, 0, "bank7"); |
| 495 | 498 | memory_install_write_bank(space, 0xc000, 0xdfff, 0, 0, "bank15"); |
| 496 | 499 | logerror("c000-dfff RAM\n"); |
| 497 | 500 | } |
| 498 | 501 | |
| 499 | | if (ts2068_port_f4_data & 0x80) |
| 502 | if (state->port_f4_data & 0x80) |
| 500 | 503 | { |
| 501 | | if (ts2068_port_ff_data & 0x80) |
| 504 | if (state->port_ff_data & 0x80) |
| 502 | 505 | { |
| 503 | 506 | memory_set_bankptr(machine, "bank8", ExROM); |
| 504 | 507 | memory_install_read_bank(space, 0xe000, 0xffff, 0, 0, "bank8"); |
| r7288 | r7289 | |
| 526 | 529 | } |
| 527 | 530 | else |
| 528 | 531 | { |
| 529 | | memory_set_bankptr(machine, "bank8", messram_get_ptr(devtag_get_device(machine, "messram")) + 0xa000); |
| 530 | | memory_set_bankptr(machine, "bank16", messram_get_ptr(devtag_get_device(machine, "messram")) + 0xa000); |
| 532 | memory_set_bankptr(machine, "bank8", messram + 0xa000); |
| 533 | memory_set_bankptr(machine, "bank16", messram + 0xa000); |
| 531 | 534 | memory_install_read_bank(space, 0xe000, 0xffff, 0, 0, "bank8"); |
| 532 | 535 | memory_install_write_bank(space, 0xe000, 0xffff, 0, 0, "bank16"); |
| 533 | 536 | logerror("e000-ffff RAM\n"); |
| 534 | 537 | } |
| 535 | 538 | } |
| 536 | 539 | |
| 537 | | static ADDRESS_MAP_START (ts2068_io, ADDRESS_SPACE_IO, 8) |
| 540 | static ADDRESS_MAP_START(ts2068_io, ADDRESS_SPACE_IO, 8) |
| 538 | 541 | AM_RANGE(0x1f, 0x1f) AM_READ( spectrum_port_1f_r ) AM_MIRROR(0xff00) |
| 539 | 542 | AM_RANGE(0x7f, 0x7f) AM_READ( spectrum_port_7f_r ) AM_MIRROR(0xff00) |
| 540 | 543 | AM_RANGE(0xdf, 0xdf) AM_READ( spectrum_port_df_r ) AM_MIRROR(0xff00) |
| r7288 | r7289 | |
| 545 | 548 | AM_RANGE(0xff, 0xff) AM_READWRITE( ts2068_port_ff_r,ts2068_port_ff_w ) AM_MIRROR(0xff00) |
| 546 | 549 | ADDRESS_MAP_END |
| 547 | 550 | |
| 548 | | static ADDRESS_MAP_START (ts2068_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 551 | static ADDRESS_MAP_START(ts2068_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 549 | 552 | AM_RANGE(0x0000, 0x1fff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank9") |
| 550 | 553 | AM_RANGE(0x2000, 0x3fff) AM_READ_BANK("bank2") AM_WRITE_BANK("bank10") |
| 551 | 554 | AM_RANGE(0x4000, 0x5fff) AM_READ_BANK("bank3") AM_WRITE_BANK("bank11") |
| r7288 | r7289 | |
| 559 | 562 | |
| 560 | 563 | static MACHINE_RESET( ts2068 ) |
| 561 | 564 | { |
| 562 | | ts2068_port_ff_data = 0; |
| 563 | | ts2068_port_f4_data = 0; |
| 565 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 566 | |
| 567 | state->port_ff_data = 0; |
| 568 | state->port_f4_data = 0; |
| 564 | 569 | ts2068_update_memory(machine); |
| 570 | MACHINE_RESET_CALL(spectrum); |
| 565 | 571 | |
| 566 | | MACHINE_RESET_CALL(spectrum); |
| 567 | 572 | } |
| 568 | 573 | |
| 569 | 574 | |
| r7288 | r7289 | |
| 571 | 576 | /* TC2048 specific functions */ |
| 572 | 577 | |
| 573 | 578 | |
| 574 | | static WRITE8_HANDLER (tc2048_port_ff_w) |
| 579 | static WRITE8_HANDLER( tc2048_port_ff_w ) |
| 575 | 580 | { |
| 576 | | ts2068_port_ff_data = data; |
| 577 | | logerror("Port %04x write %02x\n", offset, data); |
| 581 | spectrum_state *state = (spectrum_state *)space->machine->driver_data; |
| 582 | |
| 583 | state->port_ff_data = data; |
| 584 | logerror("Port %04x write %02x\n", offset, data); |
| 578 | 585 | } |
| 579 | 586 | |
| 580 | | static ADDRESS_MAP_START (tc2048_io, ADDRESS_SPACE_IO, 8) |
| 587 | static ADDRESS_MAP_START(tc2048_io, ADDRESS_SPACE_IO, 8) |
| 581 | 588 | AM_RANGE(0x00, 0x00) AM_READWRITE(spectrum_port_fe_r,spectrum_port_fe_w) AM_MIRROR(0xfffe) AM_MASK(0xffff) |
| 582 | 589 | AM_RANGE(0x1f, 0x1f) AM_READ(spectrum_port_1f_r) AM_MIRROR(0xff00) |
| 583 | 590 | AM_RANGE(0x7f, 0x7f) AM_READ(spectrum_port_7f_r) AM_MIRROR(0xff00) |
| r7288 | r7289 | |
| 585 | 592 | AM_RANGE(0xff, 0xff) AM_READWRITE(ts2068_port_ff_r,tc2048_port_ff_w) AM_MIRROR(0xff00) |
| 586 | 593 | ADDRESS_MAP_END |
| 587 | 594 | |
| 588 | | static ADDRESS_MAP_START (tc2048_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 595 | static ADDRESS_MAP_START(tc2048_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 589 | 596 | AM_RANGE( 0x0000, 0x3fff) AM_ROM |
| 590 | 597 | AM_RANGE( 0x4000, 0xffff) AM_READ_BANK("bank1") AM_WRITE_BANK("bank2") |
| 591 | 598 | ADDRESS_MAP_END |
| 592 | 599 | |
| 593 | 600 | static MACHINE_RESET( tc2048 ) |
| 594 | 601 | { |
| 595 | | memory_set_bankptr(machine, "bank1", messram_get_ptr(devtag_get_device(machine, "messram"))); |
| 596 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(devtag_get_device(machine, "messram"))); |
| 597 | | ts2068_port_ff_data = 0; |
| 602 | spectrum_state *state = (spectrum_state *)machine->driver_data; |
| 603 | UINT8 *messram = messram_get_ptr(devtag_get_device(machine, "messram")); |
| 598 | 604 | |
| 605 | memory_set_bankptr(machine, "bank1", messram); |
| 606 | memory_set_bankptr(machine, "bank2", messram); |
| 607 | state->port_ff_data = 0; |
| 608 | state->port_f4_data = -1; |
| 599 | 609 | MACHINE_RESET_CALL(spectrum); |
| 600 | 610 | } |
| 601 | 611 | |