Jump to content


Photo

Rewriting my utility


  • Please log in to reply
2 replies to this topic

#1 crusaderdesignproject

crusaderdesignproject

    GMC Member

  • GMC Member
  • 249 posts
  • Version:GM8.1

Posted 02 May 2012 - 06:36 PM

Ok. I'm confused. I've already done this and got it working in my previous build, but I've since rewritten the program (due to issues with messy coding and FPS). Everything seems as it should be, but my code isn't working. Now, this code is meant to change one part of a 4 digit hex code, in the format of "0,,Blue, Green, Red". It then returns the full code and color to draw the palette box with.
Now, here is my code.
// edit_pal_red(+/-) - Edits the red value.
var i, t;
if blending=0 {t=pal[palx,paly]; i=string_char_at(pal[palx,paly],4);}
else {t=palab; i=string_char_at(palab,4);}
	// Convert the necessary hex digit to decimal.
	i=hex_to_dec(i);
	// Now, we need to modify it by adding/subtracting 2. A wrap is necessary for subtraction.
	if argument0=0  {i+=2;} if argument0=1  {if i>0 i-=2; else i=14;}
	// Now, convert it back to hex again, using the second hex character. Through this, 16 can be reset to 0 whilst adding.
	i   =   string_char_at(dec_to_hex(i),2);
// Return the modified hex value, set into the table.
if blending=0 {pal[palx,paly]="0"+string_char_at(t,2)+string_char_at(t,3)+i; pcol[palx,paly]=draw_hex_color(pal[palx,paly]);}
else      	{palab="0"+string_char_at(t,2)+string_char_at(t,3)+i; abcol=draw_hex_color(palab);}

The problem lies in the line "if argument0=0 {i+=2;} if argument0=1 {if i>0 i-=2; else i=14;}" It is supposed to add/subtract the aforementioned value to i. But it doesn't. I removed the add/subtract stuff to make it set i to either 2 or 14. That works no problem, and the color changes. But when I add the adding and subtracting back in, it fails.

Any insight as to why?
  • 0

#2 brac37

brac37

    GMC Member

  • GMC Member
  • 765 posts
  • Version:GM7

Posted 03 May 2012 - 10:22 PM

i becomes -1 when both i and argument0 are 1. Shouldn't i become 15 in that case?
  • 0

#3 crusaderdesignproject

crusaderdesignproject

    GMC Member

  • GMC Member
  • 249 posts
  • Version:GM8.1

Posted 04 May 2012 - 01:56 AM

I is your hex digit.
Argument0 determines whether you add or subtract, (based on which mouse button you use to click to color change button)
outside of this... Argument0 plays ZERO factor into what i is

i should NOT become 15, because 15 is an odd number. Working with Genesis VDP color palettes (which my utility is designed to edit) you can only use even hex numbers... (0,2,4,6,8,A,C,E)
So, when you are at 0, and subtract, it should loop to 14, not 15

EDIT: I solved the problem with a work-around. The variable refreshes itself in the End Step event and this works just fine... I'll stick with this, unless anyone has a better solution.

Edited by crusaderdesignproject, 04 May 2012 - 02:01 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users