Skip to content

Commit 43a6991

Browse files
JoeMattclaude
andcommitted
acid: address Copilot review on PR #130
Seven inline comments on PR #130, all addressed: 1. **TOM_INT1 byte order (vblank_delivery / jerry_pit_irq / sr_mask_blocks_irq / rapid_irq_pump)** — Copilot caught that I had the byte order swapped. Per src/tom/tom.c: - Word at $F000E0: HIGH byte = "clear pending" bits passed to TOMClearPendingIRQs (data >> 8); LOW byte = enable mask (read via tomRam8[INT1+1] in TOMIRQEnabled). - I was writing `$0100` to enable VIDEO when I needed `$0001`. Fixing this immediately recovered two NOT-RUN-YET tests: vblank_delivery now PASSES rapid_irq_pump now PASSES jerry_pit_irq still NOT-RUN-YET because the JERRY PIT itself never raises an IRQ -- the timing_jerry_irqs perf counter stays 0. That's a deeper bug, surfaced cleanly now that the byte order isn't masking it. 2. **JERRY IRQ2_TIMER1 mask bit value (jerry_pit_irq)** — Copilot caught I used $0002 (which is IRQ2_DSP) instead of $0004 (IRQ2_TIMER1, per src/jerry/jerry.h:36-38). Fixed. 3. **bsr_long_61ff.s placeholder** — Copilot flagged that the file claimed to test the $61FF quirk but only ran a normal bsr.w. Repurposed as a BSR.W *control* test (so the real $61FF test in bsr_l_61ff_real.s isn't undermined by basic call/return being broken), and added an explicit pointer to the real test in the file header. 4. **run.c top comment offset** — said `0x100`, code reads `0x100000`. Fixed comment. 5. **README halfline math** — said "314400 / 600 = 524 per frame" but next table said "525 per frame", inconsistent. Reconciled: the hardware spec line count is 525 (NTSC half-lines), but our HalflineCallback fires 524 times per frame (once per transition, not once per state). Both numbers are correct; docs now spell out which is which. 6. **README status table staleness** — was already fixed in commit 4a151ba (the table now reflects per-category pass counts and lists open issues per category). 7. (No #7 -- there were 7 Copilot threads but two were paired onto the jerry_pit_irq file as separate concerns above.) Final status: 54 / 72 PASSing (was 52). The two PASSes recovered are the IRQ delivery tests Copilot's fix unlocked. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 parent 4a151ba commit 43a6991

8 files changed

Lines changed: 62 additions & 41 deletions

File tree

test/acid/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ codes; per-test perf-counter delta dumps when built with
3333
optional -- if absent, the assemble step is skipped with a warning
3434
and only the runner harness is built.
3535

36-
**52 / 72 tests PASSing across 13 categories.** Failures and
36+
**54 / 72 tests PASSing across 13 categories.** Failures and
3737
NOT-RUN-YETs are intentional documentation of known emulator gaps.
3838

3939
| Category | Tests | Pass | Open issues surfaced |
4040
|---|---:|---:|---|
4141
| smoke | 1 | 1 ||
4242
| memory | 8 | 8 ||
4343
| timing | 9 | 8 | jerry_pit_setup: PIT readback returns 0 |
44-
| irq | 9 | 6 | vblank_delivery + jerry_pit_irq + rapid_irq_pump NOT-RUN-YET (IRQ raises in TOM/JERRY per perf counters but never reaches 68K vec-64 handler) |
44+
| irq | 9 | 8 | jerry_pit_irq NOT-RUN-YET (PIT itself never raises an IRQ -- timing_jerry_irqs counter stays 0) |
4545
| blitter | 17 | 4 | 13 SRC-reading tests fail identically; lfu_zero_fill / lfu_one_fill / lfu_invert_src PASS — narrows bug to LFU source-routing |
4646
| gpu | 2 | 2 | — (gpu_basic_run + gpu_reg_access) |
4747
| dsp | 3 | 3 | dsp_mac_accumulator is currently a NOP-loop placeholder; real 40-bit-MAC math is a follow-up |
@@ -131,19 +131,21 @@ after each test and dumps the delta:
131131

132132
That tells us at a glance:
133133
- the test ran for 600 retro_run cycles (10 emulated seconds at 60 Hz)
134-
- the halfline callback fired 314400 times = exactly 524 per frame
135-
(NTSC), which is what the hardware spec calls for
134+
- the halfline callback fired 314400 times = exactly **524 per
135+
frame** (NTSC: VC sweeps 0..524 inclusive, but our HalflineCallback
136+
is invoked once per *transition*, hence 524 not 525)
136137

137-
If a future change makes the halfline rate jump to 1048800 (1048
138-
per frame), this number will catch it immediately even if no test
138+
If a future change makes the halfline rate jump to e.g. 1048800
139+
(1748 per frame, what the bug would look like if events fired on
140+
both edges), this number will catch it immediately even if no test
139141
explicitly checks for it.
140142

