Previous 15994 Revisions Next

r2718 Saturday 24th May, 2008 at 12:28:03 UTC by Miodrag Milanović
[GALAXYP] Video mode detection as on real machine
[src/mess/machine]galaxy.c
[src/mess/video]galaxy.c

src/mess/video/galaxy.c
r2717r2718
4343UINT32 gal_cnt = 0;
4444static UINT8 code = 0;
4545static UINT8 first = 0;
46
46static UINT8 prev_R = 0;
47static UINT8 add_addr =0;
4748emu_timer *gal_video_timer = NULL;
4849
4950TIMER_CALLBACK( gal_video )
r2717r2718
5354      UINT8 *gfx = memory_region(REGION_GFX1);
5455      UINT8 dat = (gal_latch_value & 0x3c) >> 2;
5556      if ((gal_cnt > 48 * 2) && (gal_cnt < 48 * 210)) { // display on screen just first 208 lines
56         UINT8 mode = cpunum_get_reg(0, Z80_IM);
57         UINT16 addr = (cpunum_get_reg(0, Z80_I) << 8) |  cpunum_get_reg(0, Z80_R) | ((gal_latch_value & 0x80) ^ 0x80);
58              if (mode == 1) {
59                 if (first==0 && (cpunum_get_reg(0, Z80_R) & 0x1f) ==0) {
60                    // Due to a fact that on real processor latch value is set at
61                    // the end of last cycle we need to skip dusplay of double
62                    // first char in each row
63                    code = 0xff;
64                    first = 1;
65               } else {
66                  code = program_read_byte(addr) & 0xbf;
67                  code += (code & 0x80) >> 1;
68                  code = gfx[(code & 0x7f) +(dat << 7 )];
69                  first = 0;
70               }
71               y = gal_cnt / 48 - 2;
72               x = (gal_cnt % 48) * 8;
73               
74               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 0) & 1; x++;
75               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 1) & 1; x++;
76               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 2) & 1; x++;
77               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 3) & 1; x++;
78               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 4) & 1; x++;
79               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 5) & 1; x++;
80               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 6) & 1; x++;
81               *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 7) & 1;
57         UINT8 mode = (gal_latch_value ) & 3; // bit 1 and 2 of latch represents mode
58         UINT16 addr = (cpunum_get_reg(0, Z80_I) << 8) | cpunum_get_reg(0, Z80_R) | ((gal_latch_value & 0x80) ^ 0x80);
59           if (mode == 0){
60              // Text mode
61              if (first==0 && (cpunum_get_reg(0, Z80_R) & 0x1f) ==0) {
62                 // Due to a fact that on real processor latch value is set at
63                 // the end of last cycle we need to skip dusplay of double
64                 // first char in each row
65                 code = 0xff;
66                 first = 1;
67            } else {
68               code = program_read_byte(addr) & 0xbf;
69               code += (code & 0x80) >> 1;
70               code = gfx[(code & 0x7f) +(dat << 7 )];
71               first = 0;
8272            }
83         if (mode == 2) {
73            y = gal_cnt / 48 - 2;
74            x = (gal_cnt % 48) * 8;
75           
76            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 0) & 1; x++;
77            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 1) & 1; x++;
78            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 2) & 1; x++;
79            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 3) & 1; x++;
80            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 4) & 1; x++;
81            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 5) & 1; x++;
82            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 6) & 1; x++;
83            *BITMAP_ADDR16(tmpbitmap, y, x ) = (code >> 7) & 1;
84         }
85         else
86         { // Graphics mode
8487            code = program_read_byte(addr);                           
8588            y = gal_cnt / 48 - 2;
8689            x = (gal_cnt % 48) * 8;
r2717r2718
112115      fillbitmap(tmpbitmap, 1, &black_area);
113116   }
114117   galaxy_interrupts_enabled = FALSE;
118   add_addr = 0;
119   prev_R = 0;
115120   return VIDEO_UPDATE_CALL ( generic_bitmapped );
116121}
117122
src/mess/machine/galaxy.c
r2717r2718
2929UINT8 gal_latch_value = 0;
3030
3131WRITE8_HANDLER( galaxy_latch_w )
32{
33   double val = (((data >>6) & 1 ) + ((data >> 2) & 1) - 1) * 32000;
32{   
33   double val = (((data >>6) & 1 ) + ((data >> 2) & 1) - 1) * 32000;         
3434   gal_latch_value = data;
3535   cassette_output(image_from_devtype_and_index(IO_CASSETTE, 0), val);
3636}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team