Skip to content

Commit 8690c6d

Browse files
DC-SWATQuzarDC
authored andcommitted
aica: Enhanced driver initialization.
Updated the AICA initialization routine to include additional setup for interrupt sources and FIQ handling. This is a sound fix for NAOMI and NAOMI 2 systems running BIOS without startup sound, as well as for Dreamcast on stock BIOS when returning to KOS from another SDK.
1 parent d060427 commit 8690c6d

3 files changed

Lines changed: 32 additions & 6 deletions

File tree

kernel/arch/dreamcast/sound/arm/aica.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
aica.c
44
(c)2000-2002 Megan Potter
55
(c)2024 Stefanos Kornilios Mitsis Poiitidis
6+
(c)2026 Ruslan Rostovtsev
67
78
ARM support routines for using the wavetable channels
89
*/
@@ -11,13 +12,26 @@
1112
#include "aica.h"
1213

1314
extern volatile aica_channel_t *chans;
15+
extern void arm_fiq_enable(void);
1416

1517
void aica_init(void) {
1618
int i, j;
1719

18-
/* Initialize AICA channels */
20+
/* SCIEB/MCIEB: mask all interrupt sources during setup. */
21+
SNDREG32(0x289C) = 0;
22+
SNDREG32(0x28B4) = 0;
23+
/* SCIRE/MCIRE: acknowledge pending Sound/Main CPU interrupts. */
24+
SNDREG32(0x28A4) = 0x7FF;
25+
SNDREG32(0x28BC) = 0x7FF;
26+
/* SCILV0/1/2: deliver AICA events on FIQ (used by fiq_timer in crt0.s). */
27+
SNDREG32(0x28A8) = 0x18;
28+
SNDREG32(0x28AC) = 0x50;
29+
SNDREG32(0x28B0) = 0x08;
30+
31+
/* Drop master volume while channel registers are cleared. */
1932
SNDREG32(0x2800) = 0x0000;
2033

34+
/* Initialize AICA channels */
2135
for(i = 0; i < 64; i++) {
2236
CHNREG32(i, 0) = 0x8000;
2337

@@ -27,7 +41,15 @@ void aica_init(void) {
2741
CHNREG32(i, 20) = 0x1f;
2842
}
2943

44+
/* Restore default mixer routing after channel reset. */
3045
SNDREG32(0x2800) = 0x000f;
46+
/* Timer A reload (same as crt0.s). */
47+
SNDREG32(0x2890) = 256 - (44100 / 4410);
48+
/* SCIEB bit 6: unmask Timer A as the sole FIQ source. */
49+
SNDREG32(0x289C) = 0x40;
50+
51+
/* Unmask FIQ in CPSR once Timer A and SCILV are configured. */
52+
arm_fiq_enable();
3153
}
3254

3355
/* Translates a volume from linear form to logarithmic form (required by

kernel/arch/dreamcast/sound/arm/crt0.s

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#
33
# crt0.s
44
# (c)2000-2002 Megan Potter
5+
# (c)2026 Ruslan Rostovtsev
56
#
67
# Startup for ARM program
78
# Adapted from Marcus' AICA example among a few other sources =)
89

910
.text
1011
.globl arm_main
12+
.globl arm_fiq_enable
1113
.globl jps
1214

1315
# Meaningless but makes the linker shut up
@@ -104,14 +106,16 @@ jps:
104106
# 1000 jiffies per second
105107
.long 256-(44100/1000)
106108

109+
arm_fiq_enable:
110+
mrs r0, CPSR
111+
orr r0, r0, #0x80
112+
bic r0, r0, #0x40
113+
msr CPSR_c, r0
114+
mov pc, lr
107115

108116
start:
109-
# Setup a basic stack, disable IRQ, enable FIQ
117+
# Setup a basic stack, disable IRQ
110118
mov sp,#0xb000
111-
mrs r10,CPSR
112-
orr r10,r10,#0x80
113-
bic r10,r10,#0x40
114-
msr CPSR_all,r10
115119

116120
# Call the main for the SPU
117121
bl arm_main
72 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)