From 72cb3a1cf6916e480cfe4f38ff825fe0bf89cb95 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 19 Nov 2019 21:54:13 -0500 Subject: [PATCH] Integrates basic unit test for Atari ST video event prediction. --- .../Clock SignalTests/AtariSTVideoTests.mm | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 OSBindings/Mac/Clock SignalTests/AtariSTVideoTests.mm diff --git a/OSBindings/Mac/Clock SignalTests/AtariSTVideoTests.mm b/OSBindings/Mac/Clock SignalTests/AtariSTVideoTests.mm new file mode 100644 index 000000000..078c47718 --- /dev/null +++ b/OSBindings/Mac/Clock SignalTests/AtariSTVideoTests.mm @@ -0,0 +1,60 @@ +// +// MasterSystemVDPTests.m +// Clock SignalTests +// +// Created by Thomas Harte on 09/10/2018. +// Copyright © 2018 Thomas Harte. All rights reserved. +// + +#import + +#include "../../../Machines/Atari/ST/Video.hpp" + +@interface AtariSTVideoTests : XCTestCase +@end + +@implementation AtariSTVideoTests + +- (void)setUp { + [super setUp]; +} + +- (void)tearDown { + [super tearDown]; +} + +- (void)testSequencePoints { + // Establish an instance of video. + Atari::ST::Video video; + uint16_t ram[256*1024]; + video.set_ram(ram, sizeof(ram)); + + // Set 4bpp, 50Hz. + video.write(0x05, 0x0200); + video.write(0x30, 0x0000); + + // Run for [more than] a whole frame making sure that no observeable outputs + // change at any time other than a sequence point. + HalfCycles next_event; + bool display_enable = false; + bool vsync = false; + bool hsync = false; + for(size_t c = 0; c < 10 * 1000 * 1000; ++c) { + const bool is_transition_point = next_event == HalfCycles(0); + + if(is_transition_point) { + display_enable = video.display_enabled(); + vsync = video.vsync(); + hsync = video.hsync(); + next_event = video.get_next_sequence_point(); + } else { + NSAssert(display_enable == video.display_enabled(), @"Unannounced change in display enabled at cycle %zu [%d before next sequence point]", c, next_event.as()); + NSAssert(vsync == video.vsync(), @"Unannounced change in vsync at cycle %zu [%d before next sequence point]", c, next_event.as()); + NSAssert(hsync == video.hsync(), @"Unannounced change in hsync at cycle %zu [%d before next sequence point]", c, next_event.as()); + } + video.run_for(HalfCycles(2)); + next_event -= HalfCycles(2); + } +} + +@end