Re: [cc65] Scalable UI without float?

From: Kevin Schuetz <scrapdog1runbox.com>
Date: 2010-04-21 05:55:32
I would recommend using some sort of fixed-point arithmetic.

However, if you do want to continue defining positions in terms of 
percentages, the simplest answer to your problem would be to multiply 
first, then divide.

gotoxy(Item1X*screensize/100,0); cputs(Item1);
gotoxy(Item2X*screensize/100,0); cputs(Item2);
gotoxy(Item3X*screensize/100,0); cputs(Item3);
gotoxy(Item4X*screensize/100,0); cputs(Item4);
gotoxy(Item5X*screensize/100,0); cputs(Item5);





On 4/20/2010 10:37 PM, Payton Byrd wrote:
> Maybe I'm just tired, but I cannot come up with a good solution for this.
>
> What I'm trying to do is locate text on the screen using conio at 
> relative positions based on the screen width.  For example, I want to 
> define five positions for five menu items:
>
> Item 1: 0%
> Item 2: 20%
> Item 3: 40%
> Item 4: 60%
> Item 5: 80%
>
> I have placed these percentages in constants in a header file.  With 
> floats, this would be trivial at runtime:
>
> gotoxy(Item1X/100*screensize,0); cputs(Item1);
> gotoxy(Item2X/100*screensize,0); cputs(Item2);
> gotoxy(Item3X/100*screensize,0); cputs(Item3);
> gotoxy(Item4X/100*screensize,0); cputs(Item4);
> gotoxy(Item5X/100*screensize,0); cputs(Item5);
>
> Obviously, the math always results in a 0 so all the labels overwrite 
> each other.  What's the best way to tackle this problem without having 
> to hard-code locations?  I want to support both the 40 and 80 column 
> modes of the 128 with simply squishing everything into the first 40 
> columns.
>
> Thanks!
> Payton
> -- 
> Payton Byrd
> <http://www.paytonbyrd.com>
> <http://it.toolbox.com/blogs/paytonbyrd>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Apr 21 05:55:47 2010

This archive was generated by hypermail 2.1.8 : 2010-04-21 05:55:49 CEST