src/mess/video/galaxy.c
| r2697 | r2698 | |
| 3 | 3 | galaxy.c |
| 4 | 4 | |
| 5 | 5 | Functions to emulate the video hardware of the Galaksija. |
| 6 | | |
| 6 | |
| 7 | 7 | 20/05/2008 - Real video implementation by Miodrag Milanovic |
| 8 | | 01/03/2008 - Update by Miodrag Milanovic to make Galaksija video work with new SVN code |
| 8 | 01/03/2008 - Update by Miodrag Milanovic to make Galaksija video work with new SVN code |
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| r2697 | r2698 | |
| 47 | 47 | emu_timer *gal_video_timer = NULL; |
| 48 | 48 | |
| 49 | 49 | TIMER_CALLBACK( gal_video ) |
| 50 | | { |
| 50 | { |
| 51 | 51 | int y,x; |
| 52 | 52 | if (galaxy_interrupts_enabled==TRUE) { |
| 53 | | UINT8 *gfx = memory_region(REGION_GFX1); |
| 53 | UINT8 *gfx = memory_region(REGION_GFX1); |
| 54 | 54 | UINT8 dat = (gal_latch_value & 0x3c) >> 2; |
| 55 | | if ((gal_cnt > 96 * 2) && (gal_cnt < 96 * 210)) { // display on screen just first 208 lines |
| 55 | if ((gal_cnt > 96 * 2) && (gal_cnt < 96 * 210)) { // display on screen just first 208 lines |
| 56 | 56 | if (((gal_cnt) % 2)==0) { //fetch code |
| 57 | | UINT16 addr = (cpunum_get_reg(0, Z80_I) << 8) | cpunum_get_reg(0, Z80_R) | ((gal_latch_value & 0x80) ^ 0x80); |
| 57 | UINT16 addr = (cpunum_get_reg(0, Z80_I) << 8) | cpunum_get_reg(0, Z80_R) | ((gal_latch_value & 0x80) ^ 0x80); |
| 58 | 58 | if (first==0 && (cpunum_get_reg(0, Z80_R) & 0x1f) ==0) { |
| 59 | 59 | // Due to a fact that on real processor latch value is set at |
| 60 | | // the end of last cycle we need to skip dusplay of double |
| 61 | | // first char in each row |
| 60 | // the end of last cycle we need to skip dusplay of double |
| 61 | // first char in each row |
| 62 | 62 | code = 0xff; |
| 63 | 63 | first = 1; |
| 64 | 64 | } else { |
| 65 | 65 | code = program_read_byte(addr) & 0xbf; |
| 66 | | code += (code & 0x80) >> 1; |
| 67 | | code = gfx[(code & 0x7f) +(dat << 7 )]; |
| 68 | | first = 0; |
| 66 | code += (code & 0x80) >> 1; |
| 67 | code = gfx[(code & 0x7f) +(dat << 7 )]; |
| 68 | first = 0; |
| 69 | 69 | } |
| 70 | 70 | y = gal_cnt / 96 - 2; |
| 71 | 71 | x = (gal_cnt % 96)*4; |
| r2697 | r2698 | |
| 76 | 76 | *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 4) & 1; x++; |
| 77 | 77 | *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 5) & 1; x++; |
| 78 | 78 | *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 6) & 1; x++; |
| 79 | | *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 7) & 1; |
| 80 | | } |
| 81 | | } |
| 82 | | gal_cnt++; |
| 83 | | } |
| 79 | *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 7) & 1; |
| 80 | } |
| 81 | } |
| 82 | gal_cnt++; |
| 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | | VIDEO_START ( galaxy ) |
| 86 | VIDEO_START ( galaxy ) |
| 87 | 87 | { |
| 88 | 88 | return VIDEO_START_CALL ( generic_bitmapped ); |
| 89 | 89 | } |
| r2697 | r2698 | |
| 93 | 93 | timer_adjust_periodic(gal_video_timer, attotime_zero, 0, attotime_never); |
| 94 | 94 | if (galaxy_interrupts_enabled == FALSE) { |
| 95 | 95 | rectangle black_area = {0,384-1,0,212-2}; |
| 96 | | fillbitmap(tmpbitmap, 1, &black_area); |
| 96 | fillbitmap(tmpbitmap, 1, &black_area); |
| 97 | 97 | } |
| 98 | | galaxy_interrupts_enabled = FALSE; |
| 98 | galaxy_interrupts_enabled = FALSE; |
| 99 | 99 | return VIDEO_UPDATE_CALL ( generic_bitmapped ); |
| 100 | 100 | } |
| 101 | 101 | |
src/mess/machine/galaxy.c
| r2697 | r2698 | |
| 30 | 30 | |
| 31 | 31 | READ8_HANDLER( galaxy_latch_r ) |
| 32 | 32 | { |
| 33 | | return 0xff; |
| 33 | return 0xff; |
| 34 | 34 | } |
| 35 | 35 | WRITE8_HANDLER( galaxy_latch_w ) |
| 36 | | { |
| 36 | { |
| 37 | 37 | double val = (((data >>6) & 1 ) + ((data >> 2) & 1) - 1) * 32000; |
| 38 | | gal_latch_value = data; |
| 39 | | cassette_output(image_from_devtype_and_index(IO_CASSETTE, 0), val); |
| 38 | gal_latch_value = data; |
| 39 | cassette_output(image_from_devtype_and_index(IO_CASSETTE, 0), val); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
| r2697 | r2698 | |
| 47 | 47 | int galaxy_interrupts_enabled = TRUE; |
| 48 | 48 | |
| 49 | 49 | INTERRUPT_GEN( galaxy_interrupt ) |
| 50 | | { |
| 51 | | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 50 | { |
| 51 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | IRQ_CALLBACK ( galaxy_irq_callback ) |
| r2697 | r2698 | |
| 173 | 173 | { |
| 174 | 174 | /* ROM 2 enable/disable */ |
| 175 | 175 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, input_port_read_indexed(machine, 7) ? SMH_BANK10 : SMH_NOP); |
| 176 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, SMH_NOP); |
| 176 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, SMH_NOP); |
| 177 | 177 | memory_set_bankptr(10, memory_region(REGION_CPU1) + 0x1000); |
| 178 | 178 | |
| 179 | 179 | cpunum_set_irq_callback(0, galaxy_irq_callback); |
| 180 | 180 | galaxy_interrupts_enabled = TRUE; |
| 181 | | |
| 181 | |
| 182 | 182 | gal_video_timer = timer_alloc(gal_video, NULL); |
| 183 | 183 | timer_adjust_periodic(gal_video_timer, attotime_zero, 0,attotime_never); |
| 184 | 184 | } |
| r2697 | r2698 | |
| 191 | 191 | MACHINE_RESET( galaxyp ) |
| 192 | 192 | { |
| 193 | 193 | UINT8 *ROM = memory_region(REGION_CPU1); |
| 194 | | |
| 195 | | cpunum_set_irq_callback(0, galaxy_irq_callback); |
| 196 | | |
| 194 | |
| 195 | cpunum_set_irq_callback(0, galaxy_irq_callback); |
| 196 | |
| 197 | 197 | ROM[0x0037] = 0x29; |
| 198 | 198 | ROM[0x03f9] = 0xcd; |
| 199 | 199 | ROM[0x03fa] = 0x00; |
| 200 | 200 | ROM[0x03fb] = 0xe0; |
| 201 | | |
| 201 | |
| 202 | 202 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_BANK11); |
| 203 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_NOP); |
| 204 | | memory_set_bankptr(11, memory_region(REGION_CPU1) + 0xe000); |
| 203 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_NOP); |
| 204 | memory_set_bankptr(11, memory_region(REGION_CPU1) + 0xe000); |
| 205 | 205 | galaxy_interrupts_enabled = TRUE; |
| 206 | 206 | |
| 207 | 207 | gal_video_timer = timer_alloc(gal_video, NULL); |
src/mess/formats/gtp_cas.c
| r2697 | r2698 | |
| 1 | 1 | /*
|
| 2 | |
|
| 3 | | Tape support for Glaksija GTP format
|
| 4 | | |
| 5 | | Miodrag Milanovic
|
| 2 | |
| 3 | Tape support for Glaksija GTP format
|
| 4 | |
| 5 | Miodrag Milanovic
|
| 6 | 6 | */
|
| 7 | 7 | #include "driver.h"
|
| 8 | 8 | #include "formats/gtp_cas.h"
|
| r2697 | r2698 | |
| 13 | 13 | #define WAVE_HIGH 0x5a9e
|
| 14 | 14 | #define WAVE_NULL 0
|
| 15 | 15 | |
| 16 | #define GTP_BLOCK_STANDARD 0x00
|
| 17 | #define GTP_BLOCK_TURBO 0x01
|
| 18 | #define GTP_BLOCK_NAME 0x10
|
| 16 | 19 | |
| 17 | | #define GTP_BLOCK_STANDARD 0x00
|
| 18 | | #define GTP_BLOCK_TURBO 0x01
|
| 19 | | #define GTP_BLOCK_NAME 0x10
|
| 20 | | |
| 21 | 20 | static INT16 wave_data;
|
| 22 | 21 | static INT16 len;
|
| 23 | 22 | |
| r2697 | r2698 | |
| 57 | 56 | gtp_output_wave(buffer,PULSE_WIDTH);
|
| 58 | 57 | wave_data = WAVE_NULL;
|
| 59 | 58 | gtp_output_wave(buffer,PERIOD_1 - 2 * PULSE_WIDTH);
|
| 60 | |
|
| 59 |
|
| 61 | 60 | return PERIOD_1 * 2;
|
| 62 | 61 | }
|
| 63 | 62 | |
| r2697 | r2698 | |
| 69 | 68 | gtp_output_wave(buffer,PULSE_WIDTH);
|
| 70 | 69 | wave_data = WAVE_NULL;
|
| 71 | 70 | gtp_output_wave(buffer,PERIOD_0 - 2 * PULSE_WIDTH);
|
| 72 | |
|
| 71 |
|
| 73 | 72 | return PERIOD_0;
|
| 74 | 73 | }
|
| 75 | 74 | |
| r2697 | r2698 | |
| 78 | 77 | UINT8 b;
|
| 79 | 78 | int j,size = 0;
|
| 80 | 79 | for (j=0;j<8;j++) {
|
| 81 | | b = (val >> j) & 1;
|
| 82 | | if (b==0) { |
| 80 | b = (val >> j) & 1;
|
| 81 | if (b==0) {
|
| 83 | 82 | size += gtp_mod_0(buffer);
|
| 84 | | } else {
|
| 83 | } else {
|
| 85 | 84 | size += gtp_mod_1(buffer);
|
| 86 | | }
|
| 85 | }
|
| 87 | 86 | }
|
| 88 | 87 | return size;
|
| 89 | 88 | }
|
| r2697 | r2698 | |
| 97 | 96 | if (i!=0) {
|
| 98 | 97 | // Interbyte pause
|
| 99 | 98 | wave_data = WAVE_NULL;
|
| 100 | | gtp_output_wave(buffer,INTERBYTE_PAUSE);
|
| 99 | gtp_output_wave(buffer,INTERBYTE_PAUSE);
|
| 101 | 100 | size += INTERBYTE_PAUSE;
|
| 102 | 101 | }
|
| 103 | 102 | size += gtp_byte(buffer,0);
|
| 104 | 103 | }
|
| 105 | | return size;
|
| 104 | return size;
|
| 106 | 105 | }
|
| 107 | 106 | |
| 108 | 107 | static int gtp_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
|
| 109 | | int size,n;
|
| 110 | | size = 0;
|
| 108 | int size,n;
|
| 109 | size = 0;
|
| 111 | 110 | n = 0;
|
| 112 | 111 | if (casdata == NULL) return -1;
|
| 113 | | while(n<caslen) {
|
| 112 | while(n<caslen) {
|
| 114 | 113 | int block_type = casdata[n];
|
| 115 | 114 | int block_size = casdata[n+2]*256 + casdata[n+1];
|
| 116 | 115 | n+=5;
|
| 117 | 116 | if (block_type==GTP_BLOCK_STANDARD) {
|
| 118 | 117 | // Interblock pause
|
| 119 | | size += INTERBLOCK_PAUSE; |
| 120 | | size += 100 * (PERIOD_0 * 8 + INTERBYTE_PAUSE) - INTERBYTE_PAUSE; |
| 118 | size += INTERBLOCK_PAUSE;
|
| 119 | size += 100 * (PERIOD_0 * 8 + INTERBYTE_PAUSE) - INTERBYTE_PAUSE;
|
| 121 | 120 | size += (PERIOD_0 * 8 + INTERBYTE_PAUSE) * block_size;
|
| 122 | 121 | }
|
| 123 | 122 | n += block_size;
|
| 124 | | } |
| 125 | | len = caslen; |
| 123 | }
|
| 124 | len = caslen;
|
| 126 | 125 | return size;
|
| 127 | 126 | }
|
| 128 | 127 | |
| 129 | 128 | static int gtp_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
|
| 130 | | int i,size,n;
|
| 131 | | size = 0;
|
| 129 | int i,size,n;
|
| 130 | size = 0;
|
| 132 | 131 | n = 0;
|
| 133 | 132 | if (bytes == NULL) return -1;
|
| 134 | | while(n<len) |
| 135 | | {
|
| 133 | while(n<len)
|
| 134 | {
|
| 136 | 135 | int block_type = bytes[n];
|
| 137 | 136 | int block_size = bytes[n+2]*256 + bytes[n+1];
|
| 138 | 137 | n+=5;
|
| r2697 | r2698 | |
| 141 | 140 | // Interblock pause
|
| 142 | 141 | wave_data = WAVE_NULL;
|
| 143 | 142 | gtp_output_wave(&buffer,INTERBLOCK_PAUSE);
|
| 144 | | size += INTERBLOCK_PAUSE;
|
| 143 | size += INTERBLOCK_PAUSE;
|
| 145 | 144 | size += gtp_sync(&buffer);
|
| 146 | |
|
| 145 |
|
| 147 | 146 | for (i=0;i<block_size;i++) {
|
| 148 | 147 | // Interbyte pause
|
| 149 | 148 | wave_data = WAVE_NULL;
|
| 150 | | gtp_output_wave(&buffer,INTERBYTE_PAUSE);
|
| 149 | gtp_output_wave(&buffer,INTERBYTE_PAUSE);
|
| 151 | 150 | size += INTERBYTE_PAUSE;
|
| 152 | |
|
| 151 |
|
| 153 | 152 | size += gtp_byte(&buffer,bytes[n]);
|
| 154 | 153 | n++;
|
| 155 | | }
|
| 154 | }
|
| 156 | 155 | }
|
| 157 | | }
|
| 156 | }
|
| 158 | 157 | return size;
|
| 159 | 158 | }
|
| 160 | 159 | |
src/mess/drivers/galaxy.c
| r2697 | r2698 | |
| 46 | 46 | static ADDRESS_MAP_START (galaxyp_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 47 | 47 | AM_RANGE(0x0000, 0x0fff) AM_ROM // ROM A |
| 48 | 48 | AM_RANGE(0x1000, 0x1fff) AM_ROM // ROM B |
| 49 | | AM_RANGE(0x2000, 0x2037) AM_MIRROR(0x07c0) AM_READ( galaxy_keyboard_r ) |
| 49 | AM_RANGE(0x2000, 0x2037) AM_MIRROR(0x07c0) AM_READ( galaxy_keyboard_r ) |
| 50 | 50 | AM_RANGE(0x2038, 0x203f) AM_MIRROR(0x07c0) AM_READWRITE( galaxy_latch_r, galaxy_latch_w ) |
| 51 | | AM_RANGE(0xe000, 0xefff) AM_ROM // ROM C |
| 51 | AM_RANGE(0xe000, 0xefff) AM_ROM // ROM C |
| 52 | 52 | AM_RANGE(0xf000, 0xffff) AM_ROM // ROM D |
| 53 | 53 | ADDRESS_MAP_END |
| 54 | 54 | |
| r2697 | r2698 | |
| 135 | 135 | INPUT_PORTS_END |
| 136 | 136 | |
| 137 | 137 | static INPUT_PORTS_START( galaxy ) |
| 138 | | PORT_INCLUDE( galaxy_common ) |
| 138 | PORT_INCLUDE( galaxy_common ) |
| 139 | 139 | PORT_START /* port 7 */ |
| 140 | 140 | PORT_CONFNAME(0x01, 0x01, "ROM 2") |
| 141 | 141 | PORT_CONFSETTING(0x01, "Installed") |
| r2697 | r2698 | |
| 143 | 143 | INPUT_PORTS_END |
| 144 | 144 | |
| 145 | 145 | static INPUT_PORTS_START( galaxyp ) |
| 146 | | PORT_INCLUDE( galaxy_common ) |
| 146 | PORT_INCLUDE( galaxy_common ) |
| 147 | 147 | INPUT_PORTS_END |
| 148 | 148 | |
| 149 | 149 | static const struct AY8910interface galaxy_ay_interface = |
| r2697 | r2698 | |
| 159 | 159 | static MACHINE_DRIVER_START( galaxy ) |
| 160 | 160 | /* basic machine hardware */ |
| 161 | 161 | MDRV_CPU_ADD(Z80, XTAL / 2) |
| 162 | | MDRV_CPU_PROGRAM_MAP(galaxy_mem, 0) |
| 162 | MDRV_CPU_PROGRAM_MAP(galaxy_mem, 0) |
| 163 | 163 | MDRV_CPU_VBLANK_INT("main", galaxy_interrupt) |
| 164 | 164 | MDRV_SCREEN_ADD("main", RASTER) |
| 165 | 165 | MDRV_SCREEN_REFRESH_RATE(50) |
| r2697 | r2698 | |
| 179 | 179 | |
| 180 | 180 | /* snapshot */ |
| 181 | 181 | MDRV_SNAPSHOT_ADD(galaxy, "gal", 0) |
| 182 | | |
| 182 | |
| 183 | 183 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 184 | 184 | MDRV_SOUND_ADD(WAVE, 0) |
| 185 | 185 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| r2697 | r2698 | |
| 206 | 206 | |
| 207 | 207 | MDRV_VIDEO_START( generic_bitmapped ) |
| 208 | 208 | MDRV_VIDEO_UPDATE( galaxy ) |
| 209 | | |
| 209 | |
| 210 | 210 | /* snapshot */ |
| 211 | 211 | MDRV_SNAPSHOT_ADD(galaxy, "gal", 0) |
| 212 | 212 | |
| r2697 | r2698 | |
| 214 | 214 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 215 | 215 | MDRV_SOUND_ADD(AY8910, XTAL/4) |
| 216 | 216 | MDRV_SOUND_CONFIG(galaxy_ay_interface) |
| 217 | | MDRV_SOUND_ADD(WAVE, 0) |
| 217 | MDRV_SOUND_ADD(WAVE, 0) |
| 218 | 218 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 219 | 219 | MACHINE_DRIVER_END |
| 220 | 220 | |
| r2697 | r2698 | |
| 228 | 228 | |
| 229 | 229 | ROM_START (galaxyp) |
| 230 | 230 | ROM_REGION (0x10000, REGION_CPU1, ROMREGION_ERASEFF) |
| 231 | | ROM_LOAD ("galrom1.bin", 0x0000, 0x1000, CRC(365f3e24) SHA1(ffc6bf2ec09eabdad76604a63f5dd697c30c4358)) |
| 231 | ROM_LOAD ("galrom1.bin", 0x0000, 0x1000, CRC(365f3e24) SHA1(ffc6bf2ec09eabdad76604a63f5dd697c30c4358)) |
| 232 | 232 | ROM_LOAD ("galrom2.bin", 0x1000, 0x1000, CRC(5dc5a100) SHA1(5d5ab4313a2d0effe7572bb129193b64cab002c1)) |
| 233 | | ROM_LOAD ("galplus.bin", 0xe000, 0x1000, CRC(d4cfab14) SHA1(b507b9026844eeb757547679907394aa42055eee)) |
| 233 | ROM_LOAD ("galplus.bin", 0xe000, 0x1000, CRC(d4cfab14) SHA1(b507b9026844eeb757547679907394aa42055eee)) |
| 234 | 234 | ROM_REGION(0x0800, REGION_GFX1,0) |
| 235 | 235 | ROM_LOAD ("galchr.bin", 0x0000, 0x0800, CRC(5c3b5bb5) SHA1(19429a61dc5e55ddec3242a8f695e06dd7961f88)) |
| 236 | 236 | ROM_END |
| r2697 | r2698 | |
| 243 | 243 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 244 | 244 | case MESS_DEVINFO_INT_COUNT: info->i = 1; break; |
| 245 | 245 | case MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE: info->i = CASSETTE_STOPPED | CASSETTE_SPEAKER_ENABLED | CASSETTE_MOTOR_ENABLED; break; |
| 246 | | case MESS_DEVINFO_PTR_CASSETTE_FORMATS: info->p = (void *)gtp_cassette_formats; break; |
| 246 | case MESS_DEVINFO_PTR_CASSETTE_FORMATS: info->p = (void *)gtp_cassette_formats; break; |
| 247 | 247 | default: cassette_device_getinfo(devclass, state, info); break; |
| 248 | 248 | } |
| 249 | 249 | } |
| r2697 | r2698 | |
| 254 | 254 | CONFIG_RAM((6+16) * 1024) |
| 255 | 255 | CONFIG_RAM((6+32) * 1024) |
| 256 | 256 | CONFIG_RAM((6+48) * 1024) |
| 257 | | CONFIG_DEVICE(galaxy_common_cassette_getinfo) |
| 257 | CONFIG_DEVICE(galaxy_common_cassette_getinfo) |
| 258 | 258 | SYSTEM_CONFIG_END |
| 259 | 259 | |
| 260 | 260 | SYSTEM_CONFIG_START(galaxyp) |