Table of Contents
- NDS — Nintendo DS Debugging Log
- Übersicht
- Architektur
- Bugs gefunden & gefixt
- ✅ ROM Loader — reset nach copy (commit 6254940)
- ✅ MSR/MRS Opcodes (commit 0466d66)
- ✅ ARM7 LDM/STM Register-Reihenfolge (commit 5d4fa32)
- ✅ CP15 DTCM/ITCM Callbacks (commit e523d5c)
- ✅ BIOS7/9 IRQ Handler HLE (commit 1e72687)
- ✅ IF-Clear De-Assertiert irq_pending (commit 1e72687)
- ✅ VBlankIntrWait CPU Halt (commit 1e72687)
- Offene Bugs
- Aktueller Status (2026-03-15 22:00 Uhr)
- Test-ROM
- Nächste Schritte
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
NDS — Nintendo DS Debugging Log
Übersicht
Dieser Artikel dokumentiert den Fortschritt beim Debuggen des NDS-Subsystems in RetroVerse.
Architektur
| Component | Details |
|---|---|
| ARM9 | ARM946E-S, 67 MHz, DTCM/ITCM |
| ARM7 | ARM7TDMI, 33 MHz |
| RAM | 4MB Main RAM (0x02000000) |
| DTCM | 16KB bei 0x027E0000 (via CP15 MCR) |
| ITCM | 32KB, Mirror 0x00000000–0x01FFFFFF |
| WRAM7 | 64KB bei 0x03800000 |
Bugs gefunden & gefixt
✅ ROM Loader — reset nach copy (commit 6254940)
Problem: nds_load_rom() rief nds_reset() NACH dem Kopieren von ARM9/ARM7-Code ins RAM.
nds_reset() hat dann alles wieder gecleared.
Fix: nds_reset() vor dem ROM-Copy aufrufen.
✅ MSR/MRS Opcodes (commit 0466d66)
Fehlende MSR/MRS-Implementierung — Spiele konnten CPSR/SPSR nicht setzen/lesen.
✅ ARM7 LDM/STM Register-Reihenfolge (commit 5d4fa32)
Problem: Bei DA/DB-Modes (STMDB/PUSH) wurden Register in falscher Reihenfolge gespeichert.
Beim LDMIA/POP wurden sie dann falsch gelesen → PC bekam den Wert von r6 (0x027E12E0 = DTCM-Adresse) statt der echten Return-Adresse.
Fix: Start-Adresse wird jetzt korrekt nach ARM-Spec berechnet, Register immer in aufsteigender Reihenfolge an aufsteigenden Adressen.
Betrifft: Sowohl ARM9 als auch ARM7.
✅ CP15 DTCM/ITCM Callbacks (commit e523d5c)
Problem: MCR-Writes zu CP15 (Register 9) wurden nicht an NDS-System weitergeleitet.
DTCM blieb auf Default-Adresse statt auf 0x027E0000.
Fix: cp15_write/cp15_read Callbacks in cpu_interface.h, nds9_cp15_write implementiert.
✅ BIOS7/9 IRQ Handler HLE (commit 1e72687)
Problem: ARM7/ARM9 sprangen bei IRQ nach 0x00000018/0xFFFF0018, dort waren nur Nullen → CPU rennt durch NOPs.
Fix: bios7[] und bios9[] in nds_reset() mit echten IRQ-Handler-Bytes gepatcht:
- Exception-Vektoren mit Spin-Loops (
B .) + IRQ-Branch - IRQ-Handler-Stub:
STMFD / LDR r0,[UserPtr] / MOV LR,PC / BX r0 / LDMFD / SUBS PC,LR,#4
✅ IF-Clear De-Assertiert irq_pending (commit 1e72687)
Problem: Wenn Game IF-Register cleared, blieb irq_pending=true im CPU-State.
Fix: Nach IF-Write: falls !(ime & ie & if) → arm7_set_irq(false).
✅ VBlankIntrWait CPU Halt (commit 1e72687)
Problem: SWI 0x05 (VBlankIntrWait) returned sofort ohne zu warten.
Fix: cpu->halted = true — CPU wird durch arm7_set_irq() beim VBlank wieder geweckt.
Offene Bugs
🐛 ARM7 Stack Korruption (Issue #169)
Symptom: ARM7 springt bei Schritt ~226521 in unmapped Adressraum (0xE1A01C00).
Bekannt:
- SP =
0x0380FB94(ARM7-WRAM) r14 = LR = 0xE1A01C01(Bit 0 = Thumb-Mode-Flag)- Wert an SP enthält einen ARM-Opcode-Wert statt gültige Adresse
- ARM7 rennt dann in Thumb-Mode durch 0x0000-NOPs
Auswirkung: ARM9 hängt in IPC-Wait-Loop bei 0x021123F0 — wartet auf ARM7 Init.
DISPCNT = 0x0000 → kein Display-Output.
Aktueller Status (2026-03-15 22:00 Uhr)
| Komponente | Status |
|---|---|
| ARM9 ROM-Load | ✅ |
| ARM9 CPU (ARM Mode) | ✅ kein Drift mehr |
| ARM9 CP15 DTCM/ITCM | ✅ |
| ARM7 ROM-Load | ✅ |
| ARM7 CPU (ARM Mode) | 🐛 Stack Korruption (#169) |
| IRQ System | ⚠️ teilweise |
| DMA | ❌ nicht implementiert |
| PPU (DISPCNT/BG) | ❌ ARM7 muss erst laufen |
| Cartridge/AUXSPICNT | ❌ |
| IPC/FIFO | ❌ |
Test-ROM
Advance Wars — Dual Strike (AWRP)
ARM9: entry=0x02000800, size=0x193678
ARM7: entry=0x02380000, size=0x26F28
Nächste Schritte
- ARM7 Stack-Korruption fixen (#169) — Root Cause: falscher Stack-Write
- IPC-Sync zwischen ARM9 und ARM7
- DMA für VRAM-Fills
- PPU BG Mode 0 Rendering