From cfae8db6d8cc96b41be918d94f8964dd63758f9e Mon Sep 17 00:00:00 2001 From: manakoAT Date: Sat, 10 Jan 2009 22:39:43 +0000 Subject: [PATCH] support for mono "bmdx" files added git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@560 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- Generic Header Creator 3/4_BALK0.BAS | 55 ---------- Generic Header Creator 3/Form1.frm | 149 ++++++++++++++++++++++---- Generic Header Creator 3/Form2.frm | 50 --------- Generic Header Creator 3/Projekt1.vbp | 1 - Generic Header Creator 3/Projekt1.vbw | 1 - src/meta/ps2_bmdx.c | 35 +++--- 6 files changed, 148 insertions(+), 143 deletions(-) delete mode 100644 Generic Header Creator 3/4_BALK0.BAS delete mode 100644 Generic Header Creator 3/Form2.frm diff --git a/Generic Header Creator 3/4_BALK0.BAS b/Generic Header Creator 3/4_BALK0.BAS deleted file mode 100644 index 0d0fda33..00000000 --- a/Generic Header Creator 3/4_BALK0.BAS +++ /dev/null @@ -1,55 +0,0 @@ -Attribute VB_Name = "Modul1" -Sub ValueChange(Ctrl As Control, ByVal V, ByVal MaxV, ByVal Farbe) - Vertikal = (Ctrl.ScaleWidth <= Ctrl.ScaleHeight) - If Vertikal Then - W = Ctrl.ScaleHeight - TW = Ctrl.TextWidth("100") - If Ctrl.Width < TW Then Ctrl.Width = TW - Else - W = Ctrl.ScaleWidth - End If - Xw = (Abs(V) / Abs(MaxV)) * W - Proz$ = LTrim$(Str$(Int((Xw / W) * 100))) - T$ = "%" - - F = Farbe - DM = 14 - Select Case F - Case 7, 10, 11, 13, 14 - F = 0 - DM = 9 - Case 15 - F = 0 - DM = 6 - End Select - Ctrl.DrawMode = DM - Ctrl.ForeColor = QBColor(F) - - Ctrl.AutoRedraw = True - Ctrl.Cls - - Select Case Vertikal - Case 0 - Ctrl.CurrentX = (W - Ctrl.TextWidth(Proz$ + "%")) \ 2 - Ctrl.Print Proz$ + T$; - Case -1 - Ctrl.CurrentX = (Ctrl.ScaleWidth - Ctrl.TextWidth(Proz$)) \ 2 - Ctrl.CurrentY = (Ctrl.ScaleHeight - 2 * Ctrl.TextHeight(Proz$)) \ 2 - Ctrl.Print Proz$; - Ctrl.CurrentX = (Ctrl.ScaleWidth - Ctrl.TextWidth("%")) \ 2 - Ctrl.CurrentY = (Ctrl.ScaleHeight - (Ctrl.TextHeight(Proz$)) \ 2) \ 2 - Ctrl.Print "%"; - End Select - - If V > 0 Then - Select Case Vertikal - Case 0 - Ctrl.Line (0, 0)-(Xw, Ctrl.ScaleHeight), QBColor(Farbe), BF - Case -1 - Ctrl.Line (0, Ctrl.ScaleHeight - Xw)-(Ctrl.ScaleWidth, Ctrl.ScaleHeight), QBColor(Farbe), BF - End Select - End If - Ctrl.AutoRedraw = False -End Sub - - diff --git a/Generic Header Creator 3/Form1.frm b/Generic Header Creator 3/Form1.frm index 2520ad74..8f3b2182 100644 --- a/Generic Header Creator 3/Form1.frm +++ b/Generic Header Creator 3/Form1.frm @@ -1750,6 +1750,8 @@ Dim TimeSecondsCutLoopEnd Dim MSADPCM_Frames Dim MSADPCM_LastFrame +Dim RiffChannels As Integer +Dim RiffBits As Integer 'setting up needed GENH variables (ordered - all are 4 bytes long) Dim strGENHCheck As String * 4 @@ -2174,6 +2176,68 @@ COUNTER = 0 End Sub +Private Sub cmdFindLoopsPSX_Click() + +Close #1 +Dim CheckByte As Byte +COUNTER = 0 + + If strInputFile = "" Then + lblINFO.Caption = ("No File selected!") + Exit Sub + ElseIf txtGENHChannels.Text = "" Then + lblINFO.Caption = ("Channel Value not set!") + Exit Sub + End If + +GENHChannels = txtGENHChannels.Text +Open strInputFile For Binary As #1 + + Do + + Get #1, 2 + COUNTER, CheckByte + + If CheckByte = 0 Then + lblINFO.Caption = "File has no Loop Flages, using standard values...!" + txtGENHLoopStartSamples.Text = "" + cmdUSEFILEEND_Click + Close #1 + Exit Sub + End If + + If CheckByte = 6 Then + txtGENHLoopStartSamples.Text = COUNTER / 16 / GENHChannels * 28 + lblINFO.Caption = "Loop Start found (" & txtGENHLoopStartSamples.Text & ")" + End If + + COUNTER = COUNTER + 16 + Loop Until CheckByte = 6 + +COUNTER = 0 + + Do + + Get #1, (FileLen(strInputFile) - 14) - COUNTER, CheckByte + + If COUNTER = &H20000 Then + Close #1 + Exit Sub + End If + + If CheckByte = 3 Then + txtGENHLoopEndSamples.Text = (FileLen(strInputFile) - COUNTER) / 16 / GENHChannels * 28 + lblINFO.Caption = "Loop End found (" & txtGENHLoopEndSamples.Text & ")" + End If + + COUNTER = COUNTER + 16 + Loop Until CheckByte = 3 + + + Close #2 + + +End Sub + Private Sub cmdUSEFILEEND_Click() Close #1 @@ -2403,19 +2467,24 @@ End Sub Private Sub File1_Click() +Close #1 'Just to be sure, to prevent crashes + If FolderBrowser1.Text = "" Then - txtInputFile.Text = File1.FileName + txtInputFile.Text = File1.FileName Else - txtInputFile.Text = FolderBrowser1.Text & "\" & File1.FileName + txtInputFile.Text = FolderBrowser1.Text & "\" & File1.FileName End If - strInputFile = txtInputFile.Text - - txtInputFileLength.Text = (FileLen(strInputFile)) - - txtOutputFile.Text = txtInputFile.Text & ".GENH" + strInputFile = txtInputFile.Text + txtInputFileLength.Text = (FileLen(strInputFile)) + txtOutputFile.Text = txtInputFile.Text & ".GENH" Open strInputFile For Binary As #1 + +'############################################################################## +'#### Here we'll implement some checks and autogetting for varoius formats #### +'############################################################################## + '"GENH" - the creator will be disabled if you select a "GENH" file Get #1, 1, strGENHCheck If strGENHCheck = "GENH" Then txtOutputFile.Text = "" @@ -2424,39 +2493,77 @@ Private Sub File1_Click() Close #1 Exit Sub Else + 'Else, we'll remove the extension for further things cmdCreateGENH.Enabled = True lblCreateGenh.Enabled = True - -On Error Resume Next - NAMECUT = txtInputFile.Text - txtOutputFile.Text = Left(NAMECUT, InStrRev(txtInputFile.Text, ".") - 1) & ".GENH" - txtGetFileName.Text = File1.FileName - - + On Error Resume Next + NAMECUT = txtInputFile.Text + txtOutputFile.Text = Left(NAMECUT, InStrRev(txtInputFile.Text, ".") - 1) & ".GENH" + txtGetFileName.Text = File1.FileName End If - If strGENHCheck = "SPSD" Then 'NAOMI / NAOMI 2 - + 'SPSD - found in various NAOMI/NAOMI2 and DreamCast games + If strGENHCheck = "SPSD" Then 'NAOMI / NAOMI 2 Get #1, 13, GENHLoopEnd Get #1, 45, GENHLoopStart - If GENHLoopStart > GENHLoopEnd Then GENHLoopStart = -1 Else GENHLoopStart = GENHLoopStart End If - comboFileFormat.ListIndex = 10 + comboFileFormat.ListIndex = 10 'Yamaha ADPCM txtGENHHeaderSkip.Text = "64" txtGENHLoopEndSamples.Text = GENHLoopEnd txtGENHLoopStartSamples.Text = GENHLoopStart - If chkHalfFileInterleave.Value = 1 Then + If chkHalfFileInterleave.Value = 1 Then GENHInterleave = GENHLoopEnd / 2 - End If - End If + End If + + + 'Riff WAVEfmt - no need to explain this... + If strGENHCheck = "RIFF" Then + Get #1, 9, strGENHCheck + If strGENHCheck = "WAVE" Then + Get #1, 13, strGENHCheck + If strGENHCheck = "fmt " Then + + Get #1, 23, RiffChannels + Get #1, 25, GENHFrequency + Get #1, 35, RiffBits + COUNTER = 0 + + Do + + Get #1, 1 + COUNTER, strGENHCheck + If strGENHCheck = "data" Then + Get #1, COUNTER + 5, GENHLoopEnd + If RiffBits = 8 Then + txtGENHLoopEndSamples = GENHLoopEnd / RiffChannels + txtGENHHeaderSkip.Text = COUNTER + 8 + txtGENHChannels.Text = RiffChannels + txtGENHFrequency.Text = GENHFrequency + ElseIf RiffBits = 16 Then + txtGENHLoopEndSamples = GENHLoopEnd / RiffChannels / 2 + txtGENHHeaderSkip.Text = COUNTER + 8 + txtGENHChannels.Text = RiffChannels + txtGENHFrequency.Text = GENHFrequency + End If + End If + COUNTER = COUNTER + 1 + Loop Until COUNTER = 2048 + End If + End If + End If + + + + + + Close #1 frmFileCreator.Caption = "File: " & strInputFile diff --git a/Generic Header Creator 3/Form2.frm b/Generic Header Creator 3/Form2.frm deleted file mode 100644 index 85584948..00000000 --- a/Generic Header Creator 3/Form2.frm +++ /dev/null @@ -1,50 +0,0 @@ -VERSION 5.00 -Begin VB.Form Form2 - Caption = "Form2" - ClientHeight = 3090 - ClientLeft = 60 - ClientTop = 450 - ClientWidth = 6195 - LinkTopic = "Form2" - ScaleHeight = 3090 - ScaleWidth = 6195 - StartUpPosition = 3 'Windows-Standard - Begin VB.CommandButton Command1 - Caption = "Start" - Height = 375 - Left = 1440 - TabIndex = 1 - Top = 1560 - Width = 3135 - End - Begin VB.TextBox Text1 - Alignment = 2 'Zentriert - Height = 285 - IMEMode = 3 'DISABLE - Left = 1440 - PasswordChar = "*" - TabIndex = 0 - Top = 1200 - Width = 3135 - End -End -Attribute VB_Name = "Form2" -Attribute VB_GlobalNameSpace = False -Attribute VB_Creatable = False -Attribute VB_PredeclaredId = True -Attribute VB_Exposed = False -Option Explicit - -Private Sub Command1_Click() - - If Text1.Text = "burnout" Then - Unload Form2 - Form1.Show - Else: - MsgBox ("Wrong password, cya :P") - Unload Form2 - Unload Form1 - End If - - -End Sub diff --git a/Generic Header Creator 3/Projekt1.vbp b/Generic Header Creator 3/Projekt1.vbp index d4dedee5..cbbea9b8 100644 --- a/Generic Header Creator 3/Projekt1.vbp +++ b/Generic Header Creator 3/Projekt1.vbp @@ -3,7 +3,6 @@ Form=Form1.frm Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation Object={49CBE90A-5F9F-4127-919C-0B74E18CB87E}#1.0#0; CK-Tools.ocx Form=frmABOUT.frm -Form=Form2.frm IconForm="Form1" Startup="Form1" HelpFile="" diff --git a/Generic Header Creator 3/Projekt1.vbw b/Generic Header Creator 3/Projekt1.vbw index cfa14829..2b2818fd 100644 --- a/Generic Header Creator 3/Projekt1.vbw +++ b/Generic Header Creator 3/Projekt1.vbw @@ -1,3 +1,2 @@ Form1 = 0, 0, 601, 456, Z, 22, 29, 623, 485, C frmABOUT = 0, 0, 0, 0, C, 132, 174, 733, 630, C -Form2 = 110, 145, 711, 601, , 44, 58, 645, 514, C diff --git a/src/meta/ps2_bmdx.c b/src/meta/ps2_bmdx.c index b7cf02c4..34d08102 100644 --- a/src/meta/ps2_bmdx.c +++ b/src/meta/ps2_bmdx.c @@ -5,7 +5,7 @@ VGMSTREAM * init_vgmstream_ps2_bmdx(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; char filename[260]; int loop_flag=0; - int channel_count; + int channel_count; off_t start_offset; int i; @@ -18,37 +18,42 @@ VGMSTREAM * init_vgmstream_ps2_bmdx(STREAMFILE *streamFile) { read_32bitBE(0x04,streamFile) != 0) goto fail; - /* check loop */ - loop_flag = (read_32bitLE(0x10,streamFile)!=0); + /* check loop */ + loop_flag = (read_32bitLE(0x10,streamFile)!=0); channel_count=read_32bitLE(0x1C,streamFile); - /* build the VGMSTREAM */ + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count,loop_flag); if (!vgmstream) goto fail; - /* fill in the vital statistics */ - vgmstream->channels = channel_count; + /* fill in the vital statistics */ + vgmstream->channels = channel_count; vgmstream->sample_rate = read_32bitLE(0x18,streamFile); - /* Check for Compression Scheme */ + /* Check for Compression Scheme */ if (read_32bitLE(0x20,streamFile) == 1) vgmstream->coding_type = coding_invert_PSX; else vgmstream->coding_type = coding_PSX; vgmstream->num_samples = read_32bitLE(0x0c,streamFile)*28/16/channel_count; - /* Get loop point values */ - if(vgmstream->loop_flag) { - vgmstream->loop_start_sample = read_32bitLE(0x10,streamFile)*28/16/channel_count; - vgmstream->loop_end_sample = vgmstream->num_samples; - } + /* Get loop point values */ + if(vgmstream->loop_flag) { + vgmstream->loop_start_sample = read_32bitLE(0x10,streamFile)*28/16/channel_count; + vgmstream->loop_end_sample = vgmstream->num_samples; + } + + if (channel_count == 1) { + vgmstream->layout_type = layout_none; + } else if (channel_count > 1) { + vgmstream->interleave_block_size = read_32bitLE(0x24,streamFile); + vgmstream->layout_type = layout_interleave; + } - vgmstream->interleave_block_size = read_32bitLE(0x24,streamFile); - vgmstream->layout_type = layout_interleave; vgmstream->meta_type = meta_PS2_BMDX; - start_offset = read_32bitLE(0x08,streamFile); + start_offset = read_32bitLE(0x08,streamFile); if (vgmstream->coding_type == coding_invert_PSX) {