141143
Counters surfaced in the per-test summary today:
142144

143145
| Counter | Source | Expected (NTSC default) |
144146
|---|---|---|
145147
| `timing_jaguar_execute_calls` | `JaguarExecuteNew` entry | 1 per `retro_run()` |
146-
| `timing_halfline_callbacks` | `HalflineCallback` entry | 525 per frame |
148+
| `timing_halfline_callbacks` | `HalflineCallback` entry | 524 per frame (NTSC) |
147149
| `timing_vblank_irqs` | TOM video-int raise | 1 per frame |
148150
| `timing_jerry_irqs` | JERRY PIT IRQ raise | 0 unless game enables PIT |
149151
| `timing_gpu_irqs_to_68k` | TOM PIT-→68K raise | 0 unless game enables TOM PIT |

test/acid/run.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Loads a libretro core via dlopen, loads a synthetic .jag test ROM,
55
* runs it for a fixed number of frames, then reads the four-word
6-
* "acid signature" out of main RAM at offset 0x100 and prints
6+
* "acid signature" out of main RAM at offset 0x100000 and prints
77
* PASS / FAIL / NOT-RUN-YET.
88
*
99
* Usage: run <core.dylib> <test.jag> [num_frames]

test/acid/tests/irq/jerry_pit_irq.s

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ JPIT1 equ $F10036 ; timer 1 prescaler
2323
JPIT2 equ $F10038 ; timer 1 divider
2424
JINTCTRL equ $F10020 ; interrupt control
2525

26-
;; Bits
27-
JINT_TIMER1 equ $0002
28-
TOM_INT_DSP_EN equ $0400 ; bit 10 enables DSP/JERRY IRQ
26+
;; Bits.
27+
;; - JERRY interrupt mask bits (per src/jerry/jerry.h):
28+
;; IRQ2_DSP=$02, IRQ2_TIMER1=$04, IRQ2_TIMER2=$08, ...
29+
;; - TOM_INT1 enable mask is the LOW byte of the word at $F000E0
30+
;; (per src/tom/tom.c TOMIRQEnabled reading tomRam8[INT1+1]).
31+
;; IRQ_DSP=4, so enable bit is $10.
32+
JINT_TIMER1 equ $0004
33+
TOM_INT_DSP_EN equ $0010
2934

3035
IRQ_FIRED equ $00000800
3136
HW_IRQ_VECTOR equ $00000100

test/acid/tests/irq/sr_mask_blocks_irq.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ entry:
3030
move.l a0,HW_IRQ_VECTOR.l
3131

3232
;; Configure TOM to fire VBlank.
33+
;; TOM_INT1 byte layout: HIGH byte = clear pending,
34+
;; LOW byte = enable mask. IRQ_VIDEO=0 -> $01.
3335
move.w #$1F00,TOM_INT1 ; clear pending
3436
move.w #2,TOM_VI ; fire on halfline 2
35-
move.w #$0100,TOM_INT1 ; enable VIDEO
37+
move.w #$0001,TOM_INT1 ; enable VIDEO
3638

3739
;; Keep 68K SR with IPL=7 (block everything).
3840
move.w #$2700,sr

test/acid/tests/irq/vblank_delivery.s

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ entry:
5454
move.w #2,TOM_VI ; VC == 2 (halflines)
5555

5656
;; Enable just the video interrupt.
57-
;; INT1 word: bit 8..12 = enable mask, bit 0..4 = clear.
58-
;; bit 0 = VIDEO -> mask bit at +8 = 0x0100.
59-
move.w #$0100,TOM_INT1
57+
;; TOM_INT1 byte layout (per src/tom/tom.c:85, 1142-1146,
58+
;; 1190-1194, 1244-1248): the LOW byte holds the enable
59+
;; mask (read by TOMIRQEnabled via tomRam8[INT1+1]); the
60+
;; HIGH byte is "clear pending" bits passed to
61+
;; TOMClearPendingIRQs. Big-endian word: high byte is
62+
;; at offset $E0, low byte at $E1.
63+
;; IRQ_VIDEO=0 -> enable bit $01.
64+
move.w #$0001,TOM_INT1
6065

6166
;; Drop 68K interrupt mask to allow IPL=2.
6267
;; SR bits 8..10 are I[2..0]; we want them all clear.

