Skip to content

Conversation

@tobybear
Copy link
Contributor

@tobybear tobybear commented Feb 9, 2025

Not all of them fully tested yet, but better than returning -1 I think.

Copy link
Owner

@vampirefrog vampirefrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll assume that you based your changes on your own research and that the code mostly works. We'll know with more certainty when we add some kind of automatic testing.

dmp_file.c Outdated
int dmp_file_save(struct dmp_file *f, int (*write_fn)(void *, size_t, void *), void *data_ptr) {
uint8_t buf[50] = { 0 };
int bc = 0;
buf[bc++] = 0x0a; // version 10
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use an incrementing pointer

dmp_file.c Outdated
#include "tools.h"

int dmp_file_load(struct dmp_file *f, uint8_t *data, size_t data_len, int system) {
#define SYSTEM_YM2612_OPN 0x02
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if these constants belong in this file or even in this position (I like to place them at the top of the file). But since they are used in a field that's defined in the struct, and the struct is defined in the header file, it's better if we move these inside the header file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DMP format changed with each iteration, making it hard to keep track to write proper importer/exporter libraries as you have to consider each and every version if you want to make it properly. The mentioned constants are for version 11 or above that now also support OPM patches in addition to OPN, so a new header field indicating the target chip/system was added with the two possible values 2 and 8 relevant for us. Before that, the system was always OPN.
I agree with the placement of the defines though, I moved them to the header now.

dmp_file.c Outdated
f.lfo = opn_voice_get_ams(voice);
f.lfo2 = opn_voice_get_pms(voice);
for(int i = 0; i < 4; i++) {
struct opn_voice_operator *op = &voice->operators[i];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this variable is used.

dmp_file.c Outdated
fop->sl = opn_voice_get_operator_sl(voice, i);
fop->rr = opn_voice_get_operator_rr(voice, i);
fop->ssg = opn_voice_get_operator_ssg_eg(voice, i);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No empty lines please

};

void dmp_file_init(struct dmp_file *f);
int dmp_file_load(struct dmp_file *f, uint8_t *data, size_t data_len, int system);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why you removed this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written above, the older versions of the DMP file format supported only YM2612 systems anyway, and for newer versions, the system information is part of the file itself, so it is not needed as a parameter.

op3_file.c Outdated
uint8_t buf[8192] = { 0 };
strcpy((char*)&buf[0], "Junglevision Patch File\x1A");
int bc = 32;
buf[bc++] = f->count_melodic & 0xff;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use incrementing pointer

tfi_file.c Outdated
*/

// get signed DT from unsigned DT
static int DT_u2s(int dt_unsigned) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use lowercase function names

@tobybear tobybear requested a review from vampirefrog February 12, 2025 07:50
sbi_file.c Outdated
int sbi_file_save(struct sbi_file *f, int (*write_fn)(void *, size_t, void *), void *data_ptr) {
uint8_t buf[52] = { 0 };
int bc = 0;
buf[bc++] = 'S';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u use pointer increment here too, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vampirefrog vampirefrog merged commit bd176e4 into vampirefrog:master Feb 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants