Previous 15994 Revisions Next

r2693 Thursday 22nd May, 2008 at 14:09:03 UTC by Miodrag Milanović
[GALAXY] Fixed video and tape is working
[src/mess/drivers]galaxy.c
[src/mess/includes]galaxy.h
[src/mess/machine]galaxy.c
[src/mess/video]galaxy.c

src/mess/includes/galaxy.h
r2692r2693
1212
1313/*----------- defined in machine/galaxy.c -----------*/
1414
15extern int galaxy_interrupts_enabled;
16
1517extern DRIVER_INIT( galaxy );
1618extern MACHINE_RESET( galaxy );
1719extern INTERRUPT_GEN( galaxy_interrupt );
r2692r2693
3234extern const gfx_layout galaxy_charlayout;
3335extern const unsigned char galaxy_palette[2*3];
3436extern PALETTE_INIT( galaxy );
35extern INTERRUPT_GEN( gal_video );
3637
38extern VIDEO_START( galaxy );
39extern VIDEO_UPDATE( galaxy );
40extern TIMER_CALLBACK( gal_video );
3741
42extern emu_timer *gal_video_timer;
43
3844#endif /* GALAXY_H_ */
src/mess/video/galaxy.c
r2692r2693
44
55  Functions to emulate the video hardware of the Galaksija.
66 
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 
99***************************************************************************/
1010
1111#include "driver.h"
r2692r2693
4444static UINT8 code = 0;
4545static UINT8 first = 0;
4646
47INTERRUPT_GEN( gal_video )
47emu_timer *gal_video_timer = NULL;
48
49TIMER_CALLBACK( gal_video )
4850{   
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            }
6569         }
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
76VIDEO_START ( galaxy )
77{
78   return VIDEO_START_CALL ( generic_bitmapped );
79}
80
81VIDEO_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);           
6887   }
69   
70   gal_cnt++;           
88   galaxy_interrupts_enabled = FALSE;     
89   return VIDEO_UPDATE_CALL ( generic_bitmapped );
7190}
91
src/mess/machine/galaxy.c
r2692r2693
1010#include "driver.h"
1111#include "cpu/z80/z80.h"
1212#include "includes/galaxy.h"
13#include "devices/cassette.h"
1314
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
1915/***************************************************************************
2016  I/O devices
2117***************************************************************************/
2218
2319READ8_HANDLER( galaxy_keyboard_r )
2420{
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   }
2627}
2728
28
2929UINT8 gal_latch_value = 0;
3030
3131READ8_HANDLER( galaxy_latch_r )
r2692r2693
4242/***************************************************************************
4343  Interrupts
4444***************************************************************************/
45int galaxy_interrupts_enabled = TRUE;
4546
4647INTERRUPT_GEN( galaxy_interrupt )
4748{   
r2692r2693
5152IRQ_CALLBACK ( galaxy_irq_callback )
5253{
5354   gal_cnt = 0;
55   galaxy_interrupts_enabled = TRUE;
56   timer_adjust_periodic(gal_video_timer, attotime_zero, 0, ATTOTIME_IN_HZ(6144000));
5457   return 1;
5558}
5659
r2692r2693
172175   memory_set_bankptr(10, memory_region(REGION_CPU1) + 0x1000);
173176
174177   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);
175182}
176183
177184DRIVER_INIT( galaxyp )
r2692r2693
193200   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_BANK11);
194201   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe000, 0xefff, 0, 0, SMH_NOP);   
195202   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
196208}
src/mess/drivers/galaxy.c
r2692r2693
11/***************************************************************************
22Galaksija driver by Krzysztof Strzecha and Miodrag Milanovic
33
422/05/2008 Galaksija plus initial support
521/05/2008 Added real video implementation (Miodrag Milanovic)
422/05/2008 Tape support added (Miodrag Milanovic)
521/05/2008 Galaksija plus initial support (Miodrag Milanovic)
620/05/2008 Added real video implementation (Miodrag Milanovic)
6718/04/2005 Possibilty to disable ROM 2. 2k, 22k, 38k and 54k memory
78       configurations added.
8913/03/2005 Memory mapping improved. Palette corrected. Supprort for newer
r2692r2693
2728#include "devices/cassette.h"
2829#include "sound/ay8910.h"
2930
30static  READ8_HANDLER ( galaxy_port_r )
31{
32    return 0;
33}
34
35static 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
4631static WRITE8_HANDLER ( galaxy_cassette_w )
4732{
4833   cassette_output(image_from_devtype_and_index(IO_CASSETTE, 0), data);
4934}
5035
51static ADDRESS_MAP_START (galaxy_io, ADDRESS_SPACE_IO, 8)
52   AM_RANGE(0x0000, 0xffff) AM_READWRITE( galaxy_port_r, galaxy_port_w )
36static 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)
5341ADDRESS_MAP_END
5442
5543
r2692r2693
177165static MACHINE_DRIVER_START( galaxy )
178166   /* basic machine hardware */
179167   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)   
182169   MDRV_CPU_VBLANK_INT("main", galaxy_interrupt)
183170   MDRV_SCREEN_ADD("main", RASTER)
184171   MDRV_SCREEN_REFRESH_RATE(50)
185   MDRV_CPU_PERIODIC_INT(gal_video,XTAL)
186172
187173   MDRV_MACHINE_RESET( galaxy )
188174
r2692r2693
195181   MDRV_PALETTE_INIT( galaxy )
196182
197183   MDRV_VIDEO_START( generic_bitmapped )
198   MDRV_VIDEO_UPDATE( generic_bitmapped )
184   MDRV_VIDEO_UPDATE( galaxy )
199185
200186   /* snapshot */
201187   MDRV_SNAPSHOT_ADD(galaxy, "gal", 0)
r2692r2693
209195   /* basic machine hardware */
210196   MDRV_CPU_ADD(Z80, XTAL / 2)
211197   MDRV_CPU_PROGRAM_MAP(galaxyp_mem, 0)
212   MDRV_CPU_IO_MAP(galaxy_io, 0)
198   MDRV_CPU_IO_MAP(galaxyp_io, 0)
213199   MDRV_CPU_VBLANK_INT("main", galaxy_interrupt)
214200   MDRV_SCREEN_ADD("main", RASTER)
215201   MDRV_SCREEN_REFRESH_RATE(50)
216   MDRV_CPU_PERIODIC_INT(gal_video,XTAL)
217202
218203   MDRV_MACHINE_RESET( galaxyp )
219204
r2692r2693
226211   MDRV_PALETTE_INIT( galaxy )
227212
228213   MDRV_VIDEO_START( generic_bitmapped )
229   MDRV_VIDEO_UPDATE( generic_bitmapped )
214   MDRV_VIDEO_UPDATE( galaxy )
230215   
231216   /* snapshot */
232217   MDRV_SNAPSHOT_ADD(galaxy, "gal", 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team