Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System C2 WIP branch #21

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
MDSDRV
======
MDSDRV C2 branch
================
A sound driver for Sega Mega Drive/Genesis.

This is a testing branch adding support for Sega System C2.

There is no Z80 so PCM playback using YM2612 DAC is not possible.

Currently the sound driver does not support or use the uPD7759 ADPCM
chip. It can be used manually by your own code if needed though.

## Features
- Runs on the 68000 with the Z80 controlling PCM playback.
- 16 monophonic tracks that can be used for BGM or sound effects.
Expand Down Expand Up @@ -99,11 +106,7 @@ automatically build the SGDK test program.
- See [mdsseq.md](doc/mdsseq.md)

#### Precautions when using DMA
- See [dma.md](doc/dma.md)

Currently the Z80 code does not have any protection against reading ROM
during DMA transfers. Please halt Z80 by issuing a bus request before
starting DMAs to ensure system stability.
Not applicable to System C2

## Copyright
© 2019-2022 Ian Karlsson.
Expand Down
12 changes: 12 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ if %ERRORLEVEL% neq 0 goto error
echo Make mdsdrv.bin ...
tools\asm68k.exe /k /p /o ae- src\blob.68k, out\mdsdrv.bin >out\error.txt, , out\mdsdrv.lst
if %ERRORLEVEL% neq 0 goto error

mkdir out\zunkyou
tools\romwak /p main.bin main.bin 2048 255
tools\romwak /b main.bin out\zunkyou\even.bin out\zunkyou\odd.bin
tools\romwak /h out\zunkyou\even.bin out\zunkyou\epr-16812.ic32 out\zunkyou\epr-16814.ic34
tools\romwak /h out\zunkyou\odd.bin out\zunkyou\epr-16811.ic31 out\zunkyou\epr-16813.ic33
rem Temporary until ADPCM tool is added
copy out\zunkyou\epr-16813.ic33 out\zunkyou\epr-16810.ic4
rem For debugging
copy out\main.lst out\zunkyou\main.lst
copy main.bin out\zunkyou\main.bin

if "%GDK_WIN%"=="" goto nosgdk
echo Make sgdk.bin
copy /b out\mdsdrv.bin sample\sgdk\res
Expand Down
85 changes: 85 additions & 0 deletions data/bgm/Levitated_Trickles_edit2.mml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#title Levitated Trickles
#composer Muscises
#date 2021-10-21
#platform megadrive

@1 fm 7 0; Sine Chords
8,20,0,4,8,12,0,0,0,0
8,20,0,4,8,12,0,0,0,0
8,20,0,4,8,12,0,0,0,0
8,20,0,4,8,12,0,0,0,0

@2 fm 1 0; Bass
31,0,0,7,0,29,0,0,5,0
22,0,15,7,0,42,0,0,3,0
26,31,15,7,1,21,0,0,2,0
31,0,9,7,0,0,0,0,0,0

@3 fm 5 5; Kick
26,31,20,7,4,6,0,0,0,0
31,0,17,4,0,0,0,0,0,0
31,0,14,4,0,0,0,0,0,0
31,0,14,6,0,0,0,0,0,0

@4 fm 1 7; Guitar
31,31,14,15,0,45,0,7,0,0
31,0,11,15,0,38,0,3,3,0
31,0,1,15,0,41,0,1,3,0
31,12,1,15,7,0,0,1,0,0

@6 psg; closed hi-hat
15>0:12
*30 @6v10o9b; D30a

@7 psg; open hi-hat
15>0:24
*31 @7v10o8b; D30b
*32 @7v10o8c; D30c

@8 psg; Long Decay
15>0:56 / 0

@10 psg; Blank
15 / 0

*100 o6l16b-r16e-<<b-r8f>b-e-fr16>b-f<<<e->fr16

A t112
A @2 v14Q8
B @3 v12Q8
D @4 v8Q8
E @4 v6Q8
F @4 v4Q8
J 'mode 1'D30

