trunk/src/mame/machine/megacd.c
| r18275 | r18276 | |
| 6 | 6 | |
| 7 | 7 | // the main MD emulation needs to know the state of these because it appears in the MD regs / affect DMA operations |
| 8 | 8 | int sega_cd_connected = 0x00; |
| 9 | | int segacd_wordram_mapped = 0; |
| 10 | 9 | |
| 11 | 10 | |
| 11 | // not in the state because the IRQ_CALLBACK needs it, and that can't be a member function? |
| 12 | UINT16 a12000_halt_reset_reg = 0x0000; |
| 12 | 13 | |
| 14 | /* Callback when the genesis enters interrupt code */ |
| 15 | // needs to be a member |
| 16 | static IRQ_CALLBACK(segacd_sub_int_callback) |
| 17 | { |
| 18 | if (irqline==2) |
| 19 | { |
| 20 | // clear this bit |
| 21 | a12000_halt_reset_reg &= ~0x0100; |
| 22 | device->machine().device(":segacd:segacd_68k")->execute().set_input_line(2, CLEAR_LINE); |
| 23 | } |
| 13 | 24 | |
| 25 | return (0x60+irqline*4)/4; // vector address |
| 26 | } |
| 14 | 27 | |
| 28 | |
| 29 | |
| 30 | |
| 15 | 31 | const device_type SEGA_SEGACD_US = &device_creator<sega_segacd_us_device>; |
| 16 | 32 | const device_type SEGA_SEGACD_JAPAN = &device_creator<sega_segacd_japan_device>; |
| 17 | 33 | const device_type SEGA_SEGACD_EUROPE = &device_creator<sega_segacd_europe_device>; |
| r18275 | r18276 | |
| 41 | 57 | } |
| 42 | 58 | |
| 43 | 59 | |
| 44 | | static MACHINE_CONFIG_FRAGMENT( segacd_fragment ) |
| 45 | 60 | |
| 46 | | MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */ |
| 47 | | MCFG_CPU_PROGRAM_MAP(segacd_map) |
| 61 | TIMER_DEVICE_CALLBACK_MEMBER( sega_segacd_device::segacd_irq3_timer_callback ) |
| 62 | { |
| 63 | CHECK_SCD_LV3_INTERRUPT |
| 64 | segacd_irq3_timer->adjust(SEGACD_IRQ3_TIMER_SPEED); |
| 65 | } |
| 48 | 66 | |
| 49 | | MCFG_DEVICE_ADD("cdc", LC89510, 0) // cd controller |
| 67 | TIMER_DEVICE_CALLBACK_MEMBER( sega_segacd_device::scd_dma_timer_callback ) |
| 68 | { |
| 69 | // todo: accurate timing of this! |
| 50 | 70 | |
| 51 | | MCFG_TIMER_ADD_NONE("sw_timer") //stopwatch timer |
| 71 | #define RATE 256 |
| 72 | CDC_Do_DMA(machine(), RATE); |
| 52 | 73 | |
| 53 | | MCFG_DEFAULT_LAYOUT( layout_megacd ) |
| 74 | // timed reset of flags |
| 75 | scd_mode_dmna_ret_flags |= 0x0021; |
| 54 | 76 | |
| 55 | | MCFG_SOUND_ADD( "cdda", CDDA, 0 ) |
| 56 | | MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 ) // TODO: accurate volume balance |
| 57 | | MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 ) |
| 77 | scd_dma_timer->adjust(attotime::from_hz(megadriv_framerate) / megadrive_total_scanlines); |
| 58 | 78 | |
| 59 | | MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164! |
| 60 | | MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 ) |
| 61 | | MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 ) |
| 79 | } |
| 62 | 80 | |
| 63 | | MCFG_TIMER_ADD("scd_dma_timer", scd_dma_timer_callback) |
| 64 | | |
| 65 | | MCFG_NVRAM_HANDLER_CLEAR() |
| 66 | | MCFG_NVRAM_ADD_0FILL("backupram") |
| 67 | | |
| 68 | | MCFG_QUANTUM_PERFECT_CPU("segacd_68k") // perfect sync to the fastest cpu |
| 69 | | MACHINE_CONFIG_END |
| 70 | | |
| 71 | | |
| 72 | | |
| 73 | | machine_config_constructor sega_segacd_device::device_mconfig_additions() const |
| 81 | TIMER_DEVICE_CALLBACK_MEMBER( sega_segacd_device::segacd_access_timer_callback ) |
| 74 | 82 | { |
| 75 | | return MACHINE_CONFIG_NAME( segacd_fragment ); |
| 83 | CheckCommand(machine()); |
| 76 | 84 | } |
| 77 | 85 | |
| 86 | TIMER_DEVICE_CALLBACK_MEMBER( sega_segacd_device::segacd_gfx_conversion_timer_callback ) |
| 87 | { |
| 88 | //printf("segacd_gfx_conversion_timer_callback\n"); |
| 78 | 89 | |
| 79 | | /* Sega CD stuff */ |
| 80 | | cpu_device *_segacd_68k_cpu; |
| 90 | CHECK_SCD_LV1_INTERRUPT |
| 81 | 91 | |
| 82 | | UINT16 segacd_irq_mask; |
| 83 | | static UINT16 *segacd_backupram; |
| 84 | | static timer_device *stopwatch_timer; |
| 85 | | static UINT8 segacd_font_color; |
| 86 | | static UINT16* segacd_font_bits; |
| 87 | | static UINT16 scd_rammode; |
| 88 | | static UINT32 scd_mode_dmna_ret_flags ; |
| 92 | segacd_conversion_active = 0; |
| 89 | 93 | |
| 90 | | static emu_timer *segacd_gfx_conversion_timer; |
| 91 | | //static emu_timer *segacd_dmna_ret_timer; |
| 92 | | static emu_timer *segacd_irq3_timer; |
| 93 | | static emu_timer *segacd_hock_timer; |
| 94 | | static UINT8 hock_cmd; |
| 95 | | static TIMER_CALLBACK( segacd_irq3_timer_callback ); |
| 96 | | timer_device* scd_dma_timer; |
| 94 | // this ends up as 0 after processing (soniccd bonus stage) |
| 95 | segacd_imagebuffer_vdot_size = 0; |
| 96 | } |
| 97 | 97 | |
| 98 | | static void segacd_mark_tiles_dirty(running_machine& machine, int offset); |
| 99 | 98 | |
| 100 | 99 | |
| 101 | | /************************************************************************************************* |
| 102 | | Sega CD related |
| 103 | | *************************************************************************************************/ |
| 104 | 100 | |
| 105 | | // The perfect syncs should make this unnecessary: forcing syncs on reads is a flawed design pattern anyway, |
| 106 | | // because the sync will only happen AFTER the read, by which time it's too late. |
| 107 | | #define SEGACD_FORCE_SYNCS 0 |
| 101 | ADDRESS_MAP_START( segacd_map, AS_PROGRAM, 16, sega_segacd_device ) |
| 102 | AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_SHARE("segacd_program") |
| 108 | 103 | |
| 109 | | static UINT8 segacd_ram_writeprotect_bits; |
| 110 | | //int segacd_ram_mode; |
| 111 | | //static int segacd_ram_mode_old; |
| 104 | AM_RANGE(0x080000, 0x0bffff) AM_READWRITE(segacd_sub_dataram_part1_r, segacd_sub_dataram_part1_w) AM_SHARE("dataram") |
| 105 | AM_RANGE(0x0c0000, 0x0dffff) AM_READWRITE(segacd_sub_dataram_part2_r, segacd_sub_dataram_part2_w) //AM_SHARE("dataram2") |
| 112 | 106 | |
| 113 | | //static int segacd_maincpu_has_ram_access = 0; |
| 114 | | static int segacd_4meg_prgbank = 0; // which bank the MainCPU can see of the SubCPU PrgRAM |
| 115 | | static int segacd_memory_priority_mode = 0; |
| 116 | | static int segacd_stampsize; |
| 117 | | //int segacd_dmna = 0; |
| 118 | | //int segacd_ret = 0; |
| 107 | AM_RANGE(0xfe0000, 0xfe3fff) AM_READWRITE(segacd_backupram_r,segacd_backupram_w) AM_SHARE("backupram") // backup RAM, odd bytes only! |
| 119 | 108 | |
| 120 | | #define READ_MAIN (0x0200) |
| 121 | | #define READ_SUB (0x0300) |
| 122 | | #define DMA_PCM (0x0400) |
| 123 | | #define DMA_PRG (0x0500) |
| 124 | | #define DMA_WRAM (0x0700) |
| 109 | AM_RANGE(0xff0000, 0xff001f) AM_DEVWRITE8_LEGACY("rfsnd", rf5c68_w, 0x00ff) // PCM, RF5C164 |
| 110 | AM_RANGE(0xff0020, 0xff003f) AM_DEVREAD8_LEGACY("rfsnd", rf5c68_r, 0x00ff) |
| 111 | AM_RANGE(0xff2000, 0xff3fff) AM_DEVREADWRITE8_LEGACY("rfsnd", rf5c68_mem_r, rf5c68_mem_w,0x00ff) // PCM, RF5C164 |
| 125 | 112 | |
| 126 | | #define REG_W_SBOUT (0x0) |
| 127 | | #define REG_W_IFCTRL (0x1) |
| 128 | | #define REG_W_DBCL (0x2) |
| 129 | | #define REG_W_DBCH (0x3) |
| 130 | | #define REG_W_DACL (0x4) |
| 131 | | #define REG_W_DACH (0x5) |
| 132 | | #define REG_W_DTTRG (0x6) |
| 133 | | #define REG_W_DTACK (0x7) |
| 134 | | #define REG_W_WAL (0x8) |
| 135 | | #define REG_W_WAH (0x9) |
| 136 | | #define REG_W_CTRL0 (0xA) |
| 137 | | #define REG_W_CTRL1 (0xB) |
| 138 | | #define REG_W_PTL (0xC) |
| 139 | | #define REG_W_PTH (0xD) |
| 140 | | #define REG_W_CTRL2 (0xE) |
| 141 | | #define REG_W_RESET (0xF) |
| 142 | 113 | |
| 143 | | #define REG_R_COMIN (0x0) |
| 144 | | #define REG_R_IFSTAT (0x1) |
| 145 | | #define REG_R_DBCL (0x2) |
| 146 | | #define REG_R_DBCH (0x3) |
| 147 | | #define REG_R_HEAD0 (0x4) |
| 148 | | #define REG_R_HEAD1 (0x5) |
| 149 | | #define REG_R_HEAD2 (0x6) |
| 150 | | #define REG_R_HEAD3 (0x7) |
| 151 | | #define REG_R_PTL (0x8) |
| 152 | | #define REG_R_PTH (0x9) |
| 153 | | #define REG_R_WAL (0xa) |
| 154 | | #define REG_R_WAH (0xb) |
| 155 | | #define REG_R_STAT0 (0xc) |
| 156 | | #define REG_R_STAT1 (0xd) |
| 157 | | #define REG_R_STAT2 (0xe) |
| 158 | | #define REG_R_STAT3 (0xf) |
| 114 | AM_RANGE(0xff8000 ,0xff8001) AM_READWRITE(segacd_sub_led_ready_r, segacd_sub_led_ready_w) |
| 115 | AM_RANGE(0xff8002 ,0xff8003) AM_READWRITE(segacd_sub_memory_mode_r, segacd_sub_memory_mode_w) |
| 159 | 116 | |
| 160 | | #define CMD_STATUS (0x0) |
| 161 | | #define CMD_STOPALL (0x1) |
| 162 | | #define CMD_GETTOC (0x2) |
| 163 | | #define CMD_READ (0x3) |
| 164 | | #define CMD_SEEK (0x4) |
| 165 | | // (0x5) |
| 166 | | #define CMD_STOP (0x6) |
| 167 | | #define CMD_RESUME (0x7) |
| 168 | | #define CMD_FF (0x8) |
| 169 | | #define CMD_RW (0x9) |
| 170 | | #define CMD_INIT (0xa) |
| 171 | | // (0xb) |
| 172 | | #define CMD_CLOSE (0xc) |
| 173 | | #define CMD_OPEN (0xd) |
| 174 | | // (0xe) |
| 175 | | // (0xf) |
| 117 | AM_RANGE(0xff8004 ,0xff8005) AM_READWRITE(segacd_cdc_mode_address_r, segacd_cdc_mode_address_w) |
| 118 | AM_RANGE(0xff8006 ,0xff8007) AM_READWRITE(segacd_cdc_data_r, segacd_cdc_data_w) |
| 119 | AM_RANGE(0xff8008, 0xff8009) AM_READ(cdc_data_sub_r) |
| 120 | AM_RANGE(0xff800a, 0xff800b) AM_READWRITE(cdc_dmaaddr_r,cdc_dmaaddr_w) // CDC DMA Address |
| 121 | AM_RANGE(0xff800c, 0xff800d) AM_READWRITE(segacd_stopwatch_timer_r, segacd_stopwatch_timer_w)// Stopwatch timer |
| 122 | AM_RANGE(0xff800e ,0xff800f) AM_READWRITE(segacd_comms_flags_r, segacd_comms_flags_subcpu_w) |
| 123 | AM_RANGE(0xff8010 ,0xff801f) AM_READWRITE(segacd_comms_sub_part1_r, segacd_comms_sub_part1_w) |
| 124 | AM_RANGE(0xff8020 ,0xff802f) AM_READWRITE(segacd_comms_sub_part2_r, segacd_comms_sub_part2_w) |
| 125 | AM_RANGE(0xff8030, 0xff8031) AM_READWRITE(segacd_irq3timer_r, segacd_irq3timer_w) // Timer W/INT3 |
| 126 | AM_RANGE(0xff8032, 0xff8033) AM_READWRITE(segacd_irq_mask_r,segacd_irq_mask_w) |
| 127 | AM_RANGE(0xff8034, 0xff8035) AM_READWRITE(segacd_cdfader_r,segacd_cdfader_w) // CD Fader |
| 128 | AM_RANGE(0xff8036, 0xff8037) AM_READWRITE(segacd_cdd_ctrl_r,segacd_cdd_ctrl_w) |
| 129 | AM_RANGE(0xff8038, 0xff8041) AM_READ8(segacd_cdd_rx_r,0xffff) |
| 130 | AM_RANGE(0xff8042, 0xff804b) AM_WRITE8(segacd_cdd_tx_w,0xffff) |
| 131 | AM_RANGE(0xff804c, 0xff804d) AM_READWRITE(segacd_font_color_r, segacd_font_color_w) |
| 132 | AM_RANGE(0xff804e, 0xff804f) AM_RAM AM_SHARE("segacd_font") |
| 133 | AM_RANGE(0xff8050, 0xff8057) AM_READ(segacd_font_converted_r) |
| 134 | AM_RANGE(0xff8058, 0xff8059) AM_READWRITE(segacd_stampsize_r, segacd_stampsize_w) // Stamp size |
| 135 | AM_RANGE(0xff805a, 0xff805b) AM_READWRITE(segacd_stampmap_base_address_r, segacd_stampmap_base_address_w) // Stamp map base address |
| 136 | AM_RANGE(0xff805c, 0xff805d) AM_READWRITE(segacd_imagebuffer_vcell_size_r, segacd_imagebuffer_vcell_size_w)// Image buffer V cell size |
| 137 | AM_RANGE(0xff805e, 0xff805f) AM_READWRITE(segacd_imagebuffer_start_address_r, segacd_imagebuffer_start_address_w) // Image buffer start address |
| 138 | AM_RANGE(0xff8060, 0xff8061) AM_READWRITE(segacd_imagebuffer_offset_r, segacd_imagebuffer_offset_w) |
| 139 | AM_RANGE(0xff8062, 0xff8063) AM_READWRITE(segacd_imagebuffer_hdot_size_r, segacd_imagebuffer_hdot_size_w) // Image buffer H dot size |
| 140 | AM_RANGE(0xff8064, 0xff8065) AM_READWRITE(segacd_imagebuffer_vdot_size_r, segacd_imagebuffer_vdot_size_w ) // Image buffer V dot size |
| 141 | AM_RANGE(0xff8066, 0xff8067) AM_WRITE(segacd_trace_vector_base_address_w)// Trace vector base address |
| 142 | // AM_RANGE(0xff8068, 0xff8069) // Subcode address |
| 176 | 143 | |
| 144 | // AM_RANGE(0xff8100, 0xff817f) // Subcode buffer area |
| 145 | // AM_RANGE(0xff8180, 0xff81ff) // mirror of subcode buffer area |
| 177 | 146 | |
| 178 | | #define TOCCMD_CURPOS (0x0) |
| 179 | | #define TOCCMD_TRKPOS (0x1) |
| 180 | | #define TOCCMD_CURTRK (0x2) |
| 181 | | #define TOCCMD_LENGTH (0x3) |
| 182 | | #define TOCCMD_FIRSTLAST (0x4) |
| 183 | | #define TOCCMD_TRACKADDR (0x5) |
| 147 | ADDRESS_MAP_END |
| 184 | 148 | |
| 185 | | struct segacd_t |
| 186 | | { |
| 187 | | cdrom_file *cd; |
| 188 | | const cdrom_toc *toc; |
| 189 | | UINT32 current_frame; |
| 190 | | }; |
| 149 | static MACHINE_CONFIG_FRAGMENT( segacd_fragment ) |
| 191 | 150 | |
| 192 | | segacd_t segacd; |
| 151 | MCFG_CPU_ADD("segacd_68k", M68000, SEGACD_CLOCK ) /* 12.5 MHz */ |
| 152 | MCFG_CPU_PROGRAM_MAP(segacd_map) |
| 193 | 153 | |
| 194 | | #define SECTOR_SIZE (2352) |
| 154 | MCFG_DEVICE_ADD("cdc", LC89510, 0) // cd controller |
| 195 | 155 | |
| 196 | | #define SET_CDD_DATA_MODE \ |
| 197 | | CDD_CONTROL |= 0x0100; \ |
| 156 | MCFG_TIMER_ADD_NONE("sw_timer") //stopwatch timer |
| 157 | MCFG_TIMER_DRIVER_ADD_PERIODIC("hock_timer", sega_segacd_device, segacd_access_timer_callback, attotime::from_hz(75)) |
| 158 | MCFG_TIMER_DRIVER_ADD("irq3_timer", sega_segacd_device, segacd_irq3_timer_callback) |
| 159 | MCFG_TIMER_DRIVER_ADD("stamp_timer", sega_segacd_device, segacd_gfx_conversion_timer_callback) |
| 160 | MCFG_TIMER_DRIVER_ADD("scd_dma_timer", sega_segacd_device, scd_dma_timer_callback) |
| 198 | 161 | |
| 199 | | #define SET_CDD_AUDIO_MODE \ |
| 200 | | CDD_CONTROL &= ~0x0100; \ |
| 162 | |
| 201 | 163 | |
| 202 | | #define STOP_CDC_READ \ |
| 203 | | SCD_STATUS_CDC &= ~0x01; \ |
| 164 | MCFG_DEFAULT_LAYOUT( layout_megacd ) |
| 204 | 165 | |
| 205 | | #define SET_CDC_READ \ |
| 206 | | SCD_STATUS_CDC |= 0x01; \ |
| 166 | MCFG_SOUND_ADD( "cdda", CDDA, 0 ) |
| 167 | MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 ) // TODO: accurate volume balance |
| 168 | MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 ) |
| 207 | 169 | |
| 208 | | #define SET_CDC_DMA \ |
| 209 | | SCD_STATUS_CDC |= 0x08; \ |
| 170 | MCFG_SOUND_ADD("rfsnd", RF5C68, SEGACD_CLOCK) // RF5C164! |
| 171 | MCFG_SOUND_ROUTE( 0, ":lspeaker", 0.50 ) |
| 172 | MCFG_SOUND_ROUTE( 1, ":rspeaker", 0.50 ) |
| 210 | 173 | |
| 211 | | #define STOP_CDC_DMA \ |
| 212 | | SCD_STATUS_CDC &= ~0x08; \ |
| 213 | 174 | |
| 214 | | #define SCD_READ_ENABLED \ |
| 215 | | (SCD_STATUS_CDC & 1) |
| 175 | MCFG_NVRAM_HANDLER_CLEAR() |
| 176 | MCFG_NVRAM_ADD_0FILL("backupram") |
| 216 | 177 | |
| 217 | | #define SCD_DMA_ENABLED \ |
| 218 | | (SCD_STATUS_CDC & 0x08) |
| 178 | MCFG_QUANTUM_PERFECT_CPU("segacd_68k") // perfect sync to the fastest cpu |
| 179 | MACHINE_CONFIG_END |
| 219 | 180 | |
| 220 | | #define CLEAR_CDD_RESULT \ |
| 221 | | CDD_MIN = CDD_SEC = CDD_FRAME = CDD_EXT = 0; \ |
| 222 | 181 | |
| 223 | | #define CHECK_SCD_LV5_INTERRUPT \ |
| 224 | | if (segacd_irq_mask & 0x20) \ |
| 225 | | { \ |
| 226 | | machine.device(":segacd:segacd_68k")->execute().set_input_line(5, HOLD_LINE); \ |
| 227 | | } \ |
| 228 | 182 | |
| 229 | | #define CHECK_SCD_LV4_INTERRUPT \ |
| 230 | | if (segacd_irq_mask & 0x10) \ |
| 231 | | { \ |
| 232 | | machine.device(":segacd:segacd_68k")->execute().set_input_line(4, HOLD_LINE); \ |
| 233 | | } \ |
| 183 | machine_config_constructor sega_segacd_device::device_mconfig_additions() const |
| 184 | { |
| 185 | return MACHINE_CONFIG_NAME( segacd_fragment ); |
| 186 | } |
| 234 | 187 | |
| 235 | | #define CHECK_SCD_LV3_INTERRUPT \ |
| 236 | | if (segacd_irq_mask & 0x08) \ |
| 237 | | { \ |
| 238 | | machine.device(":segacd:segacd_68k")->execute().set_input_line(3, HOLD_LINE); \ |
| 239 | | } \ |
| 240 | 188 | |
| 241 | | #define CHECK_SCD_LV2_INTERRUPT \ |
| 242 | | if (segacd_irq_mask & 0x04) \ |
| 243 | | { \ |
| 244 | | machine.device(":segacd:segacd_68k")->execute().set_input_line(2, HOLD_LINE); \ |
| 245 | | } \ |
| 246 | 189 | |
| 247 | | #define CHECK_SCD_LV1_INTERRUPT \ |
| 248 | | if (segacd_irq_mask & 0x02) \ |
| 249 | | { \ |
| 250 | | machine.device(":segacd:segacd_68k")->execute().set_input_line(1, HOLD_LINE); \ |
| 251 | | } \ |
| 252 | 190 | |
| 253 | | #define CURRENT_TRACK_IS_DATA \ |
| 254 | | (segacd.toc->tracks[SCD_CURTRK - 1].trktype != CD_TRACK_AUDIO) \ |
| 255 | 191 | |
| 256 | | |
| 257 | | |
| 258 | | INLINE int to_bcd(int val, bool byte) |
| 192 | inline int sega_segacd_device::to_bcd(int val, bool byte) |
| 259 | 193 | { |
| 260 | 194 | if (val > 99) val = 99; |
| 261 | 195 | |
| r18275 | r18276 | |
| 265 | 199 | |
| 266 | 200 | |
| 267 | 201 | |
| 268 | | UINT16* segacd_4meg_prgram; // pointer to SubCPU PrgRAM |
| 269 | | UINT16* segacd_dataram; |
| 270 | 202 | |
| 271 | | #define RAM_MODE_2MEG (0) |
| 272 | | #define RAM_MODE_1MEG (2) |
| 273 | 203 | |
| 274 | 204 | |
| 275 | 205 | |
| 276 | | INLINE void write_pixel(running_machine& machine, UINT8 pix, int pixeloffset ) |
| 206 | inline void sega_segacd_device::write_pixel(running_machine& machine, UINT8 pix, int pixeloffset ) |
| 277 | 207 | { |
| 278 | 208 | |
| 279 | 209 | int shift = 12-(4*(pixeloffset&0x3)); |
| r18275 | r18276 | |
| 321 | 251 | // Wily Beamish and Citizen X appear to rely on this |
| 322 | 252 | // however, it breaks the megacdj bios (megacd2j still works!) |
| 323 | 253 | // (maybe that's a timing issue instead?) |
| 324 | | UINT16 segacd_1meg_mode_word_read(int offset, UINT16 mem_mask) |
| 254 | UINT16 sega_segacd_device::segacd_1meg_mode_word_read(int offset, UINT16 mem_mask) |
| 325 | 255 | { |
| 326 | 256 | offset *= 2; |
| 327 | 257 | |
| r18275 | r18276 | |
| 334 | 264 | } |
| 335 | 265 | |
| 336 | 266 | |
| 337 | | void segacd_1meg_mode_word_write(running_machine& machine, int offset, UINT16 data, UINT16 mem_mask, int use_pm) |
| 267 | void sega_segacd_device::segacd_1meg_mode_word_write(running_machine& machine, int offset, UINT16 data, UINT16 mem_mask, int use_pm) |
| 338 | 268 | { |
| 339 | 269 | offset *= 2; |
| 340 | 270 | |
| r18275 | r18276 | |
| 393 | 323 | } |
| 394 | 324 | |
| 395 | 325 | |
| 396 | | static UINT16* segacd_dataram2; |
| 397 | 326 | |
| 398 | | UINT8 SCD_BUFFER[2560]; |
| 399 | | UINT32 SCD_STATUS; |
| 400 | | UINT32 SCD_STATUS_CDC; |
| 401 | | INT32 SCD_CURLBA; |
| 402 | | UINT8 SCD_CURTRK; |
| 403 | | |
| 404 | | UINT16 CDC_DECODE; |
| 405 | | INT16 CDC_DMACNT; // can go negative |
| 406 | | UINT16 CDC_DMA_ADDRC; |
| 407 | | UINT16 CDC_PT; |
| 408 | | UINT16 CDC_WA; |
| 409 | | UINT16 CDC_REG0; |
| 410 | | UINT16 CDC_REG1; |
| 411 | | UINT16 CDC_DMA_ADDR; |
| 412 | | UINT16 CDC_IFSTAT; |
| 413 | | UINT8 CDC_HEADB0; |
| 414 | | UINT8 CDC_HEADB1; |
| 415 | | UINT8 CDC_HEADB2; |
| 416 | | UINT8 CDC_HEADB3; |
| 417 | | UINT8 CDC_STATB0; |
| 418 | | UINT8 CDC_STATB1; |
| 419 | | UINT8 CDC_STATB2; |
| 420 | | UINT8 CDC_STATB3; |
| 421 | | UINT16 CDC_SBOUT; |
| 422 | | UINT16 CDC_IFCTRL; |
| 423 | | UINT8 CDC_CTRLB0; |
| 424 | | UINT8 CDC_CTRLB1; |
| 425 | | UINT8 CDC_CTRLB2; |
| 426 | | UINT8 CDC_BUFFER[(32 * 1024 * 2) + SECTOR_SIZE]; |
| 427 | | |
| 428 | | UINT32 CDD_STATUS; |
| 429 | | UINT32 CDD_MIN; |
| 430 | | UINT32 CDD_SEC; |
| 431 | | |
| 432 | | UINT8 CDD_RX[10]; |
| 433 | | UINT8 CDD_TX[10]; |
| 434 | | UINT32 CDD_FRAME; |
| 435 | | UINT32 CDD_EXT; |
| 436 | | UINT16 CDD_CONTROL; |
| 437 | | INT16 CDD_DONE; |
| 438 | | |
| 439 | | static void set_data_audio_mode(void) |
| 327 | void sega_segacd_device::set_data_audio_mode(void) |
| 440 | 328 | { |
| 441 | 329 | if (CURRENT_TRACK_IS_DATA) |
| 442 | 330 | { |
| r18275 | r18276 | |
| 449 | 337 | } |
| 450 | 338 | } |
| 451 | 339 | |
| 452 | | |
| 453 | | #define CDD_PLAYINGCDDA 0x0100 |
| 454 | | #define CDD_READY 0x0400 |
| 455 | | #define CDD_STOPPED 0x0900 |
| 456 | | |
| 457 | | void CDD_DoChecksum(void) |
| 340 | void sega_segacd_device::CDD_DoChecksum(void) |
| 458 | 341 | { |
| 459 | 342 | int checksum = |
| 460 | 343 | CDD_RX[0] + |
| r18275 | r18276 | |
| 473 | 356 | CDD_RX[8] = checksum; |
| 474 | 357 | } |
| 475 | 358 | |
| 476 | | void CDD_Export(void) |
| 359 | void sega_segacd_device::CDD_Export(void) |
| 477 | 360 | { |
| 478 | 361 | CDD_RX[0] = (CDD_STATUS & 0x00ff)>>0; |
| 479 | 362 | CDD_RX[1] = (CDD_STATUS & 0xff00)>>8; |
| r18275 | r18276 | |
| 494 | 377 | |
| 495 | 378 | |
| 496 | 379 | |
| 497 | | void CDC_UpdateHEAD(void) |
| 380 | void sega_segacd_device::CDC_UpdateHEAD(void) |
| 498 | 381 | { |
| 499 | 382 | if (CDC_CTRLB1 & 0x01) |
| 500 | 383 | { |
| r18275 | r18276 | |
| 511 | 394 | } |
| 512 | 395 | |
| 513 | 396 | |
| 514 | | void scd_ctrl_checks(running_machine& machine) |
| 397 | void sega_segacd_device::scd_ctrl_checks(running_machine& machine) |
| 515 | 398 | { |
| 516 | 399 | CDC_STATB0 = 0x80; |
| 517 | 400 | |
| r18275 | r18276 | |
| 526 | 409 | } |
| 527 | 410 | } |
| 528 | 411 | |
| 529 | | void scd_advance_current_readpos(void) |
| 412 | void sega_segacd_device::scd_advance_current_readpos(void) |
| 530 | 413 | { |
| 531 | 414 | SCD_CURLBA++; |
| 532 | 415 | |
| r18275 | r18276 | |
| 537 | 420 | CDC_PT &= 0x7fff; |
| 538 | 421 | } |
| 539 | 422 | |
| 540 | | int Read_LBA_To_Buffer(running_machine& machine) |
| 423 | int sega_segacd_device::Read_LBA_To_Buffer(running_machine& machine) |
| 541 | 424 | { |
| 542 | 425 | bool data_track = false; |
| 543 | 426 | if (CDD_CONTROL & 0x0100) data_track = true; |
| r18275 | r18276 | |
| 579 | 462 | return 0; |
| 580 | 463 | } |
| 581 | 464 | |
| 582 | | static void CheckCommand(running_machine& machine) |
| 465 | void sega_segacd_device::CheckCommand(running_machine& machine) |
| 583 | 466 | { |
| 584 | 467 | if (CDD_DONE) |
| 585 | 468 | { |
| r18275 | r18276 | |
| 596 | 479 | } |
| 597 | 480 | |
| 598 | 481 | |
| 599 | | void CDD_GetStatus(void) |
| 482 | void sega_segacd_device::CDD_GetStatus(void) |
| 600 | 483 | { |
| 601 | 484 | UINT16 s = (CDD_STATUS & 0x0f00); |
| 602 | 485 | |
| r18275 | r18276 | |
| 605 | 488 | } |
| 606 | 489 | |
| 607 | 490 | |
| 608 | | void CDD_Stop(running_machine &machine) |
| 491 | void sega_segacd_device::CDD_Stop(running_machine &machine) |
| 609 | 492 | { |
| 610 | 493 | CLEAR_CDD_RESULT |
| 611 | 494 | STOP_CDC_READ |
| r18275 | r18276 | |
| 616 | 499 | } |
| 617 | 500 | |
| 618 | 501 | |
| 619 | | void CDD_GetPos(void) |
| 502 | void sega_segacd_device::CDD_GetPos(void) |
| 620 | 503 | { |
| 621 | 504 | CLEAR_CDD_RESULT |
| 622 | 505 | UINT32 msf; |
| r18275 | r18276 | |
| 630 | 513 | CDD_FRAME = to_bcd(((msf & 0x000000ff)>>0),false); |
| 631 | 514 | } |
| 632 | 515 | |
| 633 | | void CDD_GetTrackPos(void) |
| 516 | void sega_segacd_device::CDD_GetTrackPos(void) |
| 634 | 517 | { |
| 635 | 518 | CLEAR_CDD_RESULT |
| 636 | 519 | int elapsedlba; |
| r18275 | r18276 | |
| 648 | 531 | CDD_FRAME = to_bcd(((msf & 0x000000ff)>>0),false); |
| 649 | 532 | } |
| 650 | 533 | |
| 651 | | void CDD_GetTrack(void) |
| 534 | void sega_segacd_device::CDD_GetTrack(void) |
| 652 | 535 | { |
| 653 | 536 | CLEAR_CDD_RESULT |
| 654 | 537 | CDD_STATUS &= 0xFF; |
| r18275 | r18276 | |
| 659 | 542 | CDD_MIN = to_bcd(SCD_CURTRK, false); |
| 660 | 543 | } |
| 661 | 544 | |
| 662 | | void CDD_Length(void) |
| 545 | void sega_segacd_device::CDD_Length(void) |
| 663 | 546 | { |
| 664 | 547 | CLEAR_CDD_RESULT |
| 665 | 548 | CDD_STATUS &= 0xFF; |
| r18275 | r18276 | |
| 676 | 559 | } |
| 677 | 560 | |
| 678 | 561 | |
| 679 | | void CDD_FirstLast(void) |
| 562 | void sega_segacd_device::CDD_FirstLast(void) |
| 680 | 563 | { |
| 681 | 564 | CLEAR_CDD_RESULT |
| 682 | 565 | CDD_STATUS &= 0xFF; |
| r18275 | r18276 | |
| 687 | 570 | CDD_SEC = to_bcd(cdrom_get_last_track(segacd.cd),false); // last |
| 688 | 571 | } |
| 689 | 572 | |
| 690 | | void CDD_GetTrackAdr(void) |
| 573 | void sega_segacd_device::CDD_GetTrackAdr(void) |
| 691 | 574 | { |
| 692 | 575 | CLEAR_CDD_RESULT |
| 693 | 576 | |
| r18275 | r18276 | |
| 717 | 600 | CDD_FRAME |= 0x0800; |
| 718 | 601 | } |
| 719 | 602 | |
| 720 | | static UINT32 getmsf_from_regs(void) |
| 603 | UINT32 sega_segacd_device::getmsf_from_regs(void) |
| 721 | 604 | { |
| 722 | 605 | UINT32 msf = 0; |
| 723 | 606 | |
| r18275 | r18276 | |
| 728 | 611 | return msf; |
| 729 | 612 | } |
| 730 | 613 | |
| 731 | | void CDD_Play(running_machine &machine) |
| 614 | void sega_segacd_device::CDD_Play(running_machine &machine) |
| 732 | 615 | { |
| 733 | 616 | CLEAR_CDD_RESULT |
| 734 | 617 | UINT32 msf = getmsf_from_regs(); |
| r18275 | r18276 | |
| 747 | 630 | } |
| 748 | 631 | |
| 749 | 632 | |
| 750 | | void CDD_Seek(void) |
| 633 | void sega_segacd_device::CDD_Seek(void) |
| 751 | 634 | { |
| 752 | 635 | CLEAR_CDD_RESULT |
| 753 | 636 | UINT32 msf = getmsf_from_regs(); |
| r18275 | r18276 | |
| 761 | 644 | } |
| 762 | 645 | |
| 763 | 646 | |
| 764 | | void CDD_Pause(running_machine &machine) |
| 647 | void sega_segacd_device::CDD_Pause(running_machine &machine) |
| 765 | 648 | { |
| 766 | 649 | CLEAR_CDD_RESULT |
| 767 | 650 | STOP_CDC_READ |
| r18275 | r18276 | |
| 774 | 657 | cdda_pause_audio( machine.device( ":segacd:cdda" ), 1 ); |
| 775 | 658 | } |
| 776 | 659 | |
| 777 | | void CDD_Resume(running_machine &machine) |
| 660 | void sega_segacd_device::CDD_Resume(running_machine &machine) |
| 778 | 661 | { |
| 779 | 662 | CLEAR_CDD_RESULT |
| 780 | 663 | STOP_CDC_READ |
| r18275 | r18276 | |
| 789 | 672 | } |
| 790 | 673 | |
| 791 | 674 | |
| 792 | | void CDD_FF(running_machine &machine) |
| 675 | void sega_segacd_device::CDD_FF(running_machine &machine) |
| 793 | 676 | { |
| 794 | 677 | fatalerror("Fast Forward unsupported\n"); |
| 795 | 678 | } |
| 796 | 679 | |
| 797 | 680 | |
| 798 | | void CDD_RW(running_machine &machine) |
| 681 | void sega_segacd_device::CDD_RW(running_machine &machine) |
| 799 | 682 | { |
| 800 | 683 | fatalerror("Fast Rewind unsupported\n"); |
| 801 | 684 | } |
| 802 | 685 | |
| 803 | 686 | |
| 804 | | void CDD_Open(void) |
| 687 | void sega_segacd_device::CDD_Open(void) |
| 805 | 688 | { |
| 806 | 689 | fatalerror("Close Tray unsupported\n"); |
| 807 | 690 | /* TODO: re-read CD-ROM buffer here (Mega CD has multi disc games iirc?) */ |
| 808 | 691 | } |
| 809 | 692 | |
| 810 | 693 | |
| 811 | | void CDD_Close(void) |
| 694 | void sega_segacd_device::CDD_Close(void) |
| 812 | 695 | { |
| 813 | 696 | fatalerror("Open Tray unsupported\n"); |
| 814 | 697 | /* TODO: clear CD-ROM buffer here */ |
| 815 | 698 | } |
| 816 | 699 | |
| 817 | 700 | |
| 818 | | void CDD_Init(void) |
| 701 | void sega_segacd_device::CDD_Init(void) |
| 819 | 702 | { |
| 820 | 703 | CLEAR_CDD_RESULT |
| 821 | 704 | STOP_CDC_READ |
| r18275 | r18276 | |
| 826 | 709 | } |
| 827 | 710 | |
| 828 | 711 | |
| 829 | | void CDD_Default(void) |
| 712 | void sega_segacd_device::CDD_Default(void) |
| 830 | 713 | { |
| 831 | 714 | CLEAR_CDD_RESULT |
| 832 | 715 | CDD_STATUS = SCD_STATUS; |
| 833 | 716 | } |
| 834 | 717 | |
| 835 | 718 | |
| 836 | | static void CDD_Reset(void) |
| 719 | void sega_segacd_device::CDD_Reset(void) |
| 837 | 720 | { |
| 838 | 721 | CLEAR_CDD_RESULT |
| 839 | 722 | CDD_CONTROL = CDD_STATUS = 0; |
| r18275 | r18276 | |
| 847 | 730 | SCD_STATUS = CDD_READY; |
| 848 | 731 | } |
| 849 | 732 | |
| 850 | | static void CDC_Reset(void) |
| 733 | void sega_segacd_device::CDC_Reset(void) |
| 851 | 734 | { |
| 852 | 735 | memset(CDC_BUFFER, 0x00, ((16 * 1024 * 2) + SECTOR_SIZE)); |
| 853 | 736 | CDC_UpdateHEAD(); |
| r18275 | r18276 | |
| 862 | 745 | } |
| 863 | 746 | |
| 864 | 747 | |
| 865 | | void lc89510_Reset(void) |
| 748 | void sega_segacd_device::lc89510_Reset(void) |
| 866 | 749 | { |
| 867 | 750 | CDD_Reset(); |
| 868 | 751 | CDC_Reset(); |
| r18275 | r18276 | |
| 870 | 753 | CDC_REG0 = CDC_REG1 = CDC_DMA_ADDR = SCD_STATUS_CDC = CDD_DONE = 0; |
| 871 | 754 | } |
| 872 | 755 | |
| 873 | | void CDC_End_Transfer(running_machine& machine) |
| 756 | void sega_segacd_device::CDC_End_Transfer(running_machine& machine) |
| 874 | 757 | { |
| 875 | 758 | STOP_CDC_DMA |
| 876 | 759 | CDC_REG0 |= 0x8000; |
| r18275 | r18276 | |
| 884 | 767 | } |
| 885 | 768 | } |
| 886 | 769 | |
| 887 | | void CDC_Do_DMA(running_machine& machine, int rate) |
| 770 | void sega_segacd_device::CDC_Do_DMA(running_machine& machine, int rate) |
| 888 | 771 | { |
| 889 | 772 | address_space& space = machine.device(":segacd:segacd_68k")->memory().space(AS_PROGRAM); |
| 890 | 773 | |
| r18275 | r18276 | |
| 1018 | 901 | |
| 1019 | 902 | |
| 1020 | 903 | |
| 1021 | | UINT16 CDC_Host_r(running_machine& machine, UINT16 type) |
| 904 | UINT16 sega_segacd_device::CDC_Host_r(running_machine& machine, UINT16 type) |
| 1022 | 905 | { |
| 1023 | 906 | UINT16 destination = CDC_REG0 & 0x0700; |
| 1024 | 907 | |
| r18275 | r18276 | |
| 1046 | 929 | } |
| 1047 | 930 | |
| 1048 | 931 | |
| 1049 | | UINT8 CDC_Reg_r(void) |
| 932 | UINT8 sega_segacd_device::CDC_Reg_r(void) |
| 1050 | 933 | { |
| 1051 | 934 | int reg = CDC_REG0 & 0xF; |
| 1052 | 935 | UINT8 ret = 0; |
| r18275 | r18276 | |
| 1092 | 975 | return ret; |
| 1093 | 976 | } |
| 1094 | 977 | |
| 1095 | | void CDC_Reg_w(UINT8 data) |
| 978 | void sega_segacd_device::CDC_Reg_w(UINT8 data) |
| 1096 | 979 | { |
| 1097 | 980 | int reg = CDC_REG0 & 0xF; |
| 1098 | 981 | |
| r18275 | r18276 | |
| 1144 | 1027 | } |
| 1145 | 1028 | } |
| 1146 | 1029 | |
| 1147 | | void CDD_Process(running_machine& machine, int reason) |
| 1030 | void sega_segacd_device::CDD_Process(running_machine& machine, int reason) |
| 1148 | 1031 | { |
| 1149 | 1032 | CDD_Export(); |
| 1150 | 1033 | CHECK_SCD_LV4_INTERRUPT |
| 1151 | 1034 | } |
| 1152 | 1035 | |
| 1153 | | void CDD_Handle_TOC_Commands(void) |
| 1036 | void sega_segacd_device::CDD_Handle_TOC_Commands(void) |
| 1154 | 1037 | { |
| 1155 | 1038 | int subcmd = CDD_TX[2]; |
| 1156 | 1039 | CDD_STATUS = (CDD_STATUS & 0xFF00) | subcmd; |
| r18275 | r18276 | |
| 1187 | 1070 | "<undefined>" // F |
| 1188 | 1071 | }; |
| 1189 | 1072 | |
| 1190 | | void CDD_Import(running_machine& machine) |
| 1073 | void sega_segacd_device::CDD_Import(running_machine& machine) |
| 1191 | 1074 | { |
| 1192 | 1075 | if(CDD_TX[1] != 2 && CDD_TX[1] != 0) |
| 1193 | 1076 | printf("%s\n",CDD_import_cmdnames[CDD_TX[1]]); |
| r18275 | r18276 | |
| 1215 | 1098 | |
| 1216 | 1099 | |
| 1217 | 1100 | |
| 1218 | | |
| 1219 | | static UINT16 segacd_hint_register; |
| 1220 | | static UINT16 segacd_imagebuffer_vdot_size; |
| 1221 | | static UINT16 segacd_imagebuffer_vcell_size; |
| 1222 | | static UINT16 segacd_imagebuffer_hdot_size; |
| 1223 | | |
| 1224 | | static UINT16 a12000_halt_reset_reg = 0x0000; |
| 1225 | | int segacd_conversion_active = 0; |
| 1226 | | static UINT16 segacd_stampmap_base_address; |
| 1227 | | static UINT16 segacd_imagebuffer_start_address; |
| 1228 | | static UINT16 segacd_imagebuffer_offset; |
| 1229 | | static tilemap_t *segacd_stampmap[4]; |
| 1230 | | //static void segacd_mark_stampmaps_dirty(void); |
| 1231 | | |
| 1232 | | |
| 1233 | | |
| 1234 | | static WRITE16_HANDLER( scd_a12000_halt_reset_w ) |
| 1101 | WRITE16_MEMBER( sega_segacd_device::scd_a12000_halt_reset_w ) |
| 1235 | 1102 | { |
| 1236 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1103 | |
| 1237 | 1104 | |
| 1238 | 1105 | UINT16 old_halt = a12000_halt_reset_reg; |
| 1239 | 1106 | |
| r18275 | r18276 | |
| 1284 | 1151 | } |
| 1285 | 1152 | } |
| 1286 | 1153 | |
| 1287 | | static READ16_HANDLER( scd_a12000_halt_reset_r ) |
| 1154 | READ16_MEMBER( sega_segacd_device::scd_a12000_halt_reset_r ) |
| 1288 | 1155 | { |
| 1289 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1290 | | |
| 1291 | 1156 | return a12000_halt_reset_reg; |
| 1292 | 1157 | } |
| 1293 | 1158 | |
| r18275 | r18276 | |
| 1303 | 1168 | // |
| 1304 | 1169 | |
| 1305 | 1170 | |
| 1306 | | static READ16_HANDLER( scd_a12002_memory_mode_r ) |
| 1171 | READ16_MEMBER( sega_segacd_device::scd_a12002_memory_mode_r ) |
| 1307 | 1172 | { |
| 1308 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1173 | |
| 1309 | 1174 | |
| 1310 | 1175 | int temp = scd_rammode; |
| 1311 | 1176 | int temp2 = 0; |
| r18275 | r18276 | |
| 1330 | 1195 | // RET = Return access (bit 1) |
| 1331 | 1196 | |
| 1332 | 1197 | |
| 1333 | | static WRITE8_HANDLER( scd_a12002_memory_mode_w_8_15 ) |
| 1198 | WRITE8_MEMBER( sega_segacd_device::scd_a12002_memory_mode_w_8_15 ) |
| 1334 | 1199 | { |
| 1335 | 1200 | if (data & 0xff00) |
| 1336 | 1201 | { |
| r18275 | r18276 | |
| 1341 | 1206 | } |
| 1342 | 1207 | |
| 1343 | 1208 | |
| 1344 | | static WRITE8_HANDLER( scd_a12002_memory_mode_w_0_7 ) |
| 1209 | WRITE8_MEMBER( sega_segacd_device::scd_a12002_memory_mode_w_0_7 ) |
| 1345 | 1210 | { |
| 1346 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1211 | |
| 1347 | 1212 | |
| 1348 | 1213 | |
| 1349 | 1214 | //printf("scd_a12002_memory_mode_w_0_7 %04x\n",data); |
| r18275 | r18276 | |
| 1367 | 1232 | } |
| 1368 | 1233 | |
| 1369 | 1234 | |
| 1370 | | static WRITE16_HANDLER( scd_a12002_memory_mode_w ) |
| 1235 | WRITE16_MEMBER( sega_segacd_device::scd_a12002_memory_mode_w ) |
| 1371 | 1236 | { |
| 1372 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1237 | |
| 1373 | 1238 | |
| 1374 | 1239 | if (ACCESSING_BITS_8_15) |
| 1375 | 1240 | scd_a12002_memory_mode_w_8_15(space, 0, data>>8, mem_mask>>8); |
| r18275 | r18276 | |
| 1381 | 1246 | |
| 1382 | 1247 | |
| 1383 | 1248 | |
| 1384 | | static READ16_HANDLER( segacd_sub_memory_mode_r ) |
| 1249 | READ16_MEMBER( sega_segacd_device::segacd_sub_memory_mode_r ) |
| 1385 | 1250 | { |
| 1386 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1251 | |
| 1387 | 1252 | |
| 1388 | 1253 | int temp = scd_rammode; |
| 1389 | 1254 | int temp2 = 0; |
| r18275 | r18276 | |
| 1396 | 1261 | } |
| 1397 | 1262 | |
| 1398 | 1263 | |
| 1399 | | WRITE8_HANDLER( segacd_sub_memory_mode_w_8_15 ) |
| 1264 | WRITE8_MEMBER( sega_segacd_device::segacd_sub_memory_mode_w_8_15 ) |
| 1400 | 1265 | { |
| 1401 | 1266 | /* setting write protect bits from sub-cpu has no effect? */ |
| 1402 | 1267 | } |
| 1403 | 1268 | |
| 1404 | 1269 | |
| 1405 | 1270 | |
| 1406 | | WRITE8_HANDLER( segacd_sub_memory_mode_w_0_7 ) |
| 1271 | WRITE8_MEMBER( sega_segacd_device::segacd_sub_memory_mode_w_0_7 ) |
| 1407 | 1272 | { |
| 1408 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1273 | |
| 1409 | 1274 | |
| 1410 | 1275 | |
| 1411 | 1276 | segacd_memory_priority_mode = (data&0x0018)>>3; |
| r18275 | r18276 | |
| 1462 | 1327 | } |
| 1463 | 1328 | } |
| 1464 | 1329 | |
| 1465 | | static WRITE16_HANDLER( segacd_sub_memory_mode_w ) |
| 1330 | WRITE16_MEMBER( sega_segacd_device::segacd_sub_memory_mode_w ) |
| 1466 | 1331 | { |
| 1467 | 1332 | //printf("segacd_sub_memory_mode_w %04x %04x\n", data, mem_mask); |
| 1468 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1333 | |
| 1469 | 1334 | |
| 1470 | 1335 | if (ACCESSING_BITS_8_15) |
| 1471 | 1336 | segacd_sub_memory_mode_w_8_15(space, 0, data>>8, mem_mask>>8); |
| r18275 | r18276 | |
| 1484 | 1349 | - main / sub sides differ in which bits are write only |
| 1485 | 1350 | ********************************************************************************/ |
| 1486 | 1351 | |
| 1487 | | static UINT16 segacd_comms_flags = 0x0000; |
| 1488 | 1352 | |
| 1489 | | static READ16_HANDLER( segacd_comms_flags_r ) |
| 1353 | READ16_MEMBER( sega_segacd_device::segacd_comms_flags_r ) |
| 1490 | 1354 | { |
| 1491 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1355 | |
| 1492 | 1356 | return segacd_comms_flags; |
| 1493 | 1357 | } |
| 1494 | 1358 | |
| 1495 | | static WRITE16_HANDLER( segacd_comms_flags_subcpu_w ) |
| 1359 | WRITE16_MEMBER( sega_segacd_device::segacd_comms_flags_subcpu_w ) |
| 1496 | 1360 | { |
| 1497 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1361 | |
| 1498 | 1362 | |
| 1499 | 1363 | if (ACCESSING_BITS_8_15) // Dragon's Lair |
| 1500 | 1364 | { |
| r18275 | r18276 | |
| 1508 | 1372 | } |
| 1509 | 1373 | } |
| 1510 | 1374 | |
| 1511 | | static WRITE16_HANDLER( segacd_comms_flags_maincpu_w ) |
| 1375 | WRITE16_MEMBER( sega_segacd_device::segacd_comms_flags_maincpu_w ) |
| 1512 | 1376 | { |
| 1513 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1377 | |
| 1514 | 1378 | |
| 1515 | 1379 | if (ACCESSING_BITS_8_15) |
| 1516 | 1380 | { |
| r18275 | r18276 | |
| 1524 | 1388 | } |
| 1525 | 1389 | } |
| 1526 | 1390 | |
| 1527 | | static READ16_HANDLER( scd_4m_prgbank_ram_r ) |
| 1391 | READ16_MEMBER( sega_segacd_device::scd_4m_prgbank_ram_r ) |
| 1528 | 1392 | { |
| 1529 | 1393 | UINT16 realoffset = ((segacd_4meg_prgbank * 0x20000)/2) + offset; |
| 1530 | 1394 | return segacd_4meg_prgram[realoffset]; |
| 1531 | 1395 | |
| 1532 | 1396 | } |
| 1533 | 1397 | |
| 1534 | | static WRITE16_HANDLER( scd_4m_prgbank_ram_w ) |
| 1398 | WRITE16_MEMBER( sega_segacd_device::scd_4m_prgbank_ram_w ) |
| 1535 | 1399 | { |
| 1536 | 1400 | UINT16 realoffset = ((segacd_4meg_prgbank * 0x20000)/2) + offset; |
| 1537 | 1401 | |
| r18275 | r18276 | |
| 1543 | 1407 | } |
| 1544 | 1408 | |
| 1545 | 1409 | |
| 1546 | | /* Callback when the genesis enters interrupt code */ |
| 1547 | | static IRQ_CALLBACK(segacd_sub_int_callback) |
| 1548 | | { |
| 1549 | | if (irqline==2) |
| 1550 | | { |
| 1551 | | // clear this bit |
| 1552 | | a12000_halt_reset_reg &= ~0x0100; |
| 1553 | | device->machine().device(":segacd:segacd_68k")->execute().set_input_line(2, CLEAR_LINE); |
| 1554 | | } |
| 1555 | 1410 | |
| 1556 | | return (0x60+irqline*4)/4; // vector address |
| 1557 | | } |
| 1558 | | |
| 1559 | | UINT16 segacd_comms_part1[0x8]; |
| 1560 | | UINT16 segacd_comms_part2[0x8]; |
| 1561 | | |
| 1562 | | static READ16_HANDLER( segacd_comms_main_part1_r ) |
| 1411 | READ16_MEMBER( sega_segacd_device::segacd_comms_main_part1_r ) |
| 1563 | 1412 | { |
| 1564 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1413 | |
| 1565 | 1414 | return segacd_comms_part1[offset]; |
| 1566 | 1415 | } |
| 1567 | 1416 | |
| 1568 | | static WRITE16_HANDLER( segacd_comms_main_part1_w ) |
| 1417 | WRITE16_MEMBER( sega_segacd_device::segacd_comms_main_part1_w ) |
| 1569 | 1418 | { |
| 1570 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1419 | |
| 1571 | 1420 | COMBINE_DATA(&segacd_comms_part1[offset]); |
| 1572 | 1421 | } |
| 1573 | 1422 | |
| 1574 | | static READ16_HANDLER( segacd_comms_main_part2_r ) |
| 1423 | READ16_MEMBER( sega_segacd_device::segacd_comms_main_part2_r ) |
| 1575 | 1424 | { |
| 1576 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1425 | |
| 1577 | 1426 | return segacd_comms_part2[offset]; |
| 1578 | 1427 | } |
| 1579 | 1428 | |
| 1580 | | static WRITE16_HANDLER( segacd_comms_main_part2_w ) |
| 1429 | WRITE16_MEMBER( sega_segacd_device::segacd_comms_main_part2_w ) |
| 1581 | 1430 | { |
| 1582 | 1431 | printf("Sega CD main CPU attempting to write to read only comms regs\n"); |
| 1583 | 1432 | } |
| 1584 | 1433 | |
| 1585 | 1434 | |
| 1586 | | static READ16_HANDLER( segacd_comms_sub_part1_r ) |
| 1435 | READ16_MEMBER( sega_segacd_device::segacd_comms_sub_part1_r ) |
| 1587 | 1436 | { |
| 1588 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1437 | |
| 1589 | 1438 | return segacd_comms_part1[offset]; |
| 1590 | 1439 | } |
| 1591 | 1440 | |
| 1592 | | static WRITE16_HANDLER( segacd_comms_sub_part1_w ) |
| 1441 | WRITE16_MEMBER( sega_segacd_device::segacd_comms_sub_part1_w ) |
| 1593 | 1442 | { |
| 1594 | 1443 | printf("Sega CD sub CPU attempting to write to read only comms regs\n"); |
| 1595 | 1444 | } |
| 1596 | 1445 | |
| 1597 | | static READ16_HANDLER( segacd_comms_sub_part2_r ) |
| 1446 | READ16_MEMBER( sega_segacd_device::segacd_comms_sub_part2_r ) |
| 1598 | 1447 | { |
| 1599 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1448 | |
| 1600 | 1449 | return segacd_comms_part2[offset]; |
| 1601 | 1450 | } |
| 1602 | 1451 | |
| 1603 | | static WRITE16_HANDLER( segacd_comms_sub_part2_w ) |
| 1452 | WRITE16_MEMBER( sega_segacd_device::segacd_comms_sub_part2_w ) |
| 1604 | 1453 | { |
| 1605 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1454 | |
| 1606 | 1455 | COMBINE_DATA(&segacd_comms_part2[offset]); |
| 1607 | 1456 | } |
| 1608 | 1457 | |
| r18275 | r18276 | |
| 1612 | 1461 | |
| 1613 | 1462 | |
| 1614 | 1463 | |
| 1615 | | static WRITE16_HANDLER( segacd_cdc_mode_address_w ) |
| 1464 | WRITE16_MEMBER( sega_segacd_device::segacd_cdc_mode_address_w ) |
| 1616 | 1465 | { |
| 1617 | 1466 | COMBINE_DATA(&CDC_REG0); |
| 1618 | 1467 | } |
| 1619 | 1468 | |
| 1620 | | static READ16_HANDLER( segacd_cdc_mode_address_r ) |
| 1469 | READ16_MEMBER( sega_segacd_device::segacd_cdc_mode_address_r ) |
| 1621 | 1470 | { |
| 1622 | 1471 | return CDC_REG0; |
| 1623 | 1472 | } |
| 1624 | 1473 | |
| 1625 | | static WRITE16_HANDLER( segacd_cdc_data_w ) |
| 1474 | WRITE16_MEMBER( sega_segacd_device::segacd_cdc_data_w ) |
| 1626 | 1475 | { |
| 1627 | 1476 | COMBINE_DATA(&CDC_REG1); |
| 1628 | 1477 | |
| r18275 | r18276 | |
| 1630 | 1479 | CDC_Reg_w(data); |
| 1631 | 1480 | } |
| 1632 | 1481 | |
| 1633 | | static READ16_HANDLER( segacd_cdc_data_r ) |
| 1482 | READ16_MEMBER( sega_segacd_device::segacd_cdc_data_r ) |
| 1634 | 1483 | { |
| 1635 | 1484 | UINT16 retdat = 0x0000; |
| 1636 | 1485 | |
| r18275 | r18276 | |
| 1644 | 1493 | |
| 1645 | 1494 | |
| 1646 | 1495 | |
| 1647 | | static READ16_HANDLER( segacd_main_dataram_part1_r ) |
| 1496 | READ16_MEMBER( sega_segacd_device::segacd_main_dataram_part1_r ) |
| 1648 | 1497 | { |
| 1649 | 1498 | if ((scd_rammode&2)==RAM_MODE_2MEG) |
| 1650 | 1499 | { |
| r18275 | r18276 | |
| 1712 | 1561 | return 0x0000; |
| 1713 | 1562 | } |
| 1714 | 1563 | |
| 1715 | | static WRITE16_HANDLER( segacd_main_dataram_part1_w ) |
| 1564 | WRITE16_MEMBER( sega_segacd_device::segacd_main_dataram_part1_w ) |
| 1716 | 1565 | { |
| 1717 | 1566 | if ((scd_rammode&2)==RAM_MODE_2MEG) |
| 1718 | 1567 | { |
| r18275 | r18276 | |
| 1752 | 1601 | } |
| 1753 | 1602 | } |
| 1754 | 1603 | |
| 1755 | | static READ16_HANDLER( scd_hint_vector_r ) |
| 1604 | READ16_MEMBER( sega_segacd_device::scd_hint_vector_r ) |
| 1756 | 1605 | { |
| 1757 | 1606 | // printf("read HINT offset %d\n", offset); |
| 1758 | 1607 | |
| r18275 | r18276 | |
| 1769 | 1618 | |
| 1770 | 1619 | } |
| 1771 | 1620 | |
| 1772 | | static READ16_HANDLER( scd_a12006_hint_register_r ) |
| 1621 | READ16_MEMBER( sega_segacd_device::scd_a12006_hint_register_r ) |
| 1773 | 1622 | { |
| 1774 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1623 | |
| 1775 | 1624 | return segacd_hint_register; |
| 1776 | 1625 | } |
| 1777 | 1626 | |
| 1778 | | static WRITE16_HANDLER( scd_a12006_hint_register_w ) |
| 1627 | WRITE16_MEMBER( sega_segacd_device::scd_a12006_hint_register_w ) |
| 1779 | 1628 | { |
| 1780 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 1629 | |
| 1781 | 1630 | COMBINE_DATA(&segacd_hint_register); |
| 1782 | 1631 | } |
| 1783 | 1632 | |
| 1784 | 1633 | |
| 1785 | | static TIMER_CALLBACK( segacd_gfx_conversion_timer_callback ) |
| 1786 | | { |
| 1787 | | //printf("segacd_gfx_conversion_timer_callback\n"); |
| 1788 | 1634 | |
| 1789 | | CHECK_SCD_LV1_INTERRUPT |
| 1790 | 1635 | |
| 1791 | | segacd_conversion_active = 0; |
| 1792 | 1636 | |
| 1793 | | // this ends up as 0 after processing (soniccd bonus stage) |
| 1794 | | segacd_imagebuffer_vdot_size = 0; |
| 1795 | 1637 | |
| 1796 | | } |
| 1797 | | |
| 1798 | | |
| 1799 | | // the tiles in RAM are 8x8 tiles |
| 1800 | | // they are referenced in the cell look-up map as either 16x16 or 32x32 tiles (made of 4 / 16 8x8 tiles) |
| 1801 | | |
| 1802 | | #define SEGACD_BYTES_PER_TILE16 (128) |
| 1803 | | #define SEGACD_BYTES_PER_TILE32 (512) |
| 1804 | | |
| 1805 | | #define SEGACD_NUM_TILES16 (0x40000/SEGACD_BYTES_PER_TILE16) |
| 1806 | | #define SEGACD_NUM_TILES32 (0x40000/SEGACD_BYTES_PER_TILE32) |
| 1807 | | |
| 1808 | | /* |
| 1809 | | static const gfx_layout sega_8x8_layout = |
| 1638 | void sega_segacd_device::segacd_mark_tiles_dirty(running_machine& machine, int offset) |
| 1810 | 1639 | { |
| 1811 | | 8,8, |
| 1812 | | SEGACD_NUM_TILES16, |
| 1813 | | 4, |
| 1814 | | { 0,1,2,3 }, |
| 1815 | | { 8,12,0,4,24,28,16,20 }, |
| 1816 | | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, |
| 1817 | | 8*32 |
| 1818 | | }; |
| 1819 | | */ |
| 1820 | | |
| 1821 | | /* also create pre-rotated versions.. - it might still be possible to use these decodes with our own copying routines */ |
| 1822 | | |
| 1823 | | |
| 1824 | | #define _16x16_SEQUENCE_1 { 8,12,0,4,24,28,16,20, 512+8, 512+12, 512+0, 512+4, 512+24, 512+28, 512+16, 512+20 }, |
| 1825 | | #define _16x16_SEQUENCE_1_FLIP { 512+20,512+16,512+28,512+24,512+4,512+0, 512+12,512+8, 20,16,28,24,4,0,12,8 }, |
| 1826 | | |
| 1827 | | #define _16x16_SEQUENCE_2 { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, 8*32, 9*32,10*32,11*32,12*32,13*32,14*32,15*32 }, |
| 1828 | | #define _16x16_SEQUENCE_2_FLIP { 15*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32, 8*32, 7*32, 6*32, 5*32, 4*32, 3*32, 2*32, 1*32, 0*32 }, |
| 1829 | | |
| 1830 | | |
| 1831 | | #define _16x16_START \ |
| 1832 | | { \ |
| 1833 | | 16,16, \ |
| 1834 | | SEGACD_NUM_TILES16, \ |
| 1835 | | 4, \ |
| 1836 | | { 0,1,2,3 }, \ |
| 1837 | | |
| 1838 | | #define _16x16_END \ |
| 1839 | | 8*128 \ |
| 1840 | | }; \ |
| 1841 | | |
| 1842 | | #define _32x32_START \ |
| 1843 | | { \ |
| 1844 | | 32,32, \ |
| 1845 | | SEGACD_NUM_TILES32, \ |
| 1846 | | 4, \ |
| 1847 | | { 0,1,2,3 }, \ |
| 1848 | | |
| 1849 | | |
| 1850 | | #define _32x32_END \ |
| 1851 | | 8*512 \ |
| 1852 | | }; \ |
| 1853 | | |
| 1854 | | |
| 1855 | | |
| 1856 | | #define _32x32_SEQUENCE_1 \ |
| 1857 | | { 8,12,0,4,24,28,16,20, \ |
| 1858 | | 1024+8, 1024+12, 1024+0, 1024+4, 1024+24, 1024+28, 1024+16, 1024+20, \ |
| 1859 | | 2048+8, 2048+12, 2048+0, 2048+4, 2048+24, 2048+28, 2048+16, 2048+20, \ |
| 1860 | | 3072+8, 3072+12, 3072+0, 3072+4, 3072+24, 3072+28, 3072+16, 3072+20 \ |
| 1861 | | }, \ |
| 1862 | | |
| 1863 | | #define _32x32_SEQUENCE_1_FLIP \ |
| 1864 | | { 3072+20, 3072+16, 3072+28, 3072+24, 3072+4, 3072+0, 3072+12, 3072+8, \ |
| 1865 | | 2048+20, 2048+16, 2048+28, 2048+24, 2048+4, 2048+0, 2048+12, 2048+8, \ |
| 1866 | | 1024+20, 1024+16, 1024+28, 1024+24, 1024+4, 1024+0, 1024+12, 1024+8, \ |
| 1867 | | 20, 16, 28, 24, 4, 0, 12, 8}, \ |
| 1868 | | |
| 1869 | | |
| 1870 | | #define _32x32_SEQUENCE_2 \ |
| 1871 | | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, \ |
| 1872 | | 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32, \ |
| 1873 | | 16*32,17*32,18*32,19*32,20*32,21*32,22*32,23*32, \ |
| 1874 | | 24*32,25*32, 26*32, 27*32, 28*32, 29*32, 30*32, 31*32}, \ |
| 1875 | | |
| 1876 | | #define _32x32_SEQUENCE_2_FLIP \ |
| 1877 | | { 31*32, 30*32, 29*32, 28*32, 27*32, 26*32, 25*32, 24*32, \ |
| 1878 | | 23*32, 22*32, 21*32, 20*32, 19*32, 18*32, 17*32, 16*32, \ |
| 1879 | | 15*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32 , 8*32 , \ |
| 1880 | | 7*32 , 6*32 , 5*32 , 4*32 , 3*32 , 2*32 , 1*32 , 0*32}, \ |
| 1881 | | |
| 1882 | | |
| 1883 | | /* 16x16 decodes */ |
| 1884 | | static const gfx_layout sega_16x16_r00_f0_layout = |
| 1885 | | _16x16_START |
| 1886 | | _16x16_SEQUENCE_1 |
| 1887 | | _16x16_SEQUENCE_2 |
| 1888 | | _16x16_END |
| 1889 | | |
| 1890 | | static const gfx_layout sega_16x16_r01_f0_layout = |
| 1891 | | _16x16_START |
| 1892 | | _16x16_SEQUENCE_2 |
| 1893 | | _16x16_SEQUENCE_1_FLIP |
| 1894 | | _16x16_END |
| 1895 | | |
| 1896 | | static const gfx_layout sega_16x16_r10_f0_layout = |
| 1897 | | _16x16_START |
| 1898 | | _16x16_SEQUENCE_1_FLIP |
| 1899 | | _16x16_SEQUENCE_2_FLIP |
| 1900 | | _16x16_END |
| 1901 | | |
| 1902 | | static const gfx_layout sega_16x16_r11_f0_layout = |
| 1903 | | _16x16_START |
| 1904 | | _16x16_SEQUENCE_2_FLIP |
| 1905 | | _16x16_SEQUENCE_1 |
| 1906 | | _16x16_END |
| 1907 | | |
| 1908 | | static const gfx_layout sega_16x16_r00_f1_layout = |
| 1909 | | _16x16_START |
| 1910 | | _16x16_SEQUENCE_1_FLIP |
| 1911 | | _16x16_SEQUENCE_2 |
| 1912 | | _16x16_END |
| 1913 | | |
| 1914 | | static const gfx_layout sega_16x16_r01_f1_layout = |
| 1915 | | _16x16_START |
| 1916 | | _16x16_SEQUENCE_2 |
| 1917 | | _16x16_SEQUENCE_1 |
| 1918 | | _16x16_END |
| 1919 | | |
| 1920 | | static const gfx_layout sega_16x16_r10_f1_layout = |
| 1921 | | _16x16_START |
| 1922 | | _16x16_SEQUENCE_1 |
| 1923 | | _16x16_SEQUENCE_2_FLIP |
| 1924 | | _16x16_END |
| 1925 | | |
| 1926 | | static const gfx_layout sega_16x16_r11_f1_layout = |
| 1927 | | _16x16_START |
| 1928 | | _16x16_SEQUENCE_2_FLIP |
| 1929 | | _16x16_SEQUENCE_1_FLIP |
| 1930 | | _16x16_END |
| 1931 | | |
| 1932 | | /* 32x32 decodes */ |
| 1933 | | static const gfx_layout sega_32x32_r00_f0_layout = |
| 1934 | | _32x32_START |
| 1935 | | _32x32_SEQUENCE_1 |
| 1936 | | _32x32_SEQUENCE_2 |
| 1937 | | _32x32_END |
| 1938 | | |
| 1939 | | static const gfx_layout sega_32x32_r01_f0_layout = |
| 1940 | | _32x32_START |
| 1941 | | _32x32_SEQUENCE_2 |
| 1942 | | _32x32_SEQUENCE_1_FLIP |
| 1943 | | _32x32_END |
| 1944 | | |
| 1945 | | static const gfx_layout sega_32x32_r10_f0_layout = |
| 1946 | | _32x32_START |
| 1947 | | _32x32_SEQUENCE_1_FLIP |
| 1948 | | _32x32_SEQUENCE_2_FLIP |
| 1949 | | _32x32_END |
| 1950 | | |
| 1951 | | static const gfx_layout sega_32x32_r11_f0_layout = |
| 1952 | | _32x32_START |
| 1953 | | _32x32_SEQUENCE_2_FLIP |
| 1954 | | _32x32_SEQUENCE_1 |
| 1955 | | _32x32_END |
| 1956 | | |
| 1957 | | static const gfx_layout sega_32x32_r00_f1_layout = |
| 1958 | | _32x32_START |
| 1959 | | _32x32_SEQUENCE_1_FLIP |
| 1960 | | _32x32_SEQUENCE_2 |
| 1961 | | _32x32_END |
| 1962 | | |
| 1963 | | static const gfx_layout sega_32x32_r01_f1_layout = |
| 1964 | | _32x32_START |
| 1965 | | _32x32_SEQUENCE_2 |
| 1966 | | _32x32_SEQUENCE_1 |
| 1967 | | _32x32_END |
| 1968 | | |
| 1969 | | static const gfx_layout sega_32x32_r10_f1_layout = |
| 1970 | | _32x32_START |
| 1971 | | _32x32_SEQUENCE_1 |
| 1972 | | _32x32_SEQUENCE_2_FLIP |
| 1973 | | _32x32_END |
| 1974 | | |
| 1975 | | static const gfx_layout sega_32x32_r11_f1_layout = |
| 1976 | | _32x32_START |
| 1977 | | _32x32_SEQUENCE_2_FLIP |
| 1978 | | _32x32_SEQUENCE_1_FLIP |
| 1979 | | _32x32_END |
| 1980 | | |
| 1981 | | |
| 1982 | | static void segacd_mark_tiles_dirty(running_machine& machine, int offset) |
| 1983 | | { |
| 1984 | 1640 | machine.gfx[0]->mark_dirty((offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 1985 | 1641 | machine.gfx[1]->mark_dirty((offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| 1986 | 1642 | machine.gfx[2]->mark_dirty((offset*2)/(SEGACD_BYTES_PER_TILE16)); |
| r18275 | r18276 | |
| 2002 | 1658 | |
| 2003 | 1659 | |
| 2004 | 1660 | // mame specific.. map registers to which tilemap cache we use |
| 2005 | | static int segacd_get_active_stampmap_tilemap(void) |
| 1661 | int sega_segacd_device::segacd_get_active_stampmap_tilemap(void) |
| 2006 | 1662 | { |
| 2007 | 1663 | return (segacd_stampsize & 0x6)>>1; |
| 2008 | 1664 | } |
| 2009 | 1665 | |
| 2010 | | #if 0 |
| 2011 | | static void segacd_mark_stampmaps_dirty(void) |
| 2012 | | { |
| 2013 | | segacd_stampmap[segacd_get_active_stampmap_tilemap(->mark_all_dirty()]); |
| 2014 | 1666 | |
| 2015 | | //segacd_stampmap[0]->mark_all_dirty(); |
| 2016 | | //segacd_stampmap[1]->mark_all_dirty(); |
| 2017 | | //segacd_stampmap[2]->mark_all_dirty(); |
| 2018 | | //segacd_stampmap[3]->mark_all_dirty(); |
| 2019 | | } |
| 2020 | | #endif |
| 2021 | 1667 | |
| 2022 | | void SCD_GET_TILE_INFO_16x16_1x1( int& tile_region, int& tileno, int tile_index ) |
| 1668 | void sega_segacd_device::SCD_GET_TILE_INFO_16x16_1x1( int& tile_region, int& tileno, int tile_index ) |
| 2023 | 1669 | { |
| 2024 | 1670 | tile_region = 0; // 16x16 tiles |
| 2025 | 1671 | int tile_base = (segacd_stampmap_base_address & 0xff80) * 4; |
| r18275 | r18276 | |
| 2033 | 1679 | tile_region+=roll; |
| 2034 | 1680 | } |
| 2035 | 1681 | |
| 2036 | | void SCD_GET_TILE_INFO_32x32_1x1( int& tile_region, int& tileno, int tile_index ) |
| 1682 | void sega_segacd_device::SCD_GET_TILE_INFO_32x32_1x1( int& tile_region, int& tileno, int tile_index ) |
| 2037 | 1683 | { |
| 2038 | 1684 | tile_region = 8; // 32x32 tiles |
| 2039 | 1685 | int tile_base = (segacd_stampmap_base_address & 0xffe0) * 4; |
| r18275 | r18276 | |
| 2048 | 1694 | } |
| 2049 | 1695 | |
| 2050 | 1696 | |
| 2051 | | void SCD_GET_TILE_INFO_16x16_16x16( int& tile_region, int& tileno, int tile_index ) |
| 1697 | void sega_segacd_device::SCD_GET_TILE_INFO_16x16_16x16( int& tile_region, int& tileno, int tile_index ) |
| 2052 | 1698 | { |
| 2053 | 1699 | tile_region = 0; // 16x16 tiles |
| 2054 | 1700 | int tile_base = (0x8000) * 4; // fixed address in this mode |
| r18275 | r18276 | |
| 2063 | 1709 | } |
| 2064 | 1710 | |
| 2065 | 1711 | |
| 2066 | | void SCD_GET_TILE_INFO_32x32_16x16( int& tile_region, int& tileno, int tile_index ) |
| 1712 | void sega_segacd_device::SCD_GET_TILE_INFO_32x32_16x16( int& tile_region, int& tileno, int tile_index ) |
| 2067 | 1713 | { |
| 2068 | 1714 | tile_region = 8; // 32x32 tiles |
| 2069 | 1715 | int tile_base = (segacd_stampmap_base_address & 0xe000) * 4; |
| r18275 | r18276 | |
| 2081 | 1727 | |
| 2082 | 1728 | |
| 2083 | 1729 | |
| 2084 | | TILE_GET_INFO_MEMBER( md_base_state::get_stampmap_16x16_1x1_tile_info ) |
| 1730 | TILE_GET_INFO_MEMBER( sega_segacd_device::get_stampmap_16x16_1x1_tile_info ) |
| 2085 | 1731 | { |
| 2086 | 1732 | int tile_region, tileno; |
| 2087 | 1733 | SCD_GET_TILE_INFO_16x16_1x1(tile_region,tileno,(int)tile_index); |
| 2088 | 1734 | SET_TILE_INFO_MEMBER(tile_region, tileno, 0, 0); |
| 2089 | 1735 | } |
| 2090 | 1736 | |
| 2091 | | TILE_GET_INFO_MEMBER( md_base_state::get_stampmap_32x32_1x1_tile_info ) |
| 1737 | TILE_GET_INFO_MEMBER( sega_segacd_device::get_stampmap_32x32_1x1_tile_info ) |
| 2092 | 1738 | { |
| 2093 | 1739 | int tile_region, tileno; |
| 2094 | 1740 | SCD_GET_TILE_INFO_32x32_1x1(tile_region,tileno,(int)tile_index); |
| r18275 | r18276 | |
| 2096 | 1742 | } |
| 2097 | 1743 | |
| 2098 | 1744 | |
| 2099 | | TILE_GET_INFO_MEMBER( md_base_state::get_stampmap_16x16_16x16_tile_info ) |
| 1745 | TILE_GET_INFO_MEMBER( sega_segacd_device::get_stampmap_16x16_16x16_tile_info ) |
| 2100 | 1746 | { |
| 2101 | 1747 | int tile_region, tileno; |
| 2102 | 1748 | SCD_GET_TILE_INFO_16x16_16x16(tile_region,tileno,(int)tile_index); |
| 2103 | 1749 | SET_TILE_INFO_MEMBER(tile_region, tileno, 0, 0); |
| 2104 | 1750 | } |
| 2105 | 1751 | |
| 2106 | | TILE_GET_INFO_MEMBER( md_base_state::get_stampmap_32x32_16x16_tile_info ) |
| 1752 | TILE_GET_INFO_MEMBER( sega_segacd_device::get_stampmap_32x32_16x16_tile_info ) |
| 2107 | 1753 | { |
| 2108 | 1754 | int tile_region, tileno; |
| 2109 | 1755 | SCD_GET_TILE_INFO_32x32_16x16(tile_region,tileno,(int)tile_index); |
| r18275 | r18276 | |
| 2112 | 1758 | |
| 2113 | 1759 | // non-tilemap functions to get a pixel from a 'tilemap' based on the above, but looking up each pixel, as to avoid the heavy cache bitmap |
| 2114 | 1760 | |
| 2115 | | INLINE UINT8 get_stampmap_16x16_1x1_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 1761 | inline UINT8 sega_segacd_device::get_stampmap_16x16_1x1_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 2116 | 1762 | { |
| 2117 | 1763 | const int tilesize = 4; // 0xf pixels |
| 2118 | 1764 | const int tilemapsize = 0x0f; |
| r18275 | r18276 | |
| 2151 | 1797 | return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))]; |
| 2152 | 1798 | } |
| 2153 | 1799 | |
| 2154 | | INLINE UINT8 get_stampmap_32x32_1x1_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 1800 | inline UINT8 sega_segacd_device::get_stampmap_32x32_1x1_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 2155 | 1801 | { |
| 2156 | 1802 | const int tilesize = 5; // 0x1f pixels |
| 2157 | 1803 | const int tilemapsize = 0x07; |
| r18275 | r18276 | |
| 2190 | 1836 | return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))]; |
| 2191 | 1837 | } |
| 2192 | 1838 | |
| 2193 | | INLINE UINT8 get_stampmap_16x16_16x16_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 1839 | inline UINT8 sega_segacd_device::get_stampmap_16x16_16x16_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 2194 | 1840 | { |
| 2195 | 1841 | const int tilesize = 4; // 0xf pixels |
| 2196 | 1842 | const int tilemapsize = 0xff; |
| r18275 | r18276 | |
| 2229 | 1875 | return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))]; |
| 2230 | 1876 | } |
| 2231 | 1877 | |
| 2232 | | INLINE UINT8 get_stampmap_32x32_16x16_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 1878 | inline UINT8 sega_segacd_device::get_stampmap_32x32_16x16_tile_info_pixel(running_machine& machine, int xpos, int ypos) |
| 2233 | 1879 | { |
| 2234 | 1880 | const int tilesize = 5; // 0x1f pixels |
| 2235 | 1881 | const int tilemapsize = 0x7f; |
| r18275 | r18276 | |
| 2268 | 1914 | return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))]; |
| 2269 | 1915 | } |
| 2270 | 1916 | |
| 2271 | | static TIMER_CALLBACK( segacd_access_timer_callback ) |
| 2272 | | { |
| 2273 | | CheckCommand(machine); |
| 2274 | | } |
| 2275 | 1917 | |
| 2276 | | READ16_HANDLER( cdc_data_sub_r ) |
| 1918 | READ16_MEMBER( sega_segacd_device::cdc_data_sub_r ) |
| 2277 | 1919 | { |
| 2278 | 1920 | return CDC_Host_r(space.machine(), READ_SUB); |
| 2279 | 1921 | } |
| 2280 | 1922 | |
| 2281 | | READ16_HANDLER( cdc_data_main_r ) |
| 1923 | READ16_MEMBER( sega_segacd_device::cdc_data_main_r ) |
| 2282 | 1924 | { |
| 2283 | 1925 | return CDC_Host_r(space.machine(), READ_MAIN); |
| 2284 | 1926 | } |
| 2285 | 1927 | |
| 2286 | 1928 | |
| 2287 | 1929 | |
| 2288 | | WRITE16_HANDLER( segacd_stopwatch_timer_w ) |
| 1930 | WRITE16_MEMBER( sega_segacd_device::segacd_stopwatch_timer_w ) |
| 2289 | 1931 | { |
| 2290 | 1932 | if(data == 0) |
| 2291 | 1933 | stopwatch_timer->reset(); |
| r18275 | r18276 | |
| 2293 | 1935 | printf("Stopwatch timer %04x\n",data); |
| 2294 | 1936 | } |
| 2295 | 1937 | |
| 2296 | | READ16_HANDLER( segacd_stopwatch_timer_r ) |
| 1938 | READ16_MEMBER( sega_segacd_device::segacd_stopwatch_timer_r ) |
| 2297 | 1939 | { |
| 2298 | 1940 | INT32 result = (stopwatch_timer->time_elapsed() * ATTOSECONDS_TO_HZ(ATTOSECONDS_IN_USEC(30.72))).as_double(); |
| 2299 | 1941 | |
| r18275 | r18276 | |
| 2301 | 1943 | } |
| 2302 | 1944 | |
| 2303 | 1945 | |
| 2304 | | /* main CPU map set up in INIT */ |
| 2305 | | void segacd_init_main_cpu( running_machine& machine ) |
| 2306 | | { |
| 2307 | | address_space& space = machine.device("maincpu")->memory().space(AS_PROGRAM); |
| 2308 | | |
| 2309 | | segacd_font_bits = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:segacd_font")->ptr()); |
| 2310 | | segacd_backupram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:backupram")->ptr()); |
| 2311 | | segacd_dataram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:dataram")->ptr()); |
| 2312 | | segacd_dataram2 = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:dataram2")->ptr()); |
| 2313 | | segacd_4meg_prgram = reinterpret_cast<UINT16 *>(machine.root_device().memshare(":segacd:segacd_program")->ptr()); |
| 2314 | | |
| 2315 | | segacd_4meg_prgbank = 0; |
| 2316 | 1946 | |
| 2317 | 1947 | |
| 2318 | | space.unmap_readwrite (0x020000,0x3fffff); |
| 2319 | 1948 | |
| 2320 | | // space.install_read_bank(0x0020000, 0x003ffff, "scd_4m_prgbank"); |
| 2321 | | // space.machine().root_device().membank("scd_4m_prgbank")->set_base(segacd_4meg_prgram + segacd_4meg_prgbank * 0x20000 ); |
| 2322 | | space.install_legacy_read_handler (0x0020000, 0x003ffff, FUNC(scd_4m_prgbank_ram_r) ); |
| 2323 | | space.install_legacy_write_handler (0x0020000, 0x003ffff, FUNC(scd_4m_prgbank_ram_w) ); |
| 2324 | | segacd_wordram_mapped = 1; |
| 2325 | 1949 | |
| 2326 | 1950 | |
| 2327 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0x200000, 0x23ffff, FUNC(segacd_main_dataram_part1_r), FUNC(segacd_main_dataram_part1_w)); // RAM shared with sub |
| 2328 | | |
| 2329 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa12000, 0xa12001, FUNC(scd_a12000_halt_reset_r), FUNC(scd_a12000_halt_reset_w)); // sub-cpu control |
| 2330 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa12002, 0xa12003, FUNC(scd_a12002_memory_mode_r), FUNC(scd_a12002_memory_mode_w)); // memory mode / write protect |
| 2331 | | //space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa12004, 0xa12005, FUNC(segacd_cdc_mode_address_r), FUNC(segacd_cdc_mode_address_w)); |
| 2332 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa12006, 0xa12007, FUNC(scd_a12006_hint_register_r), FUNC(scd_a12006_hint_register_w)); // where HINT points on main CPU |
| 2333 | | //space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_read_handler (0xa12008, 0xa12009, FUNC(cdc_data_main_r)); |
| 2334 | | |
| 2335 | | |
| 2336 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa1200c, 0xa1200d, FUNC(segacd_stopwatch_timer_r), FUNC(segacd_stopwatch_timer_w)); // starblad |
| 2337 | | |
| 2338 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa1200e, 0xa1200f, FUNC(segacd_comms_flags_r), FUNC(segacd_comms_flags_maincpu_w)); // communication flags block |
| 2339 | | |
| 2340 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa12010, 0xa1201f, FUNC(segacd_comms_main_part1_r), FUNC(segacd_comms_main_part1_w)); |
| 2341 | | space.machine().device("maincpu")->memory().space(AS_PROGRAM).install_legacy_readwrite_handler(0xa12020, 0xa1202f, FUNC(segacd_comms_main_part2_r), FUNC(segacd_comms_main_part2_w)); |
| 2342 | | |
| 2343 | | |
| 2344 | | |
| 2345 | | machine.device(":segacd:segacd_68k")->execute().set_irq_acknowledge_callback(segacd_sub_int_callback); |
| 2346 | | |
| 2347 | | space.install_legacy_read_handler (0x0000070, 0x0000073, FUNC(scd_hint_vector_r) ); |
| 2348 | | |
| 2349 | | segacd_gfx_conversion_timer = machine.scheduler().timer_alloc(FUNC(segacd_gfx_conversion_timer_callback)); |
| 2350 | | segacd_gfx_conversion_timer->adjust(attotime::never); |
| 2351 | | |
| 2352 | | //segacd_dmna_ret_timer = machine.scheduler().timer_alloc(FUNC(segacd_dmna_ret_timer_callback)); |
| 2353 | | segacd_gfx_conversion_timer->adjust(attotime::never); |
| 2354 | | |
| 2355 | | segacd_hock_timer = machine.scheduler().timer_alloc(FUNC(segacd_access_timer_callback)); |
| 2356 | | // segacd_hock_timer->adjust( attotime::from_nsec(20000000), 0, attotime::from_nsec(20000000)); |
| 2357 | | segacd_hock_timer->adjust( attotime::from_hz(75),0, attotime::from_hz(75)); |
| 2358 | | |
| 2359 | | segacd_irq3_timer = machine.scheduler().timer_alloc(FUNC(segacd_irq3_timer_callback)); |
| 2360 | | segacd_irq3_timer->adjust(attotime::never); |
| 2361 | | |
| 2362 | | |
| 2363 | | |
| 2364 | | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 2365 | | machine.gfx[0] = auto_alloc(machine, gfx_element(machine, sega_16x16_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2366 | | machine.gfx[1] = auto_alloc(machine, gfx_element(machine, sega_16x16_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2367 | | machine.gfx[2] = auto_alloc(machine, gfx_element(machine, sega_16x16_r10_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2368 | | machine.gfx[3] = auto_alloc(machine, gfx_element(machine, sega_16x16_r11_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2369 | | machine.gfx[4] = auto_alloc(machine, gfx_element(machine, sega_16x16_r00_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2370 | | machine.gfx[5] = auto_alloc(machine, gfx_element(machine, sega_16x16_r11_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2371 | | machine.gfx[6] = auto_alloc(machine, gfx_element(machine, sega_16x16_r10_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2372 | | machine.gfx[7] = auto_alloc(machine, gfx_element(machine, sega_16x16_r01_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2373 | | |
| 2374 | | machine.gfx[8] = auto_alloc(machine, gfx_element(machine, sega_32x32_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2375 | | machine.gfx[9] = auto_alloc(machine, gfx_element(machine, sega_32x32_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2376 | | machine.gfx[10]= auto_alloc(machine, gfx_element(machine, sega_32x32_r10_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2377 | | machine.gfx[11]= auto_alloc(machine, gfx_element(machine, sega_32x32_r11_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2378 | | machine.gfx[12]= auto_alloc(machine, gfx_element(machine, sega_32x32_r00_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2379 | | machine.gfx[13]= auto_alloc(machine, gfx_element(machine, sega_32x32_r11_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2380 | | machine.gfx[14]= auto_alloc(machine, gfx_element(machine, sega_32x32_r10_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2381 | | machine.gfx[15]= auto_alloc(machine, gfx_element(machine, sega_32x32_r01_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2382 | | |
| 2383 | | md_base_state *state = machine.driver_data<md_base_state>(); |
| 2384 | | segacd_stampmap[0] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(md_base_state::get_stampmap_16x16_1x1_tile_info),state), TILEMAP_SCAN_ROWS, 16, 16, 16, 16); |
| 2385 | | segacd_stampmap[1] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(md_base_state::get_stampmap_32x32_1x1_tile_info),state), TILEMAP_SCAN_ROWS, 32, 32, 8, 8); |
| 2386 | | segacd_stampmap[2] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(md_base_state::get_stampmap_16x16_16x16_tile_info),state), TILEMAP_SCAN_ROWS, 16, 16, 256, 256); // 128kb! |
| 2387 | | segacd_stampmap[3] = &machine.tilemap().create(tilemap_get_info_delegate(FUNC(md_base_state::get_stampmap_32x32_16x16_tile_info),state), TILEMAP_SCAN_ROWS, 32, 32, 128, 128); // 32kb! |
| 2388 | | } |
| 2389 | | |
| 2390 | | |
| 2391 | | |
| 2392 | | |
| 2393 | | TIMER_DEVICE_CALLBACK( scd_dma_timer_callback ) |
| 1951 | READ16_MEMBER( sega_segacd_device::segacd_sub_led_ready_r ) |
| 2394 | 1952 | { |
| 2395 | | // todo: accurate timing of this! |
| 2396 | | |
| 2397 | | #define RATE 256 |
| 2398 | | if (sega_cd_connected) |
| 2399 | | CDC_Do_DMA(timer.machine(), RATE); |
| 2400 | | |
| 2401 | | // timed reset of flags |
| 2402 | | scd_mode_dmna_ret_flags |= 0x0021; |
| 2403 | | |
| 2404 | | scd_dma_timer->adjust(attotime::from_hz(megadriv_framerate) / megadrive_total_scanlines); |
| 2405 | | } |
| 2406 | | |
| 2407 | | |
| 2408 | | MACHINE_RESET( segacd ) |
| 2409 | | { |
| 2410 | | _segacd_68k_cpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 2411 | | _segacd_68k_cpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); |
| 2412 | | |
| 2413 | | segacd_hint_register = 0xffff; // -1 |
| 2414 | | |
| 2415 | | /* init cd-rom device */ |
| 2416 | | |
| 2417 | | lc89510_Reset(); |
| 2418 | | |
| 2419 | | { |
| 2420 | | cdrom_image_device *device = machine.device<cdrom_image_device>("cdrom"); |
| 2421 | | if ( device ) |
| 2422 | | { |
| 2423 | | segacd.cd = device->get_cdrom_file(); |
| 2424 | | if ( segacd.cd ) |
| 2425 | | { |
| 2426 | | segacd.toc = cdrom_get_toc( segacd.cd ); |
| 2427 | | cdda_set_cdrom( machine.device(":segacd:cdda"), segacd.cd ); |
| 2428 | | cdda_stop_audio( machine.device( ":segacd:cdda" ) ); //stop any pending CD-DA |
| 2429 | | } |
| 2430 | | } |
| 2431 | | } |
| 2432 | | |
| 2433 | | |
| 2434 | | if (segacd.cd) |
| 2435 | | printf("cd found\n"); |
| 2436 | | |
| 2437 | | scd_rammode = 0; |
| 2438 | | scd_mode_dmna_ret_flags = 0x5421; |
| 2439 | | |
| 2440 | | |
| 2441 | | hock_cmd = 0; |
| 2442 | | stopwatch_timer = machine.device<timer_device>(":segacd:sw_timer"); |
| 2443 | | |
| 2444 | | scd_dma_timer->adjust(attotime::zero); |
| 2445 | | |
| 2446 | | |
| 2447 | | // HACK!!!! timegal, anettfut, roadaven end up with the SubCPU waiting in a loop for *something* |
| 2448 | | // overclocking the CPU, even at the point where the game is hung, allows them to continue and boot |
| 2449 | | // I'm not sure what the source of this timing problem is, it's not using IRQ3 or StopWatch at the |
| 2450 | | // time. Changing the CDHock timer to 50hz from 75hz also stops the hang, but then the video is |
| 2451 | | // too slow and has bad sound. -- Investigate! |
| 2452 | | |
| 2453 | | _segacd_68k_cpu->set_clock_scale(1.5000f); |
| 2454 | | |
| 2455 | | } |
| 2456 | | |
| 2457 | | |
| 2458 | | static int segacd_redled = 0; |
| 2459 | | static int segacd_greenled = 0; |
| 2460 | | static int segacd_ready = 1; // actually set 100ms after startup? |
| 2461 | | |
| 2462 | | static READ16_HANDLER( segacd_sub_led_ready_r ) |
| 2463 | | { |
| 2464 | 1953 | UINT16 retdata = 0x0000; |
| 2465 | 1954 | |
| 2466 | 1955 | if (ACCESSING_BITS_0_7) |
| r18275 | r18276 | |
| 2477 | 1966 | return retdata; |
| 2478 | 1967 | } |
| 2479 | 1968 | |
| 2480 | | static WRITE16_HANDLER( segacd_sub_led_ready_w ) |
| 1969 | WRITE16_MEMBER( sega_segacd_device::segacd_sub_led_ready_w ) |
| 2481 | 1970 | { |
| 2482 | 1971 | if (ACCESSING_BITS_0_7) |
| 2483 | 1972 | { |
| r18275 | r18276 | |
| 2501 | 1990 | |
| 2502 | 1991 | |
| 2503 | 1992 | |
| 2504 | | static READ16_HANDLER( segacd_sub_dataram_part1_r ) |
| 1993 | READ16_MEMBER( sega_segacd_device::segacd_sub_dataram_part1_r ) |
| 2505 | 1994 | { |
| 2506 | 1995 | if ((scd_rammode&2)==RAM_MODE_2MEG) |
| 2507 | 1996 | { |
| r18275 | r18276 | |
| 2543 | 2032 | return 0x0000; |
| 2544 | 2033 | } |
| 2545 | 2034 | |
| 2546 | | static WRITE16_HANDLER( segacd_sub_dataram_part1_w ) |
| 2035 | WRITE16_MEMBER( sega_segacd_device::segacd_sub_dataram_part1_w ) |
| 2547 | 2036 | { |
| 2548 | 2037 | if ((scd_rammode&2)==RAM_MODE_2MEG) |
| 2549 | 2038 | { |
| r18275 | r18276 | |
| 2589 | 2078 | } |
| 2590 | 2079 | } |
| 2591 | 2080 | |
| 2592 | | static READ16_HANDLER( segacd_sub_dataram_part2_r ) |
| 2081 | READ16_MEMBER( sega_segacd_device::segacd_sub_dataram_part2_r ) |
| 2593 | 2082 | { |
| 2594 | 2083 | if ((scd_rammode&2)==RAM_MODE_2MEG) |
| 2595 | 2084 | { |
| r18275 | r18276 | |
| 2614 | 2103 | return 0x0000; |
| 2615 | 2104 | } |
| 2616 | 2105 | |
| 2617 | | static WRITE16_HANDLER( segacd_sub_dataram_part2_w ) |
| 2106 | WRITE16_MEMBER( sega_segacd_device::segacd_sub_dataram_part2_w ) |
| 2618 | 2107 | { |
| 2619 | 2108 | if ((scd_rammode&2)==RAM_MODE_2MEG) |
| 2620 | 2109 | { |
| r18275 | r18276 | |
| 2638 | 2127 | |
| 2639 | 2128 | |
| 2640 | 2129 | |
| 2641 | | static READ16_HANDLER( segacd_irq_mask_r ) |
| 2130 | READ16_MEMBER( sega_segacd_device::segacd_irq_mask_r ) |
| 2642 | 2131 | { |
| 2643 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 2132 | |
| 2644 | 2133 | return segacd_irq_mask; |
| 2645 | 2134 | } |
| 2646 | 2135 | |
| 2647 | | static WRITE16_HANDLER( segacd_irq_mask_w ) |
| 2136 | WRITE16_MEMBER( sega_segacd_device::segacd_irq_mask_w ) |
| 2648 | 2137 | { |
| 2649 | 2138 | if (ACCESSING_BITS_0_7) |
| 2650 | 2139 | { |
| 2651 | 2140 | UINT16 control = CDD_CONTROL; |
| 2652 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 2141 | |
| 2653 | 2142 | // printf("segacd_irq_mask_w %04x %04x (CDD control is %04x)\n",data, mem_mask, control); |
| 2654 | 2143 | |
| 2655 | 2144 | if (data & 0x10) |
| r18275 | r18276 | |
| 2675 | 2164 | } |
| 2676 | 2165 | } |
| 2677 | 2166 | |
| 2678 | | static READ16_HANDLER( segacd_cdd_ctrl_r ) |
| 2167 | READ16_MEMBER( sega_segacd_device::segacd_cdd_ctrl_r ) |
| 2679 | 2168 | { |
| 2680 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 2169 | |
| 2681 | 2170 | return CDD_CONTROL; |
| 2682 | 2171 | } |
| 2683 | 2172 | |
| 2684 | 2173 | |
| 2685 | | static WRITE16_HANDLER( segacd_cdd_ctrl_w ) |
| 2174 | WRITE16_MEMBER( sega_segacd_device::segacd_cdd_ctrl_w ) |
| 2686 | 2175 | { |
| 2687 | 2176 | if (ACCESSING_BITS_0_7) |
| 2688 | 2177 | { |
| 2689 | 2178 | UINT16 control = CDD_CONTROL; |
| 2690 | | if (SEGACD_FORCE_SYNCS) space.machine().scheduler().synchronize(); |
| 2179 | |
| 2691 | 2180 | |
| 2692 | 2181 | //printf("segacd_cdd_ctrl_w %04x %04x (control %04x irq %04x\n", data, mem_mask, control, segacd_irq_mask); |
| 2693 | 2182 | |
| r18275 | r18276 | |
| 2714 | 2203 | |
| 2715 | 2204 | |
| 2716 | 2205 | |
| 2717 | | static READ8_HANDLER( segacd_cdd_rx_r ) |
| 2206 | READ8_MEMBER( sega_segacd_device::segacd_cdd_rx_r ) |
| 2718 | 2207 | { |
| 2719 | 2208 | return CDD_RX[offset^1]; |
| 2720 | 2209 | } |
| 2721 | 2210 | |
| 2722 | | static WRITE8_HANDLER( segacd_cdd_tx_w ) |
| 2211 | WRITE8_MEMBER( sega_segacd_device::segacd_cdd_tx_w ) |
| 2723 | 2212 | { |
| 2724 | 2213 | CDD_TX[offset^1] = data; |
| 2725 | 2214 | |
| r18275 | r18276 | |
| 2731 | 2220 | |
| 2732 | 2221 | |
| 2733 | 2222 | |
| 2734 | | static READ16_HANDLER( segacd_stampsize_r ) |
| 2223 | READ16_MEMBER( sega_segacd_device::segacd_stampsize_r ) |
| 2735 | 2224 | { |
| 2736 | 2225 | UINT16 retdata = 0x0000; |
| 2737 | 2226 | |
| r18275 | r18276 | |
| 2743 | 2232 | |
| 2744 | 2233 | } |
| 2745 | 2234 | |
| 2746 | | static WRITE16_HANDLER( segacd_stampsize_w ) |
| 2235 | WRITE16_MEMBER( sega_segacd_device::segacd_stampsize_w ) |
| 2747 | 2236 | { |
| 2748 | 2237 | //printf("segacd_stampsize_w %04x %04x\n",data, mem_mask); |
| 2749 | 2238 | if (ACCESSING_BITS_0_7) |
| r18275 | r18276 | |
| 2773 | 2262 | // the lower 3 bits of segacd_imagebuffer_hdot_size are set |
| 2774 | 2263 | |
| 2775 | 2264 | // this really needs to be doing it's own lookups rather than depending on the inefficient MAME cache.. |
| 2776 | | INLINE UINT8 read_pixel_from_stampmap( running_machine& machine, bitmap_ind16* srcbitmap, int x, int y) |
| 2265 | inline UINT8 sega_segacd_device::read_pixel_from_stampmap( running_machine& machine, bitmap_ind16* srcbitmap, int x, int y) |
| 2777 | 2266 | { |
| 2778 | 2267 | /* |
| 2779 | 2268 | if (!srcbitmap) |
| r18275 | r18276 | |
| 2805 | 2294 | |
| 2806 | 2295 | |
| 2807 | 2296 | // this triggers the conversion operation, which will cause an IRQ1 when finished |
| 2808 | | WRITE16_HANDLER( segacd_trace_vector_base_address_w ) |
| 2297 | WRITE16_MEMBER( sega_segacd_device::segacd_trace_vector_base_address_w ) |
| 2809 | 2298 | { |
| 2810 | 2299 | if ((scd_rammode&2)==RAM_MODE_1MEG) |
| 2811 | 2300 | { |
| r18275 | r18276 | |
| 2891 | 2380 | } |
| 2892 | 2381 | |
| 2893 | 2382 | // actually just the low 8 bits? |
| 2894 | | READ16_HANDLER( segacd_imagebuffer_vdot_size_r ) |
| 2383 | READ16_MEMBER( sega_segacd_device::segacd_imagebuffer_vdot_size_r ) |
| 2895 | 2384 | { |
| 2896 | 2385 | return segacd_imagebuffer_vdot_size; |
| 2897 | 2386 | } |
| 2898 | 2387 | |
| 2899 | | WRITE16_HANDLER( segacd_imagebuffer_vdot_size_w ) |
| 2388 | WRITE16_MEMBER( sega_segacd_device::segacd_imagebuffer_vdot_size_w ) |
| 2900 | 2389 | { |
| 2901 | 2390 | //printf("segacd_imagebuffer_vdot_size_w %04x %04x\n",data,mem_mask); |
| 2902 | 2391 | COMBINE_DATA(&segacd_imagebuffer_vdot_size); |
| r18275 | r18276 | |
| 2904 | 2393 | |
| 2905 | 2394 | |
| 2906 | 2395 | // basically the 'tilemap' base address, for the 16x16 / 32x32 source tiles |
| 2907 | | static READ16_HANDLER( segacd_stampmap_base_address_r ) |
| 2396 | READ16_MEMBER( sega_segacd_device::segacd_stampmap_base_address_r ) |
| 2908 | 2397 | { |
| 2909 | 2398 | // different bits are valid in different modes, but I'm guessing the register |
| 2910 | 2399 | // always returns all the bits set, even if they're not used? |
| r18275 | r18276 | |
| 2912 | 2401 | |
| 2913 | 2402 | } |
| 2914 | 2403 | |
| 2915 | | static WRITE16_HANDLER( segacd_stampmap_base_address_w ) |
| 2404 | WRITE16_MEMBER( sega_segacd_device::segacd_stampmap_base_address_w ) |
| 2916 | 2405 | { // WORD ACCESS |
| 2917 | 2406 | |
| 2918 | 2407 | // low 3 bitsa aren't used, are they stored? |
| r18275 | r18276 | |
| 2920 | 2409 | } |
| 2921 | 2410 | |
| 2922 | 2411 | // destination for 'rendering' the section of the tilemap(stampmap) requested |
| 2923 | | static READ16_HANDLER( segacd_imagebuffer_start_address_r ) |
| 2412 | READ16_MEMBER( sega_segacd_device::segacd_imagebuffer_start_address_r ) |
| 2924 | 2413 | { |
| 2925 | 2414 | return segacd_imagebuffer_start_address; |
| 2926 | 2415 | } |
| 2927 | 2416 | |
| 2928 | | static WRITE16_HANDLER( segacd_imagebuffer_start_address_w ) |
| 2417 | WRITE16_MEMBER( sega_segacd_device::segacd_imagebuffer_start_address_w ) |
| 2929 | 2418 | { |
| 2930 | 2419 | COMBINE_DATA(&segacd_imagebuffer_start_address); |
| 2931 | 2420 | |
| r18275 | r18276 | |
| 2933 | 2422 | //printf("segacd_imagebuffer_start_address_w %04x %04x (actual base = %06x)\n", data, segacd_imagebuffer_start_address, base); |
| 2934 | 2423 | } |
| 2935 | 2424 | |
| 2936 | | static READ16_HANDLER( segacd_imagebuffer_offset_r ) |
| 2425 | READ16_MEMBER( sega_segacd_device::segacd_imagebuffer_offset_r ) |
| 2937 | 2426 | { |
| 2938 | 2427 | return segacd_imagebuffer_offset; |
| 2939 | 2428 | } |
| 2940 | 2429 | |
| 2941 | | static WRITE16_HANDLER( segacd_imagebuffer_offset_w ) |
| 2430 | WRITE16_MEMBER( sega_segacd_device::segacd_imagebuffer_offset_w ) |
| 2942 | 2431 | { |
| 2943 | 2432 | COMBINE_DATA(&segacd_imagebuffer_offset); |
| 2944 | 2433 | // printf("segacd_imagebuffer_offset_w %04x\n", segacd_imagebuffer_offset); |
| 2945 | 2434 | } |
| 2946 | 2435 | |
| 2947 | | static READ16_HANDLER( segacd_imagebuffer_vcell_size_r ) |
| 2436 | READ16_MEMBER( sega_segacd_device::segacd_imagebuffer_vcell_size_r ) |
| 2948 | 2437 | { |
| 2949 | 2438 | return segacd_imagebuffer_vcell_size; |
| 2950 | 2439 | } |
| 2951 | 2440 | |
| 2952 | | static WRITE16_HANDLER( segacd_imagebuffer_vcell_size_w ) |
| 2441 | WRITE16_MEMBER( sega_segacd_device::segacd_imagebuffer_vcell_size_w ) |
| 2953 | 2442 | { |
| 2954 | 2443 | COMBINE_DATA(&segacd_imagebuffer_vcell_size); |
| 2955 | 2444 | } |
| 2956 | 2445 | |
| 2957 | 2446 | |
| 2958 | | static READ16_HANDLER( segacd_imagebuffer_hdot_size_r ) |
| 2447 | READ16_MEMBER( sega_segacd_device::segacd_imagebuffer_hdot_size_r ) |
| 2959 | 2448 | { |
| 2960 | 2449 | return segacd_imagebuffer_hdot_size; |
| 2961 | 2450 | } |
| 2962 | 2451 | |
| 2963 | | static WRITE16_HANDLER( segacd_imagebuffer_hdot_size_w ) |
| 2452 | WRITE16_MEMBER( sega_segacd_device::segacd_imagebuffer_hdot_size_w ) |
| 2964 | 2453 | { |
| 2965 | 2454 | COMBINE_DATA(&segacd_imagebuffer_hdot_size); |
| 2966 | 2455 | } |
| 2967 | 2456 | |
| 2968 | | static UINT16 segacd_irq3_timer_reg; |
| 2969 | 2457 | |
| 2970 | | static READ16_HANDLER( segacd_irq3timer_r ) |
| 2458 | |
| 2459 | READ16_MEMBER( sega_segacd_device::segacd_irq3timer_r ) |
| 2971 | 2460 | { |
| 2972 | 2461 | return segacd_irq3_timer_reg; // always returns value written, not current counter! |
| 2973 | 2462 | } |
| 2974 | 2463 | |
| 2975 | | #define SEGACD_IRQ3_TIMER_SPEED (attotime::from_nsec(segacd_irq3_timer_reg*30720)) |
| 2976 | 2464 | |
| 2977 | | static WRITE16_HANDLER( segacd_irq3timer_w ) |
| 2465 | WRITE16_MEMBER( sega_segacd_device::segacd_irq3timer_w ) |
| 2978 | 2466 | { |
| 2979 | 2467 | if (ACCESSING_BITS_0_7) |
| 2980 | 2468 | { |
| r18275 | r18276 | |
| 2993 | 2481 | |
| 2994 | 2482 | |
| 2995 | 2483 | |
| 2996 | | static TIMER_CALLBACK( segacd_irq3_timer_callback ) |
| 2997 | | { |
| 2998 | | CHECK_SCD_LV3_INTERRUPT |
| 2999 | 2484 | |
| 3000 | | segacd_irq3_timer->adjust(SEGACD_IRQ3_TIMER_SPEED); |
| 3001 | | } |
| 3002 | 2485 | |
| 3003 | 2486 | |
| 3004 | | |
| 3005 | | READ16_HANDLER( cdc_dmaaddr_r ) |
| 2487 | READ16_MEMBER( sega_segacd_device::cdc_dmaaddr_r ) |
| 3006 | 2488 | { |
| 3007 | 2489 | return CDC_DMA_ADDR; |
| 3008 | 2490 | } |
| 3009 | 2491 | |
| 3010 | | WRITE16_HANDLER( cdc_dmaaddr_w ) |
| 2492 | WRITE16_MEMBER( sega_segacd_device::cdc_dmaaddr_w ) |
| 3011 | 2493 | { |
| 3012 | 2494 | COMBINE_DATA(&CDC_DMA_ADDR); |
| 3013 | 2495 | } |
| 3014 | 2496 | |
| 3015 | | READ16_HANDLER( segacd_cdfader_r ) |
| 2497 | READ16_MEMBER( sega_segacd_device::segacd_cdfader_r ) |
| 3016 | 2498 | { |
| 3017 | 2499 | return 0; |
| 3018 | 2500 | } |
| 3019 | 2501 | |
| 3020 | | WRITE16_HANDLER( segacd_cdfader_w ) |
| 2502 | WRITE16_MEMBER( sega_segacd_device::segacd_cdfader_w ) |
| 3021 | 2503 | { |
| 3022 | 2504 | static double cdfader_vol; |
| 3023 | 2505 | if(data & 0x800f) |
| r18275 | r18276 | |
| 3035 | 2517 | cdda_set_volume(space.machine().device(":segacd:cdda"), cdfader_vol); |
| 3036 | 2518 | } |
| 3037 | 2519 | |
| 3038 | | READ16_HANDLER( segacd_backupram_r ) |
| 2520 | READ16_MEMBER( sega_segacd_device::segacd_backupram_r ) |
| 3039 | 2521 | { |
| 3040 | 2522 | if(ACCESSING_BITS_8_15 && !(space.debugger_access())) |
| 3041 | 2523 | printf("Warning: read to backupram even bytes! [%04x]\n",offset); |
| r18275 | r18276 | |
| 3043 | 2525 | return segacd_backupram[offset] & 0xff; |
| 3044 | 2526 | } |
| 3045 | 2527 | |
| 3046 | | WRITE16_HANDLER( segacd_backupram_w ) |
| 2528 | WRITE16_MEMBER( sega_segacd_device::segacd_backupram_w ) |
| 3047 | 2529 | { |
| 3048 | 2530 | if(ACCESSING_BITS_0_7) |
| 3049 | 2531 | segacd_backupram[offset] = data; |
| r18275 | r18276 | |
| 3052 | 2534 | printf("Warning: write to backupram even bytes! [%04x] %02x\n",offset,data); |
| 3053 | 2535 | } |
| 3054 | 2536 | |
| 3055 | | READ16_HANDLER( segacd_font_color_r ) |
| 2537 | READ16_MEMBER( sega_segacd_device::segacd_font_color_r ) |
| 3056 | 2538 | { |
| 3057 | 2539 | return segacd_font_color; |
| 3058 | 2540 | } |
| 3059 | 2541 | |
| 3060 | | WRITE16_HANDLER( segacd_font_color_w ) |
| 2542 | WRITE16_MEMBER( sega_segacd_device::segacd_font_color_w ) |
| 3061 | 2543 | { |
| 3062 | 2544 | if (ACCESSING_BITS_0_7) |
| 3063 | 2545 | { |
| r18275 | r18276 | |
| 3065 | 2547 | } |
| 3066 | 2548 | } |
| 3067 | 2549 | |
| 3068 | | READ16_HANDLER( segacd_font_converted_r ) |
| 2550 | READ16_MEMBER( sega_segacd_device::segacd_font_converted_r ) |
| 3069 | 2551 | { |
| 3070 | 2552 | int scbg = (segacd_font_color & 0x0f); |
| 3071 | 2553 | int scfg = (segacd_font_color & 0xf0)>>4; |
| r18275 | r18276 | |
| 3083 | 2565 | return retdata; |
| 3084 | 2566 | } |
| 3085 | 2567 | |
| 3086 | | ADDRESS_MAP_START( segacd_map, AS_PROGRAM, 16, driver_device ) |
| 3087 | | AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_SHARE("segacd_program") |
| 3088 | 2568 | |
| 3089 | | AM_RANGE(0x080000, 0x0bffff) AM_READWRITE_LEGACY(segacd_sub_dataram_part1_r, segacd_sub_dataram_part1_w) AM_SHARE("dataram") |
| 3090 | | AM_RANGE(0x0c0000, 0x0dffff) AM_READWRITE_LEGACY(segacd_sub_dataram_part2_r, segacd_sub_dataram_part2_w) AM_SHARE("dataram2") |
| 3091 | 2569 | |
| 3092 | | AM_RANGE(0xfe0000, 0xfe3fff) AM_READWRITE_LEGACY(segacd_backupram_r,segacd_backupram_w) AM_SHARE("backupram") // backup RAM, odd bytes only! |
| 3093 | 2570 | |
| 3094 | | AM_RANGE(0xff0000, 0xff001f) AM_DEVWRITE8_LEGACY("rfsnd", rf5c68_w, 0x00ff) // PCM, RF5C164 |
| 3095 | | AM_RANGE(0xff0020, 0xff003f) AM_DEVREAD8_LEGACY("rfsnd", rf5c68_r, 0x00ff) |
| 3096 | | AM_RANGE(0xff2000, 0xff3fff) AM_DEVREADWRITE8_LEGACY("rfsnd", rf5c68_mem_r, rf5c68_mem_w,0x00ff) // PCM, RF5C164 |
| 3097 | 2571 | |
| 2572 | void sega_segacd_device::device_start() |
| 2573 | { |
| 3098 | 2574 | |
| 3099 | | AM_RANGE(0xff8000 ,0xff8001) AM_READWRITE_LEGACY(segacd_sub_led_ready_r, segacd_sub_led_ready_w) |
| 3100 | | AM_RANGE(0xff8002 ,0xff8003) AM_READWRITE_LEGACY(segacd_sub_memory_mode_r, segacd_sub_memory_mode_w) |
| 2575 | _segacd_68k_cpu = machine().device<cpu_device>(":segacd:segacd_68k"); |
| 2576 | sega_cd_connected = 1; |
| 3101 | 2577 | |
| 3102 | | AM_RANGE(0xff8004 ,0xff8005) AM_READWRITE_LEGACY(segacd_cdc_mode_address_r, segacd_cdc_mode_address_w) |
| 3103 | | AM_RANGE(0xff8006 ,0xff8007) AM_READWRITE_LEGACY(segacd_cdc_data_r, segacd_cdc_data_w) |
| 3104 | | AM_RANGE(0xff8008, 0xff8009) AM_READ_LEGACY(cdc_data_sub_r) |
| 3105 | | AM_RANGE(0xff800a, 0xff800b) AM_READWRITE_LEGACY(cdc_dmaaddr_r,cdc_dmaaddr_w) // CDC DMA Address |
| 3106 | | AM_RANGE(0xff800c, 0xff800d) AM_READWRITE_LEGACY(segacd_stopwatch_timer_r, segacd_stopwatch_timer_w)// Stopwatch timer |
| 3107 | | AM_RANGE(0xff800e ,0xff800f) AM_READWRITE_LEGACY(segacd_comms_flags_r, segacd_comms_flags_subcpu_w) |
| 3108 | | AM_RANGE(0xff8010 ,0xff801f) AM_READWRITE_LEGACY(segacd_comms_sub_part1_r, segacd_comms_sub_part1_w) |
| 3109 | | AM_RANGE(0xff8020 ,0xff802f) AM_READWRITE_LEGACY(segacd_comms_sub_part2_r, segacd_comms_sub_part2_w) |
| 3110 | | AM_RANGE(0xff8030, 0xff8031) AM_READWRITE_LEGACY(segacd_irq3timer_r, segacd_irq3timer_w) // Timer W/INT3 |
| 3111 | | AM_RANGE(0xff8032, 0xff8033) AM_READWRITE_LEGACY(segacd_irq_mask_r,segacd_irq_mask_w) |
| 3112 | | AM_RANGE(0xff8034, 0xff8035) AM_READWRITE_LEGACY(segacd_cdfader_r,segacd_cdfader_w) // CD Fader |
| 3113 | | AM_RANGE(0xff8036, 0xff8037) AM_READWRITE_LEGACY(segacd_cdd_ctrl_r,segacd_cdd_ctrl_w) |
| 3114 | | AM_RANGE(0xff8038, 0xff8041) AM_READ8_LEGACY(segacd_cdd_rx_r,0xffff) |
| 3115 | | AM_RANGE(0xff8042, 0xff804b) AM_WRITE8_LEGACY(segacd_cdd_tx_w,0xffff) |
| 3116 | | AM_RANGE(0xff804c, 0xff804d) AM_READWRITE_LEGACY(segacd_font_color_r, segacd_font_color_w) |
| 3117 | | AM_RANGE(0xff804e, 0xff804f) AM_RAM AM_SHARE("segacd_font") |
| 3118 | | AM_RANGE(0xff8050, 0xff8057) AM_READ_LEGACY(segacd_font_converted_r) |
| 3119 | | AM_RANGE(0xff8058, 0xff8059) AM_READWRITE_LEGACY(segacd_stampsize_r, segacd_stampsize_w) // Stamp size |
| 3120 | | AM_RANGE(0xff805a, 0xff805b) AM_READWRITE_LEGACY(segacd_stampmap_base_address_r, segacd_stampmap_base_address_w) // Stamp map base address |
| 3121 | | AM_RANGE(0xff805c, 0xff805d) AM_READWRITE_LEGACY(segacd_imagebuffer_vcell_size_r, segacd_imagebuffer_vcell_size_w)// Image buffer V cell size |
| 3122 | | AM_RANGE(0xff805e, 0xff805f) AM_READWRITE_LEGACY(segacd_imagebuffer_start_address_r, segacd_imagebuffer_start_address_w) // Image buffer start address |
| 3123 | | AM_RANGE(0xff8060, 0xff8061) AM_READWRITE_LEGACY(segacd_imagebuffer_offset_r, segacd_imagebuffer_offset_w) |
| 3124 | | AM_RANGE(0xff8062, 0xff8063) AM_READWRITE_LEGACY(segacd_imagebuffer_hdot_size_r, segacd_imagebuffer_hdot_size_w) // Image buffer H dot size |
| 3125 | | AM_RANGE(0xff8064, 0xff8065) AM_READWRITE_LEGACY(segacd_imagebuffer_vdot_size_r, segacd_imagebuffer_vdot_size_w ) // Image buffer V dot size |
| 3126 | | AM_RANGE(0xff8066, 0xff8067) AM_WRITE_LEGACY(segacd_trace_vector_base_address_w)// Trace vector base address |
| 3127 | | // AM_RANGE(0xff8068, 0xff8069) // Subcode address |
| 2578 | scd_dma_timer = machine().device<timer_device>(":segacd:scd_dma_timer"); |
| 2579 | segacd_gfx_conversion_timer = machine().device<timer_device>(":segacd:stamp_timer"); |
| 2580 | segacd_irq3_timer = machine().device<timer_device>(":segacd:irq3_timer"); |
| 3128 | 2581 | |
| 3129 | | // AM_RANGE(0xff8100, 0xff817f) // Subcode buffer area |
| 3130 | | // AM_RANGE(0xff8180, 0xff81ff) // mirror of subcode buffer area |
| 2582 | address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 2583 | |
| 2584 | segacd_font_bits = reinterpret_cast<UINT16 *>(machine().root_device().memshare(":segacd:segacd_font")->ptr()); |
| 2585 | segacd_backupram = reinterpret_cast<UINT16 *>(machine().root_device().memshare(":segacd:backupram")->ptr()); |
| 2586 | segacd_dataram = reinterpret_cast<UINT16 *>(machine().root_device().memshare(":segacd:dataram")->ptr()); |
| 2587 | // segacd_dataram2 = reinterpret_cast<UINT16 *>(machine().root_device().memshare(":segacd:dataram2")->ptr()); |
| 2588 | segacd_4meg_prgram = reinterpret_cast<UINT16 *>(machine().root_device().memshare(":segacd:segacd_program")->ptr()); |
| 2589 | |
| 2590 | segacd_4meg_prgbank = 0; |
| 3131 | 2591 | |
| 3132 | | ADDRESS_MAP_END |
| 3133 | 2592 | |
| 2593 | space.unmap_readwrite (0x020000,0x3fffff); |
| 3134 | 2594 | |
| 3135 | 2595 | |
| 2596 | space.install_read_handler (0x0020000, 0x003ffff, read16_delegate(FUNC(sega_segacd_device::scd_4m_prgbank_ram_r),this) ); |
| 2597 | space.install_write_handler (0x0020000, 0x003ffff, write16_delegate(FUNC(sega_segacd_device::scd_4m_prgbank_ram_w),this) ); |
| 3136 | 2598 | |
| 3137 | | void sega_segacd_device::device_start() |
| 3138 | | { |
| 3139 | 2599 | |
| 2600 | space.install_readwrite_handler(0x200000, 0x23ffff, read16_delegate(FUNC(sega_segacd_device::segacd_main_dataram_part1_r),this), write16_delegate(FUNC(sega_segacd_device::segacd_main_dataram_part1_w),this)); // RAM shared with sub |
| 2601 | space.install_readwrite_handler(0xa12000, 0xa12001, read16_delegate(FUNC(sega_segacd_device::scd_a12000_halt_reset_r),this), write16_delegate(FUNC(sega_segacd_device::scd_a12000_halt_reset_w),this)); // sub-cpu control |
| 2602 | space.install_readwrite_handler(0xa12002, 0xa12003, read16_delegate(FUNC(sega_segacd_device::scd_a12002_memory_mode_r),this), write16_delegate(FUNC(sega_segacd_device::scd_a12002_memory_mode_w),this)); // memory mode / write protect |
| 2603 | //space.install_readwrite_handler(0xa12004, 0xa12005, read16_delegate(FUNC(sega_segacd_device::segacd_cdc_mode_address_r),this), write16_delegate(FUNC(sega_segacd_device::segacd_cdc_mode_address_w),this)); |
| 2604 | space.install_readwrite_handler(0xa12006, 0xa12007, read16_delegate(FUNC(sega_segacd_device::scd_a12006_hint_register_r),this), write16_delegate(FUNC(sega_segacd_device::scd_a12006_hint_register_w),this)); // where HINT points on main CPU |
| 2605 | //space.install_read_handler (0xa12008, 0xa12009, read16_delegate(FUNC(sega_segacd_device::cdc_data_main_r),this)); |
| 2606 | |
| 2607 | |
| 2608 | space.install_readwrite_handler(0xa1200c, 0xa1200d, read16_delegate(FUNC(sega_segacd_device::segacd_stopwatch_timer_r),this), write16_delegate(FUNC(sega_segacd_device::segacd_stopwatch_timer_w),this)); // starblad |
| 2609 | |
| 2610 | space.install_readwrite_handler(0xa1200e, 0xa1200f, read16_delegate(FUNC(sega_segacd_device::segacd_comms_flags_r),this), write16_delegate(FUNC(sega_segacd_device::segacd_comms_flags_maincpu_w),this)); // communication flags block |
| 2611 | |
| 2612 | space.install_readwrite_handler(0xa12010, 0xa1201f, read16_delegate(FUNC(sega_segacd_device::segacd_comms_main_part1_r),this), write16_delegate(FUNC(sega_segacd_device::segacd_comms_main_part1_w),this)); |
| 2613 | space.install_readwrite_handler(0xa12020, 0xa1202f, read16_delegate(FUNC(sega_segacd_device::segacd_comms_main_part2_r),this), write16_delegate(FUNC(sega_segacd_device::segacd_comms_main_part2_w),this)); |
| 2614 | |
| 2615 | |
| 2616 | |
| 2617 | machine().device(":segacd:segacd_68k")->execute().set_irq_acknowledge_callback(segacd_sub_int_callback); |
| 2618 | |
| 2619 | space.install_read_handler (0x0000070, 0x0000073, read16_delegate(FUNC(sega_segacd_device::scd_hint_vector_r),this) ); |
| 2620 | |
| 2621 | |
| 2622 | |
| 2623 | |
| 2624 | |
| 2625 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 2626 | machine().gfx[0] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2627 | machine().gfx[1] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2628 | machine().gfx[2] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r10_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2629 | machine().gfx[3] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r11_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2630 | machine().gfx[4] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r00_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2631 | machine().gfx[5] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r11_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2632 | machine().gfx[6] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r10_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2633 | machine().gfx[7] = auto_alloc(machine(), gfx_element(machine(), sega_16x16_r01_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2634 | |
| 2635 | machine().gfx[8] = auto_alloc(machine(), gfx_element(machine(), sega_32x32_r00_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2636 | machine().gfx[9] = auto_alloc(machine(), gfx_element(machine(), sega_32x32_r01_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2637 | machine().gfx[10]= auto_alloc(machine(), gfx_element(machine(), sega_32x32_r10_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2638 | machine().gfx[11]= auto_alloc(machine(), gfx_element(machine(), sega_32x32_r11_f0_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2639 | machine().gfx[12]= auto_alloc(machine(), gfx_element(machine(), sega_32x32_r00_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2640 | machine().gfx[13]= auto_alloc(machine(), gfx_element(machine(), sega_32x32_r11_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2641 | machine().gfx[14]= auto_alloc(machine(), gfx_element(machine(), sega_32x32_r10_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2642 | machine().gfx[15]= auto_alloc(machine(), gfx_element(machine(), sega_32x32_r01_f1_layout, (UINT8 *)segacd_dataram, 0, 0)); |
| 2643 | |
| 2644 | segacd_stampmap[0] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(sega_segacd_device::get_stampmap_16x16_1x1_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 16, 16); |
| 2645 | segacd_stampmap[1] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(sega_segacd_device::get_stampmap_32x32_1x1_tile_info),this), TILEMAP_SCAN_ROWS, 32, 32, 8, 8); |
| 2646 | segacd_stampmap[2] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(sega_segacd_device::get_stampmap_16x16_16x16_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 256, 256); // 128kb! |
| 2647 | segacd_stampmap[3] = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(sega_segacd_device::get_stampmap_32x32_16x16_tile_info),this), TILEMAP_SCAN_ROWS, 32, 32, 128, 128); // 32kb! |
| 2648 | |
| 2649 | // todo register save state stuff |
| 3140 | 2650 | } |
| 3141 | 2651 | |
| 3142 | 2652 | void sega_segacd_device::device_reset() |
| 3143 | 2653 | { |
| 3144 | 2654 | |
| 2655 | _segacd_68k_cpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE); |
| 2656 | _segacd_68k_cpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); |
| 2657 | |
| 2658 | segacd_hint_register = 0xffff; // -1 |
| 2659 | |
| 2660 | /* init cd-rom device */ |
| 2661 | |
| 2662 | lc89510_Reset(); |
| 2663 | |
| 2664 | { |
| 2665 | cdrom_image_device *cddevice = machine().device<cdrom_image_device>("cdrom"); |
| 2666 | if ( cddevice ) |
| 2667 | { |
| 2668 | segacd.cd = cddevice->get_cdrom_file(); |
| 2669 | if ( segacd.cd ) |
| 2670 | { |
| 2671 | segacd.toc = cdrom_get_toc( segacd.cd ); |
| 2672 | cdda_set_cdrom( machine().device(":segacd:cdda"), segacd.cd ); |
| 2673 | cdda_stop_audio( machine().device( ":segacd:cdda" ) ); //stop any pending CD-DA |
| 2674 | } |
| 2675 | } |
| 2676 | } |
| 2677 | |
| 2678 | |
| 2679 | if (segacd.cd) |
| 2680 | printf("cd found\n"); |
| 2681 | |
| 2682 | scd_rammode = 0; |
| 2683 | scd_mode_dmna_ret_flags = 0x5421; |
| 2684 | |
| 2685 | |
| 2686 | stopwatch_timer = machine().device<timer_device>(":segacd:sw_timer"); |
| 2687 | |
| 2688 | scd_dma_timer->adjust(attotime::zero); |
| 2689 | |
| 2690 | |
| 2691 | // HACK!!!! timegal, anettfut, roadaven end up with the SubCPU waiting in a loop for *something* |
| 2692 | // overclocking the CPU, even at the point where the game is hung, allows them to continue and boot |
| 2693 | // I'm not sure what the source of this timing problem is, it's not using IRQ3 or StopWatch at the |
| 2694 | // time. Changing the CDHock timer to 50hz from 75hz also stops the hang, but then the video is |
| 2695 | // too slow and has bad sound. -- Investigate! |
| 2696 | |
| 2697 | _segacd_68k_cpu->set_clock_scale(1.5000f); |
| 2698 | |
| 2699 | |
| 2700 | // initialize some stuff on reset |
| 2701 | |
| 2702 | segacd_ram_writeprotect_bits = 0; |
| 2703 | segacd_4meg_prgbank = 0; |
| 2704 | segacd_memory_priority_mode = 0; |
| 2705 | segacd_stampsize = 0; |
| 2706 | |
| 2707 | segacd_imagebuffer_vdot_size = 0; |
| 2708 | segacd_imagebuffer_vcell_size = 0; |
| 2709 | segacd_imagebuffer_hdot_size = 0; |
| 2710 | |
| 2711 | segacd_conversion_active = 0; |
| 2712 | segacd_stampmap_base_address = 0; |
| 2713 | segacd_imagebuffer_start_address = 0; |
| 2714 | segacd_imagebuffer_offset = 0; |
| 2715 | |
| 2716 | segacd_comms_flags = 0x0000; |
| 2717 | |
| 2718 | segacd_redled = 0; |
| 2719 | segacd_greenled = 0; |
| 2720 | segacd_ready = 1; // actually set 100ms after startup? |
| 2721 | segacd_irq3_timer_reg = 0; |
| 2722 | |
| 2723 | segacd_gfx_conversion_timer->adjust(attotime::never); |
| 2724 | segacd_irq3_timer->adjust(attotime::never); |
| 2725 | |
| 3145 | 2726 | } |
| 3146 | 2727 | |
| 3147 | 2728 | |
trunk/src/mame/machine/megacd.h
| r18275 | r18276 | |
| 2 | 2 | |
| 3 | 3 | #include "machine/lc89510.h" |
| 4 | 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | #define READ_MAIN (0x0200) |
| 9 | #define READ_SUB (0x0300) |
| 10 | #define DMA_PCM (0x0400) |
| 11 | #define DMA_PRG (0x0500) |
| 12 | #define DMA_WRAM (0x0700) |
| 13 | |
| 14 | #define REG_W_SBOUT (0x0) |
| 15 | #define REG_W_IFCTRL (0x1) |
| 16 | #define REG_W_DBCL (0x2) |
| 17 | #define REG_W_DBCH (0x3) |
| 18 | #define REG_W_DACL (0x4) |
| 19 | #define REG_W_DACH (0x5) |
| 20 | #define REG_W_DTTRG (0x6) |
| 21 | #define REG_W_DTACK (0x7) |
| 22 | #define REG_W_WAL (0x8) |
| 23 | #define REG_W_WAH (0x9) |
| 24 | #define REG_W_CTRL0 (0xA) |
| 25 | #define REG_W_CTRL1 (0xB) |
| 26 | #define REG_W_PTL (0xC) |
| 27 | #define REG_W_PTH (0xD) |
| 28 | #define REG_W_CTRL2 (0xE) |
| 29 | #define REG_W_RESET (0xF) |
| 30 | |
| 31 | #define REG_R_COMIN (0x0) |
| 32 | #define REG_R_IFSTAT (0x1) |
| 33 | #define REG_R_DBCL (0x2) |
| 34 | #define REG_R_DBCH (0x3) |
| 35 | #define REG_R_HEAD0 (0x4) |
| 36 | #define REG_R_HEAD1 (0x5) |
| 37 | #define REG_R_HEAD2 (0x6) |
| 38 | #define REG_R_HEAD3 (0x7) |
| 39 | #define REG_R_PTL (0x8) |
| 40 | #define REG_R_PTH (0x9) |
| 41 | #define REG_R_WAL (0xa) |
| 42 | #define REG_R_WAH (0xb) |
| 43 | #define REG_R_STAT0 (0xc) |
| 44 | #define REG_R_STAT1 (0xd) |
| 45 | #define REG_R_STAT2 (0xe) |
| 46 | #define REG_R_STAT3 (0xf) |
| 47 | |
| 48 | #define CMD_STATUS (0x0) |
| 49 | #define CMD_STOPALL (0x1) |
| 50 | #define CMD_GETTOC (0x2) |
| 51 | #define CMD_READ (0x3) |
| 52 | #define CMD_SEEK (0x4) |
| 53 | // (0x5) |
| 54 | #define CMD_STOP (0x6) |
| 55 | #define CMD_RESUME (0x7) |
| 56 | #define CMD_FF (0x8) |
| 57 | #define CMD_RW (0x9) |
| 58 | #define CMD_INIT (0xa) |
| 59 | // (0xb) |
| 60 | #define CMD_CLOSE (0xc) |
| 61 | #define CMD_OPEN (0xd) |
| 62 | // (0xe) |
| 63 | // (0xf) |
| 64 | |
| 65 | |
| 66 | #define TOCCMD_CURPOS (0x0) |
| 67 | #define TOCCMD_TRKPOS (0x1) |
| 68 | #define TOCCMD_CURTRK (0x2) |
| 69 | #define TOCCMD_LENGTH (0x3) |
| 70 | #define TOCCMD_FIRSTLAST (0x4) |
| 71 | #define TOCCMD_TRACKADDR (0x5) |
| 72 | |
| 73 | struct segacd_t |
| 74 | { |
| 75 | cdrom_file *cd; |
| 76 | const cdrom_toc *toc; |
| 77 | UINT32 current_frame; |
| 78 | }; |
| 79 | |
| 80 | |
| 81 | |
| 82 | #define SECTOR_SIZE (2352) |
| 83 | |
| 84 | #define SET_CDD_DATA_MODE \ |
| 85 | CDD_CONTROL |= 0x0100; \ |
| 86 | |
| 87 | #define SET_CDD_AUDIO_MODE \ |
| 88 | CDD_CONTROL &= ~0x0100; \ |
| 89 | |
| 90 | #define STOP_CDC_READ \ |
| 91 | SCD_STATUS_CDC &= ~0x01; \ |
| 92 | |
| 93 | #define SET_CDC_READ \ |
| 94 | SCD_STATUS_CDC |= 0x01; \ |
| 95 | |
| 96 | #define SET_CDC_DMA \ |
| 97 | SCD_STATUS_CDC |= 0x08; \ |
| 98 | |
| 99 | #define STOP_CDC_DMA \ |
| 100 | SCD_STATUS_CDC &= ~0x08; \ |
| 101 | |
| 102 | #define SCD_READ_ENABLED \ |
| 103 | (SCD_STATUS_CDC & 1) |
| 104 | |
| 105 | #define SCD_DMA_ENABLED \ |
| 106 | (SCD_STATUS_CDC & 0x08) |
| 107 | |
| 108 | #define CLEAR_CDD_RESULT \ |
| 109 | CDD_MIN = CDD_SEC = CDD_FRAME = CDD_EXT = 0; \ |
| 110 | |
| 111 | #define CHECK_SCD_LV5_INTERRUPT \ |
| 112 | if (segacd_irq_mask & 0x20) \ |
| 113 | { \ |
| 114 | machine.device(":segacd:segacd_68k")->execute().set_input_line(5, HOLD_LINE); \ |
| 115 | } \ |
| 116 | |
| 117 | #define CHECK_SCD_LV4_INTERRUPT \ |
| 118 | if (segacd_irq_mask & 0x10) \ |
| 119 | { \ |
| 120 | machine.device(":segacd:segacd_68k")->execute().set_input_line(4, HOLD_LINE); \ |
| 121 | } \ |
| 122 | |
| 123 | |
| 124 | |
| 125 | // from master |
| 126 | #define CHECK_SCD_LV2_INTERRUPT \ |
| 127 | if (segacd_irq_mask & 0x04) \ |
| 128 | { \ |
| 129 | machine.device(":segacd:segacd_68k")->execute().set_input_line(2, HOLD_LINE); \ |
| 130 | } \ |
| 131 | |
| 132 | |
| 133 | // irq3 timer |
| 134 | #define CHECK_SCD_LV3_INTERRUPT \ |
| 135 | if (segacd_irq_mask & 0x08) \ |
| 136 | { \ |
| 137 | machine().device(":segacd:segacd_68k")->execute().set_input_line(3, HOLD_LINE); \ |
| 138 | } \ |
| 139 | |
| 140 | // gfx convert |
| 141 | #define CHECK_SCD_LV1_INTERRUPT \ |
| 142 | if (segacd_irq_mask & 0x02) \ |
| 143 | { \ |
| 144 | machine().device(":segacd:segacd_68k")->execute().set_input_line(1, HOLD_LINE); \ |
| 145 | } \ |
| 146 | |
| 147 | #define CURRENT_TRACK_IS_DATA \ |
| 148 | (segacd.toc->tracks[SCD_CURTRK - 1].trktype != CD_TRACK_AUDIO) \ |
| 149 | |
| 150 | |
| 151 | #define RAM_MODE_2MEG (0) |
| 152 | #define RAM_MODE_1MEG (2) |
| 153 | |
| 154 | |
| 155 | #define CDD_PLAYINGCDDA 0x0100 |
| 156 | #define CDD_READY 0x0400 |
| 157 | #define CDD_STOPPED 0x0900 |
| 158 | |
| 159 | #define SEGACD_IRQ3_TIMER_SPEED (attotime::from_nsec(segacd_irq3_timer_reg*30720)) |
| 160 | |
| 161 | |
| 162 | |
| 163 | // the tiles in RAM are 8x8 tiles |
| 164 | // they are referenced in the cell look-up map as either 16x16 or 32x32 tiles (made of 4 / 16 8x8 tiles) |
| 165 | |
| 166 | #define SEGACD_BYTES_PER_TILE16 (128) |
| 167 | #define SEGACD_BYTES_PER_TILE32 (512) |
| 168 | |
| 169 | #define SEGACD_NUM_TILES16 (0x40000/SEGACD_BYTES_PER_TILE16) |
| 170 | #define SEGACD_NUM_TILES32 (0x40000/SEGACD_BYTES_PER_TILE32) |
| 171 | |
| 172 | #define _16x16_SEQUENCE_1 { 8,12,0,4,24,28,16,20, 512+8, 512+12, 512+0, 512+4, 512+24, 512+28, 512+16, 512+20 }, |
| 173 | #define _16x16_SEQUENCE_1_FLIP { 512+20,512+16,512+28,512+24,512+4,512+0, 512+12,512+8, 20,16,28,24,4,0,12,8 }, |
| 174 | |
| 175 | #define _16x16_SEQUENCE_2 { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, 8*32, 9*32,10*32,11*32,12*32,13*32,14*32,15*32 }, |
| 176 | #define _16x16_SEQUENCE_2_FLIP { 15*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32, 8*32, 7*32, 6*32, 5*32, 4*32, 3*32, 2*32, 1*32, 0*32 }, |
| 177 | |
| 178 | |
| 179 | #define _16x16_START \ |
| 180 | { \ |
| 181 | 16,16, \ |
| 182 | SEGACD_NUM_TILES16, \ |
| 183 | 4, \ |
| 184 | { 0,1,2,3 }, \ |
| 185 | |
| 186 | #define _16x16_END \ |
| 187 | 8*128 \ |
| 188 | }; \ |
| 189 | |
| 190 | #define _32x32_START \ |
| 191 | { \ |
| 192 | 32,32, \ |
| 193 | SEGACD_NUM_TILES32, \ |
| 194 | 4, \ |
| 195 | { 0,1,2,3 }, \ |
| 196 | |
| 197 | |
| 198 | #define _32x32_END \ |
| 199 | 8*512 \ |
| 200 | }; \ |
| 201 | |
| 202 | |
| 203 | |
| 204 | #define _32x32_SEQUENCE_1 \ |
| 205 | { 8,12,0,4,24,28,16,20, \ |
| 206 | 1024+8, 1024+12, 1024+0, 1024+4, 1024+24, 1024+28, 1024+16, 1024+20, \ |
| 207 | 2048+8, 2048+12, 2048+0, 2048+4, 2048+24, 2048+28, 2048+16, 2048+20, \ |
| 208 | 3072+8, 3072+12, 3072+0, 3072+4, 3072+24, 3072+28, 3072+16, 3072+20 \ |
| 209 | }, \ |
| 210 | |
| 211 | #define _32x32_SEQUENCE_1_FLIP \ |
| 212 | { 3072+20, 3072+16, 3072+28, 3072+24, 3072+4, 3072+0, 3072+12, 3072+8, \ |
| 213 | 2048+20, 2048+16, 2048+28, 2048+24, 2048+4, 2048+0, 2048+12, 2048+8, \ |
| 214 | 1024+20, 1024+16, 1024+28, 1024+24, 1024+4, 1024+0, 1024+12, 1024+8, \ |
| 215 | 20, 16, 28, 24, 4, 0, 12, 8}, \ |
| 216 | |
| 217 | |
| 218 | #define _32x32_SEQUENCE_2 \ |
| 219 | { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, \ |
| 220 | 8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32, \ |
| 221 | 16*32,17*32,18*32,19*32,20*32,21*32,22*32,23*32, \ |
| 222 | 24*32,25*32, 26*32, 27*32, 28*32, 29*32, 30*32, 31*32}, \ |
| 223 | |
| 224 | #define _32x32_SEQUENCE_2_FLIP \ |
| 225 | { 31*32, 30*32, 29*32, 28*32, 27*32, 26*32, 25*32, 24*32, \ |
| 226 | 23*32, 22*32, 21*32, 20*32, 19*32, 18*32, 17*32, 16*32, \ |
| 227 | 15*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32 , 8*32 , \ |
| 228 | 7*32 , 6*32 , 5*32 , 4*32 , 3*32 , 2*32 , 1*32 , 0*32}, \ |
| 229 | |
| 230 | |
| 231 | /* 16x16 decodes */ |
| 232 | static const gfx_layout sega_16x16_r00_f0_layout = |
| 233 | _16x16_START |
| 234 | _16x16_SEQUENCE_1 |
| 235 | _16x16_SEQUENCE_2 |
| 236 | _16x16_END |
| 237 | |
| 238 | static const gfx_layout sega_16x16_r01_f0_layout = |
| 239 | _16x16_START |
| 240 | _16x16_SEQUENCE_2 |
| 241 | _16x16_SEQUENCE_1_FLIP |
| 242 | _16x16_END |
| 243 | |
| 244 | static const gfx_layout sega_16x16_r10_f0_layout = |
| 245 | _16x16_START |
| 246 | _16x16_SEQUENCE_1_FLIP |
| 247 | _16x16_SEQUENCE_2_FLIP |
| 248 | _16x16_END |
| 249 | |
| 250 | static const gfx_layout sega_16x16_r11_f0_layout = |
| 251 | _16x16_START |
| 252 | _16x16_SEQUENCE_2_FLIP |
| 253 | _16x16_SEQUENCE_1 |
| 254 | _16x16_END |
| 255 | |
| 256 | static const gfx_layout sega_16x16_r00_f1_layout = |
| 257 | _16x16_START |
| 258 | _16x16_SEQUENCE_1_FLIP |
| 259 | _16x16_SEQUENCE_2 |
| 260 | _16x16_END |
| 261 | |
| 262 | static const gfx_layout sega_16x16_r01_f1_layout = |
| 263 | _16x16_START |
| 264 | _16x16_SEQUENCE_2 |
| 265 | _16x16_SEQUENCE_1 |
| 266 | _16x16_END |
| 267 | |
| 268 | static const gfx_layout sega_16x16_r10_f1_layout = |
| 269 | _16x16_START |
| 270 | _16x16_SEQUENCE_1 |
| 271 | _16x16_SEQUENCE_2_FLIP |
| 272 | _16x16_END |
| 273 | |
| 274 | static const gfx_layout sega_16x16_r11_f1_layout = |
| 275 | _16x16_START |
| 276 | _16x16_SEQUENCE_2_FLIP |
| 277 | _16x16_SEQUENCE_1_FLIP |
| 278 | _16x16_END |
| 279 | |
| 280 | /* 32x32 decodes */ |
| 281 | static const gfx_layout sega_32x32_r00_f0_layout = |
| 282 | _32x32_START |
| 283 | _32x32_SEQUENCE_1 |
| 284 | _32x32_SEQUENCE_2 |
| 285 | _32x32_END |
| 286 | |
| 287 | static const gfx_layout sega_32x32_r01_f0_layout = |
| 288 | _32x32_START |
| 289 | _32x32_SEQUENCE_2 |
| 290 | _32x32_SEQUENCE_1_FLIP |
| 291 | _32x32_END |
| 292 | |
| 293 | static const gfx_layout sega_32x32_r10_f0_layout = |
| 294 | _32x32_START |
| 295 | _32x32_SEQUENCE_1_FLIP |
| 296 | _32x32_SEQUENCE_2_FLIP |
| 297 | _32x32_END |
| 298 | |
| 299 | static const gfx_layout sega_32x32_r11_f0_layout = |
| 300 | _32x32_START |
| 301 | _32x32_SEQUENCE_2_FLIP |
| 302 | _32x32_SEQUENCE_1 |
| 303 | _32x32_END |
| 304 | |
| 305 | static const gfx_layout sega_32x32_r00_f1_layout = |
| 306 | _32x32_START |
| 307 | _32x32_SEQUENCE_1_FLIP |
| 308 | _32x32_SEQUENCE_2 |
| 309 | _32x32_END |
| 310 | |
| 311 | static const gfx_layout sega_32x32_r01_f1_layout = |
| 312 | _32x32_START |
| 313 | _32x32_SEQUENCE_2 |
| 314 | _32x32_SEQUENCE_1 |
| 315 | _32x32_END |
| 316 | |
| 317 | static const gfx_layout sega_32x32_r10_f1_layout = |
| 318 | _32x32_START |
| 319 | _32x32_SEQUENCE_1 |
| 320 | _32x32_SEQUENCE_2_FLIP |
| 321 | _32x32_END |
| 322 | |
| 323 | static const gfx_layout sega_32x32_r11_f1_layout = |
| 324 | _32x32_START |
| 325 | _32x32_SEQUENCE_2_FLIP |
| 326 | _32x32_SEQUENCE_1_FLIP |
| 327 | _32x32_END |
| 328 | |
| 329 | extern UINT16 a12000_halt_reset_reg; |
| 330 | |
| 5 | 331 | class sega_segacd_device : public device_t |
| 6 | 332 | { |
| 7 | 333 | public: |
| 8 | 334 | sega_segacd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock, device_type type); |
| 9 | 335 | |
| 10 | | emu_timer *m_segacd_pwm_timer; |
| 336 | cpu_device *_segacd_68k_cpu; |
| 337 | |
| 338 | |
| 339 | UINT16 segacd_irq_mask; |
| 340 | UINT16 *segacd_backupram; |
| 341 | timer_device *stopwatch_timer; |
| 342 | UINT8 segacd_font_color; |
| 343 | UINT16* segacd_font_bits; |
| 344 | UINT16 scd_rammode; |
| 345 | UINT32 scd_mode_dmna_ret_flags ; |
| 346 | |
| 347 | timer_device *segacd_gfx_conversion_timer; |
| 348 | timer_device *segacd_irq3_timer; |
| 349 | //timer_device *segacd_hock_timer; |
| 350 | timer_device* scd_dma_timer; |
| 351 | |
| 352 | UINT16* segacd_4meg_prgram; // pointer to SubCPU PrgRAM |
| 353 | UINT16* segacd_dataram; |
| 354 | UINT16* segacd_dataram2; |
| 355 | tilemap_t *segacd_stampmap[4]; |
| 356 | |
| 357 | |
| 358 | UINT8 segacd_ram_writeprotect_bits; |
| 359 | int segacd_4meg_prgbank;// = 0; // which bank the MainCPU can see of the SubCPU PrgRAM |
| 360 | int segacd_memory_priority_mode;// = 0; |
| 361 | int segacd_stampsize; |
| 362 | |
| 363 | UINT16 segacd_hint_register; |
| 364 | UINT16 segacd_imagebuffer_vdot_size; |
| 365 | UINT16 segacd_imagebuffer_vcell_size; |
| 366 | UINT16 segacd_imagebuffer_hdot_size; |
| 367 | |
| 368 | int segacd_conversion_active;// = 0; |
| 369 | UINT16 segacd_stampmap_base_address; |
| 370 | UINT16 segacd_imagebuffer_start_address; |
| 371 | UINT16 segacd_imagebuffer_offset; |
| 372 | |
| 373 | |
| 374 | UINT16 segacd_comms_flags;// = 0x0000; |
| 375 | UINT16 segacd_comms_part1[0x8]; |
| 376 | UINT16 segacd_comms_part2[0x8]; |
| 377 | |
| 378 | int segacd_redled;// = 0; |
| 379 | int segacd_greenled;// = 0; |
| 380 | int segacd_ready;// = 1; // actually set 100ms after startup? |
| 381 | UINT16 segacd_irq3_timer_reg; |
| 382 | |
| 383 | segacd_t segacd; |
| 384 | |
| 385 | UINT8 SCD_BUFFER[2560]; |
| 386 | UINT32 SCD_STATUS; |
| 387 | UINT32 SCD_STATUS_CDC; |
| 388 | INT32 SCD_CURLBA; |
| 389 | UINT8 SCD_CURTRK; |
| 390 | |
| 391 | UINT16 CDC_DECODE; |
| 392 | INT16 CDC_DMACNT; // can go negative |
| 393 | UINT16 CDC_DMA_ADDRC; |
| 394 | UINT16 CDC_PT; |
| 395 | UINT16 CDC_WA; |
| 396 | UINT16 CDC_REG0; |
| 397 | UINT16 CDC_REG1; |
| 398 | UINT16 CDC_DMA_ADDR; |
| 399 | UINT16 CDC_IFSTAT; |
| 400 | UINT8 CDC_HEADB0; |
| 401 | UINT8 CDC_HEADB1; |
| 402 | UINT8 CDC_HEADB2; |
| 403 | UINT8 CDC_HEADB3; |
| 404 | UINT8 CDC_STATB0; |
| 405 | UINT8 CDC_STATB1; |
| 406 | UINT8 CDC_STATB2; |
| 407 | UINT8 CDC_STATB3; |
| 408 | UINT16 CDC_SBOUT; |
| 409 | UINT16 CDC_IFCTRL; |
| 410 | UINT8 CDC_CTRLB0; |
| 411 | UINT8 CDC_CTRLB1; |
| 412 | UINT8 CDC_CTRLB2; |
| 413 | UINT8 CDC_BUFFER[(32 * 1024 * 2) + SECTOR_SIZE]; |
| 414 | |
| 415 | UINT32 CDD_STATUS; |
| 416 | UINT32 CDD_MIN; |
| 417 | UINT32 CDD_SEC; |
| 418 | |
| 419 | UINT8 CDD_RX[10]; |
| 420 | UINT8 CDD_TX[10]; |
| 421 | UINT32 CDD_FRAME; |
| 422 | UINT32 CDD_EXT; |
| 423 | UINT16 CDD_CONTROL; |
| 424 | INT16 CDD_DONE; |
| 425 | |
| 426 | TIMER_DEVICE_CALLBACK_MEMBER( segacd_irq3_timer_callback ); |
| 427 | TIMER_DEVICE_CALLBACK_MEMBER( scd_dma_timer_callback ); |
| 428 | TIMER_DEVICE_CALLBACK_MEMBER( segacd_access_timer_callback ); |
| 429 | TIMER_DEVICE_CALLBACK_MEMBER( segacd_gfx_conversion_timer_callback ); |
| 430 | |
| 431 | UINT16 handle_segacd_sub_int_callback(int irqline); |
| 432 | |
| 433 | inline int to_bcd(int val, bool byte); |
| 434 | inline void write_pixel(running_machine& machine, UINT8 pix, int pixeloffset ); |
| 435 | UINT16 segacd_1meg_mode_word_read(int offset, UINT16 mem_mask); |
| 436 | void segacd_1meg_mode_word_write(running_machine& machine, int offset, UINT16 data, UINT16 mem_mask, int use_pm); |
| 437 | void set_data_audio_mode(void); |
| 438 | void CDD_DoChecksum(void); |
| 439 | void CDD_Export(void); |
| 440 | void CDC_UpdateHEAD(void); |
| 441 | void scd_ctrl_checks(running_machine& machine); |
| 442 | void scd_advance_current_readpos(void); |
| 443 | int Read_LBA_To_Buffer(running_machine& machine); |
| 444 | void CheckCommand(running_machine& machine); |
| 445 | void CDD_GetStatus(void); |
| 446 | void CDD_Stop(running_machine &machine); |
| 447 | void CDD_GetPos(void); |
| 448 | void CDD_GetTrackPos(void); |
| 449 | void CDD_GetTrack(void); |
| 450 | void CDD_Length(void); |
| 451 | void CDD_FirstLast(void); |
| 452 | void CDD_GetTrackAdr(void); |
| 453 | UINT32 getmsf_from_regs(void); |
| 454 | void CDD_Play(running_machine &machine); |
| 455 | void CDD_Seek(void); |
| 456 | void CDD_Pause(running_machine &machine); |
| 457 | void CDD_Resume(running_machine &machine); |
| 458 | void CDD_FF(running_machine &machine); |
| 459 | void CDD_RW(running_machine &machine); |
| 460 | void CDD_Open(void); |
| 461 | void CDD_Close(void); |
| 462 | void CDD_Init(void); |
| 463 | void CDD_Default(void); |
| 464 | void CDD_Reset(void); |
| 465 | void CDC_Reset(void); |
| 466 | void lc89510_Reset(void); |
| 467 | void CDC_End_Transfer(running_machine& machine); |
| 468 | void CDC_Do_DMA(running_machine& machine, int rate); |
| 469 | UINT16 CDC_Host_r(running_machine& machine, UINT16 type); |
| 470 | UINT8 CDC_Reg_r(void); |
| 471 | void CDC_Reg_w(UINT8 data); |
| 472 | void CDD_Process(running_machine& machine, int reason); |
| 473 | void CDD_Handle_TOC_Commands(void); |
| 474 | void CDD_Import(running_machine& machine); |
| 475 | |
| 476 | void segacd_mark_tiles_dirty(running_machine& machine, int offset); |
| 477 | int segacd_get_active_stampmap_tilemap(void); |
| 478 | |
| 479 | void SCD_GET_TILE_INFO_16x16_1x1( int& tile_region, int& tileno, int tile_index ); |
| 480 | void SCD_GET_TILE_INFO_32x32_1x1( int& tile_region, int& tileno, int tile_index ); |
| 481 | void SCD_GET_TILE_INFO_16x16_16x16( int& tile_region, int& tileno, int tile_index ); |
| 482 | void SCD_GET_TILE_INFO_32x32_16x16( int& tile_region, int& tileno, int tile_index ); |
| 483 | |
| 484 | TILE_GET_INFO_MEMBER( get_stampmap_16x16_1x1_tile_info ); |
| 485 | TILE_GET_INFO_MEMBER( get_stampmap_32x32_1x1_tile_info ); |
| 486 | TILE_GET_INFO_MEMBER( get_stampmap_16x16_16x16_tile_info ); |
| 487 | TILE_GET_INFO_MEMBER( get_stampmap_32x32_16x16_tile_info ); |
| 488 | |
| 489 | UINT8 get_stampmap_16x16_1x1_tile_info_pixel(running_machine& machine, int xpos, int ypos); |
| 490 | UINT8 get_stampmap_32x32_1x1_tile_info_pixel(running_machine& machine, int xpos, int ypos); |
| 491 | UINT8 get_stampmap_16x16_16x16_tile_info_pixel(running_machine& machine, int xpos, int ypos); |
| 492 | UINT8 get_stampmap_32x32_16x16_tile_info_pixel(running_machine& machine, int xpos, int ypos); |
| 493 | |
| 494 | WRITE16_MEMBER( scd_a12000_halt_reset_w ); |
| 495 | READ16_MEMBER( scd_a12000_halt_reset_r ); |
| 496 | READ16_MEMBER( scd_a12002_memory_mode_r ); |
| 497 | WRITE8_MEMBER( scd_a12002_memory_mode_w_8_15 ); |
| 498 | WRITE8_MEMBER( scd_a12002_memory_mode_w_0_7 ); |
| 499 | WRITE16_MEMBER( scd_a12002_memory_mode_w ); |
| 500 | READ16_MEMBER( segacd_sub_memory_mode_r ); |
| 501 | WRITE8_MEMBER( segacd_sub_memory_mode_w_8_15 ); |
| 502 | WRITE8_MEMBER( segacd_sub_memory_mode_w_0_7 ); |
| 503 | WRITE16_MEMBER( segacd_sub_memory_mode_w ); |
| 504 | |
| 505 | READ16_MEMBER( segacd_comms_flags_r ); |
| 506 | WRITE16_MEMBER( segacd_comms_flags_subcpu_w ); |
| 507 | WRITE16_MEMBER( segacd_comms_flags_maincpu_w ); |
| 508 | READ16_MEMBER( scd_4m_prgbank_ram_r ); |
| 509 | WRITE16_MEMBER( scd_4m_prgbank_ram_w ); |
| 510 | READ16_MEMBER( segacd_comms_main_part1_r ); |
| 511 | WRITE16_MEMBER( segacd_comms_main_part1_w ); |
| 512 | READ16_MEMBER( segacd_comms_main_part2_r ); |
| 513 | WRITE16_MEMBER( segacd_comms_main_part2_w ); |
| 514 | READ16_MEMBER( segacd_comms_sub_part1_r ); |
| 515 | WRITE16_MEMBER( segacd_comms_sub_part1_w ); |
| 516 | READ16_MEMBER( segacd_comms_sub_part2_r ); |
| 517 | WRITE16_MEMBER( segacd_comms_sub_part2_w ); |
| 518 | |
| 519 | WRITE16_MEMBER( segacd_cdc_mode_address_w ); |
| 520 | READ16_MEMBER( segacd_cdc_mode_address_r ); |
| 521 | WRITE16_MEMBER( segacd_cdc_data_w ); |
| 522 | READ16_MEMBER( segacd_cdc_data_r ); |
| 523 | |
| 524 | READ16_MEMBER( segacd_main_dataram_part1_r ); |
| 525 | WRITE16_MEMBER( segacd_main_dataram_part1_w ); |
| 526 | |
| 527 | READ16_MEMBER( scd_hint_vector_r ); |
| 528 | READ16_MEMBER( scd_a12006_hint_register_r ); |
| 529 | WRITE16_MEMBER( scd_a12006_hint_register_w ); |
| 530 | |
| 531 | READ16_MEMBER( cdc_data_sub_r ); |
| 532 | READ16_MEMBER( cdc_data_main_r ); |
| 533 | WRITE16_MEMBER( segacd_stopwatch_timer_w ); |
| 534 | READ16_MEMBER( segacd_stopwatch_timer_r ); |
| 535 | READ16_MEMBER( segacd_sub_led_ready_r ); |
| 536 | WRITE16_MEMBER( segacd_sub_led_ready_w ); |
| 537 | READ16_MEMBER( segacd_sub_dataram_part1_r ); |
| 538 | WRITE16_MEMBER( segacd_sub_dataram_part1_w ); |
| 539 | READ16_MEMBER( segacd_sub_dataram_part2_r ); |
| 540 | WRITE16_MEMBER( segacd_sub_dataram_part2_w ); |
| 541 | READ16_MEMBER( segacd_irq_mask_r ); |
| 542 | WRITE16_MEMBER( segacd_irq_mask_w ); |
| 543 | READ16_MEMBER( segacd_cdd_ctrl_r ); |
| 544 | WRITE16_MEMBER( segacd_cdd_ctrl_w ); |
| 545 | READ8_MEMBER( segacd_cdd_rx_r ); |
| 546 | WRITE8_MEMBER( segacd_cdd_tx_w ); |
| 547 | READ16_MEMBER( segacd_stampsize_r ); |
| 548 | WRITE16_MEMBER( segacd_stampsize_w ); |
| 549 | |
| 550 | UINT8 read_pixel_from_stampmap( running_machine& machine, bitmap_ind16* srcbitmap, int x, int y); |
| 551 | |
| 552 | WRITE16_MEMBER( segacd_trace_vector_base_address_w ); |
| 553 | READ16_MEMBER( segacd_imagebuffer_vdot_size_r ); |
| 554 | WRITE16_MEMBER( segacd_imagebuffer_vdot_size_w ); |
| 555 | READ16_MEMBER( segacd_stampmap_base_address_r ); |
| 556 | WRITE16_MEMBER( segacd_stampmap_base_address_w ); |
| 557 | READ16_MEMBER( segacd_imagebuffer_start_address_r ); |
| 558 | WRITE16_MEMBER( segacd_imagebuffer_start_address_w ); |
| 559 | READ16_MEMBER( segacd_imagebuffer_offset_r ); |
| 560 | WRITE16_MEMBER( segacd_imagebuffer_offset_w ); |
| 561 | READ16_MEMBER( segacd_imagebuffer_vcell_size_r ); |
| 562 | WRITE16_MEMBER( segacd_imagebuffer_vcell_size_w ); |
| 563 | READ16_MEMBER( segacd_imagebuffer_hdot_size_r ); |
| 564 | WRITE16_MEMBER( segacd_imagebuffer_hdot_size_w ); |
| 565 | READ16_MEMBER( segacd_irq3timer_r ); |
| 566 | WRITE16_MEMBER( segacd_irq3timer_w ); |
| 567 | READ16_MEMBER( cdc_dmaaddr_r ); |
| 568 | WRITE16_MEMBER( cdc_dmaaddr_w ); |
| 569 | READ16_MEMBER( segacd_cdfader_r ); |
| 570 | WRITE16_MEMBER( segacd_cdfader_w ); |
| 571 | READ16_MEMBER( segacd_backupram_r ); |
| 572 | WRITE16_MEMBER( segacd_backupram_w ); |
| 573 | READ16_MEMBER( segacd_font_color_r ); |
| 574 | WRITE16_MEMBER( segacd_font_color_w ); |
| 575 | READ16_MEMBER( segacd_font_converted_r ); |
| 576 | |
| 11 | 577 | protected: |
| 12 | 578 | virtual void device_start(); |
| 13 | 579 | virtual void device_reset(); |