TestHVCounterLatchText: dc.b 'HV Counter Latch ' TestHVCounterLatchTextEnd: TestHVCounterLatchExpectedResult: dc.w $FFFF, $FFFF, $FFFF, $FFFF, $0000, $0000, $0000, $0000, $FFFF, $FFFF, $FFFF, $FFFF, $0000, $0000, $0000, $0000 dc.w $FFFF, $FFFF, $FFFF, $FFFF, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 dc.w $0000, $0000, $0000, $0000, $0000, $0000, $0000, $0000 TestHVCounterLatch: ;Initialize the text result block move.w #(TestHVCounterLatchTextEnd-TestHVCounterLatchText),D7 move.w #4,(A0)+ ;Set the number of display lines move.w D7,(A0)+ ;Set the text length move.w #$0050,D6 ;Set the data length move.w D6,(A0)+ lea TestHVCounterLatchText,A1 sub.w #1,D7 TestHVCounterLatchWriteText: move.b (A1)+,(A0)+ dbf D7,TestHVCounterLatchWriteText move.w #1,(A0)+ ;Set the expected result data present flag lea TestHVCounterLatchExpectedResult,A1 ;Write the expected result data to the buffer sub.w #1,D6 TestHVCounterLatchWriteExpectedResultData: move.b (A1)+,(A0)+ dbf D6,TestHVCounterLatchWriteExpectedResultData ;Disable HV counter latch move.w #$8004,$C00004 ;Verify that the HV counter is currently changing move.w $C00008,D0 move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest00Jump00Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest00Jump00Done HVCounterChangingTest00Jump00Fail: move.w #$0000,(A0)+ HVCounterChangingTest00Jump00Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest00Jump01Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest00Jump01Done HVCounterChangingTest00Jump01Fail: move.w #$0000,(A0)+ HVCounterChangingTest00Jump01Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest00Jump02Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest00Jump02Done HVCounterChangingTest00Jump02Fail: move.w #$0000,(A0)+ HVCounterChangingTest00Jump02Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest00Jump03Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest00Jump03Done HVCounterChangingTest00Jump03Fail: move.w #$0000,(A0)+ HVCounterChangingTest00Jump03Done: ;Enable HV counter latch move.w #$8006,$C00004 ;Verify that the HV counter is no longer changing move.w $C00008,D0 move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ ;Save the last HV counter value we just read move.w D1,D7 ;Disable HV counter latch move.w #$8004,$C00004 ;Verify that the HV counter is currently changing move.w $C00008,D0 move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest01Jump00Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest01Jump00Done HVCounterChangingTest01Jump00Fail: move.w #$0000,(A0)+ HVCounterChangingTest01Jump00Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest01Jump01Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest01Jump01Done HVCounterChangingTest01Jump01Fail: move.w #$0000,(A0)+ HVCounterChangingTest01Jump01Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest01Jump02Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest01Jump02Done HVCounterChangingTest01Jump02Fail: move.w #$0000,(A0)+ HVCounterChangingTest01Jump02Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest01Jump03Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest01Jump03Done HVCounterChangingTest01Jump03Fail: move.w #$0000,(A0)+ HVCounterChangingTest01Jump03Done: ;Enable HV counter latch move.w #$8006,$C00004 ;Verify that the HV counter is no longer changing move.w $C00008,D0 move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ ;Verify that the latched HV counter value is different to the previously latched value move.w D7,D0 move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest02Jump00Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest02Jump00Done HVCounterChangingTest02Jump00Fail: move.w #$0000,(A0)+ HVCounterChangingTest02Jump00Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest02Jump01Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest02Jump01Done HVCounterChangingTest02Jump01Fail: move.w #$0000,(A0)+ HVCounterChangingTest02Jump01Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest02Jump02Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest02Jump02Done HVCounterChangingTest02Jump02Fail: move.w #$0000,(A0)+ HVCounterChangingTest02Jump02Done: move.w $C00008,D1 eor.w D0,D1 beq HVCounterChangingTest02Jump03Fail move.w #$FFFF,(A0)+ bra HVCounterChangingTest02Jump03Done HVCounterChangingTest02Jump03Fail: move.w #$0000,(A0)+ HVCounterChangingTest02Jump03Done: ;Enable external interrupts move.w #$8B08,$C00004 ;Record the current value of the HV counter move.w $C00008,D0 ;Verify that the HV counter is not changing move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ ;Backup and clear the interrupt mask. If an external interrupt is pending, this will cause it ;to be taken. move SR,D2 move #$2000,SR ;Verify that the HV counter has not changed after enabling external interrupts move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ ;Restore the interrupt mask move D2,SR ;Disable HV counter latch move.w #$8004,$C00004 ;Enable HV counter latch move.w #$8006,$C00004 ;Verify that the HV counter is no longer changing move.w $C00008,D0 move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ ;Re-write to VDP register 0 without changing the HV counter latch enable bit, and see if ;this affects the latched HV counter data move.w #$8006,$C00004 ;Verify that the HV counter has not changed move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ ;Perform a few general VDP register write operations to see if they affect the latched HV ;counter data move.w #$8144,$C00004 move.w #$8F01,$C00004 move.w #$8F02,$C00004 ;Verify that the HV counter has not changed move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ move.w $C00008,D1 eor.w D0,D1 move.w D1,(A0)+ ;Disable HV counter latch move.w #$8004,$C00004 ;Disable external interrupts move.w #$8B00,$C00004 rts