src/mess/drivers/fm7.c
| r4876 | r4877 | |
| 47 | 47 | static UINT8 irq_flags; // active IRQ flags |
| 48 | 48 | static UINT8 irq_mask; // IRQ mask |
| 49 | 49 | emu_timer* fm7_timer; // main timer, triggered every 2.0345ms? |
| 50 | emu_timer* fm7_subtimer; // sub-CPU timer, every 1 second? |
| 50 | 51 | static UINT8 sub_busy; |
| 51 | 52 | static UINT8 basic_rom_en; |
| 52 | 53 | static UINT8 attn_irq; |
| r4876 | r4877 | |
| 158 | 159 | |
| 159 | 160 | READ8_HANDLER( fm7_subintf_r ) |
| 160 | 161 | { |
| 161 | | return sub_busy & 0x80; |
| 162 | UINT8 ret = 0; |
| 163 | |
| 164 | if(sub_busy != 0) |
| 165 | ret |= 0x80; |
| 166 | |
| 167 | return ret; |
| 162 | 168 | } |
| 163 | 169 | |
| 164 | 170 | WRITE8_HANDLER( fm7_subintf_w ) |
| r4876 | r4877 | |
| 251 | 257 | crt_enable = 0; |
| 252 | 258 | } |
| 253 | 259 | |
| 260 | READ8_HANDLER( fm7_fdc_r ) |
| 261 | { |
| 262 | switch(offset) |
| 263 | { |
| 264 | case 0: |
| 265 | return 0x80; // drive not ready |
| 266 | default: |
| 267 | logerror("FDC: read from 0x%04x\n",offset+0xfd18); |
| 268 | } |
| 269 | return 0x00; |
| 270 | } |
| 271 | |
| 272 | WRITE8_HANDLER( fm7_fdc_w ) |
| 273 | { |
| 274 | switch(offset) |
| 275 | { |
| 276 | default: |
| 277 | logerror("FDC: wrote %02x to 0x%04x\n",data,offset+0xfd18); |
| 278 | } |
| 279 | } |
| 280 | |
| 254 | 281 | static TIMER_CALLBACK( fm7_timer_irq ) |
| 255 | 282 | { |
| 256 | | if(~irq_mask & IRQ_FLAG_TIMER) |
| 283 | if(irq_mask & IRQ_FLAG_TIMER) |
| 257 | 284 | { |
| 258 | 285 | irq_flags |= IRQ_FLAG_TIMER; |
| 259 | 286 | cputag_set_input_line(machine,"maincpu",M6809_IRQ_LINE,ASSERT_LINE); |
| 260 | 287 | } |
| 261 | 288 | } |
| 262 | 289 | |
| 290 | static TIMER_CALLBACK( fm7_subtimer_irq ) |
| 291 | { |
| 292 | cputag_set_input_line(machine,"sub",INPUT_LINE_NMI,PULSE_LINE); |
| 293 | } |
| 294 | |
| 263 | 295 | static IRQ_CALLBACK(fm7_irq_ack) |
| 264 | 296 | { |
| 265 | 297 | cputag_set_input_line(device->machine,"maincpu",irqline,CLEAR_LINE); |
| r4876 | r4877 | |
| 294 | 326 | AM_RANGE(0xfd0d,0xfd0d) AM_DEVWRITE("psg",ay8910_address_w) |
| 295 | 327 | AM_RANGE(0xfd0e,0xfd0e) AM_DEVREADWRITE("psg",ay8910_r,ay8910_data_w) |
| 296 | 328 | AM_RANGE(0xfd0f,0xfd0f) AM_READWRITE(fm7_rom_en_r,fm7_rom_en_w) |
| 329 | AM_RANGE(0xfd18,0xfd1f) AM_READWRITE(fm7_fdc_r,fm7_fdc_w) |
| 297 | 330 | // Boot ROM |
| 298 | 331 | AM_RANGE(0xfe00,0xffef) AM_ROM AM_REGION("basic",0x0000) |
| 299 | 332 | AM_RANGE(0xfff0,0xffff) AM_READWRITE(vector_r,vector_w) |
| r4876 | r4877 | |
| 341 | 374 | shared_ram = auto_alloc_array(machine,UINT8,0x80); |
| 342 | 375 | fm7_video_ram = auto_alloc_array(machine,UINT8,0xc000); |
| 343 | 376 | fm7_timer = timer_alloc(machine,fm7_timer_irq,NULL); |
| 377 | fm7_subtimer = timer_alloc(machine,fm7_subtimer_irq,NULL); |
| 344 | 378 | cpu_set_irq_callback(cputag_get_cpu(machine,"maincpu"),fm7_irq_ack); |
| 345 | 379 | cpu_set_irq_callback(cputag_get_cpu(machine,"sub"),fm7_sub_irq_ack); |
| 346 | 380 | } |
| r4876 | r4877 | |
| 361 | 395 | { |
| 362 | 396 | UINT8* RAM = memory_region(machine,"maincpu"); |
| 363 | 397 | |
| 364 | | timer_adjust_periodic(fm7_timer,attotime_zero,0,ATTOTIME_IN_USEC(2034)); |
| 398 | timer_adjust_periodic(fm7_timer,ATTOTIME_IN_USEC(2034),0,ATTOTIME_IN_USEC(2034)); |
| 399 | timer_adjust_periodic(fm7_subtimer,ATTOTIME_IN_MSEC(20),0,ATTOTIME_IN_MSEC(20)); |
| 365 | 400 | irq_mask = 0xff; |
| 366 | 401 | irq_flags = 0x00; |
| 367 | 402 | attn_irq = 0; |