Commit Graph

83 Commits

Author SHA1 Message Date
Brett Vickers
9e5e21b8c9 Prevent uninitialized value bugs and improve string safety.
This change does two things:

1. Updates the registry APIs to reduce the likelihood of uninitialized
variables.

The code wasn't always checking the return value of registry load operations.
In some cases, this led to uninitialized memory being used, and crashes could
result. For example, LoadConfiguration in Applewin.cpp was using an
uninitialized value for the computer type if no registry variable for the
"Apple 2 type" was set.

New registry reading methods and macros have also been introduced, allowing
default value fallbacks for the cases where a registry variable is not found.
This makes registry access simpler and safer when a default value is known in
advance.

The registry code's style has also been updated to conform with the rest of
the code base (tabs instead of spaces, naming conventions, etc.)

2. Introduces string safety improvements.

A number of code paths have been modified to use safe-string functions instead
of their unsafe counterparts (e.g., strcpy, sprintf).  In the process, some
strings were converted from "char" to "TCHAR". This was done mostly for
consistency with the rest of the code-base.
2019-08-09 13:38:50 -07:00
tomcw
b66e5a2be9 WOZ: Small refactor 2019-08-03 18:21:41 +01:00
tomcw
1af12fbbb1 WOZ: Small refactor to call DataLatchReadWriteWOZ() for any WOZ data-latch access 2019-08-03 18:10:39 +01:00
tomcw
d973fb6b97 WOZ: Added debug dump sector & track functions 2019-08-03 17:51:19 +01:00
tomcw
b770306496 WOZ: #672
. Even disk i/o read accesses will update the data latch
. All disk i/o write accesses will update the data latch
2019-07-30 22:41:28 +01:00
tomcw
c03eb54103 WOZ: Extended latch delay for 'Wizardry III' and 'Space Quest I' copy-protection (#662, #669) 2019-07-22 19:32:25 +01:00
tomcw
75c9669884 Fixed 2x Windowed mode: to show correct track for drive-2 2019-07-09 22:18:36 +01:00
tomcw
a73038fb74 Disk: fix LOGGING and comment typo 2019-07-08 21:14:31 +01:00
tomcw
8e5505c734 Fixed LOG_DISK to use CLK_6502_NTSC 2019-07-06 12:03:15 +01:00
TomCh
4bc75093b8
Support (read-only) WOZ1/WOZ2 images (#544) (PR #653)
Supports:
- all "woz test images" v1.3 (WOZ1, WOZ2) are working, except 3.5"
- additionally: Frogger (spiradisc), Choplifter (not Enhanced //e!), Lode Runner, Marble Madness, Skyfox.
- woz images can be .gz or .zip compressed (ie. same as other supported images)
- save-state

Limitations:
- read-only, so WOZ images are forced to be write-protected
  . as a result, games that need r/w images won't work (Stickybear Town Builder, Wizardry)
- 5.25" only (not 3.5")
2019-07-05 23:01:19 +01:00
tomcw
0d112158d0 Minor improvement to fix for #640 2019-04-16 21:13:55 +01:00
tomcw
06ffa28a7a Fix for inserting a disk into an empty but spinning driver. (Fixes #640) 2019-04-16 21:11:47 +01:00
tomcw
d66cdd5f2c Remove IsSpinning() 2019-04-16 20:30:54 +01:00
tomcw
c6a11d3824 Minor fixes for LOG_DISK wrapped code 2019-04-14 17:45:01 +01:00
tomcw
ffe37e55e5 Minor: fix a few comments and remove some whitespace 2019-04-14 17:41:26 +01:00
tomcw
97ded90a1c Rename DiskIIInterfaceCard to Disk2InterfaceCard 2019-04-14 17:00:15 +01:00
tomcw
1f846fa26f Rename Disk_t to FloppyDisk; and prefix members 2019-04-14 16:58:49 +01:00
tomcw
cd62b82af4 Rename Drive_t to FloppyDrive; and prefix members 2019-04-14 16:47:41 +01:00
tomcw
971eff7875 Added info about enhanceDisk 2019-04-11 22:34:40 +01:00
tomcw
249b15b02d Get rid of duplicate func 2019-04-09 19:29:58 +01:00
tomcw
aa1e4cab09 Remove redundant Initialize() 2019-04-09 18:13:05 +01:00
tomcw
7c04c2c51e Rename var: iDrive to drive 2019-04-08 16:54:11 +01:00
tomcw
4235f08f7a Remove the 'Disk' prefix from method names 2019-04-08 10:41:47 +01:00
tomcw
f755db8516 Rename all class's private vars 2019-04-07 15:54:26 +01:00
tomcw
bbe0e67584 DiskIIInterfaceCard add in private variables 2019-04-07 15:32:24 +01:00
tomcw
e7d6eac04d Class-ify disk.cpp into DiskIIInterfaceCard 2019-04-07 14:22:05 +01:00
TomCh
dd53812132
Support for AppleColor / Video7 DHGR mixed mode (#523) (PR #620)
Supported modes selected via toggling AN3 and clocking in 80COL:
- 140 color mode (Apple calls this mode 2, Video7 calls this mode 0).
- mixed mode (Apple calls this mode 3, Video7 calls this mode 2).
- 560 mono mode (Apple calls this mode 1, Video7 calls this mode 3).

Save-state is also persists the extra state.

And there's a few corrections to APPLE2E.SYM for the 80STORE and 80COL I/O addresses.
2019-02-02 15:51:27 +00:00
tomcw
eea8cb3cdf Deprecated and removed support for v1 save-state. (Fixes #603) 2019-01-05 22:20:51 +00:00
tomcw
5ddff0d688 DiskII: read write protect - fix spinning test 2018-12-03 21:36:54 +00:00
tomcw
5504d280c7 When drive is off then data register holds its present state. (Fixes #599)
NB. Drive off = motor off && stopped spinning after 1 sec delay.
2018-12-03 17:38:52 +00:00
TomCh
53d1d04988
DiskII: Support partial nibble reads for very close disk latch reads (#586)
Support partial reads for sequential accesses of 6 or less cycles.
- And 31 or less cycles when in "Disk Access Speed" = "Authentic Speed"
Save-state support for partial read cycle (Disk][ unit v3)
Added boot-time logging for Phasor1.dsk (ProDOS 1.1.1)
2018-10-02 22:08:54 +01:00
tomcw
2ba55e0c12 Fix Swap Disk regression (fixes #543) 2018-04-02 18:21:18 +01:00
tomcw
d9accc82c5 Refactor codebase by renaming nCyclesLeft to uExecutedCycles (#540) 2018-03-03 21:27:50 +00:00
tomcw
d4a3c5c28f PrintScreen key: Improve UI feedback when any of the 3 registrations fails & log failures (fixes #547)
Also tweak to full-speed: consolidating 2 calls to DiskII module into 1 call.
2018-02-27 21:07:16 +00:00
tomcw
6c031e7930 Disk II: changing 'enhancedisk' doesn't cause a restart + added accessors (fixes #546) 2018-02-25 15:09:25 +00:00
tomcw
e1286de7a9 Disk II: 'Swap Disks' only swaps disk (not drive properties) - fixes #543 2018-02-25 14:05:45 +00:00
tomcw
92504e0751 Refactor of Disk.cpp and Disk.h in preparation for #543.
Changed struct Disk_t:
. Added new struct Drive_t with "has-a" relationship to Disk_t
. Split properties of drive into Drive_t and properties of disk into Disk_t
2018-02-25 13:38:04 +00:00
Andrea
6051bc55d0 Changes to ease code compilation in gcc. (#541)
Changes to ease code compilation in GCC.

Disk_t and HDD contain a std::string and for this reason they need a proper constructor, ZeroMemory is not guaranteed to work.
2018-02-24 15:12:40 +00:00
tomcw
20022d999d Minor: use global floppylatch 2018-02-24 13:18:26 +00:00
tomcw
dc565dd28c Removed extra local var and updated DOS 3.2 INIT comment 2018-02-23 22:39:51 +00:00
tomcw
a07d087467 Improve logging and fix asserts for DOS 3.2 INIT (#537) 2018-02-15 21:54:15 +00:00
tomcw
82fdf1ab6a DiskII: allow reading of write-protect state when in write mode (#537) 2018-02-11 14:52:21 +00:00
tomcw
62b8b5ac14 DiskII: Updated comment about motor off not affecting state 2018-01-28 12:30:54 +00:00
tomcw
da24cd6e60 DiskII: Allow stepper motor to change phase when motor is off, but during the ~1s when it's still spinning (#525) 2018-01-28 12:21:28 +00:00
tomcw
b50da5a95b DiskII: Prevent stepper motor changing phase when motor is off (fixes #525) 2018-01-27 17:02:33 +00:00
tomcw
4a69ba8a97 git merge --squash GH125-ProDOS-Format. Fix for disk formatting #125, #196, #338:
. .dsk / .nib images
. ProDOS format / DOS 3.3 init
. authentic / enhanced disk access speed

For zero-length files, resize to the complete file size when first opened (#506)
. Support both .dsk and .nib

Created a new class FormatTrack to encapsulate the new track formatting logic

Improved precision of 'authentic' drive mode's spin emulation (#125)

Save-state: (save-state DiskII unit v2)
. support Format Track state
. save DiskLastCycle

DenibblizeTrack(): added some debug asserts and comments

Updated for VS2008/VS2013/2015/2017 projs & remove dependency on ddraw.lib for VS2013/2015

Updated disk logging:
. Moved all LOG_DISK_xx macros to new DiskLog.h (since shared by Disk.cpp and DiskFormatTrack.cpp)
. For write nibble: option to log cycle count & sync byte count
. For written track: option to log gap1/2/3 and track size
. For disk latch r/w: option to log when D5AA96 detected

Other:
. Debugger: Fix CD cmd to support absolute paths (#505)
2018-01-14 18:01:22 +00:00
tomcw
34094f7299 Fix static analysis issues raised in PR #517 2017-12-17 19:35:54 +00:00
tomcw
5505ff696f HDD error wasn't cleared on a reset or power-cycle - fixes #515 2017-12-03 21:05:05 +00:00
tomcw
c49d68f2b5 Flush current track (if dirty) before 'Send to CiderPress' (fix #499) 2017-10-19 22:49:10 -07:00
tomcw
9e7318e7ed Debugger: revert behaviour from 8fce7a8 so that Ctrl+F2 doesn't immediately stop the drive spinning, but F2 still does (#460) 2017-08-12 11:50:31 +01:00