src/mess/video/avigo.c
| r12991 | r12992 | |
| 22 | 22 | #define LOG(x) do { if (AVIGO_VIDEO_DEBUG) logerror x; } while (0) |
| 23 | 23 | |
| 24 | 24 | |
| 25 | | static const gfx_layout pointerlayout = |
| 26 | | { |
| 27 | | 8, 8, |
| 28 | | 1, |
| 29 | | 2, |
| 30 | | {0, 64}, |
| 31 | | {0, 1, 2, 3, 4, 5, 6, 7}, |
| 32 | | {0 * 8, 1 * 8, 2 * 8, 3 * 8, 4 * 8, 5 * 8, 6 * 8, 7 * 8}, |
| 33 | | 8 * 8 |
| 34 | | }; |
| 35 | | |
| 36 | | static const UINT8 pointermask[] = |
| 37 | | { |
| 38 | | 0x00, 0x70, 0x60, 0x50, 0x08, 0x04, 0x00, 0x00, /* blackmask */ |
| 39 | | 0xf0, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00 /* whitemask */ |
| 40 | | }; |
| 41 | | |
| 42 | | void avigo_vh_set_stylus_marker_position(running_machine &machine, int x, int y) |
| 43 | | { |
| 44 | | avigo_state *state = machine.driver_data<avigo_state>(); |
| 45 | | state->m_stylus_x = x; |
| 46 | | state->m_stylus_y = y; |
| 47 | | } |
| 48 | | |
| 49 | 25 | READ8_HANDLER(avigo_vid_memory_r) |
| 50 | 26 | { |
| 51 | 27 | avigo_state *state = space->machine().driver_data<avigo_state>(); |
| r12991 | r12992 | |
| 98 | 74 | |
| 99 | 75 | /* allocate video memory */ |
| 100 | 76 | state->m_video_memory = auto_alloc_array_clear(machine, UINT8, ((AVIGO_SCREEN_WIDTH>>3)*AVIGO_SCREEN_HEIGHT+1)); |
| 101 | | machine.gfx[0] = gfx_element_alloc(machine, &pointerlayout, pointermask, machine.total_colors() / 16, 0); |
| 102 | | |
| 103 | | machine.gfx[0]->total_colors = 3; |
| 104 | 77 | } |
| 105 | 78 | |
| 106 | 79 | /* Initialise the palette */ |
| r12991 | r12992 | |
| 124 | 97 | int y; |
| 125 | 98 | int b; |
| 126 | 99 | int x; |
| 127 | | rectangle r; |
| 128 | 100 | |
| 129 | 101 | /* draw avigo display */ |
| 130 | 102 | for (y=0; y<AVIGO_SCREEN_HEIGHT; y++) |
| r12991 | r12992 | |
| 153 | 125 | } |
| 154 | 126 | } |
| 155 | 127 | |
| 156 | | r.min_x = 0; |
| 157 | | r.max_x = AVIGO_SCREEN_WIDTH; |
| 158 | | r.min_y = 0; |
| 159 | | r.max_y = AVIGO_SCREEN_HEIGHT; |
| 160 | | |
| 161 | | /* draw stylus marker */ |
| 162 | | drawgfx_transpen (bitmap, &r, screen->machine().gfx[0], 0, 0, 0, 0, state->m_stylus_x, state->m_stylus_y, 0); |
| 163 | 128 | #if 0 |
| 164 | 129 | { |
| 165 | 130 | |
src/mess/drivers/avigo.c
| r12991 | r12992 | |
| 45 | 45 | #include "machine/ins8250.h" |
| 46 | 46 | #include "sound/speaker.h" |
| 47 | 47 | #include "machine/ram.h" |
| 48 | #include "rendlay.h" |
| 48 | 49 | |
| 49 | 50 | /* |
| 50 | 51 | bit 7: ?? high priority. When it occurs, clear this bit. |
| r12991 | r12992 | |
| 166 | 167 | int i; |
| 167 | 168 | int current_input_port_data[4]; |
| 168 | 169 | int changed; |
| 169 | | int nx,ny; |
| 170 | | int dx, dy; |
| 171 | 170 | static const char *const linenames[] = { "LINE0", "LINE1", "LINE2", "LINE3" }; |
| 172 | 171 | |
| 173 | 172 | for (i = 0; i < 4; i++) |
| r12991 | r12992 | |
| 177 | 176 | |
| 178 | 177 | changed = current_input_port_data[3]^state->m_previous_input_port_data[3]; |
| 179 | 178 | |
| 180 | | if ((changed & 0x01)!=0) |
| 181 | | { |
| 182 | | if ((current_input_port_data[3] & 0x01)!=0) |
| 183 | | { |
| 184 | | /* pen pressed to screen */ |
| 185 | | |
| 186 | | logerror("pen pressed interrupt\n"); |
| 187 | | state->m_stylus_press_x = state->m_stylus_marker_x; |
| 188 | | state->m_stylus_press_y = state->m_stylus_marker_y; |
| 189 | | /* set pen interrupt */ |
| 190 | | state->m_irq |= (1<<6); |
| 191 | | } |
| 192 | | else |
| 193 | | { |
| 194 | | state->m_stylus_press_x = 0; |
| 195 | | state->m_stylus_press_y = 0; |
| 196 | | } |
| 197 | | } |
| 198 | | |
| 199 | 179 | if ((changed & 0x02)!=0) |
| 200 | 180 | { |
| 201 | 181 | if ((current_input_port_data[3] & 0x02)!=0) |
| r12991 | r12992 | |
| 210 | 190 | state->m_previous_input_port_data[i] = current_input_port_data[i]; |
| 211 | 191 | } |
| 212 | 192 | |
| 213 | | nx = input_port_read(timer.machine(), "POSX"); |
| 214 | | if (nx>=0x800) nx-=0x1000; |
| 215 | | else if (nx<=-0x800) nx+=0x1000; |
| 216 | | |
| 217 | | dx = nx - state->m_ox; |
| 218 | | state->m_ox = nx; |
| 219 | | |
| 220 | | ny = input_port_read(timer.machine(), "POSY"); |
| 221 | | if (ny>=0x800) ny-=0x1000; |
| 222 | | else if (ny<=-0x800) ny+=0x1000; |
| 223 | | |
| 224 | | dy = ny - state->m_oy; |
| 225 | | state->m_oy = ny; |
| 226 | | |
| 227 | | state->m_stylus_marker_x +=dx; |
| 228 | | state->m_stylus_marker_y +=dy; |
| 229 | | |
| 230 | | avigo_vh_set_stylus_marker_position(timer.machine(), state->m_stylus_marker_x, state->m_stylus_marker_y); |
| 231 | 193 | #if 0 |
| 232 | 194 | /* not sure if keyboard generates an interrupt, or if something |
| 233 | 195 | is plugged in for synchronisation! */ |
| r12991 | r12992 | |
| 398 | 360 | memcpy(state->m_flashes[0]->space()->get_read_ptr(0), machine.region("maincpu")->base()+0x10000, 0x100000); |
| 399 | 361 | memcpy(state->m_flashes[1]->space()->get_read_ptr(0), machine.region("maincpu")->base()+0x110000, 0x100000); |
| 400 | 362 | |
| 401 | | state->m_stylus_marker_x = AVIGO_SCREEN_WIDTH>>1; |
| 402 | | state->m_stylus_marker_y = AVIGO_SCREEN_HEIGHT>>1; |
| 403 | | state->m_stylus_press_x = 0; |
| 404 | | state->m_stylus_press_y = 0; |
| 405 | | avigo_vh_set_stylus_marker_position(machine, state->m_stylus_marker_x, state->m_stylus_marker_y); |
| 406 | | |
| 407 | 363 | /* initialise settings for port data */ |
| 408 | 364 | for (i = 0; i < 4; i++) |
| 409 | 365 | { |
| r12991 | r12992 | |
| 593 | 549 | if ((data & 0x08)!=0) |
| 594 | 550 | { |
| 595 | 551 | logerror("a/d select x coordinate\n"); |
| 596 | | logerror("x coord: %d\n",state->m_stylus_press_x); |
| 552 | logerror("x coord: %d\n", input_port_read(space->machine(), "POSX")); |
| 597 | 553 | |
| 598 | 554 | /* on screen range 0x060->0x03a0 */ |
| 599 | | /* 832 is on-screen range */ |
| 600 | | /* 5.2 a/d units per pixel */ |
| 601 | | |
| 602 | | if (state->m_stylus_press_x!=0) |
| 555 | if (input_port_read(space->machine(), "LINE3") & 0x01) |
| 603 | 556 | { |
| 604 | 557 | /* this might not be totally accurate because hitable screen |
| 605 | 558 | area may include the border around the screen! */ |
| 606 | | state->m_ad_value = ((int)(state->m_stylus_press_x * 5.2f))+0x060; |
| 607 | | state->m_ad_value &= 0x03fc; |
| 559 | state->m_ad_value = input_port_read(space->machine(), "POSX"); |
| 608 | 560 | } |
| 609 | 561 | else |
| 610 | 562 | { |
| r12991 | r12992 | |
| 612 | 564 | } |
| 613 | 565 | |
| 614 | 566 | logerror("ad value: %d\n",state->m_ad_value); |
| 615 | | state->m_stylus_press_x = 0; |
| 616 | 567 | |
| 617 | 568 | } |
| 618 | 569 | else |
| r12991 | r12992 | |
| 627 | 578 | /* assumption 0x044->0x0350 is screen area and |
| 628 | 579 | 0x0350->0x036a is panel at bottom */ |
| 629 | 580 | |
| 630 | | /* 780 is therefore on-screen range */ |
| 631 | | /* 3.25 a/d units per pixel */ |
| 632 | | /* a/d unit * a/d range = total height */ |
| 633 | | /* 3.25 * 1024.00 = 315.07 */ |
| 634 | | |
| 635 | 581 | logerror("a/d select y coordinate\n"); |
| 636 | | logerror("y coord: %d\n",state->m_stylus_press_y); |
| 582 | logerror("y coord: %d\n", input_port_read(space->machine(), "POSY")); |
| 637 | 583 | |
| 638 | | if (state->m_stylus_press_y!=0) |
| 584 | if (input_port_read(space->machine(), "LINE3") & 0x01) |
| 639 | 585 | { |
| 640 | | state->m_ad_value = 1024 - (((state->m_stylus_press_y)*3.25f) + 0x040); |
| 586 | state->m_ad_value = input_port_read(space->machine(), "POSY"); |
| 641 | 587 | } |
| 642 | 588 | else |
| 643 | 589 | { |
| r12991 | r12992 | |
| 645 | 591 | } |
| 646 | 592 | |
| 647 | 593 | logerror("ad value: %d\n",state->m_ad_value); |
| 648 | | state->m_stylus_press_y = 0; |
| 649 | 594 | } |
| 650 | 595 | } |
| 651 | 596 | |
| r12991 | r12992 | |
| 817 | 762 | ADDRESS_MAP_END |
| 818 | 763 | |
| 819 | 764 | |
| 765 | static INPUT_CHANGED( pen_irq ) |
| 766 | { |
| 767 | avigo_state *state = field.machine().driver_data<avigo_state>(); |
| 820 | 768 | |
| 769 | logerror("pen pressed interrupt\n"); |
| 770 | state->m_irq |= (1<<6); |
| 771 | |
| 772 | avigo_refresh_ints(field.machine()); |
| 773 | } |
| 774 | |
| 821 | 775 | static INPUT_PORTS_START(avigo) |
| 822 | 776 | PORT_START("LINE0") |
| 823 | 777 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PAGE UP") PORT_CODE(KEYCODE_PGUP) |
| r12991 | r12992 | |
| 836 | 790 | PORT_BIT(0x0fe, 0xfe, IPT_UNUSED) |
| 837 | 791 | |
| 838 | 792 | PORT_START("LINE3") |
| 839 | | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Pen/Stylus pressed") PORT_CODE(KEYCODE_Q) PORT_CODE(JOYCODE_BUTTON1) |
| 793 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Pen/Stylus pressed") PORT_CODE(KEYCODE_ENTER) PORT_CODE(MOUSECODE_BUTTON1) PORT_CHANGED( pen_irq, NULL ) |
| 840 | 794 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("?? Causes a NMI") PORT_CODE(KEYCODE_W) PORT_CODE(JOYCODE_BUTTON2) |
| 841 | 795 | |
| 842 | 796 | /* these two ports are used to emulate the position of the pen/stylus on the screen */ |
| 843 | | /* a cursor is drawn to indicate the position, so when a click is done, it will occur in the correct place */ |
| 844 | | /* To be converted to crosshair code? */ |
| 845 | 797 | PORT_START("POSX") /* Mouse - X AXIS */ |
| 846 | | PORT_BIT(0xfff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 798 | PORT_BIT(0x3ff, 0x060, IPT_LIGHTGUN_X) PORT_SENSITIVITY(100) PORT_CROSSHAIR(X, 1, 0, 0) PORT_MINMAX(0x060, 0x3a0) PORT_KEYDELTA(10) PORT_PLAYER(1) |
| 847 | 799 | |
| 848 | 800 | PORT_START("POSY") /* Mouse - Y AXIS */ |
| 849 | | PORT_BIT(0xfff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 801 | PORT_BIT(0x3ff, 0x044, IPT_LIGHTGUN_Y) PORT_SENSITIVITY(100) PORT_CROSSHAIR(Y, 1, 0, 0) PORT_MINMAX(0x044, 0x350) PORT_INVERT PORT_KEYDELTA(10) PORT_PLAYER(1) |
| 850 | 802 | INPUT_PORTS_END |
| 851 | 803 | |
| 852 | 804 | /* F4 Character Displayer */ |
| r12991 | r12992 | |
| 929 | 881 | }; |
| 930 | 882 | |
| 931 | 883 | static GFXDECODE_START( avigo ) |
| 932 | | GFXDECODE_ENTRY( "maincpu", 0x00000, avigo_charlayout, 0, 3 ) |
| 933 | 884 | GFXDECODE_ENTRY( "maincpu", 0x18992, avigo_charlayout, 0, 1 ) |
| 934 | 885 | GFXDECODE_ENTRY( "maincpu", 0x1c020, avigo_8_by_14, 0, 1 ) |
| 935 | 886 | GFXDECODE_ENTRY( "maincpu", 0x1c020, avigo_16_by_15, 0, 1 ) |
| r12991 | r12992 | |
| 939 | 890 | GFXDECODE_END |
| 940 | 891 | |
| 941 | 892 | |
| 893 | static TIMER_DEVICE_CALLBACK( avigo_scan_timer ) |
| 894 | { |
| 895 | avigo_state *state = timer.machine().driver_data<avigo_state>(); |
| 896 | |
| 897 | state->m_irq |= (1<<1); |
| 898 | |
| 899 | avigo_refresh_ints(timer.machine()); |
| 900 | } |
| 901 | |
| 902 | static TIMER_DEVICE_CALLBACK( avigo_1hz_timer ) |
| 903 | { |
| 904 | avigo_state *state = timer.machine().driver_data<avigo_state>(); |
| 905 | |
| 906 | state->m_irq |= (1<<4); |
| 907 | |
| 908 | avigo_refresh_ints(timer.machine()); |
| 909 | } |
| 910 | |
| 942 | 911 | static MACHINE_CONFIG_START( avigo, avigo_state ) |
| 943 | 912 | /* basic machine hardware */ |
| 944 | 913 | MCFG_CPU_ADD("maincpu", Z80, 4000000) |
| r12991 | r12992 | |
| 956 | 925 | MCFG_SCREEN_REFRESH_RATE(50) |
| 957 | 926 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 958 | 927 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 959 | | MCFG_SCREEN_SIZE(640, 480) |
| 960 | | MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 928 | MCFG_SCREEN_SIZE(AVIGO_SCREEN_WIDTH, AVIGO_SCREEN_HEIGHT) |
| 929 | MCFG_SCREEN_VISIBLE_AREA(0, AVIGO_SCREEN_WIDTH-1, 0, AVIGO_SCREEN_HEIGHT-1) |
| 930 | MCFG_DEFAULT_LAYOUT(layout_lcd) |
| 961 | 931 | MCFG_SCREEN_UPDATE( avigo ) |
| 962 | 932 | |
| 963 | 933 | MCFG_GFXDECODE(avigo) |
| r12991 | r12992 | |
| 983 | 953 | MCFG_RAM_ADD(RAM_TAG) |
| 984 | 954 | MCFG_RAM_DEFAULT_SIZE("128K") |
| 985 | 955 | |
| 956 | // IRQ 1 is used for scan the pen and for cursor blinking |
| 957 | MCFG_TIMER_ADD_PERIODIC("scan_timer", avigo_scan_timer, attotime::from_hz(50)) |
| 958 | |
| 959 | // IRQ 4 is generated every second, used for auto power off |
| 960 | MCFG_TIMER_ADD_PERIODIC("1hz_timer", avigo_1hz_timer, attotime::from_hz(1)) |
| 961 | |
| 986 | 962 | /* a timer used to check status of pen */ |
| 987 | 963 | /* an interrupt is generated when the pen is pressed to the screen */ |
| 988 | 964 | MCFG_TIMER_ADD_PERIODIC("avigo_timer", avigo_dummy_timer_callback, attotime::from_hz(50)) |