Skip to content

Commit

Permalink
4.3.0.0 Supported SID chip for VSIF.
Browse files Browse the repository at this point in the history
  • Loading branch information
110-kenichi committed Aug 21, 2022
1 parent d7501e1 commit 99d0ad3
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 129 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAmidiMEmo 4.2.0.0 Itoken (c)2019, 2020, 2021, 2022 / GPL-2.0
MAmidiMEmo 4.3.0.0 Itoken (c)2019, 2020, 2021, 2022 / GPL-2.0

*** What is the MAmidiMEmo? ***

Expand Down Expand Up @@ -268,6 +268,7 @@ e.g.) YM2151 has 8ch FM sounds, so you can play 8 chords on MIDI 1ch or sharing
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNQ9JE3JAQMNQ)

*** Changes ***
4.3.0.0 Supported SID chip for VSIF.
4.2.0.0 Updated ymfm engine to latest. ymfm is used for OPZ, OPQ, OPN2, OPLL.
Supported YM3806(aka OPQ) chip. YM3806(YM3533) is used by PORTATONE PSR-70.
Fixed some minor bugs for OPM,OPZ.
Expand Down
Binary file modified docs/MAmidiMEmo/Manual.pdf
Binary file not shown.
Binary file modified docs/MAmidiMEmo/Manual.pptx
Binary file not shown.
157 changes: 34 additions & 123 deletions src/VSIF/VGMPlay_C64/VSIF_C64.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
*=$0801
BasicUpstart(main)

.zp
{
addr:
.byte 0
data:
.byte 0
}

* = $0810

//CLOCK_PAL = 985248 Hz
Expand All @@ -9,6 +17,24 @@ BasicUpstart(main)
// 31250bps 31.527936 clk @ 985248 (PAL)
// 31250bps 32.727264 clk @ 1022727 Hz (NTSC)

.macro CheckStartBit1()
{
loop:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 // Fire Bit is 0?
beq loop //2 7
lda $dc00 //3 10 //Read port2 data
}

.macro CheckStartBit0()
{
loop:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 // Fire Bit is 0?
bne loop //2 7
lda $dc00 //3 10 //Read port2 data
}

main:
jsr $e544 //clear screen

Expand Down Expand Up @@ -38,27 +64,6 @@ main:
lda #%10000000 //Select Paddle #2
sta $dc00 //Bits #6-#7: Paddle selection; %01 = Paddle #1; %10 = Paddle #2.

// // value_check:
// // lda $d419 //3 13 //Read port2 data
// // lsr
// // lsr
// // lsr
// // lsr
// // and #$1f
// // adc #$30
// // jsr $ffd2 //bsout

// // lda $d41a //3 13 //Read port2 data
// // lsr
// // lsr
// // lsr
// // lsr
// // and #$1f
// // adc #$30
// // jsr $ffd2 //bsout

// //jmp value_check

/* ------------------------------------------------------------------ */
//http://codebase64.org/doku.php?id=base:joystick_input_handling
// Bit #0: 0 = Port 2 joystick up pressed.
Expand All @@ -78,10 +83,7 @@ get_address_Lo:
// adrs_lo, mid, hi, data_hi, mid, lo, ...
/* ------------------------------------------------------------------ */
get_address_Mid:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 // Fire Bit is 0?
beq get_address_Mid //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit1() //10 10
and #%00000111 //2 12
asl //2 14
asl //2 16
Expand All @@ -90,10 +92,7 @@ get_address_Mid:
sta addr //4 26

get_address_Hi:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 //Fire Bit is 0?
bne get_address_Hi //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit0() //10 10
and #%00000011 //2 12
ror //2 14
ror //2 16
Expand All @@ -102,10 +101,7 @@ get_address_Hi:
tax //2 26

get_data_Hi:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 //Fire Bit is 1?
beq get_data_Hi //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit1() //10 10
and #%00000111 //2 12
ror //2 14
ror //2 16
Expand All @@ -114,67 +110,28 @@ get_data_Hi:
sta data //4 24

get_data_Mid:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 //Fire Bit is 1?
bne get_data_Mid //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit0() //10 10
and #%00000111 //2 12
asl //2 14
asl //2 16
ora data //4 20
sta data //4 24

get_data_Lo:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 //Fire Bit is 0?
beq get_data_Lo //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit1() //10 10
and #%00000011 //2 12
//Sound SID
ora data //4 16
sta $d400,x //6 22

// sta data
// and #$f0
// lsr
// lsr
// lsr
// lsr
// adc #$30
// jsr $ffd2 //bsout
// lda data
// and #$0f
// adc #$30
// jsr $ffd2 //bsout

// txa
// and #$f0
// lsr
// lsr
// lsr
// lsr
// adc #$30
// jsr $ffd2 //bsout
// txa
// and #$0f
// adc #$30
// jsr $ffd2 //bsout

// lda #$20
// jsr $ffd2 //bsout
//jmp wait_start_bit

lda $dc00 //3 25 //Read port2 data
and #%0000_0100 //2 27

beq wait_start_bit //2 29
inx //2 31

get_data_Hi2:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 //Fire Bit is 1?
bne get_data_Hi2 //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit0() //10 10
and #%00000111 //2 12
ror //2 14
ror //2 16
Expand All @@ -183,21 +140,15 @@ get_data_Hi2:
sta data //4 24

get_data_Mid2:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 //Fire Bit is 1?
beq get_data_Mid2 //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit1() //10 10
and #%00000111 //2 12
asl //2 14
asl //2 16
ora data //4 20
sta data //4 24