A [r1]4 L [l4o3b-b-r8>l16cce-fr16>b- | l4o3a-a-r8>l16cce-fr16>a- | l4o4e-e-r8l16cce-fr16>e- | /l4o3bbr8>l16cce-fr16>b]5 | [l8.o3g-g-l16>d-g-_2]
B [r1]8 Lv12 [[l4o3ccl8.ccc8/r8l8cl16ccccr8crcrcc]l8ccccl16ccrccrcc]4
C @1 'fm3 1000' l2.o6 fr4<br4b-r4>er4 | L[l2.o6 fr4<br4b-r4/>er4]5 | l2d-e-
M @1 'fm3 0100' l2.o6 a-r4e-r4d-r4a-r4 | L[l2.o6 a-r4e-r4d-r4/a-r4]5 | l2eg-
N @1 'fm3 0010' l2.o7 cr4<g-r4fr4br4 | L[l2.o7 cr4<g-r4fr4/br4]5 | l2a-b-
O @1 'fm3 0001' l2.o7 e-r4<b-r4a-r4e-r4 | L[l2.o7 e-r4<b-r4a-r4/e-r4]5 | l2b>d-
J [r1]4 LD30[l16aabaabaabaabaabb]11 | D0l16v2[@10o7b&)1]12 [l16G08v14o5d+/&]4 | G0D30[[aar16bacbar16aar16aaba]3 | aar16bacba | /aar16bacba] | D0l16v2o3bG8[@10o6b)2/&]7

*101 [l8.o7b-<<b-16r16>b-<<b-16r8>>b->b-8]8
*102 _0*101 [l16o7e-f8./V+5]4 V-15 [[l16o7a-b-8./V+5]4 V-15 [l16o7bb-8./V+5]4 V-15 [l16o7a-f8./V+5]4 V-15 /[l16o7a-g8./V+5]4 V-15]2
D *101 LV20*102
E r16K-24 p1*101 LV25*102
F r8K16 p2*101 LV30*102

;==================================================
; Now for Something Different
;==================================================

A _0o3l2b->f4l12b-fb- | [l4<eb>e<b | l2b>f+4l12bf+b | l4<ebf+>c+ | /o3l2a->e-4l12a-e-a-]3
B l4o3cr4l12V20[o7b-12V+5]6 | [v12l4o3cr4l12V20[o8eV+5]6 | v12l4o3cr4l12V20[o7b12V+5]6 | v12l4o3cr4l12V20[o8f+V+5]6 | /v12l4o3cr4l12V20[o8a-V+5]6]3
C @1 'fm3 1000' l2.o6 fr4[dr4<ar4l2bb/l2.o6e-r4]3
M @1 'fm3 0100' l2.o6 a-r4[g-r4d-r4l2d-e-/l2.o6g-r4]3
N @1 'fm3 0010' l2.o7 cr4[<ar4er4l2de/l2.o6b-r4]3
O @1 'fm3 0001' l2.o7 e-r4[d-r4<g-r4l2g-a-/l2.o7d-r4]3
J D0G0[v10@8o6b4>b4<<c4>b4]8 | [l8o6b8 D30a8 D0@8v8>b8 D30a8 D0@8v8<<c8 D30a16a16 D0@8v8>b8 l32D30aaaaD0]4
*103 l6o5e-fa-b->e-b- [[o5eg+b_12]2 l12[b-bb-/V+5]4 V-15[a-b-a-/V+5]4 /_0V-15l6o5a-b>e-a-b>g-]2
D V20*103 | v3_0[*100)1]4 _12[*100/)1]4
E V25*103 | v1_0[*100)1]4 _12[*100/)1]4
F V30*103 | v0_0[*100)1]4 | [r1]4

B l16V20[o8c+V+5]16 | l16V20[o8g+V+5]16 | l16V20[o7b16V+5]16 | l16V20[o8f+V+5]16
142 changes: 142 additions & 0 deletions data/bgm/Web_of_Contexts(3).mml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#title Webs of Contexts
#composer Muscises
#date 2021-09-27
#platform megadrive

;FM
@1 fm 4 0; 2OP Bells
31,0,10,7,0,24,0,5,7,0
31,0,0,7,0,12,0,1,7,0
31,0,10,7,0,24,0,5,3,0
31,0,0,7,0,12,0,1,3,0

@2 fm 4 0; Pad
3,2,3,0,6,10,0,0,7,0
21,0,0,4,0,2,0,1,7,0
3,1,3,0,5,23,0,1,3,0
13,0,0,4,0,12,0,2,3,0

@3 fm 4 0; Soft Pad
3,2,2,0,6,35,0,0,7,0
21,0,1,3,0,2,0,1,7,0
3,1,2,0,5,50,0,1,3,0
13,0,1,3,0,12,0,2,3,0

;PSG
@5 psg
15>4:30 / 0

@6 psg
15>1:200 / 0

@7 psg
15 / 0

