src/mess/video/galaxy.c
| r2692 | r2693 | |
| 4 | 4 | |
| 5 | 5 | Functions to emulate the video hardware of the Galaksija. |
| 6 | 6 | |
| 7 | | 01/03/2008 - Update by Miodrag Milanovic to make Galaksija video work with new SVN code |
| 8 | | 21/05/2008 - Real video implementation by Miodrag Milanovic |
| 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 |
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| r2692 | r2693 | |
| 44 | 44 | static UINT8 code = 0; |
| 45 | 45 | static UINT8 first = 0; |
| 46 | 46 | |
| 47 | | INTERRUPT_GEN( gal_video ) |
| 47 | emu_timer *gal_video_timer = NULL; |
| 48 | |
| 49 | TIMER_CALLBACK( gal_video ) |
| 48 | 50 | { |
| 49 | | UINT8 *gfx = memory_region(REGION_GFX1); |
| 50 | | UINT8 dat = (gal_latch_value & 0x3c) >> 2; |
| 51 | | if (gal_cnt < 384 * 212) { // display on screen just first 212 lines |
| 52 | | if ((gal_cnt % 8)==0) { //fetch code |
| 53 | | UINT16 addr = (cpunum_get_reg(0, Z80_I) << 8) | cpunum_get_reg(0, Z80_R) | ((gal_latch_value & 0x80) ^ 0x80); |
| 54 | | if (first==0 && (cpunum_get_reg(0, Z80_R) & 0x1f) ==0) { |
| 55 | | // Due to a fact that on real processor latch value is set at |
| 56 | | // the end of last cycle we need to skip dusplay of double |
| 57 | | // first char in each row |
| 58 | | code = 0xff; |
| 59 | | first = 1; |
| 60 | | } else { |
| 61 | | code = program_read_byte(addr) & 0xbf; |
| 62 | | code += (code & 0x80) >> 1; |
| 63 | | code = gfx[(code & 0x7f) +(dat << 7 )]; |
| 64 | | first = 0; |
| 51 | if (galaxy_interrupts_enabled==TRUE) { |
| 52 | UINT8 *gfx = memory_region(REGION_GFX1); |
| 53 | UINT8 dat = (gal_latch_value & 0x3c) >> 2; |
| 54 | if (gal_cnt < 384 * 212) { // display on screen just first 212 lines |
| 55 | if (((gal_cnt+4) % 8)==0) { //fetch code |
| 56 | UINT16 addr = (cpunum_get_reg(0, Z80_I) << 8) | cpunum_get_reg(0, Z80_R) | ((gal_latch_value & 0x80) ^ 0x80); |
| 57 | if (first==0 && (cpunum_get_reg(0, Z80_R) & 0x1f) ==0) { |
| 58 | // Due to a fact that on real processor latch value is set at |
| 59 | // the end of last cycle we need to skip dusplay of double |
| 60 | // first char in each row |
| 61 | code = 0xff; |
| 62 | first = 1; |
| 63 | } else { |
| 64 | code = program_read_byte(addr) & 0xbf; |
| 65 | code += (code & 0x80) >> 1; |
| 66 | code = gfx[(code & 0x7f) +(dat << 7 )]; |
| 67 | first = 0; |
| 68 | } |
| 65 | 69 | } |
| 66 | | } |
| 67 | | *BITMAP_ADDR16(tmpbitmap, gal_cnt / 384, gal_cnt % 384) = (code >> (gal_cnt & 7)) & 1; |
| 70 | *BITMAP_ADDR16(tmpbitmap, gal_cnt / 384, gal_cnt % 384) = (code >> ((gal_cnt+4) & 7)) & 1; |
| 71 | } |
| 72 | gal_cnt++; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | VIDEO_START ( galaxy ) |
| 77 | { |
| 78 | return VIDEO_START_CALL ( generic_bitmapped ); |
| 79 | } |
| 80 | |
| 81 | VIDEO_UPDATE( galaxy ) |
| 82 | { |
| 83 | timer_adjust_periodic(gal_video_timer, attotime_zero, 0, attotime_never); |
| 84 | if (galaxy_interrupts_enabled == FALSE) { |
| 85 | rectangle black_area = {0,384-1,0,212-2}; |
| 86 | fillbitmap(tmpbitmap, 1, &black_area); |
| 68 | 87 | } |
| 69 | | |
| 70 | | gal_cnt++; |
| 88 | galaxy_interrupts_enabled = FALSE; |
| 89 | return VIDEO_UPDATE_CALL ( generic_bitmapped ); |
| 71 | 90 | } |
| 91 | |
src/mess/machine/galaxy.c
| r2692 | r2693 | |
| 10 | 10 | #include "driver.h" |
| 11 | 11 | #include "cpu/z80/z80.h" |
| 12 | 12 | #include "includes/galaxy.h" |
| 13 | #include "devices/cassette.h" |
| 13 | 14 | |
| 14 | | #define DEBUG_GALAXY_LATCH 0 |
| 15 | | |
| 16 | | #define LOG_GALAXY_LATCH_R(_port, _data) do { if (DEBUG_GALAXY_LATCH) logerror ("Galaxy latch read : %04x, Data: %02x\n", _port, _data); } while (0) |
| 17 | | #define LOG_GALAXY_LATCH_W(_port, _data) do { if (DEBUG_GALAXY_LATCH) logerror ("Galaxy latch write: %04x, Data: %02x\n", _port, _data); } while (0) |
| 18 | | |
| 19 | 15 | /*************************************************************************** |
| 20 | 16 | I/O devices |
| 21 | 17 | ***************************************************************************/ |
| 22 | 18 | |
| 23 | 19 | READ8_HANDLER( galaxy_keyboard_r ) |
| 24 | 20 | { |
| 25 | | return input_port_read_indexed(machine, (offset>>3)&0x07) & (0x01<<(offset&0x07)) ? 0xfe : 0xff; |
| 21 | if (offset == 0) { |
| 22 | double level = cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)); |
| 23 | return (level > 0) ? 0xfe : 0xff; |
| 24 | } else { |
| 25 | return input_port_read_indexed(machine, (offset>>3)&0x07) & (0x01<<(offset&0x07)) ? 0xfe : 0xff; |
| 26 | } |
| 26 | 27 | } |
| 27 | 28 | |
| 28 | | |
| 29 | 29 | UINT8 gal_latch_value = 0; |
| 30 | 30 | |
| 31 | 31 | READ8_HANDLER( galaxy_latch_r ) |
| r2692 | r2693 | |
| 42 | 42 | /*************************************************************************** |
| 43 | 43 | Interrupts |
| 44 | 44 | ***************************************************************************/ |
| 45 | int galaxy_interrupts_enabled = TRUE; |
| 45 | 46 | |
| 46 | 47 | INTERRUPT_GEN( galaxy_interrupt ) |
| 47 | 48 | { |
| r2692 | r2693 | |
| 51 | 52 | IRQ_CALLBACK ( galaxy_irq_callback ) |
| 52 | 53 | { |
| 53 | 54 | gal_cnt = 0; |
| 55 | galaxy_interrupts_enabled = TRUE; |
| 56 | timer_adjust_periodic(gal_video_timer, attotime_zero, 0, ATTOTIME_IN_HZ(6144000)); |
| 54 | 57 | return 1; |
| 55 | 58 | } |
| 56 | 59 | |
| r2692 | r2693 | |
| 172 | 175 | memory_set_bankptr(10, memory_region(REGION_CPU1) + 0x1000); |
| 173 | 176 | |
| 174 | 177 | cpunum_set_irq_callback(0, galaxy_irq_callback); |
| 178 | galaxy_interrupts_enabled = TRUE; |
| 179 | |
| 180 | gal_video_timer = timer_alloc(gal_video, NULL); |
| 181 | timer_adjust_periodic(gal_video_timer, attotime_zero, 0,attotime_never); |
| 175 | 182 | } |
| 176 | 183 | |
| 177 | 184 | DRIVER_INIT( galaxyp ) |
| r2692 | r2693 | |
| 193 | 200 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_BANK11); |
| 194 | 201 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_NOP); |
| 195 | 202 | memory_set_bankptr(11, memory_region(REGION_CPU1) + 0xe000); |
| 203 | galaxy_interrupts_enabled = TRUE; |
| 204 | |
| 205 | gal_video_timer = timer_alloc(gal_video, NULL); |
| 206 | timer_adjust_periodic(gal_video_timer, attotime_zero, 0, attotime_never); |
| 207 | |
| 196 | 208 | } |
src/mess/drivers/galaxy.c
| r2692 | r2693 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | Galaksija driver by Krzysztof Strzecha and Miodrag Milanovic |
| 3 | 3 | |
| 4 | | 22/05/2008 Galaksija plus initial support |
| 5 | | 21/05/2008 Added real video implementation (Miodrag Milanovic) |
| 4 | 22/05/2008 Tape support added (Miodrag Milanovic) |
| 5 | 21/05/2008 Galaksija plus initial support (Miodrag Milanovic) |
| 6 | 20/05/2008 Added real video implementation (Miodrag Milanovic) |
| 6 | 7 | 18/04/2005 Possibilty to disable ROM 2. 2k, 22k, 38k and 54k memory |
| 7 | 8 | configurations added. |
| 8 | 9 | 13/03/2005 Memory mapping improved. Palette corrected. Supprort for newer |
| r2692 | r2693 | |
| 27 | 28 | #include "devices/cassette.h" |
| 28 | 29 | #include "sound/ay8910.h" |
| 29 | 30 | |
| 30 | | static READ8_HANDLER ( galaxy_port_r ) |
| 31 | | { |
| 32 | | return 0; |
| 33 | | } |
| 34 | | |
| 35 | | static WRITE8_HANDLER ( galaxy_port_w ) |
| 36 | | { |
| 37 | | if ((offset & 0x41)==0x01) { // A6 zero A0 active |
| 38 | | AY8910_write_port_0_w(machine,offset, data); |
| 39 | | } |
| 40 | | if ((offset & 0x41)==0x00) { // A6 zero A0 on zero |
| 41 | | AY8910_control_port_0_w(machine,offset, data); |
| 42 | | } |
| 43 | | } |
| 44 | | |
| 45 | | |
| 46 | 31 | static WRITE8_HANDLER ( galaxy_cassette_w ) |
| 47 | 32 | { |
| 48 | 33 | cassette_output(image_from_devtype_and_index(IO_CASSETTE, 0), data); |
| 49 | 34 | } |
| 50 | 35 | |
| 51 | | static ADDRESS_MAP_START (galaxy_io, ADDRESS_SPACE_IO, 8) |
| 52 | | AM_RANGE(0x0000, 0xffff) AM_READWRITE( galaxy_port_r, galaxy_port_w ) |
| 36 | static ADDRESS_MAP_START (galaxyp_io, ADDRESS_SPACE_IO, 8) |
| 37 | ADDRESS_MAP_GLOBAL_MASK(0x01) |
| 38 | ADDRESS_MAP_UNMAP_HIGH |
| 39 | AM_RANGE(0xbe, 0xbe) AM_WRITE(AY8910_control_port_0_w) |
| 40 | AM_RANGE(0xbf, 0xbf) AM_WRITE(AY8910_write_port_0_w) |
| 53 | 41 | ADDRESS_MAP_END |
| 54 | 42 | |
| 55 | 43 | |
| r2692 | r2693 | |
| 177 | 165 | static MACHINE_DRIVER_START( galaxy ) |
| 178 | 166 | /* basic machine hardware */ |
| 179 | 167 | MDRV_CPU_ADD(Z80, XTAL / 2) |
| 180 | | MDRV_CPU_PROGRAM_MAP(galaxy_mem, 0) |
| 181 | | MDRV_CPU_IO_MAP(galaxy_io, 0) |
| 168 | MDRV_CPU_PROGRAM_MAP(galaxy_mem, 0) |
| 182 | 169 | MDRV_CPU_VBLANK_INT("main", galaxy_interrupt) |
| 183 | 170 | MDRV_SCREEN_ADD("main", RASTER) |
| 184 | 171 | MDRV_SCREEN_REFRESH_RATE(50) |
| 185 | | MDRV_CPU_PERIODIC_INT(gal_video,XTAL) |
| 186 | 172 | |
| 187 | 173 | MDRV_MACHINE_RESET( galaxy ) |
| 188 | 174 | |
| r2692 | r2693 | |
| 195 | 181 | MDRV_PALETTE_INIT( galaxy ) |
| 196 | 182 | |
| 197 | 183 | MDRV_VIDEO_START( generic_bitmapped ) |
| 198 | | MDRV_VIDEO_UPDATE( generic_bitmapped ) |
| 184 | MDRV_VIDEO_UPDATE( galaxy ) |
| 199 | 185 | |
| 200 | 186 | /* snapshot */ |
| 201 | 187 | MDRV_SNAPSHOT_ADD(galaxy, "gal", 0) |
| r2692 | r2693 | |
| 209 | 195 | /* basic machine hardware */ |
| 210 | 196 | MDRV_CPU_ADD(Z80, XTAL / 2) |
| 211 | 197 | MDRV_CPU_PROGRAM_MAP(galaxyp_mem, 0) |
| 212 | | MDRV_CPU_IO_MAP(galaxy_io, 0) |
| 198 | MDRV_CPU_IO_MAP(galaxyp_io, 0) |
| 213 | 199 | MDRV_CPU_VBLANK_INT("main", galaxy_interrupt) |
| 214 | 200 | MDRV_SCREEN_ADD("main", RASTER) |
| 215 | 201 | MDRV_SCREEN_REFRESH_RATE(50) |
| 216 | | MDRV_CPU_PERIODIC_INT(gal_video,XTAL) |
| 217 | 202 | |
| 218 | 203 | MDRV_MACHINE_RESET( galaxyp ) |
| 219 | 204 | |
| r2692 | r2693 | |
| 226 | 211 | MDRV_PALETTE_INIT( galaxy ) |
| 227 | 212 | |
| 228 | 213 | MDRV_VIDEO_START( generic_bitmapped ) |
| 229 | | MDRV_VIDEO_UPDATE( generic_bitmapped ) |
| 214 | MDRV_VIDEO_UPDATE( galaxy ) |
| 230 | 215 | |
| 231 | 216 | /* snapshot */ |
| 232 | 217 | MDRV_SNAPSHOT_ADD(galaxy, "gal", 0) |