|
13 | 13 | namespace detection |
14 | 14 | { |
15 | 15 |
|
| 16 | +#ifdef FOR_68K |
| 17 | + void cpu_68k(); |
16 | 18 | void cpu() |
| 19 | + { |
| 20 | + cpu_68k(); |
| 21 | + } |
| 22 | +#endif |
| 23 | +#ifdef FOR_PPC |
| 24 | + void cpu_ppc(); |
| 25 | + void cpu() |
| 26 | + { |
| 27 | + cpu_ppc(); |
| 28 | + } |
| 29 | +#endif |
| 30 | + void clockSpeed(); |
| 31 | + |
| 32 | + void cpu_68k() |
| 33 | + { |
| 34 | + int ver = os_version(); |
| 35 | + |
| 36 | + long procType; |
| 37 | + if (ver >= 0x600) |
| 38 | + { |
| 39 | + procType = detection::gestalt(gestaltProcessorType); |
| 40 | + } |
| 41 | + else |
| 42 | + { |
| 43 | + SysEnvRec rec; |
| 44 | + SysEnvirons(1, &rec); |
| 45 | + procType = rec.processor; |
| 46 | + } |
| 47 | + if (procType != NULL) |
| 48 | + { |
| 49 | + switch (procType) |
| 50 | + { |
| 51 | + case gestalt68000: |
| 52 | + printf("CPU: 68000"); |
| 53 | + break; |
| 54 | + case gestalt68010: |
| 55 | + printf("CPU: 68010"); |
| 56 | + break; |
| 57 | + case gestalt68020: |
| 58 | + printf("CPU: 68020"); |
| 59 | + break; |
| 60 | + case gestalt68030: |
| 61 | + printf("CPU: 68030"); |
| 62 | + break; |
| 63 | + case gestalt68040: |
| 64 | + printf("CPU: 68040"); |
| 65 | + break; |
| 66 | + } |
| 67 | + |
| 68 | + int ver = os_version(); |
| 69 | + if (ver >= 0x600) |
| 70 | + { |
| 71 | + clockSpeed(); |
| 72 | + } |
| 73 | + printf(" (ID: %d)", procType); |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + void cpu_ppc() |
17 | 78 | { |
18 | 79 | CPUDevice::Initialize(); |
19 | 80 | auto vec = CPUDevice::GetCPUS(); |
@@ -503,57 +564,90 @@ namespace detection |
503 | 564 |
|
504 | 565 | printf("CPU: %s", name.c_str()); |
505 | 566 |
|
506 | | - long speed = detection::gestalt(gestaltProcClkSpeed); |
507 | | - if (speed != NULL) |
508 | | - { |
509 | | - if (speed < 1000) |
510 | | - { |
511 | | - printf(" %luHz", speed); |
512 | | - } |
513 | | - else if (speed < 1000000) |
514 | | - { |
515 | | - printf(" %luKHz", speed / 1000); |
516 | | - } |
517 | | - else if (speed < 1000000000) |
518 | | - { |
519 | | - printf(" %luMHz", speed / 1000000); |
520 | | - } |
521 | | - else if (speed < 1000000000000) |
522 | | - { |
523 | | - printf(" %luGHz", speed / 1000000000); |
524 | | - } |
525 | | - else if (speed < 1000000000000000) |
526 | | - { |
527 | | - printf(" %luTHz", speed / 1000000000000); |
528 | | - } |
529 | | - else if (speed < 1000000000000000000) |
530 | | - { |
531 | | - printf(" %luPHz", speed / 1000000000000000); |
532 | | - } |
533 | | - } |
| 567 | + clockSpeed(); |
534 | 568 |
|
535 | 569 | printf(" (ID: %0X)", processorVersion); |
536 | 570 | } |
537 | 571 | } |
538 | 572 |
|
| 573 | + void clockSpeed() |
| 574 | + { |
| 575 | + float speed = (float)detection::gestalt(gestaltProcClkSpeed); |
| 576 | + if (speed != NULL) |
| 577 | + { |
| 578 | + if (speed < 1024.0) |
| 579 | + { |
| 580 | + printf(" %0.2fHz", speed); |
| 581 | + } |
| 582 | + else if (speed < 1048576.0) |
| 583 | + { |
| 584 | + printf(" %0.2fKHz", speed / 1024.0); |
| 585 | + } |
| 586 | + else if (speed < 1073741824.0) |
| 587 | + { |
| 588 | + printf(" %0.2fMHz", speed / 1048576.0); |
| 589 | + } |
| 590 | + else if (speed < 1099511627776.0) |
| 591 | + { |
| 592 | + printf(" %0.2fGHz", speed / 1073741824.0); |
| 593 | + } |
| 594 | + else if (speed < 1125899906842624.0) |
| 595 | + { |
| 596 | + printf(" %0.2fTHz", speed / 1099511627776.0); |
| 597 | + } |
| 598 | + else |
| 599 | + { |
| 600 | + printf(" %0.2fPHz", speed / 1125899906842624.0); |
| 601 | + } |
| 602 | + printf(" (%0.2f)", speed); |
| 603 | + } |
| 604 | + } |
539 | 605 | void model() |
540 | 606 | { |
541 | | - long sys = detection::gestalt(gestaltMachineType); |
| 607 | + int ver = os_version(); |
| 608 | + |
| 609 | + long sys; |
| 610 | + if (ver >= 0x600) |
| 611 | + { |
| 612 | + sys = detection::gestalt(gestaltMachineType); |
| 613 | + } |
| 614 | + else |
| 615 | + { |
| 616 | + SysEnvRec rec; |
| 617 | + SysEnvirons(1, &rec); |
| 618 | + sys = rec.machineType; |
| 619 | + // The result we get near perfectly maps to the modern one, with some exceptions. |
| 620 | + if (sys == 1) |
| 621 | + { |
| 622 | + sys = -1; |
| 623 | + } |
| 624 | + else if (sys == 2) |
| 625 | + { |
| 626 | + sys = 2; |
| 627 | + } |
| 628 | + else |
| 629 | + { |
| 630 | + sys -= 2; |
| 631 | + } |
| 632 | + } |
542 | 633 | if (sys != NULL) |
543 | 634 | { |
544 | 635 | // We're supposed to be able to use GetIndString. This does not work, presumably because they stopped updating the index, but they did give us all the numbers in the last header file. |
545 | 636 | const char *name = NULL; |
546 | 637 | unsigned char *name2 = NULL; |
547 | 638 | switch (sys) |
548 | 639 | { |
| 640 | + case 0: |
| 641 | + name = "Macintosh 128k"; |
| 642 | + break; |
549 | 643 | case 1: |
550 | 644 | name = "Macintosh Classic"; |
551 | 645 | break; |
552 | 646 | case 2: |
553 | 647 | name = "Macintosh XL"; |
554 | 648 | break; |
555 | 649 | case 3: |
556 | | - name = "Macintosh 512Ke"; |
| 650 | + name = "Macintosh 512K"; |
557 | 651 | break; |
558 | 652 |
|
559 | 653 | case 4: |
@@ -882,11 +976,11 @@ namespace detection |
882 | 976 | } |
883 | 977 | if (name != NULL) |
884 | 978 | { |
885 | | - printf("Model: %s (ID: %lu)", name, sys); |
| 979 | + printf("Model: %s (ID: %0.2f)", name, sys); |
886 | 980 | } |
887 | 981 | else |
888 | 982 | { |
889 | | - printf("Model: %s (ID: %lu)", name2, sys); |
| 983 | + printf("Model: %s (ID: %0.2f)", name2, sys); |
890 | 984 | } |
891 | 985 | } |
892 | 986 | return; |
|
0 commit comments