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
1 changed files with 10 additions and 5 deletions

View File

@ -198,16 +198,19 @@ public class Apple2e extends Computer {
RAM128k currentMemory = (RAM128k) getMemory();
if (currentMemory != null && !(currentMemory.getClass().equals(ramCard.getValue()))) {
try {
RAM128k newMemory = (RAM128k) ramCard.getValue().newInstance();
RAM128k newMemory = (RAM128k) ramCard.getValue().getConstructor(Computer.class).newInstance(this);
newMemory.copyFrom(currentMemory);
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) {
try {
currentMemory = (RAM128k) ramCard.getValue().newInstance();
} catch (InstantiationException | IllegalAccessException ex) {
currentMemory = (RAM128k) ramCard.getValue().getConstructor(Computer.class).newInstance(this);
} 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);
}
try {
@ -240,7 +243,7 @@ public class Apple2e extends Computer {
g = getVideo().getScreen();
}
try {
setVideo((Video) videoRenderer.getValue().newInstance());
setVideo((Video) videoRenderer.getValue().getConstructor(Computer.class).newInstance(this));
getVideo().configureVideoMode();
getVideo().reconfigure();
getVideo().setScreen(g);
@ -248,6 +251,8 @@ public class Apple2e extends Computer {
getVideo().resume();
} catch (InstantiationException | IllegalAccessException 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);
}
}