|
@@ -174,7 +174,7 @@ class TestHoltekEmulator implements TOutputCallback {
|
|
|
start = System.currentTimeMillis();
|
|
|
holtekEmulator.nextStep();
|
|
|
delta = System.currentTimeMillis() - start;
|
|
|
- assertTrue(delta > 9000 && delta < 10100);
|
|
|
+ assertTrue(delta > 9000 && delta < 11000);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -198,4 +198,158 @@ class TestHoltekEmulator implements TOutputCallback {
|
|
|
assertEquals(0x03, holtekEmulator.getEmulatorInternals().getAddress());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void testAEquals() throws WrongProgramSizeException {
|
|
|
+ byte[] prg = new byte[16];
|
|
|
+ for (int i = 0; i < prg.length; i++) {
|
|
|
+ prg[i] = (byte) (0x40 + i);
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ holtekEmulator.loadProgram(prg);
|
|
|
+ holtekEmulator.startProgram(true);
|
|
|
+ for (int i = 0; i < prg.length; i++) {
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(i, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testEqualsA() throws WrongProgramSizeException {
|
|
|
+ byte[] prg = new byte[] { 0x48, 0x51, 0x52, 0x53, 0x40, 0x54, 0x4F, 0x54, 0x55 };
|
|
|
+ holtekEmulator.loadProgram(prg);
|
|
|
+ holtekEmulator.startProgram(true);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x08, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ assertEquals(0x08, holtekEmulator.getEmulatorInternals().getRegister("B"));
|
|
|
+ assertEquals(0x08, holtekEmulator.getEmulatorInternals().getRegister("C"));
|
|
|
+ assertEquals(0x08, holtekEmulator.getEmulatorInternals().getRegister("D"));
|
|
|
+
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getOutput());
|
|
|
+
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0F, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getOutput());
|
|
|
+ assertTrue(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d0);
|
|
|
+ assertTrue(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d1);
|
|
|
+ assertTrue(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d2);
|
|
|
+ assertTrue(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d3);
|
|
|
+
|
|
|
+ holtekEmulator.stop();
|
|
|
+
|
|
|
+ prg = new byte[] { 0x41, 0x55, 0x56, 0x57, 0x58 };
|
|
|
+
|
|
|
+ holtekEmulator.loadProgram(prg);
|
|
|
+ holtekEmulator.startProgram(true);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x01, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getOutput());
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x03, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getOutput());
|
|
|
+ assertTrue(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d0);
|
|
|
+ assertTrue(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d1);
|
|
|
+ assertFalse(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d2);
|
|
|
+ assertFalse(((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).d3);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x07, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getOutput());
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0f, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getOutput());
|
|
|
+
|
|
|
+ holtekEmulator.stop();
|
|
|
+
|
|
|
+ prg = new byte[] { 0x41, 0x59, 0x4F, 0x59 };
|
|
|
+
|
|
|
+ holtekEmulator.loadProgram(prg);
|
|
|
+ holtekEmulator.startProgram(true);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x01, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getFeature("PWM"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0F, ((HoltekEmulatorOutput) holtekEmulator.getEmulatorOutput()).getFeature("PWM"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testAInput() throws WrongProgramSizeException {
|
|
|
+ byte[] prg = new byte[] { 0x4F, 0x51, 0x52, 0x53, 0x40, 0x61, 0x40, 0x62, 0x40, 0x63 };
|
|
|
+ holtekEmulator.loadProgram(prg);
|
|
|
+ holtekEmulator.startProgram(true);
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ }
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0f, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0f, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0f, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+
|
|
|
+ holtekEmulator.stop();
|
|
|
+
|
|
|
+ prg = new byte[] { 0x64, 0x64, 0x40, 0x65, 0x40, 0x66, 0x40, 0x67, 0x40, 0x68 };
|
|
|
+ holtekEmulator.loadProgram(prg);
|
|
|
+ holtekEmulator.startProgram(true);
|
|
|
+ holtekEmulator.getEmulatorInput().setInput((byte) 0x00);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.getEmulatorInput().setInput((byte) 0x0f);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0f, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x01, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x01, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x01, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x01, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+
|
|
|
+ holtekEmulator.stop();
|
|
|
+
|
|
|
+ prg = new byte[] { 0x40, 0x69, 0x40, 0x69, 0x40, 0x6A, 0x40, 0x6A };
|
|
|
+ holtekEmulator.loadProgram(prg);
|
|
|
+ holtekEmulator.startProgram(true);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.getEmulatorInput().setFeature("AD1", (byte) 0x00);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.getEmulatorInput().setFeature("AD1", (byte) 0x0F);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0f, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.getEmulatorInput().setFeature("AD2", (byte) 0x00);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x00, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ holtekEmulator.getEmulatorInput().setFeature("AD2", (byte) 0x0F);
|
|
|
+ holtekEmulator.nextStep();
|
|
|
+ assertEquals(0x0f, holtekEmulator.getEmulatorInternals().getRegister("A"));
|
|
|
+ }
|
|
|
}
|