[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | scinit.c -- score list functions
|
---|
| 4 | Version 33 -- 1988-07-28 -- D.N. Lynx Crowe
|
---|
| 5 |
|
---|
| 6 | long
|
---|
| 7 | scinit()
|
---|
| 8 |
|
---|
| 9 | Initializes the score data structures.
|
---|
| 10 | Returns the number of free storage units.
|
---|
| 11 |
|
---|
| 12 | struct s_entry *
|
---|
| 13 | e_clr(e1)
|
---|
| 14 | struct s_entry *e1;
|
---|
| 15 |
|
---|
| 16 | Clears the event pointed to by 'e1'. Returns 'e1'.
|
---|
| 17 | Preserves e_size field, all others set to zero.
|
---|
| 18 |
|
---|
| 19 | struct s_entry *
|
---|
| 20 | e_ins(e1, e2)
|
---|
| 21 | struct s_entry *e1, *e2;
|
---|
| 22 |
|
---|
| 23 | Inserts the event pointed to by 'e1' after the event
|
---|
| 24 | pointed to by 'e2'. Returns 'e1'.
|
---|
| 25 |
|
---|
| 26 | struct s_entry *
|
---|
| 27 | e_rmv(e1)
|
---|
| 28 | struct s_entry *e1;
|
---|
| 29 |
|
---|
| 30 | Removes the event pointed to by 'e1' from the list it's in.
|
---|
| 31 | Returns 'e1'.
|
---|
| 32 |
|
---|
| 33 | struct s_entry *
|
---|
| 34 | e_alc(w)
|
---|
| 35 | int w;
|
---|
| 36 |
|
---|
| 37 | Allocates a new event entry.
|
---|
| 38 | Returns the event entry address, or E_NULL
|
---|
| 39 | if none can be allocated.
|
---|
| 40 |
|
---|
| 41 | short
|
---|
| 42 | e_del(e1)
|
---|
| 43 | struct s_entry *e1;
|
---|
| 44 |
|
---|
| 45 | Deallocates the event entry pointed to by 'e1'.
|
---|
| 46 | Returns 0 if successful, 1 if not.
|
---|
| 47 |
|
---|
| 48 | long
|
---|
| 49 | evleft()
|
---|
| 50 |
|
---|
| 51 | Returns total number of longs left for score storage.
|
---|
| 52 | |
---|
| 53 |
|
---|
| 54 | eh_ins(ne, et)
|
---|
| 55 | struct s_entry *ne;
|
---|
| 56 | short et;
|
---|
| 57 |
|
---|
| 58 | Inserts event 'ne' of type 'et' into score header list
|
---|
| 59 | "hplist[curscor][et]" along the "up" chain.
|
---|
| 60 |
|
---|
| 61 | eh_rmv(ev, et)
|
---|
| 62 | struct s_entry *ev;
|
---|
| 63 | short et;
|
---|
| 64 |
|
---|
| 65 | Removes event 'ev' of type 'et' from score header list
|
---|
| 66 | "hplist[curscor][et]" along the "up" chain.
|
---|
| 67 |
|
---|
| 68 | sc_clr(ns)
|
---|
| 69 | short ns;
|
---|
| 70 |
|
---|
| 71 | Clears score 'ns'.
|
---|
| 72 |
|
---|
| 73 | short
|
---|
| 74 | selscor(ns)
|
---|
| 75 | short ns;
|
---|
| 76 |
|
---|
| 77 | Selects score 'ns' for use.
|
---|
| 78 |
|
---|
| 79 | =============================================================================
|
---|
| 80 | */
|
---|
| 81 |
|
---|
| 82 | #include "stddefs.h"
|
---|
| 83 | #include "hwdefs.h"
|
---|
| 84 | #include "memory.h"
|
---|
| 85 | #include "score.h"
|
---|
[e225e77] | 86 |
|
---|
| 87 | #include "scfns.h"
|
---|
| 88 |
|
---|
| 89 | extern void clkset(int16_t st);
|
---|
| 90 | extern void dsclk(void);
|
---|
[f40a309] | 91 |
|
---|
| 92 | /* |
---|
| 93 |
|
---|
[7258c6a] | 94 | */
|
---|
| 95 |
|
---|
| 96 | extern int16_t sd; /* Scroll direction */
|
---|
| 97 | extern int16_t curasg; /* Current assgnment table */
|
---|
[f40a309] | 98 | extern int16_t tmpoval; /* Current tempo */
|
---|
| 99 | extern int16_t curtun; /* Current tuning table */
|
---|
| 100 |
|
---|
| 101 | extern struct s_time stimes[N_SCORES][N_SECTS]; /* section times */
|
---|
| 102 |
|
---|
| 103 | /* |
---|
| 104 |
|
---|
| 105 | */
|
---|
| 106 |
|
---|
| 107 | /*
|
---|
| 108 | =============================================================================
|
---|
| 109 | evleft() -- returns total number of longs left for score storage.
|
---|
[7258c6a] | 110 | =============================================================================
|
---|
[f40a309] | 111 | */
|
---|
| 112 |
|
---|
| 113 | int32_t evleft(void)
|
---|
| 114 | {
|
---|
| 115 | return(spcount + (se1_cnt * E_SIZE1) + (se2_cnt * E_SIZE2) +
|
---|
| 116 | (se3_cnt * E_SIZE3));
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | /* |
---|
| 120 |
|
---|
| 121 | */
|
---|
| 122 |
|
---|
| 123 | /*
|
---|
| 124 | =============================================================================
|
---|
| 125 | scinit() -- initializes the score data structures.
|
---|
[7258c6a] | 126 | Returns the number of free storage units.
|
---|
[f40a309] | 127 | =============================================================================
|
---|
[7258c6a] | 128 | */
|
---|
[f40a309] | 129 |
|
---|
| 130 | int32_t scinit(void)
|
---|
| 131 | {
|
---|
| 132 | register int32_t i, *cp;
|
---|
| 133 |
|
---|
| 134 | se1_cnt = 0L; /* fragments */
|
---|
| 135 | size1 = E_NULL;
|
---|
| 136 | se2_cnt = 0L;
|
---|
| 137 | size2 = E_NULL;
|
---|
| 138 | se3_cnt = 0L;
|
---|
[7258c6a] | 139 | size3 = E_NULL;
|
---|
[f40a309] | 140 | se_chg = TRUE;
|
---|
| 141 | frags = 0L;
|
---|
| 142 |
|
---|
| 143 | spcount = (int32_t)MAX_SE; /* storage pool */
|
---|
| 144 | pspool = spool;
|
---|
| 145 | cp = spool;
|
---|
| 146 |
|
---|
| 147 | for (i = spcount; i-- > 0; )
|
---|
| 148 | *cp++ = 0L;
|
---|
| 149 |
|
---|
| 150 | for (i = 0; i < N_SCORES; i++) /* score names */
|
---|
| 151 | memcpy(scname[i], "{ empty score }", 16);
|
---|
| 152 |
|
---|
| 153 | memsetw(scores, 0, 2 * N_SCORES); /* score list */
|
---|
| 154 | memsetw(hplist, 0, 2 * N_SCORES * N_TYPES); /* header lists */
|
---|
| 155 | memsetw(seclist, 0, 2 * N_SCORES * N_SECTS); /* section lists */
|
---|
| 156 | memset(stimes, 0, 12 * N_SCORES * N_SECTS); /* section times */
|
---|
| 157 |
|
---|
| 158 | t_cur = t_ctr = 0L; /* times */
|
---|
| 159 | t_bak = t_cur - TO_BAK;
|
---|
| 160 | t_fwd = t_cur + TO_FWD;
|
---|
| 161 |
|
---|
| 162 | p_bak = E_NULL; /* pointers */
|
---|
| 163 | p_cur = E_NULL;
|
---|
| 164 | p_ctr = E_NULL;
|
---|
| 165 | p_fwd = E_NULL;
|
---|
| 166 | scp = E_NULL;
|
---|
| 167 |
|
---|
| 168 | curscor = 0; /* current score */
|
---|
| 169 | cursect = 0; /* current section */
|
---|
| 170 |
|
---|
| 171 | return(evleft());
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | /* |
---|
| 175 |
|
---|
| 176 | */
|
---|
| 177 |
|
---|
| 178 | /*
|
---|
| 179 | =============================================================================
|
---|
[0580615] | 180 | e_clr(e1) -- clear the event pointed to by 'e1'. Returns 'e1'.
|
---|
[f40a309] | 181 | Preserves e_size field, all others set to zero.
|
---|
| 182 | =============================================================================
|
---|
| 183 | */
|
---|
| 184 |
|
---|
| 185 | struct s_entry *e_clr(struct s_entry *e1)
|
---|
| 186 | {
|
---|
| 187 | switch (e1->e_size) {
|
---|
| 188 |
|
---|
| 189 | case E_SIZE3:
|
---|
| 190 |
|
---|
| 191 | e1->e_lft = E_NULL;
|
---|
| 192 | e1->e_rgt = E_NULL;
|
---|
| 193 |
|
---|
| 194 | case E_SIZE2:
|
---|
| 195 |
|
---|
| 196 | e1->e_up = E_NULL;
|
---|
| 197 | e1->e_dn = E_NULL;
|
---|
| 198 |
|
---|
| 199 | case E_SIZE1:
|
---|
| 200 |
|
---|
| 201 | e1->e_fwd = E_NULL;
|
---|
| 202 | e1->e_bak = E_NULL;
|
---|
| 203 |
|
---|
| 204 | e1->e_time = 0L;
|
---|
| 205 | e1->e_type = EV_NULL;
|
---|
| 206 | e1->e_data1 = 0;
|
---|
| 207 | e1->e_data2 = 0;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | return(e1);
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | /* |
---|
| 214 |
|
---|
| 215 | */
|
---|
| 216 |
|
---|
| 217 | /*
|
---|
[0580615] | 218 | =============================================================================
|
---|
[f40a309] | 219 | e_ins(e1, e2) -- inserts the event pointed to by 'e1' after the event
|
---|
| 220 | pointed to by 'e2'. Returns 'e1'.
|
---|
| 221 | =============================================================================
|
---|
| 222 | */
|
---|
| 223 |
|
---|
| 224 | struct s_entry *e_ins(struct s_entry *e1, struct s_entry *e2)
|
---|
| 225 | {
|
---|
| 226 | register struct s_entry *t1;
|
---|
| 227 |
|
---|
| 228 | t1 = e2->e_fwd;
|
---|
| 229 | e1->e_fwd = t1;
|
---|
| 230 | e1->e_bak = e2;
|
---|
| 231 | e2->e_fwd = e1;
|
---|
| 232 | t1->e_bak = e1;
|
---|
| 233 | return(e1);
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | /*
|
---|
[0580615] | 237 | =============================================================================
|
---|
[f40a309] | 238 | e_rmv(e1) -- removes the event pointed to by 'e1' from the list it's in.
|
---|
| 239 | Returns 'e1'.
|
---|
| 240 | =============================================================================
|
---|
| 241 | */
|
---|
| 242 |
|
---|
| 243 | struct s_entry *e_rmv(struct s_entry *e1)
|
---|
| 244 | {
|
---|
| 245 | register struct s_entry *t1, *t2;
|
---|
| 246 |
|
---|
| 247 | t1 = e1->e_bak;
|
---|
| 248 | t2 = e1->e_fwd;
|
---|
| 249 | t1->e_fwd = t2;
|
---|
| 250 | t2->e_bak = t1;
|
---|
| 251 | e1->e_fwd = E_NULL;
|
---|
| 252 | e1->e_bak = E_NULL;
|
---|
| 253 | return(e1);
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | /* |
---|
| 257 |
|
---|
| 258 | */
|
---|
| 259 |
|
---|
[7258c6a] | 260 | /*
|
---|
[f40a309] | 261 | =============================================================================
|
---|
| 262 | e_alc() -- allocates a new event entry.
|
---|
| 263 | Returns the event entry address, or E_NULL if none can be allocated.
|
---|
| 264 | =============================================================================
|
---|
| 265 | */
|
---|
| 266 |
|
---|
| 267 | struct s_entry *e_alc(int16_t w)
|
---|
| 268 | {
|
---|
| 269 | register struct s_entry *ev, *ex;
|
---|
| 270 |
|
---|
| 271 | se_chg = TRUE;
|
---|
| 272 |
|
---|
| 273 | switch (w) {
|
---|
| 274 |
|
---|
| 275 | case E_SIZE1:
|
---|
| 276 |
|
---|
| 277 | if (spcount LT E_SIZE1) { /* try raw free pool first */
|
---|
| 278 |
|
---|
| 279 | if (se1_cnt EQ 0) { /* try for a deleted entry */
|
---|
| 280 |
|
---|
| 281 | if (se3_cnt) { /* try to split a size3 entry */
|
---|
| 282 |
|
---|
| 283 | ex = size3;
|
---|
| 284 | size3 = ex->e_fwd;
|
---|
| 285 | ++frags;
|
---|
| 286 | --se3_cnt;
|
---|
| 287 | ex->e_size = E_SIZE1;
|
---|
| 288 | ex->e_fwd = E_NULL;
|
---|
| 289 | return(ex);
|
---|
| 290 |
|
---|
| 291 | } else {
|
---|
| 292 |
|
---|
| 293 | if (se2_cnt) { /* try a size2 split */
|
---|
| 294 |
|
---|
| 295 | ex = size2;
|
---|
| 296 | size2 = size2->e_fwd;
|
---|
| 297 | ex->e_size = E_SIZE1;
|
---|
| 298 | ex->e_fwd = E_NULL;
|
---|
| 299 | ++frags;
|
---|
| 300 | --se2_cnt;
|
---|
| 301 | return(ex);
|
---|
| 302 |
|
---|
| 303 | } else {
|
---|
| 304 |
|
---|
| 305 | return(E_NULL); /* no space */
|
---|
| 306 | }
|
---|
| 307 | }
|
---|
| 308 | /* |
---|
| 309 |
|
---|
| 310 | */
|
---|
| 311 | } else { /* deleted entry available */
|
---|
| 312 |
|
---|
| 313 | ex = size1;
|
---|
| 314 | size1 = size1->e_fwd;
|
---|
| 315 | ex->e_fwd = E_NULL;
|
---|
| 316 | --se1_cnt;
|
---|
| 317 | return(ex);
|
---|
| 318 | }
|
---|
| 319 |
|
---|
| 320 | } else { /* raw storage available */
|
---|
| 321 |
|
---|
| 322 | ex = (struct s_entry *)pspool;
|
---|
| 323 | pspool += E_SIZE1;
|
---|
| 324 | spcount -= E_SIZE1;
|
---|
| 325 | ex->e_size = E_SIZE1;
|
---|
| 326 | return(ex);
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | /* |
---|
| 330 |
|
---|
| 331 | */
|
---|
| 332 |
|
---|
| 333 | case E_SIZE2:
|
---|
| 334 |
|
---|
| 335 | if (spcount LT E_SIZE2) { /* try for raw storage */
|
---|
| 336 |
|
---|
| 337 | if (se2_cnt EQ 0) { /* try for a deleted entry */
|
---|
| 338 |
|
---|
| 339 | if (se3_cnt) { /* try to split a size3 entry */
|
---|
| 340 |
|
---|
| 341 | ex = size3;
|
---|
| 342 | size3 = size3->e_fwd;
|
---|
| 343 | ex->e_size = E_SIZE2;
|
---|
| 344 | ex->e_fwd = E_NULL;
|
---|
| 345 | --se3_cnt;
|
---|
| 346 | ++frags;
|
---|
| 347 | return(ex);
|
---|
| 348 |
|
---|
| 349 | } else {
|
---|
| 350 |
|
---|
| 351 | return(E_NULL); /* no space */
|
---|
| 352 | }
|
---|
| 353 |
|
---|
| 354 | } else { /* deleted entry available */
|
---|
| 355 |
|
---|
| 356 | ex = size2;
|
---|
| 357 | size2 = size2->e_fwd;
|
---|
| 358 | ex->e_fwd = E_NULL;
|
---|
| 359 | --se2_cnt;
|
---|
| 360 | return(ex);
|
---|
| 361 | }
|
---|
| 362 |
|
---|
| 363 | } else { /* raw storage available */
|
---|
| 364 |
|
---|
| 365 | ex = (struct s_entry *)pspool;
|
---|
| 366 | pspool += E_SIZE2;
|
---|
| 367 | spcount -= E_SIZE2;
|
---|
| 368 | ex->e_size = E_SIZE2;
|
---|
| 369 | return(ex);
|
---|
| 370 |
|
---|
| 371 | }
|
---|
| 372 |
|
---|
| 373 | /* |
---|
| 374 |
|
---|
| 375 | */
|
---|
| 376 |
|
---|
| 377 | case E_SIZE3:
|
---|
| 378 |
|
---|
| 379 | if (spcount LT E_SIZE3) { /* try for raw storage */
|
---|
| 380 |
|
---|
| 381 | if (se3_cnt EQ 0) { /* try for a deleted entry */
|
---|
| 382 |
|
---|
| 383 | return(E_NULL); /* no space left */
|
---|
| 384 |
|
---|
| 385 | } else { /* deleted entry available */
|
---|
| 386 |
|
---|
| 387 | ex = size3;
|
---|
| 388 | size3 = size3->e_fwd;
|
---|
| 389 | ex->e_fwd = E_NULL;
|
---|
| 390 | --se3_cnt;
|
---|
| 391 | return(ex);
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 | } else { /* raw storage available */
|
---|
| 395 |
|
---|
| 396 | ex = (struct s_entry *)pspool;
|
---|
| 397 | pspool += E_SIZE3;
|
---|
| 398 | spcount -= E_SIZE3;
|
---|
| 399 | ex->e_size = E_SIZE3;
|
---|
| 400 | return(ex);
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | default:
|
---|
| 404 |
|
---|
| 405 | return(E_NULL); /* invalid request */
|
---|
| 406 | }
|
---|
| 407 |
|
---|
| 408 | return(E_NULL); /* something went 'worng' ... */
|
---|
| 409 | }
|
---|
| 410 |
|
---|
[7258c6a] | 411 | /* |
---|
[f40a309] | 412 |
|
---|
| 413 | */
|
---|
| 414 |
|
---|
| 415 | /*
|
---|
| 416 | =============================================================================
|
---|
| 417 | e_del(e1) -- deallocates the event entry pointed to by 'e1'.
|
---|
| 418 | Returns 0 if successful, 1 if not.
|
---|
| 419 | =============================================================================
|
---|
| 420 | */
|
---|
| 421 |
|
---|
| 422 | int16_t e_del(struct s_entry *e1)
|
---|
| 423 | {
|
---|
| 424 | e_clr(e1);
|
---|
| 425 |
|
---|
| 426 | switch (e1->e_size) {
|
---|
| 427 |
|
---|
| 428 | case E_SIZE1:
|
---|
| 429 |
|
---|
| 430 | e1->e_fwd = size1;
|
---|
| 431 | size1 = e1;
|
---|
| 432 | ++se1_cnt;
|
---|
| 433 | break;
|
---|
| 434 |
|
---|
| 435 | case E_SIZE2:
|
---|
| 436 |
|
---|
| 437 | e1->e_fwd = size2;
|
---|
| 438 | size2 = e1;
|
---|
| 439 | ++se2_cnt;
|
---|
| 440 | break;
|
---|
| 441 |
|
---|
| 442 | case E_SIZE3:
|
---|
| 443 |
|
---|
| 444 | e1->e_fwd = size3;
|
---|
| 445 | size3 = e1;
|
---|
| 446 | ++se3_cnt;
|
---|
| 447 | break;
|
---|
| 448 |
|
---|
| 449 | default:
|
---|
| 450 | return(1);
|
---|
| 451 | }
|
---|
| 452 |
|
---|
| 453 | se_chg = TRUE;
|
---|
| 454 | return(0);
|
---|
| 455 | }
|
---|
[7258c6a] | 456 |
|
---|
[f40a309] | 457 | /* |
---|
| 458 |
|
---|
| 459 | */
|
---|
| 460 |
|
---|
| 461 | /*
|
---|
| 462 | =============================================================================
|
---|
| 463 | eh_ins(ne, et) -- insert event 'ne' of type 'et' into score header list
|
---|
| 464 | "hplist[curscor][et]" along the "up" chain.
|
---|
| 465 | =============================================================================
|
---|
| 466 | */
|
---|
| 467 |
|
---|
| 468 | void eh_ins(struct s_entry *ne, int16_t et)
|
---|
| 469 | {
|
---|
| 470 | register struct s_entry *hp, *ep;
|
---|
| 471 |
|
---|
| 472 | hp = hplist[curscor][et]; /* get list pointer */
|
---|
| 473 |
|
---|
| 474 | if (hp EQ E_NULL) { /* if list was empty */
|
---|
| 475 |
|
---|
| 476 | hplist[curscor][et] = ne; /* start the list */
|
---|
| 477 | ne->e_up = E_NULL;
|
---|
| 478 | ne->e_dn = E_NULL;
|
---|
| 479 | return;
|
---|
| 480 | }
|
---|
| 481 |
|
---|
| 482 | if (hp->e_time GT ne->e_time) { /* if first entry was later */
|
---|
| 483 |
|
---|
| 484 | hp->e_dn = ne; /* add to start of list */
|
---|
| 485 | ne->e_up = hp;
|
---|
| 486 | ne->e_dn = E_NULL;
|
---|
| 487 | hplist[curscor][et] = ne;
|
---|
| 488 | return;
|
---|
| 489 | }
|
---|
| 490 |
|
---|
| 491 | while (E_NULL NE (ep = hp->e_up)) { /* search forward */
|
---|
| 492 |
|
---|
| 493 | if (ep->e_time GT ne->e_time) { /* if we find a later event */
|
---|
| 494 |
|
---|
| 495 | ne->e_up = ep; /* insert into list */
|
---|
| 496 | ne->e_dn = hp;
|
---|
| 497 | hp->e_up = ne;
|
---|
| 498 | ep->e_dn = ne;
|
---|
| 499 | return;
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | hp = ep;
|
---|
| 503 | }
|
---|
| 504 |
|
---|
| 505 | hp->e_up = ne; /* add to end of list */
|
---|
| 506 | ne->e_up = E_NULL;
|
---|
| 507 | ne->e_dn = hp;
|
---|
| 508 | return;
|
---|
[7258c6a] | 509 | }
|
---|
[f40a309] | 510 |
|
---|
| 511 | /* |
---|
| 512 |
|
---|
| 513 | */
|
---|
| 514 |
|
---|
| 515 | /*
|
---|
| 516 | =============================================================================
|
---|
| 517 | eh_rmv(ev, et) -- remove event 'ev' of type 'et' from score header list
|
---|
| 518 | "hplist[curscor][et]" along the "up" chain.
|
---|
| 519 | =============================================================================
|
---|
| 520 | */
|
---|
| 521 |
|
---|
| 522 | void eh_rmv(struct s_entry *ev, int16_t et)
|
---|
| 523 | {
|
---|
| 524 | if (hplist[curscor][et] EQ ev) /* update hplist */
|
---|
| 525 | hplist[curscor][et] = ev->e_up;
|
---|
| 526 |
|
---|
| 527 | if (ev->e_up NE E_NULL) /* update entry above */
|
---|
| 528 | (ev->e_up)->e_dn = ev->e_dn;
|
---|
| 529 |
|
---|
| 530 | if (ev->e_dn NE E_NULL) /* update entry below */
|
---|
| 531 | (ev->e_dn)->e_up = ev->e_up;
|
---|
[7258c6a] | 532 |
|
---|
[f40a309] | 533 | ev->e_up = ev->e_dn = E_NULL; /* update entry itself */
|
---|
| 534 | }
|
---|
[7258c6a] | 535 |
|
---|
[f40a309] | 536 | /* |
---|
| 537 |
|
---|
| 538 | */
|
---|
| 539 |
|
---|
| 540 | /*
|
---|
| 541 | =============================================================================
|
---|
| 542 | sc_clr(ns) -- clear score 'ns'.
|
---|
| 543 | =============================================================================
|
---|
| 544 | */
|
---|
| 545 |
|
---|
| 546 | void sc_clr(int16_t ns)
|
---|
| 547 | {
|
---|
| 548 | register struct s_entry *dsp, *nsp;
|
---|
| 549 | register int16_t i;
|
---|
| 550 |
|
---|
| 551 | if (E_NULL NE (nsp = scores[ns])) {
|
---|
| 552 |
|
---|
| 553 | while (nsp NE (dsp = nsp->e_fwd)) {
|
---|
| 554 |
|
---|
| 555 | e_del(e_rmv(nsp)); /* delete this one */
|
---|
| 556 | nsp = dsp; /* point at the next one */
|
---|
| 557 |
|
---|
| 558 | }
|
---|
| 559 |
|
---|
| 560 | e_del(nsp); /* delete final entry */
|
---|
| 561 | }
|
---|
| 562 |
|
---|
| 563 | for (i = 0; i < N_TYPES; i++) /* clear header list */
|
---|
| 564 | hplist[ns][i] = E_NULL;
|
---|
| 565 |
|
---|
| 566 | for (i = 0; i < N_SECTS; i++) { /* clear section lists */
|
---|
| 567 |
|
---|
| 568 | seclist[ns][i] = E_NULL;
|
---|
| 569 | memset(stimes[ns], 0, 12);
|
---|
| 570 | }
|
---|
| 571 |
|
---|
[7258c6a] | 572 | memcpy(scname[ns], "{ empty score }", 16);
|
---|
[f40a309] | 573 |
|
---|
[7258c6a] | 574 | scores[ns] = E_NULL;
|
---|
[f40a309] | 575 | }
|
---|
| 576 |
|
---|
| 577 | /* |
---|
| 578 |
|
---|
| 579 | */
|
---|
| 580 |
|
---|
| 581 | /*
|
---|
| 582 | =============================================================================
|
---|
| 583 | selscor(ns) -- select score 'ns' for use
|
---|
| 584 | =============================================================================
|
---|
| 585 | */
|
---|
| 586 |
|
---|
| 587 | int16_t selscor(int16_t ns)
|
---|
| 588 | {
|
---|
| 589 | register int16_t oldscor, grp;
|
---|
| 590 | register struct s_entry *nsp, *ep;
|
---|
| 591 |
|
---|
| 592 | clkset(0); /* stop the clock */
|
---|
| 593 | dsclk();
|
---|
| 594 | fc_val = 0L; /* reset to start of score */
|
---|
| 595 | sd = D_FWD;
|
---|
| 596 | oldscor = curscor; /* setup for new score */
|
---|
| 597 | curscor = ns;
|
---|
| 598 |
|
---|
| 599 | if (E_NULL EQ (nsp = scores[ns])) { /* initialize score if needed */
|
---|
| 600 |
|
---|
| 601 | if (E_NULL EQ (nsp = e_alc(E_SIZE1))) { /* score header */
|
---|
| 602 |
|
---|
| 603 | curscor = oldscor;
|
---|
| 604 | return(FAILURE);
|
---|
| 605 | }
|
---|
| 606 |
|
---|
| 607 | scores[ns] = nsp;
|
---|
| 608 | nsp->e_fwd = nsp;
|
---|
| 609 | nsp->e_bak = nsp;
|
---|
| 610 | nsp->e_type = EV_SCORE;
|
---|
| 611 | nsp->e_data1 = ns;
|
---|
| 612 | nsp->e_time = 0L;
|
---|
| 613 |
|
---|
| 614 | if (E_NULL EQ (ep = e_alc(E_SIZE1))) { /* score end */
|
---|
| 615 |
|
---|
| 616 | sc_clr(ns);
|
---|
| 617 | curscor = oldscor;
|
---|
| 618 | return(FAILURE);
|
---|
| 619 | }
|
---|
| 620 |
|
---|
| 621 | ep->e_type = EV_FINI;
|
---|
| 622 | ep->e_data1 = ns;
|
---|
| 623 | e_ins(ep, nsp);
|
---|
| 624 | ep->e_time = 0x7FFFFFFFL;
|
---|
| 625 | nsp = scores[ns];
|
---|
| 626 | memcpy(&scname[ns][0], "%%% Untitled %%%", 16);
|
---|
| 627 | }
|
---|
| 628 |
|
---|
| 629 | scp = nsp;
|
---|
| 630 | p_bak = nsp;
|
---|
| 631 | p_cur = nsp;
|
---|
| 632 | p_ctr = nsp;
|
---|
| 633 | p_fwd = nsp;
|
---|
| 634 | cursect = 0;
|
---|
| 635 | sc_goto(0L);
|
---|
| 636 | return(SUCCESS);
|
---|
| 637 | }
|
---|