get_data_Lo2:
lda $dc00 //3 3 //Read port2 data
and #%00001000 //2 5 //Fire Bit is 0?
bne get_data_Lo2 //2 7
lda $dc00 //3 10 //Read port2 data
CheckStartBit0() //10 10
and #%00000011 //2 12
//Sound SID
ora data //4 16
Expand All @@ -212,47 +163,7 @@ wait_start_bit_jmp:
jmp wait_start_bit //3 32
/* ------------------------------------------------------------------ */

// // lda #$2d //-
// // jsr $ffd2 //bsout

// // sta data1

// // lda addr
// // lsr
// // lsr
// // lsr
// // lsr
// // adc #$30
// // jsr $ffd2 //bsout

// // lda addr
// // and #$1f
// // adc #$30
// // jsr $ffd2 //bsout

// // lda data1
// // lsr
// // lsr
// // lsr
// // lsr
// // adc #$30
// // jsr $ffd2 //bsout

// // lda data1
// // and #$1f
// // adc #$30
// // jsr $ffd2 //bsout

// // lda #$20
// // jsr $ffd2 //bsout
// // jmp wait_start_bit_0 //3 23


/* ------------------------------------------------------------------ */
addr:
.byte 0
data:
.byte 0

//https://www.c64-wiki.com/wiki/Assembler_Example
//bsout =$ffd2 //kernel character output sub
Expand Down
Binary file modified src/VSIF/VGMPlay_C64/VSIF_C64.prg
Binary file not shown.
2 changes: 1 addition & 1 deletion src/mamidimemo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static class Program
/// <summary>
///
/// </summary>
public const string FILE_VERSION = "4.2.0.0";
public const string FILE_VERSION = "4.3.0.0";

public const string FILE_COPYRIGHT = @"Virtual chiptune sound MIDI module ""MAmidiMEmo"" Version {0}
Copyright(C) 2019, 2022 Itoken.All rights reserved.";
Expand Down
53 changes: 49 additions & 4 deletions src/mamidimemo/instruments/Chips/SIDBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,53 @@ private void setSoundEngine(SoundEngineType value)
}
break;
}
initGlobalRegisters();
}
}

private void initGlobalRegisters()
{
SidWriteData(UnitNumber, 0x15, (byte)(f_FC & 0x7), (byte)(f_FC >> 3));
SidWriteData(UnitNumber, 0x17, (byte)(f_RES << 4 | (int)f_FILT));
SidWriteData(UnitNumber, 0x18, (byte)((int)f_FilterType << 4 | (int)f_Volume));
}

private SidBaseAddressType f_SidBaseAddress;

/// <summary>
///
/// </summary>
[DataMember]
[Category("Chip(Dedicated)")]
[Description("SID Address offset")]
[DefaultValue(SidBaseAddressType.D400)]
public SidBaseAddressType SidBaseAddress
{
get => f_SidBaseAddress;
set
{
if (f_SidBaseAddress != value)
{
f_SidBaseAddress = value;
initGlobalRegisters();
}
}
}

/// <summary>
///
/// </summary>
public enum SidBaseAddressType
{
D400 = 0x00,
D420 = 0x20,
D440 = 0x40,
D460 = 0x60,
D480 = 0x80,
D4A0 = 0xA0,
D4C0 = 0xC0,
D4E0 = 0xE0,
}

private int f_ftdiClkWidth = 25;

Expand Down Expand Up @@ -396,8 +440,7 @@ private void SidWriteData(uint unitNumber, int address, byte data)
{
if (CurrentSoundEngine == SoundEngineType.VSIF_C64_FTDI)
{
vsifClient.WriteData(0, (byte)address, data, f_ftdiClkWidth);
//vsifClient.WriteData(0, (byte)0x1f, 0, f_ftdiClkWidth);
vsifClient.WriteData(0, (byte)(address + SidBaseAddress), data, f_ftdiClkWidth);
}
}
DeferredWriteData(Sid_write, unitNumber, address, data);
Expand All @@ -422,7 +465,7 @@ private void SidWriteData(uint unitNumber, int address, byte data1, byte data2)
{
if (CurrentSoundEngine == SoundEngineType.VSIF_C64_FTDI)
{
vsifClient.WriteData(1, (byte)address, new byte[] { data1, data2 }, f_ftdiClkWidth);
vsifClient.WriteData(1, (byte)(address + SidBaseAddress), new byte[] { data1, data2 }, f_ftdiClkWidth);
}
}
DeferredWriteData(Sid_write, unitNumber, address + 1, data2);
Expand Down Expand Up @@ -739,6 +782,9 @@ public override void KeyOn()
parentModule.FilterType = (FilterTypes)gs.FilterType.Value;
}

//HACK: workaround of the SID bug
//parentModule.SidWriteData(parentModule.UnitNumber, Slot * 7 + 4, 0b1000);

SetTimbre();
OnVolumeUpdated();
OnPitchUpdated();
Expand Down Expand Up @@ -835,7 +881,6 @@ public override void OnPitchUpdated()

byte data = (byte)((int)w << 4 | timbre.RING << 2 | timbre.SYNC << 1 | (IsSoundOff ? 0 : 1));
parentModule.SidWriteData(un, Slot * 7 + 4, data);
parentModule.SidWriteData(un, Slot * 7 + 4, data);

base.OnPitchUpdated();
}
Expand Down

0 comments on commit 99d0ad3

Please sign in to comment.