Fixed initalization issues caused by recent refactoring and verified a few cards

This commit is contained in:
Brendan Robert 2014-09-17 23:53:59 -05:00
parent 45add680d4
commit 0eb450e9d8

View File

@ -198,16 +198,19 @@ public class Apple2e extends Computer {
RAM128k currentMemory = (RAM128k) getMemory(); RAM128k currentMemory = (RAM128k) getMemory();
if (currentMemory != null && !(currentMemory.getClass().equals(ramCard.getValue()))) { if (currentMemory != null && !(currentMemory.getClass().equals(ramCard.getValue()))) {
try { try {
RAM128k newMemory = (RAM128k) ramCard.getValue().newInstance(); RAM128k newMemory = (RAM128k) ramCard.getValue().getConstructor(Computer.class).newInstance(this);
newMemory.copyFrom(currentMemory); newMemory.copyFrom(currentMemory);
setMemory(newMemory); setMemory(newMemory);
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
if (getMemory() == null) { if (getMemory() == null) {
try { try {
currentMemory = (RAM128k) ramCard.getValue().newInstance(); currentMemory = (RAM128k) ramCard.getValue().getConstructor(Computer.class).newInstance(this);
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException ex) {
Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex);
} }
try { try {
@ -240,7 +243,7 @@ public class Apple2e extends Computer {
g = getVideo().getScreen(); g = getVideo().getScreen();
} }
try { try {
setVideo((Video) videoRenderer.getValue().newInstance()); setVideo((Video) videoRenderer.getValue().getConstructor(Computer.class).newInstance(this));
getVideo().configureVideoMode(); getVideo().configureVideoMode();
getVideo().reconfigure(); getVideo().reconfigure();
getVideo().setScreen(g); getVideo().setScreen(g);
@ -248,6 +251,8 @@ public class Apple2e extends Computer {
getVideo().resume(); getVideo().resume();
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex);
} catch (NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(Apple2e.class.getName()).log(Level.SEVERE, null, ex);
} }
} }