vgmrips

The forum about vgm files
It is currently 2018-12-14, 17:25:08

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: 2018-09-17, 16:27:52 
Offline

Joined: 2017-11-21, 16:36:09
Posts: 30
ctr, i am posting here since i have bad timing posting the irc chat, and you didn't see my messages, but i think i have found what i belive is the lfo table (its found between 0x660d144 and 0x660e944).
but its not really a waveform, its more of a linear table, and its doing something similar to a sine operation to the pointer offset.
i have made a bin file rip [url = https://drive.google.com/file/d/1Op3zAt ... sp=sharing]here[/url], and [url = https://drive.google.com/file/d/1Tcbh-o ... sp=sharing]i have made a snapshot of the routine[/url], also i wanted to include a snippet of the assembly code, but i don't know if is trash https://pastebin.com/xK3iMNKw
i have written this "quickly" before my pc gets repaired


Top
 Profile  
 
 Post subject:
PostPosted: 2018-09-17, 21:06:29 

Contributors Contributors
Staff Staff
Reverse engineers Reverse engineers
Offline
User avatar

Joined: 2013-07-17, 23:32:39
Posts: 342
That looks to just be a pitch table. I.E. the values that are written to the sound chip to specify the sound frequency. It's obvious since the highest value is about twice as big as the first value in the table, indicating that it covers an octave. Also there are 6144 16-bit values, divided by 12 that gives exactly 512 'cents' or fractions in a semitone. The LFO vibrato is created by modulating the frequency value (which as you say is a pointer into this table), meaning the sine function or table is somewhere else.

To get lower or higher octaves, the values are just shifted as necessary.


Top
 Profile  
 
 Post subject:
PostPosted: 2018-09-24, 22:03:34 
Offline

Joined: 2017-11-21, 16:36:09
Posts: 30
ctr, i have found a part of the lfo processing code, its after the address 0x0613BA10.
if you have time to investigate more on it someday, and explain me what it does, that would be really cool

EDIT: just found out it was not the right block of code, i have edited the right one now.

and the summary i wrote before was confusing, so there is a new one, from what i have seen.. (for reference, i am using channel 0x09 in song 0x1e, the vibrato depth here is 0xe2, and the lfo speed is 0x76da, converted from the tables).

so, it multiplies the lfo speed for the vibrato depth, to get a value (for semplicity i am going to refer it as lfo_val_per_phase), for finding the minimum lfo value, in register 6, the vibrato depth value is shifted by 16 bits, and it subtracts this to lfo_val_per_phase.

then, in address 0x207913c, i think is stored the current lfo value, and it subtracts the (lfo_val_per_phase) to the current lfo value (current lfo value - lfo_val_per_phase)


Top
 Profile  
 
 Post subject:
PostPosted: 2018-10-12, 11:28:10 
Offline

Joined: 2017-11-21, 16:36:09
Posts: 30
i have managed to make a (bad) transcription of the code starting from 0613BA10, that handles the current lfo value.
Code:
cps3 vibrato code transcribed

starting from 0613BA10
before anything happens, load vibrato rate (register 6) and depth (register 5)
multiply the two for vib_depth_per_rate, and override vibrato rate with it(register 5).
the value contained in address (r14 (the start of channel 10 work area, in this case 2079120) + 0x6e)
gets saved to register 3.
then, if (r3 != r8 (seems to be always 1)), goto 613ba60, else continue to 613ba3c;
shift r6 left by 16 bits regardless

613ba3c: move the current lfo value to r3, move r5 (vib_depth_per_rate) to r2, subtract it to r6 (vibrato rate << 16), and if (r2 >= r3), branch to 613ba50, else, continue to 613ba48.
load the current lfo value (in address r14 + 0x1c) to register 1, then subtract r5 to r1, and goto 0613BA6e:
move the result to the address for current lfo value.

613ba50: move 0xfe to r3, then arithmetically reverse r6 (-r6), and move r6 to the address of the current lfo value, then:
load the value inside (r14 + r0), then (r2 & r3), and save that to r14 + r0.

613ba60: move r6 (vibrato rate << 16) to r3, move the previous lfo value to r2, subtract r5 (vib_depth_per_rate) to r3.
if (r3 >= r2): goto 613ba72, else, move again the previous lfo value to r1, add r5 to r1, move the result to the address for previous lfo value.

613ba72: move 0x6e to r0, move r6 (vibrato rate << 16) to the previous lfo value, move 0x01 to r3, move the value of (r14 + r0) to r2, then (r2 | r3), and move the result to (r14 + r0).

r14 + r0 seems to contain the current lfo state (i.e. rising, falling, ect...)
and r8 may refer to a specific lfo state (maybe rising, as the algorithm that gets branched to when (r3 & r8) is true, produces values bigger than the previous lfo value)

maybe i can make a piece of c code that replicates this.

Edit: there was stuff that was wrong, now i have corrected it (or at least partially)


Top
 Profile  
 
 Post subject:
PostPosted: 2018-12-02, 18:58:26 
Offline

Joined: 2017-11-21, 16:36:09
Posts: 30
so, i got the lfo emulator to run at the rigth tick frequency with different tempos, and to find the start of the function that converts the lfo value into an usable value for the pitch table, but in that bllock of code, it uses a value that is derived from the current note begin played (at channel 0x09 (counting from zero), its located at 0x2079130, 2079132 and 2079134)
but i can't figure out where the block of code that determines that value, my tracefiles do not include it, when i try to make an another one and i cannot trigger songs in the sound test because its slow and locks me out of any input.
i was thinking of putting a watch point on a note in the song's data...

Edit: i think i found something:
to turn the note value into an usable variable, it subtracts the intrument sample's key center, then adds 7, shifth by 2, left, subtracts the value inside (current_channel_offset + 0x56), and adds 0x80, and adds again the value at (0x6788848 + 0x6, the 7th byte in an instrument key split)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 50 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
[ Time : 0.105s | 14 Queries | GZIP : On ]