Previous 15994 Revisions Next

r12992 Tuesday 4th October, 2011 at 18:19:36 UTC by Sandro Ronco
avigo: Converted to use crosshair and fixed pen input. (no whatsnew)
[src/mess/drivers]avigo.c
[src/mess/includes]avigo.h
[src/mess/video]avigo.c

src/mess/video/avigo.c
r12991r12992
2222#define LOG(x) do { if (AVIGO_VIDEO_DEBUG) logerror x; } while (0)
2323
2424
25static 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
36static 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
42void 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
4925READ8_HANDLER(avigo_vid_memory_r)
5026{
5127   avigo_state *state = space->machine().driver_data<avigo_state>();
r12991r12992
9874
9975   /* allocate video memory */
10076   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;
10477}
10578
10679/* Initialise the palette */
r12991r12992
12497   int y;
12598   int b;
12699   int x;
127   rectangle r;
128100
129101   /* draw avigo display */
130102   for (y=0; y<AVIGO_SCREEN_HEIGHT; y++)
r12991r12992
153125      }
154126   }
155127
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);
163128#if 0
164129   {
165130
src/mess/includes/avigo.h
r12991r12992
3434   int m_flash_at_0x8000;
3535   void *m_banked_opbase[4];
3636   int m_previous_input_port_data[4];
37   int m_stylus_marker_x;
38   int m_stylus_marker_y;
39   int m_stylus_press_x;
40   int m_stylus_press_y;
4137   int m_ox;
4238   int m_oy;
4339   unsigned int m_ad_value;
4440   UINT8 *m_video_memory;
4541   UINT8 m_screen_column;
46   int m_stylus_x;
47   int m_stylus_y;
48   gfx_element *m_stylus_pointer;
4942};
5043
5144
r12991r12992
5851extern SCREEN_UPDATE( avigo );
5952extern PALETTE_INIT( avigo );
6053
61void avigo_vh_set_stylus_marker_position(running_machine &machine, int x, int y);
6254
63
6455#endif /* AVIGO_H_ */
src/mess/drivers/avigo.c
r12991r12992
4545#include "machine/ins8250.h"
4646#include "sound/speaker.h"
4747#include "machine/ram.h"
48#include "rendlay.h"
4849
4950/*
5051    bit 7:                      ?? high priority. When it occurs, clear this bit.
r12991r12992
166167   int i;
167168   int current_input_port_data[4];
168169   int changed;
169   int nx,ny;
170   int dx, dy;
171170   static const char *const linenames[] = { "LINE0", "LINE1", "LINE2", "LINE3" };
172171
173172   for (i = 0; i < 4; i++)
r12991r12992
177176
178177   changed = current_input_port_data[3]^state->m_previous_input_port_data[3];
179178
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
199179   if ((changed & 0x02)!=0)
200180   {
201181      if ((current_input_port_data[3] & 0x02)!=0)
r12991r12992
210190      state->m_previous_input_port_data[i] = current_input_port_data[i];
211191   }
212192
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);
231193#if 0
232194   /* not sure if keyboard generates an interrupt, or if something
233195    is plugged in for synchronisation! */
r12991r12992
398360   memcpy(state->m_flashes[0]->space()->get_read_ptr(0), machine.region("maincpu")->base()+0x10000, 0x100000);
399361   memcpy(state->m_flashes[1]->space()->get_read_ptr(0), machine.region("maincpu")->base()+0x110000, 0x100000);
400362
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
407363   /* initialise settings for port data */
408364   for (i = 0; i < 4; i++)
409365   {
r12991r12992
593549      if ((data & 0x08)!=0)
594550      {
595551         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"));
597553
598554         /* 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)
603556         {
604557            /* this might not be totally accurate because hitable screen
605558                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");
608560         }
609561         else
610562         {
r12991r12992
612564         }
613565
614566         logerror("ad value: %d\n",state->m_ad_value);
615         state->m_stylus_press_x = 0;
616567
617568      }
618569      else
r12991r12992
627578         /* assumption 0x044->0x0350 is screen area and
628579            0x0350->0x036a is panel at bottom */
629580
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
635581         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"));
637583
638         if (state->m_stylus_press_y!=0)
584         if (input_port_read(space->machine(), "LINE3") & 0x01)
639585         {
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");
641587         }
642588         else
643589         {
r12991r12992
645591         }
646592
647593         logerror("ad value: %d\n",state->m_ad_value);
648         state->m_stylus_press_y = 0;
649594      }
650595   }
651596
r12991r12992
817762ADDRESS_MAP_END
818763
819764
765static INPUT_CHANGED( pen_irq )
766{
767   avigo_state *state = field.machine().driver_data<avigo_state>();
820768
769   logerror("pen pressed interrupt\n");
770   state->m_irq |= (1<<6);
771
772   avigo_refresh_ints(field.machine());
773}
774
821775static INPUT_PORTS_START(avigo)
822776   PORT_START("LINE0")
823777   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("PAGE UP") PORT_CODE(KEYCODE_PGUP)
r12991r12992
836790   PORT_BIT(0x0fe, 0xfe, IPT_UNUSED)
837791
838792   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 )
840794   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("?? Causes a NMI") PORT_CODE(KEYCODE_W) PORT_CODE(JOYCODE_BUTTON2)
841795
842796   /* 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? */
845797   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)
847799
848800   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)
850802INPUT_PORTS_END
851803
852804/* F4 Character Displayer */
r12991r12992
929881};
930882
931883static GFXDECODE_START( avigo )
932   GFXDECODE_ENTRY( "maincpu", 0x00000, avigo_charlayout, 0, 3 )
933884   GFXDECODE_ENTRY( "maincpu", 0x18992, avigo_charlayout, 0, 1 )
934885   GFXDECODE_ENTRY( "maincpu", 0x1c020, avigo_8_by_14, 0, 1 )
935886   GFXDECODE_ENTRY( "maincpu", 0x1c020, avigo_16_by_15, 0, 1 )
r12991r12992
939890GFXDECODE_END
940891
941892
893static 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
902static 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
942911static MACHINE_CONFIG_START( avigo, avigo_state )
943912   /* basic machine hardware */
944913   MCFG_CPU_ADD("maincpu", Z80, 4000000)
r12991r12992
956925   MCFG_SCREEN_REFRESH_RATE(50)
957926   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
958927   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)
961931   MCFG_SCREEN_UPDATE( avigo )
962932
963933   MCFG_GFXDECODE(avigo)
r12991r12992
983953   MCFG_RAM_ADD(RAM_TAG)
984954   MCFG_RAM_DEFAULT_SIZE("128K")
985955
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
986962   /* a timer used to check status of pen */
987963   /* an interrupt is generated when the pen is pressed to the screen */
988964   MCFG_TIMER_ADD_PERIODIC("avigo_timer", avigo_dummy_timer_callback, attotime::from_hz(50))

Previous 15994 Revisions Next


© 1998-2018 The MESS Team