Skip to content

Commit bd498f1

Browse files
committed
💥 Add custom instruction document
1 parent 99e6d0e commit bd498f1

File tree

3 files changed

+76
-8
lines changed

3 files changed

+76
-8
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.idea
22
target
33
nes
4+
*.o
5+
*.nes
46
cmake-build-debug

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,38 @@ can provide you with some basic knowledge of the simulator:
245245
>
246246
![Assembler](SNAPSHOTS/MemoryView.png)
247247

248+
## Custom Instructions
249+
250+
> For the convenience of program debugging and development, the simulator will continuously add custom instructions internally.
251+
252+
+ LOG($FF) log output instruction
253+
254+
```assembly
255+
LOG = $FF
256+
NULL = 0
257+
258+
.segment "STARTUP"
259+
260+
start:
261+
.byte LOG,"ra=\{c.a},rx={c.x},ry={c.y}",NULL
262+
sei
263+
clc
264+
lda #$80
265+
sta PPU_CTRL ;Enable val flag
266+
jmp waitvbl
267+
...
268+
```
269+
270+
> String support class string template function, only supports built-in variables such as c.a, c.x, c.y, etc. in the above code.
271+
272+
| 变量 | 描述 |
273+
|------------------------------------------|----------------|
274+
| c.a | CPU cumulative register |
275+
| c.x | CPU X register |
276+
| c.y | CPU Y register |
277+
278+
> Consider adding PPU, APU, and simulator related register variables in the later stage.
279+
248280
## Special thanks
249281

250282
| name | describe |

README_zh.md

+42-8
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ import cn.navclub.nes4j.bin.ppu.Frame;
113113
public class GameWorld {
114114
public NES create() {
115115
NesConsole console = NesConsole.Builder
116-
.newBuilder()
117-
//nes游戏rom
118-
.file(file)
119-
//音频输出程序
120-
.player(JavaXAudio.class)
121-
//Game loop 回调
122-
.gameLoopCallback(GameWorld.this::gameLoopCallback)
123-
.build();
116+
.newBuilder()
117+
//nes游戏rom
118+
.file(file)
119+
//音频输出程序
120+
.player(JavaXAudio.class)
121+
//Game loop 回调
122+
.gameLoopCallback(GameWorld.this::gameLoopCallback)
123+
.build();
124124
try {
125125
//一旦当前方法被调用将会阻塞当前线程直到游戏结束或者异常发生
126126
console.execute();
@@ -140,6 +140,7 @@ public class GameWorld {
140140
+ JavaXAudio.java
141141

142142
```java
143+
143144
@SuppressWarnings("all")
144145
public class JavaXAudio implements Player {
145146
private final byte[] sample;
@@ -232,6 +233,39 @@ public class JavaXAudio implements Player {
232233
>
233234
![Assembler](SNAPSHOTS/MemoryView.png)
234235

236+
## 自定义指令
237+
238+
> 为了方便程序调试开发,模拟器内部会不断新增自定义指令。
239+
240+
+ LOG($FF)日志输出指令
241+
242+
```assembly
243+
LOG = $FF
244+
NULL = 0
245+
246+
.segment "STARTUP"
247+
248+
start:
249+
.byte LOG,"ra=\{c.a},rx={c.x},ry={c.y}",NULL
250+
sei
251+
clc
252+
lda #$80
253+
sta PPU_CTRL ;Enable val flag
254+
jmp waitvbl
255+
...
256+
```
257+
258+
> 字符串支持类字符串模板功能,仅支持内置变量例如上述代码中的c.a、c.x、c.y等等
259+
260+
| 变量 | 描述 |
261+
|------------------------------------------|----------------|
262+
| c.a | CPU累计寄存器 |
263+
| c.x | CPU X寄存器 |
264+
| c.y | CPU Y寄存器 |
265+
266+
> 后期考虑新增PPU和APU、模拟器相关寄存器变量。
267+
268+
235269
## 技术交流学习
236270

237271
![qq](document/im_qq.jpg)

0 commit comments

Comments
 (0)