1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-09-12 02:24:31 +00:00

Compare commits

...

977 Commits

Author SHA1 Message Date
Thomas Harte
015a1fbd53 Merge branch 'master' into Plus4PRGs 2025-02-03 00:06:14 -05:00
Thomas Harte
318b61b4d7 Merge pull request #1467 from TomHarte/QtCI
Add Qt to CI set.
2025-02-03 00:05:54 -05:00
Thomas Harte
60640517ca Remove crutch. 2025-02-02 23:58:25 -05:00
Thomas Harte
051e38f034 Reformat. 2025-02-02 23:48:20 -05:00
Thomas Harte
300054b9f7 Attempt a full make. 2025-02-02 23:46:26 -05:00
Thomas Harte
4f9e1e3a6b Add 'icu'. 2025-02-02 23:41:47 -05:00
Thomas Harte
856bc27bf1 Must specify qtbase, at least. 2025-02-02 23:36:15 -05:00
Thomas Harte
408b774b42 Switch to archives. 2025-02-02 23:29:59 -05:00
Thomas Harte
f82ef5aad4 Apply one of those architectures. 2025-02-02 23:23:34 -05:00
Thomas Harte
a92df41eb5 List architectures, hopefully. 2025-02-02 22:58:32 -05:00
Thomas Harte
605990929d Hit and hope. 2025-02-02 22:47:23 -05:00
Thomas Harte
925ca28659 Try without architecture. 2025-02-02 22:38:31 -05:00
Thomas Harte
41e3fa7aa7 Retreat. 2025-02-02 22:24:37 -05:00
Thomas Harte
5fa27448f8 Try to coax module names. 2025-02-02 22:19:44 -05:00
Thomas Harte
c3428bdaed Try without prefixes. 2025-02-02 22:11:32 -05:00
Thomas Harte
0539de9c4e Take a guess at modules. 2025-02-02 22:05:36 -05:00
Thomas Harte
eed87164b1 Attempt a Qt build action. 2025-02-02 22:00:21 -05:00
Thomas Harte
0fe726c503 Avoid overlong line. 2025-02-02 21:50:30 -05:00
Thomas Harte
f7f2113f1c Merge pull request #1465 from TomHarte/Plus4FastLoad
Edge towards fast loading in the Plus 4.
2025-02-02 21:49:22 -05:00
Thomas Harte
49d931f5cc Disable Mac job for now. 2025-02-02 21:41:37 -05:00
Thomas Harte
4dbd63de08 Attempt version rebump. 2025-01-31 12:33:21 -05:00
Thomas Harte
3a53c349a0 Abandon attempts to build on older macOS for now. 2025-01-31 11:45:43 -05:00
Thomas Harte
a9fe5d5c87 Manually revert Xcode project version. 2025-01-30 22:48:11 -05:00
Thomas Harte
9cecccf5da Correct TAP type check. 2025-01-30 21:04:36 -05:00
Thomas Harte
6cb3bbaa2d Ensure tape ending != infinite loop. 2025-01-29 23:30:16 -05:00
Thomas Harte
0ff6a0bb53 Slightly simplify template arguments. 2025-01-29 22:51:02 -05:00
Thomas Harte
8ba57dec03 Take another stab at read_dipole. 2025-01-29 22:07:17 -05:00
Thomas Harte
d749c305ed Merge branch 'master' into Plus4FastLoad 2025-01-28 20:20:21 -05:00
Thomas Harte
f46ac2d0ed Merge pull request #1464 from TomHarte/AheadOfTimeCRCTables
Grab bag: calculate CRC tables ahead of time; improve carry typing.
2025-01-28 20:16:03 -05:00
Thomas Harte
d7b7152315 Apply const liberally. 2025-01-28 18:26:34 -05:00
Thomas Harte
da1d52033b Use contractions. 2025-01-28 18:19:31 -05:00
Thomas Harte
01ddc24c02 Require overt acknowledgement of meaning. 2025-01-28 17:42:26 -05:00
Thomas Harte
53a3e88d16 Shunt CRC XOR table generation to compile time. 2025-01-28 17:36:32 -05:00
Thomas Harte
bc8d1cc384 Merge pull request #1463 from TomHarte/AcornAnalyserStyle
Tweak Acorn analyser style.
2025-01-26 21:58:50 -05:00
Thomas Harte
ed2ba63a5f Adjust style. 2025-01-26 21:42:38 -05:00
Thomas Harte
8a2c009653 Reduce copies, size()s, code duplication. 2025-01-26 21:34:01 -05:00
Thomas Harte
55690a4c7f Merge branch 'master' into Plus4FastLoad 2025-01-22 19:49:23 -05:00
Thomas Harte
161ad4b143 Merge pull request #1462 from TomHarte/VIAPortTemplate
Reduce repetitive dynamic work in 6522 usages.
2025-01-22 19:48:24 -05:00
Thomas Harte
d701990df4 Simplify ownership of the shift value. 2025-01-22 16:12:45 -05:00
Thomas Harte
95a2d1013c Remove unused dynamic dispatcher. 2025-01-22 16:06:09 -05:00
Thomas Harte
5d4f3c0b3e Remove already-done TODO. 2025-01-22 16:04:17 -05:00
Thomas Harte
f8e4023307 Reduce repetitive dynamic work in 6522 usages. 2025-01-22 15:57:03 -05:00
Thomas Harte
609aba7c73 Made various additional style improvements. 2025-01-22 13:47:25 -05:00
Thomas Harte
bc7ab0eba1 Extend parser, accelerate headers. 2025-01-21 22:37:10 -05:00
Thomas Harte
56f271c8ad Continue failing. This is the story of my life. 2025-01-21 17:24:12 -05:00
Thomas Harte
11190cff1d Eject zero-cost execution in favour of faulty HLE. 2025-01-21 16:45:05 -05:00
Thomas Harte
348a593dc1 Flail in attempt to implement fast loading. 2025-01-21 14:13:42 -05:00
Thomas Harte
b67bb50f4a Merge pull request #1461 from TomHarte/Vic20Confidence
Include VIC hits in Vic-20 confidence selection.
2025-01-20 23:21:19 -05:00
Thomas Harte
1174f651ab Switch to logger, ignore 0xfdfx. 2025-01-20 22:47:54 -05:00
Thomas Harte
dad9777c3e Merge pull request #1460 from TomHarte/Plus4DriveSelection
Add C1541 button to mac UI; respect Target setting.
2025-01-20 22:45:49 -05:00
Thomas Harte
4f6285a8e7 Include VIC hits in Vic-20 confidence selection. 2025-01-20 22:25:24 -05:00
Thomas Harte
20cecf4702 Add C1541 button to mac UI; respect Target setting. 2025-01-20 22:02:35 -05:00
Thomas Harte
5763eabff4 Merge pull request #1459 from TomHarte/UnitTestUpdates
Repair lagging unit tests.
2025-01-20 21:41:15 -05:00
Thomas Harte
0fc753949d Repair lagging unit tests. 2025-01-20 21:36:25 -05:00
Thomas Harte
083c1b7ca7 Merge pull request #1458 from TomHarte/Plus4PRGs
Introdice alternative tape timings for the +4.
2025-01-20 20:59:33 -05:00
Thomas Harte
8f6b1b11e5 Fix member name. 2025-01-20 20:35:14 -05:00
Thomas Harte
53b7d19c10 Ensure tape images proper destruct. 2025-01-20 20:33:17 -05:00
Thomas Harte
b0b4f5e51a Add Plus 4 to Qt UI. 2025-01-20 20:31:12 -05:00
Thomas Harte
b7414aa59c Improve logging. 2025-01-20 16:19:02 -05:00
Thomas Harte
f449045118 Add some basic attempts at dynamic analysis. 2025-01-20 16:15:53 -05:00
Thomas Harte
1e9ddada37 Retain tapes and disks. 2025-01-20 15:51:01 -05:00
Thomas Harte
55d59a1854 Separate chunk parsing. 2025-01-19 18:16:33 -05:00
Thomas Harte
beb9f38514 Eliminate std::shared_ptr. 2025-01-18 23:25:08 -05:00
Thomas Harte
00b1865fc8 Fix boundary condition. 2025-01-17 21:46:43 -05:00
Thomas Harte
0f545608c4 Fix serialiser ownership, Commodore analyser. 2025-01-17 21:43:11 -05:00
Thomas Harte
bde2047184 Provide target platform where serialiser will accept it. 2025-01-17 17:09:47 -05:00
Thomas Harte
0a22d8fb9e Add TODO on final dangling issue. 2025-01-17 17:06:03 -05:00
Thomas Harte
1bef37d504 Test data only once. 2025-01-17 17:04:25 -05:00
Thomas Harte
7f5d290b66 Promote validation. 2025-01-17 17:01:09 -05:00
Thomas Harte
9461e6f285 Move validation up a level. 2025-01-17 16:59:30 -05:00
Thomas Harte
3f59a03f29 Parse Commodore .tap header only once. 2025-01-17 16:54:54 -05:00
Thomas Harte
062b581b55 Move .cas and ZX .tap initial parsing out of serialiser. 2025-01-17 16:45:09 -05:00
Thomas Harte
58d3fdc1c2 Separate stateful serialisation from tapes. 2025-01-17 16:39:21 -05:00
Thomas Harte
2f546842a7 Wire TAPs and similar directly to their targets. 2025-01-16 21:21:15 -05:00
Thomas Harte
f089a85908 Zoom out to a more likely TV cropping. 2025-01-15 22:52:20 -05:00
Thomas Harte
a6e453a452 Introdice alternative tape timings for the +4. 2025-01-15 22:11:26 -05:00
Thomas Harte
3adf3dc547 Merge pull request #1457 from TomHarte/BadlinePriority
Give priority to initial bad lines.
2025-01-13 20:40:17 -05:00
Thomas Harte
1d0ea96ae9 This hasn't been true for a while. 2025-01-13 17:38:29 -05:00
Thomas Harte
a4cb17a1cb First bad lines take priority over second ones. 2025-01-13 17:31:18 -05:00
Thomas Harte
733da3161b Merge pull request #1456 from TomHarte/CounterSets
Correct shift on hcount write.
2025-01-12 22:32:46 -05:00
Thomas Harte
1b1a0f553d Keep three least bits. 2025-01-12 22:07:56 -05:00
Thomas Harte
972619c1fe Correct shift on hcount write. 2025-01-12 21:59:22 -05:00
Thomas Harte
61086d5360 Merge pull request #1455 from TomHarte/MatchBefore
Restructure loop to perform events AT time, not upon reaching it.
2025-01-12 19:18:32 -05:00
Thomas Harte
37513d726c Restructure loop to perform events AT time, not upon reaching it. 2025-01-12 19:06:42 -05:00
Thomas Harte
6510bee327 Merge pull request #1454 from TomHarte/VideoTweaks
Restrict counter sizes; invert written horizontal counter.
2025-01-11 23:42:58 -05:00
Thomas Harte
cd36f3f096 Restrict counter sizes; invert written horizontal counter. 2025-01-11 23:19:01 -05:00
Thomas Harte
407a6f5e31 Merge pull request #1453 from TomHarte/AbsentBits
Correct status unset-bit masks.
2025-01-11 22:58:42 -05:00
Thomas Harte
2b28df280e Correct status unset-bit masks. 2025-01-11 22:47:56 -05:00
Thomas Harte
eb763ed82c Merge pull request #1452 from TomHarte/TapeMotorAgain
Ensure tape motor is a combination of programmed state and button.
2025-01-10 21:04:19 -05:00
Thomas Harte
755f53cce0 Ensure tape motor is a combination of programmed state and button. 2025-01-10 16:59:09 -05:00
Thomas Harte
c190ab40b0 Merge pull request #1451 from TomHarte/Plus4Joystick
Add joystick input.
2025-01-09 17:12:37 -05:00
Thomas Harte
a3ad82de42 Add joystick input. 2025-01-09 17:01:20 -05:00
Thomas Harte
0f6cd6904d Separate keyboard and joystick masks.
Based on aside in https://plus4world.powweb.com/forum/6867#6868 ; I don't yet know what the joystick bits are.
2025-01-09 16:41:21 -05:00
Thomas Harte
79c89af6ea Merge pull request #1450 from TomHarte/LatestWarnings
Resolve GCC ubuntu-latest build warnings.
2025-01-09 16:32:50 -05:00
Thomas Harte
56f10a9a52 Adjust ownership to avoid passing reference to uninitialised object. 2025-01-09 16:27:19 -05:00
Thomas Harte
c679e2c067 line_number is now unused. 2025-01-09 16:14:16 -05:00
Thomas Harte
0677987320 Ensure all paths return a value. 2025-01-08 22:30:32 -05:00
Thomas Harte
5fb6e6780c Eliminate unused variable (at least temporarily). 2025-01-08 22:30:17 -05:00
Thomas Harte
58ef91a7b1 Merge pull request #1449 from TomHarte/FullerAudio
Switch to full-clock PWM audio implementation, with noise generator.
2025-01-08 22:28:01 -05:00
Thomas Harte
e1ae65b6d1 Switch to PWM implementation, with noise. 2025-01-08 22:09:42 -05:00
Thomas Harte
65307186dc Provide full clock to audio. 2025-01-08 21:17:48 -05:00
Thomas Harte
6fa29c204b Extend PAL/NTSC selection to audio. 2025-01-08 20:27:37 -05:00
Thomas Harte
8219beeb1a Merge pull request #1448 from TomHarte/6502Macros
Eliminate macros from 6502 bus operation actions.
2025-01-08 20:19:09 -05:00
Thomas Harte
ace7e24dfb Eliminate Objective-C-style naming. 2025-01-07 22:55:19 -05:00
Thomas Harte
828c2a6883 Convert macros to functions. 2025-01-07 22:51:52 -05:00
Thomas Harte
f195dc313d Strongly type BusOperation. 2025-01-07 22:48:17 -05:00
Thomas Harte
5b8a005f41 Merge pull request #1447 from TomHarte/CounterAccess
Add programmatic access to video counters.
2025-01-07 22:33:28 -05:00
Thomas Harte
9feb75e645 Force high unwriteable bytes. 2025-01-07 22:21:42 -05:00
Thomas Harte
7f8e90bd29 Add video counter writes. 2025-01-07 21:56:04 -05:00
Thomas Harte
2fd34b649d Add missing video counter reads. 2025-01-07 21:40:20 -05:00
Thomas Harte
104054ed1a Merge pull request #1446 from TomHarte/Plus4VideoOptions
Add selectable display type.
2025-01-07 20:15:21 -05:00
Thomas Harte
457b28c22c Merge branch 'master' into Plus4VideoOptions 2025-01-07 20:08:54 -05:00
Thomas Harte
095c8dcd0c Merge pull request #1445 from TomHarte/Plus4Tapes
Improve support for C16 TAP files.
2025-01-07 20:07:38 -05:00
Thomas Harte
8463e9ed94 Add selectable display type. 2025-01-07 17:41:43 -05:00
Thomas Harte
b6278c6144 Remove debugging cruft. 2025-01-06 22:17:53 -05:00
Thomas Harte
1c1e1eee47 Double clock for all non-C16s. 2025-01-06 22:04:57 -05:00
Thomas Harte
b37ed9ec60 Take yet another stab at wave/half-waves. 2025-01-06 21:40:46 -05:00
Thomas Harte
45f3ef6920 Guess that all C16-style files are 'half wave'. 2025-01-06 17:26:51 -05:00
Thomas Harte
2cd6c4238b Quieten logging. 2025-01-05 22:52:40 -05:00
Thomas Harte
f6ed0b33eb Diagnose current scrolling colour fault; hack in graphics-mode fix. 2025-01-05 22:48:16 -05:00
Thomas Harte
c4f4ca3f90 Add asserts. 2025-01-05 22:45:09 -05:00
Thomas Harte
9a6780616b Close unpainted gaps. 2025-01-05 22:25:35 -05:00
Thomas Harte
db4eca0a42 Hack forward to a woring Mad Rally. 2025-01-05 22:08:20 -05:00
Thomas Harte
6d674edb48 Merge remote-tracking branch 'origin/master' into Plus4Tapes 2025-01-05 22:07:26 -05:00
Thomas Harte
c0469a044b Add missing address warnings. 2025-01-05 21:10:23 -05:00
Thomas Harte
b9b64eba9a Map all missing registers. 2025-01-05 21:06:46 -05:00
Thomas Harte
2d74387a00 Extend TAP support for C16. 2025-01-05 20:37:39 -05:00
Thomas Harte
f66b6fc20c Attempt support for C16 TAPs. 2025-01-05 08:51:20 -05:00
Thomas Harte
f0711a9fbc Use detection for play button; allow computer to set motor. 2025-01-04 22:54:13 -05:00
Thomas Harte
83a8c7215a Merge pull request #1444 from TomHarte/AudioQueueTransients
Treat kAudioQueueErr_CannotStart as ephemeral.
2025-01-04 22:39:56 -05:00
Thomas Harte
a86f966cb4 Treat kAudioQueueErr_CannotStart as ephemeral. 2025-01-04 22:24:34 -05:00
Thomas Harte
74db978b81 Fix automatic tape motor control. 2025-01-04 22:23:46 -05:00
Thomas Harte
1300546a52 Merge pull request #1443 from TomHarte/TypingSpeed
Improve +4 typing speed.
2025-01-04 19:15:55 -05:00
Thomas Harte
3aeb0bba71 Improve +4 typing speed. 2025-01-04 15:14:25 -05:00
Thomas Harte
03d3efa323 Merge pull request #1442 from TomHarte/38columns
Progress shifter outside of painted pixels.
2025-01-04 07:20:56 -05:00
Thomas Harte
f9c220bee0 Progress shifter outside of painted pixels. 2025-01-04 07:15:20 -05:00
Thomas Harte
114c2e2636 Merge pull request #1441 from TomHarte/OSSGuardNoMacro
Remove macros from CoreAudio handler.
2025-01-03 23:38:35 -05:00
Thomas Harte
75a0e622ad Remove macros from CoreAudio handler. 2025-01-03 23:25:38 -05:00
Thomas Harte
8e2de4ee30 Merge pull request #1440 from TomHarte/MenuTweak
Improve menu wording.
2025-01-03 23:23:50 -05:00
Thomas Harte
b1602261cf Remove redundant adjective. 2025-01-03 23:23:02 -05:00
Thomas Harte
e5ed11f8ec Take another swing at menu item naming. 2025-01-03 23:21:55 -05:00
Thomas Harte
c1ecfd289e Merge pull request #1438 from TomHarte/Plus4UI
Add Plus 4 to Mac UI.
2025-01-03 23:10:45 -05:00
Thomas Harte
c5cca15b4e Extend window size. 2025-01-03 23:01:33 -05:00
Thomas Harte
fa978315e6 Add Plus 4 option to Mac UI. 2025-01-03 22:59:39 -05:00
Thomas Harte
c5bffc38f4 Switch typedefs to usings. 2025-01-03 21:35:34 -05:00
Thomas Harte
88b5f6b148 Merge pull request #1437 from TomHarte/Plus4Typer
Add TED typer.
2025-01-03 21:31:56 -05:00
Thomas Harte
fc04742151 Pull input from the typer. 2025-01-03 21:03:56 -05:00
Thomas Harte
c618d18d46 Allow typers to be attached. 2025-01-03 20:29:19 -05:00
Thomas Harte
33bc7c00df Eliminate long-ago use of typedef. 2025-01-03 20:29:05 -05:00
Thomas Harte
1ed550d7f9 Merge pull request #1434 from TomHarte/Plus4Startup
Add a simulacrum of C16+4 emulation.
2025-01-03 20:11:08 -05:00
Thomas Harte
18b87f2c80 Keep a little more state outside the main loop. 2025-01-03 20:05:43 -05:00
Thomas Harte
fad503ca80 Use correct source for bitmap address. 2025-01-03 17:31:27 -05:00
Thomas Harte
37ec3e4605 Simplify flash/inversion handling. 2025-01-03 17:27:43 -05:00
Thomas Harte
70e3d23f26 Add note to self. 2025-01-02 23:10:17 -05:00
Thomas Harte
6ebf415a52 Improve invert and flash support. 2025-01-02 23:04:35 -05:00
Thomas Harte
5c31104d0e Simplify control flow, half-obey 256-character flag. 2025-01-02 22:39:23 -05:00
Thomas Harte
aed8b65e2b Mark extra constexprs. 2025-01-02 22:01:51 -05:00
Thomas Harte
906e8aa2b2 Move nullptr check to bottom of pipeline. 2025-01-02 21:02:11 -05:00
Thomas Harte
d0703f95af Normalise adjective/noun. 2025-01-02 16:01:47 -05:00
Thomas Harte
538b00797d Flatten structure. 2025-01-02 16:00:47 -05:00
Thomas Harte
985c555518 Support multicolour text. 2025-01-02 15:56:39 -05:00
Thomas Harte
5ef26a25ee Fix shift timing. 2025-01-02 15:52:20 -05:00
Thomas Harte
3db0e30d12 Factor out 1bpp and 2bpp pixel generation. 2025-01-02 15:39:45 -05:00
Thomas Harte
a666cabae9 Support extended colour text mode. 2025-01-02 15:32:44 -05:00
Thomas Harte
2e8d9018ef Add other address modes. 2025-01-02 15:09:37 -05:00
Thomas Harte
ae49505e67 Attempt multicolour bitmap mode. 2025-01-02 15:07:22 -05:00
Thomas Harte
09bd5503b4 Fetch pixels earlier for a mostly-working high-resolution output. 2025-01-02 14:42:49 -05:00
Thomas Harte
dbe733524c Reintroduce RDY control. 2025-01-02 13:49:24 -05:00
Thomas Harte
1625f5c0f9 Take a stab at high-resolution bitmap mode. 2025-01-02 13:46:35 -05:00
Thomas Harte
7cd49d07f2 Collapse to a single function. 2025-01-02 13:39:50 -05:00
Thomas Harte
a542345456 Iterate towards supporting all video modes. 2025-01-01 22:34:47 -05:00
Thomas Harte
0b98f21443 Enable extra functionality. 2025-01-01 22:34:30 -05:00
Thomas Harte
c42e231e99 Attempt fully to support x scroll. 2025-01-01 21:47:59 -05:00
Thomas Harte
ab653af4b3 Introduce pixel-level shifter. 2025-01-01 20:58:06 -05:00
Thomas Harte
8653f572c8 Move static_assert. 2025-01-01 15:06:00 -05:00
Thomas Harte
39b431fb19 Rejig marginally. 2024-12-31 22:14:02 -05:00
Thomas Harte
e158c5bc30 Extend shifting to final column of screen. 2024-12-31 20:33:27 -05:00
Thomas Harte
d0fdfda4cb Set volume peak, count up rather than down. 2024-12-31 11:45:32 -05:00
Thomas Harte
668a5ca041 Make a real attempt at some degree of audio. 2024-12-31 10:25:11 -05:00
Thomas Harte
5e3947b8bc Evaluate address lazily. 2024-12-31 08:28:42 -05:00
Thomas Harte
233a627c9f Correct longstanding confusion over character fetch. 2024-12-31 08:25:05 -05:00
Thomas Harte
6197486d49 Use increment_video_counter_ to trigger fetch. 2024-12-31 08:06:04 -05:00
Thomas Harte
60856b974b Add wiring for audio. 2024-12-30 22:56:29 -05:00
Thomas Harte
d1eca5dc21 Expand mask. 2024-12-30 21:29:36 -05:00
Thomas Harte
24b281d625 Use namespace; attempt to avoid false characters. 2024-12-30 09:14:27 -05:00
Thomas Harte
b0d1dee38b Add missing header. 2024-12-29 22:36:14 -05:00
Thomas Harte
0751c51803 Dispatch warning. 2024-12-29 22:34:32 -05:00
Thomas Harte
0005229c1e Improve header. 2024-12-29 22:21:38 -05:00
Thomas Harte
33c2353107 Alter motor control detection. 2024-12-29 22:21:02 -05:00
Thomas Harte
cb98297bb5 Add consts. 2024-12-29 22:14:48 -05:00
Thomas Harte
0e663e1da8 Add C1541 activity indicator. 2024-12-29 21:30:53 -05:00
Thomas Harte
918a8c5f8b Fix 1541 clocking, invert levels again. 2024-12-29 08:41:37 -05:00
Thomas Harte
34938e8c62 Fully connect serial port. 2024-12-28 23:07:01 -05:00
Thomas Harte
da6efe52ff Accept implicit bool, eliminate rom name repetition. 2024-12-28 22:22:28 -05:00
Thomas Harte
570f1caa8f Attempt also to integrate a C1541. 2024-12-28 21:49:04 -05:00
Thomas Harte
6f638805f7 Further eliminate std::shared_ptr connections. 2024-12-28 20:52:31 -05:00
Thomas Harte
c92b0dc886 Start normalising Commodore serial bus interface. 2024-12-28 20:11:27 -05:00
Thomas Harte
b4b216de84 Attempt press-play feedback. 2024-12-27 21:43:41 -05:00
Thomas Harte
80f5d7c735 Attempt full tape input. 2024-12-27 21:19:41 -05:00
Thomas Harte
01aeb46664 Bump version. 2024-12-27 20:59:24 -05:00
Thomas Harte
2cfd2ff624 Start adding tape player. 2024-12-27 20:59:07 -05:00
Thomas Harte
ff12bbbdb6 Simplify delay state. 2024-12-27 17:10:25 -05:00
Thomas Harte
e19fe5d0e2 Reintroduce colour burst. 2024-12-27 09:25:36 -05:00
Thomas Harte
9670d5f4de Add cursor, proving things generally to be off by one. 2024-12-27 09:20:12 -05:00
Thomas Harte
863b09c39b Increase key bindings. 2024-12-27 09:14:23 -05:00
Thomas Harte
6b90de539e Add data delays. 2024-12-26 22:39:16 -05:00
Thomas Harte
4bb53ed6ba Start trending towards an FPGA-inspired implementation. 2024-12-26 22:33:09 -05:00
Thomas Harte
e6523f3ec1 Shuffle colour conversion moment; move ownership of clock rate. 2024-12-20 09:17:40 -05:00
Thomas Harte
c8ad8c79bd Factor in x_scroll_. 2024-12-18 22:14:57 -05:00
Thomas Harte
b08cc9cb49 Use attributes, attempt real cursor. 2024-12-18 22:07:37 -05:00
Thomas Harte
4f93dc0adf Support attribute bytes. 2024-12-18 22:02:05 -05:00
Thomas Harte
096f48be33 Fix top line of cursor, add pretend cursor, page video separately. 2024-12-18 21:48:03 -05:00
Thomas Harte
81398d58a2 Improve get_rect_for_area, use in C16. 2024-12-18 20:53:03 -05:00
Thomas Harte
7466da5651 Add Keyboard. 2024-12-18 07:04:17 -05:00
Thomas Harte
c8fdde4c5e Clarify clock rates. 2024-12-17 07:08:04 -05:00
Thomas Harte
15583e7975 Avoid risk of unbounded memory consumption. 2024-12-16 22:29:23 -05:00
Thomas Harte
5acdf39566 Use a normative, unique_ptr-based cache. 2024-12-16 22:12:12 -05:00
Thomas Harte
2240ada5db Avoid going out of bounds below. 2024-12-16 22:11:49 -05:00
Thomas Harte
9d5c10d440 Edge towards realistic video collection. 2024-12-16 22:11:06 -05:00
Thomas Harte
709f350d60 Begin usage of RDY. 2024-12-16 07:18:07 -05:00
Thomas Harte
3d7e016b42 Name horizontal events. 2024-12-15 08:46:07 -05:00
Thomas Harte
b76104d145 Start edging towards proper video timing. 2024-12-14 22:06:18 -05:00
Thomas Harte
702b6d6567 Add extra note to self. 2024-12-14 11:56:13 -05:00
Thomas Harte
3e93004db6 Double nominal clock, to hit normative values. 2024-12-14 11:55:10 -05:00
Thomas Harte
589903c43c Add safety rail. 2024-12-13 23:14:00 -05:00
Thomas Harte
f41b54de21 Make a close-enough guess at chrominances. 2024-12-13 22:25:23 -05:00
Thomas Harte
700b848f26 Add overt nils to aid with debugging. 2024-12-13 21:25:01 -05:00
Thomas Harte
a1f6e93e22 Add most of the keyboard. 2024-12-13 21:24:11 -05:00
Thomas Harte
1628af2ffc Provide a stuck down key 'a'. 2024-12-13 17:56:47 -05:00
Thomas Harte
1b5d446635 Fix: writes to interrupt status _clear_. 2024-12-13 17:22:05 -05:00
Thomas Harte
83a9ef772a Add TODO explaining all currently-unhandled writes. 2024-12-13 14:02:33 -05:00
Thomas Harte
1d9c3fb827 Hack in some text output. 2024-12-13 13:56:12 -05:00
Thomas Harte
ff92bdb324 Add buffer for pixels, output _something_. 2024-12-13 13:31:15 -05:00
Thomas Harte
363ad7342a Add memory fuzzing, some text output. 2024-12-12 22:59:20 -05:00
Thomas Harte
663acd3810 Map initial border colour, white and black. 2024-12-12 22:35:50 -05:00
Thomas Harte
c2fc26089e Add background colour reading, fix writing. 2024-12-12 22:15:15 -05:00
Thomas Harte
58b464bdfc Attempt to add interrupts. 2024-12-12 22:07:51 -05:00
Thomas Harte
ed766c74e6 Add some paging. 2024-12-12 21:17:28 -05:00
Thomas Harte
1d07b8238c Add a crop rectangle. 2024-12-12 17:36:44 -05:00
Thomas Harte
41c6ed7c5a Further restrict 'active' area of the display. 2024-12-12 17:33:11 -05:00
Thomas Harte
f7750af3d0 Provide bus visibility to video; mark vertical portion of display. 2024-12-11 22:32:14 -05:00
Thomas Harte
8854ffddee Include possible clock divider. 2024-12-11 21:57:31 -05:00
Thomas Harte
a487619578 Track basic frame events. 2024-12-11 21:54:03 -05:00
Thomas Harte
0eab6146fc Introduce a CRT. 2024-12-11 21:38:32 -05:00
Thomas Harte
389ba95e5a Template out the usual repetitive stuff of segment finding. 2024-12-11 21:30:58 -05:00
Thomas Harte
84d178c0ca Transcribe event times into [mostly] non-action. 2024-12-11 17:32:51 -05:00
Thomas Harte
aed8f8efa8 Transcribe some timing numbers. 2024-12-10 22:56:14 -05:00
Thomas Harte
38325741de Forward address information to a video stub. 2024-12-10 21:29:17 -05:00
Thomas Harte
891d5c2066 Separate out TED calls, to aid with logging. 2024-12-10 18:07:07 -05:00
Thomas Harte
6b7edac6e4 Add timers. 2024-12-10 18:04:10 -05:00
Thomas Harte
ab2a576e1b Merge branch 'master' into Plus4Startup 2024-12-09 22:23:24 -05:00
Thomas Harte
5a3e4dd47b Merge pull request #1431 from TomHarte/UniqueSectors
Eliminate use of std::shared_ptr for tracks on both sides of DiskImageHolder.
2024-12-09 22:23:01 -05:00
Thomas Harte
064c4b4312 Add some logging. 2024-12-09 22:22:20 -05:00
Thomas Harte
cbde504057 Add a memory map of sorts and a 6502. 2024-12-09 17:46:31 -05:00
Thomas Harte
949cfcfa69 Load ROMs. 2024-12-09 17:31:00 -05:00
Thomas Harte
06a005321e Merge pull request #1433 from TomHarte/DeclareFieldsAfresh
Use `std::once` in preference to home-rolled solution.
2024-12-08 22:46:21 -05:00
Thomas Harte
d3587f595f Merge pull request #1432 from TomHarte/Plus4ROMs
Add definitions for some of the Plus 4 ROMs.
2024-12-08 22:42:02 -05:00
Thomas Harte
b0158ed7ce Use std::once in preference to home-rolled solution. 2024-12-08 22:35:41 -05:00
Thomas Harte
e5f4300e54 Add definitions for some of the Plus 4 ROMs. 2024-12-08 22:03:44 -05:00
Thomas Harte
7cc6f8604e Eliminate std::shared_ptr outside of DiskImageHolder. 2024-12-08 21:49:34 -05:00
Thomas Harte
657960e7d0 Eliminate use of std::shared_ptr at DiskImage and below. 2024-12-08 21:26:03 -05:00
Thomas Harte
aecd7f9283 Merge pull request #1427 from TomHarte/CommodoreAnalyser
Improve analysis of Commodore BASIC
2024-12-08 18:59:03 -06:00
Thomas Harte
6f1b30cd24 Include Plus 4 in test target. 2024-12-07 11:56:16 -06:00
Thomas Harte
a6ba549b67 Don't repeat constant. 2024-12-07 11:55:38 -06:00
Thomas Harte
84ea04f61d Improve comments. 2024-12-07 11:54:55 -06:00
Thomas Harte
0d52cf5f97 Improve constiness. 2024-12-07 11:50:18 -06:00
Thomas Harte
b15a083a15 Switch to a non-macro route for startup declarations. 2024-12-07 10:15:38 -06:00
Thomas Harte
a128247ef5 Improve comments. 2024-12-07 09:32:45 -06:00
Thomas Harte
590bd934c0 Use built-in paralel for. 2024-12-07 09:32:32 -06:00
Thomas Harte
e9826d2e7e Use launch-time declarations. 2024-12-06 16:03:46 -05:00
Thomas Harte
58ed63cd18 Consciously uglify. These shouldn't look like functions. 2024-12-06 16:03:24 -05:00
Thomas Harte
fd1bd3032f Attempt to move towards at-launch field declaration.
This avoids any need for overt thread safety in mutations.
2024-12-06 16:00:03 -05:00
Thomas Harte
d7206096ea Attempt to parallelise. 2024-12-06 15:59:47 -05:00
Thomas Harte
f43e594eca Improve style: indentation, constness, names. 2024-12-06 15:29:49 -05:00
Thomas Harte
ea4fe5e809 Propagate Plus 4 to other project files. 2024-12-06 15:20:58 -05:00
Thomas Harte
9fcb634510 Route +4 software into a non-functional +4. 2024-12-06 15:17:49 -05:00
Thomas Harte
c14a4515ce Add consts widely. 2024-12-06 15:08:21 -05:00
Thomas Harte
8e71180cd2 Add an empty shell of a C16+4 class. 2024-12-06 13:53:08 -05:00
Thomas Harte
08f98aa32f Decrease indentation. 2024-12-06 13:52:42 -05:00
Thomas Harte
e8aa9b9eb2 Avoid overrun on empty file. 2024-12-06 13:37:06 -05:00
Thomas Harte
19f815eeff Infer more from first file starting address; reduce reallocations. 2024-12-06 13:34:35 -05:00
Thomas Harte
a508f7a463 Process all files if provided with a disk or tape. 2024-12-06 13:24:15 -05:00
Thomas Harte
e58d3ee060 Remove file. 2024-12-05 22:13:02 -05:00
Thomas Harte
268842681a Adjust move semantics. 2024-12-05 22:09:07 -05:00
Thomas Harte
9b357a9fbf Reduce copying. 2024-12-05 22:05:03 -05:00
Thomas Harte
6f80018b6e Reintroduce argument. 2024-12-05 22:04:39 -05:00
Thomas Harte
7a1153be65 Improve loop detection. 2024-12-05 17:30:30 -05:00
Thomas Harte
85d4c24aba Restore parameter name. 2024-12-05 17:29:05 -05:00
Thomas Harte
48c0ae8fe4 Avoid being thrown by looping BASIC. 2024-12-05 17:28:47 -05:00
Thomas Harte
e835b2c68c Merge branch 'master' into CommodoreAnalyser 2024-12-04 22:56:05 -05:00
Thomas Harte
10d20f5d09 Merge pull request #1429 from TomHarte/FarewellMacOS12
Remove deprecated macos-12 from CI; add macos-15.
2024-12-04 22:55:06 -05:00
Thomas Harte
88b31ea940 Merge pull request #1428 from TomHarte/MoreIndentation
Adjust more dangling indentation changes.
2024-12-04 22:40:30 -05:00
Thomas Harte
9cb28d23a3 Remove deprecated macos-12; add macos-15. 2024-12-04 22:39:29 -05:00
Thomas Harte
ce5aae3f7d Adjust more dangling indentation changes. 2024-12-04 22:29:08 -05:00
Thomas Harte
e7f0eb6746 Avoid invalid accesses. 2024-12-04 22:04:00 -05:00
Thomas Harte
65a118d1f3 Attempt to locate and disassemble machine code. 2024-12-04 21:41:05 -05:00
Thomas Harte
3d2eefc7e7 Merge pull request #1426 from TomHarte/C16Plus4Analysis
Begin Plus 4 analyser work, triggering clean-up of tape file classes.
2024-12-03 23:16:10 -05:00
Thomas Harte
f804c32eee Opportunistically const. 2024-12-03 22:57:38 -05:00
Thomas Harte
b89ecadc3a Improve interface. 2024-12-03 22:54:29 -05:00
Thomas Harte
6d4ff0b89a Finally eliminate all that virtual_ nonsense. 2024-12-03 22:28:57 -05:00
Thomas Harte
598003ea39 Continue marking override. 2024-12-03 21:18:26 -05:00
Thomas Harte
6ef63790a9 Mark overrides, improve constiness. 2024-12-03 17:33:09 -05:00
Thomas Harte
3ffd986a1c Start building Commodore analyser tests. 2024-12-03 09:25:58 -05:00
Thomas Harte
0b5cd4c665 Lock all tape classes down to read-only. 2024-12-03 09:21:13 -05:00
Thomas Harte
0371b0507a Avoid potential extending run-out-of-bounds. 2024-12-03 09:19:23 -05:00
Thomas Harte
9fa71231c4 Support zero-length files; further fix bounds checks. 2024-12-02 17:23:50 -05:00
Thomas Harte
32beafc12d Test Plus 4 detectionl; add shout for additional start address. 2024-12-02 15:27:37 -05:00
Thomas Harte
09e2ef334b Fix sign of bounds check. 2024-12-02 15:27:03 -05:00
Thomas Harte
c0ce62ed2b Merge pull request #1425 from TomHarte/MoreIndentation
Take another big swing at indentation, some `const`s.
2024-12-01 22:02:25 -05:00
Thomas Harte
d3ed485e7a Take another big swing at indentation, some consts. 2024-12-01 21:44:14 -05:00
Thomas Harte
31c878b654 Merge pull request #1424 from TomHarte/InstructionSetFormatting
Improve formatting, `const`ness in instruction sets.
2024-12-01 20:24:55 -05:00
Thomas Harte
3a0f4a0bfc Improve constness, formatting. 2024-12-01 18:09:19 -05:00
Thomas Harte
8b88d1294d Remove errant spaces. 2024-12-01 09:04:32 -05:00
Thomas Harte
43fcf46d69 Limit line lengths. 2024-12-01 09:00:29 -05:00
Thomas Harte
394fe0f1f1 Improve formatting, constness in 68k and ARM instruction set implementations. 2024-12-01 08:20:24 -05:00
Thomas Harte
872921f635 Merge pull request #1423 from TomHarte/InputsFormatting
Roll formatting and `const` tweaks into Inputs.
2024-11-30 19:25:50 -05:00
Thomas Harte
7248470950 Roll formatting and const tweaks into Inputs. 2024-11-30 18:57:56 -05:00
Thomas Harte
9d87296316 Merge pull request #1422 from TomHarte/MutableLevels
Correct improper application of `const`.
2024-11-30 17:53:56 -05:00
Thomas Harte
23c67f7e38 Correct improper application of const. 2024-11-30 17:32:16 -05:00
Thomas Harte
bd98d95dbf Merge pull request #1421 from TomHarte/FurtherFormatting
Further improve formatting.
2024-11-30 17:22:00 -05:00
Thomas Harte
3addb8d72b Finish updating components. 2024-11-30 17:21:00 -05:00
Thomas Harte
5545906063 Adopt new indentation, improve constness. 2024-11-30 15:53:58 -05:00
Thomas Harte
36edfe9715 Merge pull request #1420 from TomHarte/NewIcon
Import new icons.
2024-11-29 23:10:31 -05:00
Thomas Harte
030b54a2b6 Import new icons. 2024-11-29 23:04:28 -05:00
Thomas Harte
f332613922 Merge pull request #1419 from TomHarte/Reformatting
Begin a general reformatting.
2024-11-29 22:52:29 -05:00
Thomas Harte
088bc14b11 Begin a reformatting of components. 2024-11-29 22:43:54 -05:00
Thomas Harte
86fa8da8c5 Reformat ClockReceiver. 2024-11-29 22:12:57 -05:00
Thomas Harte
abfc73299e Update remainder of 'Analyser'. 2024-11-29 21:08:35 -05:00
Thomas Harte
bd97fd5973 Improve indentation, constness of 'Activity' and dynamic analyser. 2024-11-29 17:23:05 -05:00
Thomas Harte
f00e7c4a80 Merge pull request #1413 from TomHarte/ShakerScanTarget
Avoid taking an out-of-range pointer.
2024-10-19 10:15:30 -04:00
Thomas Harte
49c811b5f5 Avoid taking an out-of-range pointer.
(Even though it was safe)
2024-10-19 10:12:51 -04:00
Thomas Harte
b6c21e071d Update version number. 2024-10-19 09:19:59 -04:00
Thomas Harte
e68129e47e Merge pull request #1412 from TomHarte/CRTCType
Specify correct 6845; experiment with vsync.
2024-10-18 20:31:45 -04:00
Thomas Harte
72d7917415 Specify correct 6845; experiment with vsync. 2024-10-16 21:02:58 -04:00
Thomas Harte
53837fe132 Merge pull request #1411 from TomHarte/CMakeWarnings
Resolve GCC/Ubuntu CI warnings.
2024-10-15 22:25:06 -04:00
Thomas Harte
08d094c786 Use appropriate std::array semantics. 2024-10-15 22:14:29 -04:00
Thomas Harte
a1634ab496 Reduce uninitialised usages. 2024-10-15 22:10:16 -04:00
Thomas Harte
d35165bd8e Correct parameter usage. 2024-10-15 21:54:04 -04:00
Thomas Harte
b701ce9721 Shuffle construction order. 2024-10-15 21:51:23 -04:00
Thomas Harte
f3e18da416 Use custom type for deleter. 2024-10-15 21:49:42 -04:00
Thomas Harte
131ab00304 Merge pull request #1410 from TomHarte/CPCLatency
Further improve the CPC side of the CPC:CRTC relationship.
2024-10-15 21:30:39 -04:00
Thomas Harte
26d7d58a5f Add TODO. 2024-10-15 21:16:07 -04:00
Thomas Harte
02f92a7818 Handle runs that don't cross a pixel boundary.
`
2024-10-15 21:15:30 -04:00
Thomas Harte
b6fff521e4 Allow new interrupts to override the end of previous. 2024-10-15 12:27:30 -04:00
Thomas Harte
23f1308231 Experiment with reads/writes earlier in the transaction. 2024-10-15 12:10:36 -04:00
Thomas Harte
947e890c59 Adjust mode latch time, timer hsync signalling. 2024-10-15 11:53:00 -04:00
Thomas Harte
0f1714de7c Merge pull request #1409 from TomHarte/68000Constness
68000: `Const` as many arguments as possible.
2024-10-13 21:58:02 -04:00
Thomas Harte
a7d2b0f63b Const as many arguments as possible. 2024-10-13 21:40:39 -04:00
Thomas Harte
9c550a8154 Merge pull request #1408 from TomHarte/M50740ExecutorStyle
Eliminate majority of M50740 macros
2024-10-10 13:46:34 -04:00
Thomas Harte
49012a21c8 Convert index macro. 2024-10-09 21:50:03 -04:00
Thomas Harte
f136151064 Transcribe op_X macros. 2024-10-09 21:46:30 -04:00
Thomas Harte
4838728521 Eliminate nibble macros. 2024-10-09 21:04:32 -04:00
Thomas Harte
95fac5dc13 Begin macro elimination. 2024-10-09 14:27:35 -04:00
Thomas Harte
ac1f7884b5 Merge pull request #1407 from TomHarte/OptionalCPMData
Reduce costs of CPC disk analysis by not loading unused contents.
2024-10-09 14:16:53 -04:00
Thomas Harte
ab411512d4 Merge pull request #1405 from TomHarte/CRTCFixes
Redraft CRTC closer to raw logic.
2024-10-09 14:14:43 -04:00
Thomas Harte
704495ff42 Made reading of data optional. 2024-10-09 12:27:51 -04:00
Thomas Harte
9acc80260f Eliminate phases due to lack of evidence. 2024-10-09 11:59:27 -04:00
Thomas Harte
7759fb7e68 Add TODO. 2024-10-09 11:48:08 -04:00
Thomas Harte
0d71724598 Eliminate extra-scanline flag. 2024-10-09 11:45:32 -04:00
Thomas Harte
ae436f7a51 Fix conflicting usages of EOF. 2024-10-09 11:16:12 -04:00
Thomas Harte
43ac20cbd2 Fix non-interlaced frame length. 2024-10-07 21:50:56 -04:00
Thomas Harte
2d90868f5c Reinstitute cursor. 2024-10-07 21:13:44 -04:00
Thomas Harte
60987ae4a7 Round out interlaced output. 2024-10-07 20:53:41 -04:00
Thomas Harte
65c1d99120 Add, disable some logging. 2024-10-05 22:30:53 -04:00
Thomas Harte
35acf88847 Take a swing at adding an adjustment period. 2024-10-03 22:07:46 -04:00
Thomas Harte
45549b5fcd Switch CRTC type. 2024-10-03 22:07:12 -04:00
Thomas Harte
2eb9fb6a08 Add faulty attempt at adjustment period. 2024-09-30 23:47:27 -04:00
Thomas Harte
0d0e1083e6 Fix potential out-of-bounds access. 2024-09-30 13:37:44 -04:00
Thomas Harte
e650f3772a Limit vertical visibility. 2024-09-30 13:35:28 -04:00
Thomas Harte
e5ff4c65b7 Fix accidental skew, off-by-one end of line. 2024-09-30 13:20:18 -04:00
Thomas Harte
276809f76a Stabilise image, albeit incorrectly. 2024-09-30 13:16:03 -04:00
Thomas Harte
5e3840c5f1 Attempt to skirt with coherence. 2024-09-29 23:08:39 -04:00
Thomas Harte
6eace2a3ef Improve address counting. 2024-09-27 21:27:56 -04:00
Thomas Harte
7817b23857 Take a swing at vertical sync. 2024-09-27 21:14:57 -04:00
Thomas Harte
432854aeb5 Restore some form of visuals. 2024-09-26 22:08:22 -04:00
Thomas Harte
433c8f9c3c Make negligible progress. 2024-09-25 19:30:08 -04:00
Thomas Harte
ea25dbfd1e Begin CRTC rejig. 2024-09-23 21:11:54 -04:00
Thomas Harte
10f8318e79 Merge pull request #1404 from TomHarte/65816SquareD
65816: correct emulation-mode `[d], y`, `PEI` and `PLB`.
2024-09-21 21:46:00 -04:00
Thomas Harte
17ff0c4f65 Fix PLD/PLB sizes. 2024-09-21 21:28:38 -04:00
Thomas Harte
9abd653fb9 Avoid impossible clamps. 2024-09-21 21:25:49 -04:00
Thomas Harte
ff6753fcdf PEI: don't page wrap. 2024-09-21 21:12:04 -04:00
Thomas Harte
a65551f652 Give PLB the same stack behaviour as PLD. 2024-09-21 21:08:02 -04:00
Thomas Harte
f0d807a0fe Fix [d], y page-wrapping behaviour. 2024-09-21 20:49:59 -04:00
Thomas Harte
dfcdbe5b6a Merge pull request #1402 from TomHarte/CPCInterruptTiming
Pull CPC interrupt to start of hsync.
2024-09-12 21:12:02 -04:00
Thomas Harte
53e73238fd Merge pull request #1403 from TomHarte/OricVSync
Extend Oric vsync to four lines.
2024-09-12 21:08:51 -04:00
Thomas Harte
581454db69 Tweak mode latch time too. 2024-09-12 20:47:27 -04:00
Thomas Harte
63d501b629 Pull interrupt to start of hsync. 2024-09-12 20:45:28 -04:00
Thomas Harte
60bd877ed9 Merge pull request #1401 from TomHarte/OricVSync
Add the Oric's v-sync hardware hack.
2024-09-10 21:18:03 -04:00
Thomas Harte
44574465c5 Extend vsync to four lines. 2024-09-10 21:06:49 -04:00
Thomas Harte
2b7382a014 Loop in vsync as a potential tape input. 2024-09-10 20:59:05 -04:00
Thomas Harte
584b6df40d Tweak 60Hz period. 2024-09-10 20:43:01 -04:00
Thomas Harte
e55f61deb2 Add vsync getter. 2024-09-10 20:31:35 -04:00
Thomas Harte
a6c6a1c6da Eliminate macros. 2024-09-10 20:29:34 -04:00
Thomas Harte
bdb5abe47b Record updated version number. 2024-09-08 21:34:02 -04:00
Thomas Harte
dbe0ebc93e Merge pull request #1400 from TomHarte/DelegateOrderTest
Fix order of `if` tests.
2024-09-08 21:30:44 -04:00
Thomas Harte
1c2f66e855 Fix order of if tests. 2024-09-08 21:23:58 -04:00
Thomas Harte
7eee3f9e5e Merge pull request #1399 from TomHarte/ElectronULARedux
Replace Electron graphics generation with FPGA transcription.
2024-09-08 21:23:09 -04:00
Thomas Harte
b7f069e1bd Add a colour burst. 2024-09-08 21:12:45 -04:00
Thomas Harte
51c8396e32 Fix faulty centring. 2024-09-08 21:06:59 -04:00
Thomas Harte
0efe649ca5 Post pixel clock. 2024-09-08 20:57:43 -04:00
Thomas Harte
75db0018bc Add note on provenance. 2024-09-08 20:20:03 -04:00
Thomas Harte
2a9e1ea045 Use normal member naming convention. 2024-09-08 20:16:43 -04:00
Thomas Harte
8feb8aaadc Reintroduce cropping, even if faulty. 2024-09-06 22:12:19 -04:00
Thomas Harte
b8f4385501 Fix palette generation. 2024-09-06 21:47:13 -04:00
Thomas Harte
d8b6d87a1c Attempt colour. 2024-09-06 21:36:05 -04:00
Thomas Harte
f10702b3ca Edge towards proper serialisation. 2024-09-06 21:01:30 -04:00
Thomas Harte
88248d7062 Fix base address, delays. 2024-09-06 20:55:26 -04:00
Thomas Harte
5ca1659bcc Do just enough to get 1bpp fixed-palette pixels. 2024-09-06 20:36:27 -04:00
Thomas Harte
59530a12fd Sub in basic transliteration of hoglet's FPGA. 2024-09-06 20:21:46 -04:00
Thomas Harte
aab2dd68b6 Substitute in a real-time video generator. 2024-09-06 20:18:29 -04:00
Thomas Harte
83f5065642 Update version. 2024-08-26 21:38:49 -04:00
Thomas Harte
7e3a331eba Merge pull request #1394 from TomHarte/ElectronFlicker
Electron: don't miss interrupts early in the frame.
2024-08-26 21:28:53 -04:00
Thomas Harte
b5932edff3 Avoid missed interrupts on wraparound. 2024-08-26 21:13:49 -04:00
Thomas Harte
12846317cb Short-circuit non-interrupts. 2024-08-26 21:13:25 -04:00
Thomas Harte
051f0546c7 Merge pull request #1393 from TomHarte/ZXAnalysis
Improve Spectrum +3 disk analysis.
2024-08-24 21:45:45 -04:00
Thomas Harte
eece8c54a4 Factgor out and reuse is-ZX test. 2024-08-22 21:17:35 -04:00
Thomas Harte
69ba94e379 Add some CP/M smarts to +3 disk analysis. 2024-08-20 21:43:31 -04:00
Thomas Harte
0de7057d6f Use standard algorithm. 2024-08-20 20:45:43 -04:00
Thomas Harte
3dcbb40c55 Merge pull request #1391 from TomHarte/SSLandCSL
Treat second argument to key_delay as optional.
2024-08-14 19:56:18 -05:00
Thomas Harte
91b263f0cf Treat second argument as optional. 2024-08-14 20:55:33 -04:00
Thomas Harte
bcd558867d Merge pull request #1387 from TomHarte/SSLandCSL
CPC: implement CSL and SSM to run Shaker tests.
2024-08-14 19:55:18 -05:00
Thomas Harte
a9c8ef642c Correct original author's typo. 2024-08-14 18:55:35 -04:00
Thomas Harte
43887b42b1 Allow vsync on line 0. 2024-08-07 23:05:26 -04:00
Thomas Harte
30b1b36e63 Test digits individually; CSLs autolink. 2024-08-07 22:44:48 -04:00
Thomas Harte
ef11262721 Expand test membership. 2024-08-07 22:15:43 -04:00
Thomas Harte
2d049f5fdc Implement reset, correct file names. 2024-08-07 22:00:24 -04:00
Thomas Harte
05f0a122f4 Blank out border. 2024-08-05 22:06:23 -04:00
Thomas Harte
1977675a73 Add some measure of graphics output. 2024-08-05 21:48:40 -04:00
Thomas Harte
4ceaab7c26 Merge branch 'master' into SSLandCSL 2024-07-26 22:08:11 -04:00
Thomas Harte
6c33177548 Merge pull request #1389 from TomHarte/6502JAM
Correct 6502 JAM bus activity.
2024-07-26 22:07:40 -04:00
Thomas Harte
76ca607021 Add a graceful end for JAM. 2024-07-26 21:45:17 -04:00
Thomas Harte
59e1a5e5f6 Correct 6502 JAM behaviour. 2024-07-26 21:43:54 -04:00
Thomas Harte
4f55b2a554 Merge branch 'SSLandCSL' of github.com:TomHarte/CLK into SSLandCSL 2024-07-08 00:24:22 +02:00
Thomas Harte
78b2a89554 Add header for std::vector. 2024-07-08 00:20:54 +02:00
Thomas Harte
1e84a735e6 Add header for std::vector. 2024-07-08 00:18:53 +02:00
Thomas Harte
9e8801d867 Add header for std::variant. 2024-07-08 00:17:39 +02:00
Thomas Harte
0e58f7fa69 Merge branch 'master' into SSLandCSL 2024-07-05 14:54:47 -04:00
Thomas Harte
94058d498c Merge pull request #1388 from TomHarte/6502BBSBBR
Correct 65c02 BBS/BBR bus activity.
2024-07-05 14:51:31 -04:00
Thomas Harte
2621bcc005 Switch to 5/6/7 BBS/BBR timing. 2024-07-05 13:44:31 -04:00
Thomas Harte
e750866ab6 Remove phoney mid-BBR/BBS access. 2024-07-02 22:01:02 -04:00
Thomas Harte
00b3007b9f Switch byte order. 2024-07-02 21:51:00 -04:00
Thomas Harte
dbc0ecde31 Catch SSM events. 2024-06-30 21:26:16 -04:00
Thomas Harte
0e30e2d865 Add CSL side of execution. 2024-06-30 20:19:02 -04:00
Thomas Harte
ba1879ef78 Add URL credit. 2024-06-28 21:53:18 -04:00
Thomas Harte
7a145d72f9 Start Shaker test case. 2024-06-28 21:52:04 -04:00
Thomas Harte
f742266177 Add SSM code capture to CPC. 2024-06-26 21:53:11 -04:00
Thomas Harte
63737c09aa Improve handling of compound sequences. 2024-06-20 22:13:19 -04:00
Thomas Harte
09e8d4ba0a Do enough to parse sample files. 2024-06-18 22:16:23 -04:00
Thomas Harte
7d728c37ee Fix comment, both grammar and content. 2024-06-18 12:56:25 -04:00
Thomas Harte
e46b12e359 Start parsing CSL. 2024-06-16 14:27:48 -04:00
Thomas Harte
b3012bd89e Update version number. 2024-06-02 22:29:25 -04:00
Thomas Harte
f521c12d85 Merge pull request #1385 from TomHarte/VicBorders
CRT: accept data during retrace.
2024-06-02 22:18:25 -04:00
Thomas Harte
58f04848a9 Fix: allow allocations on invisible areas. 2024-06-02 21:59:27 -04:00
Thomas Harte
6488f46850 Normalise variable names. 2024-06-02 21:58:49 -04:00
Thomas Harte
5f4b798cff Clarify scope of this_state. 2024-06-01 20:05:51 -04:00
Thomas Harte
ffa8f1db04 Merge pull request #1384 from TomHarte/QtArchimedes
Add Archimedes Qt UI options.
2024-05-31 21:25:49 -04:00
Thomas Harte
cf2711f6dd Add Archimedes Qt UI options. 2024-05-31 21:17:56 -04:00
Thomas Harte
25eded1895 Merge pull request #1382 from TomHarte/QtRepair
Qt: Correct Electron target name.
2024-05-29 22:24:52 -04:00
Thomas Harte
a8ac8f4a23 Correct Electron target name. 2024-05-29 22:24:15 -04:00
Thomas Harte
c67a53e95b Merge pull request #1381 from TomHarte/MemoryOrder
Avoid `std::memory_order::memory_order_X` in favour of `std::memory_order_X`.
2024-05-29 22:01:20 -04:00
Thomas Harte
edf4ba2533 Merge pull request #1380 from TomHarte/NoPairs
Eliminate various unnecessary uses of `std::make_pair`.
2024-05-29 21:59:59 -04:00
Thomas Harte
71d337c10e Avoid std::memory_order::. 2024-05-29 21:51:07 -04:00
Thomas Harte
eb9e5fb727 Eliminate various unnecessary uses of std::make_pair. 2024-05-29 21:46:33 -04:00
Thomas Harte
f133000656 Update version number. 2024-05-27 15:05:47 -04:00
Thomas Harte
71361638bb Merge pull request #1379 from TomHarte/UnambiguousRejection
Don't move cursor near disk to folder if not about to load something.
2024-05-27 15:05:04 -04:00
Thomas Harte
edc7fe9c72 Simplify actions. 2024-05-27 14:54:09 -04:00
Thomas Harte
3110041a06 Don't seem to move near disk folder if not loading. 2024-05-27 14:45:37 -04:00
Thomas Harte
ff78e4172d Merge pull request #1378 from TomHarte/FastArchimedesDisks
Support FDC overclocking as 'fast loading'.
2024-05-26 22:19:40 -04:00
Thomas Harte
a1c23be73d Remove development dead ends. 2024-05-26 22:03:48 -04:00
Thomas Harte
eb2b1cb093 Support FDC overclocking as 'fast loading'. 2024-05-26 22:02:40 -04:00
Thomas Harte
f2245b8066 Merge pull request #1377 from TomHarte/TidySWIs
Clean up, slightly.
2024-05-26 14:43:40 -04:00
Thomas Harte
793b6d1deb Clean up, slightly. 2024-05-26 14:42:54 -04:00
Thomas Harte
537b91fa3f Merge pull request #1374 from TomHarte/SWIAnalyser
Add Archimedes autostart behaviour.
2024-05-24 16:32:45 -04:00
Thomas Harte
b7777c9ca3 Avoid linkage warning. 2024-05-24 15:39:38 -04:00
Thomas Harte
5235262855 Add default value. 2024-05-24 15:29:11 -04:00
Thomas Harte
7b90c36463 Shorten clicks, ensure no lost actions. 2024-05-24 15:23:45 -04:00
Thomas Harte
6407ab0673 Clean up, improve application-menu response. 2024-05-24 14:32:55 -04:00
Thomas Harte
78ec9e5a60 Limit character range. 2024-05-23 22:31:43 -04:00
Thomas Harte
778ac6e6d1 Complete autoload loop. 2024-05-23 22:16:40 -04:00
Thomas Harte
5280f5aba2 Attempt to spot screen takeovers. 2024-05-23 22:03:40 -04:00
Thomas Harte
67add0da93 Use both sources. 2024-05-21 22:23:53 -04:00
Thomas Harte
a32da9a6e1 Restore preference against !Boot. 2024-05-21 22:12:55 -04:00
Thomas Harte
b6b70bb7ff Add title fallbacks, ensure 'read' costs even 0.0-weight options. 2024-05-21 22:06:09 -04:00
Thomas Harte
6d769c9e89 Use string similarity as a program differentiator. 2024-05-21 21:49:30 -04:00
Thomas Harte
0c683c2c81 Merge branch 'master' into SWIAnalyser 2024-05-21 07:38:23 -04:00
Thomas Harte
8e51bd7578 Merge branch 'master' of github.com:TomHarte/CLK 2024-05-21 07:38:10 -04:00
Thomas Harte
6d6dfa4f44 Introduce Archimedes analyser tests. 2024-05-20 22:48:20 -04:00
Thomas Harte
7d044ad0ab Merge pull request #1376 from TomHarte/Remove-macos-11
Eliminate macos11 runner.
2024-05-20 16:29:02 -04:00
Thomas Harte
826f4c1d48 Eliminate macos-11.
As per GitHub's announcement that "The macOS 11 runner image will be removed by 6/28/24"
2024-05-20 14:21:42 -04:00
Thomas Harte
3be5d60b1e Eliminate comparison costs. 2024-05-18 22:16:58 -04:00
Thomas Harte
26375dc023 Introduce named constants. 2024-05-16 22:19:26 -04:00
Thomas Harte
8d0d7abd5a Keep track of state separately from scanning. 2024-05-16 22:18:51 -04:00
Thomas Harte
ef03ddf2ae Extend to launching the target program. 2024-05-14 22:23:35 -04:00
Thomas Harte
1d8b33d7ae Attempt to improve trajectory. 2024-05-13 22:26:36 -04:00
Thomas Harte
308b3ca448 Gamely attempt to pick an Arc program to start. 2024-05-13 22:25:02 -04:00
Thomas Harte
ca67afea4c Correct some unique-ptr oddities. 2024-05-13 21:46:03 -04:00
Thomas Harte
0b11fc259b Add Archimedes-specific target class. 2024-05-13 21:42:38 -04:00
Thomas Harte
18ffb9294f Add full cursor automation. 2024-05-12 22:16:29 -04:00
Thomas Harte
c82517c9fd Add mouse position getter. 2024-05-11 13:07:12 -04:00
Thomas Harte
6d42c9aaf9 Start making leeway on interesting SWIs. 2024-05-06 22:40:00 -04:00
Thomas Harte
02ee3a7804 Turf out old debugging cruft. 2024-05-06 20:36:00 -04:00
Thomas Harte
bdf1dff976 Update version number. 2024-05-04 21:16:43 -04:00
Thomas Harte
e6724a701a Merge pull request #1373 from TomHarte/DiskReady
Further adjust RDY.
2024-04-30 22:50:17 -04:00
Thomas Harte
d90eedfc8c Adjust bit polarity, meaning. 2024-04-30 22:49:26 -04:00
Thomas Harte
63009d00b4 Merge pull request #1372 from TomHarte/DiskReady
Add Archimedes disk drive RDY signal.
2024-04-30 22:38:20 -04:00
Thomas Harte
6a2261d217 Merge branch 'master' into DiskReady 2024-04-30 22:38:07 -04:00
Thomas Harte
c3ad2154b5 Merge pull request #1371 from TomHarte/Interlacing
Support Archimedes interlaced video.
2024-04-30 22:37:48 -04:00
Thomas Harte
3d61861737 Ensure switch is complete. 2024-04-30 22:26:19 -04:00
Thomas Harte
7545786436 Ensure extra line types are used. 2024-04-30 22:22:18 -04:00
Thomas Harte
a997b6c677 Wire drives for IBM-style RDY. 2024-04-30 22:18:17 -04:00
Thomas Harte
72d4f638aa Merge branch 'master' into Interlacing 2024-04-30 22:08:57 -04:00
Thomas Harte
b15ff6d442 Support interlaced video timing. 2024-04-30 22:06:08 -04:00
Thomas Harte
cb70967971 Merge pull request #1370 from TomHarte/Zarch
Add automatic runtime frame-rate limiter.
2024-04-30 22:02:06 -04:00
Thomas Harte
42aea2663c Add automatic runtime frame-rate limiter. 2024-04-30 21:38:37 -04:00
Thomas Harte
a882faa7f6 Merge pull request #1369 from TomHarte/UnmaskedSubAddresses
Mildly reduce ARM/Archimedes hot-path costs.
2024-04-29 22:58:22 -04:00
Thomas Harte
5da01e4fd8 Add potential short-circuit. 2024-04-29 22:45:30 -04:00
Thomas Harte
71c5a1d419 Avoid repeated trans comparison. 2024-04-29 22:35:01 -04:00
Thomas Harte
03c3da7338 Bifurcate Zone enum, possibly to help compiler. 2024-04-29 22:34:46 -04:00
Thomas Harte
47b276ca0b Merge pull request #1368 from TomHarte/MinorTweaks
Fix trans for instruction fetches.
2024-04-29 22:29:25 -04:00
Thomas Harte
c7747ec5a0 Remove a conditional from the hot path. 2024-04-29 22:16:06 -04:00
Thomas Harte
5a84e98256 Fix trans for instruction fetches. 2024-04-29 21:54:59 -04:00
Thomas Harte
b66d69b60c Merge pull request #1367 from TomHarte/FloppyHeft
Slightly reduce processing heft of floppy accesses.
2024-04-28 22:49:31 -04:00
Thomas Harte
dfaea5a922 Reduce floppy access cost. 2024-04-28 22:40:54 -04:00
Thomas Harte
f4da417c3a Merge pull request #1366 from TomHarte/VIDCDelays
Add various VIDC output latencies.
2024-04-28 22:39:29 -04:00
Thomas Harte
fa7fff86eb Eject invalid specialisation. 2024-04-28 22:20:26 -04:00
Thomas Harte
d480f9eae2 Reinstate all missing video modes. 2024-04-28 21:49:04 -04:00
Thomas Harte
4f1aef90b8 Relocate pixel collection and cursor shifting. 2024-04-26 21:29:30 -04:00
Thomas Harte
24f4538eb7 Do faulty restoration of 4bpp mode. 2024-04-25 22:50:24 -04:00
Thomas Harte
38d096cad6 Begin new state machine, losing all non-cursor pixels. 2024-04-25 22:01:38 -04:00
Thomas Harte
b82af9c471 Fix vertical timing; don't miss border colour changes. 2024-04-24 20:47:11 -04:00
Thomas Harte
0bff2089c4 Merge pull request #1364 from TomHarte/SomeWarnings
Resolve various warnings.
2024-04-23 19:40:43 -07:00
Thomas Harte
36d9c40d7b Yuckily avoid warning. 2024-04-23 22:23:56 -04:00
Thomas Harte
becb6ce2e0 Fix two more not-really-an-issue warnings. 2024-04-23 22:20:13 -04:00
Thomas Harte
56b65780d2 Avoid loading nonsense value upon data abort. 2024-04-22 22:09:57 -04:00
Thomas Harte
265d151879 Fix data aborts. 2024-04-22 22:08:09 -04:00
Thomas Harte
c485097eed Fix bool combination. 2024-04-22 22:06:09 -04:00
Thomas Harte
f86e9fe086 Eliminate impossible conditional. 2024-04-22 21:58:49 -04:00
Thomas Harte
c91ce4cfea Ensure all routes return. 2024-04-22 21:57:20 -04:00
Thomas Harte
8e64a854fc Ensure all routes return; mildly decrease conditionals. 2024-04-22 21:56:53 -04:00
Thomas Harte
7c9383cd6b Update version number. 2024-04-20 14:45:21 -04:00
Thomas Harte
82d03e3980 Merge pull request #1362 from TomHarte/ThreeStepPipeline
Introduce some degree of an ARM pipeline.
2024-04-19 19:41:46 -07:00
Thomas Harte
0775e3ad58 This is an 8-bit value. 2024-04-19 22:35:43 -04:00
Thomas Harte
ea3eef3817 Put interrupts into pipeline, without delay. 2024-04-19 22:21:23 -04:00
Thomas Harte
83eac172c9 Revoke in-pipeline interrupts.
I'm unclear on what timing should apply here really.
2024-04-19 21:46:09 -04:00
Thomas Harte
5b13d3e893 Attempt the prefetch portion of a pipeline. 2024-04-19 21:30:15 -04:00
Thomas Harte
807835b9fe Merge pull request #1361 from TomHarte/Pipeline
Provide hooks for implementing pipeline prefetch.
2024-04-19 06:58:45 -07:00
Thomas Harte
4bf02122ee Fix disassembler. 2024-04-18 23:17:44 -04:00
Thomas Harte
e6c4454059 Provide a means for SWI interception. 2024-04-18 22:13:58 -04:00
Thomas Harte
d464ce831a Add did_set_pc. 2024-04-18 19:30:07 -04:00
Thomas Harte
018f0e097f Merge pull request #1358 from TomHarte/ADFS-D
Ensure ADFS-D discs are recognised.
2024-04-17 23:06:49 -04:00
Thomas Harte
2acb853021 Merge pull request #1357 from TomHarte/EasyWins
Improve MEMC speed.
2024-04-17 22:47:04 -04:00
Thomas Harte
acd477df39 Ensure ADFS-D discs are recognised. 2024-04-17 22:44:55 -04:00
Thomas Harte
da520de9ef Further appease GCC. 2024-04-17 22:38:32 -04:00
Thomas Harte
e680a973b0 Appease GCC with a 'default'. 2024-04-17 22:17:24 -04:00
Thomas Harte
07984a2f8b Resolve various warnings. 2024-04-17 22:15:05 -04:00
Thomas Harte
16532136e9 Merge branch 'master' into EasyWins 2024-04-17 21:40:01 -04:00
Thomas Harte
30c2c65b77 Eliminate hot-path switch. 2024-04-17 21:36:39 -04:00
Thomas Harte
b63178132d Move trans tests inside switch. 2024-04-17 21:29:42 -04:00
Thomas Harte
6d66c90aad Merge pull request #1356 from TomHarte/ArchimedesGUI
Add macOS route to starting empty Archimedes.
2024-04-17 21:26:03 -04:00
Thomas Harte
c807c75412 Revert version change. 2024-04-17 21:25:12 -04:00
Thomas Harte
f6feaddfe6 Add macOS route to starting empty Archimedes. 2024-04-17 20:44:45 -04:00
Thomas Harte
87d1a476a4 Merge pull request #1355 from TomHarte/Archimedes
Add an inaccurate, basic Archimedes.
2024-04-16 22:45:42 -04:00
Thomas Harte
f7337f2400 Adopt 50%:50% tables throughout. 2024-04-16 22:45:01 -04:00
Thomas Harte
fac94a5d36 Reduce MIPS. Until other performance issues can be resolved. 2024-04-16 22:32:00 -04:00
Thomas Harte
140228a936 Mildly reduce heft of scale read. 2024-04-16 22:31:40 -04:00
Thomas Harte
06fd91f002 Fix period, table lookup. 2024-04-16 22:12:10 -04:00
Thomas Harte
c3d4d0ee38 Introduce panning, threading. 2024-04-16 21:56:34 -04:00
Thomas Harte
30cca54e6c Diagnostically try for a square wave. 2024-04-13 22:10:34 -04:00
Thomas Harte
6ac6e48b95 Attempt audio output. 2024-04-13 21:54:50 -04:00
Thomas Harte
779794632e Generate volume ramp. 2024-04-13 20:23:47 -04:00
Thomas Harte
88bb16f261 Install proper filter frequency. 2024-04-13 15:34:39 -04:00
Thomas Harte
c134c7bdc2 Fix: signal is 'flyback', not sync. 2024-04-10 21:53:38 -04:00
Thomas Harte
6c6cda3db5 Use clocking hints. 2024-04-09 22:22:03 -04:00
Thomas Harte
a29f246536 Move to more natural position of ownership. 2024-04-09 22:10:07 -04:00
Thomas Harte
d9d675a74f Fix scan status scale. 2024-04-09 21:56:42 -04:00
Thomas Harte
d62ea95889 Make some intimation towards audio. 2024-04-09 21:53:40 -04:00
Thomas Harte
e2e951ad0b Fix layout. 2024-04-09 21:49:35 -04:00
Thomas Harte
a5a653d684 Factor vsync state into IO reads. 2024-04-09 21:49:00 -04:00
Thomas Harte
6123350895 Improve state guesswork. 2024-04-09 21:24:08 -04:00
Thomas Harte
ec73c00c3b Silence the routine stuff of interrupt masks. 2024-04-09 20:57:57 -04:00
Thomas Harte
dd24f5f4f3 Don't latch video addresses until almost the last minute. 2024-04-09 20:56:10 -04:00
Thomas Harte
82a2e802ea Life's too short; just do it in HTML. 2024-04-08 23:11:22 -04:00
Thomas Harte
3b75eeb70a Try two divs. 2024-04-08 22:46:45 -04:00
Thomas Harte
ee4575b70f Attempt a div. 2024-04-08 22:45:41 -04:00
Thomas Harte
46a4ec1cb1 Reshuffle images. 2024-04-08 22:42:49 -04:00
Thomas Harte
8ab77a3260 Attempt to even out columns. 2024-04-08 22:39:14 -04:00
Thomas Harte
b875e349c1 Mention the Archimedes. 2024-04-08 22:34:08 -04:00
Thomas Harte
169298af42 Plumb through disk insertion.
Surprisingly: some things now load.
2024-04-08 21:15:40 -04:00
Thomas Harte
5e502df48b Forward motor and drive selection. 2024-04-07 22:29:00 -04:00
Thomas Harte
4f58664f97 Catch interrupt enables. 2024-04-07 22:08:12 -04:00
Thomas Harte
ffd298218c Tie off initial values; fix FIQ usage. 2024-04-07 21:58:16 -04:00
Thomas Harte
d2b077c573 Start wiring in a floppy controller. 2024-04-07 21:22:35 -04:00
Thomas Harte
547dc29a60 Remove done TODOs. 2024-04-07 15:53:42 -04:00
Thomas Harte
69aeca5c0e Aggregate mouse deltas where possible. 2024-04-06 21:24:21 -04:00
Thomas Harte
ed7cd4b277 Fix 8bpp output, all-modes cursor. 2024-04-06 20:58:44 -04:00
Thomas Harte
7bf831e1a6 Add missing 'override'. 2024-04-06 13:51:33 -04:00
Thomas Harte
0092cb8c36 Route enough to be able to mess around. 2024-04-06 13:44:05 -04:00
Thomas Harte
543b1c644a Wire mouse events to the relevant class. 2024-04-06 13:32:59 -04:00
Thomas Harte
cfaea7a90c Add cursor within 4bpp pixel area. 2024-04-05 22:43:10 -04:00
Thomas Harte
b821645644 Capture cursor palette, switch horizontal field. 2024-04-05 22:01:01 -04:00
Thomas Harte
2865190499 Resolve video addressing issues. 2024-04-05 21:56:31 -04:00
Thomas Harte
3f40e409c5 Reduce debugging heft. 2024-04-04 22:16:11 -04:00
Thomas Harte
002e235d90 Force RGB mode. 2024-04-04 22:02:47 -04:00
Thomas Harte
7d8a364658 Reimplement LDM and STM. 2024-04-04 21:59:18 -04:00
Thomas Harte
41c471ca52 Add a force-user-aware accessor. 2024-04-04 20:17:44 -04:00
Thomas Harte
dd127f64fe Simplify range. 2024-04-03 07:23:14 -04:00
Thomas Harte
b19dcfd6dc Take another run at shifts. 2024-04-02 21:57:46 -04:00
Thomas Harte
55369464ad Add a by-eye crop. A better answer will come. 2024-04-01 22:10:05 -04:00
Thomas Harte
609c117267 Switch to English RISC OS. 2024-04-01 21:44:42 -04:00
Thomas Harte
3b62a2fe7a Restrict video buffer to first 512kb. 2024-04-01 21:39:10 -04:00
Thomas Harte
7c9715f00c Change mind about carry behaviour. 2024-04-01 21:38:44 -04:00
Thomas Harte
7de92a9457 Slightly clean up shift code. 2024-04-01 21:24:49 -04:00
Thomas Harte
0866caf934 Flaws remain, but acknowledge that pixel rate is double. 2024-04-01 10:48:20 -04:00
Thomas Harte
914b88d115 Fix non-debug build. 2024-03-31 19:17:55 -04:00
Thomas Harte
cc122a7a68 Add an SWI count, to aid in logging. 2024-03-31 18:18:26 -04:00
Thomas Harte
31979649c6 As it continues to swell, factor out the junk. 2024-03-31 18:15:48 -04:00
Thomas Harte
335d13d06d Mildly improve logging, define a few more ROMs. 2024-03-30 21:49:21 -04:00
Thomas Harte
ec785f3a8a Add URL as comment. 2024-03-30 20:54:17 -04:00
Thomas Harte
1f83a5425e Complete list of all currently-failing SWIs.
... a lot of which are probably failing correctly, i.e. they're appropriately signalling.
2024-03-30 20:48:47 -04:00
Thomas Harte
4882d6d0f2 Start adding SWI detail. 2024-03-30 15:16:48 -04:00
Thomas Harte
722743659b Add missing space. 2024-03-29 21:52:57 -04:00
Thomas Harte
6e64a79b52 Log failed SWIs. 2024-03-29 21:31:33 -04:00
Thomas Harte
8a6bf84cff Keyboard: log more, ignore unrecognised commands. 2024-03-29 20:54:07 -04:00
Thomas Harte
a0fdd8f4eb Resolve magic constant. 2024-03-28 22:15:27 -04:00
Thomas Harte
bda1783624 Make new guess at non-byte IOC reads. 2024-03-28 22:10:49 -04:00
Thomas Harte
2a14557478 Be more disciplined about errant accesses. 2024-03-28 21:31:07 -04:00
Thomas Harte
0ddbc67b1f Switch to default CMOS RAM obtained from RISC OS itself. 2024-03-28 21:23:49 -04:00
Thomas Harte
ffb5149890 Reinstate real CMOS RAM results. 2024-03-28 14:27:07 -04:00
Thomas Harte
bb339d619f Eliminate trace test; I don't think I'm going to work it through. 2024-03-28 14:23:00 -04:00
Thomas Harte
2ed11877e8 Determine a couple of further exclusions. 2024-03-28 14:11:41 -04:00
Thomas Harte
ea6b83815b Add a further category of exclusions. 2024-03-28 14:01:37 -04:00
Thomas Harte
740b0e35d5 Completely bypass ignored tests. 2024-03-28 11:28:37 -04:00
Thomas Harte
2e7c1acb88 Add note on confusion. 2024-03-28 10:34:46 -04:00
Thomas Harte
4fcb85d132 Cleave off most remaining reasons for failure. 2024-03-28 10:32:27 -04:00
Thomas Harte
f175dcea58 Hack in some more potential debugging help. 2024-03-27 22:37:37 -04:00
Thomas Harte
c04c708a9d Trade some depth for breadth. 2024-03-27 22:37:10 -04:00
Thomas Harte
f4cf1e5313 Attempt to cleave by broad reason. 2024-03-27 22:36:37 -04:00
Thomas Harte
0e17f382a1 Capture further detail. 2024-03-27 22:36:03 -04:00
Thomas Harte
f38bca37a2 Take another run at MEMC.
I hadn't spotted that it is valid to map different logical pages to the same physical page with different protection levels.
2024-03-27 10:44:40 -04:00
Thomas Harte
166793ebe6 Reduce I2C chatter. 2024-03-26 21:54:42 -04:00
Thomas Harte
8b04d0e3ef Enhance and better-document I2C states. 2024-03-26 21:52:29 -04:00
Thomas Harte
a3931674dc Seemingly navigate I2C correctly. 2024-03-26 21:33:46 -04:00
Thomas Harte
bd4ef5ec57 Switch to acknowledgement-after. 2024-03-26 14:06:11 -04:00
Thomas Harte
3ba12630ab Quieten. 2024-03-26 12:27:37 -04:00
Thomas Harte
342d90c929 Advance CMOS/I2C to a seemingly-valid read. 2024-03-26 12:24:24 -04:00
Thomas Harte
9078fc994b Try to formalise I2C events. 2024-03-25 22:10:52 -04:00
Thomas Harte
f46af4b702 OS 3.11 seems to be able to get into BASIC. 2024-03-25 22:10:35 -04:00
Thomas Harte
b112987556 Do well enough at other colour depths. 2024-03-25 22:09:55 -04:00
Thomas Harte
fc880ac130 Double down on trans mode. 2024-03-25 21:32:56 -04:00
Thomas Harte
a2d95cb982 Shuffle notes. 2024-03-25 21:31:59 -04:00
Thomas Harte
d2776071e4 Speed up debug mode. 2024-03-25 21:31:33 -04:00
Thomas Harte
72a645ec1e Fix trans; take further crack at MEMC permissions. 2024-03-25 15:50:59 -04:00
Thomas Harte
1154ffd072 Add a 'drive in use' indicator LED. 2024-03-25 15:03:54 -04:00
Thomas Harte
8ba9708942 Hopefully resolve the mystery of the latch writes. 2024-03-25 14:54:30 -04:00
Thomas Harte
521fca6089 Expose full bus to IOC dependents; add notes. 2024-03-25 11:07:44 -04:00
Thomas Harte
ae684edbe1 Formally decode bank/offset/type. 2024-03-25 10:16:36 -04:00
Thomas Harte
fa0a9aa611 Eliminate 'has_moved_rom_'. 2024-03-24 22:36:11 -04:00
Thomas Harte
5da9e0486a Simplify control flow. 2024-03-24 22:30:26 -04:00
Thomas Harte
6980fd760c Add further heavily-manual debugging aids. 2024-03-24 22:18:30 -04:00
Thomas Harte
3549488b7a Add round-trip test for status flags. 2024-03-24 22:18:16 -04:00
Thomas Harte
c1602cc8fe The keyboard and interrupts are currently trusted. 2024-03-23 21:49:52 -04:00
Thomas Harte
189dd176de Reguess state machine, fixing startup display. 2024-03-23 21:38:35 -04:00
Thomas Harte
3cf262d1f7 Improve terminology, add more documentation. 2024-03-23 21:12:01 -04:00
Thomas Harte
ccfc389274 Quieten where now confident. 2024-03-23 21:03:06 -04:00
Thomas Harte
0e07f802ac Use BACK state; accept other ACKs at any time. 2024-03-23 21:02:35 -04:00
Thomas Harte
55f92e2411 Adjust data abort address. 2024-03-23 20:31:47 -04:00
Thomas Harte
c720f3910a Avoid implicit sign cast. 2024-03-23 20:13:25 -04:00
Thomas Harte
4215edd11b Reduce noise. 2024-03-23 20:12:56 -04:00
Thomas Harte
09a61cf1a7 Don't expect an ACK after identifying. 2024-03-23 20:12:38 -04:00
Thomas Harte
5967ad0865 Sketch out whole protocol, albeit faulty. 2024-03-23 17:08:03 -04:00
Thomas Harte
eb34c38332 Add very faulty key input. 2024-03-23 15:58:48 -04:00
Thomas Harte
5ccb18225a Provide key states to the keyboard. 2024-03-23 15:43:04 -04:00
Thomas Harte
58bbce1a15 Avoid display errors upon back-pressure. 2024-03-22 22:01:12 -04:00
Thomas Harte
9ea3e547ee Fix IRQ/FIQ return addresses. 2024-03-22 21:42:34 -04:00
Thomas Harte
fb5fdc9f10 Actually apply video divider. 2024-03-22 10:24:24 -04:00
Thomas Harte
de7b7818f4 Add 4bpp output. 2024-03-22 10:18:25 -04:00
Thomas Harte
c4e6b18294 Manage pixel buffers. 2024-03-22 10:10:13 -04:00
Thomas Harte
ae6cf69449 Move responsibility for clock division; reinstate vsync interrupt. 2024-03-22 10:01:34 -04:00
Thomas Harte
4a2dcff028 Endeavour to map colours properly. 2024-03-21 21:53:50 -04:00
Thomas Harte
aa6acec8fa Don't hoard cycles per line value. 2024-03-21 21:47:27 -04:00
Thomas Harte
4ac4da908c Reduce TODOs, do _something_ with border colour. 2024-03-21 21:40:11 -04:00
Thomas Harte
66e62857c4 Give ostensibly clean timing to the CRT. 2024-03-21 21:29:53 -04:00
Thomas Harte
bbc0d8b050 Count time in phase correctly. 2024-03-21 21:15:25 -04:00
Thomas Harte
0f8bc416d1 Make first, faulty step into displaying a field. 2024-03-21 21:10:55 -04:00
Thomas Harte
2ec235170e Finish the thought on magic constants. 2024-03-21 20:45:17 -04:00
Thomas Harte
2de1a2dd0d Install and properly clock a CRT. 2024-03-21 20:41:24 -04:00
Thomas Harte
1f49c3b113 Give sound and video somewhere to read from. 2024-03-21 20:22:20 -04:00
Thomas Harte
5c645fb3c2 Switch to a fixed output clock; retain addresses. 2024-03-21 11:51:29 -04:00
Thomas Harte
40b5227f0b Deliver all addresses to the video outputter. 2024-03-21 11:24:47 -04:00
Thomas Harte
847dba8f07 Divide input pixel rate. 2024-03-21 11:03:28 -04:00
Thomas Harte
417c6c4629 Announce changes. 2024-03-21 10:51:52 -04:00
Thomas Harte
2d6a4d490e Add dummy retrace interrupt. 2024-03-21 10:02:56 -04:00
Thomas Harte
a6ec870872 Capture more audio detail. 2024-03-21 09:47:53 -04:00
Thomas Harte
389541be6d Pipe further sound parameters; obey divider. 2024-03-20 14:43:47 -04:00
Thomas Harte
208f3e24de Audio ticks are now included. 2024-03-20 14:30:21 -04:00
Thomas Harte
f7e36a1e03 Merge branch 'Archimedes' of github.com:TomHarte/CLK into Archimedes 2024-03-20 14:27:32 -04:00
Thomas Harte
1341816791 Break apart, switching to delegates for interrupts. 2024-03-20 14:26:56 -04:00
Thomas Harte
b986add74a Break apart, switching to delegates for interrupts. 2024-03-20 14:25:20 -04:00
Thomas Harte
08673ff021 Switch to macro blocks of execution; flail around audio. 2024-03-20 11:42:37 -04:00
Thomas Harte
3a2d9c6082 Give user access to ROM; clean up a touch. 2024-03-19 20:26:17 -04:00
Thomas Harte
43a3959b8f Don't data abort on missing low ROM. 2024-03-19 15:06:01 -04:00
Thomas Harte
85a738acff Get rigorous on exception addresses. 2024-03-19 15:03:31 -04:00
Thomas Harte
17dbdce230 Eliminate SDL/scons targets for which brew is broken. 2024-03-19 14:27:46 -04:00
Thomas Harte
9d084782ae Document. 2024-03-19 12:22:19 -04:00
Thomas Harte
106937b679 Run into the shifts wall with LDR/STR. 2024-03-19 12:19:49 -04:00
Thomas Harte
623eda7162 Output branches and nops correctly. 2024-03-19 11:42:41 -04:00
Thomas Harte
2ad6bb099b Begin foray into disassembly. 2024-03-19 11:34:10 -04:00
Thomas Harte
9d858bc61b IRQ and FIQ should also store PC+4. 2024-03-18 14:08:08 -04:00
Thomas Harte
612c9ce49a Transfer logging responsibility. 2024-03-18 11:09:29 -04:00
Thomas Harte
64e025484a Adjust means of waiting out address. 2024-03-17 22:14:07 -04:00
Thomas Harte
7b1f800387 Extend I2C state machine. 2024-03-17 21:55:19 -04:00
Thomas Harte
2712d50e05 Attempt some inspection. 2024-03-16 22:02:16 -04:00
Thomas Harte
47e9279bd4 Add a target for I2C activity. 2024-03-16 15:00:23 -04:00
Thomas Harte
635efd0212 Clear keyboard interrupts. 2024-03-15 23:19:26 -04:00
Thomas Harte
1c1d2891c7 Adjust IRQ/FIQ return addresses. 2024-03-15 21:59:38 -04:00
Thomas Harte
1979d2e5ba Don't set interrupt flags before capture. 2024-03-15 21:34:39 -04:00
Thomas Harte
c25d0e8843 Correctly capture mode upon exception. 2024-03-15 18:39:56 -04:00
Thomas Harte
3a899ea4be Add test coverage for STM descending, proving nothing. 2024-03-15 14:55:17 -04:00
Thomas Harte
9d08282e28 Add enough of a keyboard to respond to reset. 2024-03-15 10:57:18 -04:00
Thomas Harte
18154278d1 Add minor note on where next. 2024-03-14 21:54:20 -04:00
Thomas Harte
9063852857 Undo spurious text change. 2024-03-14 21:16:38 -04:00
Thomas Harte
bc27e3998d Fix downward block data transfers. 2024-03-14 21:09:51 -04:00
Thomas Harte
19fa0b8945 Shush logging, momentarily. 2024-03-14 10:53:38 -04:00
Thomas Harte
4987bdfec9 Throw less. 2024-03-14 10:43:51 -04:00
Thomas Harte
0e4615564d Make bit masks easily testable; expand logging. 2024-03-13 14:31:26 -04:00
Thomas Harte
7aeea535a1 Reduce branchiness. 2024-03-13 11:02:52 -04:00
Thomas Harte
6b18d775ab Eliminate unused variables. 2024-03-12 21:53:26 -04:00
Thomas Harte
2ed031e440 Prepare for additional devices. 2024-03-12 21:23:22 -04:00
Thomas Harte
5d6bb11eb7 Add return. 2024-03-12 11:37:15 -04:00
Thomas Harte
c6b91559e1 Attempt to wire up timer interrupts. 2024-03-12 11:34:31 -04:00
Thomas Harte
6efc41ded7 Come to conclusion on R15; fix link values. 2024-03-12 10:42:09 -04:00
Thomas Harte
e9c5582fe1 Add note on ambiguity to be resolved. 2024-03-12 10:04:02 -04:00
Thomas Harte
8b3c0abe93 Take another swing at R15 as a destination. 2024-03-12 09:13:05 -04:00
Thomas Harte
a5ebac1b29 Add RISC OS 3.11 to catalogue, while bug hunting. 2024-03-11 22:19:14 -04:00
Thomas Harte
1ccfae885c Remove extra slashes. 2024-03-11 15:06:17 -04:00
Thomas Harte
971bfb2ecb Unify subtractions. 2024-03-11 14:52:48 -04:00
Thomas Harte
e7457461ba Reduce magic constants. 2024-03-11 14:49:03 -04:00
Thomas Harte
e8c1e8fd3f Fix RSB carry; unify set_pc. 2024-03-11 14:48:43 -04:00
Thomas Harte
ca779bc841 Expand test set. 2024-03-11 14:48:18 -04:00
Thomas Harte
a28c97c0de Simplify privilege test. 2024-03-11 12:14:00 -04:00
Thomas Harte
db49146efe Figure out what's going on with TEQ. 2024-03-11 09:51:09 -04:00
Thomas Harte
830d70d3aa Trust tests on immediate-opcode ROR 0; limit shift by register. 2024-03-10 23:38:31 -04:00
Thomas Harte
336292bc49 Further correct R15 as a destination. 2024-03-10 22:56:02 -04:00
Thomas Harte
bd62228cc6 The test set doesn't seem to do word rotation. 2024-03-10 22:40:37 -04:00
Thomas Harte
ccdd340c9a Reads also may or may not be aligned. *sigh* 2024-03-10 22:34:56 -04:00
Thomas Harte
0b42f5fb30 Make further test-set allowances. 2024-03-10 22:29:40 -04:00
Thomas Harte
e9e1db7a05 Change LDR writeback to destination. 2024-03-10 22:29:19 -04:00
Thomas Harte
21278d028c Correct unaligned accesses. 2024-03-10 21:56:19 -04:00
Thomas Harte
fbc273f114 Add invented model for tests. 2024-03-10 21:45:56 -04:00
Thomas Harte
06a5df029d Summarise failures. 2024-03-10 16:56:39 -04:00
Thomas Harte
e17700b495 Permit digression for 03110002, temporarily. 2024-03-10 14:47:02 -04:00
Thomas Harte
655b1e516c Test PSR and PC. 2024-03-10 14:14:18 -04:00
Thomas Harte
4e7a63f792 Do a de minimis checking of memory accesses. 2024-03-09 15:18:35 -05:00
Thomas Harte
a2896b9bd0 Test register values. 2024-03-09 15:11:12 -05:00
Thomas Harte
a4cf86268e Provide full access to stored registers. 2024-03-09 15:11:04 -05:00
Thomas Harte
d059e7c5d8 Disallow copying. 2024-03-09 15:10:55 -05:00
Thomas Harte
d6f882a8bb Integrate PC and PSR, guarantee invisible register values. 2024-03-09 14:59:44 -05:00
Thomas Harte
08f50f3eff Box in flags. 2024-03-08 23:01:29 -05:00
Thomas Harte
47f7340dfc Start hacking in some ARM tests. 2024-03-08 22:54:42 -05:00
Thomas Harte
fdef8901ab Double down on uint32_t. 2024-03-08 14:13:34 -05:00
Thomas Harte
ca1c3dc005 Add extra comments.
To persuade myself in the future.
2024-03-08 11:36:17 -05:00
Thomas Harte
9406a97141 Add some register switch tests. 2024-03-08 11:34:10 -05:00
Thomas Harte
a46ec4cffb Up clock rate to 24Mhz. 2024-03-07 22:16:58 -05:00
Thomas Harte
9bb5dc3c2b Fix inclusive range. 2024-03-07 19:40:34 -05:00
Thomas Harte
f6ea442606 Include various debugging detritus. 2024-03-07 14:28:39 -05:00
Thomas Harte
fa8fcd2218 Take another swing at popcount. 2024-03-07 14:28:31 -05:00
Thomas Harte
2a36d0fcbc Adjust user-mode test. 2024-03-07 14:00:38 -05:00
Thomas Harte
0e92885ed5 Fix ad hoc popcount; ARM does carry 'backwards'. 2024-03-07 13:27:41 -05:00
Thomas Harte
f5225b69e5 Add note to self. 2024-03-07 11:48:44 -05:00
Thomas Harte
15ee84b2eb Fix MUL ambiguity. 2024-03-07 11:45:39 -05:00
Thomas Harte
d380cecdb7 Add timers that count. 2024-03-07 11:39:26 -05:00
Thomas Harte
ae3cd924e8 Add a 2Mhz tick for timers. 2024-03-07 11:12:40 -05:00
Thomas Harte
a0f0f73bde Fix MOV as unconditional branch. 2024-03-07 10:31:26 -05:00
Thomas Harte
7cdceb7b4f Add a specific shout-out on prefetch abort, for debugging. 2024-03-07 10:23:46 -05:00
Thomas Harte
38b5624639 Add a little more VIDC detail. 2024-03-07 10:05:22 -05:00
Thomas Harte
3405b3b287 Add power-on bit, moving problems forward. 2024-03-06 22:14:56 -05:00
Thomas Harte
173fc9329a Add a little protection logic. 2024-03-06 22:00:34 -05:00
Thomas Harte
691a42d81e Attempt some logical mapping. 2024-03-06 21:51:19 -05:00
Thomas Harte
4059905f85 Slightly reorder messaging. 2024-03-06 16:45:17 -05:00
Thomas Harte
bbb520fd12 Transcribe some notes. 2024-03-06 15:31:07 -05:00
Thomas Harte
108a056f1c Execution now runs into a prefetch abort loop. 2024-03-06 15:05:24 -05:00
Thomas Harte
ed92e98ca2 Start looking at address translation. 2024-03-06 14:56:06 -05:00
Thomas Harte
0d666f9935 Get a bit more rigorous about reporting. 2024-03-06 09:54:39 -05:00
Thomas Harte
fe467be124 Further stick to existing type. 2024-03-05 10:56:09 -05:00
Thomas Harte
ba5f142515 Take further stab at TEQ PC, etc. 2024-03-05 10:55:44 -05:00
Thomas Harte
ed586e80bc Don't write to the PC with logical operations. 2024-03-05 09:32:35 -05:00
Thomas Harte
871c5467d7 Avoid sign change. 2024-03-05 09:31:42 -05:00
Thomas Harte
387791635e Start to establish a memory map. 2024-03-04 21:43:06 -05:00
Thomas Harte
b7a1363add Add an incorrect execution loop. 2024-03-04 21:09:24 -05:00
Thomas Harte
341b705bef Remove pointless check. 2024-03-04 14:11:44 -05:00
Thomas Harte
0b65aa39cd Add explicit assignment operator. 2024-03-04 14:09:53 -05:00
Thomas Harte
1b7c3644f4 Eliinate meaningless 'const'. 2024-03-04 14:09:27 -05:00
Thomas Harte
0cdca12e06 Resolve type mismatches. 2024-03-04 13:53:46 -05:00
Thomas Harte
61d4c69e45 Fix template parameter reference. 2024-03-04 13:25:40 -05:00
Thomas Harte
79865e295b Avoid ambiguous template parameter; use standard type. 2024-03-04 12:20:40 -05:00
Thomas Harte
1f43047de8 Loop the ARM executor into the build. 2024-03-04 12:08:46 -05:00
Thomas Harte
6f0ad0ab71 Add an empty Archimedes shell. 2024-03-04 12:06:43 -05:00
Thomas Harte
447734b1e9 Merge pull request #1354 from TomHarte/Acorn
Reorganise 'Electron' under 'Acorn'.
2024-03-04 11:55:56 -05:00
Thomas Harte
3e80651a0e Collect 'Electron' under 'Acorn'. 2024-03-04 11:31:25 -05:00
Thomas Harte
692a9da2e4 Merge pull request #1353 from TomHarte/ArchmidesAnalysis
Add a through path for Archimedes disk images.
2024-03-04 10:57:19 -05:00
Thomas Harte
e27312c980 Add to machine lists. 2024-03-04 10:19:06 -05:00
Thomas Harte
eae92a0cdb Add a through path for Archimedes disk images. 2024-03-04 10:13:57 -05:00
Thomas Harte
95cc34ba23 Merge pull request #1352 from TomHarte/ByeByeActive
Obscure storage for active registers.
2024-03-03 22:09:34 -05:00
Thomas Harte
7532b461cd Merge pull request #1351 from TomHarte/PositiveExpression
Express offset test as positive logic.
2024-03-03 22:03:37 -05:00
Thomas Harte
230e9c6327 Obscure active. 2024-03-03 21:43:30 -05:00
Thomas Harte
11c4d2f09e Add further exposition. 2024-03-03 21:38:27 -05:00
Thomas Harte
f2db1b4aae Merge branch 'TiedDown' into PositiveExpression 2024-03-03 21:31:26 -05:00
Thomas Harte
b42a6e447d Tie down more corners. 2024-03-03 21:29:53 -05:00
Thomas Harte
8a83d71560 Fix condition. 2024-03-03 14:40:05 -05:00
Thomas Harte
9fd7d5c10f Switch test and meaning. 2024-03-03 14:34:21 -05:00
Thomas Harte
7a5ed6c427 Merge pull request #1350 from TomHarte/ArchimedesROM
Add RISC OS catalogue entry; do some basic ARM debugging.
2024-03-03 14:32:25 -05:00
Thomas Harte
4e7963ee81 Clarify PC semantics; remove faulty underscore. 2024-03-03 14:11:02 -05:00
Thomas Harte
945b7e90da Add just enough to persuade self that execution is broadly sane. 2024-03-03 14:03:08 -05:00
Thomas Harte
99f0233b76 Fix immediate offset and data processing operation. 2024-03-02 23:27:37 -05:00
Thomas Harte
62da0dee7f Unify reads. 2024-03-02 23:15:17 -05:00
Thomas Harte
1663d3d9d1 Introduce disaster of an attempted test run. 2024-03-02 22:40:12 -05:00
Thomas Harte
37499d493a Fix model name. 2024-03-02 21:47:09 -05:00
Thomas Harte
c0dd96eb7c Add a catalogue entry for RISC OS. 2024-03-02 21:44:27 -05:00
Thomas Harte
2abae4c8bf Merge pull request #1349 from TomHarte/BarrelShifterTests
Introduce barrel-shifter tests.
2024-03-02 15:24:06 -05:00
Thomas Harte
c865da67e0 Introduce further barrel-shifter tests. 2024-03-02 15:12:03 -05:00
Thomas Harte
e6f77a9b80 Add logical right-shift tests. 2024-03-01 18:06:54 -05:00
Thomas Harte
7b28b3d634 Merge pull request #1343 from TomHarte/ARM2Ops
Attempt an implementation of the ARM2 instruction set.
2024-03-01 15:20:28 -05:00
Thomas Harte
42ba6d1281 Relocate execution code appropriately. 2024-03-01 15:02:47 -05:00
Thomas Harte
85b7afd530 Attempt a complete block data transfer. 2024-03-01 14:48:36 -05:00
Thomas Harte
f2f59a4de5 Attempt to deal with data aborts. 2024-03-01 10:38:08 -05:00
Thomas Harte
5759798ad7 Deal with downward write order. 2024-02-29 14:34:20 -05:00
Thomas Harte
ab1dd7f57e Implement a little of block data transfer. 2024-02-29 11:33:40 -05:00
Thomas Harte
53a2ea3a57 Add address exception. 2024-02-29 10:49:11 -05:00
Thomas Harte
1f1e7236be Add rotation. 2024-02-29 10:47:41 -05:00
Thomas Harte
fd2c5b6679 Make a quick first attempt at memory accesses. 2024-02-29 10:18:09 -05:00
Thomas Harte
0b287c55d5 Edge towards single data transfer. 2024-02-29 10:02:57 -05:00
Thomas Harte
0de8240238 Merge branch 'master' into ARM2Ops 2024-02-28 22:21:31 -05:00
Thomas Harte
1449b2a2a6 Merge pull request #1347 from TomHarte/AppleIIFlashRate
Double Apple II flash rate.
2024-02-28 22:21:05 -05:00
Thomas Harte
0f691766ee Double flash rate. 2024-02-28 22:13:22 -05:00
Thomas Harte
3ce05e9de1 Merge pull request #1346 from TomHarte/AppleIIReset
Propagate reset to the auxiliary switches.
2024-02-28 22:02:08 -05:00
Thomas Harte
98f5d0cdb7 Propagate reset to the auxiliary switches. 2024-02-28 21:36:55 -05:00
Thomas Harte
93b4008f81 Localise flags, detect improper carry write. 2024-02-28 21:28:19 -05:00
Thomas Harte
904462b881 Regularise data transfers. 2024-02-28 21:23:57 -05:00
Thomas Harte
3b320bcdef Update coprocessor interface. 2024-02-28 14:43:31 -05:00
Thomas Harte
3368bdb99f Document exceptions, partly for my future self. 2024-02-28 14:34:31 -05:00
Thomas Harte
4d400c3cb7 Add easy exceptions. 2024-02-28 14:25:12 -05:00
Thomas Harte
474f9da3c2 Add banked registers. 2024-02-28 14:09:05 -05:00
Thomas Harte
c49b26701f Relocate and clarify barrel shifts.
With a view to independent testing.
2024-02-28 13:53:13 -05:00
Thomas Harte
9b42d35d56 Update interface. 2024-02-28 11:42:33 -05:00
Thomas Harte
645152a1fd Implement branch. 2024-02-28 11:33:28 -05:00
Thomas Harte
487ade56ed Add basic multiply. 2024-02-28 11:27:27 -05:00
Thomas Harte
60d1b36e9a Implement registers side. 2024-02-28 10:25:14 -05:00
Thomas Harte
5a48c15e46 Add scheduler side of PC writeback. 2024-02-28 10:15:23 -05:00
Thomas Harte
d6bf1808f9 Take a swing at PC-as-input. 2024-02-28 09:33:05 -05:00
Thomas Harte
b676153d21 State intention to merge status with other registers. 2024-02-27 15:36:34 -05:00
Thomas Harte
a3339cf882 Fix indentation. 2024-02-27 15:30:51 -05:00
Thomas Harte
b4e0b46bac Add notes on R15. 2024-02-27 10:04:30 -05:00
Thomas Harte
09c1b2d7db Add missing shifts. 2024-02-27 09:55:24 -05:00
Thomas Harte
4255283e33 Deal with conditionality up front. 2024-02-26 21:36:23 -05:00
Thomas Harte
16e827bb2c Add basic arithmetics. 2024-02-26 21:27:58 -05:00
Thomas Harte
def69ce6d5 Add notes on R15. 2024-02-26 15:12:39 -05:00
Thomas Harte
054a799699 Fill in the easy 50% of operations. 2024-02-26 15:10:00 -05:00
Thomas Harte
580f402bb6 Muddle further towards data processing. 2024-02-26 14:50:45 -05:00
Thomas Harte
030dda34f0 Start poking at implementation. 2024-02-26 14:30:26 -05:00
Thomas Harte
cd21b39f44 Merge pull request #1342 from TomHarte/ARM2Status
Add some degree of ARM 2 status flags.
2024-02-26 10:48:24 -05:00
Thomas Harte
481b6d0e69 Sketch out some status flags. 2024-02-25 22:01:51 -05:00
Thomas Harte
a88d41bf00 List the flags. 2024-02-25 15:21:54 -05:00
Thomas Harte
0ee3b628e8 Merge pull request #1341 from TomHarte/AYEnvelopePeriod
Correct envelope period for internal double-resolution.
2024-02-24 15:38:17 -05:00
Thomas Harte
45628ba9df Merge pull request #1337 from TomHarte/ArchimedesADFs
Add some support for Archimedes ADF files.
2024-02-24 15:32:08 -05:00
Thomas Harte
c843c395ea Correct envelope period for internal double-resolution. 2024-02-24 15:16:33 -05:00
Thomas Harte
9bdaf31d04 Add missing #include. 2024-02-24 15:09:40 -05:00
Thomas Harte
4ac2baeb9d Merge pull request #1340 from ryandesign/patch-1
Mention Macintosh 128K and 512K in README.
2024-02-24 15:08:16 -05:00
Thomas Harte
c56e82207a Extend .ADF support as far as my knowledge currently goes. 2024-02-24 15:07:45 -05:00
Thomas Harte
82abebec6e Add missing #include. 2024-02-23 16:13:26 -05:00
Ryan Carsten Schmidt
60286c3a15 Mention Macintosh 128K and 512K in README. 2024-02-23 06:32:15 -06:00
Thomas Harte
8460fe2118 Flounder around file contents. 2024-02-22 22:19:19 -05:00
Thomas Harte
4b5456c9ba Add Hugo/Nick checks. 2024-02-22 22:19:10 -05:00
Thomas Harte
ddf136556d Add an Archimedes enum, start looking at analysis. 2024-02-22 13:51:44 -05:00
Thomas Harte
4c45f4468e Merge pull request #1335 from TomHarte/ARMDecoding
Add ARM2 operation mapper.
2024-02-22 11:44:03 -05:00
Thomas Harte
73d2acca12 Moderately improve comments. 2024-02-22 11:20:22 -05:00
Thomas Harte
56a5df3783 Do the least possible manual test. 2024-02-22 10:48:19 -05:00
Thomas Harte
d205e538e1 Accept the C++ I'm in; clarify and simplify interface. 2024-02-22 10:16:54 -05:00
Thomas Harte
f9cbec668b Add empty shell for tests. 2024-02-21 15:43:24 -05:00
Thomas Harte
6577f68efc Complete instruction set; consolidate mapper. 2024-02-21 15:32:27 -05:00
Thomas Harte
e986ae2878 Add coprocessor data operations and register transfers. 2024-02-21 15:25:57 -05:00
Thomas Harte
b2696450d5 Bring forwards single data transfers. 2024-02-21 14:51:51 -05:00
Thomas Harte
2bbaf73aa2 Delete was is now duplicated. 2024-02-21 14:18:41 -05:00
Thomas Harte
0fe2c1406b Start mutating towards a form that owns the switch. 2024-02-21 14:17:01 -05:00
Thomas Harte
954d920b9e Extend what's held in the operation enum. 2024-02-20 14:14:18 -05:00
Thomas Harte
57b45076c5 Start dealing with per-instruction fields. 2024-02-17 22:13:51 -05:00
Thomas Harte
d639dc8bcb Hit up some more = default opportunities. 2024-02-17 15:42:31 -05:00
Thomas Harte
9a74ab6a8e Switch to actual mnenomics, temporarily(?) shrink table. 2024-02-17 15:41:57 -05:00
Thomas Harte
4c53414cc3 Merge branch 'master' into ARMDecoding 2024-02-17 08:14:18 -05:00
Thomas Harte
c36288dd6b Merge pull request #1334 from TomHarte/EqualsDefault
Switch to `= default`.
2024-02-17 08:13:53 -05:00
Thomas Harte
bc5727af14 Switch to = default. 2024-02-16 21:50:15 -05:00
Thomas Harte
bd0a15c054 Start working on ARM2 decoding. 2024-02-16 21:36:07 -05:00
Thomas Harte
a758112084 Merge pull request #1333 from TomHarte/DeferredSwitches
Apple II: Apply deferred video actions before getting vapour value.
2024-02-16 10:08:23 -05:00
Thomas Harte
3981f3a874 Merge branch 'master' into DeferredSwitches 2024-02-16 09:19:54 -05:00
Thomas Harte
e8036127fe Add some commentary. 2024-02-16 09:19:22 -05:00
Thomas Harte
17abd87791 Remove further !!s. 2024-02-16 08:57:43 -05:00
Thomas Harte
35545451fe Apply applicable deferred actions before lookahead. 2024-02-16 08:56:01 -05:00
Thomas Harte
64bec0cc3d Merge pull request #1332 from TomHarte/NoPrintf
Trim some printfs.
2024-02-15 21:18:43 -05:00
Thomas Harte
fadd3bc6fc Eliminate 'unused' error. 2024-02-15 13:57:11 -05:00
Thomas Harte
d9ec11c62e Use logger instead of printf. 2024-02-15 13:55:46 -05:00
Thomas Harte
093a029b8c Further reduce printf footprint. 2024-02-15 13:41:35 -05:00
Thomas Harte
b4a3b23571 Eliminate use of printf. 2024-02-15 13:32:49 -05:00
Thomas Harte
be99183f1d Remove outdated TODO. 2024-02-15 13:26:03 -05:00
Thomas Harte
dda5f41487 Merge pull request #1331 from TomHarte/IODeviceSel 2024-02-15 11:16:15 -05:00
Thomas Harte
a09457dab5 Fix IOSEL and DEVSEL assignments. 2024-02-15 10:29:30 -05:00
Thomas Harte
ac171d166e Merge pull request #1321 from TomHarte/Mockingboard
Add Mockingboard support to the Apple II.
2024-02-15 10:24:39 -05:00
Thomas Harte
51de1892c0 With minor infrastructure fixes, switch Mockingboard to stereo. 2024-02-15 09:42:33 -05:00
Thomas Harte
e1fdda928a Add Mockingboard to Qt UI. 2024-02-15 09:13:17 -05:00
Thomas Harte
1c8261dc09 Add Mockingboard to macOS UI. 2024-02-15 09:10:19 -05:00
Thomas Harte
cb22278c7f Switch meaning of bit 2. 2024-02-15 08:54:52 -05:00
Thomas Harte
809bc9d6a8 Add TODO. 2024-02-14 22:46:57 -05:00
Thomas Harte
be11f31d5d Support reset. 2024-02-14 22:22:42 -05:00
Thomas Harte
0103761b7b Corrects AY audio tone. 2024-02-14 22:16:37 -05:00
Thomas Harte
3ac5fdafab Enables AY audio, albeit underclocked. 2024-02-14 22:15:21 -05:00
Thomas Harte
1e877c7563 Add a clock to the 6522s, enable interrupts. 2024-02-14 22:01:03 -05:00
Thomas Harte
07c11e8268 Begin 6522 wiring. 2024-02-14 15:18:19 -05:00
Thomas Harte
0dcceff410 There's actually two AYs. 2024-02-14 14:31:38 -05:00
Thomas Harte
2a684ab302 Include a single AY in the mix if appropriate. 2024-02-14 10:55:53 -05:00
Thomas Harte
27059233b3 Use sample source to simplify stretching AY. 2024-02-13 22:38:18 -05:00
Thomas Harte
7f84d5ac6f Merge branch 'master' into Mockingboard 2024-02-13 14:46:59 -05:00
Thomas Harte
d43f050922 Merge pull request #1330 from TomHarte/SampleProducingAY
Convert AY to a SampleSource.
2024-02-13 14:45:31 -05:00
Thomas Harte
3ba2618547 Fix formatting, add comment. 2024-02-13 13:48:31 -05:00
Thomas Harte
a3e104f8e2 Clean up commentary. 2024-02-13 13:46:27 -05:00
Thomas Harte
1bb82189e9 Add better exposition. 2024-02-13 10:57:22 -05:00
Thomas Harte
e06a66644c Eliminate a macro. 2024-02-13 10:54:53 -05:00
Thomas Harte
6dcc13921f Make first sweep at converting AY to a SampleSource. 2024-02-13 10:51:33 -05:00
Thomas Harte
fd45745600 Merge pull request #1328 from TomHarte/PerSampleAudio
Improve SampleSource infrastructure.
2024-02-12 16:38:01 -05:00
Thomas Harte
507c3da927 Sometimes avoid unnecessary zero-fills. 2024-02-12 14:33:55 -05:00
Thomas Harte
f14e45f93e Remove various instances of ';;'. 2024-02-12 14:23:54 -05:00
Thomas Harte
3d2d9ac45e Remove default set_sample_volume_range implementation too. 2024-02-12 14:00:08 -05:00
Thomas Harte
1895b4ee5d Remove empty implementation, the better for debugging. 2024-02-12 13:59:03 -05:00
Thomas Harte
d49c07687c Unify [get_/skip_]samples, adding a third option for in-place mixing. 2024-02-12 10:55:52 -05:00
Thomas Harte
3a208460e2 Reintroduce mono to stereo conversion. 2024-02-10 21:53:12 -05:00
Thomas Harte
472297e411 Merge pull request #1324 from ryandesign/cmake
Add CMake build system
2024-02-09 14:36:00 -05:00
Thomas Harte
25085cb5af Require good ordering. 2024-02-09 14:34:59 -05:00
Thomas Harte
9909146c59 Fix typo. 2024-02-09 14:26:02 -05:00
Thomas Harte
609d81d75d Distinguish sources of samples and of whole buffers. 2024-02-09 14:25:40 -05:00
Thomas Harte
c105acf1c7 Adopt a full type for stereo samples, gaining + and +=. 2024-02-09 10:48:42 -05:00
Thomas Harte
f3d0827d14 Introduce [Mono/Stereo]Sample types. 2024-02-09 09:15:48 -05:00
Thomas Harte
a4a983eb81 Promote stereo status to template parameter. 2024-02-08 15:21:47 -05:00
Thomas Harte
48be7c677e Avoid inheritance. 2024-02-08 12:07:12 -05:00
Thomas Harte
147d817977 Use fold expression for final-answer is_stereo. 2024-02-08 11:10:08 -05:00
Thomas Harte
d481f335b8 Switch to another std::fill. 2024-02-08 10:47:05 -05:00
Thomas Harte
228012cd0c Make a further deployment of std::fill. 2024-02-01 22:03:13 -05:00
Thomas Harte
f4d8c04f3c Without yet much exposition, draft sample-by-sample interface. 2024-02-01 21:56:33 -05:00
Thomas Harte
c6c9be0b08 Adopt CRTP for SampleSource. 2024-02-01 21:47:44 -05:00
Thomas Harte
3827929a15 Merge branch 'master' into PerSampleAudio 2024-02-01 21:33:25 -05:00
Thomas Harte
ca7e4b3a0e Merge pull request #1327 from ryandesign/macos-ci
Update CI to build on macOS 11, 12, 13, and 14.
2024-02-01 21:33:11 -05:00
Thomas Harte
fd73c24fc3 Use std::fill; update volume with slider. 2024-02-01 21:32:16 -05:00
Thomas Harte
ce0d53b277 Clean up SampleSource's getters. 2024-02-01 21:29:00 -05:00
Ryan Carsten Schmidt
7dc3b5ba06 Update CI to build on macOS 11, 12, 13, and 14. 2024-01-31 06:27:11 -06:00
Thomas Harte
17cad73177 Attempt an implementation of StretchedAudioSource. 2024-01-29 16:45:20 -05:00
Thomas Harte
b28e3eb419 Merge pull request #1326 from ryandesign/MacDown
Compatibility fixes in Markdown files.
2024-01-28 17:35:41 -05:00
Ryan Carsten Schmidt
d811501421 Compatibility fixes in Markdown files.
Improve compatibility with some Markdown readers like MacDown by adding
blank lines before lists. Blank lines around headers were added for
consistency. One header level was fixed. One code block was fixed.
2024-01-27 13:24:35 -06:00
Thomas Harte
c68dd50fde Merge pull request #1323 from ryandesign/BUILD.md
Rename BUILD.txt to BUILD.md and rewrite
2024-01-25 20:38:12 -05:00
Ryan Carsten Schmidt
ad8abf2e05 Add CMake SDL builds to CI workflow. 2024-01-25 10:15:11 -06:00
Ryan Carsten Schmidt
01d9455897 Exclude *AllRAM*.cpp from CMake program sources.
These files serve as documentation and are used in tests.
2024-01-25 10:15:11 -06:00
Ryan Carsten Schmidt
cbf8849004 Add CMake build system, initially for SDL version.
See #1275
2024-01-25 10:15:05 -06:00
Ryan Carsten Schmidt
f3a7d82dc1 Update build instructions with more specifics.
Mention macOS version requirement; see #1179.
2024-01-25 09:10:36 -06:00
Ryan Carsten Schmidt
017674de35 Rename BUILD.txt to BUILD.md. 2024-01-25 08:52:06 -06:00
Thomas Harte
4f211334b5 Merge pull request #1322 from ryandesign/cstring
Add missing include of cstring for memcpy.
2024-01-24 20:53:57 -05:00
Ryan Carsten Schmidt
31e261f7e5 Add missing include of cstring for memcpy. 2024-01-24 09:00:10 -06:00
Thomas Harte
15b5a62e01 Mockingboard: start sketching out intermediate clocking. 2024-01-23 22:05:30 -05:00
Thomas Harte
f5800aa004 Merge pull request #1320 from TomHarte/MoreTemplateElimination
Apply more macro elimination.
2024-01-22 21:46:19 -05:00
Thomas Harte
584aa78695 Avoid macro. 2024-01-22 21:37:04 -05:00
Thomas Harte
030f49db83 Eliminate macro. 2024-01-22 21:33:39 -05:00
Thomas Harte
cc165b65be Switch to lambda. 2024-01-22 21:22:56 -05:00
Thomas Harte
cb125e6336 Use constexpr functions rather than macros. 2024-01-22 21:17:00 -05:00
Thomas Harte
a3337ea90f Remove macro. 2024-01-22 21:15:44 -05:00
Thomas Harte
ae31f85f0c Eliminate macro. 2024-01-22 21:11:15 -05:00
Thomas Harte
5e9f484662 Avoid macro. 2024-01-22 21:09:13 -05:00
Thomas Harte
f2e29357bf Merge pull request #1318 from TomHarte/MorePragmas
Switch trailing files to #pragma once.
2024-01-22 14:00:51 -05:00
Thomas Harte
8a1a14ba4c Switch trailing files to #pragma once. 2024-01-21 21:49:59 -05:00
Thomas Harte
31cbcb206f Commit new version number. 2024-01-21 21:25:27 -05:00
Thomas Harte
bf9e913a7b Merge pull request #1317 from TomHarte/IIgsIncludes
Add missing include of cstdint.
2024-01-21 21:24:43 -05:00
Thomas Harte
d3cea4a10f Note that arguments may be unused. 2024-01-21 21:19:51 -05:00
Thomas Harte
a6df20ff84 Eliminate printf. 2024-01-21 21:19:38 -05:00
Thomas Harte
7122a9ee16 Add missing include of cstdint. 2024-01-21 21:08:04 -05:00
684 changed files with 46421 additions and 27764 deletions

View File

@@ -1,20 +1,56 @@
name: Build name: Build
on: [pull_request] on: [pull_request]
jobs: jobs:
build-mac: # build-mac-xcodebuild:
name: Mac UI on ${{ matrix.os }} # name: Mac UI / xcodebuild / ${{ matrix.os }}
# strategy:
# matrix:
# os: [macos-13, macos-14, macos-15]
# runs-on: ${{ matrix.os }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Make
# working-directory: OSBindings/Mac
# run: xcodebuild CODE_SIGN_IDENTITY=-
build-sdl-cmake:
name: SDL UI / cmake / ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [macos-latest] os: [macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Install dependencies
shell: bash
run: |
case $RUNNER_OS in
Linux)
sudo apt-get --allow-releaseinfo-change update
sudo apt-get --fix-missing install cmake gcc-10 libsdl2-dev
;;
macOS)
brew install cmake sdl2
;;
esac
- name: Make - name: Make
working-directory: OSBindings/Mac shell: bash
run: xcodebuild CODE_SIGN_IDENTITY=- run: |
build-sdl: case $RUNNER_OS in
name: SDL UI on ${{ matrix.os }} Linux)
jobs=$(nproc --all)
;;
macOS)
jobs=$(sysctl -n hw.activecpu)
;;
*)
jobs=1
esac
cmake -S. -Bbuild -DCLK_UI=SDL -DCMAKE_BUILD_TYPE=Release
cmake --build build -v -j"$jobs"
build-sdl-scons:
name: SDL UI / scons / ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [macos-latest, ubuntu-latest] os: [macos-latest, ubuntu-latest]
@@ -49,3 +85,23 @@ jobs:
jobs=1 jobs=1
esac esac
scons -j"$jobs" scons -j"$jobs"
build-qt:
name: Qt / ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
uses: jurplel/install-qt-action@v3
with:
version: '5.15.2'
archives: 'qtbase qtmultimedia qtx11extras icu'
- name: Make
working-directory: OSBindings/Qt
shell: bash
run: |
qmake -o Makefile clksignal.pro
make

View File

@@ -22,38 +22,38 @@ namespace Activity {
and/or to show or unshow status indicators. and/or to show or unshow status indicators.
*/ */
class Observer { class Observer {
public: public:
virtual ~Observer() {} virtual ~Observer() = default;
/// Provides hints as to the sort of information presented on an LED. /// Provides hints as to the sort of information presented on an LED.
enum LEDPresentation: uint8_t { enum LEDPresentation: uint8_t {
/// This LED informs the user of some sort of persistent state, e.g. scroll lock. /// This LED informs the user of some sort of persistent state, e.g. scroll lock.
/// If this flag is absent then the LED describes an ephemeral state, such as media access. /// If this flag is absent then the LED describes an ephemeral state, such as media access.
Persistent = (1 << 0), Persistent = (1 << 0),
}; };
/// Announces to the receiver that there is an LED of name @c name. /// Announces to the receiver that there is an LED of name @c name.
virtual void register_led([[maybe_unused]] const std::string &name, [[maybe_unused]] uint8_t presentation = 0) {} virtual void register_led([[maybe_unused]] const std::string &name, [[maybe_unused]] uint8_t presentation = 0) {}
/// Announces to the receiver that there is a drive of name @c name. /// Announces to the receiver that there is a drive of name @c name.
/// ///
/// If a drive has the same name as an LED, that LED goes with this drive. /// If a drive has the same name as an LED, that LED goes with this drive.
virtual void register_drive([[maybe_unused]] const std::string &name) {} virtual void register_drive([[maybe_unused]] const std::string &name) {}
/// Informs the receiver of the new state of the LED with name @c name. /// Informs the receiver of the new state of the LED with name @c name.
virtual void set_led_status([[maybe_unused]] const std::string &name, [[maybe_unused]] bool lit) {} virtual void set_led_status([[maybe_unused]] const std::string &name, [[maybe_unused]] bool lit) {}
enum class DriveEvent { enum class DriveEvent {
StepNormal, StepNormal,
StepBelowZero, StepBelowZero,
StepBeyondMaximum StepBeyondMaximum
}; };
/// Informs the receiver that the named event just occurred for the drive with name @c name. /// Informs the receiver that the named event just occurred for the drive with name @c name.
virtual void announce_drive_event([[maybe_unused]] const std::string &name, [[maybe_unused]] DriveEvent event) {} virtual void announce_drive_event([[maybe_unused]] const std::string &name, [[maybe_unused]] DriveEvent event) {}
/// Informs the receiver of the motor-on status of the drive with name @c name. /// Informs the receiver of the motor-on status of the drive with name @c name.
virtual void set_drive_motor_status([[maybe_unused]] const std::string &name, [[maybe_unused]] bool is_on) {} virtual void set_drive_motor_status([[maybe_unused]] const std::string &name, [[maybe_unused]] bool is_on) {}
}; };
} }

View File

@@ -13,8 +13,8 @@
namespace Activity { namespace Activity {
class Source { class Source {
public: public:
virtual void set_activity_observer(Observer *observer) = 0; virtual void set_activity_observer(Observer *observer) = 0;
}; };
} }

View File

@@ -18,25 +18,25 @@ namespace Analyser::Dynamic {
The initial value of the confidence counter is 0.5. The initial value of the confidence counter is 0.5.
*/ */
class ConfidenceCounter: public ConfidenceSource { class ConfidenceCounter: public ConfidenceSource {
public: public:
/*! @returns The computed probability, based on the history of events. */ /*! @returns The computed probability, based on the history of events. */
float get_confidence() final; float get_confidence() final;
/*! Records an event that implies this is the appropriate class: pushes probability up towards 1.0. */ /*! Records an event that implies this is the appropriate class: pushes probability up towards 1.0. */
void add_hit(); void add_hit();
/*! Records an event that implies this is not the appropriate class: pushes probability down towards 0.0. */ /*! Records an event that implies this is not the appropriate class: pushes probability down towards 0.0. */
void add_miss(); void add_miss();
/*! /*!
Records an event that could be correct but isn't necessarily so; which can push probability Records an event that could be correct but isn't necessarily so; which can push probability
down towards 0.5, but will never push it upwards. down towards 0.5, but will never push it upwards.
*/ */
void add_equivocal(); void add_equivocal();
private: private:
int hits_ = 1; int hits_ = 1;
int misses_ = 1; int misses_ = 1;
}; };
} }

View File

@@ -13,7 +13,10 @@
using namespace Analyser::Dynamic; using namespace Analyser::Dynamic;
ConfidenceSummary::ConfidenceSummary(const std::vector<ConfidenceSource *> &sources, const std::vector<float> &weights) : ConfidenceSummary::ConfidenceSummary(
const std::vector<ConfidenceSource *> &sources,
const std::vector<float> &weights
) :
sources_(sources), weights_(weights) { sources_(sources), weights_(weights) {
assert(weights.size() == sources.size()); assert(weights.size() == sources.size());
weight_sum_ = std::accumulate(weights.begin(), weights.end(), 0.0f); weight_sum_ = std::accumulate(weights.begin(), weights.end(), 0.0f);

View File

@@ -18,24 +18,24 @@ namespace Analyser::Dynamic {
Summaries a collection of confidence sources by calculating their weighted sum. Summaries a collection of confidence sources by calculating their weighted sum.
*/ */
class ConfidenceSummary: public ConfidenceSource { class ConfidenceSummary: public ConfidenceSource {
public: public:
/*! /*!
Instantiates a summary that will produce the weighted sum of Instantiates a summary that will produce the weighted sum of
@c sources, each using the corresponding entry of @c weights. @c sources, each using the corresponding entry of @c weights.
Requires that @c sources and @c weights are of the same length. Requires that @c sources and @c weights are of the same length.
*/ */
ConfidenceSummary( ConfidenceSummary(
const std::vector<ConfidenceSource *> &sources, const std::vector<ConfidenceSource *> &sources,
const std::vector<float> &weights); const std::vector<float> &weights);
/*! @returns The weighted sum of all sources. */ /*! @returns The weighted sum of all sources. */
float get_confidence() final; float get_confidence() final;
private: private:
const std::vector<ConfidenceSource *> sources_; const std::vector<ConfidenceSource *> sources_;
const std::vector<float> weights_; const std::vector<float> weights_;
float weight_sum_; float weight_sum_;
}; };
} }

View File

@@ -15,90 +15,90 @@ using namespace Analyser::Dynamic;
namespace { namespace {
class MultiStruct: public Reflection::Struct { class MultiStruct: public Reflection::Struct {
public: public:
MultiStruct(const std::vector<Configurable::Device *> &devices) : devices_(devices) { MultiStruct(const std::vector<Configurable::Device *> &devices) : devices_(devices) {
for(auto device: devices) { for(auto device: devices) {
options_.emplace_back(device->get_options()); options_.emplace_back(device->get_options());
}
}
void apply() {
auto options = options_.begin();
for(auto device: devices_) {
device->set_options(*options);
++options;
}
}
std::vector<std::string> all_keys() const final {
std::set<std::string> keys;
for(auto &options: options_) {
const auto new_keys = options->all_keys();
keys.insert(new_keys.begin(), new_keys.end());
}
return std::vector<std::string>(keys.begin(), keys.end());
}
std::vector<std::string> values_for(const std::string &name) const final {
std::set<std::string> values;
for(auto &options: options_) {
const auto new_values = options->values_for(name);
values.insert(new_values.begin(), new_values.end());
}
return std::vector<std::string>(values.begin(), values.end());
}
const std::type_info *type_of(const std::string &name) const final {
for(auto &options: options_) {
auto info = options->type_of(name);
if(info) return info;
}
return nullptr;
}
size_t count_of(const std::string &name) const final {
for(auto &options: options_) {
auto info = options->type_of(name);
if(info) return options->count_of(name);
}
return 0;
}
const void *get(const std::string &name) const final {
for(auto &options: options_) {
auto value = options->get(name);
if(value) return value;
}
return nullptr;
}
void *get(const std::string &name) final {
for(auto &options: options_) {
auto value = options->get(name);
if(value) return value;
}
return nullptr;
}
void set(const std::string &name, const void *value, const size_t offset) final {
const auto safe_type = type_of(name);
if(!safe_type) return;
// Set this property only where the child's type is the same as that
// which was returned from here for type_of.
for(auto &options: options_) {
const auto type = options->type_of(name);
if(!type) continue;
if(*type == *safe_type) {
options->set(name, value, offset);
} }
} }
}
void apply() { private:
auto options = options_.begin(); const std::vector<Configurable::Device *> &devices_;
for(auto device: devices_) { std::vector<std::unique_ptr<Reflection::Struct>> options_;
device->set_options(*options);
++options;
}
}
std::vector<std::string> all_keys() const final {
std::set<std::string> keys;
for(auto &options: options_) {
const auto new_keys = options->all_keys();
keys.insert(new_keys.begin(), new_keys.end());
}
return std::vector<std::string>(keys.begin(), keys.end());
}
std::vector<std::string> values_for(const std::string &name) const final {
std::set<std::string> values;
for(auto &options: options_) {
const auto new_values = options->values_for(name);
values.insert(new_values.begin(), new_values.end());
}
return std::vector<std::string>(values.begin(), values.end());
}
const std::type_info *type_of(const std::string &name) const final {
for(auto &options: options_) {
auto info = options->type_of(name);
if(info) return info;
}
return nullptr;
}
size_t count_of(const std::string &name) const final {
for(auto &options: options_) {
auto info = options->type_of(name);
if(info) return options->count_of(name);
}
return 0;
}
const void *get(const std::string &name) const final {
for(auto &options: options_) {
auto value = options->get(name);
if(value) return value;
}
return nullptr;
}
void *get(const std::string &name) final {
for(auto &options: options_) {
auto value = options->get(name);
if(value) return value;
}
return nullptr;
}
void set(const std::string &name, const void *value, size_t offset) final {
const auto safe_type = type_of(name);
if(!safe_type) return;
// Set this property only where the child's type is the same as that
// which was returned from here for type_of.
for(auto &options: options_) {
const auto type = options->type_of(name);
if(!type) continue;
if(*type == *safe_type) {
options->set(name, value, offset);
}
}
}
private:
const std::vector<Configurable::Device *> &devices_;
std::vector<std::unique_ptr<Reflection::Struct>> options_;
}; };
} }
@@ -115,6 +115,6 @@ void MultiConfigurable::set_options(const std::unique_ptr<Reflection::Struct> &s
options->apply(); options->apply();
} }
std::unique_ptr<Reflection::Struct> MultiConfigurable::get_options() { std::unique_ptr<Reflection::Struct> MultiConfigurable::get_options() const {
return std::make_unique<MultiStruct>(devices_); return std::make_unique<MultiStruct>(devices_);
} }

View File

@@ -23,15 +23,15 @@ namespace Analyser::Dynamic {
order of delivered messages. order of delivered messages.
*/ */
class MultiConfigurable: public Configurable::Device { class MultiConfigurable: public Configurable::Device {
public: public:
MultiConfigurable(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines); MultiConfigurable(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &);
// Below is the standard Configurable::Device interface; see there for documentation. // Below is the standard Configurable::Device interface; see there for documentation.
void set_options(const std::unique_ptr<Reflection::Struct> &options) final; void set_options(const std::unique_ptr<Reflection::Struct> &) final;
std::unique_ptr<Reflection::Struct> get_options() final; std::unique_ptr<Reflection::Struct> get_options() const final;
private: private:
std::vector<Configurable::Device *> devices_; std::vector<Configurable::Device *> devices_;
}; };
} }

View File

@@ -15,52 +15,52 @@ using namespace Analyser::Dynamic;
namespace { namespace {
class MultiJoystick: public Inputs::Joystick { class MultiJoystick: public Inputs::Joystick {
public: public:
MultiJoystick(std::vector<MachineTypes::JoystickMachine *> &machines, std::size_t index) { MultiJoystick(std::vector<MachineTypes::JoystickMachine *> &machines, const std::size_t index) {
for(const auto &machine: machines) { for(const auto &machine: machines) {
const auto &joysticks = machine->get_joysticks(); const auto &joysticks = machine->get_joysticks();
if(joysticks.size() >= index) { if(joysticks.size() > index) {
joysticks_.push_back(joysticks[index].get()); joysticks_.push_back(joysticks[index].get());
}
} }
} }
}
const std::vector<Input> &get_inputs() final { const std::vector<Input> &get_inputs() final {
if(inputs.empty()) { if(inputs.empty()) {
for(const auto &joystick: joysticks_) { for(const auto &joystick: joysticks_) {
std::vector<Input> joystick_inputs = joystick->get_inputs(); std::vector<Input> joystick_inputs = joystick->get_inputs();
for(const auto &input: joystick_inputs) { for(const auto &input: joystick_inputs) {
if(std::find(inputs.begin(), inputs.end(), input) != inputs.end()) { if(std::find(inputs.begin(), inputs.end(), input) != inputs.end()) {
inputs.push_back(input); inputs.push_back(input);
}
} }
} }
} }
return inputs;
} }
void set_input(const Input &digital_input, bool is_active) final { return inputs;
for(const auto &joystick: joysticks_) { }
joystick->set_input(digital_input, is_active);
}
}
void set_input(const Input &digital_input, float value) final { void set_input(const Input &digital_input, const bool is_active) final {
for(const auto &joystick: joysticks_) { for(const auto &joystick: joysticks_) {
joystick->set_input(digital_input, value); joystick->set_input(digital_input, is_active);
}
} }
}
void reset_all_inputs() final { void set_input(const Input &digital_input, const float value) final {
for(const auto &joystick: joysticks_) { for(const auto &joystick: joysticks_) {
joystick->reset_all_inputs(); joystick->set_input(digital_input, value);
}
} }
}
private: void reset_all_inputs() final {
std::vector<Input> inputs; for(const auto &joystick: joysticks_) {
std::vector<Inputs::Joystick *> joysticks_; joystick->reset_all_inputs();
}
}
private:
std::vector<Input> inputs;
std::vector<Inputs::Joystick *> joysticks_;
}; };
} }

View File

@@ -22,14 +22,14 @@ namespace Analyser::Dynamic {
order of delivered messages. order of delivered messages.
*/ */
class MultiJoystickMachine: public MachineTypes::JoystickMachine { class MultiJoystickMachine: public MachineTypes::JoystickMachine {
public: public:
MultiJoystickMachine(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines); MultiJoystickMachine(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &);
// Below is the standard JoystickMachine::Machine interface; see there for documentation. // Below is the standard JoystickMachine::Machine interface; see there for documentation.
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() final; const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() final;
private: private:
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_; std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
}; };
} }

View File

@@ -24,7 +24,7 @@ void MultiKeyboardMachine::clear_all_keys() {
} }
} }
void MultiKeyboardMachine::set_key_state(uint16_t key, bool is_pressed) { void MultiKeyboardMachine::set_key_state(const uint16_t key, const bool is_pressed) {
for(const auto &machine: machines_) { for(const auto &machine: machines_) {
machine->set_key_state(key, is_pressed); machine->set_key_state(key, is_pressed);
} }
@@ -36,7 +36,7 @@ void MultiKeyboardMachine::type_string(const std::string &string) {
} }
} }
bool MultiKeyboardMachine::can_type(char c) const { bool MultiKeyboardMachine::can_type(const char c) const {
bool can_type = true; bool can_type = true;
for(const auto &machine: machines_) { for(const auto &machine: machines_) {
can_type &= machine->can_type(c); can_type &= machine->can_type(c);
@@ -51,12 +51,20 @@ Inputs::Keyboard &MultiKeyboardMachine::get_keyboard() {
MultiKeyboardMachine::MultiKeyboard::MultiKeyboard(const std::vector<::MachineTypes::KeyboardMachine *> &machines) MultiKeyboardMachine::MultiKeyboard::MultiKeyboard(const std::vector<::MachineTypes::KeyboardMachine *> &machines)
: machines_(machines) { : machines_(machines) {
for(const auto &machine: machines_) { for(const auto &machine: machines_) {
observed_keys_.insert(machine->get_keyboard().observed_keys().begin(), machine->get_keyboard().observed_keys().end()); observed_keys_.insert(
machine->get_keyboard().observed_keys().begin(),
machine->get_keyboard().observed_keys().end()
);
is_exclusive_ |= machine->get_keyboard().is_exclusive(); is_exclusive_ |= machine->get_keyboard().is_exclusive();
} }
} }
bool MultiKeyboardMachine::MultiKeyboard::set_key_pressed(Key key, char value, bool is_pressed, bool is_repeat) { bool MultiKeyboardMachine::MultiKeyboard::set_key_pressed(
const Key key,
const char value,
const bool is_pressed,
const bool is_repeat
) {
bool was_consumed = false; bool was_consumed = false;
for(const auto &machine: machines_) { for(const auto &machine: machines_) {
was_consumed |= machine->get_keyboard().set_key_pressed(key, value, is_pressed, is_repeat); was_consumed |= machine->get_keyboard().set_key_pressed(key, value, is_pressed, is_repeat);

View File

@@ -23,34 +23,34 @@ namespace Analyser::Dynamic {
order of delivered messages. order of delivered messages.
*/ */
class MultiKeyboardMachine: public MachineTypes::KeyboardMachine { class MultiKeyboardMachine: public MachineTypes::KeyboardMachine {
private: private:
std::vector<MachineTypes::KeyboardMachine *> machines_; std::vector<MachineTypes::KeyboardMachine *> machines_;
class MultiKeyboard: public Inputs::Keyboard {
public:
MultiKeyboard(const std::vector<MachineTypes::KeyboardMachine *> &machines);
bool set_key_pressed(Key key, char value, bool is_pressed, bool is_repeat) final;
void reset_all_keys() final;
const std::set<Key> &observed_keys() const final;
bool is_exclusive() const final;
private:
const std::vector<MachineTypes::KeyboardMachine *> &machines_;
std::set<Key> observed_keys_;
bool is_exclusive_ = false;
};
std::unique_ptr<MultiKeyboard> keyboard_;
class MultiKeyboard: public Inputs::Keyboard {
public: public:
MultiKeyboardMachine(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines); MultiKeyboard(const std::vector<MachineTypes::KeyboardMachine *> &);
// Below is the standard KeyboardMachine::Machine interface; see there for documentation. bool set_key_pressed(Key key, char value, bool is_pressed, bool is_repeat) final;
void clear_all_keys() final; void reset_all_keys() final;
void set_key_state(uint16_t key, bool is_pressed) final; const std::set<Key> &observed_keys() const final;
void type_string(const std::string &) final; bool is_exclusive() const final;
bool can_type(char c) const final;
Inputs::Keyboard &get_keyboard() final; private:
const std::vector<MachineTypes::KeyboardMachine *> &machines_;
std::set<Key> observed_keys_;
bool is_exclusive_ = false;
};
std::unique_ptr<MultiKeyboard> keyboard_;
public:
MultiKeyboardMachine(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines);
// Below is the standard KeyboardMachine::Machine interface; see there for documentation.
void clear_all_keys() final;
void set_key_state(uint16_t key, bool is_pressed) final;
void type_string(const std::string &) final;
bool can_type(char c) const final;
Inputs::Keyboard &get_keyboard() final;
}; };
} }

View File

@@ -18,6 +18,9 @@ MultiMediaTarget::MultiMediaTarget(const std::vector<std::unique_ptr<::Machine::
} }
bool MultiMediaTarget::insert_media(const Analyser::Static::Media &media) { bool MultiMediaTarget::insert_media(const Analyser::Static::Media &media) {
// TODO: copy media afresh for each target machine; media
// generally has mutable state.
bool inserted = false; bool inserted = false;
for(const auto &target : targets_) { for(const auto &target : targets_) {
inserted |= target->insert_media(media); inserted |= target->insert_media(media);

View File

@@ -23,14 +23,14 @@ namespace Analyser::Dynamic {
order of delivered messages. order of delivered messages.
*/ */
struct MultiMediaTarget: public MachineTypes::MediaTarget { struct MultiMediaTarget: public MachineTypes::MediaTarget {
public: public:
MultiMediaTarget(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines); MultiMediaTarget(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &);
// Below is the standard MediaTarget::Machine interface; see there for documentation. // Below is the standard MediaTarget::Machine interface; see there for documentation.
bool insert_media(const Analyser::Static::Media &media) final; bool insert_media(const Analyser::Static::Media &) final;
private: private:
std::vector<MachineTypes::MediaTarget *> targets_; std::vector<MachineTypes::MediaTarget *> targets_;
}; };
} }

View File

@@ -53,7 +53,7 @@ void MultiInterface<MachineType>::perform_serial(const std::function<void(Machin
} }
// MARK: - MultiScanProducer // MARK: - MultiScanProducer
void MultiScanProducer::set_scan_target(Outputs::Display::ScanTarget *scan_target) { void MultiScanProducer::set_scan_target(Outputs::Display::ScanTarget *const scan_target) {
scan_target_ = scan_target; scan_target_ = scan_target;
std::lock_guard machines_lock(machines_mutex_); std::lock_guard machines_lock(machines_mutex_);
@@ -80,7 +80,12 @@ void MultiScanProducer::did_change_machine_order() {
} }
// MARK: - MultiAudioProducer // MARK: - MultiAudioProducer
MultiAudioProducer::MultiAudioProducer(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines, std::recursive_mutex &machines_mutex) : MultiInterface(machines, machines_mutex) { MultiAudioProducer::MultiAudioProducer(
const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines,
std::recursive_mutex &machines_mutex
) :
MultiInterface(machines, machines_mutex)
{
speaker_ = MultiSpeaker::create(machines); speaker_ = MultiSpeaker::create(machines);
} }
@@ -96,7 +101,7 @@ void MultiAudioProducer::did_change_machine_order() {
// MARK: - MultiTimedMachine // MARK: - MultiTimedMachine
void MultiTimedMachine::run_for(Time::Seconds duration) { void MultiTimedMachine::run_for(const Time::Seconds duration) {
perform_parallel([duration](::MachineTypes::TimedMachine *machine) { perform_parallel([duration](::MachineTypes::TimedMachine *machine) {
if(machine->get_confidence() >= 0.01f) machine->run_for(duration); if(machine->get_confidence() >= 0.01f) machine->run_for(duration);
}); });

View File

@@ -21,88 +21,91 @@
namespace Analyser::Dynamic { namespace Analyser::Dynamic {
template <typename MachineType> class MultiInterface { template <typename MachineType> class MultiInterface {
public: public:
MultiInterface(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines, std::recursive_mutex &machines_mutex) : MultiInterface(
machines_(machines), machines_mutex_(machines_mutex), queues_(machines.size()) {} const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines,
std::recursive_mutex &machines_mutex
) :
machines_(machines), machines_mutex_(machines_mutex), queues_(machines.size()) {}
protected: protected:
/*! /*!
Performs a parallel for operation across all machines, performing the supplied Performs a parallel for operation across all machines, performing the supplied
function on each and returning only once all applications have completed. function on each and returning only once all applications have completed.
No guarantees are extended as to which thread operations will occur on. No guarantees are extended as to which thread operations will occur on.
*/ */
void perform_parallel(const std::function<void(MachineType *)> &); void perform_parallel(const std::function<void(MachineType *)> &);
/*! /*!
Performs a serial for operation across all machines, performing the supplied Performs a serial for operation across all machines, performing the supplied
function on each on the calling thread. function on each on the calling thread.
*/ */
void perform_serial(const std::function<void(MachineType *)> &); void perform_serial(const std::function<void(MachineType *)> &);
protected: protected:
const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines_; const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines_;
std::recursive_mutex &machines_mutex_; std::recursive_mutex &machines_mutex_;
private: private:
std::vector<Concurrency::AsyncTaskQueue<true>> queues_; std::vector<Concurrency::AsyncTaskQueue<true>> queues_;
}; };
class MultiTimedMachine: public MultiInterface<MachineTypes::TimedMachine>, public MachineTypes::TimedMachine { class MultiTimedMachine: public MultiInterface<MachineTypes::TimedMachine>, public MachineTypes::TimedMachine {
public: public:
using MultiInterface::MultiInterface; using MultiInterface::MultiInterface;
/*! /*!
Provides a mechanism by which a delegate can be informed each time a call to run_for has Provides a mechanism by which a delegate can be informed each time a call to run_for has
been received. been received.
*/ */
struct Delegate { struct Delegate {
virtual void did_run_machines(MultiTimedMachine *) = 0; virtual void did_run_machines(MultiTimedMachine *) = 0;
}; };
/// Sets @c delegate as the receiver of delegate messages. /// Sets @c delegate as the receiver of delegate messages.
void set_delegate(Delegate *delegate) { void set_delegate(Delegate *const delegate) {
delegate_ = delegate; delegate_ = delegate;
} }
void run_for(Time::Seconds duration) final; void run_for(Time::Seconds duration) final;
private: private:
void run_for(const Cycles) final {} void run_for(Cycles) final {}
Delegate *delegate_ = nullptr; Delegate *delegate_ = nullptr;
}; };
class MultiScanProducer: public MultiInterface<MachineTypes::ScanProducer>, public MachineTypes::ScanProducer { class MultiScanProducer: public MultiInterface<MachineTypes::ScanProducer>, public MachineTypes::ScanProducer {
public: public:
using MultiInterface::MultiInterface; using MultiInterface::MultiInterface;
/*! /*!
Informs the MultiScanProducer that the order of machines has changed; it Informs the MultiScanProducer that the order of machines has changed; it
uses this as an opportunity to synthesis any CRTMachine::Machine::Delegate messages that uses this as an opportunity to synthesis any CRTMachine::Machine::Delegate messages that
are necessary to bridge the gap between one machine and the next. are necessary to bridge the gap between one machine and the next.
*/ */
void did_change_machine_order(); void did_change_machine_order();
void set_scan_target(Outputs::Display::ScanTarget *scan_target) final; void set_scan_target(Outputs::Display::ScanTarget *) final;
Outputs::Display::ScanStatus get_scan_status() const final; Outputs::Display::ScanStatus get_scan_status() const final;
private: private:
Outputs::Display::ScanTarget *scan_target_ = nullptr; Outputs::Display::ScanTarget *scan_target_ = nullptr;
}; };
class MultiAudioProducer: public MultiInterface<MachineTypes::AudioProducer>, public MachineTypes::AudioProducer { class MultiAudioProducer: public MultiInterface<MachineTypes::AudioProducer>, public MachineTypes::AudioProducer {
public: public:
MultiAudioProducer(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines, std::recursive_mutex &machines_mutex); MultiAudioProducer(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &, std::recursive_mutex &);
/*! /*!
Informs the MultiAudio that the order of machines has changed; it Informs the MultiAudio that the order of machines has changed; it
uses this as an opportunity to switch speaker delegates as appropriate. uses this as an opportunity to switch speaker delegates as appropriate.
*/ */
void did_change_machine_order(); void did_change_machine_order();
Outputs::Speaker::Speaker *get_speaker() final; Outputs::Speaker::Speaker *get_speaker() final;
private: private:
MultiSpeaker *speaker_ = nullptr; MultiSpeaker *speaker_ = nullptr;
}; };
/*! /*!

View File

@@ -28,7 +28,7 @@ MultiSpeaker::MultiSpeaker(const std::vector<Outputs::Speaker::Speaker *> &speak
} }
} }
float MultiSpeaker::get_ideal_clock_rate_in_range(float minimum, float maximum) { float MultiSpeaker::get_ideal_clock_rate_in_range(const float minimum, const float maximum) {
float ideal = 0.0f; float ideal = 0.0f;
for(const auto &speaker: speakers_) { for(const auto &speaker: speakers_) {
ideal += speaker->get_ideal_clock_rate_in_range(minimum, maximum); ideal += speaker->get_ideal_clock_rate_in_range(minimum, maximum);
@@ -37,7 +37,7 @@ float MultiSpeaker::get_ideal_clock_rate_in_range(float minimum, float maximum)
return ideal / float(speakers_.size()); return ideal / float(speakers_.size());
} }
void MultiSpeaker::set_computed_output_rate(float cycles_per_second, int buffer_size, bool stereo) { void MultiSpeaker::set_computed_output_rate(const float cycles_per_second, const int buffer_size, const bool stereo) {
stereo_output_ = stereo; stereo_output_ = stereo;
for(const auto &speaker: speakers_) { for(const auto &speaker: speakers_) {
speaker->set_computed_output_rate(cycles_per_second, buffer_size, stereo); speaker->set_computed_output_rate(cycles_per_second, buffer_size, stereo);
@@ -54,14 +54,14 @@ bool MultiSpeaker::get_is_stereo() {
return false; return false;
} }
void MultiSpeaker::set_output_volume(float volume) { void MultiSpeaker::set_output_volume(const float volume) {
for(const auto &speaker: speakers_) { for(const auto &speaker: speakers_) {
speaker->set_output_volume(volume); speaker->set_output_volume(volume);
} }
} }
void MultiSpeaker::speaker_did_complete_samples(Speaker *speaker, const std::vector<int16_t> &buffer) { void MultiSpeaker::speaker_did_complete_samples(Speaker *const speaker, const std::vector<int16_t> &buffer) {
auto delegate = delegate_.load(std::memory_order::memory_order_relaxed); auto delegate = delegate_.load(std::memory_order_relaxed);
if(!delegate) return; if(!delegate) return;
{ {
std::lock_guard lock_guard(front_speaker_mutex_); std::lock_guard lock_guard(front_speaker_mutex_);
@@ -70,8 +70,8 @@ void MultiSpeaker::speaker_did_complete_samples(Speaker *speaker, const std::vec
did_complete_samples(this, buffer, stereo_output_); did_complete_samples(this, buffer, stereo_output_);
} }
void MultiSpeaker::speaker_did_change_input_clock(Speaker *speaker) { void MultiSpeaker::speaker_did_change_input_clock(Speaker *const speaker) {
auto delegate = delegate_.load(std::memory_order::memory_order_relaxed); auto delegate = delegate_.load(std::memory_order_relaxed);
if(!delegate) return; if(!delegate) return;
{ {
std::lock_guard lock_guard(front_speaker_mutex_); std::lock_guard lock_guard(front_speaker_mutex_);
@@ -80,12 +80,12 @@ void MultiSpeaker::speaker_did_change_input_clock(Speaker *speaker) {
delegate->speaker_did_change_input_clock(this); delegate->speaker_did_change_input_clock(this);
} }
void MultiSpeaker::set_new_front_machine(::Machine::DynamicMachine *machine) { void MultiSpeaker::set_new_front_machine(::Machine::DynamicMachine *const machine) {
{ {
std::lock_guard lock_guard(front_speaker_mutex_); std::lock_guard lock_guard(front_speaker_mutex_);
front_speaker_ = machine->audio_producer()->get_speaker(); front_speaker_ = machine->audio_producer()->get_speaker();
} }
auto delegate = delegate_.load(std::memory_order::memory_order_relaxed); auto delegate = delegate_.load(std::memory_order_relaxed);
if(delegate) { if(delegate) {
delegate->speaker_did_change_input_clock(this); delegate->speaker_did_change_input_clock(this);
} }

View File

@@ -25,32 +25,32 @@ namespace Analyser::Dynamic {
abreast of the current frontmost machine. abreast of the current frontmost machine.
*/ */
class MultiSpeaker: public Outputs::Speaker::Speaker, Outputs::Speaker::Speaker::Delegate { class MultiSpeaker: public Outputs::Speaker::Speaker, Outputs::Speaker::Speaker::Delegate {
public: public:
/*! /*!
Provides a construction mechanism that may return nullptr, in the case that all included Provides a construction mechanism that may return nullptr, in the case that all included
machines return nullptr as their speaker. machines return nullptr as their speaker.
*/ */
static MultiSpeaker *create(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines); static MultiSpeaker *create(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &);
/// This class requires the caller to nominate changes in the frontmost machine. /// This class requires the caller to nominate changes in the frontmost machine.
void set_new_front_machine(::Machine::DynamicMachine *machine); void set_new_front_machine(::Machine::DynamicMachine *);
// Below is the standard Outputs::Speaker::Speaker interface; see there for documentation. // Below is the standard Outputs::Speaker::Speaker interface; see there for documentation.
float get_ideal_clock_rate_in_range(float minimum, float maximum) override; float get_ideal_clock_rate_in_range(float minimum, float maximum) override;
void set_computed_output_rate(float cycles_per_second, int buffer_size, bool stereo) override; void set_computed_output_rate(float cycles_per_second, int buffer_size, bool stereo) override;
bool get_is_stereo() override; bool get_is_stereo() override;
void set_output_volume(float) override; void set_output_volume(float) override;
private: private:
void speaker_did_complete_samples(Speaker *speaker, const std::vector<int16_t> &buffer) final; void speaker_did_complete_samples(Speaker *speaker, const std::vector<int16_t> &buffer) final;
void speaker_did_change_input_clock(Speaker *speaker) final; void speaker_did_change_input_clock(Speaker *speaker) final;
MultiSpeaker(const std::vector<Outputs::Speaker::Speaker *> &speakers); MultiSpeaker(const std::vector<Outputs::Speaker::Speaker *> &speakers);
std::vector<Outputs::Speaker::Speaker *> speakers_; std::vector<Outputs::Speaker::Speaker *> speakers_;
Outputs::Speaker::Speaker *front_speaker_ = nullptr; Outputs::Speaker::Speaker *front_speaker_ = nullptr;
std::mutex front_speaker_mutex_; std::mutex front_speaker_mutex_;
bool stereo_output_ = false; bool stereo_output_ = false;
}; };
} }

View File

@@ -27,7 +27,8 @@ MultiMachine::MultiMachine(std::vector<std::unique_ptr<DynamicMachine>> &&machin
audio_producer_(machines_, machines_mutex_), audio_producer_(machines_, machines_mutex_),
joystick_machine_(machines_), joystick_machine_(machines_),
keyboard_machine_(machines_), keyboard_machine_(machines_),
media_target_(machines_) { media_target_(machines_)
{
timed_machine_.set_delegate(this); timed_machine_.set_delegate(this);
} }
@@ -35,13 +36,13 @@ Activity::Source *MultiMachine::activity_source() {
return nullptr; // TODO return nullptr; // TODO
} }
#define Provider(type, name, member) \ #define Provider(type, name, member) \
type *MultiMachine::name() { \ type *MultiMachine::name() { \
if(has_picked_) { \ if(has_picked_) { \
return machines_.front()->name(); \ return machines_.front()->name(); \
} else { \ } else { \
return &member; \ return &member; \
} \ } \
} }
Provider(Configurable::Device, configurable_device, configurable_) Provider(Configurable::Device, configurable_device, configurable_)

View File

@@ -38,44 +38,44 @@ namespace Analyser::Dynamic {
the others in the set, that machine stops running. the others in the set, that machine stops running.
*/ */
class MultiMachine: public ::Machine::DynamicMachine, public MultiTimedMachine::Delegate { class MultiMachine: public ::Machine::DynamicMachine, public MultiTimedMachine::Delegate {
public: public:
/*! /*!
Allows a potential MultiMachine creator to enquire as to whether there's any benefit in Allows a potential MultiMachine creator to enquire as to whether there's any benefit in
requesting this class as a proxy. requesting this class as a proxy.
@returns @c true if the multimachine would discard all but the first machine in this list; @returns @c true if the multimachine would discard all but the first machine in this list;
@c false otherwise. @c false otherwise.
*/ */
static bool would_collapse(const std::vector<std::unique_ptr<DynamicMachine>> &machines); static bool would_collapse(const std::vector<std::unique_ptr<DynamicMachine>> &);
MultiMachine(std::vector<std::unique_ptr<DynamicMachine>> &&machines); MultiMachine(std::vector<std::unique_ptr<DynamicMachine>> &&);
Activity::Source *activity_source() final; Activity::Source *activity_source() final;
Configurable::Device *configurable_device() final; Configurable::Device *configurable_device() final;
MachineTypes::TimedMachine *timed_machine() final; MachineTypes::TimedMachine *timed_machine() final;
MachineTypes::ScanProducer *scan_producer() final; MachineTypes::ScanProducer *scan_producer() final;
MachineTypes::AudioProducer *audio_producer() final; MachineTypes::AudioProducer *audio_producer() final;
MachineTypes::JoystickMachine *joystick_machine() final; MachineTypes::JoystickMachine *joystick_machine() final;
MachineTypes::KeyboardMachine *keyboard_machine() final; MachineTypes::KeyboardMachine *keyboard_machine() final;
MachineTypes::MouseMachine *mouse_machine() final; MachineTypes::MouseMachine *mouse_machine() final;
MachineTypes::MediaTarget *media_target() final; MachineTypes::MediaTarget *media_target() final;
void *raw_pointer() final; void *raw_pointer() final;
private: private:
void did_run_machines(MultiTimedMachine *) final; void did_run_machines(MultiTimedMachine *) final;
std::vector<std::unique_ptr<DynamicMachine>> machines_; std::vector<std::unique_ptr<DynamicMachine>> machines_;
std::recursive_mutex machines_mutex_; std::recursive_mutex machines_mutex_;
MultiConfigurable configurable_; MultiConfigurable configurable_;
MultiTimedMachine timed_machine_; MultiTimedMachine timed_machine_;
MultiScanProducer scan_producer_; MultiScanProducer scan_producer_;
MultiAudioProducer audio_producer_; MultiAudioProducer audio_producer_;
MultiJoystickMachine joystick_machine_; MultiJoystickMachine joystick_machine_;
MultiKeyboardMachine keyboard_machine_; MultiKeyboardMachine keyboard_machine_;
MultiMediaTarget media_target_; MultiMediaTarget media_target_;
void pick_first(); void pick_first();
bool has_picked_ = false; bool has_picked_ = false;
}; };
} }

View File

@@ -17,6 +17,7 @@ enum class Machine {
Atari2600, Atari2600,
AtariST, AtariST,
Amiga, Amiga,
Archimedes,
ColecoVision, ColecoVision,
Electron, Electron,
Enterprise, Enterprise,
@@ -24,6 +25,7 @@ enum class Machine {
MasterSystem, MasterSystem,
MSX, MSX,
Oric, Oric,
Plus4,
PCCompatible, PCCompatible,
Vic20, Vic20,
ZX8081, ZX8081,

View File

@@ -13,6 +13,7 @@
#include "../../../Numeric/CRC.hpp" #include "../../../Numeric/CRC.hpp"
#include <algorithm> #include <algorithm>
#include <cstring>
using namespace Analyser::Static::Acorn; using namespace Analyser::Static::Acorn;
@@ -48,27 +49,39 @@ std::unique_ptr<Catalogue> Analyser::Static::Acorn::GetDFSCatalogue(const std::s
char name[10]; char name[10];
snprintf(name, 10, "%c.%.7s", names->samples[0][file_offset + 7] & 0x7f, &names->samples[0][file_offset]); snprintf(name, 10, "%c.%.7s", names->samples[0][file_offset + 7] & 0x7f, &names->samples[0][file_offset]);
new_file.name = name; new_file.name = name;
new_file.load_address = uint32_t(details->samples[0][file_offset] | (details->samples[0][file_offset+1] << 8) | ((details->samples[0][file_offset+6]&0x0c) << 14)); new_file.load_address = uint32_t(
new_file.execution_address = uint32_t(details->samples[0][file_offset+2] | (details->samples[0][file_offset+3] << 8) | ((details->samples[0][file_offset+6]&0xc0) << 10)); details->samples[0][file_offset] |
(details->samples[0][file_offset+1] << 8) |
((details->samples[0][file_offset+6]&0x0c) << 14)
);
new_file.execution_address = uint32_t(
details->samples[0][file_offset+2] |
(details->samples[0][file_offset+3] << 8) |
((details->samples[0][file_offset+6]&0xc0) << 10)
);
if(names->samples[0][file_offset + 7] & 0x80) { if(names->samples[0][file_offset + 7] & 0x80) {
// File is locked; it may not be altered or deleted. // File is locked; it may not be altered or deleted.
new_file.flags |= File::Flags::Locked; new_file.flags |= File::Flags::Locked;
} }
long data_length = long(details->samples[0][file_offset+4] | (details->samples[0][file_offset+5] << 8) | ((details->samples[0][file_offset+6]&0x30) << 12)); auto data_length = long(
details->samples[0][file_offset+4] |
(details->samples[0][file_offset+5] << 8) |
((details->samples[0][file_offset+6]&0x30) << 12)
);
int start_sector = details->samples[0][file_offset+7] | ((details->samples[0][file_offset+6]&0x03) << 8); int start_sector = details->samples[0][file_offset+7] | ((details->samples[0][file_offset+6]&0x03) << 8);
new_file.data.reserve(size_t(data_length)); new_file.data.reserve(size_t(data_length));
if(start_sector < 2) continue; if(start_sector < 2) continue;
while(data_length > 0) { while(data_length > 0) {
uint8_t sector = uint8_t(start_sector % 10); const uint8_t sector = uint8_t(start_sector % 10);
uint8_t track = uint8_t(start_sector / 10); const uint8_t track = uint8_t(start_sector / 10);
start_sector++; ++start_sector;
const Storage::Encodings::MFM::Sector *next_sector = parser.sector(0, track, sector); const Storage::Encodings::MFM::Sector *next_sector = parser.sector(0, track, sector);
if(!next_sector) break; if(!next_sector) break;
long length_from_sector = std::min(data_length, 256l); const long length_from_sector = std::min(data_length, 256l);
new_file.data.insert(new_file.data.end(), next_sector->samples[0].begin(), next_sector->samples[0].begin() + length_from_sector); new_file.data.insert(new_file.data.end(), next_sector->samples[0].begin(), next_sector->samples[0].begin() + length_from_sector);
data_length -= length_from_sector; data_length -= length_from_sector;
} }
@@ -86,34 +99,57 @@ std::unique_ptr<Catalogue> Analyser::Static::Acorn::GetADFSCatalogue(const std::
auto catalogue = std::make_unique<Catalogue>(); auto catalogue = std::make_unique<Catalogue>();
Storage::Encodings::MFM::Parser parser(Storage::Encodings::MFM::Density::Double, disk); Storage::Encodings::MFM::Parser parser(Storage::Encodings::MFM::Density::Double, disk);
// Grab the second half of the free-space map because it has the boot option in it.
const Storage::Encodings::MFM::Sector *free_space_map_second_half = parser.sector(0, 0, 1); const Storage::Encodings::MFM::Sector *free_space_map_second_half = parser.sector(0, 0, 1);
if(!free_space_map_second_half) return nullptr; if(!free_space_map_second_half) return nullptr;
catalogue->has_large_sectors = free_space_map_second_half->samples[0].size() == 1024;
// Possibility: this is a large-sector disk with an old-style free space map. In which
// case the above just read the start of the root directory.
uint8_t first_directory_sector = 2;
if(catalogue->has_large_sectors && !memcmp(&free_space_map_second_half->samples[0][1], "Hugo", 4)) {
free_space_map_second_half = parser.sector(0, 0, 0);
if(!free_space_map_second_half) return nullptr;
first_directory_sector = 1;
}
std::vector<uint8_t> root_directory; std::vector<uint8_t> root_directory;
root_directory.reserve(5 * 256); root_directory.reserve(catalogue->has_large_sectors ? 2*1024 : 5*256);
for(uint8_t c = 2; c < 7; c++) {
for(uint8_t c = first_directory_sector; c < first_directory_sector + (catalogue->has_large_sectors ? 2 : 5); c++) {
const Storage::Encodings::MFM::Sector *const sector = parser.sector(0, 0, c); const Storage::Encodings::MFM::Sector *const sector = parser.sector(0, 0, c);
if(!sector) return nullptr; if(!sector) return nullptr;
root_directory.insert(root_directory.end(), sector->samples[0].begin(), sector->samples[0].end()); root_directory.insert(root_directory.end(), sector->samples[0].begin(), sector->samples[0].end());
} }
// Quick sanity checks. // Check for end of directory marker.
if(root_directory[0x4cb]) return nullptr; if(root_directory[catalogue->has_large_sectors ? 0x7d7 : 0x4cb]) return nullptr;
if(root_directory[1] != 'H' || root_directory[2] != 'u' || root_directory[3] != 'g' || root_directory[4] != 'o') return nullptr;
if(root_directory[0x4FB] != 'H' || root_directory[0x4FC] != 'u' || root_directory[0x4FD] != 'g' || root_directory[0x4FE] != 'o') return nullptr;
switch(free_space_map_second_half->samples[0][0xfd]) { // Check for both directory identifiers.
default: catalogue->bootOption = Catalogue::BootOption::None; break; const uint8_t *const start_id = &root_directory[1];
case 1: catalogue->bootOption = Catalogue::BootOption::LoadBOOT; break; const uint8_t *const end_id = &root_directory[root_directory.size() - 5];
case 2: catalogue->bootOption = Catalogue::BootOption::RunBOOT; break; catalogue->is_hugo = !memcmp(start_id, "Hugo", 4) && !memcmp(end_id, "Hugo", 4);
case 3: catalogue->bootOption = Catalogue::BootOption::ExecBOOT; break; const bool is_nick = !memcmp(start_id, "Nick", 4) && !memcmp(end_id, "Nick", 4);
if(!catalogue->is_hugo && !is_nick) {
return nullptr;
}
if(!catalogue->has_large_sectors) {
// TODO: I don't know where the boot option rests with large sectors.
switch(free_space_map_second_half->samples[0][0xfd]) {
default: catalogue->bootOption = Catalogue::BootOption::None; break;
case 1: catalogue->bootOption = Catalogue::BootOption::LoadBOOT; break;
case 2: catalogue->bootOption = Catalogue::BootOption::RunBOOT; break;
case 3: catalogue->bootOption = Catalogue::BootOption::ExecBOOT; break;
}
} }
// Parse the root directory, at least. // Parse the root directory, at least.
for(std::size_t file_offset = 0x005; file_offset < 0x4cb; file_offset += 0x1a) { const std::size_t directory_extent = catalogue->has_large_sectors ? 0x7d7 : 0x4cb;
for(std::size_t file_offset = 0x005; file_offset < directory_extent; file_offset += 0x1a) {
// Obtain the name, which will be at most ten characters long, and will // Obtain the name, which will be at most ten characters long, and will
// be terminated by either a NULL character or a \r. // be terminated by either a NULL character or a \r.
char name[11]; char name[11]{};
std::size_t c = 0; std::size_t c = 0;
for(; c < 10; c++) { for(; c < 10; c++) {
const char next = root_directory[file_offset + c] & 0x7f; const char next = root_directory[file_offset + c] & 0x7f;
@@ -122,8 +158,9 @@ std::unique_ptr<Catalogue> Analyser::Static::Acorn::GetADFSCatalogue(const std::
} }
name[c] = '\0'; name[c] = '\0';
// Skip if the name is empty. // An empty name implies the directory has ended; files are always listed in case-insensitive
if(name[0] == '\0') continue; // sorted order, with that list being terminated by a '\0'.
if(name[0] == '\0') break;
// Populate a file then. // Populate a file then.
File new_file; File new_file;
@@ -166,16 +203,36 @@ std::unique_ptr<Catalogue> Analyser::Static::Acorn::GetADFSCatalogue(const std::
new_file.data.reserve(size); new_file.data.reserve(size);
while(new_file.data.size() < size) { while(new_file.data.size() < size) {
const Storage::Encodings::MFM::Sector *const sector = parser.sector(start_sector / (80 * 16), (start_sector / 16) % 80, start_sector % 16); const Storage::Encodings::MFM::Sector *const sector =
parser.sector(start_sector / (80 * 16), (start_sector / 16) % 80, start_sector % 16);
if(!sector) break; if(!sector) break;
const auto length_from_sector = std::min(size - new_file.data.size(), sector->samples[0].size()); const auto length_from_sector = std::min(size - new_file.data.size(), sector->samples[0].size());
new_file.data.insert(new_file.data.end(), sector->samples[0].begin(), sector->samples[0].begin() + ssize_t(length_from_sector)); new_file.data.insert(
new_file.data.end(),
sector->samples[0].begin(),
sector->samples[0].begin() + ssize_t(length_from_sector)
);
++start_sector; ++start_sector;
} }
catalogue->files.push_back(std::move(new_file)); catalogue->files.push_back(std::move(new_file));
} }
// Include the directory title.
const char *title, *name;
if(catalogue->has_large_sectors) {
title = reinterpret_cast<const char *>(&root_directory[0x7dd]);
name = reinterpret_cast<const char *>(&root_directory[0x7f0]);
} else {
title = reinterpret_cast<const char *>(&root_directory[0x4d9]);
name = reinterpret_cast<const char *>(&root_directory[0x4cc]);
}
catalogue->name = std::string(title, strnlen(title, 19));
if(catalogue->name.empty() || catalogue->name == "$") {
catalogue->name = std::string(name, strnlen(name, 10));
}
return catalogue; return catalogue;
} }

View File

@@ -15,6 +15,8 @@ namespace Analyser::Static::Acorn {
/// Describes a DFS- or ADFS-format catalogue(/directory): the list of files available and the catalogue's boot option. /// Describes a DFS- or ADFS-format catalogue(/directory): the list of files available and the catalogue's boot option.
struct Catalogue { struct Catalogue {
bool is_hugo = false;
bool has_large_sectors = false;
std::string name; std::string name;
std::vector<File> files; std::vector<File> files;
enum class BootOption { enum class BootOption {
@@ -25,7 +27,7 @@ struct Catalogue {
} bootOption; } bootOption;
}; };
std::unique_ptr<Catalogue> GetDFSCatalogue(const std::shared_ptr<Storage::Disk::Disk> &disk); std::unique_ptr<Catalogue> GetDFSCatalogue(const std::shared_ptr<Storage::Disk::Disk> &);
std::unique_ptr<Catalogue> GetADFSCatalogue(const std::shared_ptr<Storage::Disk::Disk> &disk); std::unique_ptr<Catalogue> GetADFSCatalogue(const std::shared_ptr<Storage::Disk::Disk> &);
} }

View File

@@ -12,25 +12,28 @@
#include "Tape.hpp" #include "Tape.hpp"
#include "Target.hpp" #include "Target.hpp"
#include "../../../Numeric/StringSimilarity.hpp"
#include <algorithm> #include <algorithm>
#include <map>
using namespace Analyser::Static::Acorn; using namespace Analyser::Static::Acorn;
static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
AcornCartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges) { AcornCartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges) {
std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> acorn_cartridges; std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> acorn_cartridges;
for(const auto &cartridge : cartridges) { for(const auto &cartridge : cartridges) {
const auto &segments = cartridge->get_segments(); const auto &segments = cartridge->get_segments();
// only one mapped item is allowed // Only one mapped item is allowed.
if(segments.size() != 1) continue; if(segments.size() != 1) continue;
// which must be 8 or 16 kb in size // Cartridges must be 8 or 16 kb in size.
const Storage::Cartridge::Cartridge::Segment &segment = segments.front(); const Storage::Cartridge::Cartridge::Segment &segment = segments.front();
if(segment.data.size() != 0x4000 && segment.data.size() != 0x2000) continue; if(segment.data.size() != 0x4000 && segment.data.size() != 0x2000) continue;
// is a copyright string present? // Check copyright string.
const uint8_t copyright_offset = segment.data[7]; const uint8_t copyright_offset = segment.data[7];
if( if(
segment.data[copyright_offset] != 0x00 || segment.data[copyright_offset] != 0x00 ||
@@ -39,16 +42,16 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
segment.data[copyright_offset+3] != 0x29 segment.data[copyright_offset+3] != 0x29
) continue; ) continue;
// is the language entry point valid? // Check language entry point.
if(!( if(!(
(segment.data[0] == 0x00 && segment.data[1] == 0x00 && segment.data[2] == 0x00) || (segment.data[0] == 0x00 && segment.data[1] == 0x00 && segment.data[2] == 0x00) ||
(segment.data[0] != 0x00 && segment.data[2] >= 0x80 && segment.data[2] < 0xc0) (segment.data[0] != 0x00 && segment.data[2] >= 0x80 && segment.data[2] < 0xc0)
)) continue; )) continue;
// is the service entry point valid? // Check service entry point.
if(!(segment.data[5] >= 0x80 && segment.data[5] < 0xc0)) continue; if(!(segment.data[5] >= 0x80 && segment.data[5] < 0xc0)) continue;
// probability of a random binary blob that isn't an Acorn ROM proceeding to here: // Probability of a random binary blob that isn't an Acorn ROM proceeding to here:
// 1/(2^32) * // 1/(2^32) *
// ( ((2^24)-1)/(2^24)*(1/4) + 1/(2^24) ) * // ( ((2^24)-1)/(2^24)*(1/4) + 1/(2^24) ) *
// 1/4 // 1/4
@@ -59,65 +62,78 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
return acorn_cartridges; return acorn_cartridges;
} }
Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(
auto target = std::make_unique<Target>(); const Media &media,
const std::string &file_name,
TargetPlatform::IntType,
bool
) {
auto target8bit = std::make_unique<ElectronTarget>();
auto targetArchimedes = std::make_unique<ArchimedesTarget>();
// strip out inappropriate cartridges // Copy appropriate cartridges to the 8-bit target.
target->media.cartridges = AcornCartridgesFrom(media.cartridges); target8bit->media.cartridges = AcornCartridgesFrom(media.cartridges);
// if there are any tapes, attempt to get data from the first // If there are tapes, attempt to get data from the first.
if(!media.tapes.empty()) { if(!media.tapes.empty()) {
std::shared_ptr<Storage::Tape::Tape> tape = media.tapes.front(); std::shared_ptr<Storage::Tape::Tape> tape = media.tapes.front();
std::vector<File> files = GetFiles(tape); auto serialiser = tape->serialiser();
tape->reset(); std::vector<File> files = GetFiles(*serialiser);
// continue if there are any files // continue if there are any files
if(!files.empty()) { if(!files.empty()) {
bool is_basic = true; bool is_basic = true;
// If a file is execute-only, that means *RUN. // If a file is execute-only, that means *RUN.
if(files.front().flags & File::Flags::ExecuteOnly) is_basic = false; if(files.front().flags & File::Flags::ExecuteOnly) {
is_basic = false;
}
// check also for a continuous threading of BASIC lines; if none then this probably isn't BASIC code, // Check also for a continuous threading of BASIC lines; if none then this probably isn't BASIC code,
// so that's also justification to *RUN // so that's also justification to *RUN.
std::size_t pointer = 0; if(is_basic) {
uint8_t *const data = &files.front().data[0]; std::size_t pointer = 0;
const std::size_t data_size = files.front().data.size(); uint8_t *const data = &files.front().data[0];
while(1) { const std::size_t data_size = files.front().data.size();
if(pointer >= data_size-1 || data[pointer] != 13) { while(true) {
is_basic = false; if(pointer >= data_size-1 || data[pointer] != 0x0d) {
break; is_basic = false;
break;
}
if((data[pointer+1]&0x7f) == 0x7f) break;
pointer += data[pointer+3];
} }
if((data[pointer+1]&0x7f) == 0x7f) break;
pointer += data[pointer+3];
} }
// Inspect first file. If it's protected or doesn't look like BASIC // Inspect first file. If it's protected or doesn't look like BASIC
// then the loading command is *RUN. Otherwise it's CHAIN"". // then the loading command is *RUN. Otherwise it's CHAIN"".
target->loading_command = is_basic ? "CHAIN\"\"\n" : "*RUN\n"; target8bit->loading_command = is_basic ? "CHAIN\"\"\n" : "*RUN\n";
target8bit->media.tapes = media.tapes;
target->media.tapes = media.tapes;
} }
} }
if(!media.disks.empty()) { if(!media.disks.empty()) {
std::shared_ptr<Storage::Disk::Disk> disk = media.disks.front(); std::shared_ptr<Storage::Disk::Disk> disk = media.disks.front();
std::unique_ptr<Catalogue> dfs_catalogue, adfs_catalogue; std::unique_ptr<Catalogue> dfs_catalogue, adfs_catalogue;
// Get any sort of catalogue that can be found.
dfs_catalogue = GetDFSCatalogue(disk); dfs_catalogue = GetDFSCatalogue(disk);
if(dfs_catalogue == nullptr) adfs_catalogue = GetADFSCatalogue(disk); if(dfs_catalogue == nullptr) adfs_catalogue = GetADFSCatalogue(disk);
if(dfs_catalogue || adfs_catalogue) {
// 8-bit options: DFS and Hugo-style ADFS.
if(dfs_catalogue || (adfs_catalogue && !adfs_catalogue->has_large_sectors && adfs_catalogue->is_hugo)) {
// Accept the disk and determine whether DFS or ADFS ROMs are implied. // Accept the disk and determine whether DFS or ADFS ROMs are implied.
// Use the Pres ADFS if using an ADFS, as it leaves Page at &EOO. // Use the Pres ADFS if using an ADFS, as it leaves Page at &EOO.
target->media.disks = media.disks; target8bit->media.disks = media.disks;
target->has_dfs = bool(dfs_catalogue); target8bit->has_dfs = bool(dfs_catalogue);
target->has_pres_adfs = bool(adfs_catalogue); target8bit->has_pres_adfs = bool(adfs_catalogue);
// Check whether a simple shift+break will do for loading this disk. // Check whether a simple shift+break will do for loading this disk.
Catalogue::BootOption bootOption = (dfs_catalogue ?: adfs_catalogue)->bootOption; const auto bootOption = (dfs_catalogue ?: adfs_catalogue)->bootOption;
if(bootOption != Catalogue::BootOption::None) { if(bootOption != Catalogue::BootOption::None) {
target->should_shift_restart = true; target8bit->should_shift_restart = true;
} else { } else {
target->loading_command = "*CAT\n"; target8bit->loading_command = "*CAT\n";
} }
// Check whether adding the AP6 ROM is justified. // Check whether adding the AP6 ROM is justified.
@@ -133,39 +149,79 @@ Analyser::Static::TargetList Analyser::Static::Acorn::GetTargets(const Media &me
"VERIFY", "ZERO" "VERIFY", "ZERO"
}) { }) {
if(std::search(file.data.begin(), file.data.end(), command, command+strlen(command)) != file.data.end()) { if(std::search(file.data.begin(), file.data.end(), command, command+strlen(command)) != file.data.end()) {
target->has_ap6_rom = true; target8bit->has_ap6_rom = true;
target->has_sideways_ram = true; target8bit->has_sideways_ram = true;
} }
} }
} }
} else if(adfs_catalogue) {
// Archimedes options, implicitly: ADFS, non-Hugo.
targetArchimedes->media.disks = media.disks;
// Also look for the best possible startup program name, if it can be discerned.
std::multimap<double, std::string, std::greater<double>> options;
for(const auto &file: adfs_catalogue->files) {
// Skip non-Pling files.
if(file.name[0] != '!') continue;
// Take whatever else comes with a preference for things that don't
// have 'boot' or 'read' in them (the latter of which will tend to be
// read_me or read_this or similar).
constexpr char read[] = "read";
constexpr char boot[] = "boot";
const auto has = [&](const char *begin, const char *end) {
return std::search(
file.name.begin(), file.name.end(),
begin, end - 1, // i.e. don't compare the trailing NULL.
[](char lhs, char rhs) {
return std::tolower(lhs) == rhs;
}
) != file.name.end();
};
const auto has_read = has(std::begin(read), std::end(read));
const auto has_boot = has(std::begin(boot), std::end(boot));
const auto probability =
Numeric::similarity(file.name, adfs_catalogue->name) +
Numeric::similarity(file.name, file_name) -
((has_read || has_boot) ? 0.2 : 0.0);
options.emplace(probability, file.name);
}
if(!options.empty()) {
targetArchimedes->main_program = options.begin()->second;
}
} }
} }
// Enable the Acorn ADFS if a mass-storage device is attached; // Enable the Acorn ADFS if a mass-storage device is attached;
// unlike the Pres ADFS it retains SCSI logic. // unlike the Pres ADFS it retains SCSI logic.
if(!media.mass_storage_devices.empty()) { if(!media.mass_storage_devices.empty()) {
target->has_pres_adfs = false; // To override a floppy selection, if one was made. target8bit->has_pres_adfs = false; // To override a floppy selection, if one was made.
target->has_acorn_adfs = true; target8bit->has_acorn_adfs = true;
// Assume some sort of later-era Acorn work is likely to happen; // Assume some sort of later-era Acorn work is likely to happen;
// so ensure *TYPE, etc are present. // so ensure *TYPE, etc are present.
target->has_ap6_rom = true; target8bit->has_ap6_rom = true;
target->has_sideways_ram = true; target8bit->has_sideways_ram = true;
target->media.mass_storage_devices = media.mass_storage_devices; target8bit->media.mass_storage_devices = media.mass_storage_devices;
// Check for a boot option. // Check for a boot option.
const auto sector = target->media.mass_storage_devices.front()->get_block(1); const auto sector = target8bit->media.mass_storage_devices.front()->get_block(1);
if(sector[0xfd]) { if(sector[0xfd]) {
target->should_shift_restart = true; target8bit->should_shift_restart = true;
} else { } else {
target->loading_command = "*CAT\n"; target8bit->loading_command = "*CAT\n";
} }
} }
TargetList targets; TargetList targets;
if(!target->media.empty()) { if(!target8bit->media.empty()) {
targets.push_back(std::move(target)); targets.push_back(std::move(target8bit));
}
if(!targetArchimedes->media.empty()) {
targets.push_back(std::move(targetArchimedes));
} }
return targets; return targets;
} }

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Acorn { namespace Analyser::Static::Acorn {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -15,65 +15,63 @@
using namespace Analyser::Static::Acorn; using namespace Analyser::Static::Acorn;
static std::unique_ptr<File::Chunk> GetNextChunk(const std::shared_ptr<Storage::Tape::Tape> &tape, Storage::Tape::Acorn::Parser &parser) { static std::unique_ptr<File::Chunk> GetNextChunk(
Storage::Tape::TapeSerialiser &serialiser,
Storage::Tape::Acorn::Parser &parser
) {
auto new_chunk = std::make_unique<File::Chunk>(); auto new_chunk = std::make_unique<File::Chunk>();
int shift_register = 0; int shift_register = 0;
// TODO: move this into the parser // TODO: move this into the parser
#define shift() shift_register = (shift_register >> 1) | (parser.get_next_bit(tape) << 9) const auto find = [&](int target) {
while(!serialiser.is_at_end() && (shift_register != target)) {
// find next area of high tone shift_register = (shift_register >> 1) | (parser.get_next_bit(serialiser) << 9);
while(!tape->is_at_end() && (shift_register != 0x3ff)) { }
shift(); };
}
// find next 0x2a (swallowing stop bit)
while(!tape->is_at_end() && (shift_register != 0x254)) {
shift();
}
#undef shift
// Find first sync byte that follows high tone.
find(0x3ff);
find(0x254); // i.e. 0x2a wrapped in a 1 start bit and a 0 stop bit.
parser.reset_crc(); parser.reset_crc();
parser.reset_error_flag(); parser.reset_error_flag();
// read out name // Read name.
char name[11]; char name[11]{};
std::size_t name_ptr = 0; std::size_t name_ptr = 0;
while(!tape->is_at_end() && name_ptr < sizeof(name)) { while(!serialiser.is_at_end() && name_ptr < sizeof(name)) {
name[name_ptr] = char(parser.get_next_byte(tape)); name[name_ptr] = char(parser.get_next_byte(serialiser));
if(!name[name_ptr]) break; if(!name[name_ptr]) break;
++name_ptr; ++name_ptr;
} }
name[sizeof(name)-1] = '\0';
new_chunk->name = name; new_chunk->name = name;
// addresses // Read rest of header fields.
new_chunk->load_address = uint32_t(parser.get_next_word(tape)); new_chunk->load_address = uint32_t(parser.get_next_word(serialiser));
new_chunk->execution_address = uint32_t(parser.get_next_word(tape)); new_chunk->execution_address = uint32_t(parser.get_next_word(serialiser));
new_chunk->block_number = uint16_t(parser.get_next_short(tape)); new_chunk->block_number = uint16_t(parser.get_next_short(serialiser));
new_chunk->block_length = uint16_t(parser.get_next_short(tape)); new_chunk->block_length = uint16_t(parser.get_next_short(serialiser));
new_chunk->block_flag = uint8_t(parser.get_next_byte(tape)); new_chunk->block_flag = uint8_t(parser.get_next_byte(serialiser));
new_chunk->next_address = uint32_t(parser.get_next_word(tape)); new_chunk->next_address = uint32_t(parser.get_next_word(serialiser));
uint16_t calculated_header_crc = parser.get_crc(); const auto matched_crc = [&]() {
uint16_t stored_header_crc = uint16_t(parser.get_next_short(tape)); const uint16_t calculated_crc = parser.get_crc();
stored_header_crc = uint16_t((stored_header_crc >> 8) | (stored_header_crc << 8)); uint16_t stored_crc = uint16_t(parser.get_next_short(serialiser));
new_chunk->header_crc_matched = stored_header_crc == calculated_header_crc; stored_crc = uint16_t((stored_crc >> 8) | (stored_crc << 8));
return stored_crc == calculated_crc;
};
new_chunk->header_crc_matched = matched_crc();
if(!new_chunk->header_crc_matched) return nullptr; if(!new_chunk->header_crc_matched) return nullptr;
parser.reset_crc(); // Bit 6 of the block flag means 'empty block'; allow it to override declared block length.
new_chunk->data.reserve(new_chunk->block_length);
for(int c = 0; c < new_chunk->block_length; c++) {
new_chunk->data.push_back(uint8_t(parser.get_next_byte(tape)));
}
if(new_chunk->block_length && !(new_chunk->block_flag&0x40)) { if(new_chunk->block_length && !(new_chunk->block_flag&0x40)) {
uint16_t calculated_data_crc = parser.get_crc(); parser.reset_crc();
uint16_t stored_data_crc = uint16_t(parser.get_next_short(tape)); new_chunk->data.reserve(new_chunk->block_length);
stored_data_crc = uint16_t((stored_data_crc >> 8) | (stored_data_crc << 8)); for(int c = 0; c < new_chunk->block_length; c++) {
new_chunk->data_crc_matched = stored_data_crc == calculated_data_crc; new_chunk->data.push_back(uint8_t(parser.get_next_byte(serialiser)));
}
new_chunk->data_crc_matched = matched_crc();
} else { } else {
new_chunk->data_crc_matched = true; new_chunk->data_crc_matched = true;
} }
@@ -82,67 +80,62 @@ static std::unique_ptr<File::Chunk> GetNextChunk(const std::shared_ptr<Storage::
} }
static std::unique_ptr<File> GetNextFile(std::deque<File::Chunk> &chunks) { static std::unique_ptr<File> GetNextFile(std::deque<File::Chunk> &chunks) {
// find next chunk with a block number of 0 // Find next chunk with a block number of 0.
while(chunks.size() && chunks.front().block_number) { while(!chunks.empty() && chunks.front().block_number) {
chunks.pop_front(); chunks.pop_front();
} }
if(chunks.empty()) return nullptr;
if(!chunks.size()) return nullptr; // Accumulate sequential blocks until end-of-file bit is set.
// accumulate chunks for as long as block number is sequential and the end-of-file bit isn't set
auto file = std::make_unique<File>(); auto file = std::make_unique<File>();
uint16_t block_number = 0; uint16_t block_number = 0;
while(!chunks.empty()) {
while(chunks.size()) {
if(chunks.front().block_number != block_number) return nullptr; if(chunks.front().block_number != block_number) return nullptr;
bool was_last = chunks.front().block_flag & 0x80; const bool was_last = chunks.front().block_flag & 0x80;
file->chunks.push_back(chunks.front()); file->chunks.push_back(chunks.front());
chunks.pop_front(); chunks.pop_front();
block_number++; ++block_number;
if(was_last) break; if(was_last) break;
} }
// accumulate total data, copy flags appropriately // Grab metadata flags.
file->name = file->chunks.front().name; file->name = file->chunks.front().name;
file->load_address = file->chunks.front().load_address; file->load_address = file->chunks.front().load_address;
file->execution_address = file->chunks.front().execution_address; file->execution_address = file->chunks.front().execution_address;
// I think the final chunk's flags are the ones that count; TODO: check.
if(file->chunks.back().block_flag & 0x01) { if(file->chunks.back().block_flag & 0x01) {
// File is locked, which in more generalised terms means it is // File is locked i.e. for execution only.
// for execution only.
file->flags |= File::Flags::ExecuteOnly; file->flags |= File::Flags::ExecuteOnly;
} }
// copy all data into a single big block // Copy data into a single big block.
for(File::Chunk chunk : file->chunks) { file->data.reserve(file->chunks.size() * 256);
for(auto &chunk : file->chunks) {
file->data.insert(file->data.end(), chunk.data.begin(), chunk.data.end()); file->data.insert(file->data.end(), chunk.data.begin(), chunk.data.end());
} }
return file; return file;
} }
std::vector<File> Analyser::Static::Acorn::GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape) { std::vector<File> Analyser::Static::Acorn::GetFiles(Storage::Tape::TapeSerialiser &serialiser) {
Storage::Tape::Acorn::Parser parser; Storage::Tape::Acorn::Parser parser;
// populate chunk list // Read all chunks.
std::deque<File::Chunk> chunk_list; std::deque<File::Chunk> chunk_list;
while(!tape->is_at_end()) { while(!serialiser.is_at_end()) {
std::unique_ptr<File::Chunk> chunk = GetNextChunk(tape, parser); const std::unique_ptr<File::Chunk> chunk = GetNextChunk(serialiser, parser);
if(chunk) { if(chunk) {
chunk_list.push_back(*chunk); chunk_list.push_back(std::move(*chunk));
} }
} }
// decompose into file list // Convert to files.
std::vector<File> file_list; std::vector<File> file_list;
while(!chunk_list.empty()) {
while(chunk_list.size()) { const std::unique_ptr<File> next_file = GetNextFile(chunk_list);
std::unique_ptr<File> next_file = GetNextFile(chunk_list);
if(next_file) { if(next_file) {
file_list.push_back(*next_file); file_list.push_back(std::move(*next_file));
} }
} }

View File

@@ -15,6 +15,6 @@
namespace Analyser::Static::Acorn { namespace Analyser::Static::Acorn {
std::vector<File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape); std::vector<File> GetFiles(Storage::Tape::TapeSerialiser &);
} }

View File

@@ -14,7 +14,7 @@
namespace Analyser::Static::Acorn { namespace Analyser::Static::Acorn {
struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<Target> { struct ElectronTarget: public ::Analyser::Static::Target, public Reflection::StructImpl<ElectronTarget> {
bool has_acorn_adfs = false; bool has_acorn_adfs = false;
bool has_pres_adfs = false; bool has_pres_adfs = false;
bool has_dfs = false; bool has_dfs = false;
@@ -23,15 +23,27 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
bool should_shift_restart = false; bool should_shift_restart = false;
std::string loading_command; std::string loading_command;
Target() : Analyser::Static::Target(Machine::Electron) { ElectronTarget() : Analyser::Static::Target(Machine::Electron) {}
if(needs_declare()) {
DeclareField(has_pres_adfs); private:
DeclareField(has_acorn_adfs); friend Reflection::StructImpl<ElectronTarget>;
DeclareField(has_dfs); void declare_fields() {
DeclareField(has_ap6_rom); DeclareField(has_pres_adfs);
DeclareField(has_sideways_ram); DeclareField(has_acorn_adfs);
} DeclareField(has_dfs);
DeclareField(has_ap6_rom);
DeclareField(has_sideways_ram);
} }
}; };
struct ArchimedesTarget: public ::Analyser::Static::Target, public Reflection::StructImpl<ArchimedesTarget> {
std::string main_program;
ArchimedesTarget() : Analyser::Static::Target(Machine::Archimedes) {}
private:
friend Reflection::StructImpl<ArchimedesTarget>;
void declare_fields() {}
};
} }

View File

@@ -9,9 +9,14 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include "Target.hpp" #include "Target.hpp"
Analyser::Static::TargetList Analyser::Static::Amiga::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Amiga::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool is_confident
) {
// This analyser can comprehend disks and mass-storage devices only. // This analyser can comprehend disks and mass-storage devices only.
if(media.disks.empty()) return {}; if(media.disks.empty() && !is_confident) return {};
// As there is at least one usable media image, wave it through. // As there is at least one usable media image, wave it through.
Analyser::Static::TargetList targets; Analyser::Static::TargetList targets;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Amiga { namespace Analyser::Static::Amiga {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -28,13 +28,15 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
ChipRAM chip_ram = ChipRAM::FiveHundredAndTwelveKilobytes; ChipRAM chip_ram = ChipRAM::FiveHundredAndTwelveKilobytes;
FastRAM fast_ram = FastRAM::EightMegabytes; FastRAM fast_ram = FastRAM::EightMegabytes;
Target() : Analyser::Static::Target(Machine::Amiga) { Target() : Analyser::Static::Target(Machine::Amiga) {}
if(needs_declare()) {
DeclareField(fast_ram); private:
DeclareField(chip_ram); friend Reflection::StructImpl<Target>;
AnnounceEnum(FastRAM); void declare_fields() {
AnnounceEnum(ChipRAM); DeclareField(fast_ram);
} DeclareField(chip_ram);
AnnounceEnum(FastRAM);
AnnounceEnum(ChipRAM);
} }
}; };

View File

@@ -63,8 +63,8 @@ std::string RunCommandFor(const Storage::Disk::CPM::File &file) {
void InspectCatalogue( void InspectCatalogue(
const Storage::Disk::CPM::Catalogue &catalogue, const Storage::Disk::CPM::Catalogue &catalogue,
const std::unique_ptr<Analyser::Static::AmstradCPC::Target> &target) { const std::unique_ptr<Analyser::Static::AmstradCPC::Target> &target
) {
std::vector<const Storage::Disk::CPM::File *> candidate_files; std::vector<const Storage::Disk::CPM::File *> candidate_files;
candidate_files.reserve(catalogue.files.size()); candidate_files.reserve(catalogue.files.size());
for(const auto &file : catalogue.files) { for(const auto &file : catalogue.files) {
@@ -158,7 +158,10 @@ void InspectCatalogue(
target->loading_command = "cat\n"; target->loading_command = "cat\n";
} }
bool CheckBootSector(const std::shared_ptr<Storage::Disk::Disk> &disk, const std::unique_ptr<Analyser::Static::AmstradCPC::Target> &target) { bool CheckBootSector(
const std::shared_ptr<Storage::Disk::Disk> &disk,
const std::unique_ptr<Analyser::Static::AmstradCPC::Target> &target
) {
Storage::Encodings::MFM::Parser parser(Storage::Encodings::MFM::Density::Double, disk); Storage::Encodings::MFM::Parser parser(Storage::Encodings::MFM::Density::Double, disk);
const Storage::Encodings::MFM::Sector *boot_sector = parser.sector(0, 0, 0x41); const Storage::Encodings::MFM::Sector *boot_sector = parser.sector(0, 0, 0x41);
if(boot_sector != nullptr && !boot_sector->samples.empty() && boot_sector->samples[0].size() == 512) { if(boot_sector != nullptr && !boot_sector->samples.empty() && boot_sector->samples[0].size() == 512) {
@@ -182,7 +185,7 @@ bool CheckBootSector(const std::shared_ptr<Storage::Disk::Disk> &disk, const std
return false; return false;
} }
bool IsAmstradTape(const std::shared_ptr<Storage::Tape::Tape> &tape) { bool IsAmstradTape(Storage::Tape::TapeSerialiser &serialiser) {
// Limited sophistication here; look for a CPC-style file header, that is // Limited sophistication here; look for a CPC-style file header, that is
// any Spectrum-esque block with a synchronisation character of 0x2c. // any Spectrum-esque block with a synchronisation character of 0x2c.
// //
@@ -191,7 +194,7 @@ bool IsAmstradTape(const std::shared_ptr<Storage::Tape::Tape> &tape) {
Parser parser(Parser::MachineType::AmstradCPC); Parser parser(Parser::MachineType::AmstradCPC);
while(true) { while(true) {
const auto block = parser.find_block(tape); const auto block = parser.find_block(serialiser);
if(!block) break; if(!block) break;
if(block->type == 0x2c) { if(block->type == 0x2c) {
@@ -204,7 +207,12 @@ bool IsAmstradTape(const std::shared_ptr<Storage::Tape::Tape> &tape) {
} // namespace } // namespace
Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
TargetList destination; TargetList destination;
auto target = std::make_unique<Target>(); auto target = std::make_unique<Target>();
target->confidence = 0.5; target->confidence = 0.5;
@@ -214,7 +222,8 @@ Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Medi
if(!media.tapes.empty()) { if(!media.tapes.empty()) {
bool has_cpc_tape = false; bool has_cpc_tape = false;
for(auto &tape: media.tapes) { for(auto &tape: media.tapes) {
has_cpc_tape |= IsAmstradTape(tape); const auto serialiser = tape->serialiser();
has_cpc_tape |= IsAmstradTape(*serialiser);
} }
if(has_cpc_tape) { if(has_cpc_tape) {
@@ -228,26 +237,14 @@ Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Medi
} }
if(!media.disks.empty()) { if(!media.disks.empty()) {
Storage::Disk::CPM::ParameterBlock data_format; const auto data_format = Storage::Disk::CPM::ParameterBlock::cpc_data_format();
data_format.sectors_per_track = 9; const auto system_format = Storage::Disk::CPM::ParameterBlock::cpc_system_format();
data_format.tracks = 40;
data_format.block_size = 1024;
data_format.first_sector = 0xc1;
data_format.catalogue_allocation_bitmap = 0xc000;
data_format.reserved_tracks = 0;
Storage::Disk::CPM::ParameterBlock system_format;
system_format.sectors_per_track = 9;
system_format.tracks = 40;
system_format.block_size = 1024;
system_format.first_sector = 0x41;
system_format.catalogue_allocation_bitmap = 0xc000;
system_format.reserved_tracks = 2;
for(auto &disk: media.disks) { for(auto &disk: media.disks) {
// Check for an ordinary catalogue. // Check for an ordinary catalogue, making sure this isn't actually a ZX Spectrum disk.
std::unique_ptr<Storage::Disk::CPM::Catalogue> data_catalogue = Storage::Disk::CPM::GetCatalogue(disk, data_format); std::unique_ptr<Storage::Disk::CPM::Catalogue> data_catalogue =
if(data_catalogue) { Storage::Disk::CPM::GetCatalogue(disk, data_format, false);
if(data_catalogue && !data_catalogue->is_zx_spectrum_booter()) {
InspectCatalogue(*data_catalogue, target); InspectCatalogue(*data_catalogue, target);
target->media.disks.push_back(disk); target->media.disks.push_back(disk);
continue; continue;
@@ -260,8 +257,9 @@ Analyser::Static::TargetList Analyser::Static::AmstradCPC::GetTargets(const Medi
} }
// Failing that check for a system catalogue. // Failing that check for a system catalogue.
std::unique_ptr<Storage::Disk::CPM::Catalogue> system_catalogue = Storage::Disk::CPM::GetCatalogue(disk, system_format); std::unique_ptr<Storage::Disk::CPM::Catalogue> system_catalogue =
if(system_catalogue) { Storage::Disk::CPM::GetCatalogue(disk, system_format, false);
if(system_catalogue && !system_catalogue->is_zx_spectrum_booter()) {
InspectCatalogue(*system_catalogue, target); InspectCatalogue(*system_catalogue, target);
target->media.disks.push_back(disk); target->media.disks.push_back(disk);
continue; continue;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::AmstradCPC { namespace Analyser::Static::AmstradCPC {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -20,11 +20,21 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
Model model = Model::CPC464; Model model = Model::CPC464;
std::string loading_command; std::string loading_command;
Target() : Analyser::Static::Target(Machine::AmstradCPC) { ReflectableEnum(CRTCType, Type0, Type1, Type2, Type3);
if(needs_declare()) { CRTCType crtc_type = CRTCType::Type2;
DeclareField(model);
AnnounceEnum(Model); // This is used internally for testing; it therefore isn't exposed reflectively.
} bool catch_ssm_codes = false;
Target() : Analyser::Static::Target(Machine::AmstradCPC) {}
private:
friend Reflection::StructImpl<Target>;
void declare_fields() {
DeclareField(model);
DeclareField(crtc_type);
AnnounceEnum(Model);
AnnounceEnum(CRTCType);
} }
}; };

View File

@@ -9,7 +9,12 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include "Target.hpp" #include "Target.hpp"
Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
auto target = std::make_unique<Target>(); auto target = std::make_unique<Target>();
target->media = media; target->media = media;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::AppleII { namespace Analyser::Static::AppleII {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -34,18 +34,26 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
Model model = Model::IIe; Model model = Model::IIe;
DiskController disk_controller = DiskController::None; DiskController disk_controller = DiskController::None;
SCSIController scsi_controller = SCSIController::None; SCSIController scsi_controller = SCSIController::None;
bool has_mockingboard = true;
Target() : Analyser::Static::Target(Machine::AppleII) { Target() : Analyser::Static::Target(Machine::AppleII) {}
if(needs_declare()) {
DeclareField(model);
DeclareField(disk_controller);
DeclareField(scsi_controller);
AnnounceEnum(Model); private:
AnnounceEnum(DiskController); friend Reflection::StructImpl<Target>;
AnnounceEnum(SCSIController); void declare_fields() {
} DeclareField(model);
DeclareField(disk_controller);
DeclareField(scsi_controller);
DeclareField(has_mockingboard);
AnnounceEnum(Model);
AnnounceEnum(DiskController);
AnnounceEnum(SCSIController);
} }
}; };
constexpr bool is_iie(const Target::Model model) {
return model == Target::Model::IIe || model == Target::Model::EnhancedIIe;
}
} }

View File

@@ -9,7 +9,12 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include "Target.hpp" #include "Target.hpp"
Analyser::Static::TargetList Analyser::Static::AppleIIgs::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::AppleIIgs::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
auto target = std::make_unique<Target>(); auto target = std::make_unique<Target>();
target->media = media; target->media = media;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::AppleIIgs { namespace Analyser::Static::AppleIIgs {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -29,13 +29,15 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
Model model = Model::ROM01; Model model = Model::ROM01;
MemoryModel memory_model = MemoryModel::EightMB; MemoryModel memory_model = MemoryModel::EightMB;
Target() : Analyser::Static::Target(Machine::AppleIIgs) { Target() : Analyser::Static::Target(Machine::AppleIIgs) {}
if(needs_declare()) {
DeclareField(model); private:
DeclareField(memory_model); friend Reflection::StructImpl<Target>;
AnnounceEnum(Model); void declare_fields() {
AnnounceEnum(MemoryModel); DeclareField(model);
} DeclareField(memory_model);
AnnounceEnum(Model);
AnnounceEnum(MemoryModel);
} }
}; };

View File

@@ -33,11 +33,13 @@ static void DeterminePagingFor2kCartridge(Target &target, const Storage::Cartrid
// Assume that any kind of store that looks likely to be intended for large amounts of memory implies // Assume that any kind of store that looks likely to be intended for large amounts of memory implies
// large amounts of memory. // large amounts of memory.
bool has_wide_area_store = false; bool has_wide_area_store = false;
for(std::map<uint16_t, Analyser::Static::MOS6502::Instruction>::value_type &entry : high_location_disassembly.instructions_by_address) { for(const auto &entry : high_location_disassembly.instructions_by_address) {
using Instruction = Analyser::Static::MOS6502::Instruction;
if(entry.second.operation == Analyser::Static::MOS6502::Instruction::STA) { if(entry.second.operation == Analyser::Static::MOS6502::Instruction::STA) {
has_wide_area_store |= entry.second.addressing_mode == Analyser::Static::MOS6502::Instruction::Indirect; has_wide_area_store |=
has_wide_area_store |= entry.second.addressing_mode == Analyser::Static::MOS6502::Instruction::IndexedIndirectX; entry.second.addressing_mode == Instruction::Indirect ||
has_wide_area_store |= entry.second.addressing_mode == Analyser::Static::MOS6502::Instruction::IndirectIndexedY; entry.second.addressing_mode == Instruction::IndexedIndirectX ||
entry.second.addressing_mode == Instruction::IndirectIndexedY;
if(has_wide_area_store) break; if(has_wide_area_store) break;
} }
@@ -50,13 +52,21 @@ static void DeterminePagingFor2kCartridge(Target &target, const Storage::Cartrid
if(has_wide_area_store) target.paging_model = Target::PagingModel::CommaVid; if(has_wide_area_store) target.paging_model = Target::PagingModel::CommaVid;
} }
static void DeterminePagingFor8kCartridge(Target &target, const Storage::Cartridge::Cartridge::Segment &segment, const Analyser::Static::MOS6502::Disassembly &disassembly) { static void DeterminePagingFor8kCartridge(
Target &target,
const Storage::Cartridge::Cartridge::Segment &segment,
const Analyser::Static::MOS6502::Disassembly &disassembly
) {
// Activision stack titles have their vectors at the top of the low 4k, not the top, and // Activision stack titles have their vectors at the top of the low 4k, not the top, and
// always list 0xf000 as both vectors; they do not repeat them, and, inexplicably, they all // always list 0xf000 as both vectors; they do not repeat them, and, inexplicably, they all
// issue an SEI as their first instruction (maybe some sort of relic of the development environment?). // issue an SEI as their first instruction (maybe some sort of relic of the development environment?).
if( if(
segment.data[4095] == 0xf0 && segment.data[4093] == 0xf0 && segment.data[4094] == 0x00 && segment.data[4092] == 0x00 && segment.data[4095] == 0xf0 && segment.data[4093] == 0xf0 &&
(segment.data[8191] != 0xf0 || segment.data[8189] != 0xf0 || segment.data[8190] != 0x00 || segment.data[8188] != 0x00) && segment.data[4094] == 0x00 && segment.data[4092] == 0x00 &&
(
segment.data[8191] != 0xf0 || segment.data[8189] != 0xf0 ||
segment.data[8190] != 0x00 || segment.data[8188] != 0x00
) &&
segment.data[0] == 0x78 segment.data[0] == 0x78
) { ) {
target.paging_model = Target::PagingModel::ActivisionStack; target.paging_model = Target::PagingModel::ActivisionStack;
@@ -88,7 +98,11 @@ static void DeterminePagingFor8kCartridge(Target &target, const Storage::Cartrid
else if(tigervision_access_count > atari_access_count) target.paging_model = Target::PagingModel::Tigervision; else if(tigervision_access_count > atari_access_count) target.paging_model = Target::PagingModel::Tigervision;
} }
static void DeterminePagingFor16kCartridge(Target &target, const Storage::Cartridge::Cartridge::Segment &, const Analyser::Static::MOS6502::Disassembly &disassembly) { static void DeterminePagingFor16kCartridge(
Target &target,
const Storage::Cartridge::Cartridge::Segment &,
const Analyser::Static::MOS6502::Disassembly &disassembly
) {
// Make an assumption that this is the Atari paging model. // Make an assumption that this is the Atari paging model.
target.paging_model = Target::PagingModel::Atari16k; target.paging_model = Target::PagingModel::Atari16k;
@@ -108,7 +122,11 @@ static void DeterminePagingFor16kCartridge(Target &target, const Storage::Cartri
if(mnetwork_access_count > atari_access_count) target.paging_model = Target::PagingModel::MNetwork; if(mnetwork_access_count > atari_access_count) target.paging_model = Target::PagingModel::MNetwork;
} }
static void DeterminePagingFor64kCartridge(Target &target, const Storage::Cartridge::Cartridge::Segment &, const Analyser::Static::MOS6502::Disassembly &disassembly) { static void DeterminePagingFor64kCartridge(
Target &target,
const Storage::Cartridge::Cartridge::Segment &,
const Analyser::Static::MOS6502::Disassembly &disassembly
) {
// Make an assumption that this is a Tigervision if there is a write to 3F. // Make an assumption that this is a Tigervision if there is a write to 3F.
target.paging_model = target.paging_model =
(disassembly.external_stores.find(0x3f) != disassembly.external_stores.end()) ? (disassembly.external_stores.find(0x3f) != disassembly.external_stores.end()) ?
@@ -121,8 +139,12 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
return; return;
} }
const uint16_t entry_address = uint16_t(segment.data[segment.data.size() - 4] | (segment.data[segment.data.size() - 3] << 8)); const auto word = [](const uint8_t low, const uint8_t high) {
const uint16_t break_address = uint16_t(segment.data[segment.data.size() - 2] | (segment.data[segment.data.size() - 1] << 8)); return uint16_t(low | (high << 8));
};
const auto entry_address = word(segment.data[segment.data.size() - 4], segment.data[segment.data.size() - 3]);
const auto break_address = word(segment.data[segment.data.size() - 2], segment.data[segment.data.size() - 1]);
std::function<std::size_t(uint16_t address)> address_mapper = [](uint16_t address) { std::function<std::size_t(uint16_t address)> address_mapper = [](uint16_t address) {
if(!(address & 0x1000)) return size_t(-1); if(!(address & 0x1000)) return size_t(-1);
@@ -130,27 +152,16 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
}; };
const std::vector<uint8_t> final_4k(segment.data.end() - 4096, segment.data.end()); const std::vector<uint8_t> final_4k(segment.data.end() - 4096, segment.data.end());
Analyser::Static::MOS6502::Disassembly disassembly = Analyser::Static::MOS6502::Disassemble(final_4k, address_mapper, {entry_address, break_address}); const auto disassembly =
Analyser::Static::MOS6502::Disassemble(final_4k, address_mapper, {entry_address, break_address});
switch(segment.data.size()) { switch(segment.data.size()) {
case 8192: case 8192: DeterminePagingFor8kCartridge(target, segment, disassembly); break;
DeterminePagingFor8kCartridge(target, segment, disassembly); case 10495: target.paging_model = Target::PagingModel::Pitfall2; break;
break; case 12288: target.paging_model = Target::PagingModel::CBSRamPlus; break;
case 10495: case 16384: DeterminePagingFor16kCartridge(target, segment, disassembly); break;
target.paging_model = Target::PagingModel::Pitfall2; case 32768: target.paging_model = Target::PagingModel::Atari32k; break;
break; case 65536: DeterminePagingFor64kCartridge(target, segment, disassembly); break;
case 12288:
target.paging_model = Target::PagingModel::CBSRamPlus;
break;
case 16384:
DeterminePagingFor16kCartridge(target, segment, disassembly);
break;
case 32768:
target.paging_model = Target::PagingModel::Atari32k;
break;
case 65536:
DeterminePagingFor64kCartridge(target, segment, disassembly);
break;
default: default:
break; break;
} }
@@ -177,7 +188,12 @@ static void DeterminePagingForCartridge(Target &target, const Storage::Cartridge
} }
} }
Analyser::Static::TargetList Analyser::Static::Atari2600::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Atari2600::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
// TODO: sanity checking; is this image really for an Atari 2600? // TODO: sanity checking; is this image really for an Atari 2600?
auto target = std::make_unique<Target>(); auto target = std::make_unique<Target>();
target->confidence = 0.5; target->confidence = 0.5;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Atari2600 { namespace Analyser::Static::Atari2600 {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -9,7 +9,12 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include "Target.hpp" #include "Target.hpp"
Analyser::Static::TargetList Analyser::Static::AtariST::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::AtariST::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
// This analyser can comprehend disks and mass-storage devices only. // This analyser can comprehend disks and mass-storage devices only.
if(media.disks.empty()) return {}; if(media.disks.empty()) return {};

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::AtariST { namespace Analyser::Static::AtariST {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -20,11 +20,13 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
FourMegabytes); FourMegabytes);
MemorySize memory_size = MemorySize::OneMegabyte; MemorySize memory_size = MemorySize::OneMegabyte;
Target() : Analyser::Static::Target(Machine::AtariST) { Target() : Analyser::Static::Target(Machine::AtariST) {}
if(needs_declare()) {
DeclareField(memory_size); private:
AnnounceEnum(MemorySize); friend Reflection::StructImpl<Target>;
} void declare_fields() {
DeclareField(memory_size);
AnnounceEnum(MemorySize);
} }
}; };

View File

@@ -9,7 +9,7 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
ColecoCartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges) { ColecoCartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges) {
std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> coleco_cartridges; std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> coleco_cartridges;
for(const auto &cartridge : cartridges) { for(const auto &cartridge : cartridges) {
@@ -52,11 +52,20 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
return coleco_cartridges; return coleco_cartridges;
} }
Analyser::Static::TargetList Analyser::Static::Coleco::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Coleco::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
const bool is_confident
) {
TargetList targets; TargetList targets;
auto target = std::make_unique<Target>(Machine::ColecoVision); auto target = std::make_unique<Target>(Machine::ColecoVision);
target->confidence = 1.0f - 1.0f / 32768.0f; target->confidence = 1.0f - 1.0f / 32768.0f;
target->media.cartridges = ColecoCartridgesFrom(media.cartridges); if(is_confident) {
target->media = media;
} else {
target->media.cartridges = ColecoCartridgesFrom(media.cartridges);
}
if(!target->media.empty()) if(!target->media.empty())
targets.push_back(std::move(target)); targets.push_back(std::move(target));
return targets; return targets;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Coleco { namespace Analyser::Static::Coleco {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -14,159 +14,161 @@
#include <limits> #include <limits>
#include <vector> #include <vector>
#include <array> #include <array>
#include <unordered_map>
using namespace Analyser::Static::Commodore; using namespace Analyser::Static::Commodore;
class CommodoreGCRParser: public Storage::Disk::Controller { class CommodoreGCRParser: public Storage::Disk::Controller {
public: public:
CommodoreGCRParser() : Storage::Disk::Controller(4000000), shift_register_(0), track_(1) { CommodoreGCRParser() : Storage::Disk::Controller(4000000), shift_register_(0), track_(1) {
emplace_drive(4000000, 300, 2); emplace_drive(4000000, 300, 2);
set_drive(1); set_drive(1);
get_drive().set_motor_on(true); get_drive().set_motor_on(true);
} }
struct Sector { struct Sector {
uint8_t sector, track; uint8_t sector, track;
std::array<uint8_t, 256> data; std::array<uint8_t, 256> data;
bool header_checksum_matched; bool header_checksum_matched;
bool data_checksum_matched; bool data_checksum_matched;
}; };
/*! /*!
Attempts to read the sector located at @c track and @c sector. Attempts to read the sector located at @c track and @c sector.
@returns a sector if one was found; @c nullptr otherwise. @returns a sector if one was found; @c nullptr otherwise.
*/ */
std::shared_ptr<Sector> sector(uint8_t track, uint8_t sector) { const Sector *sector(const uint8_t track, const uint8_t sector) {
int difference = int(track) - int(track_); int difference = int(track) - int(track_);
track_ = track; track_ = track;
if(difference) { if(difference) {
int direction = difference < 0 ? -1 : 1; const int direction = difference < 0 ? -1 : 1;
difference *= direction; difference *= direction;
for(int c = 0; c < difference; c++) { for(int c = 0; c < difference; c++) {
get_drive().step(Storage::Disk::HeadPosition(direction)); get_drive().step(Storage::Disk::HeadPosition(direction));
}
unsigned int zone = 3;
if(track >= 18) zone = 2;
else if(track >= 25) zone = 1;
else if(track >= 31) zone = 0;
set_expected_bit_length(Storage::Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(zone));
} }
return get_sector(sector); unsigned int zone = 3;
if(track >= 18) zone = 2;
else if(track >= 25) zone = 1;
else if(track >= 31) zone = 0;
set_expected_bit_length(Storage::Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(zone));
} }
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk) { return get_sector(sector);
get_drive().set_disk(disk); }
void set_disk(const std::shared_ptr<Storage::Disk::Disk> &disk) {
get_drive().set_disk(disk);
}
private:
unsigned int shift_register_;
int index_count_;
int bit_count_;
uint8_t track_;
std::unordered_map<uint16_t, std::unique_ptr<Sector>> sector_cache_;
void process_input_bit(const int value) override {
shift_register_ = ((shift_register_ << 1) | unsigned(value)) & 0x3ff;
bit_count_++;
}
unsigned int proceed_to_next_block(const int max_index_count) {
// find GCR lead-in
proceed_to_shift_value(0x3ff);
if(shift_register_ != 0x3ff) return 0xff;
// find end of lead-in
while(shift_register_ == 0x3ff && index_count_ < max_index_count) {
run_for(Cycles(1));
} }
private: // continue for a further nine bits
unsigned int shift_register_; bit_count_ = 0;
int index_count_; while(bit_count_ < 9 && index_count_ < max_index_count) {
int bit_count_; run_for(Cycles(1));
uint8_t track_;
std::shared_ptr<Sector> sector_cache_[65536];
void process_input_bit(int value) {
shift_register_ = ((shift_register_ << 1) | unsigned(value)) & 0x3ff;
bit_count_++;
} }
unsigned int proceed_to_next_block(int max_index_count) { return Storage::Encodings::CommodoreGCR::decoding_from_dectet(shift_register_);
// find GCR lead-in }
proceed_to_shift_value(0x3ff);
if(shift_register_ != 0x3ff) return 0xff;
// find end of lead-in unsigned int get_next_byte() {
while(shift_register_ == 0x3ff && index_count_ < max_index_count) { bit_count_ = 0;
run_for(Cycles(1)); while(bit_count_ < 10) run_for(Cycles(1));
} return Storage::Encodings::CommodoreGCR::decoding_from_dectet(shift_register_);
}
// continue for a further nine bits void proceed_to_shift_value(const unsigned int shift_value) {
bit_count_ = 0; const int max_index_count = index_count_ + 2;
while(bit_count_ < 9 && index_count_ < max_index_count) { while(shift_register_ != shift_value && index_count_ < max_index_count) {
run_for(Cycles(1)); run_for(Cycles(1));
}
return Storage::Encodings::CommodoreGCR::decoding_from_dectet(shift_register_);
} }
}
unsigned int get_next_byte() { void process_index_hole() override {
bit_count_ = 0; index_count_++;
while(bit_count_ < 10) run_for(Cycles(1)); }
return Storage::Encodings::CommodoreGCR::decoding_from_dectet(shift_register_);
const Sector *get_sector(const uint8_t sector) {
const uint16_t sector_address = uint16_t((track_ << 8) | sector);
auto existing = sector_cache_.find(sector_address);
if(existing != sector_cache_.end()) return existing->second.get();
const auto first_sector = get_next_sector();
if(!first_sector) return first_sector;
if(first_sector->sector == sector) return first_sector;
while(true) {
const auto next_sector = get_next_sector();
if(next_sector->sector == first_sector->sector) return nullptr;
if(next_sector->sector == sector) return next_sector;
} }
}
void proceed_to_shift_value(unsigned int shift_value) { const Sector *get_next_sector() {
const int max_index_count = index_count_ + 2; auto sector = std::make_unique<Sector>();
while(shift_register_ != shift_value && index_count_ < max_index_count) { const int max_index_count = index_count_ + 2;
run_for(Cycles(1));
}
}
void process_index_hole() {
index_count_++;
}
std::shared_ptr<Sector> get_sector(uint8_t sector) {
const uint16_t sector_address = uint16_t((track_ << 8) | sector);
if(sector_cache_[sector_address]) return sector_cache_[sector_address];
const std::shared_ptr<Sector> first_sector = get_next_sector();
if(!first_sector) return first_sector;
if(first_sector->sector == sector) return first_sector;
while(index_count_ < max_index_count) {
// look for a sector header
while(1) { while(1) {
const std::shared_ptr<Sector> next_sector = get_next_sector(); if(proceed_to_next_block(max_index_count) == 0x08) break;
if(next_sector->sector == first_sector->sector) return nullptr; if(index_count_ >= max_index_count) return nullptr;
if(next_sector->sector == sector) return next_sector; }
// get sector details, skip if this looks malformed
uint8_t checksum = uint8_t(get_next_byte());
sector->sector = uint8_t(get_next_byte());
sector->track = uint8_t(get_next_byte());
uint8_t disk_id[2];
disk_id[0] = uint8_t(get_next_byte());
disk_id[1] = uint8_t(get_next_byte());
if(checksum != (sector->sector ^ sector->track ^ disk_id[0] ^ disk_id[1])) continue;
// look for the following data
while(1) {
if(proceed_to_next_block(max_index_count) == 0x07) break;
if(index_count_ >= max_index_count) return nullptr;
}
checksum = 0;
for(std::size_t c = 0; c < 256; c++) {
sector->data[c] = uint8_t(get_next_byte());
checksum ^= sector->data[c];
}
if(checksum == get_next_byte()) {
uint16_t sector_address = uint16_t((sector->track << 8) | sector->sector);
auto pair = sector_cache_.emplace(sector_address, std::move(sector));
return pair.first->second.get();
} }
} }
std::shared_ptr<Sector> get_next_sector() { return nullptr;
auto sector = std::make_shared<Sector>(); }
const int max_index_count = index_count_ + 2;
while(index_count_ < max_index_count) {
// look for a sector header
while(1) {
if(proceed_to_next_block(max_index_count) == 0x08) break;
if(index_count_ >= max_index_count) return nullptr;
}
// get sector details, skip if this looks malformed
uint8_t checksum = uint8_t(get_next_byte());
sector->sector = uint8_t(get_next_byte());
sector->track = uint8_t(get_next_byte());
uint8_t disk_id[2];
disk_id[0] = uint8_t(get_next_byte());
disk_id[1] = uint8_t(get_next_byte());
if(checksum != (sector->sector ^ sector->track ^ disk_id[0] ^ disk_id[1])) continue;
// look for the following data
while(1) {
if(proceed_to_next_block(max_index_count) == 0x07) break;
if(index_count_ >= max_index_count) return nullptr;
}
checksum = 0;
for(std::size_t c = 0; c < 256; c++) {
sector->data[c] = uint8_t(get_next_byte());
checksum ^= sector->data[c];
}
if(checksum == get_next_byte()) {
uint16_t sector_address = uint16_t((sector->track << 8) | sector->sector);
sector_cache_[sector_address] = sector;
return sector;
}
}
return nullptr;
}
}; };
std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<Storage::Disk::Disk> &disk) { std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<Storage::Disk::Disk> &disk) {
@@ -174,20 +176,26 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
CommodoreGCRParser parser; CommodoreGCRParser parser;
parser.set_disk(disk); parser.set_disk(disk);
// find any sector whatsoever to establish the current track // Assemble directory.
std::shared_ptr<CommodoreGCRParser::Sector> sector;
// assemble directory
std::vector<uint8_t> directory; std::vector<uint8_t> directory;
uint8_t next_track = 18; uint8_t next_track = 18;
uint8_t next_sector = 1; uint8_t next_sector = 1;
while(1) { directory.reserve(20 * 1024); // Probably more than plenty.
sector = parser.sector(next_track, next_sector); std::set<std::pair<uint8_t, uint8_t>> visited;
while(true) {
// Don't be fooled by disks that are encoded with a looping directory.
const auto key = std::make_pair(next_track, next_sector);
if(visited.find(key) != visited.end()) break;
visited.insert(key);
// Append sector to directory and follow next link.
const auto sector = parser.sector(next_track, next_sector);
if(!sector) break; if(!sector) break;
directory.insert(directory.end(), sector->data.begin(), sector->data.end()); directory.insert(directory.end(), sector->data.begin(), sector->data.end());
next_track = sector->data[0]; next_track = sector->data[0];
next_sector = sector->data[1]; next_sector = sector->data[1];
// Check for end-of-directory.
if(!next_track) break; if(!next_track) break;
} }
@@ -216,24 +224,36 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
} }
new_file.name = Storage::Data::Commodore::petscii_from_bytes(&new_file.raw_name[0], 16, false); new_file.name = Storage::Data::Commodore::petscii_from_bytes(&new_file.raw_name[0], 16, false);
std::size_t number_of_sectors = size_t(directory[header_pointer + 0x1e]) + (size_t(directory[header_pointer + 0x1f]) << 8); const std::size_t number_of_sectors =
new_file.data.reserve((number_of_sectors - 1) * 254 + 252); size_t(directory[header_pointer + 0x1e]) +
(size_t(directory[header_pointer + 0x1f]) << 8);
if(number_of_sectors) {
new_file.data.reserve((number_of_sectors - 1) * 254 + 252);
bool is_first_sector = true; bool is_first_sector = true;
while(next_track) { while(next_track) {
sector = parser.sector(next_track, next_sector); const auto sector = parser.sector(next_track, next_sector);
if(!sector) break; if(!sector) break;
next_track = sector->data[0]; next_track = sector->data[0];
next_sector = sector->data[1]; next_sector = sector->data[1];
if(is_first_sector) new_file.starting_address = uint16_t(sector->data[2]) | uint16_t(sector->data[3] << 8); if(is_first_sector) new_file.starting_address = uint16_t(sector->data[2]) | uint16_t(sector->data[3] << 8);
if(next_track) if(next_track)
new_file.data.insert(new_file.data.end(), sector->data.begin() + (is_first_sector ? 4 : 2), sector->data.end()); new_file.data.insert(
else new_file.data.end(),
new_file.data.insert(new_file.data.end(), sector->data.begin() + 2, sector->data.begin() + next_sector); sector->data.begin() + (is_first_sector ? 4 : 2),
sector->data.end()
);
else
new_file.data.insert(
new_file.data.end(),
sector->data.begin() + 2,
sector->data.begin() + next_sector
);
is_first_sector = false; is_first_sector = false;
}
} }
if(!next_track) files.push_back(new_file); if(!next_track) files.push_back(new_file);

View File

@@ -15,6 +15,6 @@
namespace Analyser::Static::Commodore { namespace Analyser::Static::Commodore {
std::vector<File> GetFiles(const std::shared_ptr<Storage::Disk::Disk> &disk); std::vector<File> GetFiles(const std::shared_ptr<Storage::Disk::Disk> &);
} }

View File

@@ -1,47 +0,0 @@
//
// File.cpp
// Clock Signal
//
// Created by Thomas Harte on 10/09/2016.
// Copyright 2016 Thomas Harte. All rights reserved.
//
#include "File.hpp"
bool Analyser::Static::Commodore::File::is_basic() {
// BASIC files are always relocatable (?)
if(type != File::RelocatableProgram) return false;
uint16_t line_address = starting_address;
int line_number = -1;
// decide whether this is a BASIC file based on the proposition that:
// (1) they're always relocatable; and
// (2) they have a per-line structure of:
// [4 bytes: address of start of next line]
// [4 bytes: this line number]
// ... null-terminated code ...
// (with a next line address of 0000 indicating end of program)
while(1) {
if(size_t(line_address - starting_address) >= data.size() + 2) break;
uint16_t next_line_address = data[line_address - starting_address];
next_line_address |= data[line_address - starting_address + 1] << 8;
if(!next_line_address) {
return true;
}
if(next_line_address < line_address + 5) break;
if(size_t(line_address - starting_address) >= data.size() + 5) break;
uint16_t next_line_number = data[line_address - starting_address + 2];
next_line_number |= data[line_address - starting_address + 3] << 8;
if(next_line_number <= line_number) break;
line_number = uint16_t(next_line_number);
line_address = next_line_address;
}
return false;
}

View File

@@ -29,8 +29,6 @@ struct File {
Relative Relative
} type; } type;
std::vector<uint8_t> data; std::vector<uint8_t> data;
bool is_basic();
}; };
} }

View File

@@ -15,23 +15,30 @@
#include "../../../Storage/Cartridge/Encodings/CommodoreROM.hpp" #include "../../../Storage/Cartridge/Encodings/CommodoreROM.hpp"
#include "../../../Outputs/Log.hpp" #include "../../../Outputs/Log.hpp"
#include "../Disassembler/6502.hpp"
#include "../Disassembler/AddressMapper.hpp"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <optional>
#include <sstream> #include <sstream>
#include <unordered_set>
using namespace Analyser::Static::Commodore; using namespace Analyser::Static::Commodore;
static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> namespace {
Vic20CartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges) {
std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
Vic20CartridgesFrom(const std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges) {
std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> vic20_cartridges; std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>> vic20_cartridges;
for(const auto &cartridge : cartridges) { for(const auto &cartridge : cartridges) {
const auto &segments = cartridge->get_segments(); const auto &segments = cartridge->get_segments();
// only one mapped item is allowed // Only one mapped item is allowed ...
if(segments.size() != 1) continue; if(segments.size() != 1) continue;
// which must be 16 kb in size // ... which must be 16 kb in size.
Storage::Cartridge::Cartridge::Segment segment = segments.front(); Storage::Cartridge::Cartridge::Segment segment = segments.front();
if(segment.start_address != 0xa000) continue; if(segment.start_address != 0xa000) continue;
if(!Storage::Cartridge::Encodings::CommodoreROM::isROM(segment.data)) continue; if(!Storage::Cartridge::Encodings::CommodoreROM::isROM(segment.data)) continue;
@@ -39,126 +46,313 @@ static std::vector<std::shared_ptr<Storage::Cartridge::Cartridge>>
vic20_cartridges.push_back(cartridge); vic20_cartridges.push_back(cartridge);
} }
// TODO: other machines?
return vic20_cartridges; return vic20_cartridges;
} }
Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType) { struct BASICAnalysis {
TargetList destination; enum class Version {
NotBASIC,
BASIC2,
BASIC4,
BASIC3_5,
} minimum_version = Version::NotBASIC;
std::vector<uint16_t> machine_code_addresses;
};
auto target = std::make_unique<Target>(); std::optional<BASICAnalysis> analyse(const File &file) {
target->machine = Machine::Vic20; // TODO: machine estimation BASICAnalysis analysis;
target->confidence = 0.5; // TODO: a proper estimation
switch(file.type) {
// For 'program' types, proceed with analysis below.
case File::RelocatableProgram:
case File::NonRelocatableProgram:
break;
// For sequential and relative data stop right now.
case File::DataSequence:
case File::Relative:
return std::nullopt;
// For user data, try decoding from the starting point.
case File::User:
analysis.machine_code_addresses.push_back(file.starting_address);
return analysis;
}
// Don't form an opinion if file is empty.
if(file.data.empty()) {
return std::nullopt;
}
uint16_t line_address = file.starting_address;
// int previous_line_number = -1;
const auto byte = [&](uint16_t address) {
return file.data[address - file.starting_address];
};
const auto word = [&](uint16_t address) {
return uint16_t(byte(address) | byte(address + 1) << 8);
};
// BASIC programs have a per-line structure of:
// [2 bytes: address of start of next line]
// [2 bytes: this line number]
// ... null-terminated code ...
// (with a next line address of 0000 indicating end of program)
//
// If a SYS is encountered that jumps into the BASIC program then treat that as
// a machine code entry point.
std::unordered_set<uint16_t> visited_lines;
while(true) {
// Analysis has failed if there isn't at least one complete BASIC line from here.
// Fall back on guessing the start address as a machine code entrypoint.
if(size_t(line_address - file.starting_address) + 5 >= file.data.size() || line_address < file.starting_address) {
analysis.machine_code_addresses.push_back(file.starting_address);
break;
}
const auto next_line_address = word(line_address);
// const auto line_number = word(line_address + 2);
uint16_t code = line_address + 4;
const auto next = [&]() -> uint8_t {
if(code >= file.starting_address + file.data.size()) {
return 0;
}
return byte(code++);
};
// TODO: sanity check on apparent line contents.
// TODO: observe token set (and possibly parameters?) to guess BASIC version.
while(true) {
const auto token = next();
if(!token || token == 0x8f) break;
switch(token) {
case 0x9e: { // SYS; parse following ASCII argument.
uint16_t address = 0;
while(true) {
const auto c = next();
if(c < '0' || c > '9') {
break;
}
address = (address * 10) + (c - '0');
};
analysis.machine_code_addresses.push_back(address);
} break;
}
}
// Exit if a formal end of the program has been declared or if, as some copy protections do,
// the linked list of line contents has been made circular.
visited_lines.insert(line_address);
if(!next_line_address || visited_lines.find(next_line_address) != visited_lines.end()) {
break;
}
// previous_line_number = line_number;
line_address = next_line_address;
}
return analysis;
}
template <typename TargetT>
void set_loading_command(TargetT &target) {
if(target.media.disks.empty()) {
target.loading_command = "LOAD\"\",1,1\nRUN\n";
} else {
target.loading_command = "LOAD\"*\",8,1\nRUN\n";
}
}
bool obviously_uses_ted(const File &file) {
const auto analysis = analyse(file);
if(!analysis) return false;
// Disassemble.
const auto disassembly = Analyser::Static::MOS6502::Disassemble(
file.data,
Analyser::Static::Disassembler::OffsetMapper(file.starting_address),
analysis->machine_code_addresses
);
// If FF3E or FF3F is touched, this is for the +4.
// TODO: probably require a very early touch.
for(const auto address: {0xff3e, 0xff3f}) {
for(const auto &collection: {
disassembly.external_loads,
disassembly.external_stores,
disassembly.external_modifies
}) {
if(collection.find(uint16_t(address)) != collection.end()) {
return true;
}
}
}
return false;
}
struct FileAnalysis {
int device = 0; int device = 0;
std::vector<File> files; std::vector<File> files;
bool is_disk = false; bool is_disk = false;
Analyser::Static::Media media;
};
// strip out inappropriate cartridges template <TargetPlatform::Type platform>
target->media.cartridges = Vic20CartridgesFrom(media.cartridges); FileAnalysis analyse_files(const Analyser::Static::Media &media) {
FileAnalysis analysis;
// check disks // Find all valid Commodore files on disks.
for(auto &disk : media.disks) { for(auto &disk : media.disks) {
std::vector<File> disk_files = GetFiles(disk); std::vector<File> disk_files = GetFiles(disk);
if(!disk_files.empty()) { if(!disk_files.empty()) {
is_disk = true; analysis.is_disk = true;
files.insert(files.end(), disk_files.begin(), disk_files.end()); analysis.files.insert(
target->media.disks.push_back(disk); analysis.files.end(),
if(!device) device = 8; std::make_move_iterator(disk_files.begin()),
std::make_move_iterator(disk_files.end())
);
analysis.media.disks.push_back(disk);
if(!analysis.device) analysis.device = 8;
} }
} }
// check tapes // Find all valid Commodore files on tapes.
for(auto &tape : media.tapes) { for(auto &tape : media.tapes) {
std::vector<File> tape_files = GetFiles(tape); auto serialiser = tape->serialiser();
tape->reset(); std::vector<File> tape_files = GetFiles(*serialiser, platform);
if(!tape_files.empty()) { if(!tape_files.empty()) {
files.insert(files.end(), tape_files.begin(), tape_files.end()); analysis.files.insert(
target->media.tapes.push_back(tape); analysis.files.end(),
if(!device) device = 1; std::make_move_iterator(tape_files.begin()),
std::make_move_iterator(tape_files.end())
);
analysis.media.tapes.push_back(tape);
if(!analysis.device) analysis.device = 1;
} }
} }
if(!files.empty()) { return analysis;
auto memory_model = Target::MemoryModel::Unexpanded; }
std::ostringstream string_stream;
string_stream << "LOAD\"" << (is_disk ? "*" : "") << "\"," << device << ","; std::string loading_command(const FileAnalysis &file_analysis) {
if(files.front().is_basic()) { std::ostringstream string_stream;
string_stream << "0"; string_stream << "LOAD\"" << (file_analysis.is_disk ? "*" : "") << "\"," << file_analysis.device;
} else {
string_stream << "1"; const auto analysis = analyse(file_analysis.files[0]);
if(analysis && !analysis->machine_code_addresses.empty()) {
string_stream << ",1";
}
string_stream << "\nRUN\n";
return string_stream.str();
}
std::pair<TargetPlatform::IntType, std::optional<Vic20Target::MemoryModel>>
analyse_starting_address(uint16_t starting_address) {
switch(starting_address) {
case 0x1c01:
// TODO: assume C128.
default:
Log::Logger<Log::Source::CommodoreStaticAnalyser>().error().append(
"Unrecognised loading address for Commodore program: %04x", starting_address);
[[fallthrough]];
case 0x1001:
return std::make_pair(TargetPlatform::Vic20 | TargetPlatform::Plus4, Vic20Target::MemoryModel::Unexpanded);
case 0x1201: return std::make_pair(TargetPlatform::Vic20, Vic20Target::MemoryModel::ThirtyTwoKB);
case 0x0401: return std::make_pair(TargetPlatform::Vic20, Vic20Target::MemoryModel::EightKB);
case 0x0801: return std::make_pair(TargetPlatform::C64, std::nullopt);
}
}
template <TargetPlatform::IntType platform>
std::unique_ptr<Analyser::Static::Target> get_target(
const Analyser::Static::Media &media,
const std::string &file_name,
bool is_confident
);
template<>
std::unique_ptr<Analyser::Static::Target> get_target<TargetPlatform::Plus4>(
const Analyser::Static::Media &media,
const std::string &,
bool is_confident
) {
auto target = std::make_unique<Plus4Target>();
if(is_confident) {
target->media = media;
set_loading_command(*target);
} else {
const auto files = analyse_files<TargetPlatform::Plus4>(media);
if(!files.files.empty()) {
target->loading_command = loading_command(files);
} }
string_stream << "\nRUN\n"; target->media.disks = media.disks;
target->loading_command = string_stream.str(); target->media.tapes = media.tapes;
// make a first guess based on loading address
switch(files.front().starting_address) {
default:
Log::Logger<Log::Source::CommodoreStaticAnalyser>().error().append("Unrecognised loading address for Commodore program: %04x", files.front().starting_address);
[[fallthrough]];
case 0x1001:
memory_model = Target::MemoryModel::Unexpanded;
break;
case 0x1201:
memory_model = Target::MemoryModel::ThirtyTwoKB;
break;
case 0x0401:
memory_model = Target::MemoryModel::EightKB;
break;
}
target->set_memory_model(memory_model);
// General approach: increase memory size conservatively such that the largest file found will fit.
// for(File &file : files) {
// std::size_t file_size = file.data.size();
// bool is_basic = file.is_basic();
/*if(is_basic)
{
// BASIC files may be relocated, so the only limit is size.
//
// An unexpanded machine has 3583 bytes free for BASIC;
// a 3kb expanded machine has 6655 bytes free.
if(file_size > 6655)
target->vic20.memory_model = Vic20MemoryModel::ThirtyTwoKB;
else if(target->vic20.memory_model == Vic20MemoryModel::Unexpanded && file_size > 3583)
target->vic20.memory_model = Vic20MemoryModel::EightKB;
}
else
{*/
// if(!file.type == File::NonRelocatableProgram)
// {
// Non-BASIC files may be relocatable but, if so, by what logic?
// Given that this is unknown, take starting address as literal
// and check against memory windows.
//
// (ignoring colour memory...)
// An unexpanded Vic has memory between 0x0000 and 0x0400; and between 0x1000 and 0x2000.
// A 3kb expanded Vic fills in the gap and has memory between 0x0000 and 0x2000.
// A 32kb expanded Vic has memory in the entire low 32kb.
// uint16_t starting_address = file.starting_address;
// If anything above the 8kb mark is touched, mark as a 32kb machine; otherwise if the
// region 0x0400 to 0x1000 is touched and this is an unexpanded machine, mark as 3kb.
// if(starting_address + file_size > 0x2000)
// target->memory_model = Target::MemoryModel::ThirtyTwoKB;
// else if(target->memory_model == Target::MemoryModel::Unexpanded && !(starting_address >= 0x1000 || starting_address+file_size < 0x0400))
// target->memory_model = Target::MemoryModel::ThirtyTwoKB;
// }
// }
} }
// Attach a 1541 if there are any disks here.
target->has_c1541 = !target->media.disks.empty();
return std::move(target);
}
template<>
std::unique_ptr<Analyser::Static::Target> get_target<TargetPlatform::Vic20>(
const Analyser::Static::Media &media,
const std::string &file_name,
bool is_confident
) {
auto target = std::make_unique<Vic20Target>();
const auto files = analyse_files<TargetPlatform::Vic20>(media);
if(!files.files.empty()) {
target->loading_command = loading_command(files);
const auto model = analyse_starting_address(files.files[0].starting_address);
if(model.second.has_value()) {
target->set_memory_model(*model.second);
}
}
if(is_confident) {
target->media = media;
set_loading_command(*target);
} else {
// Strip out inappropriate cartridges but retain all tapes and disks.
target->media.cartridges = Vic20CartridgesFrom(media.cartridges);
target->media.disks = media.disks;
target->media.tapes = media.tapes;
}
for(const auto &file : files.files) {
// The Vic-20 never has RAM after 0x8000.
if(file.ending_address >= 0x8000) {
return nullptr;
}
if(obviously_uses_ted(file)) {
return nullptr;
}
}
// Inspect filename for configuration hints.
if(!target->media.empty()) { if(!target->media.empty()) {
// Inspect filename for configuration hints. using Region = Analyser::Static::Commodore::Vic20Target::Region;
std::string lowercase_name = file_name; std::string lowercase_name = file_name;
std::transform(lowercase_name.begin(), lowercase_name.end(), lowercase_name.begin(), ::tolower); std::transform(lowercase_name.begin(), lowercase_name.end(), lowercase_name.begin(), ::tolower);
// Hint 1: 'ntsc' anywhere in the name implies America. // Hint 1: 'ntsc' anywhere in the name implies America.
if(lowercase_name.find("ntsc") != std::string::npos) { if(lowercase_name.find("ntsc") != std::string::npos) {
target->region = Analyser::Static::Commodore::Target::Region::American; target->region = Region::American;
} }
// Potential additional hints: check for TheC64 tags. // Potential additional hints: check for TheC64 tags; these are Vic-20 exclusive.
auto final_underscore = lowercase_name.find_last_of('_'); auto final_underscore = lowercase_name.find_last_of('_');
if(final_underscore != std::string::npos) { if(final_underscore != std::string::npos) {
auto iterator = lowercase_name.begin() + ssize_t(final_underscore) + 1; auto iterator = lowercase_name.begin() + ssize_t(final_underscore) + 1;
@@ -180,10 +374,10 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(const Media
target->enabled_ram.bank3 |= !strcmp(next_tag, "b3"); target->enabled_ram.bank3 |= !strcmp(next_tag, "b3");
target->enabled_ram.bank5 |= !strcmp(next_tag, "b5"); target->enabled_ram.bank5 |= !strcmp(next_tag, "b5");
if(!strcmp(next_tag, "tn")) { // i.e. NTSC. if(!strcmp(next_tag, "tn")) { // i.e. NTSC.
target->region = Analyser::Static::Commodore::Target::Region::American; target->region = Region::American;
} }
if(!strcmp(next_tag, "tp")) { // i.e. PAL. if(!strcmp(next_tag, "tp")) { // i.e. PAL.
target->region = Analyser::Static::Commodore::Target::Region::European; target->region = Region::European;
} }
// Unhandled: // Unhandled:
@@ -194,11 +388,36 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(const Media
// RO: this disk image should be treated as read-only. // RO: this disk image should be treated as read-only.
} }
} }
}
// Attach a 1540 if there are any disks here. // Attach a 1540 if there are any disks here.
target->has_c1540 = !target->media.disks.empty(); target->has_c1540 = !target->media.disks.empty();
return std::move(target);
}
destination.push_back(std::move(target)); }
Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(
const Media &media,
const std::string &file_name,
TargetPlatform::IntType platforms,
bool is_confident
) {
TargetList destination;
if(platforms & TargetPlatform::Vic20) {
auto vic20 = get_target<TargetPlatform::Vic20>(media, file_name, is_confident);
if(vic20) {
destination.push_back(std::move(vic20));
}
}
if(platforms & TargetPlatform::Plus4) {
auto plus4 = get_target<TargetPlatform::Plus4>(media, file_name, is_confident);
if(plus4) {
destination.push_back(std::move(plus4));
}
} }
return destination; return destination;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Commodore { namespace Analyser::Static::Commodore {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -12,21 +12,21 @@
using namespace Analyser::Static::Commodore; using namespace Analyser::Static::Commodore;
std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape) { std::vector<File> Analyser::Static::Commodore::GetFiles(Storage::Tape::TapeSerialiser &serialiser, TargetPlatform::Type type) {
Storage::Tape::Commodore::Parser parser; Storage::Tape::Commodore::Parser parser(type);
std::vector<File> file_list; std::vector<File> file_list;
std::unique_ptr<Storage::Tape::Commodore::Header> header = parser.get_next_header(tape); std::unique_ptr<Storage::Tape::Commodore::Header> header = parser.get_next_header(serialiser);
while(!tape->is_at_end()) { while(!serialiser.is_at_end()) {
if(!header) { if(!header) {
header = parser.get_next_header(tape); header = parser.get_next_header(serialiser);
continue; continue;
} }
switch(header->type) { switch(header->type) {
case Storage::Tape::Commodore::Header::DataSequenceHeader: { case Storage::Tape::Commodore::Header::DataSequenceHeader: {
File new_file; File &new_file = file_list.emplace_back();
new_file.name = header->name; new_file.name = header->name;
new_file.raw_name = header->raw_name; new_file.raw_name = header->raw_name;
new_file.starting_address = header->starting_address; new_file.starting_address = header->starting_address;
@@ -34,38 +34,36 @@ std::vector<File> Analyser::Static::Commodore::GetFiles(const std::shared_ptr<St
new_file.type = File::DataSequence; new_file.type = File::DataSequence;
new_file.data.swap(header->data); new_file.data.swap(header->data);
while(!tape->is_at_end()) { while(!serialiser.is_at_end()) {
header = parser.get_next_header(tape); header = parser.get_next_header(serialiser);
if(!header) continue; if(!header) continue;
if(header->type != Storage::Tape::Commodore::Header::DataBlock) break; if(header->type != Storage::Tape::Commodore::Header::DataBlock) break;
std::copy(header->data.begin(), header->data.end(), std::back_inserter(new_file.data)); std::copy(header->data.begin(), header->data.end(), std::back_inserter(new_file.data));
} }
file_list.push_back(new_file);
} }
break; break;
case Storage::Tape::Commodore::Header::RelocatableProgram: case Storage::Tape::Commodore::Header::RelocatableProgram:
case Storage::Tape::Commodore::Header::NonRelocatableProgram: { case Storage::Tape::Commodore::Header::NonRelocatableProgram: {
std::unique_ptr<Storage::Tape::Commodore::Data> data = parser.get_next_data(tape); std::unique_ptr<Storage::Tape::Commodore::Data> data = parser.get_next_data(serialiser);
if(data) { if(data) {
File new_file; File &new_file = file_list.emplace_back();
new_file.name = header->name; new_file.name = header->name;
new_file.raw_name = header->raw_name; new_file.raw_name = header->raw_name;
new_file.starting_address = header->starting_address; new_file.starting_address = header->starting_address;
new_file.ending_address = header->ending_address; new_file.ending_address = header->ending_address;
new_file.data.swap(data->data); new_file.data.swap(data->data);
new_file.type = (header->type == Storage::Tape::Commodore::Header::RelocatableProgram) ? File::RelocatableProgram : File::NonRelocatableProgram; new_file.type =
header->type == Storage::Tape::Commodore::Header::RelocatableProgram
file_list.push_back(new_file); ? File::RelocatableProgram : File::NonRelocatableProgram;
} }
header = parser.get_next_header(tape); header = parser.get_next_header(serialiser);
} }
break; break;
default: default:
header = parser.get_next_header(tape); header = parser.get_next_header(serialiser);
break; break;
} }
} }

View File

@@ -9,10 +9,11 @@
#pragma once #pragma once
#include "../../../Storage/Tape/Tape.hpp" #include "../../../Storage/Tape/Tape.hpp"
#include "../../../Storage/TargetPlatforms.hpp"
#include "File.hpp" #include "File.hpp"
namespace Analyser::Static::Commodore { namespace Analyser::Static::Commodore {
std::vector<File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape); std::vector<File> GetFiles(Storage::Tape::TapeSerialiser &, TargetPlatform::Type);
} }

View File

@@ -15,7 +15,21 @@
namespace Analyser::Static::Commodore { namespace Analyser::Static::Commodore {
struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Target> { struct Plus4Target: public Analyser::Static::Target, public Reflection::StructImpl<Plus4Target> {
// TODO: region, etc.
std::string loading_command;
bool has_c1541 = false;
Plus4Target() : Analyser::Static::Target(Machine::Plus4) {}
private:
friend Reflection::StructImpl<Plus4Target>;
void declare_fields() {
DeclareField(has_c1541);
}
};
struct Vic20Target: public Analyser::Static::Target, public Reflection::StructImpl<Vic20Target> {
enum class MemoryModel { enum class MemoryModel {
Unexpanded, Unexpanded,
EightKB, EightKB,
@@ -54,17 +68,19 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
bool has_c1540 = false; bool has_c1540 = false;
std::string loading_command; std::string loading_command;
Target() : Analyser::Static::Target(Machine::Vic20) { Vic20Target() : Analyser::Static::Target(Machine::Vic20) {}
if(needs_declare()) {
DeclareField(enabled_ram.bank0); private:
DeclareField(enabled_ram.bank1); friend Reflection::StructImpl<Vic20Target>;
DeclareField(enabled_ram.bank2); void declare_fields() {
DeclareField(enabled_ram.bank3); DeclareField(enabled_ram.bank0);
DeclareField(enabled_ram.bank5); DeclareField(enabled_ram.bank1);
DeclareField(region); DeclareField(enabled_ram.bank2);
DeclareField(has_c1540); DeclareField(enabled_ram.bank3);
AnnounceEnum(Region); DeclareField(enabled_ram.bank5);
} DeclareField(region);
DeclareField(has_c1540);
AnnounceEnum(Region);
} }
}; };

View File

@@ -17,7 +17,12 @@ using PartialDisassembly = Analyser::Static::Disassembly::PartialDisassembly<Dis
struct MOS6502Disassembler { struct MOS6502Disassembler {
static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<uint8_t> &memory, const std::function<std::size_t(uint16_t)> &address_mapper, uint16_t entry_point) { static void AddToDisassembly(
PartialDisassembly &disassembly,
const std::vector<uint8_t> &memory,
const std::function<std::size_t(uint16_t)> &address_mapper,
uint16_t entry_point
) {
disassembly.disassembly.internal_calls.insert(entry_point); disassembly.disassembly.internal_calls.insert(entry_point);
uint16_t address = entry_point; uint16_t address = entry_point;
while(true) { while(true) {
@@ -75,23 +80,25 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
} }
// Decode operation. // Decode operation.
#define RM_INSTRUCTION(base, op) \ #define RM_INSTRUCTION(base, op) \
case base+0x09: case base+0x05: case base+0x15: case base+0x01: case base+0x11: case base+0x0d: case base+0x1d: case base+0x19: \ case base+0x09: case base+0x05: case base+0x15: case base+0x01: \
instruction.operation = op; \ case base+0x11: case base+0x0d: case base+0x1d: case base+0x19: \
instruction.operation = op; \
break; break;
#define URM_INSTRUCTION(base, op) \ #define URM_INSTRUCTION(base, op) \
case base+0x07: case base+0x17: case base+0x03: case base+0x13: case base+0x0f: case base+0x1f: case base+0x1b: \ case base+0x07: case base+0x17: case base+0x03: case base+0x13: case base+0x0f: case base+0x1f: case base+0x1b: \
instruction.operation = op; \ instruction.operation = op; \
break; break;
#define M_INSTRUCTION(base, op) \ #define M_INSTRUCTION(base, op) \
case base+0x0a: case base+0x06: case base+0x16: case base+0x0e: case base+0x1e: \ case base+0x0a: case base+0x06: case base+0x16: case base+0x0e: case base+0x1e: \
instruction.operation = op; \ instruction.operation = op; \
break; break;
#define IM_INSTRUCTION(base, op) \ #define IM_INSTRUCTION(base, op) \
case base: instruction.operation = op; break; case base: instruction.operation = op; break;
switch(operation) { switch(operation) {
default: default:
instruction.operation = Instruction::KIL; instruction.operation = Instruction::KIL;
@@ -259,7 +266,10 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
disassembly.disassembly.instructions_by_address[instruction.address] = instruction; disassembly.disassembly.instructions_by_address[instruction.address] = instruction;
// TODO: something wider-ranging than this // TODO: something wider-ranging than this
if(instruction.addressing_mode == Instruction::Absolute || instruction.addressing_mode == Instruction::ZeroPage) { if(
instruction.addressing_mode == Instruction::Absolute ||
instruction.addressing_mode == Instruction::ZeroPage
) {
const size_t mapped_address = address_mapper(instruction.operand); const size_t mapped_address = address_mapper(instruction.operand);
const bool is_external = mapped_address >= memory.size(); const bool is_external = mapped_address >= memory.size();
@@ -272,20 +282,23 @@ static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<
case Instruction::ADC: case Instruction::SBC: case Instruction::ADC: case Instruction::SBC:
case Instruction::LAS: case Instruction::LAS:
case Instruction::CMP: case Instruction::CPX: case Instruction::CPY: case Instruction::CMP: case Instruction::CPX: case Instruction::CPY:
(is_external ? disassembly.disassembly.external_loads : disassembly.disassembly.internal_loads).insert(instruction.operand); (is_external ? disassembly.disassembly.external_loads : disassembly.disassembly.internal_loads)
.insert(instruction.operand);
break; break;
case Instruction::STY: case Instruction::STX: case Instruction::STA: case Instruction::STY: case Instruction::STX: case Instruction::STA:
case Instruction::AXS: case Instruction::AHX: case Instruction::SHX: case Instruction::SHY: case Instruction::AXS: case Instruction::AHX: case Instruction::SHX: case Instruction::SHY:
case Instruction::TAS: case Instruction::TAS:
(is_external ? disassembly.disassembly.external_stores : disassembly.disassembly.internal_stores).insert(instruction.operand); (is_external ? disassembly.disassembly.external_stores : disassembly.disassembly.internal_stores)
.insert(instruction.operand);
break; break;
case Instruction::SLO: case Instruction::RLA: case Instruction::SRE: case Instruction::RRA: case Instruction::SLO: case Instruction::RLA: case Instruction::SRE: case Instruction::RRA:
case Instruction::DCP: case Instruction::ISC: case Instruction::DCP: case Instruction::ISC:
case Instruction::INC: case Instruction::DEC: case Instruction::INC: case Instruction::DEC:
case Instruction::ASL: case Instruction::ROL: case Instruction::LSR: case Instruction::ROR: case Instruction::ASL: case Instruction::ROL: case Instruction::LSR: case Instruction::ROR:
(is_external ? disassembly.disassembly.external_modifies : disassembly.disassembly.internal_modifies).insert(instruction.operand); (is_external ? disassembly.disassembly.external_modifies : disassembly.disassembly.internal_modifies)
.insert(instruction.operand);
break; break;
} }
} }
@@ -330,5 +343,10 @@ Disassembly Analyser::Static::MOS6502::Disassemble(
const std::vector<uint8_t> &memory, const std::vector<uint8_t> &memory,
const std::function<std::size_t(uint16_t)> &address_mapper, const std::function<std::size_t(uint16_t)> &address_mapper,
std::vector<uint16_t> entry_points) { std::vector<uint16_t> entry_points) {
return Analyser::Static::Disassembly::Disassemble<Disassembly, uint16_t, MOS6502Disassembler>(memory, address_mapper, entry_points, false); return Analyser::Static::Disassembly::Disassemble<Disassembly, uint16_t, MOS6502Disassembler>(
memory,
address_mapper,
entry_points,
false
);
} }

View File

@@ -16,7 +16,7 @@ namespace Analyser::Static::Disassembler {
Provides an address mapper that relocates a chunk of memory so that it starts at Provides an address mapper that relocates a chunk of memory so that it starts at
address @c start_address. address @c start_address.
*/ */
template <typename T> std::function<std::size_t(T)> OffsetMapper(T start_address) { template <typename T> std::function<std::size_t(T)> OffsetMapper(const T start_address) {
return [start_address](T argument) { return [start_address](T argument) {
return size_t(argument - start_address); return size_t(argument - start_address);
}; };

View File

@@ -16,44 +16,48 @@ namespace {
using PartialDisassembly = Analyser::Static::Disassembly::PartialDisassembly<Disassembly, uint16_t>; using PartialDisassembly = Analyser::Static::Disassembly::PartialDisassembly<Disassembly, uint16_t>;
class Accessor { class Accessor {
public: public:
Accessor(const std::vector<uint8_t> &memory, const std::function<std::size_t(uint16_t)> &address_mapper, uint16_t address) : Accessor(
memory_(memory), address_mapper_(address_mapper), address_(address) {} const std::vector<uint8_t> &memory,
const std::function<std::size_t(uint16_t)> &address_mapper,
uint16_t address
) :
memory_(memory), address_mapper_(address_mapper), address_(address) {}
uint8_t byte() { uint8_t byte() {
std::size_t mapped_address = address_mapper_(address_); std::size_t mapped_address = address_mapper_(address_);
address_++; ++address_;
if(mapped_address >= memory_.size()) { if(mapped_address >= memory_.size()) {
overrun_ = true; overrun_ = true;
return 0xff; return 0xff;
}
return memory_[mapped_address];
} }
return memory_[mapped_address];
}
uint16_t word() { uint16_t word() {
uint8_t low = byte(); uint8_t low = byte();
uint8_t high = byte(); uint8_t high = byte();
return uint16_t(low | (high << 8)); return uint16_t(low | (high << 8));
} }
bool overrun() { bool overrun() const {
return overrun_; return overrun_;
} }
bool at_end() { bool at_end() const {
std::size_t mapped_address = address_mapper_(address_); std::size_t mapped_address = address_mapper_(address_);
return mapped_address >= memory_.size(); return mapped_address >= memory_.size();
} }
uint16_t address() { uint16_t address() const {
return address_; return address_;
} }
private: private:
const std::vector<uint8_t> &memory_; const std::vector<uint8_t> &memory_;
const std::function<std::size_t(uint16_t)> &address_mapper_; const std::function<std::size_t(uint16_t)> &address_mapper_;
uint16_t address_; uint16_t address_;
bool overrun_ = false; bool overrun_ = false;
}; };
constexpr uint8_t x(uint8_t v) { return v >> 6; } constexpr uint8_t x(uint8_t v) { return v >> 6; }
@@ -83,8 +87,12 @@ Instruction::Location register_pair_table2[] = {
Instruction::Location::AF Instruction::Location::AF
}; };
Instruction::Location RegisterTableEntry(int offset, Accessor &accessor, Instruction &instruction, bool needs_indirect_offset) { Instruction::Location RegisterTableEntry(
Instruction::Location register_table[] = { const int offset, Accessor &accessor,
Instruction &instruction,
const bool needs_indirect_offset
) {
constexpr Instruction::Location register_table[] = {
Instruction::Location::B, Instruction::Location::C, Instruction::Location::B, Instruction::Location::C,
Instruction::Location::D, Instruction::Location::E, Instruction::Location::D, Instruction::Location::E,
Instruction::Location::H, Instruction::Location::L, Instruction::Location::H, Instruction::Location::L,
@@ -92,7 +100,7 @@ Instruction::Location RegisterTableEntry(int offset, Accessor &accessor, Instruc
Instruction::Location::A Instruction::Location::A
}; };
Instruction::Location location = register_table[offset]; const Instruction::Location location = register_table[offset];
if(location == Instruction::Location::HL_Indirect && needs_indirect_offset) { if(location == Instruction::Location::HL_Indirect && needs_indirect_offset) {
instruction.offset = accessor.byte() - 128; instruction.offset = accessor.byte() - 128;
} }
@@ -100,7 +108,7 @@ Instruction::Location RegisterTableEntry(int offset, Accessor &accessor, Instruc
return location; return location;
} }
Instruction::Operation alu_table[] = { constexpr Instruction::Operation alu_table[] = {
Instruction::Operation::ADD, Instruction::Operation::ADD,
Instruction::Operation::ADC, Instruction::Operation::ADC,
Instruction::Operation::SUB, Instruction::Operation::SUB,
@@ -111,7 +119,7 @@ Instruction::Operation alu_table[] = {
Instruction::Operation::CP Instruction::Operation::CP
}; };
Instruction::Operation rotation_table[] = { constexpr Instruction::Operation rotation_table[] = {
Instruction::Operation::RLC, Instruction::Operation::RLC,
Instruction::Operation::RRC, Instruction::Operation::RRC,
Instruction::Operation::RL, Instruction::Operation::RL,
@@ -122,19 +130,32 @@ Instruction::Operation rotation_table[] = {
Instruction::Operation::SRL Instruction::Operation::SRL
}; };
Instruction::Operation block_table[][4] = { constexpr Instruction::Operation block_table[][4] = {
{Instruction::Operation::LDI, Instruction::Operation::CPI, Instruction::Operation::INI, Instruction::Operation::OUTI}, {
{Instruction::Operation::LDD, Instruction::Operation::CPD, Instruction::Operation::IND, Instruction::Operation::OUTD}, Instruction::Operation::LDI, Instruction::Operation::CPI,
{Instruction::Operation::LDIR, Instruction::Operation::CPIR, Instruction::Operation::INIR, Instruction::Operation::OTIR}, Instruction::Operation::INI, Instruction::Operation::OUTI
{Instruction::Operation::LDDR, Instruction::Operation::CPDR, Instruction::Operation::INDR, Instruction::Operation::OTDR}, },
{
Instruction::Operation::LDD, Instruction::Operation::CPD,
Instruction::Operation::IND, Instruction::Operation::OUTD
},
{
Instruction::Operation::LDIR, Instruction::Operation::CPIR,
Instruction::Operation::INIR, Instruction::Operation::OTIR
},
{
Instruction::Operation::LDDR, Instruction::Operation::CPDR,
Instruction::Operation::INDR, Instruction::Operation::OTDR
},
}; };
void DisassembleCBPage(Accessor &accessor, Instruction &instruction, bool needs_indirect_offset) { void DisassembleCBPage(Accessor &accessor, Instruction &instruction, const bool needs_indirect_offset) {
const uint8_t operation = accessor.byte(); const uint8_t operation = accessor.byte();
if(!x(operation)) { if(!x(operation)) {
instruction.operation = rotation_table[y(operation)]; instruction.operation = rotation_table[y(operation)];
instruction.source = instruction.destination = RegisterTableEntry(z(operation), accessor, instruction, needs_indirect_offset); instruction.source = instruction.destination =
RegisterTableEntry(z(operation), accessor, instruction, needs_indirect_offset);
} else { } else {
instruction.destination = RegisterTableEntry(z(operation), accessor, instruction, needs_indirect_offset); instruction.destination = RegisterTableEntry(z(operation), accessor, instruction, needs_indirect_offset);
instruction.source = Instruction::Location::Operand; instruction.source = Instruction::Location::Operand;
@@ -148,7 +169,7 @@ void DisassembleCBPage(Accessor &accessor, Instruction &instruction, bool needs_
} }
} }
void DisassembleEDPage(Accessor &accessor, Instruction &instruction, bool needs_indirect_offset) { void DisassembleEDPage(Accessor &accessor, Instruction &instruction, const bool needs_indirect_offset) {
const uint8_t operation = accessor.byte(); const uint8_t operation = accessor.byte();
switch(x(operation)) { switch(x(operation)) {
@@ -170,7 +191,8 @@ void DisassembleEDPage(Accessor &accessor, Instruction &instruction, bool needs_
if(y(operation) == 6) { if(y(operation) == 6) {
instruction.destination = Instruction::Location::None; instruction.destination = Instruction::Location::None;
} else { } else {
instruction.destination = RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset); instruction.destination =
RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset);
} }
break; break;
case 1: case 1:
@@ -179,7 +201,8 @@ void DisassembleEDPage(Accessor &accessor, Instruction &instruction, bool needs_
if(y(operation) == 6) { if(y(operation) == 6) {
instruction.source = Instruction::Location::None; instruction.source = Instruction::Location::None;
} else { } else {
instruction.source = RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset); instruction.source =
RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset);
} }
break; break;
case 2: case 2:
@@ -190,11 +213,13 @@ void DisassembleEDPage(Accessor &accessor, Instruction &instruction, bool needs_
case 3: case 3:
instruction.operation = Instruction::Operation::LD; instruction.operation = Instruction::Operation::LD;
if(q(operation)) { if(q(operation)) {
instruction.destination = RegisterTableEntry(p(operation), accessor, instruction, needs_indirect_offset); instruction.destination =
RegisterTableEntry(p(operation), accessor, instruction, needs_indirect_offset);
instruction.source = Instruction::Location::Operand_Indirect; instruction.source = Instruction::Location::Operand_Indirect;
} else { } else {
instruction.destination = Instruction::Location::Operand_Indirect; instruction.destination = Instruction::Location::Operand_Indirect;
instruction.source = RegisterTableEntry(p(operation), accessor, instruction, needs_indirect_offset); instruction.source =
RegisterTableEntry(p(operation), accessor, instruction, needs_indirect_offset);
} }
instruction.operand = accessor.word(); instruction.operand = accessor.word();
break; break;
@@ -202,7 +227,8 @@ void DisassembleEDPage(Accessor &accessor, Instruction &instruction, bool needs_
instruction.operation = Instruction::Operation::NEG; instruction.operation = Instruction::Operation::NEG;
break; break;
case 5: case 5:
instruction.operation = (y(operation) == 1) ? Instruction::Operation::RETI : Instruction::Operation::RETN; instruction.operation =
y(operation) == 1 ? Instruction::Operation::RETI : Instruction::Operation::RETN;
break; break;
case 6: case 6:
instruction.operation = Instruction::Operation::IM; instruction.operation = Instruction::Operation::IM;
@@ -253,7 +279,7 @@ void DisassembleMainPage(Accessor &accessor, Instruction &instruction) {
} hl_substitution = None; } hl_substitution = None;
while(true) { while(true) {
uint8_t operation = accessor.byte(); const uint8_t operation = accessor.byte();
switch(x(operation)) { switch(x(operation)) {
case 0: case 0:
@@ -343,15 +369,18 @@ void DisassembleMainPage(Accessor &accessor, Instruction &instruction) {
break; break;
case 4: case 4:
instruction.operation = Instruction::Operation::INC; instruction.operation = Instruction::Operation::INC;
instruction.source = instruction.destination = RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset); instruction.source = instruction.destination =
RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset);
break; break;
case 5: case 5:
instruction.operation = Instruction::Operation::DEC; instruction.operation = Instruction::Operation::DEC;
instruction.source = instruction.destination = RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset); instruction.source = instruction.destination =
RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset);
break; break;
case 6: case 6:
instruction.operation = Instruction::Operation::LD; instruction.operation = Instruction::Operation::LD;
instruction.destination = RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset); instruction.destination =
RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset);
instruction.source = Instruction::Location::Operand; instruction.source = Instruction::Location::Operand;
instruction.operand = accessor.byte(); instruction.operand = accessor.byte();
break; break;
@@ -374,8 +403,10 @@ void DisassembleMainPage(Accessor &accessor, Instruction &instruction) {
instruction.operation = Instruction::Operation::HALT; instruction.operation = Instruction::Operation::HALT;
} else { } else {
instruction.operation = Instruction::Operation::LD; instruction.operation = Instruction::Operation::LD;
instruction.source = RegisterTableEntry(z(operation), accessor, instruction, needs_indirect_offset); instruction.source =
instruction.destination = RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset); RegisterTableEntry(z(operation), accessor, instruction, needs_indirect_offset);
instruction.destination =
RegisterTableEntry(y(operation), accessor, instruction, needs_indirect_offset);
} }
break; break;
case 2: case 2:
@@ -517,10 +548,14 @@ void DisassembleMainPage(Accessor &accessor, Instruction &instruction) {
instruction.destination == Instruction::Location::HL_Indirect) { instruction.destination == Instruction::Location::HL_Indirect) {
if(instruction.source == Instruction::Location::HL_Indirect) { if(instruction.source == Instruction::Location::HL_Indirect) {
instruction.source = (hl_substitution == IX) ? Instruction::Location::IX_Indirect_Offset : Instruction::Location::IY_Indirect_Offset; instruction.source =
hl_substitution == IX ?
Instruction::Location::IX_Indirect_Offset : Instruction::Location::IY_Indirect_Offset;
} }
if(instruction.destination == Instruction::Location::HL_Indirect) { if(instruction.destination == Instruction::Location::HL_Indirect) {
instruction.destination = (hl_substitution == IX) ? Instruction::Location::IX_Indirect_Offset : Instruction::Location::IY_Indirect_Offset; instruction.destination =
hl_substitution == IX ?
Instruction::Location::IX_Indirect_Offset : Instruction::Location::IY_Indirect_Offset;
} }
return; return;
} }
@@ -542,7 +577,12 @@ void DisassembleMainPage(Accessor &accessor, Instruction &instruction) {
} }
struct Z80Disassembler { struct Z80Disassembler {
static void AddToDisassembly(PartialDisassembly &disassembly, const std::vector<uint8_t> &memory, const std::function<std::size_t(uint16_t)> &address_mapper, uint16_t entry_point) { static void AddToDisassembly(
PartialDisassembly &disassembly,
const std::vector<uint8_t> &memory,
const std::function<std::size_t(uint16_t)> &address_mapper,
const uint16_t entry_point
) {
disassembly.disassembly.internal_calls.insert(entry_point); disassembly.disassembly.internal_calls.insert(entry_point);
Accessor accessor(memory, address_mapper, entry_point); Accessor accessor(memory, address_mapper, entry_point);

View File

@@ -47,7 +47,12 @@ Analyser::Static::Target *OricTarget(const Storage::Encodings::AppleGCR::Sector
} }
Analyser::Static::TargetList Analyser::Static::DiskII::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::DiskII::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
// This analyser can comprehend disks only. // This analyser can comprehend disks only.
if(media.disks.empty()) return {}; if(media.disks.empty()) return {};
@@ -62,7 +67,8 @@ Analyser::Static::TargetList Analyser::Static::DiskII::GetTargets(const Media &m
} }
// Grab track 0, sector 0: the boot sector. // Grab track 0, sector 0: the boot sector.
const auto track_zero = disk->get_track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0))); const auto track_zero =
disk->track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0)));
const auto sector_map = Storage::Encodings::AppleGCR::sectors_from_segment( const auto sector_map = Storage::Encodings::AppleGCR::sectors_from_segment(
Storage::Disk::track_serialisation(*track_zero, Storage::Time(1, 50000))); Storage::Disk::track_serialisation(*track_zero, Storage::Time(1, 50000)));
@@ -89,7 +95,8 @@ Analyser::Static::TargetList Analyser::Static::DiskII::GetTargets(const Media &m
// If the boot sector looks like it's intended for the Oric, create an Oric. // If the boot sector looks like it's intended for the Oric, create an Oric.
// Otherwise go with the Apple II. // Otherwise go with the Apple II.
const auto disassembly = Analyser::Static::MOS6502::Disassemble(sector_zero->data, Analyser::Static::Disassembler::OffsetMapper(0xb800), {0xb800}); const auto disassembly = Analyser::Static::MOS6502::Disassemble(
sector_zero->data, Analyser::Static::Disassembler::OffsetMapper(0xb800), {0xb800});
bool did_read_shift_register = false; bool did_read_shift_register = false;
bool is_oric = false; bool is_oric = false;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::DiskII { namespace Analyser::Static::DiskII {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -26,7 +26,12 @@ bool insensitive_equal(const std::string &lhs, const std::string &rhs) {
} }
Analyser::Static::TargetList Analyser::Static::Enterprise::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Enterprise::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
// This analyser can comprehend disks only. // This analyser can comprehend disks only.
if(media.disks.empty()) return {}; if(media.disks.empty()) return {};
@@ -72,7 +77,8 @@ Analyser::Static::TargetList Analyser::Static::Enterprise::GetTargets(const Medi
if(!has_exdos_ini) { if(!has_exdos_ini) {
if(did_pick_file) { if(did_pick_file) {
target->loading_command = std::string("run \"") + selected_file->name + "." + selected_file->extension + "\"\n"; target->loading_command =
std::string("run \"") + selected_file->name + "." + selected_file->extension + "\"\n";
} else { } else {
target->loading_command = ":dir\n"; target->loading_command = ":dir\n";
} }

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Enterprise { namespace Analyser::Static::Enterprise {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -30,20 +30,22 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
Speed speed = Speed::FourMHz; Speed speed = Speed::FourMHz;
std::string loading_command; std::string loading_command;
Target() : Analyser::Static::Target(Machine::Enterprise) { Target() : Analyser::Static::Target(Machine::Enterprise) {}
if(needs_declare()) {
AnnounceEnum(Model);
AnnounceEnum(EXOSVersion);
AnnounceEnum(BASICVersion);
AnnounceEnum(DOS);
AnnounceEnum(Speed);
DeclareField(model); private:
DeclareField(exos_version); friend Reflection::StructImpl<Target>;
DeclareField(basic_version); void declare_fields() {
DeclareField(dos); AnnounceEnum(Model);
DeclareField(speed); AnnounceEnum(EXOSVersion);
} AnnounceEnum(BASICVersion);
AnnounceEnum(DOS);
AnnounceEnum(Speed);
DeclareField(model);
DeclareField(exos_version);
DeclareField(basic_version);
DeclareField(dos);
DeclareField(speed);
} }
}; };

View File

@@ -16,7 +16,12 @@
#include "../../../Storage/Disk/Encodings/MFM/SegmentParser.hpp" #include "../../../Storage/Disk/Encodings/MFM/SegmentParser.hpp"
Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType platforms) { Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(
const Media &media,
const std::string &file_name,
TargetPlatform::IntType platforms,
bool
) {
// This analyser can comprehend disks only. // This analyser can comprehend disks only.
if(media.disks.empty()) return {}; if(media.disks.empty()) return {};
@@ -35,11 +40,12 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(const Media &me
// If the disk image is very small or large, map it to the PC. That's the only option old enough // If the disk image is very small or large, map it to the PC. That's the only option old enough
// to have used 5.25" media. // to have used 5.25" media.
if(disk->get_maximum_head_position() <= Storage::Disk::HeadPosition(40)) { if(disk->get_maximum_head_position() <= Storage::Disk::HeadPosition(40)) {
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms); return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms, true);
} }
// Attempt to grab MFM track 0, sector 1: the boot sector. // Attempt to grab MFM track 0, sector 1: the boot sector.
const auto track_zero = disk->get_track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0))); const auto track_zero =
disk->track_at_position(Storage::Disk::Track::Address(0, Storage::Disk::HeadPosition(0)));
const auto sector_map = Storage::Encodings::MFM::sectors_from_segment( const auto sector_map = Storage::Encodings::MFM::sectors_from_segment(
Storage::Disk::track_serialisation( Storage::Disk::track_serialisation(
*track_zero, *track_zero,
@@ -48,7 +54,7 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(const Media &me
// If no sectors were found, assume this disk was either single density or high density, which both imply the PC. // If no sectors were found, assume this disk was either single density or high density, which both imply the PC.
if(sector_map.empty() || sector_map.size() > 10) { if(sector_map.empty() || sector_map.size() > 10) {
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms); return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms, true);
} }
const Storage::Encodings::MFM::Sector *boot_sector = nullptr; const Storage::Encodings::MFM::Sector *boot_sector = nullptr;
@@ -77,7 +83,7 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(const Media &me
if( if(
std::search(sample.begin(), sample.end(), string.begin(), string.end()) != sample.end() std::search(sample.begin(), sample.end(), string.begin(), string.end()) != sample.end()
) { ) {
return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms); return Analyser::Static::PCCompatible::GetTargets(media, file_name, platforms, true);
} }
} }
@@ -96,5 +102,5 @@ Analyser::Static::TargetList Analyser::Static::FAT12::GetTargets(const Media &me
// could redirect to an MSX2 with MSX-DOS2? Though it'd be nicer if I had a machine that was pure CP/M. // could redirect to an MSX2 with MSX-DOS2? Though it'd be nicer if I had a machine that was pure CP/M.
// Being unable to prove that this is a PC disk, throw it to the Enterprise. // Being unable to prove that this is a PC disk, throw it to the Enterprise.
return Analyser::Static::Enterprise::GetTargets(media, file_name, platforms); return Analyser::Static::Enterprise::GetTargets(media, file_name, platforms, false);
} }

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::FAT12 { namespace Analyser::Static::FAT12 {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -26,7 +26,7 @@ struct Cartridge: public ::Storage::Cartridge::Cartridge {
}; };
const Type type; const Type type;
Cartridge(const std::vector<Segment> &segments, Type type) : Cartridge(const std::vector<Segment> &segments, const Type type) :
Storage::Cartridge::Cartridge(segments), type(type) {} Storage::Cartridge::Cartridge(segments), type(type) {}
}; };

View File

@@ -27,7 +27,8 @@ static std::unique_ptr<Analyser::Static::Target> CartridgeTarget(
std::vector<Storage::Cartridge::Cartridge::Segment> output_segments; std::vector<Storage::Cartridge::Cartridge::Segment> output_segments;
if(segment.data.size() & 0x1fff) { if(segment.data.size() & 0x1fff) {
std::vector<uint8_t> truncated_data; std::vector<uint8_t> truncated_data;
std::vector<uint8_t>::difference_type truncated_size = std::vector<uint8_t>::difference_type(segment.data.size()) & ~0x1fff; const auto truncated_size =
std::vector<uint8_t>::difference_type(segment.data.size()) & ~0x1fff;
truncated_data.insert(truncated_data.begin(), segment.data.begin(), segment.data.begin() + truncated_size); truncated_data.insert(truncated_data.begin(), segment.data.begin(), segment.data.begin() + truncated_size);
output_segments.emplace_back(start_address, truncated_data); output_segments.emplace_back(start_address, truncated_data);
} else { } else {
@@ -82,7 +83,7 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
if(segments.size() != 1) continue; if(segments.size() != 1) continue;
// Which must be no more than 63 bytes larger than a multiple of 8 kb in size. // Which must be no more than 63 bytes larger than a multiple of 8 kb in size.
Storage::Cartridge::Cartridge::Segment segment = segments.front(); const Storage::Cartridge::Cartridge::Segment &segment = segments.front();
const size_t data_size = segment.data.size(); const size_t data_size = segment.data.size();
if(data_size < 0x2000 || (data_size & 0x1fff) > 64) continue; if(data_size < 0x2000 || (data_size & 0x1fff) > 64) continue;
@@ -101,7 +102,7 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
// Reject cartridge if the ROM header wasn't found. // Reject cartridge if the ROM header wasn't found.
if(!found_start) continue; if(!found_start) continue;
uint16_t init_address = uint16_t(segment.data[2] | (segment.data[3] << 8)); const uint16_t init_address = uint16_t(segment.data[2] | (segment.data[3] << 8));
// TODO: check for a rational init address? // TODO: check for a rational init address?
// If this ROM is less than 48kb in size then it's an ordinary ROM. Just emplace it and move on. // If this ROM is less than 48kb in size then it's an ordinary ROM. Just emplace it and move on.
@@ -137,10 +138,12 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
} }
// Weight confidences by number of observed hits; if any is above 60% confidence, just use it. // Weight confidences by number of observed hits; if any is above 60% confidence, just use it.
const auto ascii_8kb_total = address_counts[0x6000] + address_counts[0x6800] + address_counts[0x7000] + address_counts[0x7800]; const auto ascii_8kb_total =
address_counts[0x6000] + address_counts[0x6800] + address_counts[0x7000] + address_counts[0x7800];
const auto ascii_16kb_total = address_counts[0x6000] + address_counts[0x7000] + address_counts[0x77ff]; const auto ascii_16kb_total = address_counts[0x6000] + address_counts[0x7000] + address_counts[0x77ff];
const auto konami_total = address_counts[0x6000] + address_counts[0x8000] + address_counts[0xa000]; const auto konami_total = address_counts[0x6000] + address_counts[0x8000] + address_counts[0xa000];
const auto konami_with_scc_total = address_counts[0x5000] + address_counts[0x7000] + address_counts[0x9000] + address_counts[0xb000]; const auto konami_with_scc_total =
address_counts[0x5000] + address_counts[0x7000] + address_counts[0x9000] + address_counts[0xb000];
const auto total_hits = ascii_8kb_total + ascii_16kb_total + konami_total + konami_with_scc_total; const auto total_hits = ascii_8kb_total + ascii_16kb_total + konami_total + konami_with_scc_total;
@@ -182,7 +185,12 @@ static Analyser::Static::TargetList CartridgeTargetsFrom(
return targets; return targets;
} }
Analyser::Static::TargetList Analyser::Static::MSX::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::MSX::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
TargetList destination; TargetList destination;
// Append targets for any cartridges that look correct. // Append targets for any cartridges that look correct.
@@ -194,7 +202,7 @@ Analyser::Static::TargetList Analyser::Static::MSX::GetTargets(const Media &medi
// Check tapes for loadable files. // Check tapes for loadable files.
for(auto &tape : media.tapes) { for(auto &tape : media.tapes) {
std::vector<File> files_on_tape = GetFiles(tape); const std::vector<File> files_on_tape = GetFiles(tape);
if(!files_on_tape.empty()) { if(!files_on_tape.empty()) {
switch(files_on_tape.front().type) { switch(files_on_tape.front().type) {
case File::Type::ASCII: target->loading_command = "RUN\"CAS:\r"; break; case File::Type::ASCII: target->loading_command = "RUN\"CAS:\r"; break;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::MSX { namespace Analyser::Static::MSX {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -29,12 +29,12 @@ std::vector<File> Analyser::Static::MSX::GetFiles(const std::shared_ptr<Storage:
Storage::Tape::BinaryTapePlayer tape_player(1000000); Storage::Tape::BinaryTapePlayer tape_player(1000000);
tape_player.set_motor_control(true); tape_player.set_motor_control(true);
tape_player.set_tape(tape); tape_player.set_tape(tape, TargetPlatform::MSX);
using Parser = Storage::Tape::MSX::Parser; using Parser = Storage::Tape::MSX::Parser;
// Get all recognisable files from the tape. // Get all recognisable files from the tape.
while(!tape->is_at_end()) { while(!tape_player.is_at_end()) {
// Try to locate and measure a header. // Try to locate and measure a header.
std::unique_ptr<Parser::FileSpeed> file_speed = Parser::find_header(tape_player); std::unique_ptr<Parser::FileSpeed> file_speed = Parser::find_header(tape_player);
if(!file_speed) continue; if(!file_speed) continue;

View File

@@ -32,6 +32,6 @@ struct File {
File(); File();
}; };
std::vector<File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape); std::vector<File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &);
} }

View File

@@ -33,15 +33,17 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
); );
Region region = Region::USA; Region region = Region::USA;
Target(): Analyser::Static::Target(Machine::MSX) { Target(): Analyser::Static::Target(Machine::MSX) {}
if(needs_declare()) {
DeclareField(has_disk_drive); private:
DeclareField(has_msx_music); friend Reflection::StructImpl<Target>;
DeclareField(region); void declare_fields() {
AnnounceEnum(Region); DeclareField(has_disk_drive);
DeclareField(model); DeclareField(has_msx_music);
AnnounceEnum(Model); DeclareField(region);
} AnnounceEnum(Region);
DeclareField(model);
AnnounceEnum(Model);
} }
}; };

View File

@@ -9,9 +9,14 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include "Target.hpp" #include "Target.hpp"
Analyser::Static::TargetList Analyser::Static::Macintosh::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Macintosh::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool is_confident
) {
// This analyser can comprehend disks and mass-storage devices only. // This analyser can comprehend disks and mass-storage devices only.
if(media.disks.empty() && media.mass_storage_devices.empty()) return {}; if(media.disks.empty() && media.mass_storage_devices.empty() && !is_confident) return {};
// As there is at least one usable media image, wave it through. // As there is at least one usable media image, wave it through.
Analyser::Static::TargetList targets; Analyser::Static::TargetList targets;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Macintosh { namespace Analyser::Static::Macintosh {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -18,12 +18,13 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
ReflectableEnum(Model, Mac128k, Mac512k, Mac512ke, MacPlus); ReflectableEnum(Model, Mac128k, Mac512k, Mac512ke, MacPlus);
Model model = Model::MacPlus; Model model = Model::MacPlus;
Target() : Analyser::Static::Target(Machine::Macintosh) { Target() : Analyser::Static::Target(Machine::Macintosh) {}
// Boilerplate for declaring fields and potential values.
if(needs_declare()) { private:
DeclareField(model); friend Reflection::StructImpl<Target>;
AnnounceEnum(Model); void declare_fields() {
} DeclareField(model);
AnnounceEnum(Model);
} }
}; };

View File

@@ -22,12 +22,22 @@ using namespace Analyser::Static::Oric;
namespace { namespace {
int score(const Analyser::Static::MOS6502::Disassembly &disassembly, const std::set<uint16_t> &rom_functions, const std::set<uint16_t> &variable_locations) { int score(
const Analyser::Static::MOS6502::Disassembly &disassembly,
const std::set<uint16_t> &rom_functions,
const std::set<uint16_t> &variable_locations
) {
int score = 0; int score = 0;
for(const auto address : disassembly.outward_calls) score += (rom_functions.find(address) != rom_functions.end()) ? 1 : -1; for(const auto address : disassembly.outward_calls) {
for(const auto address : disassembly.external_stores) score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1; score += (rom_functions.find(address) != rom_functions.end()) ? 1 : -1;
for(const auto address : disassembly.external_loads) score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1; }
for(const auto address : disassembly.external_stores) {
score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1;
}
for(const auto address : disassembly.external_loads) {
score += (variable_locations.find(address) != variable_locations.end()) ? 1 : -1;
}
return score; return score;
} }
@@ -35,19 +45,32 @@ int score(const Analyser::Static::MOS6502::Disassembly &disassembly, const std::
int basic10_score(const Analyser::Static::MOS6502::Disassembly &disassembly) { int basic10_score(const Analyser::Static::MOS6502::Disassembly &disassembly) {
const std::set<uint16_t> rom_functions = { const std::set<uint16_t> rom_functions = {
0x0228, 0x022b, 0x0228, 0x022b,
0xc3ca, 0xc3f8, 0xc448, 0xc47c, 0xc4b5, 0xc4e3, 0xc4e0, 0xc524, 0xc56f, 0xc5a2, 0xc5f8, 0xc60a, 0xc6a5, 0xc6de, 0xc719, 0xc738, 0xc3ca, 0xc3f8, 0xc448, 0xc47c, 0xc4b5, 0xc4e3, 0xc4e0, 0xc524,
0xc773, 0xc824, 0xc832, 0xc841, 0xc8c1, 0xc8fe, 0xc91f, 0xc93f, 0xc941, 0xc91e, 0xc98b, 0xc996, 0xc9b3, 0xc9e0, 0xca0a, 0xca1c, 0xc56f, 0xc5a2, 0xc5f8, 0xc60a, 0xc6a5, 0xc6de, 0xc719, 0xc738,
0xca1f, 0xca3e, 0xca61, 0xca78, 0xca98, 0xcad2, 0xcb61, 0xcb9f, 0xcc59, 0xcbed, 0xcc0a, 0xcc8c, 0xcc8f, 0xccba, 0xccc9, 0xccfd, 0xc773, 0xc824, 0xc832, 0xc841, 0xc8c1, 0xc8fe, 0xc91f, 0xc93f,
0xce0c, 0xce77, 0xce8b, 0xcfac, 0xcf74, 0xd03c, 0xd059, 0xcff0, 0xd087, 0xd0f2, 0xd0fc, 0xd361, 0xd3eb, 0xd47e, 0xd4a6, 0xd401, 0xc941, 0xc91e, 0xc98b, 0xc996, 0xc9b3, 0xc9e0, 0xca0a, 0xca1c,
0xd593, 0xd5a3, 0xd4fa, 0xd595, 0xd730, 0xd767, 0xd816, 0xd82a, 0xd856, 0xd861, 0xd8a6, 0xd8b5, 0xd80a, 0xd867, 0xd938, 0xd894, 0xca1f, 0xca3e, 0xca61, 0xca78, 0xca98, 0xcad2, 0xcb61, 0xcb9f,
0xd89d, 0xd8ac, 0xd983, 0xd993, 0xd9b5, 0xd93d, 0xd965, 0xda3f, 0xd9c6, 0xda16, 0xdaab, 0xdada, 0xda6b, 0xdb92, 0xdbb9, 0xdc79, 0xcc59, 0xcbed, 0xcc0a, 0xcc8c, 0xcc8f, 0xccba, 0xccc9, 0xccfd,
0xdd4d, 0xdda3, 0xddbf, 0xd0d0, 0xde77, 0xdef4, 0xdf0b, 0xdf0f, 0xdf04, 0xdf12, 0xdf31, 0xdf4c, 0xdf8c, 0xdfa5, 0xdfcf, 0xe076, 0xce0c, 0xce77, 0xce8b, 0xcfac, 0xcf74, 0xd03c, 0xd059, 0xcff0,
0xe0c1, 0xe22a, 0xe27c, 0xe2a6, 0xe313, 0xe34b, 0xe387, 0xe38e, 0xe3d7, 0xe407, 0xe43b, 0xe46f, 0xe4a8, 0xe4f2, 0xe554, 0xe57d, 0xd087, 0xd0f2, 0xd0fc, 0xd361, 0xd3eb, 0xd47e, 0xd4a6, 0xd401,
0xe585, 0xe58c, 0xe594, 0xe5a4, 0xe5ab, 0xe5b6, 0xe5ea, 0xe563, 0xe5c6, 0xe630, 0xe696, 0xe6ba, 0xe6ca, 0xe725, 0xe7aa, 0xe903, 0xd593, 0xd5a3, 0xd4fa, 0xd595, 0xd730, 0xd767, 0xd816, 0xd82a,
0xe7db, 0xe80d, 0xe987, 0xe9d1, 0xe87d, 0xe905, 0xe965, 0xe974, 0xe994, 0xe9a9, 0xe9bb, 0xec45, 0xeccc, 0xedc4, 0xecc7, 0xed01, 0xd856, 0xd861, 0xd8a6, 0xd8b5, 0xd80a, 0xd867, 0xd938, 0xd894,
0xed09, 0xed70, 0xed81, 0xed8f, 0xe0ad, 0xeee8, 0xeef8, 0xebdf, 0xebe2, 0xebe5, 0xebeb, 0xebee, 0xebf4, 0xebf7, 0xebfa, 0xebe8, 0xd89d, 0xd8ac, 0xd983, 0xd993, 0xd9b5, 0xd93d, 0xd965, 0xda3f,
0xf43c, 0xf4ef, 0xf523, 0xf561, 0xf535, 0xf57b, 0xf5d3, 0xf71a, 0xf73f, 0xf7e4, 0xf7e0, 0xf82f, 0xf88f, 0xf8af, 0xf8b5, 0xf920, 0xd9c6, 0xda16, 0xdaab, 0xdada, 0xda6b, 0xdb92, 0xdbb9, 0xdc79,
0xf967, 0xf960, 0xf9c9, 0xfa14, 0xfa85, 0xfa9b, 0xfab1, 0xfac7, 0xfafa, 0xfb10, 0xfb26, 0xfbb6, 0xfbfe 0xdd4d, 0xdda3, 0xddbf, 0xd0d0, 0xde77, 0xdef4, 0xdf0b, 0xdf0f,
0xdf04, 0xdf12, 0xdf31, 0xdf4c, 0xdf8c, 0xdfa5, 0xdfcf, 0xe076,
0xe0c1, 0xe22a, 0xe27c, 0xe2a6, 0xe313, 0xe34b, 0xe387, 0xe38e,
0xe3d7, 0xe407, 0xe43b, 0xe46f, 0xe4a8, 0xe4f2, 0xe554, 0xe57d,
0xe585, 0xe58c, 0xe594, 0xe5a4, 0xe5ab, 0xe5b6, 0xe5ea, 0xe563,
0xe5c6, 0xe630, 0xe696, 0xe6ba, 0xe6ca, 0xe725, 0xe7aa, 0xe903,
0xe7db, 0xe80d, 0xe987, 0xe9d1, 0xe87d, 0xe905, 0xe965, 0xe974,
0xe994, 0xe9a9, 0xe9bb, 0xec45, 0xeccc, 0xedc4, 0xecc7, 0xed01,
0xed09, 0xed70, 0xed81, 0xed8f, 0xe0ad, 0xeee8, 0xeef8, 0xebdf,
0xebe2, 0xebe5, 0xebeb, 0xebee, 0xebf4, 0xebf7, 0xebfa, 0xebe8,
0xf43c, 0xf4ef, 0xf523, 0xf561, 0xf535, 0xf57b, 0xf5d3, 0xf71a,
0xf73f, 0xf7e4, 0xf7e0, 0xf82f, 0xf88f, 0xf8af, 0xf8b5, 0xf920,
0xf967, 0xf960, 0xf9c9, 0xfa14, 0xfa85, 0xfa9b, 0xfab1, 0xfac7,
0xfafa, 0xfb10, 0xfb26, 0xfbb6, 0xfbfe
}; };
const std::set<uint16_t> variable_locations = { const std::set<uint16_t> variable_locations = {
0x0228, 0x0229, 0x022a, 0x022b, 0x022c, 0x022d, 0x0230 0x0228, 0x0229, 0x022a, 0x022b, 0x022c, 0x022d, 0x0230
@@ -59,19 +82,32 @@ int basic10_score(const Analyser::Static::MOS6502::Disassembly &disassembly) {
int basic11_score(const Analyser::Static::MOS6502::Disassembly &disassembly) { int basic11_score(const Analyser::Static::MOS6502::Disassembly &disassembly) {
const std::set<uint16_t> rom_functions = { const std::set<uint16_t> rom_functions = {
0x0238, 0x023b, 0x023e, 0x0241, 0x0244, 0x0247, 0x0238, 0x023b, 0x023e, 0x0241, 0x0244, 0x0247,
0xc3c6, 0xc3f4, 0xc444, 0xc47c, 0xc4a8, 0xc4d3, 0xc4e0, 0xc524, 0xc55f, 0xc592, 0xc5e8, 0xc5fa, 0xc692, 0xc6b3, 0xc6ee, 0xc70d, 0xc3c6, 0xc3f4, 0xc444, 0xc47c, 0xc4a8, 0xc4d3, 0xc4e0, 0xc524,
0xc748, 0xc7fd, 0xc809, 0xc816, 0xc82f, 0xc855, 0xc8c1, 0xc915, 0xc952, 0xc971, 0xc973, 0xc9a0, 0xc9bd, 0xc9c8, 0xc9e5, 0xca12, 0xc55f, 0xc592, 0xc5e8, 0xc5fa, 0xc692, 0xc6b3, 0xc6ee, 0xc70d,
0xca3c, 0xca4e, 0xca51, 0xca70, 0xca99, 0xcac2, 0xcae2, 0xcb1c, 0xcbab, 0xcbf0, 0xcc59, 0xccb0, 0xccce, 0xcd16, 0xcd19, 0xcd46, 0xc748, 0xc7fd, 0xc809, 0xc816, 0xc82f, 0xc855, 0xc8c1, 0xc915,
0xcd55, 0xcd89, 0xce98, 0xcf03, 0xcf17, 0xcfac, 0xd000, 0xd03c, 0xd059, 0xd07c, 0xd113, 0xd17e, 0xd188, 0xd361, 0xd3eb, 0xd47e, 0xc952, 0xc971, 0xc973, 0xc9a0, 0xc9bd, 0xc9c8, 0xc9e5, 0xca12,
0xd4a6, 0xd4ba, 0xd593, 0xd5a3, 0xd5b5, 0xd650, 0xd730, 0xd767, 0xd816, 0xd82a, 0xd856, 0xd861, 0xd8a6, 0xd8b5, 0xd8c5, 0xd922, 0xca3c, 0xca4e, 0xca51, 0xca70, 0xca99, 0xcac2, 0xcae2, 0xcb1c,
0xd938, 0xd94f, 0xd958, 0xd967, 0xd983, 0xd993, 0xd9b5, 0xd9de, 0xda0c, 0xda3f, 0xda51, 0xdaa1, 0xdaab, 0xdada, 0xdaf6, 0xdb92, 0xcbab, 0xcbf0, 0xcc59, 0xccb0, 0xccce, 0xcd16, 0xcd19, 0xcd46,
0xdbb9, 0xdcaf, 0xdd51, 0xdda7, 0xddc3, 0xddd4, 0xde77, 0xdef4, 0xdf0b, 0xdf0f, 0xdf13, 0xdf21, 0xdf49, 0xdf4c, 0xdf8c, 0xdfbd, 0xcd55, 0xcd89, 0xce98, 0xcf03, 0xcf17, 0xcfac, 0xd000, 0xd03c,
0xdfe7, 0xe076, 0xe0c5, 0xe22e, 0xe27c, 0xe2aa, 0xe313, 0xe34f, 0xe38b, 0xe392, 0xe3db, 0xe407, 0xe43f, 0xe46f, 0xe4ac, 0xe4e0, 0xd059, 0xd07c, 0xd113, 0xd17e, 0xd188, 0xd361, 0xd3eb, 0xd47e,
0xe4f2, 0xe56c, 0xe57d, 0xe585, 0xe58c, 0xe594, 0xe5a4, 0xe5ab, 0xe5b6, 0xe5ea, 0xe5f5, 0xe607, 0xe65e, 0xe6c9, 0xe735, 0xe75a, 0xd4a6, 0xd4ba, 0xd593, 0xd5a3, 0xd5b5, 0xd650, 0xd730, 0xd767,
0xe76a, 0xe7b2, 0xe85b, 0xe903, 0xe909, 0xe946, 0xe987, 0xe9d1, 0xeaf0, 0xeb78, 0xebce, 0xebe7, 0xec0c, 0xec21, 0xec33, 0xec45, 0xd816, 0xd82a, 0xd856, 0xd861, 0xd8a6, 0xd8b5, 0xd8c5, 0xd922,
0xeccc, 0xedc4, 0xede0, 0xee1a, 0xee22, 0xee8c, 0xee9d, 0xeeab, 0xeec9, 0xeee8, 0xeef8, 0xf0c8, 0xf0fd, 0xf110, 0xf11d, 0xf12d, 0xd938, 0xd94f, 0xd958, 0xd967, 0xd983, 0xd993, 0xd9b5, 0xd9de,
0xf204, 0xf210, 0xf268, 0xf37f, 0xf495, 0xf4ef, 0xf523, 0xf561, 0xf590, 0xf5c1, 0xf602, 0xf71a, 0xf77c, 0xf7e4, 0xf816, 0xf865, 0xda0c, 0xda3f, 0xda51, 0xdaa1, 0xdaab, 0xdada, 0xdaf6, 0xdb92,
0xf88f, 0xf8af, 0xf8b5, 0xf920, 0xf967, 0xf9aa, 0xf9c9, 0xfa14, 0xfa9f, 0xfab5, 0xfacb, 0xfae1, 0xfb14, 0xfb2a, 0xfb40, 0xfbd0, 0xdbb9, 0xdcaf, 0xdd51, 0xdda7, 0xddc3, 0xddd4, 0xde77, 0xdef4,
0xdf0b, 0xdf0f, 0xdf13, 0xdf21, 0xdf49, 0xdf4c, 0xdf8c, 0xdfbd,
0xdfe7, 0xe076, 0xe0c5, 0xe22e, 0xe27c, 0xe2aa, 0xe313, 0xe34f,
0xe38b, 0xe392, 0xe3db, 0xe407, 0xe43f, 0xe46f, 0xe4ac, 0xe4e0,
0xe4f2, 0xe56c, 0xe57d, 0xe585, 0xe58c, 0xe594, 0xe5a4, 0xe5ab,
0xe5b6, 0xe5ea, 0xe5f5, 0xe607, 0xe65e, 0xe6c9, 0xe735, 0xe75a,
0xe76a, 0xe7b2, 0xe85b, 0xe903, 0xe909, 0xe946, 0xe987, 0xe9d1,
0xeaf0, 0xeb78, 0xebce, 0xebe7, 0xec0c, 0xec21, 0xec33, 0xec45,
0xeccc, 0xedc4, 0xede0, 0xee1a, 0xee22, 0xee8c, 0xee9d, 0xeeab,
0xeec9, 0xeee8, 0xeef8, 0xf0c8, 0xf0fd, 0xf110, 0xf11d, 0xf12d,
0xf204, 0xf210, 0xf268, 0xf37f, 0xf495, 0xf4ef, 0xf523, 0xf561,
0xf590, 0xf5c1, 0xf602, 0xf71a, 0xf77c, 0xf7e4, 0xf816, 0xf865,
0xf88f, 0xf8af, 0xf8b5, 0xf920, 0xf967, 0xf9aa, 0xf9c9, 0xfa14,
0xfa9f, 0xfab5, 0xfacb, 0xfae1, 0xfb14, 0xfb2a, 0xfb40, 0xfbd0,
0xfc18 0xfc18
}; };
const std::set<uint16_t> variable_locations = { const std::set<uint16_t> variable_locations = {
@@ -102,7 +138,7 @@ bool is_microdisc(Storage::Encodings::MFM::Parser &parser) {
return !std::memcmp(signature, first_sample.data(), sizeof(signature)); return !std::memcmp(signature, first_sample.data(), sizeof(signature));
} }
bool is_400_loader(Storage::Encodings::MFM::Parser &parser, uint16_t range_start, uint16_t range_end) { bool is_400_loader(Storage::Encodings::MFM::Parser &parser, const uint16_t range_start, const uint16_t range_end) {
/* /*
Both the Jasmin and BD-DOS boot sectors are sector 1 of track 0 and are loaded at $400; Both the Jasmin and BD-DOS boot sectors are sector 1 of track 0 and are loaded at $400;
use disassembly to test for likely matches. use disassembly to test for likely matches.
@@ -120,8 +156,8 @@ bool is_400_loader(Storage::Encodings::MFM::Parser &parser, uint16_t range_start
} }
// Grab a disassembly. // Grab a disassembly.
const auto disassembly = const auto disassembly = Analyser::Static::MOS6502::Disassemble(
Analyser::Static::MOS6502::Disassemble(first_sample, Analyser::Static::Disassembler::OffsetMapper(0x400), {0x400}); first_sample, Analyser::Static::Disassembler::OffsetMapper(0x400), {0x400});
// Check for references to the Jasmin registers. // Check for references to the Jasmin registers.
int register_hits = 0; int register_hits = 0;
@@ -145,7 +181,12 @@ bool is_bd500(Storage::Encodings::MFM::Parser &parser) {
} }
Analyser::Static::TargetList Analyser::Static::Oric::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Oric::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
auto target = std::make_unique<Target>(); auto target = std::make_unique<Target>();
target->confidence = 0.5; target->confidence = 0.5;
@@ -153,14 +194,18 @@ Analyser::Static::TargetList Analyser::Static::Oric::GetTargets(const Media &med
int basic11_votes = 0; int basic11_votes = 0;
for(auto &tape : media.tapes) { for(auto &tape : media.tapes) {
std::vector<File> tape_files = GetFiles(tape); auto serialiser = tape->serialiser();
tape->reset(); std::vector<File> tape_files = GetFiles(*serialiser);
if(!tape_files.empty()) { if(!tape_files.empty()) {
for(const auto &file : tape_files) { for(const auto &file : tape_files) {
if(file.data_type == File::MachineCode) { if(file.data_type == File::MachineCode) {
std::vector<uint16_t> entry_points = {file.starting_address}; std::vector<uint16_t> entry_points = {file.starting_address};
const Analyser::Static::MOS6502::Disassembly disassembly = const Analyser::Static::MOS6502::Disassembly disassembly =
Analyser::Static::MOS6502::Disassemble(file.data, Analyser::Static::Disassembler::OffsetMapper(file.starting_address), entry_points); Analyser::Static::MOS6502::Disassemble(
file.data,
Analyser::Static::Disassembler::OffsetMapper(file.starting_address),
entry_points
);
if(basic10_score(disassembly) > basic11_score(disassembly)) ++basic10_votes; else ++basic11_votes; if(basic10_score(disassembly) > basic11_score(disassembly)) ++basic10_votes; else ++basic11_votes;
} }

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Oric { namespace Analyser::Static::Oric {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -11,57 +11,57 @@
using namespace Analyser::Static::Oric; using namespace Analyser::Static::Oric;
std::vector<File> Analyser::Static::Oric::GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape) { std::vector<File> Analyser::Static::Oric::GetFiles(Storage::Tape::TapeSerialiser &serialiser) {
std::vector<File> files; std::vector<File> files;
Storage::Tape::Oric::Parser parser; Storage::Tape::Oric::Parser parser;
while(!tape->is_at_end()) { while(!serialiser.is_at_end()) {
// sync to next lead-in, check that it's one of three 0x16s // sync to next lead-in, check that it's one of three 0x16s
bool is_fast = parser.sync_and_get_encoding_speed(tape); bool is_fast = parser.sync_and_get_encoding_speed(serialiser);
int next_bytes[2]; int next_bytes[2];
next_bytes[0] = parser.get_next_byte(tape, is_fast); next_bytes[0] = parser.get_next_byte(serialiser, is_fast);
next_bytes[1] = parser.get_next_byte(tape, is_fast); next_bytes[1] = parser.get_next_byte(serialiser, is_fast);
if(next_bytes[0] != 0x16 || next_bytes[1] != 0x16) continue; if(next_bytes[0] != 0x16 || next_bytes[1] != 0x16) continue;
// get the first byte that isn't a 0x16, check it was a 0x24 // get the first byte that isn't a 0x16, check it was a 0x24
int byte = 0x16; int byte = 0x16;
while(!tape->is_at_end() && byte == 0x16) { while(!serialiser.is_at_end() && byte == 0x16) {
byte = parser.get_next_byte(tape, is_fast); byte = parser.get_next_byte(serialiser, is_fast);
} }
if(byte != 0x24) continue; if(byte != 0x24) continue;
// skip two empty bytes // skip two empty bytes
parser.get_next_byte(tape, is_fast); parser.get_next_byte(serialiser, is_fast);
parser.get_next_byte(tape, is_fast); parser.get_next_byte(serialiser, is_fast);
// get data and launch types // get data and launch types
File new_file; File new_file;
switch(parser.get_next_byte(tape, is_fast)) { switch(parser.get_next_byte(serialiser, is_fast)) {
case 0x00: new_file.data_type = File::ProgramType::BASIC; break; case 0x00: new_file.data_type = File::ProgramType::BASIC; break;
case 0x80: new_file.data_type = File::ProgramType::MachineCode; break; case 0x80: new_file.data_type = File::ProgramType::MachineCode; break;
default: new_file.data_type = File::ProgramType::None; break; default: new_file.data_type = File::ProgramType::None; break;
} }
switch(parser.get_next_byte(tape, is_fast)) { switch(parser.get_next_byte(serialiser, is_fast)) {
case 0x80: new_file.launch_type = File::ProgramType::BASIC; break; case 0x80: new_file.launch_type = File::ProgramType::BASIC; break;
case 0xc7: new_file.launch_type = File::ProgramType::MachineCode; break; case 0xc7: new_file.launch_type = File::ProgramType::MachineCode; break;
default: new_file.launch_type = File::ProgramType::None; break; default: new_file.launch_type = File::ProgramType::None; break;
} }
// read end and start addresses // read end and start addresses
new_file.ending_address = uint16_t(parser.get_next_byte(tape, is_fast) << 8); new_file.ending_address = uint16_t(parser.get_next_byte(serialiser, is_fast) << 8);
new_file.ending_address |= uint16_t(parser.get_next_byte(tape, is_fast)); new_file.ending_address |= uint16_t(parser.get_next_byte(serialiser, is_fast));
new_file.starting_address = uint16_t(parser.get_next_byte(tape, is_fast) << 8); new_file.starting_address = uint16_t(parser.get_next_byte(serialiser, is_fast) << 8);
new_file.starting_address |= uint16_t(parser.get_next_byte(tape, is_fast)); new_file.starting_address |= uint16_t(parser.get_next_byte(serialiser, is_fast));
// skip an empty byte // skip an empty byte
parser.get_next_byte(tape, is_fast); parser.get_next_byte(serialiser, is_fast);
// read file name, up to 16 characters and null terminated // read file name, up to 16 characters and null terminated
char file_name[17]; char file_name[17];
int name_pos = 0; int name_pos = 0;
while(name_pos < 16) { while(name_pos < 16) {
file_name[name_pos] = char(parser.get_next_byte(tape, is_fast)); file_name[name_pos] = char(parser.get_next_byte(serialiser, is_fast));
if(!file_name[name_pos]) break; if(!file_name[name_pos]) break;
name_pos++; name_pos++;
} }
@@ -72,11 +72,11 @@ std::vector<File> Analyser::Static::Oric::GetFiles(const std::shared_ptr<Storage
std::size_t body_length = new_file.ending_address - new_file.starting_address + 1; std::size_t body_length = new_file.ending_address - new_file.starting_address + 1;
new_file.data.reserve(body_length); new_file.data.reserve(body_length);
for(std::size_t c = 0; c < body_length; c++) { for(std::size_t c = 0; c < body_length; c++) {
new_file.data.push_back(uint8_t(parser.get_next_byte(tape, is_fast))); new_file.data.push_back(uint8_t(parser.get_next_byte(serialiser, is_fast)));
} }
// only one validation check: was there enough tape? // only one validation check: was there enough tape?
if(!tape->is_at_end()) { if(!serialiser.is_at_end()) {
files.push_back(new_file); files.push_back(new_file);
} }
} }

View File

@@ -28,6 +28,6 @@ struct File {
std::vector<uint8_t> data; std::vector<uint8_t> data;
}; };
std::vector<File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape); std::vector<File> GetFiles(Storage::Tape::TapeSerialiser &);
} }

View File

@@ -41,15 +41,17 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
std::string loading_command; std::string loading_command;
bool should_start_jasmin = false; bool should_start_jasmin = false;
Target(): Analyser::Static::Target(Machine::Oric) { Target(): Analyser::Static::Target(Machine::Oric) {}
if(needs_declare()) {
DeclareField(rom); private:
DeclareField(disk_interface); friend Reflection::StructImpl<Target>;
DeclareField(processor); void declare_fields() {
AnnounceEnum(ROM); DeclareField(rom);
AnnounceEnum(DiskInterface); DeclareField(disk_interface);
AnnounceEnum(Processor); DeclareField(processor);
} AnnounceEnum(ROM);
AnnounceEnum(DiskInterface);
AnnounceEnum(Processor);
} }
}; };

View File

@@ -9,7 +9,12 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include "Target.hpp" #include "Target.hpp"
Analyser::Static::TargetList Analyser::Static::PCCompatible::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::PCCompatible::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
// This analyser can comprehend disks only. // This analyser can comprehend disks only.
if(media.disks.empty()) return {}; if(media.disks.empty()) return {};

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::PCCompatible { namespace Analyser::Static::PCCompatible {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -24,13 +24,15 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
Fast); Fast);
Speed speed = Speed::Fast; Speed speed = Speed::Fast;
Target() : Analyser::Static::Target(Machine::PCCompatible) { Target() : Analyser::Static::Target(Machine::PCCompatible) {}
if(needs_declare()) {
AnnounceEnum(VideoAdaptor); private:
AnnounceEnum(Speed); friend Reflection::StructImpl<Target>;
DeclareField(adaptor); void declare_fields() {
DeclareField(speed); AnnounceEnum(VideoAdaptor);
} AnnounceEnum(Speed);
DeclareField(adaptor);
DeclareField(speed);
} }
}; };

View File

@@ -13,7 +13,12 @@
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
Analyser::Static::TargetList Analyser::Static::Sega::GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::Sega::GetTargets(
const Media &media,
const std::string &file_name,
TargetPlatform::IntType,
bool
) {
if(media.cartridges.empty()) if(media.cartridges.empty())
return {}; return {};
@@ -54,7 +59,8 @@ Analyser::Static::TargetList Analyser::Static::Sega::GetTargets(const Media &med
if(lowercase_name.find("(jp)") == std::string::npos) { if(lowercase_name.find("(jp)") == std::string::npos) {
target->region = target->region =
(lowercase_name.find("(us)") == std::string::npos && (lowercase_name.find("(us)") == std::string::npos &&
lowercase_name.find("(ntsc)") == std::string::npos) ? Target::Region::Europe : Target::Region::USA; lowercase_name.find("(ntsc)") == std::string::npos) ?
Target::Region::Europe : Target::Region::USA;
} }
} break; } break;
} }
@@ -63,9 +69,9 @@ Analyser::Static::TargetList Analyser::Static::Sega::GetTargets(const Media &med
// If one is found, set the paging scheme appropriately. // If one is found, set the paging scheme appropriately.
const uint16_t inverse_checksum = uint16_t(0x10000 - (data[0x7fe6] | (data[0x7fe7] << 8))); const uint16_t inverse_checksum = uint16_t(0x10000 - (data[0x7fe6] | (data[0x7fe7] << 8)));
if( if(
data[0x7fe3] >= 0x87 && data[0x7fe3] < 0x96 && // i.e. game is dated between 1987 and 1996 data[0x7fe3] >= 0x87 && data[0x7fe3] < 0x96 && // i.e. game is dated between 1987 and 1996
(inverse_checksum&0xff) == data[0x7fe8] && (inverse_checksum&0xff) == data[0x7fe8] &&
(inverse_checksum >> 8) == data[0x7fe9] && // i.e. the standard checksum appears to be present (inverse_checksum >> 8) == data[0x7fe9] && // i.e. the standard checksum appears to be present.
!data[0x7fea] && !data[0x7feb] && !data[0x7fec] && !data[0x7fed] && !data[0x7fee] && !data[0x7fef] !data[0x7fea] && !data[0x7feb] && !data[0x7fec] && !data[0x7fed] && !data[0x7fee] && !data[0x7fef]
) { ) {
target->paging_scheme = Target::PagingScheme::Codemasters; target->paging_scheme = Target::PagingScheme::Codemasters;

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::Sega { namespace Analyser::Static::Sega {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -37,15 +37,17 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl<Ta
Region region = Region::Japan; Region region = Region::Japan;
PagingScheme paging_scheme = PagingScheme::Sega; PagingScheme paging_scheme = PagingScheme::Sega;
Target() : Analyser::Static::Target(Machine::MasterSystem) { Target() : Analyser::Static::Target(Machine::MasterSystem) {}
if(needs_declare()) {
DeclareField(region); private:
AnnounceEnum(Region); friend Reflection::StructImpl<Target>;
} void declare_fields() {
DeclareField(region);
AnnounceEnum(Region);
} }
}; };
constexpr bool is_master_system(Analyser::Static::Sega::Target::Model model) { constexpr bool is_master_system(const Analyser::Static::Sega::Target::Model model) {
return model >= Analyser::Static::Sega::Target::Model::MasterSystem; return model >= Analyser::Static::Sega::Target::Model::MasterSystem;
} }

View File

@@ -104,14 +104,14 @@ std::string get_extension(const std::string &name) {
} }
class MediaAccumulator { class MediaAccumulator {
public: public:
MediaAccumulator(const std::string &file_name, TargetPlatform::IntType &potential_platforms) : MediaAccumulator(const std::string &file_name, TargetPlatform::IntType &potential_platforms) :
file_name_(file_name), potential_platforms_(potential_platforms), extension_(get_extension(file_name)) {} file_name_(file_name), potential_platforms_(potential_platforms), extension_(get_extension(file_name)) {}
/// Adds @c instance to the media collection and adds @c platforms to the set of potentials. /// Adds @c instance to the media collection and adds @c platforms to the set of potentials.
/// If @c instance is an @c TargetPlatform::TypeDistinguisher then it is given an opportunity to restrict the set of potentials. /// If @c instance is an @c TargetPlatform::TypeDistinguisher then it is given an opportunity to restrict the set of potentials.
template <typename InstanceT> template <typename InstanceT>
void insert(TargetPlatform::IntType platforms, std::shared_ptr<InstanceT> instance) { void insert(const TargetPlatform::IntType platforms, std::shared_ptr<InstanceT> instance) {
if constexpr (std::is_base_of_v<Storage::Disk::Disk, InstanceT>) { if constexpr (std::is_base_of_v<Storage::Disk::Disk, InstanceT>) {
media.disks.push_back(instance); media.disks.push_back(instance);
} else if constexpr (std::is_base_of_v<Storage::Tape::Tape, InstanceT>) { } else if constexpr (std::is_base_of_v<Storage::Tape::Tape, InstanceT>) {
@@ -127,20 +127,23 @@ class MediaAccumulator {
potential_platforms_ |= platforms; potential_platforms_ |= platforms;
// Check whether the instance itself has any input on target platforms. // Check whether the instance itself has any input on target platforms.
TargetPlatform::TypeDistinguisher *const distinguisher = TargetPlatform::Distinguisher *const distinguisher =
dynamic_cast<TargetPlatform::TypeDistinguisher *>(instance.get()); dynamic_cast<TargetPlatform::Distinguisher *>(instance.get());
if(distinguisher) potential_platforms_ &= distinguisher->target_platform_type(); if(distinguisher) {
was_distinguished = true;
potential_platforms_ &= distinguisher->target_platforms();
}
} }
/// Concstructs a new instance of @c InstanceT supplying @c args and adds it to the back of @c list using @c insert_instance. /// Concstructs a new instance of @c InstanceT supplying @c args and adds it to the back of @c list using @c insert_instance.
template <typename InstanceT, typename... Args> template <typename InstanceT, typename... Args>
void insert(TargetPlatform::IntType platforms, Args &&... args) { void insert(const TargetPlatform::IntType platforms, Args &&... args) {
insert(platforms, std::make_shared<InstanceT>(std::forward<Args>(args)...)); insert(platforms, std::make_shared<InstanceT>(std::forward<Args>(args)...));
} }
/// Calls @c insert with the specified parameters, ignoring any exceptions thrown. /// Calls @c insert with the specified parameters, ignoring any exceptions thrown.
template <typename InstanceT, typename... Args> template <typename InstanceT, typename... Args>
void try_insert(TargetPlatform::IntType platforms, Args &&... args) { void try_insert(const TargetPlatform::IntType platforms, Args &&... args) {
try { try {
insert<InstanceT>(platforms, std::forward<Args>(args)...); insert<InstanceT>(platforms, std::forward<Args>(args)...);
} catch(...) {} } catch(...) {}
@@ -149,22 +152,23 @@ class MediaAccumulator {
/// Performs a @c try_insert for an object of @c InstanceT if @c extension matches that of the file name, /// Performs a @c try_insert for an object of @c InstanceT if @c extension matches that of the file name,
/// providing the file name as the only construction argument. /// providing the file name as the only construction argument.
template <typename InstanceT> template <typename InstanceT>
void try_standard(TargetPlatform::IntType platforms, const char *extension) { void try_standard(const TargetPlatform::IntType platforms, const char *extension) {
if(name_matches(extension)) { if(name_matches(extension)) {
try_insert<InstanceT>(platforms, file_name_); try_insert<InstanceT>(platforms, file_name_);
} }
} }
bool name_matches(const char *extension) { bool name_matches(const char *const extension) {
return extension_ == extension; return extension_ == extension;
} }
Media media; Media media;
bool was_distinguished = false;
private: private:
const std::string &file_name_; const std::string &file_name_;
TargetPlatform::IntType &potential_platforms_; TargetPlatform::IntType &potential_platforms_;
const std::string extension_; const std::string extension_;
}; };
} }
@@ -209,7 +213,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
accumulator.try_standard<Cartridge::BinaryDump>(TargetPlatform::Coleco, "col"); accumulator.try_standard<Cartridge::BinaryDump>(TargetPlatform::Coleco, "col");
accumulator.try_standard<Tape::CSW>(TargetPlatform::AllTape, "csw"); accumulator.try_standard<Tape::CSW>(TargetPlatform::AllTape, "csw");
accumulator.try_standard<Disk::DiskImageHolder<Disk::D64>>(TargetPlatform::Commodore, "d64"); accumulator.try_standard<Disk::DiskImageHolder<Disk::D64>>(TargetPlatform::Commodore8bit, "d64");
accumulator.try_standard<MassStorage::DAT>(TargetPlatform::Acorn, "dat"); accumulator.try_standard<MassStorage::DAT>(TargetPlatform::Acorn, "dat");
accumulator.try_standard<Disk::DiskImageHolder<Disk::DMK>>(TargetPlatform::MSX, "dmk"); accumulator.try_standard<Disk::DiskImageHolder<Disk::DMK>>(TargetPlatform::MSX, "dmk");
accumulator.try_standard<Disk::DiskImageHolder<Disk::AppleDSK>>(TargetPlatform::DiskII, "do"); accumulator.try_standard<Disk::DiskImageHolder<Disk::AppleDSK>>(TargetPlatform::DiskII, "do");
@@ -223,11 +227,12 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::MSX, "dsk"); accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::MSX, "dsk");
accumulator.try_standard<Disk::DiskImageHolder<Disk::OricMFMDSK>>(TargetPlatform::Oric, "dsk"); accumulator.try_standard<Disk::DiskImageHolder<Disk::OricMFMDSK>>(TargetPlatform::Oric, "dsk");
accumulator.try_standard<Disk::DiskImageHolder<Disk::G64>>(TargetPlatform::Commodore, "g64"); accumulator.try_standard<Disk::DiskImageHolder<Disk::G64>>(TargetPlatform::Commodore8bit, "g64");
accumulator.try_standard<MassStorage::HDV>(TargetPlatform::AppleII, "hdv"); accumulator.try_standard<MassStorage::HDV>(TargetPlatform::AppleII, "hdv");
accumulator.try_standard<Disk::DiskImageHolder<Disk::HFE>>( accumulator.try_standard<Disk::DiskImageHolder<Disk::HFE>>(
TargetPlatform::Acorn | TargetPlatform::AmstradCPC | TargetPlatform::Commodore | TargetPlatform::Oric | TargetPlatform::ZXSpectrum, TargetPlatform::Acorn | TargetPlatform::AmstradCPC | TargetPlatform::Commodore |
TargetPlatform::Oric | TargetPlatform::ZXSpectrum,
"hfe"); // TODO: switch to AllDisk once the MSX stops being so greedy. "hfe"); // TODO: switch to AllDisk once the MSX stops being so greedy.
accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::PCCompatible, "ima"); accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::PCCompatible, "ima");
@@ -267,10 +272,10 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
if(accumulator.name_matches("prg")) { if(accumulator.name_matches("prg")) {
// Try instantiating as a ROM; failing that accept as a tape. // Try instantiating as a ROM; failing that accept as a tape.
try { try {
accumulator.insert<Cartridge::PRG>(TargetPlatform::Commodore, file_name); accumulator.insert<Cartridge::PRG>(TargetPlatform::Commodore8bit, file_name);
} catch(...) { } catch(...) {
try { try {
accumulator.insert<Tape::PRG>(TargetPlatform::Commodore, file_name); accumulator.insert<Tape::PRG>(TargetPlatform::Commodore8bit, file_name);
} catch(...) {} } catch(...) {}
} }
} }
@@ -285,7 +290,7 @@ static Media GetMediaAndPlatforms(const std::string &file_name, TargetPlatform::
accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::AtariST, "st"); accumulator.try_standard<Disk::DiskImageHolder<Disk::FAT12>>(TargetPlatform::AtariST, "st");
accumulator.try_standard<Disk::DiskImageHolder<Disk::STX>>(TargetPlatform::AtariST, "stx"); accumulator.try_standard<Disk::DiskImageHolder<Disk::STX>>(TargetPlatform::AtariST, "stx");
accumulator.try_standard<Tape::CommodoreTAP>(TargetPlatform::Commodore, "tap"); accumulator.try_standard<Tape::CommodoreTAP>(TargetPlatform::Commodore8bit, "tap");
accumulator.try_standard<Tape::OricTAP>(TargetPlatform::Oric, "tap"); accumulator.try_standard<Tape::OricTAP>(TargetPlatform::Oric, "tap");
accumulator.try_standard<Tape::ZXSpectrumTAP>(TargetPlatform::ZXSpectrum, "tap"); accumulator.try_standard<Tape::ZXSpectrumTAP>(TargetPlatform::ZXSpectrum, "tap");
accumulator.try_standard<Tape::TZX>(TargetPlatform::MSX, "tsx"); accumulator.try_standard<Tape::TZX>(TargetPlatform::MSX, "tsx");
@@ -334,14 +339,30 @@ TargetList Analyser::Static::GetTargets(const std::string &file_name) {
TargetPlatform::IntType potential_platforms = 0; TargetPlatform::IntType potential_platforms = 0;
Media media = GetMediaAndPlatforms(file_name, potential_platforms); Media media = GetMediaAndPlatforms(file_name, potential_platforms);
// TODO: std::popcount here.
int total_options = 0;
TargetPlatform::IntType mask = 1;
while(mask) {
total_options += bool(potential_platforms & mask);
mask <<= 1;
}
const bool is_confident = total_options == 1;
// i.e. This analyser `is_confident` if file analysis suggested only one potential target platform.
// The machine-specific static analyser will still run in case it can provide meaningful annotations on
// loading command, machine configuration, etc, but the flag will be passed onwards to mean "don't reject this".
// Hand off to platform-specific determination of whether these // Hand off to platform-specific determination of whether these
// things are actually compatible and, if so, how to load them. // things are actually compatible and, if so, how to load them.
const auto append = [&](TargetPlatform::IntType platform, auto evaluator) { const auto append = [&](TargetPlatform::IntType platform, auto evaluator) {
if(!(potential_platforms & platform)) { if(!(potential_platforms & platform)) {
return; return;
} }
auto new_targets = evaluator(media, file_name, potential_platforms); auto new_targets = evaluator(media, file_name, potential_platforms, is_confident);
std::move(new_targets.begin(), new_targets.end(), std::back_inserter(targets)); targets.insert(
targets.end(),
std::make_move_iterator(new_targets.begin()),
std::make_move_iterator(new_targets.end())
);
}; };
append(TargetPlatform::Acorn, Acorn::GetTargets); append(TargetPlatform::Acorn, Acorn::GetTargets);
@@ -352,7 +373,7 @@ TargetList Analyser::Static::GetTargets(const std::string &file_name) {
append(TargetPlatform::Atari2600, Atari2600::GetTargets); append(TargetPlatform::Atari2600, Atari2600::GetTargets);
append(TargetPlatform::AtariST, AtariST::GetTargets); append(TargetPlatform::AtariST, AtariST::GetTargets);
append(TargetPlatform::Coleco, Coleco::GetTargets); append(TargetPlatform::Coleco, Coleco::GetTargets);
append(TargetPlatform::Commodore, Commodore::GetTargets); append(TargetPlatform::Commodore8bit, Commodore::GetTargets);
append(TargetPlatform::DiskII, DiskII::GetTargets); append(TargetPlatform::DiskII, DiskII::GetTargets);
append(TargetPlatform::Enterprise, Enterprise::GetTargets); append(TargetPlatform::Enterprise, Enterprise::GetTargets);
append(TargetPlatform::FAT12, FAT12::GetTargets); append(TargetPlatform::FAT12, FAT12::GetTargets);
@@ -364,13 +385,6 @@ TargetList Analyser::Static::GetTargets(const std::string &file_name) {
append(TargetPlatform::ZX8081, ZX8081::GetTargets); append(TargetPlatform::ZX8081, ZX8081::GetTargets);
append(TargetPlatform::ZXSpectrum, ZXSpectrum::GetTargets); append(TargetPlatform::ZXSpectrum, ZXSpectrum::GetTargets);
// Reset any tapes to their initial position.
for(const auto &target : targets) {
for(auto &tape : target->media.tapes) {
tape->reset();
}
}
// Sort by initial confidence. Use a stable sort in case any of the machine-specific analysers // Sort by initial confidence. Use a stable sort in case any of the machine-specific analysers
// picked their insertion order carefully. // picked their insertion order carefully.
std::stable_sort(targets.begin(), targets.end(), std::stable_sort(targets.begin(), targets.end(),

View File

@@ -14,6 +14,7 @@
#include "../../Storage/Disk/Disk.hpp" #include "../../Storage/Disk/Disk.hpp"
#include "../../Storage/MassStorage/MassStorageDevice.hpp" #include "../../Storage/MassStorage/MassStorageDevice.hpp"
#include "../../Storage/Tape/Tape.hpp" #include "../../Storage/Tape/Tape.hpp"
#include "../../Storage/TargetPlatforms.hpp"
#include "../../Reflection/Struct.hpp" #include "../../Reflection/Struct.hpp"
#include <memory> #include <memory>
@@ -38,12 +39,15 @@ struct Media {
} }
Media &operator +=(const Media &rhs) { Media &operator +=(const Media &rhs) {
#define append(name) name.insert(name.end(), rhs.name.begin(), rhs.name.end()); const auto append = [&](auto &destination, auto &source) {
append(disks); destination.insert(destination.end(), source.begin(), source.end());
append(tapes); };
append(cartridges);
append(mass_storage_devices); append(disks, rhs.disks);
#undef append append(tapes, rhs.tapes);
append(cartridges, rhs.cartridges);
append(mass_storage_devices, rhs.mass_storage_devices);
return *this; return *this;
} }
}; };
@@ -54,16 +58,16 @@ struct Media {
*/ */
struct Target { struct Target {
Target(Machine machine) : machine(machine) {} Target(Machine machine) : machine(machine) {}
virtual ~Target() {} virtual ~Target() = default;
// This field is entirely optional. // This field is entirely optional.
std::unique_ptr<Reflection::Struct> state; std::unique_ptr<Reflection::Struct> state;
Machine machine; Machine machine;
Media media; Media media;
float confidence = 0.0f; float confidence = 0.5f;
}; };
typedef std::vector<std::unique_ptr<Target>> TargetList; using TargetList = std::vector<std::unique_ptr<Target>>;
/*! /*!
Attempts, through any available means, to return a list of potential targets for the file with the given name. Attempts, through any available means, to return a list of potential targets for the file with the given name.

View File

@@ -14,25 +14,30 @@
#include "Target.hpp" #include "Target.hpp"
#include "../../../Storage/Tape/Parsers/ZX8081.hpp" #include "../../../Storage/Tape/Parsers/ZX8081.hpp"
static std::vector<Storage::Data::ZX8081::File> GetFiles(const std::shared_ptr<Storage::Tape::Tape> &tape) { static std::vector<Storage::Data::ZX8081::File> GetFiles(Storage::Tape::TapeSerialiser &serialiser) {
std::vector<Storage::Data::ZX8081::File> files; std::vector<Storage::Data::ZX8081::File> files;
Storage::Tape::ZX8081::Parser parser; Storage::Tape::ZX8081::Parser parser;
while(!tape->is_at_end()) { while(!serialiser.is_at_end()) {
std::shared_ptr<Storage::Data::ZX8081::File> next_file = parser.get_next_file(tape); const auto next_file = parser.get_next_file(serialiser);
if(next_file != nullptr) { if(next_file) {
files.push_back(*next_file); files.push_back(std::move(*next_file));
} }
} }
return files; return files;
} }
Analyser::Static::TargetList Analyser::Static::ZX8081::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType potential_platforms) { Analyser::Static::TargetList Analyser::Static::ZX8081::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType potential_platforms,
bool
) {
TargetList destination; TargetList destination;
if(!media.tapes.empty()) { if(!media.tapes.empty()) {
std::vector<Storage::Data::ZX8081::File> files = GetFiles(media.tapes.front()); const auto serialiser = media.tapes.front()->serialiser();
media.tapes.front()->reset(); std::vector<Storage::Data::ZX8081::File> files = GetFiles(*serialiser);
if(!files.empty()) { if(!files.empty()) {
Target *const target = new Target; Target *const target = new Target;
destination.push_back(std::unique_ptr<::Analyser::Static::Target>(target)); destination.push_back(std::unique_ptr<::Analyser::Static::Target>(target));

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::ZX8081 { namespace Analyser::Static::ZX8081 {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -27,13 +27,15 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
bool ZX80_uses_ZX81_ROM = false; bool ZX80_uses_ZX81_ROM = false;
std::string loading_command; std::string loading_command;
Target(): Analyser::Static::Target(Machine::ZX8081) { Target(): Analyser::Static::Target(Machine::ZX8081) {}
if(needs_declare()) {
DeclareField(memory_model); private:
DeclareField(is_ZX81); friend Reflection::StructImpl<Target>;
DeclareField(ZX80_uses_ZX81_ROM); void declare_fields() {
AnnounceEnum(MemoryModel); DeclareField(memory_model);
} DeclareField(is_ZX81);
DeclareField(ZX80_uses_ZX81_ROM);
AnnounceEnum(MemoryModel);
} }
}; };

View File

@@ -8,14 +8,17 @@
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include "../../../Storage/Disk/Parsers/CPM.hpp"
#include "../../../Storage/Disk/Encodings/MFM/Parser.hpp" #include "../../../Storage/Disk/Encodings/MFM/Parser.hpp"
#include "../../../Storage/Tape/Parsers/Spectrum.hpp" #include "../../../Storage/Tape/Parsers/Spectrum.hpp"
#include "Target.hpp" #include "Target.hpp"
#include <algorithm>
namespace { namespace {
bool IsSpectrumTape(const std::shared_ptr<Storage::Tape::Tape> &tape) { bool IsSpectrumTape(Storage::Tape::TapeSerialiser &tape) {
using Parser = Storage::Tape::ZXSpectrum::Parser; using Parser = Storage::Tape::ZXSpectrum::Parser;
Parser parser(Parser::MachineType::ZXSpectrum); Parser parser(Parser::MachineType::ZXSpectrum);
@@ -35,28 +38,77 @@ bool IsSpectrumTape(const std::shared_ptr<Storage::Tape::Tape> &tape) {
bool IsSpectrumDisk(const std::shared_ptr<Storage::Disk::Disk> &disk) { bool IsSpectrumDisk(const std::shared_ptr<Storage::Disk::Disk> &disk) {
Storage::Encodings::MFM::Parser parser(Storage::Encodings::MFM::Density::Double, disk); Storage::Encodings::MFM::Parser parser(Storage::Encodings::MFM::Density::Double, disk);
// Get logical sector 1; the Spectrum appears to support various physical // Grab absolutely any sector from the first track to determine general encoding.
// sectors as sector 1. const Storage::Encodings::MFM::Sector *any_sector = parser.any_sector(0, 0);
const Storage::Encodings::MFM::Sector *boot_sector = nullptr; if(!any_sector) return false;
uint8_t sector_mask = 0;
while(!boot_sector) { // Determine the sector base and get logical sector 1.
boot_sector = parser.sector(0, 0, sector_mask + 1); const uint8_t sector_base = any_sector->address.sector & 0xc0;
sector_mask += 0x40; const Storage::Encodings::MFM::Sector *boot_sector = parser.sector(0, 0, sector_base + 1);
if(!sector_mask) break;
}
if(!boot_sector) return false; if(!boot_sector) return false;
// Test that the contents of the boot sector sum to 3, modulo 256. Storage::Disk::CPM::ParameterBlock cpm_format{};
uint8_t byte_sum = 0; switch(sector_base) {
for(auto byte: boot_sector->samples[0]) { case 0x40: cpm_format = Storage::Disk::CPM::ParameterBlock::cpc_system_format(); break;
byte_sum += byte; case 0xc0: cpm_format = Storage::Disk::CPM::ParameterBlock::cpc_data_format(); break;
default: {
// Check the first ten bytes of the first sector for the disk format; if these are all
// the same value then instead substitute a default format.
std::array<uint8_t, 10> format;
std::copy(boot_sector->samples[0].begin(), boot_sector->samples[0].begin() + 10, format.begin());
if(std::all_of(format.begin(), format.end(), [&](const uint8_t v) { return v == format[0]; })) {
format = {0x00, 0x00, 0x28, 0x09, 0x02, 0x01, 0x03, 0x02, 0x2a, 0x52};
}
// Parse those ten bytes as:
//
// Byte 0: disc type
// Byte 1: sidedness
// bits 0-6: arrangement
// 0 => single sided
// 1 => double sided, flip sides
// 2 => double sided, up and over
// bit 7: double-track
// Byte 2: number of tracks per side
// Byte 3: number of sectors per track
// Byte 4: Log2(sector size) - 7
// Byte 5: number of reserved tracks
// Byte 6: Log2(block size) - 7
// Byte 7: number of directory blocks
// Byte 8: gap length (read/write)
// Byte 9: gap length(format)
cpm_format.sectors_per_track = format[3];
cpm_format.tracks = format[2];
cpm_format.block_size = 128 << format[6];
cpm_format.first_sector = sector_base + 1;
cpm_format.reserved_tracks = format[5];
// i.e. bits set downward from 0x4000 for as many blocks as form the catalogue.
cpm_format.catalogue_allocation_bitmap = 0x8000 - (0x8000 >> format[7]);
} break;
} }
return byte_sum == 3;
// If the boot sector sums to 3 modulo 256 then this is a Spectrum disk.
const auto byte_sum = static_cast<uint8_t>(
std::accumulate(boot_sector->samples[0].begin(), boot_sector->samples[0].end(), 0));
if(byte_sum == 3) {
return true;
}
// ... otherwise read a CPM directory and look for a BASIC program called "DISK".
const auto catalogue = Storage::Disk::CPM::GetCatalogue(disk, cpm_format, false);
return catalogue && catalogue->is_zx_spectrum_booter();
} }
} }
Analyser::Static::TargetList Analyser::Static::ZXSpectrum::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) { Analyser::Static::TargetList Analyser::Static::ZXSpectrum::GetTargets(
const Media &media,
const std::string &,
TargetPlatform::IntType,
bool
) {
TargetList destination; TargetList destination;
auto target = std::make_unique<Target>(); auto target = std::make_unique<Target>();
target->confidence = 0.5; target->confidence = 0.5;
@@ -64,7 +116,8 @@ Analyser::Static::TargetList Analyser::Static::ZXSpectrum::GetTargets(const Medi
if(!media.tapes.empty()) { if(!media.tapes.empty()) {
bool has_spectrum_tape = false; bool has_spectrum_tape = false;
for(auto &tape: media.tapes) { for(auto &tape: media.tapes) {
has_spectrum_tape |= IsSpectrumTape(tape); auto serialiser = tape->serialiser();
has_spectrum_tape |= IsSpectrumTape(*serialiser);
} }
if(has_spectrum_tape) { if(has_spectrum_tape) {

View File

@@ -14,6 +14,6 @@
namespace Analyser::Static::ZXSpectrum { namespace Analyser::Static::ZXSpectrum {
TargetList GetTargets(const Media &media, const std::string &file_name, TargetPlatform::IntType potential_platforms); TargetList GetTargets(const Media &, const std::string &, TargetPlatform::IntType, bool);
} }

View File

@@ -27,11 +27,13 @@ struct Target: public ::Analyser::Static::Target, public Reflection::StructImpl<
Model model = Model::Plus2; Model model = Model::Plus2;
bool should_hold_enter = false; bool should_hold_enter = false;
Target(): Analyser::Static::Target(Machine::ZXSpectrum) { Target(): Analyser::Static::Target(Machine::ZXSpectrum) {}
if(needs_declare()) {
DeclareField(model); private:
AnnounceEnum(Model); friend Reflection::StructImpl<Target>;
} void declare_fields() {
DeclareField(model);
AnnounceEnum(Model);
} }
}; };

99
BUILD.md Normal file
View File

@@ -0,0 +1,99 @@
![Clock Signal Application Icon](READMEImages/Icon.png)
# Building Clock Signal
Clock Signal is available as [a macOS native application using
Metal](#macos-app) or as [a cross-platform command-line-driven SDL executable
using OpenGL](#sdl-app).
## macOS app
The macOS native application requires a Metal-capable Mac running macOS 10.13 or
later and has no prerequisites beyond the normal system libraries. It can be
built [using Xcode](#building-the-macos-app-using-xcode) or on the command line
[using `xcodebuild`](#building-the-macos-app-using-xcodebuild).
Machine ROMs are intended to be built into the application bundle; populate the
dummy folders below ROMImages before building.
The Xcode project is configured to sign the application using the developer's
certificate, but if you are not the developer then you will get a "No signing
certificate" error. To avoid this, you'll specify that you want to sign the
application to run locally.
### Building the macOS app using Xcode
Open the Clock Signal Xcode project in OSBindings/Mac.
To avoid signing errors, edit the project, select the Signing & Capabilities
tab, and change the Signing Certificate drop-down menu from "Development" to
"Sign to Run Locally".
To avoid crashes when running Clock Signal via Xcode on older Macs due to
"unrecognized selector sent to instance" errors, edit the scheme, and in the Run
section, scroll down to the Metal heading and uncheck the "API Validation"
checkbox.
To build, choose "Build" from Xcode's Product menu or press
<kbd>Command</kbd> + <kbd>B</kbd>.
To build and run, choose "Run" from the Product menu or press
<kbd>Command</kbd> + <kbd>R</kbd>.
To see the folder where the Clock Signal application was built, choose "Show
Build Folder in Finder" from the Product menu. Look in the "Products" folder for
a folder named after the configuration (e.g. "Debug" or "Release").
### Building the macOS app using `xcodebuild`
To build, change to the OSBindings/Mac directory in the Terminal, then run
`xcodebuild`, specifying `-` as the code sign identity to sign the application
to run locally to avoid signing errors:
cd OSBindings/Mac
xcodebuild CODE_SIGN_IDENTITY=-
`xcodebuild` will create a "build" folder in this directory which is where you
can find the Clock Signal application after it's compiled, in a directory named
after the configuration (e.g. "Debug" or "Release").
## SDL app
The SDL app can be built on Linux, BSD, macOS, and other Unix-like operating
systems. Prerequisites are SDL 2, ZLib and OpenGL (or Mesa). OpenGL 3.2 or
better is required at runtime. It can be built [using
SCons](#building-the-sdl-app-using-scons).
### Building the SDL app using SCons
To build, change to the OSBindings/SDL directory and run `scons`. You can add a
`-j` flag to build in parallel. For example, if you have 8 processor cores:
cd OSBindings/SDL
scons -j8
The `clksignal` executable will be created in this directory. You can run it
from here or install it by copying it where you want it, for example:
cp clksignal /usr/local/bin
To start an emulator with a particular disk image `file`, if you've installed
`clksignal` to a directory in your `PATH`, run:
clksignal file
Or if you're running it from the current directory:
./clksignal file
Other options are availble. Run `clksignal` or `./clksignal` with no arguments
to learn more.
Setting up `clksignal` as the associated program for supported file types in
your favoured filesystem browser is recommended; it has no file navigation
abilities of its own.
Some emulated systems require the provision of original machine ROMs. These are
not included and may be located in either /usr/local/share/CLK/ or
/usr/share/CLK/. You will be prompted for them if they are found to be missing.
The structure should mirror that under OSBindings in the source archive; see the
readme.txt in each folder to determine the proper files and names ahead of time.

View File

@@ -1,30 +0,0 @@
Linux, BSD
==========
Prerequisites are SDL 2, ZLib and OpenGL (or Mesa), and SCons for the provided build script. OpenGL 3.2 or better is required at runtime.
Build:
cd OSBindings/SDL
scons
Optionally:
cp clksignal /usr/bin
To launch:
clksignal file
Setting up clksignal as the associated program for supported file types in your favoured filesystem browser is recommended; it has no file navigation abilities of its own.
Some emulated systems require the provision of original machine ROMs. These are not included and may be located in either /usr/local/share/CLK/ or /usr/share/CLK/. You will be prompted for them if they are found to be missing. The structure should mirror that under OSBindings in the source archive; see the readme.txt in each folder to determine the proper files and names ahead of time.
macOS
=====
There are no prerequisites beyond the normal system libraries; the macOS build is a native Cocoa application.
Build: open the Xcode project in OSBindings/Mac and press command+b.
Machine ROMs are intended to be built into the application bundle; populate the dummy folders below ROMImages before building.

70
CMakeLists.txt Normal file
View File

@@ -0,0 +1,70 @@
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
project(CLK
LANGUAGES CXX
VERSION 24.01.22
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CLK_UIS "SDL")
#list(PREPEND CLK_UIS "QT")
#if(APPLE)
# list(PREPEND CLK_UIS "MAC")
# set(CLK_DEFAULT_UI "MAC")
#else()
set(CLK_DEFAULT_UI "SDL")
#endif()
set(CLK_UI ${CLK_DEFAULT_UI} CACHE STRING "User interface")
set_property(CACHE CLK_UI PROPERTY STRINGS ${CLK_UIS})
if(NOT CLK_UI IN_LIST CLK_UIS)
list(JOIN CLK_UIS ", " CLK_UIS_PRETTY)
message(FATAL_ERROR "Invalid value for 'CLK_UI'; must be one of ${CLK_UIS_PRETTY}")
endif()
message(STATUS "Configuring for ${CLK_UI} UI")
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include("CLK_SOURCES")
add_executable(clksignal ${CLK_SOURCES})
if(MSVC)
target_compile_options(clksignal PRIVATE /W4)
else()
# TODO: Add -Wpedandic.
target_compile_options(clksignal PRIVATE -Wall -Wextra)
endif()
find_package(ZLIB REQUIRED)
target_link_libraries(clksignal PRIVATE ZLIB::ZLIB)
if(CLK_UI STREQUAL "MAC")
enable_language(OBJC OBJCXX SWIFT)
# TODO: Build the Mac version.
else()
find_package(OpenGL REQUIRED)
target_link_libraries(clksignal PRIVATE OpenGL::GL)
if(APPLE)
target_compile_definitions(clksignal PRIVATE "GL_SILENCE_DEPRECATION" "IGNORE_APPLE")
endif()
endif()
if(CLK_UI STREQUAL "QT")
# TODO: Build the Qt version.
elseif(APPLE)
set(BLA_VENDOR Apple)
find_package(BLAS REQUIRED)
target_link_libraries(clksignal PRIVATE BLAS::BLAS)
endif()
if(CLK_UI STREQUAL "SDL")
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
target_link_libraries(clksignal PRIVATE SDL2::SDL2)
endif()
# TODO: Investigate building on Windows.

View File

@@ -56,205 +56,225 @@
Boolean operators, but forcing callers and receivers to be explicit as to usage. Boolean operators, but forcing callers and receivers to be explicit as to usage.
*/ */
template <class T> class WrappedInt { template <class T> class WrappedInt {
public: public:
using IntType = int64_t; using IntType = int64_t;
forceinline constexpr WrappedInt(IntType l) noexcept : length_(l) {} forceinline constexpr WrappedInt(IntType l) noexcept : length_(l) {}
forceinline constexpr WrappedInt() noexcept : length_(0) {} forceinline constexpr WrappedInt() noexcept : length_(0) {}
forceinline T &operator =(const T &rhs) { forceinline T &operator =(const T &rhs) {
length_ = rhs.length_; length_ = rhs.length_;
return *this; return *this;
}
forceinline T &operator +=(const T &rhs) {
length_ += rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator -=(const T &rhs) {
length_ -= rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator ++() {
++ length_;
return *static_cast<T *>(this);
}
forceinline T &operator ++(int) {
length_ ++;
return *static_cast<T *>(this);
}
forceinline T &operator --() {
-- length_;
return *static_cast<T *>(this);
}
forceinline T &operator --(int) {
length_ --;
return *static_cast<T *>(this);
}
forceinline T &operator *=(const T &rhs) {
length_ *= rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator /=(const T &rhs) {
length_ /= rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator %=(const T &rhs) {
length_ %= rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator &=(const T &rhs) {
length_ &= rhs.length_;
return *static_cast<T *>(this);
}
forceinline constexpr T operator +(const T &rhs) const { return T(length_ + rhs.length_); }
forceinline constexpr T operator -(const T &rhs) const { return T(length_ - rhs.length_); }
forceinline constexpr T operator *(const T &rhs) const { return T(length_ * rhs.length_); }
forceinline constexpr T operator /(const T &rhs) const { return T(length_ / rhs.length_); }
forceinline constexpr T operator %(const T &rhs) const { return T(length_ % rhs.length_); }
forceinline constexpr T operator &(const T &rhs) const { return T(length_ & rhs.length_); }
forceinline constexpr T operator -() const { return T(- length_); }
forceinline constexpr bool operator <(const T &rhs) const { return length_ < rhs.length_; }
forceinline constexpr bool operator >(const T &rhs) const { return length_ > rhs.length_; }
forceinline constexpr bool operator <=(const T &rhs) const { return length_ <= rhs.length_; }
forceinline constexpr bool operator >=(const T &rhs) const { return length_ >= rhs.length_; }
forceinline constexpr bool operator ==(const T &rhs) const { return length_ == rhs.length_; }
forceinline constexpr bool operator !=(const T &rhs) const { return length_ != rhs.length_; }
forceinline constexpr bool operator !() const { return !length_; }
// bool operator () is not supported because it offers an implicit cast to int,
// which is prone silently to permit misuse.
/// @returns The underlying int, converted to an integral type of your choosing, clamped to that int's range.
template<typename Type = IntType> forceinline constexpr Type as() const {
if constexpr (sizeof(Type) == sizeof(IntType)) {
if constexpr (std::is_same_v<Type, IntType>) {
return length_;
} else if constexpr (std::is_signed_v<Type>) {
// Both integers are the same size, but a signed result is being asked for
// from an unsigned original.
return length_ > Type(std::numeric_limits<Type>::max()) ?
Type(std::numeric_limits<Type>::max()) : Type(length_);
} else {
// An unsigned result is being asked for from a signed original.
return length_ < 0 ? 0 : Type(length_);
}
} }
forceinline T &operator +=(const T &rhs) { const auto clamped = std::clamp(
length_ += rhs.length_; length_,
return *static_cast<T *>(this); IntType(std::numeric_limits<Type>::min()),
} IntType(std::numeric_limits<Type>::max())
);
return Type(clamped);
}
forceinline T &operator -=(const T &rhs) { /// @returns The underlying int, in its native form.
length_ -= rhs.length_; forceinline constexpr IntType as_integral() const { return length_; }
return *static_cast<T *>(this);
}
forceinline T &operator ++() { /*!
++ length_; Severs from @c this the effect of dividing by @c divisor; @c this will end up with
return *static_cast<T *>(this); the value of @c this modulo @c divisor and @c divided by @c divisor is returned.
} */
template <typename Result = T> forceinline Result divide(const T &divisor) {
Result r;
static_cast<T *>(this)->fill(r, divisor);
return r;
}
forceinline T &operator ++(int) { /*!
length_ ++; Flushes the value in @c this. The current value is returned, and the internal value
return *static_cast<T *>(this); is reset to zero.
} */
template <typename Result> Result flush() {
// Jiggery pokery here; switching to function overloading avoids
// the namespace-level requirement for template specialisation.
Result r;
static_cast<T *>(this)->fill(r);
return r;
}
forceinline T &operator --() { // operator int() is deliberately not provided, to avoid accidental subtitution of
-- length_; // classes that use this template.
return *static_cast<T *>(this);
}
forceinline T &operator --(int) { protected:
length_ --; IntType length_;
return *static_cast<T *>(this);
}
forceinline T &operator *=(const T &rhs) {
length_ *= rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator /=(const T &rhs) {
length_ /= rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator %=(const T &rhs) {
length_ %= rhs.length_;
return *static_cast<T *>(this);
}
forceinline T &operator &=(const T &rhs) {
length_ &= rhs.length_;
return *static_cast<T *>(this);
}
forceinline constexpr T operator +(const T &rhs) const { return T(length_ + rhs.length_); }
forceinline constexpr T operator -(const T &rhs) const { return T(length_ - rhs.length_); }
forceinline constexpr T operator *(const T &rhs) const { return T(length_ * rhs.length_); }
forceinline constexpr T operator /(const T &rhs) const { return T(length_ / rhs.length_); }
forceinline constexpr T operator %(const T &rhs) const { return T(length_ % rhs.length_); }
forceinline constexpr T operator &(const T &rhs) const { return T(length_ & rhs.length_); }
forceinline constexpr T operator -() const { return T(- length_); }
forceinline constexpr bool operator <(const T &rhs) const { return length_ < rhs.length_; }
forceinline constexpr bool operator >(const T &rhs) const { return length_ > rhs.length_; }
forceinline constexpr bool operator <=(const T &rhs) const { return length_ <= rhs.length_; }
forceinline constexpr bool operator >=(const T &rhs) const { return length_ >= rhs.length_; }
forceinline constexpr bool operator ==(const T &rhs) const { return length_ == rhs.length_; }
forceinline constexpr bool operator !=(const T &rhs) const { return length_ != rhs.length_; }
forceinline constexpr bool operator !() const { return !length_; }
// bool operator () is not supported because it offers an implicit cast to int, which is prone silently to permit misuse
/// @returns The underlying int, converted to an integral type of your choosing, clamped to that int's range.
template<typename Type = IntType> forceinline constexpr Type as() const {
const auto clamped = std::clamp(length_, IntType(std::numeric_limits<Type>::min()), IntType(std::numeric_limits<Type>::max()));
return Type(clamped);
}
/// @returns The underlying int, in its native form.
forceinline constexpr IntType as_integral() const { return length_; }
/*!
Severs from @c this the effect of dividing by @c divisor; @c this will end up with
the value of @c this modulo @c divisor and @c divided by @c divisor is returned.
*/
template <typename Result = T> forceinline Result divide(const T &divisor) {
Result r;
static_cast<T *>(this)->fill(r, divisor);
return r;
}
/*!
Flushes the value in @c this. The current value is returned, and the internal value
is reset to zero.
*/
template <typename Result> Result flush() {
// Jiggery pokery here; switching to function overloading avoids
// the namespace-level requirement for template specialisation.
Result r;
static_cast<T *>(this)->fill(r);
return r;
}
// operator int() is deliberately not provided, to avoid accidental subtitution of
// classes that use this template.
protected:
IntType length_;
}; };
/// Describes an integer number of whole cycles: pairs of clock signal transitions. /// Describes an integer number of whole cycles: pairs of clock signal transitions.
class Cycles: public WrappedInt<Cycles> { class Cycles: public WrappedInt<Cycles> {
public: public:
forceinline constexpr Cycles(IntType l) noexcept : WrappedInt<Cycles>(l) {} forceinline constexpr Cycles(IntType l) noexcept : WrappedInt<Cycles>(l) {}
forceinline constexpr Cycles() noexcept : WrappedInt<Cycles>() {} forceinline constexpr Cycles() noexcept : WrappedInt<Cycles>() {}
forceinline static constexpr Cycles max() { forceinline static constexpr Cycles max() {
return Cycles(std::numeric_limits<IntType>::max()); return Cycles(std::numeric_limits<IntType>::max());
} }
private: private:
friend WrappedInt; friend WrappedInt;
void fill(Cycles &result) { void fill(Cycles &result) {
result.length_ = length_; result.length_ = length_;
length_ = 0; length_ = 0;
} }
void fill(Cycles &result, const Cycles &divisor) { void fill(Cycles &result, const Cycles &divisor) {
result.length_ = length_ / divisor.length_; result.length_ = length_ / divisor.length_;
length_ %= divisor.length_; length_ %= divisor.length_;
} }
}; };
/// Describes an integer number of half cycles: single clock signal transitions. /// Describes an integer number of half cycles: single clock signal transitions.
class HalfCycles: public WrappedInt<HalfCycles> { class HalfCycles: public WrappedInt<HalfCycles> {
public: public:
forceinline constexpr HalfCycles(IntType l) noexcept : WrappedInt<HalfCycles>(l) {} forceinline constexpr HalfCycles(IntType l) noexcept : WrappedInt<HalfCycles>(l) {}
forceinline constexpr HalfCycles() noexcept : WrappedInt<HalfCycles>() {} forceinline constexpr HalfCycles() noexcept : WrappedInt<HalfCycles>() {}
forceinline static constexpr HalfCycles max() { forceinline static constexpr HalfCycles max() {
return HalfCycles(std::numeric_limits<IntType>::max()); return HalfCycles(std::numeric_limits<IntType>::max());
} }
forceinline constexpr HalfCycles(const Cycles &cycles) noexcept : WrappedInt<HalfCycles>(cycles.as_integral() * 2) {} forceinline constexpr HalfCycles(const Cycles &cycles) noexcept :
WrappedInt<HalfCycles>(cycles.as_integral() * 2) {}
/// @returns The number of whole cycles completely covered by this span of half cycles. /// @returns The number of whole cycles completely covered by this span of half cycles.
forceinline constexpr Cycles cycles() const { forceinline constexpr Cycles cycles() const {
return Cycles(length_ >> 1); return Cycles(length_ >> 1);
} }
/*! /*!
Severs from @c this the effect of dividing by @c divisor; @c this will end up with Severs from @c this the effect of dividing by @c divisor; @c this will end up with
the value of @c this modulo @c divisor . @c this divided by @c divisor is returned. the value of @c this modulo @c divisor . @c this divided by @c divisor is returned.
*/ */
forceinline Cycles divide_cycles(const Cycles &divisor) { forceinline Cycles divide_cycles(const Cycles &divisor) {
const HalfCycles half_divisor = HalfCycles(divisor); const HalfCycles half_divisor = HalfCycles(divisor);
const Cycles result(length_ / half_divisor.length_); const Cycles result(length_ / half_divisor.length_);
length_ %= half_divisor.length_; length_ %= half_divisor.length_;
return result; return result;
} }
/*! /*!
Equivalent to @c divide_cycles(Cycles(1)) but faster. Equivalent to @c divide_cycles(Cycles(1)) but faster.
*/ */
forceinline Cycles divide_cycles() { forceinline Cycles divide_cycles() {
const Cycles result(length_ >> 1); const Cycles result(length_ >> 1);
length_ &= 1; length_ &= 1;
return result; return result;
} }
private: private:
friend WrappedInt; friend WrappedInt;
void fill(Cycles &result) { void fill(Cycles &result) {
result = Cycles(length_ >> 1); result = Cycles(length_ >> 1);
length_ &= 1; length_ &= 1;
} }
void fill(HalfCycles &result) { void fill(HalfCycles &result) {
result.length_ = length_; result.length_ = length_;
length_ = 0; length_ = 0;
} }
void fill(Cycles &result, const HalfCycles &divisor) { void fill(Cycles &result, const HalfCycles &divisor) {
result = Cycles(length_ / (divisor.length_ << 1)); result = Cycles(length_ / (divisor.length_ << 1));
length_ %= (divisor.length_ << 1); length_ %= (divisor.length_ << 1);
} }
void fill(HalfCycles &result, const HalfCycles &divisor) { void fill(HalfCycles &result, const HalfCycles &divisor) {
result.length_ = length_ / divisor.length_; result.length_ = length_ / divisor.length_;
length_ %= divisor.length_; length_ %= divisor.length_;
} }
}; };
// Create a specialisation of WrappedInt::flush for converting HalfCycles to Cycles // Create a specialisation of WrappedInt::flush for converting HalfCycles to Cycles
@@ -265,14 +285,14 @@ class HalfCycles: public WrappedInt<HalfCycles> {
automatically to gain run_for(HalfCycles). automatically to gain run_for(HalfCycles).
*/ */
template <class T> class HalfClockReceiver: public T { template <class T> class HalfClockReceiver: public T {
public: public:
using T::T; using T::T;
forceinline void run_for(const HalfCycles half_cycles) { forceinline void run_for(const HalfCycles half_cycles) {
half_cycles_ += half_cycles; half_cycles_ += half_cycles;
T::run_for(half_cycles_.flush<Cycles>()); T::run_for(half_cycles_.flush<Cycles>());
} }
private: private:
HalfCycles half_cycles_; HalfCycles half_cycles_;
}; };

View File

@@ -58,28 +58,28 @@ struct Observer {
The hint provided is just that: a hint. Owners may perform ::run_for at a greater frequency. The hint provided is just that: a hint. Owners may perform ::run_for at a greater frequency.
*/ */
class Source { class Source {
public: public:
/// Registers @c observer as the new clocking observer. /// Registers @c observer as the new clocking observer.
void set_clocking_hint_observer(Observer *observer) { void set_clocking_hint_observer(Observer *observer) {
observer_ = observer; observer_ = observer;
update_clocking_observer(); update_clocking_observer();
} }
/// @returns the current preferred clocking strategy. /// @returns the current preferred clocking strategy.
virtual Preference preferred_clocking() const = 0; virtual Preference preferred_clocking() const = 0;
private: private:
Observer *observer_ = nullptr; Observer *observer_ = nullptr;
protected: protected:
/*! /*!
Provided for subclasses; call this whenever the clocking preference might have changed. Provided for subclasses; call this whenever the clocking preference might have changed.
This will notify the observer if there is one. This will notify the observer if there is one.
*/ */
void update_clocking_observer() { void update_clocking_observer() {
if(!observer_) return; if(!observer_) return;
observer_->set_component_prefers_clocking(this, preferred_clocking()); observer_->set_component_prefers_clocking(this, preferred_clocking());
} }
}; };
} }

View File

@@ -15,73 +15,79 @@
Provides the logic to insert into and traverse a list of future scheduled items. Provides the logic to insert into and traverse a list of future scheduled items.
*/ */
template <typename TimeUnit> class DeferredQueue { template <typename TimeUnit> class DeferredQueue {
public: public:
/*! /*!
Schedules @c action to occur in @c delay units of time. Schedules @c action to occur in @c delay units of time.
*/ */
void defer(TimeUnit delay, const std::function<void(void)> &action) { void defer(TimeUnit delay, const std::function<void(void)> &action) {
// Apply immediately if there's no delay (or a negative delay). // Apply immediately if there's no delay (or a negative delay).
if(delay <= TimeUnit(0)) { if(delay <= TimeUnit(0)) {
action(); action();
return; return;
}
if(!pending_actions_.empty()) {
// Otherwise enqueue, having subtracted the delay for any preceding events,
// and subtracting from the subsequent, if any.
auto insertion_point = pending_actions_.begin();
while(insertion_point != pending_actions_.end() && insertion_point->delay < delay) {
delay -= insertion_point->delay;
++insertion_point;
}
if(insertion_point != pending_actions_.end()) {
insertion_point->delay -= delay;
} }
if(!pending_actions_.empty()) { pending_actions_.emplace(insertion_point, delay, action);
// Otherwise enqueue, having subtracted the delay for any preceding events, } else {
// and subtracting from the subsequent, if any. pending_actions_.emplace_back(delay, action);
auto insertion_point = pending_actions_.begin(); }
while(insertion_point != pending_actions_.end() && insertion_point->delay < delay) { }
delay -= insertion_point->delay;
++insertion_point;
}
if(insertion_point != pending_actions_.end()) {
insertion_point->delay -= delay;
}
pending_actions_.emplace(insertion_point, delay, action); /*!
@returns The amount of time until the next enqueued action will occur,
or TimeUnit(-1) if the queue is empty.
*/
TimeUnit time_until_next_action() const {
if(pending_actions_.empty()) return TimeUnit(-1);
return pending_actions_.front().delay;
}
/*!
Advances the queue the specified amount of time, performing any actions it reaches.
*/
void advance(TimeUnit time) {
auto erase_iterator = pending_actions_.begin();
while(erase_iterator != pending_actions_.end()) {
erase_iterator->delay -= time;
if(erase_iterator->delay <= TimeUnit(0)) {
time = -erase_iterator->delay;
erase_iterator->action();
++erase_iterator;
} else { } else {
pending_actions_.emplace_back(delay, action); break;
} }
} }
if(erase_iterator != pending_actions_.begin()) {
/*! pending_actions_.erase(pending_actions_.begin(), erase_iterator);
@returns The amount of time until the next enqueued action will occur,
or TimeUnit(-1) if the queue is empty.
*/
TimeUnit time_until_next_action() const {
if(pending_actions_.empty()) return TimeUnit(-1);
return pending_actions_.front().delay;
} }
}
/*! /// @returns @c true if no actions are enqueued; @c false otherwise.
Advances the queue the specified amount of time, performing any actions it reaches. bool empty() const {
*/ return pending_actions_.empty();
void advance(TimeUnit time) { }
auto erase_iterator = pending_actions_.begin();
while(erase_iterator != pending_actions_.end()) {
erase_iterator->delay -= time;
if(erase_iterator->delay <= TimeUnit(0)) {
time = -erase_iterator->delay;
erase_iterator->action();
++erase_iterator;
} else {
break;
}
}
if(erase_iterator != pending_actions_.begin()) {
pending_actions_.erase(pending_actions_.begin(), erase_iterator);
}
}
private: private:
// The list of deferred actions. // The list of deferred actions.
struct DeferredAction { struct DeferredAction {
TimeUnit delay; TimeUnit delay;
std::function<void(void)> action; std::function<void(void)> action;
DeferredAction(TimeUnit delay, const std::function<void(void)> &action) : delay(delay), action(std::move(action)) {} DeferredAction(TimeUnit delay, const std::function<void(void)> &action) :
}; delay(delay), action(std::move(action)) {}
std::vector<DeferredAction> pending_actions_; };
std::vector<DeferredAction> pending_actions_;
}; };
/*! /*!
@@ -92,30 +98,28 @@ template <typename TimeUnit> class DeferredQueue {
This list is efficient only for short queues. This list is efficient only for short queues.
*/ */
template <typename TimeUnit> class DeferredQueuePerformer: public DeferredQueue<TimeUnit> { template <typename TimeUnit> class DeferredQueuePerformer: public DeferredQueue<TimeUnit> {
public: public:
/// Constructs a DeferredQueue that will call target(period) in between deferred actions. /// Constructs a DeferredQueue that will call target(period) in between deferred actions.
constexpr DeferredQueuePerformer(std::function<void(TimeUnit)> &&target) : target_(std::move(target)) {} constexpr DeferredQueuePerformer(std::function<void(TimeUnit)> &&target) : target_(std::move(target)) {}
/*! /*!
Runs for @c length units of time. Runs for @c length units of time.
The constructor-supplied target will be called with one or more periods that add up to @c length; The constructor-supplied target will be called with one or more periods that add up to @c length;
any scheduled actions will be called between periods. any scheduled actions will be called between periods.
*/ */
void run_for(TimeUnit length) { void run_for(TimeUnit length) {
auto time_to_next = DeferredQueue<TimeUnit>::time_until_next_action(); auto time_to_next = DeferredQueue<TimeUnit>::time_until_next_action();
while(time_to_next != TimeUnit(-1) && time_to_next <= length) { while(time_to_next != TimeUnit(-1) && time_to_next <= length) {
target_(time_to_next); target_(time_to_next);
length -= time_to_next; length -= time_to_next;
DeferredQueue<TimeUnit>::advance(time_to_next); DeferredQueue<TimeUnit>::advance(time_to_next);
}
DeferredQueue<TimeUnit>::advance(length);
target_(length);
// TODO: optimise this to avoid the multiple std::vector deletes. Find a neat way to expose that solution, maybe?
} }
private: DeferredQueue<TimeUnit>::advance(length);
std::function<void(TimeUnit)> target_; target_(length);
}
private:
std::function<void(TimeUnit)> target_;
}; };

Some files were not shown because too many files have changed in this diff Show More