trunk/src/mess/machine/cybiko.c
| r21102 | r21103 | |
| 17 | 17 | |
| 18 | 18 | #define RAMDISK_SIZE (512 * 1024) |
| 19 | 19 | |
| 20 | | ///////////////////////// |
| 21 | | // FUNCTION PROTOTYPES // |
| 22 | | ///////////////////////// |
| 23 | 20 | |
| 24 | | // state->m_rs232 |
| 25 | | static void cybiko_rs232_init(running_machine &machine); |
| 26 | | static void cybiko_rs232_exit(void); |
| 27 | | static void cybiko_rs232_reset(void); |
| 28 | | |
| 29 | 21 | //////////////////////// |
| 30 | 22 | // DRIVER INIT & EXIT // |
| 31 | 23 | //////////////////////// |
| 32 | 24 | |
| 33 | | static void init_ram_handler(running_machine &machine, offs_t start, offs_t size, offs_t mirror) |
| 25 | DRIVER_INIT_MEMBER(cybiko_state,cybiko) |
| 34 | 26 | { |
| 35 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_read_bank(start, start + size - 1, 0, mirror - size, "bank1"); |
| 36 | | machine.device("maincpu")->memory().space(AS_PROGRAM).install_write_bank(start, start + size - 1, 0, mirror - size, "bank1"); |
| 37 | | machine.root_device().membank( "bank1" )->set_base( machine.device<ram_device>(RAM_TAG)->pointer()); |
| 38 | | } |
| 39 | | |
| 40 | | DRIVER_INIT_MEMBER(cybiko_state,cybikov1) |
| 41 | | { |
| 42 | 27 | _logerror( 0, ("init_cybikov1\n")); |
| 43 | | init_ram_handler(machine(), 0x200000, machine().device<ram_device>(RAM_TAG)->size(), 0x200000); |
| 28 | m_maincpu->space(AS_PROGRAM).install_ram(0x200000, 0x200000 + m_ram->size() - 1, 0, 0x200000 - m_ram->size(), m_ram->pointer()); |
| 44 | 29 | } |
| 45 | 30 | |
| 46 | | DRIVER_INIT_MEMBER(cybiko_state,cybikov2) |
| 47 | | { |
| 48 | | _logerror( 0, ("init_cybikov2\n")); |
| 49 | | init_ram_handler(machine(), 0x200000, machine().device<ram_device>(RAM_TAG)->size(), 0x200000); |
| 50 | | } |
| 51 | | |
| 52 | 31 | DRIVER_INIT_MEMBER(cybiko_state,cybikoxt) |
| 53 | 32 | { |
| 54 | 33 | _logerror( 0, ("init_cybikoxt\n")); |
| 55 | | init_ram_handler(machine(), 0x400000, machine().device<ram_device>(RAM_TAG)->size(), 0x200000); |
| 34 | m_maincpu->space(AS_PROGRAM).install_ram(0x400000, 0x400000 + m_ram->size() - 1, 0, 0x200000 - m_ram->size(), m_ram->pointer()); |
| 56 | 35 | } |
| 57 | 36 | |
| 58 | 37 | /////////////////// |
| 59 | 38 | // MACHINE START // |
| 60 | 39 | /////////////////// |
| 61 | 40 | |
| 62 | | static emu_file *nvram_system_fopen( running_machine &machine, UINT32 openflags, const char *name) |
| 41 | NVRAM_HANDLER( cybikoxt ) |
| 63 | 42 | { |
| 64 | | file_error filerr; |
| 65 | | astring fname(machine.system().name, PATH_SEPARATOR, name, ".nv"); |
| 66 | | emu_file *file = global_alloc(emu_file(machine.options().nvram_directory(), openflags)); |
| 67 | | filerr = file->open(fname.cstr()); |
| 68 | | if (filerr == FILERR_NONE) |
| 69 | | return file; |
| 43 | address_space &space = machine.driver_data<cybiko_state>()->m_maincpu->space(AS_PROGRAM); |
| 44 | UINT8 *buffer = global_alloc_array(UINT8, RAMDISK_SIZE); |
| 70 | 45 | |
| 71 | | global_free(file); |
| 72 | | return NULL; |
| 73 | | } |
| 74 | | |
| 75 | | typedef void (nvram_load_func)(running_machine &machine, emu_file *file); |
| 76 | | |
| 77 | | static int nvram_system_load( running_machine &machine, const char *name, nvram_load_func _nvram_load, int required) |
| 78 | | { |
| 79 | | emu_file *file; |
| 80 | | file = nvram_system_fopen( machine, OPEN_FLAG_READ, name); |
| 81 | | if (!file) |
| 46 | if (read_or_write) |
| 82 | 47 | { |
| 83 | | if (required) mame_printf_error( "nvram load failed (%s)\n", name); |
| 84 | | return FALSE; |
| 85 | | } |
| 86 | | (*_nvram_load)(machine, file); |
| 87 | | global_free(file); |
| 88 | | return TRUE; |
| 89 | | } |
| 48 | for (offs_t offs = 0; offs < RAMDISK_SIZE; offs++) |
| 49 | buffer[offs] = space.read_byte(0x400000 + offs); |
| 90 | 50 | |
| 91 | | typedef void (nvram_save_func)(running_machine &machine, emu_file *file); |
| 92 | | |
| 93 | | static int nvram_system_save( running_machine &machine, const char *name, nvram_save_func _nvram_save) |
| 94 | | { |
| 95 | | emu_file *file; |
| 96 | | file = nvram_system_fopen( machine, OPEN_FLAG_CREATE | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE_PATHS, name); |
| 97 | | if (!file) |
| 98 | | { |
| 99 | | mame_printf_error( "nvram save failed (%s)\n", name); |
| 100 | | return FALSE; |
| 51 | file->write(buffer, RAMDISK_SIZE); |
| 101 | 52 | } |
| 102 | | (*_nvram_save)(machine, file); |
| 103 | | global_free(file); |
| 104 | | return TRUE; |
| 105 | | } |
| 106 | | |
| 107 | | static void cybiko_ramdisk_load(running_machine &machine, emu_file *file) |
| 108 | | { |
| 109 | | UINT8 *ram = machine.device<ram_device>(RAM_TAG)->pointer(); |
| 110 | | #ifdef LSB_FIRST |
| 111 | | UINT8 *temp = (UINT8*)malloc( RAMDISK_SIZE); |
| 112 | | file->read( temp, RAMDISK_SIZE); |
| 113 | | for (int i = 0; i < RAMDISK_SIZE; i += 2) |
| 53 | else |
| 114 | 54 | { |
| 115 | | ram[i+0] = temp[i+1]; |
| 116 | | ram[i+1] = temp[i+0]; |
| 117 | | } |
| 118 | | free( temp); |
| 119 | | #else |
| 120 | | file->read( ram, RAMDISK_SIZE); |
| 121 | | #endif |
| 122 | | } |
| 55 | if (file) |
| 56 | file->read(buffer, RAMDISK_SIZE); |
| 57 | else |
| 58 | memset(buffer, 0, RAMDISK_SIZE); |
| 123 | 59 | |
| 124 | | static void cybiko_ramdisk_save(running_machine &machine, emu_file *file) |
| 125 | | { |
| 126 | | UINT8 *ram = machine.device<ram_device>(RAM_TAG)->pointer(); |
| 127 | | #ifdef LSB_FIRST |
| 128 | | UINT8 *temp = (UINT8*)malloc( RAMDISK_SIZE); |
| 129 | | for (int i = 0; i < RAMDISK_SIZE; i += 2) |
| 130 | | { |
| 131 | | temp[i+0] = ram[i+1]; |
| 132 | | temp[i+1] = ram[i+0]; |
| 60 | for (offs_t offs = 0; offs < RAMDISK_SIZE; offs++) |
| 61 | space.write_byte(0x400000 + offs, buffer[offs]); |
| 133 | 62 | } |
| 134 | | file->write( temp, RAMDISK_SIZE); |
| 135 | | free( temp); |
| 136 | | #else |
| 137 | | file->write( ram, RAMDISK_SIZE); |
| 138 | | #endif |
| 63 | |
| 64 | global_free(buffer); |
| 139 | 65 | } |
| 140 | 66 | |
| 141 | 67 | void cybiko_state::machine_start() |
| 142 | 68 | { |
| 143 | 69 | _logerror( 0, ("machine_start_cybikov1\n")); |
| 144 | 70 | // serial port |
| 145 | | cybiko_rs232_init(machine()); |
| 71 | cybiko_rs232_init(); |
| 146 | 72 | // other |
| 147 | | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(cybiko_state::machine_stop_cybikov1),this)); |
| 73 | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(cybiko_state::machine_stop_cybiko),this)); |
| 148 | 74 | } |
| 149 | 75 | |
| 150 | | MACHINE_START_MEMBER(cybiko_state,cybikov2) |
| 151 | | { |
| 152 | | _logerror( 0, ("machine_start_cybikov2\n")); |
| 153 | | // serial port |
| 154 | | cybiko_rs232_init(machine()); |
| 155 | | // other |
| 156 | | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(cybiko_state::machine_stop_cybikov2),this)); |
| 157 | | } |
| 158 | | |
| 159 | | MACHINE_START_MEMBER(cybiko_state,cybikoxt) |
| 160 | | { |
| 161 | | _logerror( 0, ("machine_start_cybikoxt\n")); |
| 162 | | // ramdisk |
| 163 | | nvram_system_load( machine(), "ramdisk", cybiko_ramdisk_load, 0); |
| 164 | | // serial port |
| 165 | | cybiko_rs232_init(machine()); |
| 166 | | // other |
| 167 | | machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(cybiko_state::machine_stop_cybikoxt),this)); |
| 168 | | } |
| 169 | | |
| 170 | 76 | /////////////////// |
| 171 | 77 | // MACHINE RESET // |
| 172 | 78 | /////////////////// |
| r21102 | r21103 | |
| 177 | 83 | cybiko_rs232_reset(); |
| 178 | 84 | } |
| 179 | 85 | |
| 180 | | MACHINE_RESET_MEMBER(cybiko_state,cybikov2) |
| 181 | | { |
| 182 | | _logerror( 0, ("machine_reset_cybikov2\n")); |
| 183 | | cybiko_rs232_reset(); |
| 184 | | } |
| 185 | | |
| 186 | | MACHINE_RESET_MEMBER(cybiko_state,cybikoxt) |
| 187 | | { |
| 188 | | _logerror( 0, ("machine_reset_cybikoxt\n")); |
| 189 | | cybiko_rs232_reset(); |
| 190 | | } |
| 191 | | |
| 192 | 86 | ////////////////// |
| 193 | 87 | // MACHINE STOP // |
| 194 | 88 | ////////////////// |
| 195 | 89 | |
| 196 | | void cybiko_state::machine_stop_cybikov1() |
| 90 | void cybiko_state::machine_stop_cybiko() |
| 197 | 91 | { |
| 198 | 92 | _logerror( 0, ("machine_stop_cybikov1\n")); |
| 199 | 93 | // serial port |
| 200 | 94 | cybiko_rs232_exit(); |
| 201 | 95 | } |
| 202 | 96 | |
| 203 | | void cybiko_state::machine_stop_cybikov2() |
| 204 | | { |
| 205 | | _logerror( 0, ("machine_stop_cybikov2\n")); |
| 206 | | // serial port |
| 207 | | cybiko_rs232_exit(); |
| 208 | | } |
| 209 | | |
| 210 | | void cybiko_state::machine_stop_cybikoxt() |
| 211 | | { |
| 212 | | _logerror( 0, ("machine_stop_cybikoxt\n")); |
| 213 | | // ramdisk |
| 214 | | nvram_system_save( machine(), "ramdisk", cybiko_ramdisk_save); |
| 215 | | // serial port |
| 216 | | cybiko_rs232_exit(); |
| 217 | | } |
| 218 | | |
| 219 | 97 | /////////// |
| 220 | 98 | // RS232 // |
| 221 | 99 | /////////// |
| 222 | 100 | |
| 223 | 101 | |
| 224 | | static void cybiko_rs232_init(running_machine &machine) |
| 102 | void cybiko_state::cybiko_rs232_init() |
| 225 | 103 | { |
| 226 | | cybiko_state *state = machine.driver_data<cybiko_state>(); |
| 227 | 104 | _logerror( 0, ("cybiko_rs232_init\n")); |
| 228 | | memset( &state->m_rs232, 0, sizeof( state->m_rs232)); |
| 229 | | // machine.scheduler().timer_pulse(TIME_IN_HZ( 10), FUNC(rs232_timer_callback)); |
| 105 | memset( &m_rs232, 0, sizeof(m_rs232)); |
| 106 | // machine().scheduler().timer_pulse(TIME_IN_HZ( 10), FUNC(rs232_timer_callback)); |
| 230 | 107 | } |
| 231 | 108 | |
| 232 | | static void cybiko_rs232_exit() |
| 109 | void cybiko_state::cybiko_rs232_exit() |
| 233 | 110 | { |
| 234 | 111 | _logerror( 0, ("cybiko_rs232_exit\n")); |
| 235 | 112 | } |
| 236 | 113 | |
| 237 | | static void cybiko_rs232_reset() |
| 114 | void cybiko_state::cybiko_rs232_reset() |
| 238 | 115 | { |
| 239 | 116 | _logerror( 0, ("cybiko_rs232_reset\n")); |
| 240 | 117 | } |
trunk/src/mess/includes/cybiko.h
| r21102 | r21103 | |
| 46 | 46 | public: |
| 47 | 47 | cybiko_state(const machine_config &mconfig, device_type type, const char *tag) |
| 48 | 48 | : driver_device(mconfig, type, tag), |
| 49 | m_maincpu(*this, "maincpu"), |
| 49 | 50 | m_crtc(*this, "hd66421"), |
| 50 | 51 | m_speaker(*this, SPEAKER_TAG), |
| 51 | 52 | m_rtc(*this, "rtc"), |
| 53 | m_ram(*this, RAM_TAG), |
| 52 | 54 | m_flash1(*this, "flash1"), |
| 53 | 55 | m_flash2(*this, "flash2"), |
| 54 | 56 | m_flashxt(*this, "flashxt") |
| r21102 | r21103 | |
| 75 | 77 | void cybiko_rs232_pin_txd(int data); |
| 76 | 78 | int cybiko_rs232_pin_rxd(); |
| 77 | 79 | int cybiko_rs232_rx_queue(); |
| 80 | void cybiko_rs232_init(); |
| 81 | void cybiko_rs232_exit(); |
| 82 | void cybiko_rs232_reset(); |
| 78 | 83 | |
| 84 | required_device<cpu_device> m_maincpu; |
| 79 | 85 | required_device<hd66421_device> m_crtc; |
| 80 | 86 | required_device<speaker_sound_device> m_speaker; |
| 81 | 87 | required_device<pcf8593_device> m_rtc; |
| 88 | required_device<ram_device> m_ram; |
| 82 | 89 | optional_device<at45db041_device> m_flash1; |
| 83 | 90 | optional_device<intelfsh8_device> m_flash2; |
| 84 | 91 | optional_device<intelfsh16_device> m_flashxt; |
| 85 | 92 | DECLARE_DRIVER_INIT(cybikoxt); |
| 86 | | DECLARE_DRIVER_INIT(cybikov1); |
| 87 | | DECLARE_DRIVER_INIT(cybikov2); |
| 93 | DECLARE_DRIVER_INIT(cybiko); |
| 88 | 94 | virtual void machine_start(); |
| 89 | 95 | virtual void machine_reset(); |
| 90 | 96 | virtual void palette_init(); |
| 91 | | DECLARE_MACHINE_START(cybikov2); |
| 92 | | DECLARE_MACHINE_RESET(cybikov2); |
| 93 | | DECLARE_MACHINE_START(cybikoxt); |
| 94 | | DECLARE_MACHINE_RESET(cybikoxt); |
| 95 | | UINT32 screen_update_cybiko(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 96 | | void machine_stop_cybikov1(); |
| 97 | | void machine_stop_cybikov2(); |
| 98 | | void machine_stop_cybikoxt(); |
| 97 | void machine_stop_cybiko(); |
| 99 | 98 | }; |
| 100 | 99 | |
| 100 | NVRAM_HANDLER( cybikoxt ); |
| 101 | |
| 101 | 102 | #endif /* CYBIKO_H_ */ |
trunk/src/mess/drivers/cybiko.c
| r21102 | r21103 | |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | //////////////////// |
| 299 | | // SCREEN UPDATE // |
| 300 | | //////////////////// |
| 301 | | |
| 302 | | UINT32 cybiko_state::screen_update_cybiko(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 303 | | { |
| 304 | | hd66421_device *hd66421 = machine().device<hd66421_device>( "hd66421" ); |
| 305 | | hd66421->update_screen(bitmap, cliprect); |
| 306 | | return 0; |
| 307 | | } |
| 308 | | |
| 309 | | |
| 310 | | //////////////////// |
| 311 | 299 | // MACHINE DRIVER // |
| 312 | 300 | //////////////////// |
| 313 | 301 | |
| 314 | 302 | static MACHINE_CONFIG_START( cybikov1, cybiko_state ) |
| 315 | 303 | // cpu |
| 316 | | MCFG_CPU_ADD( "maincpu", H8S2241, 11059200 ) |
| 304 | MCFG_CPU_ADD( "maincpu", H8S2241, XTAL_11_0592MHz ) |
| 317 | 305 | MCFG_CPU_PROGRAM_MAP( cybikov1_mem ) |
| 318 | 306 | MCFG_CPU_IO_MAP( cybikov1_io ) |
| 319 | 307 | // screen |
| r21102 | r21103 | |
| 321 | 309 | MCFG_SCREEN_REFRESH_RATE( 60 ) |
| 322 | 310 | MCFG_SCREEN_SIZE( HD66421_WIDTH, HD66421_HEIGHT ) |
| 323 | 311 | MCFG_SCREEN_VISIBLE_AREA( 0, HD66421_WIDTH - 1, 0, HD66421_HEIGHT - 1 ) |
| 324 | | MCFG_SCREEN_UPDATE_DRIVER(cybiko_state, screen_update_cybiko) |
| 312 | MCFG_SCREEN_UPDATE_DEVICE("hd66421", hd66421_device, update_screen) |
| 325 | 313 | |
| 326 | 314 | // video |
| 327 | 315 | MCFG_HD66421_ADD("hd66421") |
| r21102 | r21103 | |
| 344 | 332 | |
| 345 | 333 | static MACHINE_CONFIG_DERIVED( cybikov2, cybikov1) |
| 346 | 334 | // cpu |
| 347 | | MCFG_CPU_REPLACE("maincpu", H8S2246, 11059200) |
| 335 | MCFG_CPU_REPLACE("maincpu", H8S2246, XTAL_11_0592MHz) |
| 348 | 336 | MCFG_CPU_PROGRAM_MAP(cybikov2_mem ) |
| 349 | 337 | MCFG_CPU_IO_MAP(cybikov2_io ) |
| 350 | 338 | // machine |
| 351 | | MCFG_MACHINE_START_OVERRIDE(cybiko_state,cybikov2) |
| 352 | | MCFG_MACHINE_RESET_OVERRIDE(cybiko_state,cybikov2) |
| 353 | 339 | MCFG_SST_39VF020_ADD("flash2") |
| 354 | 340 | |
| 355 | 341 | /* internal ram */ |
| r21102 | r21103 | |
| 360 | 346 | |
| 361 | 347 | static MACHINE_CONFIG_DERIVED( cybikoxt, cybikov1) |
| 362 | 348 | // cpu |
| 363 | | MCFG_CPU_REPLACE("maincpu", H8S2323, 18432000) |
| 349 | MCFG_CPU_REPLACE("maincpu", H8S2323, XTAL_18_432MHz) |
| 364 | 350 | MCFG_CPU_PROGRAM_MAP(cybikoxt_mem ) |
| 365 | 351 | MCFG_CPU_IO_MAP(cybikoxt_io ) |
| 366 | 352 | // machine |
| 367 | | MCFG_MACHINE_START_OVERRIDE(cybiko_state,cybikoxt) |
| 368 | | MCFG_MACHINE_RESET_OVERRIDE(cybiko_state,cybikoxt) |
| 369 | 353 | MCFG_DEVICE_REMOVE("flash1") |
| 370 | 354 | MCFG_SST_39VF400A_ADD("flashxt") |
| 371 | 355 | |
| 356 | MCFG_NVRAM_HANDLER( cybikoxt ) |
| 357 | |
| 372 | 358 | /* internal ram */ |
| 373 | 359 | MCFG_RAM_MODIFY(RAM_TAG) |
| 374 | 360 | MCFG_RAM_DEFAULT_SIZE("2M") |
| r21102 | r21103 | |
| 421 | 407 | ////////////// |
| 422 | 408 | |
| 423 | 409 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 424 | | COMP( 2000, cybikov1, 0, 0, cybikov1, cybiko, cybiko_state, cybikov1, "Cybiko Inc", "Cybiko Classic (V1)", GAME_IMPERFECT_SOUND ) |
| 425 | | COMP( 2000, cybikov2, cybikov1, 0, cybikov2, cybiko, cybiko_state, cybikov2, "Cybiko Inc", "Cybiko Classic (V2)", GAME_IMPERFECT_SOUND ) |
| 410 | COMP( 2000, cybikov1, 0, 0, cybikov1, cybiko, cybiko_state, cybiko , "Cybiko Inc", "Cybiko Classic (V1)", GAME_IMPERFECT_SOUND ) |
| 411 | COMP( 2000, cybikov2, cybikov1, 0, cybikov2, cybiko, cybiko_state, cybiko , "Cybiko Inc", "Cybiko Classic (V2)", GAME_IMPERFECT_SOUND ) |
| 426 | 412 | COMP( 2001, cybikoxt, cybikov1, 0, cybikoxt, cybikoxt, cybiko_state, cybikoxt, "Cybiko Inc", "Cybiko Xtreme", GAME_IMPERFECT_SOUND ) |