Zesty - a pin-accurate, cycle-accurate NES emulator written in Zig
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748//! Tests about undocumented opcodes.const std = @import("std");const cpu = @import("../cpu.zig");
test "HLT" { // These opcodes all kill the CPU. const ops = [_]u8{ 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, // 0x62, 0x72, 0x92, 0xb2, 0xd2, 0xf2, };
for (ops) |op| { var z = cpu.testZes(.{ .init_cpu = false, .rom = &.{ .{ 0x8000, &.{op} }, }, }); while (!z.cpu.sync) z.stepCpu(); // Boot cycle
z.stepCpu(); // First cycle is fine
for (0..3) |_| { z.stepCpu(); // Stuck! try std.testing.expectEqual(0xffff, z.pins.cpu_addr); } }}
test "NOPs" { var z = cpu.testZes(.{ .init_cpu = false, .rom = &.{ .{ 0x8000, &.{ 0x1a, 0x3a, 0x5a, 0x7a, 0xda, 0xfa, // implied 0x80, 0x82, 0x89, 0xc2, 0xe2, // immediate 0x04, 0x44, 0x64, // zp 0x14, 0x34, 0x54, 0x74, 0xd4, 0xf4, // zp,X 0x0c, // abs 0x1c, 0x3c, 0x5c, 0x7c, 0xdc, 0xfc, // abs,X }, }, }, }); while (!z.cpu.status.brk) z.stepCpu();}