It is currently Thu Apr 02, 2020 12:52 pm

 All times are UTC

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Inverting hex values with range from 0x00-0x7FPosted: Thu Oct 16, 2014 8:04 pm

Joined: Wed Sep 24, 2014 10:37 pm
Posts: 3
Thank you Chuck for answering my last question. Progress on YMDj, the native Sega Genesis music tracker I'm working on is going really good! Check the project out if you have time. http://chipmusic.org/forums/topic/15355/ymdj-genesismd-tracker/

I ran into a bit of a mind bender though. Basically to control the volume of the YM2612 FM synthesizer, I have to send it data with a byte range of 0x00 to 0x7F to it's data port for Total Level. This is fine for the Synth Editor screen, but in the Note Entry screen where musicians will want to control the volume of their instruments as they're composing this is a problem, because this byte value actually controls attenuation of the instrument. In other words, the higher the byte, the quieter the sound. This is very non-intuitive for most people I think, who would expect that higher values would mean louder sound. So to avoid the problem I decided I want to invert this byte value. To convert 0x00, 0x01, 0x02... etc to 0x7F, 0x7E, 0x7D... etc. I want to know if there is an algorithm I can use that will do this, or if I'm going to have to resort to using a look up table.

Thanks again.

Top

 Post subject: Re: Inverting hex values with range from 0x00-0x7FPosted: Thu Oct 16, 2014 8:49 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
Just do

0x7F - n, where n is the user entered value 0,1,2, etc.

_________________
Prof. Kelly

Top

 Post subject: Re: Inverting hex values with range from 0x00-0x7FPosted: Fri Oct 17, 2014 1:11 am

Joined: Wed Sep 24, 2014 10:37 pm
Posts: 3
profkelly wrote:
Just do

0x7F - n, where n is the user entered value 0,1,2, etc.

I really think that I overthink on certain things. Sometimes the answer just stares us right in the face and we miss it. I'm really glad I asked though, because the solution I came up with was a bit more involved than that. n - 0x7F = R, then 0 - R = 0x7D or negating R. Valid, but not efficient. Thanks again for your help. I'll be sure your name goes into the "Special Thanks" section when this is all said and done. Do you prefer Chuck Kelly, or Professor Kelly?

Top

 Post subject: Re: Inverting hex values with range from 0x00-0x7FPosted: Sat Oct 18, 2014 12:57 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
CountSymphoniC wrote:
I'll be sure your name goes into the "Special Thanks" section when this is all said and done. Do you prefer Chuck Kelly, or Professor Kelly?
Either is fine.

_________________
Prof. Kelly

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 6 guests

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

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects