src/mess/drivers/einstein.c
| r1170 | r1171 | |
| 93 | 93 | #include "devices/printer.h" |
| 94 | 94 | #include "sound/ay8910.h" |
| 95 | 95 | #include "image.h" |
| 96 | #include "video/crtc6845.h" |
| 96 | 97 | |
| 97 | 98 | #define EINSTEIN_SYSTEM_CLOCK 4000000 |
| 98 | 99 | |
| r1170 | r1171 | |
| 153 | 154 | |
| 154 | 155 | |
| 155 | 156 | */ |
| 156 | | #include "video/m6845.h" |
| 157 | #include "video/crtc6845.h" |
| 157 | 158 | static int einstein_80col_state; |
| 158 | 159 | static char *einstein_80col_ram = NULL; |
| 159 | 160 | |
| r1170 | r1171 | |
| 177 | 178 | return einstein_80col_state; |
| 178 | 179 | } |
| 179 | 180 | |
| 180 | | static int Einstein_6845_RA = 0; |
| 181 | | static int Einstein_scr_x = 0; |
| 181 | //static int Einstein_6845_RA = 0; |
| 182 | //static int Einstein_scr_x = 0; |
| 182 | 183 | static int Einstein_scr_y = 0; |
| 183 | | static int Einstein_HSync = 0; |
| 184 | | static int Einstein_VSync = 0; |
| 185 | | static int Einstein_DE = 0; |
| 184 | //static int Einstein_HSync = 0; |
| 185 | //static int Einstein_VSync = 0; |
| 186 | //static int Einstein_DE = 0; |
| 186 | 187 | |
| 187 | | // called when the 6845 changes the character row |
| 188 | | static void Einstein_Set_RA(int offset, int data) |
| 189 | | { |
| 190 | | Einstein_6845_RA=data; |
| 191 | | } |
| 188 | //// called when the 6845 changes the character row |
| 189 | //static void Einstein_Set_RA(int offset, int data) |
| 190 | //{ |
| 191 | // Einstein_6845_RA=data; |
| 192 | //} |
| 193 | // |
| 194 | // |
| 195 | //// called when the 6845 changes the HSync |
| 196 | //static void Einstein_Set_HSync(int offset, int data) |
| 197 | //{ |
| 198 | // Einstein_HSync=data; |
| 199 | // if(!Einstein_HSync) |
| 200 | // { |
| 201 | // Einstein_scr_y++; |
| 202 | // Einstein_scr_x = -40; |
| 203 | // } |
| 204 | //} |
| 205 | // |
| 206 | //// called when the 6845 changes the VSync |
| 207 | //static void Einstein_Set_VSync(int offset, int data) |
| 208 | //{ |
| 209 | // Einstein_VSync=data; |
| 210 | // if (!Einstein_VSync) |
| 211 | // { |
| 212 | // Einstein_scr_y = 0; |
| 213 | // } |
| 214 | //} |
| 215 | // |
| 216 | //static void Einstein_Set_DE(int offset, int data) |
| 217 | //{ |
| 218 | // Einstein_DE = data; |
| 219 | //} |
| 192 | 220 | |
| 193 | 221 | |
| 194 | | // called when the 6845 changes the HSync |
| 195 | | static void Einstein_Set_HSync(int offset, int data) |
| 196 | | { |
| 197 | | Einstein_HSync=data; |
| 198 | | if(!Einstein_HSync) |
| 199 | | { |
| 200 | | Einstein_scr_y++; |
| 201 | | Einstein_scr_x = -40; |
| 222 | //static struct m6845_interface |
| 223 | //einstein_m6845_interface= { |
| 224 | // 0,// Memory Address register |
| 225 | // Einstein_Set_RA,// Row Address register |
| 226 | // Einstein_Set_HSync,// Horizontal status |
| 227 | // Einstein_Set_VSync,// Vertical status |
| 228 | // Einstein_Set_DE,// Display Enabled status |
| 229 | // 0,// Cursor status |
| 230 | //}; |
| 231 | |
| 232 | static void einstein_6845_update_row(mame_bitmap *bitmap, const rectangle *cliprect, UINT16 ma, |
| 233 | UINT8 ra, UINT16 y, UINT8 x_count, void *param) { |
| 234 | /* TODO: Verify implementation */ |
| 235 | unsigned char *data = memory_region(REGION_CPU1) + 0x012000; |
| 236 | unsigned char data_byte; |
| 237 | int char_code; |
| 238 | int i, x; |
| 239 | |
| 240 | for ( i = 0, x = 0; i < x_count; i++, x+=8 ) { |
| 241 | int w; |
| 242 | char_code = einstein_80col_ram[(ma + i)&0x07ff]; |
| 243 | data_byte = data[(char_code<<3) + ra]; |
| 244 | for (w=0; w<8;w++) { |
| 245 | *BITMAP_ADDR16(bitmap, y, x+w) = (data_byte & 0x080) ? 1 : 0; |
| 246 | data_byte = data_byte<<1; |
| 247 | } |
| 202 | 248 | } |
| 203 | 249 | } |
| 204 | 250 | |
| 205 | | // called when the 6845 changes the VSync |
| 206 | | static void Einstein_Set_VSync(int offset, int data) |
| 207 | | { |
| 208 | | Einstein_VSync=data; |
| 209 | | if (!Einstein_VSync) |
| 210 | | { |
| 211 | | Einstein_scr_y = 0; |
| 251 | static void einstein_6845_display_enable_changed(int display_enabled) { |
| 252 | /* TODO: Implement me properly */ |
| 253 | if ( display_enabled ) { |
| 254 | Einstein_scr_y = ( Einstein_scr_y + 1 ) % 240 /*?*/; |
| 212 | 255 | } |
| 213 | 256 | } |
| 214 | 257 | |
| 215 | | static void Einstein_Set_DE(int offset, int data) |
| 216 | | { |
| 217 | | Einstein_DE = data; |
| 218 | | } |
| 219 | | |
| 220 | | |
| 221 | | static struct m6845_interface |
| 222 | | einstein_m6845_interface= { |
| 223 | | 0,// Memory Address register |
| 224 | | Einstein_Set_RA,// Row Address register |
| 225 | | Einstein_Set_HSync,// Horizontal status |
| 226 | | Einstein_Set_VSync,// Vertical status |
| 227 | | Einstein_Set_DE,// Display Enabled status |
| 228 | | 0,// Cursor status |
| 258 | static const crtc6845_interface einstein_crtc6845_interface = { |
| 259 | 0, |
| 260 | EINSTEIN_SYSTEM_CLOCK /*?*/, |
| 261 | 8 /*?*/, |
| 262 | NULL, |
| 263 | einstein_6845_update_row, |
| 264 | NULL, |
| 265 | einstein_6845_display_enable_changed |
| 229 | 266 | }; |
| 230 | 267 | |
| 231 | 268 | /* 80 column card init */ |
| r1170 | r1171 | |
| 235 | 272 | einstein_80col_ram = auto_malloc(2048); |
| 236 | 273 | |
| 237 | 274 | /* initialise 6845 */ |
| 238 | | m6845_config(&einstein_m6845_interface); |
| 275 | crtc6845_config( 0, &einstein_crtc6845_interface ); |
| 239 | 276 | |
| 240 | 277 | einstein_80col_state=(1<<2)|(1<<1); |
| 241 | 278 | } |
| r1170 | r1171 | |
| 277 | 314 | einstein_80col_ram_w(offset,data); |
| 278 | 315 | break; |
| 279 | 316 | case 8: |
| 280 | | m6845_address_w(offset,data); |
| 317 | crtc6845_0_address_w(offset,data); |
| 281 | 318 | break; |
| 282 | 319 | case 9: |
| 283 | | m6845_register_w(offset,data); |
| 320 | crtc6845_0_register_w(offset,data); |
| 284 | 321 | break; |
| 285 | 322 | default: |
| 286 | 323 | break; |
| r1170 | r1171 | |
| 1592 | 1629 | 127*262 = 33274 cycles per frame, vsync len 375 cycles |
| 1593 | 1630 | */ |
| 1594 | 1631 | |
| 1595 | | static void einstein_80col_plot_char_line(int x,int y, mame_bitmap *bitmap) |
| 1596 | | { |
| 1597 | | int w; |
| 1598 | | if (Einstein_DE) |
| 1599 | | { |
| 1632 | //static void einstein_80col_plot_char_line(int x,int y, mame_bitmap *bitmap) |
| 1633 | //{ |
| 1634 | // int w; |
| 1635 | // if (Einstein_DE) |
| 1636 | // { |
| 1637 | // |
| 1638 | // unsigned char *data = memory_region(REGION_CPU1)+0x012000; |
| 1639 | // unsigned char data_byte; |
| 1640 | // int char_code; |
| 1641 | // |
| 1642 | // char_code = einstein_80col_ram[m6845_memory_address_r(0)&0x07ff]; |
| 1643 | // |
| 1644 | // data_byte = data[(char_code<<3) + Einstein_6845_RA]; |
| 1645 | // |
| 1646 | // for (w=0; w<8;w++) |
| 1647 | // { |
| 1648 | // *BITMAP_ADDR16(bitmap, y, x+w) = (data_byte & 0x080) ? 1 : 0; |
| 1649 | // |
| 1650 | // data_byte = data_byte<<1; |
| 1651 | // |
| 1652 | // } |
| 1653 | // } |
| 1654 | // else |
| 1655 | // { |
| 1656 | // for (w=0; w<8;w++) |
| 1657 | // *BITMAP_ADDR16(bitmap, y, x+w) = 0; |
| 1658 | // } |
| 1659 | // |
| 1660 | //} |
| 1661 | // |
| 1662 | //static VIDEO_UPDATE( einstein_80col ) |
| 1663 | //{ |
| 1664 | // long c=0; // this is used to time out the screen redraw, in the case that the 6845 is in some way out state. |
| 1665 | // |
| 1666 | // c=0; |
| 1667 | // |
| 1668 | // // loop until the end of the Vertical Sync pulse |
| 1669 | // while((Einstein_VSync)&&(c<33274)) |
| 1670 | // { |
| 1671 | // // Clock the 6845 |
| 1672 | // m6845_clock(); |
| 1673 | // c++; |
| 1674 | // } |
| 1675 | // |
| 1676 | // // loop until the Vertical Sync pulse goes high |
| 1677 | // // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal) |
| 1678 | // while((!Einstein_VSync)&&(c<33274)) |
| 1679 | // { |
| 1680 | // while ((Einstein_HSync)&&(c<33274)) |
| 1681 | // { |
| 1682 | // m6845_clock(); |
| 1683 | // c++; |
| 1684 | // } |
| 1685 | // // Do all the clever split mode changes in here before the next while loop |
| 1686 | // |
| 1687 | // while ((!Einstein_HSync)&&(c<33274)) |
| 1688 | // { |
| 1689 | // // check that we are on the emulated screen area. |
| 1690 | // if ((Einstein_scr_x>=0) && (Einstein_scr_x<640) && (Einstein_scr_y>=0) && (Einstein_scr_y<400)) |
| 1691 | // { |
| 1692 | // einstein_80col_plot_char_line(Einstein_scr_x, Einstein_scr_y, bitmap); |
| 1693 | // } |
| 1694 | // |
| 1695 | // Einstein_scr_x+=8; |
| 1696 | // |
| 1697 | // // Clock the 6845 |
| 1698 | // m6845_clock(); |
| 1699 | // c++; |
| 1700 | // } |
| 1701 | // } |
| 1702 | // return 0; |
| 1703 | //} |
| 1600 | 1704 | |
| 1601 | | unsigned char *data = memory_region(REGION_CPU1)+0x012000; |
| 1602 | | unsigned char data_byte; |
| 1603 | | int char_code; |
| 1604 | | |
| 1605 | | char_code = einstein_80col_ram[m6845_memory_address_r(0)&0x07ff]; |
| 1606 | | |
| 1607 | | data_byte = data[(char_code<<3) + Einstein_6845_RA]; |
| 1608 | | |
| 1609 | | for (w=0; w<8;w++) |
| 1610 | | { |
| 1611 | | *BITMAP_ADDR16(bitmap, y, x+w) = (data_byte & 0x080) ? 1 : 0; |
| 1612 | | |
| 1613 | | data_byte = data_byte<<1; |
| 1614 | | |
| 1615 | | } |
| 1616 | | } |
| 1617 | | else |
| 1618 | | { |
| 1619 | | for (w=0; w<8;w++) |
| 1620 | | *BITMAP_ADDR16(bitmap, y, x+w) = 0; |
| 1621 | | } |
| 1622 | | |
| 1623 | | } |
| 1624 | | |
| 1625 | | static VIDEO_UPDATE( einstein_80col ) |
| 1626 | | { |
| 1627 | | long c=0; // this is used to time out the screen redraw, in the case that the 6845 is in some way out state. |
| 1628 | | |
| 1629 | | c=0; |
| 1630 | | |
| 1631 | | // loop until the end of the Vertical Sync pulse |
| 1632 | | while((Einstein_VSync)&&(c<33274)) |
| 1633 | | { |
| 1634 | | // Clock the 6845 |
| 1635 | | m6845_clock(); |
| 1636 | | c++; |
| 1637 | | } |
| 1638 | | |
| 1639 | | // loop until the Vertical Sync pulse goes high |
| 1640 | | // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal) |
| 1641 | | while((!Einstein_VSync)&&(c<33274)) |
| 1642 | | { |
| 1643 | | while ((Einstein_HSync)&&(c<33274)) |
| 1644 | | { |
| 1645 | | m6845_clock(); |
| 1646 | | c++; |
| 1647 | | } |
| 1648 | | // Do all the clever split mode changes in here before the next while loop |
| 1649 | | |
| 1650 | | while ((!Einstein_HSync)&&(c<33274)) |
| 1651 | | { |
| 1652 | | // check that we are on the emulated screen area. |
| 1653 | | if ((Einstein_scr_x>=0) && (Einstein_scr_x<640) && (Einstein_scr_y>=0) && (Einstein_scr_y<400)) |
| 1654 | | { |
| 1655 | | einstein_80col_plot_char_line(Einstein_scr_x, Einstein_scr_y, bitmap); |
| 1656 | | } |
| 1657 | | |
| 1658 | | Einstein_scr_x+=8; |
| 1659 | | |
| 1660 | | // Clock the 6845 |
| 1661 | | m6845_clock(); |
| 1662 | | c++; |
| 1663 | | } |
| 1664 | | } |
| 1665 | | return 0; |
| 1666 | | } |
| 1667 | | |
| 1668 | 1705 | static VIDEO_UPDATE( einstein2 ) |
| 1669 | 1706 | { |
| 1670 | 1707 | video_update_tms9928a(machine, screen, bitmap, cliprect); |
| 1671 | | video_update_einstein_80col(machine, screen, bitmap, cliprect); |
| 1708 | video_update_crtc6845(machine, screen, bitmap, cliprect); |
| 1709 | // video_update_einstein_80col(machine, screen, bitmap, cliprect); |
| 1672 | 1710 | return 0; |
| 1673 | 1711 | } |
| 1674 | 1712 | |