| expect(cia.DATA).to.be.equal(0x06); | expect(cia.DATA).to.be.equal(0x06); | ||||
| }); | }); | ||||
| it("Set and Trigger TOD Alarm", function(){ | |||||
| it("TOD Alarm Set and Trigger", function(){ | |||||
| let cia = new MOSCIA(); | let cia = new MOSCIA(); | ||||
| let tick = (cycles) => { | let tick = (cycles) => { | ||||
| let ccount = cycles * 6; | let ccount = cycles * 6; | ||||
| cia.TOD = 1; | cia.TOD = 1; | ||||
| }; | }; | ||||
| // Setting up the alarm interrupts! | |||||
| cia.RS = 0x0D; | |||||
| cia.DATA = 0x84; | |||||
| // Setting alarm values. | // Setting alarm values. | ||||
| cia.RS = 0x0F; | cia.RS = 0x0F; | ||||
| cia.DATA = cia.DATA | 0x80; | cia.DATA = cia.DATA | 0x80; | ||||
| expect(IC & 0x04).to.be.equal(0x04); | expect(IC & 0x04).to.be.equal(0x04); | ||||
| expect(IC & 0x80).to.be.equal(0x80); | expect(IC & 0x80).to.be.equal(0x80); | ||||
| }); | }); | ||||
| it("Timer A", function(){ | |||||
| let cia = new MOSCIA(); | |||||
| let tick = (cycles) => { | |||||
| for (let i=0; i < cycles; i++) | |||||
| cia.phi2 = 1; | |||||
| }; | |||||
| cia.RS = 0x04; | |||||
| cia.DATA = 0xFF; | |||||
| cia.RS = 0x05; | |||||
| cia.DATA = 0x01; | |||||
| cia.RS = 0x0E; | |||||
| // Force latch load into Timer A and activate Timer A | |||||
| cia.DATA = cia.DATA | 0x11; | |||||
| cia.RS = 0x04; | |||||
| expect(cia.DATA).to.be.equal(0xFF); | |||||
| tick(1); | |||||
| expect(cia.DATA).to.be.equal(0xFE); | |||||
| tick(1); | |||||
| expect(cia.DATA).to.be.equal(0xFD); | |||||
| tick(0x0200 - 3); | |||||
| expect(cia.DATA).to.be.equal(0x00); | |||||
| cia.RS = 0x05; | |||||
| expect(cia.DATA).to.be.equal(0x00); | |||||
| tick(1); | |||||
| expect(cia.DATA).to.be.equal(0x01); | |||||
| cia.RS = 0x04; | |||||
| expect(cia.DATA).to.be.equal(0xFF); | |||||
| cia.RS = 0x0D; | |||||
| let IC = cia.DATA; | |||||
| expect(IC & 0x01).to.be.equal(0x01); | |||||
| expect(IC & 0x80).to.be.equal(0x80); | |||||
| }); | |||||
| }); | }); | ||||