Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GZYangKui committed Dec 28, 2022
1 parent fe82e3b commit d7a878d
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 143 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
target
nes
cmake-build-debug
5 changes: 4 additions & 1 deletion app/src/main/java/cn/navclub/nes4j/app/view/GameHall.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ protected List<File> call() {
if (!file.exists() || file.listFiles() == null) {
return List.of();
}
return Arrays.stream(file.listFiles()).filter(File::isFile).toList();
return Arrays
.stream(file.listFiles()).filter(File::isFile)
.filter(it -> it.getName().endsWith(".nes"))
.toList();
}
};
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/cn/navclub/nes4j/app/view/GameWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ public void handle() {
});
}

@FXML
public void reset() {
if (this.instance == null) {
return;
}
this.instance.reset();
}


private void gameLoopCallback(Frame frame, JoyPad joyPad, JoyPad joyPad1) {
var w = Frame.width;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<MenuBar fx:id="menuBar">
<Menu text="%nes4j.view">
<MenuItem text="%nes4j.pplay"/>
<MenuItem text="%nes4j.reset"/>
<MenuItem text="%nes4j.reset" onAction="#reset"/>
<MenuItem text="%nes4j.palette"/>
</Menu>
<Menu text="%nes4j.options">
Expand Down
5 changes: 0 additions & 5 deletions bin/src/main/java/cn/navclub/nes4j/bin/NES.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,10 @@ public void execute() {
} else {
//fire ppu or apu interrupt
cycles += this.cpu.interrupt(this.getInterrupt());
var programCounter = this.cpu.getPc();
if (this.debugger != null && this.debugger.hack(this)) {
//lock current program process
LockSupport.park();
}
//Check program counter whether in legal memory area
if (programCounter < 0x8000 || programCounter >= 0x10000) {
throw new RuntimeException("Text memory area except in 0x8000 to 0xffff current 0x" + Integer.toHexString(programCounter));
}
cycles += this.cpu.next();
this.instructions++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
@Getter
public enum CPUInterrupt {
//PPU
NMI(2, 0xfffa),
NMI(7, 0xfffa),
//APU
IRQ(2, 0xfffe),
IRQ(7, 0xfffe),
//CPU
BRK(1, 0xfffe);
BRK(7, 0xfffe);

private final int cycle;
private final int vector;
Expand Down
16 changes: 8 additions & 8 deletions bin/src/main/java/cn/navclub/nes4j/bin/config/ICPUStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

public enum ICPUStatus {
//Carry flag
CF,
CARRY,
//Zero flag
ZF,
ZERO,
//Interrupt disable
ID,
INTERRUPT_DISABLE,
//Decimal mode
DM,
DECIMAL_MODE,
//Break command
BK,
BREAK_COMMAND,
//Empty
BK2,
EMPTY,
//Overflow flag
OF,
OVERFLOW,
//Negative flag
NF
NEGATIVE
}
Loading

0 comments on commit d7a878d

Please sign in to comment.