[cc65] Scalable UI without float?

From: Payton Byrd <plbyrd1gmail.com>
Date: 2010-04-21 05:37:25
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:37:58 2010

This archive was generated by hypermail 2.1.8 : 2010-04-21 05:38:02 CEST