test/acid/tests/quirks/bsr_long_61ff.s

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
;
2-
; tests/quirks/bsr_long_61ff.s - 68K BSR.L $61FF Atari aln linker quirk.
2+
; tests/quirks/bsr_long_61ff.s - BSR.W control / sanity test.
33
;
4-
; The Atari `aln` linker emits BSR.L (opcode $61FF) with the
5-
; displacement filled in as an *absolute address* instead of
6-
; PC-relative. Our 68K core was patched to handle this in commit
7-
; 4fcf958 (#119). Verify by emitting one and checking it returned.
4+
; Originally drafted as a placeholder for the BSR.L $61FF quirk before
5+
; the real test (`bsr_l_61ff_real.s`, in this same directory) existed.
6+
;
7+
; Now repurposed as a BSR.W *sanity* gate -- if even a normal short-
8+
; branch BSR doesn't round-trip, the bsr_l_61ff_real test is
9+
; meaningless because we couldn't tell the failure was about the quirk
10+
; vs about call/return at all.
11+
;
12+
; The actual $61FF Atari aln quirk coverage lives in
13+
; `tests/quirks/bsr_l_61ff_real.s`, which emits the raw opcode
14+
; bytes and the absolute target.
815
;
916
; Detail codes:
10-
; 1 = BSR didn't return / target didn't run
17+
; 1 = BSR.W didn't return / target didn't run
1118
;
1219
include "include/jaguar_header.s"
1320
include "include/acid_test.s"
@@ -16,15 +23,8 @@
1623
entry:
1724
ACID_INIT
1825

19-
;; Test approach: regular BSR works (control case);
20-
;; if even regular BSR fails, the test setup is wrong.
21-
;; The aln-quirk handling is hard to assemble portably
22-
;; via vasm (it's specifically the buggy emit pattern),
23-
;; so this test is currently a placeholder asserting
24-
;; only that BSR.L itself does what it should.
25-
26-
moveq #0,d6 ; flag = 0
27-
bsr.w .target ; BSR.W (sane)
26+
moveq #0,d6 ; flag = "didn't return"
27+
bsr.w .target ; standard BSR.W
2828
tst.l d6
2929
beq.s .no_return
3030

test/acid/tests/quirks/divl_zero_traps.s

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
; ($00000014), just like the native 68000 DIV.W behaviour.
88
;
99
; Approach: install a tiny trap handler at vector 5 that sets d6=1,
10-
; then execute `divs.l #0,d2` (inline-encoded as $4C3C,$0800).
10+
; then execute `divs.l d4,d3` with d4=0. Encoded as $4C04,$3800
11+
; (matches the same form as the muls.l test in illegal_opcode_traps.s).
1112
; If the trap fires, d6 becomes 1 and the test passes.
1213
;
1314
; Detail codes:
@@ -27,14 +28,17 @@ entry:
2728
move.l a0,V_ZERODIV.l
2829

2930
moveq #0,d6 ; flag = 0
30-
move.l #12345,d2
31-
32-
;; divs.l #0,d2 => $4C3C,$2800,$00000000
33-
;; ($4C3C = DIV[?].L #imm; ext word fields:
34-
;; bit11 sg=1 (signed), bit10 sz=0 (32-bit),
35-
;; bits14-12 Dl=2, bits2-0 Dh=0 -> $2800)
36-
dc.w $4C3C,$2800
37-
dc.l $00000000
31+
move.l #12345,d3 ; dividend
32+
moveq #0,d4 ; divisor = 0
33+
34+
;; divs.l d4,d3 => $4C04,$3800
35+
;; opcode $4C04: base $4C00, mode 0 (Dn), reg 4 (d4 src)
36+
;; ext $3800:
37+
;; bits14-12 Dl=3 (quotient/dividend in d3)
38+
;; bit 11 sg=1 (signed)
39+
;; bit 10 sz=0 (32-bit, no Dh)
40+
;; bits 2-0 Dh=0 (don't-care)
41+
dc.w $4C04,$3800
3842

3943
tst.l d6
4044
beq.s .bad

test/acid/tests/stress/rapid_irq_pump.s

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ entry:
3535
move.l a0,HW_IRQ_VECTOR.l
3636

3737
;; Idle TOM, then arm video IRQ at scanline 2.
38+
;; TOM_INT1: HIGH byte = clear pending, LOW byte = enable
39+
;; (per src/tom/tom.c). IRQ_VIDEO=0 -> $01.
3840
move.w #$1F00,TOM_INT1 ; clear all pending
3941
move.w #0,TOM_INT1 ; idle
4042
move.w #2,TOM_VI
41-
move.w #$0100,TOM_INT1 ; enable video IRQ
43+
move.w #$0001,TOM_INT1 ; enable video IRQ
4244

4345
;; Drop interrupt mask: supervisor, IPL=0.
4446
move.w #$2000,sr
@@ -62,6 +64,7 @@ entry:
6264
;
6365
irq_handler:
6466
addq.l #1,IRQ_COUNTER.l
65-
;; Clear pending VIDEO bit (bit 0) and re-enable.
67+
;; Clear pending VIDEO bit (HIGH byte) and re-enable
68+
;; mask (LOW byte): $0101.
6669
move.w #$0101,TOM_INT1
6770
rte

0 commit comments

Comments
 (0)