summaryrefslogtreecommitdiff
path: root/source/blog/yaxgbc_dev_notes.md
blob: 2a1456717df0d70785e1eac4936444975d0cf3d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# yaxgbc

i hack on a gameboy color emulator from time to time. it started as... [a disassembler](https://git.iximeow.net/yaxpeax-sm83/?h=no-gods-no-) for the kind-of-but-not-Z80 processor in the Gameboy and Gameboy Color. in December or so, i looked at that library, remarked to myself that the whole disassembler is maybe 400 lines of Rust, and wondered how it would fare seeing real use.

so i started writing enough of an emulator to see that the disassembler worked (it did! yay!), and started measuring how it affected the dependent code:
* actual runtime overhead?
* how large is the compiled decoder?

TODO: fish up old numbers and screenshots. because there was substantial runtime impact, and i spotted a [missed optimization](https://github.com/rust-lang/rust/issues/107208) in rustc. i entirely rewrote the [`sm83` disassembler](https://github.com/iximeow/yaxpeax-sm83/commit/819e8a30d20c28398a00976a9925e9e741950bee) to be easier to merge the disassembler directly into code using it. as a [length-only decoder](https://github.com/iximeow/yaxpeax-sm83/commit/819e8a30d20c28398a00976a9925e9e741950bee#diff-9176af78feab5192ec447e97a2b52a0ba00b22c9e9b7ac3fc8c9763a5e9bd5caR50-R55), the decoder is on the order of 85 bytes without rustc being improved.

somewhere between discovering the issue and coming up with a redesigned decoder interface, i had an existential panic about code reuse being fundamentally incompatible with high performance/tightly-integrated libraries. i no longer have any such panic :)

## bugs aka dev log

### video issues ("ascii `video` to the terminal is good right")

### video issues ("why is the gameboy logo rendered wrong")

### interrupt issues (are they level-triggered or edge-triggered? what clears interrupt bits, if anything)

### input issues (edge/level trigger on inputs too)

### clock sync (sleep() accuracy on windows and timeBeginPeriod)

### audio issues ("there isn't any")

### audio issues ("sounds are.. backwards?? what gives" [cycles/sample vs samples/sec])

### audio issues ("noise noises too long. why." [channel 4 length docs])

### audio issues ("frequencies are all off?" [timer multiplier issue])

### video issues ("why is parallax in link's awakening broken" [not handlnig lyc=0])

### video issues ("why is oracle of seasons/oracle of ages corrupted" [dma transfers to odd addresses])

### video issues ("why is wario land 3 corrupted" [dma transfers to address 0, expecting high bits set])

...