Mapper.java

1
package com.rox.cartridge;
2
3
import com.rox.mem.MemoryBus;
4
5
import java.util.Map;
6
7
/**
8
 * A cartridge board's banking strategy: the CPU-visible {@code $6000-$FFFF} window (PRG-RAM and
9
 * PRG-ROM, however the board maps/switches them) via {@link MemoryBus#read}/{@link MemoryBus#write},
10
 * plus the PPU-visible CHR pattern table window ({@code $0000-$1FFF}, CHR-ROM or CHR-RAM depending on
11
 * the board) and the board's current nametable mirroring mode. One implementation per iNES mapper
12
 * number - {@link NromMapper} for mapper 0, {@link Mmc1Mapper} for mapper 1, {@link Mmc3Mapper} for
13
 * mapper 4.
14
 */
15
public interface Mapper extends MemoryBus {
16
    /** Read a byte from the PPU's CHR pattern table space, address {@code $0000-$1FFF}. */
17
    int readChr(int address);
18
19
    /** Write a byte to the PPU's CHR pattern table space, address {@code $0000-$1FFF} - a no-op on CHR-ROM boards. */
20
    void writeChr(int address, int value);
21
22
    /** How this board's 2KB of nametable RAM is currently aliased across the PPU's 4 logical nametables. */
23
    Mirroring nametableMirroring();
24
25
    /** The board's 8KB of PRG-RAM ({@code $6000-$7FFF}), 0-255 per element - a defensive copy, not a live view. */
26
    int[] prgRam();
27
28
    /** Replaces the board's PRG-RAM wholesale, e.g. when restoring a battery-backed save. {@code prgRam.length} must match {@link #prgRam()}'s. */
29
    void restorePrgRam(int[] prgRam);
30
31
    /** A copy of this board's complete mutable state - see {@link MapperSnapshot}. */
32
    MapperSnapshot snapshot();
33
34
    /**
35
     * Checks {@code snapshot} could be {@link #restore}d into this board, without changing anything - so
36
     * a caller restoring several components can check them all before applying any.
37
     *
38
     * @throws IllegalArgumentException if {@code snapshot} is from a different kind of board, or one with
39
     * a different RAM layout
40
     */
41
    void checkRestorable(MapperSnapshot snapshot);
42
43
    /**
44
     * Puts this board back exactly as {@code snapshot} captured it - all or nothing: a snapshot that
45
     * fails {@link #checkRestorable} is rejected before anything changes.
46
     *
47
     * @throws IllegalArgumentException if {@code snapshot} is from a different kind of board, or one with
48
     * a different RAM layout
49
     */
50
    void restore(MapperSnapshot snapshot);
51
52
    /**
53
     * Whether this board is currently asserting an IRQ onto the CPU's IRQ line - a no-op {@code false}
54
     * default, since most boards (NROM, MMC1) have no IRQ capability of their own; {@link Mmc3Mapper}
55
     * is the one implementation that overrides this.
56
     */
57
    default boolean isIrqAsserted(){
58 1 1. isIrqAsserted : replaced boolean return with true for com/rox/cartridge/Mapper::isIrqAsserted → KILLED
        return false;
59
    }
60
61
    /**
62
     * Bank/IRQ register state worth showing in a debug view, as label -> formatted-value pairs in
63
     * display order - an empty map default, since boards with nothing to switch (NROM) have none.
64
     * {@link Mmc1Mapper}/{@link Mmc3Mapper} override this with their own current register values.
65
     */
66
    default Map<String, String> debugState(){
67
        return Map.of();
68
    }
69
}

Mutations

58

1.1
Location : isIrqAsserted
Killed by : com.rox.NESTest.[engine:junit-jupiter]/[class:com.rox.NESTest]/[method:vblankNmiDoesNotFireBeforeTheRealVblankEdge()]
replaced boolean return with true for com/rox/cartridge/Mapper::isIrqAsserted → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1