src/mess/video/atarist.c
| r3783 | r3784 | |
| 15 | 15 | #include "video/atarist.h" |
| 16 | 16 | #include "includes/atarist.h" |
| 17 | 17 | |
| 18 | | static struct SHIFTER |
| 18 | INLINE pen_t atarist_shift_mode_0(running_machine *machine) |
| 19 | 19 | { |
| 20 | | UINT32 base; |
| 21 | | UINT32 ofs; |
| 22 | | UINT8 sync; |
| 23 | | UINT8 mode; |
| 24 | | UINT16 palette[16]; |
| 25 | | UINT8 lineofs; // STe |
| 26 | | UINT8 pixelofs; // STe |
| 27 | | UINT16 rr[4]; |
| 28 | | UINT16 ir[4]; |
| 29 | | int bitplane; |
| 30 | | int shift; |
| 31 | | int h, v; |
| 32 | | int de; |
| 33 | | int x_start, x_end, y_start, y_end, hblank_start, vblank_start; |
| 34 | | } shifter; |
| 20 | atarist_state *state = machine->driver_data; |
| 35 | 21 | |
| 36 | | static emu_timer *atarist_glue_timer; |
| 37 | | static emu_timer *atarist_shifter_timer; |
| 38 | | static const device_config *mfp; |
| 22 | int color = (BIT(state->shifter_rr[3], 15) << 3) | (BIT(state->shifter_rr[2], 15) << 2) | (BIT(state->shifter_rr[1], 15) << 1) | BIT(state->shifter_rr[0], 15); |
| 39 | 23 | |
| 40 | | INLINE pen_t atarist_shift_mode_0(running_machine *machine) |
| 41 | | { |
| 42 | | int color = (BIT(shifter.rr[3], 15) << 3) | (BIT(shifter.rr[2], 15) << 2) | (BIT(shifter.rr[1], 15) << 1) | BIT(shifter.rr[0], 15); |
| 24 | state->shifter_rr[0] <<= 1; |
| 25 | state->shifter_rr[1] <<= 1; |
| 26 | state->shifter_rr[2] <<= 1; |
| 27 | state->shifter_rr[3] <<= 1; |
| 43 | 28 | |
| 44 | | shifter.rr[0] <<= 1; |
| 45 | | shifter.rr[1] <<= 1; |
| 46 | | shifter.rr[2] <<= 1; |
| 47 | | shifter.rr[3] <<= 1; |
| 48 | | |
| 49 | 29 | return machine->pens[color]; |
| 50 | 30 | } |
| 51 | 31 | |
| 52 | 32 | INLINE pen_t atarist_shift_mode_1(running_machine *machine) |
| 53 | 33 | { |
| 54 | | int color = (BIT(shifter.rr[1], 15) << 1) | BIT(shifter.rr[0], 15); |
| 34 | atarist_state *state = machine->driver_data; |
| 55 | 35 | |
| 56 | | shifter.rr[0] <<= 1; |
| 57 | | shifter.rr[1] <<= 1; |
| 58 | | shifter.shift++; |
| 36 | int color = (BIT(state->shifter_rr[1], 15) << 1) | BIT(state->shifter_rr[0], 15); |
| 59 | 37 | |
| 60 | | if (shifter.shift == 16) |
| 38 | state->shifter_rr[0] <<= 1; |
| 39 | state->shifter_rr[1] <<= 1; |
| 40 | state->shifter_shift++; |
| 41 | |
| 42 | if (state->shifter_shift == 16) |
| 61 | 43 | { |
| 62 | | shifter.rr[0] = shifter.rr[2]; |
| 63 | | shifter.rr[1] = shifter.rr[3]; |
| 64 | | shifter.rr[2] = shifter.rr[3] = 0; |
| 65 | | shifter.shift = 0; |
| 44 | state->shifter_rr[0] = state->shifter_rr[2]; |
| 45 | state->shifter_rr[1] = state->shifter_rr[3]; |
| 46 | state->shifter_rr[2] = state->shifter_rr[3] = 0; |
| 47 | state->shifter_shift = 0; |
| 66 | 48 | } |
| 67 | 49 | |
| 68 | 50 | return machine->pens[color]; |
| r3783 | r3784 | |
| 70 | 52 | |
| 71 | 53 | INLINE pen_t atarist_shift_mode_2(running_machine *machine) |
| 72 | 54 | { |
| 73 | | int color = BIT(shifter.rr[0], 15); |
| 55 | atarist_state *state = machine->driver_data; |
| 74 | 56 | |
| 75 | | shifter.rr[0] <<= 1; |
| 76 | | shifter.shift++; |
| 57 | int color = BIT(state->shifter_rr[0], 15); |
| 77 | 58 | |
| 78 | | switch (shifter.shift) |
| 59 | state->shifter_rr[0] <<= 1; |
| 60 | state->shifter_shift++; |
| 61 | |
| 62 | switch (state->shifter_shift) |
| 79 | 63 | { |
| 80 | 64 | case 16: |
| 81 | | shifter.rr[0] = shifter.rr[1]; |
| 82 | | shifter.rr[1] = shifter.rr[2]; |
| 83 | | shifter.rr[2] = shifter.rr[3]; |
| 84 | | shifter.rr[3] = 0; |
| 65 | state->shifter_rr[0] = state->shifter_rr[1]; |
| 66 | state->shifter_rr[1] = state->shifter_rr[2]; |
| 67 | state->shifter_rr[2] = state->shifter_rr[3]; |
| 68 | state->shifter_rr[3] = 0; |
| 85 | 69 | break; |
| 86 | 70 | |
| 87 | 71 | case 32: |
| 88 | | shifter.rr[0] = shifter.rr[1]; |
| 89 | | shifter.rr[1] = shifter.rr[2]; |
| 90 | | shifter.rr[2] = 0; |
| 72 | state->shifter_rr[0] = state->shifter_rr[1]; |
| 73 | state->shifter_rr[1] = state->shifter_rr[2]; |
| 74 | state->shifter_rr[2] = 0; |
| 91 | 75 | break; |
| 92 | 76 | |
| 93 | 77 | case 48: |
| 94 | | shifter.rr[0] = shifter.rr[1]; |
| 95 | | shifter.rr[1] = 0; |
| 96 | | shifter.shift = 0; |
| 78 | state->shifter_rr[0] = state->shifter_rr[1]; |
| 79 | state->shifter_rr[1] = 0; |
| 80 | state->shifter_shift = 0; |
| 97 | 81 | break; |
| 98 | 82 | } |
| 99 | 83 | |
| 100 | 84 | return machine->pens[color]; |
| 101 | 85 | } |
| 102 | 86 | |
| 103 | | static TIMER_CALLBACK(atarist_shifter_tick) |
| 87 | static TIMER_CALLBACK( atarist_shifter_tick ) |
| 104 | 88 | { |
| 89 | atarist_state *state = machine->driver_data; |
| 90 | |
| 105 | 91 | int y = video_screen_get_vpos(machine->primary_screen); |
| 106 | 92 | int x = video_screen_get_hpos(machine->primary_screen); |
| 107 | 93 | |
| 108 | 94 | pen_t pen; |
| 109 | 95 | |
| 110 | | switch (shifter.mode) |
| 96 | switch (state->shifter_mode) |
| 111 | 97 | { |
| 112 | 98 | case 0: |
| 113 | 99 | pen = atarist_shift_mode_0(machine); |
| r3783 | r3784 | |
| 131 | 117 | |
| 132 | 118 | INLINE void atarist_shifter_load(running_machine *machine) |
| 133 | 119 | { |
| 134 | | UINT8 *RAM = memory_region(machine, "main") + shifter.ofs; |
| 120 | atarist_state *state = machine->driver_data; |
| 135 | 121 | |
| 136 | | shifter.ir[shifter.bitplane] = (RAM[1] << 8) | RAM[0]; |
| 137 | | shifter.bitplane++; |
| 138 | | shifter.ofs += 2; |
| 122 | const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 123 | UINT16 data = memory_read_word_16be(program, state->shifter_ofs); |
| 139 | 124 | |
| 140 | | if (shifter.bitplane == 4) |
| 125 | state->shifter_ir[state->shifter_bitplane] = data; |
| 126 | state->shifter_bitplane++; |
| 127 | state->shifter_ofs += 2; |
| 128 | |
| 129 | if (state->shifter_bitplane == 4) |
| 141 | 130 | { |
| 142 | | shifter.bitplane = 0; |
| 131 | state->shifter_bitplane = 0; |
| 143 | 132 | |
| 144 | | shifter.rr[0] = shifter.ir[0]; |
| 145 | | shifter.rr[1] = shifter.ir[1]; |
| 146 | | shifter.rr[2] = shifter.ir[2]; |
| 147 | | shifter.rr[3] = shifter.ir[3]; |
| 133 | state->shifter_rr[0] = state->shifter_ir[0]; |
| 134 | state->shifter_rr[1] = state->shifter_ir[1]; |
| 135 | state->shifter_rr[2] = state->shifter_ir[2]; |
| 136 | state->shifter_rr[3] = state->shifter_ir[3]; |
| 148 | 137 | } |
| 149 | 138 | } |
| 150 | 139 | |
| 151 | | static TIMER_CALLBACK(atarist_glue_tick) |
| 140 | static TIMER_CALLBACK( atarist_glue_tick ) |
| 152 | 141 | { |
| 142 | atarist_state *state = machine->driver_data; |
| 143 | |
| 153 | 144 | int y = video_screen_get_vpos(machine->primary_screen); |
| 154 | 145 | int x = video_screen_get_hpos(machine->primary_screen); |
| 155 | 146 | |
| 156 | | int v = (y >= shifter.y_start) && (y < shifter.y_end); |
| 157 | | int h = (x >= shifter.x_start) && (x < shifter.x_end); |
| 147 | int v = (y >= state->shifter_y_start) && (y < state->shifter_y_end); |
| 148 | int h = (x >= state->shifter_x_start) && (x < state->shifter_x_end); |
| 158 | 149 | |
| 159 | 150 | int de = h && v; |
| 160 | 151 | |
| 161 | | if (de != shifter.de) |
| 152 | if (de != state->shifter_de) |
| 162 | 153 | { |
| 163 | | mc68901_tbi_w(mfp, de); |
| 164 | | shifter.de = de; |
| 154 | mc68901_tbi_w(state->mc68901, de); |
| 155 | state->shifter_de = de; |
| 165 | 156 | } |
| 166 | 157 | |
| 167 | 158 | if (de) |
| r3783 | r3784 | |
| 169 | 160 | atarist_shifter_load(machine); |
| 170 | 161 | } |
| 171 | 162 | |
| 172 | | if ((y == shifter.vblank_start) && (x == 0)) |
| 163 | if ((y == state->shifter_vblank_start) && (x == 0)) |
| 173 | 164 | { |
| 174 | 165 | cpu_set_input_line(machine->cpu[0], M68K_IRQ_4, HOLD_LINE); |
| 175 | | shifter.ofs = shifter.base; |
| 166 | state->shifter_ofs = state->shifter_base; |
| 176 | 167 | } |
| 177 | 168 | |
| 178 | | if (x == shifter.hblank_start) |
| 169 | if (x == state->shifter_hblank_start) |
| 179 | 170 | { |
| 180 | 171 | cpu_set_input_line(machine->cpu[0], M68K_IRQ_2, HOLD_LINE); |
| 181 | | shifter.ofs += (shifter.lineofs * 2); // STe |
| 172 | state->shifter_ofs += (state->shifter_lineofs * 2); // STe |
| 182 | 173 | } |
| 183 | 174 | } |
| 184 | 175 | |
| 185 | | static void atarist_set_screen_parameters(void) |
| 176 | static void atarist_set_screen_parameters(running_machine *machine) |
| 186 | 177 | { |
| 187 | | if (shifter.sync & 0x02) |
| 178 | atarist_state *state = machine->driver_data; |
| 179 | |
| 180 | if (state->shifter_sync & 0x02) |
| 188 | 181 | { |
| 189 | | shifter.x_start = ATARIST_HBDEND_PAL; |
| 190 | | shifter.x_end = ATARIST_HBDSTART_PAL; |
| 191 | | shifter.y_start = ATARIST_VBDEND_PAL; |
| 192 | | shifter.y_end = ATARIST_VBDSTART_PAL; |
| 193 | | shifter.hblank_start = ATARIST_HBSTART_PAL; |
| 194 | | shifter.vblank_start = ATARIST_VBSTART_PAL; |
| 182 | state->shifter_x_start = ATARIST_HBDEND_PAL; |
| 183 | state->shifter_x_end = ATARIST_HBDSTART_PAL; |
| 184 | state->shifter_y_start = ATARIST_VBDEND_PAL; |
| 185 | state->shifter_y_end = ATARIST_VBDSTART_PAL; |
| 186 | state->shifter_hblank_start = ATARIST_HBSTART_PAL; |
| 187 | state->shifter_vblank_start = ATARIST_VBSTART_PAL; |
| 195 | 188 | } |
| 196 | 189 | else |
| 197 | 190 | { |
| 198 | | shifter.x_start = ATARIST_HBDEND_NTSC; |
| 199 | | shifter.x_end = ATARIST_HBDSTART_NTSC; |
| 200 | | shifter.y_start = ATARIST_VBDEND_NTSC; |
| 201 | | shifter.y_end = ATARIST_VBDSTART_NTSC; |
| 202 | | shifter.hblank_start = ATARIST_HBSTART_NTSC; |
| 203 | | shifter.vblank_start = ATARIST_VBSTART_NTSC; |
| 191 | state->shifter_x_start = ATARIST_HBDEND_NTSC; |
| 192 | state->shifter_x_end = ATARIST_HBDSTART_NTSC; |
| 193 | state->shifter_y_start = ATARIST_VBDEND_NTSC; |
| 194 | state->shifter_y_end = ATARIST_VBDSTART_NTSC; |
| 195 | state->shifter_hblank_start = ATARIST_HBSTART_NTSC; |
| 196 | state->shifter_vblank_start = ATARIST_VBSTART_NTSC; |
| 204 | 197 | } |
| 205 | 198 | } |
| 206 | 199 | |
| r3783 | r3784 | |
| 208 | 201 | |
| 209 | 202 | READ16_HANDLER( atarist_shifter_base_r ) |
| 210 | 203 | { |
| 204 | atarist_state *state = space->machine->driver_data; |
| 205 | |
| 211 | 206 | switch (offset) |
| 212 | 207 | { |
| 213 | 208 | case 0x00: |
| 214 | | return (shifter.base >> 16) & 0x3f; |
| 209 | return (state->shifter_base >> 16) & 0x3f; |
| 215 | 210 | case 0x01: |
| 216 | | return (shifter.base >> 8) & 0xff; |
| 211 | return (state->shifter_base >> 8) & 0xff; |
| 217 | 212 | } |
| 218 | 213 | |
| 219 | 214 | return 0; |
| r3783 | r3784 | |
| 221 | 216 | |
| 222 | 217 | WRITE16_HANDLER( atarist_shifter_base_w ) |
| 223 | 218 | { |
| 219 | atarist_state *state = space->machine->driver_data; |
| 220 | |
| 224 | 221 | switch (offset) |
| 225 | 222 | { |
| 226 | 223 | case 0x00: |
| 227 | | shifter.base = (shifter.base & 0x00ff00) | (data & 0x3f) << 16; |
| 228 | | logerror("SHIFTER Video Base Address %06x\n", shifter.base); |
| 224 | state->shifter_base = (state->shifter_base & 0x00ff00) | (data & 0x3f) << 16; |
| 225 | logerror("SHIFTER Video Base Address %06x\n", state->shifter_base); |
| 229 | 226 | break; |
| 230 | 227 | case 0x01: |
| 231 | | shifter.base = (shifter.base & 0x3f0000) | (data & 0xff) << 8; |
| 232 | | logerror("SHIFTER Video Base Address %06x\n", shifter.base); |
| 228 | state->shifter_base = (state->shifter_base & 0x3f0000) | (data & 0xff) << 8; |
| 229 | logerror("SHIFTER Video Base Address %06x\n", state->shifter_base); |
| 233 | 230 | break; |
| 234 | 231 | } |
| 235 | 232 | } |
| 236 | 233 | |
| 237 | 234 | READ16_HANDLER( atarist_shifter_counter_r ) |
| 238 | 235 | { |
| 236 | atarist_state *state = space->machine->driver_data; |
| 237 | |
| 239 | 238 | switch (offset) |
| 240 | 239 | { |
| 241 | 240 | case 0x00: |
| 242 | | return (shifter.ofs >> 16) & 0x3f; |
| 241 | return (state->shifter_ofs >> 16) & 0x3f; |
| 243 | 242 | case 0x01: |
| 244 | | return (shifter.ofs >> 8) & 0xff; |
| 243 | return (state->shifter_ofs >> 8) & 0xff; |
| 245 | 244 | case 0x02: |
| 246 | | return shifter.ofs & 0xff; |
| 245 | return state->shifter_ofs & 0xff; |
| 247 | 246 | } |
| 248 | 247 | |
| 249 | 248 | return 0; |
| r3783 | r3784 | |
| 251 | 250 | |
| 252 | 251 | READ8_HANDLER( atarist_shifter_sync_r ) |
| 253 | 252 | { |
| 254 | | return shifter.sync; |
| 253 | atarist_state *state = space->machine->driver_data; |
| 254 | |
| 255 | return state->shifter_sync; |
| 255 | 256 | } |
| 256 | 257 | |
| 257 | 258 | WRITE8_HANDLER( atarist_shifter_sync_w ) |
| 258 | 259 | { |
| 259 | | shifter.sync = data; |
| 260 | | logerror("SHIFTER Sync %x\n", shifter.sync); |
| 261 | | atarist_set_screen_parameters(); |
| 260 | atarist_state *state = space->machine->driver_data; |
| 261 | |
| 262 | state->shifter_sync = data; |
| 263 | logerror("SHIFTER Sync %x\n", state->shifter_sync); |
| 264 | atarist_set_screen_parameters(space->machine); |
| 262 | 265 | } |
| 263 | 266 | |
| 264 | 267 | READ8_HANDLER( atarist_shifter_mode_r ) |
| 265 | 268 | { |
| 266 | | return shifter.mode; |
| 269 | atarist_state *state = space->machine->driver_data; |
| 270 | |
| 271 | return state->shifter_mode; |
| 267 | 272 | } |
| 268 | 273 | |
| 269 | 274 | WRITE8_HANDLER( atarist_shifter_mode_w ) |
| 270 | 275 | { |
| 271 | | shifter.mode = data; |
| 272 | | logerror("SHIFTER Mode %x\n", shifter.mode); |
| 276 | atarist_state *state = space->machine->driver_data; |
| 277 | |
| 278 | state->shifter_mode = data; |
| 279 | logerror("SHIFTER Mode %x\n", state->shifter_mode); |
| 273 | 280 | } |
| 274 | 281 | |
| 275 | 282 | READ16_HANDLER( atarist_shifter_palette_r ) |
| 276 | 283 | { |
| 277 | | return shifter.palette[offset]; |
| 284 | atarist_state *state = space->machine->driver_data; |
| 285 | |
| 286 | return state->shifter_palette[offset]; |
| 278 | 287 | } |
| 279 | 288 | |
| 280 | 289 | WRITE16_HANDLER( atarist_shifter_palette_w ) |
| 281 | 290 | { |
| 282 | | shifter.palette[offset] = data; |
| 291 | atarist_state *state = space->machine->driver_data; |
| 292 | |
| 293 | state->shifter_palette[offset] = data; |
| 283 | 294 | logerror("SHIFTER Palette[%x] = %x\n", offset, data); |
| 284 | 295 | |
| 285 | 296 | palette_set_color_rgb(space->machine, offset, pal3bit(data >> 8), pal3bit(data >> 4), pal3bit(data)); |
| r3783 | r3784 | |
| 289 | 300 | |
| 290 | 301 | READ16_HANDLER( atariste_shifter_base_low_r ) |
| 291 | 302 | { |
| 292 | | return shifter.base & 0xfe; |
| 303 | atarist_state *state = space->machine->driver_data; |
| 304 | |
| 305 | return state->shifter_base & 0xfe; |
| 293 | 306 | } |
| 294 | 307 | |
| 295 | 308 | WRITE16_HANDLER( atariste_shifter_base_low_w ) |
| 296 | 309 | { |
| 297 | | shifter.base = (shifter.base & 0x3fff00) | (data & 0xfe); |
| 298 | | logerror("SHIFTER Video Base Address %06x\n", shifter.base); |
| 310 | atarist_state *state = space->machine->driver_data; |
| 311 | |
| 312 | state->shifter_base = (state->shifter_base & 0x3fff00) | (data & 0xfe); |
| 313 | logerror("SHIFTER Video Base Address %06x\n", state->shifter_base); |
| 299 | 314 | } |
| 300 | 315 | |
| 301 | 316 | READ16_HANDLER( atariste_shifter_counter_r ) |
| 302 | 317 | { |
| 318 | atarist_state *state = space->machine->driver_data; |
| 319 | |
| 303 | 320 | switch (offset) |
| 304 | 321 | { |
| 305 | 322 | case 0x00: |
| 306 | | return (shifter.ofs >> 16) & 0x3f; |
| 323 | return (state->shifter_ofs >> 16) & 0x3f; |
| 307 | 324 | case 0x01: |
| 308 | | return (shifter.ofs >> 8) & 0xff; |
| 325 | return (state->shifter_ofs >> 8) & 0xff; |
| 309 | 326 | case 0x02: |
| 310 | | return shifter.ofs & 0xfe; |
| 327 | return state->shifter_ofs & 0xfe; |
| 311 | 328 | } |
| 312 | 329 | |
| 313 | 330 | return 0; |
| r3783 | r3784 | |
| 315 | 332 | |
| 316 | 333 | WRITE16_HANDLER( atariste_shifter_counter_w ) |
| 317 | 334 | { |
| 335 | atarist_state *state = space->machine->driver_data; |
| 336 | |
| 318 | 337 | switch (offset) |
| 319 | 338 | { |
| 320 | 339 | case 0x00: |
| 321 | | shifter.ofs = (shifter.ofs & 0x00fffe) | (data & 0x3f) << 16; |
| 322 | | logerror("SHIFTER Video Address Counter %06x\n", shifter.ofs); |
| 340 | state->shifter_ofs = (state->shifter_ofs & 0x00fffe) | (data & 0x3f) << 16; |
| 341 | logerror("SHIFTER Video Address Counter %06x\n", state->shifter_ofs); |
| 323 | 342 | break; |
| 324 | 343 | case 0x01: |
| 325 | | shifter.ofs = (shifter.ofs & 0x3f00fe) | (data & 0xff) << 8; |
| 326 | | logerror("SHIFTER Video Address Counter %06x\n", shifter.ofs); |
| 344 | state->shifter_ofs = (state->shifter_ofs & 0x3f00fe) | (data & 0xff) << 8; |
| 345 | logerror("SHIFTER Video Address Counter %06x\n", state->shifter_ofs); |
| 327 | 346 | break; |
| 328 | 347 | case 0x02: |
| 329 | | shifter.ofs = (shifter.ofs & 0x3fff00) | (data & 0xfe); |
| 330 | | logerror("SHIFTER Video Address Counter %06x\n", shifter.ofs); |
| 348 | state->shifter_ofs = (state->shifter_ofs & 0x3fff00) | (data & 0xfe); |
| 349 | logerror("SHIFTER Video Address Counter %06x\n", state->shifter_ofs); |
| 331 | 350 | break; |
| 332 | 351 | } |
| 333 | 352 | } |
| 334 | 353 | |
| 335 | 354 | WRITE16_HANDLER( atariste_shifter_palette_w ) |
| 336 | 355 | { |
| 356 | atarist_state *state = space->machine->driver_data; |
| 357 | |
| 337 | 358 | int r = ((data >> 7) & 0x0e) | BIT(data, 11); |
| 338 | 359 | int g = ((data >> 3) & 0x0e) | BIT(data, 7); |
| 339 | 360 | int b = ((data << 1) & 0x0e) | BIT(data, 3); |
| 340 | 361 | |
| 341 | | shifter.palette[offset] = data; |
| 362 | state->shifter_palette[offset] = data; |
| 342 | 363 | logerror("SHIFTER palette %x = %x\n", offset, data); |
| 343 | 364 | |
| 344 | 365 | palette_set_color_rgb(space->machine, offset, r, g, b); |
| r3783 | r3784 | |
| 346 | 367 | |
| 347 | 368 | READ16_HANDLER( atariste_shifter_lineofs_r ) |
| 348 | 369 | { |
| 349 | | return shifter.lineofs; |
| 370 | atarist_state *state = space->machine->driver_data; |
| 371 | |
| 372 | return state->shifter_lineofs; |
| 350 | 373 | } |
| 351 | 374 | |
| 352 | 375 | WRITE16_HANDLER( atariste_shifter_lineofs_w ) |
| 353 | 376 | { |
| 354 | | shifter.lineofs = data & 0xff; |
| 355 | | logerror("SHIFTER Line Offset %x\n", shifter.lineofs); |
| 377 | atarist_state *state = space->machine->driver_data; |
| 378 | |
| 379 | state->shifter_lineofs = data & 0xff; |
| 380 | logerror("SHIFTER Line Offset %x\n", state->shifter_lineofs); |
| 356 | 381 | } |
| 357 | 382 | |
| 358 | 383 | READ16_HANDLER( atariste_shifter_pixelofs_r ) |
| 359 | 384 | { |
| 360 | | return shifter.pixelofs; |
| 385 | atarist_state *state = space->machine->driver_data; |
| 386 | |
| 387 | return state->shifter_pixelofs; |
| 361 | 388 | } |
| 362 | 389 | |
| 363 | 390 | WRITE16_HANDLER( atariste_shifter_pixelofs_w ) |
| 364 | 391 | { |
| 365 | | shifter.pixelofs = data & 0x0f; |
| 366 | | logerror("SHIFTER Pixel Offset %x\n", shifter.pixelofs); |
| 392 | atarist_state *state = space->machine->driver_data; |
| 393 | |
| 394 | state->shifter_pixelofs = data & 0x0f; |
| 395 | logerror("SHIFTER Pixel Offset %x\n", state->shifter_pixelofs); |
| 367 | 396 | } |
| 368 | 397 | |
| 369 | 398 | /* Atari ST Blitter */ |
| r3783 | r3784 | |
| 388 | 417 | { 1, 1, 1, 1 } |
| 389 | 418 | }; |
| 390 | 419 | |
| 391 | | static struct BLITTER |
| 392 | | { |
| 393 | | UINT16 halftone[16]; |
| 394 | | INT16 src_inc_x, src_inc_y, dst_inc_x, dst_inc_y; |
| 395 | | UINT32 src, dst; |
| 396 | | UINT16 endmask1, endmask2, endmask3; |
| 397 | | UINT16 xcount, ycount, xcountl; |
| 398 | | UINT8 hop, op, ctrl, skew; |
| 399 | | UINT32 srcbuf; |
| 400 | | } blitter; |
| 401 | | |
| 402 | 420 | static void atarist_blitter_source(running_machine *machine) |
| 403 | 421 | { |
| 404 | | UINT8 *RAM = memory_region(machine, "main") + blitter.src; |
| 422 | atarist_state *state = machine->driver_data; |
| 405 | 423 | |
| 406 | | if (blitter.src_inc_x < 0) |
| 424 | const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 425 | UINT16 data = memory_read_word_16be(program, state->blitter_src); |
| 426 | |
| 427 | if (state->blitter_src_inc_x < 0) |
| 407 | 428 | { |
| 408 | | blitter.srcbuf = (RAM[1] << 24) | (RAM[0] << 16) | (blitter.srcbuf >> 16); |
| 429 | state->blitter_srcbuf = (data << 16) | (state->blitter_srcbuf >> 16); |
| 409 | 430 | } |
| 410 | 431 | else |
| 411 | 432 | { |
| 412 | | blitter.srcbuf = (blitter.srcbuf << 16) | (RAM[1] << 8) | RAM[0]; |
| 433 | state->blitter_srcbuf = (state->blitter_srcbuf << 16) | data; |
| 413 | 434 | } |
| 414 | 435 | } |
| 415 | 436 | |
| 416 | | static UINT16 atarist_blitter_hop(void) |
| 437 | static UINT16 atarist_blitter_hop(running_machine *machine) |
| 417 | 438 | { |
| 418 | | UINT16 source = blitter.srcbuf >> (blitter.skew & 0x0f); |
| 419 | | UINT16 halftone = blitter.halftone[blitter.ctrl & 0x0f]; |
| 439 | atarist_state *state = machine->driver_data; |
| 420 | 440 | |
| 421 | | if (blitter.ctrl & ATARIST_BLITTER_CTRL_SMUDGE) |
| 441 | UINT16 source = state->blitter_srcbuf >> (state->blitter_skew & 0x0f); |
| 442 | UINT16 halftone = state->blitter_halftone[state->blitter_ctrl & 0x0f]; |
| 443 | |
| 444 | if (state->blitter_ctrl & ATARIST_BLITTER_CTRL_SMUDGE) |
| 422 | 445 | { |
| 423 | | halftone = blitter.halftone[source & 0x0f]; |
| 446 | halftone = state->blitter_halftone[source & 0x0f]; |
| 424 | 447 | } |
| 425 | 448 | |
| 426 | | switch (blitter.hop) |
| 449 | switch (state->blitter_hop) |
| 427 | 450 | { |
| 428 | 451 | case 0: |
| 429 | 452 | return 0xffff; |
| r3783 | r3784 | |
| 440 | 463 | |
| 441 | 464 | static void atarist_blitter_op(running_machine *machine, UINT16 s, UINT32 dstaddr, UINT16 mask) |
| 442 | 465 | { |
| 443 | | UINT8 *dst = memory_region(machine, "main") + dstaddr; |
| 444 | | UINT16 d = (dst[1] << 8) + dst[0]; |
| 466 | atarist_state *state = machine->driver_data; |
| 467 | const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 468 | |
| 469 | UINT16 d = memory_read_word_16be(program, dstaddr); |
| 445 | 470 | UINT16 result = 0; |
| 446 | 471 | |
| 447 | | if (blitter.op & 0x08) result = (~s & ~d); |
| 448 | | if (blitter.op & 0x04) result |= (~s & d); |
| 449 | | if (blitter.op & 0x02) result |= (s & ~d); |
| 450 | | if (blitter.op & 0x01) result |= (s & d); |
| 472 | if (state->blitter_op & 0x08) result = (~s & ~d); |
| 473 | if (state->blitter_op & 0x04) result |= (~s & d); |
| 474 | if (state->blitter_op & 0x02) result |= (s & ~d); |
| 475 | if (state->blitter_op & 0x01) result |= (s & d); |
| 451 | 476 | |
| 452 | | dst[0] = result & 0xff; |
| 453 | | dst[1] = (result >> 8) & 0xff; |
| 477 | memory_write_word_16be(program, dstaddr, result); |
| 454 | 478 | } |
| 455 | 479 | |
| 456 | 480 | static TIMER_CALLBACK( atarist_blitter_tick ) |
| 457 | 481 | { |
| 482 | atarist_state *state = machine->driver_data; |
| 483 | |
| 458 | 484 | do |
| 459 | 485 | { |
| 460 | | if (blitter.skew & ATARIST_BLITTER_SKEW_FXSR) |
| 486 | if (state->blitter_skew & ATARIST_BLITTER_SKEW_FXSR) |
| 461 | 487 | { |
| 462 | 488 | atarist_blitter_source(machine); |
| 463 | | blitter.src += blitter.src_inc_x; |
| 489 | state->blitter_src += state->blitter_src_inc_x; |
| 464 | 490 | } |
| 465 | 491 | |
| 466 | 492 | atarist_blitter_source(machine); |
| 467 | | atarist_blitter_op(machine, atarist_blitter_hop(), blitter.dst, blitter.endmask1); |
| 468 | | blitter.xcount--; |
| 493 | atarist_blitter_op(machine, atarist_blitter_hop(machine), state->blitter_dst, state->blitter_endmask1); |
| 494 | state->blitter_xcount--; |
| 469 | 495 | |
| 470 | | while (blitter.xcount > 0) |
| 496 | while (state->blitter_xcount > 0) |
| 471 | 497 | { |
| 472 | | blitter.src += blitter.src_inc_x; |
| 473 | | blitter.dst += blitter.dst_inc_x; |
| 498 | state->blitter_src += state->blitter_src_inc_x; |
| 499 | state->blitter_dst += state->blitter_dst_inc_x; |
| 474 | 500 | |
| 475 | | if (blitter.xcount == 1) |
| 501 | if (state->blitter_xcount == 1) |
| 476 | 502 | { |
| 477 | | if (!(blitter.skew & ATARIST_BLITTER_SKEW_NFSR)) |
| 503 | if (!(state->blitter_skew & ATARIST_BLITTER_SKEW_NFSR)) |
| 478 | 504 | { |
| 479 | 505 | atarist_blitter_source(machine); |
| 480 | 506 | } |
| 481 | 507 | |
| 482 | | atarist_blitter_op(machine, atarist_blitter_hop(), blitter.dst, blitter.endmask3); |
| 508 | atarist_blitter_op(machine, atarist_blitter_hop(machine), state->blitter_dst, state->blitter_endmask3); |
| 483 | 509 | } |
| 484 | 510 | else |
| 485 | 511 | { |
| 486 | 512 | atarist_blitter_source(machine); |
| 487 | | atarist_blitter_op(machine, atarist_blitter_hop(), blitter.dst, blitter.endmask2); |
| 513 | atarist_blitter_op(machine, atarist_blitter_hop(machine), state->blitter_dst, state->blitter_endmask2); |
| 488 | 514 | } |
| 489 | 515 | |
| 490 | | blitter.xcount--; |
| 516 | state->blitter_xcount--; |
| 491 | 517 | } |
| 492 | 518 | |
| 493 | | blitter.src += blitter.src_inc_y; |
| 494 | | blitter.dst += blitter.dst_inc_y; |
| 519 | state->blitter_src += state->blitter_src_inc_y; |
| 520 | state->blitter_dst += state->blitter_dst_inc_y; |
| 495 | 521 | |
| 496 | | if (blitter.dst_inc_y < 0) |
| 522 | if (state->blitter_dst_inc_y < 0) |
| 497 | 523 | { |
| 498 | | blitter.ctrl = (blitter.ctrl & 0xf0) | (((blitter.ctrl & 0x0f) - 1) & 0x0f); |
| 524 | state->blitter_ctrl = (state->blitter_ctrl & 0xf0) | (((state->blitter_ctrl & 0x0f) - 1) & 0x0f); |
| 499 | 525 | } |
| 500 | 526 | else |
| 501 | 527 | { |
| 502 | | blitter.ctrl = (blitter.ctrl & 0xf0) | (((blitter.ctrl & 0x0f) + 1) & 0x0f); |
| 528 | state->blitter_ctrl = (state->blitter_ctrl & 0xf0) | (((state->blitter_ctrl & 0x0f) + 1) & 0x0f); |
| 503 | 529 | } |
| 504 | 530 | |
| 505 | | blitter.xcount = blitter.xcountl; |
| 506 | | blitter.ycount--; |
| 531 | state->blitter_xcount = state->blitter_xcountl; |
| 532 | state->blitter_ycount--; |
| 507 | 533 | } |
| 508 | | while (blitter.ycount > 0); |
| 534 | while (state->blitter_ycount > 0); |
| 509 | 535 | |
| 510 | | blitter.ctrl &= 0x7f; |
| 536 | state->blitter_ctrl &= 0x7f; |
| 511 | 537 | } |
| 512 | 538 | |
| 513 | 539 | READ16_HANDLER( atarist_blitter_halftone_r ) |
| 514 | 540 | { |
| 515 | | return blitter.halftone[offset]; |
| 541 | atarist_state *state = space->machine->driver_data; |
| 542 | |
| 543 | return state->blitter_halftone[offset]; |
| 516 | 544 | } |
| 517 | 545 | |
| 518 | 546 | READ16_HANDLER( atarist_blitter_src_inc_x_r ) |
| 519 | 547 | { |
| 520 | | return blitter.src_inc_x; |
| 548 | atarist_state *state = space->machine->driver_data; |
| 549 | |
| 550 | return state->blitter_src_inc_x; |
| 521 | 551 | } |
| 522 | 552 | |
| 523 | 553 | READ16_HANDLER( atarist_blitter_src_inc_y_r ) |
| 524 | 554 | { |
| 525 | | return blitter.src_inc_y; |
| 555 | atarist_state *state = space->machine->driver_data; |
| 556 | |
| 557 | return state->blitter_src_inc_y; |
| 526 | 558 | } |
| 527 | 559 | |
| 528 | 560 | READ16_HANDLER( atarist_blitter_src_r ) |
| 529 | 561 | { |
| 562 | atarist_state *state = space->machine->driver_data; |
| 563 | |
| 530 | 564 | switch (offset) |
| 531 | 565 | { |
| 532 | 566 | case 0: |
| 533 | | return (blitter.src >> 16) & 0xff; |
| 567 | return (state->blitter_src >> 16) & 0xff; |
| 534 | 568 | case 1: |
| 535 | | return blitter.src & 0xfffe; |
| 569 | return state->blitter_src & 0xfffe; |
| 536 | 570 | } |
| 537 | 571 | |
| 538 | 572 | return 0; |
| r3783 | r3784 | |
| 540 | 574 | |
| 541 | 575 | READ16_HANDLER( atarist_blitter_end_mask_r ) |
| 542 | 576 | { |
| 577 | atarist_state *state = space->machine->driver_data; |
| 578 | |
| 543 | 579 | switch (offset) |
| 544 | 580 | { |
| 545 | 581 | case 0: |
| 546 | | return blitter.endmask1; |
| 582 | return state->blitter_endmask1; |
| 547 | 583 | case 1: |
| 548 | | return blitter.endmask2; |
| 584 | return state->blitter_endmask2; |
| 549 | 585 | case 2: |
| 550 | | return blitter.endmask3; |
| 586 | return state->blitter_endmask3; |
| 551 | 587 | } |
| 552 | 588 | |
| 553 | 589 | return 0; |
| r3783 | r3784 | |
| 555 | 591 | |
| 556 | 592 | READ16_HANDLER( atarist_blitter_dst_inc_x_r ) |
| 557 | 593 | { |
| 558 | | return blitter.dst_inc_x; |
| 594 | atarist_state *state = space->machine->driver_data; |
| 595 | |
| 596 | return state->blitter_dst_inc_x; |
| 559 | 597 | } |
| 560 | 598 | |
| 561 | 599 | READ16_HANDLER( atarist_blitter_dst_inc_y_r ) |
| 562 | 600 | { |
| 563 | | return blitter.dst_inc_y; |
| 601 | atarist_state *state = space->machine->driver_data; |
| 602 | |
| 603 | return state->blitter_dst_inc_y; |
| 564 | 604 | } |
| 565 | 605 | |
| 566 | 606 | READ16_HANDLER( atarist_blitter_dst_r ) |
| 567 | 607 | { |
| 608 | atarist_state *state = space->machine->driver_data; |
| 609 | |
| 568 | 610 | switch (offset) |
| 569 | 611 | { |
| 570 | 612 | case 0: |
| 571 | | return (blitter.dst >> 16) & 0xff; |
| 613 | return (state->blitter_dst >> 16) & 0xff; |
| 572 | 614 | case 1: |
| 573 | | return blitter.dst & 0xfffe; |
| 615 | return state->blitter_dst & 0xfffe; |
| 574 | 616 | } |
| 575 | 617 | |
| 576 | 618 | return 0; |
| r3783 | r3784 | |
| 578 | 620 | |
| 579 | 621 | READ16_HANDLER( atarist_blitter_count_x_r ) |
| 580 | 622 | { |
| 581 | | return blitter.xcount; |
| 623 | atarist_state *state = space->machine->driver_data; |
| 624 | |
| 625 | return state->blitter_xcount; |
| 582 | 626 | } |
| 583 | 627 | |
| 584 | 628 | READ16_HANDLER( atarist_blitter_count_y_r ) |
| 585 | 629 | { |
| 586 | | return blitter.ycount; |
| 630 | atarist_state *state = space->machine->driver_data; |
| 631 | |
| 632 | return state->blitter_ycount; |
| 587 | 633 | } |
| 588 | 634 | |
| 589 | 635 | READ16_HANDLER( atarist_blitter_op_r ) |
| 590 | 636 | { |
| 637 | atarist_state *state = space->machine->driver_data; |
| 638 | |
| 591 | 639 | if (ACCESSING_BITS_0_7) |
| 592 | 640 | { |
| 593 | | return blitter.hop; |
| 641 | return state->blitter_hop; |
| 594 | 642 | } |
| 595 | 643 | else |
| 596 | 644 | { |
| 597 | | return blitter.op; |
| 645 | return state->blitter_op; |
| 598 | 646 | } |
| 599 | 647 | } |
| 600 | 648 | |
| 601 | 649 | READ16_HANDLER( atarist_blitter_ctrl_r ) |
| 602 | 650 | { |
| 651 | atarist_state *state = space->machine->driver_data; |
| 652 | |
| 603 | 653 | if (ACCESSING_BITS_0_7) |
| 604 | 654 | { |
| 605 | | return blitter.ctrl; |
| 655 | return state->blitter_ctrl; |
| 606 | 656 | } |
| 607 | 657 | else |
| 608 | 658 | { |
| 609 | | return blitter.skew; |
| 659 | return state->blitter_skew; |
| 610 | 660 | } |
| 611 | 661 | } |
| 612 | 662 | |
| 613 | 663 | WRITE16_HANDLER( atarist_blitter_halftone_w ) |
| 614 | 664 | { |
| 615 | | blitter.halftone[offset] = data; |
| 665 | atarist_state *state = space->machine->driver_data; |
| 666 | |
| 667 | state->blitter_halftone[offset] = data; |
| 616 | 668 | } |
| 617 | 669 | |
| 618 | 670 | WRITE16_HANDLER( atarist_blitter_src_inc_x_w ) |
| 619 | 671 | { |
| 620 | | blitter.src_inc_x = data & 0xfffe; |
| 672 | atarist_state *state = space->machine->driver_data; |
| 673 | |
| 674 | state->blitter_src_inc_x = data & 0xfffe; |
| 621 | 675 | } |
| 622 | 676 | |
| 623 | 677 | WRITE16_HANDLER( atarist_blitter_src_inc_y_w ) |
| 624 | 678 | { |
| 625 | | blitter.src_inc_y = data & 0xfffe; |
| 679 | atarist_state *state = space->machine->driver_data; |
| 680 | |
| 681 | state->blitter_src_inc_y = data & 0xfffe; |
| 626 | 682 | } |
| 627 | 683 | |
| 628 | 684 | WRITE16_HANDLER( atarist_blitter_src_w ) |
| 629 | 685 | { |
| 686 | atarist_state *state = space->machine->driver_data; |
| 687 | |
| 630 | 688 | switch (offset) |
| 631 | 689 | { |
| 632 | 690 | case 0: |
| 633 | | blitter.src = (data & 0xff) | (blitter.src & 0xfffe); |
| 691 | state->blitter_src = (data & 0xff) | (state->blitter_src & 0xfffe); |
| 634 | 692 | case 1: |
| 635 | | blitter.src = (blitter.src & 0xff0000) | (data & 0xfffe); |
| 693 | state->blitter_src = (state->blitter_src & 0xff0000) | (data & 0xfffe); |
| 636 | 694 | } |
| 637 | 695 | } |
| 638 | 696 | |
| 639 | 697 | WRITE16_HANDLER( atarist_blitter_end_mask_w ) |
| 640 | 698 | { |
| 699 | atarist_state *state = space->machine->driver_data; |
| 700 | |
| 641 | 701 | switch (offset) |
| 642 | 702 | { |
| 643 | 703 | case 0: |
| 644 | | blitter.endmask1 = data; |
| 704 | state->blitter_endmask1 = data; |
| 645 | 705 | case 1: |
| 646 | | blitter.endmask2 = data; |
| 706 | state->blitter_endmask2 = data; |
| 647 | 707 | case 2: |
| 648 | | blitter.endmask3 = data; |
| 708 | state->blitter_endmask3 = data; |
| 649 | 709 | } |
| 650 | 710 | } |
| 651 | 711 | |
| 652 | 712 | WRITE16_HANDLER( atarist_blitter_dst_inc_x_w ) |
| 653 | 713 | { |
| 654 | | blitter.dst_inc_x = data & 0xfffe; |
| 714 | atarist_state *state = space->machine->driver_data; |
| 715 | |
| 716 | state->blitter_dst_inc_x = data & 0xfffe; |
| 655 | 717 | } |
| 656 | 718 | |
| 657 | 719 | WRITE16_HANDLER( atarist_blitter_dst_inc_y_w ) |
| 658 | 720 | { |
| 659 | | blitter.dst_inc_y = data & 0xfffe; |
| 721 | atarist_state *state = space->machine->driver_data; |
| 722 | |
| 723 | state->blitter_dst_inc_y = data & 0xfffe; |
| 660 | 724 | } |
| 661 | 725 | |
| 662 | 726 | WRITE16_HANDLER( atarist_blitter_dst_w ) |
| 663 | 727 | { |
| 728 | atarist_state *state = space->machine->driver_data; |
| 729 | |
| 664 | 730 | switch (offset) |
| 665 | 731 | { |
| 666 | 732 | case 0: |
| 667 | | blitter.dst = (data & 0xff) | (blitter.dst & 0xfffe); |
| 733 | state->blitter_dst = (data & 0xff) | (state->blitter_dst & 0xfffe); |
| 668 | 734 | case 1: |
| 669 | | blitter.dst = (blitter.dst & 0xff0000) | (data & 0xfffe); |
| 735 | state->blitter_dst = (state->blitter_dst & 0xff0000) | (data & 0xfffe); |
| 670 | 736 | } |
| 671 | 737 | } |
| 672 | 738 | |
| 673 | 739 | WRITE16_HANDLER( atarist_blitter_count_x_w ) |
| 674 | 740 | { |
| 675 | | blitter.xcount = data; |
| 741 | atarist_state *state = space->machine->driver_data; |
| 742 | |
| 743 | state->blitter_xcount = data; |
| 676 | 744 | } |
| 677 | 745 | |
| 678 | 746 | WRITE16_HANDLER( atarist_blitter_count_y_w ) |
| 679 | 747 | { |
| 680 | | blitter.ycount = data; |
| 748 | atarist_state *state = space->machine->driver_data; |
| 749 | |
| 750 | state->blitter_ycount = data; |
| 681 | 751 | } |
| 682 | 752 | |
| 683 | 753 | WRITE16_HANDLER( atarist_blitter_op_w ) |
| 684 | 754 | { |
| 755 | atarist_state *state = space->machine->driver_data; |
| 756 | |
| 685 | 757 | if (ACCESSING_BITS_0_7) |
| 686 | 758 | { |
| 687 | | blitter.hop = (data >> 8) & 0x03; |
| 759 | state->blitter_hop = (data >> 8) & 0x03; |
| 688 | 760 | } |
| 689 | 761 | else |
| 690 | 762 | { |
| 691 | | blitter.op = data & 0x0f; |
| 763 | state->blitter_op = data & 0x0f; |
| 692 | 764 | } |
| 693 | 765 | } |
| 694 | 766 | |
| 695 | 767 | WRITE16_HANDLER( atarist_blitter_ctrl_w ) |
| 696 | 768 | { |
| 769 | atarist_state *state = space->machine->driver_data; |
| 770 | |
| 697 | 771 | if (ACCESSING_BITS_0_7) |
| 698 | 772 | { |
| 699 | | blitter.ctrl = (data >> 8) & 0xef; |
| 773 | state->blitter_ctrl = (data >> 8) & 0xef; |
| 700 | 774 | |
| 701 | | if (!(blitter.ctrl & ATARIST_BLITTER_CTRL_BUSY)) |
| 775 | if (!(state->blitter_ctrl & ATARIST_BLITTER_CTRL_BUSY)) |
| 702 | 776 | { |
| 703 | 777 | if ((data >> 8) & ATARIST_BLITTER_CTRL_BUSY) |
| 704 | 778 | { |
| 705 | | int nops = BLITTER_NOPS[blitter.op][blitter.hop]; // each NOP takes 4 cycles |
| 779 | int nops = BLITTER_NOPS[state->blitter_op][state->blitter_hop]; // each NOP takes 4 cycles |
| 706 | 780 | timer_set(space->machine, ATTOTIME_IN_HZ((Y2/4)/(4*nops)), NULL, 0, atarist_blitter_tick); |
| 707 | 781 | } |
| 708 | 782 | } |
| 709 | 783 | } |
| 710 | 784 | else |
| 711 | 785 | { |
| 712 | | blitter.skew = data & 0xcf; |
| 786 | state->blitter_skew = data & 0xcf; |
| 713 | 787 | } |
| 714 | 788 | } |
| 715 | 789 | |
| r3783 | r3784 | |
| 717 | 791 | |
| 718 | 792 | VIDEO_START( atarist ) |
| 719 | 793 | { |
| 720 | | mfp = device_list_find_by_tag(machine->config->devicelist, MC68901, MC68901_TAG); |
| 794 | atarist_state *state = machine->driver_data; |
| 721 | 795 | |
| 722 | | atarist_shifter_timer = timer_alloc(machine, atarist_shifter_tick, NULL); |
| 723 | | atarist_glue_timer = timer_alloc(machine, atarist_glue_tick, NULL); |
| 796 | state->shifter_timer = timer_alloc(machine, atarist_shifter_tick, NULL); |
| 797 | state->glue_timer = timer_alloc(machine, atarist_glue_tick, NULL); |
| 724 | 798 | |
| 725 | | timer_adjust_periodic(atarist_shifter_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/4)); // 125 ns |
| 726 | | timer_adjust_periodic(atarist_glue_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/16)); // 500 ns |
| 799 | timer_adjust_periodic(state->shifter_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/4)); // 125 ns |
| 800 | timer_adjust_periodic(state->glue_timer, video_screen_get_time_until_pos(machine->primary_screen,0,0), 0, ATTOTIME_IN_HZ(Y2/16)); // 500 ns |
| 727 | 801 | |
| 728 | | memset(&shifter, 0, sizeof(shifter)); |
| 802 | /* register for state saving */ |
| 803 | state_save_register_global(machine, state->shifter_base); |
| 804 | state_save_register_global(machine, state->shifter_ofs); |
| 805 | state_save_register_global(machine, state->shifter_sync); |
| 806 | state_save_register_global(machine, state->shifter_mode); |
| 807 | state_save_register_global_array(machine, state->shifter_palette); |
| 808 | state_save_register_global(machine, state->shifter_lineofs); |
| 809 | state_save_register_global(machine, state->shifter_pixelofs); |
| 810 | state_save_register_global_array(machine, state->shifter_rr); |
| 811 | state_save_register_global_array(machine, state->shifter_ir); |
| 812 | state_save_register_global(machine, state->shifter_bitplane); |
| 813 | state_save_register_global(machine, state->shifter_shift); |
| 814 | state_save_register_global(machine, state->shifter_h); |
| 815 | state_save_register_global(machine, state->shifter_v); |
| 816 | state_save_register_global(machine, state->shifter_de); |
| 729 | 817 | |
| 730 | | state_save_register_global(machine, shifter.base); |
| 731 | | state_save_register_global(machine, shifter.ofs); |
| 732 | | state_save_register_global(machine, shifter.sync); |
| 733 | | state_save_register_global(machine, shifter.mode); |
| 734 | | state_save_register_global_array(machine, shifter.palette); |
| 735 | | state_save_register_global(machine, shifter.lineofs); |
| 736 | | state_save_register_global(machine, shifter.pixelofs); |
| 737 | | state_save_register_global_array(machine, shifter.rr); |
| 738 | | state_save_register_global_array(machine, shifter.ir); |
| 739 | | state_save_register_global(machine, shifter.bitplane); |
| 740 | | state_save_register_global(machine, shifter.shift); |
| 741 | | state_save_register_global(machine, shifter.h); |
| 742 | | state_save_register_global(machine, shifter.v); |
| 743 | | state_save_register_global(machine, shifter.de); |
| 818 | state_save_register_global_array(machine, state->blitter_halftone); |
| 819 | state_save_register_global(machine, state->blitter_src_inc_x); |
| 820 | state_save_register_global(machine, state->blitter_src_inc_y); |
| 821 | state_save_register_global(machine, state->blitter_dst_inc_x); |
| 822 | state_save_register_global(machine, state->blitter_dst_inc_y); |
| 823 | state_save_register_global(machine, state->blitter_src); |
| 824 | state_save_register_global(machine, state->blitter_dst); |
| 825 | state_save_register_global(machine, state->blitter_endmask1); |
| 826 | state_save_register_global(machine, state->blitter_endmask2); |
| 827 | state_save_register_global(machine, state->blitter_endmask3); |
| 828 | state_save_register_global(machine, state->blitter_xcount); |
| 829 | state_save_register_global(machine, state->blitter_ycount); |
| 830 | state_save_register_global(machine, state->blitter_xcountl); |
| 831 | state_save_register_global(machine, state->blitter_hop); |
| 832 | state_save_register_global(machine, state->blitter_op); |
| 833 | state_save_register_global(machine, state->blitter_ctrl); |
| 834 | state_save_register_global(machine, state->blitter_skew); |
| 744 | 835 | |
| 745 | | state_save_register_global_array(machine, blitter.halftone); |
| 746 | | state_save_register_global(machine, blitter.src_inc_x); |
| 747 | | state_save_register_global(machine, blitter.src_inc_y); |
| 748 | | state_save_register_global(machine, blitter.dst_inc_x); |
| 749 | | state_save_register_global(machine, blitter.dst_inc_y); |
| 750 | | state_save_register_global(machine, blitter.src); |
| 751 | | state_save_register_global(machine, blitter.dst); |
| 752 | | state_save_register_global(machine, blitter.endmask1); |
| 753 | | state_save_register_global(machine, blitter.endmask2); |
| 754 | | state_save_register_global(machine, blitter.endmask3); |
| 755 | | state_save_register_global(machine, blitter.xcount); |
| 756 | | state_save_register_global(machine, blitter.ycount); |
| 757 | | state_save_register_global(machine, blitter.xcountl); |
| 758 | | state_save_register_global(machine, blitter.hop); |
| 759 | | state_save_register_global(machine, blitter.op); |
| 760 | | state_save_register_global(machine, blitter.ctrl); |
| 761 | | state_save_register_global(machine, blitter.skew); |
| 836 | atarist_set_screen_parameters(machine); |
| 762 | 837 | |
| 763 | | atarist_set_screen_parameters(); |
| 764 | | |
| 765 | 838 | VIDEO_START_CALL(generic_bitmapped); |
| 766 | 839 | } |
src/mess/drivers/atarist.c
| r3783 | r3784 | |
| 20 | 20 | |
| 21 | 21 | TODO: |
| 22 | 22 | |
| 23 | - move static variables to driver state |
| 23 | 24 | - fix floppy interface |
| 24 | 25 | - fix mouse |
| 25 | 26 | - MSA disk image support |
| r3783 | r3784 | |
| 35 | 36 | |
| 36 | 37 | */ |
| 37 | 38 | |
| 39 | static UINT8 mfp_rx, mfp_tx; |
| 40 | static UINT8 ikbd_rx, ikbd_tx; |
| 41 | static UINT8 acia_midi_rx = 1, acia_midi_tx = 1; |
| 42 | |
| 38 | 43 | /* Floppy Disk Controller */ |
| 39 | 44 | |
| 40 | | #define ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST 0x04 |
| 41 | | #define ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO 0x02 |
| 42 | | #define ATARIST_FLOPPY_STATUS_DMA_ERROR 0x01 |
| 43 | | |
| 44 | | #define ATARIST_FLOPPY_MODE_WRITE 0x0100 |
| 45 | | #define ATARIST_FLOPPY_MODE_FDC_ACCESS 0x0080 |
| 46 | | #define ATARIST_FLOPPY_MODE_DMA_DISABLE 0x0040 |
| 47 | | #define ATARIST_FLOPPY_MODE_SECTOR_COUNT 0x0010 |
| 48 | | #define ATARIST_FLOPPY_MODE_HDC 0x0008 |
| 49 | | #define ATARIST_FLOPPY_MODE_ADDRESS_MASK 0x0006 |
| 50 | | |
| 51 | | #define ATARIST_FLOPPY_BYTES_PER_SECTOR 512 |
| 52 | | |
| 53 | | static struct FDC |
| 54 | | { |
| 55 | | UINT32 dmabase; |
| 56 | | UINT16 status, mode; |
| 57 | | UINT8 sectors; |
| 58 | | int dmabytes; |
| 59 | | int irq; |
| 60 | | } fdc; |
| 61 | | |
| 62 | 45 | static void atarist_fdc_dma_transfer(running_machine *machine) |
| 63 | 46 | { |
| 64 | | UINT8 *RAM = memory_region(machine, "main"); |
| 47 | const address_space *program = cputag_get_address_space(machine, "main", ADDRESS_SPACE_PROGRAM); |
| 48 | atarist_state *state = machine->driver_data; |
| 65 | 49 | |
| 66 | | if ((fdc.mode & ATARIST_FLOPPY_MODE_DMA_DISABLE) == 0) |
| 50 | if ((state->fdc_mode & ATARIST_FLOPPY_MODE_DMA_DISABLE) == 0) |
| 67 | 51 | { |
| 68 | | while (fdc.sectors > 0) |
| 52 | while (state->fdc_sectors > 0) |
| 69 | 53 | { |
| 70 | | if (fdc.mode & ATARIST_FLOPPY_MODE_WRITE) |
| 54 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_WRITE) |
| 71 | 55 | { |
| 72 | | wd17xx_data_w(cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0, RAM[fdc.dmabase]); |
| 56 | UINT8 data = memory_read_byte_8be(program, state->fdc_dmabase); |
| 57 | |
| 58 | wd17xx_data_w(program, 0, data); |
| 73 | 59 | } |
| 74 | 60 | else |
| 75 | 61 | { |
| 76 | | RAM[fdc.dmabase] = wd17xx_data_r(cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0); |
| 62 | UINT8 data = wd17xx_data_r(program, 0); |
| 63 | |
| 64 | memory_write_byte_8be(program, state->fdc_dmabase, data); |
| 77 | 65 | } |
| 78 | 66 | |
| 79 | | fdc.dmabase++; |
| 80 | | fdc.dmabytes--; |
| 67 | state->fdc_dmabase++; |
| 68 | state->fdc_dmabytes--; |
| 81 | 69 | |
| 82 | | if (fdc.dmabytes == 0) |
| 70 | if (state->fdc_dmabytes == 0) |
| 83 | 71 | { |
| 84 | | fdc.sectors--; |
| 72 | state->fdc_sectors--; |
| 85 | 73 | |
| 86 | | if (fdc.sectors == 0) |
| 74 | if (state->fdc_sectors == 0) |
| 87 | 75 | { |
| 88 | | fdc.status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO; |
| 76 | state->fdc_status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO; |
| 89 | 77 | } |
| 90 | 78 | else |
| 91 | 79 | { |
| 92 | | fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR; |
| 80 | state->fdc_dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR; |
| 93 | 81 | } |
| 94 | 82 | } |
| 95 | 83 | } |
| r3783 | r3784 | |
| 98 | 86 | |
| 99 | 87 | static void atarist_fdc_callback(running_machine *machine, wd17xx_state_t event, void *param) |
| 100 | 88 | { |
| 89 | atarist_state *state = machine->driver_data; |
| 90 | |
| 101 | 91 | switch (event) |
| 102 | 92 | { |
| 103 | 93 | case WD17XX_IRQ_SET: |
| 104 | | fdc.irq = 1; |
| 94 | state->fdc_irq = 1; |
| 105 | 95 | break; |
| 106 | 96 | |
| 107 | 97 | case WD17XX_IRQ_CLR: |
| 108 | | fdc.irq = 0; |
| 98 | state->fdc_irq = 0; |
| 109 | 99 | break; |
| 110 | 100 | |
| 111 | 101 | case WD17XX_DRQ_SET: |
| 112 | | fdc.status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; |
| 102 | state->fdc_status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; |
| 113 | 103 | atarist_fdc_dma_transfer(machine); |
| 114 | 104 | break; |
| 115 | 105 | |
| 116 | 106 | case WD17XX_DRQ_CLR: |
| 117 | | fdc.status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; |
| 107 | state->fdc_status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST; |
| 118 | 108 | break; |
| 119 | 109 | } |
| 120 | 110 | } |
| 121 | 111 | |
| 122 | 112 | static READ16_HANDLER( atarist_fdc_data_r ) |
| 123 | 113 | { |
| 124 | | if (fdc.mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 114 | atarist_state *state = space->machine->driver_data; |
| 115 | |
| 116 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 125 | 117 | { |
| 126 | | return fdc.sectors; |
| 118 | return state->fdc_sectors; |
| 127 | 119 | } |
| 128 | 120 | else |
| 129 | 121 | { |
| 130 | | if (fdc.mode & ATARIST_FLOPPY_MODE_HDC) |
| 122 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_HDC) |
| 131 | 123 | { |
| 132 | 124 | // HDC not implemented |
| 133 | | fdc.status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR; |
| 125 | state->fdc_status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR; |
| 134 | 126 | |
| 135 | 127 | return 0; |
| 136 | 128 | } |
| 137 | 129 | else |
| 138 | 130 | { |
| 139 | | return wd17xx_r(space, (fdc.mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1); |
| 131 | return wd17xx_r(space, (state->fdc_mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1); |
| 140 | 132 | } |
| 141 | 133 | } |
| 142 | 134 | } |
| 143 | 135 | |
| 144 | 136 | static WRITE16_HANDLER( atarist_fdc_data_w ) |
| 145 | 137 | { |
| 146 | | if (fdc.mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 138 | atarist_state *state = space->machine->driver_data; |
| 139 | |
| 140 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT) |
| 147 | 141 | { |
| 148 | 142 | if (data == 0) |
| 149 | 143 | { |
| 150 | | fdc.status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO; |
| 144 | state->fdc_status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO; |
| 151 | 145 | } |
| 152 | 146 | else |
| 153 | 147 | { |
| 154 | | fdc.status |= ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO; |
| 148 | state->fdc_status |= ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO; |
| 155 | 149 | } |
| 156 | 150 | |
| 157 | | fdc.sectors = data; |
| 151 | state->fdc_sectors = data; |
| 158 | 152 | } |
| 159 | 153 | else |
| 160 | 154 | { |
| 161 | | if (fdc.mode & ATARIST_FLOPPY_MODE_HDC) |
| 155 | if (state->fdc_mode & ATARIST_FLOPPY_MODE_HDC) |
| 162 | 156 | { |
| 163 | 157 | // HDC not implemented |
| 164 | | fdc.status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR; |
| 158 | state->fdc_status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR; |
| 165 | 159 | } |
| 166 | 160 | else |
| 167 | 161 | { |
| 168 | | wd17xx_w(space, (fdc.mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1, data); |
| 162 | wd17xx_w(space, (state->fdc_mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1, data); |
| 169 | 163 | } |
| 170 | 164 | } |
| 171 | 165 | } |
| 172 | 166 | |
| 173 | 167 | static READ16_HANDLER( atarist_fdc_dma_status_r ) |
| 174 | 168 | { |
| 175 | | return fdc.status; |
| 169 | atarist_state *state = space->machine->driver_data; |
| 170 | |
| 171 | return state->fdc_status; |
| 176 | 172 | } |
| 177 | 173 | |
| 178 | 174 | static WRITE16_HANDLER( atarist_fdc_dma_mode_w ) |
| 179 | 175 | { |
| 180 | | if ((data & ATARIST_FLOPPY_MODE_WRITE) != (fdc.mode & ATARIST_FLOPPY_MODE_WRITE)) |
| 176 | atarist_state *state = space->machine->driver_data; |
| 177 | |
| 178 | if ((data & ATARIST_FLOPPY_MODE_WRITE) != (state->fdc_mode & ATARIST_FLOPPY_MODE_WRITE)) |
| 181 | 179 | { |
| 182 | | fdc.status = 0; |
| 183 | | fdc.sectors = 0; |
| 180 | state->fdc_status = 0; |
| 181 | state->fdc_sectors = 0; |
| 184 | 182 | } |
| 185 | 183 | |
| 186 | | fdc.mode = data; |
| 184 | state->fdc_mode = data; |
| 187 | 185 | } |
| 188 | 186 | |
| 189 | 187 | static READ16_HANDLER( atarist_fdc_dma_base_r ) |
| 190 | 188 | { |
| 189 | atarist_state *state = space->machine->driver_data; |
| 190 | |
| 191 | 191 | switch (offset) |
| 192 | 192 | { |
| 193 | 193 | case 0: |
| 194 | | return (fdc.dmabase >> 16) & 0xff; |
| 194 | return (state->fdc_dmabase >> 16) & 0xff; |
| 195 | 195 | case 1: |
| 196 | | return (fdc.dmabase >> 8) & 0xff; |
| 196 | return (state->fdc_dmabase >> 8) & 0xff; |
| 197 | 197 | case 2: |
| 198 | | return fdc.dmabase & 0xff; |
| 198 | return state->fdc_dmabase & 0xff; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | return 0; |
| r3783 | r3784 | |
| 203 | 203 | |
| 204 | 204 | static WRITE16_HANDLER( atarist_fdc_dma_base_w ) |
| 205 | 205 | { |
| 206 | atarist_state *state = space->machine->driver_data; |
| 207 | |
| 206 | 208 | switch (offset) |
| 207 | 209 | { |
| 208 | 210 | case 0: |
| 209 | | fdc.dmabase = (fdc.dmabase & 0x00ffff) | ((data & 0xff) << 16); |
| 211 | state->fdc_dmabase = (state->fdc_dmabase & 0x00ffff) | ((data & 0xff) << 16); |
| 210 | 212 | break; |
| 211 | 213 | case 1: |
| 212 | | fdc.dmabase = (fdc.dmabase & 0x0000ff) | ((data & 0xff) << 8); |
| 214 | state->fdc_dmabase = (state->fdc_dmabase & 0x0000ff) | ((data & 0xff) << 8); |
| 213 | 215 | break; |
| 214 | 216 | case 2: |
| 215 | | fdc.dmabase = data & 0xff; |
| 217 | state->fdc_dmabase = data & 0xff; |
| 216 | 218 | break; |
| 217 | 219 | } |
| 218 | 220 | |
| 219 | | fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR; |
| 221 | state->fdc_dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR; |
| 220 | 222 | } |
| 221 | 223 | |
| 222 | 224 | /* MMU */ |
| 223 | 225 | |
| 224 | | static int mmu; |
| 225 | | |
| 226 | 226 | static READ16_HANDLER( atarist_mmu_r ) |
| 227 | 227 | { |
| 228 | | return mmu; |
| 228 | atarist_state *state = space->machine->driver_data; |
| 229 | |
| 230 | return state->mmu; |
| 229 | 231 | } |
| 230 | 232 | |
| 231 | 233 | static WRITE16_HANDLER( atarist_mmu_w ) |
| 232 | 234 | { |
| 233 | | mmu = data & 0xff; |
| 235 | atarist_state *state = space->machine->driver_data; |
| 236 | |
| 237 | state->mmu = data & 0xff; |
| 234 | 238 | } |
| 235 | 239 | |
| 236 | 240 | /* IKBD */ |
| 237 | 241 | |
| 238 | | static struct IKBD |
| 239 | | { |
| 240 | | UINT8 keylatch; |
| 241 | | UINT8 mouse_x, mouse_y; |
| 242 | | UINT8 mouse_px, mouse_py, mouse_pc; |
| 243 | | UINT8 rx, tx; |
| 244 | | } ikbd; |
| 245 | | |
| 246 | 242 | static const int IKBD_MOUSE_XYA[3][4] = { { 0, 0, 0, 0 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 } }; |
| 247 | 243 | static const int IKBD_MOUSE_XYB[3][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 1, 1, 0, 0 } }; |
| 248 | 244 | |
| 249 | | enum |
| 250 | | { |
| 251 | | IKBD_MOUSE_PHASE_STATIC = 0, |
| 252 | | IKBD_MOUSE_PHASE_POSITIVE, |
| 253 | | IKBD_MOUSE_PHASE_NEGATIVE |
| 254 | | }; |
| 255 | | |
| 256 | 245 | static READ8_HANDLER( ikbd_port1_r ) |
| 257 | 246 | { |
| 258 | 247 | /* |
| r3783 | r3784 | |
| 270 | 259 | |
| 271 | 260 | */ |
| 272 | 261 | |
| 273 | | return ikbd.keylatch; |
| 262 | atarist_state *state = space->machine->driver_data; |
| 263 | |
| 264 | return state->ikbd_keylatch; |
| 274 | 265 | } |
| 275 | 266 | |
| 276 | 267 | static READ8_HANDLER( ikbd_port2_r ) |
| r3783 | r3784 | |
| 287 | 278 | |
| 288 | 279 | */ |
| 289 | 280 | |
| 290 | | return (ikbd.tx << 3) | (input_port_read_safe(space->machine, "IKBD_JOY1", 0xff) & 0x06); |
| 281 | atarist_state *state = space->machine->driver_data; |
| 282 | |
| 283 | return (ikbd_tx << 3) | (input_port_read_safe(space->machine, "IKBD_JOY1", 0xff) & 0x06); |
| 291 | 284 | } |
| 292 | 285 | |
| 293 | 286 | static WRITE8_HANDLER( ikbd_port2_w ) |
| r3783 | r3784 | |
| 304 | 297 | |
| 305 | 298 | */ |
| 306 | 299 | |
| 307 | | ikbd.rx = (data & 0x10) >> 4; |
| 300 | atarist_state *state = space->machine->driver_data; |
| 301 | |
| 302 | ikbd_rx = (data & 0x10) >> 4; |
| 308 | 303 | } |
| 309 | 304 | |
| 310 | 305 | static WRITE8_HANDLER( ikbd_port3_w ) |
| r3783 | r3784 | |
| 324 | 319 | |
| 325 | 320 | */ |
| 326 | 321 | |
| 322 | atarist_state *state = space->machine->driver_data; |
| 323 | |
| 327 | 324 | set_led_status(1, data & 0x01); |
| 328 | 325 | |
| 329 | | if (~data & 0x02) ikbd.keylatch = input_port_read(space->machine, "P31"); |
| 330 | | if (~data & 0x04) ikbd.keylatch = input_port_read(space->machine, "P32"); |
| 331 | | if (~data & 0x08) ikbd.keylatch = input_port_read(space->machine, "P33"); |
| 332 | | if (~data & 0x10) ikbd.keylatch = input_port_read(space->machine, "P34"); |
| 333 | | if (~data & 0x20) ikbd.keylatch = input_port_read(space->machine, "P35"); |
| 334 | | if (~data & 0x40) ikbd.keylatch = input_port_read(space->machine, "P36"); |
| 335 | | if (~data & 0x80) ikbd.keylatch = input_port_read(space->machine, "P37"); |
| 326 | if (~data & 0x02) state->ikbd_keylatch = input_port_read(space->machine, "P31"); |
| 327 | if (~data & 0x04) state->ikbd_keylatch = input_port_read(space->machine, "P32"); |
| 328 | if (~data & 0x08) state->ikbd_keylatch = input_port_read(space->machine, "P33"); |
| 329 | if (~data & 0x10) state->ikbd_keylatch = input_port_read(space->machine, "P34"); |
| 330 | if (~data & 0x20) state->ikbd_keylatch = input_port_read(space->machine, "P35"); |
| 331 | if (~data & 0x40) state->ikbd_keylatch = input_port_read(space->machine, "P36"); |
| 332 | if (~data & 0x80) state->ikbd_keylatch = input_port_read(space->machine, "P37"); |
| 336 | 333 | } |
| 337 | 334 | |
| 338 | 335 | static READ8_HANDLER( ikbd_port4_r ) |
| r3783 | r3784 | |
| 352 | 349 | |
| 353 | 350 | */ |
| 354 | 351 | |
| 352 | atarist_state *state = space->machine->driver_data; |
| 353 | |
| 355 | 354 | if (input_port_read(space->machine, "config") & 0x01) |
| 356 | 355 | { |
| 357 | 356 | /* |
| r3783 | r3784 | |
| 367 | 366 | UINT8 x = input_port_read_safe(space->machine, "IKBD_MOUSEX", 0x00); |
| 368 | 367 | UINT8 y = input_port_read_safe(space->machine, "IKBD_MOUSEY", 0x00); |
| 369 | 368 | |
| 370 | | if (x == ikbd.mouse_x) |
| 369 | if (x == state->ikbd_mouse_x) |
| 371 | 370 | { |
| 372 | | ikbd.mouse_px = IKBD_MOUSE_PHASE_STATIC; |
| 371 | state->ikbd_mouse_px = IKBD_MOUSE_PHASE_STATIC; |
| 373 | 372 | } |
| 374 | | else if (x > ikbd.mouse_x) |
| 373 | else if (x > state->ikbd_mouse_x) |
| 375 | 374 | { |
| 376 | | ikbd.mouse_px = IKBD_MOUSE_PHASE_POSITIVE; |
| 375 | state->ikbd_mouse_px = IKBD_MOUSE_PHASE_POSITIVE; |
| 377 | 376 | } |
| 378 | | else if (x < ikbd.mouse_x) |
| 377 | else if (x < state->ikbd_mouse_x) |
| 379 | 378 | { |
| 380 | | ikbd.mouse_px = IKBD_MOUSE_PHASE_NEGATIVE; |
| 379 | state->ikbd_mouse_px = IKBD_MOUSE_PHASE_NEGATIVE; |
| 381 | 380 | } |
| 382 | 381 | |
| 383 | | if (y == ikbd.mouse_y) |
| 382 | if (y == state->ikbd_mouse_y) |
| 384 | 383 | { |
| 385 | | ikbd.mouse_py = IKBD_MOUSE_PHASE_STATIC; |
| 384 | state->ikbd_mouse_py = IKBD_MOUSE_PHASE_STATIC; |
| 386 | 385 | } |
| 387 | | else if (y > ikbd.mouse_y) |
| 386 | else if (y > state->ikbd_mouse_y) |
| 388 | 387 | { |
| 389 | | ikbd.mouse_py = IKBD_MOUSE_PHASE_POSITIVE; |
| 388 | state->ikbd_mouse_py = IKBD_MOUSE_PHASE_POSITIVE; |
| 390 | 389 | } |
| 391 | | else if (y < ikbd.mouse_y) |
| 390 | else if (y < state->ikbd_mouse_y) |
| 392 | 391 | { |
| 393 | | ikbd.mouse_py = IKBD_MOUSE_PHASE_NEGATIVE; |
| 392 | state->ikbd_mouse_py = IKBD_MOUSE_PHASE_NEGATIVE; |
| 394 | 393 | } |
| 395 | 394 | |
| 396 | | data |= IKBD_MOUSE_XYB[ikbd.mouse_px][ikbd.mouse_pc]; // XB |
| 397 | | data |= IKBD_MOUSE_XYA[ikbd.mouse_px][ikbd.mouse_pc] << 1; // XA |
| 398 | | data |= IKBD_MOUSE_XYA[ikbd.mouse_py][ikbd.mouse_pc] << 2; // YA |
| 399 | | data |= IKBD_MOUSE_XYB[ikbd.mouse_py][ikbd.mouse_pc] << 3; // YB |
| 395 | data |= IKBD_MOUSE_XYB[state->ikbd_mouse_px][state->ikbd_mouse_pc]; // XB |
| 396 | data |= IKBD_MOUSE_XYA[state->ikbd_mouse_px][state->ikbd_mouse_pc] << 1; // XA |
| 397 | data |= IKBD_MOUSE_XYA[state->ikbd_mouse_py][state->ikbd_mouse_pc] << 2; // YA |
| 398 | data |= IKBD_MOUSE_XYB[state->ikbd_mouse_py][state->ikbd_mouse_pc] << 3; // YB |
| 400 | 399 | |
| 401 | | ikbd.mouse_pc++; |
| 400 | state->ikbd_mouse_pc++; |
| 402 | 401 | |
| 403 | | if (ikbd.mouse_pc == 4) |
| 402 | if (state->ikbd_mouse_pc == 4) |
| 404 | 403 | { |
| 405 | | ikbd.mouse_pc = 0; |
| 404 | state->ikbd_mouse_pc = 0; |
| 406 | 405 | } |
| 407 | 406 | |
| 408 | | ikbd.mouse_x = x; |
| 409 | | ikbd.mouse_y = y; |
| 407 | state->ikbd_mouse_x = x; |
| 408 | state->ikbd_mouse_y = y; |
| 410 | 409 | |
| 411 | 410 | return data; |
| 412 | 411 | } |
| r3783 | r3784 | |
| 433 | 432 | |
| 434 | 433 | */ |
| 435 | 434 | |
| 436 | | if (~data & 0x01) ikbd.keylatch = input_port_read(space->machine, "P40"); |
| 437 | | if (~data & 0x02) ikbd.keylatch = input_port_read(space->machine, "P41"); |
| 438 | | if (~data & 0x04) ikbd.keylatch = input_port_read(space->machine, "P42"); |
| 439 | | if (~data & 0x08) ikbd.keylatch = input_port_read(space->machine, "P43"); |
| 440 | | if (~data & 0x10) ikbd.keylatch = input_port_read(space->machine, "P44"); |
| 441 | | if (~data & 0x20) ikbd.keylatch = input_port_read(space->machine, "P45"); |
| 442 | | if (~data & 0x40) ikbd.keylatch = input_port_read(space->machine, "P46"); |
| 443 | | if (~data & 0x80) ikbd.keylatch = input_port_read(space->machine, "P47"); |
| 435 | atarist_state *state = space->machine->driver_data; |
| 436 | |
| 437 | if (~data & 0x01) state->ikbd_keylatch = input_port_read(space->machine, "P40"); |
| 438 | if (~data & 0x02) state->ikbd_keylatch = input_port_read(space->machine, "P41"); |
| 439 | if (~data & 0x04) state->ikbd_keylatch = input_port_read(space->machine, "P42"); |
| 440 | if (~data & 0x08) state->ikbd_keylatch = input_port_read(space->machine, "P43"); |
| 441 | if (~data & 0x10) state->ikbd_keylatch = input_port_read(space->machine, "P44"); |
| 442 | if (~data & 0x20) state->ikbd_keylatch = input_port_read(space->machine, "P45"); |
| 443 | if (~data & 0x40) state->ikbd_keylatch = input_port_read(space->machine, "P46"); |
| 444 | if (~data & 0x80) state->ikbd_keylatch = input_port_read(space->machine, "P47"); |
| 444 | 445 | } |
| 445 | 446 | |
| 446 | 447 | /* DMA Sound */ |
| 447 | 448 | |
| 448 | | static struct DMASOUND |
| 449 | | { |
| 450 | | UINT32 base, end, cntr; |
| 451 | | UINT32 baselatch, endlatch; |
| 452 | | UINT16 ctrl, mode; |
| 453 | | UINT8 fifo[8]; |
| 454 | | UINT8 samples; |
| 455 | | int active; |
| 456 | | } dmasound; |
| 457 | | |
| 458 | 449 | static const int DMASOUND_RATE[] = { Y2/640/8, Y2/640/4, Y2/640/2, Y2/640 }; |
| 459 | 450 | |
| 460 | | static emu_timer *dmasound_timer; |
| 461 | | |
| 462 | 451 | static void atariste_dmasound_set_state(running_machine *machine, int level) |
| 463 | 452 | { |
| 464 | | const device_config *mc68901 = device_list_find_by_tag(machine->config->devicelist, MC68901, MC68901_TAG); |
| 453 | atarist_state *state = machine->driver_data; |
| 465 | 454 | |
| 466 | | dmasound.active = level; |
| 467 | | mc68901_tai_w(mc68901, level); |
| 455 | state->dmasnd_active = level; |
| 456 | mc68901_tai_w(state->mc68901, level); |
| 468 | 457 | |
| 469 | 458 | if (level == 0) |
| 470 | 459 | { |
| 471 | | dmasound.baselatch = dmasound.base; |
| 472 | | dmasound.endlatch = dmasound.end; |
| 460 | state->dmasnd_baselatch = state->dmasnd_base; |
| 461 | state->dmasnd_endlatch = state->dmasnd_end; |
| 473 | 462 | } |
| 474 | 463 | else |
| 475 | 464 | { |
| 476 | | dmasound.cntr = dmasound.baselatch; |
| 465 | state->dmasnd_cntr = state->dmasnd_baselatch; |
| 477 | 466 | } |
| 478 | 467 | } |
| 479 | 468 | |
| 480 | 469 | static TIMER_CALLBACK( atariste_dmasound_tick ) |
| 481 | 470 | { |
| 482 | | if (dmasound.samples == 0) |
| 471 | atarist_state *state = machine->driver_data; |
| 472 | |
| 473 | if (state->dmasnd_samples == 0) |
| 483 | 474 | { |
| 484 | 475 | int i; |
| 485 | 476 | UINT8 *RAM = memory_region(machine, "main"); |
| 486 | 477 | |
| 487 | 478 | for (i = 0; i < 8; i++) |
| 488 | 479 | { |
| 489 | | dmasound.fifo[i] = RAM[dmasound.cntr]; |
| 490 | | dmasound.cntr++; |
| 491 | | dmasound.samples++; |
| 480 | state->dmasnd_fifo[i] = RAM[state->dmasnd_cntr]; |
| 481 | state->dmasnd_cntr++; |
| 482 | state->dmasnd_samples++; |
| 492 | 483 | |
| 493 | | if (dmasound.cntr == dmasound.endlatch) |
| 484 | if (state->dmasnd_cntr == state->dmasnd_endlatch) |
| 494 | 485 | { |
| 495 | 486 | atariste_dmasound_set_state(machine, 0); |
| 496 | 487 | break; |
| r3783 | r3784 | |
| 498 | 489 | } |
| 499 | 490 | } |
| 500 | 491 | |
| 501 | | if (dmasound.ctrl & 0x80) |
| 492 | if (state->dmasnd_ctrl & 0x80) |
| 502 | 493 | { |
| 503 | | // logerror("DMA sound left %i\n", dmasound.fifo[7 - dmasound.samples]); |
| 504 | | dmasound.samples--; |
| 494 | // logerror("DMA sound left %i\n", state->dmasnd_fifo[7 - state->dmasnd_samples]); |
| 495 | state->dmasnd_samples--; |
| 505 | 496 | |
| 506 | | // logerror("DMA sound right %i\n", dmasound.fifo[7 - dmasound.samples]); |
| 507 | | dmasound.samples--; |
| 497 | // logerror("DMA sound right %i\n", state->dmasnd_fifo[7 - state->dmasnd_samples]); |
| 498 | state->dmasnd_samples--; |
| 508 | 499 | } |
| 509 | 500 | else |
| 510 | 501 | { |
| 511 | | // logerror("DMA sound mono %i\n", dmasound.fifo[7 - dmasound.samples]); |
| 512 | | dmasound.samples--; |
| 502 | // logerror("DMA sound mono %i\n", state->dmasnd_fifo[7 - state->dmasnd_samples]); |
| 503 | state->dmasnd_samples--; |
| 513 | 504 | } |
| 514 | 505 | |
| 515 | | if ((dmasound.samples == 0) && (dmasound.active == 0)) |
| 506 | if ((state->dmasnd_samples == 0) && (state->dmasnd_active == 0)) |
| 516 | 507 | { |
| 517 | | if ((dmasound.ctrl & 0x03) == 0x03) |
| 508 | if ((state->dmasnd_ctrl & 0x03) == 0x03) |
| 518 | 509 | { |
| 519 | 510 | atariste_dmasound_set_state(machine, 1); |
| 520 | 511 | } |
| 521 | 512 | else |
| 522 | 513 | { |
| 523 | | timer_enable(dmasound_timer, 0); |
| 514 | timer_enable(state->dmasound_timer, 0); |
| 524 | 515 | } |
| 525 | 516 | } |
| 526 | 517 | } |
| 527 | 518 | |
| 528 | 519 | static READ16_HANDLER( atariste_sound_dma_control_r ) |
| 529 | 520 | { |
| 530 | | return dmasound.ctrl; |
| 521 | atarist_state *state = space->machine->driver_data; |
| 522 | |
| 523 | return state->dmasnd_ctrl; |
| 531 | 524 | } |
| 532 | 525 | |
| 533 | 526 | static READ16_HANDLER( atariste_sound_dma_base_r ) |
| 534 | 527 | { |
| 528 | atarist_state *state = space->machine->driver_data; |
| 529 | |
| 535 | 530 | switch (offset) |
| 536 | 531 | { |
| 537 | 532 | case 0x00: |
| 538 | | return (dmasound.base >> 16) & 0x3f; |
| 533 | return (state->dmasnd_base >> 16) & 0x3f; |
| 539 | 534 | case 0x01: |
| 540 | | return (dmasound.base >> 8) & 0xff; |
| 535 | return (state->dmasnd_base >> 8) & 0xff; |
| 541 | 536 | case 0x02: |
| 542 | | return dmasound.base & 0xff; |
| 537 | return state->dmasnd_base & 0xff; |
| 543 | 538 | } |
| 544 | 539 | |
| 545 | 540 | return 0; |
| r3783 | r3784 | |
| 547 | 542 | |
| 548 | 543 | static READ16_HANDLER( atariste_sound_dma_counter_r ) |
| 549 | 544 | { |
| 545 | atarist_state *state = space->machine->driver_data; |
| 546 | |
| 550 | 547 | switch (offset) |
| 551 | 548 | { |
| 552 | 549 | case 0x00: |
| 553 | | return (dmasound.cntr >> 16) & 0x3f; |
| 550 | return (state->dmasnd_cntr >> 16) & 0x3f; |
| 554 | 551 | case 0x01: |
| 555 | | return (dmasound.cntr >> 8) & 0xff; |
| 552 | return (state->dmasnd_cntr >> 8) & 0xff; |
| 556 | 553 | case 0x02: |
| 557 | | return dmasound.cntr & 0xff; |
| 554 | return state->dmasnd_cntr & 0xff; |
| 558 | 555 | } |
| 559 | 556 | |
| 560 | 557 | return 0; |
| r3783 | r3784 | |
| 562 | 559 | |
| 563 | 560 | static READ16_HANDLER( atariste_sound_dma_end_r ) |
| 564 | 561 | { |
| 562 | atarist_state *state = space->machine->driver_data; |
| 563 | |
| 565 | 564 | switch (offset) |
| 566 | 565 | { |
| 567 | 566 | case 0x00: |
| 568 | | return (dmasound.end >> 16) & 0x3f; |
| 567 | return (state->dmasnd_end >> 16) & 0x3f; |
| 569 | 568 | case 0x01: |
| 570 | | return (dmasound.end >> 8) & 0xff; |
| 569 | return (state->dmasnd_end >> 8) & 0xff; |
| 571 | 570 | case 0x02: |
| 572 | | return dmasound.end & 0xff; |
| 571 | return state->dmasnd_end & 0xff; |
| 573 | 572 | } |
| 574 | 573 | |
| 575 | 574 | return 0; |
| r3783 | r3784 | |
| 577 | 576 | |
| 578 | 577 | static READ16_HANDLER( atariste_sound_mode_r ) |
| 579 | 578 | { |
| 580 | | return dmasound.mode; |
| 579 | atarist_state *state = space->machine->driver_data; |
| 580 | |
| 581 | return state->dmasnd_mode; |
| 581 | 582 | } |
| 582 | 583 | |
| 583 | 584 | static WRITE16_HANDLER( atariste_sound_dma_control_w ) |
| 584 | 585 | { |
| 585 | | dmasound.ctrl = data & 0x03; |
| 586 | atarist_state *state = space->machine->driver_data; |
| 586 | 587 | |
| 587 | | if (dmasound.ctrl & 0x01) |
| 588 | state->dmasnd_ctrl = data & 0x03; |
| 589 | |
| 590 | if (state->dmasnd_ctrl & 0x01) |
| 588 | 591 | { |
| 589 | | if (!dmasound.active) |
| 592 | if (!state->dmasnd_active) |
| 590 | 593 | { |
| 591 | 594 | atariste_dmasound_set_state(space->machine, 1); |
| 592 | | timer_adjust_periodic(dmasound_timer, attotime_zero, 0, ATTOTIME_IN_HZ(DMASOUND_RATE[dmasound.mode & 0x03])); |
| 595 | timer_adjust_periodic(state->dmasound_timer, attotime_zero, 0, ATTOTIME_IN_HZ(DMASOUND_RATE[state->dmasnd_mode & 0x03])); |
| 593 | 596 | } |
| 594 | 597 | } |
| 595 | 598 | else |
| 596 | 599 | { |
| 597 | 600 | atariste_dmasound_set_state(space->machine, 0); |
| 598 | | timer_enable(dmasound_timer, 0); |
| 601 | timer_enable(state->dmasound_timer, 0); |
| 599 | 602 | } |
| 600 | 603 | } |
| 601 | 604 | |
| 602 | 605 | static WRITE16_HANDLER( atariste_sound_dma_base_w ) |
| 603 | 606 | { |
| 607 | atarist_state *state = space->machine->driver_data; |
| 608 | |
| 604 | 609 | switch (offset) |
| 605 | 610 | { |
| 606 | 611 | case 0x00: |
| 607 | | dmasound.base = (data << 16) & 0x3f0000; |
| 612 | state->dmasnd_base = (data << 16) & 0x3f0000; |
| 608 | 613 | break; |
| 609 | 614 | case 0x01: |
| 610 | | dmasound.base = (dmasound.base & 0x3f00fe) | (data & 0xff) << 8; |
| 615 | state->dmasnd_base = (state->dmasnd_base & 0x3f00fe) | (data & 0xff) << 8; |
| 611 | 616 | break; |
| 612 | 617 | case 0x02: |
| 613 | | dmasound.base = (dmasound.base & 0x3fff00) | (data & 0xfe); |
| 618 | state->dmasnd_base = (state->dmasnd_base & 0x3fff00) | (data & 0xfe); |
| 614 | 619 | break; |
| 615 | 620 | } |
| 616 | 621 | |
| 617 | | if (!dmasound.active) |
| 622 | if (!state->dmasnd_active) |
| 618 | 623 | { |
| 619 | | dmasound.baselatch = dmasound.base; |
| 624 | state->dmasnd_baselatch = state->dmasnd_base; |
| 620 | 625 | } |
| 621 | 626 | } |
| 622 | 627 | |
| 623 | 628 | static WRITE16_HANDLER( atariste_sound_dma_end_w ) |
| 624 | 629 | { |
| 630 | atarist_state *state = space->machine->driver_data; |
| 631 | |
| 625 | 632 | switch (offset) |
| 626 | 633 | { |
| 627 | 634 | case 0x00: |
| 628 | | dmasound.end = (data << 16) & 0x3f0000; |
| 635 | state->dmasnd_end = (data << 16) & 0x3f0000; |
| 629 | 636 | break; |
| 630 | 637 | case 0x01: |
| 631 | | dmasound.end = (dmasound.end & 0x3f00fe) | (data & 0xff) << 8; |
| 638 | state->dmasnd_end = (state->dmasnd_end & 0x3f00fe) | (data & 0xff) << 8; |
| 632 | 639 | break; |
| 633 | 640 | case 0x02: |
| 634 | | dmasound.end = (dmasound.end & 0x3fff00) | (data & 0xfe); |
| 641 | state->dmasnd_end = (state->dmasnd_end & 0x3fff00) | (data & 0xfe); |
| 635 | 642 | break; |
| 636 | 643 | } |
| 637 | 644 | |
| 638 | | if (!dmasound.active) |
| 645 | if (!state->dmasnd_active) |
| 639 | 646 | { |
| 640 | | dmasound.endlatch = dmasound.end; |
| 647 | state->dmasnd_endlatch = state->dmasnd_end; |
| 641 | 648 | } |
| 642 | 649 | } |
| 643 | 650 | |
| 644 | 651 | static WRITE16_HANDLER( atariste_sound_mode_w ) |
| 645 | 652 | { |
| 646 | | dmasound.mode = data & 0x8f; |
| 653 | atarist_state *state = space->machine->driver_data; |
| 654 | |
| 655 | state->dmasnd_mode = data & 0x8f; |
| 647 | 656 | } |
| 648 | 657 | |
| 649 | 658 | /* Microwire */ |
| 650 | 659 | |
| 651 | | static struct MICROWIRE |
| 652 | | { |
| 653 | | UINT16 data, mask; |
| 654 | | int shift; |
| 655 | | } mwire; |
| 656 | | |
| 657 | | static emu_timer *microwire_timer; |
| 658 | | |
| 659 | 660 | static void atariste_microwire_shift(running_machine *machine) |
| 660 | 661 | { |
| 661 | | const device_config *lmc1992 = device_list_find_by_tag(machine->config->devicelist, LMC1992, LMC1992_TAG); |
| 662 | atarist_state *state = machine->driver_data; |
| 662 | 663 | |
| 663 | | if (BIT(mwire.mask, 15)) |
| 664 | if (BIT(state->mw_mask, 15)) |
| 664 | 665 | { |
| 665 | | lmc1992_data_w(lmc1992, BIT(mwire.data, 15)); |
| 666 | | lmc1992_clock_w(lmc1992, 1); |
| 667 | | lmc1992_clock_w(lmc1992, 0); |
| 666 | lmc1992_data_w(state->lmc1992, BIT(state->mw_data, 15)); |
| 667 | lmc1992_clock_w(state->lmc1992, 1); |
| 668 | lmc1992_clock_w(state->lmc1992, 0); |
| 668 | 669 | } |
| 669 | 670 | |
| 670 | 671 | // rotate mask and data left |
| 671 | 672 | |
| 672 | | mwire.mask = (mwire.mask << 1) | BIT(mwire.mask, 15); |
| 673 | | mwire.data = (mwire.data << 1) | BIT(mwire.data, 15); |
| 674 | | mwire.shift++; |
| 673 | state->mw_mask = (state->mw_mask << 1) | BIT(state->mw_mask, 15); |
| 674 | state->mw_data = (state->mw_data << 1) | BIT(state->mw_data, 15); |
| 675 | state->mw_shift++; |
| 675 | 676 | } |
| 676 | 677 | |
| 677 | 678 | static TIMER_CALLBACK( atariste_microwire_tick ) |
| 678 | 679 | { |
| 679 | | const device_config *lmc1992 = device_list_find_by_tag(machine->config->devicelist, LMC1992, LMC1992_TAG); |
| 680 | atarist_state *state = machine->driver_data; |
| 680 | 681 | |
| 681 | | switch (mwire.shift) |
| 682 | switch (state->mw_shift) |
| 682 | 683 | { |
| 683 | 684 | case 0: |
| 684 | | lmc1992_enable_w(lmc1992, 0); |
| 685 | lmc1992_enable_w(state->lmc1992, 0); |
| 685 | 686 | atariste_microwire_shift(machine); |
| 686 | 687 | break; |
| 687 | 688 | |
| r3783 | r3784 | |
| 691 | 692 | |
| 692 | 693 | case 15: |
| 693 | 694 | atariste_microwire_shift(machine); |
| 694 | | lmc1992_enable_w(lmc1992, 1); |
| 695 | | mwire.shift = 0; |
| 696 | | timer_enable(microwire_timer, 0); |
| 695 | lmc1992_enable_w(state->lmc1992, 1); |
| 696 | state->mw_shift = 0; |
| 697 | timer_enable(state->microwire_timer, 0); |
| 697 | 698 | break; |
| 698 | 699 | } |
| 699 | 700 | } |
| 700 | 701 | |
| 701 | 702 | static READ16_HANDLER( atariste_microwire_data_r ) |
| 702 | 703 | { |
| 703 | | return mwire.data; |
| 704 | atarist_state *state = space->machine->driver_data; |
| 705 | |
| 706 | return state->mw_data; |
| 704 | 707 | } |
| 705 | 708 | |
| 706 | 709 | static WRITE16_HANDLER( atariste_microwire_data_w ) |
| 707 | 710 | { |
| 708 | | if (!timer_enabled(microwire_timer)) |
| 711 | atarist_state *state = space->machine->driver_data; |
| 712 | |
| 713 | if (!timer_enabled(state->microwire_timer)) |
| 709 | 714 | { |
| 710 | | mwire.data = data; |
| 711 | | timer_adjust_periodic(microwire_timer, attotime_zero, 0, ATTOTIME_IN_USEC(2)); |
| 715 | state->mw_data = data; |
| 716 | timer_adjust_periodic(state->microwire_timer, attotime_zero, 0, ATTOTIME_IN_USEC(2)); |
| 712 | 717 | } |
| 713 | 718 | } |
| 714 | 719 | |
| 715 | 720 | static READ16_HANDLER( atariste_microwire_mask_r ) |
| 716 | 721 | { |
| 717 | | return mwire.mask; |
| 722 | atarist_state *state = space->machine->driver_data; |
| 723 | |
| 724 | return state->mw_mask; |
| 718 | 725 | } |
| 719 | 726 | |
| 720 | 727 | static WRITE16_HANDLER( atariste_microwire_mask_w ) |
| 721 | 728 | { |
| 722 | | if (!timer_enabled(microwire_timer)) |
| 729 | atarist_state *state = space->machine->driver_data; |
| 730 | |
| 731 | if (!timer_enabled(state->microwire_timer)) |
| 723 | 732 | { |
| 724 | | mwire.mask = data; |
| 733 | state->mw_mask = data; |
| 725 | 734 | } |
| 726 | 735 | } |
| 727 | 736 | |
| 728 | 737 | /* Mega STe Cache */ |
| 729 | 738 | |
| 730 | | static UINT16 megaste_cache; |
| 731 | | |
| 732 | 739 | static READ16_HANDLER( megaste_cache_r ) |
| 733 | 740 | { |
| 734 | | return megaste_cache; |
| 741 | atarist_state *state = space->machine->driver_data; |
| 742 | |
| 743 | return state->megaste_cache; |
| 735 | 744 | } |
| 736 | 745 | |
| 737 | 746 | static WRITE16_HANDLER( megaste_cache_w ) |
| 738 | 747 | { |
| 739 | | megaste_cache = data; |
| 740 | | cpu_set_clock(space->machine->cpu[0], (data & 0x01) ? Y2/2 : Y2/4); |
| 748 | atarist_state *state = space->machine->driver_data; |
| 749 | |
| 750 | state->megaste_cache = data; |
| 751 | |
| 752 | cpu_set_clock(space->machine->cpu[0], BIT(data, 0) ? Y2/2 : Y2/4); |
| 741 | 753 | } |
| 742 | 754 | |
| 743 | 755 | /* ST Book */ |
| r3783 | r3784 | |
| 1266 | 1278 | |
| 1267 | 1279 | static WRITE8_HANDLER( ym2149_port_a_w ) |
| 1268 | 1280 | { |
| 1269 | | wd17xx_set_side((data & 0x01) ? 0 : 1); |
| 1281 | wd17xx_set_side(BIT(data, 0) ? 0 : 1); |
| 1270 | 1282 | |
| 1271 | | if (!(data & 0x02)) |
| 1283 | if (!BIT(data, 1)) |
| 1272 | 1284 | { |
| 1273 | 1285 | wd17xx_set_drive(0); |
| 1274 | 1286 | } |
| 1275 | 1287 | |
| 1276 | | if (!(data & 0x04)) |
| 1288 | if (!BIT(data, 2)) |
| 1277 | 1289 | { |
| 1278 | 1290 | wd17xx_set_drive(1); |
| 1279 | 1291 | } |
| r3783 | r3784 | |
| 1281 | 1293 | // 0x08 = RTS |
| 1282 | 1294 | // 0x10 = DTR |
| 1283 | 1295 | |
| 1284 | | centronics_write_handshake(0, (data & 0x20) ? 0 : CENTRONICS_STROBE, CENTRONICS_STROBE); |
| 1296 | centronics_write_handshake(0, BIT(data, 5) ? 0 : CENTRONICS_STROBE, CENTRONICS_STROBE); |
| 1285 | 1297 | |
| 1286 | 1298 | // 0x40 = General Purpose Output |
| 1287 | 1299 | // 0x80 = Reserved |
| r3783 | r3784 | |
| 1304 | 1316 | |
| 1305 | 1317 | /* Machine Drivers */ |
| 1306 | 1318 | |
| 1307 | | static int acia_irq; |
| 1308 | | static UINT8 acia_midi_rx = 1, acia_midi_tx = 1; |
| 1309 | | |
| 1310 | 1319 | static void acia_interrupt(const device_config *device, int state) |
| 1311 | 1320 | { |
| 1312 | | acia_irq = state; |
| 1321 | atarist_state *driver_state = device->machine->driver_data; |
| 1322 | |
| 1323 | driver_state->acia_irq = state; |
| 1313 | 1324 | } |
| 1314 | 1325 | |
| 1315 | 1326 | static const acia6850_interface acia_ikbd_intf = |
| 1316 | 1327 | { |
| 1317 | 1328 | Y2/64, |
| 1318 | 1329 | Y2/64, |
| 1319 | | &ikbd.rx, |
| 1320 | | &ikbd.tx, |
| 1330 | &ikbd_rx, |
| 1331 | &ikbd_tx, |
| 1321 | 1332 | NULL, |
| 1322 | 1333 | NULL, |
| 1323 | 1334 | NULL, |
| r3783 | r3784 | |
| 1353 | 1364 | |
| 1354 | 1365 | */ |
| 1355 | 1366 | |
| 1367 | atarist_state *state = device->machine->driver_data; |
| 1368 | |
| 1356 | 1369 | UINT8 data = (centronics_read_handshake(0) & CENTRONICS_NOT_BUSY) >> 7; |
| 1357 | 1370 | |
| 1358 | 1371 | mc68901_tai_w(device, data & 0x01); |
| 1359 | 1372 | |
| 1360 | | data |= (acia_irq << 4); |
| 1361 | | data |= (fdc.irq << 5); |
| 1373 | data |= (state->acia_irq << 4); |
| 1374 | data |= (state->fdc_irq << 5); |
| 1362 | 1375 | data |= (input_port_read(device->machine, "config") & 0x80); |
| 1363 | 1376 | |
| 1364 | 1377 | return data; |
| r3783 | r3784 | |
| 1366 | 1379 | |
| 1367 | 1380 | static IRQ_CALLBACK( atarist_int_ack ) |
| 1368 | 1381 | { |
| 1382 | atarist_state *state = device->machine->driver_data; |
| 1383 | |
| 1369 | 1384 | const device_config *mc68901 = device_list_find_by_tag(device->machine->config->devicelist, MC68901, MC68901_TAG); |
| 1370 | 1385 | |
| 1371 | 1386 | if (irqline == M68K_IRQ_6) |
| r3783 | r3784 | |
| 1381 | 1396 | cpu_set_input_line(device->machine->cpu[0], M68K_IRQ_6, level); |
| 1382 | 1397 | } |
| 1383 | 1398 | |
| 1384 | | static UINT8 mfp_rx, mfp_tx; |
| 1385 | | |
| 1386 | 1399 | static MC68901_INTERFACE( mfp_intf ) |
| 1387 | 1400 | { |
| 1388 | 1401 | Y2/8, |
| r3783 | r3784 | |
| 1407 | 1420 | |
| 1408 | 1421 | static void atarist_configure_memory(running_machine *machine) |
| 1409 | 1422 | { |
| 1423 | const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 1410 | 1424 | UINT8 *RAM = memory_region(machine, "main"); |
| 1411 | 1425 | |
| 1412 | 1426 | switch (mess_ram_size) |
| 1413 | 1427 | { |
| 1414 | 1428 | case 256 * 1024: |
| 1415 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x03ffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1416 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x040000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1429 | memory_install_readwrite16_handler(program, 0x000008, 0x03ffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1430 | memory_install_readwrite16_handler(program, 0x040000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1417 | 1431 | break; |
| 1418 | 1432 | case 512 * 1024: |
| 1419 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x07ffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1420 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x080000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1433 | memory_install_readwrite16_handler(program, 0x000008, 0x07ffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1434 | memory_install_readwrite16_handler(program, 0x080000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1421 | 1435 | break; |
| 1422 | 1436 | case 1024 * 1024: |
| 1423 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x0fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1424 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1437 | memory_install_readwrite16_handler(program, 0x000008, 0x0fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1438 | memory_install_readwrite16_handler(program, 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1425 | 1439 | break; |
| 1426 | 1440 | case 2048 * 1024: |
| 1427 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1428 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1441 | memory_install_readwrite16_handler(program, 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1442 | memory_install_readwrite16_handler(program, 0x200000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1429 | 1443 | break; |
| 1430 | 1444 | case 4096 * 1024: |
| 1431 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1432 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2); |
| 1445 | memory_install_readwrite16_handler(program, 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1446 | memory_install_readwrite16_handler(program, 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2); |
| 1433 | 1447 | break; |
| 1434 | 1448 | } |
| 1435 | 1449 | |
| r3783 | r3784 | |
| 1439 | 1453 | memory_configure_bank(machine, 2, 0, 1, RAM + 0x200000, 0); |
| 1440 | 1454 | memory_set_bank(machine, 2, 0); |
| 1441 | 1455 | |
| 1442 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1456 | memory_install_readwrite16_handler(program, 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1443 | 1457 | |
| 1444 | 1458 | memory_configure_bank(machine, 3, 0, 1, RAM + 0xfa0000, 0); |
| 1445 | 1459 | memory_set_bank(machine, 3, 0); |
| r3783 | r3784 | |
| 1447 | 1461 | |
| 1448 | 1462 | static void atarist_state_save(running_machine *machine) |
| 1449 | 1463 | { |
| 1450 | | memset(&fdc, 0, sizeof(fdc)); |
| 1464 | atarist_state *state = machine->driver_data; |
| 1451 | 1465 | |
| 1452 | | fdc.status |= ATARIST_FLOPPY_STATUS_DMA_ERROR; |
| 1466 | state->fdc_status |= ATARIST_FLOPPY_STATUS_DMA_ERROR; |
| 1453 | 1467 | |
| 1454 | | memset(&ikbd, 0, sizeof(ikbd)); |
| 1455 | | |
| 1456 | | state_save_register_global(machine, mmu); |
| 1457 | | state_save_register_global(machine, fdc.dmabase); |
| 1458 | | state_save_register_global(machine, fdc.status); |
| 1459 | | state_save_register_global(machine, fdc.mode); |
| 1460 | | state_save_register_global(machine, fdc.sectors); |
| 1461 | | state_save_register_global(machine, fdc.dmabytes); |
| 1462 | | state_save_register_global(machine, fdc.irq); |
| 1463 | | state_save_register_global(machine, ikbd.keylatch); |
| 1464 | | state_save_register_global(machine, ikbd.mouse_x); |
| 1465 | | state_save_register_global(machine, ikbd.mouse_y); |
| 1466 | | state_save_register_global(machine, ikbd.mouse_px); |
| 1467 | | state_save_register_global(machine, ikbd.mouse_py); |
| 1468 | | state_save_register_global(machine, ikbd.mouse_pc); |
| 1469 | | state_save_register_global(machine, ikbd.rx); |
| 1470 | | state_save_register_global(machine, ikbd.tx); |
| 1471 | | state_save_register_global(machine, acia_irq); |
| 1468 | state_save_register_global(machine, state->mmu); |
| 1469 | state_save_register_global(machine, state->fdc_dmabase); |
| 1470 | state_save_register_global(machine, state->fdc_status); |
| 1471 | state_save_register_global(machine, state->fdc_mode); |
| 1472 | state_save_register_global(machine, state->fdc_sectors); |
| 1473 | state_save_register_global(machine, state->fdc_dmabytes); |
| 1474 | state_save_register_global(machine, state->fdc_irq); |
| 1475 | state_save_register_global(machine, state->ikbd_keylatch); |
| 1476 | state_save_register_global(machine, state->ikbd_mouse_x); |
| 1477 | state_save_register_global(machine, state->ikbd_mouse_y); |
| 1478 | state_save_register_global(machine, state->ikbd_mouse_px); |
| 1479 | state_save_register_global(machine, state->ikbd_mouse_py); |
| 1480 | state_save_register_global(machine, state->ikbd_mouse_pc); |
| 1481 | state_save_register_global(machine, ikbd_rx); |
| 1482 | state_save_register_global(machine, ikbd_tx); |
| 1483 | state_save_register_global(machine, state->acia_irq); |
| 1472 | 1484 | state_save_register_global(machine, acia_midi_rx); |
| 1473 | 1485 | state_save_register_global(machine, acia_midi_tx); |
| 1474 | 1486 | state_save_register_global(machine, mfp_rx); |
| r3783 | r3784 | |
| 1477 | 1489 | |
| 1478 | 1490 | static MACHINE_START( atarist ) |
| 1479 | 1491 | { |
| 1492 | atarist_state *state = machine->driver_data; |
| 1493 | |
| 1494 | /* configure RAM banking */ |
| 1480 | 1495 | atarist_configure_memory(machine); |
| 1481 | | atarist_state_save(machine); |
| 1482 | 1496 | |
| 1497 | /* configure devices */ |
| 1483 | 1498 | centronics_config(0, atarist_centronics_config); |
| 1484 | 1499 | wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL); |
| 1485 | 1500 | |
| 1501 | /* set CPU interrupt callback */ |
| 1486 | 1502 | cpu_set_irq_callback(machine->cpu[0], atarist_int_ack); |
| 1503 | |
| 1504 | /* find devices */ |
| 1505 | state->mc68901 = devtag_get_device(machine, MC68901, MC68901_TAG); |
| 1506 | |
| 1507 | /* register for state saving */ |
| 1508 | atarist_state_save(machine); |
| 1487 | 1509 | } |
| 1488 | 1510 | |
| 1489 | 1511 | static const struct rp5c15_interface rtc_intf = |
| r3783 | r3784 | |
| 1494 | 1516 | static MACHINE_START( megast ) |
| 1495 | 1517 | { |
| 1496 | 1518 | MACHINE_START_CALL(atarist); |
| 1519 | |
| 1497 | 1520 | rp5c15_init(machine, &rtc_intf); |
| 1498 | 1521 | } |
| 1499 | 1522 | |
| r3783 | r3784 | |
| 1514 | 1537 | |
| 1515 | 1538 | */ |
| 1516 | 1539 | |
| 1540 | atarist_state *state = device->machine->driver_data; |
| 1541 | |
| 1517 | 1542 | UINT8 data = (centronics_read_handshake(0) & CENTRONICS_NOT_BUSY) >> 7; |
| 1518 | 1543 | |
| 1519 | | data |= (acia_irq << 4); |
| 1520 | | data |= (fdc.irq << 5); |
| 1521 | | data |= (input_port_read(device->machine, "config") & 0x80) ^ (dmasound.active << 7); |
| 1544 | data |= (state->acia_irq << 4); |
| 1545 | data |= (state->fdc_irq << 5); |
| 1546 | data |= (input_port_read(device->machine, "config") & 0x80) ^ (state->dmasnd_active << 7); |
| 1522 | 1547 | |
| 1523 | 1548 | return data; |
| 1524 | 1549 | } |
| r3783 | r3784 | |
| 1539 | 1564 | |
| 1540 | 1565 | static void atariste_state_save(running_machine *machine) |
| 1541 | 1566 | { |
| 1567 | atarist_state *state = machine->driver_data; |
| 1568 | |
| 1542 | 1569 | atarist_state_save(machine); |
| 1543 | 1570 | |
| 1544 | | memset(&mwire, 0, sizeof(mwire)); |
| 1545 | | memset(&dmasound, 0, sizeof(dmasound)); |
| 1546 | | |
| 1547 | | state_save_register_global(machine, dmasound.base); |
| 1548 | | state_save_register_global(machine, dmasound.end); |
| 1549 | | state_save_register_global(machine, dmasound.cntr); |
| 1550 | | state_save_register_global(machine, dmasound.baselatch); |
| 1551 | | state_save_register_global(machine, dmasound.endlatch); |
| 1552 | | state_save_register_global(machine, dmasound.ctrl); |
| 1553 | | state_save_register_global(machine, dmasound.mode); |
| 1554 | | state_save_register_global_array(machine, dmasound.fifo); |
| 1555 | | state_save_register_global(machine, dmasound.samples); |
| 1556 | | state_save_register_global(machine, dmasound.active); |
| 1557 | | |
| 1558 | | state_save_register_global(machine, mwire.data); |
| 1559 | | state_save_register_global(machine, mwire.mask); |
| 1560 | | state_save_register_global(machine, mwire.shift); |
| 1571 | state_save_register_global(machine, state->dmasnd_base); |
| 1572 | state_save_register_global(machine, state->dmasnd_end); |
| 1573 | state_save_register_global(machine, state->dmasnd_cntr); |
| 1574 | state_save_register_global(machine, state->dmasnd_baselatch); |
| 1575 | state_save_register_global(machine, state->dmasnd_endlatch); |
| 1576 | state_save_register_global(machine, state->dmasnd_ctrl); |
| 1577 | state_save_register_global(machine, state->dmasnd_mode); |
| 1578 | state_save_register_global_array(machine, state->dmasnd_fifo); |
| 1579 | state_save_register_global(machine, state->dmasnd_samples); |
| 1580 | state_save_register_global(machine, state->dmasnd_active); |
| 1581 | state_save_register_global(machine, state->mw_data); |
| 1582 | state_save_register_global(machine, state->mw_mask); |
| 1583 | state_save_register_global(machine, state->mw_shift); |
| 1561 | 1584 | } |
| 1562 | 1585 | |
| 1563 | 1586 | static MACHINE_START( atariste ) |
| 1564 | 1587 | { |
| 1588 | atarist_state *state = machine->driver_data; |
| 1589 | |
| 1590 | /* configure RAM banking */ |
| 1565 | 1591 | atarist_configure_memory(machine); |
| 1566 | | atariste_state_save(machine); |
| 1567 | 1592 | |
| 1593 | /* configure devices */ |
| 1568 | 1594 | centronics_config(0, atarist_centronics_config); |
| 1569 | 1595 | wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL); |
| 1570 | 1596 | |
| 1597 | /* set CPU interrupt callback */ |
| 1571 | 1598 | cpu_set_irq_callback(machine->cpu[0], atarist_int_ack); |
| 1572 | 1599 | |
| 1573 | | dmasound_timer = timer_alloc(machine, atariste_dmasound_tick, NULL); |
| 1574 | | microwire_timer = timer_alloc(machine, atariste_microwire_tick, NULL); |
| 1600 | /* allocate timers */ |
| 1601 | state->dmasound_timer = timer_alloc(machine, atariste_dmasound_tick, NULL); |
| 1602 | state->microwire_timer = timer_alloc(machine, atariste_microwire_tick, NULL); |
| 1603 | |
| 1604 | /* find devices */ |
| 1605 | state->lmc1992 = devtag_get_device(machine, LMC1992, LMC1992_TAG); |
| 1606 | |
| 1607 | /* register for state saving */ |
| 1608 | atariste_state_save(machine); |
| 1575 | 1609 | } |
| 1576 | 1610 | |
| 1577 | 1611 | static MACHINE_START( megaste ) |
| 1578 | 1612 | { |
| 1579 | | machine_start_atariste(machine); |
| 1580 | | state_save_register_global(machine, megaste_cache); |
| 1613 | atarist_state *state = machine->driver_data; |
| 1614 | |
| 1615 | MACHINE_START_CALL(atariste); |
| 1616 | |
| 1581 | 1617 | rp5c15_init(machine, &rtc_intf); |
| 1618 | |
| 1619 | state_save_register_global(machine, state->megaste_cache); |
| 1582 | 1620 | } |
| 1583 | 1621 | |
| 1584 | 1622 | static void stbook_configure_memory(running_machine *machine) |
| 1585 | 1623 | { |
| 1624 | const address_space *program = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 1586 | 1625 | UINT8 *RAM = memory_region(machine, "main"); |
| 1587 | 1626 | |
| 1588 | 1627 | switch (mess_ram_size) |
| 1589 | 1628 | { |
| 1590 | 1629 | case 1024 * 1024: |
| 1591 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x07ffff, 0, 0x080000, SMH_BANK1, SMH_BANK1); |
| 1592 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1630 | memory_install_readwrite16_handler(program, 0x000008, 0x07ffff, 0, 0x080000, SMH_BANK1, SMH_BANK1); |
| 1631 | memory_install_readwrite16_handler(program, 0x100000, 0x3fffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1593 | 1632 | break; |
| 1594 | 1633 | case 4096 * 1024: |
| 1595 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1596 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2); |
| 1634 | memory_install_readwrite16_handler(program, 0x000008, 0x1fffff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 1635 | memory_install_readwrite16_handler(program, 0x200000, 0x3fffff, 0, 0, SMH_BANK2, SMH_BANK2); |
| 1597 | 1636 | break; |
| 1598 | 1637 | } |
| 1599 | 1638 | |
| r3783 | r3784 | |
| 1603 | 1642 | memory_configure_bank(machine, 2, 0, 1, RAM + 0x200000, 0); |
| 1604 | 1643 | memory_set_bank(machine, 2, 0); |
| 1605 | 1644 | |
| 1606 | | memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1645 | memory_install_readwrite16_handler(program, 0xfa0000, 0xfbffff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 1607 | 1646 | |
| 1608 | 1647 | memory_configure_bank(machine, 3, 0, 1, RAM + 0xfa0000, 0); |
| 1609 | 1648 | memory_set_bank(machine, 3, 0); |
| r3783 | r3784 | |
| 1673 | 1712 | |
| 1674 | 1713 | */ |
| 1675 | 1714 | |
| 1715 | atarist_state *state = device->machine->driver_data; |
| 1716 | |
| 1676 | 1717 | UINT8 data = (centronics_read_handshake(0) & CENTRONICS_NOT_BUSY) >> 7; |
| 1677 | 1718 | |
| 1678 | | data |= (acia_irq << 4); |
| 1679 | | data |= (fdc.irq << 5); |
| 1719 | data |= (state->acia_irq << 4); |
| 1720 | data |= (state->fdc_irq << 5); |
| 1680 | 1721 | |
| 1681 | 1722 | return data; |
| 1682 | 1723 | } |
| r3783 | r3784 | |
| 1697 | 1738 | |
| 1698 | 1739 | static MACHINE_START( stbook ) |
| 1699 | 1740 | { |
| 1741 | atarist_state *state = machine->driver_data; |
| 1742 | |
| 1743 | /* configure RAM banking */ |
| 1700 | 1744 | stbook_configure_memory(machine); |
| 1701 | | atariste_state_save(machine); |
| 1702 | 1745 | |
| 1703 | | state_save_register_global(machine, krxd); |
| 1704 | | state_save_register_global(machine, ktxd); |
| 1705 | | |
| 1746 | /* configure devices */ |
| 1706 | 1747 | centronics_config(0, atarist_centronics_config); |
| 1707 | 1748 | wd17xx_init(machine, WD_TYPE_1772, atarist_fdc_callback, NULL); |
| 1708 | 1749 | rp5c15_init(machine, &rtc_intf); |
| 1709 | 1750 | |
| 1751 | /* set CPU interrupt callback */ |
| 1710 | 1752 | cpu_set_irq_callback(machine->cpu[0], atarist_int_ack); |
| 1753 | |
| 1754 | /* find devices */ |
| 1755 | state->mc68901 = devtag_get_device(machine, MC68901, MC68901_TAG); |
| 1756 | |
| 1757 | /* register for state saving */ |
| 1758 | atariste_state_save(machine); |
| 1759 | state_save_register_global(machine, krxd); |
| 1760 | state_save_register_global(machine, ktxd); |
| 1711 | 1761 | } |
| 1712 | 1762 | |
| 1713 | 1763 | static MACHINE_DRIVER_START( atarist ) |
| r3783 | r3784 | |
| 2038 | 2088 | switch(state) |
| 2039 | 2089 | { |
| 2040 | 2090 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2041 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 2091 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 2042 | 2092 | |
| 2043 | 2093 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2044 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(atarist_floppy); break; |
| 2094 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(atarist_floppy); break; |
| 2045 | 2095 | |
| 2046 | 2096 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2047 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "st"); break; |
| 2097 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "st"); break; |
| 2048 | 2098 | |
| 2049 | 2099 | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 2050 | 2100 | } |
| r3783 | r3784 | |
| 2076 | 2126 | { |
| 2077 | 2127 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2078 | 2128 | case MESS_DEVINFO_INT_TYPE: info->i = IO_SERIAL; break; |
| 2079 | | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 2129 | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 2080 | 2130 | |
| 2081 | 2131 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2082 | | case MESS_DEVINFO_PTR_START: info->start = DEVICE_START_NAME(serial_device); break; |
| 2132 | case MESS_DEVINFO_PTR_START: info->start = DEVICE_START_NAME(serial_device); break; |
| 2083 | 2133 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(atarist_serial); break; |
| 2084 | 2134 | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(serial_device); break; |
| 2085 | 2135 | |
| r3783 | r3784 | |
| 2095 | 2145 | { |
| 2096 | 2146 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2097 | 2147 | case MESS_DEVINFO_INT_TYPE: info->i = IO_SERIAL; break; |
| 2098 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 2148 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 2099 | 2149 | |
| 2100 | 2150 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2101 | | case MESS_DEVINFO_PTR_START: info->start = DEVICE_START_NAME(serial_device); break; |
| 2151 | case MESS_DEVINFO_PTR_START: info->start = DEVICE_START_NAME(serial_device); break; |
| 2102 | 2152 | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(atarist_serial); break; |
| 2103 | 2153 | case MESS_DEVINFO_PTR_UNLOAD: info->unload = DEVICE_IMAGE_UNLOAD_NAME(serial_device); break; |
| 2104 | 2154 | |
| r3783 | r3784 | |
| 2117 | 2167 | { |
| 2118 | 2168 | if (image_fread(image, ptr, filesize) == filesize) |
| 2119 | 2169 | { |
| 2120 | | memory_install_readwrite16_handler(cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_BANK3, SMH_BANK3); |
| 2170 | memory_install_readwrite16_handler(cputag_get_address_space(image->machine, "main", ADDRESS_SPACE_PROGRAM), 0xfa0000, 0xfbffff, 0, 0, SMH_BANK3, SMH_BANK3); |
| 2121 | 2171 | |
| 2122 | 2172 | return INIT_PASS; |
| 2123 | 2173 | } |