;PSG Arpeggioes
@M1 | 0 0 0 2 2 2 9 9 9
@M2 | 0 0 0 2 2 2 7 7 7
@M3 | 0 0 0 3 3 3 5 5 5
@M4 | 0 0 0 4 4 4 7 7 7
@M5 | 0 0 0 3 3 3 8 8 8
@M6 | 0 0 0 3 3 3 7 7 7
@M7 | 0


;====================================================================
; Ext. CH3 Backing
;====================================================================

A t95
A @2 v10Q8
B @2 v7Q8
D @2 v7Q8
E @2 v7Q8
F @2 v7Q8

C @1 'fm3 1100' [V12l16 o5 a-&e-&g-&<b&>d-&e-&b-g-&e-&<a-&b-&>e-&d-&g-&b&b-]48
M 'fm3 0011' [r1]r16[V20K-24l16 o5 a-&e-&g-&<b&>d-&e-&b-g-&e-&<a-&b-&>e-&d-&g-&b&b-]46

C @1 'fm3 1100' [V16l16G90 o5 a-&e-&g-&<b&>d-&e-&b-g-&e-&<a-&b-&>e-&d-&g-&b&b-]32
M 'fm3 0011' [K-28V24l16G90 o5 a-&e-&g-&<b&>d-&e-&b-g-&e-&<a-&b-&>e-&d-&g-&b&b-]32

C @1 'fm3 1100' G0[V12l16 o5 a-&e-&g-&<b&>d-&e-&b-g-&e-&<a-&b-&>e-&d-&g-&b&b-&]8 [l16b-&V+4]8 r1
M 'fm3 0011' G0[V20K-24l16 o5 a-&e-&g-&<b&>d-&e-&b-g-&e-&<a-&b-&>e-&d-&g-&b&b-&]6r4


;====================================================================
; Section A
;====================================================================

A [r1]4
B [r1]4
D [r1]4
E [r1]4
F [r1]4
G [r1]6
H [r1]12
I [r1]12r4

A [o3l1d-^^^| e-^^^]
B p1o5 [l1a-^^^ | b-^^^]
D p2o5 [l1b^^^| l d-^^^]
E p2[l1o5>e-^^^ | f^^^]
F p1[l1o5>g-^^^ | a-^^^]

