draw_sync_list

This function draws a “synced” vectorlist (as Vide can export, see: Vecci->Export)

This version is even faster than the “standard” version generated by Vide for assembler.

The delay (5) is used for the zeroing of a sync. Delay of 5 should work for all positions on screen.
If you do not move far for the vectorlist to be drawn, you can reduce that value. If you draw in the center you can skip the delay entirely.

 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
#include <vectrex.h>

// #define DRAW_SCALE 0x0c // smallest scale printSync can cope with!

// this is quite a "C" optimized version of print_sync
// (-O3 and no_frame_pointer)
#define ZERO_DELAY 5

void draw_synced_list_c(
signed char *u,
signed int y,
signed int x,
unsigned int scaleMove,
unsigned int scaleList)
{
	do
	{
		// resnyc / startsync
		VIA_shift_reg = 0;		// all output is BLANK
		
		// move to zero
		VIA_cntl = (int)0xcc;	// zero the integrators
		VIA_port_a = 0;			// reset integrator offset
		VIA_port_b = (int)0b10000010;
		
		VIA_t1_cnt_lo = scaleMove;
		// delay, till beam is at zero
		// volatile - otherwise delay loop does not work with -O
		for (volatile signed int b=ZERO_DELAY; b>0; b--);
		VIA_port_b= (int)0b10000011;
		
		// move to "location"
		VIA_port_a = y;			// y pos to dac
		VIA_cntl = (int)0xce;	// disable zero, disable all blank
		VIA_port_b = 0;			// mux enable, dac to -> integrator y (and x)
		VIA_port_b = 1;			// mux disable, dac only to x
		VIA_port_a = x;			// dac -> x
		VIA_t1_cnt_hi=0;		// start timer
		
		// this can be done before the wait loop
		// since it only fills the latch, not the actual timer!
		VIA_t1_cnt_lo = scaleList;
		u+=3;
		
		// moveing test for yx== 0 into the move delay
		if ((*(u-2)!=0) || (*(u-1)!=0))
		{
			while ((VIA_int_flags & 0x40) == 0); // wait till timer finishes
			
			// internal moveTo
			VIA_port_a = *(u-2);	// y pos to dac
			VIA_cntl = (int)0xce;	// disable zero, disable all blank
			VIA_port_b = 0;			// mux enable, dac to -> integrator y (and x)
			VIA_port_b = 1;			// mux disable, dac only to x
			VIA_port_a = *(u-1);	// dac -> x
			VIA_t1_cnt_hi=0;		// start timer
			while ((VIA_int_flags & 0x40) == 0); // wait till timer finishes
		}
		else
		{
			while ((VIA_int_flags & 0x40) == 0); // wait till timer finishes
		}
		
		while (1)
		{
			if (*u<0) // draw line
			{
				// draw a vector
				VIA_port_a = *(1+u);		// y pos to dac
				VIA_port_b = 0;				// mux enable, dac to -> integrator y (and x)
				VIA_port_b=1;				// mux disable, dac only to x
				VIA_port_a = *(2+u);		// dac -> x
				VIA_t1_cnt_hi=0;			// start timer
				VIA_shift_reg = (int)0xff;	// draw complete line
				while ((VIA_int_flags & 0x40) == 0); // wait till timer finishes
				VIA_shift_reg = 0;			// all output is BLANK
			}
			else if (*u == 0) // moveTo
			{
				if ((*(u+1)!=0) || (*(u+2)!=0))
				{
					// internal moveTo
					VIA_port_a = *(1+u);	// y pos to dac
					VIA_cntl = (int)0xce;	// disable zero, disable all blank
					VIA_port_b = 0;			// mux enable, dac to -> integrator y (and x)
					VIA_port_b =1;			// mux disable, dac only to x
					VIA_port_a = *(2+u);	// dac -> x
					VIA_t1_cnt_hi=0;		// start timer
					while ((VIA_int_flags & 0x40) == 0); // wait till timer finishes
				}
			}
			else
			{
				break;
			}
			u+=3;
		}
	} while (*u != 2);
}