[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | scgoto.c -- position display at a given frame time
|
---|
| 4 | Version 48 -- 1988-09-23 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #define DEBUG_GO 0 /* define non-zero for sc_goto() debug */
|
---|
| 9 | #define CHECKPTR 0 /* define non-zero to check pointers */
|
---|
| 10 |
|
---|
[b28a12e] | 11 | #include "ram.h"
|
---|
[f40a309] | 12 |
|
---|
| 13 | /*
|
---|
| 14 | =============================================================================
|
---|
| 15 | sc_goto(tval) -- position score display at time 'tval'
|
---|
| 16 | =============================================================================
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[7258c6a] | 19 | int16_t sc_goto(int32_t tval)
|
---|
[f40a309] | 20 | {
|
---|
| 21 | register struct gdsel *gdsp;
|
---|
| 22 | register struct s_entry *rp;
|
---|
[7258c6a] | 23 | register int32_t tf, rt;
|
---|
| 24 | register int16_t mod48 = 48;
|
---|
[f40a309] | 25 |
|
---|
| 26 | #if CHECKPTR
|
---|
| 27 | Pcheck(p_fwd, "p_fwd - sc_goto entry");
|
---|
| 28 | Pcheck(p_ctr, "p_ctr - sc_goto entry");
|
---|
| 29 | Pcheck(p_bak, "p_bak - sc_goto entry");
|
---|
| 30 | Pcheck(p_cur, "p_cur - sc_goto entry");
|
---|
| 31 | #endif
|
---|
| 32 |
|
---|
| 33 | /* quick check of pointers so we don't crash */
|
---|
| 34 |
|
---|
| 35 | if ((p_fwd EQ E_NULL) OR (p_cur EQ E_NULL) OR
|
---|
| 36 | (p_bak EQ E_NULL) OR (p_ctr EQ E_NULL))
|
---|
| 37 | return(FAILURE);
|
---|
| 38 |
|
---|
| 39 | if (v_regs[5] & 0x0180) /* setup for VSDD bank 0 */
|
---|
| 40 | vbank(0);
|
---|
| 41 |
|
---|
| 42 | sd = D_FWD; /* set display and scroll direction */
|
---|
| 43 | swctrl = FALSE; /* stop scroll wheel */
|
---|
| 44 | swflag = FALSE; /* ... */
|
---|
[9519422] | 45 |
|
---|
[f40a309] | 46 | recsw = FALSE; /* force play mode on goto */
|
---|
| 47 | dsrpmod(); /* update video and LCD displays */
|
---|
| 48 |
|
---|
| 49 | if (ndisp EQ 2)
|
---|
| 50 | sreset(); /* reset highlighting if score is up */
|
---|
| 51 |
|
---|
[e225e77] | 52 | quiet(-1, -1); /* quiet the instrument */
|
---|
[f40a309] | 53 | clrnl(); /* clear note entry lists */
|
---|
| 54 | clrsctl(); /* clear slice control data */
|
---|
| 55 |
|
---|
| 56 | t_bak = tval - TO_BAK; /* set target time at p_bak */
|
---|
| 57 | t_fwd = t_bak; /* set target time at p_fwd */
|
---|
| 58 | t_ctr = tval; /* set target time at p_ctr */
|
---|
| 59 | t_cur = tval; /* set target time at p_cur */
|
---|
| 60 |
|
---|
| 61 | p_bak = frfind(t_bak, 0); /* position p_bak at t_bak */
|
---|
| 62 | p_cur = frfind(t_cur, 1); /* position p_cur at t_cur */
|
---|
| 63 | p_fwd = frfind(t_fwd, 1); /* position p_fwd at t_fwd */
|
---|
| 64 |
|
---|
[fa38804] | 65 |
|
---|
[f40a309] | 66 | /* reset the display pointers to the target time */
|
---|
| 67 |
|
---|
| 68 | if ((t_fwd LE 0) AND (p_fwd->e_type EQ EV_SCORE))
|
---|
| 69 | p_fwd = p_fwd->e_fwd; /* skip score header */
|
---|
| 70 |
|
---|
| 71 | rp = p_fwd; /* current forward event pointer */
|
---|
| 72 | rt = t_fwd; /* current forward event time */
|
---|
| 73 | tf = tval + TO_FWD; /* target event time */
|
---|
| 74 |
|
---|
| 75 | #if DEBUG_GO
|
---|
| 76 | if (verbose) {
|
---|
| 77 |
|
---|
| 78 | printf("## sc_goto(%8ld) ENTRY - tf: %8ld\n", tval, tf);
|
---|
| 79 |
|
---|
| 80 | printf(" t_bak: %8ld t_ctr: %8ld t_fwd: %8ld t_cur: %8ld\n",
|
---|
| 81 | t_bak, t_ctr, t_fwd, t_cur);
|
---|
| 82 |
|
---|
| 83 | printf(" p_bak: %08lX p_ctr: %08lX p_fwd: %08lX p_cur: %08lX\n",
|
---|
| 84 | p_bak, p_ctr, p_fwd, p_cur);
|
---|
| 85 | }
|
---|
| 86 | #endif
|
---|
| 87 |
|
---|
| 88 | while (rt++ LT tf) { /* advance p_fwd chain to tf */
|
---|
| 89 |
|
---|
| 90 | if (rp->e_type NE EV_FINI) { /* don't pass end of score */
|
---|
| 91 |
|
---|
| 92 | while (rp->e_time LE rt) { /* check event time */
|
---|
| 93 |
|
---|
| 94 | if (ndisp EQ 2) /* display event */
|
---|
| 95 | se_disp(rp, D_FWD, gdstbn, 0);
|
---|
| 96 |
|
---|
| 97 | rp = rp->e_fwd; /* point at next event */
|
---|
| 98 |
|
---|
| 99 | if (rp->e_type EQ EV_FINI) /* done if at end */
|
---|
| 100 | break;
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | if (ndisp EQ 2) {
|
---|
| 105 |
|
---|
| 106 | if (0 EQ (rt % mod48)) { /* handle beat markers */
|
---|
| 107 |
|
---|
| 108 | if ((struct gdsel *)NULL NE (gdsp = gdfsep)) {
|
---|
| 109 |
|
---|
| 110 | gdfsep = gdsp->next;
|
---|
| 111 |
|
---|
| 112 | gdsp->next = gdstbn[12];
|
---|
| 113 | gdsp->note = 0x1111;
|
---|
| 114 | gdsp->code = 1;
|
---|
| 115 |
|
---|
| 116 | gdstbn[12] = gdsp;
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | sc_adv(); /* scroll the display */
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | p_fwd = rp; /* update p_fwd for next event */
|
---|
| 125 | t_fwd = tf; /* update t_fwd */
|
---|
| 126 |
|
---|
[fa38804] | 127 |
|
---|
[f40a309] | 128 | /* execute & display things at current time to start things out right */
|
---|
| 129 |
|
---|
| 130 | if (ndisp EQ 2) /* if score is up ... */
|
---|
| 131 | dssect(); /* display section */
|
---|
| 132 |
|
---|
| 133 | rp = p_cur; /* current event pointer */
|
---|
| 134 | rt = t_cur; /* current event time */
|
---|
| 135 |
|
---|
| 136 | if ((rt LE 0) AND (rp->e_type EQ EV_SCORE)) /* skip score header */
|
---|
| 137 | rp = rp->e_fwd;
|
---|
| 138 |
|
---|
| 139 | if (rp->e_type NE EV_FINI) { /* if we aren't at end of score */
|
---|
| 140 |
|
---|
| 141 | while (rp->e_time EQ rt) { /* do events at current time */
|
---|
| 142 |
|
---|
| 143 | se_exec(rp, D_FWD); /* execute event */
|
---|
| 144 |
|
---|
| 145 | if (ndisp EQ 2)
|
---|
| 146 | se_disp(rp, D_FWD, gdstbc, 1); /* update center slice */
|
---|
| 147 |
|
---|
| 148 | rp = rp->e_fwd; /* point at next event */
|
---|
| 149 |
|
---|
| 150 | if (rp->e_type EQ EV_FINI) /* done if at end */
|
---|
| 151 | break;
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | p_cur = rp; /* update p_cur */
|
---|
| 156 | p_ctr = rp; /* update p_ctr */
|
---|
| 157 |
|
---|
| 158 | if (ndisp EQ 2) { /* if score is up ... */
|
---|
| 159 |
|
---|
| 160 | scupd(); /* update event display */
|
---|
| 161 | sdwins(); /* refresh windows */
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | #if DEBUG_GO
|
---|
| 165 | if (verbose) {
|
---|
| 166 |
|
---|
| 167 | printf("## sc_goto(%8ld) EXIT\n");
|
---|
| 168 |
|
---|
| 169 | printf(" t_bak: %8ld t_ctr: %8ld t_fwd: %8ld t_cur: %8ld\n",
|
---|
| 170 | t_bak, t_ctr, t_fwd, t_cur);
|
---|
| 171 |
|
---|
| 172 | printf(" p_bak: %08lx p_ctr: %08lx p_fwd: %08lx p_cur: %08lx\n",
|
---|
| 173 | p_bak, p_ctr, p_fwd, p_cur);
|
---|
| 174 | }
|
---|
| 175 | #endif
|
---|
| 176 |
|
---|
| 177 | #if CHECKPTR
|
---|
| 178 | Pcheck(p_fwd, "p_fwd - sc_goto exiting");
|
---|
| 179 | Pcheck(p_ctr, "p_ctr - sc_goto exiting");
|
---|
| 180 | Pcheck(p_bak, "p_bak - sc_goto exiting");
|
---|
| 181 | Pcheck(p_cur, "p_cur - sc_goto exiting");
|
---|
| 182 | #endif
|
---|
| 183 |
|
---|
| 184 | return(SUCCESS);
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | /*
|
---|
| 188 | =============================================================================
|
---|
| 189 | sc_refr() -- refresh the display to a particular time
|
---|
| 190 | =============================================================================
|
---|
| 191 | */
|
---|
| 192 |
|
---|
[7258c6a] | 193 | int16_t sc_refr(int32_t t)
|
---|
[f40a309] | 194 | {
|
---|
[7258c6a] | 195 | int16_t oldrs, rc;
|
---|
[f40a309] | 196 |
|
---|
| 197 | oldrs = recsw; /* save recsw */
|
---|
| 198 | rc = sc_goto(t); /* refresh the display via a goto */
|
---|
| 199 | recsw = oldrs; /* restore recsw */
|
---|
| 200 | dsrpmod(); /* update display of recsw */
|
---|
| 201 | return(rc); /* return status from sc_goto */
|
---|
| 202 | }
|
---|
[6262b5c] | 203 |
|
---|