G G0 [v10@6M1o4l1g- | [r1]3 | M2g- | M3a- | M4g- | r1]3
H @5 r4[v7[)2o4d-8<g-8.b8>d-8.<e-8a-4/)1>d-8<g-8.b8>d-8.<e-8b-4] | o4d-8<g-8.b8>d-8.<e-8a-4 | [o4d-8<g-8.b8>d-8.<e-8a-4>d-8<g-8.b8>d-8.<e-8b-4(2]] | [o4d-8<g-8.b8(1>d-8.<e-8/a-4(2]
I @5 r8K-28[v3[)2o4d-8<g-8.b8>d-8.<e-8a-4/)1>d-8<g-8.b8>d-8.<e-8b-4] | o4d-8<g-8.b8>d-8.<e-8a-4 | [o4d-8<g-8.b8>d-8.<e-8a-4>d-8<g-8.b8>d-8.<e-8/b-4(2]/b-4(2]

;====================================================================
; Section B
;====================================================================

A [o3l1a-^^^G20 | >d-^&e-g-&G16]
B p2 [o5b^^^| >c^^^]
D p1o6 [e-^^^ | e-^^^]
E p1o6[g-^^^ | g^^^]
F p2o6[b-^^^ | b-^^^]

G v10[M2g-8.g-8.g-8(2] | v10[a-8.a-8.a-8(2] | v10[M5b-8.b-8.b-8(2] | [v10[M2>d-8.d-8.d-8(2]] | v10[M6e-8.e-8.e-8(2]
H @6v8o5[M2g-8.g-8.g-8(1] | v8[a-8.a-8.a-8(1] | v8[M5b-8.b-8.b-8(1] | [v8[M2>d-8.d-8.d-8(1]] | v8[M6e-8.e-8.e-8(1]
I o5v8l16K28@6[\=2,5 o3 b\b-\e-\g-\d-\e-\<b-\b\/)2]4 | [\=2,5 o3 b\b-\e-\g-\d-\e-\<b-\b\(1]

;====================================================================
; Section C
;====================================================================

A [l1o3G20d-&e-a-bG16]3
B [l1o5G20p1a-&b-p2baG16]3
D [l1o5G20p2b&>d-p1e-d-G16]3
E [l1G20o5p1>e-&fp2g-dG16]3
F [l1G20o5p2>g-&a-p1b-g-G16]3
G G0 [v12@6M1o4l1g- | M2g- | M3a- | M6g-]3
H G0 K-24 r4.[v10@6M1o4l1g- | M2g- | M3a- | M6g-]3
I l16K-32[\=2,5 o3 b\b-\e-\g-\d-\e-\<b-\b\)1]3 | [\=2,5 o3 b\b-\e-\g-\d-\e-\<b-\b\]3 | [\=2,5 o3 b\b-\e-\g-\d-\e-\<b-\/b\(1]8

;====================================================================
; Section D
;====================================================================

A @2v11 [K20o3l1G24d-&a->d-a- | o3e-b->e-b-]
B @3v9 [K28p1o5 l1a-^^^ | b-^^^G0]
D @3v9 [K16p2o5 l1b^^^| l d-^^^G0]
E @3v9 [K24p2l1o5>e-^^^ | f^^^G0]
F @3v9 [K8p1l1o5>g-^^^ | a-^^^G0]
G G0 v12[@6M1o4l1g- | M2g- | M3a- /| M4g-(2]4 M6e-(2
H G0 K-24v10[@6M1o4l1g- | M2g- | M3a- /| M4g-(2]4 M6e-2^8(2
I @5o6v5l8[\=1,3 e-\)1]8[\=1,3 e-\(1]8 | [\=1,3 d-\)1]8[\=1,3 d-\(1]8 | [\=1,3 <b\)1]8[\=1,3 b\(1]8 | [\=1,3 b-\)1]8[\=1,3 b-\(1]8

;====================================================================
; Coda
;====================================================================

A @2v11 [o3l1a-abg-V-1/G20&]4
B @3v10 [p2o5l1g-p1gp2ap1bV-1/G24&]4
D @3v10 [p1o5l1b-p2bp1>d-p2d-V-1/G24&]4
E @3v10 [p2l1o5bp1>dp2dp1eV-1/G24&]4
F @3v10 [p1l1o5>e-p2g-p1g-p2a-V-1/G24&]4
G @7v7o3M7l16[G90a-&e-&g-&<b&>d-&e-&b-g-&e-&<a-&b-&>e-&d-&g-&b&b-&)1]8 | v12l32[G0\=2,4 a-\e-\g-\<b\>d-\e-\b-\g-\e-\<a-\b-\>e-\d-\g-\b\b-\(1]8
H @5o5v5l16M7[[\=1,3 e-\)1]8[\=1,3 d\(1]8 | [\=1,3 d-\)1]8[\=1,3 <a-\(1]8]4 | [\=1,3 <a-\(1]8
I @5o6v5l16[[\=1,3 e-\)1]8[\=1,3 d\(1]8 | [\=1,3 d-\)1]8[\=1,3 <a-\(1]8]4 | [\=1,3 <a-\(1]8


Binary file removed data/bgm/idk.mds
Binary file not shown.
Binary file removed data/bgm/junkers_high.mds
Binary file not shown.
Binary file removed data/bgm/midnight.mds
Binary file not shown.
Binary file removed data/bgm/passport.mds
Binary file not shown.
Binary file removed data/bgm/sand_light.mds
Binary file not shown.
2 changes: 2 additions & 0 deletions src/blob.68k
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SYSTEM_C equ 1

; builds MDSDRV as binary blob
include "src/mddef.inc"
include "src/mdsdrv.inc"
Expand Down
1 change: 1 addition & 0 deletions src/main.68k
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DEBUG_SCREEN equ 1
SYSTEM_C equ 1

; MD library includes
include "src/mdinit.68k"
Expand Down
16 changes: 11 additions & 5 deletions src/mdbug.68k
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@ bug1
move.b #$df,(a0)
move.b #$ff,(a0)

move.w #$100,z80_reset
move.w #$100,z80_bus_request
if ~def(SYSTEM_C)
move.w #$100,z80_reset
move.w #$100,z80_bus_request
endif

bsr.w vdp_init
move.w #$000,z80_reset
if ~def(SYSTEM_C)
move.w #$000,z80_reset
endif

move.l a7,a5 ;pointer to exception frame

Expand All @@ -144,8 +148,10 @@ bug1
moveq #35,d1
bsr.w vdp_print

move.w #$100,z80_reset
move.w #$000,z80_bus_request
if ~def(SYSTEM_C)
move.w #$100,z80_reset
move.w #$000,z80_bus_request
endif

; print registers
lea bug_tab(pc),a0
Expand Down
Loading