summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/awpvid.c
blob: 933f6cb4f3a69a87a9cf363b91ba7a11d2b0c8b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*************************************************************************************

    AWP Hardware video simulation system

    A.G.E Code Copyright J. Wallace and the AGEMAME Development Team.
    Visit http://www.mameworld.net/agemame/ for more information.

    M.A.M.E Core Copyright Nicola Salmoria and the MAME Team,
    used under license from http://mamedev.org

**************************************************************************************

   NOTE: Fading lamp system currently only recognises three lamp states:

   0=off, 1, 2= fully on

   Based on evidence, newer techs may need more states, but we can give them their own
   handlers at some stage in the distant future.

   Instructions:
   In order to set up displays (dot matrices, etc) we normally set up the unique
   displays first, and then add the remainder in order.

   The priorities (in descending order) are:

   Full video screens
   Dot matrix displays
   Other, as yet unknown devices

**************************************************************************************/

#include "emu.h"
#include "awpvid.h"
#include "rendlay.h"
#include "machine/steppers.h"

static UINT8 steps[MAX_STEPPERS];
static UINT8 symbols[MAX_STEPPERS];
static UINT8 reelpos[MAX_STEPPERS];

void awp_reel_setup(void)
{
	int x,reels;
	char rstep[16],rsym[16];

	if (!output_get_value("TotalReels"))
	{
		reels = 6 ;
	}
	else
	{
		reels = output_get_value("TotalReels");
	}

	for ( x = 0; x < reels; x++ )
	{
		sprintf(rstep, "ReelSteps%d",x+1);
		sprintf(rsym, "ReelSymbols%d",x+1);

		if (!output_get_value(rstep))
		{
			steps[x] = 6 ;
		}
		else
		{
			steps[x] = output_get_value(rstep);
		}

		if (!output_get_value(rsym))
		{
			symbols[x] = 1 ;
		}
		else
		{
			symbols[x] = output_get_value(rsym);
		}
	}
}

void awp_draw_reel(int rno)
{
	int rsteps = steps[rno];
	int rsymbols = symbols[rno];
	int m;
	int x = rno + 1;
	char rg[16], rga[16], rgb[16];

	sprintf(rg,"reel%d", x);
	reelpos[rno] = stepper_get_position(rno);
	if (reelpos[rno] == output_get_value(rg))
	{
		// Not moved, no need to update.
	}
	else
	{
		reelpos[rno] = stepper_get_position(rno)%(stepper_get_max(rno)-1);
		for ( m = 0; m < (rsymbols-1); m++ )
		{
			{
				sprintf(rga,"reel%da%d", x, m);
				output_set_value(rga,(reelpos[rno] + rsteps * m)%stepper_get_max(rno));
			}

			{
				if ((reelpos[rno] - rsteps * m) < 0)
				{
					sprintf(rgb,"reel%db%d", x, m);
					output_set_value(rgb,(reelpos[rno] - (rsteps * m - stepper_get_max(rno))));
				}
				else
				{
					sprintf(rgb,"reel%db%d", x, m);
					output_set_value(rgb,(reelpos[rno] - rsteps * m));
				}
			}
		}
		output_set_value(rg,(reelpos[rno]));
	}
}