Fixed an old annoying bug where a restored video card wouldn't properly display a blinking cursor; originally, I assumed it was a CRTC register restoration bug, but actually, some supporting variables (eg, cBlinks) were not getting initialized in both the reset() and restore() code paths. This is also a good time to remember that when an uninitialized array from some hardware state gets serialized and deserialized to/from JSON, the array is restored as a series of "null" values, not as "undefined" values, so it's best for any code checking for undefined values to use "== null" rather than "=== undefined".

This commit is contained in:
Jeff Parsons 2017-06-26 08:56:17 -07:00 committed by Jeff Parsons
commit ed75397b83
10 changed files with 58 additions and 36 deletions

View file

@ -1308,7 +1308,7 @@ class Bus extends Component {
if (aNotify !== undefined) {
if (aNotify[0]) {
dataPort = aNotify[0](port, addrLIP);
if (dataPort === undefined) {
if (dataPort == null) {
dataPort = maskPort;
} else {
dataPort &= maskPort;

View file

@ -3166,10 +3166,6 @@ class Video extends Component {
this.buildFonts();
this.nMode = null;
this.iCellCursor = -1; // initially, there is no visible cursor cell
this.cBlinks = -1; // initially, blinking is not active
this.cBlinkVisible = 0; // no visible blinking characters (yet)
this.setMode(this.nModeDefault);
if (this.cardActive.addrBuffer && fRandomize) {
@ -3697,6 +3693,14 @@ class Video extends Component {
}
}
}
if (!fRebuild) {
/*
* Perform some additional initialization common to both reset() and restore() sequences.
*/
this.iCellCursor = -1; // initially, there is no visible cursor cell
this.cBlinks = -1; // initially, blinking is not active
this.cBlinkVisible = 0; // no visible blinking characters (yet)
}
return fChanges;
}
@ -6399,7 +6403,7 @@ class Video extends Component {
* The IBM VGA ROM makes some hardware determinations based on how the CRTC controller responds when
* the IO_SELECT bit in the Miscellaneous Output Register is cleared; normally, that would mean ports
* 0x3B? are decoded and ports 0x3D? are ignored. We didn't used to bother ignoring them, but the
* VGA ROM's logic requires it, so now we also check fActive. However, we ignore only CTRC reads;
* VGA ROM's logic requires it, so now we also check fActive. However, we ignore only CRTC reads;
* we retain any writes in case that information proves useful later.
*
* Note that returning an undefined value now signals the Bus component to return whatever default value
@ -7328,7 +7332,7 @@ Video.TOUCH = {
* Why simulate a SPACE if the tap is in the middle third (center) of the screen? Well, apparently
* I didn't explain earlier that the WHOLE reason I originally added KEYGRID support (before it was
* even called KEYGRID support) was to make the 1985 game "Rogue" (pcjs.org/apps/pcx86/1985/rogue)
* more fun to play on an iPad, and space is a commonly required key.
* more fun to play on an iPad (the space-bar is a commonly required key).
*/
Video.KEYGRID = [
[Keyboard.SIMCODE.HOME, Keyboard.SIMCODE.UP, Keyboard.SIMCODE.PGUP],