Previous 15994 Revisions Next

r2679 Wednesday 21st May, 2008 at 08:51:59 UTC by Miodrag Milanović
[GALAXY] Real video implementation
[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
r2678r2679
1616extern MACHINE_RESET( galaxy );
1717extern INTERRUPT_GEN( galaxy_interrupt );
1818extern SNAPSHOT_LOAD( galaxy );
19extern int galaxy_interrupts_enabled;
2019extern READ8_HANDLER( galaxy_keyboard_r );
2120extern READ8_HANDLER( galaxy_latch_r );
2221extern WRITE8_HANDLER( galaxy_latch_w );
2322
23extern MACHINE_RESET( galaxyp );
2424
25extern UINT32 gal_cnt;
26extern UINT8 gal_latch_value;
27
2528/*----------- defined in video/galaxy.c -----------*/
2629
2730extern const gfx_layout galaxy_charlayout;
2831extern const unsigned char galaxy_palette[2*3];
29extern const unsigned short galaxy_colortable[1][2];
3032extern PALETTE_INIT( galaxy );
31extern VIDEO_START( galaxy );
32extern VIDEO_UPDATE( galaxy );
33extern INTERRUPT_GEN( gal_video );
3334
3435
3536#endif /* GALAXY_H_ */
src/mess/video/galaxy.c
r2678r2679
55  Functions to emulate the video hardware of the Galaksija.
66 
77  01/03/2008 - Update by Miodrag Milanovic to make Galaksija video work with new SVN code
8
8  21/05/2008 - Real video implementation by Miodrag Milanovic
99***************************************************************************/
1010
1111#include "driver.h"
1212#include "includes/galaxy.h"
1313#include "cpu/z80/z80.h"
1414
15static int horizontal_pos = 0x0b;
16
1715const gfx_layout galaxy_charlayout =
1816{
1917   8, 13,            /* 8x8 characters */
r2678r2679
4240   }
4341}
4442
45VIDEO_START( galaxy )
46{
47}
43UINT32 gal_cnt = 0;
44static UINT8 code = 0;
45static UINT8 first = 0;
4846
49VIDEO_UPDATE( galaxy )
50{
51   int offs;
52   rectangle black_area = {0,0,0,16*13};
53   static int fast_mode = FALSE;
54   int full_refresh = 1;
55
56   UINT8* videoram = mess_ram;
57
58   if (!galaxy_interrupts_enabled)
59   {
60      black_area.min_x = 0;
61      black_area.max_x = 32*8-1;
62      black_area.min_y = 0;
63      black_area.max_y = 16*13-1;
64      fillbitmap(bitmap, 1, &black_area);
65      fast_mode = TRUE;
66      return 0;
67   }
68
69   if (horizontal_pos!=program_read_byte(0x2ba8))
70   {
71      full_refresh=1;
72      horizontal_pos = program_read_byte(0x2ba8);
73      if (horizontal_pos > 0x0b)
74      {
75         black_area.min_x =  0;
76         black_area.max_x =  8*(horizontal_pos-0x0b)-1;
47INTERRUPT_GEN( gal_video )
48{   
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;           
65         }
7766      }
78      if (horizontal_pos < 0x0b)
79      {
80         black_area.min_x = 8*(21+horizontal_pos);
81         black_area.max_x = 32*8-1;
82      }
83      if (horizontal_pos == 0x0b)
84         black_area.min_x =  black_area.max_x = 0;
85      fillbitmap(bitmap, 1, &black_area);
67      *BITMAP_ADDR16(tmpbitmap, gal_cnt / 384, gal_cnt % 384) = (code >> (gal_cnt & 7)) & 1;
8668   }
87
88   for( offs = 0; offs < 512; offs++ )
89   {
90      int sx, sy;
91      int code = videoram[offs];
92
93      sx = (offs % 32) * 8 + horizontal_pos*8-88;
94
95      if (sx>=0 && sx<32*8)
96      {
97         if ((code>63 && code<96) || (code>127 && code<192))
98            code-=64;
99         if (code>191)
100            code-=128;
101         sy = (offs / 32) * 13;
102         drawgfx(bitmap, screen->machine->gfx[0], code & 0x7f, 0, 0,0, sx,sy,
103            NULL, TRANSPARENCY_NONE, 0);
104      }
105   }
106
107   galaxy_interrupts_enabled = FALSE;
108   return 0;
69   
70   gal_cnt++;           
10971}
src/mess/machine/galaxy.c
r2678r2679
1616#define LOG_GALAXY_LATCH_R(_port, _data) do { if (DEBUG_GALAXY_LATCH) logerror ("Galaxy latch read : %04x, Data: %02x\n", _port, _data); } while (0)
1717#define LOG_GALAXY_LATCH_W(_port, _data) do { if (DEBUG_GALAXY_LATCH) logerror ("Galaxy latch write: %04x, Data: %02x\n", _port, _data); } while (0)
1818
19int galaxy_interrupts_enabled = TRUE;
20
2119/***************************************************************************
2220  I/O devices
2321***************************************************************************/
r2678r2679
2725   return input_port_read_indexed(machine, (offset>>3)&0x07) & (0x01<<(offset&0x07)) ? 0xfe : 0xff;
2826}
2927
28
29UINT8 gal_latch_value = 0;
30
3031READ8_HANDLER( galaxy_latch_r )
3132{
32   UINT8 data = 0xff;
33   LOG_GALAXY_LATCH_R(offset, data);
34   return data;
33   return 0xff;   
3534}
36
3735WRITE8_HANDLER( galaxy_latch_w )
38{
39   LOG_GALAXY_LATCH_W(offset, data);
36{   
37   gal_latch_value = data;   
4038}
4139
40
41
4242/***************************************************************************
4343  Interrupts
4444***************************************************************************/
4545
4646INTERRUPT_GEN( galaxy_interrupt )
47{
48   cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
47{   
48   cpunum_set_input_line(machine, 0, 0, HOLD_LINE);   
4949}
5050
51static IRQ_CALLBACK(galaxy_irq_callback)
51IRQ_CALLBACK ( galaxy_irq_callback )
5252{
53   galaxy_interrupts_enabled = TRUE;
53   gal_cnt = 0;
5454   return 1;
5555}
5656
r2678r2679
168168{
169169   /* ROM 2 enable/disable */
170170   memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, input_port_read_indexed(machine, 7) ? SMH_BANK10 : SMH_NOP);
171   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, SMH_NOP);
172   if (input_port_read_indexed(machine, 7))
173      memory_set_bankptr(10, memory_region(REGION_CPU1) + 0x1000);
171   memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x1000, 0x1fff, 0, 0, SMH_NOP);   
172   memory_set_bankptr(10, memory_region(REGION_CPU1) + 0x1000);
174173
175174   cpunum_set_irq_callback(0, galaxy_irq_callback);
176
177   galaxy_interrupts_enabled = TRUE;
178175}
src/mess/drivers/galaxy.c
r2678r2679
11/***************************************************************************
22Galaksija driver by Krzysztof Strzecha
33
421/05/2008 Added real video implementation (Miodrag Milanovic)
4518/04/2005 Possibilty to disable ROM 2. 2k, 22k, 38k and 54k memory
56       configurations added.
6713/03/2005 Memory mapping improved. Palette corrected. Supprort for newer
r2678r2679
171801/01/2001 Preliminary driver.
1819
1920To do:
20-Video subsystem 'real' emulation
2121-Tape
2222-Galaksija Plus
2323
r2678r2679
4141   AM_RANGE(0x2038, 0x203f) AM_MIRROR(0x07c0) AM_READWRITE( galaxy_latch_r, galaxy_latch_w )
4242ADDRESS_MAP_END
4343
44
4544static GFXDECODE_START( galaxy )
4645   GFXDECODE_ENTRY( REGION_GFX1, 0x0000, galaxy_charlayout, 0, 2 )
4746GFXDECODE_END
r2678r2679
129128      PORT_CONFSETTING(   0x00, "Not installed")
130129INPUT_PORTS_END
131130
131
132#define XTAL 6144000
133
134
132135static MACHINE_DRIVER_START( galaxy )
133136   /* basic machine hardware */
134   MDRV_CPU_ADD(Z80, 3072000)
137   MDRV_CPU_ADD(Z80, XTAL / 2)
135138   MDRV_CPU_PROGRAM_MAP(galaxy_mem, 0)
136139   MDRV_CPU_IO_MAP(galaxy_readport, galaxy_writeport)
137140   MDRV_CPU_VBLANK_INT("main", galaxy_interrupt)
138141   MDRV_SCREEN_ADD("main", RASTER)
139142   MDRV_SCREEN_REFRESH_RATE(50)
140   MDRV_SCREEN_VBLANK_TIME(0)
141   MDRV_INTERLEAVE(1)
143   MDRV_CPU_PERIODIC_INT(gal_video,XTAL)
142144
143145   MDRV_MACHINE_RESET( galaxy )
144146
145147   /* video hardware */
146148   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
147   MDRV_SCREEN_SIZE(256, 208)
148   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 0, 208-1)
149   MDRV_SCREEN_SIZE(384, 212)
150   MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 0, 212-1)
149151   MDRV_GFXDECODE( galaxy )
150152   MDRV_PALETTE_LENGTH(sizeof (galaxy_palette) / 3)
151153   MDRV_PALETTE_INIT( galaxy )
152154
153   MDRV_VIDEO_START( galaxy )
154   MDRV_VIDEO_UPDATE( galaxy )
155   MDRV_VIDEO_START( generic_bitmapped )
156   MDRV_VIDEO_UPDATE( generic_bitmapped )
155157
156158   /* snapshot */
157159   MDRV_SNAPSHOT_ADD(galaxy, "gal", 0)
r2678r2679
165167   ROM_LOAD ("galchr.bin", 0x0000, 0x0800, CRC(5c3b5bb5) SHA1(19429a61dc5e55ddec3242a8f695e06dd7961f88))
166168ROM_END
167169
170
168171SYSTEM_CONFIG_START(galaxy)
169172   CONFIG_RAM(2 * 1024)
170173   CONFIG_RAM_DEFAULT(6 * 1024)
r2678r2679
174177SYSTEM_CONFIG_END
175178
176179/*    YEAR  NAME    PARENT  COMPAT  MACHINE INPUT   INIT    CONFIG  COMPANY FULLNAME */
177COMP(1983,   galaxy,   0,   0,   galaxy,   galaxy,   galaxy,   galaxy,   "",   "Galaksija", 0)
180COMP(1983,   galaxy,      0,      0,   galaxy,   galaxy,   galaxy,   galaxy,   "Elektronika inzenjering",         "Galaksija",      0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team