Returns 1 on success, 0 on failure. Sets *a,*v,*c. */
| 491 | |
| 492 | /* Returns 1 on success, 0 on failure. Sets *a,*v,*c. */ |
| 493 | int FCEUI_DecodeGG(const char *str, int *a, int *v, int *c) |
| 494 | { |
| 495 | uint16 A; |
| 496 | uint8 V,C; |
| 497 | uint8 t; |
| 498 | int s; |
| 499 | |
| 500 | A=0x8000; |
| 501 | V=0; |
| 502 | C=0; |
| 503 | |
| 504 | s=strlen(str); |
| 505 | if(s!=6 && s!=8) return(0); |
| 506 | |
| 507 | t=GGtobin(*str++); |
| 508 | V|=(t&0x07); |
| 509 | V|=(t&0x08)<<4; |
| 510 | |
| 511 | t=GGtobin(*str++); |
| 512 | V|=(t&0x07)<<4; |
| 513 | A|=(t&0x08)<<4; |
| 514 | |
| 515 | t=GGtobin(*str++); |
| 516 | A|=(t&0x07)<<4; |
| 517 | //if(t&0x08) return(0); /* 8-character code?! */ |
| 518 | |
| 519 | t=GGtobin(*str++); |
| 520 | A|=(t&0x07)<<12; |
| 521 | A|=(t&0x08); |
| 522 | |
| 523 | t=GGtobin(*str++); |
| 524 | A|=(t&0x07); |
| 525 | A|=(t&0x08)<<8; |
| 526 | |
| 527 | if(s==6) |
| 528 | { |
| 529 | t=GGtobin(*str++); |
| 530 | A|=(t&0x07)<<8; |
| 531 | V|=(t&0x08); |
| 532 | |
| 533 | *a=A; |
| 534 | *v=V; |
| 535 | *c=-1; |
| 536 | return(1); |
| 537 | } |
| 538 | else |
| 539 | { |
| 540 | t=GGtobin(*str++); |
| 541 | A|=(t&0x07)<<8; |
| 542 | C|=(t&0x08); |
| 543 | |
| 544 | t=GGtobin(*str++); |
| 545 | C|=(t&0x07); |
| 546 | C|=(t&0x08)<<4; |
| 547 | |
| 548 | t=GGtobin(*str++); |
| 549 | C|=(t&0x07)<<4; |
| 550 | V|=(t&0x08); |
no test coverage detected